HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Creep Respawn problem

12-12-2006, 08:22 AM#1
galmore
Quote:
No need to reply i fix my problem
And i made my first real JASS like script lol
the Fixed trigger is add to the bottem of this post

Ok im trying to create a creep respawn effect.
Heres what i do ...

in the Map Init trigger i find and fill an array with the creeps locations and assign the Index for the creep to the creeps Custom Value

Trigger:
Create Spawn Location Array
Events
Conditions
Collapse Actions
Set Loop_Counter = 0
Collapse Unit Group - Pick every unit in (Units owned by Neutral Hostile) and do (Actions)
Collapse Loop - Actions
Set Loop_Counter = (Loop_Counter + 1)
Set Spawn_Location[Loop_Counter] = (Position of (Picked unit))
Unit - Set the custom value of (Picked unit) to Loop_Counter
Game - Display to (All players) the text: (String(Loop_Counter))

This does fill the array with the mobs locations

So then when a creep dies i wait 10 sec and make a new creep at the location stored in the array and assign the new creep the same Index

Trigger:
Spawn
Collapse Events
Unit - A unit owned by Neutral Hostile Dies
Conditions
Collapse Actions
Set Location = (Custom value of (Dying unit))
Set Dying_Unit_type = (Unit-type of (Dying unit))
Wait 10.00 seconds
Unit - Create 1 Dying_Unit_type for Neutral Hostile at Spawn_Location[Location] facing Default building facing (270.0) degrees
Unit - Set the custom value of (Last created unit) to Temp_int
Game - Display to (All players) the text: (Name of (Last created unit))

But the problem seems(and i would even go so far as to say IS) that the variables are being over writen as new creeps die

When i kill just one mob then wait for the respawn it works

So If anyone can tell me how to get around this or another way of having creeps respawn at there start locations i would love to hear about it

also this is for a RPG style map so there will be a LOT of Creeps

Collapse JASS:
function Trig_Spawn_Actions takes nothing returns nothing
    local integer index
    local integer unit_type
    set index = GetUnitUserData(GetDyingUnit())
    set unit_type = GetUnitTypeId(GetDyingUnit())
    call TriggerSleepAction( 10.00 )
    call CreateNUnitsAtLoc( 1, unit_type, Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Spawn_Location[index], bj_UNIT_FACING )
    call SetUnitUserData( GetLastCreatedUnit(), index )
    call DisplayTextToForce( GetPlayersAll(), GetUnitName(GetLastCreatedUnit()) )
endfunction

//===========================================================================
function InitTrig_Spawn takes nothing returns nothing
    set gg_trg_Spawn = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Spawn, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Spawn, function Trig_Spawn_Actions )
endfunction

All i did was changed the scope of the variables so that any new instances of this trigger would have there oun
or at least thats what i think i did this is the first bit of real scripting i have dont for War3 :P im so proud :)
12-12-2006, 08:54 AM#2
Wyvernoid
I was also very proud when I first solved my problem just as how you did...

Cheers guy! And don't forget to call BJDebugMsg("Good Job!").