harvesting.py (2455B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\behaviors\trees\harvesting.py 2 from behaviors.actions.ballparks import SelectItemByTypes, SelectClosestPointOnObject, ApproachCoordinatesAction, FullStopAction 3 from behaviors.actions.effects import PlayOneShotStretchEffectAction 4 from behaviors.actions.timer import SucceedAfterTimeoutAction 5 from behaviors.behaviortree import BehaviorTree 6 from behaviors.blackboards.scopes import ScopeTypes 7 from behaviors.composites import Sequence, PrioritySelector 8 from behaviors.conditions.ballparks import IsCoordinateWithinDistance 9 from brennivin.itertoolsext import Bundle 10 SELECTED_HARVEST_TARGET = (ScopeTypes.EntityGroup, 'SELECTED_HARVEST_TARGET') 11 SELECTED_HARVEST_LOCATION = (ScopeTypes.Item, 'SELECTED_HARVEST_LOCATION') 12 HARVESTABLE_STRUCTURE_SET = [34573, 13 34717, 14 34761, 15 34762, 16 34763, 17 34764, 18 34765] 19 DECONSTRUCTION_EFFECT = 'effects.DeconstructionBeam' 20 HARVEST_EFFECT = 'effects.HarvestingBeam' 21 DECONSTRUCTION_DURATION_MS = 10000.0 22 HARVEST_DURATION_MS = 10000.0 23 EFFECT_DELAY_SEC = 5.0 24 25 def CreateHarvestOutpostBehaviorTree(): 26 root = CreateHarvestOutpostBehavior() 27 tree = BehaviorTree() 28 tree.StartRootTask(root) 29 return tree 30 31 32 def CreateHarvestOutpostBehavior(): 33 return Sequence(Bundle(name='Harvest Mechanical Parts')).AddSubTask(SelectItemByTypes(Bundle(typeIds=HARVESTABLE_STRUCTURE_SET, selectedItemAddress=SELECTED_HARVEST_TARGET))).AddSubTask(SelectClosestPointOnObject(Bundle(objectIdAddress=SELECTED_HARVEST_TARGET, closestPointAddress=SELECTED_HARVEST_LOCATION))).AddSubTask(PrioritySelector().AddSubTask(IsCoordinateWithinDistance(Bundle(coordinateAddress=SELECTED_HARVEST_LOCATION, maxDistance=8000.0))).AddSubTask(ApproachCoordinatesAction(Bundle(coordinateAddress=SELECTED_HARVEST_LOCATION, notifyRange=5000.0, blocking=True)))).AddSubTask(Sequence().AddSubTask(FullStopAction()).AddSubTask(PlayOneShotStretchEffectAction(Bundle(effectDuration=DECONSTRUCTION_DURATION_MS, effectName=DECONSTRUCTION_EFFECT, effectTargetAddress=SELECTED_HARVEST_TARGET))).AddSubTask(SucceedAfterTimeoutAction(Bundle(timeoutSeconds=EFFECT_DELAY_SEC + DECONSTRUCTION_DURATION_MS / 1000.0))).AddSubTask(PlayOneShotStretchEffectAction(Bundle(effectDuration=HARVEST_DURATION_MS, effectName=HARVEST_EFFECT, effectTargetAddress=SELECTED_HARVEST_TARGET))).AddSubTask(SucceedAfterTimeoutAction(Bundle(timeoutSeconds=EFFECT_DELAY_SEC + HARVEST_DURATION_MS / 1000.0))))