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

peasant mining gold mine -> give item to gold mine

Status
Not open for further replies.
Level 4
Joined
Mar 12, 2008
Messages
89
hello, I have a problem.....I need when unit (peasant) mining gold mine to make 0,1% chance to create item into a gold mine inventory thanks
 
Level 3
Joined
Jun 3, 2004
Messages
19
add this to your map initialisation trigger

Actions
_ Unit Group - Pick every unit in (Units of type Gold Mine) and do (Actions)
_ _ Loop - Actions
_ _ _ Set Int_C = (Int_C + 1)
_ _ _ Set Mine[Int_C] = (Picked unit)
_ _ _ Unit - Set the custom value of (Picked unit) to (Resource quantity contained in (Picked unit))


and create this trigger

Prospecting
_ Events
_ _ Time - Every 0.50 seconds of game time
_ Conditions
_ Actions
_ _ For each (Integer A) from 1 to Int_C, do (Actions)
_ _ _ Loop - Actions
_ _ _ _ If (All Conditions are True) then do (Then Actions) else do (Else Actions)
_ _ _ _ _ If - Conditions
_ _ _ _ _ _ (Custom value of Mine[(Integer A)]) Greater than (Resource quantity contained in Mine[(Integer A)])
_ _ _ _ _ _ (Random integer number between 1 and 1000) Equal to 7
_ _ _ _ _ Then - Actions
_ _ _ _ _ _ Item - Create Gem Fragment at (Position of Mine[(Integer A)])
_ _ _ _ _ _ Hero - Give (Last created item) to Mine[(Integer A)]
_ _ _ _ _ Else - Actions
_ _ _ _ Unit - Set the custom value of Mine[(Integer A)] to (Resource quantity contained in Mine[(Integer A)])


Int_C = integer (default 0), Mine = unit array
:)

Though if the gold mine is neutral, you're not going to get that gem out of there, better off to just create it at the position of the mine and let it automatically place at the side. If you meant create the item in the worker's inventory, I'm not sure how to detect a unit that is carrying gold. You could give the item to the nearest worker, or a worker within range, but that may not select the worker that just left it.


EDIT:
Ah, okay. Here's an updated version that will give the item to the miners, and will only work for miners, not wisps or acolytes. The downside is however that it will not be detected when the worker is issued an order whilst inside the mine, only when they are allowed to "resumeharvesting" by default. Then again, if it's a 0.1% chance of a gem dropping, this will be hardly noticeable. This also removes the necessity of the first trigger.

Prospecting
Events
Unit - A unit Is issued an order targeting an object
Conditions
(Issued order) Equal to (Order(resumeharvesting))
(Random integer number between 1 and 1000) Equal to 7
Actions
Item - Create Gem Fragment at (Position of (Triggering unit))
Hero - Give (Last created item) to (Triggering unit)

....
Though
Harvesting lumber uses the same order string -_-.
If you use this trigger you'll have to add a unit-type condition as well, and make sure that unit type can only harvest gold. ack -_-
 
Last edited:
Level 9
Joined
Apr 3, 2008
Messages
700
  • Conditions
    • (Issued order) Equal to (Order(returnresources))
  • Actions
    • Set i = (Random integer number between 1 and 10)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • i Equal to 1
      • Then - Actions
        • Hero - Create AnyItem and give it to (MineGlobalVariableUnit)
      • Else - Actions
 
Level 4
Joined
Mar 12, 2008
Messages
89
mr__coolies u r right It works
Day Elven ur trigger doesn´t works
but I am giving rep to all who helps me
SOLVED!
 
Status
Not open for further replies.
Top