• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Storing and loading unit values

Status
Not open for further replies.
Level 6
Joined
Apr 1, 2009
Messages
201
I had an idea for a summoning system for my rpg that I'm making but can't figure out how to create this trigger. I'm not very good at triggering. My idea is that a player types a message similar to "Summon Demon" as a substring. What I think I need is a hastable or game cache to store a list of units that can be saved as a substring and called up when a message similar to the example are typed. If I didn't explain good enough or this was too confusing feel free to reply or send me a message. Any help at all would be greatly appreciated.
 
Level 3
Joined
Apr 20, 2010
Messages
46
From the sounds of it, you want players to be able to summon (and presumably Return) units during play, and they summon them via text commands?

It doesn't necessarily require a hashtable or game cache.

When a player types a chat message, you check for the substring of Summon. You take the rest of the player's message as how you find What to summon. So I'd have it loop through a String array until it finds a match. It will then summon the unit, in the case of a specific unit, it takes it from a Unit array and moves it into play, in the case of a unit-type, it takes it from a Unit-Type array and creates a new unit.

Got that?

  • Summon Unit
    • Events
      • Player - Player 1 (Red) types a chat message containing Summon as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to Summon
    • Actions
      • -------- The condition will prevent it trying to summon things whenever someone just happens to say "Summon" --------
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Substring((Entered chat string), 8, (Length of (Entered chat string)))) Equal to (UnitStringArray[(Integer A)])
            • Then - Actions
              • -------- // Create or move the unit --------
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Integer A) Equal to 10
                • Then - Actions
                  • -------- // Display error to player --------
                  • Game - Display to (All players) the text: No such unit
                • Else - Actions
 
Last edited:
I am not sure if Matched Chat String will work.
Try this:
  • Trigger
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • For each (IntegerA) from 1 to 12, do (Actions)
      • Loop - Actions
        • Trigger - Add to Trigger2<gen> the event (Player - Player(IntegerA) types "summon demon" as a Substring
  • Trigger2
  • Events
  • Conditions
  • Actions
    • Set String = (Substring((Entered chat string), 12, (Length of (Entered chat string)))
    • If (All conditions are true) then do (Actions) else do (Actions)
      • If - Conditions
        • (String) Equal to Drake //String comparison
      • Then - Actions
        • Unit - Create 1 Drake for (Triggering player) at...
String is a String variable.

If you want default warcraft III units to spawn, you can also do
Unit - Create 1 (Unit-type(String)) for (Triggering player)..

You can also set a list of String variables and a list of Unit types (array enhanced for both cases). Then, you can set
  • Set Strings[1] = drake
  • Set Strings[2] = nazgul
  • Set Units[1] = Golden Drake
  • Set Units[2] = Flying Nazgul
  • For each (IntegerA) from 1 to 12, do (Actions)
    • Loop - Actions
      • Trigger - Add to Trigger2<gen> the event (Player - Player(IntegerA) types "summon demon" as a Substring
  • Trigger2
  • Events
  • Conditions
  • Actions
    • Set String = (Substring((Entered chat string), 12, (Length of (Entered chat string)))
    • For each (IntegerA) from 1 to 2, do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • (String) Equal to Strings[(IntegerA)] //String comparison
          • Then - Actions
            • Set Temp_Int = (IntegerA)
          • Else - Actions
    • Unit - Create 1 Units[Temp_Int] for (Triggering player) at...
 
Level 6
Joined
Apr 1, 2009
Messages
201
Didn't Work

I tried it but nothing happened. Not sure If I did something wrong but I followed the example you did but just changed the name of the integers.
 
This will work easily (Matched Chat String worked when I wanted players to type radio-1, radio-2, radio-3 and each identified a different song to play):

  • Events
    • Player Types "Summon Demon" as a substring
  • Conditions
  • Actions
    • If (Matched Chat String) Equal To "Summon Demon of Death" then
      • Then - Actions
        • Unit - Create Demon Of Death
      • Else - Actions
        • If (Matched Chat String) Equal To "Summon Demon Revenance" then
          • Then - Actions
            • Unit - Create Demon of Revenance
          • Else - Actions
 
Status
Not open for further replies.
Top