After we get the Survivalism virtue in the Might tree, when we kill an alien, we see the research beaker icon pop up (scroll up) along with +n where n is science gained equal to a percentage of that killed alien's strength, on the tile that we killed the alien.
I have a similar script, but instead of science, I award culture for killing aliens. I'll show the code for this because I think you'll find it very useful:
function OnAlienKilled(playerId, killedPlayerId, unitTypeKey)
local player = Players[playerId]
if (player:IsEverAlive() and player:GetCivilizationType() == GameInfoTypes["CIVILIZATION_MY_SPONSOR"]) then
local unit = GameInfo["Units"][unitTypeKey]
if ((unit ~= nil) and unit.AlienLifeform) then
player:ChangeCulture((unit.Combat + unit.RangedCombat) * 0.5)
end
end
end
GameEvents.UnitKilledInCombat.Add(OnAlienKilled);
I assume that player:ChangeCulture(...) would automatically pop up the culture icon with the yield. The culture count does change as expected, which is great. But what, if it applies, script do I write to also get the on-tile "notification-animation" that, for example, I gained 56 culture (I don't remember the exact number) for killing a siege worm? I'm not talking about the notifications that show up on the lower-right hand side of the screen (like "city has grown" or "intruder alert").
Please feel free to use the above code in case you need to award yields based on the unit that you kill and/or the faction it belonged to, instead of a flat value (which is provided in modding a part of the XML).
I have a similar script, but instead of science, I award culture for killing aliens. I'll show the code for this because I think you'll find it very useful:
Spoiler :
function OnAlienKilled(playerId, killedPlayerId, unitTypeKey)
local player = Players[playerId]
if (player:IsEverAlive() and player:GetCivilizationType() == GameInfoTypes["CIVILIZATION_MY_SPONSOR"]) then
local unit = GameInfo["Units"][unitTypeKey]
if ((unit ~= nil) and unit.AlienLifeform) then
player:ChangeCulture((unit.Combat + unit.RangedCombat) * 0.5)
end
end
end
GameEvents.UnitKilledInCombat.Add(OnAlienKilled);
I assume that player:ChangeCulture(...) would automatically pop up the culture icon with the yield. The culture count does change as expected, which is great. But what, if it applies, script do I write to also get the on-tile "notification-animation" that, for example, I gained 56 culture (I don't remember the exact number) for killing a siege worm? I'm not talking about the notifications that show up on the lower-right hand side of the screen (like "city has grown" or "intruder alert").
Please feel free to use the above code in case you need to award yields based on the unit that you kill and/or the faction it belonged to, instead of a flat value (which is provided in modding a part of the XML).