• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

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