• 0

    posted a message on Removing SCVs from "Select Idle Workers" while they wait for a Refinery to finish building

    Here is my solution:

    Explanation: Add a behaviour to workers that is disabled unless the worker is stationary, visible, trying to mine, and doesn't already have gas in its hands. This behaviour periodically checks if units that are touching the worker are valid to have a new ability cast on them (requires being a structure, owned by the player, that has gas, is still in progress of being built, and that the worker currently is trying to gather from). If valid, tell workers to add the new ability (validate they are not already using this new ability) to the front of their queue. This ability generates a channeled effect, and the channeling from this ability effect keeps the worker considered "non-idle". Use a periodic validator on this channeled effect to break out of the channel when the vespene structure is no longer considered in progress (completed or dead).

    Behaviours

    <!--Behaviour that periodically calls an Effect search-->
    <CBehaviorBuff id="PeriodicRefineryCheck">
        <InfoFlags index="Hidden" value="1"/>
        <EditorCategories value="AbilityorEffectType:Units"/>
        <DisableValidatorArray value="WorkerIsHarvestingCombine"/>
        <DisableValidatorArray value="CasterIsStationary"/>
        <DisableValidatorArray value="CasterIsVisible"/>
        <DisableValidatorArray value="WorkerNotCarryingVespeneCombine"/>
        <DisableValidatorArray value="WorkerNoIdleChannelOrder"/>
        <PeriodicEffect value="WorkerFindVespeneStructureStopIdle"/>
    </CBehaviorBuff>
     

    Effects

    <!--Effects-->
         <!--The Effect Search-->
    <CEffectEnumArea id="WorkerFindVespeneStructureStopIdle">
        <EditorCategories value=""/>
        <AreaArray Effect="WorkerStartStopIdleAbility"/>
        <SearchFlags index="ExtendByUnitRadius" value="1"/>
        <SearchFlags index="SameCliff" value="1"/>
    </CEffectEnumArea>
    
         <!--Issue Order Effect that starts the Ability-->
    <CEffectIssueOrder id="WorkerStartStopIdleAbility">
        <EditorCategories value=""/>
        <WhichUnit Value="Caster"/>
        <Abil value="WorkerStopIdleAbilityVespene"/>
        <CmdFlags index="Preempt" value="1"/>
        <CmdFlags index="AutoQueued" value="1"/>
        <Target Value="TargetUnit"/>
    </CEffectIssueOrder>
        
         <!--The Effect (channeled) by the Ability-->
    <CEffectCreatePersistent id="WorkerChannelStopIdle">
        <ValidatorArray value="HasVespene"/>
        <ValidatorArray value="WorkerNoIdleChannelOrder"/>
        <ValidatorArray value="WorkerCasterGatheringThisCombine"/>
        <EditorCategories value=""/>
        <WhichLocation Value="TargetUnit"/>
        <Flags index="Channeled" value="1"/>
        <Flags index="PersistUntilDestroyed" value="1"/>
        <PeriodicValidator value="IsUnderConstruction"/>
    </CEffectCreatePersistent>
     

    Abilities

    <!--Ability-->
    <CAbilEffectTarget id="WorkerStopIdleAbilityVespene">
        <Effect index="0" value="WorkerChannelStopIdle"/>
        <Flags index="AllowMovement" value="1"/>
        <Flags index="BestUnit" value="0"/>
        <TargetFilters value="Structure,HarvestableResource,Visible,UnderConstruction;Self,Ally,Neutral,Enemy,Dead,Hidden"/>
        <Range value="0.25"/>
        <CmdButtonArray index="Execute" DefaultButtonFace="Gather"/>
    </CAbilEffectTarget>
     

    Validators

    <!--Validators-->
         <!--Validators confirming the target of the periodic search is the particular geyser the worker is going to mine from-->
    <CValidatorUnitOrderQueue id="WorkerDroneGatheringThis">
        <AbilLink value="DroneHarvest"/>
        <Target Value="TargetUnit"/>
    </CValidatorUnitOrderQueue>
    <CValidatorUnitOrderQueue id="WorkerSCVGatheringThis">
        <AbilLink value="SCVHarvest"/>
        <Target Value="TargetUnit"/>
    </CValidatorUnitOrderQueue>
    <CValidatorUnitOrderQueue id="WorkerProbeGatheringThis">
        <AbilLink value="ProbeHarvest"/>
        <Target Value="TargetUnit"/>
    </CValidatorUnitOrderQueue>
    <CValidatorCombine id="WorkerCasterGatheringThisCombine">
        <CombineArray value="WorkerDroneGatheringThis"/>
        <CombineArray value="WorkerProbeGatheringThis"/>
        <CombineArray value="WorkerSCVGatheringThis"/>
    </CValidatorCombine>
    
     <!--Validator that makes sure the worker isn't already channeling before issuing a new channel order-->
    <CValidatorUnitCompareOrderCount id="WorkerNoIdleChannelOrder">
        <ResultNoUnit value="NotWhileOccupied"/>
        <AbilLink value="WorkerStopIdleAbilityVespene"/>
    </CValidatorUnitCompareOrderCount>
    
         <!--Validators that tell the Periodic Search Behaviour to disable itself unless the worker is mining. To be honest these could probably be cut out as it is my well-intentioned attempt to mitigate any performance impact by reducing the number of periodic searches... except doing multiple comparisons to enable/disable the ability may just have the same impact making it pointless -->
    <CValidatorUnitCompareOrderCount id="WorkerIsDroneHarvesting">
        <ResultFailed value="Error,Is Not Harvesting"/>
        <AbilLink value="DroneHarvest"/>
        <Value value="1"/>
    </CValidatorUnitCompareOrderCount>
    <CValidatorUnitCompareOrderCount id="WorkerIsProbeHarvesting">
        <ResultFailed value="Error,Is Not Harvesting"/>
        <AbilLink value="ProbeHarvest"/>
        <Value value="1"/>
    </CValidatorUnitCompareOrderCount>
    <CValidatorUnitCompareOrderCount id="WorkerIsSCVHarvesting">
        <ResultFailed value="Error,Is Not Harvesting"/>
        <AbilLink value="SCVHarvest"/>
        <Value value="1"/>
    </CValidatorUnitCompareOrderCount>
    <CValidatorCombine id="WorkerIsHarvestingCombine">
        <CombineArray value="WorkerIsDroneHarvesting"/>
        <CombineArray value="WorkerIsProbeHarvesting"/>
        <CombineArray value="WorkerIsSCVHarvesting"/>
    </CValidatorCombine>
    
    
         <!--Validators that prevent workers that already have gas from sitting uselessly waiting for a refinery to finish. To be honest these could probably be cut out as well. It's a nice little QoL that makes things feel polished to leave them in but it really is a lot of validators for pretty small impact so up to you-->
     <CValidatorUnitCompareBehaviorCount id="WorkerNotCarryingRichVespeneProtoss">
        <WhichUnit Value="Caster"/>
        <Behavior value="CarryHarvestableRichVespeneGeyserGasProtoss"/>
    </CValidatorUnitCompareBehaviorCount>
    <CValidatorUnitCompareBehaviorCount id="WorkerNotCarryingRichVespeneZerg">
        <WhichUnit Value="Caster"/>
        <Behavior value="CarryHarvestableRichVespeneGeyserGasZerg"/>
    </CValidatorUnitCompareBehaviorCount>
    <CValidatorUnitCompareBehaviorCount id="WorkerNotCarryingRichVespeneTerran">
        <WhichUnit Value="Caster"/>
        <Behavior value="CarryHarvestableVespeneGeyserGas"/>
    </CValidatorUnitCompareBehaviorCount>
    <CValidatorUnitCompareBehaviorCount id="WorkerNotCarryingVespeneProtoss">
        <WhichUnit Value="Caster"/>
        <Behavior value="CarryHarvestableVespeneGeyserGasProtoss"/>
    </CValidatorUnitCompareBehaviorCount>
    <CValidatorUnitCompareBehaviorCount id="WorkerNotCarryingVespeneZerg">
        <WhichUnit Value="Caster"/>
        <Behavior value="CarryHarvestableVespeneGeyserGasZerg"/>
    </CValidatorUnitCompareBehaviorCount>
    <CValidatorUnitCompareBehaviorCount id="WorkerNotCarryingVespeneTerran">
        <WhichUnit Value="Caster"/>
        <Behavior value="CarryHarvestableVespeneGeyserGas"/>
    </CValidatorUnitCompareBehaviorCount>
    <CValidatorCombine id="WorkerNotCarryingVespeneCombine">
        <Type value="And"/>
        <CombineArray value="WorkerNotCarryingRichVespeneProtoss"/>
        <CombineArray value="WorkerNotCarryingRichVespeneTerran"/>
        <CombineArray value="WorkerNotCarryingRichVespeneZerg"/>
        <CombineArray value="WorkerNotCarryingVespeneProtoss"/>
        <CombineArray value="WorkerNotCarryingVespeneTerran"/>
        <CombineArray value="WorkerNotCarryingVespeneZerg"/>
    </CValidatorCombine>
     

    Units

    <!--Units (Workers need the ability and behaviour added)-->
    <CUnit id="SCV">
       <AbilArray Link="WorkerStopIdleAbilityVespene"/>
       <BehaviorArray Link="PeriodicRefineryCheck"/>
    </CUnit>
    <CUnit id="Probe">
       <AbilArray Link="WorkerStopIdleAbilityVespene"/>
       <BehaviorArray Link="PeriodicRefineryCheck"/>
    </CUnit>
    <CUnit id="Drone">
       <AbilArray Link="WorkerStopIdleAbilityVespene"/>
       <BehaviorArray Link="PeriodicRefineryCheck"/>
    </CUnit>
    Posted in: Data
  • To post a comment, please or register a new account.