• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Percentage Item Drops?

Status
Not open for further replies.
Level 12
Joined
Jun 10, 2008
Messages
1,043
I was wondering if its possible (without JASS) to make a set unit-type drop a specific item-type based on percentage, like, for example, the unit has a 30% chance to drop a "Trollslayer Sword", 50% chance to drop a "Steel Sword", 20% chanc to drop a "Destroyer Sword." And also, would i have to add up to 100% or, could they drop multiple items with each item having a set %age (EX: Trollslayer 70%, Steel Sword 90%, Destroyer Sword 20%), where the other left over percent would be dropping nothing?

Sorry if its confusing, can't think of any other way to describe it though. Basically, can you make units drop weapons based on a percentage of weapon drops, and if you can, how?
 
@ Stygian Shadow

There is a relatively easy GUI way to do it. I'll give example from my map

This trigger shows a complete way for multiple item drops. It is the actual trigger from my map (I'll replace the names with others so it makes more sense. Look for ALL CAPS)
  • Events
    • Unit - A unit Dies
  • Conditions
  • Actions
    • Set LOCATION = (Position of (Dying unit)) //SET LOCATION HERE
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Or - Any (Conditions) are true
          • Conditions
            • (Unit-type of (Triggering unit)) Equal to UNIT 1
            • (Unit-type of (Triggering unit)) Equal to UNIT 2
            • (Unit-type of (Triggering unit)) Equal to UNIT 3
            • //DESTROY MEMORY LEAK
      • Then - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Random integer number between 1 and 100) Less than or equal to 10
          • Then - Actions
            • Item - Create ITEM 1 at LOCATION //You can add more items to this by simply copy pasting above trigger and changing for items you want dropped
          • Else - Actions
          • //If chance didnt proc it repeats for next item
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Random integer number between 1 and 100) Less than or equal to 8
              • Then - Actions
                • Item - Create ITEM 2 at LOCATION
                • //DESTROY MEMORY LEAK
              • Else - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • //You hopefully get the picture
1. You can continue this cycle as long as you want. Putting multiple items in one "then" section will make both spawn at the location

2. Make sure to remove memory leaks for whatever location you use. Set the location in the trigger where you see this //SET LOCATION HERE and set the clearer here //DESTROY MEMORY LEAK . Destroy memory leak by typing in custom script "Call RemoveLocation (udg_your_variable)" without the quotation marks.

3. If you want this trigger to be able to run multiple times in one death (get the effects from the first if/then/else and be able to get the effects of any other if/then/else at the same time), simply copy paste the trigger and change any data.

I believe that works. Hope it helped.

EDIT: I realize that adiktuz and defskull apparently answered this question a few days ago, and much simpler than I did. Here's a link
http://www.hiveworkshop.com/forums/world-editor-help-zone-98/item-drop-chance-trigger-193347/
 
Last edited:
Level 12
Joined
Jun 10, 2008
Messages
1,043
Umm, sorry but I've never done a trigger like this before - so i'm a little confused.
Wouldn't the Position of dying unit be the location? So what do I put in for the //SET LOCATION thing, and hwo do I destroy it in the DESTROY MEMORY LEAKS part?
 
By setting the location in a variable (type of variable is "point", and it is NOT an array), it allows you to delete it by using custom script, or a small snippet of JASS, to destroy the memory leak. And the reason the item is spawned at the variable is because the variable is THE EXACT SAME PLACE AS THE POSITION OF THE DYING UNIT BECAUSE YOU SET IT TO BE THE EXACT SAME PLACE

Memory Leaks are saved data that doesn't get deleted automatically when a trigger runs. For example, when you take the position of dying unit (a point), and you use it without using a variable and custom script to destroy it, you "leak" a point. This means your game will have to keep track of the point for the entire duration of the match, making it laggier and increasing chance of disconnect. Instead of letting this happen, we use a variable to store the position and then use custom script AFTER (do not EVER put before or else it erases the variable) the job is done to clear the data from the wc3 engine.


Here is an example using actual variable names
  • Events
    • Unit - A unit Dies
  • Conditions
  • Actions
    • Set Temp_point = (Position of (Triggering Unit))
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Or - Any (Conditions) are true
          • Conditions
            • (Unit-type of (Triggering unit)) Equal to Mummy
            • (Unit-type of (Triggering unit)) Equal to Villager Zombie
            • (Unit-type of (Triggering unit)) Equal to Zombie
      • Then - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Random integer number between 1 and 100) Less than or equal to 10
          • Then - Actions
            • Item - Create Health +20 at Temp_point
            • Custom script: call RemoveLocation(udg_Temp_point)
          • Else - Actions
            • Custom script: call RemoveLocation(udg_Temp_point)
In this example, when any of the three unit types die, it has a chance (1/10) to create an item called health +20 at temp point. Notice that at the START of the variable temp point was set to the position of the dying unit. After temp point was used in a function and was not needed further, I removed it by typing "call RemoveLocation(udg_Temp_point)", which basically means destroy the location Temp_point from warcraft 3's memory. As a side note, we use triggering unit in the variable because it is faster and works more efficiently (or so I'm told).

If you still don't understand how this functions, and how to use variables and custom script to remove memory leaks, just post in another comment. To gain a complete understanding of what causes memory leaks, and which things (groups, points, , special effects) can cause memory leaks, and more importantly, how to fix them, try looking up a tutorial on the subject. I'm sure that the Hive has plenty.

EDIT: If you post your triggers all nice and neat inside hidden tabs I'm sure some people will help you with the specifics of it, but make sure to post in the right area (triggers and script section)
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240
Beef_Is_Back, you leak if the item doesn't spawn :)

There are (at least) three ways of doing the drops.

1.
  • Untitled Trigger 039
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set i = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i Less than or equal to 20
        • Then - Actions
          • Set point = (Position of (Triggering unit))
          • Item - Create Claws of Attack +15 at point
          • Custom script: call RemoveLocation(udg_point)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • i Less than or equal to 50
            • Then - Actions
              • Set point = (Position of (Triggering unit))
              • Item - Create Crown of Kings +5 at point
              • Custom script: call RemoveLocation(udg_point)
            • Else - Actions
The claws have 20% chance to drop, the crown has 30% chance. Both can't drop at the same time.

2.
  • ¨If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Random integer number between 1 and 100) Less than or equal to 20
    • Then - Actions
      • Set point = (Position of (Triggering unit))
      • Item - Create Claws of Attack +15 at point
      • Custom script: call RemoveLocation(udg_point)
    • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Less than or equal to 50
        • Then - Actions
          • Set point = (Position of (Triggering unit))
          • Item - Create Crown of Kings +5 at point
          • Custom script: call RemoveLocation(udg_point)
        • Else - Actions
The claws have 20% chance to drop, the crown has 40% [ ((100-20)*50)/100 ] chance. Both can't drop at the same time.

3.
  • Untitled Trigger 039
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set i = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i Less than or equal to 20
        • Then - Actions
          • Set point = (Position of (Triggering unit))
          • Item - Create Claws of Attack +15 at point
          • Custom script: call RemoveLocation(udg_point)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i Less than or equal to 50
        • Then - Actions
          • Set point = (Position of (Triggering unit))
          • Item - Create Crown of Kings +5 at point
          • Custom script: call RemoveLocation(udg_point)
        • Else - Actions
The claws have 20% chance to drop, the crown has 50% chance. Both can drop at the same time.

You could variate 3 by rolling the random number for both items separately.
 
Status
Not open for further replies.
Top