• 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.

Chat Message Based Commands for New Map

Status
Not open for further replies.
Level 2
Joined
Apr 18, 2011
Messages
11
Well i've done most of the trigger work on my new map now, but i cannot figure out how to make triggers with chat message based events work.

Most importantly i need an efficient trigger for a random system, as when a player types -random and they are on the allience side, they are given a random allience hero and if a player on the horde side types -random, they are given a random horde heroe. (For some reason my trigger just picked the same hero each time.) I also need it so that when that hero is selected by random, it cannot be picked from the hero selector shop or selected by random again. If possible i would like to use a -repick trigger also.




Secondly i would like to add a -swap function so that when a player types -swap(colour of player on his side) and the player of that colour types -swap in return, ownership is switched between their 2 heroes.


Thanks in advance for help!
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
-random. You divide it into parts, which work only if the triggeringplayer is on the corosponding side.
You basically make 2 sets of heroes, 1 for each side. Everytime one is randomly choose, you remove it from the set and choose another random element.

The swap purly swaps unit ownership and then changes which side the player is classed as.

A random set is done by storing units in an arraylist and replacing the removed element (random hero) with the last element and decrementing the arraylist size.
 
Level 2
Joined
Apr 18, 2011
Messages
11
Thanks, but i'm still not able to create a working random trigger, it always creates the same hero type. I would be extremely grateful if somebody could create a test map.
 
Level 5
Joined
Sep 1, 2010
Messages
168
Simply put, create a unit array for each force with the available heroes and when player types a chat message that matches exactly "-random", check whether he's an ally of this or that side, then save a random integer number between 0 and the last filled in your unit array.
Create one unit of (unitarray[number]) for triggering player, then make that unit unavailable for training for each player.
next is to move all units in the array that are coming after the randomed number to move 1 number down in the array and reducing the max.number for your random by 1.

If you don't make a repick command, that's it. If you add repick too, you need to make the picked unit available for training again and add it to the proper tavern or whatever you use for selling as well as add it in the unit array at the end and increase the random max number by one again.

Hope this explains it well enough; if not, feel free to ask what I've explained messy (basically this is the same as Dr Super Good said with less words).

As for always creating the same hero again and again: if you're testing your map form world edit, there may be a function activated which sets randoms to always create the same random number.. if you can't find where this option is, simply test again firectly from your map folder in warcraft 3, then it should work.
 
Status
Not open for further replies.
Top