• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How to get movespeed of hero

Status
Not open for further replies.
Level 2
Joined
Mar 9, 2023
Messages
3
Hello Hive community!
I'm experienced C++ programmer and ex wc3 semi pro, dota 1 top player.
want to improve my skills, learn some WorldEditor basics or/and advanced features.
Know some scripting (Lua) from Wow
Want to start with getting -ms to get current hero movement speed (like in dota)
Show me the route please!
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,868
Hello, what you're trying to do is extremely simple. Open up the Trigger Editor and create a new trigger and begin modifying it.

1) First, you need to add an Event to your trigger (Control + E), which is what allows the trigger to run. An Event is basically something happening in the game, A unit dying, A hero gaining a level, 5.00 seconds of game-time passing, etc...

In this case you are looking for a chat command which is a Player Event.
  • Events
    • Player 1 (Red) types a chat messages containing -ms as An exact match
2) Next you have the option to add Conditions to your trigger (Control + D). This is where you can ask questions about the Event and anything else going on in the game. For example: Is the player's Hero alive? Does the Player belong to a certain Team? Does 2 + X Equal 5? etc...

In this case you don't really need a Condition since your trigger is so simple and straightforward.

3) Finally we get to the Actions of the trigger (Control + R) which define what is going to happen after any of your Events occur and all of the Conditions are met. Here we can Deal damage, Create units, Kill units, Add resources to Players, Display text messages, etc...

In this case you are looking for a Text Message action that displays the current movement speed of a unit. Now how you get this unit can depend, in DotA (at least when I played it 15 years ago), the game had an Event that detected when a Player chose a Hero and then stored that Hero in a Unit variable. This variable was then referenced whenever you typed -ms in order to display the Hero's current movement speed.

In your case it'd be best to see the current movement speed of whichever unit you have selected. To do this I would create another trigger and a Unit variable, then setup the triggers to look like this:
  • Events
    • Player 1 (Red) Selects a unit
  • Conditions
  • Actions
    • Set Variable SelectedUnit = (Triggering unit)
  • Events
    • Player 1 (Red) types a chat messages containing -ms as An exact match
  • Conditions
  • Actions
    • Game - Display to (All players) for 30.00 seconds the text: (String((Current movement speed of SelectedUnit)))
The end result will be two triggers and 1 variable. Variables are managed in the Variable Editor (Control + L).

Notes:
Movement speed is a Real (fractional number aka a float), and not a String, therefore you need to use the Conversion function Convert Real To String in order to display it in a Text Message (string).

Everything in the trigger editor is categorized by name and you have a Search For Text option that should make your life easier. For instance, typing "text" in the Search For Action box for an Action will bring up the Text Message action. It's not as useful for Events or Conditions but it comes in handy for Actions.

If you want these triggers to work for different players you need to copy and paste the Events and change Player 1 (Red) to another player. It's okay to have multiple Events registered to the same trigger, that just means that the trigger will run when ANY of those Events happen. However, the SelectedUnit variable will not play very nice with multiple players since it's value will change globally (it's a global variable after all) and is being shared between them. The solution is to change SelectedUnit so that it's now an Array and use the Player's number (each Player object has a number associated with them) as the [index] of your array. This is one way of making your triggers MPI, which means Multi-Player-Instanceable, aka making them work for multiple players. I don't think you're worried about this though since you said you were simply testing things out on your own.
 

Attachments

  • Movement Speed 1.w3m
    17.7 KB · Views: 4
Last edited:
Level 2
Joined
Mar 9, 2023
Messages
3
stuck on point
how to get there?

joinbottom.gif
set.gif
Set Variable SelectedUnit = (Triggering unit)
 

Attachments

  • 1.png
    1.png
    193.6 KB · Views: 11

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,868
Set that variable's type to Unit inside of the Variable Editor if you haven't already. Then you simply click the red field that says Value to open up a menu containing all of the functions related to Units. You then find the Event Response called Triggering unit and select it and press OK.

Also, you should be doing this inside of a new empty trigger, not the default "Map Initialization" trigger that is used to start a melee game. You can delete that trigger.
 
Status
Not open for further replies.
Top