Mercurial > mm7
changeset 2323:983b8c995127
_43AFE3_calc_spell_damage moved to spells.h, cleaned it up a bit
SpellData changed to class, added constructor, change ::field_10 to baseDamage and bonusSkillDamage
author | Grumpy7 |
---|---|
date | Thu, 27 Mar 2014 23:28:54 +0100 |
parents | 9dbfeda280d7 |
children | b2e3ac05f2b3 |
files | Spells.cpp Spells.h mm7_unsorted_subs.h |
diffstat | 3 files changed, 149 insertions(+), 133 deletions(-) [+] |
line wrap: on
line diff
--- a/Spells.cpp Mon Mar 17 22:53:24 2014 +0100 +++ b/Spells.cpp Thu Mar 27 23:28:54 2014 +0100 @@ -47,120 +47,140 @@ {545, 0}, {555, 0} }}; + + + +SpellData::SpellData( __int16 innormalMana, __int16 inExpertLevelMana, __int16 inMasterLevelMana, __int16 inMagisterLevelMana, + __int16 inNormalLevelRecovery, __int16 inExpertLevelRecovery, __int16 inMasterLevelRecovery, __int16 inMagisterLevelRecovery, + __int8 inbaseDamage, __int8 inbonusSkillDamage, __int16 instats ): +uNormalLevelMana(innormalMana), +uExpertLevelMana(inExpertLevelMana), +uMasterLevelMana(inMasterLevelMana), +uMagisterLevelMana(inMagisterLevelMana), +uNormalLevelRecovery(inNormalLevelRecovery), +uExpertLevelRecovery(inExpertLevelRecovery), +uMasterLevelRecovery(inMasterLevelRecovery), +uMagisterLevelRecovery(inMagisterLevelRecovery), +baseDamage(inbaseDamage), +bonusSkillDamage(inbonusSkillDamage), +stats(instats) +{ + +} + //9 spellbook pages 11 spells per page 9*11 =99 +1 zero struct at 0. It counted from 1! std::array<SpellData, 100> pSpellDatas={{ - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + SpellData(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), - {1, 1, 1, 1, 60, 60, 60, 40, 0, 0},//0 - {2, 2, 2, 2, 110, 110, 100, 90, 768, 0}, - {3, 3, 3, 3, 120, 120, 120, 120, 0, 0}, - {4, 4, 4, 4, 120, 120, 120, 120, 0, 0}, - {5, 5, 5, 5, 120, 120, 120, 120, 0, 0}, - {8, 8, 8, 8, 100, 100, 90, 80, 1536, 0}, - {10, 10, 10, 10, 150, 150, 150, 150, 1536, 0}, - {15, 15, 15, 15, 120, 120, 120, 120, 1536, 0}, - {20, 20, 20, 20, 100, 100, 100, 90, 264, 0}, - {25, 25, 25, 25, 100, 100, 100, 90, 268, 0}, - {30, 30, 30, 30, 90, 90, 90, 90, 3855, 0}, + SpellData(1, 1, 1, 1, 60, 60, 60, 40, 0, 0, 0),//0 fire + SpellData(2, 2, 2, 2, 110, 110, 100, 90, 3, 3, 0), + SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), + SpellData(4, 4, 4, 4, 120, 120, 120, 120, 0, 0, 0), + SpellData(5, 5, 5, 5, 120, 120, 120, 120, 0, 0, 0), + SpellData(8, 8, 8, 8, 100, 100, 90, 80, 0, 6, 0), + SpellData(10, 10, 10, 10, 150, 150, 150, 150, 0, 6, 0), + SpellData(15, 15, 15, 15, 120, 120, 120, 120, 0, 6, 0), + SpellData(20, 20, 20, 20, 100, 100, 100, 90, 8, 1, 0), + SpellData(25, 25, 25, 25, 100, 100, 100, 90, 12, 1, 0), + SpellData(30, 30, 30, 30, 90, 90, 90, 90, 15, 15, 0), - {1, 1, 1, 0, 60, 60, 60, 60, 0, 0}, //1 - {2, 2, 2, 2, 120, 120, 120, 100, 0, 0}, - {3, 3, 3, 3, 120, 120, 120, 120, 0, 0}, - {4, 4, 4, 4, 110, 100, 90, 80, 258, 0}, - {5, 5, 5, 5, 90, 90, 70, 50, 0, 0}, - {8, 8, 8, 8, 120, 120, 120, 120, 0, 0}, - {10, 10, 10, 10, 100, 100, 90, 70, 2048, 0}, - {15, 15, 15, 15, 200, 200, 200, 200, 0, 0}, - {20, 20, 20, 20, 100, 100, 100, 90, 2570, 0}, - {25, 25, 25, 25, 250, 250, 250, 250, 0, 0}, - {30, 30, 30, 30, 90, 90, 90, 90, 276, 0}, + SpellData(1, 1, 1, 0, 60, 60, 60, 60, 0, 0, 0), //1 air + SpellData(2, 2, 2, 2, 120, 120, 120, 100, 0, 0, 0), + SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), + SpellData(4, 4, 4, 4, 110, 100, 90, 80, 2, 1, 0), + SpellData(5, 5, 5, 5, 90, 90, 70, 50, 0, 0, 0), + SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0), + SpellData(10, 10, 10, 10, 100, 100, 90, 70, 0, 8, 0), + SpellData(15, 15, 15, 15, 200, 200, 200, 200, 0, 0, 0), + SpellData(20, 20, 20, 20, 100, 100, 100, 90, 10, 10, 0), + SpellData(25, 25, 25, 25, 250, 250, 250, 250, 0, 0, 0), + SpellData(30, 30, 30, 30, 90, 90, 90, 90, 20, 1, 0), - {1, 1, 1, 1, 60, 60, 60, 20, 0, 0}, //2 - {2, 2, 2, 2, 110, 100, 90, 70, 514, 0}, - {3, 3, 3, 3, 120, 120, 120, 120, 0, 0}, - {4, 4, 4, 4, 110, 100, 90, 80, 1024, 0}, - {5, 5, 5, 5, 150, 150, 150, 150, 0, 0}, - {8, 8, 8, 8, 200, 200, 200, 200, 0, 0}, - {10, 10, 10, 10, 100, 100, 90, 80, 2313, 0}, - {15, 15, 15, 15, 140, 140, 140, 140, 0, 0}, - {20, 20, 20, 20, 200, 200, 200, 200, 0, 0}, - {25, 25, 25, 25, 80, 80, 80, 80, 780, 0}, - {30, 30, 30, 30, 250, 250, 250, 250, 0, 0}, + SpellData(1, 1, 1, 1, 60, 60, 60, 20, 0, 0, 0), //2 water + SpellData(2, 2, 2, 2, 110, 100, 90, 70, 2, 2, 0), + SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), + SpellData(4, 4, 4, 4, 110, 100, 90, 80, 0, 4, 0), + SpellData(5, 5, 5, 5, 150, 150, 150, 150, 0, 0, 0), + SpellData(8, 8, 8, 8, 200, 200, 200, 200, 0, 0, 0), + SpellData(10, 10, 10, 10, 100, 100, 90, 80, 9, 9, 0), + SpellData(15, 15, 15, 15, 140, 140, 140, 140, 0, 0, 0), + SpellData(20, 20, 20, 20, 200, 200, 200, 200, 0, 0, 0), + SpellData(25, 25, 25, 25, 80, 80, 80, 80, 12, 3, 0), + SpellData(30, 30, 30, 30, 250, 250, 250, 250, 0, 0, 0), - {1, 1, 1, 1, 80, 80, 80, 80, 0, 0}, //3 - {2, 2, 2, 2, 100, 100, 100, 100, 0, 0}, - {3, 3, 3, 3, 120, 120, 120, 120, 0, 0}, - {4, 4, 4, 4, 110, 100, 90, 80, 773, 0}, - {5, 5, 5, 5, 120, 120, 120, 120, 0, 0}, - {8, 8, 8, 8, 100, 100, 90, 80, 2304, 0}, - {10, 10, 10, 10, 140, 140, 140, 140, 0, 0}, - {15, 15, 15, 15, 90, 90, 90, 80, 2048, 0}, - {20, 20, 20, 20, 150, 150, 150, 150, 0, 0}, - {25, 25, 25, 25, 100, 100, 100, 90, 276, 0}, - {30, 30, 30, 30, 90, 90, 90, 90, 25, 0}, + SpellData(1, 1, 1, 1, 80, 80, 80, 80, 0, 0, 0), //3 earth + SpellData(2, 2, 2, 2, 100, 100, 100, 100, 0, 0, 0), + SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), + SpellData(4, 4, 4, 4, 110, 100, 90, 80, 5, 3, 0), + SpellData(5, 5, 5, 5, 120, 120, 120, 120, 0, 0, 0), + SpellData(8, 8, 8, 8, 100, 100, 90, 80, 0, 9, 0), + SpellData(10, 10, 10, 10, 140, 140, 140, 140, 0, 0, 0), + SpellData(15, 15, 15, 15, 90, 90, 90, 80, 0, 8, 0), + SpellData(20, 20, 20, 20, 150, 150, 150, 150, 0, 0, 0), + SpellData(25, 25, 25, 25, 100, 100, 100, 90, 20, 1, 0), + SpellData(30, 30, 30, 30, 90, 90, 90, 90, 25, 0, 0), - {1, 1, 1, 1, 100, 100, 100, 100, 0, 0}, //4 - {2, 2, 2, 2, 100, 100, 100, 100, 0, 0}, - {3, 3, 3, 3, 90, 90, 90, 90, 0, 0}, - {4, 4, 4, 4, 120, 120, 120, 120, 0, 0}, - {5, 5, 5, 5, 120, 120, 120, 120, 0, 0}, - {8, 8, 8, 8, 120, 120, 120, 120, 0, 0}, - {10, 10, 10, 10, 120, 120, 120, 120, 0, 0}, - {15, 15, 15, 15, 100, 100, 100, 100, 2058, 0}, - {20, 20, 20, 20, 240, 240, 240, 240, 0, 0}, - {25, 25, 25, 25, 150, 150, 150, 150, 0, 0}, - {30, 30, 30, 30, 1000, 1000, 1000, 1000, 0, 0}, + SpellData(1, 1, 1, 1, 100, 100, 100, 100, 0, 0, 0), //4 spirit + SpellData(2, 2, 2, 2, 100, 100, 100, 100, 0, 0, 0), + SpellData(3, 3, 3, 3, 90, 90, 90, 90, 0, 0, 0), + SpellData(4, 4, 4, 4, 120, 120, 120, 120, 0, 0, 0), + SpellData(5, 5, 5, 5, 120, 120, 120, 120, 0, 0, 0), + SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0), + SpellData(10, 10, 10, 10, 120, 120, 120, 120, 0, 0, 0), + SpellData(15, 15, 15, 15, 100, 100, 100, 100, 10, 8, 0), + SpellData(20, 20, 20, 20, 240, 240, 240, 240, 0, 0, 0), + SpellData(25, 25, 25, 25, 150, 150, 150, 150, 0, 0, 0), + SpellData(30, 30, 30, 30, 1000, 1000, 1000, 1000, 0, 0, 0), - {1, 1, 1, 1, 120, 120, 120, 120, 0, 0}, //5 - {2, 2, 2, 2, 110, 110, 110, 110, 771, 0}, - {3, 3, 3, 3, 120, 120, 120, 120, 0, 0}, - {4, 4, 4, 4, 110, 100, 90, 80, 0, 0}, - {5, 5, 5, 5, 100, 100, 100, 100, 0, 0}, - {8, 8, 8, 8, 120, 120, 120, 120, 0, 0}, - {10, 10, 10, 10, 120, 120, 120, 120, 0, 0}, - {15, 15, 15, 15, 80, 80, 80, 80, 0, 0}, - {20, 20, 20, 20, 120, 120, 120, 120, 0, 0}, - {25, 25, 25, 25, 110, 110, 110, 100, 268, 0}, - {30, 30, 30, 30, 120, 120, 120, 120, 0, 0}, + SpellData(1, 1, 1, 1, 120, 120, 120, 120, 0, 0, 0), //5 mind + SpellData(2, 2, 2, 2, 110, 110, 110, 110, 3, 3, 0), + SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), + SpellData(4, 4, 4, 4, 110, 100, 90, 80, 0, 0, 0), + SpellData(5, 5, 5, 5, 100, 100, 100, 100, 0, 0, 0), + SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0), + SpellData(10, 10, 10, 10, 120, 120, 120, 120, 0, 0, 0), + SpellData(15, 15, 15, 15, 80, 80, 80, 80, 0, 0, 0), + SpellData(20, 20, 20, 20, 120, 120, 120, 120, 0, 0, 0), + SpellData(25, 25, 25, 25, 110, 110, 110, 100, 12, 12, 0), + SpellData(30, 30, 30, 30, 120, 120, 120, 120, 0, 0, 0), - {1, 1, 1, 1, 120, 120, 120, 120, 0, 0}, //6 - {2, 2, 2, 2, 100, 100, 100, 100, 0, 0}, - {3, 3, 3, 3, 120, 120, 120, 120, 0, 0}, - {4, 4, 4, 4, 110, 100, 90, 80, 520, 0}, - {5, 5, 5, 5, 110, 110, 110, 110, 0, 0}, - {8, 8, 8, 8, 120, 120, 120, 120, 0, 0}, - {10, 10, 10, 10, 120, 120, 120, 120, 0, 0}, - {15, 15, 15, 15, 120, 120, 120, 120, 0, 0}, - {20, 20, 20, 20, 120, 120, 120, 120, 0, 0}, - {25, 25, 25, 25, 110, 110, 110, 100, 1310, 0}, - {30, 30, 30, 30, 100, 100, 100, 100, 0, 0}, + SpellData(1, 1, 1, 1, 120, 120, 120, 120, 0, 0, 0), //6 body + SpellData(2, 2, 2, 2, 100, 100, 100, 100, 0, 0, 0), + SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), + SpellData(4, 4, 4, 4, 110, 100, 90, 80, 8, 2, 0), + SpellData(5, 5, 5, 5, 110, 110, 110, 110, 0, 0, 0), + SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0), + SpellData(10, 10, 10, 10, 120, 120, 120, 120, 0, 0, 0), + SpellData(15, 15, 15, 15, 120, 120, 120, 120, 0, 0, 0), + SpellData(20, 20, 20, 20, 120, 120, 120, 120, 0, 0, 0), + SpellData(25, 25, 25, 25, 110, 110, 110, 100, 30, 5, 0), + SpellData(30, 30, 30, 30, 100, 100, 100, 100, 0, 0, 0), - {5, 5, 5, 5, 110, 100, 90, 80, 1024, 0}, //7 - {10, 10, 10, 10, 120, 110, 100, 90, 4112, 0}, - {15, 15, 15, 15, 120, 110, 100, 90, 0, 0}, - {20, 20, 20, 20, 160, 140, 120, 100, 0, 0}, - {25, 25, 25, 25, 140, 140, 140, 140, 0, 0}, - {30, 30, 30, 30, 500, 500, 500, 500, 0, 0}, - {35, 35, 35, 35, 135, 135, 120, 100, 281, 0}, - {40, 40, 40, 40, 500, 500, 500, 500, 0, 0}, - {45, 45, 45, 45, 250, 250, 250, 250, 0, 0}, - {50, 50, 50, 50, 150, 150, 150, 135, 5140, 0}, - {55, 55, 55, 55, 300, 300, 300, 300, 0, 0}, + SpellData(5, 5, 5, 5, 110, 100, 90, 80, 0, 4, 0), //7 light + SpellData(10, 10, 10, 10, 120, 110, 100, 90, 16, 16, 0), + SpellData(15, 15, 15, 15, 120, 110, 100, 90, 0, 0, 0), + SpellData(20, 20, 20, 20, 160, 140, 120, 100, 0, 0, 0), + SpellData(25, 25, 25, 25, 140, 140, 140, 140, 0, 0, 0), + SpellData(30, 30, 30, 30, 500, 500, 500, 500, 0, 0, 0), + SpellData(35, 35, 35, 35, 135, 135, 120, 100, 25, 1, 0), + SpellData(40, 40, 40, 40, 500, 500, 500, 500, 0, 0, 0), + SpellData(45, 45, 45, 45, 250, 250, 250, 250, 0, 0, 0), + SpellData(50, 50, 50, 50, 150, 150, 150, 135, 20, 20, 0), + SpellData(55, 55, 55, 55, 300, 300, 300, 300, 0, 0, 0), - {10, 10, 10, 10, 140, 140, 140, 140, 0, 0}, //8 - {15, 15, 15, 15, 120, 110, 100, 90, 2585, 0}, - {20, 20, 20, 20, 120, 100, 90, 120, 0, 0}, - {25, 25, 25, 25, 120, 120, 120, 120, 0, 0}, - {30, 30, 30, 30, 90, 90, 80, 70, 1542, 0}, - {35, 35, 35, 35, 120, 120, 100, 80, 0, 0}, - {40, 40, 40, 40, 110, 110, 110, 110, 0, 0}, - {45, 45, 45, 45, 200, 200, 200, 150, 0, 0}, - {50, 50, 50, 50, 120, 120, 120, 100, 6400, 0}, - {55, 55, 55, 55, 250, 250, 250, 250, 306, 0}, - {60, 60, 60, 60, 300, 300, 300, 300, 2073, 0} + SpellData(10, 10, 10, 10, 140, 140, 140, 140, 0, 0, 0), //8 dark + SpellData(15, 15, 15, 15, 120, 110, 100, 90, 25, 10, 0), + SpellData(20, 20, 20, 20, 120, 100, 90, 120, 0, 0, 0), + SpellData(25, 25, 25, 25, 120, 120, 120, 120, 0, 0, 0), + SpellData(30, 30, 30, 30, 90, 90, 80, 70, 6, 6, 0), + SpellData(35, 35, 35, 35, 120, 120, 100, 80, 0, 0, 0), + SpellData(40, 40, 40, 40, 110, 110, 110, 110, 0, 0, 0), + SpellData(45, 45, 45, 45, 200, 200, 200, 150, 0, 0, 0), + SpellData(50, 50, 50, 50, 120, 120, 120, 100, 0, 25, 0), + SpellData(55, 55, 55, 55, 250, 250, 250, 250, 50, 1, 0), + SpellData(60, 60, 60, 60, 300, 300, 300, 300, 25, 8, 0) }}; - std::array<unsigned int, 25> wand_spell_ids = { // 135 Wand of Fire 136 Wand of Sparks 137 Wand of Poison 138 Wand of Stunning 139 Wand of Harm @@ -330,7 +350,6 @@ if ((i % 11)==0) strtok(NULL, "\r"); } - } //----- (00448DF8) -------------------------------------------------------- void __fastcall EventCastSpell(int uSpellID, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz)//sub_448DF8 @@ -1061,42 +1080,33 @@ return ( pSpellDatas[uSpellID].stats & 0xC ); } //----- (0043AFE3) -------------------------------------------------------- -int __fastcall _43AFE3_calc_spell_damage(int a1, int a2, signed int a3, int a4) +int _43AFE3_calc_spell_damage(int spellId, int spellLevel, signed int skillMastery, int currentHp) { int result; // eax@1 unsigned int v5; // [sp-4h] [bp-8h]@9 result = 0; - if ( a1 == 7 ) + if ( spellId == SPELL_FIRE_FIRE_SPIKE ) { - if ( a3 <= 0 ) - return result; - if ( a3 <= 2 ) - { - v5 = 6; - } - else + switch (skillMastery) { - if ( a3 == 3 ) - { - v5 = 8; - } - else - { - if ( a3 != 4 ) - return result; - v5 = 10; - } + case 1: + case 2: + v5 = 6; + case 3: + v5 = 8; + case 4: + v5 = 10; + default: + return 0; } - result = GetDiceResult(a2, v5); + result = GetDiceResult(spellLevel, v5); } + else if ( spellId == SPELL_EARTH_MASS_DISTORTION ) + result = currentHp * (pSpellDatas[SPELL_EARTH_MASS_DISTORTION].baseDamage + 2 * spellLevel) / 100; else - { - if ( a1 == 44 ) - result = a4 * (LOBYTE(pSpellDatas[40].field_10) + 2 * a2) / 100; - else - result = *((char *)&pSpellDatas[0].field_10 + 20 * a1) - + GetDiceResult(a2, *((char *)&pSpellDatas[0].field_10 + 20 * a1 + 1)); - } + result = pSpellDatas[spellId].baseDamage + + GetDiceResult(spellLevel, pSpellDatas[spellId].bonusSkillDamage); + return result; } \ No newline at end of file
--- a/Spells.h Mon Mar 17 22:53:24 2014 +0100 +++ b/Spells.h Thu Mar 27 23:28:54 2014 +0100 @@ -217,8 +217,12 @@ /* 151 */ #pragma pack(push, 1) -struct SpellData +class SpellData { +public: + SpellData(__int16 innormalMana, __int16 inExpertLevelMana, __int16 inMasterLevelMana, __int16 inMagisterLevelMana, + __int16 inNormalLevelRecovery, __int16 inExpertLevelRecovery, __int16 inMasterLevelRecovery, __int16 inMagisterLevelRecovery, + __int8 inbaseDamage, __int8 inbonusSkillDamage, __int16 instats); union { unsigned __int16 mana_per_skill[4]; @@ -241,7 +245,8 @@ unsigned __int16 uMagisterLevelRecovery; }; }; - __int16 field_10; + __int8 baseDamage; + __int8 bonusSkillDamage; __int16 stats; // char field_12; // char field_13; @@ -278,4 +283,6 @@ extern std::array<stru324_spell, 103> stru_4E3ACC; extern std::array<SpellData, 100> pSpellDatas; -extern std::array<unsigned int, 25> wand_spell_ids; \ No newline at end of file +extern std::array<unsigned int, 25> wand_spell_ids; + +int _43AFE3_calc_spell_damage(int spellId, int spellLevel, signed int skillMastery, int currentHp);
--- a/mm7_unsorted_subs.h Mon Mar 17 22:53:24 2014 +0100 +++ b/mm7_unsorted_subs.h Thu Mar 27 23:28:54 2014 +0100 @@ -83,7 +83,6 @@ void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int a2, struct Vec3_int_ *pPos, signed int a4); void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2); // idb double __fastcall sub_43AE12(signed int a1); -int __fastcall _43AFE3_calc_spell_damage(int a1, int a2, signed int a3, int a4); void ItemDamageFromActor(unsigned int uObjID, unsigned int uActorID, struct Vec3_int_ *pVelocity); void CharacterUI_LoadPaperdollTextures(); int GetItemTextureFilename(char *pOut, signed int item_id, int index, int shoulder);