Well, believe me, I'd love to see a 3rd harvestable resource too. If you can pull it off, it'll be great, but that doesn't take away I'm very sceptic and I really doubt it's possible anyway. At least, the current way you've taken will not be a good solution, so you'll have to look at another - more efficient - way...@ Eleandor: You might be right, and i might be wrong, but still,, dont be so negative,
Pick all units on the map of type (worker) and filter them by the current order.
If it is harvest, check distance between the unit and the target.
Should be a bit more efficient.
Jass is no option, custom scripts are fine.
So one more time: I need a trigger that will run as soon as a tree is harvested, then I need to check what kind of tree it is.
Depending on the tree the unit will get an custom value, lets say summer tree is value 1 while barrens is value 2.
When the 'lumber' is returned I want to cancel the deposit and the message showing the lumber and instead based of the custom value of the unit store a value to the fitting integer and also show a message.
My main problem is detecting when a resource is harvested and when it's deposited. xD
Hmm, the custom harvesting thing seems better yes.
And more simple, oh spiwn I find it rather annoying to use units for there will be like more then a 1000 of those deposits.
How about doing it like this:
Pick all units on the map of type (worker) and filter them by the current order.
If it is harvest, check distance between the unit and the target.
Should be a bit more efficient.
I still do not have much time to make a harvesting system, but I made something.
You didn't quite get that: All units of type is faster than all units matching condition(Type of Matching unit is The type).
But anyway I realized there is no way to get the target of the current order, so I made something to optimize your process.
You need to edit only "Your Trigger".
P.s. forgot to put a lumber mill or something
set udg_*Name_of_Array*[i]=0
function Trig_Order_Actions takes nothing returns nothing
local integer i=AllocateValue()
set udg_Destructables[i]=GetOrderTargetDestructable()
call GroupAddUnit(udg_TreehUnitGroup,GetTriggerUnit())
set udg_*Name_of_Array*[i]=0
call SetUnitUserData(GetTriggerUnit(),i)
endfunction
Making mistakes is not strange to me.
First comment:
The group managing triggers used the custom values in order to identify the destructibles.
Two choices here:
I can change the jass code so that it uses an attachment system or game-cache.
Or you do not use the custom values to store something, but instead you use an integer array. Use the custom value as an index to that array. In that case you have to add a line in the code:
In the trigger "Order", in the actions function ("Trig_Order_Actions") the line
set udg_*Name_of_Array*[i]=0
so it looks something like this(it can be any line except the first)
JASS:function Trig_Order_Actions takes nothing returns nothing local integer i=AllocateValue() set udg_Destructables[i]=GetOrderTargetDestructable() call GroupAddUnit(udg_TreehUnitGroup,GetTriggerUnit()) set udg_*Name_of_Array*[i]=0 call SetUnitUserData(GetTriggerUnit(),i) endfunction
The second is easier and better(though the first isn't hard).
P.s. The value in the custom value of a worker is a unique value, assigned to that unit when it is ordered to harvest.
Note that at the moment my group managing works only for peons. Easily changeable to anything anyone wants.
Ok, i think i understand, so (like some maps do) every unit (most of the times in the map but now) in the group has an own custom value, and you set a variable ( SomeIntegerReplacingCustomValueVariable[custom value of unit] ) to +1?
Is that where you are going to?
And you mean peon-type units, or workers?
Yeah that is what I meant.
Yeah, except in this case it is not for all units, but only for workers. But a system like PUI can be used and all units will get an index including the workers.
And I meant peasants
Lol.
Is Airandius interested only in the deposition, that would be a lot easier
Lets check first page.
*checking*
Still not sure.
Hm.
How do you intend to get rid the +## message?
Anyways, if this is only to detect when a unit deposits lumber, none of this is necessary.
You can use the event Player - Player 1's current lumber becomes greater than 0
If Current lumber of Triggering Player is greater than PlayerLumberOld[ Player number of Triggering Player]
Turn this trigger off
Do stuff
Turn it back on
else
set PlayerLumberOld[ Player number of Triggering Player]=Current lumber of Triggering Player
But I thought he wanted to do something with the workers, something else.
P.s. Of course add more events
Actually the logic I posted above works every time a worker deposits lumber, and you can get the amount he deposited.
Then I played around with the harvest ability and came up with a way to do this
Well, I tried increasing the level of Harvest - no good.
Then I tried replacing harvest with a different harvest - worked, but the lumber carried wasn't saved.
And then I tried adding another harvest - worked
(except that there were two messages on delivery)
So The way I came up with:
Make several versions of harvest, exactly the same(with 1 damage to tree).
All but one should go in a spell book. Not sure, as I haven't tested but I think that they can go in different levels of the same spell book. (All) The spell books will be disabled so that they are not displayed.
So when a unit is ordered to harvest a tree, check the tree type and set level of the spell book(or if the above doesn't work add/remove the proper amount of spell books).
Now, when the unit harvests a tree, the tree will be damaged for as much as the number of harvest abilities the units has(assuming they all are set to 1). Also the unit will carry that same amount. And when it delivers the lumber, the player will get the proper amount, but the message will still display a lot of number on top of each other.
This way requires that the tries that yield more lumber have more live.