• 🏆 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] random hero

Status
Not open for further replies.
Level 2
Joined
Nov 14, 2008
Messages
21
I have my trigger set up so when u type -random it gives u a random hero from a list of all possible heros thing is it tends to give out the same hero first i had it so i could keep doing it to make sure it wasnt stuck on one hero and it isnt just more then 90% of the time u get the same hero first...any idea how to fix tht?
 
Level 13
Joined
May 11, 2008
Messages
1,198
show me your map or variables and triggers and so on so i can figure out what you are doing. i learned how to make a random unit, and it can be done even more simply with a chat message than with my method. err...well that's my guess... let me double check.

anyway let me test it real quick and i'll get back to you in a jiffy assuming it works i'll tell you what you need.

yeah...works good. i'm just not sure what kind of condition you are going to need though. you'll have to figure that out on your own if you want to prevent them from spamming random heroes.


you need to make a variable for your map for the random units to be chosen.

set them to an array.

you need a unit type array. set the array number to however many units are going to be in this randomized chat command picking.

you should set a trigger for map initialization for setting the variable, like this:

set udg_runners_random[0] = 'uaco'
set udg_runners_random[1] = 'ushd'
set udg_runners_random[2] = 'ugho'
set udg_runners_random[3] = 'uabo'
set udg_runners_random[4] = 'umtw'
set udg_runners_random[5] = 'ucry'
set udg_runners_random[6] = 'ugar'
set udg_runners_random[7] = 'uban'
set udg_runners_random[8] = 'unec'
set udg_runners_random[9] = 'uobs'
set udg_runners_random[10] = 'ufro'
set udg_runners_random[11] = 'hfoo'
set udg_runners_random[12] = 'hkni'
set udg_runners_random[13] = 'hrif'
set udg_runners_random[14] = 'hmtm'
set udg_runners_random[15] = 'hgyr'
set udg_runners_random[16] = 'hgry'
set udg_runners_random[17] = 'hmpr'
set udg_runners_random[18] = 'hsor'
set udg_runners_random[19] = 'hmtt'
set udg_runners_random[20] = 'hspt'
set udg_runners_random[21] = 'hdhw'
set udg_runners_random[22] = 'ogru'
set udg_runners_random[23] = 'orai'
set udg_runners_random[24] = 'otau'
set udg_runners_random[25] = 'ohun'

that's jass by the way...setting it in gui isn't much different.
in jass you see the udg_ come before the variable name.
you kinda pick the units yourself instead of using the id number for the unit as you can see is in this jass trigger.

i edited a random pick trigger from my map to this:

  • random runner choice Copy
    • Events
      • Player - Player 1 (Red) types a chat message containing -random as An exact match
      • Player - Player 2 (Blue) types a chat message containing -random as An exact match
      • Player - Player 3 (Teal) types a chat message containing -random as An exact match
      • Player - Player 4 (Purple) types a chat message containing -random as An exact match
      • Player - Player 5 (Yellow) types a chat message containing -random as An exact match
      • Player - Player 6 (Orange) types a chat message containing -random as An exact match
      • Player - Player 7 (Green) types a chat message containing -random as An exact match
      • Player - Player 8 (Pink) types a chat message containing -random as An exact match
      • Player - Player 9 (Gray) types a chat message containing -random as An exact match
      • Player - Player 10 (Light Blue) types a chat message containing -random as An exact match
      • Player - Player 11 (Dark Green) types a chat message containing -random as An exact match
      • Player - Player 12 (Brown) types a chat message containing -random as An exact match
    • Conditions
    • Actions
      • Set points = (Position of (Triggering unit))
      • Unit - Create 1 runners_random[(Random integer number between 0 and 25)] for (Triggering player) at points facing Default building facing (270.0) degrees
      • Point - Remove points
and unless i forgot something, that should be all you need, besides the obvious conditions that you'll want to add and any additional actions.
 
Last edited:
Level 2
Joined
Nov 14, 2008
Messages
21
ok heres my map its under the first folder of triggers and its call random select...i have things kind of un organized right now and very basic im not very good at creating maps so i know alot of my triggers can be done with just one trigger instead of like 5 but it works for me so im sticking with it
 

Attachments

  • hoofis.w3x
    95.1 KB · Views: 53
Level 13
Joined
May 11, 2008
Messages
1,198
it looks like your problem may just be that your array for your variable is only 1, that's why it's always the same hero. you need to change that number. go into edit variables and change that array from 1-16, and do the rest of what i showed you...let me check to see what else you got.

oh, you're doing a player one chooses random thing...does that trigger work or no? eek, it looks hard to understand...anyway you need to change your math random number to just one and 16 right? that's the way my trigger is. 0-25 for thr 26 guys. so that's 26 numbers. btw 1-x and 0-x are both ok as far as i know but i like starting arrays from zero better. preference. oh and btw you'll need to create a point and remove it like i did because locations/points will crash maps.

also, i didn't double read it but i'm pretty sure under your random select trigger (which is the one you're having problems with) needs to have matching unit instead of last created unit in the conditions.

anyway if you compare your trigger to mine you'll see that yours only activates for player 1's chat message. i used to not know how to put everyone's chat message in one trigger also but all you have to do is add everyone's chat message to the events of the trigger and then for your actions or conditions you put in triggering player. so instead of saying for player one create a unit say for triggering player create a unit.

those are just tips in case you don't wanna start over from scratch or don't understand my example but you should be able to understand my example, just pm me or something if you don't get it.
 
Level 2
Joined
Nov 14, 2008
Messages
21
yeah everything in the map works im not sure how some of it works but it does lol ill try tht and c how it goes ill try other things to...
 
Level 13
Joined
May 11, 2008
Messages
1,198
anyway your random hero problem is definitely because your variable for your units is only set to an array of one. so change that first and take it from there.
i'm pretty sure you're going to have to change that condition i mentioned earlier, at any rate if you want to keep that condition.

edit: i'll pm you, this is crazy.
 
Level 13
Joined
May 11, 2008
Messages
1,198
whoops nevermind i can't pm cuz i can't attach pictures to pm

you need to change it here.

oh btw...forget that part about the points being set to trigger unit lol...that was an error.
(i obviously fixed just as i was about to test the map and then forgot to change it) just set it to a region of yours.
 

Attachments

  • Clipboard02.jpg
    Clipboard02.jpg
    63 KB · Views: 90
  • Clipboard03.jpg
    Clipboard03.jpg
    108.2 KB · Views: 81
Status
Not open for further replies.
Top