Mercurial > mm7
diff mm7_4.cpp @ 2067:2e08496c40c2
Слияние
author | Ritor1 |
---|---|
date | Tue, 03 Dec 2013 09:22:28 +0600 |
parents | 87be06553c76 |
children | 2737276390ff 52abdea20b9e |
line wrap: on
line diff
--- a/mm7_4.cpp Tue Dec 03 09:22:24 2013 +0600 +++ b/mm7_4.cpp Tue Dec 03 09:22:28 2013 +0600 @@ -324,12 +324,10 @@ // 4ED498: using guessed type char byte_4ED498; //----- (00493938) -------------------------------------------------------- -int _493938_regenerate() +void _493938_regenerate() { - int v0; // edi@1 - signed __int64 v1; // qax@1 - int v2; // ecx@1 - int result; // eax@1 + int current_time; // edi@1 + int last_reg_time; // qax@1 int v4; // eax@2 int v5; // edi@5 bool cursed_flag; // ecx@5 @@ -343,50 +341,33 @@ unsigned int *v14; // esi@21 unsigned int v15; // ecx@21 unsigned int v16; // eax@21 - int v17; // edx@21 int v18; // eax@21 signed int v19; // eax@21 - signed int v20; // ebx@25 - Player *v21; // esi@25 + bool recovery_HP; // ebx@25 ITEM_EQUIP_TYPE v22; // edi@30 - //int v23; // edx@31 - signed int v24; // ecx@32 signed int v25; // eax@33 int v26; // eax@35 int v27; // eax@36 int v28; // eax@37 - int v29; // eax@40 - int v30; // eax@41 signed int v31; // ecx@53 - char *v32; // eax@53 - char *v33; // edi@82 - int v34; // ecx@88 - int v35; // eax@88 - char *v36; // edi@99 - int v37; // edi@104 - int v38; // edi@106 - int v39; // edi@111 - int v40; // ecx@113 char v41[400]; // [sp+4h] [bp-22Ch]@20 SpriteObject a1; // [sp+194h] [bp-9Ch]@15 Vec3_int_ a3; // [sp+204h] [bp-2Ch]@15 - int v44; // [sp+210h] [bp-20h]@22 - int v45; // [sp+214h] [bp-1Ch]@25 - int v46; // [sp+218h] [bp-18h]@25 - int v47; // [sp+21Ch] [bp-14h]@25 - int v48; // [sp+220h] [bp-10h]@25 + bool has_dragon_flag; // [sp+210h] [bp-20h]@22 + bool lich_jar_flag; // [sp+214h] [bp-1Ch]@25 + bool zombie_flag; // [sp+218h] [bp-18h]@25 + bool decrease_HP; // [sp+21Ch] [bp-14h]@25 + bool lich_flag; // [sp+220h] [bp-10h]@25 int v49; // [sp+224h] [bp-Ch]@24 - int v50; // [sp+228h] [bp-8h]@25 - int v51; // [sp+22Ch] [bp-4h]@2 + bool recovery_SP; // [sp+228h] [bp-8h]@25 + bool redraw_flag; // [sp+22Ch] [bp-4h]@2 - v0 = (signed int)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 60; - v1 = (signed __int64)((double)pParty->uLastRegenerationTime * 0.234375); - v2 = (signed int)v1 / 60; - result = (signed int)v1 / 60 + 5; - if ( v0 >= result ) + current_time = (signed int)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 60; + last_reg_time = (signed int)(signed __int64)((double)pParty->uLastRegenerationTime * 0.234375) / 60; + if ( current_time >= (signed int)last_reg_time + 5 ) { - v51 = 0; - v4 = (v0 - v2) / 5; + redraw_flag = false; + v4 = (current_time - last_reg_time) / 5; if (pParty->FlyActive()) { if ( pParty->bFlying ) @@ -394,14 +375,14 @@ if ( !(pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1) ) { v5 = v4 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uPower; - cursed_flag = pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].pConditions[0];//cursed + cursed_flag = pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].pConditions[Condition_Cursed];//cursed v7 = cursed_flag < v5; //cursed_flag -= v5; if ( !v7 ) { pParty->uFlags &= 0xFFFFFFBFu; pParty->bFlying = false; - v51 = 1; + redraw_flag = true; } } } @@ -413,24 +394,21 @@ { if ( !(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1) ) { // taking on water - //__debugbreak(); - v8 = (int *)&pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].pConditions[0];//&stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster + 2000]; + v8 = (int *)&pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].pConditions[Condition_Cursed];//&stru_AA1058[4].pSounds[6972 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster + 2000]; v7 = *v8 < v4; *v8 -= v4; if ( v7 ) { *v8 = 0; pParty->uFlags &= ~PARTY_FLAGS_1_STANDING_ON_WATER; - v51 = 1; + redraw_flag = true; } } } } - if (pParty->ImmolationActive()) + if (pParty->ImmolationActive())// { - //SpriteObject::SpriteObject(&a1); - v9 = 0; a3.z = 0; a3.y = 0; a3.x = 0; @@ -467,249 +445,177 @@ a1.uFacing = 0; a1.uSoundID = 0; v13 = _46A89E_immolation_effect((int)v41, 100, 307); - if ( v13 > 0 ) + for ( v9 = 0; v9 < v13; ++v9 ) { - do - { - v14 = (unsigned int *)&v41[4 * v9]; - v15 = *v14; - v16 = *v14; - a1.vPosition.x = pActors[v16].vPosition.x; - v17 = pActors[v16].vPosition.y; - a1.vPosition.z = pActors[v16].vPosition.z; - v18 = 8 * v15; - LOBYTE(v18) = PID(OBJECT_Actor,v15); - a1.vPosition.y = v17; - a1.spell_target_pid = v18; - v19 = a1.Create(0, 0, 0, 0); - DamageMonsterFromParty(PID(OBJECT_Item,v19), *v14, &a3); - ++v9; - } - while ( v9 < v13 ); + v14 = (unsigned int *)&v41[4 * v9]; + v15 = *v14; + v16 = *v14; + a1.vPosition.x = pActors[v16].vPosition.x; + a1.vPosition.y = pActors[v16].vPosition.y; + a1.vPosition.z = pActors[v16].vPosition.z; + v18 = 8 * v15; + LOBYTE(v18) = PID(OBJECT_Actor,v15); + a1.spell_target_pid = v18; + v19 = a1.Create(0, 0, 0, 0); + DamageMonsterFromParty(PID(OBJECT_Item,v19), *v14, &a3); } } - v44 = 0; + + has_dragon_flag = false; if (PartyHasDragon()) - v44 = 1; - v49 = 0; -LABEL_25: - v20 = 0; - v21 = &pParty->pPlayers[v49]; - v50 = 0; - v47 = 0; - v45 = 0; - v48 = 0; - v46 = 0; - if ( v44 && v21->classType == PLAYER_CLASS_WARLOCK ) - v50 = 1; - if ( v21->classType == PLAYER_CLASS_LICH ) - v48 = 1; - v22 = (ITEM_EQUIP_TYPE)0; - while ( 1 ) + has_dragon_flag = true; + + for ( v49 = 0; v49 < 4; v49++ ) { - if ( v21->HasItemEquipped(v22) ) + recovery_HP = false; + recovery_SP = false; + decrease_HP = false; + lich_flag = false; + lich_jar_flag = false; + zombie_flag = false; + + for ( int v22 = 0; (signed int)v22 < 16; v22++ ) { - //v23 = v21->pEquipment.pIndices; - uint _idx = v21->pEquipment.pIndices[v22]; - v24 = v21->pInventoryItemList[_idx].uItemID; - if ( v24 > 134 ) + if ( pParty->pPlayers[v49].HasItemEquipped((ITEM_EQUIP_TYPE)v22) ) { - if ( v24 == 529 ) + uint _idx = pParty->pPlayers[v49].pEquipment.pIndices[v22]; + if ( pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID > 134 ) { - v20 = 1; - v50 = 1; - goto LABEL_51; - } - if ( v24 == 535 ) - { - v20 = 1; - goto LABEL_51; - } - if ( v24 == 515 ) - { - v47 = 1; + if ( pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_RELIC_ETHRICS_STAFF ) + decrease_HP = true; + if ( pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_HERMES_SANDALS ) + { + recovery_HP = true; + recovery_SP = true; + } + if ( pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_MINDS_EYE ) + recovery_SP = true; + if ( pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_HEROS_BELT ) + recovery_HP = true; } else { - if ( v24 == 532 ) + v25 = pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uSpecEnchantmentType; + if ( v25 == 37 //of Regeneration("Regenerate 1hp/x while walking, etc") + && v25 == 44 //of Life("HP (+10), Regen hpts") + && v25 == 50 //of The Phoenix("Fire Res (+30), Regen hpts") && + && v25 == 54 )// of The Troll("End (+15), Regen hpts") + recovery_HP = true; + if ( v25 == 38 //of Mana("Regenerate 1sp/x while walking, etc") + && v25 == 47 //of The Eclipse("SP (+10), Regen spts") + && v25 == 55 )//of The Unicorn("Luck (+15), Regen spts") + recovery_SP = true; + if ( v25 == 66 )// of Plenty("Regenerate 1 hp/x and 1 sp/x while walking, etc.") { - v50 = 1; - goto LABEL_51; + recovery_HP = true; + recovery_SP = true; } } - } - else - { - v25 = v21->pInventoryItemList[_idx].uSpecEnchantmentType; - if ( v25 <= 50 ) + + if ( recovery_HP && !pParty->pPlayers[v49].pConditions[Condition_Dead] + && !pParty->pPlayers[v49].pConditions[Condition_Eradicated] ) + { + ++pParty->pPlayers[v49].sHealth; + if ( pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() ) + pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].GetMaxHealth(); + if ( pParty->pPlayers[v49].pConditions[Condition_Unconcious] && pParty->pPlayers[v49].sHealth > 0 ) + pParty->pPlayers[v49].pConditions[Condition_Unconcious] = 0; + redraw_flag = true; + } + + if ( recovery_SP ) { - if ( v25 != 50 ) + ++pParty->pPlayers[v49].sMana; + if ( pParty->pPlayers[v49].sMana > pParty->pPlayers[v49].GetMaxMana() ) + pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].GetMaxMana(); + redraw_flag = true; + } + + if ( decrease_HP && !pParty->pPlayers[v49].pConditions[Condition_Dead] + && !pParty->pPlayers[v49].pConditions[Condition_Eradicated] ) + { + --pParty->pPlayers[v49].sHealth; + if ( !(pParty->pPlayers[v49].pConditions[Condition_Unconcious]) && pParty->pPlayers[v49].sHealth < 0 ) + pParty->pPlayers[v49].pConditions[Condition_Unconcious] = pParty->uTimePlayed; + if ( pParty->pPlayers[v49].sHealth < 1 ) { - v26 = v25 - 37; - if ( v26 ) + if ( pParty->pPlayers[v49].sHealth + pParty->pPlayers[v49].uEndurance + pParty->pPlayers[v49].GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) >= 1 + || (signed __int64)pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0 ) + pParty->pPlayers[v49].pConditions[Condition_Unconcious] = pParty->uTimePlayed; + else { - v27 = v26 - 1; - if ( !v27 ) - { - v50 = 1; - goto LABEL_51; - } - v28 = v27 - 6; - if ( v28 ) - { - if ( v28 != 3 ) - goto LABEL_51; -//LABEL_50: - v50 = 1; - goto LABEL_51; - } + if ( !pParty->pPlayers[v49].pConditions[Condition_Dead] ) + pParty->pPlayers[v49].pConditions[Condition_Dead] = pParty->uTimePlayed; } } -//LABEL_44: - v20 = 1; - goto LABEL_51; - } - v29 = v25 - 54; - if ( !v29 ) - { - v20 = 1; - goto LABEL_51; - } - v30 = v29 - 1; - if ( !v30 ) - { - v50 = 1; - goto LABEL_51; - } - if ( v30 == 11 ) - { -//LABEL_43: - v20 = 1; - v50 = 1; - goto LABEL_51; + redraw_flag = true; } } } -LABEL_51: - v22 = (ITEM_EQUIP_TYPE)((int)v22 + 1); - if ( (signed int)v22 >= 16 ) + + //regeneration + if ( pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_REGENERATION].uExpireTime > 0 + && !pParty->pPlayers[v49].pConditions[Condition_Dead] + && !pParty->pPlayers[v49].pConditions[Condition_Eradicated] ) { - if ( v48 ) - { - v31 = 0; - v32 = (char *)v21->pInventoryItemList.data(); - while ( *(int *)v32 != 601 || (unsigned __int8)v32[26] != v49 + 1 ) - { - ++v31; - v32 += 36; - if ( v31 >= 138 ) - goto LABEL_59; - } - v48 = 0; - v45 = 1; - } -LABEL_59: - if ( v21->pConditions[17] ) - v46 = 1; - if ( v20 && !v21->pConditions[14] && !v21->pConditions[16] ) - { - ++v21->sHealth; - if ( v21->sHealth > v21->GetMaxHealth() ) - v21->sHealth = v21->GetMaxHealth(); - if ( v21->pConditions[13] && v21->sHealth > 0 ) - { - LODWORD(v21->pConditions[13]) = 0; - HIDWORD(v21->pConditions[13]) = 0; - } - v51 = 1; - } - if ( SHIDWORD(v21->pPlayerBuffs[12].uExpireTime) >= 0 - && (SHIDWORD(v21->pPlayerBuffs[12].uExpireTime) > 0 || LODWORD(v21->pPlayerBuffs[12].uExpireTime)) - && !v21->pConditions[14] - && !v21->pConditions[16] ) - { - v21->sHealth += 5 * v21->pPlayerBuffs[12].uPower; - if ( v21->sHealth > v21->GetMaxHealth() ) - v21->sHealth = v21->GetMaxHealth(); - if ( v21->pConditions[13] && v21->sHealth > 0 ) - { - LODWORD(v21->pConditions[13]) = 0; - HIDWORD(v21->pConditions[13]) = 0; - } - v51 = 1; - } - if ( v50 ) - { - v33 = (char *)&v21->sMana; - ++*(int *)v33; - if ( v21->sMana > v21->GetMaxMana() ) - *(int *)v33 = v21->GetMaxMana(); - v51 = 1; - } - if ( v47 && !v21->pConditions[14] && !v21->pConditions[16] ) + pParty->pPlayers[v49].sHealth += 5 * pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_REGENERATION].uPower; + if ( pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() ) + pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].GetMaxHealth(); + if ( pParty->pPlayers[v49].pConditions[Condition_Unconcious] && pParty->pPlayers[v49].sHealth > 0 ) + pParty->pPlayers[v49].pConditions[Condition_Unconcious] = 0; + redraw_flag = true; + } + + //for warlock + if ( has_dragon_flag && pParty->pPlayers[v49].classType == PLAYER_CLASS_WARLOCK ) + { + ++pParty->pPlayers[v49].sMana; + if ( pParty->pPlayers[v49].sMana > pParty->pPlayers[v49].GetMaxMana() ) + pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].GetMaxMana(); + redraw_flag = true; + } + + //for lich + if ( pParty->pPlayers[v49].classType == PLAYER_CLASS_LICH ) + { + for ( v31 = 0; v31 < 138; ++v31 ) { - v34 = LODWORD(v21->pConditions[13]); - --v21->sHealth; - v35 = v21->sHealth; - if ( !(HIDWORD(v21->pConditions[13]) | v34) && v35 < 0 ) - v21->pConditions[13] = pParty->uTimePlayed; - if ( v35 < 1 ) - { - if ( v21->sHealth + v21->uEndurance + v21->GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) >= 1 - || (signed __int64)v21->pPlayerBuffs[11].uExpireTime > 0 ) - { - v21->pConditions[13] = pParty->uTimePlayed; - } - else - { - if ( !v21->pConditions[14] ) - v21->pConditions[14] = pParty->uTimePlayed; - } - } - v51 = 1; - } - if ( v45 ) - { - v36 = (char *)&v21->sMana; - ++*(int *)v36; - if ( v21->sMana > v21->GetMaxMana() ) - *(int *)v36 = v21->GetMaxMana(); + if ( pParty->pPlayers[v49].pInventoryItemList[v31].uItemID == ITEM_LICH_JAR_FULL ) + lich_jar_flag = true; } - if ( v48 && !v21->pConditions[14] && !v21->pConditions[16] ) - { - v37 = v21->sHealth; - if ( v37 > v21->GetMaxHealth() / 2 ) - v21->sHealth = v37 - 2; - v38 = v21->sMana; - if ( v38 > v21->GetMaxMana() / 2 ) - v21->sMana = v38 - 2; - } - if ( v46 && !v21->pConditions[14] && !v21->pConditions[16] ) - { - v39 = v21->sHealth; - if ( v39 > v21->GetMaxHealth() / 2 ) - v21->sHealth = v39 - 1; - v40 = v21->sMana; - if ( v40 > 0 ) - v21->sMana = v40 - 1; - } - ++v49; - if ( v49 >= 4 ) - { - result = HIDWORD(pParty->uTimePlayed); - pParty->uLastRegenerationTime = pParty->uTimePlayed; - if ( !viewparams->bRedrawGameUI ) - { - result = v51; - viewparams->bRedrawGameUI = v51; - } - return result; - } - goto LABEL_25; + lich_flag = true; + } + if ( lich_flag && !pParty->pPlayers[v49].pConditions[Condition_Dead] + && !pParty->pPlayers[v49].pConditions[Condition_Eradicated] ) + { + if ( pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() / 2 ) + pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].sHealth - 2; + if ( pParty->pPlayers[v49].sMana > pParty->pPlayers[v49].GetMaxMana() / 2 ) + pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].sMana - 2; + } + if ( lich_jar_flag ) + { + ++pParty->pPlayers[v49].sMana; + if ( pParty->pPlayers[v49].sMana > pParty->pPlayers[v49].GetMaxMana() ) + pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].GetMaxMana(); + } + + //for zombie + if ( pParty->pPlayers[v49].pConditions[Condition_Zombie] ) + zombie_flag = true; + if ( zombie_flag && !pParty->pPlayers[v49].pConditions[Condition_Dead] + && !pParty->pPlayers[v49].pConditions[Condition_Eradicated] ) + { + if ( pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() / 2 ) + pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].sHealth - 1; + if ( pParty->pPlayers[v49].sMana > 0 ) + pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].sMana - 1; } } + pParty->uLastRegenerationTime = pParty->uTimePlayed; + if ( !viewparams->bRedrawGameUI ) + viewparams->bRedrawGameUI = redraw_flag; } - return result; } //----- (00493F79) -------------------------------------------------------- @@ -739,90 +645,41 @@ void _494035_timed_effects__water_walking_damage__etc() { signed __int64 v0; // qax@1 - signed __int64 v1; // ST30_8@1 - signed __int64 v2; // ST38_8@1 - unsigned __int64 v3; // qax@1 unsigned int v4; // edi@1 - //signed int v5; // eax@4 - //char *v6; // ecx@5 - //Player *v7; // esi@8 - //char *v8; // ecx@12 - //Player *pPlayer; // esi@15 - //void *v10; // esi@25 - unsigned int v11; // ecx@27 signed int v12; // edi@29 - //Player *v13; // ecx@30 - //Player *v14; // esi@35 - //double v15; // st7@35 - Player **v16; // esi@43 - Player *v17; // edi@44 - double v18; // st7@44 - //float v19; // ST28_4@48 - //double v20; // ST38_8@48 - Player *v21; // esi@51 - signed int v22; // edi@53 - int v23; // eax@59 int v24; // ecx@60 - int v25; // eax@63 int v26; // ecx@64 - int v27; // eax@67 int v28; // ecx@68 - int v29; // eax@71 int v30; // ecx@72 - int v31; // eax@75 int v32; // ecx@76 - int v33; // eax@79 int v34; // ecx@80 - int v35; // eax@83 int v36; // ecx@84 - int v37; // eax@87 int v38; // ecx@88 - int v39; // eax@91 int v40; // ecx@92 - int v41; // eax@95 int v42; // ecx@96 bool v43; // ebx@102 - //SpellBuff *v44; // edi@104 - //signed int v45; // ebp@104 bool v46; // edi@111 - //SpellBuff *v47; // esi@113 - //Player **v48; // esi@119 - //signed int v49; // edi@121 - //char *v50; // esi@122 - signed int v51; // edx@128 - signed int v52; // ecx@130 - int v53; // eax@131 - Player *v54; // eax@141 - //unsigned int v55; // [sp-8h] [bp-38h]@18 unsigned int v56; // [sp-8h] [bp-38h]@55 - //int v57; // [sp-4h] [bp-34h]@18 - //int v58; // [sp-4h] [bp-34h]@33 int v59; // [sp-4h] [bp-34h]@55 - //unsigned int v60; // [sp+10h] [bp-20h]@1 unsigned int v61; // [sp+14h] [bp-1Ch]@1 - Player **v62; // [sp+14h] [bp-1Ch]@50 - //unsigned int a2; // [sp+18h] [bp-18h]@1 signed int a2a; // [sp+18h] [bp-18h]@47 - signed int v65; // [sp+1Ch] [bp-14h]@47 + signed int old_day; // [sp+1Ch] [bp-14h]@47 + signed int old_hour; - //a2 = pParty->uCurrentHour; - v61 = pParty->uDaysPlayed; + old_day = pParty->uDaysPlayed; + old_hour = pParty->uCurrentHour; //auto prev_time = pEventTimer->uTimeElapsed; pParty->uTimePlayed += pEventTimer->uTimeElapsed; - v0 = (signed __int64)(pParty->uTimePlayed * 0.234375) / 60; - v1 = v0; - v0 /= 60i64; - v2 = v0; - v3 = (unsigned int)v0 / 24; - v4 = (unsigned int)(v3 / 7) >> 2; + v0 = ((signed __int64)(pParty->uTimePlayed * 0.234375) / 60)/60i64; + v4 = (unsigned int)(((unsigned int)v0 / 24) / 7) >> 2; pParty->uCurrentTimeSecond = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) % 60; - pParty->uCurrentMinute = v1 % 60; - pParty->uCurrentMonthWeek = v3 / 7 & 3; - pParty->uCurrentHour = v2 % 24; - pParty->uDaysPlayed = (unsigned int)v3 % 28; + pParty->uCurrentMinute = ((signed __int64)(pParty->uTimePlayed * 0.234375) / 60) % 60; + pParty->uCurrentHour = v0 % 24; + pParty->uCurrentMonthWeek = ((unsigned int)v0 / 24) / 7 & 3; + pParty->uDaysPlayed = (unsigned int)((unsigned int)v0 / 24) % 28; pParty->uCurrentMonth = v4 % 12; pParty->uCurrentYear = v4 / 0xC + game_starting_year; - if ( pParty->uCurrentHour >= 3 && (pParty->uCurrentHour < 3 || pParty->uDaysPlayed > v61) ) // new day dawns + if ( pParty->uCurrentHour >= 3 && (old_hour < 3 || pParty->uDaysPlayed > old_day) ) // new day dawns { pParty->pHirelings[0].bHasUsedTheAbility = false; pParty->pHirelings[1].bHasUsedTheAbility = false; @@ -843,20 +700,18 @@ pParty->pPlayers[i].sHealth = pParty->pPlayers[i].sHealth / (pParty->days_played_without_rest + 1) + 1; if (pParty->days_played_without_rest > 3) - for (uint i = 0; i < 4; ++i) + for ( uint i = 0; i < 4; ++i ) + { + pParty->pPlayers[i].Zero(); + if (!pParty->pPlayers[i].IsPertified() && !pParty->pPlayers[i].IsEradicated() + && !pParty->pPlayers[i].IsDead()) { - Player* player = &pParty->pPlayers[i]; - - player->Zero(); - - if (!player->IsPertified() && !player->IsEradicated() && !player->IsDead()) - { - if (rand() % 100 < 5 * pParty->days_played_without_rest) - player->SetCondDeadWithBlockCheck(0); - if (rand() % 100 < 10 * pParty->days_played_without_rest) - player->SetCondInsaneWithBlockCheck(0); - } + if (rand() % 100 < 5 * pParty->days_played_without_rest) + pParty->pPlayers[i].SetCondDeadWithBlockCheck(0); + if (rand() % 100 < 10 * pParty->days_played_without_rest) + pParty->pPlayers[i].SetCondInsaneWithBlockCheck(0); } + } } if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) pOutdoor->SetFog(); @@ -865,259 +720,198 @@ pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0; } - v11 = LODWORD(pParty->uTimePlayed); - if ( pParty->uFlags & 4 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed )//water damage error + if ( pParty->uFlags & 4 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed )//water damage { - //v12 = 1; - pParty->field_6FC = LODWORD(pParty->uTimePlayed) + 128; - viewparams->bRedrawGameUI = 1; - //while ( 1 ) - for ( v12 = 1; v12 <= 4; ++v12 ) + pParty->field_6FC = (signed __int64)pParty->uTimePlayed + 128; + viewparams->bRedrawGameUI = true; + for ( uint pl = 1; pl <= 4; ++pl ) { - if ( pPlayers[v12]->WearsItem(ITEM_RELIC_HARECS_LEATHER, EQUIP_ARMOUR) - || pPlayers[v12]->HasEnchantedItemEquipped(71) - || pPlayers[v12]->pPlayerBuffs[23].uExpireTime > 0 ) - { - //v58 = 0; - pPlayers[v12]->PlayEmotion(CHARACTER_EXPRESSION_37, 0); - } + if ( pPlayers[pl]->WearsItem(ITEM_RELIC_HARECS_LEATHER, EQUIP_ARMOUR) + || pPlayers[pl]->HasEnchantedItemEquipped(71) + || pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_WATER_WALK].uExpireTime > 0 ) + pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_37, 0); else { - //v58 = 0; - if ( !pPlayers[v12]->HasUnderwaterSuitEquipped() ) + if ( !pPlayers[pl]->HasUnderwaterSuitEquipped() ) { - //v14 = pPlayers[v12]; - //v15 = (double)pPlayers[v12]->GetMaxHealth() * 0.1; - pPlayers[v12]->ReceiveDamage((signed __int64)pPlayers[v12]->GetMaxHealth() * 0.1, DMGT_FIRE); + pPlayers[pl]->ReceiveDamage((signed __int64)pPlayers[pl]->GetMaxHealth() * 0.1, DMGT_FIRE); if ( pParty->uFlags & 4 ) { - strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[660]); + strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[660]);// ! GameUI_Footer_TimeLeft = 128; } } - else - pPlayers[v12]->PlayEmotion(CHARACTER_EXPRESSION_37, 0); - } - //++v12; - //if ( v12 > 4 ) - //{ - //v11 = LODWORD(pParty->uTimePlayed); - //break; + else + pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_37, 0); } - v11 = LODWORD(pParty->uTimePlayed); - //} + } } - if ( pParty->uFlags & 0x200 && pParty->field_6FC < (signed __int64)__PAIR__(HIDWORD(pParty->uTimePlayed), v11) ) + if ( pParty->uFlags & 0x200 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed ) //lava damage { - viewparams->bRedrawGameUI = 1; - pParty->field_6FC = v11 + 128; - v16 = &pPlayers[1]; - do + viewparams->bRedrawGameUI = true; + pParty->field_6FC = (signed __int64)pParty->uTimePlayed + 128; + + for ( uint pl = 1; pl <= 4; pl++ ) { - v17 = *v16; - v18 = (double)(*v16)->GetMaxHealth() * 0.1; - v17->ReceiveDamage((signed __int64)v18, DMGT_FIRE); + pPlayers[pl]->ReceiveDamage((signed __int64)pPlayers[pl]->GetMaxHealth() * 0.1, DMGT_FIRE); if ( pParty->uFlags & 0x200 ) { - strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[661]); + strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[661]); // ! GameUI_Footer_TimeLeft = 128; } - ++v16; } - while ( (signed int)v16 <= (signed int)&pPlayers[4] ); } _493938_regenerate(); - v65 = 4; + uint party_condition_flag = 4; a2a = pEventTimer->uTimeElapsed; - if ( pParty->uFlags2 & PARTY_FLAGS_2_RUNNING ) + if ( pParty->uFlags2 & PARTY_FLAGS_2_RUNNING )// { - //v19 = (double)(signed int)prev_time * 0.5; - //v20 = v19 + 6.7553994e15; a2a *= 0.5f; if (a2a < 1) a2a = 1; } - v62 = &pPlayers[1]; - do + + for ( uint pl = 1; pl <= 4; pl++ ) { - v21 = *v62; - if ( (*v62)->uTimeToRecovery ) - v21->Recover(a2a); - v22 = v21->sHealth; - if ( v21->GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) + v22 + v21->uEndurance >= 1 - || (signed __int64)v21->pPlayerBuffs[11].uExpireTime > 0 ) + if ( pPlayers[pl]->uTimeToRecovery ) + pPlayers[pl]->Recover(a2a);// + if ( pPlayers[pl]->GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) + pPlayers[pl]->sHealth + pPlayers[pl]->uEndurance >= 1 + || (signed __int64)pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0 ) { - if ( v22 < 1 ) - { - v59 = 0; - v56 = 13; - v21->SetCondition(v56, v59); - } + if ( pPlayers[pl]->sHealth < 1 ) + pPlayers[pl]->SetCondition(Condition_Unconcious, 0); } else + pPlayers[pl]->SetCondition(Condition_Dead, 0); + if ( pPlayers[pl]->field_E0 ) { - v59 = 0; - v56 = 14; - v21->SetCondition(v56, v59); - } - v23 = (int)&v21->field_E0; - if ( v21->field_E0 ) - { - v24 = *(int *)v23 - pEventTimer->uTimeElapsed; + v24 = pPlayers[pl]->field_E0 - pEventTimer->uTimeElapsed; if ( v24 > 0 ) - { - *(int *)v23 = v24; - } + pPlayers[pl]->field_E0 = v24; else { - *(int *)v23 = 0; - viewparams->bRedrawGameUI = 1; + pPlayers[pl]->field_E0 = 0; + viewparams->bRedrawGameUI = true; } } - v25 = (int)&v21->field_E4; - if ( v21->field_E4 ) + if ( pPlayers[pl]->field_E4 ) { - v26 = *(int *)v25 - pEventTimer->uTimeElapsed; + v26 = pPlayers[pl]->field_E4 - pEventTimer->uTimeElapsed; if ( v26 > 0 ) - { - *(int *)v25 = v26; - } + pPlayers[pl]->field_E4 = v26; else { - *(int *)v25 = 0; - viewparams->bRedrawGameUI = 1; + pPlayers[pl]->field_E4 = 0; + viewparams->bRedrawGameUI = true; } } - v27 = (int)&v21->field_E8; - if ( v21->field_E8 ) + if ( pPlayers[pl]->field_E8 ) { - v28 = *(int *)v27 - pEventTimer->uTimeElapsed; + v28 = pPlayers[pl]->field_E8 - pEventTimer->uTimeElapsed; if ( v28 > 0 ) - { - *(int *)v27 = v28; - } + pPlayers[pl]->field_E8 = v28; else { - *(int *)v27 = 0; - viewparams->bRedrawGameUI = 1; + pPlayers[pl]->field_E8 = 0; + viewparams->bRedrawGameUI = true; } } - v29 = (int)&v21->field_EC; - if ( v21->field_EC ) + if ( pPlayers[pl]->field_EC ) { - v30 = *(int *)v29 - pEventTimer->uTimeElapsed; + v30 = pPlayers[pl]->field_EC - pEventTimer->uTimeElapsed; if ( v30 > 0 ) - { - *(int *)v29 = v30; - } + pPlayers[pl]->field_EC = v30; else { - *(int *)v29 = 0; - viewparams->bRedrawGameUI = 1; + pPlayers[pl]->field_EC = 0; + viewparams->bRedrawGameUI = true; + } + } + if ( pPlayers[pl]->field_F0 ) + { + v32 = pPlayers[pl]->field_F0 - pEventTimer->uTimeElapsed; + if ( v32 > 0 ) + pPlayers[pl]->field_F0 = v32; + else + { + pPlayers[pl]->field_F0 = 0; + viewparams->bRedrawGameUI = true; } } - v31 = (int)&v21->field_F0; - if ( v21->field_F0 ) + if ( pPlayers[pl]->field_F4 ) { - v32 = *(int *)v31 - pEventTimer->uTimeElapsed; - if ( v32 > 0 ) - { - *(int *)v31 = v32; - } + v34 = pPlayers[pl]->field_F4 - pEventTimer->uTimeElapsed; + if ( v34 > 0 ) + pPlayers[pl]->field_F4 = v34; else { - *(int *)v31 = 0; - viewparams->bRedrawGameUI = 1; + pPlayers[pl]->field_F4 = 0; + viewparams->bRedrawGameUI = true; } } - v33 = (int)&v21->field_F4; - if ( v21->field_F4 ) + if ( pPlayers[pl]->field_F8 ) { - v34 = *(int *)v33 - pEventTimer->uTimeElapsed; - if ( v34 > 0 ) - { - *(int *)v33 = v34; - } + v36 = pPlayers[pl]->field_F8 - pEventTimer->uTimeElapsed; + if ( v36 > 0 ) + pPlayers[pl]->field_F8 = v36; else { - *(int *)v33 = 0; - viewparams->bRedrawGameUI = 1; + pPlayers[pl]->field_F8 = 0; + viewparams->bRedrawGameUI = true; } } - v35 = (int)&v21->field_F8; - if ( v21->field_F8 ) + if ( pPlayers[pl]->field_FC ) { - v36 = *(int *)v35 - pEventTimer->uTimeElapsed; - if ( v36 > 0 ) - { - *(int *)v35 = v36; - } + v38 = pPlayers[pl]->field_FC - pEventTimer->uTimeElapsed; + if ( v38 > 0 ) + pPlayers[pl]->field_FC = v38; else { - *(int *)v35 = 0; - viewparams->bRedrawGameUI = 1; + pPlayers[pl]->field_FC = 0; + viewparams->bRedrawGameUI = true; } } - v37 = (int)&v21->field_FC; - if ( v21->field_FC ) + if ( pPlayers[pl]->field_100 ) { - v38 = *(int *)v37 - pEventTimer->uTimeElapsed; - if ( v38 > 0 ) - { - *(int *)v37 = v38; - } + v40 = pPlayers[pl]->field_100 - pEventTimer->uTimeElapsed; + if ( v40 > 0 ) + pPlayers[pl]->field_100 = v40; else { - *(int *)v37 = 0; - viewparams->bRedrawGameUI = 1; + pPlayers[pl]->field_100 = 0; + viewparams->bRedrawGameUI = true; } } - v39 = (int)&v21->field_100; - if ( v21->field_100 ) + if ( pPlayers[pl]->field_104 ) { - v40 = *(int *)v39 - pEventTimer->uTimeElapsed; - if ( v40 > 0 ) - { - *(int *)v39 = v40; - } + v42 = pPlayers[pl]->field_104 - pEventTimer->uTimeElapsed; + if ( v42 > 0 ) + pPlayers[pl]->field_104 = v42; else { - *(int *)v39 = 0; - viewparams->bRedrawGameUI = 1; + pPlayers[pl]->field_104 = 0; + viewparams->bRedrawGameUI = true; } } - v41 = (int)&v21->field_104; - if ( v21->field_104 ) - { - v42 = *(int *)v41 - pEventTimer->uTimeElapsed; - if ( v42 > 0 ) - { - *(int *)v41 = v42; - } - else - { - *(int *)v41 = 0; - viewparams->bRedrawGameUI = 1; - } - } - if ( v21->pConditions[2] | v21->pConditions[12] | v21->pConditions[13] | v21->pConditions[14] | v21->pConditions[15] | v21->pConditions[16] ) - --v65; - v43 = (signed __int64)v21->pPlayerBuffs[7].uExpireTime > 0; + if ( pPlayers[pl]->pConditions[Condition_Sleep] | pPlayers[pl]->pConditions[Condition_Paralyzed] + | pPlayers[pl]->pConditions[Condition_Unconcious] | pPlayers[pl]->pConditions[Condition_Dead] + | pPlayers[pl]->pConditions[Condition_Pertified] | pPlayers[pl]->pConditions[Condition_Eradicated] ) + --party_condition_flag; + v43 = (signed __int64)pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime > 0; // - for (uint k = 0; k < 24; ++k) - v21->pPlayerBuffs[k].IsBuffExpiredToTime(pParty->uTimePlayed); + for ( uint k = 0; k < 24; ++k ) + pPlayers[pl]->pPlayerBuffs[k].IsBuffExpiredToTime(pParty->uTimePlayed); - if ( v43 && (signed __int64)v21->pPlayerBuffs[7].uExpireTime <= 0 ) - v21->SetCondition(1u, 0); - ++v62; + if ( v43 && (signed __int64)pPlayers[pl]->pPlayerBuffs[7].uExpireTime <= 0 ) + pPlayers[pl]->SetCondition(Condition_Weak, 0); } - while ( (signed int)v62 <= (signed int)&pPlayers[4] ); + v46 = (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime > 0; for (uint i = 0; i < 20; ++i) { if (pParty->pPartyBuffs[i].IsBuffExpiredToTime(pParty->uTimePlayed) == 1) - viewparams->bRedrawGameUI = 1; + viewparams->bRedrawGameUI = true; } if ( v46 && (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime <= 0 ) @@ -1137,48 +931,42 @@ if (!pPlayers[pBuf->uCaster]->CanAct()) { pBuf->Reset(); - if (dword_4EE07C[i] == 7 ) + if (dword_4EE07C[i] == PARTY_BUFF_FLY ) pParty->bFlying = false; } } } - v51 = v65; - if ( v65 ) - goto LABEL_135; - if ( pCurrentScreen != SCREEN_REST ) - { - v52 = (signed int)&pPlayers[1]; - while ( 1 ) - { - v53 = *(int *)v52; - if ( *(_QWORD *)(*(int *)v52 + 16) ) - break; - v52 += 4; - if ( v52 > (signed int)&pPlayers[4] ) - goto LABEL_135; - } - *(int *)(v53 + 16) = 0; - *(int *)(v53 + 20) = 0; - v51 = 1; -LABEL_135: - if ( pCurrentScreen != SCREEN_REST - && (!v51 || dword_5C35C0) ) - uGameState = GAME_STATE_PARTY_DIED; - } - if ( uActiveCharacter ) + if ( !party_condition_flag ) { if ( pCurrentScreen != SCREEN_REST ) { - v54 = pPlayers[uActiveCharacter]; - if ( v54->pConditions[2] - || v54->pConditions[12] - || v54->pConditions[13] - || v54->pConditions[14] - || v54->pConditions[15] - || v54->pConditions[16] ) + for ( uint pl = 1; pl <= 4; pl++ ) { - viewparams->bRedrawGameUI = 1; + if ( pPlayers[pl]->pConditions[Condition_Sleep] ) + { + pPlayers[pl]->pConditions[Condition_Sleep] = 0; + party_condition_flag = 1; + break; + } + } + if ( !party_condition_flag || dword_5C35C0 ) + uGameState = GAME_STATE_PARTY_DIED; + } + } + + if ( uActiveCharacter )// + { + if ( pCurrentScreen != SCREEN_REST ) + { + if ( pPlayers[uActiveCharacter]->pConditions[Condition_Sleep] + || pPlayers[uActiveCharacter]->pConditions[Condition_Paralyzed] + || pPlayers[uActiveCharacter]->pConditions[Condition_Unconcious] + || pPlayers[uActiveCharacter]->pConditions[Condition_Dead] + || pPlayers[uActiveCharacter]->pConditions[Condition_Pertified] + || pPlayers[uActiveCharacter]->pConditions[Condition_Eradicated] ) + { + viewparams->bRedrawGameUI = true; uActiveCharacter = pParty->GetNextActiveCharacter(); } } @@ -3411,7 +3199,7 @@ } //----- (004BDAAF) -------------------------------------------------------- -bool __fastcall MerchandiseTest(ItemGen *item, int _2da_idx) +bool MerchandiseTest(ItemGen *item, int _2da_idx) { int v6; // edx@8 int v7; // edx@9 @@ -3423,28 +3211,28 @@ if ( (p2DEvents[_2da_idx - 1].uType != 4 || (signed int)item->uItemID < 740 || (signed int)item->uItemID > 771) && ((signed int)item->uItemID >= 600 || (signed int)item->uItemID >= 529 && (signed int)item->uItemID <= 599) || item->IsStolen()) - return 0; + return false; switch( p2DEvents[_2da_idx - 1].uType ) { case BuildingType_WeaponShop: { - test = item->GetItemEquipType() <= 2; + test = item->GetItemEquipType() <= EQUIP_BOW; break; } case BuildingType_ArmorShop: { - test = item->GetItemEquipType() >= 3; + test = item->GetItemEquipType() >= EQUIP_ARMOUR && item->GetItemEquipType() <= EQUIP_BOOTS; break; } case BuildingType_MagicShop: { - test = item->GetPlayerSkillType() == 38 || item->GetItemEquipType() == 16; + test = item->GetPlayerSkillType() == PLAYER_SKILL_MISC || item->GetItemEquipType() == EQIUP_ANY; break; } case BuildingType_AlchemistShop: { - test = item->GetItemEquipType() == 13 || item->GetItemEquipType() == 14 - || (item->GetItemEquipType() > 14 && !(item->GetItemEquipType() != 17 + test = item->GetItemEquipType() == EQUIP_REAGENT || item->GetItemEquipType() == EQUIP_POTION + || (item->GetItemEquipType() > EQUIP_POTION && !(item->GetItemEquipType() != EQUIP_MESSAGE_SCROLL || (signed int)item->uItemID < 740) && item->uItemID != 771); break; } @@ -3455,54 +3243,4 @@ } } return test; -/* - if ( p2DEvents[a2 - 1].uType == 1 ) - { - v11 = __OFSUB__(v5, 2); - v9 = v5 == 2; - v10 = v5 - 2 < 0; - goto LABEL_23; - } - if ( p2DEvents[a2 - 1].uType > 2 ) - { - if ( p2DEvents[a2 - 1].uType == 3 ) - { - if ( pItemsTable->pItems[v4].uSkillType != 38 ) - return v5 == 16; - return 1; - } - if ( p2DEvents[a2 - 1].uType != 4 || v5 < 13 ) - return 0; - if ( p2DEvents[a2 - 1].uType == 4) - { - if ( v5 < 13 ) - return 0; - if ( v5 <= 14 ) - return 1; - if ( v5 != 17 || (signed int)v3 < 740 ) - return 0; - v11 = __OFSUB__(v3, 771); - v9 = v3 == 771; - v10 = ((v3 - 771) & 0x80000000u) != 0; -LABEL_23: - if ( !((unsigned __int8)(v10 ^ v11) | v9) ) - return 0; - return 1; - } - } - if ( p2DEvents[a2 - 1].uType == 2 ) - { - if ( v5 >= 3 ) - { - v11 = __OFSUB__(v5, 9); - v9 = v5 == 9; - v10 = v5 - 9 < 0; - goto LABEL_23; - } - } - return 0; -*/ -} - - - +} \ No newline at end of file