• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Problem with my creep respawn system

Status
Not open for further replies.
Level 4
Joined
May 23, 2010
Messages
83
  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- --------
      • -------- Get Creeps --------
      • -------- --------
      • -------- set neutral creeps respawnand types (for both meele and ranged units) --------
      • Set neutralCreeps_respawntime = 1.00
      • Trigger - Add to Stronger Creep Respawns <gen> the event (Time - Every neutralCreeps_respawntime seconds of game time)
      • Set neutralCreeps_typeInt = (neutralCreeps_typeInt + 1)
      • Set neutralCreeps_meeleType[neutralCreeps_typeInt] = Peasant
      • Set neutralCreeps_typeInt = (neutralCreeps_typeInt + 1)
      • Set neutralCreeps_meeleType[neutralCreeps_typeInt] = Peon
      • Set neutralCreeps_typeInt = (neutralCreeps_typeInt + 1)
      • Set neutralCreeps_meeleType[neutralCreeps_typeInt] = Wisp
      • Set neutralCreeps_typeInt = (neutralCreeps_typeInt + 1)
      • Set neutralCreeps_meeleType[neutralCreeps_typeInt] = Acolyte
      • Set neutralCreeps_typeInt = (neutralCreeps_typeInt + 1)
      • Set neutralCreeps_meeleType[neutralCreeps_typeInt] = Mur'gul Slave
      • -------- set regions where creeps will be spawned --------
      • -------- generalint[1] is for storage groups and regions where creeps will be included --------
      • Set neutralCreeps_generalint[1] = (neutralCreeps_generalint[1] + 1)
      • Set neutralCreeps_regionsSpot[neutralCreeps_generalint[1]] = Region 009 <gen>
      • Set neutralCreeps_generalint[1] = (neutralCreeps_generalint[1] + 1)
      • Set neutralCreeps_regionsSpot[neutralCreeps_generalint[1]] = Region 010 <gen>
      • Set neutralCreeps_generalint[1] = (neutralCreeps_generalint[1] + 1)
      • Set neutralCreeps_regionsSpot[neutralCreeps_generalint[1]] = Region 011 <gen>
      • -------- create first wave of creeps --------
      • For each (Integer A) from 1 to neutralCreeps_generalint[1], do (Actions)
        • Loop - Actions
          • Unit - Create 1 neutralCreeps_meeleType[1] for Neutral Hostile at (Center of neutralCreeps_regionsSpot[(Integer A)]) facing Default building facing degrees
          • Unit Group - Add (Last created unit) to neutralCreeps_group[(Integer A)]
          • Unit - Create 1 neutralCreeps_meeleType[1] for Neutral Hostile at (Center of neutralCreeps_regionsSpot[(Integer A)]) facing Default building facing degrees
          • Unit Group - Add (Last created unit) to neutralCreeps_group[(Integer A)]
  • Stronger Creep Respawns
    • Events
    • Conditions
    • Actions
      • -------- [2] is to keep things working (used as base variable) --------
      • For each (Integer neutralCreeps_generalint[2]) from 1 to neutralCreeps_generalint[1], do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (All units of neutralCreeps_group[neutralCreeps_generalint[2]] are dead) Equal to True
            • Then - Actions
              • Unit Group - Pick every unit in neutralCreeps_group[neutralCreeps_generalint[2]] and do (Actions)
                • Loop - Actions
                  • For each (Integer B) from 1 to neutralCreeps_typeInt, do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Unit-type of (Picked unit)) Equal to neutralCreeps_meeleType[(Integer B)]
                          • ((Integer B) + 1) Less than or equal to neutralCreeps_typeInt
                        • Then - Actions
                          • Unit - Create 1 neutralCreeps_meeleType[((Integer B) + 1)] for Neutral Hostile at (Center of neutralCreeps_regionsSpot[neutralCreeps_generalint[2]]) facing Default building facing degrees
                          • Unit Group - Add (Last created unit) to neutralCreeps_group[neutralCreeps_generalint[2]]
                          • Unit - Set the custom value of (Last created unit) to (Custom value of (Picked unit))
                          • Unit Group - Remove (Picked unit) from neutralCreeps_group[neutralCreeps_generalint[2]]
i got theese 2 triggers to respawn creeps i dont really like to use custom values on units because im starting this new map and they got better usage i think. basically the triggers are meant to spawn creeps at map initialization (this works) they are added to units groups and periodically, if all units of each unit group is dead they must be respawned stronger (there is the problem, all dead units are spawned into neutralCreeps_regionSpot[1] and as the get stronger they spawn in a greater number).

if anyone can help with this.. i really think its a variable got out of its place but i cant find it and i really need to get this working

edit: removed disabled function
 
Yes, you have set the variables in a wrong way. First off,
your + 1 integer variables should be like this:
  • Set neutralCreeps_meeleType[1] = Peasant
  • Set neutralCreeps_meeleType[2] = Peon
  • Set neutralCreeps_meeleType[3] = Wisp
  • Set neutralCreeps_meeleType[4] = Acolyte
  • Set neutralCreeps_meeleType[5] = Mur'gul Slave
And the loading part should be:
  • Stronger Creep Respawns
  • Events
    • Time - Every 1.00 seconds of game-time
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (All units of neutralCreeps_group[neutralCreeps_generalint[2]] are dead) Equal to True
      • Then - Actions
        • Set Integer = (Integer + 1)
        • Set Point1 = (Center of neutralCreeps_regionSpot)
        • Unit - Create 1 neutralCreeps_meeleType[Integer] at Point1 facing Default building facing degrees
        • Custom script: call RemoveLocation (udg_Point1)
      • Else - Actions
 
Level 4
Joined
May 23, 2010
Messages
83
Yes, you have set the variables in a wrong way.
And the loading part should be:
  • Stronger Creep Respawns
  • Events
    • Time - Every 1.00 seconds of game-time
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (All units of neutralCreeps_group[neutralCreeps_generalint[2]] are dead) Equal to True
      • Then - Actions
        • Set Integer = (Integer + 1)
        • Set Point1 = (Center of neutralCreeps_regionSpot)
        • Unit - Create 1 neutralCreeps_meeleType[Integer] at Point1 facing Default building facing degrees
        • Custom script: call RemoveLocation (udg_Point1)
      • Else - Actions

yes it mey work for 1 spot only... there will be a lot of spots so is there a problem to search for unit type using (for each integer variable from 1 to (total diferent unit types)) like i did?
 
First off, this:
  • ((Integer B) + 1) Less than or equal to neutralCreeps_typeInt
Should be "Less than", not "Less than or Equal to".

Secondly, you can use Hashtables to define the spots you are referring to.

Create 1 invisible unit at each spot (locust, no model, no shadow) and increase integer by + 1, saving this value to the unit, like this:
  • Trigger
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Hashtable - Create a hashtable
    • Set Hashtable = (Last created hashtable)
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units of type InvisibleDummy) and do (Actions)
      • Loop - Actions
        • Unit Group - Add (Picked unit) to DummyGroup
  • Trigger2
  • Events
    • Time - Every 1.00 seconds of game-time
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (All units of neutralCreeps_group[neutralCreeps_generalint[2]] are dead) Equal to True
      • Then - Actions
        • Unit Group - Pick every unit in DummyGroup and do (Actions)
          • Loop - Actions
            • Set WhichInteger = (Load (Key(integer)) of (Key(Picked unit))
            • If (All conditions are true) then do (Actions) else do (Actions)
              • If - Conditions
                • (WhichInteger) Less than 5
              • Then - Actions
                • Hashtable - Save (WhichInteger + 1) as (Key(integer)) of (Key(Picked unit)) in Hashtable
                • Set Point1 = (Position of (Picked unit))
                • Unit - Create 1 neutralCreeps_meeleType[WhichInteger] at Point1 facing Default building facing degrees
                • Custom script: call RemoveLocation (udg_Point1)
              • Else - Actions
    • Else - Actions
For more about hashtables:
http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/hashtables-mui-133407/
 
Status
Not open for further replies.
Top