Lua code for a certain promotion

JohnTheBaba

Chieftain
Joined
Mar 20, 2019
Messages
10
In the Superpowers modpack; Clash of Civilizations there is a certain attack effect, written with lua code. The proton collider vessel (unique unit of the late game) with the ChainReactionID promotion that gives the unique ability after a range attack, to inflict damage to all enemy units in the visible plot tiles equal to 33% of damage dealt in the target unit.

But this effect doesn't seem to work or take effect in the game. I am posting the code here for revision to see if it's broken or incomplete.

local ChainReactionID = GameInfo.UnitPromotions["PROMOTION_CHAIN_REACTION"].ID

-------------------------Chain Reaction
if pAttackingUnit:IsHasPromotion(ChainReactionID) then

for unit in pDefendingPlayer:Units() do
if unit ~= nil then
local plot = unit:GetPlot()
if unit:IsCombatUnit() and unit:GetID()~= pDefendingUnit:GetID() and PlotIsVisibleToHuman(plot) then
local DamageOri = pAttackingUnit:GetRangeCombatDamage(unit,nil,false)
local ChainDamage = 0.33 * DamageOri
unit:ChangeDamage(ChainDamage,pAttackingPlayer)
print ("Chain Reaction!")
end
end
end
end
 
Last edited:
Back
Top Bottom