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

Move item with text message

Status
Not open for further replies.
Level 2
Joined
Mar 1, 2022
Messages
3
Hey guys,

I made some sort of MOBA map and I want to make a trigger which gives my hero item in inventory slot 6 to a little storage building which every player has a personal storage of.

So if I type !6 in the chat, then the item my hero has in slot 6 is removed from the hero and given to my personal storage so I can later take it again or sell it.

How do I do this?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,565
  • Example with PN
    • Events
      • Player - Player 1 (Red) types a chat message containing !6 as An exact match
    • Conditions
    • Actions
      • Set VariableSet PN = (Player number of (Triggering player))
      • Hero - Give (Item carried by Player_Hero[PN] in slot 6) to Player_Storage[PN]
Player_Hero and Player_Storage are both Unit array variables. You'd have these set beforehand to each Player's Hero and Storage unit.

PN is an Integer variable, it's optional, I use it here because it makes working with Player numbers easier. An example without it:
  • Example no PN
    • Events
      • Player - Player 1 (Red) types a chat message containing !6 as An exact match
    • Conditions
    • Actions
      • Hero - Give (Item carried by Player_Hero[(Player number of (Triggering player))] in slot 6) to Player_Storage[(Player number of (Triggering player))]

Note that if the Storage is full the Item will drop at it's position. Also, you need to add an Event for each Player that can use this trigger. Currently it will only work for Player 1 (Red).
 
Last edited:
Level 2
Joined
Mar 1, 2022
Messages
3
  • Example with PN
    • Events
      • Player - Player 1 (Red) types a chat message containing !6 as An exact match
    • Conditions
    • Actions
      • Set VariableSet PN = (Player number of (Triggering player))
      • Hero - Give (Item carried by Player_Hero[PN] in slot 6) to Player_Storage[PN]
Player_Hero and Player_Storage are both Unit array variables. You'd have these set beforehand to each Player's Hero and Storage unit.

PN is an Integer variable, it's optional, I use it here because it makes working with Player numbers easier. An example without it:
  • Example no PN
    • Events
      • Player - Player 1 (Red) types a chat message containing !6 as An exact match
    • Conditions
    • Actions
      • Hero - Give (Item carried by Player_Hero[(Player number of (Triggering player))] in slot 6) to Player_Storage[(Player number of (Triggering player))]

Note that if the Storage is full the Item will drop at it's position. Also, you need to add an Event for each Player that can use this trigger. Currently it will only work for Player 1 (Red).
And how do I link the PlayerHero variables to the respective heroes? At the beginning of the game you can choose between 87 heroes, so do I need a variable for each possible hero for each possible player choosing him?

Same with the storages: is it just the following?

Action - Set StorageNumber[1] = Storage of Player 1

and the same with every other storages? Or is there more to it?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,565
Well, how do you pick your Hero? Is it purchased from a Tavern? Do you use the classic Wisp + Circle of Power and Regions? A custom system?

I imagine it would look something like this:
  • Events
    • Unit - A hero is chosen
  • Conditions
  • Actions
    • Set VariableSet PN = Player number of (Owner of (Triggering unit))
    • Set VariableSet PlayerHero[PN] = (Triggering unit)
Obviously that Event doesn't exist, so you need to adapt it to whatever system of hero selection you're using.

Remember, there's more than one way of doing things, it all depends on how your map works.

Also, I assume your Storage units are preplaced, so during Map Initialization you can setup those variables:
  • Events
    • Map initialization
  • Conditions
  • Actions
    • Set VariableSet PlayerStorage[1] = Player 1's storage unit
    • Set VariableSet PlayerStorage[2] = Player 2's storage unit
    • Set VariableSet PlayerStorage[3] = Player 3's storage unit
    • Set VariableSet PlayerStorage[4] = Player 4's storage unit
    • etc...
If you create the Storage units with triggers then you can use (Last created unit) to reference them.
 
Last edited:
Level 2
Joined
Mar 1, 2022
Messages
3
Thank you very much for your help! I tried it with the way the heros go from the selection region to their base and it worked brilliantly. Again, thank you so much!
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,565
Thank you very much for your help! I tried it with the way the heros go from the selection region to their base and it worked brilliantly. Again, thank you so much!
You're welcome, and keep in mind that you can use these variables for any future triggers. The PlayerHero[] variable creates this relationship where as long as you have a Player you also have access to their Hero and as long as you have access to a Hero you also have their Player. It's this link that makes any trigger you create have far greater control and utility.

It's even more useful with the Pick Every Player action and Player Group variables. You can use these Player Groups to contain your different Players and break them up into teams, which should serve useful in a MOBA. There's also the Pick Every Unit action and Unit Group variables which are just as useful if you want to track/modify groups of Units instead of Players.

If I were to make a MOBA, let's use DotA as an example, I'd have two Player Groups: Scourge and Alliance.
Then I'd have two Unit Groups: ScourgeHeroes and AllianceHeroes.

This way I'm tracking everything important. From there, all of your future triggers will have easy access to the Heroes/Players at any given moment. Alliance wins the game? Pick every player in the Alliance player group and give them Victory while doing the opposite to the players in the Scourge player group.

Using these methods will create a strong foundation for your triggers which will benefit any future triggers you create. In a map like a MOBA where everyone is subject to the same experience, albeit slightly different due to having different heroes, these methods are vital!
 
Last edited:
Status
Not open for further replies.
Top