• 🏆 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] All Random Help

Status
Not open for further replies.
Level 3
Joined
Dec 20, 2008
Messages
19
Hello! I need help with an AR mode for my map, I just want it so that you can get a random hero by buying the Random Hero option. And im not exactly sure how to do this. PLz help
Heres my code

  • Human Random
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Random_Heros[1] = Paladin
      • Set Random_Heros[2] = Archmage
      • Set Random_Heros[3] = Mountain King
      • Set Random_Heros[4] = Blood Mage
      • Set Random_Heros[5] = Keeper of the Grove
      • Set Random_Heros[6] = Priestess of the Moon
      • Set Random_Heros[7] = Demon Hunter
      • Set Random_Heros[8] = Warden
      • Set Random_Heros[9] = Corrupt Treant
  • Heros red
    • Events
      • Unit - A unit owned by Player 1 (Red) Acquires an item
    • Conditions
      • (Item being manipulated) Equal to (Item carried by (Triggering unit) of type Random Hero)
    • Actions
      • Set Random_Heros[1] = (Unit-type of (Triggering unit))
      • Unit - Create 1 Random_Heros[(Random integer number between 1 and 1)] for Player 1 (Red) at (Center of Random Hero 1 <gen>) facing Default building facing degrees
What am i doing wrong?
 
Last edited by a moderator:
Level 10
Joined
Mar 16, 2009
Messages
354
Events
Unit - Generic unit event - A unit aquires an item
Conditions
(Item being manipulated) Equal to (Item carried by (Triggering unit) of type Random Hero)
Actions
Set RandomHeroSelect(variable) = Random integer between 1 and 9
If / Then / Else - If (RandomHeroSelect(variable) equal to 1) then do (Trigger - Run (the trigger to get hero 1) (igroning conditions) else do nothing
If / Then / Else - If (RandomHeroSelect(variable) equal to 2) then do (Trigger - Run (the trigger to get hero 2) (igroning conditions) else do nothing
If / Then / Else - If (RandomHeroSelect(variable) equal to 3) then do (Trigger - Run (the trigger to get hero 3) (igroning conditions) else do nothing
If / Then / Else - If (RandomHeroSelect(variable) equal to 4) then do (Trigger - Run (the trigger to get hero 4) (igroning conditions) else do nothing

Tested and works if you have problems message me ^^
 
Level 3
Joined
Dec 20, 2008
Messages
19
Huh no it did not >_< im not sure what im doing wrong heres my code again
  • Hero red
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item being manipulated) Equal to (Item carried by (Triggering unit) of type Random Hero)
    • Actions
      • Set Randomheroselect = (Random integer number between 1 and 4)
      • If (Randomheroselect Equal to 1) then do (Trigger - Run Paladin red <gen> (ignoring conditions)) else do (Do nothing)
      • If (Randomheroselect Equal to 2) then do (Trigger - Run Archmage red <gen> (ignoring conditions)) else do (Do nothing)
      • If (Randomheroselect Equal to 3) then do (Trigger - Run Bloodmage red <gen> (ignoring conditions)) else do (Do nothing)
      • If (Randomheroselect Equal to 4) then do (Trigger - Run Mountain red <gen> (ignoring conditions)) else do (Do nothing)
  • Paladin red
    • Events
    • Conditions
      • (Player 1 (Red) slot status) Equal to Is playing
    • Actions
      • Unit - Create 1 Paladin for Player 1 (Red) at (Center of Random Hero 1 <gen>) facing Default building facing degrees
  • Archmage red
    • Events
    • Conditions
      • (Player 1 (Red) slot status) Equal to Is playing
    • Actions
      • Unit - Create 1 Archmage for Player 1 (Red) at (Center of Random Hero 1 <gen>) facing Default building facing degrees
  • Bloodmage red
    • Events
    • Conditions
      • (Player 1 (Red) slot status) Equal to Is playing
    • Actions
      • Unit - Create 1 Blood Mage for Player 1 (Red) at (Center of Random Hero 1 <gen>) facing Default building facing degrees
  • Mountain red
    • Events
    • Conditions
      • (Player 1 (Red) slot status) Equal to Is playing
    • Actions
      • Unit - Create 1 Mountain King for Player 1 (Red) at (Center of Random Hero 1 <gen>) facing Default building facing degrees
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Those triggers makes less sense, at least parts of it.

You did the right thing in the beginning, rather than doing it more complex in your second post right above.

The issue would first come if the item you have is a powerup. In those cases the item is used instantly, thus, the unit would not have the item. If not, then fine, but then you should remove the item once it has been hold.

The second issue would be (replying to your first post) is that you
  • Set Random_Heros[1] = (Unit-type of (Triggering unit))
now, that would replace your initalized setting of that type being a Paladin, and replace it with your "buying units unit id". That will mess alot up.

This is what I suggest instead. (Leave the "Human Random" trigger as it is.)
  • Buy Random Hero
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Item-type of (Sold Item)) Equal to Random Hero
    • Actions
      • -------- Dont forget leaks --------
      • Set point = (Center of Random Hero 1 <gen>)
      • -------- Create unit using random number and the unittypes you declared in the map init trigger. --------
      • Unit - Create 1 Random_Heros[(Random integer number between 1 and 9)] for (Owner of (Buying unit)) at point facing Default building facing degrees
      • -------- Clear up leaks --------
      • Custom script: call RemoveLocation( udg_point )
Very simple, and should work =)
 
Last edited:
Level 10
Joined
Mar 16, 2009
Messages
354
yeah i would use ecchos condition, the actions work fine and i tested them its just you dont have the right condition(the condition only worked with perminent class items).
testing to find a better condition replying when i find one

EDIT: ok use this condition (Item-type of (item carried by (triggering unit) in slot 1)) Equal to Random Hero
if the item is a power up this wont work the item has to be one that actually appears in the inventory

or use the Event a unit sells an item and Condition (Item-type of (Sold Item)) Equal to Random Hero like eccho suggested
 
Level 9
Joined
Jun 7, 2008
Messages
440
Wouldn't it be easier to add all Heros to a unitgroup? Then just create a random unit from that group, and remove the created unit from it?
  • Actions
    • Set Allrandom_Hero = (random unit from (HEROS)
    • Unit - Create 1 unit of type (Allrandom_Hero) at (location) facing default building degrees
    • Unit-group - Remove Allrandom_Hero from (HEROS)
    • Set Allrandom_Hero = no unit
 
Status
Not open for further replies.
Top