1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-16 09:25:57 -05:00
OpenDiablo2/d2core/d2records/monster_stats_loader.go
2020-12-18 18:59:29 +01:00

281 lines
15 KiB
Go

package d2records
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
)
// nolint:funlen // cant reduce
func monsterStatsLoader(r *RecordManager, d *d2txt.DataDictionary) error {
records := make(MonStats)
for d.Next() {
record := &MonStatRecord{
Key: d.String("Id"),
ID: d.Number("hcIdx"),
BaseKey: d.String("BaseId"),
NextKey: d.String("NextInClass"),
PaletteId: d.Number("TransLvl"),
NameString: d.String("NameStr"),
ExtraDataKey: d.String("MonStatsEx"),
PropertiesKey: d.String("MonProp"),
MonsterGroup: d.String("MonType"),
AiKey: d.String("AI"),
DescriptionStringTableKey: d.String("DescStr"),
AnimationDirectoryToken: d.String("Code"),
Enabled: d.Number("enabled") > 0,
IsRanged: d.Number("rangedtype") > 0,
SpawnsMinions: d.Number("placespawn") > 0,
SpawnKey: d.String("spawn"),
SpawnOffsetX: d.Number("spawnx"),
SpawnOffsetY: d.Number("spawny"),
SpawnAnimationKey: d.String("spawnmode"),
MinionId1: d.String("minion1"),
MinionId2: d.String("minion2"),
IsLeader: d.Number("SetBoss") > 0,
TransferLeadership: d.Number("BossXfer") > 0,
MinionPartyMin: d.Number("PartyMin"),
MinionPartyMax: d.Number("PartyMax"),
MinionGroupMin: d.Number("MinGrp"),
MinionGroupMax: d.Number("MaxGrp"),
PopulationReductionPercent: d.Number("sparsePopulate"),
SpeedBase: d.Number("Velocity"),
SpeedRun: d.Number("Run"),
Rarity: d.Number("Rarity"),
LevelNormal: d.Number("Level"),
LevelNightmare: d.Number("Level(N)"),
LevelHell: d.Number("Level(H)"),
SoundKeyNormal: d.String("MonSound"),
SoundKeySpecial: d.String("UMonSound"),
ThreatLevel: d.Number("threat"),
AiDelayNormal: d.Number("aidel"),
AiDelayNightmare: d.Number("aidel(N)"),
AiDelayHell: d.Number("aidel(H)"),
AiDistanceNormal: d.Number("aidist"),
AiDistanceNightmare: d.Number("aidist(N)"),
AiDistanceHell: d.Number("aidist(H)"),
AiParameterNormal1: d.Number("aip1"),
AiParameterNormal2: d.Number("aip2"),
AiParameterNormal3: d.Number("aip3"),
AiParameterNormal4: d.Number("aip4"),
AiParameterNormal5: d.Number("aip5"),
AiParameterNormal6: d.Number("aip6"),
AiParameterNormal7: d.Number("aip7"),
AiParameterNormal8: d.Number("aip8"),
AiParameterNightmare1: d.Number("aip1(N)"),
AiParameterNightmare2: d.Number("aip2(N)"),
AiParameterNightmare3: d.Number("aip3(N)"),
AiParameterNightmare4: d.Number("aip4(N)"),
AiParameterNightmare5: d.Number("aip5(N)"),
AiParameterNightmare6: d.Number("aip6(N)"),
AiParameterNightmare7: d.Number("aip7(N)"),
AiParameterNightmare8: d.Number("aip8(N)"),
AiParameterHell1: d.Number("aip1(H)"),
AiParameterHell2: d.Number("aip2(H)"),
AiParameterHell3: d.Number("aip3(H)"),
AiParameterHell4: d.Number("aip4(H)"),
AiParameterHell5: d.Number("aip5(H)"),
AiParameterHell6: d.Number("aip6(H)"),
AiParameterHell7: d.Number("aip7(H)"),
AiParameterHell8: d.Number("aip8(H)"),
MissileA1: d.String("MissA1"),
MissileA2: d.String("MissA2"),
MissileS1: d.String("MissS1"),
MissileS2: d.String("MissS2"),
MissileS3: d.String("MissS3"),
MissileS4: d.String("MissS4"),
MissileC: d.String("MissC"),
MissileSQ: d.String("MissSQ"),
Alignment: d2enum.MonsterAlignmentType(d.Number("Align")),
IsLevelSpawnable: d.Number("isSpawn") > 0,
IsMelee: d.Number("isMelee") > 0,
IsNpc: d.Number("npc") > 0,
IsInteractable: d.Number("interact") > 0,
HasInventory: d.Number("inventory") > 0,
CanEnterTown: d.Number("inTown") > 0,
IsUndeadLow: d.Number("lUndead") > 0,
IsUndeadHigh: d.Number("hUndead") > 0,
IsDemon: d.Number("demon") > 0,
IsFlying: d.Number("flying") > 0,
CanOpenDoors: d.Number("opendoors") > 0,
IsSpecialBoss: d.Number("boss") > 0,
IsActBoss: d.Number("primeevil") > 0,
IsKillable: d.Number("killable") > 0,
IsAiSwitchable: d.Number("switchai") > 0,
DisableAura: d.Number("noAura") > 0,
DisableMultiShot: d.Number("nomultishot") > 0,
DisableCounting: d.Number("neverCount") > 0,
IgnorePets: d.Number("petIgnore") > 0,
DealsDamageOnDeath: d.Number("deathDmg") > 0,
GenericSpawn: d.Number("genericSpawn") > 0,
SkillId1: d.String("Skill1"),
SkillId2: d.String("Skill2"),
SkillId3: d.String("Skill3"),
SkillId4: d.String("Skill4"),
SkillId5: d.String("Skill5"),
SkillId6: d.String("Skill6"),
SkillId7: d.String("Skill7"),
SkillId8: d.String("Skill8"),
SkillAnimation1: d.String("Sk1mode"),
SkillAnimation2: d.String("Sk2mode"),
SkillAnimation3: d.String("Sk3mode"),
SkillAnimation4: d.String("Sk4mode"),
SkillAnimation5: d.String("Sk5mode"),
SkillAnimation6: d.String("Sk6mode"),
SkillAnimation7: d.String("Sk7mode"),
SkillAnimation8: d.String("Sk8mode"),
SkillLevel1: d.Number("Sk1lvl"),
SkillLevel2: d.Number("Sk2lvl"),
SkillLevel3: d.Number("Sk3lvl"),
SkillLevel4: d.Number("Sk4lvl"),
SkillLevel5: d.Number("Sk5lvl"),
SkillLevel6: d.Number("Sk6lvl"),
SkillLevel7: d.Number("Sk7lvl"),
SkillLevel8: d.Number("Sk8lvl"),
LeechSensitivityNormal: d.Number("Drain"),
LeechSensitivityNightmare: d.Number("Drain(N)"),
LeechSensitivityHell: d.Number("Drain(H)"),
ColdSensitivityNormal: d.Number("coldeffect"),
ColdSensitivityNightmare: d.Number("coldeffect(N)"),
ColdSensitivityHell: d.Number("coldeffect(H)"),
ResistancePhysicalNormal: d.Number("ResDm"),
ResistancePhysicalNightmare: d.Number("ResDm(N)"),
ResistancePhysicalHell: d.Number("ResDm(H)"),
ResistanceMagicNormal: d.Number("ResMa"),
ResistanceMagicNightmare: d.Number("ResMa(N)"),
ResistanceMagicHell: d.Number("ResMa(H)"),
ResistanceFireNormal: d.Number("ResFi"),
ResistanceFireNightmare: d.Number("ResFi(N)"),
ResistanceFireHell: d.Number("ResFi(H)"),
ResistanceLightningNormal: d.Number("ResLi"),
ResistanceLightningNightmare: d.Number("ResLi(N)"),
ResistanceLightningHell: d.Number("ResLi(H)"),
ResistanceColdNormal: d.Number("ResCo"),
ResistanceColdNightmare: d.Number("ResCo(N)"),
ResistanceColdHell: d.Number("ResCo(H)"),
ResistancePoisonNormal: d.Number("ResPo"),
ResistancePoisonNightmare: d.Number("ResPo(N)"),
ResistancePoisonHell: d.Number("ResPo(H)"),
HealthRegenPerFrame: d.Number("DamageRegen"),
DamageSkillId: d.String("SkillDamage"),
IgnoreMonLevelTxt: d.Number("noRatio") > 0,
CanBlockWithoutShield: d.Number("NoShldBlock") > 0,
ChanceToBlockNormal: d.Number("ToBlock"),
ChanceToBlockNightmare: d.Number("ToBlock(N)"),
ChanceToBlockHell: d.Number("ToBlock(H)"),
ChanceDeadlyStrike: d.Number("Crit"),
MinHPNormal: d.Number("minHP"),
MinHPNightmare: d.Number("MinHP(N)"),
MinHPHell: d.Number("MinHP(H)"),
MaxHPNormal: d.Number("maxHP"),
MaxHPNightmare: d.Number("MaxHP(N)"),
MaxHPHell: d.Number("MaxHP(H)"),
ArmorClassNormal: d.Number("AC"),
ArmorClassNightmare: d.Number("AC(N)"),
ArmorClassHell: d.Number("AC(H)"),
ExperienceNormal: d.Number("Exp"),
ExperienceNightmare: d.Number("Exp(N)"),
ExperienceHell: d.Number("Exp(H)"),
DamageMinA1Normal: d.Number("A1MinD"),
DamageMinA1Nightmare: d.Number("A1MinD(N)"),
DamageMinA1Hell: d.Number("A1MinD(H)"),
DamageMaxA1Normal: d.Number("A1MaxD"),
DamageMaxA1Nightmare: d.Number("A1MaxD(N)"),
DamageMaxA1Hell: d.Number("A1MaxD(H)"),
DamageMinA2Normal: d.Number("A2MinD"),
DamageMinA2Nightmare: d.Number("A2MinD(N)"),
DamageMinA2Hell: d.Number("A2MinD(H)"),
DamageMaxA2Normal: d.Number("A2MaxD"),
DamageMaxA2Nightmare: d.Number("A2MaxD(N)"),
DamageMaxA2Hell: d.Number("A2MaxD(H)"),
DamageMinS1Normal: d.Number("S1MinD"),
DamageMinS1Nightmare: d.Number("S1MinD(N)"),
DamageMinS1Hell: d.Number("S1MinD(H)"),
DamageMaxS1Normal: d.Number("S1MaxD"),
DamageMaxS1Nightmare: d.Number("S1MaxD(N)"),
DamageMaxS1Hell: d.Number("S1MaxD(H)"),
AttackRatingA1Normal: d.Number("A1TH"),
AttackRatingA1Nightmare: d.Number("A1TH(N)"),
AttackRatingA1Hell: d.Number("A1TH(H)"),
AttackRatingA2Normal: d.Number("A2TH"),
AttackRatingA2Nightmare: d.Number("A2TH(N)"),
AttackRatingA2Hell: d.Number("A2TH(H)"),
AttackRatingS1Normal: d.Number("S1TH"),
AttackRatingS1Nightmare: d.Number("S1TH(N)"),
AttackRatingS1Hell: d.Number("S1TH(H)"),
ElementAttackMode1: d.String("El1Mode"),
ElementAttackMode2: d.String("El2Mode"),
ElementAttackMode3: d.String("El3Mode"),
ElementType1: d.String("El1Type"),
ElementType2: d.String("El2Type"),
ElementType3: d.String("El3Type"),
ElementChance1Normal: d.Number("El1Pct"),
ElementChance1Nightmare: d.Number("El1Pct(N)"),
ElementChance1Hell: d.Number("El1Pct(H)"),
ElementChance2Normal: d.Number("El2Pct"),
ElementChance2Nightmare: d.Number("El2Pct(N)"),
ElementChance2Hell: d.Number("El2Pct(H)"),
ElementChance3Normal: d.Number("El3Pct"),
ElementChance3Nightmare: d.Number("El3Pct(N)"),
ElementChance3Hell: d.Number("El3Pct(H)"),
ElementDamageMin1Normal: d.Number("El1MinD"),
ElementDamageMin1Nightmare: d.Number("El1MinD(N)"),
ElementDamageMin1Hell: d.Number("El1MinD(H)"),
ElementDamageMin2Normal: d.Number("El2MinD"),
ElementDamageMin2Nightmare: d.Number("El2MinD(N)"),
ElementDamageMin2Hell: d.Number("El2MinD(H)"),
ElementDamageMin3Normal: d.Number("El3MinD"),
ElementDamageMin3Nightmare: d.Number("El3MinD(N)"),
ElementDamageMin3Hell: d.Number("El3MinD(H)"),
ElementDamageMax1Normal: d.Number("El1MaxD"),
ElementDamageMax1Nightmare: d.Number("El1MaxD(N)"),
ElementDamageMax1Hell: d.Number("El1MaxD(H)"),
ElementDamageMax2Normal: d.Number("El2MaxD"),
ElementDamageMax2Nightmare: d.Number("El2MaxD(N)"),
ElementDamageMax2Hell: d.Number("El2MaxD(H)"),
ElementDamageMax3Normal: d.Number("El3MaxD"),
ElementDamageMax3Nightmare: d.Number("El3MaxD(N)"),
ElementDamageMax3Hell: d.Number("El3MaxD(H)"),
ElementDuration1Normal: d.Number("El1Dur"),
ElementDuration1Nightmare: d.Number("El1Dur(N)"),
ElementDuration1Hell: d.Number("El1Dur(H)"),
ElementDuration2Normal: d.Number("El2Dur"),
ElementDuration2Nightmare: d.Number("El2Dur(N)"),
ElementDuration2Hell: d.Number("El2Dur(H)"),
ElementDuration3Normal: d.Number("El3Dur"),
ElementDuration3Nightmare: d.Number("El3Dur(N)"),
ElementDuration3Hell: d.Number("El3Dur(H)"),
TreasureClassNormal: d.String("TreasureClass1"),
TreasureClassNightmare: d.String("TreasureClass1(N)"),
TreasureClassHell: d.String("TreasureClass1(H)"),
TreasureClassChampionNormal: d.String("TreasureClass2"),
TreasureClassChampionNightmare: d.String("TreasureClass2(N)"),
TreasureClassChampionHell: d.String("TreasureClass2(H)"),
TreasureClass3UniqueNormal: d.String("TreasureClass3"),
TreasureClass3UniqueNightmare: d.String("TreasureClass3(N)"),
TreasureClass3UniqueHell: d.String("TreasureClass3(H)"),
TreasureClassQuestNormal: d.String("TreasureClass4"),
TreasureClassQuestNightmare: d.String("TreasureClass4(N)"),
TreasureClassQuestHell: d.String("TreasureClass4(H)"),
TreasureClassQuestTriggerId: d.String("TCQuestId"),
TreasureClassQuestCompleteId: d.String("TCQuestCP"),
SpecialEndDeath: d.Number("SplEndDeath"),
SpecialGetModeChart: d.Number("SplGetModeChart") > 0,
SpecialEndGeneric: d.Number("SplEndGeneric") > 0,
SpecialClientEnd: d.Number("SplClientEnd") > 0,
}
records[record.Key] = record
}
if d.Err != nil {
return d.Err
}
r.Debugf("Loaded %d MonStat records", len(records))
r.Monster.Stats = records
return nil
}