diff mm7_2.cpp @ 1413:3881d2f94eb1

UseNPCSkill DIALOGUE_USE_NPC_ABILITY
author Nomad
date Sat, 27 Jul 2013 16:09:00 +0200
parents 2423bc2af692
children 110eac219e5a
line wrap: on
line diff
--- a/mm7_2.cpp	Sat Jul 27 14:28:14 2013 +0200
+++ b/mm7_2.cpp	Sat Jul 27 16:09:00 2013 +0200
@@ -69,59 +69,167 @@
 #include "Lights.h"
 
 //----- (004BB756) --------------------------------------------------------
-signed int __fastcall sub_4BB756(signed int a1)
+int UseNPCSkill(NPCProf profession)
 {
-  unsigned int v1; // esi@8
-  unsigned int v3; // ecx@10
-  Player *v4; // esi@15
-  int v5; // ebx@16
-  int v6; // ST38_4@16
-  Player *v7; // esi@18
-  int v8; // ebx@19
-  int v9; // ST30_4@19
-  int v10; // ST44_4@19
-  int v11; // ST48_4@19
-  int v12; // ST4C_4@19
-  int v13; // ST50_4@19
-  int v14; // ST3C_4@19
-  int v15; // ST40_4@19
-  int v16; // ST34_4@19
-  int v17; // ST38_4@19
-  Player *v18; // esi@21
-  int v19; // eax@26
-  int v20; // eax@39
-  SoundID v21; // [sp-20h] [bp-54h]@25
-  signed int v22; // [sp-1Ch] [bp-50h]@25
-  unsigned int v23; // [sp-18h] [bp-4Ch]@25
-  signed int v24; // [sp-14h] [bp-48h]@25
-  signed int v25; // [sp-10h] [bp-44h]@25
-  int v26; // [sp-10h] [bp-44h]@32
-  int v27; // [sp-Ch] [bp-40h]@25
-  unsigned int v28; // [sp-Ch] [bp-40h]@32
-  unsigned int v29; // [sp-8h] [bp-3Ch]@25
-  __int16 v30; // [sp-8h] [bp-3Ch]@32
-  int v31; // [sp-4h] [bp-38h]@25
-  int v32; // [sp-4h] [bp-38h]@32
-
-  if ( a1 > 39 )
-  {
-    if ( a1 != 40 )
+  switch (profession)
+  {
+    case Healer:
+    {
+      for (int i = 0; i < 4; ++i)
+        pParty->pPlayers[i].sHealth = pParty->pPlayers[i].GetMaxHealth();
+    }
+    break;
+
+    case ExpertHealer:
+    {
+      for (int i = 0; i < 4; ++i)
+      {
+        auto player = &pParty->pPlayers[i];
+        player->sHealth = player->GetMaxHealth();
+
+        for (int j = 0; j < 14; ++j)
+          player->pConditions[i] = 0;
+        player->pConditions[18] = 0;
+      }
+    }
+    break;
+
+    case MasterHealer:
+    {
+      for (int i = 0; i < 4; ++i)
+      {
+        auto player = &pParty->pPlayers[i];
+        player->sHealth = player->GetMaxHealth();
+
+        auto v5 = LODWORD(player->pConditions[19]);//*((int *)v4 - 32);
+        auto v6 = HIDWORD(player->pConditions[19]);//*((int *)v4 - 31);
+        memset(player->pConditions, 0, 0xA0u);
+
+        __debugbreak();
+        *(int *)&player->pActiveSkills[8] = v5;
+        *(int *)&player->pActiveSkills[10] = v6;
+      }
+    }
+    break;
+
+    case Cook:
+    {
+      if (pParty->uNumFoodRations >= 13)
+        return 1;
+
+      Party::GiveFood(1);
+    }
+    break;
+
+    case Chef:
+    {
+      if (pParty->uNumFoodRations >= 13)
+        return 1;
+
+      if (pParty->uNumFoodRations == 13)
+        Party::GiveFood(1);
+      else
+        Party::GiveFood(2);
+    }
+    break;
+
+    case WindMaster:
     {
-      if ( a1 == 41 )
+      if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
+      {
+        ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2);
+        pAudioPlayer->PlaySound(SOUND_203, 0, 0, -1, 0, 0, 0, 0);
+      }
+      else
+      {
+        auto v19 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536);
+        pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + 60 * (256 * 2), 3, 1, v19, 0);
+        pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags |= 1u;
+        pAudioPlayer->PlaySound(SOUND_11090, 0, 0, -1, 0, 0, 0, 0);
+      }
+    }
+    break;
+
+    case WaterMaster:
+    {
+      auto v20 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536);
+      pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(pParty->uTimePlayed + 60 * (256 * (2 + 1)), 3, 0, v20, 0);
+      pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags |= 1u;
+      pAudioPlayer->PlaySound(SOUND_12040, 0, 0, -1, 0, 0, 0, 0);
+    }
+    break;
+
+    case GateMaster:
+    {
+      pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
+      dword_50C9DC = 195;
+      ptr_50C9E0 = GetNPCData(sDialogue_SpeakingActorNPC_ID);
+    }
+    break;
+
+    case Acolyte:      _42777D_CastSpell_UseWand_ShootArrow(46, 0, 133, 0, 0); break;
+    case Piper:        _42777D_CastSpell_UseWand_ShootArrow(51, 0, 133, 0, 0); break;
+    case FallenWizard: _42777D_CastSpell_UseWand_ShootArrow(86, 0, 133, 0, 0); break;
+      
+    case Teacher:
+    case Instructor:
+    case Armsmaster:
+    case Weaponsmaster:
+    case Apprentice:
+    case Mystic:
+    case Spellmaster:
+    case Trader:
+    case Merchant:
+    case Scout:
+    case Herbalist:
+    case Apothecary:
+    case Tinker:
+    case Locksmith:
+    case Fool:
+    case ChimneySweep:
+    case Porter:
+    case QuarterMaster:
+    case Factor:
+    case Banker:
+    case Horseman:
+    case Bard:
+    case Enchanter:
+    case Cartographer:
+    case Explorer:
+    case Pirate:
+    case Squire:
+    case Psychic:
+    case Gypsy:
+    case Diplomat:
+    case Duper:
+    case Burglar:
+    case Acolyte2:
+    case Initiate:
+    case Prelate:
+    case Monk:
+    case Sage:
+    case Hunter:
+      break;
+
+    default:
+      assert(false && "Invalid enum value");
+  }
+  return 0;
+
+
+  /*
+  if ( profession > 39 )
+  {
+    if ( profession != 40 )
+    {
+      if ( profession == 41 )
       {
         pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0);
-        /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
-        {
-          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape;
-          pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0;
-          *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
-          ++pMessageQueue_50CBD0->uNumMessages;
-        }*/
         dword_50C9DC = 195;
         ptr_50C9E0 = GetNPCData(sDialogue_SpeakingActorNPC_ID);
         return 0;
       }
-      if ( a1 == 42 )
+      if ( profession == 42 )
       {
         v32 = 0;
         v30 = 0;
@@ -130,7 +238,7 @@
       }
       else
       {
-        if ( a1 == 43 )
+        if ( profession == 43 )
         {
           v32 = 0;
           v30 = 0;
@@ -139,7 +247,7 @@
         }
         else
         {
-          if ( a1 != 52 )
+          if ( profession != 52 )
             return 0;
           v32 = 0;
           v30 = 0;
@@ -165,7 +273,7 @@
     pAudioPlayer->PlaySound(v21, v22, v23, v24, v25, v27, v29, v31);
     return 0;
   }
-  if ( a1 == 39 )
+  if ( profession == 39 )
   {
     if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
     {
@@ -196,7 +304,7 @@
     pAudioPlayer->PlaySound(v21, v22, v23, v24, v25, v27, v29, v31);
     return 0;
   }
-  if ( a1 == 10 )
+  if ( profession == 10 )
   {
     v18 = pParty->pPlayers;
     do
@@ -207,21 +315,11 @@
     while ( (signed int)v18 < (signed int)pParty->pHirelings );
     return 0;
   }
-  if ( a1 == 11 )
+  if ( profession == 11 )
   {
     v7 = pParty->pPlayers;//(char *)&pParty->pPlayers[0].pConditions[15];
     do
     {
-      /*v8 = *((int *)v7 - 2);
-      v9 = *((int *)v7 - 1);
-      v10 = *(int *)v7;
-      v11 = *((int *)v7 + 1);
-      v12 = *((int *)v7 + 2);
-      v13 = *((int *)v7 + 3);
-      v14 = *((int *)v7 + 8);
-      v15 = *((int *)v7 + 9);
-      v16 = *((int *)v7 + 4);
-      v17 = *((int *)v7 + 5);*/
 	  v8 = LODWORD(v7->pConditions[14]);
 	  v9 = HIDWORD(v7->pConditions[14]);
 	  v10 = LODWORD(v7->pConditions[15]);
@@ -249,7 +347,7 @@
     while ( v7 <= pPlayers[3] );
     return 0;
   }
-  if ( a1 == 12 )
+  if ( profession == 12 )
   {
 	  v4 = pParty->pPlayers;//(char *)&pParty->pPlayers[0].pActiveSkills[8];
     do
@@ -265,7 +363,7 @@
     while ( v4 <= pPlayers[3] );
     return 0;
   }
-  if ( a1 == 33 )
+  if ( profession == 33 )
   {
     v1 = 14;
     if ( pParty->uNumFoodRations >= 0xE )
@@ -277,7 +375,7 @@
       pParty->uNumFoodRations = v1;
     return 0;
   }
-  if ( a1 == 34 )
+  if ( profession == 34 )
   {
     v1 = 14;
     if ( pParty->uNumFoodRations >= 0xE )
@@ -285,9 +383,8 @@
     v3 = 2;
     goto LABEL_13;
   }
-  return 0;
+  return 0;*/
 }
-// 50C9DC: using guessed type int dword_50C9DC;
 
 //----- (004BBA85) --------------------------------------------------------
 const char *sub_4BBA85_bounties()