Spawning System

stavious

New Member
Reaction score
24
I'm going into a bit of a new feild for me and testing the ORPG map styles. Currently I'm trying to make one; just to test my abilities with the Editor and expand my knowledge a bit. I want the creeps in my map to re-spawn, like in any simple map. So basically I want a Spawning System for the creeps in my map. I was just wondering who could give me the most efficant trigger for this or could point out to me which way may work better than the other one. Thanx for helping me understand better :) .
 

emjlr3

Change can be a good thing
Reaction score
395
well...the most efficient is...well...JASS

are your units preplaced, or do you place them?

if they are preplaced, then...

at map init, have this

Code:
local integer i = 1
local unit u
local group g = CreateGroup()

call GroupEnumUnitsInRect(g,bj_mapInitialPlayableArea,null)        
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
        call GroupRemoveUnit(g,u)      
        if GetOwningPlayer(u)== Player(PLAYER_NEUTRAL_AGGRESSIVE) then 
            set udg_Creep_Types[i] = GetUnitTypeId(u)
            set udg_Creep_Positions[i] = GetUnitLoc(u)
            call SetUnitUserData( u, i)
        endif
        set i = i + 1        
    endloop 

call DestroyGroup(g)
set g = null

u need two global variables
Creep_Types - integer array
Creep_Positions - location array

then to respawn them

Code:
function creep_revive_Actions takes nothing returns nothing
    local integer i = GetUnitUserData(GetTriggerUnit()) 
     
    call PolledWait( 60.00 ) // length of tiem for respawn
    set bj_lastCreatedUnit = CreateUnitAtLoc( Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Creep_Types[i], udg_Creep_Positions[i], GetRandomReal(0, 360) )
    call SetUnitUserData( bj_lastCreatedUnit, i )  
endfunction

function blah takes nothing returns nothing
local trigger creep_revive = CreateTrigger()

call TriggerRegisterPlayerUnitEvent(creep_revive, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH, null)
    call TriggerAddAction( creep_revive, function creep_revive_Actions )

set creep_revive = null
endfunction

whats in function blah can also be at map init, if you want, to save space, but your revive function must be above it in the same trigger
 

stavious

New Member
Reaction score
24
Oh, I should've mentioned: I don't know the first thing about JASS. I use only the triggers in the Editor for all of my map works, nothing above that. So if you could give your answers using those triggers that would be great ;) .
 

Knights

You can change this now in User CP.
Reaction score
71
Heres one:


Code:
Spawn
    Events
        Time - Elapsed game time is 0.00 seconds
    Conditions
    Actions
        Unit Group - Pick every unit in (Units owned by Player 12 (Brown)) and do (Actions)
            Loop - Actions
                Set CreepInt = (CreepInt + 1)
                Set CreepPlace[CreepInt] = (Region centered at (Position of (Picked unit)) with size (25.00, 25.00))
                Set Creep[CreepInt] = (Picked unit)
                Set CreepAngle[CreepInt] = (Facing of (Picked unit))
        Custom script:   call DestroyGroup (bj_lastCreatedGroup)

Code:
NewSpawn
    Events
        Unit - A unit Dies
    Conditions
        (Owner of (Dying unit)) Equal to Player 12 (Brown)
    Actions
        For each (Integer A) from 1 to CreepInt, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Creep[(Integer A)] Equal to (Dying unit)
                    Then - Actions
                        Wait 48.00 seconds
                        Unit - Create 1 (Unit-type of (Dying unit)) for Player 12 (Brown) at (Center of CreepPlace[(Integer A)]) facing CreepAngle[(Integer A)] degrees
                        Set CreepPlace[(Integer A)] = (Region centered at (Position of (Last created unit)) with size (25.00, 25.00))
                        Set Creep[(Integer A)] = (Picked unit)
                    Else - Actions
                        Do nothing
 

stavious

New Member
Reaction score
24
Hmm Knights, I don't understand your first trigger too much. Can you explain a bit what they both do so I can get a better idea; thanx :D .
And does anyone seem to have a better way of making a spawning system? If so please share them with me :) .
 

Chocobo

White-Flower
Reaction score
409
Code:
NewSpawn
    Events
        Unit - A unit Dies
    Conditions
        (Owner of (Dying unit)) Equal to Player 12 (Brown)
    Actions
        For each (Integer A) from 1 to CreepInt, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Creep[(Integer A)] Equal to (Dying unit)
                    Then - Actions
                        Wait 48.00 seconds
                        Unit - Create 1 (Unit-type of (Dying unit)) for Player 12 (Brown) at (Center of CreepPlace[(Integer A)]) facing CreepAngle[(Integer A)] degrees
                        Set CreepPlace[(Integer A)] = (Region centered at (Position of (Last created unit)) with size (25.00, 25.00))
                        Set Creep[(Integer A)] = (Picked unit)
                    Else - Actions
                        Do nothing

:p I wonder if there will be a lot of creeps after

Here my code :

Code:
Set Levels
Events
Game - Time Elasped 0.00 seconds of game-time

Conditions
None

Actions
//Determines Unit Types.
LevelUnit1[1] = Footman (Level 1)
LevelUnit1[2] = Footman (Level 2)
...
LevelUnit1[10] = Footman (Level 10)
LevelUnit2[1] = Rifleman (Level 1)
LevelUnit2[2] = Rifleman (Level 2)
....
LevelUnit2[10] = Rifleman (Level 10)
//This Triggers up to 10 Levels, like heroes in Melee mode.

Code:
Respawn
Events
Unit - Generic unit dies

Conditions
(Owner of (Triggering unit)) Equal to Player 12 (Brown)
//Player 12 is Creeps, you can change it as you want

Actions
Custom Script : local unit udg_Killer
Custom Script : call PolledWait(60. )
Set RandomInt = (Random Integer between 1 to 2) //Determines a unit-type
If (RandomInt) Equal to 1 //Will Create a UnitType1
      Then Unit - Create 1 UnitType1[(Hero level of (Killer))] for (Player 12) at (<whatever>) facing 0.00 degrees //Footman
      Else Unit - Create 1 UnitType2[(Hero level of (Kiler))] for (Player 12) at (<whatever>) facing 0.00 degrees //Rifleman
 

stavious

New Member
Reaction score
24
Chocobo does that trigger use JASS or something? If not I don't really get the Custom Script part (since I never use those :eek: ).
 

monoVertex

I'm back!
Reaction score
460
The Custom Script is for useing Jass in GUI so yeah, that trigger uses Jass, but so little that it can't be a problem :p
 

Chocobo

White-Flower
Reaction score
409
stavious said:
Chocobo does that trigger use JASS or something? If not I don't really get the Custom Script part (since I never use those :eek: ).

Custom Script : local unit udg_Killer
Custom Script : call PolledWait(60. )

Code:
Custom Script : local unit udg_Killer

It is to declare a "local" variable, which is only used by a function.

Code:
Custom Script : call PolledWait(60. )

Equal to : Wait 60 seconds of game-time.
 

Chewbalka

New Member
Reaction score
14
Events
Time- Every ?.?? seconds of game time
(periodic event)
Conditions-
Actions- Create # Unit For (player 1?) At (Center of(playable map area) Facing (default building facing)

Revive

Events-
unit- Owned by (player 1?) Dies
Condition
Action
Create 1 (unit-type of(dying unit)) For (player 1?) at (Center of (playable map area)) Facing (default building facing)

Like this? a basic spawn
youll need regions made for top and a allready made unit in the Seconds unless you change the (dying unit) thing lol.
 
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