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

Random System between classes

Status
Not open for further replies.
Level 8
Joined
Mar 24, 2011
Messages
353
The question is:
- I Have 6 classes! (Warrior*, Mage, Paladin, Priest, Scout and Druid)
*The Warrior is an "special case", because i have "two" types of warrior (Human and Dwarf, see?)
- And I can not count as different classes (totaling 7 classes) that although "units" different class is the same, so if the system vote to be the class "warrior" will have to say "a second vote" to know whether it will be the "warrior dwarf" or "warrior human", understand?
- The system can not repeat any class. (ex: 1 Mage, 1 Paladin and 2 Priest. Or 1 WarriorH, 1 WarriorD, and 2 Druid), don't! This can not happen! I need only 1 of any class!
- The map has 4 players (red, blue, green and yellow) Then what has to happen? the system must be random between 6 classes, giving one class for each player owner (1 for Red, 1 for Blue, 1 for Green and 1 for Yellow), creating the "Unit" in Region "Y". And of course they are 4 players and 6 classes and no one class can be repeated, 4 classes will tar inside and 2 class will tar out of the game. Understand?

Basically i need an "system" that when the player Red/Blue/Green/Yellow say in chat "-RC", go for random into each of 6 classes (with "special case of Warrior remember when pick warrior the system do an "second votation" for decide if is the WarriorHuman ou the WarriorDwarf), don't repeating no one of classes and giving of class for each of 4 players (and how is 6 classes and 4 players, 2 classes are left out and are discarded.
- Ps: No matter which players wrote "-RC" first or after, nor is every man for himself. Starting from the moment that one of four players write "-RC" in the chat, the classe of the units will be created in the region "Y" in any way for each of the players, understand?

The logic is easy to understand the system, but it is full of "buts" and this makes it difficult to explain it. But I tried to simplify the maximum possibly of how the system works that I need. Sorry many writing errors that I should have made up. As I said the system is hard to explain and English is not my natural language, sorry. But someone who understands trigger can help me with this trigger? Thank you ^_^
 
Last edited:

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
For clean code I would go with hashtables but to keep it simple, I would use a slightly limiting array method.

The concept is basically this:

Init trigger
unit[101] = class 1, unit 1
unit[102] = class 1, unit 2
class[1] = 2
unit[201]= class 2. unit 2
class[2] = 1

ANOTHER TRIGGER:

set random = 1-number of classes
set random2 = unit[(random * 100) + 1-class[random]]
spawn random 2 for triggering player

this indexing method would support 100 units per class and 81 classes.
 
Level 8
Joined
Mar 24, 2011
Messages
353
Hi dudes, The system is 100% automatic, people or players do not interfere with anything. They do not vote, do not choose, do nothing. in fact, the only "interference" they have with the system is to "start it" by typing in the chat. understand?
- When: one of players (red, blue, green or yellow) digitar "-RC" no chat
- The trigger will give away for each of the 4 players one class and create a unit (the character) for that player in the region "Y", not repeating any kind. And what is Basically USER says:

So you want the 6 actual classes to have the same probability of being picked, and if warrior is picked it should have 50% chance to be human and 50% chance dwarf? And OFC no repeat classes.
 
Level 39
Joined
Feb 27, 2007
Messages
5,010
  • Events
    • -------- These need to be the players that are actually playing in your map --------
    • -------- It's unclear to me if you meant you changed the player colors or you were using Players 1,2,5,7 --------
    • -------- Note that they also need to be changed in the Actions --------
    • Player - Player 1 (Red) types a chat message containing -RC as An exact match
    • Player - Player 2 (Blue) types a chat message containing -RC as An exact match
    • Player - Player 5 (Teal) types a chat message containing -RC as An exact match
    • Player - Player 7 (Purple) types a chat message containing -RC as An exact match
  • Conditions
  • Actions
    • Set HERO_PLAYERS[1] = Player 1 (Red)
    • Set HERO_PLAYERS[2] = Player 2 (Blue)
    • Set HERO_PLAYERS[3] = Player 5 (Yellow)
    • Set HERO_PLAYERS[4] = Player 7 (Green)
    • Set CLASSES = 6
    • Set CLASS[1] = 'Uwar'
    • Set HAS_SUBCLASS[1] = true
    • Set SUBCLASS_A[1] = 'Whmn'
    • Set SUBCLASS_B[1] = 'Wdwf'
    • -------- If you want to make another subclass for a different class, follow the above template --------
    • -------- Also you want these to be unit type arrays, I just wrote the rawcodes to show which class they would correspond to --------
    • Set CLASS[2] = 'Umag'
    • Set CLASS[3] = 'Upal'
    • Set CLASS[4] = 'Upst'
    • Set CLASS[5] = 'Usct'
    • Set CLASS[6] = 'Udrd'
    • Set TempLoc = (Center of <HERO SPAWN REGION>))
    • For each (Integer A) from 1 to 4 do (Actions)
      • Loop - Actions
        • Set RAND = Random integer from 1 to CLASSES
        • If (All conditions are true) then do (then) else do (else)
          • If - Conditions
            • HAS_SUBCLASS[RAND] equal to true
          • Then - Actions
            • If (All conditions are true) then do (then) else do (else)
              • If - Conditions
                • (Random integer from 1 to 2) equal to 1
              • Then - Actions
                • Set CREATE = SUBCLASS_A[RAND]
              • Else - Actions
                • Set CREATE = SUBCLASS_B[RAND]
            • Set CREATE = SUBCLASS
          • Else - Actions
            • Set CREATE = CLASSES[RAND]
        • Unit - Create 1 CREATE for HERO_PLAYERS[(Integer A)] at TempLoc
        • Set CLASS[RAND] = CLASS[CLASSES]
        • Set HAS_SUBCLASS[RAND] = HAS_SUBCLASS[CLASSES]
        • Set SUBCLASS_A[RAND] = SUBCLASS_A[CLASSES]
        • Set SUBCLASS_B[RAND] = SUBCLASS_B[CLASSES]
        • Set CLASSES = CLASSES - 1
    • Custom script call RemoveLocation(udg_TempLoc) //Make sure you change this to show udg_ + whatever you called your location variable with _ instead of spaces
    • Trigger - Turn off (this trigger)
 
Level 8
Joined
Mar 24, 2011
Messages
353
automatic

  • Events
    • -------- These need to be the players that are actually playing in your map --------
    • -------- It's unclear to me if you meant you changed the player colors or you were using Players 1,2,5,7 --------
    • -------- Note that they also need to be changed in the Actions --------
    • Player - Player 1 (Red) types a chat message containing -RC as An exact match
    • Player - Player 2 (Blue) types a chat message containing -RC as An exact match
    • Player - Player 5 (Teal) types a chat message containing -RC as An exact match
    • Player - Player 7 (Purple) types a chat message containing -RC as An exact match
  • Conditions
  • Actions
    • Set HERO_PLAYERS[1] = Player 1 (Red)
    • Set HERO_PLAYERS[2] = Player 2 (Blue)
    • Set HERO_PLAYERS[3] = Player 5 (Yellow)
    • Set HERO_PLAYERS[4] = Player 7 (Green)
    • Set CLASSES = 6
    • Set CLASS[1] = 'Uwar'
    • Set HAS_SUBCLASS[1] = true
    • Set SUBCLASS_A[1] = 'Whmn'
    • Set SUBCLASS_B[1] = 'Wdwf'
    • -------- If you want to make another subclass for a different class, follow the above template --------
    • -------- Also you want these to be unit type arrays, I just wrote the rawcodes to show which class they would correspond to --------
    • Set CLASS[2] = 'Umag'
    • Set CLASS[3] = 'Upal'
    • Set CLASS[4] = 'Upst'
    • Set CLASS[5] = 'Usct'
    • Set CLASS[6] = 'Udrd'
    • Set TempLoc = (Center of <HERO SPAWN REGION>))
    • For each (Integer A) from 1 to 4 do (Actions)
      • Loop - Actions
        • Set RAND = Random integer from 1 to CLASSES
        • If (All conditions are true) then do (then) else do (else)
          • If - Conditions
            • HAS_SUBCLASS[RAND] equal to true
          • Then - Actions
            • If (All conditions are true) then do (then) else do (else)
              • If - Conditions
                • (Random integer from 1 to 2) equal to 1
              • Then - Actions
                • Set CREATE = SUBCLASS_A[RAND]
              • Else - Actions
                • Set CREATE = SUBCLASS_B[RAND]
            • Set CREATE = SUBCLASS
          • Else - Actions
            • Set CREATE = CLASSES[RAND]
        • Unit - Create 1 CREATE for HERO_PLAYERS[(Integer A)] at TempLoc
        • Set CLASS[RAND] = CLASS[CLASSES]
        • Set HAS_SUBCLASS[RAND] = HAS_SUBCLASS[CLASSES]
        • Set SUBCLASS_A[RAND] = SUBCLASS_A[CLASSES]
        • Set SUBCLASS_B[RAND] = SUBCLASS_B[CLASSES]
        • Set CLASSES = CLASSES - 1
    • Custom script call RemoveLocation(udg_TempLoc) //Make sure you change this to show udg_ + whatever you called your location variable with _ instead of spaces
    • Trigger - Turn off (this trigger)

Hey thanks dude :D
- I just got a little confused about "what" is each variable?


- HERO_ PLAYERS = Set Variable of "Player" with 4 array?
- CLASSES = Set Variable of "Integer"?
- CLASS = Set Variable of "Unit" with 6 array? and the texts of: UWar, UMag, UPal, Upst (...), is the Units of my map?
- SUBCLASS_A[1] and SUBCLASS_B[2], i dont understand this :/
- HAS_SUBCLASS?

I is so much confuse dude :c
 
Level 39
Joined
Feb 27, 2007
Messages
5,010
Hey thanks dude :D
- I just got a little confused about "what" is each variable?


- HERO_ PLAYERS = Set Variable of "Player" with 4 array?
- CLASSES = Set Variable of "Integer"?
- CLASS = Set Variable of "Unit" with 6 array? and the texts of: UWar, UMag, UPal, Upst (...), is the Units of my map?
- SUBCLASS_A[1] and SUBCLASS_B[2], i dont understand this :/
- HAS_SUBCLASS?

I is so much confuse dude :c
1. Yes
2. Yes
3. Unit type array of size 6, holding the unit types of each of your classes. I accidentally added a Set CLASS[1] = 'Uwar' but you wouldn't have just a basic "warrior" class, so CLASS[1] wouldn't be assigned.
4. There are CLASSES number different classes a player can randomly be given. To keep track of all the information about which one is the warrior with 2 subclasses (and any others you may wish to have subclasses in the future) we organize them by indexing. CLASS[x], SUBCLASS_A[x], SUBCLASS_B[x] are all the information about which unit types to spawn for the players and correspond to the same type ("warrior" or "priest") when x is the same (x= 1 warrior, = 2 mage, etc. in my above example).
5. If the Class has subclasses-warrior has 2- (set to true) or if it doesn't (set to false). The code checks to see if it is a subclass before randomly picking between the 2 subclasses. They are called "A" and "B" respectively.
 
Level 8
Joined
Mar 24, 2011
Messages
353
1. Yes
2. Yes
3. Unit type array of size 6, holding the unit types of each of your classes. I accidentally added a Set CLASS[1] = 'Uwar' but you wouldn't have just a basic "warrior" class, so CLASS[1] wouldn't be assigned.
4. There are CLASSES number different classes a player can randomly be given. To keep track of all the information about which one is the warrior with 2 subclasses (and any others you may wish to have subclasses in the future) we organize them by indexing. CLASS[x], SUBCLASS_A[x], SUBCLASS_B[x] are all the information about which unit types to spawn for the players and correspond to the same type ("warrior" or "priest") when x is the same (x= 1 warrior, = 2 mage, etc. in my above example).
5. If the Class has subclasses-warrior has 2- (set to true) or if it doesn't (set to false). The code checks to see if it is a subclass before randomly picking between the 2 subclasses. They are called "A" and "B" respectively.

Excuse me please, but now I was very confused about how or what, especially on which "variable" use for each text or similar. Without wanting to abuse their goodwill. But you could send me (or attach) the map you use to make this system up? so I can see and analyze much more (about what is what, or what use such a trigger line) which variable goes right text there. Could? :(
 
Level 39
Joined
Feb 27, 2007
Messages
5,010
Excuse me please, but now I was very confused about how or what, especially on which "variable" use for each text or similar. Without wanting to abuse their goodwill. But you could send me (or attach) the map you use to make this system up? so I can see and analyze much more (about what is what, or what use such a trigger line) which variable goes right text there. Could? :(
There was a minor error in my trigger text above and I changed the method a little.
 

Attachments

  • Random Class.w3x
    18.2 KB · Views: 54
Level 8
Joined
Mar 24, 2011
Messages
353
There was a minor error in my trigger text above and I changed the method a little.
Hey hi, very thanks for help-me. the map/trigger help so much. But her has an bug :c
Always "random" the same units :/

In my map:
- Red: Druid
- Blue: Scout
- Green: Paladin
- Yellow: Mage
Aways!

An in map that you put how example, is the same.. always "random" same units :c
- Red: NE Archer
- Blue: Ghoul
- Green: Night Elf Ship
- Yellow: Grunt
Aways :/
 
Status
Not open for further replies.
Top