Hello again everyone. I'm almost done with another mod, but I'm running into one snag that I really hope you all can help me solve.
The problem is thus: I've made a promotion that I want to grant the unit a combat bonus for their next combat, and then heal them after that combat. To do this, I'm trying to use Lua to remove the promotion after combat (the promotion grants +25% combat bonus correctly and everything):
Now, the code works.... but not when Quick Combat is on. The event I'm using seems to only fire after combat animations, so unless the player watches every combat animation, the promotion will never heal the unit and get removed. Please, for the love of Firaxis, tell me there's another event I can hook my function into to have the same effect, or some non-dll way to implement this. This is pretty much the last thing I have to do for this mod to be completely done!
The problem is thus: I've made a promotion that I want to grant the unit a combat bonus for their next combat, and then heal them after that combat. To do this, I'm trying to use Lua to remove the promotion after combat (the promotion grants +25% combat bonus correctly and everything):
Code:
function DEPHeal(attackingPlayer, attackingUnit, attackingUnitDamage, attackingUnitFinalDamage, attackingUnitMaxHitPoints, defendingPlayer, defendingUnit, defendingUnitDamage, defendingUnitFinalDamage, defendingUnitMaxHitPoints)
local pPlayer = Players[attackingPlayer];
local pUnit = pPlayer:GetUnitByID(attackingUnit);
if pUnit then
if pUnit:IsHasPromotion(iDEPPromotionBonus) then
pUnit:ChangeDamage(-25);
pUnit:SetHasPromotion(iDEPPromotionBonus, false);
end
end
pPlayer = Players[defendingPlayer];
pUnit = pPlayer:GetUnitByID(defendingUnit);
if pUnit then
if pUnit:IsHasPromotion(iDEPPromotionBonus) then
pUnit:ChangeDamage(-25);
pUnit:SetHasPromotion(iDEPPromotionBonus, false);
end
end
end
Events.EndCombatSim.Add(DEPHeal)
Now, the code works.... but not when Quick Combat is on. The event I'm using seems to only fire after combat animations, so unless the player watches every combat animation, the promotion will never heal the unit and get removed. Please, for the love of Firaxis, tell me there's another event I can hook my function into to have the same effect, or some non-dll way to implement this. This is pretty much the last thing I have to do for this mod to be completely done!