- Joined
- Dec 31, 2005
- Messages
- 712
I am just starting - this is my first code after reading Daelin's perfect tutorial. This trigger is supposed to cause a certain damage to the attacked unit, when a unit of type H000 attacks and the target takes the damage. Unfortunately the game is closed right after being attacked.
The spell name is Mana Leak. It's based on Defend, so I can activate and deactivate it. There's a trigger that changes AE_ManaLeakActive (I'm sure that the problem is not with that one). Hope I'm not wasting your time, maybe it's an idiot spelling mistake...
Already THANKS
Hossomi
[edit: Jass codes in this site looks beautiful ]
JASS:
function ManaLeakCond1 takes nothing returns boolean
return GetUnitTypeId(GetAttacker()) == 'H000'
endfunction
function ManaLeakCond2 takes nothing returns boolean
return udg_AE_ManaLeakActive
endfunction
function ManaLeakAndCond takes nothing returns boolean
return GetBooleanAnd(ManaLeakCond1(), ManaLeakCond2())
endfunction
function ManaLeakDamage takes nothing returns nothing
local integer Level
local integer Int
set udg_AE_ManaLeakDamage = 1.00
set Int = 0
set Level = GetUnitAbilityLevelSwapped('A003', udg_AECaster)
loop
exitwhen Int >= Level
set udg_AE_ManaLeakDamage = udg_AE_ManaLeakDamage * 2
set Int = Int + 1
endloop
call UnitDamageTargetBJ( udg_AECaster, udg_AE_ManaLeakTarget, udg_AE_ManaLeakDamage, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
call SetUnitManaBJ (udg_AE_ManaLeakTarget, GetUnitStateSwap( UNIT_STATE_MANA, udg_AE_ManaLeakTarget) - udg_AE_ManaLeakDamage )
call SetUnitManaBJ (udg_AECaster, GetUnitStateSwap( UNIT_STATE_MANA, udg_AECaster) - 1 )
call DestroyTrigger(udg_AE_ManaLeakTrigger)
set udg_AE_ManaLeakTrigger = null
set udg_AE_ManaLeakTarget = null
set udg_AECaster = null
endfunction
function ManaLeakAct takes nothing returns nothing
set udg_AE_ManaLeakTarget = GetAttackedUnitBJ()
set udg_AECaster = GetAttacker()
set udg_AE_ManaLeakTrigger = CreateTrigger()
call TriggerRegisterUnitEvent (udg_AE_ManaLeakTrigger, udg_AE_ManaLeakTarget, EVENT_UNIT_DAMAGED)
call TriggerAddAction (udg_AE_ManaLeakTrigger, function ManaLeakDamage )
endfunction
//===========================================================================
function InitTrig_AE_Mana_Leak takes nothing returns nothing
set gg_trg_AE_Mana_Leak = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_AE_Mana_Leak, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition (gg_trg_AE_Mana_Leak, Condition(function ManaLeakAndCond))
call TriggerAddAction( gg_trg_AE_Mana_Leak, function ManaLeakAct )
endfunction
The spell name is Mana Leak. It's based on Defend, so I can activate and deactivate it. There's a trigger that changes AE_ManaLeakActive (I'm sure that the problem is not with that one). Hope I'm not wasting your time, maybe it's an idiot spelling mistake...
Already THANKS
Hossomi
[edit: Jass codes in this site looks beautiful ]