JassCraft says the syntax is fine but when trying to enable it in WE Trigger file i made called main it gives me expected errors up and down.
Code:
globals
unit udg_Kisame=null
location udg_point=null
group udg_group=null
effect udg_Effect=null
soundtype udg_Effect2=null
unit udg_Target=null
unit udg_Kakashi=null
trigger gg_trg_Main=null
trigger gg_trg_Untitled_Trigger_001 = null
location tp1=null
location tp2=null
location tp3=null
trigger udg_trigger_raikiri=null
unit udg_unit01=null
group tg=null
real dx=0
endglobals
function InitGlobals takes nothing returns nothing
local integer i = 0
set udg_group = CreateGroup()
endfunction
function Trig_Main_Actions takes nothing returns nothing
call DisplayTextToForce( GetPlayersAll(), "NAruto Test Map" )
endfunction
function Trig_raikiri_Conditions takes nothing returns boolean // the condition, that spell cast=raikiri
return (GetSpellAbilityId()=='A001')
endfunction
function trigenemy takes nothing returns boolean //a condition to determine which types of units are targeted, invoked later in trigger
return IsUnitAliveBJ(GetFilterUnit()) and IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit())) //chooses only living enemies as targets, can be expanded to disallow buildings or heroes, etc.
endfunction
function raikiri_dam takes nothing returns nothing // damage section of spell
call UnitDamageTargetBJ(GetTriggerUnit(),GetEnumUnit(),dx,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_MAGIC) // target damage use triggerunit to do damage, the chaos type tends to make it "pure" aka not affected by armor type
set tp2=GetUnitLoc(GetEnumUnit()) //get location of unit, has to be defined beforehand to avoid causing leaks
call AddSpecialEffectLocBJ(tp2,"Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl") //makes the effect at location of unit
call DestroyEffect(GetLastCreatedEffectBJ()) //stop effect
call RemoveLocation (tp2) //cleans up the location once not needed anymore
endfunction
function Trig_raikiri_Actions takes nothing returns nothing
local unit u=GetTriggerUnit() //trigger unit, because "u" is easier to type later on then "GetTriggerUnit()"
set udg_unit01=GetSpellTargetUnit() // unit that is targeted by spell
set tp1=GetUnitLoc(udg_unit01) //get location
set tp3=PolarProjectionBJ(tp1,80.00,GetUnitFacing(u)) //actually this defines the spot to which the unit will be moved, to be about arm's length from enemy
call SetUnitPositionLocFacingLocBJ(GetTriggerUnit(),tp3,tp1) // move to tp3, a spot next to enemy and face tp1 - the spot enemy is standing
call RemoveLocation (tp3) //remove location since not needed anymore
set dx=I2R((GetHeroStatBJ(bj_HEROSTAT_AGI,u,true)+50)*(GetUnitAbilityLevel(u,'A001'))) // formula for dmg, I define it here to avoid having to calculate when damaging every enemy in range
set tg=GetUnitsInRangeOfLocMatching(300,tp1,Condition(function trigenemy)) //creates unit group to be his, based on range 300 from spot cast (tp1) and matching the condition trigenemy (written higher up in trigger)
call ForGroupBJ(tg,function raikiri_dam) // execute dmg
call DestroyGroup (tg) //gets rid of the group once not needed, trigger would function even without this line but as the leak builds up it would eventually contribute to lag
call RemoveLocation (tp1) // location not needed anymore
endfunction
//===========================================================================
function InitTrig_Main takes nothing returns nothing
set gg_trg_Main = CreateTrigger( )
call TriggerAddAction( gg_trg_Main, function Trig_Main_Actions )
endfunction