diff mm7_4.cpp @ 198:e6e348d66a75

Some work on spellbook
author Nomad
date Sat, 16 Feb 2013 21:46:07 +0200
parents 650d96af8855
children 0c64754c7fd4
line wrap: on
line diff
--- a/mm7_4.cpp	Sat Feb 16 20:24:31 2013 +0200
+++ b/mm7_4.cpp	Sat Feb 16 21:46:07 2013 +0200
@@ -1,5 +1,6 @@
 #include <io.h>
 #include <direct.h>
+#include <assert.h>
 
 #include "MapInfo.h"
 #include "Game.h"
@@ -5861,7 +5862,7 @@
   signed int uSkillIdx; // eax@45
   int v15; // eax@70
   signed int v16; // ecx@70
-  unsigned int v18; // [sp-4h] [bp-84h]@48
+  //unsigned int v18; // [sp-4h] [bp-84h]@48
   ItemGen item; // [sp+Ch] [bp-74h]@37
   char v20[32]; // [sp+30h] [bp-50h]@29
   //char v21; // [sp+31h] [bp-4Fh]@29
@@ -5999,7 +6000,7 @@
       if ( pPlayer->pActiveSkills[12+i] )
         ++uSpellBookPageCount;
     }
-    pPlayer->pNumSpellBookPage = uSpellBookPageCount;
+    pPlayer->lastOpenedSpellbookPage = uSpellBookPageCount;
     pItemsTable->GenerateItem(2, 40, &item);
     pPlayer->AddItem2(-1, &item);
     uSkillIdx = 0;
@@ -6010,96 +6011,66 @@
       {
         switch ( uSkillIdx )
         {
-          case 0:
-            v18 = 61;
-            pPlayer->AddItem(-1, v18);
-            break;
-          case 1:
-            v18 = 1;
-            pPlayer->AddItem(-1, v18);
-            break;
-          case 2:
-            v18 = 15;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 3:
-            v18 = 23;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 4:
-            v18 = 31;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 5:
-            v18 = 47;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 6:
-            v18 = 50;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 8:
-            v18 = 84;
-  			pPlayer->AddItem(-1, v18);
-            break;
-          case 9:
-            v18 = 66;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 10:
-            v18 = 71;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 11:
-            v18 = 76;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 12:
+          case PLAYER_SKILL_STAFF:   pPlayer->AddItem(-1, 61); break;
+          case PLAYER_SKILL_SWORD:   pPlayer->AddItem(-1, 1); break;
+          case PLAYER_SKILL_DAGGER:  pPlayer->AddItem(-1, 15); break;
+          case PLAYER_SKILL_AXE:     pPlayer->AddItem(-1, 23); break;
+          case PLAYER_SKILL_SPEAR:   pPlayer->AddItem(-1, 31); break;
+          case PLAYER_SKILL_BOW:     pPlayer->AddItem(-1, 47); break;
+          case PLAYER_SKILL_MACE:    pPlayer->AddItem(-1, 50); break;
+          case PLAYER_SKILL_BLASTER: assert(false); break;
+          case PLAYER_SKILL_SHIELD:  pPlayer->AddItem(-1, 84); break;
+          case PLAYER_SKILL_LEATHER: pPlayer->AddItem(-1, 66); break;
+          case PLAYER_SKILL_CHAIN:   pPlayer->AddItem(-1, 71); break;
+          case PLAYER_SKILL_PLATE:   pPlayer->AddItem(-1, 76); break;
+          case PLAYER_SKILL_FIRE:
             pPlayer->AddItem(-1, 0x191);
-            pPlayer->spellbook.pFireSpellbook.bIsSpellbookAvailable = 1;
-            break;
-          case 13:
+            pPlayer->spellbook.pFireSpellbook.bIsSpellAvailable[0] = true;
+          break;
+          case PLAYER_SKILL_AIR:
             pPlayer->AddItem(-1, 0x19C);
-            pPlayer->spellbook.pAirSpellbook.bIsSpellbookAvailable = 1;
-            break;
-          case 14:
+            pPlayer->spellbook.pAirSpellbook.bIsSpellAvailable[0] = true;
+          break;
+          case PLAYER_SKILL_WATER:
             pPlayer->AddItem(-1, 0x1A7);
-			pPlayer->spellbook.pWaterSpellbook.bIsSpellbookAvailable = 1;
-            break;
-          case 15:
+			pPlayer->spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true;
+          break;
+          case PLAYER_SKILL_EARTH:
             pPlayer->AddItem(-1, 0x1B2);
-			pPlayer->spellbook.pEarthSpellbook.bIsSpellbookAvailable = 1;
-            break;
-          case 16:
+			pPlayer->spellbook.pEarthSpellbook.bIsSpellAvailable[0] = true;
+          break;
+          case PLAYER_SKILL_SPIRIT:
             pPlayer->AddItem(-1, 0x1BD);
-			pPlayer->spellbook.pSpiritSpellbook.bIsSpellbookAvailable = 1;
-            break;
-          case 17:
+			pPlayer->spellbook.pSpiritSpellbook.bIsSpellAvailable[0] = true;
+          break;
+          case PLAYER_SKILL_MIND:
             pPlayer->AddItem(-1, 0x1C8);
-			pPlayer->spellbook.pMindSpellbook.bIsSpellbookAvailable = 1;
-            break;
-          case 18:
+			pPlayer->spellbook.pMindSpellbook.bIsSpellAvailable[0] = true;
+          break;
+          case PLAYER_SKILL_BODY:
             pPlayer->AddItem(-1, 0x1D3);
-			pPlayer->spellbook.pBodySpellbook.bIsSpellbookAvailable = 1;
-            break;
-          case 21:
-          case 23:
-          case 25:
-          case 26:
-          case 29:
-          case 36:
+			pPlayer->spellbook.pBodySpellbook.bIsSpellAvailable[0] = true;
+          break;
+          case PLAYER_SKILL_LIGHT:
+          case PLAYER_SKILL_DARK:
+          case PLAYER_SKILL_DIPLOMACY:
+            assert(false);
+          break;
+          case PLAYER_SKILL_ITEM_ID:
+          case PLAYER_SKILL_REPAIR:
+          case PLAYER_SKILL_MEDITATION:
+          case PLAYER_SKILL_PERCEPTION:
+          case PLAYER_SKILL_TRAP_DISARM:
+          case PLAYER_SKILL_LEARNING:
             pPlayer->AddItem(-1, 0xDC);
-            v18 = 5 * (rand() % 3 + 40);
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 30:
-            v18 = 115;
-			pPlayer->AddItem(-1, v18);
-            break;
-          case 31:
-            v18 = 110;
-            pPlayer->AddItem(-1, v18);
-            break;
+			pPlayer->AddItem(-1, 5 * (rand() % 3 + 40));
+          break;
+          case PLAYER_SKILL_DODGE:
+			pPlayer->AddItem(-1, 115);
+          break;
+          case PLAYER_SKILL_UNARMED:
+            pPlayer->AddItem(-1, 110);
+          break;
           default:
             break;
         }