forked from CivLeague/BBG
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitPanel_CondemnCommand.lua
More file actions
50 lines (40 loc) · 1.27 KB
/
UnitPanel_CondemnCommand.lua
File metadata and controls
50 lines (40 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
function ModifiedCommand_Condemn(eOwner : number, iUnitID : number)
local pPlayer = Players[eOwner];
if (pPlayer == nil) then
return;
end
local pUnit = pPlayer:GetUnits():FindID(iUnitID);
if (pUnit == nil) then
return;
end
local unitsInPlot = Units.GetUnitsInPlotLayerID(pUnit:GetX(), pUnit:GetY(), 3); --religiousLayerID = 3
if unitsInPlot ~= nil then
for _,targetUnit in ipairs(unitsInPlot) do
local religiousStrength = targetUnit:GetReligion():GetReligiousStrength();
if religiousStrength > 0 then
--VERSION REDUCE HEALTH:
local maxDamage = targetUnit:GetMaxDamage();
local currentDamage = targetUnit:GetDamage();
if maxDamage - currentDamage > 50 then
targetUnit:ChangeDamage(50);
else
UnitManager.Kill(targetUnit);
end
--VERSION REMOVE CHARGE:
--local chargesRemaining = targetUnit:GetReligion():GetSpreadCharges();
--if chargesRemaining > 1 then
--targetUnit:GetReligion():ChangeSpreadCharges(-1);
--else
--UnitManager.Kill(targetUnit);
--end
end
end
end
UnitManager.ReportActivation(pUnit, "CONDEMN_MOD");
UnitManager.FinishMoves(pUnit);
end
function Initialize()
GameEvents.ModifiedCommand_Condemn.Add(ModifiedCommand_Condemn);
print ("Initialized!");
end
Initialize();