Is there a lua event for when a unit kills another unit

Ambug666

Chieftain
Joined
Jun 23, 2009
Messages
92
I know there is a lua event for when a unit dies, and that gives the player of the unit and the unit type. What I want to trigger on is when a specific civ's unit has killed another unit. Is there a way to do this?

On that note, is there a way to add to a civ's current research (not research the civ generates, but the amount it has researched toward the current tech) using lua?
 
For the research part of your question you can probably use one of these:

http://modiki.civfanatics.com/index.php/TeamTechs_(Civ5_Type)

I don't know about the kill event, but if you're just looking to add raw research to the current tech after combat victory, the unit tag to give a yield after a kill (like the celts with faith, aztec with culture) might work; just set the yield to science. I don't know where specifically the yield goes, but I assume your current tech.
 
I haven't tried any of these but they look like they should do what you want.

For checking if a unit is killed:
http://modiki.civfanatics.com/index.php/Events.EndCombatSim_(Civ5_API)


For updating a player's current research:
http://modiki.civfanatics.com/index.php/Player.GetResearchProgress_(Civ5_API)

and

http://modiki.civfanatics.com/index.php/Player.SetResearchingTech_(Civ5_API)


A very good site for obtaining information is:
http://modiki.civfanatics.com/index.php/Lua_and_UI_Reference


All of my links (and turingmachine's link) came from this site.
 
EndCombat doesn't execute under some conditions when units die (Firaxis broke RunCombat/EndCombat in build 674) I can't remember the exact set of circumstances but if you seach for any of Spatz's posts about it he fully explained all the problems that broke his mods
 
When considering something similar, the workaround I came up with was to use Events.SerialEventUnitDestroyed and then use something else to determine whose turn it is. There may be the odd exception (suicide attack and citadel off the top of my head), but it is exceedingly likely that the player whose turn it is is the one who killed the unit.
 
Back
Top Bottom