Add on-fit pilot security attribute, and use it in effects
This commit is contained in:
15
eos/db/migrations/upgrade48.py
Normal file
15
eos/db/migrations/upgrade48.py
Normal file
@@ -0,0 +1,15 @@
|
||||
"""
|
||||
Migration 48
|
||||
|
||||
- added pilot security column (CONCORD ships)
|
||||
"""
|
||||
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
|
||||
def upgrade(saveddata_engine):
|
||||
try:
|
||||
saveddata_engine.execute("SELECT pilotSecurity FROM fits LIMIT 1")
|
||||
except sqlalchemy.exc.DatabaseError:
|
||||
saveddata_engine.execute("ALTER TABLE fits ADD COLUMN pilotSecurity FLOAT")
|
||||
@@ -63,7 +63,8 @@ fits_table = Table("fits", saveddata_meta,
|
||||
Column("ignoreRestrictions", Boolean, default=0),
|
||||
Column("created", DateTime, nullable=True, default=datetime.datetime.now),
|
||||
Column("modified", DateTime, nullable=True, default=datetime.datetime.now, onupdate=datetime.datetime.now),
|
||||
Column("systemSecurity", Integer, nullable=True)
|
||||
Column("systemSecurity", Integer, nullable=True),
|
||||
Column("pilotSecurity", Float, nullable=True),
|
||||
)
|
||||
|
||||
projectedFits_table = Table("projectedFits", saveddata_meta,
|
||||
|
||||
@@ -32121,22 +32121,24 @@ class Effect6871(BaseEffect):
|
||||
type = 'passive'
|
||||
|
||||
@staticmethod
|
||||
def handler(fit, src, context, projectionRange, **kwargs):
|
||||
def handler(fit, ship, context, projectionRange, **kwargs):
|
||||
|
||||
# Get pilot sec status bonus directly here, instead of going through the intermediary effects
|
||||
# via https://forums.eveonline.com/default.aspx?g=posts&t=515826
|
||||
try:
|
||||
bonus = max(0, min(50.0, (src.owner.character.secStatus * 10)))
|
||||
sec_status = ship.owner.getPilotSecurity(low_limit=0, high_limit=5)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
bonus = None
|
||||
return
|
||||
|
||||
if bonus is not None:
|
||||
fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill('Repair Systems'),
|
||||
'armorDamageAmount', bonus, **kwargs)
|
||||
fit.modules.filteredItemBoost(lambda mod: mod.item.requiresSkill('Shield Operation'),
|
||||
'shieldBonus', bonus, **kwargs)
|
||||
bonus = sec_status * 10
|
||||
fit.modules.filteredItemBoost(
|
||||
lambda mod: mod.item.requiresSkill('Repair Systems'),
|
||||
'armorDamageAmount', bonus, **kwargs)
|
||||
fit.modules.filteredItemBoost(
|
||||
lambda mod: mod.item.requiresSkill('Shield Operation'),
|
||||
'shieldBonus', bonus, **kwargs)
|
||||
|
||||
|
||||
class Effect6872(BaseEffect):
|
||||
@@ -40869,12 +40871,12 @@ class Effect12165(BaseEffect):
|
||||
|
||||
# Get pilot sec status bonus directly here, instead of going through the intermediary effects
|
||||
try:
|
||||
capped_ss = max(-10, min(0, (ship.owner.character.secStatus)))
|
||||
sec_status = ship.owner.getPilotSecurity(low_limit=-10, high_limit=0)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except:
|
||||
return
|
||||
bonus = ship.getModifiedItemAttr('ATFrigDmgBonus') * capped_ss
|
||||
bonus = ship.getModifiedItemAttr('ATFrigDmgBonus') * sec_status
|
||||
fit.modules.filteredItemBoost(
|
||||
lambda mod: (mod.item.requiresSkill('Small Energy Turret')
|
||||
or mod.item.requiresSkill('Small Hybrid Turret')
|
||||
|
||||
@@ -1743,6 +1743,18 @@ class Fit:
|
||||
secstatus = FitSystemSecurity.NULLSEC
|
||||
return secstatus
|
||||
|
||||
def getPilotSecurity(self, low_limit=-10, high_limit=5):
|
||||
secstatus = self.pilotSecurity
|
||||
# Not defined -> use character SS, with 0.0 fallback if it fails
|
||||
if secstatus is None:
|
||||
try:
|
||||
secstatus = self.character.secStatus
|
||||
except (SystemExit, KeyboardInterrupt):
|
||||
raise
|
||||
except:
|
||||
secstatus = 0
|
||||
return max(low_limit, min(high_limit, secstatus))
|
||||
|
||||
def activeModulesIter(self):
|
||||
for mod in self.modules:
|
||||
if mod.state >= FittingModuleState.ACTIVE:
|
||||
@@ -1824,6 +1836,7 @@ class Fit:
|
||||
fitCopy.targetProfile = self.targetProfile
|
||||
fitCopy.implantLocation = self.implantLocation
|
||||
fitCopy.systemSecurity = self.systemSecurity
|
||||
fitCopy.pilotSecurity = self.pilotSecurity
|
||||
fitCopy.notes = self.notes
|
||||
|
||||
for i in self.modules:
|
||||
|
||||
Reference in New Issue
Block a user