Mercurial > mm7
changeset 828:0f56abdcce94
Massive refactors of spells + PID (packed id) macros introduced.
author | Nomad |
---|---|
date | Wed, 27 Mar 2013 00:27:38 +0200 |
parents | fe4c8b113548 |
children | d5b1870df3ab |
files | Actor.cpp Actor.h MM7.h Outdoor.cpp Party.cpp Player.cpp SpriteObject.cpp UIPopup.cpp UiGame.cpp Vis.cpp mm7_3.cpp mm7_5.cpp mm7_6.cpp stru6.cpp |
diffstat | 14 files changed, 1691 insertions(+), 1572 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Tue Mar 26 20:06:51 2013 +0200 +++ b/Actor.cpp Wed Mar 27 00:27:38 2013 +0200 @@ -21,6 +21,14 @@ #include "GUIWindow.h" #include "GUIFont.h" +#include "MM7.h" + + + + + + + Actor pActors[500]; int uNumActors; @@ -384,7 +392,7 @@ int v15; // eax@34 AIDirection *v16; // esi@34 unsigned __int16 v17; // di@34 - int v18; // eax@34 + //int v18; // eax@34 int v19; // edi@34 int v20; // eax@35 int v21; // eax@39 @@ -444,7 +452,7 @@ int v75; // eax@184 AIDirection *v76; // esi@184 unsigned __int16 v77; // di@184 - int v78; // eax@184 + //int v78; // eax@184 int v79; // edx@185 int v80; // eax@185 int v81; // eax@189 @@ -456,7 +464,7 @@ unsigned __int16 v87; // di@192 __int16 v88; // ax@192 signed int v89; // ecx@192 - int v90; // eax@192 + //int v90; // eax@192 signed int v91; // eax@200 int v92; // eax@201 int v93; // ecx@207 @@ -609,9 +617,7 @@ a1.uSoundID = 0; a1.uAttributes = 0; a1.uSectorID = pIndoor->GetSector(v13, v14, v15); - v18 = 8 * LODWORD(v120); - LOBYTE(v18) = 8 * LOBYTE(v120) | AI_OBJECT_ACTOR; - a1.spell_caster_pid = v18; + a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120)); a1.uSpriteFrameID = 0; a1.spell_target_pid = 0; a1.field_60_distance_related_prolly_lod = 3; @@ -693,10 +699,8 @@ v89 = v86->uDistance; a1.uSectorID = v88; LODWORD(v119) = v89; - v90 = 8 * LODWORD(v120); - LOBYTE(v90) = 8 * LOBYTE(v120) | OBJECT_Actor; a1.uSpriteFrameID = 0; - a1.spell_caster_pid = v90; + a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120)); a1.spell_target_pid = 0; a1.field_60_distance_related_prolly_lod = 3; if ( (double)v89 >= 307.2 ) @@ -1382,9 +1386,7 @@ a1.uSoundID = 0; a1.uAttributes = 0; a1.uSectorID = pIndoor->GetSector(v73, v74, v75); - v78 = 8 * LODWORD(v120); - LOBYTE(v78) = 8 * LOBYTE(v120) | OBJECT_Actor; - a1.spell_caster_pid = v78; + a1.spell_caster_pid = PID(OBJECT_Actor, LODWORD(v120)); a1.uSpriteFrameID = 0; a1.spell_target_pid = 0; a1.field_60_distance_related_prolly_lod = 3; @@ -1490,7 +1492,7 @@ unsigned __int16 v9; // ax@19 __int16 v10; // ax@19 signed int v11; // ecx@19 - int v12; // eax@19 + //int v12; // eax@19 int v13; // edx@28 //SpriteObject a1; // [sp+Ch] [bp-74h]@1 unsigned int v15; // [sp+7Ch] [bp-4h]@1 @@ -1580,10 +1582,8 @@ v10 = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); v11 = v4->uDistance; a1.uSectorID = v10; - v12 = 8 * v15; - LOBYTE(v12) = 8 * v15 | AI_OBJECT_ACTOR; a1.uSpriteFrameID = 0; - a1.spell_caster_pid = v12; + a1.spell_caster_pid = PID(OBJECT_Actor, v15); a1.spell_target_pid = 0; if ( (double)v11 >= 307.2 ) { @@ -1645,7 +1645,7 @@ unsigned __int16 v4; // ax@5 int v5; // ebx@6 int v6; // ecx@6 - int v7; // eax@6 + //int v7; // eax@6 SpriteObject a1; // [sp+Ch] [bp-78h]@1 unsigned int v10; // [sp+7Ch] [bp-8h]@1 int v11; // [sp+80h] [bp-4h]@6 @@ -1686,10 +1686,8 @@ a1.uSoundID = 0; a1.uAttributes = 0; a1.uSectorID = pIndoor->GetSector(v5, a1.vPosition.y, v6); - v7 = 8 * v10; - LOBYTE(v7) = 8 * v10 | OBJECT_Actor; a1.uSpriteFrameID = 0; - a1.spell_caster_pid = v7; + a1.spell_caster_pid = PID(OBJECT_Actor, v10); a1.spell_target_pid = 0; a1.field_60_distance_related_prolly_lod = 3; a1.field_61 = 4; @@ -1983,7 +1981,7 @@ v9 = &pActors[v5]; if ( !a4 ) { - v10 = Actor::GetDirectionInfo(8 * v5 | AI_OBJECT_ACTOR, v4, &a3, 0); + v10 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v5), v4, &a3, 0); v7 = &v13; memcpy(&v13, v10, sizeof(v13)); v8 = 0; @@ -2020,7 +2018,7 @@ AIDirection a3; if (!a4) - a4 = Actor::GetDirectionInfo(8 * uActorID | 3, object_to_face_pid, &a3, 0); + a4 = Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), object_to_face_pid, &a3, 0); actor->uAIState = Standing; if (!uActionLength) @@ -2121,7 +2119,7 @@ v13 = 0; if ( !arg0 ) { - v14 = Actor::GetDirectionInfo(8 * v24 | OBJECT_Actor, a2, &a3, 0); + v14 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v24), a2, &a3, 0); v12 = &v20; memcpy(&v20, v14, sizeof(v20)); v13 = 0; @@ -3173,7 +3171,7 @@ int v4; // eax@3 int v5; // eax@4 unsigned int v6; // eax@6 - signed int v7; // eax@12 + //signed int v7; // eax@12 signed int v8; // [sp-18h] [bp-1Ch]@10 signed int v9; // [sp-14h] [bp-18h]@10 int v10; // [sp-10h] [bp-14h]@10 @@ -3220,9 +3218,7 @@ v9 = 0; v8 = 0; } - v7 = 8 * uActorID; - LOBYTE(v7) = 8 * uActorID | OBJECT_Actor; - pAudioPlayer->PlaySound((SoundID)(signed __int16)v3, v7, 0, v8, v9, v10, v11, v12); + pAudioPlayer->PlaySound((SoundID)(signed __int16)v3, PID(OBJECT_Actor, uActorID), 0, v8, v9, v10, v11, v12); } } @@ -3628,7 +3624,7 @@ if ( v23 <= v11 && v27 <= v11 && v12 <= v11 - && sub_4070EF_prolly_collide_objects(8 * i | OBJECT_Actor, 8 * uActorID | OBJECT_Actor) + && sub_4070EF_prolly_collide_objects(PID(OBJECT_Actor, i), PID(OBJECT_Actor, uActorID)) && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 ) { v25 = v23 * v23 + v27 * v27 + v19 * v19; @@ -3645,7 +3641,7 @@ { //v13 = 8 * v21; //LOBYTE(v13) = 8 * v21 | OBJECT_Actor; - *a2 = 8 * v21 | OBJECT_Actor; + *a2 = PID(OBJECT_Actor, v21); } if (pParty->Invisible())
--- a/Actor.h Tue Mar 26 20:06:51 2013 +0200 +++ b/Actor.h Wed Mar 27 00:27:38 2013 +0200 @@ -68,15 +68,6 @@ -/* 337 */ -enum AI_OBJECT_TYPE -{ - AI_OBJECT_LAYING_ITEM = 0x2, - AI_OBJECT_ACTOR = 0x3, - AI_OBJECT_PARTY = 0x4, - AI_OBJECT_DECORATION = 0x5, -}; - /* 264 */ enum AIState : unsigned __int16 {
--- a/MM7.h Tue Mar 26 20:06:51 2013 +0200 +++ b/MM7.h Wed Mar 27 00:27:38 2013 +0200 @@ -22,6 +22,8 @@ #define BYTE3(a) (*((unsigned char *)&a + 3)) #define PID(type, id) (unsigned int)((((8 * (id))) | (type)) & 0xFFFF) // packed id +#define PID_TYPE(pid) (unsigned int)((pid) & 7) // extract type +#define PID_ID(pid) (unsigned int)(((pid) & 0xFFFF) >> 3) // extract value typedef unsigned __int16 _WORD;
--- a/Outdoor.cpp Tue Mar 26 20:06:51 2013 +0200 +++ b/Outdoor.cpp Wed Mar 27 00:27:38 2013 +0200 @@ -24,7 +24,7 @@ #include "Events.h" #include "mm7_data.h" -//#include "MM7.h" +#include "MM7.h" @@ -2949,8 +2949,8 @@ y = actor->vPosition.y; if (actor->uAIState == Summoned) { - if ((actor->uSummonerID & 7) != OBJECT_Actor || - pActors[actor->uSummonerID >> 3].pMonsterInfo.uSpecialAbilityDamageDiceSides != 1 ) + if (PID_TYPE(actor->uSummonerID) != OBJECT_Actor || + pActors[PID_ID(actor->uSummonerID)].pMonsterInfo.uSpecialAbilityDamageDiceSides != 1 ) { z += floorf(actor->uActorHeight * 0.5f + 0.5f); } @@ -3115,7 +3115,7 @@ HIWORD(v34) = HIWORD(X); LOWORD(v34) = 0; v28->dimming_level = 0; - v28->sZValue = v34 + (8 * i | OBJECT_Actor); + v28->sZValue = v34 + PID(OBJECT_Actor, i); v28->field_14_actor_id = i; v35 = pMonsterList->pMonsters; v36 = actor->pMonsterInfo.uID;
--- a/Party.cpp Tue Mar 26 20:06:51 2013 +0200 +++ b/Party.cpp Wed Mar 27 00:27:38 2013 +0200 @@ -15,6 +15,7 @@ #include "texts.h" #include "mm7_data.h" +#include "MM7.h" @@ -139,7 +140,7 @@ v12 = 0; if ( pParty->bTurnBasedModeOn == 1 ) { - if ( pTurnEngine->field_4 != 2 || (pTurnEngine->pQueue[0].uPackedID & 7) != OBJECT_Player) + if ( pTurnEngine->field_4 != 2 || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) != OBJECT_Player) return 0; v2 = pTurnEngine->pQueue[0].uPackedID >> 3; return v2 + 1;
--- a/Player.cpp Tue Mar 26 20:06:51 2013 +0200 +++ b/Player.cpp Wed Mar 27 00:27:38 2013 +0200 @@ -25,6 +25,7 @@ #include "texts.h" #include "mm7_data.h" +#include "MM7.h" @@ -582,7 +583,7 @@ int v9; // eax@10 //unsigned int pVoiceID; // ecx@10 int v11; // esi@10 - signed int v12; // eax@11 + //signed int v12; // eax@11 signed int v13; // esi@12 int v14; // eax@12 //int v15; // eax@17 @@ -629,8 +630,7 @@ if (int _v1 = byte_4ECF08[v11 - 1][uVoiceID]) { pSoundId = rand() % _v1 + 2 * (v11 + 50 * uVoiceID) + 4998; - v12 = (8 * pPlayerNum + 312) | OBJECT_Player; - pAudioPlayer->PlaySound((SoundID)pSoundId, v12, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0); + pAudioPlayer->PlaySound((SoundID)pSoundId, PID(OBJECT_Player, pPlayerNum + 39), 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0); } } } @@ -4549,7 +4549,7 @@ //----- (0048E96A) -------------------------------------------------------- void Player::SetRecoveryTime(signed int rec) { - assert(rec > 0); + assert(rec >= 0); if (rec > uTimeToRecovery) uTimeToRecovery = rec;
--- a/SpriteObject.cpp Tue Mar 26 20:06:51 2013 +0200 +++ b/SpriteObject.cpp Wed Mar 27 00:27:38 2013 +0200 @@ -14,7 +14,16 @@ #include "LOD.h" #include "Actor.h" #include "Events.h" + #include "mm7_data.h" +#include "MM7.h" + + + + + + + size_t uNumSpriteObjects; SpriteObject pSpriteObjects[MAX_SPRITE_OBJECTS]; @@ -408,11 +417,11 @@ v58 = v16; v18 = WorldPosToGridCellX(v17); _46E26D_collide_against_sprites(v18, v58); - if ( (v1->spell_caster_pid & 7) != OBJECT_Player) + if (PID_TYPE(v1->spell_caster_pid) != OBJECT_Player) _46EF01_collision_chech_player(0); - if ( (v1->spell_caster_pid & 7) == OBJECT_Actor) + if (PID_TYPE(v1->spell_caster_pid) == OBJECT_Actor) { - v19 = v1->spell_caster_pid >> 3; + v19 = PID_ID(v1->spell_caster_pid); if ( v19 >= 0 ) { if ( v19 < (signed int)(uNumActors - 1) ) @@ -514,10 +523,10 @@ if ( !_46BFFA_check_object_intercept(uLayingItemID_, stru_721530.uFaceID) ) return; } - v30 = (signed int)stru_721530.uFaceID >> 3; - if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) + v30 = (signed int)PID_ID(stru_721530.uFaceID); + if (PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) break; - if ( (stru_721530.uFaceID & 7) == OBJECT_BModel) + if (PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) { v31 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; v32 = &v31->pFaces[v30 & 0x3F]; @@ -698,11 +707,11 @@ { _46E44E_collide_against_faces_and_portals(0); _46E0B2_collide_against_decorations(); - if ( (pSpriteObject->spell_caster_pid & 7) != OBJECT_Player) + if (PID_TYPE(pSpriteObject->spell_caster_pid) != OBJECT_Player) _46EF01_collision_chech_player(1); v13 = pSpriteObject->spell_caster_pid; v42 = v8; - if ( (v13 & 7) == OBJECT_Actor) + if (PID_TYPE(v13) == OBJECT_Actor) { if ( (signed int)uNumActors > v8 ) { @@ -800,7 +809,7 @@ if ( pObject->uFlags & 0x40 && !_46BFFA_check_object_intercept(uLayingItemID, stru_721530.uFaceID) ) return; v15 = (signed int)stru_721530.uFaceID >> 3; - if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) + if (PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) { v40 = integer_sqrt(pSpriteObject->vVelocity.x * pSpriteObject->vVelocity.x + pSpriteObject->vVelocity.y * pSpriteObject->vVelocity.y); v23 = stru_5C6E00->Atan2(pSpriteObject->vPosition.x - pLevelDecorations[v15].vPosition.x, @@ -817,9 +826,9 @@ } else { - if ( (stru_721530.uFaceID & 7) != OBJECT_BModel) + if (PID_TYPE(stru_721530.uFaceID) != OBJECT_BModel) goto LABEL_64; - stru_721530.field_84 = (signed int)stru_721530.uFaceID >> 3; + stru_721530.field_84 = (signed int)PID_ID(stru_721530.uFaceID); v16 = &pIndoor->pFaces[v15]; if ( v16->uPolygonType != 3 ) {
--- a/UIPopup.cpp Tue Mar 26 20:06:51 2013 +0200 +++ b/UIPopup.cpp Wed Mar 27 00:27:38 2013 +0200 @@ -2120,9 +2120,9 @@ else v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; v6 = (unsigned __int16)v5; - if ( (v6 & 7) != OBJECT_Item) + if (PID_TYPE(v6) != OBJECT_Item) { - if ( (v6 & 7) == OBJECT_Actor) + if (PID_TYPE(v6) == OBJECT_Actor) { if ( pRenderer->uNumSceneBegins ) {
--- a/UiGame.cpp Tue Mar 26 20:06:51 2013 +0200 +++ b/UiGame.cpp Wed Mar 27 00:27:38 2013 +0200 @@ -585,8 +585,8 @@ v18 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; } pMouse->uPointingObjectID = (unsigned __int16)v18; - v19 = (signed int)(unsigned __int16)v18 >> 3; - if ( (v18 & 7) == OBJECT_Item ) + v19 = (signed)PID_ID(v18); + if (PID_TYPE(v18) == OBJECT_Item) { v30 = v19; if ( pObjectList->pObjects[pSpriteObjects[v30].uObjectDescID].uFlags & 0x10 ) @@ -630,9 +630,9 @@ } else { - if ( (v18 & 7) != OBJECT_Actor ) + if (PID_TYPE(v18) != OBJECT_Actor) { - if ( (v18 & 7) == OBJECT_Decoration ) + if (PID_TYPE(v18) == OBJECT_Decoration) { v23 = &pLevelDecorations[v19]; v24 = v23; @@ -686,7 +686,7 @@ uLastPointedObjectID = pMouse->uPointingObjectID; return; } - if ( (v18 & 7) == OBJECT_BModel) + if (PID_TYPE(v18) == OBJECT_BModel) { if ( v18 < (signed int)0x2000000u ) { @@ -1442,7 +1442,7 @@ { if ( pTurnEngine->field_4 != 1 ) { - if ( (pTurnEngine->pQueue[0].uPackedID & 7) == OBJECT_Player) + if (PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player) { //v14 = 0; if ( pTurnEngine->uActorQueueSize > 0 ) @@ -1452,7 +1452,7 @@ { auto pElem = pTurnEngine->pQueue + i; - if ( (pElem->uPackedID & 7) != OBJECT_Player) + if (PID_TYPE(pElem->uPackedID) != OBJECT_Player) break; v16 = dword_5079D0; if ( pParty->uFlags & 0x10 )
--- a/Vis.cpp Tue Mar 26 20:06:51 2013 +0200 +++ b/Vis.cpp Wed Mar 27 00:27:38 2013 +0200 @@ -9,7 +9,7 @@ #include "Log.h" #include "mm7_data.h" -//#include "MM7.h" +#include "MM7.h" static Vis_SelectionList Vis_static_sub_4C1944_stru_F8BDE8; @@ -377,7 +377,7 @@ { pGame->pIndoorCameraD3D->ViewTransform(&intersection, 1u); int v13 = _48B561_mess_with_scaling_along_z(/*v12, */intersection.vWorldViewPosition.x); - v13 += (8 * (j | (i << 6)) | OBJECT_BModel); + v13 += PID(OBJECT_BModel, j | (i << 6)); list->AddObject(face, VisObjectType_Face, v13); } @@ -1802,7 +1802,7 @@ int result; // eax@1 signed int pFaceID; // esi@2 BLVFace *pFace; // edi@4 - unsigned int v7; // eax@6 + //unsigned int v7; // eax@6 Vis_ObjectInfo *v8; // eax@6 signed int i; // [sp+18h] [bp-8h]@1 @@ -1819,9 +1819,7 @@ { if ( is_part_of_selection(pFace, filter) ) { - v7 = 8 * pFaceID; - LOBYTE(v7) = 8 * pFaceID | OBJECT_BModel; - v8 = _4C1026(pFace, v7, pick_depth); + v8 = _4C1026(pFace, PID(OBJECT_BModel, pFaceID), pick_depth); if ( v8 ) list->AddObject(v8->object, v8->object_type, v8->sZValue); } @@ -1853,7 +1851,7 @@ BLVFace blv_face; blv_face.FromODM(face); - int pid = 8 * (j | (i << 6)) | OBJECT_BModel; + int pid = PID(OBJECT_BModel, j | (i << 6)); if (auto object_info = _4C1026(&blv_face, pid, pick_depth)) list->AddObject(object_info->object, object_info->object_type, object_info->sZValue); }
--- a/mm7_3.cpp Tue Mar 26 20:06:51 2013 +0200 +++ b/mm7_3.cpp Wed Mar 27 00:27:38 2013 +0200 @@ -43,6 +43,8 @@ #include "stru298.h" #include "texts.h" #include "Log.h" + +#include "MM7.h" #include "mm7_data.h" //----- (0046E44E) -------------------------------------------------------- @@ -13603,7 +13605,7 @@ { v11 = uNumActors; SpawnEncounter((MapInfo *)&pMapStats->pInfos[v10], &v16, 0, count, 0); - memcpy(&v15, Actor::GetDirectionInfo(8 * v11 | AI_OBJECT_ACTOR, 4u, &a3, 1), sizeof(v15)); + memcpy(&v15, Actor::GetDirectionInfo(PID(OBJECT_Actor, v11), 4u, &a3, 1), sizeof(v15)); v12 = v11; if ( (signed int)v11 < (signed int)uNumActors ) { @@ -14931,834 +14933,834 @@ // 4F75D8: using guessed type int ai_arrays_size; //----- (00401A91) -------------------------------------------------------- -void __cdecl UpdateActorAI() -{ - //unsigned int v0; // esi@4 - int v1; // eax@7 - int v2; // ecx@7 - int v3; // eax@7 - signed int v4; // edi@10 - Actor *v5; // esi@12 - signed int v6; // eax@14 - __int16 v7; // cx@14 - Player **v8; // esi@20 - Player *pPlayer; // ecx@21 - //Actor *pActor; // esi@34 - //__int16 v11; // ax@34 - //unsigned int v12; // eax@47 - //signed int v13; // edi@47 - //SpellBuff *v14; // ebx@47 - //unsigned int v15; // edi@67 - //char *v16; // eax@67 - //unsigned int v17; // edx@67 - //unsigned int v18; // ecx@67 - //unsigned __int16 v19; // ax@72 - //int *v20; // esi@80 - Actor *v21; // ebx@80 - unsigned __int16 v22; // ax@86 - //signed int v23; // eax@94 - //unsigned int v24; // eax@102 - signed int v25; // edi@102 - SpellBuff *v26; // esi@102 - unsigned int v27; // ecx@123 - unsigned int v28; // eax@123 - unsigned int v29; // eax@127 - AIDirection *v30; // eax@129 - unsigned __int16 v31; // ax@132 - unsigned int v32; // esi@142 - int v33; // eax@144 - int v34; // eax@147 - char v35; // al@150 - unsigned int v36; // edi@152 - signed int v37; // eax@154 - unsigned __int8 v38; // sf@158 - unsigned __int8 v39; // of@158 - signed int v40; // edx@166 - unsigned int v41; // ecx@166 - double v42; // st7@176 - double v43; // st6@176 - bool v44; // eax@189 - bool v45; // eax@192 - unsigned __int8 v46; // cl@197 - double v47; // st7@206 - double v48; // st7@207 - char v49; // zf@208 - char v50; // zf@214 - signed int v51; // edx@219 - unsigned int v52; // ecx@219 - __int16 v53; // fps@224 - unsigned __int8 v54; // c0@224 - unsigned __int8 v55; // c3@224 - double v56; // st7@226 - AIDirection *v57; // eax@246 - double v58; // st7@246 - signed int v59; // [sp-18h] [bp-C8h]@213 - int v60; // [sp-14h] [bp-C4h]@144 - int v61; // [sp-14h] [bp-C4h]@168 - AIDirection *v62; // [sp-14h] [bp-C4h]@213 - signed int v63; // [sp-14h] [bp-C4h]@216 - unsigned int v64; // [sp-14h] [bp-C4h]@219 - unsigned int v65; // [sp-10h] [bp-C0h]@144 - char v66; // [sp-10h] [bp-C0h]@147 - AIDirection *v67; // [sp-10h] [bp-C0h]@167 - int v68; // [sp-10h] [bp-C0h]@168 - AIDirection *v69; // [sp-10h] [bp-C0h]@206 - int v70; // [sp-10h] [bp-C0h]@213 - AIDirection *v71; // [sp-10h] [bp-C0h]@216 - AIDirection v72; // [sp+0h] [bp-B0h]@246 - AIDirection a3; // [sp+1Ch] [bp-94h]@129 - AIDirection v74; // [sp+38h] [bp-78h]@246 - AIDirection v75; // [sp+54h] [bp-5Ch]@129 - int v76; // [sp+70h] [bp-40h]@83 - signed int a1; // [sp+74h] [bp-3Ch]@129 - int v78; // [sp+78h] [bp-38h]@79 - AIDirection pDir; // [sp+7Ch] [bp-34h]@129 - float v80; // [sp+98h] [bp-18h]@33 - int v81; // [sp+9Ch] [bp-14h]@100 - int v82; // [sp+A0h] [bp-10h]@45 - //unsigned int uActorID; // [sp+A4h] [bp-Ch]@32 - unsigned int v84; // [sp+A8h] [bp-8h]@11 - signed int a2; // [sp+ACh] [bp-4h]@83 - - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - MakeActorAIList_ODM(); - else - MakeActorAIList_BLV(); - - //v0 = 0; - if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->armageddon_timer > 0 ) - { - if ( pParty->armageddon_timer > 417 ) - { - pParty->armageddon_timer = 0; - } - else - { - pParty->sRotationY = (stru_5C6E00->uIntegerDoublePi - 1) & (pParty->sRotationY + rand() % 16 - 8); - v1 = rand(); - v2 = 128; - v3 = pParty->sRotationX + v1 % 16 - 8; - pParty->sRotationX = v3; - if ( v3 > 128 || (v2 = -128, v3 < -128) ) - pParty->sRotationX = v2; - pParty->uFlags |= 2u; - pParty->armageddon_timer -= pMiscTimer->uTimeElapsed; - v4 = pParty->field_16140 + 50; - if ( pParty->armageddon_timer <= 0 ) - { - pParty->armageddon_timer = 0; - v84 = 0; - if ( (signed int)uNumActors > 0 ) - { - v5 = pActors;//[0].sCurrentHP; - do - { - if ( v5->CanAct() ) - { - v6 = stru_50C198.CalcMagicalDamageToActor(v5, 5, v4); - v7 = v5->sCurrentHP - v6; - v5->sCurrentHP = v7; - if ( v6 ) - { - if ( v7 >= 0 ) - { - Actor::_4030AD(v84, 4, 0); - } - else - { - Actor::Die(v84); - if ( v5->pMonsterInfo.uExp ) - GivePartyExp(pMonsterStats->pInfos[v5->pMonsterInfo.uID].uExp); - } - } - } - ++v84; - ++v5; - } - while ( (signed int)v84 < (signed int)uNumActors ); - } - v8 = &pPlayers[1]; - do - { - pPlayer = *v8; - if ( !(*v8)->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] ) - pPlayer->ReceiveDamage(v4, 5); - ++v8; - } - while ( (signed int)v8 <= (signed int)&pPlayers[4] ); - //v0 = 0; - } - if (pTurnEngine->field_1C) - --pTurnEngine->field_1C; - } - } - - if (pParty->bTurnBasedModeOn) - { - pTurnEngine->_405E14(); - return; - } - - - //uActorID = v0; - for (uint i = 0; i < uNumActors; ++i) - { - auto actor = pActors + i; - //LODWORD(v80) = (int)(char *)pActors + 176; // uAIState - //do - //{ - //pActor = (Actor *)(LODWORD(v80) - 176); - //v11 = *(unsigned int *)LODWORD(v80); - //v49 = *(unsigned int *)LODWORD(v80) == 5; - ai_near_actors_targets_pid[i] = OBJECT_Player; - if (actor->uAIState == Dead || actor->uAIState == Removed || actor->uAIState == Disabled || actor->uAttributes & 0x0400) - continue; - - if (!actor->sCurrentHP && actor->uAIState != Dying) - Actor::Die(i); - - //v84 = *(_QWORD *)(LODWORD(v80) + 84) <= 0i64 ? 0 : 1; - //v82 = *(_QWORD *)(LODWORD(v80) + 52) <= 0i64 ? 0 : 1; - //v12 = 0; - //v13 = 0; - //v14 = (SpellBuff *)(LODWORD(v80) + 36); - for (uint j = 0; j < 22; ++j) - { - if (j != 10) - actor->pActorBuffs[j]._4585CA(pParty->uTimePlayed); - } - /*do - { - if ( v13 != 10 ) - { - v14->_4585CA(pParty->uTimePlayed); - v12 = 0; - } - ++v13; - ++v14; - } - while ( v13 < 22 );*/ - if (!actor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime) - //&& SHIDWORD(pActor->pActorBuffs[3].uExpireTime) <= (signed int)v12 && (SHIDWORD(pActor->pActorBuffs[3].uExpireTime) < (signed int)v12 - // || LODWORD(pActor->pActorBuffs[3].uExpireTime) <= v12) ) - actor->uActorHeight = pMonsterList->pMonsters[actor->pMonsterInfo.uID - 1].uMonsterHeight; - if (actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime) - actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - else - actor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[actor->pMonsterInfo.uID].uHostilityType; - - if (actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime || - actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) - continue; - - //v15 = pMiscTimer->uTimeElapsed; - //v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime; - //v17 = pActor->uCurrentActionTime; - //v18 = pActor->pMonsterInfo.uRecoveryTime; - if (actor->pMonsterInfo.uRecoveryTime) - { - if (actor->pMonsterInfo.uRecoveryTime < pMiscTimer->uTimeElapsed) - actor->pMonsterInfo.uRecoveryTime = 0; - else actor->pMonsterInfo.uRecoveryTime -= pMiscTimer->uTimeElapsed; - } - - actor->uCurrentActionTime += pMiscTimer->uTimeElapsed; - if (actor->uCurrentActionTime < actor->uCurrentActionLength) - continue; - - //v19 = actor->uAIState; - if (actor->uAIState == Dying) - actor->uAIState = Dead; - else - { - if (actor->uAIState != Summoned) - { - Actor::AI_StandOrBored(i, OBJECT_Player, 256, nullptr); - continue; - } - actor->uAIState = Standing; - } - - actor->uCurrentActionTime = 0; - actor->uCurrentActionLength = 0; - actor->UpdateAnimation(); - //LABEL_78: - //++uActorID; - //LODWORD(v80) += 836; - //} - //while ( (signed int)uActorID < (signed int)uNumActors ); - } - - - v78 = 0; - int actor_id = -1; - if ( ai_arrays_size > 0 ) - { - //while ( 1 ) - for(v78 = 0; v78 < ai_arrays_size; ++v78) - { - actor_id = ai_near_actors_ids[v78]; - assert(actor_id < uNumActors); - - //v20 = &ai_near_actors_targets_pid[actor_id]; - v21 = &pActors[actor_id]; - Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); - if (v21->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id]) - v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - a2 = ai_near_actors_targets_pid[actor_id]; - v76 = a2 & 7; - if ( (a2 & 7) == OBJECT_Actor) - v80 = 0.5; - else - v80 = 1.0; - v22 = v21->uAIState; - if ( v22 == Dying || v22 == Dead || v22 == Removed || v22 == Disabled || v22 == Summoned) - { - continue; - } - else - { - if ( !v21->sCurrentHP ) - Actor::Die(actor_id); - v25 = 0; - v26 = v21->pActorBuffs; - do - { - if ( v25 != 10 ) - { - v26->_4585CA(pParty->uTimePlayed); - //v24 = 0; - } - ++v25; - ++v26; - } - while ( v25 < 22 ); - if ( (signed __int64)v21->pActorBuffs[3].uExpireTime > 0 - && SHIDWORD(v21->pActorBuffs[3].uExpireTime) <= 0 - && (SHIDWORD(v21->pActorBuffs[3].uExpireTime) < 0 - || LODWORD(v21->pActorBuffs[3].uExpireTime) <= 0) ) - v21->uActorHeight = pMonsterList->pMonsters[v21->pMonsterInfo.uID - 1].uMonsterHeight; - if ( (signed __int64)v21->pActorBuffs[1].uExpireTime > 0 ) - { - v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) <= 0 ) - { - if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) < 0 - || LODWORD(v21->pActorBuffs[1].uExpireTime) <= 0 ) - v21->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[v21->pMonsterInfo.uID].uHostilityType; - } - } - if ( (signed __int64)v21->pActorBuffs[2].uExpireTime > 0 - && SHIDWORD(v21->pActorBuffs[2].uExpireTime) <= 0 - && (SHIDWORD(v21->pActorBuffs[2].uExpireTime) < 0 - || LODWORD(v21->pActorBuffs[2].uExpireTime) <= 0) ) - { - v21->uAIState = Removed; - continue; - } - else if ( v21->pActorBuffs[5].uExpireTime || v21->pActorBuffs[6].uExpireTime ) - { - continue; - } - else - { - v27 = pMiscTimer->uTimeElapsed; - v28 = v21->pMonsterInfo.uRecoveryTime; - v21->uCurrentActionTime += pMiscTimer->uTimeElapsed; - if ( (signed int)v28 > 0 ) - v21->pMonsterInfo.uRecoveryTime = v28 - v27; - if ( v21->pMonsterInfo.uRecoveryTime< 0 ) - v21->pMonsterInfo.uRecoveryTime = 0; - v29 = v21->uAttributes; - if ( !(v29 & 0x8000) ) - v21->uAttributes = v29 | 0x8000; - a1 = 8 * actor_id | OBJECT_Actor; - v30 = Actor::GetDirectionInfo(8 * actor_id | OBJECT_Actor, a2, &a3, 0); - v49 = v21->pMonsterInfo.uHostilityType == 0; - memcpy(&v75, v30, sizeof(v75)); - memcpy(&pDir, &v75, sizeof(pDir)); - if ( !v49 - && (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 - && v80 * 307.2 >= (double)(signed int)v75.uDistance - && ((v31 = v21->uAIState, v31 == 6) || !v31 || v31 == 1 || v31 == 9) - || v21->pMonsterInfo.uMissleAttack1Type && v21->uAIState == 8 ) - { - v32 = actor_id; - } - else - { - if ( (signed int)v21->uCurrentActionTime < v21->uCurrentActionLength ) - { - continue; - } - else if ( v21->uAIState == 2 ) - { - v32 = actor_id; - v35 = stru_50C198.special_ability_use_check(v21, actor_id); - stru_50FE08.Add( - a1, - 5120, - v21->vPosition.x, - v21->vPosition.y, - v21->vPosition.z + ((signed int)v21->uActorHeight >> 1), - v35, - 1 - ); - } - else if ( v21->uAIState == 3 ) - { - v34 = v21->pMonsterInfo.uMissleAttack1Type; - v66 = 0; - v32 = actor_id; - Actor::_404874(actor_id, &pDir, v34, v66); - } - else if ( v21->uAIState == 12 ) - { - v34 = v21->pMonsterInfo.uMissleAttack2Type; - v66 = 1; - v32 = actor_id; - Actor::_404874(actor_id, &pDir, v34, v66); - } - else - { - v32 = actor_id; - if ( v21->uAIState == 13 ) - { - v65 = v21->pMonsterInfo.uSpellSkillAndMastery1; - v60 = 2; - v33 = v21->pMonsterInfo.uSpell1ID; - Actor::_404AC7(actor_id, &pDir, v33, v60, v65); - } - else if ( v21->uAIState == 18 ) - { - v65 = v21->pMonsterInfo.uSpellSkillAndMastery2; - v60 = 3; - v33 = v21->pMonsterInfo.uSpell2ID; - Actor::_404AC7(actor_id, &pDir, v33, v60, v65); - } - } - } - } - } - v36 = v75.uDistance; - if ( !v21->pMonsterInfo.uHostilityType ) - { - if ( v76 == 3 ) - { - v36 = v75.uDistance; - v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (v21->pMonsterInfo.uID - 1) / 3] - + (pActors[a2 >> 3].pMonsterInfo.uID - 1) / 3); - } - else - { - v37 = 4; - } - if ( v37 == 2 ) - { - v39 = __OFSUB__(v36, 1024); - v38 = ((v36 - 1024) & 0x80000000u) != 0; - } - else if ( v37 == 3 ) - { - v39 = __OFSUB__(v36, 2560); - v38 = ((v36 - 2560) & 0x80000000u) != 0; - } - else if ( v37 == 4 ) - { - v39 = __OFSUB__(v36, 5120); - v38 = ((v36 - 5120) & 0x80000000u) != 0; - } - if ( v37 >= 1 && v37 <= 4 && v38 ^ v39 || v37 == 1 ) - v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - } - if ( (signed __int64)v21->pActorBuffs[4].uExpireTime > 0 ) - { - v40 = a2; - v41 = v32; - if ( (signed int)v36 >= 10240 ) - { - v68 = 0; - v61 = 1024; - Actor::_4032B2(v41, v40, v61, v68); - continue; - } - v67 = &pDir; - Actor::_402968(v41, v40, 0, v67); - continue; - } - if ( v21->pMonsterInfo.uHostilityType == 4 && a2 ) - { - if ( !(v21->uAttributes & 0x020000) || v21->pMonsterInfo.uAIType == 1 ) - { - if ( v21->pMonsterInfo.uAIType == 1 ) - { - v67 = &pDir; - if ( v21->pMonsterInfo.uMovementType != 5 ) - { - v40 = a2; - v41 = v32; - Actor::_402968(v41, v40, 0, v67); - continue; - } - Actor::AI_Stand( - v32, - a2, - (signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333), - &pDir); - } - else - { - if ( v21->pMonsterInfo.uAIType == 2 ) - { - v84 = v21->sCurrentHP; - v42 = (double)(signed int)v84; - v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.2; - } - else - { - v84 = v21->sCurrentHP; - v42 = (double)(signed int)v84; - v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.1; - } - if ( v21->pMonsterInfo.uAIType == 2 || v21->pMonsterInfo.uAIType == 3 ) - if ( v43 > v42 && (signed int)v36 < 10240 ) - { - v67 = &pDir; - v40 = a2; - v41 = v32; - Actor::_402968(v41, v40, 0, v67); - continue; - } - } - } - v81 = v36 - v21->uActorRadius; - if ( v76 == 3 ) - v81 -= pActors[a2 >> 3].uActorRadius; - if ( v81 < 0 ) - v81 = 0; - rand(); - v44 = (signed int)v21->pMonsterInfo.uRecoveryTime <= 0; - v21->uAttributes &= 0xFBFFFF; - v82 = 0; - v49 = v21->pMonsterInfo.uMovementType == 5; - v84 = v44; - if ( v49 ) - v82 = 1; - if ( v81 < 5120 ) - { - v45 = stru_50C198.special_ability_use_check(v21, v32); - if ( !v45 ) - { - if ( v21->pMonsterInfo.uMissleAttack1Type ) - { - if ( v84 ) - { - Actor::_403476(v32, a2, &pDir); - continue; - - } - if ( v82 ) - { - v69 = &pDir; - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - //UNDEF(v53); - v69 = &pDir; - if ( !(v54 | v55) ) - { - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69); - continue; - } - v56 = v80 * 307.2; - if ( (double)v81 >= v56 ) - { - if ( v81 >= 1024 ) - { - if ( v82 ) - { - v69 = &pDir; - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - v71 = &pDir; - v63 = 0; - - Actor::_402686(v32, a2, v63, v71); - continue; - } - if ( v82 ) - { - v69 = &pDir; - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - v70 = (signed __int64)v56; - v62 = &pDir; - v59 = 0; - Actor::_40281C(v32, a2, v59, v62, v70); - continue; - } - v49 = v84 == 0; - v69 = &pDir; - if ( v49 ) - { - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - Actor::_403C6C(v32, a2, &pDir); - continue; - } - if ( v45 != 1 ) - { - if ( v45 > 1 && v45 <= 3 ) - { - if ( v45 == 2 ) - v46 = v21->pMonsterInfo.uSpell1ID; - else - v46 = v21->pMonsterInfo.uSpell2ID; - if ( v46 ) - { - if ( v84 ) - { - if ( v45 == 2 ) - Actor::_403854(v32, a2, &pDir); - else - Actor::_403A60(v32, a2, &pDir); - continue; - } - if ( v80 * 307.2 > (double)v81 || v82 ) - { - v69 = &pDir; - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - - } - v69 = &pDir; - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69); - continue; - } - v48 = v80 * 307.2; - if ( (double)v81 >= v48 ) - { - if ( v81 >= 1024 ) - { - v50 = v82 == 0; - if ( !v50 ) - { - v69 = &pDir; - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - v71 = &pDir; - v63 = 256; - Actor::_402686(v32, a2, v63, v71); - continue; - - } - if ( v82 ) - { - v69 = &pDir; - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - v70 = (signed __int64)v48; - v62 = &pDir; - v59 = 0; - Actor::_40281C(v32, a2, v59, v62, v70); - continue; - } - v49 = v84 == 0; - v69 = &pDir; - if ( v49 ) - { - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - Actor::_403C6C(v32, a2, &pDir); - continue; - } - } - } - } - if ( v21->pMonsterInfo.uHostilityType != 4 || !a2 || v81 >= 5120 || v45 != 1 ) - { - if ( !v21->pMonsterInfo.uMovementType ) - { - v68 = 0; - v61 = 1024; - v41 = v32; - v40 = 4; - Actor::_4032B2(v41, v40, v61, v68); - continue; - - } - if ( v21->pMonsterInfo.uMovementType == 1 ) - { - v68 = 0; - v61 = 2560; - v41 = v32; - v40 = 4; - Actor::_4032B2(v41, v40, v61, v68); - continue; - } - if ( v21->pMonsterInfo.uMovementType == 2 ) - { - v68 = 0; - v61 = 5120; - v41 = v32; - v40 = 4; - Actor::_4032B2(v41, v40, v61, v68); - continue; - } - if ( v21->pMonsterInfo.uMovementType == 4 ) - { - v68 = 0; - v61 = 10240; - v41 = v32; - v40 = 4; - Actor::_4032B2(v41, v40, v61, v68); - continue; - } - if ( v21->pMonsterInfo.uMovementType == 5 ) - { - v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0); - v58 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - memcpy(&v74, v57, sizeof(v74)); - memcpy(&pDir, &v74, sizeof(pDir)); - v69 = &pDir; - v52 = actor_id; - v64 = (signed __int64)v58; - v51 = 4; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - continue; - - } - if ( !v21->pMonsterInfo.uMissleAttack2Type ) - { - v56 = v80 * 307.2; - if ( (double)v81 >= v56 ) - { - if ( v81 >= 1024 ) - { - v50 = v82 == 0; - if ( !v50 ) - { - v69 = &pDir; - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - v71 = &pDir; - v63 = 256; - Actor::_402686(v32, a2, v63, v71); - continue; - } - if ( v82 ) - { - v69 = &pDir; - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - v70 = (signed __int64)v56; - v62 = &pDir; - v59 = 0; - Actor::_40281C(v32, a2, v59, v62, v70); - continue; - - } - v49 = v84 == 0; - v69 = &pDir; - if ( v49 ) - { - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - Actor::_403C6C(v32, a2, &pDir); - continue; - } - if ( !v84 ) - { - if ( v82 ) - { - v69 = &pDir; - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - //UNDEF(v53); - v69 = &pDir; - if ( !(v54 | v55) ) - { - v51 = a2; - v64 = (signed __int64)v47; - v52 = v32; - Actor::AI_Stand(v52, v51, v64, v69); - continue; - } - Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69); - continue; - } - Actor::_40368B(v32, a2, &pDir); - } - } +void __cdecl UpdateActorAI() +{ + //unsigned int v0; // esi@4 + int v1; // eax@7 + int v2; // ecx@7 + int v3; // eax@7 + signed int v4; // edi@10 + Actor *v5; // esi@12 + signed int v6; // eax@14 + __int16 v7; // cx@14 + Player **v8; // esi@20 + Player *pPlayer; // ecx@21 + //Actor *pActor; // esi@34 + //__int16 v11; // ax@34 + //unsigned int v12; // eax@47 + //signed int v13; // edi@47 + //SpellBuff *v14; // ebx@47 + //unsigned int v15; // edi@67 + //char *v16; // eax@67 + //unsigned int v17; // edx@67 + //unsigned int v18; // ecx@67 + //unsigned __int16 v19; // ax@72 + //int *v20; // esi@80 + Actor *v21; // ebx@80 + unsigned __int16 v22; // ax@86 + //signed int v23; // eax@94 + //unsigned int v24; // eax@102 + signed int v25; // edi@102 + SpellBuff *v26; // esi@102 + unsigned int v27; // ecx@123 + unsigned int v28; // eax@123 + unsigned int v29; // eax@127 + AIDirection *v30; // eax@129 + unsigned __int16 v31; // ax@132 + unsigned int v32; // esi@142 + int v33; // eax@144 + int v34; // eax@147 + char v35; // al@150 + unsigned int v36; // edi@152 + signed int v37; // eax@154 + unsigned __int8 v38; // sf@158 + unsigned __int8 v39; // of@158 + signed int v40; // edx@166 + unsigned int v41; // ecx@166 + double v42; // st7@176 + double v43; // st6@176 + bool v44; // eax@189 + bool v45; // eax@192 + unsigned __int8 v46; // cl@197 + double v47; // st7@206 + double v48; // st7@207 + char v49; // zf@208 + char v50; // zf@214 + signed int v51; // edx@219 + unsigned int v52; // ecx@219 + __int16 v53; // fps@224 + unsigned __int8 v54; // c0@224 + unsigned __int8 v55; // c3@224 + double v56; // st7@226 + AIDirection *v57; // eax@246 + double v58; // st7@246 + signed int v59; // [sp-18h] [bp-C8h]@213 + int v60; // [sp-14h] [bp-C4h]@144 + int v61; // [sp-14h] [bp-C4h]@168 + AIDirection *v62; // [sp-14h] [bp-C4h]@213 + signed int v63; // [sp-14h] [bp-C4h]@216 + unsigned int v64; // [sp-14h] [bp-C4h]@219 + unsigned int v65; // [sp-10h] [bp-C0h]@144 + char v66; // [sp-10h] [bp-C0h]@147 + AIDirection *v67; // [sp-10h] [bp-C0h]@167 + int v68; // [sp-10h] [bp-C0h]@168 + AIDirection *v69; // [sp-10h] [bp-C0h]@206 + int v70; // [sp-10h] [bp-C0h]@213 + AIDirection *v71; // [sp-10h] [bp-C0h]@216 + AIDirection v72; // [sp+0h] [bp-B0h]@246 + AIDirection a3; // [sp+1Ch] [bp-94h]@129 + AIDirection v74; // [sp+38h] [bp-78h]@246 + AIDirection v75; // [sp+54h] [bp-5Ch]@129 + int v76; // [sp+70h] [bp-40h]@83 + signed int a1; // [sp+74h] [bp-3Ch]@129 + int v78; // [sp+78h] [bp-38h]@79 + AIDirection pDir; // [sp+7Ch] [bp-34h]@129 + float v80; // [sp+98h] [bp-18h]@33 + int v81; // [sp+9Ch] [bp-14h]@100 + int v82; // [sp+A0h] [bp-10h]@45 + //unsigned int uActorID; // [sp+A4h] [bp-Ch]@32 + unsigned int v84; // [sp+A8h] [bp-8h]@11 + signed int a2; // [sp+ACh] [bp-4h]@83 + + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + MakeActorAIList_ODM(); + else + MakeActorAIList_BLV(); + + //v0 = 0; + if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->armageddon_timer > 0 ) + { + if ( pParty->armageddon_timer > 417 ) + { + pParty->armageddon_timer = 0; + } + else + { + pParty->sRotationY = (stru_5C6E00->uIntegerDoublePi - 1) & (pParty->sRotationY + rand() % 16 - 8); + v1 = rand(); + v2 = 128; + v3 = pParty->sRotationX + v1 % 16 - 8; + pParty->sRotationX = v3; + if ( v3 > 128 || (v2 = -128, v3 < -128) ) + pParty->sRotationX = v2; + pParty->uFlags |= 2u; + pParty->armageddon_timer -= pMiscTimer->uTimeElapsed; + v4 = pParty->field_16140 + 50; + if ( pParty->armageddon_timer <= 0 ) + { + pParty->armageddon_timer = 0; + v84 = 0; + if ( (signed int)uNumActors > 0 ) + { + v5 = pActors;//[0].sCurrentHP; + do + { + if ( v5->CanAct() ) + { + v6 = stru_50C198.CalcMagicalDamageToActor(v5, 5, v4); + v7 = v5->sCurrentHP - v6; + v5->sCurrentHP = v7; + if ( v6 ) + { + if ( v7 >= 0 ) + { + Actor::_4030AD(v84, 4, 0); + } + else + { + Actor::Die(v84); + if ( v5->pMonsterInfo.uExp ) + GivePartyExp(pMonsterStats->pInfos[v5->pMonsterInfo.uID].uExp); + } + } + } + ++v84; + ++v5; + } + while ( (signed int)v84 < (signed int)uNumActors ); + } + v8 = &pPlayers[1]; + do + { + pPlayer = *v8; + if ( !(*v8)->pConditions[14] && !pPlayer->pConditions[15] && !pPlayer->pConditions[16] ) + pPlayer->ReceiveDamage(v4, 5); + ++v8; + } + while ( (signed int)v8 <= (signed int)&pPlayers[4] ); + //v0 = 0; + } + if (pTurnEngine->field_1C) + --pTurnEngine->field_1C; + } + } + + if (pParty->bTurnBasedModeOn) + { + pTurnEngine->_405E14(); + return; + } + + + //uActorID = v0; + for (uint i = 0; i < uNumActors; ++i) + { + auto actor = pActors + i; + //LODWORD(v80) = (int)(char *)pActors + 176; // uAIState + //do + //{ + //pActor = (Actor *)(LODWORD(v80) - 176); + //v11 = *(unsigned int *)LODWORD(v80); + //v49 = *(unsigned int *)LODWORD(v80) == 5; + ai_near_actors_targets_pid[i] = OBJECT_Player; + if (actor->uAIState == Dead || actor->uAIState == Removed || actor->uAIState == Disabled || actor->uAttributes & 0x0400) + continue; + + if (!actor->sCurrentHP && actor->uAIState != Dying) + Actor::Die(i); + + //v84 = *(_QWORD *)(LODWORD(v80) + 84) <= 0i64 ? 0 : 1; + //v82 = *(_QWORD *)(LODWORD(v80) + 52) <= 0i64 ? 0 : 1; + //v12 = 0; + //v13 = 0; + //v14 = (SpellBuff *)(LODWORD(v80) + 36); + for (uint j = 0; j < 22; ++j) + { + if (j != 10) + actor->pActorBuffs[j]._4585CA(pParty->uTimePlayed); + } + /*do + { + if ( v13 != 10 ) + { + v14->_4585CA(pParty->uTimePlayed); + v12 = 0; + } + ++v13; + ++v14; + } + while ( v13 < 22 );*/ + if (!actor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime) + //&& SHIDWORD(pActor->pActorBuffs[3].uExpireTime) <= (signed int)v12 && (SHIDWORD(pActor->pActorBuffs[3].uExpireTime) < (signed int)v12 + // || LODWORD(pActor->pActorBuffs[3].uExpireTime) <= v12) ) + actor->uActorHeight = pMonsterList->pMonsters[actor->pMonsterInfo.uID - 1].uMonsterHeight; + if (actor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime) + actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + else + actor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[actor->pMonsterInfo.uID].uHostilityType; + + if (actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime || + actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) + continue; + + //v15 = pMiscTimer->uTimeElapsed; + //v16 = (char *)&pActor->pMonsterInfo.uRecoveryTime; + //v17 = pActor->uCurrentActionTime; + //v18 = pActor->pMonsterInfo.uRecoveryTime; + if (actor->pMonsterInfo.uRecoveryTime) + { + if (actor->pMonsterInfo.uRecoveryTime < pMiscTimer->uTimeElapsed) + actor->pMonsterInfo.uRecoveryTime = 0; + else actor->pMonsterInfo.uRecoveryTime -= pMiscTimer->uTimeElapsed; + } + + actor->uCurrentActionTime += pMiscTimer->uTimeElapsed; + if (actor->uCurrentActionTime < actor->uCurrentActionLength) + continue; + + //v19 = actor->uAIState; + if (actor->uAIState == Dying) + actor->uAIState = Dead; + else + { + if (actor->uAIState != Summoned) + { + Actor::AI_StandOrBored(i, OBJECT_Player, 256, nullptr); + continue; + } + actor->uAIState = Standing; + } + + actor->uCurrentActionTime = 0; + actor->uCurrentActionLength = 0; + actor->UpdateAnimation(); + //LABEL_78: + //++uActorID; + //LODWORD(v80) += 836; + //} + //while ( (signed int)uActorID < (signed int)uNumActors ); + } + + + v78 = 0; + int actor_id = -1; + if ( ai_arrays_size > 0 ) + { + //while ( 1 ) + for(v78 = 0; v78 < ai_arrays_size; ++v78) + { + actor_id = ai_near_actors_ids[v78]; + assert(actor_id < uNumActors); + + //v20 = &ai_near_actors_targets_pid[actor_id]; + v21 = &pActors[actor_id]; + Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); + if (v21->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id]) + v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + a2 = ai_near_actors_targets_pid[actor_id]; + v76 = a2 & 7; + if ( (a2 & 7) == OBJECT_Actor) + v80 = 0.5; + else + v80 = 1.0; + v22 = v21->uAIState; + if ( v22 == Dying || v22 == Dead || v22 == Removed || v22 == Disabled || v22 == Summoned) + { + continue; + } + else + { + if ( !v21->sCurrentHP ) + Actor::Die(actor_id); + v25 = 0; + v26 = v21->pActorBuffs; + do + { + if ( v25 != 10 ) + { + v26->_4585CA(pParty->uTimePlayed); + //v24 = 0; + } + ++v25; + ++v26; + } + while ( v25 < 22 ); + if ( (signed __int64)v21->pActorBuffs[3].uExpireTime > 0 + && SHIDWORD(v21->pActorBuffs[3].uExpireTime) <= 0 + && (SHIDWORD(v21->pActorBuffs[3].uExpireTime) < 0 + || LODWORD(v21->pActorBuffs[3].uExpireTime) <= 0) ) + v21->uActorHeight = pMonsterList->pMonsters[v21->pMonsterInfo.uID - 1].uMonsterHeight; + if ( (signed __int64)v21->pActorBuffs[1].uExpireTime > 0 ) + { + v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) <= 0 ) + { + if ( SHIDWORD(v21->pActorBuffs[1].uExpireTime) < 0 + || LODWORD(v21->pActorBuffs[1].uExpireTime) <= 0 ) + v21->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[v21->pMonsterInfo.uID].uHostilityType; + } + } + if ( (signed __int64)v21->pActorBuffs[2].uExpireTime > 0 + && SHIDWORD(v21->pActorBuffs[2].uExpireTime) <= 0 + && (SHIDWORD(v21->pActorBuffs[2].uExpireTime) < 0 + || LODWORD(v21->pActorBuffs[2].uExpireTime) <= 0) ) + { + v21->uAIState = Removed; + continue; + } + else if ( v21->pActorBuffs[5].uExpireTime || v21->pActorBuffs[6].uExpireTime ) + { + continue; + } + else + { + v27 = pMiscTimer->uTimeElapsed; + v28 = v21->pMonsterInfo.uRecoveryTime; + v21->uCurrentActionTime += pMiscTimer->uTimeElapsed; + if ( (signed int)v28 > 0 ) + v21->pMonsterInfo.uRecoveryTime = v28 - v27; + if ( v21->pMonsterInfo.uRecoveryTime< 0 ) + v21->pMonsterInfo.uRecoveryTime = 0; + v29 = v21->uAttributes; + if ( !(v29 & 0x8000) ) + v21->uAttributes = v29 | 0x8000; + a1 = 8 * actor_id | OBJECT_Actor; + v30 = Actor::GetDirectionInfo(8 * actor_id | OBJECT_Actor, a2, &a3, 0); + v49 = v21->pMonsterInfo.uHostilityType == 0; + memcpy(&v75, v30, sizeof(v75)); + memcpy(&pDir, &v75, sizeof(pDir)); + if ( !v49 + && (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 + && v80 * 307.2 >= (double)(signed int)v75.uDistance + && ((v31 = v21->uAIState, v31 == 6) || !v31 || v31 == 1 || v31 == 9) + || v21->pMonsterInfo.uMissleAttack1Type && v21->uAIState == 8 ) + { + v32 = actor_id; + } + else + { + if ( (signed int)v21->uCurrentActionTime < v21->uCurrentActionLength ) + { + continue; + } + else if ( v21->uAIState == 2 ) + { + v32 = actor_id; + v35 = stru_50C198.special_ability_use_check(v21, actor_id); + stru_50FE08.Add( + a1, + 5120, + v21->vPosition.x, + v21->vPosition.y, + v21->vPosition.z + ((signed int)v21->uActorHeight >> 1), + v35, + 1 + ); + } + else if ( v21->uAIState == 3 ) + { + v34 = v21->pMonsterInfo.uMissleAttack1Type; + v66 = 0; + v32 = actor_id; + Actor::_404874(actor_id, &pDir, v34, v66); + } + else if ( v21->uAIState == 12 ) + { + v34 = v21->pMonsterInfo.uMissleAttack2Type; + v66 = 1; + v32 = actor_id; + Actor::_404874(actor_id, &pDir, v34, v66); + } + else + { + v32 = actor_id; + if ( v21->uAIState == 13 ) + { + v65 = v21->pMonsterInfo.uSpellSkillAndMastery1; + v60 = 2; + v33 = v21->pMonsterInfo.uSpell1ID; + Actor::_404AC7(actor_id, &pDir, v33, v60, v65); + } + else if ( v21->uAIState == 18 ) + { + v65 = v21->pMonsterInfo.uSpellSkillAndMastery2; + v60 = 3; + v33 = v21->pMonsterInfo.uSpell2ID; + Actor::_404AC7(actor_id, &pDir, v33, v60, v65); + } + } + } + } + } + v36 = v75.uDistance; + if ( !v21->pMonsterInfo.uHostilityType ) + { + if ( v76 == 3 ) + { + v36 = v75.uDistance; + v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (v21->pMonsterInfo.uID - 1) / 3] + + (pActors[a2 >> 3].pMonsterInfo.uID - 1) / 3); + } + else + { + v37 = 4; + } + if ( v37 == 2 ) + { + v39 = __OFSUB__(v36, 1024); + v38 = ((v36 - 1024) & 0x80000000u) != 0; + } + else if ( v37 == 3 ) + { + v39 = __OFSUB__(v36, 2560); + v38 = ((v36 - 2560) & 0x80000000u) != 0; + } + else if ( v37 == 4 ) + { + v39 = __OFSUB__(v36, 5120); + v38 = ((v36 - 5120) & 0x80000000u) != 0; + } + if ( v37 >= 1 && v37 <= 4 && v38 ^ v39 || v37 == 1 ) + v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + } + if ( (signed __int64)v21->pActorBuffs[4].uExpireTime > 0 ) + { + v40 = a2; + v41 = v32; + if ( (signed int)v36 >= 10240 ) + { + v68 = 0; + v61 = 1024; + Actor::_4032B2(v41, v40, v61, v68); + continue; + } + v67 = &pDir; + Actor::_402968(v41, v40, 0, v67); + continue; + } + if ( v21->pMonsterInfo.uHostilityType == 4 && a2 ) + { + if ( !(v21->uAttributes & 0x020000) || v21->pMonsterInfo.uAIType == 1 ) + { + if ( v21->pMonsterInfo.uAIType == 1 ) + { + v67 = &pDir; + if ( v21->pMonsterInfo.uMovementType != 5 ) + { + v40 = a2; + v41 = v32; + Actor::_402968(v41, v40, 0, v67); + continue; + } + Actor::AI_Stand( + v32, + a2, + (signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333), + &pDir); + } + else + { + if ( v21->pMonsterInfo.uAIType == 2 ) + { + v84 = v21->sCurrentHP; + v42 = (double)(signed int)v84; + v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.2; + } + else + { + v84 = v21->sCurrentHP; + v42 = (double)(signed int)v84; + v43 = (double)(signed int)v21->pMonsterInfo.uHP * 0.1; + } + if ( v21->pMonsterInfo.uAIType == 2 || v21->pMonsterInfo.uAIType == 3 ) + if ( v43 > v42 && (signed int)v36 < 10240 ) + { + v67 = &pDir; + v40 = a2; + v41 = v32; + Actor::_402968(v41, v40, 0, v67); + continue; + } + } + } + v81 = v36 - v21->uActorRadius; + if ( v76 == 3 ) + v81 -= pActors[a2 >> 3].uActorRadius; + if ( v81 < 0 ) + v81 = 0; + rand(); + v44 = (signed int)v21->pMonsterInfo.uRecoveryTime <= 0; + v21->uAttributes &= 0xFBFFFF; + v82 = 0; + v49 = v21->pMonsterInfo.uMovementType == 5; + v84 = v44; + if ( v49 ) + v82 = 1; + if ( v81 < 5120 ) + { + v45 = stru_50C198.special_ability_use_check(v21, v32); + if ( !v45 ) + { + if ( v21->pMonsterInfo.uMissleAttack1Type ) + { + if ( v84 ) + { + Actor::_403476(v32, a2, &pDir); + continue; + + } + if ( v82 ) + { + v69 = &pDir; + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + v51 = a2; + v64 = (signed __int64)v47; + v52 = v32; + Actor::AI_Stand(v52, v51, v64, v69); + continue; + } + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + //UNDEF(v53); + v69 = &pDir; + if ( !(v54 | v55) ) + { + v51 = a2; + v64 = (signed __int64)v47; + v52 = v32; + Actor::AI_Stand(v52, v51, v64, v69); + continue; + } + Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69); + continue; + } + v56 = v80 * 307.2; + if ( (double)v81 >= v56 ) + { + if ( v81 >= 1024 ) + { + if ( v82 ) + { + v69 = &pDir; + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + v51 = a2; + v64 = (signed __int64)v47; + v52 = v32; + Actor::AI_Stand(v52, v51, v64, v69); + continue; + } + v71 = &pDir; + v63 = 0; + + Actor::_402686(v32, a2, v63, v71); + continue; + } + if ( v82 ) + { + v69 = &pDir; + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + v51 = a2; + v64 = (signed __int64)v47; + v52 = v32; + Actor::AI_Stand(v52, v51, v64, v69); + continue; + } + v70 = (signed __int64)v56; + v62 = &pDir; + v59 = 0; + Actor::_40281C(v32, a2, v59, v62, v70); + continue; + } + v49 = v84 == 0; + v69 = &pDir; + if ( v49 ) + { + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + v51 = a2; + v64 = (signed __int64)v47; + v52 = v32; + Actor::AI_Stand(v52, v51, v64, v69); + continue; + } + Actor::_403C6C(v32, a2, &pDir); + continue; + } + if ( v45 != 1 ) + { + if ( v45 > 1 && v45 <= 3 ) + { + if ( v45 == 2 ) + v46 = v21->pMonsterInfo.uSpell1ID; + else + v46 = v21->pMonsterInfo.uSpell2ID; + if ( v46 ) + { + if ( v84 ) + { + if ( v45 == 2 ) + Actor::_403854(v32, a2, &pDir); + else + Actor::_403A60(v32, a2, &pDir); + continue; + } + if ( v80 * 307.2 > (double)v81 || v82 ) + { + v69 = &pDir; + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + v51 = a2; + v64 = (signed __int64)v47; + v52 = v32; + Actor::AI_Stand(v52, v51, v64, v69); + continue; + + } + v69 = &pDir; + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69); + continue; + } + v48 = v80 * 307.2; + if ( (double)v81 >= v48 ) + { + if ( v81 >= 1024 ) + { + v50 = v82 == 0; + if ( !v50 ) + { + v69 = &pDir; + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + v51 = a2; + v64 = (signed __int64)v47; + v52 = v32; + Actor::AI_Stand(v52, v51, v64, v69); + continue; + } + v71 = &pDir; + v63 = 256; + Actor::_402686(v32, a2, v63, v71); + continue; + + } + if ( v82 ) + { + v69 = &pDir; + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + v51 = a2; + v64 = (signed __int64)v47; + v52 = v32; + Actor::AI_Stand(v52, v51, v64, v69); + continue; + } + v70 = (signed __int64)v48; + v62 = &pDir; + v59 = 0; + Actor::_40281C(v32, a2, v59, v62, v70); + continue; + } + v49 = v84 == 0; + v69 = &pDir; + if ( v49 ) + { + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + v51 = a2; + v64 = (signed __int64)v47; + v52 = v32; + Actor::AI_Stand(v52, v51, v64, v69); + continue; + } + Actor::_403C6C(v32, a2, &pDir); + continue; + } + } + } + } + if ( v21->pMonsterInfo.uHostilityType != 4 || !a2 || v81 >= 5120 || v45 != 1 ) + { + if ( !v21->pMonsterInfo.uMovementType ) + { + v68 = 0; + v61 = 1024; + v41 = v32; + v40 = 4; + Actor::_4032B2(v41, v40, v61, v68); + continue; + + } + if ( v21->pMonsterInfo.uMovementType == 1 ) + { + v68 = 0; + v61 = 2560; + v41 = v32; + v40 = 4; + Actor::_4032B2(v41, v40, v61, v68); + continue; + } + if ( v21->pMonsterInfo.uMovementType == 2 ) + { + v68 = 0; + v61 = 5120; + v41 = v32; + v40 = 4; + Actor::_4032B2(v41, v40, v61, v68); + continue; + } + if ( v21->pMonsterInfo.uMovementType == 4 ) + { + v68 = 0; + v61 = 10240; + v41 = v32; + v40 = 4; + Actor::_4032B2(v41, v40, v61, v68); + continue; + } + if ( v21->pMonsterInfo.uMovementType == 5 ) + { + v57 = Actor::GetDirectionInfo(a1, 4u, &v72, 0); + v58 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + memcpy(&v74, v57, sizeof(v74)); + memcpy(&pDir, &v74, sizeof(pDir)); + v69 = &pDir; + v52 = actor_id; + v64 = (signed __int64)v58; + v51 = 4; + Actor::AI_Stand(v52, v51, v64, v69); + continue; + } + continue; + + } + if ( !v21->pMonsterInfo.uMissleAttack2Type ) + { + v56 = v80 * 307.2; + if ( (double)v81 >= v56 ) + { + if ( v81 >= 1024 ) + { + v50 = v82 == 0; + if ( !v50 ) + { + v69 = &pDir; + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + v51 = a2; + v64 = (signed __int64)v47; + v52 = v32; + Actor::AI_Stand(v52, v51, v64, v69); + continue; + } + v71 = &pDir; + v63 = 256; + Actor::_402686(v32, a2, v63, v71); + continue; + } + if ( v82 ) + { + v69 = &pDir; + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + v51 = a2; + v64 = (signed __int64)v47; + v52 = v32; + Actor::AI_Stand(v52, v51, v64, v69); + continue; + } + v70 = (signed __int64)v56; + v62 = &pDir; + v59 = 0; + Actor::_40281C(v32, a2, v59, v62, v70); + continue; + + } + v49 = v84 == 0; + v69 = &pDir; + if ( v49 ) + { + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + v51 = a2; + v64 = (signed __int64)v47; + v52 = v32; + Actor::AI_Stand(v52, v51, v64, v69); + continue; + } + Actor::_403C6C(v32, a2, &pDir); + continue; + } + if ( !v84 ) + { + if ( v82 ) + { + v69 = &pDir; + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + v51 = a2; + v64 = (signed __int64)v47; + v52 = v32; + Actor::AI_Stand(v52, v51, v64, v69); + continue; + } + v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; + //UNDEF(v53); + v69 = &pDir; + if ( !(v54 | v55) ) + { + v51 = a2; + v64 = (signed __int64)v47; + v52 = v32; + Actor::AI_Stand(v52, v51, v64, v69); + continue; + } + Actor::_402AD7(v32, a2, v32, (signed __int64)v47, v69); + continue; + } + Actor::_40368B(v32, a2, &pDir); + } + } } //----- (0040261D) --------------------------------------------------------
--- a/mm7_5.cpp Tue Mar 26 20:06:51 2013 +0200 +++ b/mm7_5.cpp Wed Mar 27 00:27:38 2013 +0200 @@ -5680,44 +5680,32 @@ //----- (0043A97E) -------------------------------------------------------- void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2) { - unsigned int v2; // esi@1 - unsigned int v3; // ebx@1 - int v4; // edi@1 - int v5; // edx@1 - unsigned int v6; // [sp+10h] [bp-4h]@1 - - v6 = uLayingItemID; - v2 = uLayingItemID; - v3 = a2 >> 3; - v4 = pSpriteObjects[uLayingItemID].spell_caster_pid & 7; - v5 = (a2 & 7) - 3; - if ( v5 ) - { - if ( v5 == 1 ) - { - layingitem_vel_50FDFC.x = pSpriteObjects[v2].vVelocity.x; - layingitem_vel_50FDFC.y = pSpriteObjects[v2].vVelocity.y; - layingitem_vel_50FDFC.z = pSpriteObjects[v2].vVelocity.z; - Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z); - DamagePlayerFromMonster(8 * v6 | 2, pSpriteObjects[v2].field_61, &layingitem_vel_50FDFC, 0xFFFFFFFFu); - } - } - else - { - layingitem_vel_50FDFC.x = pSpriteObjects[v2].vVelocity.x; - layingitem_vel_50FDFC.y = pSpriteObjects[v2].vVelocity.y; - layingitem_vel_50FDFC.z = pSpriteObjects[v2].vVelocity.z; + if ( PID_TYPE(a2) == OBJECT_BLVDoor) + { + layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x; + layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y; + layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z; + Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z); - switch ( v4 ) + DamagePlayerFromMonster(PID(OBJECT_Item, uLayingItemID), pSpriteObjects[uLayingItemID].field_61, &layingitem_vel_50FDFC, 0xFFFFFFFFu); + } + else if (PID_TYPE(a2) == OBJECT_Actor) + { + layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x; + layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y; + layingitem_vel_50FDFC.z = pSpriteObjects[uLayingItemID].vVelocity.z; + + Vec3_int_::Normalize(&layingitem_vel_50FDFC.x, &layingitem_vel_50FDFC.y, &layingitem_vel_50FDFC.z); + switch (PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid)) { case OBJECT_Actor: - sub_43B1B0(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC, pSpriteObjects[v2].field_61); + sub_43B1B0(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC, pSpriteObjects[uLayingItemID].field_61); break; case OBJECT_Player: - DamageMonsterFromParty(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC); + DamageMonsterFromParty(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC); break; case OBJECT_Item: - sub_43B057(8 * v6 | AI_OBJECT_LAYING_ITEM, v3, &layingitem_vel_50FDFC); + sub_43B057(PID(OBJECT_Item, uLayingItemID), PID_ID(a2), &layingitem_vel_50FDFC); break; } } @@ -6894,8 +6882,8 @@ _404544(); v2 = v1->pQueue; v3 = 0; - if ( (v1->pQueue[0].uPackedID & 7) == OBJECT_Player) - uActiveCharacter = (v1->pQueue[0].uPackedID >> 3) + 1; + if (PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) + uActiveCharacter = PID_ID(v1->pQueue[0].uPackedID) + 1; else uActiveCharacter = 0; viewparams->bRedrawGameUI = 1; @@ -6913,9 +6901,9 @@ goto LABEL_27; do { - if ( (v2->uPackedID & 7) != OBJECT_Player) - { - v5 = &pActors[v2->uPackedID >> 3]; + if (PID_TYPE(v2->uPackedID) != OBJECT_Player) + { + v5 = &pActors[PID_ID(v2->uPackedID)]; LOWORD(v6) = v5->uAIState; if ( (short)v6 == 4 || (short)v6 == 8 @@ -6971,9 +6959,9 @@ v9 = v1->pQueue; do { - if ( (v9->uPackedID & 7) != OBJECT_Player) - { - v10 = v9->uPackedID >> 3; + if (PID_TYPE(v9->uPackedID) != OBJECT_Player) + { + v10 = PID_ID(v9->uPackedID); v11 = pActors[v10].uAIState; if ( v11 != 5 ) { @@ -7023,7 +7011,7 @@ v4 = v1->pQueue[0].field_4; if ( v4 ) { - if ( (v1->pQueue[0].uPackedID & 7) == OBJECT_Player) + if (PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) { v5 = v1->uActorQueueSize; while ( 1 ) @@ -7122,8 +7110,8 @@ } v2->pQueue[a2].field_4 = v6; v2->_404544(); - if ( (v2->pQueue[0].uPackedID & 7) == OBJECT_Player) - uActiveCharacter = (v2->pQueue[0].uPackedID >> 3) + 1; + if (PID_TYPE(v2->pQueue[0].uPackedID) == OBJECT_Player) + uActiveCharacter = PID_ID(v2->pQueue[0].uPackedID) + 1; else uActiveCharacter = 0; result = (int)&v2->pQueue[0].field_4; @@ -7201,7 +7189,7 @@ v1 = this; LOWORD(v2) = _404544(); if ( v1->pQueue[0].field_4 <= 0 - || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, (v1->pQueue[0].uPackedID & 7) != OBJECT_Player) ? (uActiveCharacter = 0) : (v2 = (v2 >> 3) + 1, uActiveCharacter = v2), + || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, PID_TYPE(v1->pQueue[0].uPackedID) != OBJECT_Player) ? (uActiveCharacter = 0) : (v2 = (v2 >> 3) + 1, uActiveCharacter = v2), viewparams->bRedrawGameUI = 1, v1->pQueue[0].field_4 <= 0) ) { @@ -7269,13 +7257,13 @@ v1 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2)); v28 = v1; v3 = v1->uPackedID; - if ( (v1->uPackedID & 7) != OBJECT_Player) - { - v4 = v3 >> 3; // turn based only stuff - a2a = ai_near_actors_targets_pid[v3 >> 3]; - memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[v3 >> 3], &a3, 0), sizeof(a3)); + if (PID_TYPE(v1->uPackedID) != OBJECT_Player) + { + v4 = PID_ID(v3); + a2a = ai_near_actors_targets_pid[PID_ID(v3)]; + memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[PID_ID(v3)], &a3, 0), sizeof(a3)); memcpy(&a4, &a3, sizeof(a4)); - v5 = &pActors[v3 >> 3]; + v5 = &pActors[PID_ID(v3 >> 3)]; LOWORD(v3) = v5->uAIState; if ( (short)v3 != Dead ) { @@ -7433,11 +7421,8 @@ v9 = 0; v20 = 0; } - if ( (v22 & 7) == OBJECT_Actor) - v10 = (unsigned __int8)*(&byte_5C8D1A[89 - * (pMonsterStats->pInfos[pActors[v22 >> 3].pMonsterInfo.uID].uID - 1) - / 3] - + (v5->pMonsterInfo.uID - 1) / 3); + if (PID_TYPE(v22) == OBJECT_Actor) + v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[v22 >> 3].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3); else v10 = 4; if ( v10 == 1 ) @@ -7566,9 +7551,9 @@ while ( 1 ) { v5 = v10->uPackedID; - if ( (v10->uPackedID & 7) == OBJECT_Actor) - { - v8 = ai_near_actors_targets_pid[v5 >> 3]; + if (PID_TYPE(v10->uPackedID) == OBJECT_Actor) + { + v8 = ai_near_actors_targets_pid[PID_ID(v5)]; memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, v2), sizeof(v7)); if ( !v1->_406D10(a2) ) Actor::AI_Stand(v10->uPackedID >> 3, v8, 0x20u, &v7); @@ -7605,9 +7590,9 @@ v2 = this->pQueue; do { - if ( (v2->uPackedID & 7) == OBJECT_Actor) - { - v3 = v2->uPackedID >> 3; + if (PID_TYPE(v2->uPackedID) == OBJECT_Actor) + { + v3 = PID_ID(v2->uPackedID); v8 = v3; if ( pActors[v3].CanAct() ) { @@ -7660,7 +7645,7 @@ { v4 = v14->uPackedID; a1 = v14->uPackedID; - if ( (a1 & 7) != OBJECT_Player) + if (PID_TYPE(a1) != OBJECT_Player) { v5 = v4 >> 3; v12 = v5; @@ -7743,10 +7728,11 @@ unsigned int uActorID; // [sp+50h] [bp-4h]@2 unsigned int a2a; // [sp+5Ch] [bp+8h]@7 + __debugbreak(); v2 = *(&this->field_0 + 4 * (a2 + 2)); - if ( (v2 & 7) == OBJECT_Player) + if (PID_TYPE(v2) == OBJECT_Player) return 0; - v3 = v2 >> 3; + v3 = PID_ID(v2); uActorID = v3; v4 = &pActors[v3]; v5 = v4->uAIState; @@ -7938,9 +7924,9 @@ v14 = this->pQueue; do { - if ( (v3->uPackedID & 7) != OBJECT_Player) - { - v4 = v3->uPackedID >> 3; + if (PID_TYPE(v3->uPackedID) != OBJECT_Player) + { + v4 = PID_ID(v3->uPackedID); uActorID = v4; v5 = &pActors[v4]; v6 = v5->uAIState; @@ -11620,9 +11606,9 @@ else v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; v6 = (unsigned __int16)v5; - if ( (v5 & 7) == OBJECT_Actor + if (PID_TYPE(v5) == OBJECT_Actor && uActiveCharacter - && v5 < 33554432 + && v5 < 0x2000000 && pPlayers[uActiveCharacter]->CanAct() && pPlayers[uActiveCharacter]->CanSteal() ) { @@ -11633,7 +11619,7 @@ *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; ++pMessageQueue_50CBD0->uNumMessages; }*/ - pMessageQueue_50CBD0->AddMessage(UIMSG_1B, v6 >> 3, 0); + pMessageQueue_50CBD0->AddMessage(UIMSG_1B, PID_ID(v6), 0); if ( pParty->bTurnBasedModeOn == 1 ) {
--- a/mm7_6.cpp Tue Mar 26 20:06:51 2013 +0200 +++ b/mm7_6.cpp Wed Mar 27 00:27:38 2013 +0200 @@ -2489,20 +2489,20 @@ //int v32; // eax@112 //char *v33; // edx@113 //int v34; // eax@121 - int v35; // eax@123 - int v36; // edx@125 + //int v35; // eax@123 + //int v36; // edx@125 //int v37; // eax@129 - signed int v38; // edi@129 - signed int v39; // eax@129 - int v40; // ecx@129 - int v41; // eax@129 - signed int v42; // eax@129 - int *v43; // ecx@129 + //signed int v38; // edi@129 + //signed int v39; // eax@129 + //int v40; // ecx@129 + //int v41; // eax@129 + //signed int v42; // eax@129 + //int *v43; // ecx@129 //int v44; // eax@132 - int v45; // ecx@132 + //int v45; // ecx@132 int v46; // eax@132 - unsigned int v47; // edx@133 - int v48; // eax@137 + //unsigned int v47; // edx@133 + //int v48; // eax@137 //int v49; // eax@137 //int v50; // eax@141 int v51; // eax@146 @@ -2537,7 +2537,7 @@ //int v80; // eax@232 //__int16 v81; // ST18_2@245 //stru6 *v82; // eax@245 - signed int v83; // edi@245 + //signed int v83; // edi@245 //__int16 v84; // ST18_2@245 //stru6 *v85; // eax@245 //__int16 v86; // ST18_2@245 @@ -2574,8 +2574,8 @@ int v117; // edx@281 int v118; // edx@283 int v119; // edi@286 - int v120; // eax@286 - int v121; // eax@286 + //int v120; // eax@286 + //int v121; // eax@286 signed int v122; // eax@286 int v123; // ecx@288 int v124; // ecx@289 @@ -2606,7 +2606,7 @@ int v149; // ecx@312 int v150; // ecx@313 int v151; // ecx@314 - signed int v152; // eax@322 + //signed int v152; // eax@322 int v153; // ecx@322 int v154; // eax@322 int v155; // eax@323 @@ -2617,7 +2617,7 @@ signed __int64 v160; // qtt@334 //int v161; // eax@339 int v162; // edi@340 - int v163; // eax@340 + //int v163; // eax@340 signed int v164; // eax@340 signed int v165; // edi@340 //stru6 *v166; // eax@340 @@ -2693,7 +2693,7 @@ //stru6 *v236; // eax@469 //__int16 v237; // ST18_2@469 //stru6 *v238; // eax@469 - __int16 v239; // ST1C_2@469 + //__int16 v239; // ST1C_2@469 char *v240; // ecx@472 double v241; // st7@478 signed __int64 v242; // qax@484 @@ -2780,7 +2780,7 @@ int v323; // edi@635 char *v324; // eax@635 Player *v325; // ecx@640 - int v326; // eax@643 + //int v326; // eax@643 //int v327; // eax@648 int v328; // ecx@651 int v329; // ecx@652 @@ -2824,7 +2824,7 @@ //stru6 *v367; // eax@704 //int v368; // eax@704 Actor *v369; // edi@705 - int v370; // eax@706 + //int v370; // eax@706 int v371; // ecx@709 int v372; // ecx@710 int v373; // eax@715 @@ -2839,9 +2839,9 @@ int v382; // ecx@727 Player *v383; // eax@728 int v384; // eax@733 - int v385; // edi@736 - signed int v386; // eax@736 - Player *v387; // edi@738 + //int v385; // edi@736 + //signed int v386; // eax@736 + //Player *v387; // edi@738 int v388; // edi@740 //unsigned __int16 v389; // ST1C_2@740 //__int16 v390; // ST18_2@740 @@ -2881,14 +2881,14 @@ int v424; // ecx@809 int v425; // eax@811 signed int v426; // eax@815 - signed int v427; // eax@820 + //signed int v427; // eax@820 int v428; // ecx@825 int v429; // ecx@826 int v430; // eax@828 //stru6 *v431; // eax@831 //int v432; // eax@831 Actor *v433; // edi@832 - int v434; // eax@833 + //int v434; // eax@833 int v435; // ecx@837 int v436; // ecx@838 //__int16 v437; // ST1C_2@843 @@ -2962,16 +2962,16 @@ int v505; // eax@943 //int v506; // eax@943 int v507; // edi@944 - int v508; // eax@944 + //int v508; // eax@944 signed int v509; // eax@944 signed int v510; // edi@944 Actor *v511; // edi@946 - int v512; // eax@946 + //int v512; // eax@946 SpellBuff *v513; // edi@946 int v514; // ecx@950 int v515; // ecx@951 int v516; // eax@953 - int v517; // eax@956 + //int v517; // eax@956 Actor *v518; // edx@957 __int16 v519; // cx@958 int v520; // ecx@968 @@ -2988,7 +2988,7 @@ int v531; // eax@982 //int v532; // eax@982 int v533; // edi@983 - int v534; // eax@983 + //int v534; // eax@983 signed int v535; // eax@983 signed int v536; // edi@983 stru6 *v537; // eax@984 @@ -3036,7 +3036,7 @@ __int16 v579; // ax@1029 //int v580; // eax@1031 int v581; // edi@1031 - int v582; // eax@1031 + //int v582; // eax@1031 //__int16 v583; // ST1C_2@1034 //__int16 v584; // ST18_2@1034 char *v585; // esi@1034 @@ -3053,7 +3053,7 @@ int v596; // esi@1066 unsigned int v597; // edi@1067 int v598; // eax@1079 - signed int v599; // eax@1082 + //signed int v599; // eax@1082 int v600; // edi@1086 int v601; // edx@1086 int v602; // eax@1086 @@ -3080,15 +3080,15 @@ signed __int64 v623; // qax@1127 //int v624; // eax@1127 int v625; // edi@1129 - int v626; // eax@1129 + //int v626; // eax@1129 signed int v627; // eax@1129 signed int v628; // edi@1129 int v629; // ecx@1130 Player *v630; // eax@1131 int v631; // eax@1137 - int v632; // edi@1140 - Player *v633; // eax@1140 - signed int v634; // eax@1140 + //int v632; // edi@1140 + //Player *v633; // eax@1140 + //signed int v634; // eax@1140 int v635; // edi@1142 //unsigned __int16 v636; // ST1C_2@1142 //__int16 v637; // ST18_2@1142 @@ -3108,7 +3108,7 @@ //unsigned __int16 v651; // [sp-8h] [bp-E8Ch]@100 //unsigned __int16 v652; // [sp-8h] [bp-E8Ch]@304 //unsigned __int16 v653; // [sp-4h] [bp-E88h]@100 - int v654; // [sp-4h] [bp-E88h]@124 + //int v654; // [sp-4h] [bp-E88h]@124 //unsigned __int16 v655; // [sp-4h] [bp-E88h]@304 unsigned int v656; // [sp-4h] [bp-E88h]@639 int v657; // [sp-4h] [bp-E88h]@807 @@ -3123,12 +3123,12 @@ int v666; // [sp+4h] [bp-E80h]@12 PLAYER_SKILL_TYPE v667; // [sp+4h] [bp-E80h]@25 //unsigned __int8 v668; // [sp+4h] [bp-E80h]@100 - int v669; // [sp+4h] [bp-E80h]@123 - Vec3_int_ *v670; // [sp+4h] [bp-E80h]@133 + //int v669; // [sp+4h] [bp-E80h]@123 + //Vec3_int_ *v670; // [sp+4h] [bp-E80h]@133 int v671; // [sp+4h] [bp-E80h]@146 unsigned int v672; // [sp+4h] [bp-E80h]@164 //unsigned __int8 v673; // [sp+4h] [bp-E80h]@304 - __int16 v674; // [sp+4h] [bp-E80h]@684 + //__int16 v674; // [sp+4h] [bp-E80h]@684 const char *v675; // [sp+4h] [bp-E80h]@800 int v676; // [sp+4h] [bp-E80h]@807 int v677; // [sp+4h] [bp-E80h]@861 @@ -3142,28 +3142,28 @@ unsigned __int64 v685; // [sp+D08h] [bp-17Ch]@416 int x; // [sp+D20h] [bp-164h]@327 unsigned __int64 v687; // [sp+D24h] [bp-160h]@327 - int v688; // [sp+D2Ch] [bp-158h]@943 - int v689; // [sp+D30h] [bp-154h]@943 - int v690; // [sp+D34h] [bp-150h]@943 - int v691; // [sp+D38h] [bp-14Ch]@137 - int v692; // [sp+D3Ch] [bp-148h]@137 - int v693; // [sp+D40h] [bp-144h]@137 - int v694; // [sp+D44h] [bp-140h]@982 - int v695; // [sp+D48h] [bp-13Ch]@982 - int v696; // [sp+D4Ch] [bp-138h]@982 - int v697; // [sp+D50h] [bp-134h]@129 - int v698; // [sp+D54h] [bp-130h]@129 - int v699; // [sp+D58h] [bp-12Ch]@129 + Vec3_int_ v688; // [sp+D2Ch] [bp-158h]@943 + //int v689; // [sp+D30h] [bp-154h]@943 + //int v690; // [sp+D34h] [bp-150h]@943 + Vec3_int_ v691; // [sp+D38h] [bp-14Ch]@137 + //int v692; // [sp+D3Ch] [bp-148h]@137 + //int v693; // [sp+D40h] [bp-144h]@137 + Vec3_int_ v694; // [sp+D44h] [bp-140h]@982 + //int v695; // [sp+D48h] [bp-13Ch]@982 + //int v696; // [sp+D4Ch] [bp-138h]@982 + Vec3_int_ v697; // [sp+D50h] [bp-134h]@129 + //int v698; // [sp+D54h] [bp-130h]@129 + //int v699; // [sp+D58h] [bp-12Ch]@129 Vec3_int_ v700; // [sp+D5Ch] [bp-128h]@339 - int v701; // [sp+D68h] [bp-11Ch]@286 - int v702; // [sp+D6Ch] [bp-118h]@286 - int v703; // [sp+D70h] [bp-114h]@286 - int v704; // [sp+D74h] [bp-110h]@132 - int v705; // [sp+D78h] [bp-10Ch]@132 - int v706; // [sp+D7Ch] [bp-108h]@132 - int v707; // [sp+D80h] [bp-104h]@1127 - int v708; // [sp+D84h] [bp-100h]@1127 - int v709; // [sp+D88h] [bp-FCh]@1127 + Vec3_int_ v701; // [sp+D68h] [bp-11Ch]@286 + //int v702; // [sp+D6Ch] [bp-118h]@286 + //int v703; // [sp+D70h] [bp-114h]@286 + Vec3_int_ v704; // [sp+D74h] [bp-110h]@132 + //int v705; // [sp+D78h] [bp-10Ch]@132 + //int v706; // [sp+D7Ch] [bp-108h]@132 + Vec3_int_ v707; // [sp+D80h] [bp-104h]@1127 + //int v708; // [sp+D84h] [bp-100h]@1127 + //int v709; // [sp+D88h] [bp-FCh]@1127 char v710; // [sp+D8Ch] [bp-F8h]@1156 stru277 *v711; // [sp+D90h] [bp-F4h]@1 __int64 v712; // [sp+D94h] [bp-F0h]@991 @@ -3181,7 +3181,7 @@ ItemGen *_this; // [sp+E50h] [bp-34h]@23 float v725; // [sp+E54h] [bp-30h]@23 Player *v726; // [sp+E58h] [bp-2Ch]@131 - int v726b; + //int v726b; float v727; // [sp+E5Ch] [bp-28h]@1 unsigned int uRequiredMana; // [sp+E60h] [bp-24h]@53 Player *pPlayer; // [sp+E64h] [bp-20h]@8 @@ -3238,7 +3238,7 @@ a2 = stru_50C198.FindClosestActor(5120, 1, v666); v6 = pMouse->uPointingObjectID; - if ( pMouse->uPointingObjectID && (v6 & 7) == OBJECT_Actor && pActors[v6 >> 3].CanAct() ) + if ( pMouse->uPointingObjectID && PID_TYPE(v6) == OBJECT_Actor && pActors[PID_ID(v6)].CanAct() ) a2 = pMouse->uPointingObjectID; } @@ -3246,9 +3246,9 @@ a1.uType = stru_4E3ACC[v3->spellnum].field_0; if (a1.uType) { - if ( (a2 & 7) == OBJECT_Actor) + if (PID_TYPE(a2) == OBJECT_Actor) { - memcpy(&v715, Actor::GetDirectionInfo((8 * v3->uPlayerID + 8) | OBJECT_Player, a2, &a3, 0), sizeof(v715)); + memcpy(&v715, Actor::GetDirectionInfo(PID(OBJECT_Player, v3->uPlayerID + 8), a2, &a3, 0), sizeof(v715)); v2 = v723; } else @@ -3313,7 +3313,6 @@ } } - v730 = v3->spellnum; if (v3->forced_spell_skill_level) uRequiredMana = 0; else @@ -3328,7 +3327,6 @@ break; ShowStatusBarString(pGlobalTXT_LocalizationStrings[586], 2u); // "Not enough spell points" -LABEL_203: v3->spellnum = 0; LABEL_1166: ++n; @@ -3336,10 +3334,11 @@ return; } - if (pPlayer->Cursed() && v730 < SPELL_BOW_ARROW) + v730 = v3->spellnum; + if (pPlayer->Cursed() && v3->spellnum < SPELL_BOW_ARROW) if (rand() % 100 < 50) { - if ( pParty->bTurnBasedModeOn == 0 ) + if (!pParty->bTurnBasedModeOn) { //v646 = pPlayer; pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); @@ -3464,9 +3463,11 @@ goto play_sound_and_continue; pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)3600 * v2 * 4.2666669), v731, amount, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case SPELL_FIRE_FIRE_SPIKE: + { v29 = v731 - 2; if ( v29 ) { @@ -3492,12 +3493,12 @@ //LOBYTE(v32) = v32 | OBJECT_Player; //if ( (signed int)uNumSpriteObjects > 0 ) - HIDWORD(v733) = 0; + int _v733 = 0; for (uint i = 0; i < uNumSpriteObjects; ++i) { auto object = pSpriteObjects + i; - if (object->uType && object->spell_id == SPELL_FIRE_FIRE_SPIKE && object->spell_caster_pid == (8 * (int)v3->uPlayerID) | OBJECT_Player) - ++HIDWORD(v733); + if (object->uType && object->spell_id == SPELL_FIRE_FIRE_SPIKE && object->spell_caster_pid == PID(OBJECT_Player, v3->uPlayerID)) + ++_v733; /*v33 = (char *)&pSpriteObjects[0].field_48; v730 = uNumSpriteObjects; do @@ -3509,11 +3510,12 @@ } while ( v730 );*/ } - if ( SHIDWORD(v733) > amount ) + if (_v733 > amount) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -3539,25 +3541,32 @@ a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(a1.uAttributes) |= 4u; - v669 = v3->uPlayerID + 1; v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - v35 = pParty->sRotationX + 10; - goto LABEL_124; + if ( a1.Create(pParty->sRotationY, pParty->sRotationX + 10, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } case 20: + { if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; if (!a2) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; - } - if ( (a2 & 7) != OBJECT_Actor) - goto LABEL_1056; - v699 = 0; - v698 = 0; - v697 = 0; + v3->spellnum = 0; + goto LABEL_1166; + } + if (PID_TYPE(a2) != OBJECT_Actor) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + v697.x = 0; + v697.y = 0; + v697.z = 0; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -3569,31 +3578,31 @@ a1.field_60_distance_related_prolly_lod = 0; a1.uFacing = 0; a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); - v38 = a2 >> 3; a1.uSoundID = LOWORD(v3->sound_id); - v39 = a2 >> 3; - a1.vPosition.x = pActors[v39].vPosition.x; - v40 = pActors[v39].vPosition.y; - a1.vPosition.z = pActors[v39].vPosition.z; - v41 = 8 * (a2 >> 3); - a1.vPosition.y = v40; - LOBYTE(v41) = v41 | OBJECT_Actor; - a1.spell_target_pid = v41; - v42 = a1.Create(0, 0, 0, 0); - v43 = &v697; - goto LABEL_133; + a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x; + a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z; + a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y; + a1.spell_target_pid = PID(OBJECT_Actor, a2 >> 3); + auto obj_id = a1.Create(0, 0, 0, 0); + DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v697); + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 44: + { if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v726 = (Player *)(a2 >> 3); - HIDWORD(v733) = 836 * (a2 >> 3); + if ( !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 3u) ) - goto LABEL_1056; - pActors[a2 >> 3].pActorBuffs[10].Apply( - pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0); - v706 = 0; - v705 = 0; - v704 = 0; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + pActors[a2 >> 3].pActorBuffs[10].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0); + v704.x = 0; + v704.y = 0; + v704.z = 0; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -3604,59 +3613,59 @@ a1.uSpriteFrameID = 0; a1.field_60_distance_related_prolly_lod = 0; a1.uFacing = 0; - v38 = (signed int)v726; a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.uSoundID = LOWORD(v3->sound_id); - a1.vPosition.x = *(__int16 *)((char *)&pActors[0].vPosition.x + HIDWORD(v733)); - v45 = *(__int16 *)((char *)&pActors[0].vPosition.y + HIDWORD(v733)); - a1.vPosition.z = *(__int16 *)((char *)&pActors[0].vPosition.z + HIDWORD(v733)); - a1.vPosition.y = v45; + a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x; + a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y; + a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z; a1.spell_target_pid = PID(OBJECT_Actor, (int)v726); - v42 = a1.Create(0, 0, 0, 0); - v43 = &v704; -LABEL_133: - v670 = (Vec3_int_ *)v43; - v47 = v38; - goto LABEL_139; + + auto obj_id = a1.Create(0, 0, 0, 0); + DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v704); + + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 79: - if ( !pPlayer->CanCastSpell(uRequiredMana) || !a2 || (a2 & 7) != OBJECT_Actor) - goto play_sound_and_continue; - v730 = a2 >> 3; - v693 = 0; - HIDWORD(v733) = (int)&pActors[a2 >> 3]; - v692 = 0; - v691 = 0; + { + if ( !pPlayer->CanCastSpell(uRequiredMana) || !a2 || PID_TYPE(a2) != OBJECT_Actor) + goto play_sound_and_continue; + //v730 = a2 >> 3; + //HIDWORD(v733) = (int)&pActors[PID_ID(a2)]; + v691.x = 0; + v691.y = 0; + v691.z = 0; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); - a1.vPosition.x = *(short *)(HIDWORD(v733) + 142); - a1.vPosition.y = *(short *)(HIDWORD(v733) + 144); - v48 = *(short *)(HIDWORD(v733) + 138); - a1.vPosition.z = *(short *)(HIDWORD(v733) + 138); + a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x; + a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y; + a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z; a1.uAttributes = 0; - a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, v48); + a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); a1.uSpriteFrameID = 0; a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.spell_target_pid = a2; a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); a1.uFacing = LOWORD(v715.uYawAngle); - LOBYTE(a1.uAttributes) |= 0x80u; + a1.uAttributes |= 0x80u; a1.uSoundID = LOWORD(v3->sound_id); - v726 = (Player *)a1.Create(0, 0, 0, 0); + + auto obj_id = a1.Create(0, 0, 0, 0); if ( !MonsterStats::BelongsToSupertype(*(short *)(HIDWORD(v733) + 96), MONSTER_SUPERTYPE_UNDEAD) ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; - } - v47 = v730; - v670 = (Vec3_int_ *)&v691; - v42 = (signed int)v726; -LABEL_139: - DamageMonsterFromParty(8 * v42 | 2, v47, v670); - goto LABEL_1056; + v3->spellnum = 0; + goto LABEL_1166; + } + DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v691); + LODWORD(v727) = 1; + goto play_sound_and_continue; + } case SPELL_FIRE_FIRE_BOLT: @@ -3690,16 +3699,21 @@ else a1.uSectorID = 0; a1.uSpriteFrameID = 0; - a1.spell_caster_pid = (8 * v3->uPlayerID) | OBJECT_Player; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.spell_target_pid = a2; a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); a1.uFacing = LOWORD(v715.uYawAngle); a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(a1.uAttributes) |= 4u; - if ( v3->spellnum == 18 ) + if ( v3->spellnum == SPELL_AIR_LIGHNING_BOLT ) LOBYTE(a1.uAttributes) |= 0x40u; - goto LABEL_156; + + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; + if ( a1.Create(v715.uYawAngle, v715.uPitchAngle, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + LODWORD(v727) = 1; + goto play_sound_and_continue; @@ -3725,22 +3739,28 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( pPlayer->CanCastSpell(uRequiredMana) ) goto LABEL_152; goto play_sound_and_continue; + + case 81: + { if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - if ( !a2 - || (a2 & 7) != OBJECT_Actor - || (v730 = a2 >> 3, - v721 = (int)&pActors[a2 >> 3], + + if (PID_TYPE(a2) != OBJECT_Actor || + (v730 = PID_ID(a2), + v721 = (int)&pActors[PID_ID(a2)], !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 9u)) ) - goto LABEL_1056; - Actor::AI_Stand(v730, 4u, 0x80u, 0); - v726 = (Player *)(23040 * v2); + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + Actor::AI_Stand(PID_ID(a2), 4u, 0x80u, 0); v54 = (signed __int64)((double)(23040 * v2) * 0.033333335); v55 = v721; ((SpellBuff *)(v721 + 308))->Apply(pParty->uTimePlayed + (signed int)v54, v731, 0, 0, 0); @@ -3750,6 +3770,8 @@ *(short *)(v55 + 150) = 0; v661 = (Actor *)v55; goto LABEL_165; + } + case 35: if ( v731 == 2 ) { @@ -3776,17 +3798,18 @@ LODWORD(v733) = v57; if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - if ( (a2 & 7) != OBJECT_Actor - || (v721 = 836 * (a2 >> 3), - LODWORD(v718) = (int)&pActors[a2 >> 3], - !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 3u)) ) - goto LABEL_1056; - v726 = (Player *)(23040 * v2); + if (PID_TYPE(a2) != OBJECT_Actor + || (v721 = 836 * PID_ID(a2), + LODWORD(v718) = (int)&pActors[PID_ID(a2)], + !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3u)) ) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } v58 = (signed __int64)((double)(23040 * v2) * 0.033333335); v59 = v721; //((SpellBuff *)((char *)&pActors[0].pActorBuffs[7] + v721))->Apply( - pActors[a2 >> 3].pActorBuffs[7].Apply( - pParty->uTimePlayed + (signed int)v58, + pActors[a2 >> 3].pActorBuffs[7].Apply(pParty->uTimePlayed + (signed int)v58, v731, amount, 0, @@ -3795,30 +3818,33 @@ v672 = 0; v661 = (Actor *)LODWORD(v718); goto LABEL_165; + + case 60: + { if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v730 = 836 * (a2 >> 3); - if ( !stru_50C198.GetMagicalResistance(&pActors[a2>>3], 7u) ) - goto LABEL_1056; - LODWORD(v733) = 300 * v2; + + if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 7u) ) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + + uint power = 300 * v2; if ( v731 == 2 ) { - LODWORD(v733) = 600 * v2; - } - else - { - if ( v731 == 3 ) - LODWORD(v733) = 29030400; - } + power = 600 * v2; + } + else if ( v731 == 3 ) + power = 29030400; + //((SpellBuff *)((char *)&pActors[0].pActorBuffs[9] + v730))->Reset(); - pActors[a2 >> 3].pActorBuffs[9].Reset(); + pActors[PID_ID(a2)].pActorBuffs[9].Reset(); //((SpellBuff *)((char *)&pActors[0].pActorBuffs[12] + v730))->Reset(); - pActors[a2 >> 3].pActorBuffs[12].Reset(); - v726 = (Player *)((int)v733 << 7); + pActors[PID_ID(a2)].pActorBuffs[12].Reset(); //((SpellBuff *)((char *)&pActors[0].pActorBuffs[1] + v730))->Apply( - pActors[a2 >> 3].pActorBuffs[1].Apply( - pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), + pActors[PID_ID(a2)].pActorBuffs[1].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(power << 7) * 0.033333335), v731, 0, 0, 0); a1.stru_24.Reset(); a1.spell_id = v3->spellnum; @@ -3827,6 +3853,8 @@ v60 = pObjectList->ObjectIDByItemID(a1.uType); v61 = a2 >> 3; goto LABEL_1086; + } + case 92: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -3849,8 +3877,18 @@ a1.spell_skill = v731; a1.spell_id = SPELL_FIRE_PROTECTION_FROM_FIRE; a1.spell_level = 300 * v2; - goto LABEL_154; + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(a1.uAttributes) |= 4u; + + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; + + if ( a1.Create(v715.uYawAngle, v715.uPitchAngle, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 4: + { v63 = v731 - 1; if ( !v63 ) { @@ -3880,7 +3918,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; v730c = &pParty->pPlayers[v3->uPlayerID_2].pInventoryItems[a2]; - v726 = (Player *)&pItemsTable->pItems[v730c->uItemID].pIconName; + auto _itm = &pItemsTable->pItems[v730c->uItemID]; v730c->UpdateTempBonus(pParty->uTimePlayed); if ( v730c->uItemID < 64 || v730c->uItemID > 65 ) { @@ -3890,7 +3928,7 @@ { if (!v730c->uEnchantmentType) { - v68 = BYTE4(v726->pConditions[3]); + v68 = _itm->uEquipType; if ( !v68 || v68 == 1 || v68 == 2 ) { if ( !pItemsTable->IsMaterialNonCommon(v730c) ) @@ -3900,21 +3938,17 @@ *(int *)(v730 + 12) = amount; if ( !v14 ) { - v726 = (Player *)((int)v733 << 7); *(_QWORD *)(v69 + 28) = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); *(int *)(v69 + 20) |= 8u; } *(int *)(v69 + 20) |= 0x10u; -LABEL_1055: dword_50C9A8 = 256; -LABEL_1056: LODWORD(v727) = 1; play_sound_and_continue: if ( v3->field_8 & 0x20 ) { -LABEL_1162: if ( v727 != 0.0 ) pAudioPlayer->PlaySound( (SoundID)word_4EE088_sound_ids[v3->spellnum], @@ -3946,12 +3980,23 @@ if ( v727 != 0.0 ) { pPlayer->PlaySound(SPEECH_49, 0); - goto LABEL_1162; + if ( v727 != 0.0 ) + pAudioPlayer->PlaySound( + (SoundID)word_4EE088_sound_ids[v3->spellnum], + 0, + 0, + -1, + 0, + v3->sound_id, + 0, + 0); + + v3->spellnum = 0; + v2 = v723; + goto LABEL_1166; } } v3->spellnum = 0; - //v1 = 0; -LABEL_1165: v2 = v723; goto LABEL_1166; } @@ -3967,9 +4012,12 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; + } case SPELL_BODY_REGENERATION: + { v70 = v731 - 1; LODWORD(v733) = 3600 * v2; if ( v70 && (v71 = v70 - 1) != 0 ) @@ -3995,7 +4043,9 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_REGENERATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)v733 * 4.2666669), v731, amount, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } case SPELL_FIRE_PROTECTION_FROM_FIRE: case SPELL_AIR_PROTECTION_FROM_AIR: @@ -4065,11 +4115,10 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v83 = 1; v90 = (double)(signed int)v733 * 4.2666669; pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, v731, amount, 0, 0); - LODWORD(v727) = 1; + LODWORD(v727) = 1; goto play_sound_and_continue; case SPELL_FIRE_HASTE: @@ -4107,7 +4156,6 @@ while ( v92 <= &pParty->pPlayers[3] ); if (LODWORD(v727)) { - v726 = (Player *)((int)v733 << 7); pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 0); @@ -4154,7 +4202,6 @@ v716 = v111; //v658 = v111; //v653 = amount; - v726 = (Player *)((int)v733 << 7); //v651 = 1; //v28 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); //v27 = (char *)&pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS]; @@ -4163,10 +4210,10 @@ //LABEL_104: //LODWORD(v650) = v28; pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), 1, amount, v111, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; } v105 = 0; - v726 = (Player *)((int)v733 << 7); v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); v730b = pParty->pPlayers;//[0].pPlayerBuffs[1]; do @@ -4178,29 +4225,30 @@ ++v105; } while ( v730b <= &pParty->pPlayers[3] ); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case 52: - if ( pPlayer->CanCastSpell(uRequiredMana) && a2 && (a2 & 7) == OBJECT_Actor) - { - v730 = a2 >> 3; - v112 = &pActors[a2 >> 3]; - v726 = (Player *)abs(v112->vPosition.z - pParty->vPosition.z); + if ( pPlayer->CanCastSpell(uRequiredMana) && a2 && PID_TYPE(a2) == OBJECT_Actor) + { + //v730 = a2 >> 3; + v112 = &pActors[PID_ID(a2)]; + //v726 = (Player *)abs(v112->vPosition.z - pParty->vPosition.z); v721 = abs(v112->vPosition.y - pParty->vPosition.y); v113 = abs(v112->vPosition.x - pParty->vPosition.x); _this = (ItemGen *)v113; v114 = v721; - v115 = (unsigned int)v726; + v115 = (unsigned int)abs(v112->vPosition.z - pParty->vPosition.z); if ( v113 < v721 ) { v116 = v113; v113 = v721; v114 = v116; } - if ( v113 < (signed int)v726 ) + if ( v113 < (signed int)v115 ) { v117 = v113; - v113 = (int)v726; + v113 = (int)v115; v115 = v117; } if ( v114 < (signed int)v115 ) @@ -4212,9 +4260,9 @@ _this = (ItemGen *)(((unsigned int)(11 * v114) >> 5) + (v115 >> 2) + v113); if ( (double)(signed int)this <= 307.2 ) { - v703 = 0; - v702 = 0; - v701 = 0; + v701.x = 0; + v701.y = 0; + v701.z = 0; a1.stru_24.Reset(); v119 = HIDWORD(v733); a1.spell_id = *(int *)HIDWORD(v733); @@ -4224,21 +4272,16 @@ a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; - v120 = 8 * *(short *)(v119 + 2); - LOBYTE(v120) = v120 | OBJECT_Player; a1.field_60_distance_related_prolly_lod = 0; - a1.spell_caster_pid = v120; + a1.spell_caster_pid = PID(OBJECT_Player, *(short *)(v119 + 2)); a1.uFacing = 0; a1.uSoundID = *(short *)(v119 + 16); a1.vPosition.x = v112->vPosition.x; a1.vPosition.y = v112->vPosition.y; - v726 = (Player *)v112->uActorHeight; - v121 = 8 * a2; - a1.vPosition.z = v112->vPosition.z - (unsigned int)(signed __int64)((double)(signed int)v726 * unk_4D8548); - LOBYTE(v121) = 8 * a2 | 3; - a1.spell_target_pid = v121; + a1.vPosition.z = v112->vPosition.z - (unsigned int)(signed __int64)((double)(signed int)v112->uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, a2); v122 = a1.Create(0, 0, 0, 0); - DamageMonsterFromParty(8 * v122 | 2, v730, (Vec3_int_ *)&v701); + DamageMonsterFromParty(PID(OBJECT_Item, v122), PID_ID(a2), &v701); LODWORD(v727) = 1; } else @@ -4302,12 +4345,10 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v83 = 1; - v726 = (Player *)((int)v733 << 7); v90 = (double)(signed int)((int)v733 << 7) * 0.033333335; //LABEL_304: pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, v731, amount, 0, 0); - LODWORD(v727) = v83; + LODWORD(v727) = 1; goto play_sound_and_continue; case SPELL_FIRE_IMMOLATION: @@ -4325,10 +4366,9 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v726 = (Player *)((int)v733 << 7); - pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case 9: v149 = v731 - 1; @@ -4345,17 +4385,17 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[491], 2); // Can't cast Meteor Shower indoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; LODWORD(v725) = a2 & 7; - if ( (a2 & 7) == OBJECT_Actor) - { - v152 = a2 >> 3; - uRequiredMana = pActors[v152].vPosition.x; - v153 = pActors[v152].vPosition.y; - v154 = pActors[v152].vPosition.z; + if (PID_TYPE(a2) == OBJECT_Actor) + { + uRequiredMana = pActors[PID_ID(a2)].vPosition.x; + v153 = pActors[PID_ID(a2)].vPosition.y; + v154 = pActors[PID_ID(a2)].vPosition.z; LODWORD(v727) = v153; } else @@ -4370,12 +4410,12 @@ v713 = v154 + 2500; v721 = 0; LODWORD(v718) = 0; - if ( (signed int)this > 0 ) + if ( (signed int)_this > 0 ) { *(float *)&y = (double)SHIDWORD(v733); *(float *)&v732 = (double)v713; v730 = LODWORD(v725) == 3 ? a2 : 0; - v726 = (Player *)this; + auto _this_cpy = (int)_this; do { v157 = rand(); @@ -4410,7 +4450,7 @@ a1.uSectorID = 0; a1.vPosition.z = a2 + v713; a1.uSpriteFrameID = 0; - a1.spell_caster_pid = 8 * v3->uPlayerID | OBJECT_Player; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.spell_target_pid = v730; a1.field_60_distance_related_prolly_lod = stru_50C198._427546(a2 + 2500); a1.uFacing = v687; @@ -4426,24 +4466,27 @@ ++pTurnEngine->field_1C; LODWORD(v718) = rand() % 1024 - 512; v160 = rand(); - v14 = v726 == (Player *)1; - v726 = (Player *)((char *)v726 - 1); + v14 = _this_cpy-- == 1; v721 = (unsigned __int64)(v160 % 1024) - 512; } while ( !v14 ); } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 10: + { //v67 = 2; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[492], 2); // Can't cast Inferno outdoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v726 = (Player *)sub_46A6AC((int)dword_50BF30, 100, 4096); + auto _v726 = sub_46A6AC((int)dword_50BF30, 100, 4096); v700.z = 0; v700.y = 0; v700.x = 0; @@ -4460,28 +4503,27 @@ a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.uSoundID = LOWORD(v3->sound_id); a2 = 0; - if ( (signed int)v726 > 0 ) + if ( (signed int)_v726 > 0 ) { do { v162 = dword_50BF30[a2]; a1.vPosition.x = pActors[v162].vPosition.x; a1.vPosition.y = pActors[v162].vPosition.y; - v732 = pActors[v162].uActorHeight; - a1.vPosition.z = pActors[v162].vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - v163 = 8 * dword_50BF30[a2]; - LOBYTE(v163) = v163 | OBJECT_Actor; - a1.spell_target_pid = v163; + a1.vPosition.z = pActors[v162].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v162].uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); v164 = a1.Create(0, 0, 0, 0); v165 = a2; - DamageMonsterFromParty(8 * v164 | AI_OBJECT_LAYING_ITEM, dword_50BF30[a2], &v700); + DamageMonsterFromParty(PID(OBJECT_Item, v164), dword_50BF30[a2], &v700); pGame->GetStru6()->_4A81CA(&a1); pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFF3C1Eu, 0x40u); a2 = v165 + 1; } - while ( v165 + 1 < (signed int)v726 ); - } - goto LABEL_1056; + while ( v165 + 1 < (signed int)_v726 ); + } + LODWORD(v727) = 1; + goto play_sound_and_continue; + } case SPELL_AIR_WIZARD_EYE: LODWORD(v733) = 3600 * v2; @@ -4495,10 +4537,9 @@ } while ( v168 < 4 ); - v732 = (int)v733 << 7; - pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case SPELL_AIR_FEATHER_FALL: v170 = v731 - 1; @@ -4530,13 +4571,13 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v83 = 1; - v732 = (int)v733 << 7; - pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); - LODWORD(v727) = v83; + + pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); + LODWORD(v727) = 1; goto play_sound_and_continue; case SPELL_AIR_SPARKS: + { v184 = v731 - 1; if ( v184 ) { @@ -4565,8 +4606,7 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v726 = (Player *)((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360); - v732 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (amount - 1); + auto _v726 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -4587,8 +4627,8 @@ a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(a1.uAttributes) |= 4u; - v188 = (signed int)v726 / -2; - v189 = (signed int)v726 / 2; + v188 = (signed int)_v726 / -2; + v189 = (signed int)_v726 / 2; while ( v188 <= v189 ) { a1.uFacing = v188 + LOWORD(v715.uYawAngle); @@ -4599,9 +4639,12 @@ v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; - v188 += v732; - } - goto LABEL_1056; + v188 += _v726 / (amount - 1); + } + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 16: if ( pParty->uFlags & PARTY_FLAGS_1_FALLING) { @@ -4617,7 +4660,8 @@ while ( v191 < 4 ); BYTE1(pParty->uFlags) |= 1u; pParty->uFallSpeed = 1000; - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case SPELL_AIR_INVISIBILITY: v192 = v731 - 1; @@ -4653,7 +4697,8 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[638], 2); // There are hostile creatures nearby! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( pPlayer->CanCastSpell(uRequiredMana) ) { @@ -4661,15 +4706,14 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v83 = 1; - v732 = (int)v733 << 7; pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, 0, 0); - LODWORD(v727) = v83; + LODWORD(v727) = 1; } goto play_sound_and_continue; case 21: + { if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2); // Can not cast Fly indoors! @@ -4695,18 +4739,20 @@ v207 = v3->uPlayerID + 1; v716 = v206; - v732 = (int)v733 << 7; - pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, v206, v207); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } case 22: + { //v67 = 2; if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[495], 2); // Can't cast Starburst indoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -4730,7 +4776,6 @@ v713 = pParty->vPosition.y + v214; v208 = LODWORD(v725); } - v726 = (Player *)v211; HIDWORD(v733) = 0; *(float *)&v732 = (double)v211; LODWORD(v725) = v211 + 2500; @@ -4742,24 +4787,23 @@ { v215 = rand(); v216 = (double)v721; - v727 = v216; v217 = (double)SHIDWORD(v733); *(float *)&uRequiredMana = v217; _this = (ItemGen *)(v215 % 1000); *((float *)&v733 + 1) = (double)(v215 % 1000) + *(float *)&v732 - *(float *)&y; *(float *)&v721 = v217 * v217; - *(float *)&v726 = v216 * v216; - if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + *(float *)&v726 + *(float *)&v721) <= 1.0 ) + //*(float *)&v726 = v216 * v216; + if ( sqrt(*((float *)&v733 + 1) * *((float *)&v733 + 1) + v216 * v216 + *(float *)&v721) <= 1.0 ) { LODWORD(v685) = 0; HIDWORD(v685) = 0; } else { - v684 = (signed __int64)sqrt(*(float *)&v726 + *(float *)&v721); + v684 = (signed __int64)sqrt(v216 * v216 + *(float *)&v721); v685 = __PAIR__( stru_5C6E00->Atan2(v684, (signed __int64)*((float *)&v733 + 1)), - stru_5C6E00->Atan2((signed __int64)v727, (signed __int64)*(float *)&uRequiredMana)); + stru_5C6E00->Atan2((signed __int64)v216, (signed __int64)*(float *)&uRequiredMana)); } a1.stru_24.Reset(); a1.spell_id = v3->spellnum; @@ -4772,8 +4816,9 @@ a1.uSectorID = 0; a1.vPosition.z = (int)((char *)_this + LODWORD(v725)); a1.uSpriteFrameID = 0; - a1.spell_caster_pid = 8 * v3->uPlayerID | OBJECT_Player; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.spell_target_pid = v730; + __debugbreak(); a1.field_60_distance_related_prolly_lod = stru_50C198._427546((int)&_this[69].uNumCharges); a1.uFacing = v685; a1.uSoundID = LOWORD(v3->sound_id); @@ -4792,7 +4837,10 @@ HIDWORD(v733) = (unsigned __int64)(v218 % 1024) - 512; } while ( !v14 ); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 23: v219 = v731 - 2; if ( v219 ) @@ -4871,21 +4919,17 @@ a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); a1.uFacing = LOWORD(v715.uYawAngle); a1.uSoundID = LOWORD(v3->sound_id); -LABEL_154: + if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(a1.uAttributes) |= 4u; -LABEL_156: - v669 = v3->uPlayerID + 1; - v36 = v715.uYawAngle; + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - v654 = v715.uPitchAngle; -LABEL_157: - if ( a1.Create(v36, v654, v659, v669) != -1 && pParty->bTurnBasedModeOn == 1 ) + + if ( a1.Create(v715.uYawAngle, v715.uPitchAngle, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; } else { - v732 = SHIDWORD(v733) / (amount - 1); a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -4921,12 +4965,14 @@ v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; - v227 += v732; + v227 += SHIDWORD(v733) / (amount - 1); } while ( v227 <= (signed int)y ); } } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 27: if ( !pPlayers[v3->uPlayerID + 1]->GetMaxMana() ) { @@ -4946,16 +4992,15 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v239 = v3->uPlayerID + 1; - v732 = v229 << 7; - pParty->pPartyBuffs[18].Apply( + + pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply( pParty->uTimePlayed + (signed int)(signed __int64)((double)(v229 << 7) * 0.033333335), v731, amount, v716, - v239); + v3->uPlayerID + 1); if ( v731 == 4 ) - pParty->pPartyBuffs[18].uFlags = 1; + pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags = 1; LODWORD(v727) = 1; goto play_sound_and_continue; @@ -4972,7 +5017,8 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( v731 == 1 || v731 == 2 ) { @@ -5011,10 +5057,14 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); v3->spellnum = 0; - goto LABEL_1165; + v2 = v723; + goto LABEL_1166; } *((int *)v243 + 5) |= 0x40u; - goto LABEL_1055; + dword_50C9A8 = 256; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 30: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -5022,7 +5072,6 @@ HIDWORD(v733) = 10 * v2; v730 = 1; v244 = (char *)&pParty->pPlayers[v3->uPlayerID_2]; - v726 = &pParty->pPlayers[v3->uPlayerID_2]; if ( v731 == 1 ) { v245 = (int)&v244[36 * a2 + 532]; @@ -5080,7 +5129,10 @@ *(int *)(v245 + 8) = v256 + v254 % (v255 - v256 + 1); LABEL_612: _this->uItemID |= 0x20u; - goto LABEL_1055; + + dword_50C9A8 = 256; + LODWORD(v727) = 1; + goto play_sound_and_continue; } goto LABEL_615; } @@ -5107,7 +5159,8 @@ v317 = pGlobalTXT_LocalizationStrings[585]; ShowStatusBarString(v317, 2u); pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - v318 = v726; + __debugbreak(); // decompilation error; most probably v318 is the caster, filled in case 54 + //v318 = v726; v3->spellnum = 0; v318->PlaySound(SPEECH_43, 0); } @@ -5216,6 +5269,7 @@ } else { + __debugbreak(); // v726 is most probably the caster, filled in case 54 if ( v731 != 4 || (v245 = (int)&v726->pInventoryItems[a2], v246 = *(int *)v245, *(int *)v245 > 134) || v726->pInventoryItems[a2].uSpecEnchantmentType != 0 @@ -5343,7 +5397,8 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } v292 = *(char *)(LODWORD(v725) + 28); if ( !(v292 == 3 | v292 == 4 | v292 == 5 | v292 == 6 | v292 == 7 | v292 == 8 | v292 == 9 | v292 == 10 | v292 == 11) ) @@ -5357,7 +5412,8 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( rand() % 100 >= 80 ) { @@ -5428,7 +5484,10 @@ + rand() % 10;//(pItemsTable->field_116D8[19] - pItemsTable->field_116D8[18] + 1); } v294->uAttributes |= 0x20u; - goto LABEL_1055; + dword_50C9A8 = 256; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case SPELL_WATER_TOWN_PORTAL: amount = 10 * v2; if ( pPlayer->sMana < (signed int)uRequiredMana ) @@ -5437,18 +5496,21 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } town_portal_caster_id = LOBYTE(v3->uPlayerID); pMessageQueue_50CBD0->AddMessage(UIMSG_OnCastTownPortal, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case 33: LODWORD(v733) = 604800 * v2; if ( !_strcmpi(pCurrentMapName, "d05.blv") ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } v319 = uRequiredMana; if ( pPlayer->sMana >= (signed int)uRequiredMana ) @@ -5487,13 +5549,22 @@ v323 = v3->uPlayerID_2; v324 = (char *)&pParty->pPlayers[v323].pConditions[15]; if ( !pParty->pPlayers[v323].pConditions[15] ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } if ( v731 == 4 ) - goto LABEL_637; + { + *(int *)v324 = 0; + *((int *)v324 + 1) = 0; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } v732 = amount << 7; v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); v656 = 15; goto LABEL_640; + case 41: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -5511,25 +5582,27 @@ pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); a1.uSpriteFrameID = 0; - v326 = 8 * v3->uPlayerID; - LOBYTE(v326) = v326 | OBJECT_Player; - a1.spell_caster_pid = v326; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.spell_target_pid = a2; a1.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); a1.uFacing = LOWORD(pParty->sRotationY); a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(a1.uAttributes) |= 4u; - v669 = v3->uPlayerID + 1; + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - v654 = pParty->sRotationX; - goto LABEL_125; + if ( a1.Create(pParty->sRotationY, pParty->sRotationX, v659, v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 43: if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -5552,14 +5625,12 @@ a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) a1.uAttributes = 4; - v669 = 0; + v659 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - v35 = (signed int)stru_5C6E00->uIntegerHalfPi / 2; -LABEL_124: - v654 = v35; -LABEL_125: - v36 = pParty->sRotationY; - goto LABEL_157; + if ( a1.Create(pParty->sRotationY, stru_5C6E00->uIntegerHalfPi / 2, v659, 0) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->field_1C; + LODWORD(v727) = 1; + goto play_sound_and_continue; case SPELL_SPIRIT_DETECT_LIFE: v328 = v731 - 2; @@ -5582,13 +5653,9 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v83 = 1; - - v732 = (int)v733 << 7; pParty->pPartyBuffs[PARTY_BUFF_DETECT_LIFE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); - LODWORD(v727) = v83; - + LODWORD(v727) = 1; goto play_sound_and_continue; case SPELL_SPIRIT_FATE: @@ -5625,9 +5692,10 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, v731, amount, 0, 0); - goto LABEL_1056; - } - if ( (v342 & 7) == OBJECT_Actor) + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + if (PID_TYPE(v342) == OBJECT_Actor) { v343 = v342 >> 3; HIDWORD(v344) = 0 + ((pParty->uTimePlayed + 1280) >> 32); @@ -5639,7 +5707,8 @@ LABEL_165: pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(v661, v672); } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case 49: v348 = v731 - 2; @@ -5666,21 +5735,29 @@ goto play_sound_and_continue; v351 = &pParty->pPlayers[v3->uPlayerID_2]; if ( !v351->pConditions[0] ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } if ( v731 == 4 ) { LODWORD(v351->pConditions[0]) = 0; HIDWORD(v351->pConditions[0]) = 0; - goto LABEL_904; - } - v732 = amount << 7; - v351->DiscardConditionIfLastsLongerThan( - 0, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - if ( HIDWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) | LODWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) ) - goto LABEL_1056; - v674 = v3->uPlayerID_2; - goto LABEL_685; + } + else + { + v732 = amount << 7; + v351->DiscardConditionIfLastsLongerThan(0, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + if ( HIDWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) | LODWORD(pParty->pPlayers[v3->uPlayerID_2].pConditions[0]) ) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + } + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); + LODWORD(v727) = 1; + goto play_sound_and_continue; + case SPELL_SPIRIT_PRESERVATION: v354 = v731 - 2; if ( v354 && (v355 = v354 - 1) != 0 && v355 == 1 ) @@ -5694,13 +5771,11 @@ { pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - v732 = (int)v733 << 7; - pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; } a2 = 0; - v732 = (int)v733 << 7; v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); v357 = pParty->pPlayers;//[0].pPlayerBuffs[11]; do @@ -5711,8 +5786,11 @@ ++v357;// = (SpellBuff *)((char *)v357 + 6972); } while ( v357 <= &pParty->pPlayers[3] ); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 48: + { v364 = v731 - 2; if ( !v364 || (v365 = v364 - 1) != 0 && v365 != 1 ) v366 = 60 * (v2 + 3); @@ -5721,7 +5799,7 @@ LODWORD(v733) = v366; if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v726 = (Player *)sub_46A6AC((int)dword_50BF30, 100, 4096); + auto _v726 = sub_46A6AC((int)dword_50BF30, 100, 4096); pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFFu, 0xC0u); ++a1.uType; a1.stru_24.Reset(); @@ -5736,26 +5814,26 @@ a1.uFacing = 0; a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.uSoundID = LOWORD(v3->sound_id); - for ( a2 = 0; a2 < (signed int)v726; ++a2 ) + for ( a2 = 0; a2 < (signed int)_v726; ++a2 ) { v369 = &pActors[dword_50BF30[a2]]; if ( MonsterStats::BelongsToSupertype(v369->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) { a1.vPosition.x = v369->vPosition.x; a1.vPosition.y = v369->vPosition.y; - v732 = v369->uActorHeight; - a1.vPosition.z = v369->vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - v370 = 8 * dword_50BF30[a2]; - LOBYTE(v370) = v370 | OBJECT_Actor; - a1.spell_target_pid = v370; + a1.vPosition.z = v369->vPosition.z - (unsigned int)(signed __int64)((double)v369->uActorHeight * unk_4D8548); + + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); a1.Create(0, 0, 0, 0); - v732 = (int)v733 << 7; v369->pActorBuffs[4].Apply( pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); } } - goto LABEL_1056; + LODWORD(v727) = 1; + } + goto play_sound_and_continue; + case 53: v371 = v731 - 2; if ( v371 && (v372 = v371 - 1) != 0 && v372 == 1 ) @@ -5767,7 +5845,10 @@ pOtherOverlayList->_4418B1(5080, v3->uPlayerID_2 + 100, 0, 65536); v373 = v3->uPlayerID_2; if ( !(HIDWORD(pParty->pPlayers[v373].pConditions[14]) | LODWORD(pParty->pPlayers[v373].pConditions[14])) ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } v14 = v731 == 4; pParty->pPlayers[v373].sHealth = 1; if ( v14 ) @@ -5781,7 +5862,6 @@ } else { - v732 = amount << 7; *(float *)&a2 = (double)(amount << 7) * 0.033333335; pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xEu, @@ -5827,17 +5907,15 @@ { do { - v385 = 4 * v682[HIDWORD(v733)] + 10965188; - pPlayers[v682[HIDWORD(v733)]]->sHealth = v732; - v726 = *(Player **)v385; - v386 = v726->GetMaxHealth(); - if ( v726->sHealth > v386 ) - *(int *)(*(int *)v385 + 6460) = v726->GetMaxHealth(); - v387 = *(Player **)v385; - if ( v387->sHealth > 0 ) + //v385 = (ItemGen **)&pPlayers[v682[HIDWORD(v733)]]; + v726 = pPlayers[v682[HIDWORD(v733)]]; + v726->sHealth = v732; + //v386 = v726->GetMaxHealth(); + if ( v726->sHealth > v726->GetMaxHealth()) + v726->sHealth = v726->GetMaxHealth(); + if ( v726->sHealth > 0 ) { - LODWORD(v387->pConditions[13]) = 0; - HIDWORD(v387->pConditions[13]) = 0; + v726->pConditions[Player::Condition_Unconcious] = 0; } v388 = HIDWORD(v733); @@ -5846,7 +5924,8 @@ } while ( v388 + 1 < v730 ); } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case 55: v392 = v731 - 1; @@ -5894,30 +5973,21 @@ } else { - v732 = amount << 7; *(float *)&a2 = (double)(amount << 7) * 0.033333335; - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( - 0x10u, + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0x10u, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( - 0xEu, + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xEu, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( - 0xDu, + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xDu, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - *(float *)&a2)); } - v83 = 1; pParty->pPlayers[v3->uPlayerID_2].SetCondition(1u, 1); pParty->pPlayers[v3->uPlayerID_2].sHealth = 1; pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); } - else - { - v83 = 1; - } - LODWORD(v727) = v83; + LODWORD(v727) = 1; goto play_sound_and_continue; case 61: @@ -5948,13 +6018,22 @@ v323 = v3->uPlayerID_2; v324 = (char *)&pParty->pPlayers[v323].pConditions[12]; if ( !pParty->pPlayers[v323].pConditions[12] ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } if ( v731 == 4 ) - goto LABEL_637; - v732 = amount << 7; + { + *(int *)v324 = 0; + *((int *)v324 + 1) = 0; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); v656 = 12; goto LABEL_640; + + case 56: v411 = v731 - 2; if ( v411 ) @@ -5987,19 +6066,30 @@ v323 = v3->uPlayerID_2; v324 = (char *)&pParty->pPlayers[v323].pConditions[3]; if ( !pParty->pPlayers[v323].pConditions[3] ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } if ( v731 == 4 ) - goto LABEL_637; - v732 = amount << 7; + { + *(int *)v324 = 0; + *((int *)v324 + 1) = 0; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); v656 = 3; goto LABEL_640; + case 59: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - if ( a2 == 0 || (a2 & 7) != OBJECT_Actor) - goto LABEL_1056; - v417 = (int)&pActors[a2 >> 3]; + if (PID_TYPE(a2) != OBJECT_Actor) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + v417 = (int)&pActors[PID_ID(a2)]; v730 = v417; if ( !(*(char *)(v417 + 38) & 0x80) ) { @@ -6088,15 +6178,17 @@ amount = v425; if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v426 = a2 >> 3; - if ( (a2 & 7) != OBJECT_Actor) - goto LABEL_1056; + v426 = PID_ID(a2); + if (PID_TYPE(a2) != OBJECT_Actor) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } v730 = 836 * v426; if ( stru_50C198.GetMagicalResistance(&pActors[v426], 7u) ) { pActors[v426].pActorBuffs[1].Reset(); pActors[v426].pActorBuffs[12].Reset(); - v732 = amount << 7; pActors[v426].pActorBuffs[9].Apply( pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), v731, 0, 0, 0); @@ -6109,23 +6201,25 @@ v60 = pObjectList->ObjectIDByItemID(a1.uType); v61 = v426; goto LABEL_1086; + + case 66: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; amount = 600 * v2; - v427 = a2 >> 3; - if ( (a2 & 7) != OBJECT_Actor) - goto LABEL_1056; - v730 = 836 * v427; - if ( MonsterStats::BelongsToSupertype(pActors[v427].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) - goto play_sound_and_continue; - if ( stru_50C198.GetMagicalResistance(&pActors[v427], 7u) ) - { - pActors[v427].pActorBuffs[9].Reset(); - pActors[v427].pActorBuffs[1].Reset(); - v732 = amount << 7; - pActors[v427].pActorBuffs[12].Apply( - pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), + if (PID_TYPE(a2) != OBJECT_Actor) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + v730 = 836 * PID_ID(a2); + if ( MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) + goto play_sound_and_continue; + if ( stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 7u) ) + { + pActors[PID_ID(a2)].pActorBuffs[9].Reset(); + pActors[PID_ID(a2)].pActorBuffs[1].Reset(); + pActors[PID_ID(a2)].pActorBuffs[12].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), v731, 0, 0, 0); } a1.stru_24.Reset(); @@ -6133,9 +6227,11 @@ a1.spell_level = v2; a1.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(a1.uType); - v61 = v427; + v61 = PID_ID(a2); goto LABEL_1086; + case 63: + { v428 = v731 - 2; if ( v428 && (v429 = v428 - 1) != 0 && v429 == 1 ) v430 = 300 * v2; @@ -6144,7 +6240,7 @@ amount = v430; if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v726 = (Player *)sub_46A6AC((int)dword_50BF30, 100, 4096); + auto _v726 = sub_46A6AC((int)dword_50BF30, 100, 4096); pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0Au, 0xC0u); ++a1.uType; a1.stru_24.Reset(); @@ -6159,28 +6255,27 @@ a1.uFacing = 0; a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.uSoundID = LOWORD(v3->sound_id); - for ( a2 = 0; a2 < (signed int)v726; ++a2 ) + for ( a2 = 0; a2 < (signed int)_v726; ++a2 ) { v433 = &pActors[dword_50BF30[a2]]; if ( MonsterStats::BelongsToSupertype(v433->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) break; a1.vPosition.x = v433->vPosition.x; a1.vPosition.y = v433->vPosition.y; - v732 = v433->uActorHeight; - a1.vPosition.z = v433->vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - v434 = 8 * dword_50BF30[a2]; - LOBYTE(v434) = v434 | OBJECT_Actor; - a1.spell_target_pid = v434; + a1.vPosition.z = v433->vPosition.z - (unsigned int)(signed __int64)((double)v433->uActorHeight * unk_4D8548); + + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); a1.Create(0, 0, 0, 0); if ( stru_50C198.GetMagicalResistance(v433, 7u) ) { - v732 = amount << 7; - v433->pActorBuffs[4].Apply( - pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), + v433->pActorBuffs[4].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), v731, 0, 0, 0); } } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 64: v435 = v731 - 2; if ( v435 && (v436 = v435 - 1) != 0 && v436 == 1 ) @@ -6204,16 +6299,16 @@ } else { - v732 = amount << 7; - pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( - 5u, + pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan(5u, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); } v377 = &pParty->pPlayers[v3->uPlayerID_2]; LABEL_720: v377->SetCondition(1, 0); } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 42: v442 = v731 - 2; if ( !v442 ) @@ -6234,8 +6329,8 @@ amount = v444; if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v445 = a2 >> 3; - if ( (a2 & 7) == OBJECT_Item) + v445 = PID_ID(a2); + if (PID_TYPE(a2) == OBJECT_Item) { v449 = (char *)&pSpriteObjects[v445].stru_24; v450 = *(int *)v449; @@ -6246,7 +6341,7 @@ } else { - sprintfex(pTmpBuf2, (char*)pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v450].pUnidentifiedName); + sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v450].pUnidentifiedName); ShowStatusBarString(pTmpBuf2, 2u); if ( !pParty->AddItem(&pSpriteObjects[v445].stru_24) ) pParty->SetHoldingItem(&pSpriteObjects[v445].stru_24); @@ -6255,23 +6350,29 @@ } else { - if ( (a2 & 7) == OBJECT_Actor) + if (PID_TYPE(a2) == OBJECT_Actor) { stru_50C198.LootActor(&pActors[v445]); } else { - if ( (a2 & 7) != OBJECT_Decoration) + if (PID_TYPE(a2) != OBJECT_Decoration) { - if ( (a2 & 7) != OBJECT_BModel) - goto LABEL_1056; + if (PID_TYPE(a2) != OBJECT_BModel) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } dword_507CD8 = 1; v677 = 1; if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) v446 = pIndoor->pFaceExtras[pIndoor->pFaces[v445].uFaceExtraID].uEventID; else v446 = pOutdoor->pBModels[a2 >> 9].pFaces[v445 & 0x3F].sCogTriggeredID; - goto LABEL_866; + + EventProcessor(v446, a2, v677); + LODWORD(v727) = 1; + goto play_sound_and_continue; } v447 = &pLevelDecorations[v445]; dword_507CD8 = 1; @@ -6280,9 +6381,9 @@ { v677 = 1; v446 = v448; -LABEL_866: EventProcessor(v446, a2, v677); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; } if ( v447->IsInteractive() ) { @@ -6292,7 +6393,9 @@ } } } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 67: v451 = v731 - 2; if ( v451 ) @@ -6325,20 +6428,23 @@ v323 = v3->uPlayerID_2; v324 = (char *)&pParty->pPlayers[v323].pConditions[1]; if ( !pParty->pPlayers[v323].pConditions[1] ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } if ( v731 == 4 ) { -LABEL_637: *(int *)v324 = 0; *((int *)v324 + 1) = 0; - goto LABEL_1056; - } - v732 = amount << 7; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); v656 = 1; LABEL_640: v325 = &pParty->pPlayers[v323]; goto LABEL_641; + case 68: v457 = v731 - 2; if ( v457 ) @@ -6367,16 +6473,13 @@ if (!v460) { pParty->pPlayers[v3->uPlayerID_2].Heal(amount); -LABEL_904: - v674 = v3->uPlayerID_2; -LABEL_685: - pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v674); + pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); } else { - if ( (v460 & 7) == OBJECT_Actor) + if (PID_TYPE(v460) == OBJECT_Actor) { - v461 = &pActors[v460 >> 3]; + v461 = &pActors[PID_ID(v460)]; v462 = v461->uAIState; v463 = v461->pMonsterInfo.uHP; if ( v462 != 5 ) @@ -6396,7 +6499,9 @@ } } } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 72: v464 = v731 - 2; if ( !v464 ) @@ -6426,7 +6531,10 @@ if ( !(HIDWORD(pParty->pPlayers[v470].pConditions[6]) | LODWORD(pParty->pPlayers[v470].pConditions[6])) && !(HIDWORD(pParty->pPlayers[v470].pConditions[8]) | LODWORD(pParty->pPlayers[v470].pConditions[8])) && !(HIDWORD(pParty->pPlayers[v470].pConditions[10]) | LODWORD(pParty->pPlayers[v470].pConditions[10])) ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } if ( v731 == 4 ) { LODWORD(pParty->pPlayers[v470].pConditions[6]) = 0; @@ -6437,9 +6545,9 @@ v472 = v3->uPlayerID_2; LODWORD(pParty->pPlayers[v472].pConditions[10]) = 0; HIDWORD(pParty->pPlayers[v472].pConditions[10]) = 0; - goto LABEL_1056; - } - v732 = amount << 7; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } *(float *)&a2 = (double)(amount << 7) * 0.033333335; pParty->pPlayers[v470].DiscardConditionIfLastsLongerThan( 6u, @@ -6463,10 +6571,9 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v732 = (int)v733 << 7; - pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case 73: LODWORD(v733) = 3600 * v2; @@ -6486,15 +6593,15 @@ pParty->pPlayers[2].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, 0); pParty->pPlayers[3].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4, v2, v2, 0); - goto LABEL_1056; - //goto LABEL_104; + LODWORD(v727) = 1; + goto play_sound_and_continue; } pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - v732 = (int)v733 << 7; - pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, v2, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 74: v493 = v731 - 2; if ( v493 && (v494 = v493 - 1) != 0 && v494 == 1 ) @@ -6509,7 +6616,10 @@ if ( !(HIDWORD(pParty->pPlayers[v498].pConditions[7]) | LODWORD(pParty->pPlayers[v498].pConditions[7])) && !(HIDWORD(pParty->pPlayers[v498].pConditions[9]) | LODWORD(pParty->pPlayers[v498].pConditions[9])) && !(HIDWORD(pParty->pPlayers[v498].pConditions[11]) | LODWORD(pParty->pPlayers[v498].pConditions[11])) ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } if ( v731 == 4 ) { LODWORD(pParty->pPlayers[v498].pConditions[7]) = 0; @@ -6523,7 +6633,6 @@ } else { - v732 = amount << 7; *(float *)&a2 = (double)(amount << 7) * 0.033333335; pParty->pPlayers[v498].DiscardConditionIfLastsLongerThan( 7u, @@ -6538,7 +6647,9 @@ LABEL_641: v325->DiscardConditionIfLastsLongerThan(v656, v663); } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 77: { amount = 5 * v2 + 10; @@ -6554,7 +6665,8 @@ ++v1; } while ( (signed int)v501 < (signed int)pParty->pHirelings ); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; } case 80: sRecoveryTime -= v2; @@ -6565,9 +6677,9 @@ v505 = sub_46A6AC((int)dword_50BF30, 100, 4096); ++a1.uType; HIDWORD(v733) = v505; - v690 = 0; - v689 = 0; - v688 = 0; + v688.x = 0; + v688.y = 0; + v688.z = 0; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -6588,14 +6700,11 @@ v507 = dword_50BF30[a2]; a1.vPosition.x = pActors[v507].vPosition.x; a1.vPosition.y = pActors[v507].vPosition.y; - v732 = pActors[v507].uActorHeight; - a1.vPosition.z = pActors[v507].vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - v508 = 8 * dword_50BF30[a2]; - LOBYTE(v508) = v508 | OBJECT_Actor; - a1.spell_target_pid = v508; + a1.vPosition.z = pActors[v507].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v507].uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); v509 = a1.Create(0, 0, 0, 0); v510 = a2; - DamageMonsterFromParty(8 * v509 | OBJECT_Item, dword_50BF30[a2], (Vec3_int_ *)&v688); + DamageMonsterFromParty(PID(OBJECT_Item, v509), dword_50BF30[a2], (Vec3_int_ *)&v688); a2 = v510 + 1; } while ( v510 + 1 < SHIDWORD(v733) ); @@ -6605,23 +6714,19 @@ v511 = &pActors[dword_50BF30[a2]]; a1.vPosition.x = v511->vPosition.x; a1.vPosition.y = v511->vPosition.y; - v732 = v511->uActorHeight; - a1.vPosition.z = v511->vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - v512 = 8 * dword_50BF30[a2]; - LOBYTE(v512) = v512 | OBJECT_Actor; - a1.spell_target_pid = v512; + a1.vPosition.z = v511->vPosition.z - (unsigned int)(signed __int64)((double)v511->uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); a1.Create(0, 0, 0, 0); v513 = v511->pActorBuffs; - v726 = (Player *)22; - do + for (int _v726 = 22; _v726 != 0; --_v726) { v513->Reset(); ++v513; - v726 = (Player *)((char *)v726 - 1); } - while ( *(float *)&v726 != 0.0 ); - } - goto LABEL_1056; + } + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 82: v514 = v731 - 2; if ( !v514 ) @@ -6647,32 +6752,34 @@ amount = 3; } v733 = __PAIR__(0, v516); - v517 = 8 * v3->uPlayerID; - LOBYTE(v517) = v517 | 4; + if ( (signed int)uNumActors > 0 ) { v518 = pActors;//[0].uAIState; - v726b = uNumActors; + auto _v726 = uNumActors; do { v519 = v518->uAIState; - if ( v518->uAIState != 5 && v519 != 11 && v519 != 19 && v517 == v518->uSummonerID ) + if ( v518->uAIState != 5 && v519 != 11 && v519 != 19 && PID(OBJECT_Player, v3->uPlayerID) == v518->uSummonerID ) ++HIDWORD(v733); ++v518; - --v726; + --_v726; } - while ( v726 != 0 ); + while ( _v726 != 0 ); } if ( SHIDWORD(v733) >= amount ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[648], 2); // This character can't summon any more monsters! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; sub_44FA4C_spawn_light_elemental(v3->uPlayerID, v731, v733); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 83: v520 = v731 - 2; if ( !v520 ) @@ -6705,13 +6812,9 @@ pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 1); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 2); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, 3); - v83 = 1; - - v732 = (int)v733 << 7; pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, 0, 0); - LODWORD(v727) = v83; - + LODWORD(v727) = 1; goto play_sound_and_continue; case 84: @@ -6720,16 +6823,16 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[497], 2); // Can't cast Prismatic Light outdoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; v531 = sub_46A6AC((int)dword_50BF30, 100, 4096); ++a1.uType; - v726 = (Player *)v531; - v696 = 0; - v695 = 0; - v694 = 0; + v694.x = 0; + v694.y = 0; + v694.z = 0; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -6743,30 +6846,29 @@ a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.uSoundID = LOWORD(v3->sound_id); a2 = 0; - if ( (signed int)v726 > 0 ) + if ( (signed int)v531 > 0 ) { do { v533 = dword_50BF30[a2]; a1.vPosition.x = pActors[v533].vPosition.x; a1.vPosition.y = pActors[v533].vPosition.y; - v732 = pActors[v533].uActorHeight; - a1.vPosition.z = pActors[v533].vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - v534 = 8 * dword_50BF30[a2]; - LOBYTE(v534) = v534 | OBJECT_Actor; - a1.spell_target_pid = v534; + a1.vPosition.z = pActors[v533].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v533].uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); v535 = a1.Create(0, 0, 0, 0); v536 = a2; - DamageMonsterFromParty(8 * v535 | OBJECT_Item, dword_50BF30[a2], (Vec3_int_ *)&v694); + DamageMonsterFromParty(PID(OBJECT_Item, v535), dword_50BF30[a2], &v694); a2 = v536 + 1; } - while ( v536 + 1 < (signed int)v726 ); + while ( v536 + 1 < (signed int)v531 ); } v537 = pGame->GetStru6(); pGame->GetStru6()->_4A8BFC(); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case SPELL_LIGHT_DAY_OF_PROTECTION: + { v538 = v731 - 2; if ( v538 && (v539 = v538 - 1) != 0 && v539 == 1 ) { @@ -6805,8 +6907,12 @@ v550, 0, 0); pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v731, v550, 0, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 86: + { v551 = v731 - 2; if ( !v551 ) goto LABEL_998; @@ -6834,7 +6940,7 @@ y = (char *)(60 * (v2 * HIDWORD(v733) + 60)); v732 = (300 * amount * v2 + 60) << 7; v730 = v2 + 5; - v726 = 0; + int _v726 = 0; v553 = pParty->pPlayers;//[0].pConditions[1]; *((float *)&v733 + 1) = (double)v732 * 0.033333335; do @@ -6847,7 +6953,7 @@ //((SpellBuff *)(v553 + 6056))->Apply( v553->pPlayerBuffs[4].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v731, v730, 0, 0); if ( *(_QWORD *)v553 ) - v726 = (Player *)1; + _v726 = 1; ++v553; } while ( v553 <= &pParty->pPlayers[3] ); @@ -6855,18 +6961,23 @@ pParty->pPartyBuffs[PARTY_BUFF_HEROISM].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v731, v730, 0, 0); pParty->pPartyBuffs[PARTY_BUFF_SHIELD].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v562, 0, 0, 0); pParty->pPartyBuffs[PARTY_BUFF_STONE_SKIN].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733 + 1)), v562, v730, 0, 0); - if (v726) - goto LABEL_1056; - v732 = (int)y << 7; - pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply((signed __int64)((double)(signed int)((int)y << 7) * 0.033333335 + (double)(signed __int64)pParty->uTimePlayed), v562, v730, 0, 0); - goto LABEL_1056; + if (!_v726) + { + pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply((signed __int64)((double)(signed int)((int)y << 7) * 0.033333335 + (double)(signed __int64)pParty->uTimePlayed), v562, v730, 0, 0); + } + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + + case 88: amount = 3; if ( pPlayer->uNumDivineInterventionCastsThisDay >= 3u ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -6901,7 +7012,9 @@ *(short *)v572 = pPlayer->sAgeModifier + 10; sRecoveryTime += -5 * v2; ++v571->uNumDivineInterventionCastsThisDay; - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 89: v573 = v731 - 2; if ( v573 ) @@ -6941,12 +7054,13 @@ goto play_sound_and_continue; } v577 = (Player *)(v576 >> 3); - v726 = v577; + //v726 = v577; if ( v577 == (Player *)-1 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[496], 2); // No valid target exists! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } v578 = (int)&pActors[(int)v577]; v721 = v578; @@ -6954,7 +7068,8 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } ++a1.uType; a1.stru_24.Reset(); @@ -6973,13 +7088,12 @@ a1.vPosition.x = *(short *)(v721 + 142); a1.vPosition.y = *(short *)(v721 + 144); v732 = *(short *)(v721 + 138); - v582 = 8 * (int)v726; a1.vPosition.z = *(short *)(v721 + 146) - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - a1.spell_target_pid = PID(OBJECT_Actor, (int)v726); + a1.spell_target_pid = PID(OBJECT_Actor, (int)v577); a1.Create(0, 0, 0, 0); if ( *(char *)(v581 + 52) > amount ) goto play_sound_and_continue; - Actor::Resurrect((unsigned int)v726); + Actor::Resurrect((unsigned int)v577); *(char *)(v581 + 61) = 0; *(char *)(v581 + 53) = 0; *(char *)(v581 + 54) = 0; @@ -6994,7 +7108,9 @@ ((SpellBuff *)(v581 + 404))->Reset(); if ( *(short *)(v581 + 40) > 10 * amount ) *(short *)(v581 + 40) = 10 * amount; - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 91: v588 = v731 - 1; amount = 16; @@ -7009,6 +7125,7 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; + __debugbreak(); HIDWORD(v733) = (int)(char *)&pParty + 6972 * v3->uPlayerID_2 + 36 * a2 + 3040; v732 = (signed int)&pItemsTable->pItems[*(int *)HIDWORD(v733)].pIconName; ((ItemGen *)HIDWORD(v733))->UpdateTempBonus(pParty->uTimePlayed); @@ -7025,7 +7142,8 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } v592 = HIDWORD(v733); v14 = v731 == 4; @@ -7033,13 +7151,16 @@ if ( !v14 ) { v732 = (int)v733 << 7; - *(_QWORD *)(v592 + 28) = pParty->uTimePlayed - + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); + *(_QWORD *)(v592 + 28) = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); *(int *)(v592 + 20) |= 8u; } *(char *)(v592 + 20) |= 0x80u; - goto LABEL_1055; + dword_50C9A8 = 256; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 93: + { v593 = v731 - 2; if ( !v593 ) goto LABEL_1062; @@ -7058,8 +7179,7 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v726 = (Player *)((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360); - v732 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (amount - 1); + auto _v726 = ((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360); a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -7080,9 +7200,9 @@ a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(a1.uAttributes) |= 4u; - v596 = (signed int)v726 / -2; - y = (char *)((signed int)v726 / 2); - if ( (signed int)v726 / -2 <= (signed int)v726 / 2 ) + v596 = (signed int)_v726 / -2; + y = (char *)((signed int)_v726 / 2); + if ( (signed int)_v726 / -2 <= (signed int)_v726 / 2 ) { v597 = v715.uYawAngle; do @@ -7095,11 +7215,14 @@ v3->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; - v596 += v732; + v596 += _v726 / (amount - 1); } while ( v596 <= (signed int)y ); } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 94: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -7118,30 +7241,31 @@ if ( v731 == 4 ) LODWORD(v733) = 29030400; LABEL_1082: - v599 = a2 >> 3; - if ( (a2 & 7) != OBJECT_Actor) - goto LABEL_1056; - v730 = 836 * v599; - if ( !MonsterStats::BelongsToSupertype(pActors[v599].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) - goto play_sound_and_continue; - if ( !stru_50C198.GetMagicalResistance(&pActors[v599], 0xAu) ) + if (PID_TYPE(a2) != OBJECT_Actor) + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + v730 = 836 * PID_ID(a2); + if ( !MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) + goto play_sound_and_continue; + if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 0xAu) ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; - } - pActors[v599].pActorBuffs[9].Reset(); - pActors[v599].pActorBuffs[1].Reset(); - v732 = (int)v733 << 7; - pActors[v599].pActorBuffs[12].Apply( - pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), + v3->spellnum = 0; + goto LABEL_1166; + } + pActors[PID_ID(a2)].pActorBuffs[9].Reset(); + pActors[PID_ID(a2)].pActorBuffs[1].Reset(); + pActors[PID_ID(a2)].pActorBuffs[12].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; a1.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(a1.uType); - v61 = v599; + v61 = PID_ID(a2); LABEL_1086: v600 = pActors[v61].vPosition.y; v601 = pActors[v61].vPosition.x; @@ -7165,7 +7289,9 @@ LOBYTE(a1.uAttributes) |= 0x80u; a1.uSoundID = LOWORD(v3->sound_id); a1.Create(0, 0, 0, v3->uPlayerID + 1); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 96: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -7211,7 +7337,8 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } v610 = 76 * v609; *((int *)&pParty->pPlayers[3].pInstalledBeacons[4].uBeaconTime + 19 * v609) = 0; @@ -7257,13 +7384,11 @@ { pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, v3->uPlayerID_2); - v732 = (int)v733 << 7; - pParty->pPlayers[v3->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v615, v716, 0); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; } a2 = 0; - v732 = (int)v733 << 7; v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); v619 = pParty->pPlayers;//[0].pPlayerBuffs[10]; do @@ -7274,17 +7399,19 @@ ++v619; } while ( v619 <= &pParty->pPlayers[3] ); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 99: + { if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v726 = 0; pGame->GetIndoorCamera(); v623 = (signed __int64)GetPickDepth(); HIDWORD(v733) = sub_46A6AC((int)dword_50BF30, 100, v623); - v709 = 0; - v708 = 0; - v707 = 0; + v707.x = 0; + v707.y = 0; + v707.z = 0; a1.stru_24.Reset(); a1.spell_id = v3->spellnum; a1.spell_level = v2; @@ -7298,22 +7425,21 @@ a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); a1.uSoundID = LOWORD(v3->sound_id); a2 = 0; + int _v726 = 0; if ( SHIDWORD(v733) > 0 ) { - v726 = (Player *)(HIDWORD(v733) * (7 * v2 + 25)); + _v726 = (HIDWORD(v733) * (7 * v2 + 25)); do { v625 = dword_50BF30[a2]; a1.vPosition.x = pActors[v625].vPosition.x; a1.vPosition.y = pActors[v625].vPosition.y; - v732 = pActors[v625].uActorHeight; - a1.vPosition.z = pActors[v625].vPosition.z - (unsigned int)(signed __int64)((double)v732 * unk_4D8548); - v626 = 8 * dword_50BF30[a2]; - LOBYTE(v626) = v626 | OBJECT_Actor; - a1.spell_target_pid = v626; + //v732 = pActors[v625].uActorHeight; + a1.vPosition.z = pActors[v625].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v625].uActorHeight * unk_4D8548); + a1.spell_target_pid = PID(OBJECT_Actor, dword_50BF30[a2]); v627 = a1.Create(0, 0, 0, 0); v628 = a2; - DamageMonsterFromParty(8 * v627 | 2, dword_50BF30[a2], (Vec3_int_ *)&v707); + DamageMonsterFromParty(PID(OBJECT_Item, v627), dword_50BF30[a2], &v707); a2 = v628 + 1; } while ( v628 + 1 < SHIDWORD(v733) ); @@ -7336,19 +7462,20 @@ ++v629; } while ( v629 <= 4 ); - v732 = (signed __int64)((double)(signed int)v726 / (double)v730); + v732 = (signed __int64)((double)(signed int)_v726 / (double)v730); HIDWORD(v733) = 0; if ( v730 > 0 ) { do { - v632 = 4 * v681[HIDWORD(v733)] + 10965188; - v633 = pPlayers[v681[HIDWORD(v733)]]; - v633->sHealth += v732; - v726 = *(Player **)v632; - v634 = v726->GetMaxHealth(); - if ( v726->sHealth > v634 ) - *(int *)(*(int *)v632 + 6460) = v726->GetMaxHealth(); + //v632 = 4 * v681[HIDWORD(v733)] + 10965188; + v726 = pPlayers[v681[HIDWORD(v733)]]; + //v633 = pPlayers[v681[HIDWORD(v733)]]; + v726->sHealth += v732; + //v726 = *(Player **)v632; + //v634 = v726->GetMaxHealth(); + if ( v726->sHealth > v726->GetMaxHealth()) + v726->sHealth = v726->GetMaxHealth(); v635 = HIDWORD(v733); pGame->GetStru6()->SetPlayerBuffAnim(v3->spellnum, WORD2(v733)); @@ -7357,13 +7484,18 @@ while ( v635 + 1 < v730 ); } pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0, 0x40u); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 98: + { if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[499], 2); // Can't cast Armageddon indoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } v640 = v731 - 2; if ( !v640 || (v641 = v640 - 1) == 0 || (amount = 4, v641 != 1) ) @@ -7372,7 +7504,8 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - goto LABEL_203; + v3->spellnum = 0; + goto LABEL_1166; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -7381,7 +7514,7 @@ ++pPlayer->uNumArmageddonCasts; if ( pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; - v726 = (Player *)50; + auto _v726 = 50; do { v642 = rand() % 4096 - 2048; @@ -7391,10 +7524,13 @@ v732 = GetTerrainHeightsAroundParty2(v642 + pParty->vPosition.x, (int)y, (int *)&v710, 0); v644 = rand(); sub_42F7EB_DropItemAt(0xFE6u, v721, (int)y, v732 + 16, v644 % 500 + 500, 1, 0, 0, 0); - v726 = (Player *)((char *)v726 - 1); - } - while ( *(float *)&v726 != 0.0 ); - goto LABEL_1056; + --_v726; + } + while ( _v726 != 0 ); + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + default: goto play_sound_and_continue; } @@ -7411,7 +7547,6 @@ } else { - v732 = amount << 7; v223 = ((Player *)v222)->DiscardConditionIfLastsLongerThan( 2u, pParty->uTimePlayed - (signed int)(signed __int64)((double)(amount << 7) * 0.033333335)); @@ -7423,7 +7558,10 @@ v222 += 6972; HIDWORD(v733) = (int)v222; if ( (signed int)v222 >= (signed int)pParty->pHirelings ) - goto LABEL_1056; + { + LODWORD(v727) = 1; + goto play_sound_and_continue; + } continue; } } @@ -7728,7 +7866,7 @@ a3.z = actor->vPosition.z - pParty->vPosition.z; Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z); - DamageMonsterFromParty((8 * (uActiveCharacter - 1)) | OBJECT_Player, target_id, &a3); + DamageMonsterFromParty(PID(OBJECT_Player, uActiveCharacter - 1), target_id, &a3); if (player->WearsItem(ITEM_ARTIFACT_SPLITTER, 1) || player->WearsItem(ITEM_ARTIFACT_SPLITTER, 0)) _42FA66_do_explosive_impact( actor->vPosition.x, @@ -7856,9 +7994,9 @@ { v22 = *v28; v11 = *v28 & 0xFFFF; - if ( (*(char *)v28 & 7) == OBJECT_Actor) + if (PID_TYPE(v11) == OBJECT_Actor) { - v12 = &pActors[(unsigned int)v11 >> 3]; + v12 = &pActors[PID_ID(v11)]; v13 = v12->uAIState; if ( v13 != 5 ) { @@ -7866,7 +8004,7 @@ && v13 != 11 && v13 != 19 && v13 != 17 - && (!a3 || pActors[(unsigned int)v11 >> 3].GetActorsRelation(0)) ) + && (!a3 || pActors[PID_ID(v11)].GetActorsRelation(0)) ) { if ( (!a4 || MonsterStats::BelongsToSupertype(v12->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD)) && v22 <= pick_depth << 16 ) @@ -8251,9 +8389,9 @@ int v7; // esi@1 char *v8; // ecx@2 unsigned __int16 v9; // ax@5 - int v10; // eax@10 + //int v10; // eax@10 signed int result; // eax@11 - __int16 v12; // ax@12 + //__int16 v12; // ax@12 //SpriteObject a1a; // [sp+Ch] [bp-74h]@1 int v14; // [sp+7Ch] [bp-4h]@1 @@ -8298,9 +8436,7 @@ a1a.uSoundID = 0; if ( a6 >= 1 || a6 <= 4 ) { - v10 = 8 * a6 - 8; - LOBYTE(v10) = v10 | OBJECT_Player; - a1a.spell_caster_pid = v10; + a1a.spell_caster_pid = PID(OBJECT_Player, a6 - 1); } else { @@ -8309,10 +8445,7 @@ result = a1a.Create(0, 0, 0, 0); if ( result != -1 ) { - v12 = 8 * result; - LOBYTE(v12) = v12 | 2; - result = stru_50FE08.Add( - v12, + result = stru_50FE08.Add(PID(OBJECT_Item, result), a5, SLOWORD(a1a.vPosition.x), SLOWORD(a1a.vPosition.y), @@ -8649,8 +8782,7 @@ { v24 = v6->GetAttackRecoveryTime(false); if ( !pParty->bTurnBasedModeOn ) - pPlayers[uActiveCharacter]->SetRecoveryTime( - (signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v24 * 2.133333333333333)); + pPlayers[uActiveCharacter]->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v24 * 2.133333333333333)); pStru277->_427D48(uActiveCharacter); pTurnEngine->_40471C(); } @@ -8662,7 +8794,7 @@ { if (pParty->bTurnBasedModeOn) { - if ( pTurnEngine->field_4 == OBJECT_Actor || (pTurnEngine->pQueue[0].uPackedID & 7) == OBJECT_Player) + if (pTurnEngine->field_4 == OBJECT_Actor || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player) { pParty->bTurnBasedModeOn = 0; pTurnEngine->End(true);
--- a/stru6.cpp Tue Mar 26 20:06:51 2013 +0200 +++ b/stru6.cpp Wed Mar 27 00:27:38 2013 +0200 @@ -17,6 +17,8 @@ #include "Overlays.h" #include "stru160.h" +#include "MM7.h" + @@ -831,8 +833,8 @@ if (pRenderer->pRenderD3D) { result = a2->spell_caster_pid & 7; - if ((a2->spell_caster_pid & 7) != OBJECT_Actor && - (a2->spell_caster_pid & 7) != OBJECT_Item) + if (PID_TYPE(a2->spell_caster_pid) != OBJECT_Actor && + PID_TYPE(a2->spell_caster_pid) != OBJECT_Item) { if (field_204 != 4) {