diff Engine/Party.cpp @ 2565:117c219bf913

Party, items and stuff are abstracted from savegame file representation
author a.parshin
date Wed, 20 May 2015 15:12:33 +0200
parents c674d547cc7c
children 30eb6dcac768
line wrap: on
line diff
--- a/Engine/Party.cpp	Wed May 20 00:56:07 2015 +0200
+++ b/Engine/Party.cpp	Wed May 20 15:12:33 2015 +0200
@@ -272,7 +272,7 @@
 }
 
 //----- (0049137D) --------------------------------------------------------
-void Party::CreateDefaultParty(char bGiveItems)
+void Party::CreateDefaultParty(bool bDebugGiveItems)
 {
   Player *pCharacter; // esi@3
   int uSkillIdx; // eax@11
@@ -285,7 +285,7 @@
   this->hirelingScrollPosition = 0;
   memset(&pHirelings, 0, sizeof(pHirelings));
 
-  strcpy(this->pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]); //Zoltan
+  strcpy(this->pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]); // Zoltan
   this->pPlayers[0].uPrevFace = 17;
   this->pPlayers[0].uCurrentFace = 17;
   this->pPlayers[0].uPrevVoiceID = 17;
@@ -297,15 +297,16 @@
   this->pPlayers[0].uAccuracy = 13;
   this->pPlayers[0].uSpeed = 14;
   this->pPlayers[0].uLuck = 7;
-  this->pPlayers[0].pActiveSkills[PLAYER_SKILL_LEATHER] = 1;         // leather
-  this->pPlayers[0].pActiveSkills[PLAYER_SKILL_ARMSMASTER] = 1;        // armsmaster
-  this->pPlayers[0].pActiveSkills[PLAYER_SKILL_BOW] = 1;         // bow
-  this->pPlayers[0].pActiveSkills[PLAYER_SKILL_SWORD] = 1;         // sword
+  this->pPlayers[0].pActiveSkills[PLAYER_SKILL_LEATHER] = 1;
+  this->pPlayers[0].pActiveSkills[PLAYER_SKILL_ARMSMASTER] = 1;
+  this->pPlayers[0].pActiveSkills[PLAYER_SKILL_BOW] = 1;
+  this->pPlayers[0].pActiveSkills[PLAYER_SKILL_SWORD] = 1;
+
+  strcpy(this->pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); // Roderic
   this->pPlayers[1].uPrevFace = 3;
   this->pPlayers[1].uCurrentFace = 3;
   this->pPlayers[1].uPrevVoiceID = 3;
   this->pPlayers[1].uVoiceID = 3;
-  strcpy(this->pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); //Roderic
   this->pPlayers[1].uMight = 13;
   this->pPlayers[1].uIntelligence = 9;
   this->pPlayers[1].uWillpower = 9;
@@ -313,15 +314,16 @@
   this->pPlayers[1].uAccuracy = 13;
   this->pPlayers[1].uSpeed = 13;
   this->pPlayers[1].uLuck = 13;
-  this->pPlayers[1].pActiveSkills[PLAYER_SKILL_LEATHER] = 1;         // leather
-  this->pPlayers[1].pActiveSkills[PLAYER_SKILL_STEALING] = 1;        // stealing
-  this->pPlayers[1].pActiveSkills[PLAYER_SKILL_DAGGER] = 1;         // dagger
-  this->pPlayers[1].pActiveSkills[PLAYER_SKILL_TRAP_DISARM] = 1;        // disarm trap
+  this->pPlayers[1].pActiveSkills[PLAYER_SKILL_LEATHER] = 1;
+  this->pPlayers[1].pActiveSkills[PLAYER_SKILL_STEALING] = 1;
+  this->pPlayers[1].pActiveSkills[PLAYER_SKILL_DAGGER] = 1;
+  this->pPlayers[1].pActiveSkills[PLAYER_SKILL_TRAP_DISARM] = 1;
+
+  strcpy(this->pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); // Serena
   this->pPlayers[2].uPrevFace = 14;
   this->pPlayers[2].uCurrentFace = 14;
   this->pPlayers[2].uPrevVoiceID = 14;
   this->pPlayers[2].uVoiceID = 14;
-  strcpy(this->pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); // Serena
   this->pPlayers[2].uMight = 12;
   this->pPlayers[2].uIntelligence = 9;
   this->pPlayers[2].uWillpower = 20;
@@ -329,10 +331,11 @@
   this->pPlayers[2].uAccuracy = 7;
   this->pPlayers[2].uSpeed = 13;
   this->pPlayers[2].uLuck = 7;
-  this->pPlayers[2].pActiveSkills[PLAYER_SKILL_ALCHEMY] = 1;        // alchemy
-  this->pPlayers[2].pActiveSkills[PLAYER_SKILL_LEATHER] = 1;         // leather
-  this->pPlayers[2].pActiveSkills[PLAYER_SKILL_BODY] = 1;        // body
-  this->pPlayers[2].pActiveSkills[PLAYER_SKILL_MACE] = 1;         // mace
+  this->pPlayers[2].pActiveSkills[PLAYER_SKILL_ALCHEMY] = 1;
+  this->pPlayers[2].pActiveSkills[PLAYER_SKILL_LEATHER] = 1;
+  this->pPlayers[2].pActiveSkills[PLAYER_SKILL_BODY] = 1;
+  this->pPlayers[2].pActiveSkills[PLAYER_SKILL_MACE] = 1;
+
   strcpy(this->pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]); // Alexis
   this->pPlayers[3].uPrevFace = 10;
   this->pPlayers[3].uCurrentFace = 10;
@@ -349,24 +352,29 @@
   this->pPlayers[3].pActiveSkills[PLAYER_SKILL_AIR] = 1;        // air
   this->pPlayers[3].pActiveSkills[PLAYER_SKILL_FIRE] = 1;        // fire
   this->pPlayers[3].pActiveSkills[PLAYER_SKILL_STAFF] = 1;         // staff
+
   for (uNumPlayers = 0; uNumPlayers < 4; uNumPlayers++)
   {
     pCharacter = &pParty->pPlayers[uNumPlayers];
+
     if (pCharacter->classType == PLAYER_CLASS_KNIGHT)
-      pCharacter->sResMagicBase = 10; //player[i].pResMagicBase
+      pCharacter->sResMagicBase = 10;
+
     pCharacter->lastOpenedSpellbookPage = 0;
     for (int i = 0; i < 9; i++)//for Magic Book
     {
-	    if (pPlayers[uNumPlayers].pActiveSkills[12+i])
+	  if (pPlayers[uNumPlayers].pActiveSkills[12+i])
       {
         pCharacter->lastOpenedSpellbookPage = i;
         break;
       }
     }
+
     pCharacter->uExpressionTimePassed = 0;
-    Dst.Reset();
-    if ( bGiveItems )
+
+    if (bDebugGiveItems)
     {
+        Dst.Reset();
       pItemsTable->GenerateItem(2, 40, &Dst); //ring
       pCharacter->AddItem2(-1, &Dst);
 	    for (uSkillIdx = 0; uSkillIdx < 36; uSkillIdx++)
@@ -457,13 +465,14 @@
           pCharacter->pInventoryItemList[i].SetIdentified();
       }
     }
+
     pCharacter->sHealth = pCharacter->GetMaxHealth();
     pCharacter->sMana = pCharacter->GetMaxMana();
   }
 }
 
 //----- (004917CE) --------------------------------------------------------
-int Party::Reset()
+void Party::Reset()
 {  
   Zero();
 
@@ -472,11 +481,13 @@
   uNumGold = 200;
   uNumFoodRations = 7;
 
-  
   alignment = PartyAlignment_Neutral;
   SetUserInterface(alignment, true);
 
-  uTimePlayed = 0x21C00u;
+  // 0x21C00 = 138240
+  // 138240 x 0.234375 = 32400
+  // 32400 / 60 / 60 = 9 am
+  uTimePlayed = 0x21C00;
   uLastRegenerationTime = 0x21C00;
 
   bTurnBasedModeOn = false;
@@ -487,9 +498,6 @@
     ::pPlayers[i + 1] = &pPlayers[i];
 
   pPlayers[0].Reset(PLAYER_CLASS_KNIGHT);
-  pPlayers[1].Reset(PLAYER_CLASS_THEIF);
-  pPlayers[2].Reset(PLAYER_CLASS_CLERIC);
-  pPlayers[3].Reset(PLAYER_CLASS_SORCERER);
   pPlayers[0].uCurrentFace = 17;
   pPlayers[0].uPrevVoiceID = 17;
   pPlayers[0].uVoiceID = 17;
@@ -500,6 +508,7 @@
   strcpy(pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]);
 
 
+  pPlayers[1].Reset(PLAYER_CLASS_THEIF);
   pPlayers[1].uCurrentFace = 3;
   pPlayers[1].uPrevVoiceID = 3;
   pPlayers[1].uVoiceID = 3;
@@ -507,6 +516,8 @@
   pPlayers[1].uSex = pPlayers[1].GetSexByVoice();
   pPlayers[1].RandomizeName();
   strcpy(pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]);
+
+  pPlayers[2].Reset(PLAYER_CLASS_CLERIC);
   pPlayers[2].uCurrentFace = 14;
   pPlayers[2].uPrevVoiceID = 14;
   pPlayers[2].uVoiceID = 14;
@@ -514,6 +525,8 @@
   pPlayers[2].uSex = pPlayers[3].GetSexByVoice();
   pPlayers[2].RandomizeName();
   strcpy(pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]);
+
+  pPlayers[3].Reset(PLAYER_CLASS_SORCERER);
   pPlayers[3].uCurrentFace = 10;
   pPlayers[3].uPrevVoiceID = 10;
   pPlayers[3].uVoiceID = 10;
@@ -539,18 +552,11 @@
   for (uint i = 1; i < 20; ++i)
     pPartyBuffs[i].Reset();
 
-
   current_character_screen_window = WINDOW_CharacterWindow_Stats;  // default character ui - stats
   uFlags = 0;
   memset(_autonote_bits, 0, sizeof(_autonote_bits));
   memset(_quest_bits, 0, sizeof(_quest_bits));
   pIsArtifactFound.fill(0);
-  _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_RED_POTION_ACTIVE, 1);
-  _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_SEASHELL_ACTIVE, 1);
-  _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_LONGBOW_ACTIVE, 1);
-  _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_PLATE_ACTIVE, 1);
-  _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_LUTE_ACTIVE, 1);
-  _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_HAT_ACTIVE, 1);
 
   PartyTimes._shop_ban_times.fill(0);
 
@@ -559,7 +565,6 @@
   pNPCStats->pNewNPCData[3].uFlags |= 128;//|= 0x80u; Lady Margaret
   _494035_timed_effects__water_walking_damage__etc();
   pEventTimer->Pause();
-  return 0;
 }