Ability Help

TheCrystal

New Member
Reaction score
36
I begun making an ability a few days ago, had some trouble figuring out events (thanks to this site) and now I'm not sure what's wrong.

The objective of the ability is to create a skull that attacks a unit, which gives it a temporary buff, then it creates another skull that moves to a different target and does the same action. Its damage is done off of a previous data, added to a variable, which is later used to increase the mana of the caster. I'll add comments since the ability seems a little confusing.
The effect is also never created.



JASS:
function NMCC takes nothing returns boolean
if (IsUnitEnemy(GetFilterUnit(), Player(udg_TempInteger)) == true) then
return true
else 
return false
endif
endfunction





function ManaCoil takes nothing returns nothing
local group g = CreateGroup()
local unit c = GetTriggerUnit()
local unit u = null //Skull unit
local unit w = GetSpellTargetUnit()
local real r = 0
local integer i = 1
local location l = GetUnitLoc(c)
local location q = null
local effect e = null
local real px = 0
local real py = 0
local boolean b = false //No targets boolean
local integer twowait = 2  //Two second wait time.
local real DamageDone = 0
local integer TooLong = 0
if 'A00D' == GetSpellAbilityId() then //Condition
call DisplayTextToPlayer(Player(0),0,0,"A00D") //Debug
set u = CreateUnitAtLoc(Player(13),'h001',l,0)
call IssueTargetOrder(u,"attack",w)
loop //Wait till target has buff
    exitwhen UnitHasBuffBJ(w, 'B006') == true
    call IssueTargetOrder(u,"attack",w)
    call Wait(.1)
endloop
call RemoveUnit(u)
set e = AddSpecialEffectTarget("Abilities/Spells/Undead/DeathCoil/DeathCoilMissile.mdl",w,"overhead")
call Wait(2)
call UnitRemoveBuffBJ( 'B006', w )
call DestroyEffect(e)
call DamageUnit(udg_ZZZWisdom[GetPlayerId(GetOwningPlayer(c))+1],w,c,0)
set DamageDone = udg_ZZZWisdom[GetPlayerId(GetOwningPlayer(c))+1] //To add to caster mana


loop
    call DisplayTextToPlayer(Player(0),0,0,"BigLoop") //debug
    exitwhen GetUnitAbilityLevel(c,'A00D') == i or b == true
    set i = i+1
    call RemoveLocation(l)
    set l = GetUnitLoc(w)
    set u = CreateUnitAtLoc(Player(13),'h001',l,0)
    set udg_TempInteger = GetPlayerId(GetOwningPlayer(c))
    call GroupEnumUnitsInRange(g,GetLocationX(l),GetLocationY(l),350,Condition(function NMCC)) //All nearby enemy units who are enemy of caster
    set w = null
    set w = FirstOfGroup(g)
    if w == null then //No targets
        set b = true
        call RemoveUnit(u)
        call RemoveLocation(l)
        set twowait = 0
    endif
    
    
    call IssueTargetOrder(u,"attack",w)
    loop
        exitwhen UnitHasBuffBJ(w, 'B006') == true or b == true
        call IssueTargetOrder(u,"attack",w)
        call Wait(.1)
        set TooLong = TooLong+1
        if TooLong == 500 then
            set b = true
        endif
    endloop
    call RemoveUnit(u)
    set e = AddSpecialEffectTarget("Abilities/Spells/Undead/DeathCoil/DeathCoilMissile.mdl",GetSpellTargetUnit(),"head")
    call Wait(twowait)
    call DestroyEffect(e)
    if b == false then
        call DamageUnit(udg_ZZZWisdom[GetPlayerId(GetOwningPlayer(c))+1],GetSpellTargetUnit(),c,0)
        set DamageDone=DamageDone+udg_ZZZWisdom[GetPlayerId(GetOwningPlayer(c))+1]
    endif
    
    call GroupClear(g)    
endloop
call SetUnitManaBJ(c, (GetUnitStateSwap(UNIT_STATE_MANA, GetTriggerUnit()) + DamageDone) ) //Addmana
endif
call RemoveLocation(l)
call RemoveLocation(q)
set g = null
set u = null
set c = null
endfunction





The first part of the ability works till it comes to the big loop, where it doesn't create the unit.
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56

TheCrystal

New Member
Reaction score
36
It is a function my friend created which is a little bit more accurate then the normal TriggerSleepAction and such.
 

TheCrystal

New Member
Reaction score
36
I see, so that's part of the problem. I was testing it incorrectly. Well, it loops, but it still works odd. The effect is never created, and the first skull hits, does its work, the first bigloop works, does its work, the second big loop doesn't, or the third, then the fourth it creates a skull and it just sits there doing nothing.
(Leveling it up to 3)

Here's an update of the trig, btw.


JASS:
function NMCC takes nothing returns boolean
     return IsUnitEnemy(GetFilterUnit(), Player(udg_TempInteger)) == true
endfunction







function ManaCoil takes nothing returns nothing
local group g = CreateGroup()
local unit c = GetTriggerUnit()
local unit u = null //Skull unit
local unit w = GetSpellTargetUnit()
local real r = 0
local integer i = 1
local location l = GetUnitLoc(c)
local location q = null
local effect e = null
local real px = 0
local real py = 0
local boolean b = false //No targets boolean
local integer twowait = 2  //Two second wait time.
local real DamageDone = 0
local integer TooLong = 0
if 'A00D' == GetSpellAbilityId() then //Condition
call DisplayTextToPlayer(Player(0),0,0,"A00D") //Debug
set u = CreateUnitAtLoc(Player(13),'h001',l,0)
call IssueTargetOrder(u,"attack",w)
loop //Wait till target has buff
    exitwhen UnitHasBuffBJ(w, 'B006') == true
    call IssueTargetOrder(u,"attack",w)
    call Wait(.1)
endloop
call RemoveUnit(u)
set e = AddSpecialEffectTarget("Abilities/Spells/Undead/DeathCoil/DeathCoilMissile.mdl",w,"head")
call Wait(2)
call UnitRemoveBuffBJ( 'B006', w )
call DestroyEffect(e)
call DamageUnit(udg_ZZZWisdom[GetPlayerId(GetOwningPlayer(c))+1],w,c,0)
set DamageDone = udg_ZZZWisdom[GetPlayerId(GetOwningPlayer(c))+1] //To add to caster mana


loop
    call DisplayTextToPlayer(Player(0),0,0,"BigLoop") //debug
    exitwhen (GetUnitAbilityLevel(c,'A00D'))*2 == i or b == true
    set i = i+1
    call RemoveLocation(l)
    set l = GetUnitLoc(w)
    set u = CreateUnitAtLoc(Player(13),'h001',l,0)
    set udg_TempInteger = GetPlayerId(GetOwningPlayer(c))
    call GroupEnumUnitsInRange(g,GetLocationX(l),GetLocationY(l),350,Condition(function NMCC)) //All nearby enemy units who are enemy of caster
    set w = null
    set w = FirstOfGroup(g)
    if w == null then //No targets
        set b = true
        call RemoveUnit(u)
        call RemoveLocation(l)
        set twowait = 0
    endif
    
    
    call IssueTargetOrder(u,"attack",w)
    loop
        exitwhen UnitHasBuffBJ(w, 'B006') == true or b == true
        call IssueTargetOrder(u,"attack",w)
        call Wait(.1)
        set TooLong = TooLong+1
        if TooLong == 500 then
            set b = true
        endif
    endloop
    call RemoveUnit(u)
    set e = AddSpecialEffectTarget("Abilities/Spells/Undead/DeathCoil/DeathCoilMissile.mdl",GetSpellTargetUnit(),"head")
    call Wait(twowait)
    call DestroyEffect(e)
    if b == false then
        call DamageUnit(udg_ZZZWisdom[GetPlayerId(GetOwningPlayer(c))+1],GetSpellTargetUnit(),c,0)
        set DamageDone=DamageDone+udg_ZZZWisdom[GetPlayerId(GetOwningPlayer(c))+1]
    endif
    
    call GroupClear(g)    
endloop
call SetUnitManaBJ(c, (GetUnitStateSwap(UNIT_STATE_MANA, GetTriggerUnit()) + DamageDone) ) //Addmana
endif
call RemoveLocation(l)
call RemoveLocation(q)
set g = null
set u = null
set c = null
endfunction
 

Rainther

I guess I should write something of value here...
Reaction score
61
JASS:
    exitwhen (GetUnitAbilityLevel(c,'A00D'))*2 == i or b == true
Bad dog :p if the ability is level 3 this will be repeated 5 times and 3 times if the level is 2. Change it to
JASS:
    exitwhen (GetUnitAbilityLevel(c,'A00D'))+1 == i or b == true
If something. Don't have time to check they rest atm.
 

TheCrystal

New Member
Reaction score
36
I'll just set it to, ((GetUnitAbilityLevel(c,'A00D')*2)+1), this way it jumps several times (As the intention, since the damage is small and the mana gained would be less then the ability's cost).

Edit: Btw, the same bug is still occurring.
Edit2: The bug happens randomly, once the thing didn't spawn for two BigLoops, once it just stopped after the second time, and one time it stopped on the third time.
 
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