HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Detect when a peasant unloads his lumber?

08-21-2004, 02:41 AM#1
Dalten
How, how how???

Thanks thanks thanks.
08-21-2004, 05:01 AM#2
BBDino
I had a similar problem with detecting gold, i'd love to know if theres a way, it just seems that no abilties fire off and no triggers are appropritte when a peasant returns.

Btw i used a messy system of AOE's unit detection and custom values to create myself a custom gold mining system when i had too, it probably leaked a bit but it did becoem entirly capable of figuring out when gold had been brought to it by peasants.
08-21-2004, 07:22 AM#3
Grater
A trigger like this can be used to detect when a player recieves a small amount of lumber.
Code:
Lumber Detect Event
    Events
        Player - Player 1 (Red)'s Current lumber becomes Greater than or equal to 0.00
    Conditions
        ((Player 1 (Red) Current lumber) - LastLumber) Less than or equal to 10
    Actions
        Game - Display to (All players) the text: Lumber Recieved
        Set LastLumber = (Player 1 (Red) Current lumber)

This trigger can be used to detect when a peasent has returned a load of wood - fairly reliably, it doesn't work if there are no nearby trees left, i'm not sure what you can do about that.
Code:
Lumber Dropoff
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
    Actions
        Custom script:   set udg_TempInt=GetIssuedOrderIdBJ()
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                TempInt Equal to 852019
                Or - Any (Conditions) are true
                    Conditions
                        (Destructible-type of (Target destructible of issued order)) Equal to Ashenvale Canopy Tree
                        (Destructible-type of (Target destructible of issued order)) Equal to Ashenvale Tree Wall
                        etc
            Then - Actions
                -------- Ordered Unit has just dropped off some lumber. --------
            Else - Actions
It is possible to combine the two approaches in order to determine both the unit dropping off the lumber and the quantity of lumber, if you need to.
08-21-2004, 08:27 AM#4
Dalten
Quote:
Originally Posted by Grater
A trigger like this can be used to detect when a player recieves a small amount of lumber.
Code:
Lumber Detect Event
    Events
        Player - Player 1 (Red)'s Current lumber becomes Greater than or equal to 0.00
    Conditions
        ((Player 1 (Red) Current lumber) - LastLumber) Less than or equal to 10
    Actions
        Game - Display to (All players) the text: Lumber Recieved
        Set LastLumber = (Player 1 (Red) Current lumber)

This trigger can be used to detect when a peasent has returned a load of wood - fairly reliably, it doesn't work if there are no nearby trees left, i'm not sure what you can do about that.
Code:
Lumber Dropoff
    Events
        Unit - A unit Is issued an order targeting an object
    Conditions
    Actions
        Custom script:   set udg_TempInt=GetIssuedOrderIdBJ()
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                TempInt Equal to 852019
                Or - Any (Conditions) are true
                    Conditions
                        (Destructible-type of (Target destructible of issued order)) Equal to Ashenvale Canopy Tree
                        (Destructible-type of (Target destructible of issued order)) Equal to Ashenvale Tree Wall
                        etc
            Then - Actions
                -------- Ordered Unit has just dropped off some lumber. --------
            Else - Actions
It is possible to combine the two approaches in order to determine both the unit dropping off the lumber and the quantity of lumber, if you need to.

I thought of doing the first one but I'll need this for several peons on the same team so the events might overlap if two or more return lumber at the same time or close to the same time.

I really don't know what your doing in the 2nd trigger though, i don't know jass at all.

What i have now is: 1) I detect when a destructible, a tree to be specifc, in a certain rect dies. It just resurrects the tree and sets a flag that says that the peon has finished harvesting.

2) Then, i let the peon automatically run to the mill to drop off the wood. I use the "unit enters rect" event, with a slight delay so he has enough time to drop off the lumber and I can tell him to do what i want after that.

This works, but I can forsee several problems that would come up with my pseudo AI that i'm trying to make.

I think what i'll just do is once my "finished harvesting" flag is thrown, i'll just replace the peon as soon as he gets close to the mill and manually add lumber to the player's total....

Unless you see a better way? thanks.
08-21-2004, 10:54 AM#5
Grater
My second trigger is the better way. It detects the "Go back and harvest more wood" order - this order has no name (hence the small amount of JASS) and it's also shared for gold mining, which is why you need to check that it's targetting a tree.... unless you have no goldmines. i suppose you could also detect for Target Unit is "Not a goldmine"

To use my trigger all you need to do is create an integer variable called "TempInt" then copy the custom script exactly as it is there, that is put the text "set udg_TempInt=GetIssuedOrderIdBJ()" in a custom script action.

Below the " -------- Ordered Unit has just dropped off some lumber. --------"
you can use "Event Response - Ordered Unit" to refer to the peon that just dropped off lumber.

And btw with the first trigger there is no overlap problem, it's instant, you could have a thousand peons harvesting and it'll catch each and every drop off (ofcourse it needs to be modified to work with multiple players having peons). Only real problem is if you cancel a priest or archer (ie something that costs 10 lumber) you get refunded 10 lumber, and it cant tell the difference between that refund and a peon dropping off wood.