GreatBayethe
Chieftain
- Joined
- Jul 12, 2017
- Messages
- 24
I made a code, and it seemed to work well. But, after my units that has the promotion kill enemies and get science, when my units that don't have the promotion kill enemies, I get science. What is the problem? Please help me.
Code:
function GuardogScienceBoostUnit(iKiller, iKilled, unitType)
local pPlayer = Players[iKiller]
if pPlayer:IsAlive() and pPlayer:GetCivilizationType() == pJimmyNeutron then
for pMyUnit in pPlayer:Units() do
if pMyUnit:IsHasPromotion(pGuardogPromotion) then
local iScienceboost = math.max(GameInfo.Units[unitType].Combat, GameInfo.Units[unitType].RangedCombat)
local pTeamTechs = Teams[pPlayer:GetTeam()]:GetTeamTechs()
pTeamTechs:ChangeResearchProgress(pPlayer:GetCurrentResearch(), iScienceboost, pPlayer)
end
end
end
end
GameEvents.UnitKilledInCombat.Add(GuardogScienceBoostUnit)