• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Stupid Bug is stupid

Status
Not open for further replies.
Level 7
Joined
Mar 5, 2009
Messages
254
Hello,im currently working on an map and when i tested it i found a bug,when i kill a unit type Murloc Plaguebearer,then the map after like 60 seconds create an type of unit of Elder sasquatch at a point close to center of playable map area.And when i kill more murlocs,(i have respawn system) they do respawn but also the map creates that sasquatchs for every murlocplaguebearer that i kill.When i kill any other type of units this bug doesn't happen.I don't know what is wrong.Here is the respawn system that i use :
  • INIT Store Creeps
    • Events
      • Map initialization
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Set Loop = 0
      • Unit Group - Pick every unit in (Units owned by Neutral Hostile) and do (Actions)
        • Loop - Actions
          • Set Creep_Type[Loop] = (Unit-type of (Picked unit))
          • Set Creep_Position[Loop] = (Position of (Picked unit))
          • Unit - Set the custom value of (Picked unit) to Loop
          • Set Loop = (Loop + 1)
JASS:
function Trig_Revive_Creeps_Actions takes nothing returns nothing
    local integer CUSTOM
    set CUSTOM = GetUnitUserData(GetDyingUnit())
    call TriggerSleepAction( 60.00 )
    call CreateNUnitsAtLoc( 1, udg_Creep_Type[CUSTOM], Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Creep_Position[CUSTOM], bj_UNIT_FACING )
    call SetUnitUserData( GetLastCreatedUnit(), CUSTOM )
endfunction

//===========================================================================
function InitTrig_Revive_Creeps takes nothing returns nothing
    set gg_trg_Revive_Creeps = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Revive_Creeps, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Revive_Creeps, function Trig_Revive_Creeps_Actions )
endfunction
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
This can be due to the TriggerSleepAction, try using a timer instead.
Waits are inacurate...

EDIT: nevermind, due to the local integer this shouldn't be the cause of the problem.
I'll examine this more thoroughly.

Also: why do you have 2 events in your first trigger? Is it because more units are added to Neutral Hostile?
Then it might be that the values get overwritten by the itteration of the unit group.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
That is the main problem, you don't know what you are doing, it simply does what you ask, there is no bug.

If you're using the unit custom data somewhere else, this will screwed up, that is probably the case.
And the init is weird.

What you want to do exactly ?
 
Level 7
Joined
Mar 5, 2009
Messages
254
Ok so this is what happeend :
I removed creep respawn system,no bug
added it,bug is there
created new unit to replace the old,but based on another unit with changed model : BUG is there

*PLAYS and notices how some murlocs doesn't have disease ability at first and then when they respawn some disease stuff is added to them as effect :eekani:*

*Removes the disease ability from the murlocs*

*BUG IS GONE :eekani:*
scaled.php



Seriosly,what does a respawn creep trigger action has to do with The spells that the units are using? :eekani: :eekani: :eekani: :goblin_jawdrop: :goblin_wtf:
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
What if you use this instead:

JASS:
function Trig_Revive_Creeps_Actions takes nothing returns nothing
    local integer CUSTOM
    local unit u
    set CUSTOM = GetUnitUserData(GetDyingUnit())
    call TriggerSleepAction( 60.00 )
    set u = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Creep_Type[CUSTOM], GetLocationX(udg_Creep_Position[CUSTOM]), GetLocationY(udg_Creep_Position[CUSTOM]), bj_UNIT_FACING)
    call SetUnitUserData(u, CUSTOM)
endfunction

//===========================================================================
function InitTrig_Revive_Creeps takes nothing returns nothing
    set gg_trg_Revive_Creeps = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Revive_Creeps, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Revive_Creeps, function Trig_Revive_Creeps_Actions )
endfunction

EDIT: late respond, nevermind.. I thought it might have something to do with GetLastCreatedUnit()...
Causing it to set the UnitUserData for the incorrect unit.
 
Try this (create a hashtable called HASH in variable editor before):

JASS:
function ReviveCallback takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer CUSTOM = LoadInteger(udg_HASH, GetHandleId(t), 1)
    call SetUnitUserData(CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Creep_Type[CUSTOM], GetLocationX(udg_Creep_Position[CUSTOM]), GetLocationY(udg_Creep_Position[CUSTOM]), bj_UNIT_FACING ), CUSTOM)
    call FlushChildHashtable(udg_HASH, GetHandleId(t))
    call DestroyTimer(t)
    set t = null
endfunction

function Trig_Revive_Creeps_Actions takes nothing returns nothing
    local integer CUSTOM = GetUnitUserData(GetDyingUnit())
    local timer t = CreateTimer()
    call SaveInteger(udg_HASH, GetHandleId(t), 0, CUSTOM)
    call TimerStart(t, 60, false, function ReviveCallback)
    set t = null
endfunction

//===========================================================================
function InitTrig_Revive_Creeps takes nothing returns nothing
    set gg_trg_Revive_Creeps = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Revive_Creeps, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Revive_Creeps, function Trig_Revive_Creeps_Actions )
endfunction
Does it work?

However, even if it works: This is total bullcrap. I recommend using a unit indexing system and a premade unit respawn system. There are plenty of them available on the web. Other than that: try to learn how to use hashtables and GetHandleId(). This is the ABC of triggering.

Also, try to avoid starting at 0 when using GetUnitUserData as an index. As 0 is the default setting for all units, it might return a false positive. Start at 1, so that 0 is reserved for unindexed units!
otherwise all dying units that are not indexed by your init function (for example spawns, summoned units, dummy units) that die will revive eventually, using the entry that was first made in your list! This is definitely the reason for your weird bug.
 
Everything works now guys,i just needed to remove the Disease ability from the murloc,u know the disease ability has some ward unit type and i don't know what exacty went wrong.. but its allright now
The reason for your bug is your indexing function.
Replace it with this one:

  • INIT Store Creeps
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Set Loop = 1
      • Unit Group - Pick every unit in (Units owned by Neutral Hostile) and do (Actions)
        • Loop - Actions
          • Set Creep_Type[Loop] = (Unit-type of (Picked unit))
          • Set Creep_Position[Loop] = (Position of (Picked unit))
          • Unit - Set the custom value of (Picked unit) to Loop
          • Set Loop = (Loop + 1)
Replace your jass script with this one:
JASS:
function ReviveCallback takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer CUSTOM = LoadInteger(udg_HASH, GetHandleId(t), 1)
    call SetUnitUserData(CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Creep_Type[CUSTOM], GetLocationX(udg_Creep_Position[CUSTOM]), GetLocationY(udg_Creep_Position[CUSTOM]), bj_UNIT_FACING ), CUSTOM)
    call FlushChildHashtable(udg_HASH, GetHandleId(t))
    call DestroyTimer(t)
    set t = null
endfunction

function Trig_Revive_Creeps_Actions takes nothing returns nothing
    local integer CUSTOM = GetUnitUserData(GetDyingUnit())
    local timer t
    if GetUnitUserData(GetDyingUnit()) > 0 then
       set t = CreateTimer()
       call SaveInteger(udg_HASH, GetHandleId(t), 0, CUSTOM)
       call TimerStart(t, 60, false, function ReviveCallback)
       set t = null
    endif
endfunction

//===========================================================================
function InitTrig_Revive_Creeps takes nothing returns nothing
    set gg_trg_Revive_Creeps = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Revive_Creeps, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Revive_Creeps, function Trig_Revive_Creeps_Actions )
endfunction
The reason for that is that desease might create a dummy unit. When the creep with desease dies, a hidden unit dies with it, causing your respawn trigger to fire again. As the dummy unit has no custom index, it takes the first entry of your revive list and goes with that, which is your sasquatsh.
 
This picks every unit owned by neutral hostile and it does every action for it,so when that sasquatch spawns under neutral hostile it is also set as creep type
Sure it does, that's how it's supposed to be. And "spawning" units don't fire this trigger, as the event runs only once (okay, twice, due to the double event, but not more).
 
Status
Not open for further replies.
Top