• 🏆 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!

Creep respawn system

Status
Not open for further replies.
Level 2
Joined
Nov 9, 2006
Messages
25
I'm writing a creep respawn system which basically works like this.

Map Initialization - Stores all of the creeps to separate unit groups. There is a different unit group for each level of creeps. So a CreepsLevel1 unit group with all of those lvl 1 units in it, CreepsLevel2, with all of the lvl 2's, ect.

A unit dies - Get which unit group it belongs to, and then start a timer which expires in (2x level of dying unit) seconds. After it expires, spawn a random creep from the next unit group.

The problems I'm having.

1) How do i store a unit thats not placed on the map. to a unit array (or unit group). I want to make a unit group with all of the lvl 1 creeps, but i can only add units that are already on the map to the unit group. Is there anyway to get around this, besides creating 1 of each the units, adding them to the unit array, and then removing them?

2) For respawning, is there more efficient way to write the system then masive if/then/else's (without JASS)? I was thinking of writing the respawn trigger to be something like:
If a unit is a member of unit group 1, then spawn a random unit from unit group 2 at dying units posistion, if it is a member of unit group 2, then spawn a random unit from unit group 3, ect.

Thanks in advance :)
 
Level 4
Joined
Jun 1, 2007
Messages
92
1. Instead of using Unit or Unit Group variable types, you should use Unit-Type instead. Level1, Level2, and Level3 are Unit-Type[3] variable arrays.
  • Set Variables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Level1[1] = Peasant
      • Set Level1[2] = Footman
      • Set Level1[3] = Rifleman
      • Set Level2[1] = Priest
      • Set Level2[2] = Flying Machine
      • Set Level2[3] = Sorceress
      • Set Level3[1] = Knight
      • Set Level3[2] = Gryphon Rider
      • Set Level3[1] = Dragonhawk Rider
2. With the trigger above, you can do something like this, however you will require many If/Then/Else's depending on how many Levels you have, but you only really need to change the bold part of each trigger, which isn't hard at all.
  • Respawning
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 3, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Dying unit)) Equal to [B]Level1[/B][(Integer A)]
            • Then - Actions
              • Unit - Create 1 [B]Level2[/B][(Random integer number between 1 and 3)] for Player 1 (Red) at (Position of (Dying unit)) facing Default building facing degrees
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Dying unit)) Equal to [B]Level2[/B][(Integer A)]
                • Then - Actions
                  • Unit - Create 1 [B]Level3[/B][(Random integer number between 1 and 3)] for Player 1 (Red) at (Position of (Dying unit)) facing Default building facing degrees
                • Else - Actions
 
Level 2
Joined
Nov 9, 2006
Messages
25
Thanks for the help. How would i do it if i wanted it to wait a varying amount of times for the respawn. Should i use wait actions, or set timers?
 
Status
Not open for further replies.
Top