Serf in area

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

Seiten: 1

SH
#1
16.09.2018 20:55
Beiträge: 62

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
Beiträge: 1367

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
Beiträge: 62

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
Beiträge: 1367

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
Beiträge: 62

I understand, it works. Thank you!

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

Seiten: 1

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

Impressum