Hi all,
Is there any way to get the current production for a user? I'm talking about units/buildings/research as it is shown in the observer interface. This trigger would fire off every X seconds and just pull the data for the players in the player group that are currently playing. Data would be saved to a bank like:
I can imagine you might have to track buildings/units/research separately which is okay too. I've tried a few things including counting only units "Under Construction" but am unable to get any meaningful data out.
Has anyone built anything like this and can shed some light on the direction I should go in?
You could try something like "pick all units owned by player 1" followed by an if/then/else function with a condition checking whether the unit is complete. If not, add a line to the bank with the unit's completion %.
My problem is that first part. I don't see any function that returns all units owned by player X. The best I can find is "Units in Region With Alliance to Player." Since the building units are not in a "region" then they are not returned by this function (at least that's my theory as to why I'm not seeing anything). Here's my code.
Variable-SetallUnitsGroup=(Unitsin(Entiremap)havingallianceAllywithplayerplayermatchingExcluded:Missile,Dead,Hidden,withatmostAnyAmount)UnitGroup-ForeachunitunitinallUnitsGroupdo(Actions)ActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If(unitisunderconstruction)==TrueThenBank-Storestring"found a unit under construction"as"key"ofsection"data"inbankplayerBankElse
If this route doesn't work, I suppose I could track the event "Unit - Any Unit construction progress is Started" and add that unit to an array (or data table - haven't played with either that much) and then check on the progress of the units in there every so often.
Thoughts?
EDIT: Took a stab at my alternate solution proposal and it seems units are not included in the Event "Any Unit construction progress is Started" and only buildings are:
EventsUnit-AnyUnitconstructionprogressisStartedLocalVariablesunitPickedName=""<String>unit=NoUnit<Unit>playerBank=NoBank<Bank>player=0<Integer>ConditionsActionsPlayerGroup-Foreachplayerplayerin(Allplayers)do(Actions)ActionsGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If(Ownerof(Triggeringprogressunit))==playerThenVariable-SetplayerBank=productionBanksArray[player]
Variable - Set unit = (Triggering progress unit)
Variable - Set unitPickedName = (Value of Units (Unit type of unit) Name for player Any Player)
Bank - Store string unitPickedName as "key" of section "data" in bank playerBank
Bank - Save bank playerBank
Else
Looks like it's not possible to see how far along a unit is in production? Can this be true?
The "units in region matching condition" is enough to determine which player owns the unit. The wording is literally:
"Unit Group - Pick each unit in (Any units in (Entire map) owned by player 1 matching Required: Structure; Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)"
Hope this helps. If you have any questions (I know maybe it isn't so easy to just look at the map) please go ahead and ask. You can find me on skype as rtschutter if you need an immediate answer, I may forget to check this thread again.
Hi all, Is there any way to get the current production for a user? I'm talking about units/buildings/research as it is shown in the observer interface. This trigger would fire off every X seconds and just pull the data for the players in the player group that are currently playing. Data would be saved to a bank like:
I can imagine you might have to track buildings/units/research separately which is okay too. I've tried a few things including counting only units "Under Construction" but am unable to get any meaningful data out.
Has anyone built anything like this and can shed some light on the direction I should go in?
Thanks for the help! :)
@marktronic: Go
You could try something like "pick all units owned by player 1" followed by an if/then/else function with a condition checking whether the unit is complete. If not, add a line to the bank with the unit's completion %.
Something similar may work with research.
@BasharTeg: Go
My problem is that first part. I don't see any function that returns all units owned by player X. The best I can find is "Units in Region With Alliance to Player." Since the building units are not in a "region" then they are not returned by this function (at least that's my theory as to why I'm not seeing anything). Here's my code.
If this route doesn't work, I suppose I could track the event "Unit - Any Unit construction progress is Started" and add that unit to an array (or data table - haven't played with either that much) and then check on the progress of the units in there every so often.
Thoughts?
EDIT: Took a stab at my alternate solution proposal and it seems units are not included in the Event "Any Unit construction progress is Started" and only buildings are:
Looks like it's not possible to see how far along a unit is in production? Can this be true?
I made a quick map which reports each 5 seconds the unit progress for any units in training on the map owned by Player 1.
Here it is.
The "units in region matching condition" is enough to determine which player owns the unit. The wording is literally:
"Unit Group - Pick each unit in (Any units in (Entire map) owned by player 1 matching Required: Structure; Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)"
Hope this helps. If you have any questions (I know maybe it isn't so easy to just look at the map) please go ahead and ask. You can find me on skype as rtschutter if you need an immediate answer, I may forget to check this thread again.