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

Selecting monsters from a pool

Status
Not open for further replies.
Level 23
Joined
Oct 12, 2008
Messages
1,783
This is probably a very simple system, but Ive been brainfarting for the last few hours on how to set this up.

Need a system that selects a new monster 'faction' each wave
For example...
Wave Possible Factions
1Gnolls, Kobolds
2Orc, Human
3Orc, Human, Troll
4Orc, Human, Undead
5Demons

- Wave count affects the faction type available to spawn (eg. Orc can spawn as either wave 1-3)
 
Last edited:
Level 23
Joined
Oct 12, 2008
Messages
1,783
  • wave setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet WaveUnitType1[1] = Peasant
      • Set VariableSet WaveUnitType2[1] = Footman
      • Set VariableSet WaveUnitType3[1] = No unit-type
      • Set VariableSet WaveUnitCount1[1] = 5
      • Set VariableSet WaveUnitCount2[1] = 5
      • -------- You can leave WaveCount3 unassigned since WaveUnitType3 = No Unit-Type --------
  • wave spawn
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet CurrentWave = (CurrentWave + 1)
      • -------- -------------- --------
      • -------- Wave Unit-Type 1 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WaveUnitType1[CurrentWave] Not equal to No unit-type
        • Then - Actions
          • Unit - Create WaveUnitCount1[CurrentWave] WaveUnitType1[CurrentWave] for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
        • Else - Actions
      • -------- -------------- --------
      • -------- Wave Unit-Type 2 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WaveUnitType2[CurrentWave] Not equal to No unit-type
        • Then - Actions
          • Unit - Create WaveUnitCount2[CurrentWave] WaveUnitType2[CurrentWave] for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
        • Else - Actions
      • -------- -------------- --------
      • -------- Wave Unit-Type 3 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WaveUnitType3[CurrentWave] Not equal to No unit-type
        • Then - Actions
          • Unit - Create WaveUnitCount3[CurrentWave] WaveUnitType3[CurrentWave] for Neutral Hostile at (Center of (Playable map area)) facing Default building facing degrees
        • Else - Actions
And if you wanted to spawn multiple waves at multiple regions you could use a Loop and Region Arrays:
  • For each (Integer A) from 1 to TotalPlayers, do (Actions)
    • Loop - Actions
      • Set VariableSet TempPoint = SpawnRegion[IntegerA]
      • Unit - Create WaveUnitCount1[CurrentWave] WaveUnitType1[CurrentWave] for Neutral Hostile at TempPoint facing Default building facing degrees
Or a PlayerGroup approach since it's easier to manage which players have left the game.
  • Player Group - Pick every player in ActivePlayers and do (Actions)
    • Loop - Actions
      • Set VariableSet TempPoint = SpawnRegion[Player number of picked player]
      • Unit - Create WaveUnitCount1[CurrentWave] WaveUnitType1[CurrentWave] for Neutral Hostile at TempPoint facing Default building facing degrees
Im mostly asking how to set up the faction index not how to actually spawn a unit.
Sorry for not being clear enough (Ive rewritten the first post to better explain the question)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,558
Alright, I managed a little system using a Hashtable.

  • Faction Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set VariableSet FactionHashtable = (Last created hashtable)
      • -------- --------- --------
      • -------- Set Factions --------
      • Set VariableSet TotalFactions = 7
      • -------- --------- --------
      • Set VariableSet Gnolls = 1
      • Set VariableSet Kobolds = 2
      • Set VariableSet Orc = 3
      • Set VariableSet Human = 4
      • Set VariableSet Troll = 5
      • Set VariableSet Undead = 6
      • Set VariableSet Demons = 7
      • -------- --------- --------
      • -------- Set Faction Names (Unneeded but I use this in the Faction Spawn example) --------
      • Set VariableSet FactionNames[Gnolls] = Gnolls
      • Set VariableSet FactionNames[Kobolds] = Kobolds
      • Set VariableSet FactionNames[Orc] = Orc
      • Set VariableSet FactionNames[Human] = Human
      • Set VariableSet FactionNames[Troll] = Troll
      • Set VariableSet FactionNames[Undead] = Undead
      • Set VariableSet FactionNames[Demons] = Demons
      • -------- --------- --------
      • -------- Save Factions --------
      • -------- 0 = Number of Factions Used For This Wave --------
      • -------- 1+ = The Faction --------
      • -------- --------- --------
      • Set VariableSet WaveIndex = (WaveIndex + 1)
      • Set VariableSet FactionCount = 2
      • Hashtable - Save FactionCount as 0 of WaveIndex in FactionHashtable.
      • Hashtable - Save Gnolls as 1 of WaveIndex in FactionHashtable.
      • Hashtable - Save Kobolds as 2 of WaveIndex in FactionHashtable.
      • -------- --------- --------
      • Set VariableSet WaveIndex = (WaveIndex + 1)
      • Set VariableSet FactionCount = 2
      • Hashtable - Save FactionCount as 0 of WaveIndex in FactionHashtable.
      • Hashtable - Save Orc as 1 of WaveIndex in FactionHashtable.
      • Hashtable - Save Human as 2 of WaveIndex in FactionHashtable.
      • -------- --------- --------
      • Set VariableSet WaveIndex = (WaveIndex + 1)
      • Set VariableSet FactionCount = 3
      • Hashtable - Save FactionCount as 0 of WaveIndex in FactionHashtable.
      • Hashtable - Save Orc as 1 of WaveIndex in FactionHashtable.
      • Hashtable - Save Human as 2 of WaveIndex in FactionHashtable.
      • Hashtable - Save Troll as 3 of WaveIndex in FactionHashtable.
      • -------- --------- --------
      • Set VariableSet WaveIndex = (WaveIndex + 1)
      • Set VariableSet FactionCount = 3
      • Hashtable - Save FactionCount as 0 of WaveIndex in FactionHashtable.
      • Hashtable - Save Orc as 1 of WaveIndex in FactionHashtable.
      • Hashtable - Save Human as 2 of WaveIndex in FactionHashtable.
      • Hashtable - Save Undead as 3 of WaveIndex in FactionHashtable.
      • -------- --------- --------
      • Set VariableSet WaveIndex = (WaveIndex + 1)
      • Set VariableSet FactionCount = 1
      • Hashtable - Save FactionCount as 0 of WaveIndex in FactionHashtable.
      • Hashtable - Save Demons as 1 of WaveIndex in FactionHashtable.
  • Faction Spawn
    • Events
      • Time - Every 3.00 seconds of game time
    • Conditions
    • Actions
      • -------- Increase the Wave Count --------
      • Set VariableSet CurrentWave = (CurrentWave + 1)
      • -------- --------- --------
      • -------- Load the FactionCount saved in our Hashtable --------
      • Set VariableSet FactionCount = (Load 0 of CurrentWave from FactionHashtable.)
      • -------- --------- --------
      • -------- Choose a random number based on how many Factions the Current Wave uses --------
      • Set VariableSet RandomNumber = (Random integer number between 1 and FactionCount)
      • -------- --------- --------
      • -------- Load a random Faction using this random number --------
      • Set VariableSet LoadedFaction = (Load RandomNumber of CurrentWave from FactionHashtable.)
      • -------- --------- --------
      • -------- Loop through all of the possible Factions, finding whichever one is equal to our LoadedFaction --------
      • For each (Integer A) from 1 to TotalFactions, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LoadedFaction Equal to (Integer A)
            • Then - Actions
              • Game - Display to (All players) for 30.00 seconds the text: (Spawn Faction + FactionNames[LoadedFaction])
              • -------- 1 = Gnolls --------
              • -------- 2 = Kobolds --------
              • -------- 3 = Orc --------
              • -------- 4 = Human --------
              • -------- 5 = Troll --------
              • -------- 6 = Undead --------
              • -------- 7 = Demons --------
            • Else - Actions
So once you have LoadedFaction you can do something like "If LoadedFaction equal to Orc then Create Orc Units"
 

Attachments

  • Faction Fixed.w3m
    18.6 KB · Views: 16
Last edited:
Status
Not open for further replies.
Top