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

tracker.py (7848B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\dogma\effects\tracker.py
      2 from eve.common.script.sys import idCheckers
      3 from eveprefs import prefs
      4 from eveProto.generated.eve.effect.support.remote.pvp_pb2 import ShieldBoostApplied, ArmorRepairApplied, HullRepairApplied, CapacitorTransmissionApplied, TrackingComputerApplied, SensorBoosterApplied
      5 from logging import getLogger
      6 logger = getLogger(__name__)
      7 
      8 class DogmaEffectTracker(object):
      9 
     10     @classmethod
     11     def _track_effect(cls, event_class, *args):
     12         sm.GetService('externalQueueMgr').PublishEvent(event_class, *args)
     13 
     14     @classmethod
     15     def track_electronic_warfare_effect(cls, event_class, attacker_char_id, victim_char_id, value, module_type_id):
     16         if idCheckers.IsEvePlayerCharacter(attacker_char_id) and idCheckers.IsEvePlayerCharacter(victim_char_id):
     17             cls._track_effect(event_class, attacker_char_id, victim_char_id, int(round(value)), module_type_id)
     18 
     19     @classmethod
     20     def track_remote_support_effect(cls, event_class, actor_id, actor_ship_id, actor_ship_type_id, target_id, target_ship_id, target_ship_type_id, target_ship_class, target_corp_id, target_alliance_id, target_faction_id, change_amount, module_type_id, solar_system_id, constellation_id, region_id):
     21         if not idCheckers.IsEvePlayerCharacter(actor_id) or not idCheckers.IsEvePlayerCharacter(target_id):
     22             return
     23         if not idCheckers.IsShipType(actor_ship_type_id) or not idCheckers.IsShipType(target_ship_type_id):
     24             return
     25         if not idCheckers.IsModuleType(module_type_id):
     26             if not idCheckers.IsLogisticDrone(module_type_id):
     27                 return
     28         if not idCheckers.IsCorporation(target_corp_id):
     29             return
     30         if not idCheckers.IsSolarSystem(solar_system_id):
     31             return
     32         change_amount = int(round(change_amount)) if change_amount else 0
     33         event = event_class()
     34         if event_class == ShieldBoostApplied:
     35             event.booster.sequential = actor_id
     36             event.amount_boosted = change_amount
     37         elif event_class in [ArmorRepairApplied, HullRepairApplied]:
     38             event.repairer.sequential = actor_id
     39             event.amount_repaired = change_amount
     40         elif event_class == CapacitorTransmissionApplied:
     41             event.transmitter.sequential = actor_id
     42             event.amount_transmitted = change_amount
     43         elif event_class in [TrackingComputerApplied, SensorBoosterApplied]:
     44             event.booster.sequential = actor_id
     45         cls._add_target(event, event_class, target_id, target_ship_id, target_ship_type_id, target_ship_class, target_corp_id, target_alliance_id, target_faction_id)
     46         cls._add_location(event, event_class, solar_system_id, constellation_id, region_id)
     47         event.module_type.sequential = module_type_id
     48         event.actor.character.sequential = actor_id
     49         event.actor.ship.sequential = actor_ship_id
     50         event.actor.ship_type.sequential = actor_ship_type_id
     51         event.actor.module_type.sequential = module_type_id
     52         sm.GetService('externalQueueMgr').PublishEventPayload(event)
     53         cls._log_remote_support_effect(event_class, actor_id, actor_ship_id, actor_ship_type_id, target_id, target_ship_id, target_ship_type_id, target_ship_class, target_corp_id, target_alliance_id, target_faction_id, change_amount, module_type_id, solar_system_id, constellation_id, region_id)
     54 
     55     @classmethod
     56     def _add_target(cls, event, event_class, target_id, target_ship_id, target_ship_type_id, target_ship_class, target_corp_id, target_alliance_id, target_faction_id):
     57         if event_class in [ShieldBoostApplied, ArmorRepairApplied]:
     58             event.target_participant.character.sequential = target_id
     59             event.target_participant.ship.sequential = target_ship_id
     60             event.target_participant.ship_type.sequential = target_ship_type_id
     61             event.target_participant.ship_class.sequential = target_ship_class
     62             event.target_participant.membership.corporation.sequential = target_corp_id
     63             if idCheckers.IsFaction(target_faction_id):
     64                 event.target_participant.membership.faction.id.sequential = target_faction_id
     65             else:
     66                 event.target_participant.membership.faction.no_faction = True
     67             if idCheckers.IsAlliance(target_alliance_id):
     68                 event.target_participant.membership.alliance.id.sequential = target_alliance_id
     69             else:
     70                 event.target_participant.membership.alliance.no_alliance = True
     71         event.target.character.sequential = target_id
     72         event.target.ship.sequential = target_ship_id
     73         event.target.ship_type.sequential = target_ship_type_id
     74         event.target.corporation.sequential = target_corp_id
     75         if idCheckers.IsFaction(target_faction_id):
     76             event.target.faction.sequential = target_faction_id
     77         else:
     78             event.target.no_faction = True
     79         if idCheckers.IsAlliance(target_alliance_id):
     80             event.target.alliance.sequential = target_alliance_id
     81         else:
     82             event.target.no_alliance = True
     83 
     84     @classmethod
     85     def _add_location(cls, event, event_class, solar_system_id, constellation_id, region_id):
     86         event.solar_system.sequential = solar_system_id
     87         if event_class in [ShieldBoostApplied, ArmorRepairApplied]:
     88             event.constellation.sequential = constellation_id
     89             event.region.sequential = region_id
     90 
     91     @classmethod
     92     def _should_log(self):
     93         return prefs.clusterMode != 'LIVE'
     94 
     95     @classmethod
     96     def _log_remote_support_effect(cls, event_class, actor_id, actor_ship_id, actor_ship_type_id, target_id, target_ship_id, target_ship_type_id, target_ship_class, target_corp_id, target_alliance_id, target_faction_id, change_amount, module_type_id, solar_system_id, constellation_id, region_id):
     97         if not cls._should_log():
     98             return
     99         from evetypes import GetName
    100         logger.info('Remote Support Effect: event {event_class}, actor {actor_name} (ID {actor_id}) in ship {actor_ship_name} (ID {actor_ship_id}, Type {actor_ship_type_id}), target {target_name} (ID {target_id}) in ship {target_ship_name} (ID {target_ship_id}, Type {target_ship_type_id}, Class {target_ship_class}) of corp {corp_name} (ID {corp_id}) and alliance {alliance_name} (ID {alliance_id}) and faction {faction_name} (ID: {faction_id}), in solar system {solar_system_name} (ID {solar_system_id}), constellation {constellation_name} (ID {constellation_id}), region {region_name} (ID {region_id}), via module {module_name} (Type {module_type_id}) and change amount {change_amount}'.format(event_class=event_class, actor_name=cfg.eveowners.Get(actor_id).ownerName, actor_id=actor_id, actor_ship_name=GetName(actor_ship_type_id), actor_ship_id=actor_ship_id, actor_ship_type_id=actor_ship_type_id, target_name=cfg.eveowners.Get(target_id).ownerName, target_id=target_id, target_ship_name=GetName(target_ship_type_id), target_ship_id=target_ship_id, target_ship_type_id=target_ship_type_id, target_ship_class=target_ship_class, corp_name=cfg.eveowners.Get(target_corp_id).ownerName, corp_id=target_corp_id, alliance_name=cfg.eveowners.Get(target_alliance_id).ownerName if target_alliance_id else '-', alliance_id=target_alliance_id or '-', faction_name=cfg.eveowners.Get(target_faction_id).ownerName if target_faction_id else '-', faction_id=target_faction_id or '-', solar_system_name=cfg.evelocations.Get(solar_system_id).name, solar_system_id=solar_system_id, constellation_name=cfg.evelocations.Get(constellation_id).name, constellation_id=constellation_id, region_name=cfg.evelocations.Get(region_id).name, region_id=region_id, module_name=GetName(module_type_id), module_type_id=module_type_id, change_amount=change_amount))