Serf in area

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

Pages: 1

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

Serf in area

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

____________________
Sorry for my German

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

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: 127

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.

____________________
Sorry for my German

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

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: 127

I understand, it works. Thank you!

____________________
Sorry for my German

Pages: 1

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

Impressum