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

Status
Not open for further replies.
Level 5
Joined
Jul 17, 2006
Messages
145
alright here is what i have so far:
  • Actions
    • Set Random_Hero = 10
    • Set Hero_Array[1] = Captain Rodger
    • Set Hero_Array[2] = Captain Will
    • Set Hero_Array[3] = Captain Hapo
    • Set Hero_Array[4] = Captain Bonez
    • Set Hero_Array[5] = Captain Nick
    • Set Hero_Array[6] = Captain Kasith
    • Set Hero_Array[7] = Captain Henry
    • Set Hero_Array[8] = Captain Neron
    • Set Hero_Array[9] = Captian Eritheg
    • Set Hero_Array[10] = Captian Gemros
  • RC command
    • Events
      • Player - Player 3 (Teal) types a chat message containing -rc as An exact match
    • Conditions
      • CommandLock Equal to False
    • Actions
      • Game - Display to (All players) the text: |c0000FF00Random Ca...
      • For each (Integer A) from 3 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) slot status) Equal to Is playing
            • Then - Actions
              • Set Random_Hero = (Random integer number between 1 and Hero_Count)
              • Unit - Create 1 Hero_Array[Random_Hero] for (Player((Integer A))) at ((Player((Integer A))) start location) facing Default building facing degrees
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Owner of (Last created unit)) is an ally of Player 1 (Red)) Equal to True
                • Then - Actions
                  • Unit - Move (Last created unit) instantly to (Center of SouthRespawn <gen>)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Owner of (Last created unit)) is an ally of Player 2 (Blue)) Equal to True
                • Then - Actions
                  • Unit - Move (Last created unit) instantly to (Center of NorthRespawn <gen>)
                • Else - Actions
              • Set Captian[(Player number of (Owner of (Last created unit)))] = (Unit-type of (Last created unit))
              • Set PlayerBoat[(Player number of (Owner of (Last created unit)))] = (Last created unit)
              • Unit - Remove (Random unit from (Units owned by (Owner of (Last created unit)) of type Hero Selecter)) from the game
              • Hero - Create Bowmen Crew and give it to (Last created unit)
              • Camera - Pan camera for (Owner of (Last created unit)) to (Position of (Last created unit)) over 1.00 seconds
            • Else - Actions
              • Do nothing

this works fine, but when used there is a possibility that someone will get the same hero as someone else. is there any way to prevent that?
 
Last edited by a moderator:
Level 11
Joined
Jul 12, 2005
Messages
764
You messed sthg up with the variables. You use Random_Hero to setup the max number of heroes, but the second trigger uses Hero_Count as the limit...

Set Random_Hero = 10 -->this is in the first trig
...
And in the second trig:
Set Random_Hero = (Random integer number between 1 and Hero_Count)

???
 
Level 5
Joined
Jul 17, 2006
Messages
145
whoops lol well i had it right before and i messed around with it and now its not right.

here:

  • Actions
    • Set Hero_Count = 10
    • Set Hero_Array[1] = Captain Rodger
    • Set Hero_Array[2] = Captain Will
    • Set Hero_Array[3] = Captain Hapo
    • Set Hero_Array[4] = Captain Bonez
    • Set Hero_Array[5] = Captain Nick
    • Set Hero_Array[6] = Captain Kasith
    • Set Hero_Array[7] = Captain Henry
    • Set Hero_Array[8] = Captain Neron
    • Set Hero_Array[9] = Captian Eritheg
    • Set Hero_Array[10] = Captian Gemros
and as for the trigger tags, i thought you guys took them out. one day i came here and they dident seem to work and the buttons werent on the reply interface.

*edit* like right now im looking at it and the trigger tags arent working... :/
 
Level 2
Joined
Mar 9, 2005
Messages
19
why dont u just give all heroes in region and make a trigger to pick random unit from group and then do change owner and move to your new region. Wont even need a variable!
 
Level 11
Joined
Jul 12, 2005
Messages
764
Include some boolean variables in the trigger to check if the randommed hero is already out. Put the whole thing into a loop, written in jass:

Custom script - loop
Custom script - exitwhen udg_<HeroVar> != null
//Put the things in here
Custom script - endloop

This is just the beginning. If you manage to build up the system on your own from this, bravo then. If not, i'll write a trigger for you and send it next time.

This is the best situation to show how easier to use jass, when it comes to systems.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,191
To do it simply while keeping it random, use jass.

JASS:
function RUH takes integer i returns integer
    local integer l
    local integer h
    if udg_Hero_Array_Boolean[i] == false then
        set h = udg_Hero_Array[i]
        set udg_Hero_Array_Boolean[i] = true
    else
        set l = i
        loop
            if l == 10 then //set this to the size of the array (last number with hero type)
                set l = 1//set this to the first number in your hero array that contains a hero type.
            else
                set l = l+1
            endif
            if udg_Hero_Array_Boolean[l] == false then
                set h = udg_Hero_Array[l]
                set udg_Hero_Array_Boolean[l] = true
            endif
            exitwhen h != 0
        endloop
    endif
    return h
endfunction

Please inform me if there are any syntax mistakes in the jass script above.

This function I created requires you to make a global boolean array called Hero_Array_Boolean which has the same size as the Hero_Array
Basicly all you need to do is call this with a random integer from 1-10 and it will return a random hero (in unit type form (integer)) while making sure each player gets a unique hero (NEVER FAILS).
It is in jass so you have to learn some basic jass inorder to use it.
If you want to add/remove heroes, you need to make sure that you change the noted variable.

To use just paste it in your custom script section and call.

how to use?
For each player simply call this with a random integer and then make the unit from the integer it returns (it returns a unit type (integer)).

Note for moderators.
I am awair that this topic is in the GUI sections and that I am refering to jass but this was the easiest method I could think of to solve the problem so please do not be annoyed at me since I am only trying to help solve his problem and at anytime I will remove the jass if told to.
 
Level 11
Joined
Jul 12, 2005
Messages
764
Ok, here's the map:
It has 3 types of Random Hero Selection, two of them uses the jass loop, one of them is fully in GUI. All of them works, but the most reliable, and fastest is the third one, so i recommend that one. Not hard to implement.
I also included a random-hero creation for every single player (When they type -rh they will get a random hero).
 

Attachments

  • RandomHeroSystem.w3x
    18 KB · Views: 97
Status
Not open for further replies.
Top