Mercurial > mm7
diff mm7_6.cpp @ 838:d061180f2b42
Merge
author | Gloval |
---|---|
date | Thu, 28 Mar 2013 00:37:58 +0400 |
parents | dfd683c4f538 |
children | ceef50611567 710cf848ad24 |
line wrap: on
line diff
--- a/mm7_6.cpp Thu Mar 28 00:37:27 2013 +0400 +++ b/mm7_6.cpp Thu Mar 28 00:37:58 2013 +0400 @@ -4,7 +4,6 @@ #include "Game.h" #include "GUIWindow.h" #include "GUIFont.h" -#include "GUIButton.h" #include "GUIProgressBar.h" #include "Party.h" #include "AudioPlayer.h" @@ -2094,19 +2093,19 @@ unsigned int v14; // eax@23 //stru277 *v15; // esi@27 //stru277 *v16; // eax@28 - GUIWindow *v17; // eax@43 - GUIWindow *v18; // [sp-30h] [bp-48h]@44 - unsigned int v19; // [sp-2Ch] [bp-44h]@44 - unsigned int v20; // [sp-28h] [bp-40h]@44 - unsigned int v21; // [sp-24h] [bp-3Ch]@44 - unsigned int v22; // [sp-20h] [bp-38h]@44 - int v23; // [sp-1Ch] [bp-34h]@44 - int v24; // [sp-18h] [bp-30h]@44 - unsigned int v25; // [sp-14h] [bp-2Ch]@43 - unsigned int v26; // [sp-10h] [bp-28h]@43 - unsigned __int8 v27; // [sp-Ch] [bp-24h]@43 - char *v28; // [sp-8h] [bp-20h]@43 - Texture *v29; // [sp-4h] [bp-1Ch]@43 + //GUIWindow *v17; // eax@43 + //GUIWindow *v18; // [sp-30h] [bp-48h]@44 + //unsigned int v19; // [sp-2Ch] [bp-44h]@44 + //unsigned int v20; // [sp-28h] [bp-40h]@44 + //unsigned int v21; // [sp-24h] [bp-3Ch]@44 + //unsigned int v22; // [sp-20h] [bp-38h]@44 + //int v23; // [sp-1Ch] [bp-34h]@44 + //int v24; // [sp-18h] [bp-30h]@44 + //unsigned int v25; // [sp-14h] [bp-2Ch]@43 + //unsigned int v26; // [sp-10h] [bp-28h]@43 + //unsigned __int8 v27; // [sp-Ch] [bp-24h]@43 + //char *v28; // [sp-8h] [bp-20h]@43 + //Texture *v29; // [sp-4h] [bp-1Ch]@43 //__int16 a3a; // [sp+10h] [bp-8h]@1 //__int16 a2a; // [sp+14h] [bp-4h]@1 @@ -2288,10 +2287,10 @@ if ( pGUIWindow_Settings ) return; pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0); - pGUIWindow_Settings->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 0, 0x31u, "", 0); - pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 1u, 0x32u, "", 0); - pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 2u, 0x33u, "", 0); - pGUIWindow_Settings->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, 0x45u, 3u, 0x34u, "", 0); + pGUIWindow_Settings->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_45, 0, 0x31u, "", 0); + pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_45, 1u, 0x32u, "", 0); + pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_45, 2u, 0x33u, "", 0); + pGUIWindow_Settings->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_45, 3u, 0x34u, "", 0); sub_421B2C_PlaceInInventory_or_DropPickedItem(); return; } @@ -2299,23 +2298,9 @@ { if ( pGUIWindow_Settings ) return; - v17 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0); - v29 = 0; - v28 = ""; - v27 = 0; - v26 = 0; - v25 = 70; -LABEL_44: - v24 = 0; - v23 = 1; - v22 = 344; - v21 = game_viewport_width; - v20 = 8; - v19 = 8; - pGUIWindow_Settings = v17; - v18 = v17; -LABEL_56: - v18->CreateButton(v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29); + + pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0); + pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_46, 0, 0, "", 0); sub_421B2C_PlaceInInventory_or_DropPickedItem(); return; } @@ -2323,13 +2308,11 @@ { if ( pGUIWindow_Settings ) return; - v17 = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0); - v29 = 0; - v28 = ""; - v27 = 0; - v26 = 0; - v25 = 190; - goto LABEL_44; + + pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0); + pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_BE, 0, 0, "", 0); + sub_421B2C_PlaceInInventory_or_DropPickedItem(); + return; } if ( (char)a5 < 0 ) { @@ -2349,44 +2332,36 @@ if ( pGUIWindow_Settings ) return; pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0); - pGUIWindow_Settings->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 0, 0x31u, "", 0); - pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 1u, 0x32u, "", 0); - pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 2u, 0x33u, "", 0); - pGUIWindow_Settings->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, 0x8Du, 3u, 0x34u, "", 0); - pGUIWindow_Settings->CreateButton(8, 8, game_viewport_width, 344, 1, 0, 140, 0, 0, "", NULL); + pGUIWindow_Settings->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_8D, 0, 0x31u, "", 0); + pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_8D, 1, 0x32u, "", 0); + pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_8D, 2, 0x33u, "", 0); + pGUIWindow_Settings->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_8D, 3, 0x34u, "", 0); + pGUIWindow_Settings->CreateButton(8, 8, game_viewport_width, game_viewport_height, 1, 0, UIMSG_8C, 0, 0, "", NULL); sub_421B2C_PlaceInInventory_or_DropPickedItem(); } if ( HIBYTE(a5) & 2 && !pGUIWindow_Settings ) { pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, (WindowType)(WINDOW_HouseInterior|0x2), (int)&pStru277[result], 0); - pBtn_NPCLeft = pGUIWindow_Settings->CreateButton( - 0x1D5u, - 0xB2u, - (uTextureID_Btn_NPCLeft != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_NPCLeft].uTextureWidth : 24), - (uTextureID_Btn_NPCLeft != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_NPCLeft].uTextureHeight : 26), + pBtn_NPCLeft = pGUIWindow_Settings->CreateButton(469, 178, + pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureWidth, + pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureHeight, 1, 0, - 0xBCu, - 0, + UIMSG_ScrollNPCPanel, 0, 0, "", - (Texture *)(uTextureID_Btn_NPCLeft != -1 ? &pIcons_LOD->pTextures[uTextureID_Btn_NPCLeft] : 0), - 0); - pBtn_NPCRight = pGUIWindow_Settings->CreateButton( - 0x272u, - 0xB2u, - (uTextureID_Btn_NPCRight != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_NPCRight].uTextureWidth : 24), - (uTextureID_Btn_NPCRight != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_NPCRight].uTextureHeight : 26), + pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft), 0); + pBtn_NPCRight = pGUIWindow_Settings->CreateButton(626, 178, + pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureWidth, + pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureHeight, 1, 0, - 0xBCu, - 1u, + UIMSG_ScrollNPCPanel, 1, 0, "", - (Texture *)(uTextureID_Btn_NPCRight != -1 ? &pIcons_LOD->pTextures[uTextureID_Btn_NPCRight] : 0), - 0); - pGUIWindow_Settings->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, 0x8Fu, 4u, 0x35u, "", 0); - pGUIWindow_Settings->CreateButton(0x231u, 0x95u, 0x40u, 0x4Au, 1, 0, 0x8Fu, 5u, 0x36u, "", 0); + pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight), 0); + pGUIWindow_Settings->CreateButton(0x1EBu, 149, 64, 74, 1, 0, UIMSG_8F, 4, 0x35u, "", 0); + pGUIWindow_Settings->CreateButton(0x231u, 149, 64, 74, 1, 0, UIMSG_8F, 5, 0x36u, "", 0); } } } @@ -2421,7 +2396,7 @@ } //----- (00427DA0) -------------------------------------------------------- -unsigned int stru277::PushStru277(__int16 a2, __int16 uPlayerID, __int16 skill_level, __int16 a5, int a6) +unsigned int stru277::PushStru277(__int16 a2, __int16 uPlayerID, __int16 skill_level, __int16 a5, int spell_sound_id) { unsigned int result; // eax@1 stru277 *v7; // edx@1 @@ -2445,7 +2420,7 @@ v8->spell_target_pid = 0; v8->field_8 = a5; v8->forced_spell_skill_level = skill_level; - v8->field_10 = a6; + v8->sound_id = spell_sound_id; LABEL_8: if ( result == 10 ) result = -1; @@ -2466,17 +2441,17 @@ //char v9; // al@44 //int v10; // eax@45 unsigned __int16 v11; // cx@45 - signed int v12; // ecx@48 + //signed int v12; // ecx@48 //int v13; // eax@53 unsigned __int8 v14; // zf@53 //unsigned int v15; // edx@53 //signed int v16; // eax@53 Player *v17; // esi@70 - int v18; // eax@72 - int v19; // eax@74 + //int v18; // eax@72 + //int v19; // eax@74 char *v20; // eax@74 signed int i; // esi@76 - int v22; // eax@88 + //int v22; // eax@88 __int16 v23; // ax@88 //int v24; // ecx@93 //int v25; // ecx@94 @@ -2488,26 +2463,26 @@ //int v31; // eax@112 //int v32; // eax@112 //char *v33; // edx@113 - int v34; // eax@121 - 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 - int v44; // eax@132 - int v45; // ecx@132 + //int v34; // eax@121 + //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 + //int v44; // eax@132 + //int v45; // ecx@132 int v46; // eax@132 - unsigned int v47; // edx@133 - int v48; // eax@137 - int v49; // eax@137 - int v50; // eax@141 + //unsigned int v47; // edx@133 + //int v48; // eax@137 + //int v49; // eax@137 + //int v50; // eax@141 int v51; // eax@146 __int16 v52; // ax@153 - int v53; // eax@153 + //int v53; // eax@153 signed __int64 v54; // qax@164 int v55; // edi@164 //stru6 *v56; // eax@165 @@ -2516,7 +2491,7 @@ int v59; // edi@177 unsigned __int16 v60; // ax@184 int v61; // ecx@184 - int v62; // eax@186 + //int v62; // eax@186 int v63; // ecx@187 int v64; // ecx@188 int v65; // ecx@189 @@ -2537,7 +2512,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 +2549,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 +2581,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 @@ -2615,9 +2590,9 @@ double v158; // st7@326 double v159; // st6@326 signed __int64 v160; // qtt@334 - int v161; // eax@339 + //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 @@ -2641,7 +2616,7 @@ int v184; // ecx@358 int v185; // ecx@359 int v186; // ecx@360 - int v187; // eax@367 + //int v187; // eax@367 int v188; // esi@369 int v189; // edi@369 //const char *v190; // ecx@377 @@ -2680,7 +2655,7 @@ char v223; // al@438 int v224; // ecx@442 int v225; // ecx@443 - int v226; // eax@451 + //int v226; // eax@451 int v227; // esi@453 unsigned int v228; // edi@454 int v229; // edi@466 @@ -2693,7 +2668,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,8 +2755,8 @@ int v323; // edi@635 char *v324; // eax@635 Player *v325; // ecx@640 - int v326; // eax@643 - int v327; // eax@648 + //int v326; // eax@643 + //int v327; // eax@648 int v328; // ecx@651 int v329; // ecx@652 int v330; // edi@654 @@ -2822,9 +2797,9 @@ int v365; // ecx@699 int v366; // eax@701 //stru6 *v367; // eax@704 - int v368; // 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 +2814,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 +2856,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 + //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 @@ -2960,18 +2935,18 @@ //stru6 *v503; // eax@940 //stru6 *v504; // eax@943 int v505; // eax@943 - int v506; // 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 @@ -2986,9 +2961,9 @@ //__int16 v529; // ST18_2@975 //stru6 *v530; // eax@975 int v531; // eax@982 - int v532; // 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 @@ -3034,9 +3009,9 @@ Player *v577; // eax@1026 int v578; // eax@1028 __int16 v579; // ax@1029 - int v580; // eax@1031 + //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 @@ -3049,16 +3024,16 @@ int v592; // esi@1052 int v593; // ecx@1057 int v594; // ecx@1058 - int v595; // eax@1064 + //int v595; // eax@1064 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 int v603; // ecx@1086 - int v604; // eax@1087 + //int v604; // eax@1087 char *v605; // eax@1089 int v606; // edx@1091 int v607; // ecx@1100 @@ -3078,17 +3053,17 @@ //__int16 v621; // ST18_2@1124 //stru6 *v622; // eax@1124 signed __int64 v623; // qax@1127 - int v624; // eax@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 +3083,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 +3098,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 +3117,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 +3156,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 +3213,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 +3221,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 + 1), a2, &a3, 0), sizeof(v715)); v2 = v723; } else @@ -3299,7 +3274,6 @@ if ( HIBYTE(v11) & 1 ) { - v12 = 4; v731 = 4; } else @@ -3312,15 +3286,13 @@ { v731 = 3; } - v12 = v731; } - v730 = v3->spellnum; if (v3->forced_spell_skill_level) uRequiredMana = 0; else - uRequiredMana = pSpellDatas[v3->spellnum].mana_per_skill[v12 - 1]; - sRecoveryTime = pSpellDatas[v3->spellnum].recovery_per_skill[v12 - 1]; + uRequiredMana = pSpellDatas[v3->spellnum].mana_per_skill[v731 - 1]; + sRecoveryTime = pSpellDatas[v3->spellnum].recovery_per_skill[v731 - 1]; if (LODWORD(v725) == PLAYER_SKILL_DARK && pParty->uCurrentHour == 0 && pParty->uCurrentMinute == 0 || LODWORD(v725) == PLAYER_SKILL_LIGHT && pParty->uCurrentHour == 12 && pParty->uCurrentMinute == 0) @@ -3330,7 +3302,6 @@ break; ShowStatusBarString(pGlobalTXT_LocalizationStrings[586], 2u); // "Not enough spell points" -LABEL_203: v3->spellnum = 0; LABEL_1166: ++n; @@ -3338,10 +3309,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)); @@ -3376,10 +3348,9 @@ _this = (ItemGen *)2; sRecoveryTime = v17->GetAttackRecoveryTime(true); a1.stru_24.Reset(); - v18 = v3->spellnum; - a1.field_4C = v2; - a1.field_48 = v18; - a1.field_50 = v731; + a1.spell_level = v2; + a1.spell_id = v3->spellnum; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); if ( v17->WearsItem(510, 2) ) a1.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u); @@ -3388,13 +3359,11 @@ a1.uAttributes = 0; a1.uSpriteFrameID = 0; a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - v19 = 8 * v3->uPlayerID; - LOBYTE(v19) = v19 | OBJECT_Player; - a1.field_58_pid = v19; - a1.field_5C = a2; + 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->field_10); + a1.uSoundID = LOWORD(v3->sound_id); v20 = (char *)&pParty->pPlayers[v3->uPlayerID]; memcpy(&a1.stru_24, &v20[36 * *((int *)v20 + 1620) + 496], sizeof(a1.stru_24)); a1.uAttributes = 256; @@ -3418,22 +3387,20 @@ case SPELL_LASER_PROJECTILE: sRecoveryTime = pPlayer->GetAttackRecoveryTime(0); a1.stru_24.Reset(); - a1.field_48 = v3->spellnum; - a1.field_4C = v723; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v723; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.x = pParty->vPosition.x; a1.vPosition.y = pParty->vPosition.y; a1.uAttributes = 0; a1.uSpriteFrameID = 0; a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2; - v22 = 8 * v3->uPlayerID; - LOBYTE(v22) = v22 | OBJECT_Player; - a1.field_58_pid = v22; - a1.field_5C = a2; + 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->field_10); + a1.uSoundID = LOWORD(v3->sound_id); memcpy( &a1.stru_24, &pParty->pPlayers[v3->uPlayerID].spellbook.pDarkSpellbook.bIsSpellAvailable[36 @@ -3457,7 +3424,7 @@ case SPELL_FIRE_TORCH_LIGHT: LODWORD(v733) = 3600 * v2; - switch (v12) + switch (v731) { case 1: amount = 2; break; case 2: amount = 3; break; @@ -3471,10 +3438,12 @@ 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 = v12 - 2; + { + v29 = v731 - 2; if ( v29 ) { v30 = v29 - 1; @@ -3499,12 +3468,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->field_48 == 7 && object->field_58_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 @@ -3516,19 +3485,20 @@ } 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; a1.stru_24.Reset(); - a1.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.y = pParty->vPosition.y; a1.vPosition.x = pParty->vPosition.x; @@ -3539,185 +3509,189 @@ pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); a1.uSpriteFrameID = 0; - v34 = 8 * v3->uPlayerID; - LOBYTE(v34) = v34 | OBJECT_Player; - a1.field_58_pid = v34; - a1.field_5C = a2; + 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->field_10); + 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.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; - v37 = v3->uPlayerID; a1.field_60_distance_related_prolly_lod = 0; - v37 *= 8; - LOBYTE(v37) = v37 | OBJECT_Player; a1.uFacing = 0; - a1.field_58_pid = v37; - v38 = a2 >> 3; - a1.uSoundID = LOWORD(v3->field_10); - 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.field_5C = v41; - v42 = a1.Create(0, 0, 0, 0); - v43 = &v697; - goto LABEL_133; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.uSoundID = LOWORD(v3->sound_id); + 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.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; - v44 = v3->uPlayerID; a1.field_60_distance_related_prolly_lod = 0; a1.uFacing = 0; - v44 *= 8; - LOBYTE(v44) = v44 | OBJECT_Player; - v38 = (signed int)v726; - a1.field_58_pid = v44; - a1.uSoundID = LOWORD(v3->field_10); - 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)); - v46 = 8 * (int)v726; - a1.vPosition.y = v45; - LOBYTE(v46) = 8 * (char)v726 | OBJECT_Actor; - a1.field_5C = v46; - v42 = a1.Create(0, 0, 0, 0); - v43 = &v704; -LABEL_133: - v670 = (Vec3_int_ *)v43; - v47 = v38; - goto LABEL_139; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.uSoundID = LOWORD(v3->sound_id); + 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); + + 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.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + 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; - v49 = 8 * v3->uPlayerID; - LOBYTE(v49) = v49 | OBJECT_Player; - a1.field_58_pid = v49; - a1.field_5C = a2; + 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); - LOWORD(v49) = LOWORD(v3->field_10); - LOBYTE(a1.uAttributes) |= 0x80u; - a1.uSoundID = v49; - v726 = (Player *)a1.Create(0, 0, 0, 0); + a1.uAttributes |= 0x80u; + a1.uSoundID = LOWORD(v3->sound_id); + + 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: - case 6: - case 11: - case 18: - case 26: - case 32: - case 34: - case 37: - case 57: - case 65: - case 70: - case 78: - case 97: + case SPELL_FIRE_FIREBALL: + case SPELL_FIRE_INCINERATE: + case SPELL_AIR_LIGHNING_BOLT: + case SPELL_WATER_ICE_BOLT: + case SPELL_WATER_ICE_BLAST: + case SPELL_EARTH_STUN: + case SPELL_EARTH_DEADLY_SWARM: + case SPELL_MIND_MIND_BLAST: + case SPELL_MIND_PSYCHIC_SHOCK: + case SPELL_BODY_HARM: + case SPELL_LIGHT_LIGHT_BOLT: + case SPELL_DARK_DRAGON_BREATH: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; a1.stru_24.Reset(); - a1.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.y = pParty->vPosition.y; a1.vPosition.x = pParty->vPosition.x; a1.uAttributes = 0; a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - a1.uSectorID = pIndoor->GetSector( - pParty->vPosition.x, - pParty->vPosition.y, - pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, + pParty->vPosition.y, + pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); + else a1.uSectorID = 0; + a1.uSpriteFrameID = 0; - v50 = 8 * v3->uPlayerID; - LOBYTE(v50) = v50 | OBJECT_Player; - a1.field_58_pid = v50; - a1.field_5C = a2; + 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->field_10); + 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; + + + case 29: case 39: case 76: @@ -3725,9 +3699,9 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; a1.stru_24.Reset(); - a1.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2; a1.vPosition.y = pParty->vPosition.y; @@ -3740,22 +3714,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); @@ -3765,20 +3745,22 @@ *(short *)(v55 + 150) = 0; v661 = (Actor *)v55; goto LABEL_165; + } + case 35: - if ( v12 == 2 ) + if ( v731 == 2 ) { v57 = 300 * v2; } else { - if ( v12 == 3 ) + if ( v731 == 3 ) { amount = 4; v57 = 300 * v2; goto LABEL_174; } - if ( v12 == 4 ) + if ( v731 == 4 ) { v57 = 300 * v2; amount = 8; @@ -3791,17 +3773,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, @@ -3810,38 +3793,43 @@ 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.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(a1.uType); v61 = a2 >> 3; goto LABEL_1086; + } + case 92: if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; @@ -3856,19 +3844,27 @@ pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); a1.uSpriteFrameID = 0; - v62 = 8 * v3->uPlayerID; - LOBYTE(v62) = v62 | OBJECT_Player; - a1.field_58_pid = v62; - a1.field_5C = a2; + 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->field_10); - a1.field_50 = v731; - a1.field_48 = 3; - a1.field_4C = 300 * v2; - goto LABEL_154; + a1.uSoundID = LOWORD(v3->sound_id); + a1.spell_skill = v731; + a1.spell_id = SPELL_FIRE_PROTECTION_FROM_FIRE; + a1.spell_level = 300 * v2; + 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 = v12 - 1; + { + v63 = v731 - 1; if ( !v63 ) { amount = 10; @@ -3897,7 +3893,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 ) { @@ -3907,7 +3903,7 @@ { if (!v730c->uEnchantmentType) { - v68 = BYTE4(v726->pConditions[3]); + v68 = _itm->uEquipType; if ( !v68 || v68 == 1 || v68 == 2 ) { if ( !pItemsTable->IsMaterialNonCommon(v730c) ) @@ -3917,21 +3913,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], @@ -3939,7 +3931,7 @@ 0, -1, 0, - v3->field_10, + v3->sound_id, 0, 0); } @@ -3963,12 +3955,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; } @@ -3984,10 +3987,13 @@ 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 = v12 - 1; + { + v70 = v731 - 1; LODWORD(v733) = 3600 * v2; if ( v70 && (v71 = v70 - 1) != 0 ) { @@ -4012,7 +4018,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: @@ -4020,7 +4028,7 @@ case SPELL_EARTH_PROTECTION_FROM_EARTH: case SPELL_MIND_PROTECTION_FROM_MIND: case SPELL_BODY_PROTECTION_FROM_BODY: - v76 = v12 - 1; + v76 = v731 - 1; LODWORD(v733) = 3600 * v2; if ( v76 ) { @@ -4082,29 +4090,28 @@ 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: - if ( v12 <= 0 ) + if ( v731 <= 0 ) goto LABEL_254; - if ( v12 <= 2 ) + if ( v731 <= 2 ) { v91 = 60 * (v2 + 60); } else { - if ( v12 == 3 ) + if ( v731 == 3 ) { v91 = 180 * (v2 + 20); } else { - if ( v12 != 4 ) + if ( v731 != 4 ) goto LABEL_254; v91 = 240 * (v2 + 15); } @@ -4124,7 +4131,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); @@ -4136,7 +4142,7 @@ goto play_sound_and_continue; case SPELL_SPIRIT_BLESS: - v101 = v12 - 1; + v101 = v731 - 1; if ( v101 && (v102 = v101 - 1) != 0 ) { v103 = v102 - 1; @@ -4171,7 +4177,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]; @@ -4180,10 +4185,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 @@ -4195,29 +4200,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 ) @@ -4229,33 +4235,28 @@ _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.field_48 = *(int *)HIDWORD(v733); - a1.field_4C = v723; - a1.field_50 = v731; + a1.spell_id = *(int *)HIDWORD(v733); + a1.spell_level = v723; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); 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.field_58_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.field_5C = 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 @@ -4271,7 +4272,7 @@ case SPELL_AIR_SHIELD: case SPELL_EARTH_STONESKIN: case SPELL_SPIRIT_HEROISM: - v123 = v12 - 1; + v123 = v731 - 1; if ( v123 && (v124 = v123 - 1) != 0 ) { v125 = v124 - 1; @@ -4319,16 +4320,14 @@ 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: - v138 = v12 - 2; + v138 = v731 - 2; if ( v138 && (v139 = v138 - 1) != 0 && v139 == 1 ) v140 = 600 * v2; else @@ -4342,13 +4341,12 @@ 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 = v12 - 1; + v149 = v731 - 1; if ( v149 && (v150 = v149 - 1) != 0 && (v151 = v150 - 1) != 0 ) { if ( v151 == 1 ) @@ -4362,17 +4360,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 @@ -4387,12 +4385,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(); @@ -4417,9 +4415,9 @@ stru_5C6E00->Atan2((signed __int64)v718, (signed __int64)*(float *)&v721)); } a1.stru_24.Reset(); - a1.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.vPosition.x = uRequiredMana; @@ -4427,11 +4425,11 @@ a1.uSectorID = 0; a1.vPosition.z = a2 + v713; a1.uSpriteFrameID = 0; - a1.field_58_pid = 8 * v3->uPlayerID | OBJECT_Player; - a1.field_5C = v730; + 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; - a1.uSoundID = LOWORD(v3->field_10); + a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) a1.uAttributes = 4; if ( a1.Create( @@ -4443,65 +4441,64 @@ ++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; a1.stru_24.Reset(); - a1.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; - v161 = v3->uPlayerID; a1.field_60_distance_related_prolly_lod = 0; a1.uFacing = 0; - v161 *= 8; - LOBYTE(v161) = v161 | OBJECT_Player; - a1.field_58_pid = v161; - a1.uSoundID = LOWORD(v3->field_10); + 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.field_5C = 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; @@ -4515,13 +4512,12 @@ } 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 = v12 - 1; + v170 = v731 - 1; if ( !v170 ) { v173 = 300 * v2; @@ -4550,14 +4546,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_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 = v12 - 1; + { + v184 = v731 - 1; if ( v184 ) { v185 = v184 - 1; @@ -4585,12 +4581,11 @@ } 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.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.y = pParty->vPosition.y; a1.vPosition.x = pParty->vPosition.x; @@ -4601,16 +4596,14 @@ pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); a1.uSpriteFrameID = 0; - v187 = 8 * v3->uPlayerID; - LOBYTE(v187) = v187 | OBJECT_Player; - a1.field_58_pid = v187; - a1.field_5C = a2; + 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.uSoundID = LOWORD(v3->field_10); + 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); @@ -4621,9 +4614,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) { @@ -4639,10 +4635,11 @@ 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 = v12 - 1; + v192 = v731 - 1; if ( !v192 ) { amount = v2; @@ -4675,7 +4672,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) ) { @@ -4683,15 +4681,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! @@ -4717,18 +4714,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; @@ -4752,7 +4751,6 @@ v713 = pParty->vPosition.y + v214; v208 = LODWORD(v725); } - v726 = (Player *)v211; HIDWORD(v733) = 0; *(float *)&v732 = (double)v211; LODWORD(v725) = v211 + 2500; @@ -4764,29 +4762,28 @@ { 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.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.vPosition.x = LODWORD(v718); @@ -4794,11 +4791,12 @@ a1.uSectorID = 0; a1.vPosition.z = (int)((char *)_this + LODWORD(v725)); a1.uSpriteFrameID = 0; - a1.field_58_pid = 8 * v3->uPlayerID | OBJECT_Player; - a1.field_5C = v730; + 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->field_10); + a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) a1.uAttributes = 4; if ( a1.Create( @@ -4814,9 +4812,12 @@ HIDWORD(v733) = (unsigned __int64)(v218 % 1024) - 512; } while ( !v14 ); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + } + case 23: - v219 = v12 - 2; + v219 = v731 - 2; if ( v219 ) { v220 = v219 - 1; @@ -4846,7 +4847,7 @@ HIDWORD(v733) = (int)(char *)&pParty + 2508; break; case 24: - v224 = v12 - 2; + v224 = v731 - 2; if ( v224 ) { v225 = v224 - 1; @@ -4873,9 +4874,9 @@ { LABEL_152: a1.stru_24.Reset(); - a1.field_48 = v3->spellnum; - a1.field_50 = v731; - a1.field_4C = v2; + a1.spell_id = v3->spellnum; + a1.spell_skill = v731; + a1.spell_level = v2; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.y = pParty->vPosition.y; v51 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; @@ -4888,32 +4889,26 @@ v52 = pIndoor->GetSector(pParty->vPosition.x, v660, v671); a1.uSpriteFrameID = 0; a1.uSectorID = v52; - v53 = 8 * v3->uPlayerID; - LOBYTE(v53) = v53 | OBJECT_Player; - a1.field_58_pid = v53; - a1.field_5C = a2; + 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->field_10); -LABEL_154: + a1.uSoundID = LOWORD(v3->sound_id); + 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.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.y = pParty->vPosition.y; a1.vPosition.x = pParty->vPosition.x; @@ -4924,12 +4919,10 @@ pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); a1.uSpriteFrameID = 0; - v226 = 8 * v3->uPlayerID; - LOBYTE(v226) = v226 | OBJECT_Player; - a1.field_58_pid = v226; - a1.field_5C = a2; + 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.uSoundID = LOWORD(v3->field_10); + a1.uSoundID = LOWORD(v3->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(a1.uAttributes) |= 4u; v227 = SHIDWORD(v733) / -2; @@ -4947,12 +4940,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() ) { @@ -4972,16 +4967,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; @@ -4998,7 +4992,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 ) { @@ -5037,10 +5032,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; @@ -5048,7 +5047,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]; @@ -5106,7 +5104,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; } @@ -5133,7 +5134,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); } @@ -5242,6 +5244,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 @@ -5369,7 +5372,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) ) @@ -5383,7 +5387,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 ) { @@ -5454,27 +5459,33 @@ + 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 ) goto play_sound_and_continue; - if ( pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW) && v12 != 4 || rand() % 100 >= amount && v731 != 4 ) + if ( pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW) && v731 != 4 || rand() % 100 >= amount && v731 != 4 ) { 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 ) @@ -5485,13 +5496,13 @@ _506348_current_lloyd_playerid = v3->uPlayerID; ::uRequiredMana = v319; ::sRecoveryTime = sRecoveryTime; - dword_50633C = v3->field_10; + dword_50633C = v3->sound_id; dword_506338 = v3->spellnum; LOBYTE(v3->field_8) |= 0x20u; } goto play_sound_and_continue; case 40: - v320 = v12 - 2; + v320 = v731 - 2; if ( !v320 ) goto LABEL_632; v321 = v320 - 1; @@ -5513,20 +5524,29 @@ 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; a1.stru_24.Reset(); - a1.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.y = pParty->vPosition.y; a1.vPosition.x = pParty->vPosition.x; @@ -5537,33 +5557,35 @@ pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); a1.uSpriteFrameID = 0; - v326 = 8 * v3->uPlayerID; - LOBYTE(v326) = v326 | OBJECT_Player; - a1.field_58_pid = v326; - a1.field_5C = a2; + 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->field_10); + 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; a1.uType = 4090; a1.stru_24.Reset(); - a1.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.x = pParty->vPosition.x; a1.vPosition.y = pParty->vPosition.y; @@ -5571,26 +5593,22 @@ a1.uSectorID = 0; a1.uSpriteFrameID = 0; a1.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - v327 = 8 * v3->uPlayerID; - LOBYTE(v327) = v327 | OBJECT_Player; a1.field_60_distance_related_prolly_lod = 0; - a1.field_58_pid = v327; - a1.field_5C = a2; + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.spell_target_pid = a2; a1.uFacing = LOWORD(pParty->sRotationY); - a1.uSoundID = LOWORD(v3->field_10); + 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 = v12 - 2; + v328 = v731 - 2; if ( v328 ) { v329 = v328 - 1; @@ -5610,18 +5628,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_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: LODWORD(v733) = 300; - v339 = v12 - 2; + v339 = v731 - 2; if ( v339 ) { v340 = v339 - 1; @@ -5653,9 +5667,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); @@ -5667,10 +5682,11 @@ 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 = v12 - 2; + v348 = v731 - 2; if ( !v348 ) goto LABEL_677; v349 = v348 - 1; @@ -5694,23 +5710,31 @@ 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 = v12 - 2; + v354 = v731 - 2; if ( v354 && (v355 = v354 - 1) != 0 && v355 == 1 ) v356 = 900 * (v2 + 4); else @@ -5722,13 +5746,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 @@ -5739,9 +5761,12 @@ ++v357;// = (SpellBuff *)((char *)v357 + 6972); } while ( v357 <= &pParty->pPlayers[3] ); - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 48: - v364 = v12 - 2; + { + v364 = v731 - 2; if ( !v364 || (v365 = v364 - 1) != 0 && v365 != 1 ) v366 = 60 * (v2 + 3); else @@ -5749,46 +5774,43 @@ 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(); - a1.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; - v368 = v3->uPlayerID; a1.field_60_distance_related_prolly_lod = 0; a1.uFacing = 0; - v368 *= 8; - LOBYTE(v368) = v368 | OBJECT_Player; - a1.field_58_pid = v368; - a1.uSoundID = LOWORD(v3->field_10); - for ( a2 = 0; a2 < (signed int)v726; ++a2 ) + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.uSoundID = LOWORD(v3->sound_id); + 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.field_5C = 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 = v12 - 2; + v371 = v731 - 2; if ( v371 && (v372 = v371 - 1) != 0 && v372 == 1 ) amount = 0; else @@ -5798,7 +5820,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 ) @@ -5812,7 +5837,6 @@ } else { - v732 = amount << 7; *(float *)&a2 = (double)(amount << 7) * 0.033333335; pParty->pPlayers[v3->uPlayerID_2].DiscardConditionIfLastsLongerThan( 0xEu, @@ -5824,7 +5848,7 @@ v377 = &pParty->pPlayers[v3->uPlayerID_2]; goto LABEL_720; case 54: - v378 = v12 - 2; + v378 = v731 - 2; if ( v378 && (v379 = v378 - 1) != 0 && v379 == 1 ) v380 = 4 * v2; else @@ -5858,17 +5882,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); @@ -5877,10 +5899,11 @@ } while ( v388 + 1 < v730 ); } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; case 55: - v392 = v12 - 1; + v392 = v731 - 1; if ( !v392 ) { v395 = 180 * v2; @@ -5925,34 +5948,25 @@ } 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: - v405 = v12 - 2; + v405 = v731 - 2; if ( !v405 ) goto LABEL_766; v406 = v405 - 1; @@ -5979,15 +5993,24 @@ 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 = v12 - 2; + v411 = v731 - 2; if ( v411 ) { v412 = v411 - 1; @@ -6018,19 +6041,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,9 +6122,9 @@ LABEL_807: ShowStatusBarString(pTmpBuf2, 2u); a1.stru_24.Reset(); - a1.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.x = *(short *)(v730 + 142); a1.vPosition.y = *(short *)(v730 + 144); @@ -6100,7 +6134,7 @@ v657 = a1.vPosition.x; goto LABEL_1087; case 62: - v423 = v12 - 2; + v423 = v731 - 2; if ( !v423 ) goto LABEL_813; v424 = v423 - 1; @@ -6119,55 +6153,61 @@ 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); pActors[v426].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; } a1.stru_24.Reset(); - a1.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; 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(); - a1.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + 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 = v12 - 2; + { + v428 = v731 - 2; if ( v428 && (v429 = v428 - 1) != 0 && v429 == 1 ) v430 = 300 * v2; else @@ -6175,48 +6215,44 @@ 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(); - a1.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; - v432 = v3->uPlayerID; a1.field_60_distance_related_prolly_lod = 0; a1.uFacing = 0; - v432 *= 8; - LOBYTE(v432) = v432 | OBJECT_Player; - a1.field_58_pid = v432; - a1.uSoundID = LOWORD(v3->field_10); - for ( a2 = 0; a2 < (signed int)v726; ++a2 ) + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.uSoundID = LOWORD(v3->sound_id); + 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.field_5C = 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 = v12 - 2; + v435 = v731 - 2; if ( v435 && (v436 = v435 - 1) != 0 && v436 == 1 ) amount = 0; else @@ -6238,18 +6274,18 @@ } 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 = v12 - 2; + v442 = v731 - 2; if ( !v442 ) goto LABEL_855; v443 = v442 - 1; @@ -6268,8 +6304,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; @@ -6280,7 +6316,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); @@ -6289,23 +6325,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; @@ -6314,9 +6356,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() ) { @@ -6326,9 +6368,11 @@ } } } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 67: - v451 = v12 - 2; + v451 = v731 - 2; if ( v451 ) { v452 = v451 - 1; @@ -6359,22 +6403,25 @@ 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 = v12 - 2; + v457 = v731 - 2; if ( v457 ) { v458 = v457 - 1; @@ -6401,16 +6448,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 ) @@ -6430,9 +6474,11 @@ } } } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 72: - v464 = v12 - 2; + v464 = v731 - 2; if ( !v464 ) goto LABEL_910; v465 = v464 - 1; @@ -6460,7 +6506,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; @@ -6471,9 +6520,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, @@ -6497,10 +6546,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; @@ -6520,17 +6568,17 @@ 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 = v12 - 2; + v493 = v731 - 2; if ( v493 && (v494 = v493 - 1) != 0 && v494 == 1 ) amount = 0; else @@ -6543,7 +6591,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; @@ -6557,7 +6608,6 @@ } else { - v732 = amount << 7; *(float *)&a2 = (double)(amount << 7) * 0.033333335; pParty->pPlayers[v498].DiscardConditionIfLastsLongerThan( 7u, @@ -6572,7 +6622,9 @@ LABEL_641: v325->DiscardConditionIfLastsLongerThan(v656, v663); } - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 77: { amount = 5 * v2 + 10; @@ -6588,7 +6640,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; @@ -6599,24 +6652,21 @@ 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.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; - v506 = v3->uPlayerID; a1.field_60_distance_related_prolly_lod = 0; a1.uFacing = 0; - v506 *= 8; - LOBYTE(v506) = v506 | OBJECT_Player; - a1.field_58_pid = v506; - a1.uSoundID = LOWORD(v3->field_10); + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.uSoundID = LOWORD(v3->sound_id); a2 = 0; if ( SHIDWORD(v733) > 0 ) { @@ -6625,14 +6675,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.field_5C = 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) ); @@ -6642,25 +6689,21 @@ 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.field_5C = 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 = v12 - 2; + v514 = v731 - 2; if ( !v514 ) goto LABEL_955; v515 = v514 - 1; @@ -6684,34 +6727,36 @@ 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 = v12 - 2; + v520 = v731 - 2; if ( !v520 ) goto LABEL_973; v521 = v520 - 1; @@ -6742,13 +6787,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: @@ -6757,57 +6798,53 @@ { 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.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; - v532 = v3->uPlayerID; a1.field_60_distance_related_prolly_lod = 0; a1.uFacing = 0; - v532 *= 8; - LOBYTE(v532) = v532 | OBJECT_Player; - a1.field_58_pid = v532; - a1.uSoundID = LOWORD(v3->field_10); + 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.field_5C = 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 = v12 - 2; + { + v538 = v731 - 2; if ( v538 && (v539 = v538 - 1) != 0 && v539 == 1 ) { amount = 5 * v2; @@ -6845,9 +6882,13 @@ 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 = v12 - 2; + { + v551 = v731 - 2; if ( !v551 ) goto LABEL_998; v552 = v551 - 1; @@ -6874,7 +6915,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 @@ -6887,7 +6928,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] ); @@ -6895,18 +6936,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; @@ -6941,9 +6987,11 @@ *(short *)v572 = pPlayer->sAgeModifier + 10; sRecoveryTime += -5 * v2; ++v571->uNumDivineInterventionCastsThisDay; - goto LABEL_1056; + LODWORD(v727) = 1; + goto play_sound_and_continue; + case 89: - v573 = v12 - 2; + v573 = v731 - 2; if ( v573 ) { v574 = v573 - 1; @@ -6981,12 +7029,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; @@ -6994,36 +7043,32 @@ { 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(); - a1.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; - v580 = v3->uPlayerID; a1.field_60_distance_related_prolly_lod = 0; v581 = v721; - v580 *= 8; - LOBYTE(v580) = v580 | OBJECT_Player; a1.uFacing = 0; - a1.field_58_pid = v580; - a1.uSoundID = LOWORD(v3->field_10); + a1.spell_caster_pid = PID(OBJECT_Player, v3->uPlayerID); + a1.uSoundID = LOWORD(v3->sound_id); 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); - LOBYTE(v582) = 8 * (char)v726 | OBJECT_Actor; - a1.field_5C = v582; + 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; @@ -7038,9 +7083,11 @@ ((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 = v12 - 1; + v588 = v731 - 1; amount = 16; if ( v588 && (v589 = v588 - 1) != 0 && (v590 = v589 - 1) != 0 ) { @@ -7053,6 +7100,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); @@ -7069,7 +7117,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; @@ -7077,14 +7126,17 @@ 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 = v12 - 2; + { + v593 = v731 - 2; if ( !v593 ) goto LABEL_1062; v594 = v593 - 1; @@ -7102,12 +7154,11 @@ } 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.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.vPosition.x = pParty->vPosition.x; a1.vPosition.y = pParty->vPosition.y; @@ -7118,17 +7169,15 @@ pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2); a1.uSpriteFrameID = 0; - v595 = 8 * v3->uPlayerID; - LOBYTE(v595) = v595 | OBJECT_Player; - a1.field_58_pid = v595; - a1.field_5C = a2; + 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.uSoundID = LOWORD(v3->field_10); + 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 @@ -7141,11 +7190,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; @@ -7164,30 +7216,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.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + 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; @@ -7204,17 +7257,16 @@ a1.uAttributes = 0; a1.uSectorID = pIndoor->GetSector(v657, v665, v676); a1.uSpriteFrameID = 0; - v604 = 8 * v3->uPlayerID; - LOBYTE(v604) = v604 | OBJECT_Player; - a1.field_58_pid = v604; - a1.field_5C = a2; + 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); - LOWORD(v604) = LOWORD(v3->field_10); LOBYTE(a1.uAttributes) |= 0x80u; - a1.uSoundID = v604; + 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; @@ -7260,7 +7312,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; @@ -7284,15 +7337,15 @@ LODWORD(v727) = 1; goto play_sound_and_continue; case 95: - if ( v12 <= 0 ) + if ( v731 <= 0 ) goto LABEL_1119; - if ( v12 <= 3 ) + if ( v731 <= 3 ) { v614 = 300 * (v2 + 12); } else { - if ( v12 != 4 ) + if ( v731 != 4 ) goto LABEL_1119; v614 = 900 * (v2 + 4); } @@ -7306,13 +7359,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 @@ -7323,49 +7374,47 @@ ++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.field_48 = v3->spellnum; - a1.field_4C = v2; - a1.field_50 = v731; + a1.spell_id = v3->spellnum; + a1.spell_level = v2; + a1.spell_skill = v731; a1.uObjectDescID = pObjectList->ObjectIDByItemID(a1.uType); a1.uAttributes = 0; a1.uSectorID = 0; a1.uSpriteFrameID = 0; - v624 = v3->uPlayerID; a1.field_60_distance_related_prolly_lod = 0; a1.uFacing = 0; - v624 *= 8; - LOBYTE(v624) = v624 | OBJECT_Player; - a1.field_58_pid = v624; - a1.uSoundID = LOWORD(v3->field_10); + 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.field_5C = 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) ); @@ -7388,19 +7437,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)); @@ -7409,22 +7459,28 @@ 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; - } - v640 = v12 - 2; + v3->spellnum = 0; + goto LABEL_1166; + } + v640 = v731 - 2; if ( !v640 || (v641 = v640 - 1) == 0 || (amount = 4, v641 != 1) ) amount = 3; if ( pPlayer->uNumArmageddonCasts >= amount || pParty->armageddon_timer > 0 ) { 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; @@ -7433,7 +7489,7 @@ ++pPlayer->uNumArmageddonCasts; if ( pParty->bTurnBasedModeOn == 1 ) ++pTurnEngine->field_1C; - v726 = (Player *)50; + auto _v726 = 50; do { v642 = rand() % 4096 - 2048; @@ -7443,10 +7499,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; } @@ -7463,7 +7522,6 @@ } else { - v732 = amount << 7; v223 = ((Player *)v222)->DiscardConditionIfLastsLongerThan( 2u, pParty->uTimePlayed - (signed int)(signed __int64)((double)(amount << 7) * 0.033333335)); @@ -7475,7 +7533,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; } } @@ -7780,7 +7841,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, @@ -7908,9 +7969,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 ) { @@ -7918,7 +7979,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 ) @@ -8147,9 +8208,9 @@ v9 = v22; } v10 = 0; - a1a.field_50 = 0; - a1a.field_4C = 0; - a1a.field_48 = 0; + a1a.spell_skill = 0; + a1a.spell_level = 0; + a1a.spell_id = 0; a1a.field_54 = 0; a1a.uType = v9; if ( (signed int)pObjectList->uNumObjects <= 0 ) @@ -8177,8 +8238,8 @@ a1a.uAttributes = attributes; a1a.uSectorID = pIndoor->GetSector(v21, y, z); a1a.uSpriteFrameID = 0; - a1a.field_58_pid = 0; - a1a.field_5C = 0; + a1a.spell_caster_pid = 0; + a1a.spell_target_pid = 0; if ( !(a1a.uAttributes & 0x10) ) { v13 = 0; @@ -8253,9 +8314,9 @@ a1.stru_24.Reset(); v5 = 0; - a1.field_50 = 0; - a1.field_4C = 0; - a1.field_48 = 0; + a1.spell_skill = 0; + a1.spell_level = 0; + a1.spell_id = 0; a1.field_54 = 0; a1.uType = 800; if ( (signed int)pObjectList->uNumObjects <= 0 ) @@ -8283,8 +8344,8 @@ a1.uAttributes = 0; a1.uSectorID = pIndoor->GetSector(v3, v4, z); a1.uSpriteFrameID = 0; - a1.field_58_pid = 0; - a1.field_5C = 0; + a1.spell_caster_pid = 0; + a1.spell_target_pid = 0; v8 = a1.Create(0, 0, 0, 0); if ( v8 != -1 ) { @@ -8303,9 +8364,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 @@ -8316,9 +8377,9 @@ a1a.uType = 600; a1a.stru_24.Reset(); - a1a.field_48 = 6; - a1a.field_4C = 8; - a1a.field_50 = 3; + a1a.spell_id = SPELL_FIRE_FIREBALL; + a1a.spell_level = 8; + a1a.spell_skill = 3; v14 = 0; if ( (signed int)pObjectList->uNumObjects <= 0 ) { @@ -8344,27 +8405,22 @@ a1a.uAttributes = 0; a1a.uSectorID = pIndoor->GetSector(v6, v7, a3); a1a.uSpriteFrameID = 0; - a1a.field_5C = 0; + a1a.spell_target_pid = 0; a1a.field_60_distance_related_prolly_lod = 0; a1a.uFacing = 0; a1a.uSoundID = 0; if ( a6 >= 1 || a6 <= 4 ) { - v10 = 8 * a6 - 8; - LOBYTE(v10) = v10 | OBJECT_Player; - a1a.field_58_pid = v10; + a1a.spell_caster_pid = PID(OBJECT_Player, a6 - 1); } else { - a1a.field_58_pid = 0; + a1a.spell_caster_pid = 0; } 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), @@ -8455,7 +8511,7 @@ void __cdecl ProcessInputActions() { ActionQueue *pActionQueue; // esi@7 - Keyboard *v3; // ecx@8 + //Keyboard *v3; // ecx@8 char v4; // al@9 ActionQueue *v5; // ecx@19 Player *v6; // ecx@86 @@ -8503,12 +8559,11 @@ pActionQueue = pPartyActionQueue; while ( 1 ) { - v3 = pGame->pKeyboardInstance; v17 = pKeyActionMap->pVirtualKeyCodesMapping[inputAction]; if ( pKeyActionMap->pToggleTypes[inputAction] ) - v4 = v3->WasKeyPressed(v17); + v4 = pKeyboard->WasKeyPressed(v17); else - v4 = v3->IsKeyBeingHeld(v17); + v4 = pKeyboard->IsKeyBeingHeld(v17); if ( v4 ) { switch ( inputAction ) @@ -8701,8 +8756,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(); } @@ -8714,7 +8768,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);