undockQuestions.py (7080B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\station\undockQuestions.py 2 import structures 3 from ballparkCommon.docking import CanDock 4 from carbonui import const as uiconst 5 from eve.client.script.ui.station.askForUndock import IsOkToBoardWithModulesLackingSkills 6 from eve.common.lib import appConst 7 from eve.common.script.sys.idCheckers import IsStation 8 from eve.common.script.util.facwarCommon import IsOccupierEnemyFaction 9 from evestations.standingsrestriction import get_station_standings_restriction 10 from eveuniverse.security import is_high_sec_or_higher, is_low_sec_or_higher 11 from factionwarfare.dockableChecks import IsDockableStructureUsageRestrictedByOccupationState, IsShipExemptFromDockingRestrictions 12 from operations.client.operationscontroller import GetOperationsController 13 from operations.client.util import are_operations_active 14 from player_messaging.client.ui_message import prompt_player_fsd_dialog 15 16 def IsOkToUndock(): 17 if not IsOkToUndockInUnfriendlySpace(): 18 return False 19 if not IsOkToUndockInHighSecWhileAtWar(): 20 return False 21 if not IsOkToBoardWithModulesLackingSkills(sm.GetService('clientDogmaIM').GetDogmaLocation()): 22 return False 23 if not IsOkToUndockWithCrimewatchTimers(): 24 return False 25 if not IsOkToUndockInInceptionNPE(): 26 return False 27 if not IsOkToUndockFromStructureInShipThatCannotRedock(): 28 return False 29 if not IsOkToUndockInHighSecIfMilitiaMember(): 30 return False 31 if not IsOkToUndockStandingsRestriction(): 32 return False 33 return True 34 35 36 def IsOkToUndockFromStructureInShipThatCannotRedock(): 37 if session.structureid: 38 invCache = sm.GetService('invCache') 39 shipTypeID = invCache.GetInventoryFromId(session.shipid).typeID 40 stationTypeID = invCache.GetInventoryFromId(session.structureid).typeID 41 if not CanDock(stationTypeID, shipTypeID): 42 msgResult = prompt_player_fsd_dialog('AskUndockWithShipThatCannotDock', {'item': shipTypeID}, uiconst.YESNO) 43 return msgResult == uiconst.ID_YES 44 return True 45 46 47 def IsOkToUndockInUnfriendlySpace(): 48 if settings.user.suppress.Get('suppress.AskUndockInEnemySystem', None): 49 return True 50 if session.structureid: 51 if sm.RemoteSvc('structureSettings').CharacterHasSetting(session.structureid, structures.SETTING_HOUSING_CAN_DOCK): 52 return True 53 from eve.client.script.ui.shared.dockedUI.controllers.structureController import StructureController 54 structureController = StructureController(itemID=session.structureid) 55 ownerName = cfg.eveowners.Get(structureController.GetOwnerID()).ownerName 56 if not _ConfirmDoUndockInEnemySystem(ownerName): 57 return False 58 elif session.warfactionid: 59 fwOccupationState = sm.GetService('fwWarzoneSvc').GetLocalOccupationState() 60 if fwOccupationState and not fwOccupationState.isFrontline: 61 if IsOccupierEnemyFaction(session.warfactionid, fwOccupationState.occupierID): 62 occupierName = cfg.eveowners.Get(fwOccupationState.occupierID).ownerName 63 if not _ConfirmDoUndockInEnemySystem(occupierName): 64 return False 65 return True 66 67 68 def _ConfirmDoUndockInEnemySystem(ownerName): 69 if prompt_player_fsd_dialog('AskUndockInEnemySystem', {'sovHolderName': ownerName}, uiconst.YESNO, suppress=uiconst.ID_YES) != uiconst.ID_YES: 70 return False 71 return True 72 73 74 def IsOkToUndockInHighSecWhileAtWar(): 75 if not sm.GetService('securitySvc').is_effective_high_sec_system(session.solarsystemid2): 76 return True 77 if not sm.GetService('war').IsPlayerCurrentlyAtWarOrInFW(): 78 return True 79 if prompt_player_fsd_dialog('AskUndockInHighSecWhileAtWar', {}, uiconst.YESNO) != uiconst.ID_YES: 80 return False 81 return True 82 83 84 def IsOkToUndockWithCrimewatchTimers(): 85 systemSecStatus = sm.GetService('securitySvc').get_modified_security_class(session.solarsystemid2) 86 crimewatchSvc = sm.GetService('crimewatchSvc') 87 if crimewatchSvc.IsCriminal(session.charid): 88 if is_high_sec_or_higher(systemSecStatus): 89 if prompt_player_fsd_dialog('UndockCriminalConfirm', {}, uiconst.YESNO) == uiconst.ID_YES: 90 return True 91 else: 92 return False 93 if is_low_sec_or_higher(systemSecStatus): 94 engagements = crimewatchSvc.GetMyEngagements() 95 if len(engagements): 96 if prompt_player_fsd_dialog('UndockAggressionConfirm', {}, uiconst.YESNO, suppress=uiconst.ID_YES) != uiconst.ID_YES: 97 return False 98 return True 99 100 101 def IsOkToUndockWithMissingCargo(): 102 if settings.user.suppress.Get('suppress.CourierUndockMissingCargo', None): 103 return True 104 if sm.GetService('journal').CheckUndock(session.stationid): 105 return True 106 return False 107 108 109 def IsOkToUndockInInceptionNPE(): 110 if not are_operations_active(): 111 return True 112 return GetOperationsController().can_undock() 113 114 115 def IsOkToUndockInHighSecIfMilitiaMember(): 116 if not session.warfactionid: 117 return True 118 systemCheckSupressed = settings.user.suppress.Get('suppress.FacWarWarningUndock', None) == uiconst.ID_OK 119 if systemCheckSupressed: 120 return True 121 dockableItem = None 122 if sm.GetService('station').stationItem: 123 dockableItem = sm.GetService('station').stationItem 124 elif session.structureid: 125 structureInfo = sm.GetService('structureDirectory').GetStructureInfo(session.structureid) 126 if structureInfo: 127 dockableItem = structureInfo 128 if not dockableItem: 129 return True 130 isSafe = sm.GetService('facwar').CheckForSafeSystem(dockableItem, session.warfactionid) 131 if isSafe: 132 return True 133 if not prompt_player_fsd_dialog('FacWarWarningUndock', {}, uiconst.OKCANCEL) == uiconst.ID_OK: 134 settings.user.suppress.Set('suppress.FacWarWarningUndock', None) 135 return False 136 return True 137 138 139 def IsOkToUndockStandingsRestriction(): 140 if not IsStation(session.locationid): 141 return True 142 standingsRestriction = get_station_standings_restriction(appConst.stationServiceDocking, session.locationid, session.charid) 143 if not standingsRestriction: 144 return True 145 userInput = prompt_player_fsd_dialog('AskUndockStandingsRestriction', params=standingsRestriction, buttons=uiconst.YESNO) 146 return userInput == uiconst.ID_YES 147 148 149 def CheckOkToUndockWhileAttackerInFW(): 150 if not session.warfactionid: 151 return 152 if not sm.GetService('fwWarzoneSvc').IsWarzoneSolarSystem(session.solarsystemid2): 153 return 154 invCache = sm.GetService('invCache') 155 shipTypeID = invCache.GetInventoryFromId(session.shipid).typeID 156 if IsShipExemptFromDockingRestrictions(shipTypeID): 157 return 158 occupationState = sm.GetService('fwWarzoneSvc').GetLocalOccupationState() 159 restricted = IsDockableStructureUsageRestrictedByOccupationState(occupationState, session.warfactionid) 160 if restricted: 161 raise UserError('CantUndockWhenAttackerInFw')