Spell doesn't work, maybe bad base-skill?

Lehona

New Member
Reaction score
12
I got this two triggers in my (test-)map, but the spell, which should save the target untouched and transfer all damage to the caster, doesn't work.
JASS:
scope HGB4 initializer HGBe4

globals
private constant integer ID = 'HoGu'
public real HP = 0.0
endglobals

private function Cons takes nothing returns boolean
return (GetSpellAbilityId() == ID)
endfunction

private function HoGuBe4 takes nothing returns nothing HolyGuardBe4
    local unit u
    loop
        exitwhen UnitHasBuffBJ(u, MyScope_BC)
        set u = GroupPickRandomUnit (GetUnitsInRectAll(GetPlayableMapRect()))
    endloop
    set HP = GetUnitState (u, UNIT_STATE_LIFE)
endfunction
        
private function HGBe4 takes nothing returns nothing
local trigger t = CreateTrigger()
local unit u
loop
exitwhen GetUnitAbilityLevel(u, ID) > 0
set u = GroupPickRandomUnit(GetUnitsInRectAll(GetPlayableMapRect()))
if GetUnitAbilityLevel(u, ID) > 0 then 
call TriggerRegisterUnitEvent (t, u, EVENT_UNIT_SPELL_CAST)
endif
endloop
call TriggerAddAction (t, function HoGuBe4)
call TriggerAddCondition (t, Filter(function Cons))
endfunction

endscope


scope MyScope initializer HG
globals
public constant integer BC = 'X001'
endglobals

private function Cons takes nothing returns boolean
    return (UnitHasBuffBJ(GetTriggerUnit(), BC))
endfunction

private function HolyGuard takes nothing returns nothing
    local unit u
    local real r = GetUnitState(u, UNIT_STATE_LIFE)
    local real r2 = GetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE)
    local real HPT = HGB4_HP
    loop
        exitwhen GetUnitAbilityLevel(u, 'HoGu') > 0
        set u = GroupPickRandomUnit (GetUnitsInRectAll(GetPlayableMapRect()))
    endloop
    
    set r2 = HGB4_HP - r2
    set r = r - r2
    call SetUnitState (u, UNIT_STATE_LIFE, r)    
    call SetUnitState (GetTriggerUnit(), UNIT_STATE_LIFE, HGB4_HP)
endfunction

private function HG takes nothing returns nothing
    local trigger t = CreateTrigger()
    local unit u
    loop                                         
    exitwhen  UnitHasBuffBJ(u, BC)
    set u = GroupPickRandomUnit(GetUnitsInRectAll(GetPlayableMapRect()))
    if UnitHasBuffBJ(u, BC) then 
    call TriggerRegisterUnitEvent (t,u, EVENT_UNIT_DAMAGED)
    endif
    endloop
    call TriggerAddAction (t, function HolyGuard)
    call TriggerAddCondition(t, Filter(function Cons))
endfunction
endscope


JASS:
scope MyScope initializer HG
globals
public constant integer BC = 'X001'
endglobals

private function Cons takes nothing returns boolean
    return (UnitHasBuffBJ(GetTriggerUnit(), BC))
endfunction

private function HolyGuard takes nothing returns nothing
    local unit u
    local real r = GetUnitState(u, UNIT_STATE_LIFE)
    local real r2 = GetUnitState(GetTriggerUnit(), UNIT_STATE_LIFE)
    local real HPT = HGB4_HP
    loop
        exitwhen GetUnitAbilityLevel(u, 'HoGu') > 0
        set u = GroupPickRandomUnit (GetUnitsInRectAll(GetPlayableMapRect()))
    endloop
    
    set r2 = HGB4_HP - r2
    set r = r - r2
    call SetUnitState (u, UNIT_STATE_LIFE, r)    
    call SetUnitState (GetTriggerUnit(), UNIT_STATE_LIFE, HGB4_HP)
endfunction

private function HG takes nothing returns nothing
    local trigger t = CreateTrigger()
    local unit u
    loop                                         
    exitwhen  UnitHasBuffBJ(u, BC)
    set u = GroupPickRandomUnit(GetUnitsInRectAll(GetPlayableMapRect()))
    if UnitHasBuffBJ(u, BC) then 
    call TriggerRegisterUnitEvent (t,u, EVENT_UNIT_DAMAGED)
    endif
    endloop
    call TriggerAddAction (t, function HolyGuard)
    call TriggerAddCondition(t, Filter(function Cons))
endfunction
endscope


The spell is actually based on Holy Light (I didn't found any good baseskill, because I play just DotA, not any melee maps) and gives the target a buff, which is based on anti-magicshield (magic immun!).
 

BlackDeath09

New Member
Reaction score
9
I would love to help but you posted this in the wrong section here you will receive help for most but not all things, there is a specific forum for JASS Help so if you are new please read the rules first before posting im getting really sick of seeing JASS HELP in this forum
 

Lehona

New Member
Reaction score
12
Okay, thaugt that here I can also get help for questions about base skills.
Can maybe a moderator fix my bad?^^
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top