• 🏆 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] Spawning same item!

Status
Not open for further replies.
Level 5
Joined
Jul 17, 2010
Messages
140
Heey im trying to make a chest throw down a random item from a group table i make, but i drops the same item every time??
Any suggestions on what it is?

This is the Items that should be randomly dropped
Code:
Glove Items Table
    Events
        Map initialization
    Conditions
    Actions
        Set Glove_Items[0] = |cFFC000C0Nightslayer Gloves|r
        Set Glove_Items[1] = |cffc000c0Acherus Knight´s Gloves|r
        Set Glove_Items[2] = |cFFC000C0Lawbringer Gauntlets|r
        Set Glove_Items[3] = |cFFC000C0Gauntlets of Might|r
        Set Glove_Items[4] = |cFFC000C0Felheart Gloves|r
        Set Glove_Items[5] = |cFFC000C0Earthfury Gauntlets|r
        Set Glove_Items[6] = |cFFC000C0Cenarion Gloves|r
        Set Glove_Items[7] = |cFFBB00DDGloves of Prophecy|r
        Set Glove_Items[8] = |cFFBB00DDArcanist Gloves|r
        Set Glove_Items[9] = |cff3464e0Adventurers Gloves|r
        Set Glove_Items[10] = |cff3464e0Adventurers Gloves|r

This is the trigger to drop the random item in the selected table.
Code:
Open Chest
    Events
        Unit - A unit Is attacked
    Conditions
        (Unit-type of (Attacked unit)) Equal to Chest
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Attacked unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True
            Then - Actions
                Animation - Play (Attacked unit)'s stand - 2 animation
                Unit - Change ownership of (Attacked unit) to Neutral Passive and Change color
                Unit - Remove Chest Mark Showing (+1) from (Attacked unit)
                Item - Create Glove_Items[(Random integer number between 0 and 10)] at ((Position of (Attacking unit)) offset by (100.00, 0.00))
                Animation - Reset (Attacked unit)'s animation
            Else - Actions

-Thanks in advance!
 
Level 7
Joined
Mar 10, 2013
Messages
366
Use the
Code:
[trigger][/trigger]
bbtags instead of the code ones.

Set this random integer into a variable and make it show to all players to see if you're getting random numbers correctly
 
There is an option in World Editor - file - Preference - Map Testing - use fixed Random.

I actually did not know that option exists...



To do:
(Note: variables encased in <> are arbitrary)

Generate a global point variable:
<point_var>
Generate two global unit variables:
<unit_var1>
<unit_var2>

  • Custom Script: local location loc2
  • Set <unit_var1> = (Attacking Unit)
  • Set <unit_var2> = (Triggering unit)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • ((Attacked unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True
    • Then - Actions
      • Set <point_var> = (Position of <unit_var1>)
      • Animation - Play <unit_var2>'s stand - 2 animation
      • Unit - Change ownership of <unit_var2> to Neutral Passive and Change color
      • Unit - Remove Chest Mark Showing (+1) from <unit_var2>
      • Custom Script: set loc2 = udg_<point_var>
      • Custom Script: set udg_<point_var> = Location(GetLocationX(loc2) + 100, GetLocationY(loc2))
      • Item - Create Glove_Items[(Random integer number between 0 and 10)] at <point_var>)
      • Animation - Queue <unit_var2>'s animation
      • Custom Script: call RemoveLocation(udg_<point_var>)
      • Custom Script: call RemoveLocation(loc2)
      • Custom Script: set loc2 = null
    • Else - Actions
 
Level 5
Joined
Jul 17, 2010
Messages
140
I actually did not know that option exists...



To do:
(Note: variables encased in <> are arbitrary)

Generate a global point variable:
<point_var>
Generate two global unit variables:
<unit_var1>
<unit_var2>

  • Custom Script: local location loc2
  • Set <unit_var1> = (Attacking Unit)
  • Set <unit_var2> = (Triggering unit)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • ((Attacked unit) belongs to an enemy of (Owner of (Attacking unit))) Equal to True
    • Then - Actions
      • Set <point_var> = (Position of <unit_var1>)
      • Animation - Play <unit_var2>'s stand - 2 animation
      • Unit - Change ownership of <unit_var2> to Neutral Passive and Change color
      • Unit - Remove Chest Mark Showing (+1) from <unit_var2>
      • Custom Script: set loc2 = udg_<point_var>
      • Custom Script: set udg_<point_var> = Location(GetLocationX(loc2) + 100, GetLocationY(loc2))
      • Item - Create Glove_Items[(Random integer number between 0 and 10)] at <point_var>)
      • Animation - Queue <unit_var2>'s animation
      • Custom Script: call RemoveLocation(udg_<point_var>)
      • Custom Script: call RemoveLocation(loc2)
      • Custom Script: set loc2 = null
    • Else - Actions

Why is it better to put attacking and attacked unit in a variable?
 
Status
Not open for further replies.
Top