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

Detect when a peasant returns a resource?

Status
Not open for further replies.
The orders used are:
1. harvest/smart
2. resumeharvesting = issued when the peasant exits the mine or finishes harvesting lumber
3. harvest = issued after a resource is dropped

The last harvest order can be changed into something else because of shift-click/queuing orders.

Unless I'm missing an order that it isn't shown through Event - A Unit is ordered with..., I think neither of those three is a good order to detect returning of resource.
 
1st. I think that it would be impossible to detect which peasant returned a resource just by checking for a change in the player's resources.

2nd. Hmmm. That could work. The problem would be is that how would I be able to check if the peasant is carrying a resource or not?

I could check for resumeharvest but a player can queue a smart/move/other order after a peasant is done harvesting.
 
Level 12
Joined
Jan 2, 2016
Messages
973
you could make some triggers (it'd require some basic jass as well):
event 0,00 game time has passed:
select all the bases of players and create a trigger (make a function for that)
the trigger should be: when a peasent comes in range (150-200 units) from that base.
Condition: current order of the unit = harvest
make the unit hidden, start a timer for .... seconds, and when it's finished - unhide the unit.

Also make another trigger - for the trigger creating function to run every time a base is built.

And destroy the triggers when a base is destroyed.

I admit that it's not so simple task, but it can be achieved xP

I am trying to learn Jass right now, so maybe I will try to make this and will post it here if it works :)
 
Can you check for animations in GUI? Such as Stand-Gold or Walk-Lumber?

you could make some triggers (it'd require some basic jass as well):
event 0,00 game time has passed:
select all the bases of players and create a trigger (make a function for that)
the trigger should be: when a peasent comes in range (150-200 units) from that base.
Condition: current order of the unit = harvest
make the unit hidden, start a timer for .... seconds, and when it's finished - unhide the unit.

Also make another trigger - for the trigger creating function to run every time a base is built.

And destroy the triggers when a base is destroyed.

I admit that it's not so simple task, but it can be achieved xP

I am trying to learn Jass right now, so maybe I will try to make this and will post it here if it works :)

Is it even possible to get the current order of a unit?

Can you check for animations in GUI? Such as Stand-Gold or Walk-Lumber?

This. I want to know if this is possible.
 
Level 12
Joined
Jan 2, 2016
Messages
973
Okay, I finished it and it works perfectly!
I used a simpler method than I initially thought of :p

View attachment 151688

  • Disap
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(harvest))
      • (Load (Key Boolean) of (Key (Triggering unit)) from Table) Equal to True
    • Actions
      • Hashtable - Save False as (Key Boolean) of (Key (Triggering unit)) in Table
      • Custom script: call Harv_Disapear()
  • Condition
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(resumeharvesting))
    • Actions
      • Hashtable - Save True as (Key Boolean) of (Key (Triggering unit)) in Table
JASS:
function TimerEx takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = LoadUnitHandle(udg_Table, GetHandleId(t), 0)
    call PauseUnitBJ( false, u )
    call ShowUnitShow( u )
    call FlushChildHashtable(udg_Table, GetHandleId(t))
    call DestroyTimer(t)
    set t = null
    set u = null
endfunction

function TimerSt takes nothing returns nothing
    local timer t = CreateTimer()
    call SaveUnitHandle(udg_Table, GetHandleId(t), 0, GetTriggerUnit())
    call TimerStart(t, 2, false, function TimerEx)
    set t = null
endfunction

function Harv_Disapear takes nothing returns nothing
    call PauseUnitBJ( true, GetTriggerUnit() )
    call ShowUnitHide( GetTriggerUnit() )
    call TimerSt()
endfunction

EDIT: I had some suspecions that it may bug out if:
1) a player orders the unit to resumeharvesting manually, but it didn't, cuz the unit is still automatically ordered to harvest after that
2) a player orders a unit to harvest lumber while it is carrying gold (or the other way around), but it still didn't happen, as the "harvest" button is replaced with "resumeharvesting" one, while the unit is carrying resources, and the only way to order it to harvest to other material would be by ordering "smart", but that doesn't make the trigger run :)
 
Last edited:
Okay, I finished it and it works perfectly!
I used a simpler method than I initially thought of :p

View attachment 151688

  • Disap
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(harvest))
      • (Load (Key Boolean) of (Key (Triggering unit)) from Table) Equal to True
    • Actions
      • Hashtable - Save False as (Key Boolean) of (Key (Triggering unit)) in Table
      • Custom script: call Harv_Disapear()
  • Condition
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(resumeharvesting))
    • Actions
      • Hashtable - Save True as (Key Boolean) of (Key (Triggering unit)) in Table
JASS:
function TimerEx takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = LoadUnitHandle(udg_Table, GetHandleId(t), 0)
    call PauseUnitBJ( false, u )
    call ShowUnitShow( u )
    call FlushChildHashtable(udg_Table, GetHandleId(t))
    call DestroyTimer(t)
    set t = null
    set u = null
endfunction

function TimerSt takes nothing returns nothing
    local timer t = CreateTimer()
    call SaveUnitHandle(udg_Table, GetHandleId(t), 0, GetTriggerUnit())
    call TimerStart(t, 2, false, function TimerEx)
    set t = null
endfunction

function Harv_Disapear takes nothing returns nothing
    call PauseUnitBJ( true, GetTriggerUnit() )
    call ShowUnitHide( GetTriggerUnit() )
    call TimerSt()
endfunction

And...we're progressing!

There is a problem though, smart orders.

What if the peasant is issued an order (through shift-right-click) after it goes inside the mine/harvest lumber? The order resumeharvest order wouldn't be called, therefore the system would break.

Same thing with the harvest order.
 
Level 12
Joined
Jan 2, 2016
Messages
973
Okay... After a lot of thinking, I came to the conclusion, that fixing this cannot be achieved so easily. I tried to add extra conditions, I tried making other triggers, that check for stuff, but I don't know how to detect the moment when they return the resources.

Perhaps a really complex system could do it:
When the unit is given an order, and the target of the order is gold min - set a boolean to true, start a timer = the distance between the unit and the gold mine / the unit's speed. Store the timer into a cell of a hashtable, with the unit as a parent.

Then when it gets another order - it checks if this timer has expired or not. If it has - it sets boolean1 for the unit to true and if the target unit of the newly issued order is equal to town hall / keep / castle / lumber mill / etc... set boolean2 to true and start a timer = the distance between the unit and the target point of issued order / the unit's speed.

Then when it's issued an order: if boolean1 is true, boolean2 is true, and the timer has expired - call Harv_Disapear(), and set the unit's boolean1 and boolean2 to false
if the timer hasn't expired - set boolean2 to flase (don't touch boolean 1), and destroy the timer.

Every time a unit, which boolean1 is true is issued an order "smart" or "resumeharversting" - set it's boolean2 to true and start the timer again.

boolean1 = has the unit picked up resources
boolean2 = is the unit going towards a building to return the resources.

But I don't really feel like doing that....
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
If it's for lumber and there are no other source of lumber in the map, you could periosically monitor the current order of all peasants and store it in a variable.

Then, I believe there's a GUI event that is somethinf like:
Player 1's lumber become greater than 0.
^Using that Event, you can know when you gain a lumber.
Then when the trigger with ^that event fires, check the peasant who has it's order changed.
It is important that you periodically update the variables containing the current order of all the peasants so you won't run into problems and bugs.
 
Okay... After a lot of thinking, I came to the conclusion, that fixing this cannot be achieved so easily. I tried to add extra conditions, I tried making other triggers, that check for stuff, but I don't know how to detect the moment when they return the resources.

Perhaps a really complex system could do it:
When the unit is given an order, and the target of the order is gold min - set a boolean to true, start a timer = the distance between the unit and the gold mine / the unit's speed. Store the timer into a cell of a hashtable, with the unit as a parent.

Then when it gets another order - it checks if this timer has expired or not. If it has - it sets boolean1 for the unit to true and if the target unit of the newly issued order is equal to town hall / keep / castle / lumber mill / etc... set boolean2 to true and start a timer = the distance between the unit and the target point of issued order / the unit's speed.

Then when it's issued an order: if boolean1 is true, boolean2 is true, and the timer has expired - call Harv_Disapear(), and set the unit's boolean1 and boolean2 to false
if the timer hasn't expired - set boolean2 to flase (don't touch boolean 1), and destroy the timer.

Every time a unit, which boolean1 is true is issued an order "smart" or "resumeharversting" - set it's boolean2 to true and start the timer again.

boolean1 = has the unit picked up resources
boolean2 = is the unit going towards a building to return the resources.

But I don't really feel like doing that....

Awww, thank you very much anyway. At least you made some kind of foundation for this.

If it's for lumber and there are no other source of lumber in the map, you could periosically monitor the current order of all peasants and store it in a variable.

Then, I believe there's a GUI event that is somethinf like:
Player 1's lumber become greater than 0.
^Using that Event, you can know when you gain a lumber.
Then when the trigger with ^that event fires, check the peasant who has it's order changed.
It is important that you periodically update the variables containing the current order of all the peasants so you won't run into problems and bugs.


It's for both resources, gold and lumber. The map is just any other altered melee map.

The problem I can see here is canceling training of units and building of structures. I feel like it would be very impractical to catch and differentiate a raise in resources through peasant dropping off or through cancelling of structures/training.
 

Kazeon

Hosted Project: EC
Level 33
Joined
Oct 12, 2011
Messages
3,449
I've done this already without using any custom resource system.
First, you have to be able to convert "smart" order into it's actual order. Then as have been said before, you can periodically check peasant's current order and previous order. If the current order is "harvest" and previous order is "resumeharvesting", then it's your event.
But of course it has limitations. You can immediately issue "resumeharvesting" order continously right after the peasant reached the hall and headed to the wood, by right-clicking the building. And the event will be fired continously everytime the peasant reached the building. You can trick this by using timer to indicate delay between the events.
But yeah, the most elegant way to solve this is by creating custom resource system.

I can upload the map if you need it. But of course, without any documentation so you have to figure everything I'm doing there out by yourself. :p
 
A test map is greatly appreciated and way more convenient than me building the system from ground-up. No need to worry, I can figure out what's happening whether it's vjass, jass, or simply gui.

I'm avoiding a custom resource system (unless it's based off the default Harvest abilities and not some dummy casting ability such as Channel) because I think the game AI won't be smart enough to use it.
 
Last edited:
Level 12
Joined
Jan 2, 2016
Messages
973
I've done this already without using any custom resource system.
First, you have to be able to convert "smart" order into it's actual order. Then as have been said before, you can periodically check peasant's current order and previous order. If the current order is "harvest" and previous order is "resumeharvesting", then it's your event.
But of course it has limitations. You can immediately issue "resumeharvesting" order continously right after the peasant reached the hall and headed to the wood, by right-clicking the building. And the event will be fired continously everytime the peasant reached the building. You can trick this by using timer to indicate delay between the events.
But yeah, the most elegant way to solve this is by creating custom resource system.

I can upload the map if you need it. But of course, without any documentation so you have to figure everything I'm doing there out by yourself. :p

Say, how do you convert "smart" into the unit's actual order?
 
Level 12
Joined
Jan 2, 2016
Messages
973
Well, if it's done that way - it woudln't work.
My trigger activates AFTER the peon has returned the resources.
If a player orders it "smart" with the shift, towards some point - the "smart" wouldn't be converted to harvest and it wouldn't work.

If I do it the other way (based on the unit's old orders) - if the unit is returning resources and the player interupts it - the trigger will run and the unit will disapear for 2 seconds.
 
Well, if it's done that way - it woudln't work.
My trigger activates AFTER the peon has returned the resources.
If a player orders it "smart" with the shift, towards some point - the "smart" wouldn't be converted to harvest and it wouldn't work.

If I do it the other way (based on the unit's old orders) - if the unit is returning resources and the player interupts it - the trigger will run and the unit will disapear for 2 seconds.

Now I'm stumped also

I've done this already without using any custom resource system.
First, you have to be able to convert "smart" order into it's actual order. Then as have been said before, you can periodically check peasant's current order and previous order. If the current order is "harvest" and previous order is "resumeharvesting", then it's your event.
But of course it has limitations. You can immediately issue "resumeharvesting" order continously right after the peasant reached the hall and headed to the wood, by right-clicking the building. And the event will be fired continously everytime the peasant reached the building. You can trick this by using timer to indicate delay between the events.
But yeah, the most elegant way to solve this is by creating custom resource system.

I can upload the map if you need it. But of course, without any documentation so you have to figure everything I'm doing there out by yourself. :p

Hey Quilnez, if you don't mind me asking, how's the test map/system going?
 
Level 12
Joined
Jan 2, 2016
Messages
973
Aha, I see.
By the way. When loading your map I'm getting "Trigger function does not exsist in database: CreateTimer" is that fatal?
And which one is the trigger, that detects the gold returning event? You kind a got a lot of triggers there.
 
Here we go (it's one of my project). But perhaps you want to play test the map first to see how the event takes places. You can ask me any question any time. ;)

Thank you very much, I'll try to fool around with it.

Is there any catch to this? Or anything that can be exploited? And also, as WereElf said, where did you get the CreateTimer function?

Aha, I see.
By the way. When loading your map I'm getting "Trigger function does not exsist in database: CreateTimer" is that fatal?
And which one is the trigger, that detects the gold returning event? You kind a got a lot of triggers there.

Its the OnOrder trigger I think.
 
I'm not sure I followed everything, but this might help. It's a simple getorderid trigger.

  • Get Order String and ID tool
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • Actions
      • Game - Display to (All players) the text: (Name of (Triggering unit))
      • Custom script: call DisplayTimedTextToForce( GetPlayersAll(), 30, ( "Order Id: " + I2S(GetIssuedOrderId()) ) )
      • Game - Display to (All players) the text: (String((Issued order)))
It will return the value of the unit, order ID, and the order string.

Now, let's try to detect gold and lumber.

I assume you tried this?
  • Player - Player 1 (Red)'s Current gold becomes Greater than or equal to 0.00
or
  • Player - Player 1 (Red)'s Current lumber becomes Greater than or equal to 0.00
The trick would be to save each in a variable and then detect when it went up. So at the end of each change set an real variable called OldGold[(player number)] = players current gold. Then at the beginning of the same trigger set NewGold[(player number)] and check is NewGold greater than OldGold. If yes, then you just detected the receipt of gold.

Edit:

I just re-read your question. Oops. So maybe, you can detect the peasant who just dropped off the lumber by looking to see which one is closest and who's current order is harvest.
 
I'm not sure I followed everything, but this might help. It's a simple getorderid trigger.

  • Get Order String and ID tool
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 1 (Red)
    • Actions
      • Game - Display to (All players) the text: (Name of (Triggering unit))
      • Custom script: call DisplayTimedTextToForce( GetPlayersAll(), 30, ( "Order Id: " + I2S(GetIssuedOrderId()) ) )
      • Game - Display to (All players) the text: (String((Issued order)))
It will return the value of the unit, order ID, and the order string.

Now, let's try to detect gold and lumber.

I assume you tried this?
  • Player - Player 1 (Red)'s Current gold becomes Greater than or equal to 0.00
or
  • Player - Player 1 (Red)'s Current lumber becomes Greater than or equal to 0.00
The trick would be to save each in a variable and then detect when it went up. So at the end of each change set an real variable called OldGold[(player number)] = players current gold. Then at the beginning of the same trigger set NewGold[(player number)] and check is NewGold greater than OldGold. If yes, then you just detected the receipt of gold.

Edit:

I just re-read your question. Oops. So maybe, you can detect the peasant who just dropped off the lumber by looking to see which one is closest and who's current order is harvest.

Wouldn't that bug out when two peasants returned the same resource at the same time? The possibility of something like this might be small but it can still happen. And as developers, we don't want anything exploited.
 
Wouldn't that bug out when two peasants returned the same resource at the same time? The possibility of something like this might be small but it can still happen. And as developers, we don't want anything exploited.

It shouldn't. Each instance will fire the trigger. Each time it will look for the closest peasant. Each time it will hide the peasant. It can check for hidden peasants and not re-hide them. Of course the best way to answer your question would be to try it out. Have you tried it?
 
It shouldn't. Each instance will fire the trigger. Each time it will look for the closest peasant. Each time it will hide the peasant. It can check for hidden peasants and not re-hide them. Of course the best way to answer your question would be to try it out. Have you tried it?

I haven't, I was just speaking hypothetically, and will continue to do so until I get the chance to work with the editor once more ^^

How would I go about differentiating a rise in resource through peasants and rise in resource through cancellation of building/training, creep bounties, etc.?
 
How would I go about differentiating a rise in resource through peasants and rise in resource through cancellation of building/training, creep bounties, etc.?

Great question. Let me work on this. Also, I forgot to give you this:
  • Custom script: call IssueImmediateOrderById(GetTriggerUnit(), udg_OrderId)
Once you get the order ID, you should use it.

Edit:
This is not perfect, but it does let the peon enter the mill. What it does not do is keep the mill occupied while one peon is inside and make the next one wait to get in. All peons spend 1 second inside and then return to work. Also, it is hard to hide the hp bar and selection circle without dropping the unit from the unit selection.

This system detects lumber increases.
Detects the peon unit giving the lumber.
Puts the peon inside the <gen>mill.
And sends the peon back to work after 1 second.

I hope this helps get you started. The best way is to actually build it because there are things that will come up that you will not have prepared for in theorizing. For example the Mill-Occupied system will be a bit tricky and you will need to find a way to hide the hp bar better. "Hide unit" drops the unit from selection. Forcing a re-select might help, but what if you wanted to select another unit when the unit was inside the mill.

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Melee Game - Create starting units (for all players)
      • Player - Set Player 1 (Red) Current gold to 750
      • Player - Set Player 1 (Red) Current lumber to 750
      • Game - Set the time of day to 6.00
      • Set PastLumber = 750.00
      • Trigger - Add to Detect Lumber Increase <gen> the event (Player - Player 1 (Red)'s Current lumber becomes Greater than PastLumber)
      • Trigger - Add to Detect Lumber Decrease <gen> the event (Player - Player 1 (Red)'s Current lumber becomes Less than PastLumber)
  • Detect Lumber Increase
    • Events
    • Conditions
    • Actions
      • Set PastLumber = (Real((Player 1 (Red) Current lumber)))
      • Trigger - Turn on Detect Lumber Unit <gen>
  • Detect Lumber Decrease
    • Events
    • Conditions
    • Actions
      • Set PastLumber = (Real((Player 1 (Red) Current lumber)))
  • Detect Lumber Unit
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(harvest))
        • Then - Actions
          • Set Mill = Lumber Mill 0000 <gen>
          • Set index = (index + 1)
          • Set Time[index] = 0
          • Set LumberUnit[index] = (Triggering unit)
          • Set Loc[index] = (Position of LumberUnit[index])
          • Animation - Change LumberUnit[index]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 100.00% transparency
          • Animation - Change LumberUnit[index]'s size to (0.01%, 0.01%, 0.01%) of its original size
          • Unit - Pause LumberUnit[index]
          • Unit - Add Crow Form to (Triggering unit)
          • Unit - Remove Crow Form from (Triggering unit)
          • Unit - Turn collision for LumberUnit[index] Off
          • Unit - Move LumberUnit[index] instantly to (Position of Mill)
          • Animation - Play Mill's work animation
          • Game - Display to (All players) the text: (Enters Peon# + (String(index)))
          • Trigger - Turn on Exit Mill <gen>
          • Trigger - Turn off (This trigger)
        • Else - Actions
  • Exit Mill
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to index, do (Actions)
        • Loop - Actions
          • Set Time[(Integer A)] = (Time[(Integer A)] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Time[(Integer A)] Equal to 10
            • Then - Actions
              • Set Loop = (Loop + 1)
              • Game - Display to (All players) the text: (Releasing Peon# + (String(Loop)))
              • Animation - Change LumberUnit[Loop]'s size to (100.00%, 100.00%, 100.00%) of its original size
              • Animation - Change LumberUnit[Loop]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
              • Unit - Turn collision for LumberUnit[Loop] On
              • Unit - Move LumberUnit[Loop] instantly to Loc[Loop]
              • Unit - Unpause LumberUnit[Loop]
              • Unit - Order LumberUnit[Loop] to Harvest Nearby Lumber
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Loop Equal to index
                • Then - Actions
                  • Animation - Play Mill's stand animation
                  • Set index = 0
                  • Set Loop = 0
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
 

Attachments

  • Lumber Detection.w3x
    21.1 KB · Views: 101
Last edited:
Great question. Let me work on this. Also, I forgot to give you this:
  • Custom script: call IssueImmediateOrderById(GetTriggerUnit(), udg_OrderId)
Once you get the order ID, you should use it.

Edit:
This is not perfect, but it does let the peon enter the mill. What it does not do is keep the mill occupied while one peon is inside and make the next one wait to get in. All peons spend 1 second inside and then return to work. Also, it is hard to hide the hp bar and selection circle without dropping the unit from the unit selection.

This system detects lumber increases.
Detects the peon unit giving the lumber.
Puts the peon inside the <gen>mill.
And sends the peon back to work after 1 second.

I hope this helps get you started. The best way is to actually build it because there are things that will come up that you will not have prepared for in theorizing. For example the Mill-Occupied system will be a bit tricky and you will need to find a way to hide the hp bar better. "Hide unit" drops the unit from selection. Forcing a re-select might help, but what if you wanted to select another unit when the unit was inside the mill.

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Melee Game - Create starting units (for all players)
      • Player - Set Player 1 (Red) Current gold to 750
      • Player - Set Player 1 (Red) Current lumber to 750
      • Game - Set the time of day to 6.00
      • Set PastLumber = 750.00
      • Trigger - Add to Detect Lumber Increase <gen> the event (Player - Player 1 (Red)'s Current lumber becomes Greater than PastLumber)
      • Trigger - Add to Detect Lumber Decrease <gen> the event (Player - Player 1 (Red)'s Current lumber becomes Less than PastLumber)
  • Detect Lumber Increase
    • Events
    • Conditions
    • Actions
      • Set PastLumber = (Real((Player 1 (Red) Current lumber)))
      • Trigger - Turn on Detect Lumber Unit <gen>
  • Detect Lumber Decrease
    • Events
    • Conditions
    • Actions
      • Set PastLumber = (Real((Player 1 (Red) Current lumber)))
  • Detect Lumber Unit
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Issued order) Equal to (Order(harvest))
        • Then - Actions
          • Set Mill = Lumber Mill 0000 <gen>
          • Set index = (index + 1)
          • Set Time[index] = 0
          • Set LumberUnit[index] = (Triggering unit)
          • Set Loc[index] = (Position of LumberUnit[index])
          • Animation - Change LumberUnit[index]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 100.00% transparency
          • Animation - Change LumberUnit[index]'s size to (0.01%, 0.01%, 0.01%) of its original size
          • Unit - Pause LumberUnit[index]
          • Unit - Add Crow Form to (Triggering unit)
          • Unit - Remove Crow Form from (Triggering unit)
          • Unit - Turn collision for LumberUnit[index] Off
          • Unit - Move LumberUnit[index] instantly to (Position of Mill)
          • Animation - Play Mill's work animation
          • Game - Display to (All players) the text: (Enters Peon# + (String(index)))
          • Trigger - Turn on Exit Mill <gen>
          • Trigger - Turn off (This trigger)
        • Else - Actions
  • Exit Mill
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to index, do (Actions)
        • Loop - Actions
          • Set Time[(Integer A)] = (Time[(Integer A)] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Time[(Integer A)] Equal to 10
            • Then - Actions
              • Set Loop = (Loop + 1)
              • Game - Display to (All players) the text: (Releasing Peon# + (String(Loop)))
              • Animation - Change LumberUnit[Loop]'s size to (100.00%, 100.00%, 100.00%) of its original size
              • Animation - Change LumberUnit[Loop]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
              • Unit - Turn collision for LumberUnit[Loop] On
              • Unit - Move LumberUnit[Loop] instantly to Loc[Loop]
              • Unit - Unpause LumberUnit[Loop]
              • Unit - Order LumberUnit[Loop] to Harvest Nearby Lumber
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Loop Equal to index
                • Then - Actions
                  • Animation - Play Mill's stand animation
                  • Set index = 0
                  • Set Loop = 0
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions

Hey, thank you very much! ^^

There's a bit of problem though. When the peasant is issued an order other than harvest through shift-right-clicking, the peasant doesn't hide.

Major props to you for making the mill play the stand work anim, looks good!

EDIT: Same problem goes Quilnez's system. Is this a lost cause? :V
 
Hey, thank you very much! ^^

There's a bit of problem though. When the peasant is issued an order other than harvest through shift-right-clicking, the peasant doesn't hide.

Major props to you for making the mill play the stand work anim, looks good!

EDIT: Same problem goes Quilnez's system. Is this a lost cause? :V

Well, you can just get rid of the condition for the order "harvest" and make it work on move and attack also. Then check for peon-type units and units within 100 of mill-type units.

It's not a lost cause at all. I did this in a matter of hours to help a stranger, if you are invested in this project and idea, then a little elbow grease will do the trick.

There are other problems with my system as well. For now it only works for player 1, and it is not very efficient. For example, you should make it so that it only looks for a unit if the lumber increase is less than 10 and it should stop looking after 0.10 seconds.

I didn't make a full system that would be something that one might submit to the spells forum. I just made the most basic frame for a system. I assumed you would complete it. I didn't do that because I'm not sure how your map works and what other systems it uses. I don't know what types of buildings you will use. For example, mine only works with that one lumber mill. To make it work with other mills you need to add a trigger to detect when mills are constructed.

My system will also shut off the work animation when the lumber mill is researching. These are all easy fixes.

This system will work but you will need to make it happen. I expect to see peasants lined up around that mill just like a gold mine, taking turns dropping off lumber. I know you can do it.
 
Last edited:
Well, you can just get rid of the condition for the order "harvest" and make it work on move and attack also. Then check for peon-type units and units within 100 of mill-type units.

It's not a lost cause at all. I did this in a matter of hours to help a stranger, if you are invested in this project and idea, then a little elbow grease will do the trick.

There are other problems with my system as well. For now it only works for player 1, and it is not very efficient. For example, you should make it so that it only looks for a unit if the lumber increase is less than 10 and it should stop looking after 0.10 seconds.

I didn't make a full system that would be something that one might submit to the spells forum. I just made the most basic frame for a system. I assumed you would complete it. I didn't do that because I'm not sure how your map works and what other systems it uses. I don't know what types of buildings you will use. For example, mine only works with that one lumber mill. To make it work with other mills you need to add a trigger to detect when mills are constructed.

My system will also shut off the work animation when the lumber mill is researching. These are all easy fixes.

This system will work but you will need to make it happen. I expect to see peasants lined up around that mill just like a gold mine, taking turns dropping off lumber. I know you can do it.

I have already asked this thing back in 2009.

Now that I'm reviving the project, I still have no idea what to do. Don't get me wrong though, I can code, it's just that I really have no idea how to detect this. :V

This is to be used for a few things:
- Hiding peasants for 4 seconds when dropping off resources gathered.
- Adding bonus gold/lumber to the returned resources when conditions/upgrades are met (especially for lumber, 50 hits for 100 lumber, still 50 hits for 125 lumber).
 
Level 12
Joined
Jan 2, 2016
Messages
973
Okay, I had started making the system, but I had saved the map on an external Hard Drive. And today, when I plugged it in, my PC said that I need to repair the hard drive (and I did), and then I couldn't open the map anymore.
However, here is the logic of what I was trying to do:
Every time a unit (peon/pesant/ghoul) is given an order, targeting a gold mine or a destructible (tree) - I set a boolean to true and save it in the unit's hashtable field as boolean 1.
I start a timer = the distance between the unit and the target of the order, divided by the unit's movespeed. I save the timer in the unit's hashtable as well.
Every time a unit (which can harvest) is given an order - I check if their boolean 1 is true. If it is - I check the unit's timer time. If it has expired - I set unit's boolean 2 to true.
I set boolean 1 to false, regardless if the timer has expired or not (unless the target of the issued order is equal to gold mine or a tree), and I destroy the timer.
If the new order is targeted at town hall / keep / castle / lumber mill/ etc... - I set the unit's boolean 3 to true, and I start another timer = the distance between the unit and the target of issued order / the unit's move speed.
When it's given a new order - it checks if boolean 3 is equal to true. If it is true - it checks the timer of the unit. If it has expired - it hides the unit (and pauses it), and sets boolean 2 to false.
Even if the timer hasn't expred - the timer is destroyed and boolean 3 is set to false.

boolean 1 = the unit is going towards resources
boolean 2 = the unit has picked up resources
boolean 3 = the unit is going to return resources

This way is a bit inaccurate as the distance / the speed isn't always = the time needed to reach the destination, as this way ignores pathing.

A better way to do it would be:
Save target of issued order into the unit's hashtable, and when it's given a new order - it checks the distance between it and its old target. If it's under a certain amount - it sets boolean 2 to true. And follows the same logic as the previous xP
 
Level 15
Joined
Aug 14, 2007
Messages
936
detect all the orders given to peasant, check for stun buffs/roots.

When unit is issued order to return resource, use the timer system to detect its distance to the main hall, once condition met do whatever you want ;p

(BY USING THE WARCRAFT STANDARD FUCKING RESOURCE MINING I MUST ADD FOR THOSE WHO DIDN'T GET THE JOKE)
 
Last edited by a moderator:
I have already asked this thing back in 2009.

Now that I'm reviving the project, I still have no idea what to do. Don't get me wrong though, I can code, it's just that I really have no idea how to detect this. :V

This is to be used for a few things:
- Hiding peasants for 4 seconds when dropping off resources gathered.
- Adding bonus gold/lumber to the returned resources when conditions/upgrades are met (especially for lumber, 50 hits for 100 lumber, still 50 hits for 125 lumber).

Did you test the map? Because, I did and it works. If you want it to be 4 seconds, just change it.

I don't understand this, "50 hits for 100 lumber, still 50 hits for 125 lumber." Why not just used improved lumber? You can make an OE improved gold mining too. The upgrade has adjustable data sets.
 
Did you test the map? Because, I did and it works. If you want it to be 4 seconds, just change it.

I don't understand this, "50 hits for 100 lumber, still 50 hits for 125 lumber." Why not just used improved lumber? You can make an OE improved gold mining too. The upgrade has adjustable data sets.

The one you posted days before? Yes I did. Replied to it at post #32.

50 tree hits dealing 2 damage to the tree will give 100 lumber. I'm trying to make it so that when an upgrade/requirement is met, you will get 125 lumber instead but still in 50 tree hits.

Using the Human lumber harvest upgrade doesn't do what I plan to do. Setting a 25 bonus lumber capacity but it will also change the tree hits needed to 62-63.

It can be done with the gold capacity upgrade though.

Thanks for the pointers everyone! I'll try and create the system basing on all of your ideas.
 
Status
Not open for further replies.
Top