NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

deployment.py (8410B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\structures\deployment.py
      2 import math
      3 import evetypes
      4 import inventorycommon.const
      5 from moonmining.const import MAXIMUM_MINING_BEACON_DISTANCE, MOONMINING_NOT_POSSIBLE, MOONMINING_POSSIBLE, MOONMINING_NEVER_AVAILABLE
      6 from moonmining.miningBeacons import GetMiningBeaconPositionForMoon, FindMoonBeaconInRangeOfPosition
      7 from eveprefs import boot
      8 GROUP_DISTANCE = {inventorycommon.const.groupMoonMiningBeacon: 0,
      9  inventorycommon.const.groupBiomass: 5000,
     10  inventorycommon.const.groupWreck: 5000,
     11  inventorycommon.const.groupCargoContainer: 5000,
     12  inventorycommon.const.groupSpawnContainer: 5000,
     13  inventorycommon.const.groupSecureCargoContainer: 5000,
     14  inventorycommon.const.groupAuditLogSecureContainer: 5000,
     15  inventorycommon.const.groupFreightContainer: 5000,
     16  inventorycommon.const.groupIndustrialSupportFacility: 5000,
     17  inventorycommon.const.groupStationConversionMonument: 100000,
     18  inventorycommon.const.groupLargeCollidableObject: 100000,
     19  inventorycommon.const.groupEncounterSurveillanceSystem: 1000000,
     20  inventorycommon.const.groupStructureNpcEngineeringComplex: 2000000,
     21  inventorycommon.const.groupControlBunker: 1000000,
     22  inventorycommon.const.groupStructureJumpBridge: 500000,
     23  inventorycommon.const.groupStructureCynoJammer: 500000,
     24  inventorycommon.const.groupStructureCynoBeacon: 200000,
     25  inventorycommon.const.groupInfrastructureHub: 10000000}
     26 CATEGORY_DISTANCES = {inventorycommon.const.categoryEntity: 5000,
     27  inventorycommon.const.categoryShip: 5000,
     28  inventorycommon.const.categoryDrone: 5000,
     29  inventorycommon.const.categoryFighter: 5000,
     30  inventorycommon.const.categoryDeployable: 5000,
     31  inventorycommon.const.categoryAsteroid: 5000,
     32  inventorycommon.const.categoryCelestial: 1000000,
     33  inventorycommon.const.categoryOrbital: 1000000,
     34  inventorycommon.const.categorySovereigntyStructure: 1000000,
     35  inventorycommon.const.categoryStation: 1000000,
     36  inventorycommon.const.categoryStarbase: 1000000,
     37  inventorycommon.const.categoryStructure: 1000000}
     38 GROUP_MIN_DISTANCE_TO_STARGATE = {inventorycommon.const.groupStructureJumpBridge: 100000000}
     39 GROUPS_REQUIRING_CONQUERABLE_SYSTEM = {inventorycommon.const.groupStructureJumpBridge, inventorycommon.const.groupStructureCynoJammer, inventorycommon.const.groupStructureCynoBeacon}
     40 MAX_GROUP_PER_SOLARSYSTEM = {inventorycommon.const.groupStructureJumpBridge: 1,
     41  inventorycommon.const.groupStructureCynoJammer: 1,
     42  inventorycommon.const.groupStructureCynoBeacon: 1}
     43 MAX_ADM_FOR_HOSTILE_DEPLOYMENT_BY_TYPE = {inventorycommon.const.typeCitadelAstrahus: 4,
     44  inventorycommon.const.typeEngineeringComplexRaitaru: 4,
     45  inventorycommon.const.typeRefineryAthanor: 4}
     46 MINIMUM_MOON_DISTANCE = 4000000
     47 WARPIN_POINT = 1
     48 REAL_BALL = 2
     49 JUMP_BRIDGE_LINK_CHARACTER = u'\xbb'
     50 AUTOMOONMINER_DESIGNATED_SPOTS = 0
     51 AUTOMOONMINER_BEACON = 1
     52 DEPLOY_DIST_MAX = 800000
     53 
     54 def GetDeploymentDistance(typeID):
     55     import evetypes
     56     groupID = evetypes.GetGroupID(typeID)
     57     categoryID = evetypes.GetCategoryID(typeID)
     58     return GROUP_DISTANCE.get(groupID, CATEGORY_DISTANCES.get(categoryID, 0))
     59 
     60 
     61 def GetDeploymentConflictForBalls(ballpark, ballsAndItems, typeID, position):
     62     balls = [ (item.itemID,
     63      item.typeID,
     64      (ball.x, ball.y, ball.z),
     65      ball.radius,
     66      REAL_BALL) for ball, item in ballsAndItems ]
     67     balls += [ (item.itemID,
     68      item.typeID,
     69      xyz,
     70      0,
     71      WARPIN_POINT) for ball, item, xyz in ballpark.GetWarpinPoints() ]
     72     conflict = FindDeploymentConflict(ballpark.solarsystemID, typeID, position, balls)
     73     return conflict
     74 
     75 
     76 def FindDeploymentConflict(solarSystemID, typeID, location, balls):
     77     import evetypes
     78     from eve.common.script.sys import idCheckers
     79     groupID = evetypes.GetGroupID(typeID)
     80     typeRadius = evetypes.GetRadius(typeID)
     81     isDrillingPlatform = IsDrillingPlatform(typeID)
     82     hasGroupStargateRestriction = HasGroupStargateRestriction(groupID)
     83     myDeploymentDistance = GetDeploymentDistance(typeID)
     84     if idCheckers.IsAutoMoonMiner(typeID):
     85         moonID = FindMoonBeaconInRangeOfPosition(solarSystemID, location, MAXIMUM_MINING_BEACON_DISTANCE)
     86         if not moonID:
     87             return (inventorycommon.const.typeMoonMiningBeacon, -MAXIMUM_MINING_BEACON_DISTANCE, REAL_BALL)
     88     for ballID, ballTypeID, position, radius, pointType in balls:
     89         distanceBetween = DistanceBetween(location, position)
     90         if _IsBallMoon(ballTypeID, pointType) and distanceBetween < MINIMUM_MOON_DISTANCE + typeRadius + radius:
     91             canDeployNearMoon = False
     92             if isDrillingPlatform:
     93                 miningBeaconPosition = GetMiningBeaconPositionForMoon(ballID)
     94                 if miningBeaconPosition is not None:
     95                     if DistanceBetween(miningBeaconPosition, location) < MAXIMUM_MINING_BEACON_DISTANCE:
     96                         canDeployNearMoon = True
     97             if not canDeployNearMoon:
     98                 return (ballTypeID, MINIMUM_MOON_DISTANCE, pointType)
     99         if hasGroupStargateRestriction and IsStargate(ballTypeID):
    100             minimumDistance = GROUP_MIN_DISTANCE_TO_STARGATE[groupID]
    101             if distanceBetween < minimumDistance + typeRadius + radius:
    102                 return (ballTypeID, minimumDistance, pointType)
    103         minimum = GetDeploymentDistance(ballTypeID)
    104         if evetypes.GetCategoryID(ballTypeID) == inventorycommon.const.categoryStructure:
    105             minimum = min(minimum, myDeploymentDistance)
    106         if minimum and distanceBetween < minimum + typeRadius + radius:
    107             return (ballTypeID, minimum, pointType)
    108 
    109 
    110 def _IsBallMoon(ballTypeID, pointType):
    111     isBallMoon = pointType == REAL_BALL and evetypes.GetGroupID(ballTypeID) == inventorycommon.const.groupMoon
    112     return isBallMoon
    113 
    114 
    115 def IsDrillingPlatform(typeID):
    116     return evetypes.GetGroupID(typeID) in (inventorycommon.const.groupStructureDrillingPlatform, inventorycommon.const.groupUpwellMoonDrill)
    117 
    118 
    119 def HasGroupStargateRestriction(groupID):
    120     return groupID in GROUP_MIN_DISTANCE_TO_STARGATE
    121 
    122 
    123 def IsStargate(typeID):
    124     return evetypes.GetGroupID(typeID) == inventorycommon.const.groupStargate
    125 
    126 
    127 def GetMoonminingAvailabilityValueForBalls(ballsAndItems, typeID, location):
    128     if not IsDrillingPlatform(typeID):
    129         return MOONMINING_NEVER_AVAILABLE
    130     balls = [ (item.itemID,
    131      item.typeID,
    132      (ball.x, ball.y, ball.z),
    133      ball.radius,
    134      REAL_BALL) for ball, item in ballsAndItems ]
    135     typeRadius = evetypes.GetRadius(typeID)
    136     for ballID, ballTypeID, position, radius, pointType in balls:
    137         if not _IsBallMoon(ballTypeID, pointType):
    138             continue
    139         distanceBetween = DistanceBetween(location, position)
    140         if distanceBetween < MINIMUM_MOON_DISTANCE + typeRadius + radius:
    141             miningBeaconPosition = GetMiningBeaconPositionForMoon(ballID)
    142             if not miningBeaconPosition:
    143                 return MOONMINING_NEVER_AVAILABLE
    144             if DistanceBetween(miningBeaconPosition, location) < MAXIMUM_MINING_BEACON_DISTANCE:
    145                 return MOONMINING_POSSIBLE
    146 
    147     return MOONMINING_NOT_POSSIBLE
    148 
    149 
    150 def DistanceBetween(a, b):
    151     return math.sqrt(sum([ (a - b) ** 2 for a, b in zip(a, b) ]))
    152 
    153 
    154 def GetStructureNamePrefix(structureTypeID, solarSystemID, extraConfig = None):
    155     solarSystemName = GetUntranslatedSolarSystemName(solarSystemID)
    156     if evetypes.IsUpwellStargate(structureTypeID):
    157         if extraConfig is None:
    158             raise RuntimeError("Shouldn't be here without destinationSolarsystemID")
    159         destinationSolarsystemID = extraConfig.get('destinationSolarsystemID', None)
    160         if not destinationSolarsystemID:
    161             raise RuntimeError("Shouldn't be here without destinationSolarsystemID")
    162         destinationSystemName = GetUntranslatedSolarSystemName(destinationSolarsystemID)
    163         return '%s %s %s - ' % (solarSystemName, JUMP_BRIDGE_LINK_CHARACTER, destinationSystemName)
    164     else:
    165         return '%s - ' % solarSystemName
    166 
    167 
    168 def GetUntranslatedSolarSystemName(solarsystemID):
    169     import localization
    170     from localization import CleanImportantMarkup
    171     if boot.region == 'optic':
    172         languageID = localization.const.LOCALE_SHORT_CHINESE
    173     else:
    174         languageID = localization.const.LOCALE_SHORT_ENGLISH
    175     solarSystemInfo = cfg.mapSystemCache.get(solarsystemID, None)
    176     return CleanImportantMarkup(localization.GetByMessageID(solarSystemInfo.nameID, languageID=languageID))