• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

[LUA QUESTION] Methods of getting unit id?

Tryhard Trevor

Chieftain
Joined
Feb 29, 2016
Messages
22
Working on some lua for a custom UA for my custom Civ. My idea for the unique ability is that the Civ would receive some sort of bonus for killing enemy units while playing defensively, or at some kind of disadvantage. One idea I had was: Enemy units killed inside your territory provide bonus gold and production. To do this, I've been using the GameEvents.UnitKilledInCombat.Add(Main) hook. Now this hook returns the killer's ID, the victim's ID, and the unitTypeId. In order to check where the unit that got killed was standing, or really anything about the unit, I need its unitID, not the unitTypeId. Anybody know of a method that I can use to access the unitID of the unit being killed?
 
I don't think there's any way to get the UnitID from GameEvents.UnitKilledInCombat (as the unit doesn't even exist by the time it's run), but you could use GameEvents.UnitPrekill, which does return a UnitID, and for that matter gives the X and Y directly. It returns for all removals of a unit from the game, not just deaths in combat, but it has an "eKillingPlayer" perameter which is -1 if it's not combat, so you can easily just check that.
 
Wow, thanks for the quick response. I'm going to try this out. Once again, thanks for the help, I really appreciate it.
 
So I got the hook to work in my lua, however, I still can't find it on the spreadsheet. What exact parameters does it return?
 
Back
Top Bottom