MagnaGuard
Active Member
- Reaction score
- 49
So came back after school problems and need someone to look over and tell me why the syntax thingy gave me so many errors
Spell is just a passive so if the hero is attacked, theres a chance for the attacker to get damaged.
JASS:
scope flame initializer Init
globals
private constant integer ID = 039;A000039; //spell rawcode
private constant string effect = "Abilities\\Spells\\Human\\MarkOfChaos\\MarkOfChaosTarget.mdl"
private constant string effect_place = "origin"
endglobals
private function damage takes integer a returns integer //Sets the damage the spell does
return a * 50
endfunction
private function level takes integer a returns integer //Gets the chance for the spell to work
return a * 2
endfunction
private function cond takes nothing returns boolean //Checking conditions and returns ture or false
return IsPlayerEnemy(GetOwningPlayer(GetAttacker()),GetOwningPlayer(GetTriggerUnit())) and GetRandomInt(0,100) <= level(GetUnitAbilityLevel(GetTriggerUnit(), ID))
endfunction
private function Actions takes nothing returns nothing
local unit t = GetTriggerUnit()
local unit a = GetAttacker()
local effect e = AddSpecialEffectTarget(effect, a, effect_place)
call DestroyEffect(e)
call UnitDamageTarget(t, a, damage(GetUnitAbilityLevel(t, ID)), true, true, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
set t=null
set a=null
set e=null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger( )
loop
exitwhen i>15
call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_UNIT_ATTACKED)
endloop
call TriggerAddAction( t, Actions )
call TriggerAddCondition(t, Filter(function cond))
call TriggerAddAction(t,function action)
endfunction
endscope
Spell is just a passive so if the hero is attacked, theres a chance for the attacker to get damaged.