So, I decided to start getting myself into JASS coding, after reading the guide (And understanding 25% of it), I decided to try a couple of triggers for simple spells, but they seem not to be working correctly
Here's the first and simplest one, it's for a 'phased movement' spell. It is basically a spell based off Haste Potion that makes the target ethereal for its duration and gives it a slowing aura
The problem with this one is in the 'loop' part. I tried to make it so the trigger would remove the 'Ethereal' and 'Slow Aura' spells off the unit once it checked it didn't have the 'Phased movement' debuff anymore, but for some reason it didn't work, so I was forced to use 'TriggerSleepAction(8)' function to solve it (8 seconds being the duration of the spell). It works this way, but it seems far from optimal, and besides I'd like to know what I'm doing wrong with the loop.
The second one is a bit more complicated (At least for my capabilities in jass), it's a simple spell based off Berserk. What I intended to do is that, when a unit with the spell buff receives damage, the damage source receives the same amount of damage it dealt (I could've used Thorns Aura, but it wouldn't reflect ranged attacks nor spell damage)
I tried to make it work, but I get an 'expected a name' error and I don't clearly know how to fix it, also I'm unsure as to whether the spell would work even if I fixed that part
I'm just started into this whole JASS thing, so I admit it may look dreadful, but in any case, any sort of guidance concerning these 2 triggers is appreciated
Here's the first and simplest one, it's for a 'phased movement' spell. It is basically a spell based off Haste Potion that makes the target ethereal for its duration and gives it a slowing aura
JASS:
function PMovement_Condition takes nothing returns boolean
return GetSpellAbilityId()=='A00C' //ID FOR PHASED MOVEMENT SPELL
endfunction
function PMovement_Action takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local integer PMLevel = GetUnitAbilityLevel(caster,'B00C')
call UnitAddAbilityBJ('Aetl',caster)//ETHEREAL ABILITY
call UnitAddAbilityBJ('A01T',caster)//SLOW AURA ABILITY BASED OFF TORNADO AURA
call SetUnitPathing(caster,false)
call TriggerSleepAction(8)
loop
exitwhen(PMLevel==0)//PHASED MOVEMENT BUFF
endloop
call UnitRemoveAbilityBJ('Aetl',caster)
call UnitRemoveAbilityBJ('A01T',caster)
call SetUnitPathing(caster,true)
set caster = null
endfunction
function InitTrig_PMovement takes nothing returns nothing
local trigger PMovement = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(PMovement,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(PMovement,Condition(function PMovement_Condition))
call TriggerAddAction(PMovement,function PMovement_Action)
endfunction
The problem with this one is in the 'loop' part. I tried to make it so the trigger would remove the 'Ethereal' and 'Slow Aura' spells off the unit once it checked it didn't have the 'Phased movement' debuff anymore, but for some reason it didn't work, so I was forced to use 'TriggerSleepAction(8)' function to solve it (8 seconds being the duration of the spell). It works this way, but it seems far from optimal, and besides I'd like to know what I'm doing wrong with the loop.
The second one is a bit more complicated (At least for my capabilities in jass), it's a simple spell based off Berserk. What I intended to do is that, when a unit with the spell buff receives damage, the damage source receives the same amount of damage it dealt (I could've used Thorns Aura, but it wouldn't reflect ranged attacks nor spell damage)
I tried to make it work, but I get an 'expected a name' error and I don't clearly know how to fix it, also I'm unsure as to whether the spell would work even if I fixed that part
JASS:
function PBalance_Condition takes nothing returns boolean
if(not(UnitHasBuffBJ(GetTriggerUnit(),'B00B')==true)) then//CONTRARY TO WHAT YOU MAY THINK, 'B00B' IS THE ID FOR THE SPELL BUFF
return false
endif
return true
endfunction
function PBalance_Action takes nothing returns nothing
local unit caster = GetTriggerUnit()
local unit PMDamageSource = GetEventDamageSource()
local real PMDamage = GetEventDamage()
call UnitDamageTargetBJ(caster,PMDamageSource,PMDamage,ATTACK_TYPE_CHAOS,DAMAGE_TYPE_UNKNOWN)
endfunction
function InitTrig_PBalance takes nothing returns nothing
local trigger PBalance = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(PBalance,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerRegisterUnitEvent(PBalance,caster,EVENT_UNIT_DAMAGED )//THIS IS WHERE I GET AN 'EXPECTED A NAME' ERROR
call TriggerAddCondition(PBalance,Condition(function PBalance_Condition))
call TriggerAddAction(PBalance,function PBalance_Action)
endfunction
I'm just started into this whole JASS thing, so I admit it may look dreadful, but in any case, any sort of guidance concerning these 2 triggers is appreciated