diff SpriteObject.cpp @ 2331:9551756f46c4

Moving functions out of mm7_6.cpp into appropriate classes as static methods or free functions
author Grumpy7
date Wed, 02 Apr 2014 01:21:05 +0200
parents df24d11208df
children ddb803517a48
line wrap: on
line diff
--- a/SpriteObject.cpp	Tue Apr 01 23:44:27 2014 +0200
+++ b/SpriteObject.cpp	Wed Apr 02 01:21:05 2014 +0200
@@ -14,6 +14,7 @@
 #include "LOD.h"
 #include "Actor.h"
 #include "Events.h"
+#include "AudioPlayer.h"
 #include "Level/Decoration.h"
 
 #include "mm7_data.h"
@@ -1042,4 +1043,114 @@
       }
     }
   }
+}
+
+
+//----- (0042F7EB) --------------------------------------------------------
+bool SpriteObject::sub_42F7EB_DropItemAt(unsigned int uSpriteID, int x, int y, int z, int a4, int count, int a7, unsigned __int16 attributes, ItemGen *a9)
+{
+  unsigned __int16 pObjectDescID; // ax@7
+  SpriteObject pSpellObject; // [sp+Ch] [bp-78h]@1
+
+  pSpellObject.stru_24.Reset();
+  if ( a9 )
+    memcpy(&pSpellObject.stru_24, a9, sizeof(pSpellObject.stru_24));
+  pSpellObject.spell_skill = 0;
+  pSpellObject.spell_level = 0;
+  pSpellObject.spell_id = 0;
+  pSpellObject.field_54 = 0;
+  pSpellObject.uType = uSpriteID;
+  pObjectDescID = 0;
+  for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i )
+  {
+    if ( (short)uSpriteID == pObjectList->pObjects[i].uObjectID )
+      pObjectDescID = i;
+  }
+  pSpellObject.uObjectDescID = pObjectDescID;
+  pSpellObject.vPosition.x = x;
+  pSpellObject.vPosition.y = y;
+  pSpellObject.vPosition.z = z;
+  pSpellObject.uSoundID = 0;
+  pSpellObject.uAttributes = attributes;
+  pSpellObject.uSectorID = pIndoor->GetSector(x, y, z);
+  pSpellObject.uSpriteFrameID = 0;
+  pSpellObject.spell_caster_pid = 0;
+  pSpellObject.spell_target_pid = 0;
+  if ( !(pSpellObject.uAttributes & 0x10) )
+  {
+    if ( pItemsTable->uAllItemsCount )
+    {
+      for ( uint i = 1; i < pItemsTable->uAllItemsCount; ++i )
+      {
+        if ( pItemsTable->pItems[i].uSpriteID == uSpriteID )
+          pSpellObject.stru_24.uItemID = i;
+      }
+    }
+  }
+  if ( a7 )
+  {
+    if ( count > 0 )
+    {
+      for ( uint i = count; i; --i )
+      {
+        pSpellObject.uFacing = rand() % (signed int)stru_5C6E00->uIntegerDoublePi;
+        pSpellObject.Create((signed __int16)pSpellObject.uFacing,
+          ((signed int)stru_5C6E00->uIntegerHalfPi / 2) + (rand() % ((signed int)stru_5C6E00->uIntegerHalfPi / 2)), a4, 0);
+
+      }
+    }
+  }
+  else
+  {
+    pSpellObject.uFacing = 0;
+    if ( count > 0 )
+    {
+      for ( uint i = count; i; --i )
+      {
+        pSpellObject.Create((signed __int16)pSpellObject.uFacing, stru_5C6E00->uIntegerHalfPi, a4, 0);
+      }
+    }
+  }
+  return true;
+}
+
+//----- (0042F960) --------------------------------------------------------
+void SpriteObject::sub_42F960_create_object(int x, int y, int z)
+{
+  unsigned __int16 v7; // ax@5
+  signed int v8; // eax@6
+  signed int v9; // eax@7
+
+  SpriteObject a1; // [sp+Ch] [bp-70h]@1
+  //SpriteObject::SpriteObject(&a1);
+  a1.stru_24.Reset();
+
+  a1.spell_skill = 0;
+  a1.spell_level = 0;
+  a1.spell_id = 0;
+  a1.field_54 = 0;
+  a1.uType = 800;
+  v7 = 0;
+  for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i )
+  {
+    if ( a1.uType == pObjectList->pObjects[i].uObjectID  )
+      v7 = i;
+  }
+  a1.uObjectDescID = v7;
+  a1.vPosition.x = x;
+  a1.vPosition.y = y;
+  a1.vPosition.z = z;
+  a1.uSoundID = 0;
+  a1.uAttributes = 0;
+  a1.uSectorID = pIndoor->GetSector(x, y, z);
+  a1.uSpriteFrameID = 0;
+  a1.spell_caster_pid = 0;
+  a1.spell_target_pid = 0;
+  v8 = a1.Create(0, 0, 0, 0);
+  if ( v8 != -1 )
+  {
+    v9 = 8 * v8;
+    LOBYTE(v9) = v9 | 2;
+    pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x14), v9, 0, -1, 0, 0, 0, 0);
+  }
 }
\ No newline at end of file