Serf in area

» Settlers Map Source Forums » Siedler DEdK Script Forum » Serf in area

Pages: 1

SH
#1
16-09-2018 20:55
Posts: 46

Serf in area

Hi!
How to do that one of the serfs in the area change a player (or do something other)?

____________________
It's important to understand the scripts you use.

mcb
#2
16-09-2018 21:40
Posts: 1331

Something like this:

function changeSerfInArea(pl, pos, rang, newpl)
	local _, id = Logic.GetPlayerEntitiesInArea(pl, Entities.PU_Serf, pos.X, pos.Y, rang, 1)
	if IsAlive(id) then
		ChangePlayer(id, newpl)
	end
end

SH
#3
17-09-2018 16:47
Posts: 46

OK, but when I attached the function Logic.SetTaskList

function changeSerfInArea(pl, pos, rang, newpl)
	local _, id = Logic.GetPlayerEntitiesInArea(pl, Entities.PU_Serf, pos.X, pos.Y, rang, 1)
	if IsAlive(id) then
		ChangePlayer(id, newpl)
     Logic.SetTaskList(id,TaskLists.TL_SERF_BUILD)
	end
end

the TaskList no works.

____________________
It's important to understand the scripts you use.

mcb
#4
17-09-2018 16:58
Posts: 1331

This is expected, because ChangePlayer destroys the entity and creates a new one, with new id. But ChangePlayer should return the new id, so

function changeSerfInArea(pl, pos, rang, newpl)
	local _, id = Logic.GetPlayerEntitiesInArea(pl, Entities.PU_Serf, pos.X, pos.Y, rang, 1)
	if IsAlive(id) then
		id = ChangePlayer(id, newpl)
		Logic.SetTaskList(id, TaskLists.TL_SERF_BUILD)
	end
end

sould work (but i never tested this).

SH
#5
17-09-2018 17:35
Posts: 46

I understand, it works. Thank you!

____________________
It's important to understand the scripts you use.

Pages: 1

SiteEngine v1.5.0 by nevermind, ©2005-2007
Design by SpiderFive (www.siedler-games.de) - English translation by juja

Impressum