• 🏆 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] Drop item after killed an units with percentage

Status
Not open for further replies.
Level 2
Joined
Jun 22, 2012
Messages
5
please anyone give me a trigger for add some percentage of an item will drop if i kill a units. ex: footman will drop a gold coin with 10% drop chance to drop the gold coin itself. i really need it for my project
 
Level 9
Joined
Apr 19, 2011
Messages
447
Don't worry, that's very easy.
This is what I would do:


  • Drop Item
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to [YOUR UNIT HERE]
    • Actions
      • Set RANDOM = (Random integer number between 1 and 10)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If: Conditions
          • RANDOM Lesser than or equal to 1
        • Then: Actions
          • Set LEAK = (Position of (Triggering unit))
          • Item - Create [YOUR ITEM HERE] at LEAK
          • Custom script: call RemoveLocation(udg_LEAK)
        • Other: Actions
LEAK -> Point variable
RANDOM -> Integer variable

Put in [YOUR UNIT HERE] the unit type you want to drop the item, and put the item itself in [YOUR ITEM HERE]. If you choose a Footman, and a Gold Coin, this trigger should make every Footman that dies to have a 10% chance of droping a Gold Coin.
You can change the value in the condition [RANDOM is Lesser than or equal to X] to modify the chances of dropping.

If you want only certain units to drop the item, not all of them, you could add them to a unit group, and when a unit of that type dies, check if it's included in that unit group.
Also, if the item is going to be dropped by, for example, just one unit; you could use the [Specific Unit Event] instead of [Generic Unit Event].

Maybe there's an easier way to do it, but this should work fine.

Regards
 
Level 2
Joined
Jun 22, 2012
Messages
5
Don't worry, that's very easy.
This is what I would do:


  • Drop Item
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to [YOUR UNIT HERE]
    • Actions
      • Set RANDOM = (Random integer number between 1 and 10)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If: Conditions
          • RANDOM Lesser than or equal to 1
        • Then: Actions
          • Set LEAK = (Position of (Triggering unit))
          • Item - Create [YOUR ITEM HERE] at LEAK
          • Custom script: call RemoveLocation(udg_LEAK)
        • Other: Actions
LEAK -> Point variable
RANDOM -> Integer variable

Put in [YOUR UNIT HERE] the unit type you want to drop the item, and put the item itself in [YOUR ITEM HERE]. If you choose a Footman, and a Gold Coin, this trigger should make every Footman that dies to have a 10% chance of droping a Gold Coin.
You can change the value in the condition [RANDOM is Lesser than or equal to X] to modify the chances of dropping.

If you want only certain units to drop the item, not all of them, you could add them to a unit group, and when a unit of that type dies, check if it's included in that unit group.
Also, if the item is going to be dropped by, for example, just one unit; you could use the [Specific Unit Event] instead of [Generic Unit Event].

Maybe there's an easier way to do it, but this should work fine.

Regards

wow! it's really work and very helped with complete guide description!! thank you so much NarGalloth!!
hope this trigger will help the other users too.
thanks for your help,
+REP :cgrin:
 
Status
Not open for further replies.
Top