Big problems i can't understand

Roku

New Member
Reaction score
3
Hey, well im trying to make this triggered spell, which works like this: the unit places down the healing stream totem (ward), and then units withing 600 range of the totem get healed every 2 sec, based of the heroes int. Here's my trigger:
JASS:
scope LHT

globals
//**************************************************************************************************    
    private constant integer SumUnit = 'o001' // Ward Rawcode
    private constant real HealBase = 100 // Totem Base-Heal
    private constant real TotemRadius = 600 // The AoE affected by the totem
    private constant real Interval = 2 // Healing Interval
    private constant real LifeSpawn = 60 // The totem's duration
//**************************************************************************************************
    
    private location array Totloc
    private integer pt
    private unit array caster
    private integer pc
    private unit array affected
    private integer pa
endglobals

struct LHT
    unit caster
    real heal
    real dur = 0
    location tl
endstruct

private function Cond takes nothing returns boolean
    return GetUnitTypeId(GetSummonedUnit()) == SumUnit
endfunction

private function Unit_Filter takes nothing returns boolean
    if IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(caster[pc])) then
		return false
	endif
    if(IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)) then
       return false
    endif
	if(IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE))then
		return false
	endif
	if GetUnitTypeId(GetFilterUnit()) == SumUnit then
		return false
	endif
    return true
endfunction

private function setaffected takes nothing returns nothing
    local unit a = GetEnumUnit()
    //call PingMinimapLocForForce(bj_FORCE_ALL_PLAYERS, GetUnitLoc(a), 2)
    //set affected[pa] = null
    set pa = GetUnitIndex(a)
    set affected[pa] = a
    set a = null
endfunction

private function Heal takes nothing returns boolean
    local LHT data = ABCT_GetData()
    local real h = data.heal
    local unit a
    local group af    
    local location sp = data.tl
    local location p
    local unit u
    
    call BJDebugMsg("Healing...")
    //set affected[pa] = null
    call BJDebugMsg("Healing2...")
    call PingMinimapLocForForce(bj_FORCE_ALL_PLAYERS, Totloc[pt], 2)
    set af = GetUnitsInRangeOfLocMatching(TotemRadius, Totloc[pt], Condition(function Unit_Filter))
    call ForGroup(af, function setaffected)
    set a = affected[pa]
    set p = GetUnitLoc(a)
    call CreateNUnitsAtLoc( 1, 'h005', GetOwningPlayer(a), p, bj_UNIT_FACING ) // Adding a dummy buff to the affected units
    set u = bj_lastCreatedUnit
    call UnitAddAbility(u, 'A022')
    call IssueTargetOrder( u, "bloodlust", a )
    call UnitApplyTimedLife(u, 'BTLF', 2.00)
    if data.dur == LifeSpawn then
    call data.destroy()
    set data.dur = 0
    return true
    else
        set data.dur = data.dur + Interval
        //call PingMinimapLocForForce(bj_FORCE_ALL_PLAYERS, GetUnitLoc(a), 2)
        call BJDebugMsg("Healing...")
        call SetUnitState(a, UNIT_STATE_LIFE, GetUnitState(a, UNIT_STATE_LIFE) - (h/50 + HealBase))
    endif
        
    call DestroyGroup(af)
    //call RemoveLocation(sp)
    call RemoveLocation(p)
    set af = null
    set a = null
    set u = null
    //set sp = null
    set p = null
    
    return false
endfunction

private function action takes nothing returns nothing
    local LHT data = LHT.create()
    local unit c = GetSummoningUnit()
    local unit s = GetSummonedUnit()
    local location sp = GetUnitLoc(s)
    local integer i = GetHeroInt(c,true)
    local real cr = I2R(i)
    local group af 
    set pt = GetUnitIndex(s)
    set Totloc[pt] = GetUnitLoc(s)
    set pc = GetUnitIndex(c)
    set caster[pc] = c
    //set af = GetUnitsInRangeOfLocMatching(TotemRadius, sp, Condition(function Unit_Filter))
    //call ForGroup(af, function setaffected)
    set data.tl = sp
    set data.heal = cr
    call PingMinimapLocForForce(bj_FORCE_ALL_PLAYERS, data.tl, 2)
    call ABCT_Start(function Heal, data, Interval)
    
    call RemoveLocation(sp)
    call DestroyGroup(af)
    set af = null
    set c = null
    set s = null
    set sp = null
endfunction

    //===========================================================================
function InitTrig_Totem takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SUMMON )
    call TriggerAddCondition( t, Condition( function Cond) )
    call TriggerAddAction( t, function action )
endfunction

endscope


Basically the thing i dont understand is that whenever i use the function "set affected[pa] = null" all the remaining actions of the trigger get skipped. Doesnt matter where i insert it, all the other things after it get ignored. I would need this, so if a unit leaves the 600 range of the totem, it doesnt get healed anymore. Any help appreciated!
 

Roku

New Member
Reaction score
3
Could you tell me more about war3err and how to use it? Never heard of it. And what do you mean by uninitialized?
 
Reaction score
456
Enable it from the NewGen's Grimoire menu. I guess it's the one that shows you these ingame:
Code:
Op Limit - Execute 300,000 bytecode operations
Divide by zero - Divide by integer or real 0
Var use - Attempt to get the value of an uninitialized var
ExecuteFunc("func") - If func does not exist or func has arguments, this stops a crash.
Player(x) - If x > 15 or x < 0

In your case, it would be this:
Var use - Attempt to get the value of an uninitialized var
 

Roku

New Member
Reaction score
3
Yes, i have and had that box checked ("enable war3err"), my spell still doesnt work.

EDIT: Ehm, i finally got your point, and gave pa the initial value of 1 at the start of the trigger (declaration of globals). It works now. +rep
 
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