Creep respawn trigger

TfauxT

New Member
Reaction score
2
I can't get monsters to respawn correctly, heres the trigger I'm using.

JASS:
function Trig_Unit_respawnsNORM_Copy_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetDyingUnit(), UNIT_TYPE_HERO) == false ) ) then
        return false
    endif
    return true
endfunction

function Trig_Unit_respawnsNORM_Copy_Actions takes nothing returns nothing
    set udg_MobSpawn = GetUnitTypeId(GetDyingUnit())
    call TriggerSleepAction( 230.00 )
    call CreateNUnitsAtLoc( 1, udg_MobSpawn, Player(11), GetUnitLoc(GetDyingUnit()), bj_UNIT_FACING )
endfunction

//===========================================================================
function InitTrig_Unit_respawnsNORM_Copy takes nothing returns nothing
    set gg_trg_Unit_respawnsNORM_Copy = CreateTrigger(  )
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Unit_respawnsNORM_Copy, Player(11), EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Unit_respawnsNORM_Copy, Condition( function Trig_Unit_respawnsNORM_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Unit_respawnsNORM_Copy, function Trig_Unit_respawnsNORM_Copy_Actions )
endfunction
For GUI users, this trigger would like this:
Trigger - Unit owned by player 12 brown dies
Condition - dying unit is a hero equal to false
Actions- set MobSpawn= unit type of dying unit.
wait 150 seconds
Unit- create 1 Mobspawn at position of dying unit.

Any assistance is appreciated :)
 

TfauxT

New Member
Reaction score
2
Thank you Ghan, again you are so helpful:rolleyes:
I will try that out and see if it functions the way I want it to. Thank you.

Is there a command to reset/delete a variable after it has been used?
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> Is there a command to reset/delete a variable after it has been used?

Depends on the type of variable.
What are you trying to do?
 

TfauxT

New Member
Reaction score
2
To make things quick, this is what I'm trying to do with my creeps:

Code:
Mob Respawn
    Events
        Unit - A unit owned by Player 12 (Brown) Dies
    Conditions
        ((Dying unit) is A Hero) Equal to False
    Actions
        Set MobSpawn = (Unit-type of (Dying unit))
        Set DeathPoint = (Position of (Dying unit))
        Wait 150.00 seconds
        Unit - Create 1 MobSpawn for Player 12 (Brown) at DeathPoint facing Default building facing degrees
The problem is I do not know how to reset or remove the variables after the trigger is done, so it ends up repsawning the same mobs over and over at each point you kill a new mob. I'm new to jass and the like, so sorry if this is such a simple fix :confused:
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
That's why you use a local variable.
Local variables are only used in the trigger in which they are created.
So, there will be no confusion.
Of course, the easiest thing to do would be to put the

Code:
Set MobSpawn = (Unit-type of (Dying unit))

after the wait like this:

Code:
Wait 150.00 seconds
Set DeathPoint = (Position of (Dying unit))
Set MobSpawn = (Unit-type of (Dying unit))
Unit - Create 1 MobSpawn for Player 12 (Brown) at DeathPoint facing Default building facing degrees
 

TfauxT

New Member
Reaction score
2
Oh! so the local variables must be after the wait for it to work correct? :banghead: I did not think the position would cause such a fuss.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> so the local variables must be after the wait for it to work correct?

No.
But that variable in the GUI version was not local.
If it were, it wouldn't matter where you put it.
The reason you have a problem is because that was a global variable.
 

Ghan

Administrator - Servers are fun
Staff member
Reaction score
888
> how would I create a local variable?

In JASS.
Or, if you insist, with a Custom Script:

Code:
Custom Script: local unit TempUnit

Note, however, that a local variable will be unusable in GUI events, conditions and actions.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top