3

I want to make a rather simple (?) change: I would like Probes (or other workers) to be able to carry multiple minerals at the same time. I would expect the probe to:

  • approach the mineral field
  • gather minerals
  • gather minerals again
  • ... and again...
  • and then carry it back to the base

Originally I thought it is a simple data change of the worker: I thought it could be simple as changing the behavior Carry Mineral Field Minerals->(Basic) Stats; Maximum Stack Count from 1 to 5. Unfortunately, as soon as a probe gathers the minerals, it automatically returns.

After giving it more thought I figured there may be some built-in trigger, checking if the worker is already carrying minerals - and if that is so - issuing a "Return" order. Since then I have been digging into available triggers, scripts, unpacking Liberty and Swarm mods, but so far - I could find nothing.

Any ideas? Pointers?

I am new to modding and I don't plan to do anything big. Just want to hack this for some experimentation...

I know how to increase gather time and how to make probe just carry more minerals in a single patch... but I want to specifically make the probe retrigger the gathering multiple times before it returns (and add some delay in between)

Also, I don't care what happens when mixing minerals with gas or any other resource.

  • Now, I haven't used galaxy editor at all, but I have lots of experience in War3WorldEdit, and your issue would probably be - as you've said - limitations of engines basic functions. If the triggers work the same as in W3WE (or like it) you could always try keeping some sort of counter for every created probe that represents a stack of minerals (removing gathered materials from the probe and adding 1), and giving him the resources when having 5 counters? – user1337 Nov 20 '14 at 22:59
  • ACKSHULLY: Why not just increase the carry load of the probe? – user1337 Nov 20 '14 at 23:00
  • @user1337 Thank you for your comment. I was able to reduce the carried minerals to 0 and remove the animation of carrying minerals (UnitBehaviorRemove(... , "CarryMineralFieldMinerals",1), but the worker is still making an empty trip back-and-forth. Any ideas how to reissue the gathering order on the mineral patch? – CygnusX1 Nov 21 '14 at 11:02
  • As for your second question: I want to specifically gather minerals multiple times (with gaps in between) rather than having one long, big gather with big load of the probe. Why? I believe it can allow better scaling of the saturation of an expansion. But to confirm it, I want to make an experiment. – CygnusX1 Nov 21 '14 at 11:04
  • Update: I was able to order again to gather minerals when necessary. But how do I know which mineral patch to gather from (i.e. which minerals were last to gather) – CygnusX1 Nov 21 '14 at 13:37
2

Following the idea of user1337 I came with the following idea:

  • When a worker is harvesting, remember which mineral field it did it from
  • When a worker finished harvesting, remove its cargo and repeat the harvesting order, for the same mineral field, again.
  • Have a "stack count" remembering how many times the above point occured. When a threshold is reached, allow the unit to return normally.
  • The amount of returned minerals should be multiplied by the amount of stack count.

The first point is to remember, in the unit, which mineral field it is gathering from. The information will be used later when returning. See the question/answer Probe returning: From which mineral field it gathered resources? and Custom variables/fields for units?

(Trigger) onStartGettingResources
Events
    TriggerAddEventUnitAbility(null, "ProbeHarvest", 0, c_abilHarvestStageHarvest, false)
    TriggerAddEventUnitAbility(null, "DroneHarvest", 0, c_abilHarvestStageHarvest, false)
    TriggerAddEventUnitAbility(null, "SCVHarvest", 0, c_abilHarvestStageHarvest, false)
Local Variables
    minerals <unit>
        EventUnitTargetUnit()
Actions
    StoreUnitWithUnit(EventUnit(), "miningFrom", minerals) //custom function for custom "fields" in a unit

The second trigger should occur when a worker finished harvesting. Experiments have shown it is best triggered by change of the unit behavior triggered when it started carrying minerals. Triggering it on ability stage ApproachDropOff causes short animation stuttering.

(Trigger) onProbeGetResources
Events
    TriggerAddEventUnitBehaviorChange(null, "CarryMineralFieldMinerals", c_unitBehaviorChangeActivate)
Conditions
    Comparison(UnitGetType(EventUnit()), ==, "Probe")
Actions
    GatherResourcesStack("ProbeHarvest", 0) //custom function, see below

.... //Similar triggers for SCV and Drone

(Global variable) g_gatherStackCount <constant int>
    4

(Action definition) GatherResourcesStack
Parameters
    gatherCommand <Ability Command - Unit>
Local Variables
    mineralPatch <unit>
        GetUnitWithUnit(EventUnit(), "miningFrom")
    stackCount <int>
        GetIntWithUnit(EventUnit(), "minigStackCount")
Actions
    SetVariable(stackCount, ArithmeticInt(stackCount, +, 1))
    IfThenElse()
        if
            Comparison(stackCount, <, g_gatherStackCount)
        then
            UnitSetPropertyFixed(EventUnit(), c_unitPropCarriedMinerals, 0.0)
            StoreIntWithUnit(EventUnit(), "miningStackCount", stackCount)
            UnitBehaviorRemove(EventUnit(), "CarryMineralFieldMinerals", 1)
            UnitIssueOrder(EventUnit(), OrderTargetingUnit(gatherCommand, mineralPatch), c_orderQueueReplace)
        else
            StoreIntWithUnit(EventUnit(), "miningStackCount", 0)
            UnitSetPropertyFixed(EventUnit(), c_unitPropCarriedMinerals, 
                ArithmeticReal(
                    UnitGetPropertyFixed(EventUnit(), c_unitPropCarriedMinerals, c_unitPropCurrent),
                    *, g_gatherStackCount
                )
            )
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.