• 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.

[JASS] Need Help with Respawn Trigger

Status
Not open for further replies.
Level 1
Joined
May 30, 2007
Messages
1
My first Thread :eekani:

whatever .. ^^' ... i am having a real hard time with one of my triggers ^^ ... it shall respawn every unit that dies at exactly the point where it has been when the map started, therefore at map init every creep is picked and some actions to save its loc are performed ... but my problem is that every game a single creep keeps on respawning after it dies ... about 400 creeps in the map but exactly this one keeps on respawning and respawning ... so that it slowly floods an area ... deleting this one creep makes another creep keep on respawning ...

The init trigger is in gui just to help for a simplier understanding:
(btw: no tmpInteger isnt used by another trigger .. so it doesnt overlap..)

  • Respawn Unit Init Gui
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Set tmpInteger = 0
      • Set TempUnitGroup = (Units owned by Neutral Hostile)
      • Unit Group - Pick every unit in TempUnitGroup and do (Actions)
        • Loop - Actions
          • Set GraveyardPoints[tmpInteger] = (Position of (Picked unit))
          • Set GraveyardUnits[tmpInteger] = (Unit-type of (Picked unit))
          • Unit - Set the custom value of (Picked unit) to tmpInteger
          • Set tmpInteger = (tmpInteger + 1)
      • Set tmpInteger = 0
      • Custom script: call DestroyGroup(udg_TempUnitGroup)
      • Trigger - Destroy (This trigger)
Then the Actually Respawn Trigger:

JASS:
function Trig_Respawn_Unit_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_SUMMONED) == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_Respawn_Unit_Actions takes nothing returns nothing
    local integer c = 0
    set c = GetUnitUserData(GetDyingUnit())
    call TriggerSleepAction( 45.00 )
    call CreateNUnitsAtLoc( 1, udg_GraveyardUnits[c], Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_GraveyardPoints[c], bj_UNIT_FACING )
    call SetUnitUserData( GetLastCreatedUnit(), c )
    set c = 0
endfunction


function InitTrig_Respawn_Unit takes nothing returns nothing
    set gg_trg_Respawn_Unit = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Respawn_Unit, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Respawn_Unit, Condition( function Trig_Respawn_Unit_Conditions ) )
    call TriggerAddAction( gg_trg_Respawn_Unit, function Trig_Respawn_Unit_Actions )
endfunction
 
Status
Not open for further replies.
Top