Skip to content

Commit

Permalink
Add on-fit pilot security attribute, and use it in effects
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkFenX committed Oct 30, 2024
1 parent 2bb35a1 commit b807e2a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
15 changes: 15 additions & 0 deletions eos/db/migrations/upgrade48.py
Original file line number Diff line number Diff line change
@@ -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")
3 changes: 2 additions & 1 deletion eos/db/saveddata/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
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,
Expand Down
22 changes: 12 additions & 10 deletions eos/effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -40869,12 +40871,12 @@ def handler(fit, ship, context, projectionRange, **kwargs):

# 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')
Expand Down
13 changes: 13 additions & 0 deletions eos/saveddata/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1743,6 +1743,18 @@ def getSystemSecurity(self):
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:
Expand Down Expand Up @@ -1824,6 +1836,7 @@ def __deepcopy__(self, memo=None):
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:
Expand Down

0 comments on commit b807e2a

Please sign in to comment.