My structs arnt MUI?

theXact

New Member
Reaction score
0
Hell all, so I have this spell and im using structs in order to pass variables into a timer. my problem is if the spell is cast more than once it stops the previous one in order to do then next one! So aperantly my struct variables are being overwritten causing it to stop! I'm wondering if I implemented them wrong, I'm no pro so this could very well be the problem! Anyway heres the code hopefully someone can enlighten me!

JASS:
truct divide
    unit hole
    unit hole2
endstruct

function Black_Hole_Filter takes nothing returns boolean
	return true//IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE)==false and(IsUnitType(GetFilterUnit(),UNIT_TYPE_ANCIENT)==false or Black_Hole_IsBear(GetFilterUnit()))and IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetUnit(H2Tx(GetTriggeringTrigger()),"g8")))
endfunction

function Trig_Divide_By_0_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A01P'
endfunction

function kill_group takes nothing returns nothing
    local location loc = GetUnitLoc(GetEnumUnit())
    call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Undead\\Darksummoning\\DarkSummonTarget.mdl", loc))
    call KillUnit(GetEnumUnit())
    call ShowUnit(GetEnumUnit(), false)
endfunction

function move_unit2 takes nothing returns nothing
    local divide divide_data = GetCSData(GetExpiredTimer())
    local unit hole = divide_data.hole2
	local location lN0=GetUnitLoc(GetEnumUnit())
	local location lN1=GetUnitLoc(hole)
	local location lN2 =PolarProjectionBJ(lN1,DistanceBetweenPoints(lN1,lN0)-1,AngleBetweenPoints(lN1,lN0))
	call SetUnitPositionLoc(GetEnumUnit(),lN2)
	call RemoveLocation(lN0)
	call RemoveLocation(lN1)
	call RemoveLocation(lN2)
endfunction

function move_unit takes nothing returns nothing
    local timer move = GetExpiredTimer()
    local divide divide_data = GetCSData(GetExpiredTimer())
    local boolexpr Group_Check = Condition (function Black_Hole_Filter)
    local unit hole = divide_data.hole2
    local real loc1 = GetUnitX(hole)
    local real loc2 = GetUnitY(hole)
    local group move_group
    set move_group = CreateGroup()
    call GroupEnumUnitsInRangeOfLoc(move_group,GetUnitLoc(hole),650, Group_Check)
    call ForGroup(move_group, function move_unit2)
    call GroupEnumUnitsInRangeOfLoc(move_group,GetUnitLoc(hole),20, Group_Check)
    call ForGroup(move_group, function kill_group)
    if (not(GetUnitState(hole, UNIT_STATE_LIFE)>0))then
        call PauseTimer(move)
        call DestroyTimer(move)
        call divide_data.destroy()
    endif  
endfunction

function Spell_Effect takes nothing returns nothing
    local timer Effect = GetExpiredTimer()
    local unit Black_Hole
    local integer count = 0
    local divide divide_data = GetCSData(GetExpiredTimer())
    local unit hole = divide_data.hole
    local real loc1 = GetUnitX(hole)
    local real loc2 = GetUnitY(hole)
    call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeTarget.mdl", loc1, loc2))
    if (not(GetUnitState(hole, UNIT_STATE_LIFE)>0))then
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeTarget.mdl", loc1, loc2))
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeTarget.mdl", loc1, loc2))
        call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeTarget.mdl", loc1, loc2))
        call PauseTimer(Effect)
        call DestroyTimer(Effect)
        call divide_data.destroy()
    endif  
endfunction

function Trig_BlackHole_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local integer count = 0
    local unit Black_Hole
    local unit Black_Hole_2
    local timer Effect = CreateTimer()
    local timer move = CreateTimer()
    local divide divide_data = GetCSData(GetExpiredTimer())
    local real loc1 = GetUnitX(caster)
    local real loc2 = GetUnitY(caster)
    set Black_Hole = CreateUnit(GetOwningPlayer(caster),'e004',GetUnitX(caster),GetUnitY(caster),270)
    set Black_Hole_2 = CreateUnit(GetOwningPlayer(caster),'e004',GetUnitX(caster),GetUnitY(caster),270)
    call SetUnitPathing(Black_Hole,false)
    call SetUnitPathing(Black_Hole_2,false)
    call UnitApplyTimedLife(Black_Hole,'BTLF',20)
    call UnitApplyTimedLife(Black_Hole_2,'BTLF',24)
    set divide_data.hole = Black_Hole
    set divide_data.hole2 = Black_Hole_2
    call TimerStart(move, 0.02, true, function move_unit)
    call TimerStart(Effect, 0.2, true, function Spell_Effect)
    call TriggerSleepAction(24)
    loop
        set Black_Hole = CreateUnit(GetOwningPlayer(caster),'e000',loc1, loc2,270)
        call UnitApplyTimedLife(Black_Hole,'BTLF',0.1)
        exitwhen count == 5
        call SetUnitScale( Black_Hole, 4,4,4)
        set count = count + 1
    endloop
endfunction

//===========================================================================
function InitTrig_BlackHole takes nothing returns nothing
    local trigger  gg_trg_BlackHole = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_BlackHole, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition ( gg_trg_BlackHole, Condition (function Trig_BlackHole_Conditions) )
    call TriggerAddAction( gg_trg_BlackHole, function Trig_BlackHole_Actions )
endfunction


note: This is not finished code, i know there are leaks and inefficiencies
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
You're never creating or attaching your structs anywhere. Heck, this:
[ljass]local divide divide_data = GetCSData(GetExpiredTimer())[/ljass]
doesn't even really make sense as it exists within the actions function, since there is no expired timer, and since nothing should be attached to it yet.

Also, it's good to recycle timers for about 527 reasons. To ease your transition from classic dynamic timers, I recommend using this. Once you get TU down, if you want good efficiency for rapid looping MUI things like what this does, I recommend learning how to work with struct stacks and linked lists.

And again, you need to actually attach struct to timers to get them later.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
    local divide divide_data = GetCSData(GetExpiredTimer())

No!, it returns 0.

JASS:
    local divide divide_data = divide.create()

This returns new instance.
 
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