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

Peasent is Carrying Resouces

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Isn't there any kind of Animation comparison? You could do it detecting when the unit plays the Gold Gather animation (or however it's called, or its index).
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Ok... Do this:

Place a gold mine, and one worker, and a townhall to deliver the gold.

Every 0.5 second of game time
Game - Display Text -> Current order of YourWorker <gen>

That way you can know what's the worker doing, and what changes when he goes inside and outside the gold mine.


EDIT: If you "right click" the mine, the order is "smart". When the worker gets out of the mine carrying the gold, the action is "resume harvesting", same than "return resources" actions. When you order "harvest" the unit, the action is "harvest". Same happens with trees.

You would have to add peasants to a unit group, and pick every 0.03 segs every unit in that unit group, and if the action is "resume harvest" and the unit is in (Units within xxxx distance from Unit of Type Gold Mine) then-> Give the item. Of course, removing the leaks.

EDIT2: This may work. It has leaks and it's poorly done (it's 2:20am) but may give you a clue. Just like it's, it creates the item only if the worker is really near to the gold mine right after he leaves the gold mine.

EDIT3: Tried to fix triggers a bit.

EDit 4: Map added

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Melee Game - Create starting units (for all players)
      • Unit - Create 1 Peasant for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Set GoldMines = (Units of type Gold Mine)
      • Hashtable - Create a hashtable
      • Set MineHash = (Last created hashtable)
  • Untitled Trigger 002
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Peasant
    • Actions
      • Unit Group - Add (Triggering unit) to Peasants
  • Untitled Trigger 001
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (String((Current order of (Last created unit))))
      • Unit Group - Pick every unit in Peasants and do (Actions)
        • Loop - Actions
          • Set Unit = (Picked unit)
          • Custom script: set udg_i = GetHandleId(udg_Unit)
          • Set TPoint = (Position of Unit)
          • Set TGroup = (Units within 325.00 of TPoint matching ((Unit-type of (Matching unit)) Equal to Gold Mine))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in TGroup) Greater than 0
              • (Current order of Unit) Equal to (Order(resumeharvesting))
              • (Load 0 of i from MineHash) Equal to False
            • Then - Actions
              • Hero - Create Claws of Attack +15 and give it to Unit
              • Hashtable - Save True as 0 of i in MineHash
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in TGroup) Greater than 0
              • (Current order of Unit) Equal to (Order(harvest))
              • (Load 0 of i from MineHash) Equal to True
            • Then - Actions
              • Hashtable - Save False as 0 of i in MineHash
            • Else - Actions
          • Custom script: call RemoveLocation(udg_TPoint)
          • Custom script: call DestroyGroup(udg_TGroup)
I'm not sure, but I guess this is needed to avoid storing unneeded unit data.

  • Untitled Trigger 003
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Peasant
    • Actions
      • Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in MineHash
Doesn't work always. May stop working for one or two trips (Of returning gold) if you give a different order during the process. Don't have the time right now to check why it doesn't work when you interrupt the action (It's 2:36am now)
 

Attachments

  • Simple test.w3x
    19.1 KB · Views: 42
Last edited:
Level 29
Joined
Mar 10, 2009
Messages
5,016
@supertoinkz
Im not talking about ReturnHarvest but 'during' the harvest of trees, the order
will be checked all the time and the real will be set to "0" everytime...it will really
work but I have another idea...

Here Gallin, try this...
  • ReturnHarvest
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Peasant
    • Actions
      • Custom script: local integer o = GetUnitCurrentOrder(GetTriggerUnit())
      • Custom script: if o==852018 then
      • -------- actions come here --------
      • Custom script: call BJDebugMsg(I2S(o))
      • Custom script: endif
the 852018 is the order spell/id of the harvest...
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Depends... If the unit is ordered "resumeharvesting" and has a tree really near to him, you can say that he was harvesting a tree.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
  • Destructible - Pick every destructible within 256.00 of (Center of (Playable map area)) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
        • Then - Actions
        • Else - Actions
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
M... You would have to pick every unit around the townhall and check if the current order is "resumeharvesting" and give the item, but couldn't know if the unit harvested gold or wood, unless you check that before.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I don't know if you can give Townhall the Inventory Ability... Anyway, you can remove the item from the peasant, and create it in the Townhall. Is "easier" than actually giving the item.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
After the peasants return the resources, the most common action they would do is "harvest". The same way I did the triggers to detect if the unit was harvesting gold, or tree, you could detect if the unit is ordered to harvest and has a near town hall
 
Status
Not open for further replies.
Top