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

[Trigger] Change fly height to whatever is in chat string

Status
Not open for further replies.
Level 22
Joined
Feb 4, 2005
Messages
3,971
I'm replacing an old ability system with land/take off to happen with chat strings. I want to make so that whatever number is included in the chat command, the altitude to be changed to that number. I couldn't think of a way.

  • Commands
    • Events
      • Player - Player 7 (Green) types a chat message containing <Empty String> as An exact match
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to /altitude X ;;this is the command and X is the number;;
        • Then - Actions
          • Unit Group - Pick every unit in (Units currently selected by Player 7 (Green)) and do (If (((Picked unit) is A flying unit) Equal to True) then do (Animation - Change (Picked unit) flying height to (The X in the chat string) at 100.00) else do (Do nothing))
        • Else - Actions
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
Conversion - Convert String To Real
  • (Real((Entered chat string))) Equal to 500.00
events don't have to be created for every single player
this requires much less writing
  • For each (Integer i) from 1 to 12, do (Actions)
    • Loop - Actions
      • Trigger - Add to SomeTrigger <gen> the event (Player - (Player(i)) types a chat message containing <Empty String> as A substring)
and if you want the command to require a sufix
  • SetHeightPerChat
    • Events
      • Player - Player 1 (Red) types a chat message containing -setheight as A substring
    • Conditions
      • -setheight Equal to (Substring((Entered chat string), 1, 11))
    • Actions
      • Animation - Change SomeUnit flying height to (Real((Substring((Entered chat string), 12, 15)))) at 0.00
the condition is necessary because "1000 -setheight " would trigger it, too

there also is a tutorial about it
http://www.hiveworkshop.com/forums/general-mapping-tutorials-278/using-chat-commands-34686/
 
Since it's a substring:
  • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units currently selected by (Triggering player)) and do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Actions) else do (Actions)
          • If - Conditions
            • ((Picked unit) is a flying unit) Equal to True)
          • Then - Actions
            • Set Height = (Substring((Entered Chat String), 10, (Length of (Entered chat string)))
            • Animation - Change (Picked unit) flying height to (Real(Height)) at 100000.00
          • Else - Actions
Animatio
 
Level 22
Joined
Feb 4, 2005
Messages
3,971
D4rk Gandalf, I'm using one player, otherwise I would know how to make it for all players, thx. Also this is very much and most likely of the last if not the last trigger that I'm having problem with, since I can do others myself and I will soon quit using war3 editor forever. ^_^

Pharaoh,

  • Commandz
    • Events
      • Player - Player 7 (Green) types a chat message containing <Empty String> as An exact match
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to /altitude
        • Then - Actions
          • Unit Group - Pick every unit in (Units currently selected by Player 7 (Green)) and do (If (((Picked unit) is A flying unit) Equal to True) then do (Animation - Change (Picked unit) flying height to (Real((Substring((Entered chat string), 10, (Length of (Entered chat string)))))) at 100.00) else do (Do nothing))
        • Else - Actions
I am using the enters chat string as exact match. Is it why it isn't working, needs to be uses BlaBlabla as a substring Event? Or do I need a number like /altitude (Number) ? Yes I decided not to use a variable and as you can see use your variable value directly, and err didnt use the custom script. So is it the Event or the Condition that is wrong, cause nothing ahppens?
 
Yes, it has to be Substring and this:
  • (Entered chat string) Equal to /altitude
must be
  • (Substring((Entered Chat String), 1, 9) Equal to /altitude
Oh, what is more,
  • (Real((Substring((Entered chat string), 10, (Length of (Entered chat string)))))) at 100.00
That 10 is the space between the altitude word and the number, so change that 10 to 11.
 
Level 22
Joined
Feb 4, 2005
Messages
3,971
New trigger, forget above. Ok when the value was 10, it didn't work but when I changed the value to 11 in the below trigger, works perfectly - whatever number I type, it changes to it. Thank you Pharaoh! You are helpful as usual and seems a pro triggerer :) Hey Ive also worked with that thing for 7 years just not all the time. Maybe that was my last request for help in war3 triggers (let's see). *gemmed*

  • Altitude
    • Events
      • Player - Player 7 (Green) types a chat message containing /altitude as A substring
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units currently selected by Player 7 (Green)) and do (If (((Picked unit) is A flying unit) Equal to True) then do (Animation - Change (Picked unit) flying height to (Real((Substring((Entered chat string), 11, (Length of (Entered chat string)))))) at 100.00) else do (Do nothing))
 
  • Melee Initialization
    • Events
      • Player - Player 1 (Red) types a chat message containing /altitude as A substring
    • Conditions
      • (Substring((Entered chat string), 1, 9)) Equal to /altitude
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units currently selected by (Triggering player)) and do (Actions)
        • Loop - Actions
          • Animation - Change (Picked unit) flying height to (Real((Substring((Entered chat string), 11, (Length of (Entered chat string)))))) at 1000000000.00
Test Map: View attachment Altitude.w3x


Edit: Oh, I posted by the time you were editing your post. Good job ;)
BTW, I did tell you to change it to 11 ;p
 
Level 22
Joined
Feb 4, 2005
Messages
3,971
Edit: Oh, I posted by the time you were editing your post. Good job ;)
BTW, I did tell you to change it to 11 ;p

Now I can make the units fly/land and remove thouse lousy abilities for fly/land i've made in the past. It was only the value had to be 11 as you said, wow I would have never thought. Good job to you, you are good :)

I also didnt see your edit about '11' at first :p
 
Status
Not open for further replies.
Top