Skip to content

Commit 151a12d

Browse files
committed
Move MGEF/AVIF constants out of brec
They're game-specific constants and brec is becoming really big anyways with all the duplicate code that's getting moved into it, so let's move these into game/*/constants, where they belong. Note that all the MGEF stuff is Oblivion-only, but actor_values could actually be updated for the other games. I haven't done this yet, because it's only used in 100% Oblivion-specific code (save editing and patchers). Avoid circular import between brec/bush Not a problem with absolute imports, but breaks with relative ones.
1 parent 2a465a8 commit 151a12d

6 files changed

Lines changed: 396 additions & 362 deletions

File tree

Mopy/bash/brec.py

Lines changed: 10 additions & 322 deletions
Original file line numberDiff line numberDiff line change
@@ -3024,300 +3024,30 @@ def __init__(self, entry_type_val, element):
30243024
}, decider=AttrValDecider('entryType'),
30253025
fallback=MelNull('NULL')) # ignore
30263026

3027-
##: Ripped from bush.py may belong to game/
3028-
# Magic Info ------------------------------------------------------------------
3029-
_magicEffects = {
3030-
'ABAT': [5,_(u'Absorb Attribute'),0.95],
3031-
'ABFA': [5,_(u'Absorb Fatigue'),6],
3032-
'ABHE': [5,_(u'Absorb Health'),16],
3033-
'ABSK': [5,_(u'Absorb Skill'),2.1],
3034-
'ABSP': [5,_(u'Absorb Magicka'),7.5],
3035-
'BA01': [1,_(u'Bound Armor Extra 01'),0],#--Formid == 0
3036-
'BA02': [1,_(u'Bound Armor Extra 02'),0],#--Formid == 0
3037-
'BA03': [1,_(u'Bound Armor Extra 03'),0],#--Formid == 0
3038-
'BA04': [1,_(u'Bound Armor Extra 04'),0],#--Formid == 0
3039-
'BA05': [1,_(u'Bound Armor Extra 05'),0],#--Formid == 0
3040-
'BA06': [1,_(u'Bound Armor Extra 06'),0],#--Formid == 0
3041-
'BA07': [1,_(u'Bound Armor Extra 07'),0],#--Formid == 0
3042-
'BA08': [1,_(u'Bound Armor Extra 08'),0],#--Formid == 0
3043-
'BA09': [1,_(u'Bound Armor Extra 09'),0],#--Formid == 0
3044-
'BA10': [1,_(u'Bound Armor Extra 10'),0],#--Formid == 0
3045-
'BABO': [1,_(u'Bound Boots'),12],
3046-
'BACU': [1,_(u'Bound Cuirass'),12],
3047-
'BAGA': [1,_(u'Bound Gauntlets'),8],
3048-
'BAGR': [1,_(u'Bound Greaves'),12],
3049-
'BAHE': [1,_(u'Bound Helmet'),12],
3050-
'BASH': [1,_(u'Bound Shield'),12],
3051-
'BRDN': [0,_(u'Burden'),0.21],
3052-
'BW01': [1,_(u'Bound Order Weapon 1'),1],
3053-
'BW02': [1,_(u'Bound Order Weapon 2'),1],
3054-
'BW03': [1,_(u'Bound Order Weapon 3'),1],
3055-
'BW04': [1,_(u'Bound Order Weapon 4'),1],
3056-
'BW05': [1,_(u'Bound Order Weapon 5'),1],
3057-
'BW06': [1,_(u'Bound Order Weapon 6'),1],
3058-
'BW07': [1,_(u'Summon Staff of Sheogorath'),1],
3059-
'BW08': [1,_(u'Bound Priest Dagger'),1],
3060-
'BW09': [1,_(u'Bound Weapon Extra 09'),0],#--Formid == 0
3061-
'BW10': [1,_(u'Bound Weapon Extra 10'),0],#--Formid == 0
3062-
'BWAX': [1,_(u'Bound Axe'),39],
3063-
'BWBO': [1,_(u'Bound Bow'),95],
3064-
'BWDA': [1,_(u'Bound Dagger'),14],
3065-
'BWMA': [1,_(u'Bound Mace'),91],
3066-
'BWSW': [1,_(u'Bound Sword'),235],
3067-
'CALM': [3,_(u'Calm'),0.47],
3068-
'CHML': [3,_(u'Chameleon'),0.63],
3069-
'CHRM': [3,_(u'Charm'),0.2],
3070-
'COCR': [3,_(u'Command Creature'),0.6],
3071-
'COHU': [3,_(u'Command Humanoid'),0.75],
3072-
'CUDI': [5,_(u'Cure Disease'),1400],
3073-
'CUPA': [5,_(u'Cure Paralysis'),500],
3074-
'CUPO': [5,_(u'Cure Poison'),600],
3075-
'DARK': [3,_(u'DO NOT USE - Darkness'),0],
3076-
'DEMO': [3,_(u'Demoralize'),0.49],
3077-
'DGAT': [2,_(u'Damage Attribute'),100],
3078-
'DGFA': [2,_(u'Damage Fatigue'),4.4],
3079-
'DGHE': [2,_(u'Damage Health'),12],
3080-
'DGSP': [2,_(u'Damage Magicka'),2.45],
3081-
'DIAR': [2,_(u'Disintegrate Armor'),6.2],
3082-
'DISE': [2,_(u'Disease Info'),0], #--Formid == 0
3083-
'DIWE': [2,_(u'Disintegrate Weapon'),6.2],
3084-
'DRAT': [2,_(u'Drain Attribute'),0.7],
3085-
'DRFA': [2,_(u'Drain Fatigue'),0.18],
3086-
'DRHE': [2,_(u'Drain Health'),0.9],
3087-
'DRSK': [2,_(u'Drain Skill'),0.65],
3088-
'DRSP': [2,_(u'Drain Magicka'),0.18],
3089-
'DSPL': [4,_(u'Dispel'),3.6],
3090-
'DTCT': [4,_(u'Detect Life'),0.08],
3091-
'DUMY': [2,_(u'Mehrunes Dagon'),0], #--Formid == 0
3092-
'FIDG': [2,_(u'Fire Damage'),7.5],
3093-
'FISH': [0,_(u'Fire Shield'),0.95],
3094-
'FOAT': [5,_(u'Fortify Attribute'),0.6],
3095-
'FOFA': [5,_(u'Fortify Fatigue'),0.04],
3096-
'FOHE': [5,_(u'Fortify Health'),0.14],
3097-
'FOMM': [5,_(u'Fortify Magicka Multiplier'),0.04],
3098-
'FOSK': [5,_(u'Fortify Skill'),0.6],
3099-
'FOSP': [5,_(u'Fortify Magicka'),0.15],
3100-
'FRDG': [2,_(u'Frost Damage'),7.4],
3101-
'FRNZ': [3,_(u'Frenzy'),0.04],
3102-
'FRSH': [0,_(u'Frost Shield'),0.95],
3103-
'FTHR': [0,_(u'Feather'),0.1],
3104-
'INVI': [3,_(u'Invisibility'),40],
3105-
'LGHT': [3,_(u'Light'),0.051],
3106-
'LISH': [0,_(u'Shock Shield'),0.95],
3107-
'LOCK': [0,_(u'DO NOT USE - Lock'),30],
3108-
'MYHL': [1,_(u'Summon Mythic Dawn Helm'),110],
3109-
'MYTH': [1,_(u'Summon Mythic Dawn Armor'),120],
3110-
'NEYE': [3,_(u'Night-Eye'),22],
3111-
'OPEN': [0,_(u'Open'),4.3],
3112-
'PARA': [3,_(u'Paralyze'),475],
3113-
'POSN': [2,_(u'Poison Info'),0],
3114-
'RALY': [3,_(u'Rally'),0.03],
3115-
'REAN': [1,_(u'Reanimate'),10],
3116-
'REAT': [5,_(u'Restore Attribute'),38],
3117-
'REDG': [4,_(u'Reflect Damage'),2.5],
3118-
'REFA': [5,_(u'Restore Fatigue'),2],
3119-
'REHE': [5,_(u'Restore Health'),10],
3120-
'RESP': [5,_(u'Restore Magicka'),2.5],
3121-
'RFLC': [4,_(u'Reflect Spell'),3.5],
3122-
'RSDI': [5,_(u'Resist Disease'),0.5],
3123-
'RSFI': [5,_(u'Resist Fire'),0.5],
3124-
'RSFR': [5,_(u'Resist Frost'),0.5],
3125-
'RSMA': [5,_(u'Resist Magic'),2],
3126-
'RSNW': [5,_(u'Resist Normal Weapons'),1.5],
3127-
'RSPA': [5,_(u'Resist Paralysis'),0.75],
3128-
'RSPO': [5,_(u'Resist Poison'),0.5],
3129-
'RSSH': [5,_(u'Resist Shock'),0.5],
3130-
'RSWD': [5,_(u'Resist Water Damage'),0], #--Formid == 0
3131-
'SABS': [4,_(u'Spell Absorption'),3],
3132-
'SEFF': [0,_(u'Script Effect'),0],
3133-
'SHDG': [2,_(u'Shock Damage'),7.8],
3134-
'SHLD': [0,_(u'Shield'),0.45],
3135-
'SLNC': [3,_(u'Silence'),60],
3136-
'STMA': [2,_(u'Stunted Magicka'),0],
3137-
'STRP': [4,_(u'Soul Trap'),30],
3138-
'SUDG': [2,_(u'Sun Damage'),9],
3139-
'TELE': [4,_(u'Telekinesis'),0.49],
3140-
'TURN': [1,_(u'Turn Undead'),0.083],
3141-
'VAMP': [2,_(u'Vampirism'),0],
3142-
'WABR': [0,_(u'Water Breathing'),14.5],
3143-
'WAWA': [0,_(u'Water Walking'),13],
3144-
'WKDI': [2,_(u'Weakness to Disease'),0.12],
3145-
'WKFI': [2,_(u'Weakness to Fire'),0.1],
3146-
'WKFR': [2,_(u'Weakness to Frost'),0.1],
3147-
'WKMA': [2,_(u'Weakness to Magic'),0.25],
3148-
'WKNW': [2,_(u'Weakness to Normal Weapons'),0.25],
3149-
'WKPO': [2,_(u'Weakness to Poison'),0.1],
3150-
'WKSH': [2,_(u'Weakness to Shock'),0.1],
3151-
'Z001': [1,_(u'Summon Rufio\'s Ghost'),13],
3152-
'Z002': [1,_(u'Summon Ancestor Guardian'),33.3],
3153-
'Z003': [1,_(u'Summon Spiderling'),45],
3154-
'Z004': [1,_(u'Summon Flesh Atronach'),1],
3155-
'Z005': [1,_(u'Summon Bear'),47.3],
3156-
'Z006': [1,_(u'Summon Gluttonous Hunger'),61],
3157-
'Z007': [1,_(u'Summon Ravenous Hunger'),123.33],
3158-
'Z008': [1,_(u'Summon Voracious Hunger'),175],
3159-
'Z009': [1,_(u'Summon Dark Seducer'),1],
3160-
'Z010': [1,_(u'Summon Golden Saint'),1],
3161-
'Z011': [1,_(u'Wabba Summon'),0],
3162-
'Z012': [1,_(u'Summon Decrepit Shambles'),45],
3163-
'Z013': [1,_(u'Summon Shambles'),87.5],
3164-
'Z014': [1,_(u'Summon Replete Shambles'),150],
3165-
'Z015': [1,_(u'Summon Hunger'),22],
3166-
'Z016': [1,_(u'Summon Mangled Flesh Atronach'),22],
3167-
'Z017': [1,_(u'Summon Torn Flesh Atronach'),32.5],
3168-
'Z018': [1,_(u'Summon Stitched Flesh Atronach'),75.5],
3169-
'Z019': [1,_(u'Summon Sewn Flesh Atronach'),195],
3170-
'Z020': [1,_(u'Extra Summon 20'),0],
3171-
'ZCLA': [1,_(u'Summon Clannfear'),75.56],
3172-
'ZDAE': [1,_(u'Summon Daedroth'),123.33],
3173-
'ZDRE': [1,_(u'Summon Dremora'),72.5],
3174-
'ZDRL': [1,_(u'Summon Dremora Lord'),157.14],
3175-
'ZFIA': [1,_(u'Summon Flame Atronach'),45],
3176-
'ZFRA': [1,_(u'Summon Frost Atronach'),102.86],
3177-
'ZGHO': [1,_(u'Summon Ghost'),22],
3178-
'ZHDZ': [1,_(u'Summon Headless Zombie'),56],
3179-
'ZLIC': [1,_(u'Summon Lich'),350],
3180-
'ZSCA': [1,_(u'Summon Scamp'),30],
3181-
'ZSKA': [1,_(u'Summon Skeleton Guardian'),32.5],
3182-
'ZSKC': [1,_(u'Summon Skeleton Champion'),152],
3183-
'ZSKE': [1,_(u'Summon Skeleton'),11.25],
3184-
'ZSKH': [1,_(u'Summon Skeleton Hero'),66],
3185-
'ZSPD': [1,_(u'Summon Spider Daedra'),195],
3186-
'ZSTA': [1,_(u'Summon Storm Atronach'),125],
3187-
'ZWRA': [1,_(u'Summon Faded Wraith'),87.5],
3188-
'ZWRL': [1,_(u'Summon Gloom Wraith'),260],
3189-
'ZXIV': [1,_(u'Summon Xivilai'),200],
3190-
'ZZOM': [1,_(u'Summon Zombie'),16.67],
3191-
}
3192-
_strU = struct.Struct('I').unpack
3193-
mgef_school = dict((x, y) for x, [y, z, _num] in _magicEffects.items())
3194-
mgef_name = dict((x, z) for x, [y, z, __num] in _magicEffects.items())
3195-
_mgef_basevalue = dict((x, a) for x, [y, z, a] in _magicEffects.items())
3196-
mgef_school.update({_strU(x)[0]:y for x,[y,z,a] in _magicEffects.items()})
3197-
mgef_name.update({_strU(x)[0]:z for x,[y,z,a] in _magicEffects.items()})
3198-
_mgef_basevalue.update(
3199-
{_strU(x)[0]: a for x, [y, z, a] in _magicEffects.items()})
3200-
3201-
#Doesn't list mgefs that use actor values, but rather mgefs that have a generic name
3202-
#Ex: Absorb Attribute becomes Absorb Magicka if the effect's actorValue field contains 9
3203-
# But it is actually using an attribute rather than an actor value
3204-
#Ex: Burden uses an actual actor value (encumbrance) but it isn't listed since its name doesn't change
3205-
genericAVEffects = {
3206-
'ABAT', #--Absorb Attribute (Use Attribute)
3207-
'ABSK', #--Absorb Skill (Use Skill)
3208-
'DGAT', #--Damage Attribute (Use Attribute)
3209-
'DRAT', #--Drain Attribute (Use Attribute)
3210-
'DRSK', #--Drain Skill (Use Skill)
3211-
'FOAT', #--Fortify Attribute (Use Attribute)
3212-
'FOSK', #--Fortify Skill (Use Skill)
3213-
'REAT', #--Restore Attribute (Use Attribute)
3214-
}
3215-
genericAVEffects |= set((_strU(x)[0] for x in genericAVEffects))
3216-
3217-
actorValues = [
3218-
_(u'Strength'), #--00
3219-
_(u'Intelligence'),
3220-
_(u'Willpower'),
3221-
_(u'Agility'),
3222-
_(u'Speed'),
3223-
_(u'Endurance'),
3224-
_(u'Personality'),
3225-
_(u'Luck'),
3226-
_(u'Health'),
3227-
_(u'Magicka'),
3228-
3229-
_(u'Fatigue'), #--10
3230-
_(u'Encumbrance'),
3231-
_(u'Armorer'),
3232-
_(u'Athletics'),
3233-
_(u'Blade'),
3234-
_(u'Block'),
3235-
_(u'Blunt'),
3236-
_(u'Hand To Hand'),
3237-
_(u'Heavy Armor'),
3238-
_(u'Alchemy'),
3239-
3240-
_(u'Alteration'), #--20
3241-
_(u'Conjuration'),
3242-
_(u'Destruction'),
3243-
_(u'Illusion'),
3244-
_(u'Mysticism'),
3245-
_(u'Restoration'),
3246-
_(u'Acrobatics'),
3247-
_(u'Light Armor'),
3248-
_(u'Marksman'),
3249-
_(u'Mercantile'),
3250-
3251-
_(u'Security'), #--30
3252-
_(u'Sneak'),
3253-
_(u'Speechcraft'),
3254-
u'Aggression',
3255-
u'Confidence',
3256-
u'Energy',
3257-
u'Responsibility',
3258-
u'Bounty',
3259-
u'UNKNOWN 38',
3260-
u'UNKNOWN 39',
3261-
3262-
u'MagickaMultiplier', #--40
3263-
u'NightEyeBonus',
3264-
u'AttackBonus',
3265-
u'DefendBonus',
3266-
u'CastingPenalty',
3267-
u'Blindness',
3268-
u'Chameleon',
3269-
u'Invisibility',
3270-
u'Paralysis',
3271-
u'Silence',
3272-
3273-
u'Confusion', #--50
3274-
u'DetectItemRange',
3275-
u'SpellAbsorbChance',
3276-
u'SpellReflectChance',
3277-
u'SwimSpeedMultiplier',
3278-
u'WaterBreathing',
3279-
u'WaterWalking',
3280-
u'StuntedMagicka',
3281-
u'DetectLifeRange',
3282-
u'ReflectDamage',
3283-
3284-
u'Telekinesis', #--60
3285-
u'ResistFire',
3286-
u'ResistFrost',
3287-
u'ResistDisease',
3288-
u'ResistMagic',
3289-
u'ResistNormalWeapons',
3290-
u'ResistParalysis',
3291-
u'ResistPoison',
3292-
u'ResistShock',
3293-
u'Vampirism',
3294-
3295-
u'Darkness', #--70
3296-
u'ResistWaterDamage',
3297-
]
3298-
32993027
#------------------------------------------------------------------------------
33003028
class MreHasEffects(object):
33013029
"""Mixin class for magic items."""
33023030
__slots__ = []
33033031

33043032
def getEffects(self):
33053033
"""Returns a summary of effects. Useful for alchemical catalog."""
3034+
import bush
33063035
effects = []
33073036
effectsAppend = effects.append
33083037
for effect in self.effects:
33093038
mgef, actorValue = effect.name, effect.actorValue
3310-
if mgef not in genericAVEffects:
3039+
if mgef not in bush.game.generic_av_effects:
33113040
actorValue = 0
33123041
effectsAppend((mgef,actorValue))
33133042
return effects
33143043

33153044
def getSpellSchool(self):
33163045
"""Returns the school based on the highest cost spell effect."""
3046+
import bush
33173047
spellSchool = [0,0]
33183048
for effect in self.effects:
3319-
school = mgef_school[effect.name]
3320-
effectValue = _mgef_basevalue[effect.name]
3049+
school = bush.game.mgef_school[effect.name]
3050+
effectValue = bush.game.mgef_basevalue[effect.name]
33213051
if effect.magnitude:
33223052
effectValue *= effect.magnitude
33233053
if effect.area:
@@ -3330,18 +3060,19 @@ def getSpellSchool(self):
33303060

33313061
def getEffectsSummary(self):
33323062
"""Return a text description of magic effects."""
3063+
import bush
33333064
with sio() as buff:
3334-
avEffects = genericAVEffects
3335-
aValues = actorValues
3065+
avEffects = bush.game.generic_av_effects
3066+
aValues = bush.game.actor_values
33363067
buffWrite = buff.write
33373068
if self.effects:
33383069
school = self.getSpellSchool()
3339-
buffWrite(actorValues[20+school] + u'\n')
3070+
buffWrite(aValues[20+school] + u'\n')
33403071
for index,effect in enumerate(self.effects):
33413072
if effect.scriptEffect:
33423073
effectName = effect.scriptEffect.full or u'Script Effect'
33433074
else:
3344-
effectName = mgef_name[effect.name]
3075+
effectName = bush.game.mgef_name[effect.name]
33453076
if effect.name in avEffects:
33463077
effectName = re.sub(_(u'(Attribute|Skill)'),aValues[effect.actorValue],effectName)
33473078
buffWrite(u'o+*'[effect.recipient]+u' '+effectName)
@@ -3350,46 +3081,3 @@ def getEffectsSummary(self):
33503081
if effect.duration > 1: buffWrite(u' %sd'%effect.duration)
33513082
buffWrite(u'\n')
33523083
return buff.getvalue()
3353-
3354-
hostileEffects = {
3355-
'ABAT', #--Absorb Attribute
3356-
'ABFA', #--Absorb Fatigue
3357-
'ABHE', #--Absorb Health
3358-
'ABSK', #--Absorb Skill
3359-
'ABSP', #--Absorb Magicka
3360-
'BRDN', #--Burden
3361-
'DEMO', #--Demoralize
3362-
'DGAT', #--Damage Attribute
3363-
'DGFA', #--Damage Fatigue
3364-
'DGHE', #--Damage Health
3365-
'DGSP', #--Damage Magicka
3366-
'DIAR', #--Disintegrate Armor
3367-
'DIWE', #--Disintegrate Weapon
3368-
'DRAT', #--Drain Attribute
3369-
'DRFA', #--Drain Fatigue
3370-
'DRHE', #--Drain Health
3371-
'DRSK', #--Drain Skill
3372-
'DRSP', #--Drain Magicka
3373-
'FIDG', #--Fire Damage
3374-
'FRDG', #--Frost Damage
3375-
'FRNZ', #--Frenzy
3376-
'PARA', #--Paralyze
3377-
'SHDG', #--Shock Damage
3378-
'SLNC', #--Silence
3379-
'STMA', #--Stunted Magicka
3380-
'STRP', #--Soul Trap
3381-
'SUDG', #--Sun Damage
3382-
'TURN', #--Turn Undead
3383-
'WKDI', #--Weakness to Disease
3384-
'WKFI', #--Weakness to Fire
3385-
'WKFR', #--Weakness to Frost
3386-
'WKMA', #--Weakness to Magic
3387-
'WKNW', #--Weakness to Normal Weapons
3388-
'WKPO', #--Weakness to Poison
3389-
'WKSH', #--Weakness to Shock
3390-
}
3391-
hostileEffects |= set((_strU(x)[0] for x in hostileEffects))
3392-
3393-
#--Cleanup --------------------------------------------------------------------
3394-
#------------------------------------------------------------------------------
3395-
del _strU

0 commit comments

Comments
 (0)