RenaissanceFan
Warlord
- Joined
- Mar 15, 2011
- Messages
- 125
Hello again. I'm trying to write a script that does the following, line by line, assigned to the RunCombatSim event:
1) Checks if the attacking unit was a galleon;
2) Checks if the defending unit's domain was sea;
3) Checks if the damage was enough to destroy the unit;
4) Random 70% chance for getting 25
;
5) Awards the gold.
Could you take a look and see if it would work? Also, what to script so it prints "Your Galleon has earned 25 (gold icon) from the (enemy ship unit type).? The parts I need help are in italic.
Thanks in advance.
1) Checks if the attacking unit was a galleon;
2) Checks if the defending unit's domain was sea;
3) Checks if the damage was enough to destroy the unit;
4) Random 70% chance for getting 25

5) Awards the gold.
Could you take a look and see if it would work? Also, what to script so it prints "Your Galleon has earned 25 (gold icon) from the (enemy ship unit type).? The parts I need help are in italic.
Code:
function GalleonAwardGold(iAttackingPlayer, iAttackingUnit, iAttackingUnitDamage, iAttackingUnitFinalDamage, iAttackingUnitMaxHitPoints, iDefendingPlayer, iDefendingUnit, iDefendingUnitDamage, iDefendingUnitFinalDamage, iDefendingUnitMaxHitPoints, bContinuation)
if (iAttackingUnit:GetUnitType() == GameInfoTypes["UNIT_GALLEON"]) then
if (iDefendingUnit:GetDomainType() == GameInfoTypes["DOMAIN_SEA"]) then
if (iDefendingUnitFinalDamage >= iDefendingUnitMaxHitPoints) then
if (Game.Rand(100, "Galleon Award Chance") < 70) then
local iGold = Game.Rand(25, "Galleon Award Value")
iAttackingPlayer.ChangeGold(iGold)
end
end
end
end
end
Events.RunCombatSim.Add( GalleonAwardGold );
Thanks in advance.