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

Outpost creep respawn

Status
Not open for further replies.
Level 1
Joined
Oct 7, 2021
Messages
2
ok so i need help with creep spawning for players but.
It must work as outpost mechanic like corrupted mine of player 1 will spawn creep in n seconds, but if it destroyed over gold mine other player can build his outpost mine and it will spawn creeps for him, and i did not found any triggers for it, or found but not understood how to use them
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
So I think I understand what you mean. There are goldmines that the players can corrupt which after doing so will periodically spawn units.

Some questions:
  • Do you want to use goldmines/corrupted goldmines? Or is that just an example?
  • Does the goldmine spawn the units at it's position? Or are they spawned at a region somewhere else?
  • Are the units trained using the unit queue? Like how a Barracks can train up to 7 units at a time (similar to Castle Fight).
 
Level 1
Joined
Oct 7, 2021
Messages
2
So I think I understand what you mean. There are goldmines that the players can corrupt which after doing so will periodically spawn units.

Some questions:
  • Do you want to use goldmines/corrupted goldmines? Or is that just an example?
  • Does the goldmine spawn the units at it's position? Or are they spawned at a region somewhere else?
  • Are the units trained using the unit queue? Like how a Barracks can train up to 7 units at a time (similar to Castle Fight).
1)example, something else will be used.
2)spawn in same region as gm
3)units must be created by unit create script
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
I made a rather complicated to understand but easy to use system. Hopefully you find it useful. I take advantage of Hashtables to track what units an Outpost should spawn. It also uses a Timer System that I made the other day to handle periodically spawning the units with ease.

This is the important trigger that you need to configure:
  • Capture Outpost
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Outpost
    • Actions
      • -------- Configure these variables to define the types of units and how many of them spawn as well as how often: --------
      • Set VariableSet Out_TotalUnitTypes = 3
      • Set VariableSet Out_UnitInterval = 10.00
      • Set VariableSet Out_UnitType[1] = Footman
      • Set VariableSet Out_UnitType[2] = Rifleman
      • Set VariableSet Out_UnitType[3] = Knight
      • Set VariableSet Out_UnitCount[1] = 3
      • Set VariableSet Out_UnitCount[2] = 2
      • Set VariableSet Out_UnitCount[3] = 1
      • Trigger - Run Add Outpost To System <gen> (ignoring conditions)
So when an Outpost is finished constructing you define what units spawn, how many of each spawn, and how often they spawn. You simply match the [Indexes] of the variables, so UnitType[1] and UnitCount[1] go together and UnitType[2] and UnitCount[2] go together. This pattern continues and you can add as many [Indexes] as you want so you could have a UnitType[4]/UnitCount[4], etc.

In my example I am spawning:
3 Footman
2 Rifleman
1 Knight
Every 10.00 seconds.

TotalUnitTypes must be set to the highest [Index] that you use in the trigger. In this case that would be [3].


This is the trigger that runs every 10.00 seconds and actually Creates the units. It uses my Timer System which is why it doesn't have any Events. It will run automatically whenever an Outpost timer expires. I know it looks complicated but just ignore anything you don't understand. I am Creating X units of type Y for the Outpost Owner at the position of the Outpost:
  • Spawn Outpost Units
    • Events
    • Conditions
    • Actions
      • -------- TS_Source = The Outpost that this expired timer is associated with. --------
      • -------- --------
      • -------- Setup some important variables: --------
      • Set VariableSet Out_Player = (Owner of TS_Source)
      • Custom script: set udg_Out_HandleOutpost = udg_TS_Source
      • Set VariableSet Out_TotalUnitTypes = (Load 0 of (Key Out_HandleOutpost.) from Out_Hash.)
      • Set VariableSet Out_Point = (Position of TS_Source)
      • -------- --------
      • -------- Create the outpost units: --------
      • For each (Integer Out_Loop) from 1 to Out_TotalUnitTypes, do (Actions)
        • Loop - Actions
          • -------- Load saved values from the outpost: --------
          • Set VariableSet Out_Id = (Load Out_Loop of (Key Out_HandleOutpost.) from Out_Hash.)
          • Custom script: set udg_Out_UnitType[udg_Out_Loop] = udg_Out_Id
          • Set VariableSet Out_UnitCount[Out_Loop] = (Load (Out_Loop x -1) of (Key Out_HandleOutpost.) from Out_Hash.)
          • -------- --------
          • -------- Create the outpost units: --------
          • Unit - Create Out_UnitCount[Out_Loop] Out_UnitType[Out_Loop] for Out_Player at Out_Point facing Default building facing degrees
          • -------- --------
          • -------- This is an example that you should delete or fix. It orders the spawned units to attack somewhere at random. It leaks A LOT of Points! --------
          • Unit Group - Order (Last created unit group) to Attack-Move To (Random point in (Playable map area))
      • -------- --------
      • -------- Remove the Point so it doesn't cause a memory leak: --------
      • Custom script: call RemoveLocation (udg_Out_Point)
Note that each batch of Created units can be referenced in (Last created unit group). They're created at the same time in-game but technically they're created one by one. So in my example the 3 Footman are created, then the 2 Rifleman, and finally the 1 Knight.

Also, this orders the units to attack randomly but it's leaking many Points because I use the Random point function instead of Setting/Removing a Point variable:
  • Unit Group - Order (Last created unit group) to Attack-Move To (Random point in (Playable map area))
More importantly, this action is just an example of what you could do with the created units. You should delete it.
 

Attachments

  • Outpost System 1.w3m
    24.4 KB · Views: 8
Last edited:
Status
Not open for further replies.
Top