SerialEventUnitCreated: Triggers on Embark?

FramedArchitect

Reluctant Modder
Joined
Mar 25, 2012
Messages
802
Location
Missouri
I found that the SerialEventUnitCreated/Destroyed hooks trigger every time a unit embarks/disembarks. I would like to disable those hooks in the event that a unit is embarking or disembarking.

While you can detect a unit's current activitytype, none of the instance methods seem to detect a unit's current missiontype. I thought unit:LastMissionPlot might be useful but it always produces runtime error for me.

Is there an efficient way to detect if a unit has just embarked/disembarked?
 
see some answers in the thread here: http://forums.civfanatics.com/showthread.php?t=434826

there is no direct method AFAIK, how do you want to use it exactly ?

Thanks for the direction. I'm using certain units to grant civilizational benefits while they are alive, so I need consistent method to track birth/death. I always hated embark, now that I know it triggers unit birth/death I hate it more.
 
I meant to update this thread a while back when I discovered this method that is simple and disables firing on unit embark:

Code:
function OnUnitDestroyed(iPlayer, iUnit)
	local unit = Players[iPlayer]:GetUnitByID(iUnit);
	if unit and not unit:IsDead() then return end
end
Events.SerialEventUnitDestroyed.Add( OnUnitDestroyed )
 
Back
Top Bottom