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

[Solved] Item Drop Problem

Status
Not open for further replies.
Level 6
Joined
Apr 1, 2009
Messages
201
I can't figure out what is wrong with this.... The problem is every time and every game the same random integer between 1-100 occurs. It is 3,29,25,3,23,43,88. You can restart the game and even exit the game and start it up but you get the same numbers every time. If I change the random integer from 1-100 to anything else I get different numbers but reoccurring every time.

1st Trigger - Setup
The first trigger sets what my variables are equal to
  • Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Player and Player's Inventory --------
      • Set PlayerGroupOne[1] = Player 1 (Red)
      • Set PlayerInventory[1] = Player 1 Inventory <gen>
      • Set PlayerGroupOne[2] = Player 2 (Blue)
      • Set PlayerInventory[2] = Player 2 Inventory <gen>
      • Set PlayerGroupOne[3] = Player 3 (Teal)
      • Set PlayerInventory[3] = Player 3 Inventory <gen>
      • Set PlayerGroupOne[4] = Player 4 (Purple)
      • Set PlayerInventory[4] = Player 4 Inventory <gen>
      • Set PlayerGroupOne[5] = Player 5 (Yellow)
      • Set PlayerInventory[5] = Player 5 Inventory <gen>
      • Set PlayerGroupOne[6] = Player 6 (Orange)
      • Set PlayerInventory[6] = Player 6 Inventory <gen>
      • Set PlayerGroupOne[7] = Player 7 (Green)
      • Set PlayerInventory[7] = Player 7 Inventory <gen>
      • Set PlayerGroupOne[8] = Player 8 (Pink)
      • Set PlayerInventory[8] = Player 8 Inventory <gen>
      • -------- Unit Loot and Unit --------
      • Set TriggerLootUnitType[1] = Wolf (Loot)
      • Set TriggerLootType[1] = Wolf <gen>
2nd Trigger - The Ability
When you cast the ability on the corpse of the unit it finds which unit it is from my setup and then runs which trigger that unit is associated with
  • Loot
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Loot [G]
    • Actions
      • Set LootCaster = (Owner of (Triggering unit))
      • For each (Integer TriggerUnitLootInt) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Target unit of ability being cast)) Equal to TriggerLootUnitType[TriggerUnitLootInt]
            • Then - Actions
              • Unit - Remove (Target unit of ability being cast) from the game
              • Trigger - Run TriggerLootType[TriggerUnitLootInt] (checking conditions)
            • Else - Actions
3rd Trigger - Item Drop Chances
This trigger is run off the previous one according to which unit variable it was and sets the item drop chance and what each % chance has to drop. The "DropChanceInt" Sets the drop chance. Then after the condition it moves the item to the players inventory region. It's part of a system I'm developing.
  • Wolf
    • Events
    • Conditions
    • Actions
      • For each (Integer LootingInt) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LootCaster Equal to PlayerGroupOne[LootingInt]
            • Then - Actions
              • Set DropChanceInt = (Random integer number between 1 and 100)
              • Game - Display to (All players) the text: (String(DropChanceInt))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • DropChanceInt Greater than or equal to 1
                  • DropChanceInt Less than or equal to 5
                • Then - Actions
                  • Set PlayerInventoryRegion = (Center of PlayerInventory[LootingInt])
                  • Item - Create Wolf Fur at PlayerInventoryRegion
                  • Item - Create Wolf Meat at PlayerInventoryRegion
                  • Item - Create Wolf Claw at PlayerInventoryRegion
                  • Item - Create Gold (Full) at PlayerInventoryRegion
                  • Custom script: call RemoveLocation(udg_PlayerInventoryRegion)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • DropChanceInt Greater than 5
                  • DropChanceInt Less than or equal to 15
                • Then - Actions
                  • Set PlayerInventoryRegion = (Center of PlayerInventory[LootingInt])
                  • Item - Create Wolf Fur at PlayerInventoryRegion
                  • Item - Create Wolf Fur at PlayerInventoryRegion
                  • Custom script: call RemoveLocation(udg_PlayerInventoryRegion)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • DropChanceInt Greater than 15
                  • DropChanceInt Less than or equal to 30
                • Then - Actions
                  • Set PlayerInventoryRegion = (Center of PlayerInventory[LootingInt])
                  • Item - Create Wolf Claw at PlayerInventoryRegion
                  • Custom script: call RemoveLocation(udg_PlayerInventoryRegion)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • DropChanceInt Greater than 30
                  • DropChanceInt Less than or equal to 50
                • Then - Actions
                  • Set PlayerInventoryRegion = (Center of PlayerInventory[LootingInt])
                  • Item - Create Wolf Meat at PlayerInventoryRegion
                  • Item - Create Bones at PlayerInventoryRegion
                  • Custom script: call RemoveLocation(udg_PlayerInventoryRegion)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • DropChanceInt Greater than 50
                  • DropChanceInt Less than or equal to 100
                • Then - Actions
                  • Do nothing
                • Else - Actions
            • Else - Actions

If any of this is unclear or you would like the test map just let me know.
 
Last edited:
Level 3
Joined
Nov 16, 2011
Messages
54
Uncle Google is your friend
Random Number always giving the same number - Ever test a map, only to find out that randomness is always the same (the random hero is always the same, or the random chance is always the same)? This can easily be fixed by going into File -> Preferences -> Test Map, and unchecking the "Use Fixed Random Seed" box.
 
Status
Not open for further replies.
Top