# HG changeset patch # User Nomad # Date 1378551798 -7200 # Node ID 7d986a3960920941f23e76b316f1644899917188 # Parent 86cb7398d2a85de370de0a900bb40538c894242a# Parent 6e4980797714967cce701479e9b4347498d523a5 Merge diff -r 86cb7398d2a8 -r 7d986a396092 Actor.cpp --- a/Actor.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/Actor.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -42,7 +42,7 @@ std::array pActors; -int uNumActors; +size_t uNumActors; stru319 stru_50C198; // idb @@ -294,7 +294,7 @@ } //----- (00404AC7) -------------------------------------------------------- -void __fastcall Actor::AI_SpellAttack(unsigned int uActorID, AIDirection *pDir, int spellnum, int a4, unsigned int uSkillLevel) +void __fastcall Actor::AI_SpellAttack(unsigned int uActorID, AIDirection *pDir, int uSpellID, int a4, unsigned int uSkillLevel) { Actor *v5; // esi@1 unsigned int v6; // edi@1 @@ -426,25 +426,25 @@ v117 = pDir; v6 = uSkillLevel & 0x3F; v7 = SkillToMastery(uSkillLevel); - if ( spellnum <= 47 ) + if ( uSpellID <= 47 ) { - if ( spellnum != 47 ) + if ( uSpellID != 47 ) { - if ( spellnum <= 18 ) + if ( uSpellID <= 18 ) { - if ( spellnum == 18 || spellnum == 2 ) + if ( uSpellID == 18 || uSpellID == 2 ) goto LABEL_159; - if ( spellnum != 5 ) + if ( uSpellID != 5 ) { - if ( spellnum == 6 ) + if ( uSpellID == 6 ) goto LABEL_159; - if ( spellnum != 9 ) + if ( uSpellID != 9 ) { - if ( spellnum != 11 ) + if ( uSpellID != 11 ) { - if ( spellnum != 15 ) + if ( uSpellID != 15 ) { - if ( spellnum != 17 ) + if ( uSpellID != 17 ) return; if ( (signed int)v7 <= 0 ) goto LABEL_20; @@ -577,7 +577,7 @@ return; } LABEL_159: - a1.uType = stru_4E3ACC[spellnum].uType; + a1.uType = stru_4E3ACC[uSpellID].uType; v119 = 0.0; if ( (signed int)pObjectList->uNumObjects <= 0 ) { @@ -598,7 +598,7 @@ } a1.uObjectDescID = v82; a1.stru_24.Reset(); - a1.spell_id = spellnum; + a1.spell_id = uSpellID; v83 = v5->vPosition.x; v84 = v5->vPosition.y; a1.spell_level = uSkillLevel; @@ -660,7 +660,7 @@ LOBYTE(v92) = v92 | 2; v100 = 0; v99 = v92; - v22 = (SoundID)word_4EE088_sound_ids[spellnum]; + v22 = (SoundID)word_4EE088_sound_ids[uSpellID]; goto LABEL_202; } return; @@ -844,13 +844,13 @@ v39 = 0; goto LABEL_79; } - if ( spellnum == 26 || spellnum == 29 ) + if ( uSpellID == 26 || uSpellID == 29 ) goto LABEL_159; - if ( spellnum != 38 ) + if ( uSpellID != 38 ) { - if ( spellnum == 39 || spellnum == 41 ) + if ( uSpellID == 39 || uSpellID == 41 ) goto LABEL_159; - if ( spellnum != 46 ) + if ( uSpellID != 46 ) return; if ( (signed int)v7 > 0 ) { @@ -971,9 +971,9 @@ LOWORD(v48) = 0; goto LABEL_114; } - if ( spellnum <= 80 ) + if ( uSpellID <= 80 ) { - if ( spellnum == 80 ) + if ( uSpellID == 80 ) { v56 = pParty->pPartyBuffs; do @@ -1019,11 +1019,11 @@ v22 = (SoundID)word_4EE088_sound_ids[80]; goto LABEL_202; } - if ( spellnum != 51 ) + if ( uSpellID != 51 ) { - if ( spellnum == 57 || spellnum == 65 || spellnum == 70 ) + if ( uSpellID == 57 || uSpellID == 65 || uSpellID == 70 ) goto LABEL_159; - if ( spellnum == 73 ) + if ( uSpellID == 73 ) { if ( (signed int)v7 <= 0 || (signed int)v7 > 4 ) v51 = 0; @@ -1048,7 +1048,7 @@ v98 = (SoundID)16060; goto LABEL_222; } - if ( spellnum == 77 ) + if ( uSpellID == 77 ) { v5->sCurrentHP += 5 * v6 + 10; if ( v5->sCurrentHP >= (signed int)v5->pMonsterInfo.uHP ) @@ -1057,7 +1057,7 @@ v47 = 0; goto LABEL_127; } - v49 = spellnum == 78; + v49 = uSpellID == 78; LABEL_158: if ( !v49 ) return; @@ -1104,7 +1104,7 @@ v54 = 0; goto LABEL_142; } - if ( spellnum == 85 ) + if ( uSpellID == 85 ) { if ( (signed int)v7 > 0 ) { @@ -1148,7 +1148,7 @@ v96 = 0; goto LABEL_221; } - if ( spellnum == 86 ) + if ( uSpellID == 86 ) { if ( (signed int)v7 > 0 ) { @@ -1191,13 +1191,13 @@ v94 = 0; goto LABEL_212; } - if ( spellnum == 90 ) + if ( uSpellID == 90 ) goto LABEL_159; - if ( spellnum != 93 ) + if ( uSpellID != 93 ) { - if ( spellnum != 95 ) + if ( uSpellID != 95 ) { - v49 = spellnum == 97; + v49 = uSpellID == 97; goto LABEL_158; } if ( (signed int)v7 > 0 ) @@ -2308,7 +2308,7 @@ result = pPlayer->CanAct(); if ( result ) { - pCastSpellInfo.data()->_427D48(v1); + CastSpellInfoHelpers::_427D48(); v4 = 0; v5 = pMapStats->GetMapInfo(pCurrentMapName); if ( v5 ) @@ -2985,8 +2985,8 @@ actor->UpdateAnimation(); for (uint i = 0; i < 5; ++i) - if (pParty->field_750[i] == actor->pMonsterInfo.uID) - pParty->field_75A[i] = true; + if (pParty->monster_id_for_hunting[i] == actor->pMonsterInfo.uID) + pParty->monster_for_hunting_killed[i] = true; for (uint i = 0; i < 22; ++i) actor->pActorBuffs[i].Reset(); @@ -3468,7 +3468,7 @@ if ( v23 <= v11 && v27 <= v11 && v12 <= v11 - && sub_4070EF_prolly_collide_objects(PID(OBJECT_Actor, i), PID(OBJECT_Actor, uActorID)) + && sub_4070EF_prolly_detect_player(PID(OBJECT_Actor, i), PID(OBJECT_Actor, uActorID)) && v23 * v23 + v27 * v27 + v19 * v19 < (unsigned int)v25 ) { v25 = v23 * v23 + v27 * v27 + v19 * v19; diff -r 86cb7398d2a8 -r 7d986a396092 Actor.h --- a/Actor.h Sat Sep 07 12:51:06 2013 +0200 +++ b/Actor.h Sat Sep 07 13:03:18 2013 +0200 @@ -214,7 +214,7 @@ static struct AIDirection *__fastcall GetDirectionInfo(unsigned int uObj1ID, unsigned int uObj2ID, struct AIDirection *pOut, int a4); static signed int __fastcall Explode(unsigned int uActorID); static char __fastcall AI_RangedAttack(unsigned int uActorID, struct AIDirection *a2, int type, char a4); - static void __fastcall AI_SpellAttack(unsigned int uActorID, struct AIDirection *pDir, int spellnum, int a4, unsigned int uSkillLevel); + static void __fastcall AI_SpellAttack(unsigned int uActorID, struct AIDirection *pDir, int uSpellID, int a4, unsigned int uSkillLevel); static void AggroSurroundingPeasants(unsigned int uActorID, int a2); static bool ArePeasantsOfSameFaction(Actor *a1, Actor *a2); static bool StealFrom(unsigned int uActorID); @@ -274,6 +274,5 @@ //extern Actor pMonsterInfoUI_Doll; - extern std::array pActors; -extern int uNumActors; \ No newline at end of file +extern size_t uNumActors; diff -r 86cb7398d2a8 -r 7d986a396092 Arcomage.cpp --- a/Arcomage.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/Arcomage.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -447,10 +447,10 @@ } //----- (0040DFC1) -------------------------------------------------------- -void ArcomageGame::OnMouseMove(POINT *pXY) +void ArcomageGame::OnMouseMove(int x, int y) { - pArcomageGame->mouse_x = pXY->x; - pArcomageGame->mouse_y = pXY->y; + pArcomageGame->mouse_x = x; + pArcomageGame->mouse_y = y; } diff -r 86cb7398d2a8 -r 7d986a396092 Arcomage.h --- a/Arcomage.h Sat Sep 07 12:51:06 2013 +0200 +++ b/Arcomage.h Sat Sep 07 13:03:18 2013 +0200 @@ -141,7 +141,7 @@ static bool MsgLoop(int a1, ArcomageGame_stru1 *a2); static void PlaySound(unsigned int event_id); static void OnMouseClick(char right_left, bool bDown); - static void OnMouseMove(POINT *pXY); + static void OnMouseMove(int x, int y); static void GetCardRect(unsigned int uCardID, RECT *pCardRect); static void Loop(); diff -r 86cb7398d2a8 -r 7d986a396092 AudioPlayer.cpp --- a/AudioPlayer.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/AudioPlayer.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -1681,7 +1681,7 @@ auto decor_desc = &pDecorationList->pDecorations[decor->uDecorationDescID]; //v48 = &pDecorationList->pDecorations[decor->uDecorationDescID]; //v49 = v48->uFlags; - uNumRepeats = (~(unsigned __int8)decor_desc->uFlags & DECORATION_SLOW_LOOP) >> 6; + uNumRepeats = (~(unsigned __int8)decor_desc->uFlags & DECORATION_DESC_SLOW_LOOP) >> 6; if (decor_desc->SoundOnDawn() || decor_desc->SoundOnDusk()) { diff -r 86cb7398d2a8 -r 7d986a396092 CastSpellInfo.cpp --- a/CastSpellInfo.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/CastSpellInfo.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -25,8 +25,11 @@ #include "texts.h" #include "LOD.h" +const size_t CastSpellInfoCount = 10; +std::array pCastSpellInfo; + //----- (00427E01) -------------------------------------------------------- -void CastSpellInfo::_427E01_cast_spell() +void CastSpellInfoHelpers::_427E01_cast_spell() { int v2; // edi@1 CastSpellInfo *pCastSpell; // ebx@2 @@ -306,20 +309,20 @@ LODWORD(v733) = 0; v723 = 0; v727 = 0.0; - for(n = 0; n < 10; ++n) + for(n = 0; n < CastSpellInfoCount; ++n) { - pCastSpell = &this[n]; + pCastSpell = &pCastSpellInfo[n]; HIDWORD(v733) = (int)pCastSpell; - if ( pCastSpell->spellnum == 0 ) + if ( pCastSpell->uSpellID == 0 ) continue; if (pParty->Invisible()) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); - if ( pCastSpell->field_8 & 0x3CA ) + if ( pCastSpell->uFlags & 0x3CA ) { if ( !pParty->pPlayers[pCastSpell->uPlayerID].CanAct() ) - this->_427D48(1); + _427D48(); continue; } pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID]; @@ -327,9 +330,9 @@ a2 = pCastSpell->spell_target_pid; if (!pCastSpell->spell_target_pid) { - if (pCastSpell->spellnum == SPELL_LIGHT_DESTROY_UNDEAD || - pCastSpell->spellnum == SPELL_SPIRIT_TURN_UNDEAD || - pCastSpell->spellnum == SPELL_DARK_CONTROL_UNDEAD ) + if (pCastSpell->uSpellID == SPELL_LIGHT_DESTROY_UNDEAD || + pCastSpell->uSpellID == SPELL_SPIRIT_TURN_UNDEAD || + pCastSpell->uSpellID == SPELL_DARK_CONTROL_UNDEAD ) v666 = 1; else v666 = 0; @@ -341,7 +344,7 @@ } - pSpellSprite.uType = stru_4E3ACC[pCastSpell->spellnum].uType; + pSpellSprite.uType = stru_4E3ACC[pCastSpell->uSpellID].uType; if (pSpellSprite.uType) { if (PID_TYPE(a2) == OBJECT_Actor) @@ -367,25 +370,25 @@ else { //v667 = PLAYER_SKILL_STAFF; - if (pCastSpell->spellnum < SPELL_AIR_WIZARD_EYE) + if (pCastSpell->uSpellID < SPELL_AIR_WIZARD_EYE) v667 = PLAYER_SKILL_FIRE; - else if (pCastSpell->spellnum < SPELL_WATER_AWAKEN) + else if (pCastSpell->uSpellID < SPELL_WATER_AWAKEN) v667 = PLAYER_SKILL_AIR; - else if (pCastSpell->spellnum < SPELL_EARTH_STUN) + else if (pCastSpell->uSpellID < SPELL_EARTH_STUN) v667 = PLAYER_SKILL_WATER; - else if (pCastSpell->spellnum < SPELL_SPIRIT_DETECT_LIFE) + else if (pCastSpell->uSpellID < SPELL_SPIRIT_DETECT_LIFE) v667 = PLAYER_SKILL_EARTH; - else if (pCastSpell->spellnum < SPELL_MIND_REMOVE_FEAR) + else if (pCastSpell->uSpellID < SPELL_MIND_REMOVE_FEAR) v667 = PLAYER_SKILL_SPIRIT; - else if (pCastSpell->spellnum < SPELL_BODY_CURE_WEAKNESS) + else if (pCastSpell->uSpellID < SPELL_BODY_CURE_WEAKNESS) v667 = PLAYER_SKILL_MIND; - else if (pCastSpell->spellnum < SPELL_LIGHT_LIGHT_BOLT) + else if (pCastSpell->uSpellID < SPELL_LIGHT_LIGHT_BOLT) v667 = PLAYER_SKILL_BODY; - else if (pCastSpell->spellnum < SPELL_DARK_REANIMATE) + else if (pCastSpell->uSpellID < SPELL_DARK_REANIMATE) v667 = PLAYER_SKILL_LIGHT; - else if (pCastSpell->spellnum < SPELL_BOW_ARROW) + else if (pCastSpell->uSpellID < SPELL_BOW_ARROW) v667 = PLAYER_SKILL_DARK; - else if (pCastSpell->spellnum == SPELL_BOW_ARROW) + else if (pCastSpell->uSpellID == SPELL_BOW_ARROW) v667 = PLAYER_SKILL_BOW; else assert(false && "Unknown spell"); @@ -400,21 +403,21 @@ if (pCastSpell->forced_spell_skill_level) uRequiredMana = 0; else - uRequiredMana = pSpellDatas[pCastSpell->spellnum - 1].mana_per_skill[v731 - 1]; - sRecoveryTime = pSpellDatas[pCastSpell->spellnum - 1].recovery_per_skill[v731 - 1]; + uRequiredMana = pSpellDatas[pCastSpell->uSpellID - 1].mana_per_skill[v731 - 1]; + sRecoveryTime = pSpellDatas[pCastSpell->uSpellID - 1].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) uRequiredMana = 0; - if (pCastSpell->spellnum < SPELL_BOW_ARROW && pPlayer->sMana < uRequiredMana) + if (pCastSpell->uSpellID < SPELL_BOW_ARROW && pPlayer->sMana < uRequiredMana) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[586], 2u); // "Not enough spell points" - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } - v730 = pCastSpell->spellnum; - if (pPlayer->IsCursed() && pCastSpell->spellnum < SPELL_BOW_ARROW && rand() % 100 < 50) + v730 = pCastSpell->uSpellID; + if (pPlayer->IsCursed() && pCastSpell->uSpellID < SPELL_BOW_ARROW && rand() % 100 < 50) { if (!pParty->bTurnBasedModeOn) { @@ -428,18 +431,18 @@ //v646 = pPlayer; //v648 = sRecoveryTime; //v649 = pPlayer; - pParty->pTurnBasedPlayerRecoveryTimes[this[n].uPlayerID] = 100; + pParty->pTurnBasedPlayerRecoveryTimes[pCastSpellInfo[n].uPlayerID] = 100; pPlayer->SetRecoveryTime(sRecoveryTime); pTurnEngine->ApplyPlayerAction(); } ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); // "Spell failed" pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - this[n].spellnum = 0; + pCastSpellInfo[n].uSpellID = 0; pPlayer->sMana -= uRequiredMana; return; } - switch ( pCastSpell->spellnum ) + switch ( pCastSpell->uSpellID ) { case SPELL_101: assert(false && "Unknown spell effect #101 (prolly flaming bow arrow"); @@ -451,7 +454,7 @@ sRecoveryTime = pPlayer->GetAttackRecoveryTime(true); pSpellSprite.stru_24.Reset(); pSpellSprite.spell_level = v2; - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); if ( pPlayer->WearsItem(ITEM_ARTEFACT_ULLYSES, EQUIP_BOW) ) @@ -486,7 +489,7 @@ { sRecoveryTime = pPlayer->GetAttackRecoveryTime(0); pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v723; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -569,13 +572,13 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -606,7 +609,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if (PID_TYPE(a2) != OBJECT_Actor) @@ -618,7 +621,7 @@ v697.y = 0; v697.z = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -652,7 +655,7 @@ v704.y = 0; v704.z = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -682,7 +685,7 @@ v691.y = 0; v691.z = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -703,7 +706,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v691); @@ -727,7 +730,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -747,7 +750,7 @@ pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(pSpellSprite.uAttributes) |= 4u; - if ( pCastSpell->spellnum == SPELL_AIR_LIGHNING_BOLT ) + if ( pCastSpell->uSpellID == SPELL_AIR_LIGHNING_BOLT ) LOBYTE(pSpellSprite.uAttributes) |= 0x40u; v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) @@ -763,7 +766,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -797,13 +800,13 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( pPlayer->CanCastSpell(uRequiredMana) ) { pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_skill = v731; pSpellSprite.spell_level = v2; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -915,7 +918,7 @@ pActors[PID_ID(a2)].pActorBuffs[1].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(power << 7) * 0.033333335), v731, 0, 0, 0); pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1023,7 +1026,7 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } case SPELL_BODY_REGENERATION: @@ -1040,7 +1043,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_REGENERATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)v733 * 4.2666669), v731, amount, 0, 0); LODWORD(v727) = 1; @@ -1063,7 +1066,7 @@ assert(false); } - switch (pCastSpell->spellnum) + switch (pCastSpell->uSpellID) { case SPELL_FIRE_PROTECTION_FROM_FIRE: LODWORD(v725) = PARTY_BUFF_RESIST_FIRE; @@ -1089,10 +1092,10 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); 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; @@ -1124,10 +1127,10 @@ { 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(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); } } break; @@ -1149,7 +1152,7 @@ if ( v731 == 1 ) { v108 = pCastSpell->uPlayerID_2; - v109 = pCastSpell->spellnum; + v109 = pCastSpell->uSpellID; v110 = pGame->GetStru6(); pGame->GetStru6()->SetPlayerBuffAnim(v109, v108); v111 = pOtherOverlayList->_4418B1(10000, pCastSpell->uPlayerID_2 + 310, 0, 65536); @@ -1173,7 +1176,7 @@ v730b = pParty->pPlayers;//[0].pPlayerBuffs[1]; do { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, v105); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, v105); v716 = pOtherOverlayList->_4418B1(10000, v105 + 310, 0, 65536); v730b->pPlayerBuffs[1].Apply(pParty->uTimePlayed + v717, v731, amount, v716, 0); ++v730b; @@ -1214,13 +1217,13 @@ v114 = v118; } _this = (ItemGen *)(((unsigned int)(11 * v114) >> 5) + (v115 >> 2) + v113); - if ( (double)(signed int)this <= 307.2 ) + if ( (double)(signed int)_this <= 307.2 ) { v701.x = 0; v701.y = 0; v701.z = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v723; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1243,7 +1246,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; } //pCastSpell = (CastSpellInfo *)HIDWORD(v733); } @@ -1262,7 +1265,7 @@ default: assert(false); } - v127 = pCastSpell->spellnum; + v127 = pCastSpell->uSpellID; if ( v127 == 17 ) { amount = 0; @@ -1285,10 +1288,10 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); 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); @@ -1304,10 +1307,10 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0); LODWORD(v727) = 1; @@ -1330,7 +1333,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[491], 2); // Can't cast Meteor Shower indoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) @@ -1374,7 +1377,7 @@ stru_5C6E00->Atan2(j, k)); } pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1409,7 +1412,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[492], 2); // Can't cast Inferno outdoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) @@ -1419,7 +1422,7 @@ v700.y = 0; v700.x = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1486,10 +1489,10 @@ do pOtherOverlayList->_4418B1(2010, v174++ + 100, 0, 65536); while ( v174 < 4 ); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); 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; @@ -1510,7 +1513,7 @@ break; auto _v726 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1580,15 +1583,15 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[638], 2); // There are hostile creatures nearby! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( pPlayer->CanCastSpell(uRequiredMana) ) { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); 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) = 1; @@ -1635,7 +1638,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[495], 2); // Can't cast Starburst indoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) @@ -1690,7 +1693,7 @@ stru_5C6E00->Atan2((signed __int64)v216, (signed __int64)*(float *)&uRequiredMana)); } pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1775,7 +1778,7 @@ if ( amount == 1 ) { pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_skill = v731; pSpellSprite.spell_level = v2; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1804,7 +1807,7 @@ else { pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1859,10 +1862,10 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; v716 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply( pParty->uTimePlayed + (signed int)(signed __int64)((double)(v229 << 7) * 0.033333335), @@ -1889,7 +1892,7 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( v731 == 1 || v731 == 2 ) @@ -1921,7 +1924,7 @@ dword_50C9D8 = 1; ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; v2 = v723; continue; } @@ -2096,7 +2099,7 @@ ShowStatusBarString(v317, 2u); pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); v318 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; v318->PlaySound(SPEECH_43, 0); } @@ -2111,7 +2114,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } town_portal_caster_id = LOBYTE(pCastSpell->uPlayerID); @@ -2126,7 +2129,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } v319 = uRequiredMana; @@ -2139,8 +2142,8 @@ ::uRequiredMana = v319; ::sRecoveryTime = sRecoveryTime; dword_50633C = pCastSpell->sound_id; - dword_506338 = pCastSpell->spellnum; - LOBYTE(pCastSpell->field_8) |= 0x20u; + dword_506338 = pCastSpell->uSpellID; + pCastSpell->uFlags |= 0x20u; } break; } @@ -2186,7 +2189,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -2219,14 +2222,14 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; pSpellSprite.uType = 4090; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -2268,10 +2271,10 @@ LODWORD(v733) = v330; if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); 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) = 1; @@ -2294,7 +2297,7 @@ v342 = pCastSpell->spell_target_pid; if ( v342 == 0 ) { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, v731, amount, 0, 0); LODWORD(v727) = 1; @@ -2348,7 +2351,7 @@ break; } } - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); LODWORD(v727) = 1; break; } @@ -2362,7 +2365,7 @@ break; if ( v731 == 1 || v731 == 2 ) { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); pParty->pPlayers[pCastSpell->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); LODWORD(v727) = 1; break; @@ -2372,7 +2375,7 @@ v357 = pParty->pPlayers;//[0].pPlayerBuffs[11]; do { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, a2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, a2); v357->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + v717, v731, 0, 0, 0); ++a2; ++v357;// = (SpellBuff *)((char *)v357 + 6972); @@ -2393,7 +2396,7 @@ pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFFu, 0xC0u); ++pSpellSprite.uType; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -2510,7 +2513,7 @@ } v388 = _v733; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, LOWORD(v682[_v733]) - 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, LOWORD(v682[_v733]) - 1); _v733 = v388 + 1; } while ( v388 + 1 < v730 ); @@ -2561,7 +2564,7 @@ } pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(1u, 1); pParty->pPlayers[pCastSpell->uPlayerID_2].sHealth = 1; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); } LODWORD(v727) = 1; break; @@ -2580,7 +2583,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); v323 = pCastSpell->uPlayerID_2; v324 = (char *)&pParty->pPlayers[v323].pConditions[12]; if ( !pParty->pPlayers[v323].pConditions[12] ) @@ -2617,7 +2620,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); v323 = pCastSpell->uPlayerID_2; v324 = (char *)&pParty->pPlayers[v323].pConditions[3]; if ( !pParty->pPlayers[v323].pConditions[3] ) @@ -2719,7 +2722,7 @@ } ShowStatusBarString(pTmpBuf2.data(), 2u); pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -2772,7 +2775,7 @@ pActors[v426].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; } pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -2822,7 +2825,7 @@ v731, 0, 0, 0); } pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -2863,7 +2866,7 @@ pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0Au, 0xC0u); ++pSpellSprite.uType; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -2904,7 +2907,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); v440 = pCastSpell->uPlayerID_2; if ( HIDWORD(pParty->pPlayers[v440].pConditions[5]) | LODWORD(pParty->pPlayers[v440].pConditions[5]) ) { @@ -2984,7 +2987,7 @@ break; } OpenedTelekinesis = true; - if ( pLevelDecorations[v445].field_16_event_id ) + if ( pLevelDecorations[v445].uEventID ) { EventProcessor(v448, a2, 1); LODWORD(v727) = 1; @@ -3015,7 +3018,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); v323 = pCastSpell->uPlayerID_2; v324 = (char *)&pParty->pPlayers[v323].pConditions[1]; if ( !pParty->pPlayers[v323].pConditions[1] ) @@ -3054,7 +3057,7 @@ if (!v460) { pParty->pPlayers[pCastSpell->uPlayerID_2].Heal(amount); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); } else { @@ -3097,7 +3100,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); v470 = pCastSpell->uPlayerID_2; 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])) @@ -3140,10 +3143,10 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0); LODWORD(v727) = 1; @@ -3157,10 +3160,10 @@ break; if ( v731 == 4 ) { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); v732 = (int)v733 << 7; v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); pParty->pPlayers[0].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, 0); @@ -3171,7 +3174,7 @@ LODWORD(v727) = 1; break; } - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); pParty->pPlayers[pCastSpell->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); LODWORD(v727) = 1; @@ -3186,7 +3189,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); v498 = pCastSpell->uPlayerID_2; 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])) @@ -3232,7 +3235,7 @@ int v1 = 0; do { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, v1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, v1); v501->Heal(amount); ++v501; ++v1; @@ -3255,7 +3258,7 @@ v688.y = 0; v688.z = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -3324,7 +3327,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[648], 2); // This character can't summon any more monsters! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) @@ -3347,10 +3350,10 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); 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) = 1; @@ -3363,7 +3366,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[497], 2); // Can't cast Prismatic Light outdoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) @@ -3374,7 +3377,7 @@ v694.y = 0; v694.z = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -3422,10 +3425,10 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); v732 = v730 << 7; v549 = (double)(v730 << 7) * 0.033333335; @@ -3468,10 +3471,10 @@ *((float *)&v733) = (double)v732 * 0.033333335; do { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); //((SpellBuff *)(v553 + 6056))->Apply( v553->pPlayerBuffs[4].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733)), v731, v730, 0, 0); @@ -3498,7 +3501,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) @@ -3521,11 +3524,11 @@ *(int *)(_this->uItemID + 6460) = v565; v567 = (*v566)->GetMaxMana(); *(int *)(_this->uItemID + 6464) = v567; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, a2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, a2); ++a2; _this = (ItemGen *)((char *)_this + 4); } - while ( (signed int)this < (signed int)&qword_A750D8 ); + while ( (signed int)_this < (signed int)&qword_A750D8 ); v571 = pPlayer; v572 = (char *)&pPlayer->sAgeModifier; if ( pPlayer->sAgeModifier + 10 >= 120 ) @@ -3554,7 +3557,7 @@ if (!v576) { v585 = (char *)&pParty->pPlayers[pCastSpell->uPlayerID_2]; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); if ( *((_QWORD *)v585 + 14) ) { ((Player *)v585)->SetCondition(0x11u, 1); @@ -3570,7 +3573,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[496], 2); // No valid target exists! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } v578 = (int)&pActors[(int)v577]; @@ -3579,12 +3582,12 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } ++pSpellSprite.uType; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -3653,7 +3656,7 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } v592 = _v733; @@ -3685,7 +3688,7 @@ break; auto _v726 = ((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360); pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -3751,7 +3754,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } pActor->pActorBuffs[9].Reset(); @@ -3759,7 +3762,7 @@ pActor->pActorBuffs[12].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -3835,7 +3838,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } v610 = 76 * v609; @@ -3880,7 +3883,7 @@ break; if ( v731 != 3 && v731 != 4 ) { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, v716, 0); LODWORD(v727) = 1; break; @@ -3890,7 +3893,7 @@ v619 = pParty->pPlayers;//[0].pPlayerBuffs[10]; do { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, a2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, a2); v619->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + v717, v731, amount, v716, 0); ++a2; ++v619; @@ -3910,7 +3913,7 @@ v707.y = 0; v707.z = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -3975,7 +3978,7 @@ v726->sHealth = v726->GetMaxHealth(); v635 = _v733; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, WORD2(v733)); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, WORD2(v733)); _v733 = v635 + 1; } while ( v635 + 1 < v730 ); @@ -3990,7 +3993,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[499], 2); // Can't cast Armageddon indoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( v731 == 4) @@ -4001,7 +4004,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) @@ -4031,10 +4034,10 @@ default: break; } - if ( pCastSpell->field_8 & 0x20 ) + if ( pCastSpell->uFlags & 0x20 ) { if ( v727 != 0.0 ) - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->spellnum], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0); + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->uSpellID], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0); } else { @@ -4057,63 +4060,52 @@ { pPlayer->PlaySound(SPEECH_49, 0); if ( v727 != 0.0 ) - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->spellnum], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0); + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->uSpellID], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0); } } - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; v2 = v723; continue; } } //----- (00427DA0) -------------------------------------------------------- -unsigned int CastSpellInfo::PushCastSpellInfo(__int16 a2, __int16 uPlayerID, __int16 skill_level, __int16 a5, int spell_sound_id) +size_t PushCastSpellInfo(uint16_t uSpellID, uint16_t uPlayerID, __int16 skill_level, uint16_t uFlags, int spell_sound_id) { - for ( uint i = 0; i < 10; i++ ) + for (size_t i = 0; i < CastSpellInfoCount; i++) { - if ( !this[i].spellnum ) + if (!pCastSpellInfo[i].uSpellID) { - this[i].spellnum = a2; - this[i].uPlayerID = uPlayerID; - if ( a5 & 0x10 ) - this[i].uPlayerID_2 = uPlayerID; - this[i].field_6 = 0; - this[i].spell_target_pid = 0; - this[i].field_8 = a5; - this[i].forced_spell_skill_level = skill_level; - this[i].sound_id = spell_sound_id; + pCastSpellInfo[i].uSpellID = uSpellID; + pCastSpellInfo[i].uPlayerID = uPlayerID; + if (uFlags & 0x10) + pCastSpellInfo[i].uPlayerID_2 = uPlayerID; + pCastSpellInfo[i].field_6 = 0; + pCastSpellInfo[i].spell_target_pid = 0; + pCastSpellInfo[i].uFlags = uFlags; + pCastSpellInfo[i].forced_spell_skill_level = skill_level; + pCastSpellInfo[i].sound_id = spell_sound_id; return i; } } return -1; } //----- (00427D48) -------------------------------------------------------- -void CastSpellInfo::_427D48(unsigned int uPlayerID)//Press S +void CastSpellInfoHelpers::_427D48() { - CastSpellInfo *v2; // esi@1 - signed int v3; // ebx@1 - - v2 = this; - v3 = 10; - do + for (size_t i = 0; i < CastSpellInfoCount; i++) { - if ( v2->spellnum ) + if (pCastSpellInfo[i].uSpellID && pCastSpellInfo[i].uFlags & 0x3CA) { - if ( v2->field_8 & 0x3CA ) - { - v2->spellnum = 0; - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; - back_to_game(); - } + pCastSpellInfo[i].uSpellID = 0; + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + unk_50C9A0 = 0; + back_to_game(); } - ++v2; - --v3; } - while ( v3 ); } //----- (0042777D) -------------------------------------------------------- void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6) @@ -4316,24 +4308,22 @@ if (a5 & 0x3CA) { - assert(sizeof(pCastSpellInfo) / sizeof(*pCastSpellInfo.data()) == 10); - for (uint i = 0; i < 10; ++i) - if (pCastSpellInfo[i].field_8 & 0x3CA) + for (uint i = 0; i < CastSpellInfoCount; ++i) + if (pCastSpellInfo[i].uFlags & 0x3CA) { - pCastSpellInfo[i].spellnum = 0; + pCastSpellInfo[i].uSpellID = 0; break; } } - assert(sizeof(pCastSpellInfo) / sizeof(*pCastSpellInfo.data()) == 10); - for (uint i = 0; i < 10; ++i) + for (uint i = 0; i < CastSpellInfoCount; ++i) { auto spell = &pCastSpellInfo[i]; - if (!spell->spellnum) + if (!spell->uSpellID) continue; - spell->spellnum = 0; - if (spell->field_8 & 0x3CA) + spell->uSpellID = 0; + if (spell->uFlags & 0x3CA) { pGUIWindow_Settings->Release(); pGUIWindow_Settings = nullptr; @@ -4344,7 +4334,7 @@ } } - int result = pCastSpellInfo.data()->PushCastSpellInfo(a1, uPlayerID, a4, a5, a6); + int result = PushCastSpellInfo(a1, uPlayerID, a4, a5, a6); if ( result != -1 ) { if ( a5 & 2 ) @@ -4422,101 +4412,3 @@ } } } - -const wchar_t *UIMessage2String(UIMessageType msg) -{ - #define CASE(xxx) case xxx: swprintf(b, wcslen(L"%03X/%s"), L"%03X/%s", msg, L#xxx); return b; - static wchar_t b[256]; // bad for threads - switch (msg) - { - CASE(UIMSG_SelectSpell) - CASE(UIMSG_ChangeGameState) - CASE(UIMSG_Attack) - CASE(UIMSG_PlayArcomage) - CASE(UIMSG_MainMenu_ShowPartyCreationWnd) - CASE(UIMSG_MainMenu_ShowLoadWindow) - CASE(UIMSG_ShowCredits) - CASE(UIMSG_ExitToWindows) - CASE(UIMSG_PlayerCreationChangeName) - CASE(UIMSG_PlayerCreationClickPlus) - CASE(UIMSG_PlayerCreationClickMinus) - CASE(UIMSG_PlayerCreationSelectActiveSkill) - CASE(UIMSG_PlayerCreationSelectClass) - CASE(UIMSG_PlayerCreationClickOK) - CASE(UIMSG_PlayerCreationClickReset) - CASE(UIMSG_ClickBooksBtn) - CASE(UIMSG_PlayerCreationRemoveUpSkill) - CASE(UIMSG_PlayerCreationRemoveDownSkill) - CASE(UIMSG_SPellbook_ShowHightlightedSpellInfo) - CASE(UIMSG_LoadGame) - CASE(UIMSG_SaveGame) - CASE(UIMSG_ShowStatus_DateTime) - CASE(UIMSG_ShowStatus_ManaHP) - CASE(UIMSG_ShowStatus_Player) - CASE(UIMSG_Wait5Minutes) - CASE(UIMSG_Wait1Hour) - CASE(UIMSG_ShowStatus_Food) - CASE(UIMSG_ShowStatus_Funds) - CASE(UIMSG_QuickReference) - CASE(UIMSG_GameMenuButton) - CASE(UIMSG_AlreadyResting) - CASE(UIMSG_SelectCharacter) - CASE(UIMSG_ChangeSoundVolume) - CASE(UIMSG_ChangeMusicVolume) - CASE(UIMSG_Escape) - CASE(UIMSG_PlayerCreation_SelectAttribute) - CASE(UIMSG_InventoryLeftClick) - CASE(UIMSG_SkillUp) - CASE(UIMSG_GameMenu_ReturnToGame) - CASE(UIMSG_StartNewGame) - CASE(UIMSG_Game_OpenLoadGameDialog) - CASE(UIMSG_Game_OpenSaveGameDialog) - CASE(UIMSG_Game_OpenOptionsDialog) - CASE(UIMSG_SetGraphicsMode) - CASE(UIMSG_Quit) - CASE(UIMSG_StartHireling1Dialogue) - CASE(UIMSG_StartHireling2Dialogue) - CASE(UIMSG_SelectNPCDialogueOption) - CASE(UIMSG_CastSpellFromBook) - CASE(UIMSG_PlayerCreation_VoicePrev) - CASE(UIMSG_PlayerCreation_VoiceNext) - CASE(UIMSG_StartNPCDialogue) - CASE(UIMSG_ArrowUp) - CASE(UIMSG_DownArrow) - CASE(UIMSG_SaveLoadBtn) - CASE(UIMSG_SelectLoadSlot) - CASE(UIMSG_Cancel) - CASE(UIMSG_ExitRest) - CASE(UIMSG_PlayerCreation_FacePrev) - CASE(UIMSG_PlayerCreation_FaceNext) - CASE(UIMSG_CycleCharacters) - CASE(UIMSG_SetTurnSpeed) - CASE(UIMSG_ToggleWalkSound) - CASE(UIMSG_ChangeVoiceVolume) - CASE(UIMSG_ToggleShowDamage) - CASE(UIMSG_ScrollNPCPanel) - CASE(UIMSG_ShowFinalWindow) - CASE(UIMSG_OpenQuestBook) - CASE(UIMSG_OpenAutonotes) - CASE(UIMSG_OpenMapBook) - CASE(UIMSG_OpenCalendar) - CASE(UIMSG_OpenHistoryBook) - CASE(UIMSG_ToggleAlwaysRun) - CASE(UIMSG_ToggleFlipOnExit) - CASE(UIMSG_Game_Action) - CASE(UIMSG_RentRoom) - CASE(UIMSG_TransitionUI_Confirm) - CASE(UIMSG_OpenKeyMappingOptions) - CASE(UIMSG_SelectKeyPage1) - CASE(UIMSG_SelectKeyPage2) - CASE(UIMSG_ResetKeyMapping) - CASE(UIMSG_ChangeKeyButton) - CASE(UIMSG_OpenVideoOptions) - CASE(UIMSG_ToggleBloodsplats) - CASE(UIMSG_ToggleColoredLights) - CASE(UIMSG_ToggleTint) - default: - swprintf(b, wcslen(L"UIMSG_%03X") , L"UIMSG_%03X", msg); return b; - }; - #undef CASE -} \ No newline at end of file diff -r 86cb7398d2a8 -r 7d986a396092 CastSpellInfo.h --- a/CastSpellInfo.h Sat Sep 07 12:51:06 2013 +0200 +++ b/CastSpellInfo.h Sat Sep 07 13:03:18 2013 +0200 @@ -1,6 +1,14 @@ #pragma once + +#include + #include +namespace CastSpellInfoHelpers +{ + void _427D48(); + void _427E01_cast_spell(); +}; /* 271 */ #pragma pack(push, 1) @@ -9,30 +17,18 @@ //----- (00426987) -------------------------------------------------------- inline CastSpellInfo() { - field_8 = 0; - spellnum = 0; - field_6 = 0; - uPlayerID_2 = 0; - uPlayerID = 0; - sound_id = 0; + memset(this, 0, sizeof(this)); } - void _427D48(unsigned int uPlayerID); - unsigned int PushCastSpellInfo(__int16 a2, __int16 uPlayerID, __int16 skill_level, __int16 a5, int sound_id); struct GUIWindow *GetCastSpellInInventoryWindow(); - void _427E01_cast_spell(); - __int16 spellnum; - unsigned __int16 uPlayerID; - __int16 uPlayerID_2; + uint16_t uSpellID; + uint16_t uPlayerID; + uint16_t uPlayerID_2; __int16 field_6; - __int16 field_8; + uint16_t uFlags; __int16 forced_spell_skill_level; int spell_target_pid; int sound_id; }; #pragma pack(pop) - - -extern std::array pCastSpellInfo; -extern CastSpellInfo stru_50CDB4; // idb diff -r 86cb7398d2a8 -r 7d986a396092 DecalBuilder.h --- a/DecalBuilder.h Sat Sep 07 12:51:06 2013 +0200 +++ b/DecalBuilder.h Sat Sep 07 13:03:18 2013 +0200 @@ -1,4 +1,7 @@ #pragma once + +#include + #include "Render.h" /* 158 */ @@ -120,7 +123,7 @@ __int16 field_C0A; __int16 field_C0C; __int16 field_C0E; - uint uColorMultiplier; + uint32_t uColorMultiplier; int field_C14; DecalBuilder_stru0 *field_C18; int field_C1C; diff -r 86cb7398d2a8 -r 7d986a396092 DecorationList.cpp --- a/DecorationList.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/DecorationList.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -249,19 +249,6 @@ fwrite(v1->pDecorations, 0x54u, v1->uNumDecorations, v3); fclose(v3); } -//----- (004583B0) -------------------------------------------------------- -LevelDecoration::LevelDecoration() -{ - this->field_1A = 0; - this->field_18 = 0; - this->vPosition.z = 0; - this->vPosition.y = 0; - this->vPosition.x = 0; - this->uDecorationDescID = 0; - this->field_2 = 0; - this->field_16_event_id = 0; - this->uCog = 0; -} //----- (004488B6) -------------------------------------------------------- unsigned __int16 DecorationList::GetDecorIdByName(const char *pName) { diff -r 86cb7398d2a8 -r 7d986a396092 DecorationList.h --- a/DecorationList.h Sat Sep 07 12:51:06 2013 +0200 +++ b/DecorationList.h Sat Sep 07 13:03:18 2013 +0200 @@ -4,19 +4,19 @@ /* 321 */ -enum DECORATION_FLAGS +enum DECORATION_DESC_FLAGS { - DECORATION_MOVE_THROUGH = 0x1, - DECORATION_DONT_DRAW = 0x2, - DECORATION_FLICKER_SLOW = 0x4, - DECORATION_FICKER_AVERAGE = 0x8, - DECORATION_FICKER_FAST = 0x10, - DECORATION_MARKER = 0x20, - DECORATION_SLOW_LOOP = 0x40, - DECORATION_EMITS_FIRE = 0x80, - DECORATION_SOUND_ON_DAWN = 0x100, - DECORATION_SOUND_ON_DUSK = 0x200, - DECORATION_EMITS_SMOKE = 0x400, + DECORATION_DESC_MOVE_THROUGH = 0x0001, + DECORATION_DESC_DONT_DRAW = 0x0002, + DECORATION_DESC_FLICKER_SLOW = 0x0004, + DECORATION_DESC_FICKER_AVERAGE = 0x0008, + DECORATION_DESC_FICKER_FAST = 0x0010, + DECORATION_DESC_MARKER = 0x0020, + DECORATION_DESC_SLOW_LOOP = 0x0040, + DECORATION_DESC_EMITS_FIRE = 0x0080, + DECORATION_DESC_SOUND_ON_DAWN = 0x0100, + DECORATION_DESC_SOUND_ON_DUSK = 0x0200, + DECORATION_DESC_EMITS_SMOKE = 0x0400, }; @@ -25,10 +25,10 @@ #pragma pack(push, 1) struct DecorationDesc_mm6 { - inline bool CanMoveThrough() {return (uFlags & DECORATION_MOVE_THROUGH) != 0;} - inline bool DontDraw() {return (uFlags & DECORATION_DONT_DRAW) != 0;} - inline bool SoundOnDawn() {return (uFlags & DECORATION_SOUND_ON_DAWN) != 0;} - inline bool SoundOnDusk() {return (uFlags & DECORATION_SOUND_ON_DUSK) != 0;} + inline bool CanMoveThrough() {return (uFlags & DECORATION_DESC_MOVE_THROUGH) != 0;} + inline bool DontDraw() {return (uFlags & DECORATION_DESC_DONT_DRAW) != 0;} + inline bool SoundOnDawn() {return (uFlags & DECORATION_DESC_SOUND_ON_DAWN) != 0;} + inline bool SoundOnDusk() {return (uFlags & DECORATION_DESC_SOUND_ON_DUSK) != 0;} char pName[32]; char field_20[32]; diff -r 86cb7398d2a8 -r 7d986a396092 Events.cpp --- a/Events.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/Events.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -65,62 +65,62 @@ //----- (00443CE1) -------------------------------------------------------- unsigned int LoadEventsToBuffer(const char *pContainerName, char *pBuffer, unsigned int uBufferSize) { - FILE *pLodFile; // eax@1 - unsigned int uTextureSize; // esi@3 - char Args[60]; // [sp+8h] [bp-B4h]@6 - void *ptr; // [sp+B8h] [bp-4h]@1 - Texture DstBuf; // [sp+6Ch] [bp-50h]@1 + FILE *pLodFile; // eax@1 + unsigned int uTextureSize; // esi@3 + char Args[60]; // [sp+8h] [bp-B4h]@6 + void *ptr; // [sp+B8h] [bp-4h]@1 + Texture DstBuf; // [sp+6Ch] [bp-50h]@1 - ptr = pEvents_LOD->LoadRaw(pContainerName, 0); - pLodFile = pEvents_LOD->FindContainer(pContainerName, 0); - if ( !pLodFile ) - Abortf("Unable to load %s", pContainerName); - fread(&DstBuf, 1, 48, pLodFile); - uTextureSize = DstBuf.uDecompressedSize; - if ( !DstBuf.uDecompressedSize ) - uTextureSize = DstBuf.uTextureSize; - memset(&DstBuf, 0, 72); - if ( uTextureSize >= (signed int)uBufferSize ) - { - sprintf(Args, "File %s Size %lu - Buffer size %lu", pContainerName, uTextureSize, uBufferSize); - Abortf(Args); - } - memcpy(pBuffer, ptr, uTextureSize); - pAllocator->FreeChunk(ptr); - return uTextureSize; - } + ptr = pEvents_LOD->LoadRaw(pContainerName, 0); + pLodFile = pEvents_LOD->FindContainer(pContainerName, 0); + if ( !pLodFile ) + Abortf("Unable to load %s", pContainerName); + fread(&DstBuf, 1, 48, pLodFile); + uTextureSize = DstBuf.uDecompressedSize; + if ( !DstBuf.uDecompressedSize ) + uTextureSize = DstBuf.uTextureSize; + memset(&DstBuf, 0, 72); + if ( uTextureSize >= (signed int)uBufferSize ) + { + sprintf(Args, "File %s Size %lu - Buffer size %lu", pContainerName, uTextureSize, uBufferSize); + Abortf(Args); + } + memcpy(pBuffer, ptr, uTextureSize); + pAllocator->FreeChunk(ptr); + return uTextureSize; + } //----- (00443DA1) -------------------------------------------------------- void Initialize_GlobalEVT() { - struct raw_event_header - { - unsigned char evt_size; - unsigned char evt_id_l; - unsigned char evt_id_h; - unsigned char evt_sequence_num; - } ; - uint events_count; - unsigned int offset_in; - raw_event_header *current_hdr; - uGlobalEVT_NumEvents = 0; - uGlobalEVT_Size = LoadEventsToBuffer("global.evt", pGlobalEVT.data(), 46080); - if ( !uGlobalEVT_Size ) - return; - memset(pGlobalEVT_Index.data(), 0x80, sizeof(pGlobalEVT_Index));//52800 - events_count = uGlobalEVT_NumEvents; - current_hdr=(raw_event_header *)pGlobalEVT.data(); - offset_in=0; - for (events_count = 0, offset_in = 0; offset_in < uGlobalEVT_Size; ++events_count) - { - pGlobalEVT_Index[events_count].uEventID=current_hdr->evt_id_l+(current_hdr->evt_id_h<<8); - pGlobalEVT_Index[events_count].event_sequence_num=current_hdr->evt_sequence_num; - pGlobalEVT_Index[events_count].uEventOffsetInEVT=offset_in; - offset_in+=current_hdr->evt_size+1; + struct raw_event_header + { + unsigned char evt_size; + unsigned char evt_id_l; + unsigned char evt_id_h; + unsigned char evt_sequence_num; + } ; + uint events_count; + unsigned int offset_in; + raw_event_header *current_hdr; + uGlobalEVT_NumEvents = 0; + uGlobalEVT_Size = LoadEventsToBuffer("global.evt", pGlobalEVT.data(), 46080); + if ( !uGlobalEVT_Size ) + return; + memset(pGlobalEVT_Index.data(), 0x80, sizeof(pGlobalEVT_Index));//52800 + events_count = uGlobalEVT_NumEvents; + current_hdr=(raw_event_header *)pGlobalEVT.data(); + offset_in=0; + for (events_count = 0, offset_in = 0; offset_in < uGlobalEVT_Size; ++events_count) + { + pGlobalEVT_Index[events_count].uEventID=current_hdr->evt_id_l+(current_hdr->evt_id_h<<8); + pGlobalEVT_Index[events_count].event_sequence_num=current_hdr->evt_sequence_num; + pGlobalEVT_Index[events_count].uEventOffsetInEVT=offset_in; + offset_in+=current_hdr->evt_size+1; - current_hdr=(raw_event_header *)&pGlobalEVT[offset_in]; - } - uGlobalEVT_NumEvents = events_count; + current_hdr=(raw_event_header *)&pGlobalEVT[offset_in]; + } + uGlobalEVT_NumEvents = events_count; assert(uGlobalEVT_NumEvents < 4400); } @@ -129,26 +129,26 @@ //----- (00443EF8) -------------------------------------------------------- void LoadLevel_InitializeLevelEvt() - { + { struct raw_event_header - { + { unsigned char evt_size; unsigned char evt_id_l; unsigned char evt_id_h; unsigned char evt_sequence_num; } ; uint events_count; - unsigned int offset_in; - raw_event_header *current_hdr; + unsigned int offset_in; + raw_event_header *current_hdr; - if (!uLevelEVT_Size) - return; + if (!uLevelEVT_Size) + return; - memset(array_5B5928_timers, 0, 3200); - memset(pLevelEVT_Index.data(), 80, sizeof(EventIndex)*4400); + memset(array_5B5928_timers, 0, 3200); + memset(pLevelEVT_Index.data(), 80, sizeof(EventIndex)*4400); - uLevelEVT_NumEvents = 0; - dword_5B65C8_timers_count = 0; + uLevelEVT_NumEvents = 0; + dword_5B65C8_timers_count = 0; current_hdr=(raw_event_header *)pLevelEVT.data(); offset_in=0; @@ -156,7 +156,7 @@ { pLevelEVT_Index[events_count].uEventID=current_hdr->evt_id_l+(current_hdr->evt_id_h<<8); pLevelEVT_Index[events_count].event_sequence_num=current_hdr->evt_sequence_num; - pLevelEVT_Index[events_count].uEventOffsetInEVT=offset_in; + pLevelEVT_Index[events_count].uEventOffsetInEVT=offset_in; offset_in+=current_hdr->evt_size+1; current_hdr=(raw_event_header *)&pLevelEVT[offset_in]; @@ -173,512 +173,512 @@ Emerald Isle #110 // Fire Resistance fountain -0 LocationName -0 if (Player.FireResistance < 50) - { -1 Set(Player.FireResistance, 50) -2 SetFooterString(22) // +50 Fire Resistance (temporarily) -3 Add(Party.Autonotes, 2) -4 goto return - } -5 SetFooterString(11) // Refreshing! -6 return +0 LocationName +0 if (Player.FireResistance < 50) + { +1 Set(Player.FireResistance, 50) +2 SetFooterString(22) // +50 Fire Resistance (temporarily) +3 Add(Party.Autonotes, 2) +4 goto return + } +5 SetFooterString(11) // Refreshing! +6 return Emerald Isle #111 // ??? - Initialize - Set(Map.Variables[0], 30) - Set(Map.Variables[1], 30) + Initialize + Set(Map.Variables[0], 30) + Set(Map.Variables[1], 30) Emerald Isle #114 // month timer - manage luck fountain -0 LocationName -0 if (Player.BaseLuck >= 15) - { -2 SetFooterString(11) // Refreshing! -3 return - } - else - { -1 if (Map.Variables[2] >= 1) - { -4 Sub(Map.Variables[2], 1) -5 Add(Player.BaseLuck, 2) -6 SetFooterString(25) // +2 Luck (Permament) -7 return - } - else - { -2 SetFooterString(11) // Refreshing! -3 return - } - } +0 LocationName +0 if (Player.BaseLuck >= 15) + { +2 SetFooterString(11) // Refreshing! +3 return + } + else + { +1 if (Map.Variables[2] >= 1) + { +4 Sub(Map.Variables[2], 1) +5 Add(Player.BaseLuck, 2) +6 SetFooterString(25) // +2 Luck (Permament) +7 return + } + else + { +2 SetFooterString(11) // Refreshing! +3 return + } + } -8 Initialize -9 Set Map.Variables[2], 8 +8 Initialize +9 Set Map.Variables[2], 8 Emerald Isle #115 // week timer - gold fountain in the center of town -0 LocationName -0 if (Map.Variables[4] < 3) - { -1 if (Map.Variables[3] == 0) - { -2 if (Party.Gold < 201) - { -3 if (Player.BaseLuck >= 15) - { -5 Add(Map.Variables[3], 1) -6 Add(Party.Gold, 1000) -7 Add(Map.Variables[4], 1) -8 goto return - } - else - { -4 goto 9 - } - } - } - } -9 SetFooterString(11) // Refreshing! -10 return +0 LocationName +0 if (Map.Variables[4] < 3) + { +1 if (Map.Variables[3] == 0) + { +2 if (Party.Gold < 201) + { +3 if (Player.BaseLuck >= 15) + { +5 Add(Map.Variables[3], 1) +6 Add(Party.Gold, 1000) +7 Add(Map.Variables[4], 1) +8 goto return + } + else + { +4 goto 9 + } + } + } + } +9 SetFooterString(11) // Refreshing! +10 return -11 Initialize -12 Set(Map.Variables[3], 0) +11 Initialize +12 Set(Map.Variables[3], 0) -Emerald Isle #220 // day timer - monster spawner -0 LocationName -0 Initialize -1 if (NumAliveActors(group=20) != 0) -2 return -3 SpawnMonsters(1, level=1, count=10, x=-336, y=14512, z=0, group=20) -4 SpawnMonsters(1, level=2, count=5, x=16, y=16352, z=90, group=20) -5 SpawnMonsters(1, level=1, count=10, x=480, y=18288, z=6, group=20) +Emerald Isle #220 // day timer - monster spawner +0 LocationName +0 Initialize +1 if (NumAliveActors(group=20) != 0) +2 return +3 SpawnMonsters(1, level=1, count=10, x=-336, y=14512, z=0, group=20) +4 SpawnMonsters(1, level=2, count=5, x=16, y=16352, z=90, group=20) +5 SpawnMonsters(1, level=1, count=10, x=480, y=18288, z=6, group=20) -Emerald Isle #200 // margareth dock tip -0 if (!QBits.QuestDone[17]) - { -1 InitiateNPCDialogue(npc=19) - } -2 return +Emerald Isle #200 // margareth dock tip +0 if (!QBits.QuestDone[17]) + { +1 InitiateNPCDialogue(npc=19) + } +2 return -Emerald Isle #201 // margareth armoury tip -0 if (!QBits.QuestDone[17]) - { -1 InitiateNPCDialogue(npc=20) - } -2 return +Emerald Isle #201 // margareth armoury tip +0 if (!QBits.QuestDone[17]) + { +1 InitiateNPCDialogue(npc=20) + } +2 return */ - } + } //----- (0044684A) -------------------------------------------------------- void EventProcessor(int uEventID, int targetObj, int canShowMessages, int entry_line) { - unsigned int v3; // eax@5 - signed int v4; // esi@7 - //char *v5; // eax@8 - Player *v6; // ecx@8 - //char *v7; // ebp@8 - //signed int v8; // edx@10 - //int v9; // edi@12 - //ByteArray *v10; // esi@12 - int v11; // eax@14 - char *v12; // eax@15 - //char *v13; // edi@21 - int v14; // ebp@21 - int v15; // edi@21 - const char *v16; // esi@21 - bool v17; // edx@21 - int v18; // ecx@22 - int v19; // ebp@36 - signed int v20; // ecx@40 - int v21; // eax@40 - int v22; // edx@40 - int v23; // eax@40 - unsigned __int16 v24; // ax@45 - int v25; // eax@54 - LevelDecoration *v26; // eax@55 - int v27; // eax@57 - int v28; // ecx@57 - //int v29; // edx@58 - int pEventID; // eax@58 - int pNPC_ID; // ecx@58 - int pIndex; // esi@58 - NPCData *pNPC; // ecx@58 - int v34; // esi@59 - int v35; // esi@60 - int v36; // esi@61 - int v37; // esi@62 - int v38; // eax@78 - int v39; // ecx@78 - size_t v40; // edx@78 - Actor *v41; // esi@79 - int v42; // eax@84 - int v43; // ecx@84 - size_t v44; // edx@84 - Actor *v45; // esi@85 - void *v46; // eax@91 - GUIWindow *v47; // eax@93 - GUIButton *v48; // ecx@93 - GUIButton *v49; // esi@94 - char v50; // al@100 - Player *v51; // esi@103 - Player *v52; // ecx@106 - int v53; // ecx@107 - char v54; // al@111 - Player *v55; // esi@114 - Player *v56; // ecx@117 - int v57; // ecx@118 - signed int pValue; // ebp@124 - Player *pPlayer; // esi@125 - int v60; // eax@126 - int v61; // edx@133 - int v62; // eax@139 - int v63; // ebp@145 - signed int v64; // edi@146 - unsigned int v65; // edx@148 - Player *v66; // ecx@148 - int v67; // esi@148 - signed int v68; // eax@151 - int v69; // esi@151 - Player *v70; // ecx@158 - unsigned int v71; // eax@159 - int v72; // esi@159 - signed int v73; // eax@162 - int v74; // esi@162 - int v75; // edx@172 - Player *v76; // esi@173 - signed int v77; // ebp@186 - int v78; // edx@186 - Player *v79; // esi@187 - //signed int v80; // ebp@200 - //int v81; // edx@200 - Player *v82; // esi@201 - int v83; // eax@212 - int v84; // ebp@220 - signed int v85; // ebp@224 - char v86; // al@224 - Player *v87; // esi@227 - Player *v88; // ecx@231 - int v89; // ecx@232 - int v90; // eax@243 - const char *v91; // ecx@247 - int v92; // eax@251 - char *v93; // eax@252 - int v94; // ecx@262 - int v95; // ebp@262 - int v96; // edx@262 - int v97; // eax@262 - unsigned int v98; // edx@265 - const char *v99; // esi@267 - int v100; // edx@267 - //char *v101; // edi@281 - unsigned int v102; // esi@281 - int v103; // edi@284 - int v104; // eax@288 - int v105; // edx@294 - int v106; // [sp-20h] [bp-4C8h]@278 - signed int v107; // [sp-1Ch] [bp-4C4h]@278 - unsigned int v108; // [sp-18h] [bp-4C0h]@278 - signed int v109; // [sp-14h] [bp-4BCh]@278 - signed int v110; // [sp-10h] [bp-4B8h]@278 - int v111; // [sp-Ch] [bp-4B4h]@278 - // Event *v112; // [sp-8h] [bp-4B0h]@5 - int v113; // [sp-8h] [bp-4B0h]@106 - int v114; // [sp-8h] [bp-4B0h]@117 - signed int v115; // [sp-8h] [bp-4B0h]@231 - unsigned int v116; // [sp-8h] [bp-4B0h]@278 - int v117; // [sp-4h] [bp-4ACh]@106 - int v118; // [sp-4h] [bp-4ACh]@117 - int v119; // [sp-4h] [bp-4ACh]@231 - int v120; // [sp-4h] [bp-4ACh]@278 - int v121; // [sp-4h] [bp-4ACh]@294 - int curr_seq_num; // [sp+10h] [bp-498h]@4 - //char *v123; // [sp+14h] [bp-494h]@0 - signed int v124; // [sp+18h] [bp-490h]@7 - //signed int v125; // [sp+1Ch] [bp-48Ch]@155 - int v126; // [sp+1Ch] [bp-48Ch]@262 - int player_choose; // [sp+20h] [bp-488h]@4 - int v128; // [sp+24h] [bp-484h]@21 - int v129; // [sp+24h] [bp-484h]@262 - signed int v130; // [sp+28h] [bp-480h]@0 - //int v131; // [sp+2Ch] [bp-47Ch]@1 - int v132; // [sp+30h] [bp-478h]@262 - signed int v133; // [sp+34h] [bp-474h]@1 - int v134; // [sp+38h] [bp-470h]@262 - int v135; // [sp+3Ch] [bp-46Ch]@262 - int v136; // [sp+40h] [bp-468h]@40 - int v137; // [sp+44h] [bp-464h]@40 - int v138; // [sp+48h] [bp-460h]@40 - int v139; // [sp+4Ch] [bp-45Ch]@40 - ItemGen item; // [sp+50h] [bp-458h]@15 - char Source[120]; // [sp+74h] [bp-434h]@15 - char Str[120]; // [sp+ECh] [bp-3BCh]@21 - Actor Dst; // [sp+164h] [bp-344h]@53 + unsigned int v3; // eax@5 + signed int v4; // esi@7 + //char *v5; // eax@8 + Player *v6; // ecx@8 + //char *v7; // ebp@8 + //signed int v8; // edx@10 + //int v9; // edi@12 + //ByteArray *v10; // esi@12 + int v11; // eax@14 + char *v12; // eax@15 + //char *v13; // edi@21 + int v14; // ebp@21 + int v15; // edi@21 + const char *v16; // esi@21 + bool v17; // edx@21 + int v18; // ecx@22 + int v19; // ebp@36 + signed int v20; // ecx@40 + int v21; // eax@40 + int v22; // edx@40 + int v23; // eax@40 + unsigned __int16 v24; // ax@45 + int v25; // eax@54 + LevelDecoration *v26; // eax@55 + int v27; // eax@57 + int v28; // ecx@57 + //int v29; // edx@58 + int pEventID; // eax@58 + int pNPC_ID; // ecx@58 + int pIndex; // esi@58 + NPCData *pNPC; // ecx@58 + int v34; // esi@59 + int v35; // esi@60 + int v36; // esi@61 + int v37; // esi@62 + int v38; // eax@78 + int v39; // ecx@78 + size_t v40; // edx@78 + Actor *v41; // esi@79 + int v42; // eax@84 + int v43; // ecx@84 + size_t v44; // edx@84 + Actor *v45; // esi@85 + void *v46; // eax@91 + GUIWindow *v47; // eax@93 + GUIButton *v48; // ecx@93 + GUIButton *v49; // esi@94 + char v50; // al@100 + Player *v51; // esi@103 + Player *v52; // ecx@106 + int v53; // ecx@107 + char v54; // al@111 + Player *v55; // esi@114 + Player *v56; // ecx@117 + int v57; // ecx@118 + signed int pValue; // ebp@124 + Player *pPlayer; // esi@125 + int v60; // eax@126 + int v61; // edx@133 + int v62; // eax@139 + int v63; // ebp@145 + signed int v64; // edi@146 + unsigned int v65; // edx@148 + Player *v66; // ecx@148 + int v67; // esi@148 + signed int v68; // eax@151 + int v69; // esi@151 + Player *v70; // ecx@158 + unsigned int v71; // eax@159 + int v72; // esi@159 + signed int v73; // eax@162 + int v74; // esi@162 + int v75; // edx@172 + Player *v76; // esi@173 + signed int v77; // ebp@186 + int v78; // edx@186 + Player *v79; // esi@187 + //signed int v80; // ebp@200 + //int v81; // edx@200 + Player *v82; // esi@201 + int v83; // eax@212 + int v84; // ebp@220 + signed int v85; // ebp@224 + char v86; // al@224 + Player *v87; // esi@227 + Player *v88; // ecx@231 + int v89; // ecx@232 + int v90; // eax@243 + const char *v91; // ecx@247 + int v92; // eax@251 + char *v93; // eax@252 + int v94; // ecx@262 + int v95; // ebp@262 + int v96; // edx@262 + int v97; // eax@262 + unsigned int v98; // edx@265 + const char *v99; // esi@267 + int v100; // edx@267 + //char *v101; // edi@281 + unsigned int v102; // esi@281 + int v103; // edi@284 + int v104; // eax@288 + int v105; // edx@294 + int v106; // [sp-20h] [bp-4C8h]@278 + signed int v107; // [sp-1Ch] [bp-4C4h]@278 + unsigned int v108; // [sp-18h] [bp-4C0h]@278 + signed int v109; // [sp-14h] [bp-4BCh]@278 + signed int v110; // [sp-10h] [bp-4B8h]@278 + int v111; // [sp-Ch] [bp-4B4h]@278 + // Event *v112; // [sp-8h] [bp-4B0h]@5 + int v113; // [sp-8h] [bp-4B0h]@106 + int v114; // [sp-8h] [bp-4B0h]@117 + signed int v115; // [sp-8h] [bp-4B0h]@231 + unsigned int v116; // [sp-8h] [bp-4B0h]@278 + int v117; // [sp-4h] [bp-4ACh]@106 + int v118; // [sp-4h] [bp-4ACh]@117 + int v119; // [sp-4h] [bp-4ACh]@231 + int v120; // [sp-4h] [bp-4ACh]@278 + int v121; // [sp-4h] [bp-4ACh]@294 + int curr_seq_num; // [sp+10h] [bp-498h]@4 + //char *v123; // [sp+14h] [bp-494h]@0 + signed int v124; // [sp+18h] [bp-490h]@7 + //signed int v125; // [sp+1Ch] [bp-48Ch]@155 + int v126; // [sp+1Ch] [bp-48Ch]@262 + int player_choose; // [sp+20h] [bp-488h]@4 + int v128; // [sp+24h] [bp-484h]@21 + int v129; // [sp+24h] [bp-484h]@262 + signed int v130; // [sp+28h] [bp-480h]@0 + //int v131; // [sp+2Ch] [bp-47Ch]@1 + int v132; // [sp+30h] [bp-478h]@262 + signed int v133; // [sp+34h] [bp-474h]@1 + int v134; // [sp+38h] [bp-470h]@262 + int v135; // [sp+3Ch] [bp-46Ch]@262 + int v136; // [sp+40h] [bp-468h]@40 + int v137; // [sp+44h] [bp-464h]@40 + int v138; // [sp+48h] [bp-460h]@40 + int v139; // [sp+4Ch] [bp-45Ch]@40 + ItemGen item; // [sp+50h] [bp-458h]@15 + char Source[120]; // [sp+74h] [bp-434h]@15 + char Str[120]; // [sp+ECh] [bp-3BCh]@21 + Actor Dst; // [sp+164h] [bp-344h]@53 - //v131 = uEventID; - v133 = 0; - EvtTargetObj = targetObj; - dword_5B65C4 = 0; - if ( !uEventID ) - { - if ( !GameUI_Footer_TimeLeft ) - ShowStatusBarString(pGlobalTXT_LocalizationStrings[521], 2u);// Nothing here - return; - } - player_choose = (uActiveCharacter == 0)?6:4; //4 - active or 6 - random player if active =0 - curr_seq_num = entry_line; + //v131 = uEventID; + v133 = 0; + EvtTargetObj = targetObj; + dword_5B65C4 = 0; + if ( !uEventID ) + { + if ( !GameUI_Footer_TimeLeft ) + ShowStatusBarString(pGlobalTXT_LocalizationStrings[521], 2u);// Nothing here + return; + } + player_choose = (uActiveCharacter == 0)?6:4; //4 - active or 6 - random player if active =0 + curr_seq_num = entry_line; - if ( activeLevelDecoration ) - { - uSomeEVT_NumEvents = uGlobalEVT_NumEvents; - pSomeEVT = pGlobalEVT.data(); - memcpy(pSomeEVT_Events.data(), pGlobalEVT_Index.data(), sizeof(EventIndex)*4400); //4400 evts - } - else - { - uSomeEVT_NumEvents = uLevelEVT_NumEvents; - pSomeEVT = pLevelEVT.data(); - memcpy(pSomeEVT_Events.data(), pLevelEVT_Index.data(), sizeof(EventIndex)*4400); - } + if ( activeLevelDecoration ) + { + uSomeEVT_NumEvents = uGlobalEVT_NumEvents; + pSomeEVT = pGlobalEVT.data(); + memcpy(pSomeEVT_Events.data(), pGlobalEVT_Index.data(), sizeof(EventIndex)*4400); //4400 evts + } + else + { + uSomeEVT_NumEvents = uLevelEVT_NumEvents; + pSomeEVT = pLevelEVT.data(); + memcpy(pSomeEVT_Events.data(), pLevelEVT_Index.data(), sizeof(EventIndex)*4400); + } - v4 = 0; - v124 = 0; - //for (uint i = 0; i < uSomeEVT_NumEvents; ++i) - // { - //v6 = v123; - //v7 = ""; - while ( 1 ) - { - if ( dword_5B65C4 ) - goto LABEL_301; - //v8 = v4; - if ( pSomeEVT_Events[v4].uEventID == uEventID && pSomeEVT_Events[v4].event_sequence_num == curr_seq_num ) - { - //v9 = pSomeEVT_Events[v8].uEventOffsetInEVT; - //v10 = (ByteArray *)&v5[v9]; - auto _evt = (_evt_raw *)(pSomeEVT + pSomeEVT_Events[v4].uEventOffsetInEVT); + v4 = 0; + v124 = 0; + //for (uint i = 0; i < uSomeEVT_NumEvents; ++i) + // { + //v6 = v123; + //v7 = ""; + while ( 1 ) + { + if ( dword_5B65C4 ) + goto LABEL_301; + //v8 = v4; + if ( pSomeEVT_Events[v4].uEventID == uEventID && pSomeEVT_Events[v4].event_sequence_num == curr_seq_num ) + { + //v9 = pSomeEVT_Events[v8].uEventOffsetInEVT; + //v10 = (ByteArray *)&v5[v9]; + auto _evt = (_evt_raw *)(pSomeEVT + pSomeEVT_Events[v4].uEventOffsetInEVT); - switch (_evt->_e_type) - { - case EVENT_CheckSeason: - // - if ( !sub_4465DF_check_season(_evt->v5) ) + switch (_evt->_e_type) + { + case EVENT_CheckSeason: + // + if ( !sub_4465DF_check_season(_evt->v5) ) { - ++curr_seq_num; - v4 = v124; - break; + ++curr_seq_num; + v4 = v124; + break; } - v124 = -1; - curr_seq_num = _evt->v6 - 1; - ++curr_seq_num; - break; - case EVENT_ShowMovie: - { - strcpy(Source, (char *)&_evt->v7); - v12 = (char *)&item.uExpireTime + strlen(Source) + 7; - if ( *v12 == 32 ) - *v12 = 0; - if ( pVideoPlayer->field_54 ) - pVideoPlayer->Unload(); - pVideoPlayer->bStopBeforeSchedule = 0; - pVideoPlayer->pResetflag = 0; + v124 = -1; + curr_seq_num = _evt->v6 - 1; + ++curr_seq_num; + break; + case EVENT_ShowMovie: + { + strcpy(Source, (char *)&_evt->v7); + v12 = (char *)&item.uExpireTime + strlen(Source) + 7; + if ( *v12 == 32 ) + *v12 = 0; + if ( pVideoPlayer->field_54 ) + pVideoPlayer->Unload(); + pVideoPlayer->bStopBeforeSchedule = 0; + pVideoPlayer->pResetflag = 0; - v128 = pCurrentScreen; - //v13 = &pSomeEVT[v9]; - //v14 = (unsigned __int8)v13[5]; - //v15 = (unsigned __int8)v13[6]; - v14 = _evt->v5; - v15 = _evt->v6; - strcpy(Str, Source); - v16 = RemoveQuotes(Str); - VideoPlayer::MovieLoop(v16, 0, v14, 1); - if ( !_stricmp(v16, "arbiter good") ) + v128 = pCurrentScreen; + //v13 = &pSomeEVT[v9]; + //v14 = (unsigned __int8)v13[5]; + //v15 = (unsigned __int8)v13[6]; + v14 = _evt->v5; + v15 = _evt->v6; + strcpy(Str, Source); + v16 = RemoveQuotes(Str); + VideoPlayer::MovieLoop(v16, 0, v14, 1); + if ( !_stricmp(v16, "arbiter good") ) { pParty->alignment = PartyAlignment_Good; - v18 = 0; - LOBYTE(v17) = 1; - SetUserInterface(PartyAlignment_Good, v17); - if ( !v15 || v128 == 3 ) - { - pCurrentScreen = v128; - if ( v128 == 3 ) - pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; - if ( v128 == 13 ) - pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); - } + v18 = 0; + LOBYTE(v17) = 1; + SetUserInterface(PartyAlignment_Good, v17); + if ( !v15 || v128 == 3 ) + { + pCurrentScreen = v128; + if ( v128 == 3 ) + pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; + if ( v128 == 13 ) + pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); + } + + ++curr_seq_num; + v4 = v124; - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - } - if ( !_stricmp(v16, "arbiter evil") ) - { - v18 = 2; - pParty->alignment = PartyAlignment_Evil; - LOBYTE(v17) = 1; - SetUserInterface(PartyAlignment_Evil, v17); - if ( !v15 || v128 == 3 ) - { - pCurrentScreen = v128; - if ( v128 == 3 ) - pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; - if ( v128 == 13 ) - pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); - } - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; + //v6 = v123; + //v7 = ""; + break; + } + if ( !_stricmp(v16, "arbiter evil") ) + { + v18 = 2; + pParty->alignment = PartyAlignment_Evil; + LOBYTE(v17) = 1; + SetUserInterface(PartyAlignment_Evil, v17); + if ( !v15 || v128 == 3 ) + { + pCurrentScreen = v128; + if ( v128 == 3 ) + pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; + if ( v128 == 13 ) + pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); + } + ++curr_seq_num; + v4 = v124; - break; - } - if ( !_stricmp(v16, "pcout01") ) // moving to harmondale from emerald isle + //v6 = v123; + //v7 = ""; + + break; + } + if ( !_stricmp(v16, "pcout01") ) // moving to harmondale from emerald isle { - Rest(0x2760u); - pParty->RestAndHeal(); - pParty->days_played_without_rest = 0; + Rest(0x2760u); + pParty->RestAndHeal(); + pParty->days_played_without_rest = 0; } - if ( !v15 || v128 == 3 ) - { - pCurrentScreen = v128; - if ( v128 == 3 ) - pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; - if ( v128 == 13 ) - pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); - } - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - } - break; - case EVENT_CheckSkill: - { - v19 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((unsigned int)_evt->v10 << 8)) << 8)) << 8); - if ( player_choose < 0 ) - goto LABEL_47; - if ( player_choose <= 3 ) - { - v24 = pParty->pPlayers[0].pActiveSkills[3486 * player_choose + _evt->v5]; - } - else - { - if ( player_choose == 4 ) - { - v24 = pPlayers[uActiveCharacter]->pActiveSkills[_evt->v5]; - } - else - { - if ( player_choose == 5 ) - { - v20 = 0; - v21 = 3486 * v130 + _evt->v5; - v136 = 1; - LOWORD(v21) = pParty->pPlayers[0].pActiveSkills[v21]; - v137 = v21 & 0x40; - v138 = v21 & 0x80; - v22 = v21 & 0x100; - v23 = v21 & 0x3F; - v139 = v22; - while ( v23 < v19 || !*(&v136 + _evt->v6) ) - { - ++v20; - if ( v20 >= 4 ) - { - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - } - } - v11 = _evt->v11; - goto LABEL_130; - } + if ( !v15 || v128 == 3 ) + { + pCurrentScreen = v128; + if ( v128 == 3 ) + pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; + if ( v128 == 13 ) + pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); + } + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + } + break; + case EVENT_CheckSkill: + { + v19 = _evt->v7 + ((_evt->v8 + ((_evt->v9 + ((unsigned int)_evt->v10 << 8)) << 8)) << 8); + if ( player_choose < 0 ) + goto LABEL_47; + if ( player_choose <= 3 ) + { + v24 = pParty->pPlayers[0].pActiveSkills[3486 * player_choose + _evt->v5]; + } + else + { + if ( player_choose == 4 ) + { + v24 = pPlayers[uActiveCharacter]->pActiveSkills[_evt->v5]; + } + else + { + if ( player_choose == 5 ) + { + v20 = 0; + v21 = 3486 * v130 + _evt->v5; + v136 = 1; + LOWORD(v21) = pParty->pPlayers[0].pActiveSkills[v21]; + v137 = v21 & 0x40; + v138 = v21 & 0x80; + v22 = v21 & 0x100; + v23 = v21 & 0x3F; + v139 = v22; + while ( v23 < v19 || !*(&v136 + _evt->v6) ) + { + ++v20; + if ( v20 >= 4 ) + { + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + } + } + v11 = _evt->v11; + goto LABEL_130; + } LABEL_47: - //v10 = (ByteArray *)&v5[v9]; - v24 = pParty->pPlayers[0].pActiveSkills[_evt->v5 + 3486 * rand() % 4]; - } - } - v136 = 1; - v137 = v24 & 0x40; - v138 = v24 & 0x80; - v139 = v24 & 0x100; - if ( (v24 & 0x3F) >= v19 && *(&v136 + _evt->v6) ) - { - v11 = _evt->v11; - goto LABEL_130; - } - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - } - break; + //v10 = (ByteArray *)&v5[v9]; + v24 = pParty->pPlayers[0].pActiveSkills[_evt->v5 + 3486 * rand() % 4]; + } + } + v136 = 1; + v137 = v24 & 0x40; + v138 = v24 & 0x80; + v139 = v24 & 0x100; + if ( (v24 & 0x3F) >= v19 && *(&v136 + _evt->v6) ) + { + v11 = _evt->v11; + goto LABEL_130; + } + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + } + break; - case EVENT_SpeakNPC: - if ( canShowMessages ) - { - //Actor::Actor(&Dst); - memset(&Dst, 0, 0x344u); - dword_5B65D0_dialogue_actor_npc_id = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8); - Dst.sNPC_ID = dword_5B65D0_dialogue_actor_npc_id; - GameUI_InitializeDialogue(&Dst, false); - } - else - { - bDialogueUI_InitializeActor_NPC_ID = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8); - } - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_ChangeEvent: - v25 = EVT_DWORD(_evt->v5); - if ( v25 ) - { - stru_5E4C90._decor_events[activeLevelDecoration->_idx_in_stru123] = _evt->v5 - 124; - } - else - { - v26 = (LevelDecoration *)activeLevelDecoration; - stru_5E4C90._decor_events[activeLevelDecoration ->_idx_in_stru123] = 0; - v26->field_2 |= 0x0020; - } - ++curr_seq_num; - v4 = v124; + case EVENT_SpeakNPC: + if ( canShowMessages ) + { + //Actor::Actor(&Dst); + memset(&Dst, 0, 0x344u); + dword_5B65D0_dialogue_actor_npc_id = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8); + Dst.sNPC_ID = dword_5B65D0_dialogue_actor_npc_id; + GameUI_InitializeDialogue(&Dst, false); + } + else + { + bDialogueUI_InitializeActor_NPC_ID = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8); + } + ++curr_seq_num; + v4 = v124; - break; - case EVENT_SetNPCGreeting: - v27 = EVT_DWORD(_evt->v5); - pNPCStats->pNewNPCData[v27].uFlags &= 0xFFFFFFFCu; - pNPCStats->pNewNPCData[v27].greet = EVT_DWORD(_evt->v9); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; + //v6 = v123; + //v7 = ""; + break; + case EVENT_ChangeEvent: + v25 = EVT_DWORD(_evt->v5); + if ( v25 ) + { + stru_5E4C90._decor_events[activeLevelDecoration->_idx_in_stru123] = _evt->v5 - 124; + } + else + { + v26 = (LevelDecoration *)activeLevelDecoration; + stru_5E4C90._decor_events[activeLevelDecoration ->_idx_in_stru123] = 0; + v26->uFlags |= LEVEL_DECORATION_INVISIBLE; + } + ++curr_seq_num; + v4 = v124; + + break; + case EVENT_SetNPCGreeting: + v27 = EVT_DWORD(_evt->v5); + pNPCStats->pNewNPCData[v27].uFlags &= 0xFFFFFFFCu; + pNPCStats->pNewNPCData[v27].greet = EVT_DWORD(_evt->v9); + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; case EVENT_SetNPCTopic: { //v29 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); @@ -722,381 +722,381 @@ } v4 = v124; break; - case EVENT_NPCSetItem: - sub_448518_npc_set_item(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); - ++curr_seq_num; - v4 = v124; + case EVENT_NPCSetItem: + sub_448518_npc_set_item(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); + ++curr_seq_num; + v4 = v124; - break; - case EVENT_SetActorItem: - Actor::GiveItem(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); - ++curr_seq_num; - v4 = v124; - break; - case EVENT_SetNPCGroupNews: - pNPCStats->pGroups_copy[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)] = _evt->v9 + ((uint)_evt->v10 << 8); - ++curr_seq_num; - v4 = v124; - break; - case EVENT_SetActorGroup: - __debugbreak(); - *(&pActors[0].uGroup + 0x11000000 * _evt->v8 + 209 * (_evt->v5 + ((_evt->v6 + ((uint)_evt->v7 << 8)) << 8))) = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); - ++curr_seq_num; - v4 = v124; - break; - case EVENT_ChangeGroup: - v38 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); - v39 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); - v40 = uNumActors; - __debugbreak(); - if ( (signed int)uNumActors > 0 ) - { - v41 = pActors.data();//[0].uGroup; - do - { - if ( v41->uGroup == v38 ) - v41->uGroup = v39; - ++v41; - --v40; - } - while ( v40 ); - } - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_ChangeGroupAlly: - v42 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); - v43 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); - v44 = uNumActors; - __debugbreak(); - if ( (signed int)uNumActors > 0 ) - { - v45 = pActors.data();//[0].uAlly; - do - { - if ( v45->uGroup == v42 ) - v45->uAlly = v43; - ++v45; - --v44; - } - while ( v44 ); - } - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_MoveNPC: - { + break; + case EVENT_SetActorItem: + Actor::GiveItem(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); + ++curr_seq_num; + v4 = v124; + break; + case EVENT_SetNPCGroupNews: + pNPCStats->pGroups_copy[_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8)] = _evt->v9 + ((uint)_evt->v10 << 8); + ++curr_seq_num; + v4 = v124; + break; + case EVENT_SetActorGroup: + __debugbreak(); + *(&pActors[0].uGroup + 0x11000000 * _evt->v8 + 209 * (_evt->v5 + ((_evt->v6 + ((uint)_evt->v7 << 8)) << 8))) = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); + ++curr_seq_num; + v4 = v124; + break; + case EVENT_ChangeGroup: + v38 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); + v39 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); + v40 = uNumActors; + __debugbreak(); + if ( (signed int)uNumActors > 0 ) + { + v41 = pActors.data();//[0].uGroup; + do + { + if ( v41->uGroup == v38 ) + v41->uGroup = v39; + ++v41; + --v40; + } + while ( v40 ); + } + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_ChangeGroupAlly: + v42 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); + v43 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); + v44 = uNumActors; + __debugbreak(); + if ( (signed int)uNumActors > 0 ) + { + v45 = pActors.data();//[0].uAlly; + do + { + if ( v45->uGroup == v42 ) + v45->uAlly = v43; + ++v45; + --v44; + } + while ( v44 ); + } + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_MoveNPC: + { + + pNPCStats->pNewNPCData[EVT_DWORD(_evt->v5)].Location2D =EVT_DWORD(_evt->v9); + if ( window_SpeakInHouse ) + { - pNPCStats->pNewNPCData[EVT_DWORD(_evt->v5)].Location2D =EVT_DWORD(_evt->v9); - if ( window_SpeakInHouse ) - { - - if ( window_SpeakInHouse->par1C == 165 ) - { - sub_4BD8B5(); - pVideoPlayer->Unload(); - window_SpeakInHouse->Release(); - pParty->uFlags &= ~2; - activeLevelDecoration = (LevelDecoration*)1; - if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) ) - { - pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0); - window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0); - v48 = window_SpeakInHouse->pControlsHead; - if ( v48 ) - { - do - { - v49 = v48->pNext; - pAllocator->FreeChunk(v48); - v48 = v49; - } - while ( v49 ); - } - window_SpeakInHouse->pControlsHead = 0; - window_SpeakInHouse->pControlsTail = 0; - window_SpeakInHouse->uNumControls = 0; - } - } - else - { - if ( window_SpeakInHouse->par1C == 553 ) - pVideoPlayer->bLoopPlaying = 0; - } - } - - } + if ( window_SpeakInHouse->par1C == 165 ) + { + sub_4BD8B5(); + pVideoPlayer->Unload(); + window_SpeakInHouse->Release(); + pParty->uFlags &= ~2; + activeLevelDecoration = (LevelDecoration*)1; + if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) ) + { + pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0); + window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0); + v48 = window_SpeakInHouse->pControlsHead; + if ( v48 ) + { + do + { + v49 = v48->pNext; + pAllocator->FreeChunk(v48); + v48 = v49; + } + while ( v49 ); + } + window_SpeakInHouse->pControlsHead = 0; + window_SpeakInHouse->pControlsTail = 0; + window_SpeakInHouse->uNumControls = 0; + } + } + else + { + if ( window_SpeakInHouse->par1C == 553 ) + pVideoPlayer->bLoopPlaying = 0; + } + } + + } ++curr_seq_num; - v4 = v124; + v4 = v124; + + break; + case EVENT_Jmp: + curr_seq_num = _evt->v5 - 1; + ++curr_seq_num; + v4 = -1; - break; - case EVENT_Jmp: - curr_seq_num = _evt->v5 - 1; - ++curr_seq_num; - v4 = -1; + break; + case EVENT_ShowFace: + if ( _evt->v5 <= 3u ) //someone + pParty->pPlayers[_evt->v5].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); + else if ( _evt->v5 == 4 ) //active + pParty->pPlayers[uActiveCharacter].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); + else if ( _evt->v5 == 5 ) //all players + { + for(int i=0; i<4; ++i) + pParty->pPlayers[i].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); + } + else //random player + pParty->pPlayers[rand() % 4].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); + ++curr_seq_num; + v4 = v124; - break; - case EVENT_ShowFace: - if ( _evt->v5 <= 3u ) //someone - pParty->pPlayers[_evt->v5].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); - else if ( _evt->v5 == 4 ) //active - pParty->pPlayers[uActiveCharacter].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); - else if ( _evt->v5 == 5 ) //all players - { - for(int i=0; i<4; ++i) - pParty->pPlayers[i].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); - } - else //random player - pParty->pPlayers[rand() % 4].PlayEmotion((CHARACTER_EXPRESSION_ID)_evt->v6, 0); - ++curr_seq_num; - v4 = v124; + break; + case EVENT_CharacterAnimation: + if ( _evt->v5 <= 3u ) //someone + pParty->pPlayers[_evt->v5].PlaySound((PlayerSpeech) _evt->v6, 0); + else if ( _evt->v5 == 4 ) //active + pParty->pPlayers[uActiveCharacter].PlaySound((PlayerSpeech) _evt->v6, 0); + else if ( _evt->v5 == 5 ) //all + for(int i=0; i<4; ++i) + pParty->pPlayers[i].PlaySound((PlayerSpeech) _evt->v6, 0); + else //random + pParty->pPlayers[rand() % 4].PlaySound((PlayerSpeech) _evt->v6, 0); + ++curr_seq_num; + v4 = v124; - break; - case EVENT_CharacterAnimation: - if ( _evt->v5 <= 3u ) //someone - pParty->pPlayers[_evt->v5].PlaySound((PlayerSpeech) _evt->v6, 0); - else if ( _evt->v5 == 4 ) //active - pParty->pPlayers[uActiveCharacter].PlaySound((PlayerSpeech) _evt->v6, 0); - else if ( _evt->v5 == 5 ) //all - for(int i=0; i<4; ++i) - pParty->pPlayers[i].PlaySound((PlayerSpeech) _evt->v6, 0); - else //random - pParty->pPlayers[rand() % 4].PlaySound((PlayerSpeech) _evt->v6, 0); - ++curr_seq_num; - v4 = v124; + break; + case EVENT_ForPartyMember: + player_choose = _evt->v5; + ++curr_seq_num; + v4 = v124; + break; + case EVENT_SummonItem: + sub_42F7EB_DropItemAt(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), + _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), + _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8), + _evt->v17 + ((_evt->v18 + ((_evt->v19 + ((uint)_evt->v20 << 8)) << 8)) << 8), + _evt->v21 + ((_evt->v22 + ((_evt->v23 + ((uint)_evt->v24 << 8)) << 8)) << 8), + _evt->v25, _evt->v26, 0, 0); + ++curr_seq_num; + v4 = v124; - break; - case EVENT_ForPartyMember: - player_choose = _evt->v5; - ++curr_seq_num; - v4 = v124; - break; - case EVENT_SummonItem: - sub_42F7EB_DropItemAt(_evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8), - _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8), - _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8), - _evt->v17 + ((_evt->v18 + ((_evt->v19 + ((uint)_evt->v20 << 8)) << 8)) << 8), - _evt->v21 + ((_evt->v22 + ((_evt->v23 + ((uint)_evt->v24 << 8)) << 8)) << 8), - _evt->v25, _evt->v26, 0, 0); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_Compare: - pValue = EVT_DWORD(_evt->v7); - if ( player_choose <= 3 ) - { - if ( pPlayers[player_choose]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) - { - v124 = -1; - curr_seq_num = _evt->v11 - 1; - } - } - else if ( player_choose == 4 ) //active - { - if ( uActiveCharacter ) - { - if ( pPlayers[uActiveCharacter]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) - { - v124 = -1; - curr_seq_num = _evt->v11 - 1; - } - } - } - else if ( player_choose == 5 )//all - { - v130=0; - for(int i = 1; i < 5; ++i) - { - if ( pPlayers[i]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) - { - v124 = -1; - curr_seq_num = _evt->v11 - 1; - break; - } - ++v130; - } - } - else if ( player_choose == 6 ) //random - { - if ( pPlayers[rand() % 4]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) - { - v124 = -1; - curr_seq_num = _evt->v11 - 1; - } - } - ++curr_seq_num; - v4 = v124; - break; - case EVENT_IsActorAlive: - if (IsActorAlive(EVT_BYTE(_evt->v5), EVT_DWORD(_evt->v6), EVT_BYTE(_evt->v10))) - { - v124 = -1; - curr_seq_num = _evt->v11 - 1; - } - ++curr_seq_num; - v4 = v124; - break; - case EVENT_Substract: - pValue = EVT_DWORD(_evt->v7); - if ( EVT_WORD(_evt->v5) == VAR_PlayerItemInHands ) - { - if ( pParty->pPickedItem.uItemID == pValue )//In hand - { - pMouse->RemoveHoldingItem(); - ++curr_seq_num; - v4 = v124; - break; - } - v67 = (int)pPlayers[uActiveCharacter]->pInventoryMatrix; - for ( v65 = 0; v65 < 126; ++v65 ) - { - if ( (int)&pPlayers[uActiveCharacter]->pInventoryItemList[v67] == pValue ) - { - pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v65); - ++curr_seq_num; - v4 = v124; - break; - } - v67 += 4; - } - while ( (signed int)v65 < 126 ); - v69 = (int)&pPlayers[uActiveCharacter]->pEquipment; - for ( v68 = 0; v68 < 16; ++v68 ) - { - if ( *(int *)v69 && (int)&pPlayers[uActiveCharacter]->pInventoryItemList[v69] == pValue ) - { - *(&pPlayers[uActiveCharacter]->pEquipment.uShield + v68) = 0; - ++curr_seq_num; - v4 = v124; - break; - } - v69 += 4; - } - for (int i = 1; i < 5; i++) - { - v72 = (int)pPlayers[i]->pInventoryMatrix; - for ( int v71 = 0; v71 < 126; ++v71 ) - { - if ( (int)&pPlayers[i]->pInventoryItemList[v72] == pValue ) - { - pPlayers[i]->RemoveItemAtInventoryIndex(v71); - break; - } - v72 += 4; - } - v73 = 0; - v74 = (int)&pPlayers[i]->pEquipment; - while ( !*(int *)v74 || (int)&pPlayer->pInventoryItemList[v74] != pValue ) - { - ++v73; - v74 += 4; - if ( v73 >= 16 ) - break; - } - *(&pPlayers[i]->pEquipment.uShield + v73) = 0; - } - } - if ( player_choose <= 3 ) - { - pPlayer = &pParty->pPlayers[player_choose]; - pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } - else if ( player_choose == 4 ) //active - { - if ( uActiveCharacter ) - { - pPlayer = pPlayers[uActiveCharacter]; - pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } - } - else if ( player_choose == 5 )//all - { - v130 = 0; - for(int i = 1; i < 5; ++i) - { - if ( pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) - break; - } - ++v130; - } - else if ( player_choose == 6 ) //random - { - player_choose = rand() % 4; - pPlayer = &pParty->pPlayers[player_choose]; - pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } - ++curr_seq_num; - v4 = v124; - break; - case EVENT_Set: - pValue = EVT_DWORD(_evt->v7); - if ( player_choose <= 3 ) - { - pPlayer = &pParty->pPlayers[player_choose]; - pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } - else if ( player_choose == 4 ) //active - { - if ( uActiveCharacter ) - { - pPlayer = pPlayers[uActiveCharacter]; - pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } - } - else if ( player_choose == 5 )//all - { + //v6 = v123; + //v7 = ""; + break; + case EVENT_Compare: + pValue = EVT_DWORD(_evt->v7); + if ( player_choose <= 3 ) + { + if ( pPlayers[player_choose]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) + { + v124 = -1; + curr_seq_num = _evt->v11 - 1; + } + } + else if ( player_choose == 4 ) //active + { + if ( uActiveCharacter ) + { + if ( pPlayers[uActiveCharacter]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) + { + v124 = -1; + curr_seq_num = _evt->v11 - 1; + } + } + } + else if ( player_choose == 5 )//all + { + v130=0; + for(int i = 1; i < 5; ++i) + { + if ( pPlayers[i]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) + { + v124 = -1; + curr_seq_num = _evt->v11 - 1; + break; + } + ++v130; + } + } + else if ( player_choose == 6 ) //random + { + if ( pPlayers[rand() % 4]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) + { + v124 = -1; + curr_seq_num = _evt->v11 - 1; + } + } + ++curr_seq_num; + v4 = v124; + break; + case EVENT_IsActorAlive: + if (IsActorAlive(EVT_BYTE(_evt->v5), EVT_DWORD(_evt->v6), EVT_BYTE(_evt->v10))) + { + v124 = -1; + curr_seq_num = _evt->v11 - 1; + } + ++curr_seq_num; + v4 = v124; + break; + case EVENT_Substract: + pValue = EVT_DWORD(_evt->v7); + if ( EVT_WORD(_evt->v5) == VAR_PlayerItemInHands ) + { + if ( pParty->pPickedItem.uItemID == pValue )//In hand + { + pMouse->RemoveHoldingItem(); + ++curr_seq_num; + v4 = v124; + break; + } + v67 = (int)pPlayers[uActiveCharacter]->pInventoryMatrix; + for ( v65 = 0; v65 < 126; ++v65 ) + { + if ( (int)&pPlayers[uActiveCharacter]->pInventoryItemList[v67] == pValue ) + { + pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v65); + ++curr_seq_num; + v4 = v124; + break; + } + v67 += 4; + } + while ( (signed int)v65 < 126 ); + v69 = (int)&pPlayers[uActiveCharacter]->pEquipment; + for ( v68 = 0; v68 < 16; ++v68 ) + { + if ( *(int *)v69 && (int)&pPlayers[uActiveCharacter]->pInventoryItemList[v69] == pValue ) + { + *(&pPlayers[uActiveCharacter]->pEquipment.uShield + v68) = 0; + ++curr_seq_num; + v4 = v124; + break; + } + v69 += 4; + } + for (int i = 1; i < 5; i++) + { + v72 = (int)pPlayers[i]->pInventoryMatrix; + for ( int v71 = 0; v71 < 126; ++v71 ) + { + if ( (int)&pPlayers[i]->pInventoryItemList[v72] == pValue ) + { + pPlayers[i]->RemoveItemAtInventoryIndex(v71); + break; + } + v72 += 4; + } + v73 = 0; + v74 = (int)&pPlayers[i]->pEquipment; + while ( !*(int *)v74 || (int)&pPlayer->pInventoryItemList[v74] != pValue ) + { + ++v73; + v74 += 4; + if ( v73 >= 16 ) + break; + } + *(&pPlayers[i]->pEquipment.uShield + v73) = 0; + } + } + if ( player_choose <= 3 ) + { + pPlayer = &pParty->pPlayers[player_choose]; + pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + else if ( player_choose == 4 ) //active + { + if ( uActiveCharacter ) + { + pPlayer = pPlayers[uActiveCharacter]; + pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + } + else if ( player_choose == 5 )//all + { + v130 = 0; + for(int i = 1; i < 5; ++i) + { + if ( pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) + break; + } + ++v130; + } + else if ( player_choose == 6 ) //random + { + player_choose = rand() % 4; + pPlayer = &pParty->pPlayers[player_choose]; + pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + ++curr_seq_num; + v4 = v124; + break; + case EVENT_Set: + pValue = EVT_DWORD(_evt->v7); + if ( player_choose <= 3 ) + { + pPlayer = &pParty->pPlayers[player_choose]; + pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + else if ( player_choose == 4 ) //active + { + if ( uActiveCharacter ) + { + pPlayer = pPlayers[uActiveCharacter]; + pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + } + else if ( player_choose == 5 )//all + { //recheck v130 - for(int i = 1; i < 5; ++i) - pPlayers[i]->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + for(int i = 1; i < 5; ++i) + pPlayers[i]->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } - else if ( player_choose == 6 ) //random - { - player_choose = rand() % 4; - pPlayer = &pParty->pPlayers[player_choose]; - pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + else if ( player_choose == 6 ) //random + { + player_choose = rand() % 4; + pPlayer = &pParty->pPlayers[player_choose]; + pPlayer->SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } + } ++curr_seq_num; v4 = v124; break; - case EVENT_Add: - pValue = EVT_DWORD(_evt->v7); - if ( player_choose <= 3 ) - { - pPlayer = &pParty->pPlayers[player_choose]; - pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } - else if ( player_choose == 4 ) //active - { - if ( uActiveCharacter ) - { - pPlayer = pPlayers[uActiveCharacter]; - pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } - } - else if ( player_choose == 5 )//all - { - //v130 = 0; - for(int i = 1; i < 5; ++i) - pPlayers[i]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + case EVENT_Add: + pValue = EVT_DWORD(_evt->v7); + if ( player_choose <= 3 ) + { + pPlayer = &pParty->pPlayers[player_choose]; + pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + else if ( player_choose == 4 ) //active + { + if ( uActiveCharacter ) + { + pPlayer = pPlayers[uActiveCharacter]; + pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + } + else if ( player_choose == 5 )//all + { + //v130 = 0; + for(int i = 1; i < 5; ++i) + pPlayers[i]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } - else if ( player_choose == 6 ) //random - { - player_choose = rand() % 4; - pPlayer = &pParty->pPlayers[player_choose]; - pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } + } + else if ( player_choose == 6 ) //random + { + player_choose = rand() % 4; + pPlayer = &pParty->pPlayers[player_choose]; + pPlayer->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } v83 = EVT_WORD(_evt->v5); if (v83 == 21 || // gold well on emerald isle v83 == 22 || v83 == 23 || v83 == 24 ) @@ -1107,432 +1107,432 @@ ++curr_seq_num; v4 = v124; break; - case EVENT_InputString: - if ( !entry_line ) - { - strcpy(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[EVT_DWORD(_evt->v5 )]]); - v105 = curr_seq_num; - v121 = 26; + case EVENT_InputString: + if ( !entry_line ) + { + strcpy(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[EVT_DWORD(_evt->v5 )]]); + v105 = curr_seq_num; + v121 = 26; LABEL_295: - sub_4451A8_press_any_key(uEventID, v105, v121); + sub_4451A8_press_any_key(uEventID, v105, v121); LABEL_301: - if ( v133 == 1 ) - OnMapLeave(); - return; - } - v84 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8); - if ( !_stricmp(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8)]]) - || !_stricmp(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[v84]]) ) - { - v11 = _evt->v17; + if ( v133 == 1 ) + OnMapLeave(); + return; + } + v84 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8); + if ( !_stricmp(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[_evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8)]]) + || !_stricmp(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[v84]]) ) + { + v11 = _evt->v17; LABEL_130: - //v124 = -1; + //v124 = -1; LABEL_131: - curr_seq_num = v11 - 1; - } - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_RandomGoTo: - //v124 = -1; - v11 = (unsigned __int8)*(&_evt->v5 + rand() % ((_evt->v5 != 0) + (_evt->v6 != 0) + (_evt->v7 != 0) + (_evt->v8 != 0) + (_evt->v9 != 0) - + (_evt->v10 != 0))); + curr_seq_num = v11 - 1; + } + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_RandomGoTo: + //v124 = -1; + v11 = (unsigned __int8)*(&_evt->v5 + rand() % ((_evt->v5 != 0) + (_evt->v6 != 0) + (_evt->v7 != 0) + (_evt->v8 != 0) + (_evt->v9 != 0) + + (_evt->v10 != 0))); curr_seq_num = v11 - 1; ++curr_seq_num; v4 = v124; break; - case EVENT_ReceiveDamage: - v85 = EVT_DWORD(_evt->v7 ); - v86 = _evt->v5; - if ( (unsigned __int8)v86 <= 3 ) - { - v119 = _evt->v6; - v115 = EVT_DWORD(_evt->v7 ); - v89 = (unsigned __int8)v86; - v88 = &pParty->pPlayers[v89]; - v88->ReceiveDamage(v115, (DAMAGE_TYPE)v119); - ++curr_seq_num; - v4 = v124; - break; - } - if ( v86 == 4 ) - { - if ( !uActiveCharacter ) - { - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - } - v119 = _evt->v6; - v88 = pPlayers[uActiveCharacter]; - v115 = EVT_DWORD(_evt->v7 ); - v88->ReceiveDamage(v115, (DAMAGE_TYPE)v119); - ++curr_seq_num; - v4 = v124; - break; - } - if ( v86 != 5 ) - { - v119 = _evt->v6; - v115 = EVT_DWORD(_evt->v7 ); - v89 = rand() % 4; - v88 = &pParty->pPlayers[v89]; - v88->ReceiveDamage(v115, (DAMAGE_TYPE)v119); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - } - v87 = pParty->pPlayers; - do - { - v87->ReceiveDamage(v85, (DAMAGE_TYPE)_evt->v6); - ++v87; - } - while ( (signed int)v87 < (signed int)pParty->pHirelings ); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_ToggleIndoorLight: - pIndoor->ToggleLight(EVT_DWORD(_evt->v5 ), _evt->v9); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_SetFacesBit: - sub_44892E_set_faces_bit(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_ToggleChestFlag: - Chest::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_ToggleActorFlag: - Actor::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_ToggleActorGroupFlag: - ToggleActorGroupFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_SetSnow: - if ( !_evt->v5 ) - pWeather->bRenderSnow = _evt->v6 != 0; - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_StatusText: - v90 = EVT_DWORD(_evt->v5 ); - if ( activeLevelDecoration ) - { - if ( activeLevelDecoration == (LevelDecoration*)1 ) - { - current_npc_text = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90]; - } - if ( canShowMessages == 1 ) - { - v91 = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90]; - //LABEL_248: - ShowStatusBarString(v91, 2u); - } - } - else - { - if ( canShowMessages == 1 ) - { - v91 = &pLevelStr[pLevelStrOffsets[v90]]; - ShowStatusBarString(v91, 2u); - } - } - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_ShowMessage: - v92 = EVT_DWORD(_evt->v5 ); - if ( activeLevelDecoration ) - { - v93 = (char *)pNPCTopics[v92-1].pText;//(&dword_721664)[8 * v92]; - byte_5B0938[0] = 0; - current_npc_text = v93; - } - else - { - strcpy(byte_5B0938.data(), &pLevelStr[pLevelStrOffsets[v92]]); - } - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_CastSpell: + case EVENT_ReceiveDamage: + v85 = EVT_DWORD(_evt->v7 ); + v86 = _evt->v5; + if ( (unsigned __int8)v86 <= 3 ) + { + v119 = _evt->v6; + v115 = EVT_DWORD(_evt->v7 ); + v89 = (unsigned __int8)v86; + v88 = &pParty->pPlayers[v89]; + v88->ReceiveDamage(v115, (DAMAGE_TYPE)v119); + ++curr_seq_num; + v4 = v124; + break; + } + if ( v86 == 4 ) + { + if ( !uActiveCharacter ) + { + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + } + v119 = _evt->v6; + v88 = pPlayers[uActiveCharacter]; + v115 = EVT_DWORD(_evt->v7 ); + v88->ReceiveDamage(v115, (DAMAGE_TYPE)v119); + ++curr_seq_num; + v4 = v124; + break; + } + if ( v86 != 5 ) + { + v119 = _evt->v6; + v115 = EVT_DWORD(_evt->v7 ); + v89 = rand() % 4; + v88 = &pParty->pPlayers[v89]; + v88->ReceiveDamage(v115, (DAMAGE_TYPE)v119); + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + } + v87 = pParty->pPlayers; + do + { + v87->ReceiveDamage(v85, (DAMAGE_TYPE)_evt->v6); + ++v87; + } + while ( (signed int)v87 < (signed int)pParty->pHirelings ); + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_ToggleIndoorLight: + pIndoor->ToggleLight(EVT_DWORD(_evt->v5 ), _evt->v9); + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_SetFacesBit: + sub_44892E_set_faces_bit(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_ToggleChestFlag: + Chest::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_ToggleActorFlag: + Actor::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_ToggleActorGroupFlag: + ToggleActorGroupFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_SetSnow: + if ( !_evt->v5 ) + pWeather->bRenderSnow = _evt->v6 != 0; + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_StatusText: + v90 = EVT_DWORD(_evt->v5 ); + if ( activeLevelDecoration ) + { + if ( activeLevelDecoration == (LevelDecoration*)1 ) + { + current_npc_text = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90]; + } + if ( canShowMessages == 1 ) + { + v91 = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90]; + //LABEL_248: + ShowStatusBarString(v91, 2u); + } + } + else + { + if ( canShowMessages == 1 ) + { + v91 = &pLevelStr[pLevelStrOffsets[v90]]; + ShowStatusBarString(v91, 2u); + } + } + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_ShowMessage: + v92 = EVT_DWORD(_evt->v5 ); + if ( activeLevelDecoration ) + { + v93 = (char *)pNPCTopics[v92-1].pText;//(&dword_721664)[8 * v92]; + byte_5B0938[0] = 0; + current_npc_text = v93; + } + else + { + strcpy(byte_5B0938.data(), &pLevelStr[pLevelStrOffsets[v92]]); + } + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_CastSpell: EventCastSpell(_evt->v5, _evt->v6, _evt->v7, EVT_DWORD(_evt->v8 ), EVT_DWORD(_evt->v12 ), EVT_DWORD(_evt->v16 ), EVT_DWORD(_evt->v20 ), EVT_DWORD(_evt->v24 ), EVT_DWORD(_evt->v28 )); ++curr_seq_num; v4 = v124; break; - case EVENT_SetTexture: - sub_44861E_set_texture(EVT_DWORD(_evt->v5 ), (char *)&_evt->v9); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_SetSprite: - SetDecorationSprite(EVT_DWORD(_evt->v5 ), _evt->v9, (char *)&_evt->v10); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_SummonMonsters: - sub_448CF4_spawn_monsters(_evt->v5, _evt->v6, _evt->v7,EVT_DWORD(_evt->v8 ), + case EVENT_SetTexture: + sub_44861E_set_texture(EVT_DWORD(_evt->v5 ), (char *)&_evt->v9); + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_SetSprite: + SetDecorationSprite(EVT_DWORD(_evt->v5 ), _evt->v9, (char *)&_evt->v10); + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_SummonMonsters: + sub_448CF4_spawn_monsters(_evt->v5, _evt->v6, _evt->v7,EVT_DWORD(_evt->v8 ), EVT_DWORD(_evt->v12 ), EVT_DWORD(_evt->v16 ), EVT_DWORD(_evt->v20 ), EVT_DWORD(_evt->v24 )); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_MouseOver: - case EVENT_LocationName: - --curr_seq_num; - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_ChangeDoorState: - sub_449A49_door_switch_animation(_evt->v5, _evt->v6); - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_OpenChest: - if ( !Chest::Open(_evt->v5) ) - goto LABEL_301; - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_MoveToMap: - v94 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); - v135 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); - v132 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); - v126 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8); - v129 = _evt->v17 + ((_evt->v18 + ((_evt->v19 + ((uint)_evt->v20 << 8)) << 8)) << 8); - v95 = _evt->v21 + ((_evt->v22 + ((_evt->v23 + ((uint)_evt->v24 << 8)) << 8)) << 8); - v96 = _evt->v25; - v97 = v96 + ((_evt->v26 + ((_evt->v27 + ((uint)_evt->v28 << 8)) << 8)) << 8); - v134 = v96 + ((_evt->v26 + ((_evt->v27 + ((uint)_evt->v28 << 8)) << 8)) << 8); - if ( _evt->v29 || _evt->v30 ) - { - if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode ) - pRenderer->_49FD3A(); - TransitionUI_Load(_evt->v29, _evt->v30, v135, v132, v126, v129, v95, v134, (char *)&_evt->v31); - dword_5C3418 = uEventID; - dword_5C341C = curr_seq_num + 1; - goto LABEL_301; - } - _5B65AC_npcdata_fame_or_other = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); - _5B65A8_npcdata_uflags_or_other = v94; - _5B65B0_npcdata_rep_or_other = v126; - if ( v129 == -1 ) - { - v98 = _5B65B4_npcdata_loword_house_or_other; - } - else - { - v98 = v129 & stru_5C6E00->uDoublePiMask; - _5B65B4_npcdata_loword_house_or_other = v129 & stru_5C6E00->uDoublePiMask; - } - v99 = (char *)&_evt->v31; - _5B65B8_npcdata_hiword_house_or_other = v95; - dword_5B65BC = v97; - v100 = v94 | v132 | v126 | v95 | v97 | v98; - dword_5B65C0 = v100; - if ( *v99 == 48 ) - { - if ( v100 ) - { - pParty->vPosition.x = v135; - pParty->vPosition.y = v132; - pParty->vPosition.z = v126; - pParty->uFallStartY = v126; - if ( _5B65B4_npcdata_loword_house_or_other != -1 ) - pParty->sRotationY = _5B65B4_npcdata_loword_house_or_other; - _5B65B4_npcdata_loword_house_or_other = -1; - v120 = 0; - v116 = 0; - v111 = 0; - v110 = 0; - v109 = -1; - v108 = 0; - v107 = 0; - pParty->sRotationX = v95; - pParty->uFallSpeed = v134; - dword_5B65C0 = 0; - dword_5B65BC = 0; - _5B65B8_npcdata_hiword_house_or_other = 0; - _5B65B0_npcdata_rep_or_other = 0; - _5B65AC_npcdata_fame_or_other = 0; - _5B65A8_npcdata_uflags_or_other = 0; - v106 = 232; + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_MouseOver: + case EVENT_LocationName: + --curr_seq_num; + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_ChangeDoorState: + sub_449A49_door_switch_animation(_evt->v5, _evt->v6); + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_OpenChest: + if ( !Chest::Open(_evt->v5) ) + goto LABEL_301; + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_MoveToMap: + v94 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); + v135 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); + v132 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); + v126 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8); + v129 = _evt->v17 + ((_evt->v18 + ((_evt->v19 + ((uint)_evt->v20 << 8)) << 8)) << 8); + v95 = _evt->v21 + ((_evt->v22 + ((_evt->v23 + ((uint)_evt->v24 << 8)) << 8)) << 8); + v96 = _evt->v25; + v97 = v96 + ((_evt->v26 + ((_evt->v27 + ((uint)_evt->v28 << 8)) << 8)) << 8); + v134 = v96 + ((_evt->v26 + ((_evt->v27 + ((uint)_evt->v28 << 8)) << 8)) << 8); + if ( _evt->v29 || _evt->v30 ) + { + if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode ) + pRenderer->_49FD3A(); + TransitionUI_Load(_evt->v29, _evt->v30, v135, v132, v126, v129, v95, v134, (char *)&_evt->v31); + dword_5C3418 = uEventID; + dword_5C341C = curr_seq_num + 1; + goto LABEL_301; + } + _5B65AC_npcdata_fame_or_other = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); + _5B65A8_npcdata_uflags_or_other = v94; + _5B65B0_npcdata_rep_or_other = v126; + if ( v129 == -1 ) + { + v98 = _5B65B4_npcdata_loword_house_or_other; + } + else + { + v98 = v129 & stru_5C6E00->uDoublePiMask; + _5B65B4_npcdata_loword_house_or_other = v129 & stru_5C6E00->uDoublePiMask; + } + v99 = (char *)&_evt->v31; + _5B65B8_npcdata_hiword_house_or_other = v95; + dword_5B65BC = v97; + v100 = v94 | v132 | v126 | v95 | v97 | v98; + dword_5B65C0 = v100; + if ( *v99 == 48 ) + { + if ( v100 ) + { + pParty->vPosition.x = v135; + pParty->vPosition.y = v132; + pParty->vPosition.z = v126; + pParty->uFallStartY = v126; + if ( _5B65B4_npcdata_loword_house_or_other != -1 ) + pParty->sRotationY = _5B65B4_npcdata_loword_house_or_other; + _5B65B4_npcdata_loword_house_or_other = -1; + v120 = 0; + v116 = 0; + v111 = 0; + v110 = 0; + v109 = -1; + v108 = 0; + v107 = 0; + pParty->sRotationX = v95; + pParty->uFallSpeed = v134; + dword_5B65C0 = 0; + dword_5B65BC = 0; + _5B65B8_npcdata_hiword_house_or_other = 0; + _5B65B0_npcdata_rep_or_other = 0; + _5B65AC_npcdata_fame_or_other = 0; + _5B65A8_npcdata_uflags_or_other = 0; + v106 = 232; LABEL_280: - pAudioPlayer->PlaySound((SoundID)v106, v107, v108, v109, v110, v111, v116, v120); - } - } - else - { - pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)((activeLevelDecoration == NULL) + 1); - sub_44987B(v99, MapStartPoint_Party); - v133 = 1; - if ( pCurrentScreen == SCREEN_HOUSE ) - { - if ( uGameState == GAME_STATE_2 ) - { - pAudioPlayer->StopChannels(-1, -1); - dialog_menu_id = HOUSE_DIALOGUE_NULL; - while ( sub_4BD8B5() ) - ; - pVideoPlayer->Unload(); - window_SpeakInHouse->Release(); - window_SpeakInHouse = 0; - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - pDialogueNPCCount = 0; - pDialogueWindow->Release(); - dialog_menu_id = HOUSE_DIALOGUE_NULL; - pDialogueWindow = 0; - pIcons_LOD->SyncLoadedFilesCount(); - } - OnMapLeave(); - return; - } - } - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_PlaySound: - v120 = 0; - v116 = 0; - v111 = 0; - v110 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8); - v109 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); - v108 = 0; - v107 = 0; - v106 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); - goto LABEL_280; - case EVENT_GiveItem: - item.Reset(); - //v101 = &pSomeEVT[v9]; - v102 = _evt->v7 - + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8); - pItemsTable->GenerateItem(_evt->v5, _evt->v6, &item); - if ( v102 ) - item.uItemID = v102; - pParty->SetHoldingItem(&item); - ++curr_seq_num; - v4 = v124; - //v6 = v123; - //v7 = ""; - break; - case EVENT_SpeakInHouse: - if ( EnterHouse((enum HOUSE_ID)EVT_DWORD(_evt->v5))) - { - if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode ) - pRenderer->_49FD3A(); - pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0); - pAudioPlayer->PlaySound(SOUND_EnteringAHouse, 814, 0, -1, 0, 0, 0, 0); - v104 = 187; - if ( uCurrentHouse_Animation != 167 ) - v104 = EVT_DWORD(_evt->v5); - window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, v104, 0); - window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); - window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); - window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); - window_SpeakInHouse->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); - window_SpeakInHouse->CreateButton( 0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, '\t', "", 0); - } - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - case EVENT_PressAnyKey: - v121 = 33; - v105 = curr_seq_num + 1; - goto LABEL_295; - case EVENT_Exit: - if ( v133 == 1 ) - OnMapLeave(); - return; - default: - ++curr_seq_num; - v4 = v124; - - //v6 = v123; - //v7 = ""; - break; - } - } - ++v4; - v124 = v4; - if ( v4 >= uSomeEVT_NumEvents ) - goto LABEL_301; - //} - } - } + pAudioPlayer->PlaySound((SoundID)v106, v107, v108, v109, v110, v111, v116, v120); + } + } + else + { + pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)((activeLevelDecoration == NULL) + 1); + sub_44987B(v99, MapStartPoint_Party); + v133 = 1; + if ( pCurrentScreen == SCREEN_HOUSE ) + { + if ( uGameState == GAME_STATE_2 ) + { + pAudioPlayer->StopChannels(-1, -1); + dialog_menu_id = HOUSE_DIALOGUE_NULL; + while ( sub_4BD8B5() ) + ; + pVideoPlayer->Unload(); + window_SpeakInHouse->Release(); + window_SpeakInHouse = 0; + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = 1; + pDialogueNPCCount = 0; + pDialogueWindow->Release(); + dialog_menu_id = HOUSE_DIALOGUE_NULL; + pDialogueWindow = 0; + pIcons_LOD->SyncLoadedFilesCount(); + } + OnMapLeave(); + return; + } + } + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_PlaySound: + v120 = 0; + v116 = 0; + v111 = 0; + v110 = _evt->v13 + ((_evt->v14 + ((_evt->v15 + ((uint)_evt->v16 << 8)) << 8)) << 8); + v109 = _evt->v9 + ((_evt->v10 + ((_evt->v11 + ((uint)_evt->v12 << 8)) << 8)) << 8); + v108 = 0; + v107 = 0; + v106 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); + goto LABEL_280; + case EVENT_GiveItem: + item.Reset(); + //v101 = &pSomeEVT[v9]; + v102 = _evt->v7 + + ((_evt->v8 + ((_evt->v9 + ((uint)_evt->v10 << 8)) << 8)) << 8); + pItemsTable->GenerateItem(_evt->v5, _evt->v6, &item); + if ( v102 ) + item.uItemID = v102; + pParty->SetHoldingItem(&item); + ++curr_seq_num; + v4 = v124; + //v6 = v123; + //v7 = ""; + break; + case EVENT_SpeakInHouse: + if ( EnterHouse((enum HOUSE_ID)EVT_DWORD(_evt->v5))) + { + if ( pRenderer->pRenderD3D && !pRenderer->bWindowMode ) + pRenderer->_49FD3A(); + pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_EnteringAHouse, 814, 0, -1, 0, 0, 0, 0); + v104 = 187; + if ( uCurrentHouse_Animation != 167 ) + v104 = EVT_DWORD(_evt->v5); + window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, v104, 0); + window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); + window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); + window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); + window_SpeakInHouse->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); + window_SpeakInHouse->CreateButton( 0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, '\t', "", 0); + } + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + case EVENT_PressAnyKey: + v121 = 33; + v105 = curr_seq_num + 1; + goto LABEL_295; + case EVENT_Exit: + if ( v133 == 1 ) + OnMapLeave(); + return; + default: + ++curr_seq_num; + v4 = v124; + + //v6 = v123; + //v7 = ""; + break; + } + } + ++v4; + v124 = v4; + if ( v4 >= uSomeEVT_NumEvents ) + goto LABEL_301; + //} + } + } //----- (00444732) -------------------------------------------------------- char *GetEventHintString(unsigned int uEventID) @@ -1548,14 +1548,14 @@ event_index = 0; if ( uLevelEVT_NumEvents <= 0 ) return NULL; - + //v2 = (char *)&pLevelEVT_Index[0].uEventOffsetInEVT; while ( 1 ) { if ( pLevelEVT_Index[event_index].uEventID == uEventID ) { - test_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index].uEventOffsetInEVT]; - last_evt=test_evt; + test_evt=(_evt_raw*)&pLevelEVT[pLevelEVT_Index[event_index].uEventOffsetInEVT]; + last_evt=test_evt; event_pos = pLevelEVT_Index[event_index+1].uEventOffsetInEVT; if ( test_evt->_e_type == EVENT_MouseOver ) break; @@ -1564,7 +1564,7 @@ if ( event_index >= uLevelEVT_NumEvents ) return NULL; } - test_evt=(_evt_raw*)&pLevelEVT[event_pos]; + test_evt=(_evt_raw*)&pLevelEVT[event_pos]; if ( test_evt->_e_type== EVENT_SpeakInHouse ) { str_index = EVT_DWORD(test_evt->v5); @@ -1575,7 +1575,7 @@ for ( i = event_index+1; pLevelEVT_Index[i].uEventID == uEventID; ++i ) { event_pos = pLevelEVT_Index[i].uEventOffsetInEVT; - test_evt=(_evt_raw*)&pLevelEVT[event_pos]; + test_evt=(_evt_raw*)&pLevelEVT[event_pos]; if ( test_evt->_e_type == EVENT_SpeakInHouse ) { str_index = EVT_DWORD(test_evt->v5); @@ -1585,6 +1585,6 @@ } result = &pLevelStr[pLevelStrOffsets[EVT_BYTE(last_evt->v5)]]; } - + return result; } diff -r 86cb7398d2a8 -r 7d986a396092 GUIWindow.cpp --- a/GUIWindow.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/GUIWindow.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -911,7 +911,7 @@ pDialogWindow.uFrameZ = 457; pTextHeight = pFontArrus->CalcTextHeight(current_npc_text, &pDialogWindow, 13, 0); v6 = pTextHeight + 7; - pRenderer->_4A6A68(8, 352 - (pTextHeight + 7), &pIcons_LOD->pTextures[uTextureID_Leather], + pRenderer->GetLeather(8, 352 - (pTextHeight + 7), &pIcons_LOD->pTextures[uTextureID_Leather], pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight - (pTextHeight + 7)); pRenderer->DrawTextureIndexed(8, 347 - v6, pTexture_591428); v7 = FitTextInAWindow(current_npc_text, pFontArrus, &pDialogWindow, 0xDu, 0); diff -r 86cb7398d2a8 -r 7d986a396092 GUIWindow.h --- a/GUIWindow.h Sat Sep 07 12:51:06 2013 +0200 +++ b/GUIWindow.h Sat Sep 07 13:03:18 2013 +0200 @@ -1,10 +1,9 @@ #pragma once -#include "Player.h" + +#include #include - - - +#include "Player.h" enum UIMessageType: unsigned __int32 { @@ -566,7 +565,7 @@ // transition & travel ui -void TransitionUI_Load(uint anim_id, uint exit_pic_id, int x, int y, int z, int directiony, int directionx, int a8, const char *pLocationName); +void TransitionUI_Load(uint32_t anim_id, uint32_t exit_pic_id, int x, int y, int z, int directiony, int directionx, int a8, const char *pLocationName); void TransitionUI_Draw(); void TravelUI_Load(); diff -r 86cb7398d2a8 -r 7d986a396092 Game.cpp --- a/Game.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/Game.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -212,36 +212,39 @@ ++frames_this_second; - - if (render_framerate) + extern bool debug_information; + if ( debug_information ) { - sprintf(pTmpBuf.data(), "FPS: % .4f", framerate); - pPrimaryWindow->DrawText(pFontArrus, 494, 0, TargetColor(0, 0, 0), pTmpBuf.data(), 0, 0, 0); - } + if (render_framerate) + { + sprintf(pTmpBuf.data(), "FPS: % .4f", framerate); + pPrimaryWindow->DrawText(pFontArrus, 494, 0, TargetColor(0, 0, 0), pTmpBuf.data(), 0, 0, 0); + } - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - auto sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); - sprintf(pTmpBuf.data(), "Party Sector ID: %u/%u\n", sector_id, pIndoor->uNumSectors); - pPrimaryWindow->DrawText(pFontArrus, 16, 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, 0xFFFFFFFF); + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + auto sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); + sprintf(pTmpBuf.data(), "Party Sector ID: %u/%u\n", sector_id, pIndoor->uNumSectors); + pPrimaryWindow->DrawText(pFontArrus, 16, 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, 0xFFFFFFFF); + } + sprintf(pTmpBuf.data(), "Party Position: % d % d % d", pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); + pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, 0xFFFFFFFF); + + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + uint uFaceID; + auto sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); + auto floor_level = BLV_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + 40, sector_id, &uFaceID); + sprintf(pTmpBuf.data(), "BLV_GetFloorLevel: %d face_id %d\n", floor_level, uFaceID); + } + else + { + int on_water, _a6; + auto floor_level = ODM_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z, 0, &on_water, &_a6, false); + sprintf(pTmpBuf.data(), "ODM_GetFloorLevel: %d on_water: %s a6 = %d\n", floor_level, on_water ? "true" : "false", _a6); + } + pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16 + 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, 0xFFFFFFFF); } - sprintf(pTmpBuf.data(), "Party Position: % d % d % d", pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); - pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, 0xFFFFFFFF); - - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - uint uFaceID; - auto sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); - auto floor_level = BLV_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + 40, sector_id, &uFaceID); - sprintf(pTmpBuf.data(), "BLV_GetFloorLevel: %d face_id %d\n", floor_level, uFaceID); - } - else - { - int on_water, _a6; - auto floor_level = ODM_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z, 0, &on_water, &_a6, false); - sprintf(pTmpBuf.data(), "ODM_GetFloorLevel: %d on_water: %s a6 = %d\n", floor_level, on_water ? "true" : "false", _a6); - } - pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16 + 16, TargetColor(255, 255, 255), pTmpBuf.data(), 0, 0, 0xFFFFFFFF); GUI_UpdateWindows(); pParty->UpdatePlayersAndHirelingsEmotions(); diff -r 86cb7398d2a8 -r 7d986a396092 Indoor.cpp --- a/Indoor.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/Indoor.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -2245,7 +2245,7 @@ for (uint i = 0; i < uNumLevelDecorations; ++i) { - memcpy(&pLevelDecorations[i].field_2, pData, 2); + memcpy(&pLevelDecorations[i].uFlags, pData, 2); pData += 2; } @@ -3868,7 +3868,7 @@ _6807B8_level_decorations_ids[v16] = i; } - if ( !(pDecortaion->field_2 & 0x20) ) + if (!(pDecortaion->uFlags & LEVEL_DECORATION_INVISIBLE)) { v17 = &pDecorationList->pDecorations[pDecortaion->uDecorationDescID]; if (!v17->DontDraw()) @@ -3897,7 +3897,7 @@ } } - if (!pDecortaion->field_16_event_id) + if (!pDecortaion->uEventID) { if (pDecortaion->IsInteractive()) { @@ -3908,7 +3908,7 @@ v22 = stru_5E4C90._decor_events[v21 + 74 - 75]; v35 = v21; if ( !v22 ) - pDecortaion->field_2 |= 0x20; + pDecortaion->uFlags |= LEVEL_DECORATION_INVISIBLE; } } } @@ -4397,7 +4397,7 @@ { v20 = &pActors[ai_near_actors_ids[v18]]; if ( v20->uAttributes & 0x8000 - || (v21 = sub_4070EF_prolly_collide_objects(PID(OBJECT_Actor,ai_near_actors_ids[v18]), 4u), v18 = i, v21) ) + || (v21 = sub_4070EF_prolly_detect_player(PID(OBJECT_Actor,ai_near_actors_ids[v18]), 4u), v18 = i, v21) ) { v22 = ai_near_actors_ids[v18]; v20->uAttributes |= 0x8000u; @@ -4984,12 +4984,12 @@ //v26 = uDecorationID; //LODWORD(v31) = uSectorID; v2 = &pLevelDecorations[uDecorationID]; - if (v2->field_2 & 0x20) + if (v2->uFlags & LEVEL_DECORATION_INVISIBLE) return; v3 = &pDecorationList->pDecorations[v2->uDecorationDescID]; v4 = v3->uFlags; - if (v3->uFlags & DECORATION_EMITS_FIRE) + if (v3->uFlags & DECORATION_DESC_EMITS_FIRE) { memset(&local_0, 0, 0x68u); // fire, like at the Pit's tavern v5 = (double)v2->vPosition.x; @@ -5009,7 +5009,7 @@ } - if (v4 & DECORATION_DONT_DRAW) + if (v4 & DECORATION_DESC_DONT_DRAW) return; v6 = v2->vPosition.x; @@ -6155,11 +6155,11 @@ case OBJECT_Decoration: v8 = &pLevelDecorations[PID_ID(a1)]; - v9 = v8->field_16_event_id; + v9 = v8->uEventID; if ( v9 ) { EventProcessor(v9, a1, 1); - LOBYTE(v8->field_2) |= 8u; + v8->uFlags |= LEVEL_DECORATION_VISIBLE_ON_MAP; } else { diff -r 86cb7398d2a8 -r 7d986a396092 Indoor.h --- a/Indoor.h Sat Sep 07 12:51:06 2013 +0200 +++ b/Indoor.h Sat Sep 07 13:03:18 2013 +0200 @@ -1,5 +1,6 @@ #pragma once -#include "VectorTypes.h" + +#include "Level/Decoration.h" #include "Indoor_stuff.h" @@ -28,28 +29,7 @@ -/* 74 */ -#pragma pack(push, 1) -struct LevelDecoration -{ - LevelDecoration(); - int GetGlobalEvent(); - bool IsInteractive(); - bool _47A825(); - - unsigned __int16 uDecorationDescID; - __int16 field_2; - struct Vec3_int_ vPosition; - int field_10_y_rot; - __int16 uCog; - __int16 field_16_event_id; - __int16 field_18; - __int16 field_1A; - __int16 _idx_in_stru123; - __int16 field_1E; -}; -#pragma pack(pop) extern std::array pLevelDecorations; extern size_t uNumLevelDecorations; extern LevelDecoration* activeLevelDecoration; diff -r 86cb7398d2a8 -r 7d986a396092 IndoorCameraD3D.cpp --- a/IndoorCameraD3D.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/IndoorCameraD3D.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -687,10 +687,8 @@ RenderVertexSoft *v6; // eax@2 RenderVertexSoft *v7; // edi@3 char v8; // zf@3 - IndoorCameraD3D *v9; // [sp+10h] [bp-4h]@1 unsigned int uNumVerticesa; // [sp+20h] [bp+Ch]@2 - v9 = this; v5 = 0; if ( (signed int)(uNumVertices - 1) > 0 ) { @@ -765,17 +763,6 @@ //----- (00437906) -------------------------------------------------------- void IndoorCameraD3D::PrepareAndDrawDebugOutline(BLVFace *pFace, unsigned int uDiffuse) { - char *v3; // eax@2 - signed int v4; // ecx@2 - signed int v5; // ebx@5 - Vec3_short_ *v6; // edx@6 - char *v7; // esi@6 - signed int v8; // ecx@7 - IndoorCameraD3D *thisa; // [sp+8h] [bp-4h]@1 - - thisa = this; - - static RenderVertexSoft static_sub_437906_array_50CDD0[64]; static bool __init_flag1 = false; if (!__init_flag1) @@ -785,25 +772,20 @@ for (uint i = 0; i < 64; ++i) static_sub_437906_array_50CDD0[i].flt_2C = 0.0f; } - - v5 = 0; if ( pFace->uNumVertices ) { - v6 = pIndoor->pVertices; - v7 = (char *)&static_sub_437906_array_50CDD0[0].vWorldPosition.y; - do + for ( uint i = 0; i < pFace->uNumVertices; i++ ) { - v8 = v5++; - *((float *)v7 - 1) = (double)v6[pFace->pVertexIDs[v8]].x; - *(float *)v7 = (double)v6[pFace->pVertexIDs[v8]].y; - v7 += 48; - *((float *)v7 - 11) = (double)v6[pFace->pVertexIDs[v8]].z; - *((float *)v7 - 4) = (double)pFace->pVertexUIDs[v8]; - *((float *)v7 - 3) = (double)pFace->pVertexVIDs[v8]; + static_sub_437906_array_50CDD0[i].vWorldPosition.x = (double)pIndoor->pVertices[pFace->pVertexIDs[i]].x; + static_sub_437906_array_50CDD0[i].vWorldPosition.y = (double)pIndoor->pVertices[pFace->pVertexIDs[i]].y; + static_sub_437906_array_50CDD0[i].vWorldPosition.z = (double)pIndoor->pVertices[pFace->pVertexIDs[i]].z; + static_sub_437906_array_50CDD0[i].u = (double)pFace->pVertexUIDs[i]; + static_sub_437906_array_50CDD0[i].v = (double)pFace->pVertexVIDs[i]; } - while ( v5 < pFace->uNumVertices ); } - debug_outline_sw(static_sub_437906_array_50CDD0, pFace->uNumVertices, uDiffuse, 0.0); + extern bool draw_debug_line; + if ( draw_debug_line ) + debug_outline_sw(static_sub_437906_array_50CDD0, pFace->uNumVertices, uDiffuse, 0.0); } // 50D9D0: using guessed type char static_sub_437906_byte_50D9D0_init_flag; diff -r 86cb7398d2a8 -r 7d986a396092 Indoor_stuff.h --- a/Indoor_stuff.h Sat Sep 07 12:51:06 2013 +0200 +++ b/Indoor_stuff.h Sat Sep 07 13:03:18 2013 +0200 @@ -1,4 +1,7 @@ #pragma once + +#include + #include "Render.h" #include "IndoorCameraD3D.h" diff -r 86cb7398d2a8 -r 7d986a396092 Level/Decoration.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Level/Decoration.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -0,0 +1,172 @@ +#include "Decoration.h" +#include "../Party.h" + +//----- (004583B0) -------------------------------------------------------- +LevelDecoration::LevelDecoration() +{ + memset(this, 0, sizeof(this)); +} + +//----- (00450929) -------------------------------------------------------- +int LevelDecoration::GetGlobalEvent() +{ + //LevelDecoration *v1; // esi@1 + //signed int v2; // eax@1 + //int v3; // eax@5 + //int v4; // eax@6 + //int v5; // eax@7 + //int v6; // eax@8 + //int v7; // eax@9 + //int result; // eax@14 + //int v9; // eax@18 + //int v10; // eax@19 + //int v11; // eax@20 + //int v12; // eax@21 + //int v13; // eax@22 + + switch (uDecorationDescID) + { + case 0: case 1: + case 2: case 3: + return 0; + + case 4: return 16; // dec01 "Trash Pile" + case 5: return 32; // dec02 "Campfire" + case 6: return 12 + rand() % 4; // dec03 "Cauldron" + case 7: case 8: + case 9: case 10: + return 0; + + case 11: return 34; // dec08 "Fruit plate" + case 12: + return 0; + + case 13: return 17; // dec10 "Trash Pile" + case 14: return 18; // dec11 "Filth" + case 15: case 16: case 17: + case 18: case 19: case 20: + case 21: case 22: case 23: + return 0; + + case 24: return 36; // dec21 "Keg" + case 25: case 26: case 27: case 28: case 29: + case 30: case 31: case 32: case 33: + return 0; + + case 34: return 4 + rand() % 6; // dec32 "Barrel" + case 35: case 36: case 37: case 38: case 39: + case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: + case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: + case 60: case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: case 69: + case 70: case 71: case 72: case 73: case 74: case 75: case 76: case 77: case 78: case 79: + case 80: case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88: case 89: + case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97: case 98: case 99: + case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109: + case 110: case 111: case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119: + case 120: case 121: case 122: case 123: case 124: case 125: case 126: case 127: case 128: case 129: + case 130: case 131: case 132: case 133: case 134: case 135: case 136: case 137: case 138: case 139: + case 140: case 141: case 142: case 143: case 144: case 145: case 146: case 147: case 148: case 149: + case 150: case 151: case 152: case 153: case 154: case 155: case 156: case 157: case 158: case 159: + case 160: case 161: case 162: case 163: case 164: case 165: case 166: case 167: case 168: case 169: + case 170: case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179: + case 180: case 181: case 182: case 183: + + case 184: return 33; // dec24 "Campfire" + case 185: case 186: + return 0; + + case 187: // dec88 "Mushroom" + case 190: // dec91 "Mushroom" + return 37; + + case 188: case 189: + case 191: case 192: case 193: case 194: case 195: case 196: + case 197: case 198: case 199: case 200: case 201: case 202: + case 203: case 204: case 205: + return 0; + + case 206: return 162 + rand() % 7; // dec60 + case 207: return 169 + rand() % 7; // dec61 + case 208: return 176 + rand() % 7; // dec62 + case 209: return 183 + rand() % 7; // dec63 + case 210: return 150; // dec64 "Magic pedestal" + case 211: return 151; // dec65 "Magic pedestal" + case 212: return 152; // dec66 "Magic pedestal" + case 213: return 153; // dec67 "Magic pedestal" + case 214: return 154; // dec68 "Magic pedestal" + case 215: return 155; // dec69 "Magic pedestal" + case 216: return 156; // dec70 "Magic pedestal" + case 217: return 157; // dec71 "Magic pedestal" + case 218: return 158; // dec72 "Magic pedestal" + case 219: return 159; // dec73 "Magic pedestal" + case 220: return 160; // dec74 "Magic pedestal" + case 221: return 161; // dec75 "Magic pedestal" + + case 222: case 223: case 224: + case 225: case 226: case 227: + return 0; + + default: assert(false && "Invalid Decoration"); + } +} + +//----- (0047A825) -------------------------------------------------------- +bool LevelDecoration::IsObeliskChestActive() +{ + //bool v1; // ebx@1 + //LevelDecoration *v2; // edi@1 + + static const std::array aObeliskQuests = { + PARTY_QUEST_OBELISK_HARMONDALE, + PARTY_QUEST_OBELISK_ERATHIA, + PARTY_QUEST_OBELISK_TULAREAN_FOREST, + PARTY_QUEST_OBELISK_DEYJA, + PARTY_QUEST_OBELISK_BRACADA_DESERT, + PARTY_QUEST_OBELISK_CELESTE, + PARTY_QUEST_OBELISK_THE_PIT, + PARTY_QUEST_OBELISK_EVENMORN_ISLAND, + PARTY_QUEST_OBELISK_MOUNT_NIGHON, + PARTY_QUEST_OBELISK_BARROW_DOWNS, + PARTY_QUEST_OBELISK_LAND_OF_THE_GIANTS, + PARTY_QUEST_OBELISK_TATALIA, + PARTY_QUEST_OBELISK_AVLEE, + PARTY_QUEST_OBELISK_STONE_CITY + }; + + if (pParty->uCurrentHour == 0 + && !TestPartyQuestBit(PARTY_QUEST_OBELISK_TREASURE_FOUND) + && std::all_of(aObeliskQuests.begin(), aObeliskQuests.end(), TestPartyQuestBit)) + { + this->uFlags &= ~LEVEL_DECORATION_INVISIBLE; + return true; + } + + this->uFlags |= LEVEL_DECORATION_INVISIBLE; + return false; +} + +//----- (0044C2F4) -------------------------------------------------------- +bool LevelDecoration::IsInteractive() +{ + switch (uDecorationDescID) + { + case 4: // trash pile + case 5: // campfire + case 6: // cauldron + case 11: // fruit plate + case 13: // trash pile + case 14: // dirt + case 24: // keg + case 184: // fire + case 187: // fire + case 190: // fire + return true; + } + + if (uDecorationDescID >= 206 && uDecorationDescID <= 209) // lighthouse fire + return true; + if (uDecorationDescID >= 210 && uDecorationDescID <= 221) // magic pedestal + return true; + + return false; +} diff -r 86cb7398d2a8 -r 7d986a396092 Level/Decoration.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Level/Decoration.h Sat Sep 07 13:03:18 2013 +0200 @@ -0,0 +1,38 @@ +#pragma once + +#include + +#include "../VectorTypes.h" + +enum LEVEL_DECORATION_FLAGS: uint16_t +{ + LEVEL_DECORATION_TRIGGERED_BY_TOUCH = 0x01, + LEVEL_DECORATION_TRIGGERED_BY_MONSTER = 0x02, + LEVEL_DECORATION_TRIGGERED_BY_OBJECT = 0x04, + LEVEL_DECORATION_VISIBLE_ON_MAP = 0x08, + LEVEL_DECORATION_CHEST = 0x10, + LEVEL_DECORATION_INVISIBLE = 0x20, + LEVEL_DECORATION_OBELISK_CHEST = 0x40, +}; + +/* 74 */ +#pragma pack(push, 1) +struct LevelDecoration +{ + LevelDecoration(); + int GetGlobalEvent(); + bool IsInteractive(); + bool IsObeliskChestActive(); + + uint16_t uDecorationDescID; + uint16_t uFlags; + Vec3_int_ vPosition; + int32_t field_10_y_rot; + uint16_t uCog; + uint16_t uEventID; + uint16_t uTriggerRange; + int16_t field_1A; + int16_t _idx_in_stru123; + int16_t field_1E; +}; +#pragma pack(pop) diff -r 86cb7398d2a8 -r 7d986a396092 Log.cpp --- a/Log.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/Log.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -1,13 +1,11 @@ #include "Log.h" - #include #include + HANDLE hStdOut = nullptr; - - void Log::Initialize() { if (AllocConsole()) @@ -21,15 +19,12 @@ return; va_list args; - wchar_t pMsg[8192]; va_start(args, pFormat); - vswprintf_s(pMsg, 8192, pFormat, args); + vwprintf_s(pFormat, args); va_end(args); + puts("\r\n"); - DWORD w; - WriteConsole(hStdOut, pMsg, lstrlenW(pMsg), &w, nullptr); - WriteConsole(hStdOut, L"\r\n", 2, &w, nullptr); } //----- (004BE386) -------------------------------------------------------- diff -r 86cb7398d2a8 -r 7d986a396092 Math.h --- a/Math.h Sat Sep 07 12:51:06 2013 +0200 +++ b/Math.h Sat Sep 07 13:03:18 2013 +0200 @@ -1,11 +1,7 @@ #pragma once + #include #include -#include -#include -#include -#include - /* 186 */ #pragma pack(push, 1) @@ -28,26 +24,20 @@ }; #pragma pack(pop) - int fixpoint_sub0(int, int); int fixpoint_div(int, int); int fixpoint_mul(int, int); int fixpoint_from_float(float value); -#ifndef ROUNDING_EPSILON -#define ROUNDING_EPSILON 0.0000001 -#endif - - template -int bankersRounding( +inline int bankersRounding( const FloatType& value ) { assert("Method unsupported for this type" && false); return value; } -template<> static int bankersRounding(const float& inValue) +template<> inline int bankersRounding(const float& inValue) { union Cast { @@ -61,8 +51,7 @@ #pragma push_macro("max") #undef max - -template<> static int bankersRounding(const double& inValue) +template<> inline int bankersRounding(const double& inValue) { double maxValue = std::numeric_limits::max(); assert(maxValue - 6755399441055744.0 >= inValue); @@ -75,8 +64,6 @@ c.d = inValue + 6755399441055744.0; return c.l; } - - #pragma pop_macro("max") -extern struct stru193_math *stru_5C6E00; \ No newline at end of file +extern struct stru193_math *stru_5C6E00; diff -r 86cb7398d2a8 -r 7d986a396092 NPC.cpp --- a/NPC.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/NPC.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -1343,7 +1343,7 @@ OracleDialogue(); goto _return; case 311: - sub_4BBA85_bounties(); + CheckBountyRespawnAndAward(); goto _return; }*/ if ( pEventNumber < 200 || pEventNumber > 310 ) @@ -1358,7 +1358,7 @@ { if ( pEventNumber == 311 ) { - sub_4BBA85_bounties(); + CheckBountyRespawnAndAward(); } else { diff -r 86cb7398d2a8 -r 7d986a396092 Outdoor.cpp --- a/Outdoor.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/Outdoor.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -2271,7 +2271,7 @@ //thisa = (int)&pLevelDecorations[0].field_2; //do //{ - memcpy(&pLevelDecorations[i].field_2, pSrc, 2); + memcpy(&pLevelDecorations[i].uFlags, pSrc, 2); pSrc += 2; //thisa += 32; //v85 = (char *)v85 + 2; @@ -2717,8 +2717,8 @@ _6807B8_level_decorations_ids[v5] = i; } if ( v8 && decor->uCog == 20 ) - decor->field_2 |= 0x0040u; - if ( !decor->field_16_event_id ) + decor->uFlags |= LEVEL_DECORATION_OBELISK_CHEST; + if ( !decor->uEventID ) { if ( decor->IsInteractive() ) { @@ -2727,7 +2727,7 @@ v6 = v1 + 75; decor->_idx_in_stru123 = v6; if ( !stru_5E4C90._decor_events[v1++] ) - decor->field_2 |= 0x0020u; + decor->uFlags |= LEVEL_DECORATION_INVISIBLE; } } } diff -r 86cb7398d2a8 -r 7d986a396092 Party.cpp --- a/Party.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/Party.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -1222,10 +1222,6 @@ { if ( _506F18_num_minutes_to_sleep < 6 ) { - pParty->pPlayers[3].SetAsleep(false); - pParty->pPlayers[2].SetAsleep(false); - pParty->pPlayers[1].SetAsleep(false); - pParty->pPlayers[0].SetAsleep(false); if ( _506F18_num_minutes_to_sleep ) { Rest(_506F18_num_minutes_to_sleep); @@ -1234,25 +1230,8 @@ } if ( dword_506F14 == 2 ) { - pGUIWindow_CurrentMenu->Release(); - pEventTimer->Resume(); - if ( pTexture_RestUI_CurrentSkyFrame ) - pTexture_RestUI_CurrentSkyFrame->Release(); - if ( pTexture_RestUI_CurrentHourglassFrame ) - pTexture_RestUI_CurrentHourglassFrame->Release(); - pTexture_RestUI_CurrentHourglassFrame = 0; - pTexture_RestUI_CurrentSkyFrame = 0; - pIcons_LOD->RemoveTexturesPackFromTextureList(); - pIcons_LOD->SyncLoadedFilesCount(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - { - pOutdoor->UpdateSunlightVectors(); - pOutdoor->UpdateFog(); - } + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); } - dword_506F14 = 0; } else { diff -r 86cb7398d2a8 -r 7d986a396092 Party.h --- a/Party.h Sat Sep 07 12:51:06 2013 +0200 +++ b/Party.h Sat Sep 07 13:03:18 2013 +0200 @@ -1,13 +1,13 @@ #pragma once #include "Player.h" #include "NPC.h" -#include "VectorTypes.h" +#include "mm7_data.h" #define PARTY_AUTONOTES_BIT__EMERALD_FIRE_FOUNTAIN 2 -enum PARTY_QUEST_BITS: unsigned __int32 +enum PARTY_QUEST_BITS: uint16 { PARTY_QUEST_EMERALD_RED_POTION_ACTIVE = 1, PARTY_QUEST_EMERALD_SEASHELL_ACTIVE = 2, @@ -20,6 +20,24 @@ PARTY_QUEST_EVENMORN_MAP_FOUND = 64, PARTY_QUEST_FINISHED_EMERALD_ISLE = 136, + + PARTY_QUEST_OBELISK_HARMONDALE = 164, + PARTY_QUEST_OBELISK_ERATHIA = 165, + PARTY_QUEST_OBELISK_TULAREAN_FOREST = 166, + PARTY_QUEST_OBELISK_DEYJA = 167, + PARTY_QUEST_OBELISK_BRACADA_DESERT = 168, + PARTY_QUEST_OBELISK_CELESTE = 169, + PARTY_QUEST_OBELISK_THE_PIT = 170, + PARTY_QUEST_OBELISK_EVENMORN_ISLAND = 171, + PARTY_QUEST_OBELISK_MOUNT_NIGHON = 172, + PARTY_QUEST_OBELISK_BARROW_DOWNS = 173, + PARTY_QUEST_OBELISK_LAND_OF_THE_GIANTS = 174, + PARTY_QUEST_OBELISK_TATALIA = 175, + PARTY_QUEST_OBELISK_AVLEE = 176, + PARTY_QUEST_OBELISK_STONE_CITY = 177, + + PARTY_QUEST_OBELISK_TREASURE_FOUND = 178, + PARTY_QUEST_FOUNTAIN_HARMONDALE = 206, PARTY_QUEST_FOUNTAIN_NIGHON = 207, PARTY_QUEST_FOUNTAIN_PIERPONT = 208, @@ -28,9 +46,6 @@ PARTY_QUEST_FOUNTAIN_EVENMORN_ISLE = 211 }; - - - /* 355 */ enum PARTY_FLAGS_1: __int32 { @@ -135,9 +150,10 @@ #pragma pack(push, 1) struct Party_stru0 { - int field_0[20]; + //__int64 field_0[10]; + __int64 bountyHunting_next_generation_time[10]; // int field_50[170]; - __int64 field_50[85]; + __int64 Shops_next_generation_time[85];//field_50 __int64 _shop_ban_times[53]; int field_4A0[20]; int field_4F0[38]; @@ -250,8 +266,8 @@ int uNumPrisonTerms; unsigned int uNumBountiesCollected; int field_74C; - __int16 field_750[5]; - __int16 field_75A[5]; + __int16 monster_id_for_hunting[5]; + __int16 monster_for_hunting_killed[5]; unsigned char days_played_without_rest; unsigned __int8 _quest_bits[64]; unsigned __int8 pArcomageWins[16]; @@ -300,3 +316,7 @@ extern struct ActionQueue *pPartyActionQueue; +inline bool TestPartyQuestBit(PARTY_QUEST_BITS bit) +{ + return _449B57_test_bit(pParty->_quest_bits, bit); +} diff -r 86cb7398d2a8 -r 7d986a396092 Player.cpp --- a/Player.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/Player.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -2108,9 +2108,6 @@ v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MIN, 0); v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2; v4 = v1->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3; - v5 = v1->pActiveSkills[5]; - if ( v5 && (signed int)SkillToMastery(v5) >= 4 && HasItemEquipped(EQUIP_BOW) ) - v4 += v1->pActiveSkills[5] & 0x3F; if ( v4 >= 1 ) result = v4; else @@ -2132,9 +2129,6 @@ v2 = GetItemsBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_MAX, 0); v3 = GetSkillBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v2; v4 = v1->_ranged_dmg_bonus + GetMagicalBonus(CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS) + v3; - v5 = v1->pActiveSkills[5]; - if ( v5 && (signed int)SkillToMastery(v5) >= 4 && HasItemEquipped(EQUIP_BOW) ) - v4 += v1->pActiveSkills[5] & 0x3F; if ( v4 >= 1 ) result = v4; else @@ -4803,455 +4797,252 @@ return result; } + //----- (0048FC00) -------------------------------------------------------- -int Player::GetSkillBonus(enum CHARACTER_ATTRIBUTE_TYPE a2) -{ - - - - Player *v2; // esi@1 - int armmaster_skill; // eax@1 - char v4; // di@1 - signed int v5; // ebx@1 - unsigned int armaster_mastery; // eax@2 - unsigned __int8 v7; // sf@5 - unsigned __int8 v8; // of@5 - PlayerEquipment *v9; // ebx@19 - Player *v10; // ecx@20 - PLAYER_SKILL_TYPE v11; // edi@21 - int v12; // eax@21 - int v13; // edi@21 - char v14; // di@25 - signed int v15; // esi@25 - char v16; // al@32 - int v18; // eax@36 - unsigned int v19; // eax@37 - ITEM_EQUIP_TYPE v20; // edi@40 - int v21; // edx@41 - int v22; // eax@42 - PLAYER_SKILL_TYPE v23; // edi@45 - unsigned __int16 v24; // ax@45 - unsigned __int16 v25; // bx@45 - unsigned int v26; // eax@45 - unsigned __int8 v27; // sf@50 - unsigned __int8 v28; // of@50 - unsigned int v29; // eax@52 - int v30; // eax@55 - int v31; // eax@58 - unsigned int v32; // eax@59 - int v33; // eax@65 - char v34; // si@65 - ITEM_EQUIP_TYPE v35; // edi@69 - int v36; // edx@70 - int v37; // eax@71 - PLAYER_SKILL_TYPE v38; // edi@74 - int v39; // eax@74 - int v40; // eax@89 - char v41; // si@89 - int v42; // eax@96 - PLAYER_SKILL_TYPE v43; // edx@97 - int v44; // eax@97 - int v45; // eax@98 - int v46; // eax@99 - int v47; // eax@100 - int v48; // eax@101 - int v49; // eax@102 - unsigned __int16 v50; // ax@113 - char v51; // di@113 - unsigned int v52; // eax@113 - int v53; // edi@113 - signed int i; // ecx@113 - unsigned __int16 v55; // ax@118 - char v56; // si@118 - unsigned int v57; // eax@118 - int v58; // esi@121 - signed int j; // ecx@121 - int base_value; // edi@126 - int attrib_modif; // eax@126 - signed int v62; // [sp-4h] [bp-30h]@26 - signed int v63; // [sp-4h] [bp-30h]@80 - int v64; // [sp+Ch] [bp-20h]@104 - int v65; // [sp+10h] [bp-1Ch]@104 - int v66; // [sp+14h] [bp-18h]@104 - int v67; // [sp+18h] [bp-14h]@104 - int v68; // [sp+1Ch] [bp-10h]@69 - PlayerEquipment *v69; // [sp+20h] [bp-Ch]@1 - int skill_bonus; // [sp+24h] [bp-8h]@1 - ITEM_EQUIP_TYPE v71; // [sp+28h] [bp-4h]@1 - int a1; // [sp+34h] [bp+8h]@21 - int a1a; // [sp+34h] [bp+8h]@74 - signed int a1b; // [sp+34h] [bp+8h]@94 - int multiplier; - int arm_bonus; - int lvl_avl[4]; - - v2 = this; - skill_bonus = 0; - v69 = 0; - multiplier =0; - arm_bonus =0; - v71 = (ITEM_EQUIP_TYPE)0; - armmaster_skill = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER); - v4 = armmaster_skill; - v5 = 1; - if ( armmaster_skill ) - { - armaster_mastery = SkillToMastery(armmaster_skill); - if ( a2 == CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS ) - { - if ( armaster_mastery == 4 ) - multiplier =2; - else if ( armaster_mastery == 3 ) - multiplier =1; - } - else if ( a2 == CHARACTER_ATTRIBUTE_ATTACK ) - { - if ( armaster_mastery == 4 ) - multiplier =2; - else if ( armaster_mastery >= 2 ) - multiplier =1; +int Player::GetSkillBonus(enum CHARACTER_ATTRIBUTE_TYPE inSkill) //TODO: move the individual implementations to attribute classes once possible +{ + int armsMasterBonus; + + armsMasterBonus = 0; + int armmaster_skill = GetActualSkillLevel(PLAYER_SKILL_ARMSMASTER); + if ( armmaster_skill > 0 ) + { + int multiplier = 0; + if ( inSkill == CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS ) + { + multiplier = GetMultiplierForMastery(armmaster_skill, 0, 0, 1, 2); + } + else if ( inSkill == CHARACTER_ATTRIBUTE_ATTACK ) + { + multiplier = GetMultiplierForMastery(armmaster_skill, 0, 1, 1, 2); } - arm_bonus=(armmaster_skill&0x3F)*multiplier; - } - - - if ( a2 == CHARACTER_ATTRIBUTE_HEALTH ) - { - base_value = pBaseHealthPerLevelByClass[classType]; - attrib_modif = GetBodybuilding(); - return base_value * attrib_modif; - } - if ( a2 == CHARACTER_ATTRIBUTE_MANA ) - { - base_value = pBaseManaPerLevelByClass[classType]; - attrib_modif = GetMeditation(); - return base_value * attrib_modif; - } - if ( a2 == CHARACTER_ATTRIBUTE_AC_BONUS ) - { - a1b = 0; - v71 = (ITEM_EQUIP_TYPE)0; - - for (j=0; j<16; ++j) + armsMasterBonus = multiplier * (armmaster_skill & 0x3F); + } + + switch(inSkill) + { + case CHARACTER_ATTRIBUTE_RANGED_DMG_BONUS: + if (HasItemEquipped(EQUIP_BOW)) + { + int bowSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE); + int multiplier = GetMultiplierForMastery(bowSkillLevel, 0, 0, 0, 1); + return multiplier * (bowSkillLevel & 0x3F); + } + return 0; + break; + case CHARACTER_ATTRIBUTE_HEALTH: + { + int base_value = pBaseHealthPerLevelByClass[classType]; + int attrib_modif = GetBodybuilding(); + return base_value * attrib_modif; + } + break; + case CHARACTER_ATTRIBUTE_MANA: + { + int base_value = pBaseManaPerLevelByClass[classType]; + int attrib_modif = GetMeditation(); + return base_value * attrib_modif; + } + break; + case CHARACTER_ATTRIBUTE_AC_BONUS: + { + bool wearingArmor = false; + bool wearingLeather = false; + unsigned int ACSum = 0; + + for (int j = 0; j < 16; ++j) + { + if (pEquipment.pIndices[j] && (!pOwnItems[pEquipment.pIndices[j]].Broken())) + { + int curr_item = pOwnItems[pEquipment.pIndices[j]].uItemID; + PLAYER_SKILL_TYPE itemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[curr_item].uSkillType; + int currArmorSkillLevel = GetActualSkillLevel(itemSkillType); + int multiplier = 0; + switch (itemSkillType) { - if (pEquipment.pIndices[j]&&(!pOwnItems[ pEquipment.pIndices[j]].Broken())) - { - int curr_item =pOwnItems[pEquipment.pIndices[j]].uItemID; - v44=pItemsTable->pItems[curr_item].uSkillType; - switch (v44) - { - - case PLAYER_SKILL_STAFF: - - lvl_avl[0]=0; - lvl_avl[1]=1; - lvl_avl[2]=0; - lvl_avl[3]=0; - break; - case PLAYER_SKILL_SWORD: - case PLAYER_SKILL_SPEAR: - lvl_avl[0]=0; - lvl_avl[1]=0; - lvl_avl[2]=0; - lvl_avl[3]=1; - break; - case PLAYER_SKILL_SHIELD: - a1b = 1; - lvl_avl[0]=1; - lvl_avl[1]=0; - lvl_avl[2]=1; - lvl_avl[3]=0; - break; - case PLAYER_SKILL_LEATHER: - v71 = (ITEM_EQUIP_TYPE)1; - lvl_avl[0]=1; - lvl_avl[1]=0; - lvl_avl[2]=1; - lvl_avl[3]=0; - - break; - case PLAYER_SKILL_CHAIN: - a1b = 1; - lvl_avl[0]=1; - lvl_avl[1]=0; - lvl_avl[2]=0; - lvl_avl[3]=0; - break; - case PLAYER_SKILL_PLATE: - a1b = 1; - lvl_avl[0]=1; - lvl_avl[1]=0; - lvl_avl[2]=0; - lvl_avl[3]=0; - break; - default: - continue; - } - - v50= GetActualSkillLevel((PLAYER_SKILL_TYPE)v44); - v51 = v50; - v52 = SkillToMastery(v50); - v53 = v51 & 0x3F; - for ( i = 0; i < (signed int)v52; ++i ) - { - if ( lvl_avl[i] ) - skill_bonus += v53; - } - - } + case PLAYER_SKILL_STAFF: + multiplier = GetMultiplierForMastery(currArmorSkillLevel, 0, 1, 1, 1); + break; + case PLAYER_SKILL_SWORD: + case PLAYER_SKILL_SPEAR: + multiplier = GetMultiplierForMastery(currArmorSkillLevel, 0, 0, 0, 1); + break; + case PLAYER_SKILL_SHIELD: + wearingArmor = true; + multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 2, 2); + break; + case PLAYER_SKILL_LEATHER: + wearingLeather = true; + multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 2, 2); + break; + case PLAYER_SKILL_CHAIN: + wearingArmor = true; + multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 1, 1); + break; + case PLAYER_SKILL_PLATE: + wearingArmor = true; + multiplier = GetMultiplierForMastery(currArmorSkillLevel, 1, 1, 1, 1); + break; } - - lvl_avl[0]=1; - lvl_avl[1]=1; - lvl_avl[2]=1; - lvl_avl[3]=0; - - v55 = GetActualSkillLevel(PLAYER_SKILL_DODGE); - v56 = v55; - v57 = SkillToMastery(v55); - if ( !a1b && (!v71 || v57 == 4) ) - { - v58 = v56 & 0x3F; - for ( j = 0; j < (signed int)v57; ++j ) - { - if ( lvl_avl[j] ) - skill_bonus += v58; - } - } - return skill_bonus; - - - } - - if (a2 == CHARACTER_ATTRIBUTE_ATTACK) - { - - if ( v2->IsUnarmed() == 1 ) - { - v33 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED); - v34 = v33; - if ( !v33 ) - return skill_bonus; - if ( SkillToMastery(v33) >= 3 ) - multiplier = 2; - else - multiplier=1; - v30 = multiplier * (v34 & 0x3F); - return arm_bonus + v30; - } - v35 = (ITEM_EQUIP_TYPE)0; - v68 = 0; - for (i=0; i<16 ; ++i) - { - if ( v2->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) + ACSum += multiplier * (currArmorSkillLevel & 0x3F); + } + } + + int dodgeSkillLevel = GetActualSkillLevel(PLAYER_SKILL_DODGE); + int dodgeMastery = SkillToMastery(dodgeSkillLevel); + int multiplier = GetMultiplierForMastery(dodgeSkillLevel, 1, 2, 3, 3); + if ( !wearingArmor && (!wearingLeather || dodgeMastery == 4) ) + { + ACSum += multiplier * (dodgeSkillLevel & 0x3F); + } + return ACSum; + } + break; + case CHARACTER_ATTRIBUTE_ATTACK: + if ( this->IsUnarmed() ) + { + int unarmedSkill = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); + if (!unarmedSkill) + { + return 0; + } + int multiplier = GetMultiplierForMastery(unarmedSkill, 0, 1, 2, 2); + return armsMasterBonus + multiplier * (unarmedSkill & 0x3F); + } + for (int i = 0; i < 16; ++i) + { + if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) + { + int currItemIndex = this->pEquipment.pIndices[i] - 1; + if ( pItemsTable->pItems[currItemIndex].uEquipType <= EQUIP_MAIN_HAND) + { + PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[currItemIndex].uSkillType; + int currentItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); + if (currItemSkillType == PLAYER_SKILL_BLASTER) { - v37 = v2->pEquipment.pIndices[i]-1; - if ( pItemsTable->pItems[v37].uEquipType <= EQUIP_MAIN_HAND) - break; + int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 2, 3, 5); + return multiplier * (currentItemSkillLevel & 0x3F); } - } - if ( i >= 16 ) - return skill_bonus; - - v38 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v37].uSkillType; - a1a = v2->GetActualSkillLevel(v38); - v39= SkillToMastery(a1a); - v71 = (ITEM_EQUIP_TYPE)0; - switch (v38) - { - case PLAYER_SKILL_STAFF: - v71 = (ITEM_EQUIP_TYPE)1; - if ( v39 == 4 ) + else if (currItemSkillType == PLAYER_SKILL_STAFF && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) { - v40 = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED); - v41 = v40; - - if ( v40 ) - { - if ( SkillToMastery(v40) >= 3 ) - multiplier = 2; - else - multiplier=1; - v68 = multiplier * (v41 & 0x3F); - } + int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); + int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 1, 2, 2); + return multiplier * (unarmedSkillLevel & 0x3F) + armsMasterBonus + (currentItemSkillLevel & 0x3F); } - break; - case PLAYER_SKILL_SWORD: - case PLAYER_SKILL_DAGGER: - case PLAYER_SKILL_AXE: - case PLAYER_SKILL_SPEAR: - case PLAYER_SKILL_MACE: - v71 = (ITEM_EQUIP_TYPE)1; - break; - case PLAYER_SKILL_BLASTER: - - switch (v39) + else { - case 0: multiplier=1; break; - case 1: multiplier=3; break; - case 3: multiplier=3; break; - case 4: multiplier=5; break; + return armsMasterBonus + (currentItemSkillLevel & 0x3F); } - v5 = multiplier; - return v5 * (a1a & 0x3F); - break; - } - - - - v30 = v68 + v71 * (a1a & 0x3F); - return (int)((char *)v69 + v30); - - } - - - if ( a2 != 9 ) - { - - if ( a2 <= CHARACTER_ATTRIBUTE_ATTACK ) - return skill_bonus; - if ( a2 > CHARACTER_ATTRIBUTE_MELEE_DMG_MAX ) - { - if ( a2 != CHARACTER_ATTRIBUTE_RANGED_ATTACK ) - return skill_bonus; - v71 = (ITEM_EQUIP_TYPE)0; - v9 = &v2->pEquipment; - while ( 1 ) + } + } + } + return 0; + break; + + case CHARACTER_ATTRIBUTE_RANGED_ATTACK: + for (int i = 0; i < 16; i++) + { + if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) + { + PLAYER_SKILL_TYPE currentItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[this->pInventoryItemList[this->pEquipment.pIndices[i] - 1].uItemID].uSkillType; + int currentItemSkillLevel = this->GetActualSkillLevel(currentItemSkillType); + if ( currentItemSkillType == PLAYER_SKILL_BOW ) { - if ( v2->HasItemEquipped(v71) ) - { - v11 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v2->pInventoryItemList[*(_DWORD *)v9].uItemID].uEquipType; - LOBYTE(v12) = this->GetActualSkillLevel(v11); - a1 = v12; - SkillToMastery(v12); - v13 = v11 - 5; - if ( !v13 ) - return a1 & 0x3F; - if ( v13 == 2 ) - break; - } - v71 = (ITEM_EQUIP_TYPE)((int)v71 + 1); - v9 = (PlayerEquipment *)((char *)v9 + 4); - if ( (signed int)v71 >= 16 ) - return skill_bonus; + int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 0, 0, 0, 0); + return multiplier * (currentItemSkillLevel & 0x3F); } - v14 = a1; - v15 = 1; - if ( (signed int)SkillToMastery(a1) >= 4 ) - { - v62 = 5; - goto LABEL_31; - } - if ( (signed int)SkillToMastery(a1) >= 3 ) - { - v62 = 3; - goto LABEL_31; + else if ( currentItemSkillType == PLAYER_SKILL_BLASTER ) + { + int multiplier = GetMultiplierForMastery(currentItemSkillLevel, 1, 2, 3, 5); + return multiplier * (currentItemSkillLevel & 0x3F); } - if ( (signed int)SkillToMastery(a1) < 2 ) - goto LABEL_32; - goto LABEL_30; - } - if ( v2->IsUnarmed() ) - { - LOBYTE(v18) = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED); - v14 = v18; - if ( !v18 ) - return skill_bonus; - v15 = 0; - v19 = SkillToMastery(v18); - if ( (signed int)v19 < 3 ) + } + } + return 0; + break; + + case CHARACTER_ATTRIBUTE_MELEE_DMG_BONUS: + if ( this->IsUnarmed() ) + { + int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); + if ( !unarmedSkillLevel ) + { + return 0; + } + int multiplier = GetMultiplierForMastery(unarmedSkillLevel, 0, 1, 2, 2); + return multiplier * (unarmedSkillLevel & 0x3F); + } + for (int i = 0; i < 16; i++) + { + if ( this->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) + { + int currItemId = this->pInventoryItemList[this->pEquipment.pIndices[i]].uItemID; + if ( pItemsTable->pItems[currItemId].uEquipType == EQUIP_MAIN_HAND || pItemsTable->pItems[currItemId].uEquipType == EQUIP_OFF_HAND ) { - if ( (signed int)v19 >= 2 ) - v15 = 1; -LABEL_32: - v16 = v14; - return v15 * (v16 & 0x3F); - } -LABEL_30: - v62 = 2; -LABEL_31: - v15 = v62; - goto LABEL_32; - } - v20 = (ITEM_EQUIP_TYPE)0; - while ( 1 ) - { - if ( v2->HasItemEquipped(v20) ) - { - v22 = this->pInventoryItemList[this->pEquipment.pIndices[v20]].uItemID; - if ( pItemsTable->pItems[v22].uEquipType <= 1u ) - break; - } - v20 = (ITEM_EQUIP_TYPE)((int)v20 + 1); - if ( (signed int)v20 >= 16 ) - return skill_bonus; - } - v71 = (ITEM_EQUIP_TYPE)0; - v23 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v22].uSkillType; - LOBYTE(v24) = v2->GetActualSkillLevel(v23); - v25 = v24; - v26 = SkillToMastery(v24); - if ( !v23 ) - { - if ( (signed int)SkillToMastery(v25) >= 4 ) - { - LOBYTE(v31) = v2->GetActualSkillLevel(PLAYER_SKILL_UNARMED); - LOBYTE(v25) = v31; - if ( v31 ) + PLAYER_SKILL_TYPE currItemSkillType = (PLAYER_SKILL_TYPE)pItemsTable->pItems[currItemId].uSkillType; + int currItemSkillLevel = this->GetActualSkillLevel(currItemSkillType); + int baseSkillBonus; + int multiplier; + switch (currItemSkillType) { - v15 = 0; - v32 = SkillToMastery(v31); - if ( (signed int)v32 < 3 ) + case PLAYER_SKILL_STAFF: + if ( SkillToMastery(currItemSkillLevel) >= 4 && this->GetActualSkillLevel(PLAYER_SKILL_UNARMED) > 0) { - if ( (signed int)v32 >= 2 ) - v15 = 1; + int unarmedSkillLevel = this->GetActualSkillLevel(PLAYER_SKILL_UNARMED); + int multiplier = GetMultiplierForMastery(unarmedSkillLevel, 0, 1, 2, 2); + return multiplier * (unarmedSkillLevel & 0x3F); } else { - v15 = 2; + return armsMasterBonus; } - v16 = v25; - return v15 * (v16 & 0x3F); + break; + + case PLAYER_SKILL_DAGGER: + multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 0, 1); + baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); + return armsMasterBonus + baseSkillBonus; + break; + case PLAYER_SKILL_SWORD: + multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 0, 0); + baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); + return armsMasterBonus + baseSkillBonus; + break; + case PLAYER_SKILL_MACE: + case PLAYER_SKILL_SPEAR: + multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 1, 1, 1); + baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); + return armsMasterBonus + baseSkillBonus; + break; + case PLAYER_SKILL_AXE: + multiplier = GetMultiplierForMastery(currItemSkillLevel, 0, 0, 1, 1); + baseSkillBonus = multiplier * (currItemSkillLevel & 0x3F); + return armsMasterBonus + baseSkillBonus; + break; } } - goto LABEL_55; - } - if ( v23 == PLAYER_SKILL_DAGGER ) - { - v29 = SkillToMastery(v25); - v28 = __OFSUB__(v29, 4); - v27 = ((v29 - 4) & 0x80000000u) != 0; - } - else - { - if ( v23 <= PLAYER_SKILL_DAGGER ) - goto LABEL_55; - if ( v23 > PLAYER_SKILL_SPEAR ) - { - if ( v23 == PLAYER_SKILL_MACE ) - { - v28 = __OFSUB__(v26, 2); - v27 = v26 - 2 < 0; - goto LABEL_53; - } -LABEL_55: - v30 = v71 * (v25 & 0x3F); - return (int)((char *)v69 + v30); - } - v28 = __OFSUB__(v26, 3); - v27 = v26 - 3 < 0; - } -LABEL_53: - if ( !(v27 ^ v28) ) - v71 = (ITEM_EQUIP_TYPE)1; - goto LABEL_55; - } - - - assert(false && "Unknown attribute!"); + } + } + return 0; + break; + default: return 0; -} - + } +} + +unsigned int Player::GetMultiplierForMastery(unsigned int skillValue, int mult1, int mult2, int mult3, int mult4) +{ + int masteryLvl = SkillToMastery(skillValue); + switch (masteryLvl) + { + case 1: return mult1; + case 2: return mult2; + case 3: return mult3; + case 4: return mult4; + } + assert(false); + return 0; +} //----- (00490109) -------------------------------------------------------- // faces are: 0 1 2 3 human males // 4 5 6 7 human females @@ -7547,15 +7338,20 @@ goto _play_sound; case VAR_Sex: Dst->uSex = (PLAYER_SEX)val; - goto _play_anim_and_exit; + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + goto _play_sound; case VAR_Class: Dst->classType = (PLAYER_CLASS_TYPE)val; - goto _play_anim_and_exit; + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + goto _play_sound; case VAR_CurrentHP: v8 = &Dst->sHealth; *v8 += val; if ( Dst->sHealth <= Dst->GetMaxHealth() ) - goto _play_anim_and_exit; + { + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + goto _play_sound; + } v9 = v4->GetMaxHealth(); goto LABEL_23; case VAR_MaxHP: @@ -7573,7 +7369,8 @@ LABEL_23: *v8 = v9; } - goto _play_anim_and_exit; + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + goto _play_sound; case VAR_MaxSP: v11 = GetMaxMana(); v4->_mana_related = 0; @@ -7592,7 +7389,8 @@ *v12 += val; if ( *v12 > 255 ) *v12 = 255; - goto _play_anim_and_exit; + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + goto _play_sound; case VAR_Age: Dst->sAgeModifier += val; return; @@ -7608,14 +7406,25 @@ v14->PlaySound(SPEECH_96, 0); } v15 = (char *)v4->_achieved_awards_bits; - goto LABEL_44; + _449B7E_toggle_bit((unsigned char *)v15, val, 1); + if ( v34 != 1 ) + { + if ( v3 != 1 ) + return; + goto _play_sound; + } + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + if ( v3 != 1 ) + return; + goto _play_sound; case VAR_Experience: v16 = __CFADD__(val, LODWORD(Dst->uExperience)); LODWORD(Dst->uExperience) += val; HIDWORD(Dst->uExperience) += ((unsigned __int64)val >> 32) + v16; if ( (signed __int64)Dst->uExperience > 4000000000i64 ) Dst->uExperience = 4000000000i64; - goto _play_anim_and_exit; + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + goto _play_sound; case VAR_QBits_QuestsDone: if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & pParty->_quest_bits[((signed __int16)val - 1) >> 3]) //&& (&dword_722F10)[4 * val] ) @@ -7628,9 +7437,17 @@ pPlayers[uPlayerIdx + 1]->PlaySound(SPEECH_93, 0); } v15 = (char *)pParty->_quest_bits; -LABEL_44: - _449B7E_toggle_bit((unsigned char *)v15, val, 1u); - goto LABEL_173; + _449B7E_toggle_bit((unsigned char *)v15, val, 1); + if ( v34 != 1 ) + { + if ( v3 != 1 ) + return; + goto _play_sound; + } + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + if ( v3 != 1 ) + return; + goto _play_sound; case VAR_PlayerItemInHands: item.Reset(); item.Reset(); @@ -7762,9 +7579,9 @@ *v18 += val; if ( *v18 > 255 ) *v18 = 255; - v31 = 0; - v29 = 92; - goto LABEL_116; + pPlayers[uPlayerIdx + 1]->PlaySound(SPEECH_92, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + goto _play_sound; default: return; } @@ -7777,10 +7594,9 @@ *v19 = 255; v31 = 0; v29 = SPEECH_91; -LABEL_116: - v3 = 1; pPlayers[uPlayerIdx + 1]->PlaySound((PlayerSpeech)v29, v31); - goto _play_anim_and_maybe_sound; + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + goto _play_sound; } if ( var_type <= VAR_DisarmTrapSkill ) { @@ -7850,7 +7666,8 @@ LOBYTE(v21) = v21 & 0xC0; *(short *)v20 = v22 | v21; } - goto _play_anim_and_exit; + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + goto _play_sound; } if ( var_type <= VAR_LearningSkill ) return; @@ -7873,13 +7690,7 @@ } memset(Dst, 0, 0xA0u); } -_play_anim_and_exit: - v3 = 1; -_play_anim_and_maybe_sound: pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); -_maybe_play_sound: - if ( v3 != 1 ) - return; goto _play_sound; } if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & pParty->_autonote_bits[((signed __int16)val - 1) >> 3]) @@ -7895,17 +7706,32 @@ } _449B7E_toggle_bit(pParty->_autonote_bits, val, 1); v3 = 1; -LABEL_173: if ( v34 != 1 ) - goto _maybe_play_sound; - goto _play_anim_and_maybe_sound; + { + if ( v3 != 1 ) + return; + goto _play_sound; + } + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + if ( v3 != 1 ) + return; + goto _play_sound; } if ( var_type > VAR_GoldInBank ) { if ( var_type == 307 ) { pParty->uNumDeaths += val; - goto LABEL_173; + if ( v34 != 1 ) + { + if ( v3 != 1 ) + return; + goto _play_sound; + } + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + if ( v3 != 1 ) + return; + goto _play_sound; } switch ( var_type ) { diff -r 86cb7398d2a8 -r 7d986a396092 Player.h --- a/Player.h Sat Sep 07 12:51:06 2013 +0200 +++ b/Player.h Sat Sep 07 13:03:18 2013 +0200 @@ -10,9 +10,12 @@ #define PLAYER_BUFF_FATE 4 #define PLAYER_BUFF_HAMMERHANDS 6 #define PLAYER_BUFF_7 7 +#define PLAYER_BUFF_8 8 #define PLAYER_BUFF_PAIN_REFLECTION 10 #define PLAYER_BUFF_PRESERVATION 11 #define PLAYER_BUFF_REGENERATION 12 +#define PLAYER_BUFF_13 13 +#define PLAYER_BUFF_14 14 #define PLAYER_GUILD_BITS__SPIRIT_MEMBERSHIP 58 @@ -618,6 +621,7 @@ inline bool IsMale() { return GetSexByVoice() == SEX_MALE;} inline bool IsFemale() { return !IsMale();} + unsigned int GetMultiplierForMastery(unsigned int skillValue, int mult1, int mult2, int mult3, int mult4); __int64 pConditions[20]; unsigned __int64 uExperience; char pName[16]; diff -r 86cb7398d2a8 -r 7d986a396092 Render.cpp --- a/Render.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/Render.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -915,259 +915,259 @@ auto decor = &pLevelDecorations[i]; auto v0 = (char *)&pLevelDecorations[i].vPosition.y; - if ( (!(decor->field_2 & 0x40) || decor->_47A825()) && !(decor->field_2 & 0x20) ) - { - //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID]; - auto decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID; - v2 = decor_desc->uFlags; - if ( (char)v2 >= 0 ) + if ((!(decor->uFlags & LEVEL_DECORATION_OBELISK_CHEST) || decor->IsObeliskChestActive()) && !(decor->uFlags & LEVEL_DECORATION_INVISIBLE)) + { + //v1 = &pDecorationList->pDecorations[decor->uDecorationDescID]; + auto decor_desc = pDecorationList->pDecorations + decor->uDecorationDescID; + v2 = decor_desc->uFlags; + if ( (char)v2 >= 0 ) + { + if ( !(v2 & 0x22) ) { - if ( !(v2 & 0x22) ) + //v4 = decor->vPosition.x; + //v5 = decor->vPosition.z; + v6 = pMiscTimer->uTotalGameTimeElapsed; + //y = decor->vPosition.y; + //x = decor->vPosition.x; + //v36 = decor->vPosition.z; + v7 = abs(decor->vPosition.x + decor->vPosition.y); + + + #pragma region "New: seasons change" + extern bool change_seasons; + if (change_seasons) + switch (pParty->uCurrentMonth) + { + // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites + case 11: case 0: case 1: // winter + switch (decor_desc->uSpriteID) + { + //case 468: //bush02 grows on swamps, which are evergreeen actually + case 548: // flower10 + case 547: // flower09 + case 541: // flower03 + case 539: continue; // flower01 + + case 483: // tree01 + case 486: // tree04 + case 492: // tree10 + pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); + v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); + break; + + default: + v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); + } + break; + + case 2: case 3: case 4: // spring + switch (decor_desc->uSpriteID) + { + } + v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); + break; + + case 8: case 9: case 10: // autumn + switch (decor_desc->uSpriteID) + { + //case 468: //bush02 grows on swamps, which are evergreeen actually + case 548: // flower10 + case 547: // flower09 + case 541: // flower03 + case 539: continue; // flower01 + + case 483: // tree01 + case 486: // tree04 + case 492: // tree10 + pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); + v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); + break; + + default: + v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); + } + break; + + case 5: case 6: case 7: // summer + //all green by default + v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); + break; + + default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); + } + else + v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); + #pragma endregion + //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); + + //v9 = v8; + v42 = v8->uFlags; + a5 = v8->uGlowRadius; + v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pIndoorCamera->pos.x, + decor->vPosition.y - pIndoorCamera->pos.y); + v11 = *((int *)v0 + 2); + v37 = v10; + v12 = v42; + v38 = 0; + v13 = ((signed int)(stru_5C6E00->uIntegerPi + + ((signed int)stru_5C6E00->uIntegerPi >> 3) + + v11 + - (signed int)v37) >> 8) & 7; + v37 = (unsigned __int16 *)v13; + if ( v42 & 2 ) + v38 = 2; + if ( (256 << v13) & v42 ) + v38 |= 4u; + if ( v12 & 0x40000 ) + v38 |= 0x40u; + if ( v12 & 0x20000 ) + LOBYTE(v38) = v38 | 0x80; + if ( a5 ) { - //v4 = decor->vPosition.x; - //v5 = decor->vPosition.z; - v6 = pMiscTimer->uTotalGameTimeElapsed; - //y = decor->vPosition.y; - //x = decor->vPosition.x; - //v36 = decor->vPosition.z; - v7 = abs(decor->vPosition.x + decor->vPosition.y); - - - #pragma region "New: seasons change" - extern bool change_seasons; - if (change_seasons) - switch (pParty->uCurrentMonth) - { - // case 531 (tree60), 536 (tree65), 537 (tree66) have no autumn/winter sprites - case 11: case 0: case 1: // winter - switch (decor_desc->uSpriteID) - { - //case 468: //bush02 grows on swamps, which are evergreeen actually - case 548: // flower10 - case 547: // flower09 - case 541: // flower03 - case 539: continue; // flower01 - - case 483: // tree01 - case 486: // tree04 - case 492: // tree10 - pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 2); - v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 2, v6 + v7); - break; - - default: - v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); - } - break; - - case 2: case 3: case 4: // spring - switch (decor_desc->uSpriteID) - { - } - v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); - break; - - case 8: case 9: case 10: // autumn - switch (decor_desc->uSpriteID) - { - //case 468: //bush02 grows on swamps, which are evergreeen actually - case 548: // flower10 - case 547: // flower09 - case 541: // flower03 - case 539: continue; // flower01 - - case 483: // tree01 - case 486: // tree04 - case 492: // tree10 - pSpriteFrameTable->InitializeSprite(decor_desc->uSpriteID + 1); - v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID + 1, v6 + v7); - break; - - default: - v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); - } - break; - - case 5: case 6: case 7: // summer - //all green by default - v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); - break; - - default: assert(pParty->uCurrentMonth >= 0 && pParty->uCurrentMonth < 12); - } - else - v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); - #pragma endregion - //v8 = pSpriteFrameTable->GetFrame(decor_desc->uSpriteID, v6 + v7); - - //v9 = v8; - v42 = v8->uFlags; - a5 = v8->uGlowRadius; - v10 = (unsigned __int16 *)stru_5C6E00->Atan2(decor->vPosition.x - pIndoorCamera->pos.x, - decor->vPosition.y - pIndoorCamera->pos.y); - v11 = *((int *)v0 + 2); - v37 = v10; - v12 = v42; - v38 = 0; - v13 = ((signed int)(stru_5C6E00->uIntegerPi - + ((signed int)stru_5C6E00->uIntegerPi >> 3) - + v11 - - (signed int)v37) >> 8) & 7; - v37 = (unsigned __int16 *)v13; - if ( v42 & 2 ) - v38 = 2; - if ( (256 << v13) & v42 ) - v38 |= 4u; - if ( v12 & 0x40000 ) - v38 |= 0x40u; - if ( v12 & 0x20000 ) - LOBYTE(v38) = v38 | 0x80; - if ( a5 ) + if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) { - if ( pRenderer->pRenderD3D && pRenderer->bUseColoredLights ) - { - v14 = decor_desc->uColoredLightRed; - v15 = decor_desc->uColoredLightGreen; - v16 = decor_desc->uColoredLightBlue; - } - else - { - v16 = 255; - v14 = 255; - v15 = 255; - } - b = v16; - pStationaryLightsStack->AddLight( - decor->vPosition.x, - decor->vPosition.y, - decor->vPosition.z + decor_desc->uDecorationHeight / 2, - a5, - v14, - v15, - v16, - byte_4E94D0); - } - v17 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; - if ( pIndoorCamera->sRotationX ) - { - v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; - v18 = ((unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); - v42 = v18; - b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; - a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; - v40 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; - v41 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; - v19 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; - v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); - v39 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); - if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) - { - v21 = a5 - b; - v41 = a5 - b; - a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; - b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; - v22 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) - a5; -LABEL_30: - v42 = v22; - v40 = 2 * abs(v20); - v23 = abs(v21); - if ( v40 >= v23 ) - { - LODWORD(v24) = 0; - HIDWORD(v24) = SLOWORD(pOutdoorCamera->int_fov_rad); - a5 = v24 / v39; - v25 = pViewport->uScreenCenterX - - ((signed int)(((unsigned __int64)(v24 / v39 * v41) >> 16) + 32768) >> 16); - b = (unsigned __int64)(a5 * (signed __int64)v42) >> 16; - v41 = v24 / v39; - v40 = pViewport->uScreenCenterY - - ((signed int)(((unsigned __int64)(a5 * (signed __int64)v42) >> 16) + 32768) >> 16); - v42 = v8->scale; - v41 = (unsigned __int64)(v42 * v24 / v39) >> 16; - v37 = (unsigned __int16 *)&v8->pHwSpriteIDs[(int)v37]; - if ( pRenderer->pRenderD3D ) - { - v26 = v41; - v42 = pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth >> 1; - b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; - } - else - { - v26 = v41; - v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth >> 1; - b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; - } - if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) - { - if (::uNumBillboardsToDraw >= 500) - return; - v27 = &pBillboardRenderList[::uNumBillboardsToDraw++]; - ++uNumDecorationsDrawnThisFrame; - v27->uHwSpriteID = *v37; - v28 = v8->uPaletteIndex; - v27->_screenspace_x_scaler_packedfloat = v26; - v27->_screenspace_y_scaler_packedfloat = v26; - v29 = v38; - v27->uScreenSpaceX = v25; - HIBYTE(v29) |= 2u; - v27->uPalette = v28; - v27->field_1E = v29; - v27->world_x = decor->vPosition.x; - v27->world_y = decor->vPosition.y; - v27->world_z = decor->vPosition.z; - v27->uScreenSpaceY = v40; - HIWORD(v30) = HIWORD(v39); - v31 = PID(OBJECT_Decoration,i); - LOWORD(v30) = 0; - v27->uIndoorSectorID = 0; - v27->sZValue = v30 + v31; - v27->dimming_level = 0; - v27->pSpriteFrame = v8; - v27->uTintColor = 0; - } - } - goto LABEL_38; - } + v14 = decor_desc->uColoredLightRed; + v15 = decor_desc->uColoredLightGreen; + v16 = decor_desc->uColoredLightBlue; } else { - v42 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; - v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; - b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; - a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; - v20 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); - v39 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); - if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) + v16 = 255; + v14 = 255; + v15 = 255; + } + b = v16; + pStationaryLightsStack->AddLight( + decor->vPosition.x, + decor->vPosition.y, + decor->vPosition.z + decor_desc->uDecorationHeight / 2, + a5, + v14, + v15, + v16, + byte_4E94D0); + } + v17 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; + if ( pIndoorCamera->sRotationX ) + { + v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; + v18 = ((unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) + + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); + v42 = v18; + b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; + a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; + v40 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; + v41 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; + v19 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; + v20 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); + v39 = v19 + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); + if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) + { + v21 = a5 - b; + v41 = a5 - b; + a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16; + b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16; + v22 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) - a5; +LABEL_30: + v42 = v22; + v40 = 2 * abs(v20); + v23 = abs(v21); + if ( v40 >= v23 ) { - a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; - b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; - v21 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; - v41 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; - v22 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; - goto LABEL_30; + LODWORD(v24) = 0; + HIDWORD(v24) = SLOWORD(pOutdoorCamera->int_fov_rad); + a5 = v24 / v39; + v25 = pViewport->uScreenCenterX + - ((signed int)(((unsigned __int64)(v24 / v39 * v41) >> 16) + 32768) >> 16); + b = (unsigned __int64)(a5 * (signed __int64)v42) >> 16; + v41 = v24 / v39; + v40 = pViewport->uScreenCenterY + - ((signed int)(((unsigned __int64)(a5 * (signed __int64)v42) >> 16) + 32768) >> 16); + v42 = v8->scale; + v41 = (unsigned __int64)(v42 * v24 / v39) >> 16; + v37 = (unsigned __int16 *)&v8->pHwSpriteIDs[(int)v37]; + if ( pRenderer->pRenderD3D ) + { + v26 = v41; + v42 = pSprites_LOD->pHardwareSprites[(signed __int16)*v37].uBufferWidth >> 1; + b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; + } + else + { + v26 = v41; + v42 = pSprites_LOD->pSpriteHeaders[(signed __int16)*v37].uWidth >> 1; + b = (unsigned __int64)(v42 * (signed __int64)v41) >> 16; + } + if ( b + v25 >= (signed int)pViewport->uViewportTL_X && v25 - b <= (signed int)pViewport->uViewportBR_X ) + { + if (::uNumBillboardsToDraw >= 500) + return; + v27 = &pBillboardRenderList[::uNumBillboardsToDraw++]; + ++uNumDecorationsDrawnThisFrame; + v27->uHwSpriteID = *v37; + v28 = v8->uPaletteIndex; + v27->_screenspace_x_scaler_packedfloat = v26; + v27->_screenspace_y_scaler_packedfloat = v26; + v29 = v38; + v27->uScreenSpaceX = v25; + HIBYTE(v29) |= 2u; + v27->uPalette = v28; + v27->field_1E = v29; + v27->world_x = decor->vPosition.x; + v27->world_y = decor->vPosition.y; + v27->world_z = decor->vPosition.z; + v27->uScreenSpaceY = v40; + HIWORD(v30) = HIWORD(v39); + v31 = PID(OBJECT_Decoration,i); + LOWORD(v30) = 0; + v27->uIndoorSectorID = 0; + v27->sZValue = v30 + v31; + v27->dimming_level = 0; + v27->pSpriteFrame = v8; + v27->uTintColor = 0; + } } + goto LABEL_38; + } + } + else + { + v42 = (decor->vPosition.x - pIndoorCamera->pos.x) << 16; + v40 = (decor->vPosition.y - pIndoorCamera->pos.y) << 16; + b = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; + a5 = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; + v20 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); + v39 = b + ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); + if ( v20 >= 262144 && v20 <= pOutdoorCamera->shading_dist_mist << 16 ) + { + a5 = (unsigned __int64)(v42 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; + b = (unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; + v21 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; + v41 = ((unsigned __int64)(v40 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - a5; + v22 = (decor->vPosition.z - pIndoorCamera->pos.z) << 16; + goto LABEL_30; } } } - else - { - memset(&local_0, 0, 0x68u); - v3 = (double)*((signed int *)v0 - 1); - local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; - local_0.uDiffuse = 0xFF3C1E; - local_0.x = v3; - local_0.y = (double)*(signed int *)v0; - local_0.z = (double)*((signed int *)v0 + 1); - local_0.r = 0.0; - local_0.g = 0.0; - local_0.b = 0.0; - local_0.flt_28 = 1.0; - local_0.timeToLive = (rand() & 0x80) + 128; - local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); - pGame->pParticleEngine->AddParticle(&local_0); - } - } + } + else + { + memset(&local_0, 0, 0x68u); + v3 = (double)*((signed int *)v0 - 1); + local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; + local_0.uDiffuse = 0xFF3C1E; + local_0.x = v3; + local_0.y = (double)*(signed int *)v0; + local_0.z = (double)*((signed int *)v0 + 1); + local_0.r = 0.0; + local_0.g = 0.0; + local_0.b = 0.0; + local_0.flt_28 = 1.0; + local_0.timeToLive = (rand() & 0x80) + 128; + local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); + pGame->pParticleEngine->AddParticle(&local_0); + } + } LABEL_38: ; //++v35; @@ -2103,7 +2103,7 @@ hd_water_current_frame = 0; } -bool Render::Initialize(bool bWindowed, uint uDefaultDevice, bool bColoredLights, uint uDetailLevel, uint bTinting) +bool Render::Initialize(bool bWindowed, uint32_t uDefaultDevice, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) { bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); bStartInWindow = bWindowed; @@ -7359,20 +7359,13 @@ } //----- (004A6A68) -------------------------------------------------------- -void Render::_4A6A68(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) -{ - Render *v5; // ebx@1 - unsigned __int16 v6; // ax@1 - - v5 = this; - +void Render::GetLeather(unsigned int a2, unsigned int a3, Texture *a4, __int16 height) +{ Texture tex; // [sp+Ch] [bp-48h]@1 - //Texture::Texture(&tex); - - v6 = a4->uTextureHeight - height; + memcpy(&tex, a4, sizeof(tex)); - tex.uTextureHeight = v6; - if ( (signed __int16)v6 > 0 ) + tex.uTextureHeight = a4->uTextureHeight - height; + if ( (signed __int16)tex.uTextureHeight > 0 ) DrawTextureIndexed(a2, a3, &tex); } diff -r 86cb7398d2a8 -r 7d986a396092 Render.h --- a/Render.h Sat Sep 07 12:51:06 2013 +0200 +++ b/Render.h Sat Sep 07 13:03:18 2013 +0200 @@ -1,5 +1,7 @@ #pragma once -#include + +#include +#include #include "lib\legacy_dx\d3d.h" #include "OSAPI.h" @@ -169,7 +171,7 @@ HWLTexture *LoadTexture(const char *pName, int bMipMaps); FILE *pFile; - uint uSignature; + uint32_t uSignature; unsigned int uDataOffset; unsigned int uNumItems; char *pSpriteNames[50000]; @@ -267,8 +269,8 @@ static Render *Create() {return new Render;} - bool Initialize(bool bWindowed, uint uDefaultDevice, - bool bColoredLights, uint uDetailLevel, uint bTinting); + bool Initialize(bool bWindowed, uint32_t uDefaultDevice, + bool bColoredLights, uint32_t uDetailLevel, bool bTinting); bool IsColorKeySupported(IDirectDraw4 *); @@ -348,7 +350,7 @@ void _4A65CC(unsigned int x, unsigned int y, struct Texture *a4, struct Texture *a5, int a6, int a7, int a8); void DrawTransparentRedShade(unsigned int a2, unsigned int a3, struct Texture *a4); void DrawTransparentGreenShade(signed int a2, signed int a3, struct Texture *pTexture); - void _4A6A68(unsigned int a2, unsigned int a3, struct Texture *a4, __int16 height); + void GetLeather(unsigned int a2, unsigned int a3, struct Texture *a4, __int16 height); void DrawTextPalette(int x, int y, unsigned char* font_pixels, int a5, unsigned int uFontHeight, unsigned __int16 *pPalette, int a8); void DrawText(signed int uOutX, signed int uOutY, unsigned __int8 *pFontPixels, unsigned int uCharWidth, unsigned int uCharHeight, unsigned __int16 *pFontPalette, unsigned __int16 uFaceColor, unsigned __int16 uShadowColor); void FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16); @@ -435,7 +437,7 @@ unsigned int uMinDeviceTextureDim; int field_10365C; unsigned int bUsingSpecular; - uint uFogColor; + uint32_t uFogColor; int field_103668; unsigned int pHDWaterBitmapIDs[7]; char field_103688[32]; @@ -447,7 +449,7 @@ int _gpu_memory_used; void ( *pBeforePresentFunction)(); int field_1036C4; - uint bFogEnabled; + uint32_t bFogEnabled; int field_1036CC; RenderBillboardD3D pBillboardRenderListD3D[1000]; unsigned int uNumBillboardsToDraw; diff -r 86cb7398d2a8 -r 7d986a396092 SaveLoad.cpp --- a/SaveLoad.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/SaveLoad.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -415,7 +415,7 @@ for (int i = 0; i <(signed int)uNumLevelDecorations; ++i) { - memcpy(data_write_pos, &pLevelDecorations[i].field_2, 2); + memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2); data_write_pos+= 2; } @@ -465,7 +465,7 @@ for (int i = 0; i < (signed int)uNumLevelDecorations; ++i) { - memcpy(data_write_pos, &pLevelDecorations[i].field_2, 2); + memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2); data_write_pos += 2; } memcpy(data_write_pos, &uNumActors, 4); diff -r 86cb7398d2a8 -r 7d986a396092 Spells.cpp --- a/Spells.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/Spells.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -441,7 +441,7 @@ } //----- (00448DF8) -------------------------------------------------------- -void __fastcall EventCastSpell(int spellnum, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz)//sub_448DF8 +void __fastcall EventCastSpell(int uSpellID, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz)//sub_448DF8 { int v9; // esi@1 double v10; // st7@4 @@ -509,7 +509,7 @@ v9 = 0; v59 = uSkillLevel + 1; - //spellnum_ = spellnum; + //spellnum_ = uSpellID; v60 = 0; if ( tox || toy || toz ) { @@ -552,12 +552,12 @@ SpriteObject a1; // [sp+38h] [bp-7Ch]@12 //SpriteObject::SpriteObject(&a1); - a1.uType = stru_4E3ACC[spellnum].uType; - if ( spellnum > 58 ) + a1.uType = stru_4E3ACC[uSpellID].uType; + if ( uSpellID > 58 ) { - if ( spellnum == 69 ) + if ( uSpellID == 69 ) goto LABEL_117; - if ( spellnum != 83 ) + if ( uSpellID != 83 ) return; v40 = v15 - 2; if ( v40 ) @@ -604,9 +604,9 @@ v37->Apply(v36, a7b, v43, 0, 0); goto LABEL_139; } - if ( spellnum != 58 ) + if ( uSpellID != 58 ) { - switch ( spellnum ) + switch ( uSpellID ) { case 2: case 6: @@ -618,7 +618,7 @@ case 41: a1.stru_24.Reset(); v16 = 0; - a1.spell_id = spellnum; + a1.spell_id = uSpellID; a1.spell_level = uSkill; a1.spell_skill = v15; if ( (signed int)pObjectList->uNumObjects <= 0 ) @@ -703,7 +703,7 @@ a8b = a7c / (v60 - 1); a1.stru_24.Reset(); v21 = 0; - a1.spell_id = spellnum; + a1.spell_id = uSpellID; a1.spell_level = uSkill; a1.spell_skill = v15; if ( (signed int)pObjectList->uNumObjects <= 0 ) @@ -759,7 +759,7 @@ } a1.stru_24.Reset(); v16 = 0; - a1.spell_id = spellnum; + a1.spell_id = uSpellID; a1.spell_level = uSkill; a1.spell_skill = v15; if ( (signed int)pObjectList->uNumObjects <= 0 ) @@ -849,7 +849,7 @@ a8c = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v60 - 1); a1.stru_24.Reset(); v25 = 0; - a1.spell_id = spellnum; + a1.spell_id = uSpellID; a1.spell_level = uSkill; a1.spell_skill = v15; if ( (signed int)pObjectList->uNumObjects <= 0 ) @@ -924,7 +924,7 @@ return; a1.stru_24.Reset(); v29 = 0; - a1.spell_id = spellnum; + a1.spell_id = uSpellID; a1.spell_level = uSkill; a1.spell_skill = v15; if ( (signed int)pObjectList->uNumObjects <= 0 ) @@ -985,10 +985,10 @@ 0, 0); //v33 = spellnum_; - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 1); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 2); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 3); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); goto LABEL_138; case 17: case 38: @@ -1006,7 +1006,7 @@ v9 = 3600 * (uSkill + 1); break; } - switch ( spellnum ) + switch ( uSpellID ) { case 17: v60 = 0; @@ -1023,10 +1023,10 @@ v60 = v34; break; } - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 1); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 2); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 3); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); v52 = 0; v50 = 0; v48 = v60; @@ -1040,10 +1040,10 @@ v38 = 60 * uSkill; else v38 = 600 * uSkill; - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 1); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 2); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 3); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); v52 = 0; v50 = 0; v48 = uSkill; @@ -1131,7 +1131,7 @@ goto LABEL_125; } LABEL_125: - switch ( spellnum ) + switch ( uSpellID ) { case 3: uSkill = 6; @@ -1153,16 +1153,16 @@ break; } //v45 = spellnum_; - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 1); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 2); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 3); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); pParty->pPartyBuffs[uSkill].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)a6_4 * 4.2666669), v15, v60, 0, 0); //levela = 1; LABEL_138: //if ( levela ) LABEL_139: - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[spellnum], 0, 0, fromx, fromy, 0, 0, 0); + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); } //----- (00427769) -------------------------------------------------------- bool __fastcall sub_427769_spell(unsigned int uSpellID) diff -r 86cb7398d2a8 -r 7d986a396092 Spells.h --- a/Spells.h Sat Sep 07 12:51:06 2013 +0200 +++ b/Spells.h Sat Sep 07 13:03:18 2013 +0200 @@ -1,5 +1,7 @@ #pragma once +#include + #include "VectorTypes.h" /* 360 */ diff -r 86cb7398d2a8 -r 7d986a396092 Sprites.cpp --- a/Sprites.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/Sprites.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -752,7 +752,7 @@ if ( PID_TYPE(v4) == OBJECT_Decoration) { v5 = &pLevelDecorations[(signed __int16)v4 >> 3]; - if ( !(v5->field_2 & 0x20) ) + if (!(v5->uFlags & LEVEL_DECORATION_INVISIBLE)) { v6 = &pDecorationList->pDecorations[v5->uDecorationDescID]; if (!v6->CanMoveThrough()) diff -r 86cb7398d2a8 -r 7d986a396092 UI/Books/UIMapBook.cpp --- a/UI/Books/UIMapBook.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/UI/Books/UIMapBook.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -528,21 +528,21 @@ { v51 = pParty->sRotationY & stru_5C6E00->uDoublePiMask; if ( (signed int)v51 <= 1920 ) - v50 = 7; + v50 = 6; if ( (signed int)v51 < 1664 ) - v50 = 6; + v50 = 5; if ( (signed int)v51 <= 1408 ) - v50 = 5; + v50 = 4; if ( (signed int)v51 < 1152 ) - v50 = 4; + v50 = 3; if ( (signed int)v51 <= 896 ) - v50 = 3; + v50 = 2; if ( (signed int)v51 < 640 ) - v50 = 2; + v50 = 1; if ( (signed int)v51 <= 384 ) - v50 = 1; - if ( (signed int)v51 < 128 ) v50 = 0; + if ( (signed int)v51 < 128 || (signed int)v51 > 1920 ) + v50 = 7; pRenderer->DrawTransparentRedShade(v47, v49, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[v50])); } result = TargetColor(0xFFu, 0xFFu, 0xFFu); @@ -551,7 +551,7 @@ { for ( uint i = 0; i < (signed int)uNumLevelDecorations; ++i ) { - if ( pLevelDecorations[i].field_2 & 8 ) + if (pLevelDecorations[i].uFlags & LEVEL_DECORATION_VISIBLE_ON_MAP) { screenHeight = pLevelDecorations[i].vPosition.y - pCenterY; v93 = (unsigned __int16 *)(pLevelDecorations[i].vPosition.x - viewparams->sViewCenterX); diff -r 86cb7398d2a8 -r 7d986a396092 UI/UICharacter.cpp --- a/UI/UICharacter.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/UI/UICharacter.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -1764,7 +1764,7 @@ } } } - memset(byte_5111F6.data(), 0, 16); + memset(byte_5111F6.data(), 0, sizeof(byte_5111F6)); for (uint i = 0; i < 4; ++i) { auto player = pParty->pPlayers + i; @@ -2012,43 +2012,43 @@ //First column(Ïåðâàÿ êîëîíêà) pY = 53; sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[144], - UI_GetHealthManaStringColor(player->GetActualMight(), player->GetBaseStrength()), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualMight(), player->GetBaseStrength()), player->GetActualMight(), player->GetBaseStrength());//Might pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, pY, 0, pTmpBuf.data(), 0, 0, 0); pY += LOBYTE(pFontArrus->uFontHeight) - 2; sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[116], - UI_GetHealthManaStringColor(player->GetActualIntelligence(), player->GetBaseIntelligence()), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualIntelligence(), player->GetBaseIntelligence()), player->GetActualIntelligence(), player->GetBaseIntelligence());//Intellect pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, pY, 0, pTmpBuf.data(), 0, 0, 0); pY += LOBYTE(pFontArrus->uFontHeight) - 2; sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[163], - UI_GetHealthManaStringColor(player->GetActualWillpower(), player->GetBaseWillpower()), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualWillpower(), player->GetBaseWillpower()), player->GetActualWillpower(), player->GetBaseWillpower());// pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, pY, 0, pTmpBuf.data(), 0, 0, 0); pY += LOBYTE(pFontArrus->uFontHeight) - 2; sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[75], - UI_GetHealthManaStringColor(player->GetActualEndurance(), player->GetBaseEndurance()), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualEndurance(), player->GetBaseEndurance()), player->GetActualEndurance(), player->GetBaseEndurance());// pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, pY, 0, pTmpBuf.data(), 0, 0, 0); pY += LOBYTE(pFontArrus->uFontHeight) - 2; sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[1], - UI_GetHealthManaStringColor(player->GetActualAccuracy(), player->GetBaseAccuracy()), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualAccuracy(), player->GetBaseAccuracy()), player->GetActualAccuracy(), player->GetBaseAccuracy()); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, pY, 0, pTmpBuf.data(), 0, 0, 0); pY += LOBYTE(pFontArrus->uFontHeight) - 2; sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[211], - UI_GetHealthManaStringColor(player->GetActualSpeed(), player->GetBaseSpeed()), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualSpeed(), player->GetBaseSpeed()), player->GetActualSpeed(), player->GetBaseSpeed()); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, pY, 0, pTmpBuf.data(), 0, 0, 0); pY += LOBYTE(pFontArrus->uFontHeight) - 2; sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n\n", pGlobalTXT_LocalizationStrings[136], - UI_GetHealthManaStringColor(player->GetActualLuck(), player->GetBaseLuck()), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualLuck(), player->GetBaseLuck()), player->GetActualLuck(), player->GetBaseLuck()); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, pY, 0, pTmpBuf.data(), 0, 0, 0); @@ -2057,7 +2057,7 @@ a2 = "%s\f%05u\r388%d\f00000 / %d\n"; pY += 2 * LOBYTE(pFontArrus->uFontHeight) + 5; sprintf(pTmpBuf.data(), a2, pGlobalTXT_LocalizationStrings[108], - UI_GetHealthManaStringColor(player->sHealth, player->GetMaxHealth()), + UI_GetHealthManaAndOtherQualitiesStringColor(player->sHealth, player->GetMaxHealth()), player->sHealth, player->GetMaxHealth()); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, pY, 0, pTmpBuf.data(), 0, 0, 0); @@ -2066,13 +2066,13 @@ a2 = "%s\f%05u\r388%d\f00000 / %d\n"; pY += LOBYTE(pFontArrus->uFontHeight) - 2; sprintf(pTmpBuf.data(), a2, pGlobalTXT_LocalizationStrings[212], - UI_GetHealthManaStringColor(player->sMana, player->GetMaxMana()), + UI_GetHealthManaAndOtherQualitiesStringColor(player->sMana, player->GetMaxMana()), player->sMana, player->GetMaxMana()); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, pY, 0, pTmpBuf.data(), 0, 0, 0); pY += LOBYTE(pFontArrus->uFontHeight) - 2; sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n\n", pGlobalTXT_LocalizationStrings[12], - UI_GetHealthManaStringColor(player->GetActualAC(), player->GetBaseAC()), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualAC(), player->GetBaseAC()), player->GetActualAC(), player->GetBaseAC()); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, pY, 0, pTmpBuf.data(), 0, 0, 0); @@ -2091,7 +2091,7 @@ //Second column (Âòîðàÿ êîëîíêà) pY = 50; sprintf(pTmpBuf.data(), "%s\f%05u\t100%d\f00000 / %d\n", pGlobalTXT_LocalizationStrings[5], - UI_GetHealthManaStringColor(player->GetActualAge(), player->GetBaseAge()), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualAge(), player->GetBaseAge()), player->GetActualAge(), player->GetBaseAge()); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, pY, 0, pTmpBuf.data(), 0, 0, 0); @@ -2100,7 +2100,7 @@ a2 = "%s\f%05u\t180%d\f00000 / %d\n"; pY += LOBYTE(pFontArrus->uFontHeight) - 2; sprintf(pTmpBuf.data(), a2, pGlobalTXT_LocalizationStrings[131],//Óðîâ. - UI_GetHealthManaStringColor(player->GetActualLevel(), player->GetBaseLevel()), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualLevel(), player->GetBaseLevel()), player->GetActualLevel(), player->GetBaseLevel()); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, pY, 0, pTmpBuf.data(), 0, 0, 0); @@ -2132,7 +2132,7 @@ a2 = "%s\f%05u\t180%d\f00000 / %d\n"; pY += 2 * LOBYTE(pFontArrus->uFontHeight) - 4; sprintf(pTmpBuf.data(), a2, pGlobalTXT_LocalizationStrings[87], - UI_GetHealthManaStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE)), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE)), player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE)); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, pY, 0, pTmpBuf.data(), 0, 0, 0); @@ -2141,7 +2141,7 @@ a2 = "%s\f%05u\t180%d\f00000 / %d\n"; pY += LOBYTE(pFontArrus->uFontHeight) - 2; sprintf(pTmpBuf.data(), a2, pGlobalTXT_LocalizationStrings[6], - UI_GetHealthManaStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_AIR), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_AIR)), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_AIR), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_AIR)), player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_AIR), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_AIR)); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, pY, 0, pTmpBuf.data(), 0, 0, 0); @@ -2150,7 +2150,7 @@ a2 = "%s\f%05u\t180%d\f00000 / %d\n"; pY += LOBYTE(pFontArrus->uFontHeight) - 2; sprintf(pTmpBuf.data(), a2, pGlobalTXT_LocalizationStrings[240], - UI_GetHealthManaStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_WATER), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_WATER)), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_WATER), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_WATER)), player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_WATER), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_WATER)); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, pY, 0, pTmpBuf.data(), 0, 0, 0); @@ -2159,7 +2159,7 @@ a2 = "%s\f%05u\t180%d\f00000 / %d\n"; pY += LOBYTE(pFontArrus->uFontHeight) - 2; sprintf(pTmpBuf.data(), a2, pGlobalTXT_LocalizationStrings[70], - UI_GetHealthManaStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH)), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH)), player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH)); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, pY, 0, pTmpBuf.data(), 0, 0, 0); @@ -2168,11 +2168,11 @@ a2 = "%s\f%05u\t180%d\f00000 / %d\n"; pY += LOBYTE(pFontArrus->uFontHeight) - 2; sprintf(pTmpBuf.data(), a2, pGlobalTXT_LocalizationStrings[142], - UI_GetHealthManaStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_MIND)), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_MIND)), player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_MIND)); if ( player->classType == PLAYER_CLASS_LICH && player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_MIND) == 200 ) sprintf(pTmpBuf.data(), format_4E2E00, pGlobalTXT_LocalizationStrings[142], - UI_GetHealthManaStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND), 200), pGlobalTXT_LocalizationStrings[625]); + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND), 200), pGlobalTXT_LocalizationStrings[625]); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, pY, 0, pTmpBuf.data(), 0, 0, 0); a2 = format_4E2E10; @@ -2180,11 +2180,11 @@ a2 = "%s\f%05u\t180%d\f00000 / %d\n"; pY += LOBYTE(pFontArrus->uFontHeight) - 2; sprintf(pTmpBuf.data(), a2, pGlobalTXT_LocalizationStrings[29], - UI_GetHealthManaStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_BODY)), + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_BODY)), player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY), player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_BODY)); if ( player->classType == PLAYER_CLASS_LICH && player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_BODY) == 200 ) sprintf(pTmpBuf.data(), format_4E2E00, pGlobalTXT_LocalizationStrings[29], - UI_GetHealthManaStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY), 200), pGlobalTXT_LocalizationStrings[625]); + UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY), 200), pGlobalTXT_LocalizationStrings[625]); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, pY, 0, pTmpBuf.data(), 0, 0, 0); } @@ -2323,43 +2323,19 @@ unsigned int v3; // edx@4 unsigned int pSkillType; // esi@5 unsigned __int16 v5; // ax@7 - //unsigned int v6; // edi@19 int v7; // esi@27 int v8; // eax@29 - //int v9; // edx@32 - int v10; // esi@34 - //int v11; // eax@34 - int v12; // esi@38 - //int v13; // eax@38 - char v14; // zf@38 - int v15; // esi@42 - //int v16; // eax@42 int v17; // eax@44 unsigned int v18; // ecx@55 unsigned int v19; // eax@55 - int v20; // esi@60 - //int v21; // eax@60 unsigned int v22; // eax@61 int v23; // eax@62 - int v24; // esi@65 - int v25; // eax@65 int v26; // eax@69 - int v27; // esi@81 - int v28; // eax@81 - int v29; // esi@84 - int v30; // eax@84 - int v31; // eax@85 - unsigned int v32; // ecx@88 - unsigned int v33; // eax@88 int v34; // esi@90 - unsigned int v35; // eax@91 int v36; // esi@93 - int v37; // edi@93 ItemGen *v38; // edi@93 - __int16 v39; // dx@99 ItemGen _this; // [sp+Ch] [bp-40h]@1 unsigned int v48; // [sp+30h] [bp-1Ch]@88 - unsigned int v49; // [sp+34h] [bp-18h]@57 unsigned int v50; // [sp+38h] [bp-14h]@50 int v51; // [sp+3Ch] [bp-10h]@1 int v52; // [sp+40h] [bp-Ch]@5 @@ -2367,12 +2343,9 @@ v51 = 0; _this.Reset(); - //v0 = pPlayers[uActiveCharacter]; v1 = pPlayers[uActiveCharacter]->pEquipment.uMainHand; v2 = pPlayers[uActiveCharacter]->pEquipment.uShield; - //v54 = pPlayers[uActiveCharacter]->pEquipment.uShield; - //v53 = v1; - if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItemList[v1 - 1]].uEquipType == 1 ) + if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItemList[v1 - 1]].uEquipType == EQUIP_MAIN_HAND ) v51 = v1; v3 = pParty->pPickedItem.uItemID; if ( pParty->pPickedItem.uItemID ) @@ -2396,15 +2369,15 @@ { if ( (pSkillType == 8 || pSkillType == 1 || pSkillType == 2) && v1 - && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItemList[v1-1]].uSkillType == 4 ) - { + && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItemList[v1 - 1]].uSkillType == 4 ) + { LOBYTE(v5) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_SPEAR); if ( (signed int)SkillToMastery(v5) < 3 ) { pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); return; } - } + } } if ( !pPlayers[uActiveCharacter]->CanEquip_RaceAndAlignmentCheck(v3) ) { @@ -2418,7 +2391,6 @@ WetsuitOn(uActiveCharacter); return; } - //v6 = v52; switch ( pEquipType ) { case EQUIP_BOW: @@ -2429,7 +2401,7 @@ case EQUIP_GAUNTLETS: case EQUIP_BOOTS: case EQUIP_AMULET: - if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) )//íåò íàâûêà { pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); return; @@ -2443,8 +2415,8 @@ if ( pParty->pPickedItem.uItemID == ITEM_WETSUIT ) WetsuitOff(uActiveCharacter); return; - - case EQUIP_RING://Êîëüöà +//------------------------dress rings(îäåâàíèå êîëåö)---------------------------------- + case EQUIP_RING: if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) { pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); @@ -2470,42 +2442,39 @@ } if ( v52 == 16 )//çàìåùåíèå ïîñëåäíåãî êîëüöà { - v52 = pPlayers[uActiveCharacter]->pEquipment.uRings[6] - 1; + v52 = pPlayers[uActiveCharacter]->pEquipment.uRings[5] - 1; memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v10 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v52); - *(char *)(v10 + 556) = 0; + pPlayers[uActiveCharacter]->pInventoryItemList[v52].uBodyAnchor = 0; pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v10 + 532)); + pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v52]); _this.uBodyAnchor = 16; - memcpy((void *)(v10 + 532), &_this, 0x24u); - pPlayers[uActiveCharacter]->pEquipment.uRings[6] = v52 + 1; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v52], &_this, 0x24u); + pPlayers[uActiveCharacter]->pEquipment.uRings[5] = v52 + 1; } return; - +//------------------dress shield(îäåòü ùèò)------------------------------------------------------ case EQUIP_SHIELD://Ùèò - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) + if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) )//â àêâàëàíãå { pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; } - if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) )//íåò íàâûêà { pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); return; } - if ( v2 ) + if ( v2 )//ñìåíà ùèòà ùèòîì { --v2; memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v12 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2); - *(char *)(v12 + 556) = 0; + pPlayers[uActiveCharacter]->pInventoryItemList[v2].uBodyAnchor = 0; pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v12 + 532)); + pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v2]); _this.uBodyAnchor = 1; - v14 = v51 == 0; - memcpy((void *)(v12 + 532), &_this, 0x24u); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v2], &_this, 0x24u); pPlayers[uActiveCharacter]->pEquipment.uShield = v2 + 1; - if ( v14 ) + if ( v51 == EQUIP_OFF_HAND ) return; } else @@ -2513,26 +2482,27 @@ v52 = pPlayers[uActiveCharacter]->FindFreeInventoryListSlot(); if ( v52 < 0 ) return; - if ( !v51 ) + if ( !v51 )// îáû÷íàÿ óñòàíîâêà ùèòà íà ïóñòóþ ðóêó { pParty->pPickedItem.uBodyAnchor = 1; v17 = v52 + 1; memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v52])); pPlayers[uActiveCharacter]->pEquipment.uShield = v17; pMouse->RemoveHoldingItem(); - return; + return; } + v1--;//ñòàâèì ùèò êîãäà äåðæèò äâóðó÷íûé ìå÷ memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v15 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v1 - 1)); - *(char *)(v15 + 556) = 0; + pPlayers[uActiveCharacter]->pInventoryItemList[v1].uBodyAnchor = 0; pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v15 + 532)); + pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v1]); _this.uBodyAnchor = 1; memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v52])); pPlayers[uActiveCharacter]->pEquipment.uShield = v52 + 1; } pPlayers[uActiveCharacter]->pEquipment.uMainHand = 0; return; +//-------------------------taken in hand(âçÿòü â ðóêó)------------------------------------------- case EQUIP_OFF_HAND: case EQUIP_WAND: if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) @@ -2553,7 +2523,6 @@ { v18 = pMouse->uMouseClickX; v19 = pMouse->uMouseClickY; - v49 = v19; if ( (signed int)v18 >= 560 ) { if ( !v51 ) @@ -2562,19 +2531,16 @@ { --v2; memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v20 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2); - *(char *)(v20 + 556) = 0; + pPlayers[uActiveCharacter]->pInventoryItemList[v2].uBodyAnchor = 0; pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v20 + 532)); + pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v2]); _this.uBodyAnchor = 1; - v14 = pEquipType == EQUIP_WAND; - memcpy((void *)(v20 + 532), &_this, 0x24u); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v2], &_this, 0x24u); pPlayers[uActiveCharacter]->pEquipment.uShield = v2 + 1; - if ( !v14 ) + if ( pEquipType != EQUIP_WAND ) return; - v22 = _this.uItemID; - v50 = v22; - if ( v50 ) + v50 = _this.uItemID; + if ( _this.uItemID ) { __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); @@ -2589,7 +2555,7 @@ memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v23], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v23])); pPlayers[uActiveCharacter]->pEquipment.uShield = v23 + 1; pMouse->RemoveHoldingItem(); - if ( pEquipType != 12 ) + if ( pEquipType != EQUIP_WAND ) return; v22 = *(int *)v50; v50 = v22; @@ -2612,7 +2578,7 @@ memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v26], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v26])); pPlayers[uActiveCharacter]->pEquipment.uMainHand = v26 + 1; pMouse->RemoveHoldingItem(); - if ( pEquipType != 12 ) + if ( pEquipType != EQUIP_WAND ) return; v22 = *(int *)v50; v50 = v22; @@ -2625,103 +2591,92 @@ } --v1; memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v24 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1); - *(char *)(v24 + 556) = 0; + pPlayers[uActiveCharacter]->pInventoryItemList[v1].uBodyAnchor = 0; pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v24 + 532)); + pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v1]); _this.uBodyAnchor = 2; - v25 = v1 + 1; - v14 = pEquipType == 12; - memcpy((void *)(v24 + 532), &_this, 0x24u); - pPlayers[uActiveCharacter]->pEquipment.uMainHand = v25; - if ( v14 ) + memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v1], &_this, 0x24u); + pPlayers[uActiveCharacter]->pEquipment.uMainHand = v1 + 1; + if ( pEquipType == EQUIP_WAND ) v50 = _this.uItemID; if ( v51 ) pPlayers[uActiveCharacter]->pEquipment.uShield = 0; - if ( v50 ) + if ( v50 )//âçÿòü æåçë { __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 stru_A750F8[uActiveCharacter - 1]._494836( *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); } break; +//---------------------------take two hands(âçÿòü äâóìÿ ðóêàìè)--------------------------------- case EQUIP_MAIN_HAND: if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) { pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); return; } - if ( v1 ) + if ( v1 )//âçÿòü äâóðó÷íûé ìå÷ êîäà íåò ùèòà(çàìåùåíèå îðóæèÿ) { if ( v2 ) { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; } --v1; memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v27 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1); - *(char *)(v27 + 556) = 0; + pPlayers[uActiveCharacter]->pInventoryItemList[v1].uBodyAnchor = 0; pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v27 + 532)); + pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v1]); _this.uBodyAnchor = 2; - v28 = v1 + 1; - memcpy((void *)(v27 + 532), &_this, 0x24u); - pPlayers[uActiveCharacter]->pEquipment.uMainHand = v28; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v1], &_this, 0x24u); + pPlayers[uActiveCharacter]->pEquipment.uMainHand = v1 + 1; } else { v52 = pPlayers[uActiveCharacter]->FindFreeInventoryListSlot(); if ( v52 >= 0 ) { - if ( v2 ) + if ( v2 )//âçÿòü äâóðó÷íûé ìå÷ êîäà åñòü ùèò(çàìåùåíèå ùèòîì) { + v2--; memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v29 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v2 - 1)); - *(char *)(v29 + 556) = 0; + pPlayers[uActiveCharacter]->pInventoryItemList[v2].uBodyAnchor = 0; pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v29 + 532)); + pParty->SetHoldingItem(&pPlayers[uActiveCharacter]->pInventoryItemList[v2]); _this.uBodyAnchor = 2; - v30 = v52 + 1; memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v52])); pPlayers[uActiveCharacter]->pEquipment.uShield = 0; - pPlayers[uActiveCharacter]->pEquipment.uMainHand = v30; + pPlayers[uActiveCharacter]->pEquipment.uMainHand = v52 + 1; } else { pParty->pPickedItem.uBodyAnchor = 2; - v31 = v52 + 1; memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v52])); - pPlayers[uActiveCharacter]->pEquipment.uMainHand = v31; + pPlayers[uActiveCharacter]->pEquipment.uMainHand = v52 + 1; pMouse->RemoveHoldingItem(); } } } return; +//------------------------------------------------------------------------------- default: - pPlayers[uActiveCharacter]->UseItem_DrinkPotion_etc(uActiveCharacter, 0); + pPlayers[uActiveCharacter]->UseItem_DrinkPotion_etc(uActiveCharacter, 0);//âûïèòü íàïèòîê è äð. return; } return; } - v32 = pMouse->uMouseClickX; - v33 = pMouse->uMouseClickY; - - v34 = pRenderer->pActiveZBuffer[v32 + pSRZBufferLineOffsets[v33]] & 0xFFFF; + v34 = pRenderer->pActiveZBuffer[pMouse->uMouseClickX + pSRZBufferLineOffsets[pMouse->uMouseClickY]] & 0xFFFF; if ( v34 ) { v36 = v34 - 1; - v37 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v36); - v50 = v37; - v38 = (ItemGen *)(v37 + 532); - v14 = v38->uItemID == ITEM_WETSUIT; + v38 = &pPlayers[uActiveCharacter]->pInventoryItemList[v36]; pEquipType = pItemsTable->pItems[v38->uItemID].uEquipType; - if ( v14 ) + if ( v38->uItemID == ITEM_WETSUIT ) { if ( bUnderwater ) { @@ -2730,13 +2685,12 @@ } WetsuitOff(uActiveCharacter); } - if ( unk_50C9A0 ) + if ( unk_50C9A0 )//íàëîæèòü çàêë íà ýêèïèðîâêó { - *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; + *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu;//CastSpellInfo *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; - v39 = pEquipType; *((int *)pGUIWindow_Settings->ptr_1C + 3) = v36; - *((short *)pGUIWindow_Settings->ptr_1C + 3) = v39; + *((short *)pGUIWindow_Settings->ptr_1C + 3) = pEquipType; ptr_50C9A4 = v38; unk_50C9A0 = 0; if ( pMessageQueue_50CBD0->uNumMessages ) @@ -2748,22 +2702,21 @@ } else { - if ( !ptr_50C9A4 ) + if ( !ptr_50C9A4 )//ñíÿòü âåùü { pParty->SetHoldingItem(v38); - *(&pPlayers[uActiveCharacter]->uBirthYear + *(char *)(v50 + 556)) = 0; + *(&pPlayers[uActiveCharacter]->uBirthYear + pPlayers[uActiveCharacter]->pInventoryItemList[v36].uBodyAnchor) = 0;// ýòî pPlayers[uActiveCharacter]->pEquipment[pPlayers[uActiveCharacter]->pInventoryItemList[v36].uBodyAnchor] v38->Reset(); } } } - else + else//ñíÿòü ëóê { - v35 = pPlayers[uActiveCharacter]->pEquipment.uBow; - if ( v35 ) + if ( pPlayers[uActiveCharacter]->pEquipment.uBow ) { - auto _a = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItemList[v35 - 1]; - pParty->SetHoldingItem(_a); - _a->Reset(); + _this = pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->pEquipment.uBow - 1]; + pParty->SetHoldingItem(&_this); + _this.Reset(); pPlayers[uActiveCharacter]->pEquipment.uBow = 0; } } diff -r 86cb7398d2a8 -r 7d986a396092 UI/UIGuilds.cpp --- a/UI/UIGuilds.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/UI/UIGuilds.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -40,7 +40,6 @@ int v26; // ecx@47 GUIButton *pButton; // eax@49 unsigned int v29; // eax@49 - char *pText; // eax@52 int pTextHeight; // eax@55 unsigned int v32; // ecx@55 int v33; // eax@55 @@ -72,9 +71,10 @@ int v61; // [sp+2E0h] [bp-Ch]@35 int pItemNum; unsigned int v62; // [sp+2E4h] [bp-8h]@13 - int v63; // [sp+2E8h] [bp-4h]@1 + int pPrice; // [sp+2E8h] [bp-4h]@1 int pNumActivItem; int all_text_height; + int pX; memcpy(&working_window, window_SpeakInHouse, sizeof(GUIWindow)); working_window.uFrameX = 483; @@ -83,9 +83,9 @@ pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu); pColorYellow = TargetColor(0xFFu, 0xFFu, 0x9Bu); base_teach_price = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier * 500.0); - v63 = base_teach_price * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; - if ( v63 < base_teach_price / 3 ) - v63 = base_teach_price / 3; + pPrice = base_teach_price * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; + if ( pPrice < base_teach_price / 3 ) + pPrice = base_teach_price / 3; strcpy(Dest, ""); strcpy(v46, ""); strcpy(v47, ""); @@ -105,14 +105,14 @@ } else { - if ( pParty->uNumGold < v63 ) + if ( pParty->uNumGold < pPrice ) { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); //"You don't have enough gold" + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); //"You don't have enough gold" PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); } else { - Party::TakeGold(v63); + Party::TakeGold(pPrice); pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] = 1; } } @@ -123,45 +123,36 @@ pRenderer->DrawTextureIndexed(8, 8, ShopTexture); v6 = 0; v62 = 0; - v63 = 32; - do + for ( pX = 32; pX < 452; pX += 70 )//ðàñïîëîæåíèå â âåðõíåì ðÿäó { - if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v6].uItemID) + if ( pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v6].uItemID ) { - pRenderer->DrawTextureTransparent(v63, 0x5Au, ItemsInShopTexture[v6]); + pRenderer->DrawTextureTransparent(pX, 90, ItemsInShopTexture[v6]); ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 230528), ItemsInShopTexture[v6], v6 + 1); } - v63 += 70; v62 += 280; ++v6; } - while ( v63 < 452 ); v62 = 1680; v7 = 6; - v63 = 32; - do + for ( pX = 32; pX < 452; pX += 70 )//ðàñïîëîæåíèå â íèæíåì ðÿäó { if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v7].uItemID) { - pRenderer->DrawTextureTransparent(v63, 0xFAu, ItemsInShopTexture[v7]); + pRenderer->DrawTextureTransparent(pX, 250, ItemsInShopTexture[v7]); ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 638448), ItemsInShopTexture[v7], v7 + 1); } - v63 += 70; v62 += 280; ++v7; } - while ( v63 < 452 ); if ( HouseUI_CheckIfPlayerCanInteract() ) { v8 = 0; - v9 = 12; - do + for ( v9 = 12; v9; --v9 ) { - if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v9].uItemID ) + if ( pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v9].uItemID > 0 ) ++v8; - --v9; } - while ( v9 ); GetAsyncKeyState(17); statusbar_string = pGlobalTXT_LocalizationStrings[195]; //"Select the Item to Buy" if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) @@ -169,8 +160,7 @@ DrawTextAtStatusBar(statusbar_string, 0); if ( !v8 ) { - working_window.DrawCurrentTime(__PAIR__( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)window_SpeakInHouse->ptr_1C + 44472], - *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)window_SpeakInHouse->ptr_1C + 44468]) - pParty->uTimePlayed); + working_window.DrawCurrentTime(pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C] - pParty->uTimePlayed);//"Ïðèõîäèòå ÷åðåç 14 äíåé" return; } v12 = pMouse->GetCursorPos(&v51); @@ -183,7 +173,7 @@ v16 = (int)window_SpeakInHouse->ptr_1C; uPlayerID = uActiveCharacter - 1; v17 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, BuildingType_MagicShop, v16, 2); - v18 = BuildDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0); + v18 = BuildDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0); v19 = pFontArrus->CalcTextHeight(v18, &working_window, 0, 0); working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138, pColorWhite, v18, 3); return; @@ -195,7 +185,7 @@ guild_mambership_flags[(unsigned int)window_SpeakInHouse->ptr_1C-139]) ) { //you must me member v38 = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &working_window, 0, 0); - working_window.DrawTitleText(pFontArrus, 0, (212 - v38) / 2 + 101, pColorYellow, pNPCTopics[121].pText, 3u); + working_window.DrawTitleText(pFontArrus, 0, (212 - v38) / 2 + 101, pColorYellow, pNPCTopics[121].pText, 3); pDialogueWindow->pNumPresenceButton = 0; return; } @@ -248,7 +238,7 @@ } if ( pSkillFlag ) { - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v63); //"Skill Cost: %lu" + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pPrice); //"Skill Cost: %lu" working_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); } v58 = (149 - all_text_height) / v61; @@ -265,9 +255,8 @@ v29 = pButton->msg_param; if ( v29 == 18 ) { - pText = pGlobalTXT_LocalizationStrings[400]; //"Buy Spells" pButton->uY = v58 + v26; - pTextHeight = pFontArrus->CalcTextHeight(pText, &working_window, 0, 0); + pTextHeight = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[400], &working_window, 0, 0); v32 = pButton->uY; pButton->uHeight = pTextHeight; v33 = v32 + pTextHeight - 1; @@ -276,7 +265,7 @@ pTextColor = pColorYellow; if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) pTextColor = pColorWhite; - working_window.DrawTitleText(pFontArrus, 0, v32, pTextColor, pText, 3); + working_window.DrawTitleText(pFontArrus, 0, v32, pTextColor, pGlobalTXT_LocalizationStrings[400], 3);//"Buy Spells" } else { diff -r 86cb7398d2a8 -r 7d986a396092 UI/UIHouses.cpp --- a/UI/UIHouses.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/UI/UIHouses.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -109,10 +109,6 @@ {255, 255, 255, 255} // HOUSE_BOATS_73 }; - - - - std::array pAnimatedRooms = //0x4E5F70 {{ {"", 0x4, 0x1F4, 0, 0, 0}, @@ -326,7 +322,7 @@ num_buttons = 2; CreateButtonInColumn(0, 102); CreateButtonInColumn(1, 103); - if ( pParty->HasItem(651) ) //Arcomage Deck + if ( pParty->HasItem(651) ) //Arcomage Deck { num_buttons = 3; CreateButtonInColumn(2, 104); @@ -369,24 +365,6 @@ //----- (004B3B42) -------------------------------------------------------- void InitializaDialogueOptions(BuildingType type) { - /*int v1; // ecx@18 - int v2; // ecx@19 - int v3; // ecx@20 - signed int v4; // esi@22 - signed int v5; // eax@22 - unsigned int v6; // edx@24 - int v7; // ecx@24 - int result; // eax@43 - int v9; // [sp-10h] [bp-14h]@28 - int v10; // [sp-Ch] [bp-10h]@28 - int v11; // [sp-8h] [bp-Ch]@28 - unsigned int v12; // [sp-4h] [bp-8h]@4 - unsigned int v13; // [sp-4h] [bp-8h]@5 - unsigned int v14; // [sp-4h] [bp-8h]@9 - unsigned int v15; // [sp-4h] [bp-8h]@10 - unsigned int v16; // [sp-4h] [bp-8h]@14 - int v17; // [sp-4h] [bp-8h]@28*/ - switch (type) { case BuildingType_WeaponShop: @@ -764,39 +742,30 @@ //----- (004B1784) -------------------------------------------------------- bool HouseUI_CheckIfPlayerCanInteract() { - Player *pPlayer; // ebx@1 - bool result; // eax@2 - int v3; // eax@3 - GUIWindow v4; // [sp+4h] [bp-54h]@3 + GUIWindow window; // [sp+4h] [bp-54h]@3 - pPlayer = pPlayers[uActiveCharacter]; - if ( pPlayer->CanAct() ) + if ( pPlayers[uActiveCharacter]->CanAct() ) { pDialogueWindow->pNumPresenceButton = dword_F8B1E0; - result = 1; + return true; } else { pDialogueWindow->pNumPresenceButton = 0; - memcpy(&v4, pPrimaryWindow, sizeof(v4)); - v4.uFrameX = 483; - v4.uFrameWidth = 148; - v4.uFrameZ = 334; - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[427], pPlayer->pName, pGlobalTXT_LocalizationStrings[562]);// - // "%s is in no condition to %s" - // "do anything" - v3 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &v4, 0, 0); - v4.DrawTitleText(pFontArrus, 0, (212 - v3) / 2 + 101, ui_house_player_cant_interact_color, pTmpBuf.data(), 3u); - result = 0; + memcpy(&window, pPrimaryWindow, sizeof(window)); + window.uFrameX = 483; + window.uFrameWidth = 148; + window.uFrameZ = 334; + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[427], pPlayers[uActiveCharacter]->pName, + pGlobalTXT_LocalizationStrings[562]); // "%s is in no condition to %s""do anything" + window.DrawTitleText(pFontArrus, 0, (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &window, 0, 0)) / 2 + 101, ui_house_player_cant_interact_color, pTmpBuf.data(), 3); + return false; } - return result; } //----- (0044622E) -------------------------------------------------------- bool EnterHouse(enum HOUSE_ID uHouseID) { - //enum HOUSE_ID v1; // edi@1 - //int v2; // edi@5 signed int uOpenTime; // eax@5 signed int uCloseTime; // esi@5 unsigned int v5; // esi@5 @@ -804,27 +773,18 @@ signed int am_pm_flag_open; // ecx@10 signed int am_pm_flag_close; // eax@10 int v9; // esi@10 - //unsigned int v10; // esi@16 int v11; // ecx@17 unsigned int v12; // kr00_4@25 - //Player *v13; // esi@25 int v14; // eax@25 - //Player *v15; // esi@27 - //signed int v16; // eax@32 unsigned int v17; // eax@37 signed int v18; // edi@37 signed int v19; // edi@41 - //unsigned int v20; // ecx@41 - //const char *v22; // [sp-4h] [bp-40h]@33 char pContainer[40]; // [sp+Ch] [bp-30h]@32 unsigned int v24; // [sp+34h] [bp-8h]@5 - //enum HOUSE_ID v25; // [sp+38h] [bp-4h]@1 - //v1 = uHouseID; - //v25 = uHouseID; GameUI_Footer_TimedString[0] = 0; pFooterString[0] = 0; - ShowStatusBarString("", 2u); + ShowStatusBarString("", 2); if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; viewparams->bRedrawGameUI = 1; @@ -952,25 +912,11 @@ //----- (0044606A) -------------------------------------------------------- void PrepareHouse(HOUSE_ID house) { - //unsigned int v1; // ebx@1 - //signed int v2; // esi@1 - //int uExitPic; // edi@1 __int16 uExitMapID; // ax@2 - //int result; // eax@5 - //unsigned int *v6; // ecx@8 int v7; // ebx@11 - //int v8; // esi@16 - //unsigned int v9; // eax@16 - //unsigned int v10; // eax@19 - //int v11; // ecx@19 - //char pContainer[36]; // [sp+Ch] [bp-54h]@16 int v13; // [sp+30h] [bp-30h]@11 int npc_id_arr[6]; // [sp+34h] [bp-2Ch]@1 - //unsigned int v15; // [sp+4Ch] [bp-14h]@1 int uAnimationID; // [sp+50h] [bp-10h]@1 - //unsigned int *v17; // [sp+54h] [bp-Ch]@3 - //unsigned int v18; // [sp+58h] [bp-8h]@1 - //int v19; // [sp+5Ch] [bp-4h]@7 uAnimationID = p2DEvents[house - 1].uAnimationID; @@ -1041,21 +987,9 @@ //----- (004BCACC) -------------------------------------------------------- void __fastcall OnSelectShopDialogueOption(signed int uMessageParam) { - //unsigned int v1; // edi@1 - //signed int v2; // ebx@1 - //signed int v3; // ecx@2 - int v4; // eax@5 - signed int v5; // esi@5 - //Player *v6; // ecx@5 - //signed int v7; // edx@5 + int experience_for_next_level; // eax@5 GUIWindow *v8; // esi@10 - unsigned int v9; // eax@12 - int v10; // esi@31 - int v11; // edi@31 - int v12; // esi@32 - __int16 v13; // bp@32 - int v14; // edx@32 - GUIWindow *v15; // eax@32 + //int v11; // edi@31 int v16; // eax@32 int v17; // eax@33 int v18; // eax@34 @@ -1065,24 +999,13 @@ __int16 v22; // ax@107 __int16 v23; // ax@132 __int16 v24; // ax@163 - int v25; // esi@190 - __int16 v26; // ax@190 - char v27; // zf@190 - Player *v28; // edi@192 - int v29; // eax@204 - void *v30; // esi@208 - unsigned __int64 v31; // qax@208 - signed int v32; // edi@209 - int v33; // eax@210 unsigned int v34; // eax@211 - //Player *v35; // edi@227 signed int v36; // esi@227 int v37; // ecx@227 int v38; // esi@230 int v39; // edx@235 int v40; // edi@243 unsigned __int64 v41; // qax@243 - //void *v42; // eax@244 signed int v43; // edi@244 int v44; // edx@244 int v45; // eax@246 @@ -1095,83 +1018,62 @@ void *v52; // eax@260 signed int v53; // edi@260 int v54; // eax@262 - //signed int v55; // [sp+10h] [bp-10h]@1 - int v56; // [sp+14h] [bp-Ch]@31 - //v1 = 0; - //v2 = a1; - //v55 = a1; if ( !pDialogueWindow->pNumPresenceButton ) return; pRenderer->ClearZBuffer(0, 479); - //v3 = dword_F8B198; if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN) v8 = window_SpeakInHouse; - //else if (dialog_menu_id == HOUSE_DIALOGUE_MAIN) { - if ( in_current_building_type == BuildingType_Training ) - { - if ( uMessageParam == HOUSE_DIALOGUE_TRAININGHALL_TRAIN ) - { - v4 = 0; - v5 = 0; - //v6 = pPlayers[uActiveCharacter]; - //v7 = pPlayers[uActiveCharacter]->uLevel; - if ( pPlayers[uActiveCharacter]->uLevel > 0 ) - { - do - v4 += v5++ + 1; - while ( v5 < pPlayers[uActiveCharacter]->uLevel ); - } - if (pPlayers[uActiveCharacter]->uLevel < pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - 89] && - (signed __int64)pPlayers[uActiveCharacter]->uExperience < 1000 * v4) - return; - } - pDialogueWindow->Release(); - pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0); - pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation" - pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0); - pDialogueWindow->CreateButton(8, 8, 0x1C2, 0x140, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr); -// LABEL_10: - //v3 = dword_F8B198; - v8 = window_SpeakInHouse; - } - //else - if ( in_current_building_type != BuildingType_Training ) - { - v8 = window_SpeakInHouse; - if ((in_current_building_type == BuildingType_Stables || in_current_building_type == BuildingType_Boats) && - transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][uMessageParam - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]].pSchedule[pParty->uDaysPlayed % 7] - || in_current_building_type != BuildingType_Temple || uMessageParam != BuildingType_MindGuild ) - { - //LABEL_9: - pDialogueWindow->Release(); - pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0); - pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation" - pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0); - pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr); - // LABEL_10: - //v3 = dword_F8B198; - v8 = window_SpeakInHouse; - } - else if (uActiveCharacter) - { - if ( !pPlayers[uActiveCharacter]->IsPlayerHealableByTemple() ) - return; - v8 = window_SpeakInHouse; - } - } - //LABEL_11: - dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam; - if ( in_current_building_type < BuildingType_19 ) - { - v9 = pIcons_LOD->LoadTexture(off_4F03B8[(int)in_current_building_type], TEXTURE_16BIT_PALETTE); - //v3 = dword_F8B198; - ShopTexture = &pIcons_LOD->pTextures[v9]; - //LABEL_13: - v8 = window_SpeakInHouse; - } + if ( in_current_building_type == BuildingType_Training ) + { + if ( uMessageParam == HOUSE_DIALOGUE_TRAININGHALL_TRAIN ) + { + experience_for_next_level = 0; + if ( pPlayers[uActiveCharacter]->uLevel > 0 ) + { + for( uint i = 0; i < pPlayers[uActiveCharacter]->uLevel; i++ ) + experience_for_next_level += i + 1; + } + if (pPlayers[uActiveCharacter]->uLevel < pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - 89] && + (signed __int64)pPlayers[uActiveCharacter]->uExperience < 1000 * experience_for_next_level)//test experience + return; + } + pDialogueWindow->Release(); + pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0); + pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation" + pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0); + pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr); + v8 = window_SpeakInHouse; + } + if ( in_current_building_type != BuildingType_Training ) + { + v8 = window_SpeakInHouse; + if ((in_current_building_type == BuildingType_Stables || in_current_building_type == BuildingType_Boats) && + transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][uMessageParam - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]].pSchedule[pParty->uDaysPlayed % 7] + || in_current_building_type != BuildingType_Temple || uMessageParam != BuildingType_MindGuild ) + { + pDialogueWindow->Release(); + pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0); + pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation" + pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0); + pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr); + v8 = window_SpeakInHouse; + } + else if (uActiveCharacter) + { + if ( !pPlayers[uActiveCharacter]->IsPlayerHealableByTemple() ) + return; + v8 = window_SpeakInHouse; + } + } + dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam; + if ( in_current_building_type < BuildingType_19 ) + { + ShopTexture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(off_4F03B8[(int)in_current_building_type], TEXTURE_16BIT_PALETTE)]; + v8 = window_SpeakInHouse; + } } //NEW @@ -1190,243 +1092,190 @@ case BuildingType_15: case BuildingType_16: { - if ( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472] >= (signed __int64)pParty->uTimePlayed && - *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44468] >= (signed __int64)pParty->uTimePlayed ) + if ( pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C] >= (signed __int64)pParty->uTimePlayed ) { - v32 = 0; - do + for ( uint i = 0; i < 12; ++i ) { - //v33 = *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v32 + 12 * (unsigned int)v8->ptr_1C)); - v33 = pParty->SpellBooksInGuilds[v8->par1C-139][v32].uItemID; - if ( v33 ) + if ( pParty->SpellBooksInGuilds[v8->par1C-139][i].uItemID ) { - v34 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v33].pIconName, TEXTURE_16BIT_PALETTE); + v34 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->SpellBooksInGuilds[v8->par1C-139][i].uItemID].pIconName, TEXTURE_16BIT_PALETTE); v8 = window_SpeakInHouse; - ItemsInShopTexture[v32] = &pIcons_LOD->pTextures[v34]; + ItemsInShopTexture[i] = &pIcons_LOD->pTextures[v34]; } - ++v32; } - while ( v32 < 12 ); } - else + else//generation new books { SpellBookGenerator(); - v30 = window_SpeakInHouse->ptr_1C; - v31 = pParty->uTimePlayed + (signed __int64)((double)(0xA8C000 - //* (signed int)p2DEvents_minus1[26 * (unsigned int)ptr_507BC0->ptr_1C]) + pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C] = pParty->uTimePlayed + (signed __int64)((double)(0xA8C000 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) * 0.033333335); - *(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44468] = v31; - *(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44472] = HIDWORD(v31); } - //return; break; } case BuildingType_TownHall: { - if ( uMessageParam == 99 ) + if ( uMessageParam == HOUSE_DIALOGUE_TOWNHALL_MESSAGE ) { - v10 = (int)((char *)v8->ptr_1C - 102); - v56 = v10; - v11 = 8 * v10 + 11325428; - if ( pParty->field_3C.field_0[2 * v10 + 1] >= (signed __int64)pParty->uTimePlayed - && pParty->field_3C.field_0[2 * v10] >= (signed __int64)pParty->uTimePlayed ) + if ( pParty->field_3C.bountyHunting_next_generation_time[(int)((char *)v8->ptr_1C - 102)] < (signed __int64)pParty->uTimePlayed )//new generation { - v13 = 0; + pParty->monster_for_hunting_killed[(int)((char *)v8->ptr_1C - 102)] = false; + pParty->field_3C.bountyHunting_next_generation_time[(int)((char *)v8->ptr_1C - 102)] = (signed __int64)((double)(309657600 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) * 0.033333335); + pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1; + v16 = (int)((char *)window_SpeakInHouse->ptr_1C - 102); + if ( !v16 ) + { + while ( 1 ) + { + v24 = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)]; + if ( (unsigned __int16)v24 < 115 || (unsigned __int16)v24 > 132 ) + { + if ( ((unsigned __int16)v24 < 235 || (unsigned __int16)v24 > 252) + && ((unsigned __int16)v24 < 133 || (unsigned __int16)v24 > 150) + && ((unsigned __int16)v24 < 0x97u || (unsigned __int16)v24 > 0xBAu) + && ((unsigned __int16)v24 < 0xBEu || (unsigned __int16)v24 > 0xC0u) + && ((unsigned __int16)v24 < 0xC4u || (unsigned __int16)v24 > 0xC6u) + && ((unsigned __int16)v24 < 0x2Bu || (unsigned __int16)v24 > 0x2Du) + && ((unsigned __int16)v24 < 0xCDu || (unsigned __int16)v24 > 0xCFu) + && ((unsigned __int16)v24 < 0x5Eu || (unsigned __int16)v24 > 0x60u) + && ((unsigned __int16)v24 < 0xFDu || (unsigned __int16)v24 > 0xFFu) + && ((unsigned __int16)v24 < 0x6Du || (unsigned __int16)v24 > 0x6Fu) + && ((unsigned __int16)v24 < 0x61u || (unsigned __int16)v24 > 0x63u) ) + break; + } + pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1; + } + } + if ( v16 == 1 ) + { + while ( 1 ) + { + v23 = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)]; + if ( (unsigned __int16)v23 < 115 || (unsigned __int16)v23 > 132 ) + { + if ( ((unsigned __int16)v23 < 0xE8u || (unsigned __int16)v23 > 0xF9u) + && ((unsigned __int16)v23 < 0x85u || (unsigned __int16)v23 > 0x96u) + && ((unsigned __int16)v23 < 0x97u || (unsigned __int16)v23 > 0xBAu) + && ((unsigned __int16)v23 < 0xBEu || (unsigned __int16)v23 > 0xC0u) + && ((unsigned __int16)v23 < 0xC4u || (unsigned __int16)v23 > 0xC6u) + && ((unsigned __int16)v23 < 0x2Bu || (unsigned __int16)v23 > 0x2Du) + && ((unsigned __int16)v23 < 0x52u || (unsigned __int16)v23 > 0x54u) + && ((unsigned __int16)v23 < 4 || (unsigned __int16)v23 > 6) + && ((unsigned __int16)v23 < 0x37u || (unsigned __int16)v23 > 0x39u) + && ((unsigned __int16)v23 < 0x3Au || (unsigned __int16)v23 > 0x3Cu) + && ((unsigned __int16)v23 < 0x3Du || (unsigned __int16)v23 > 0x3Fu) + && ((unsigned __int16)v23 < 0xFDu || (unsigned __int16)v23 > 0xFFu) + && ((unsigned __int16)v23 < 0x61u || (unsigned __int16)v23 > 0x63u) + && ((unsigned __int16)v23 < 0xCDu || (unsigned __int16)v23 > 0xCFu) ) + break; + } + pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1; + } + } + if ( v16 == 2 ) + { + while ( 1 ) + { + v22 = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)]; + if ( (unsigned __int16)v22 < 0x73u || (unsigned __int16)v22 > 0x84u ) + { + if ( ((unsigned __int16)v22 < 0xE8u || (unsigned __int16)v22 > 0xF9u) + && ((unsigned __int16)v22 < 0x85u || (unsigned __int16)v22 > 0x96u) + && ((unsigned __int16)v22 < 0x97u || (unsigned __int16)v22 > 0xBAu) + && ((unsigned __int16)v22 < 0xBEu || (unsigned __int16)v22 > 0xC0u) + && ((unsigned __int16)v22 < 0xC4u || (unsigned __int16)v22 > 0xC6u) + && ((unsigned __int16)v22 < 0x2Bu || (unsigned __int16)v22 > 0x2Du) + && ((unsigned __int16)v22 < 0x31u || (unsigned __int16)v22 > 0x33u) + && ((unsigned __int16)v22 < 0x34u || (unsigned __int16)v22 > 0x36u) + && ((unsigned __int16)v22 < 0xFDu || (unsigned __int16)v22 > 0xFFu) + && ((unsigned __int16)v22 < 0x61u || (unsigned __int16)v22 > 0x63u) + && ((unsigned __int16)v22 < 0x1Cu || (unsigned __int16)v22 > 0x1Eu) ) + break; + } + pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1; + } + } + if ( v16 == 3 ) + { + while ( 1 ) + { + v21 = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)]; + if ( (unsigned __int16)v21 < 0x73u || (unsigned __int16)v21 > 0x84u ) + { + if ( ((unsigned __int16)v21 < 0xE8u || (unsigned __int16)v21 > 0xF9u) + && ((unsigned __int16)v21 < 0x85u || (unsigned __int16)v21 > 0x96u) + && ((unsigned __int16)v21 < 0x97u || (unsigned __int16)v21 > 0xBAu) + && ((unsigned __int16)v21 < 0xBEu || (unsigned __int16)v21 > 0xC0u) + && ((unsigned __int16)v21 < 0xC4u || (unsigned __int16)v21 > 0xC6u) + && ((unsigned __int16)v21 < 0x2Bu || (unsigned __int16)v21 > 0x2Du) + && ((unsigned __int16)v21 < 0x5Eu || (unsigned __int16)v21 > 0x60u) + && ((unsigned __int16)v21 < 0x43u || (unsigned __int16)v21 > 0x45u) + && ((unsigned __int16)v21 < 0x4Fu || (unsigned __int16)v21 > 0x51u) + && ((unsigned __int16)v21 < 0xC1u || (unsigned __int16)v21 > 0xC3u) + && ((unsigned __int16)v21 < 0x13u || (unsigned __int16)v21 > 0x15u) + && ((unsigned __int16)v21 < 0xFDu || (unsigned __int16)v21 > 0xFFu) + && ((unsigned __int16)v21 < 0x61u || (unsigned __int16)v21 > 0x63u) + && ((unsigned __int16)v21 < 0x6Au || (unsigned __int16)v21 > 0x6Cu) ) + break; + } + pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1; + } + } + if ( v16 == 4 ) + { + while ( 1 ) + { + v20 = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)]; + if ( (unsigned __int16)v20 < 0x73u || (unsigned __int16)v20 > 0x84u ) + { + if ( ((unsigned __int16)v20 < 0xE8u || (unsigned __int16)v20 > 0xF9u) + && ((unsigned __int16)v20 < 0x85u || (unsigned __int16)v20 > 0x96u) + && ((unsigned __int16)v20 < 0x97u || (unsigned __int16)v20 > 0xBAu) + && ((unsigned __int16)v20 < 0xBEu || (unsigned __int16)v20 > 0xC0u) + && ((unsigned __int16)v20 < 0xC4u || (unsigned __int16)v20 > 0xC6u) + && ((unsigned __int16)v20 < 0x2Bu || (unsigned __int16)v20 > 0x2Du) + && ((unsigned __int16)v20 < 0x6Du || (unsigned __int16)v20 > 0x6Fu) + && ((unsigned __int16)v20 < 0x46u || (unsigned __int16)v20 > 0x48u) + && ((unsigned __int16)v20 < 0x100u || (unsigned __int16)v20 > 0x102u) + && ((unsigned __int16)v20 < 0xD9u || (unsigned __int16)v20 > 0xDBu) + && ((unsigned __int16)v20 < 0xC7u || (unsigned __int16)v20 > 0xC9u) + && ((unsigned __int16)v20 < 0xE5u || (unsigned __int16)v20 > 0xE7u) + && ((unsigned __int16)v20 < 0xDFu || (unsigned __int16)v20 > 0xE1u) + && ((unsigned __int16)v20 < 0x5Bu || (unsigned __int16)v20 > 0x5Du) + && ((unsigned __int16)v20 < 0x49u || (unsigned __int16)v20 > 0x4Bu) + && ((unsigned __int16)v20 < 0xFDu || (unsigned __int16)v20 > 0xFFu) + && ((unsigned __int16)v20 < 0x61u || (unsigned __int16)v20 > 0x63u) + && ((unsigned __int16)v20 < 0x10u || (unsigned __int16)v20 > 0x12u) ) + break; + } + pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = rand() % 258 + 1; + } + } + } + bountyHunting_monster_id_for_hunting = pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)]; + if ( !pParty->monster_for_hunting_killed[(int)((char *)v8->ptr_1C - 102)] ) + { + bountyHunting_text = pNPCTopics[351].pText;//" ýòîì ìåñÿöó íàçíà÷åíà íàãðàäà çà ãîëîâó %s..." + if ( !pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] ) + bountyHunting_text = pNPCTopics[353].pText;//"Êîå êòî óæå ïðèõîäèë â ýòîì ìåñÿöå çà íàãðàäîé" } else { - v12 = v10; - v13 = 0; - pParty->field_75A[v12] = 0; - *(_QWORD *)v11 = (signed __int64)((double)(309657600 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) * 0.033333335); - v14 = rand() % 258; - v15 = window_SpeakInHouse; - pParty->field_750[v12] = v14 + 1; - v16 = (int)((char *)v15->ptr_1C - 102); - if ( v16 ) + if ( pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] > 0 )//get prize { - v17 = v16 - 1; - if ( v17 ) - { - v18 = v17 - 1; - if ( v18 ) - { - v19 = v18 - 1; - if ( v19 ) - { - if ( v19 == 1 ) - { - while ( 1 ) - { - v20 = pParty->field_750[v12]; - if ( (unsigned __int16)v20 < 0x73u || (unsigned __int16)v20 > 0x84u ) - { - if ( ((unsigned __int16)v20 < 0xE8u || (unsigned __int16)v20 > 0xF9u) - && ((unsigned __int16)v20 < 0x85u || (unsigned __int16)v20 > 0x96u) - && ((unsigned __int16)v20 < 0x97u || (unsigned __int16)v20 > 0xBAu) - && ((unsigned __int16)v20 < 0xBEu || (unsigned __int16)v20 > 0xC0u) - && ((unsigned __int16)v20 < 0xC4u || (unsigned __int16)v20 > 0xC6u) - && ((unsigned __int16)v20 < 0x2Bu || (unsigned __int16)v20 > 0x2Du) - && ((unsigned __int16)v20 < 0x6Du || (unsigned __int16)v20 > 0x6Fu) - && ((unsigned __int16)v20 < 0x46u || (unsigned __int16)v20 > 0x48u) - && ((unsigned __int16)v20 < 0x100u || (unsigned __int16)v20 > 0x102u) - && ((unsigned __int16)v20 < 0xD9u || (unsigned __int16)v20 > 0xDBu) - && ((unsigned __int16)v20 < 0xC7u || (unsigned __int16)v20 > 0xC9u) - && ((unsigned __int16)v20 < 0xE5u || (unsigned __int16)v20 > 0xE7u) - && ((unsigned __int16)v20 < 0xDFu || (unsigned __int16)v20 > 0xE1u) - && ((unsigned __int16)v20 < 0x5Bu || (unsigned __int16)v20 > 0x5Du) - && ((unsigned __int16)v20 < 0x49u || (unsigned __int16)v20 > 0x4Bu) - && ((unsigned __int16)v20 < 0xFDu || (unsigned __int16)v20 > 0xFFu) - && ((unsigned __int16)v20 < 0x61u || (unsigned __int16)v20 > 0x63u) - && ((unsigned __int16)v20 < 0x10u || (unsigned __int16)v20 > 0x12u) ) - break; - } - pParty->field_750[v12] = rand() % 258 + 1; - } - } - } - else - { - while ( 1 ) - { - v21 = pParty->field_750[v12]; - if ( (unsigned __int16)v21 < 0x73u || (unsigned __int16)v21 > 0x84u ) - { - if ( ((unsigned __int16)v21 < 0xE8u || (unsigned __int16)v21 > 0xF9u) - && ((unsigned __int16)v21 < 0x85u || (unsigned __int16)v21 > 0x96u) - && ((unsigned __int16)v21 < 0x97u || (unsigned __int16)v21 > 0xBAu) - && ((unsigned __int16)v21 < 0xBEu || (unsigned __int16)v21 > 0xC0u) - && ((unsigned __int16)v21 < 0xC4u || (unsigned __int16)v21 > 0xC6u) - && ((unsigned __int16)v21 < 0x2Bu || (unsigned __int16)v21 > 0x2Du) - && ((unsigned __int16)v21 < 0x5Eu || (unsigned __int16)v21 > 0x60u) - && ((unsigned __int16)v21 < 0x43u || (unsigned __int16)v21 > 0x45u) - && ((unsigned __int16)v21 < 0x4Fu || (unsigned __int16)v21 > 0x51u) - && ((unsigned __int16)v21 < 0xC1u || (unsigned __int16)v21 > 0xC3u) - && ((unsigned __int16)v21 < 0x13u || (unsigned __int16)v21 > 0x15u) - && ((unsigned __int16)v21 < 0xFDu || (unsigned __int16)v21 > 0xFFu) - && ((unsigned __int16)v21 < 0x61u || (unsigned __int16)v21 > 0x63u) - && ((unsigned __int16)v21 < 0x6Au || (unsigned __int16)v21 > 0x6Cu) ) - break; - } - pParty->field_750[v12] = rand() % 258 + 1; - } - } - } - else - { - while ( 1 ) - { - v22 = pParty->field_750[v12]; - if ( (unsigned __int16)v22 < 0x73u || (unsigned __int16)v22 > 0x84u ) - { - if ( ((unsigned __int16)v22 < 0xE8u || (unsigned __int16)v22 > 0xF9u) - && ((unsigned __int16)v22 < 0x85u || (unsigned __int16)v22 > 0x96u) - && ((unsigned __int16)v22 < 0x97u || (unsigned __int16)v22 > 0xBAu) - && ((unsigned __int16)v22 < 0xBEu || (unsigned __int16)v22 > 0xC0u) - && ((unsigned __int16)v22 < 0xC4u || (unsigned __int16)v22 > 0xC6u) - && ((unsigned __int16)v22 < 0x2Bu || (unsigned __int16)v22 > 0x2Du) - && ((unsigned __int16)v22 < 0x31u || (unsigned __int16)v22 > 0x33u) - && ((unsigned __int16)v22 < 0x34u || (unsigned __int16)v22 > 0x36u) - && ((unsigned __int16)v22 < 0xFDu || (unsigned __int16)v22 > 0xFFu) - && ((unsigned __int16)v22 < 0x61u || (unsigned __int16)v22 > 0x63u) - && ((unsigned __int16)v22 < 0x1Cu || (unsigned __int16)v22 > 0x1Eu) ) - break; - } - pParty->field_750[v12] = rand() % 258 + 1; - } - } - } - else - { - while ( 1 ) - { - v23 = pParty->field_750[v12]; - if ( (unsigned __int16)v23 < 0x73u || (unsigned __int16)v23 > 0x84u ) - { - if ( ((unsigned __int16)v23 < 0xE8u || (unsigned __int16)v23 > 0xF9u) - && ((unsigned __int16)v23 < 0x85u || (unsigned __int16)v23 > 0x96u) - && ((unsigned __int16)v23 < 0x97u || (unsigned __int16)v23 > 0xBAu) - && ((unsigned __int16)v23 < 0xBEu || (unsigned __int16)v23 > 0xC0u) - && ((unsigned __int16)v23 < 0xC4u || (unsigned __int16)v23 > 0xC6u) - && ((unsigned __int16)v23 < 0x2Bu || (unsigned __int16)v23 > 0x2Du) - && ((unsigned __int16)v23 < 0x52u || (unsigned __int16)v23 > 0x54u) - && ((unsigned __int16)v23 < 4u || (unsigned __int16)v23 > 6u) - && ((unsigned __int16)v23 < 0x37u || (unsigned __int16)v23 > 0x39u) - && ((unsigned __int16)v23 < 0x3Au || (unsigned __int16)v23 > 0x3Cu) - && ((unsigned __int16)v23 < 0x3Du || (unsigned __int16)v23 > 0x3Fu) - && ((unsigned __int16)v23 < 0xFDu || (unsigned __int16)v23 > 0xFFu) - && ((unsigned __int16)v23 < 0x61u || (unsigned __int16)v23 > 0x63u) - && ((unsigned __int16)v23 < 0xCDu || (unsigned __int16)v23 > 0xCFu) ) - break; - } - pParty->field_750[v12] = rand() % 258 + 1; - } - } - } - else - { - while ( 1 ) - { - v24 = pParty->field_750[v12]; - if ( (unsigned __int16)v24 < 0x73u || (unsigned __int16)v24 > 0x84u ) - { - if ( ((unsigned __int16)v24 < 0xEBu || (unsigned __int16)v24 > 0xFCu) - && ((unsigned __int16)v24 < 0x85u || (unsigned __int16)v24 > 0x96u) - && ((unsigned __int16)v24 < 0x97u || (unsigned __int16)v24 > 0xBAu) - && ((unsigned __int16)v24 < 0xBEu || (unsigned __int16)v24 > 0xC0u) - && ((unsigned __int16)v24 < 0xC4u || (unsigned __int16)v24 > 0xC6u) - && ((unsigned __int16)v24 < 0x2Bu || (unsigned __int16)v24 > 0x2Du) - && ((unsigned __int16)v24 < 0xCDu || (unsigned __int16)v24 > 0xCFu) - && ((unsigned __int16)v24 < 0x5Eu || (unsigned __int16)v24 > 0x60u) - && ((unsigned __int16)v24 < 0xFDu || (unsigned __int16)v24 > 0xFFu) - && ((unsigned __int16)v24 < 0x6Du || (unsigned __int16)v24 > 0x6Fu) - && ((unsigned __int16)v24 < 0x61u || (unsigned __int16)v24 > 0x63u) ) - break; - } - pParty->field_750[v12] = rand() % 258 + 1; - } - } - v10 = v56; - } - v25 = v10; - v26 = pParty->field_750[v25]; - v27 = pParty->field_75A[v25] == v13; - word_F8B1A0 = pParty->field_750[v25]; - if ( v27 ) - { - //v1 = 0; - v27 = v26 == v13; - v29 = (int)pNPCTopics[351].pText; - if ( v27 ) - v29 = (int)pNPCTopics[353].pText; - dword_F8B1A4 = (char *)v29; - } - else - { - if ( v26 != v13 ) - { - party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)v26].uLevel, 0); - v28 = pParty->pPlayers; - do - { - v28->SetVariable(VAR_Award, 86); - ++v28; - } - while ( (signed int)v28 < (signed int)pParty->pHirelings ); - pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v25]].uLevel; - pParty->field_750[v25] = v13; - pParty->field_75A[v25] = v13; - } - //v1 = 0; - dword_F8B1A4 = pNPCTopics[352].pText; - } - } - else if ( uMessageParam == HOUSE_DIALOGUE_TOWNHALL_100 ) - { - pKeyActionMap->EnterText(1, 10, v8); - } - break; - } + party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)]].uLevel, 0); + for ( uint i = 0; i < 4; ++i ) + pParty->pPlayers[i].SetVariable(VAR_Award, 86); + pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)]].uLevel; + pParty->monster_id_for_hunting[(int)((char *)v8->ptr_1C - 102)] = 0; + pParty->monster_for_hunting_killed[(int)((char *)v8->ptr_1C - 102)] = false; + } + bountyHunting_text = pNPCTopics[352].pText;//"Ïîçäðàâëÿþ! Âû óñïåøíî..." + } + } + else if ( uMessageParam == HOUSE_DIALOGUE_TOWNHALL_PAY_FINE ) + pKeyActionMap->EnterText(1, 10, v8); + break; + } case BuildingType_Bank: { if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 ) @@ -1676,7 +1525,7 @@ v25 = v10; v26 = pParty->field_750[v25]; v27 = pParty->field_75A[v25] == v13; - word_F8B1A0 = pParty->field_750[v25]; + bountyHunting_monster_id_for_hunting = pParty->field_750[v25]; if ( v27 ) { //v1 = 0; @@ -1684,7 +1533,7 @@ v29 = (int)pNPCTopics[351].pText; if ( v27 ) v29 = (int)pNPCTopics[353].pText; - dword_F8B1A4 = (char *)v29; + bountyHunting_text = (char *)v29; } else { @@ -1703,7 +1552,7 @@ pParty->field_75A[v25] = v13; } //v1 = 0; - dword_F8B1A4 = pNPCTopics[352].pText; + bountyHunting_text = pNPCTopics[352].pText; } } else if ( uMessageParam == 100 ) @@ -1755,11 +1604,11 @@ case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: { - if ( pParty->field_3C.field_50[(unsigned int)v8->ptr_1C] < (signed __int64)pParty->uTimePlayed ) + if ( pParty->field_3C.Shops_next_generation_time[(unsigned int)v8->ptr_1C] < (signed __int64)pParty->uTimePlayed ) { GenerateStandartShopItems(); GenerateSpecialShopItems(); - pParty->field_3C.field_50[window_SpeakInHouse->par1C] = pParty->uTimePlayed + (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) * 0.033333335); + pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C] = pParty->uTimePlayed + (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) * 0.033333335); } if ( uMessageParam == HOUSE_DIALOGUE_SHOP_BUY_STANDARD ) { @@ -1838,8 +1687,6 @@ { if( uMessageParam >= HOUSE_DIALOGUE_36 && uMessageParam <= HOUSE_DIALOGUE_GUILD_LEARN_SKILL ) { - //v35 = pPlayers[uActiveCharacter]; - //v36 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)v8->ptr_1C] * 500.0); v36 = (signed __int64)(p2DEvents[(unsigned int)v8->ptr_1C - 1].flt_24 * 500.0); v37 = v36 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; if ( v37 < v36 / 3 ) @@ -1951,7 +1798,7 @@ sub_421B2C_PlaceInInventory_or_DropPickedItem(); return; } - if ( pParty->field_3C.field_50[(unsigned int)v8->ptr_1C] < (signed __int64)pParty->uTimePlayed ) + if ( pParty->field_3C.Shops_next_generation_time[(unsigned int)v8->ptr_1C] < (signed __int64)pParty->uTimePlayed ) { GenerateStandartShopItems(); GenerateSpecialShopItems(); @@ -1962,7 +1809,7 @@ //+ (signed __int64)((double)(11059200 * (signed int)p2DEvents_minus1[26 * (unsigned int)ptr_507BC0->ptr_1C]) + (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) * 0.033333335); - pParty->field_3C.field_50[v40] = v41; + pParty->field_3C.Shops_next_generation_time[v40] = v41; } v42 = v8->ptr_1C; @@ -2069,11 +1916,6 @@ unsigned int v3; // eax@1 signed int v4; // ebx@1 stru365_travel_info *v5; // esi@7 - //int v6; // eax@9 - //int v7; // eax@9 - //int v8; // eax@12 - //int v9; // edi@12 - //int v10; // edx@12 int v11; // ecx@12 signed int v12; // esi@13 signed int v13; // edi@14 @@ -2393,177 +2235,131 @@ //----- (004B7911) -------------------------------------------------------- void TownHallDialog() { - GUIWindow *v0; // eax@4 int v1; // eax@10 int v2; // esi@10 - GUIFont *v3; // ST20_4@20 - int v4; // eax@20 - MonsterInfo *v5; // edi@21 - unsigned int v6; // ST20_4@21 - char *v7; // ST1C_4@21 - unsigned int v8; // eax@21 - int v9; // esi@21 - char *v10; // eax@23 - signed int v11; // ebx@24 - signed int i; // esi@26 - int v13; // eax@27 - GUIWindow *v14; // ecx@28 - __int64 v15; // qax@28 + signed int pStringSum; // ebx@24 signed int v16; // ebx@28 int v17; // ebx@28 - unsigned __int8 v18; // sf@28 - char **v19; // edi@29 - GUIButton *v20; // eax@30 - GUIButton *v21; // esi@30 - int v22; // eax@30 + GUIButton *pButton; // eax@30 + int pTextHeight; // eax@30 unsigned int v23; // ecx@30 - unsigned __int16 v24; // ax@30 - GUIWindow a1; // [sp+Ch] [bp-110h]@21 - GUIWindow w; // [sp+60h] [bp-BCh]@21 - GUIWindow _this; // [sp+B4h] [bp-68h]@1 - int v28; // [sp+108h] [bp-14h]@1 + unsigned __int16 pTextColor; // ax@30 + GUIWindow window; // [sp+60h] [bp-BCh]@21 + GUIWindow townHall_window; // [sp+B4h] [bp-68h]@1 int v29; // [sp+10Ch] [bp-10h]@28 - int v30; // [sp+110h] [bp-Ch]@1 int v31; // [sp+114h] [bp-8h]@29 GUIFont *pOutString; // [sp+118h] [bp-4h]@21 - memcpy(&_this, window_SpeakInHouse, sizeof(_this)); - _this.uFrameX = 483; - _this.uFrameWidth = 148; - _this.uFrameZ = 334; - v28 = TargetColor(0xFFu, 0xFFu, 0xFFu); - v30 = TargetColor(0xFFu, 0xFFu, 0x9Bu); - sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine); - _this.DrawTitleText(pFontArrus, 0, 0x104u, v30, pTmpBuf.data(), 3u); + memcpy(&townHall_window, window_SpeakInHouse, sizeof(townHall_window)); + townHall_window.uFrameX = 483; + townHall_window.uFrameWidth = 148; + townHall_window.uFrameZ = 334; + sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine);//Òåêóùèé øòðàô + townHall_window.DrawTitleText(pFontArrus, 0, 260, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3); switch(dialog_menu_id) { - case HOUSE_DIALOGUE_MAIN: - { - v11 = 1; - pOutString = 0; - pShopOptions[0] = pGlobalTXT_LocalizationStrings[604]; - if ( pParty->uFine ) - { - pShopOptions[1] = pGlobalTXT_LocalizationStrings[603]; - v11 = 2; - } - for ( i = 0; i < v11; ++i ) - { - v13 = pFontArrus->CalcTextHeight(pShopOptions[i], &_this, 0, 0); - pOutString = (GUIFont *)((char *)pOutString + v13); - } - v29 = (100 - (signed int)pOutString) / v11; - v14 = pDialogueWindow; - v15 = 80 - v11 * (100 - (signed int)pOutString) / v11 - (signed int)pOutString; - v16 = v15 - HIDWORD(v15); - LODWORD(v15) = pDialogueWindow->pStartingPosActiveItem; - HIDWORD(v15) = v15 + pDialogueWindow->pNumPresenceButton; - v17 = (v16 >> 1) - v29 / 2 + 158; - v18 = -pDialogueWindow->pNumPresenceButton < 0; - pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem; - if ( v18 ^ __OFSUB__((int)v15, HIDWORD(v15)) ) - { - v31 = 2; - v19 = pShopOptions.data(); - do - { - v20 = v14->GetControl((unsigned int)pOutString); - v21 = v20; - v20->uY = v29 + v17; - v22 = pFontArrus->CalcTextHeight(*v19, &_this, 0, 0); - v23 = v21->uY; - v21->uHeight = v22; - v17 = v23 + v22 - 1; - v21->uW = v17; - v24 = v30; - if ( pDialogueWindow->pCurrentPosActiveItem != v31 ) - v24 = v28; - _this.DrawTitleText(pFontArrus, 0, v23, v24, *v19, 3u); - v14 = pDialogueWindow; - ++v31; - ++v19; - pOutString = (GUIFont *)((char *)pOutString + 1); - } - while ( (signed int)pOutString < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); - } - break; - } - - case HOUSE_DIALOGUE_TOWNHALL_99: - { - v5 = &pMonsterStats->pInfos[word_F8B1A0]; - v6 = TargetColor(0xFFu, 0xFFu, 0xFFu); - v7 = v5->pName; - v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu); - sprintf(pTmpBuf.data(), "\f%05d%s\f%05d", v8, v7, v6); - sprintf(pTmpBuf2.data(), dword_F8B1A4, pTmpBuf.data(), 100 * v5->uLevel); - current_npc_text = pTmpBuf2.data(); - memcpy(&a1, pDialogueWindow, sizeof(a1)); - w.uFrameWidth = 458; - w.uFrameZ = 457; - pOutString = pFontArrus; - v9 = pFontArrus->CalcTextHeight(pTmpBuf2.data(), &w, 13, 0) + 7; - if ( 352 - v9 < 8 ) - { - pOutString = pFontCreate; - v9 = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7; - } - - auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather); - pRenderer->_4A6A68(8u, 352 - v9, pTex, pTex->uTextureHeight - v9); - pRenderer->DrawTextureIndexed(8u, 347 - v9, pTexture_591428); - v10 = FitTextInAWindow(current_npc_text, pOutString, &w, 0xDu, 0); - a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0); - break; - } - case HOUSE_DIALOGUE_TOWNHALL_100: - { - v0 = window_SpeakInHouse; - if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) - { - sprintfex(pTmpBuf.data(), "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]); // "Pay" "How Much?" - _this.DrawTitleText(pFontArrus, 0, 0x92u, v30, pTmpBuf.data(), 3u); - _this.DrawTitleText(pFontArrus, 0, 0xBAu, v28, (const char *)pKeyActionMap->pPressedKeysBuffer, 3); - v3 = pFontArrus; - v4 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer); - _this.DrawFlashingInputCursor(v4 / 2 + 80, 185, v3); - return; - } - if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) - { - v1 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); - v2 = v1; - if ( v1 <= 0 ) - { - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - return; - } - if ( v1 > pParty->uNumGold ) - { - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); - v2 = pParty->uNumGold; - } - if ( v2 > pParty->uFine ) - v2 = pParty->uFine; - Party::TakeGold(v2); - pParty->uFine -= v2; - if ( pParty->uFine < 0 ) - pParty->uFine = 0; - if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0); - v0 = window_SpeakInHouse; - } - if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED) - { - v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE; - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - } - break; - } - default: - { - break; - } + case HOUSE_DIALOGUE_MAIN: + { + pStringSum = 1; + pTextHeight = 0; + pShopOptions[0] = pGlobalTXT_LocalizationStrings[604];//Îõîòà çà âîçíàãðàæäåíèå + if ( pParty->uFine > 0 ) + { + pShopOptions[1] = pGlobalTXT_LocalizationStrings[603];//Çàïëàòèòü øòðàô + pStringSum = 2; + } + for ( uint i = 0; i < pStringSum; ++i ) + pTextHeight += pFontArrus->CalcTextHeight(pShopOptions[i], &townHall_window, 0, 0); + v29 = (100 - pTextHeight) / pStringSum; + v16 = 80 - pStringSum * ((100 - pTextHeight) / pStringSum); + v17 = (v16 / 2) - v29 / 2 + 158; + if ( pDialogueWindow->pNumPresenceButton > 0 ) + { + v31 = 2; + uint j = 0; + for ( uint i = pDialogueWindow->pStartingPosActiveItem; + i < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++i ) + { + pButton = pDialogueWindow->GetControl(i); + pButton->uY = v29 + v17; + pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[j], &townHall_window, 0, 0); + v23 = pButton->uY; + pButton->uHeight = pTextHeight; + v17 = v23 + pTextHeight - 1; + pButton->uW = v17; + pTextColor = TargetColor(0xFFu, 0xFFu, 0x9Bu); + if ( pDialogueWindow->pCurrentPosActiveItem != v31 ) + pTextColor = TargetColor(0xFFu, 0xFFu, 0xFFu); + townHall_window.DrawTitleText(pFontArrus, 0, v23, pTextColor, pShopOptions[j], 3); + ++v31; + ++j; + } + } + break; + } + case HOUSE_DIALOGUE_TOWNHALL_MESSAGE: + { + sprintf(pTmpBuf.data(), "\f%05d%s\f%05d", TargetColor(0xFFu, 0xFFu, 0x9Bu), + pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].pName, TargetColor(0xFFu, 0xFFu, 0xFFu)); + sprintf(pTmpBuf2.data(), bountyHunting_text, pTmpBuf.data(), 100 * pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].uLevel); + current_npc_text = pTmpBuf2.data(); + memcpy(&window, pDialogueWindow, sizeof(window)); + window.uFrameWidth = 458; + window.uFrameZ = 457; + pOutString = pFontArrus; + pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf2.data(), &window, 13, 0) + 7; + if ( 352 - pTextHeight < 8 ) + { + pOutString = pFontCreate; + pTextHeight = pFontCreate->CalcTextHeight(current_npc_text, &window, 13, 0) + 7; + } + pRenderer->GetLeather(8, 352 - pTextHeight, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - pTextHeight); + pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428); + window.DrawText(pOutString, 13, 354 - pTextHeight, 0, FitTextInAWindow(current_npc_text, pOutString, &window, 13, 0), 0, 0, 0); + break; + } + case HOUSE_DIALOGUE_TOWNHALL_PAY_FINE: + { + if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) + { + sprintfex(pTmpBuf.data(), "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]); // "Pay" "How Much?" + townHall_window.DrawTitleText(pFontArrus, 0, 146, TargetColor(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3); + townHall_window.DrawTitleText(pFontArrus, 0, 186, TargetColor(0xFFu, 0xFFu, 0xFFu), (const char *)pKeyActionMap->pPressedKeysBuffer, 3); + townHall_window.DrawFlashingInputCursor(pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer) / 2 + 80, 185, pFontArrus); + return; + } + if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) + { + v1 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); + v2 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); + if ( v1 <= 0 ) + { + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + if ( v1 > pParty->uNumGold ) + { + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); + v2 = pParty->uNumGold; + } + if ( v2 > pParty->uFine ) + v2 = pParty->uFine; + Party::TakeGold(v2); + pParty->uFine -= v2; + if ( pParty->uFine < 0 ) + pParty->uFine = 0; + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0); + } + if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED) + { + window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + } + break; + } + default: + break; } return; } @@ -2932,7 +2728,7 @@ pTextHeight = pFontCreate->CalcTextHeight(pTmpBuf.data(), &dialog_window, 12, 0) + 7; } auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather); - pRenderer->_4A6A68(8, 352 - pTextHeight, pTex, pTex->uTextureHeight - pTextHeight); + pRenderer->GetLeather(8, 352 - pTextHeight, pTex, pTex->uTextureHeight - pTextHeight); pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428); v63 = FitTextInAWindow(pTmpBuf.data(), pOutString, &dialog_window, 0xCu, 0); window_SpeakInHouse->DrawText(pOutString, 12, 354 - pTextHeight, 0, v63, 0, 0, 0); @@ -2946,7 +2742,7 @@ v61 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 12, 0); pTextHeight = v61 + 7; auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather); - pRenderer->_4A6A68(8, 352 - (v61 + 7), pTex, pTex->uTextureHeight - (v61 + 7)); + pRenderer->GetLeather(8, 352 - (v61 + 7), pTex, pTex->uTextureHeight - (v61 + 7)); pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428); v63 = FitTextInAWindow(pTmpBuf.data(), pFontArrus, &dialog_window, 0xCu, 0); window_SpeakInHouse->DrawText(pFontArrus, 12, 354 - pTextHeight, 0, v63, 0, 0, 0); @@ -4224,7 +4020,7 @@ pInString = (char *)*(&pNPCStats->field_17884 + ((v10 & 3) == 2) + 2 * v9); v11 = pFontArrus->CalcTextHeight(pInString, &a1, 13, 0); v12 = v11 + 7; - pRenderer->_4A6A68(8, 352 - (v11 + 7), + pRenderer->GetLeather(8, 352 - (v11 + 7), pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - (v11 + 7)); pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); @@ -4267,7 +4063,6 @@ v33 = _4B254D_SkillMasteryTeacher((int)v52.ptr_1C); LABEL_44: v15 = v33; -LABEL_45: v16 = (GUIButton *)pInString; goto LABEL_49; } @@ -4280,15 +4075,16 @@ v28 = v27 - 1; if ( !v28 ) { - v29 = (char *)&pMonsterStats + 88 * word_F8B1A0; + v29 = pMonsterStats->pInfos[bountyHunting_monster_id_for_hunting].pName; v30 = TargetColor(0xFFu, 0xFFu, 0xFFu); v31 = *(int *)v29; v32 = TargetColor(0xFFu, 0xFFu, 0x9Bu); sprintfex(pTmpBuf.data(), "\f%05d%s\f%05d", v32, v31, v30); - sprintfex(pTmpBuf2.data(), dword_F8B1A4, pTmpBuf.data(), 100 * (unsigned __int8)v29[8]); + sprintfex(pTmpBuf2.data(), bountyHunting_text, pTmpBuf.data(), 100 * (unsigned __int8)v29[8]); current_npc_text = pTmpBuf2.data(); v15 = ""; - goto LABEL_45; + v16 = (GUIButton *)pInString; + goto LABEL_49; } if ( v28 != 10 ) goto LABEL_41; @@ -4330,7 +4126,8 @@ sprintf(pTmpBuf.data(), format_4E2D80, v55, pItemsTable->pItems[contract_approved].pUnidentifiedName); sprintf(pTmpBuf2.data(), current_npc_text, pTmpBuf.data()); current_npc_text = pTmpBuf2.data(); - goto LABEL_45; + v16 = (GUIButton *)pInString; + goto LABEL_49; } v21 = v20 - 1; if ( !v21 ) @@ -4427,11 +4224,9 @@ v47 = pFontCreate; v48 = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7; } - pRenderer->_4A6A68(8, 352 - v48, - pIcons_LOD->GetTexture(uTextureID_Leather), - pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - v48); + pRenderer->GetLeather(8, 352 - v48, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - v48); pRenderer->DrawTextureIndexed(8u, 347 - v48, pTexture_591428); - v49 = FitTextInAWindow(current_npc_text, v47, &w, 0xDu, 0); + v49 = FitTextInAWindow(current_npc_text, v47, &w, 13, 0); a1.DrawText(v47, 13, 354 - v48, 0, v49, 0, 0, 0); } } diff -r 86cb7398d2a8 -r 7d986a396092 UI/UIHouses.h --- a/UI/UIHouses.h Sat Sep 07 12:51:06 2013 +0200 +++ b/UI/UIHouses.h Sat Sep 07 13:03:18 2013 +0200 @@ -32,8 +32,8 @@ HOUSE_DIALOGUE_LEARN_SKILLS = 96, HOUSE_DIALOGUE_97 = 97, HOUSE_DIALOGUE_98 = 98, - HOUSE_DIALOGUE_TOWNHALL_99 = 99, - HOUSE_DIALOGUE_TOWNHALL_100 = 100, + HOUSE_DIALOGUE_TOWNHALL_MESSAGE = 99, + HOUSE_DIALOGUE_TOWNHALL_PAY_FINE = 100, HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN = 101, HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES = 102, HOUSE_DIALOGUE_TAVERN_ARCOMAGE_VICTORY_CONDITIONS = 103, diff -r 86cb7398d2a8 -r 7d986a396092 UI/UIMainMenu.cpp --- a/UI/UIMainMenu.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/UI/UIMainMenu.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -117,14 +117,14 @@ pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("torchB")); pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("torchA")); - pTextureIDs_pMapDirs[0] = pIcons_LOD->LoadTexture("MAPDIR8", TEXTURE_16BIT_PALETTE); - pTextureIDs_pMapDirs[1] = pIcons_LOD->LoadTexture("MAPDIR1", TEXTURE_16BIT_PALETTE); - pTextureIDs_pMapDirs[2] = pIcons_LOD->LoadTexture("MAPDIR2", TEXTURE_16BIT_PALETTE); - pTextureIDs_pMapDirs[3] = pIcons_LOD->LoadTexture("MAPDIR3", TEXTURE_16BIT_PALETTE); - pTextureIDs_pMapDirs[4] = pIcons_LOD->LoadTexture("MAPDIR4", TEXTURE_16BIT_PALETTE); - pTextureIDs_pMapDirs[5] = pIcons_LOD->LoadTexture("MAPDIR5", TEXTURE_16BIT_PALETTE); - pTextureIDs_pMapDirs[6] = pIcons_LOD->LoadTexture("MAPDIR6", TEXTURE_16BIT_PALETTE); - pTextureIDs_pMapDirs[7] = pIcons_LOD->LoadTexture("MAPDIR7", TEXTURE_16BIT_PALETTE); + pTextureIDs_pMapDirs[0] = pIcons_LOD->LoadTexture("MAPDIR1", TEXTURE_16BIT_PALETTE); + pTextureIDs_pMapDirs[1] = pIcons_LOD->LoadTexture("MAPDIR2", TEXTURE_16BIT_PALETTE); + pTextureIDs_pMapDirs[2] = pIcons_LOD->LoadTexture("MAPDIR3", TEXTURE_16BIT_PALETTE); + pTextureIDs_pMapDirs[3] = pIcons_LOD->LoadTexture("MAPDIR4", TEXTURE_16BIT_PALETTE); + pTextureIDs_pMapDirs[4] = pIcons_LOD->LoadTexture("MAPDIR5", TEXTURE_16BIT_PALETTE); + pTextureIDs_pMapDirs[5] = pIcons_LOD->LoadTexture("MAPDIR6", TEXTURE_16BIT_PALETTE); + pTextureIDs_pMapDirs[6] = pIcons_LOD->LoadTexture("MAPDIR7", TEXTURE_16BIT_PALETTE); + pTextureIDs_pMapDirs[7] = pIcons_LOD->LoadTexture("MAPDIR8", TEXTURE_16BIT_PALETTE); uTextureID_BarBlue = pIcons_LOD->LoadTexture("ib-statB", TEXTURE_16BIT_PALETTE); uTextureID_BarGreen = pIcons_LOD->LoadTexture("ib-statG", TEXTURE_16BIT_PALETTE); diff -r 86cb7398d2a8 -r 7d986a396092 UI/UIShops.cpp --- a/UI/UIShops.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/UI/UIShops.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -70,7 +70,7 @@ int v61; // eax@90 int v62; // ecx@90 ItemGen *pItemInShop; // esi@90 - int v64; // eax@95 + //int v64; // eax@95 int all_text_height; // esi@96 char **v66; // edi@96 int v67; // eax@97 @@ -233,8 +233,8 @@ pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60]; if ( !v56 || !Str ) { - v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2); - v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2)], + uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } @@ -248,7 +248,7 @@ } else { - dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); + dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed);//Ïðèõîäèòå ÷åðåç 7 äíåé pNumActiveItem = 0; //added } } @@ -424,22 +424,20 @@ pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724]; if ( !v56 || !Str ) { - v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2); - v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); - pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); - dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); + v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2)], + uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0)) / 2 + 138, pColorWhite, v7, 3); } else { v7 = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); - pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); - dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0)) / 2 + 138, pColorWhite, v7, 3); } } } else { - dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); + dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); pNumActiveItem = 0; //added } } @@ -769,7 +767,7 @@ dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; } - dialog_window.DrawCurrentTime( pParty->field_3C.field_50[window_SpeakInHouse->par1C]- pParty->uTimePlayed); + dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C]- pParty->uTimePlayed); return; } break; @@ -841,7 +839,7 @@ dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; } - dialog_window.DrawCurrentTime( pParty->field_3C.field_50[window_SpeakInHouse->par1C]- pParty->uTimePlayed); + dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C]- pParty->uTimePlayed); return; } break; @@ -1018,7 +1016,7 @@ while ( v104 < 8 ); return; } - dialog_window.DrawCurrentTime(pParty->field_3C.field_50[window_SpeakInHouse->par1C]- pParty->uTimePlayed); + dialog_window.DrawCurrentTime(pParty->field_3C.Shops_next_generation_time[window_SpeakInHouse->par1C]- pParty->uTimePlayed); return; } break; @@ -1351,7 +1349,7 @@ DrawTextAtStatusBar(v65, 0); if ( !v109 ) { - dialog_window.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); + dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); return; } v66 = pMouse->GetCursorPos(&v98); @@ -1551,7 +1549,7 @@ DrawTextAtStatusBar(v65, 0); if ( !v109 ) { - dialog_window.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); + dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); return; } v66 = pMouse->GetCursorPos(&v98); @@ -1932,7 +1930,7 @@ DrawTextAtStatusBar(v69, 0); if ( !v117 ) { - dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); + dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); return; } v70 = pMouse->GetCursorPos(&v102); @@ -2063,7 +2061,7 @@ DrawTextAtStatusBar(v69, 0); if ( !v117 ) { - dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); + dialog_window.DrawCurrentTime( pParty->field_3C.Shops_next_generation_time[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); return; } v70 = pMouse->GetCursorPos(&v102); diff -r 86cb7398d2a8 -r 7d986a396092 UI/UiGame.cpp --- a/UI/UiGame.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/UI/UiGame.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -33,31 +33,17 @@ #include "..\texts.h" #include "UIHouses.h" #include "..\BSPModel.h" - - - +#include "..\Math.h" int uTextureID_GameUI_CharSelectionFrame; // 50C98C - - - - //----- (00421D00) -------------------------------------------------------- void __fastcall GameUI_OnPlayerPortraitLeftClick(unsigned int uPlayerID) { - //unsigned int v1; // esi@1 - //int v2; // eax@2 - //Player *v3; // ecx@2 - //Player *v4; // ecx@5 - unsigned int v5; // [sp-4h] [bp-10h]@21 - - //v1 = uPlayerID; auto player = &pParty->pPlayers[uPlayerID - 1]; if (pParty->pPickedItem.uItemID) { - //v3 = player; if (auto slot = player->AddItem(-1, pParty->pPickedItem.uItemID)) { memcpy(&player->pInventoryItemList[slot-1], &pParty->pPickedItem, 0x24u); @@ -70,16 +56,14 @@ { player = pPlayers[uActiveCharacter]; } - if(player->CanAct() || !pPlayers[uActiveCharacter]->CanAct()) - player->PlaySound(SPEECH_NoRoom, 0); + if( player->CanAct() || !pPlayers[uActiveCharacter]->CanAct() ) + player->PlaySound(SPEECH_NoRoom, 0); } -//LABEL_9: if (pCurrentScreen == SCREEN_GAME) { viewparams->bRedrawGameUI = true; if ( uActiveCharacter != uPlayerID ) - //goto LABEL_27; { if ( pPlayers[uPlayerID]->uTimeToRecovery ) return; @@ -87,29 +71,23 @@ uActiveCharacter = uPlayerID; return; } - v5 = 7; -//LABEL_22: - pGUIWindow_CurrentMenu = CharacterUI_Initialize(v5); + pGUIWindow_CurrentMenu = CharacterUI_Initialize(7); return; } if ( pCurrentScreen == SCREEN_SPELL_BOOK ) return; if ( pCurrentScreen == SCREEN_CHEST ) { -//LABEL_23: viewparams->bRedrawGameUI = true; if ( uActiveCharacter == uPlayerID ) { pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; pCurrentScreen = SCREEN_CHEST_INVENTORY; - //goto LABEL_28; uActiveCharacter = uPlayerID; return; } -//LABEL_27: if ( pPlayers[uPlayerID]->uTimeToRecovery ) return; - //goto LABEL_28; uActiveCharacter = uPlayerID; return; } @@ -117,7 +95,6 @@ { if ( pCurrentScreen == SCREEN_E ) { -//LABEL_28: uActiveCharacter = uPlayerID; return; } @@ -129,20 +106,16 @@ FillAwardsData(); return; } - //goto LABEL_23; viewparams->bRedrawGameUI = true; if ( uActiveCharacter == uPlayerID ) { pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; pCurrentScreen = SCREEN_CHEST_INVENTORY; - //goto LABEL_28; uActiveCharacter = uPlayerID; return; } -//LABEL_27: if ( pPlayers[uPlayerID]->uTimeToRecovery ) return; - //goto LABEL_28; uActiveCharacter = uPlayerID; return; } @@ -150,16 +123,13 @@ return; viewparams->bRedrawGameUI = true; if ( uActiveCharacter != uPlayerID ) - //goto LABEL_28; uActiveCharacter = uPlayerID; return; if (dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD || dialog_menu_id == HOUSE_DIALOGUE_SHOP_6) { __debugbreak(); // fix indexing pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; - v5 = 14; - //goto LABEL_22; - pGUIWindow_CurrentMenu = CharacterUI_Initialize(v5); + pGUIWindow_CurrentMenu = CharacterUI_Initialize(14); return; } } @@ -170,30 +140,16 @@ void GameUI_DrawNPCPopup(void *_this)//PopupWindowForBenefitAndJoinText { int v1; // edi@2 - int v2; // ecx@2 - NPCData *v3; // eax@2 - NPCData *v4; // esi@7 - NPCData *v5; // eax@16 - NPCData *v6; // esi@16 - const CHAR *v7; // eax@18 - unsigned int v8; // eax@25 - unsigned int v9; // eax@25 - const char *v10; // ST14_4@26 + NPCData *pNPC; // eax@16 + const CHAR *pText; // eax@18 char *v11; // esi@26 - const char *v12; // ST18_4@27 - unsigned __int16 v13; // ax@28 - char *v14; // eax@28 - GUIWindow a1; // [sp+Ch] [bp-60h]@23 + GUIWindow popup_window; // [sp+Ch] [bp-60h]@23 int a2; // [sp+60h] [bp-Ch]@16 - void *v17; // [sp+64h] [bp-8h]@1 LPCSTR lpsz; // [sp+68h] [bp-4h]@6 - v17 = _this; if ( bNoNPCHiring != 1 ) { v1 = 0; - v2 = 0; - v3 = pParty->pHirelings; /*do { if ( v3->pName ) @@ -221,7 +177,7 @@ ++v4; } while ( (signed int)lpsz < (signed int)pNPCStats->uNumNewNPCs );*/ - for (int i = 0; i < pNPCStats->uNumNewNPCs; ++i) + for ( uint i = 0; i < pNPCStats->uNumNewNPCs; ++i ) { if (pNPCStats->pNewNPCData[i].Hired()) { @@ -233,69 +189,57 @@ } } } - if ( (signed int)((char *)v17 + (unsigned __int8)pParty->field_709) < v1 ) + if ( (signed int)((char *)_this + (unsigned __int8)pParty->field_709) < v1 ) { - sDialogue_SpeakingActorNPC_ID = -1 - (unsigned __int8)pParty->field_709 - (int)v17; - v5 = GetNewNPCData(sDialogue_SpeakingActorNPC_ID, &a2); - v6 = v5; - if ( v5 ) + sDialogue_SpeakingActorNPC_ID = -1 - (unsigned __int8)pParty->field_709 - (int)_this; + pNPC = GetNewNPCData(sDialogue_SpeakingActorNPC_ID, &a2); + if ( pNPC ) { if ( a2 == 57 ) - v7 = pNPCTopics[512].pText; // Baby dragon + pText = pNPCTopics[512].pText; // Baby dragon else - v7 = (const CHAR *)pNPCStats->pProfessions[v5->uProfession].pBenefits; - lpsz = v7; - if ( !v7 ) + pText = (const CHAR *)pNPCStats->pProfessions[pNPC->uProfession].pBenefits; + lpsz = pText; + if ( !pText ) { - lpsz = (LPCSTR)pNPCStats->pProfessions[v5->uProfession].pJoinText; + lpsz = (LPCSTR)pNPCStats->pProfessions[pNPC->uProfession].pJoinText; if ( !lpsz ) lpsz = ""; } - a1.Hint = 0; - a1.uFrameX = 38; - a1.uFrameY = 60; - a1.uFrameWidth = 276; - a1.uFrameZ = 313; - a1.uFrameHeight = pFontArrus->CalcTextHeight(lpsz, &a1, 0, 0) - + 2 * LOBYTE(pFontArrus->uFontHeight) - + 24; - if ( (signed int)a1.uFrameHeight < 130 ) - a1.uFrameHeight = 130; - a1.uFrameWidth = 400; - a1.uFrameZ = a1.uFrameX + 399; - a1.DrawMessageBox(0); - sprintfex(pTmpBuf2.data(), "NPC%03d", v6->uPortraitID); - v8 = pIcons_LOD->LoadTexture(pTmpBuf2.data(), TEXTURE_16BIT_PALETTE); - pRenderer->DrawTextureIndexed( - a1.uFrameX + 22, - a1.uFrameY + 36, - (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0)); - v9 = v6->uProfession; - if ( v9 ) + popup_window.Hint = 0; + popup_window.uFrameX = 38; + popup_window.uFrameY = 60; + popup_window.uFrameWidth = 276; + popup_window.uFrameZ = 313; + popup_window.uFrameHeight = pFontArrus->CalcTextHeight(lpsz, &popup_window, 0, 0) + 2 * LOBYTE(pFontArrus->uFontHeight) + 24; + if ( (signed int)popup_window.uFrameHeight < 130 ) + popup_window.uFrameHeight = 130; + popup_window.uFrameWidth = 400; + popup_window.uFrameZ = popup_window.uFrameX + 399; + popup_window.DrawMessageBox(0); + sprintfex(pTmpBuf2.data(), "NPC%03d", pNPC->uPortraitID); + pRenderer->DrawTextureIndexed(popup_window.uFrameX + 22, popup_window.uFrameY + 36, + (Texture *)(pIcons_LOD->LoadTexture(pTmpBuf2.data(), TEXTURE_16BIT_PALETTE) != -1 + ? &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pTmpBuf2.data(), TEXTURE_16BIT_PALETTE)] : 0)); + if ( pNPC->uProfession ) { - v10 = v6->pName; v11 = pTmpBuf.data(); - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], v10, aNPCProfessionNames[v9]); + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], pNPC->pName, aNPCProfessionNames[pNPC->uProfession]); } else { - v12 = v6->pName; v11 = pTmpBuf.data(); - strcpy(pTmpBuf.data(), v12); + strcpy(pTmpBuf.data(), pNPC->pName); } - v13 = TargetColor(0xFFu, 0xFFu, 0x9Bu); - a1.DrawTitleText(pFontArrus, 0, 0xCu, v13, v11, 3u); - a1.uFrameWidth -= 24; - a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1; - v14 = BuildDialogueString((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0); - a1.DrawText(pFontArrus, 100, 36, 0, v14, 0, 0, 0); + popup_window.DrawTitleText(pFontArrus, 0, 12, TargetColor(0xFFu, 0xFFu, 0x9Bu), v11, 3); + popup_window.uFrameWidth -= 24; + popup_window.uFrameZ = popup_window.uFrameX + popup_window.uFrameWidth - 1; + popup_window.DrawText(pFontArrus, 100, 36, 0, BuildDialogueString((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0), 0, 0, 0); } } } } - - //----- (00445D4A) -------------------------------------------------------- void GameUI_InitializeDialogue(Actor *actor, int bPlayerSaysHello) { @@ -403,64 +347,31 @@ { NPCData *pNPC; // ebx@2 int pGreetType; // eax@2 - //unsigned __int16 v2; // di@2 - //unsigned int v3; // eax@2 - char *v4; // esi@3 - //int v5; // eax@11 - //char *v6; // ecx@13 - //char *v7; // eax@16 - //unsigned int v8; // edi@19 - //char *v9; // ecx@27 - char *v10; // eax@29 - //int v11; // eax@30 - int v12; // esi@39 - char *v13; // eax@41 - GUIButton *v14; // eax@43 - //GUIButton *v15; // edi@43 - signed int v16; // eax@44 - //unsigned int v23; // eax@53 - //const char *v24; // eax@59 - //unsigned __int16 v30; // cx@83 - int v31; // ecx@86 + int pTextHeight; // esi@39 + GUIButton *pButton; // eax@43 int v32; // ebx@93 - //unsigned int v33; // eax@93 - GUIWindow *v34; // ecx@93 - int v35; // esi@93 - int i; // eax@93 - GUIButton *v37; // eax@94 + uint v35; // esi@93 int v38; // eax@95 signed int v39; // esi@99 signed int v40; // eax@102 unsigned int v41; // ebx@102 int v42; // edi@102 - GUIButton *v43; // esi@103 - int v44; // eax@104 unsigned int v45; // ecx@104 - unsigned __int16 *v46; // edx@104 - unsigned __int16 v47; // ax@104 - GUIWindow pWindow; // [sp+4h] [bp-110h]@39 - int v49; // [sp+Ch] [bp-108h]@39 - int v50; // [sp+14h] [bp-100h]@39 - GUIWindow v51; // [sp+58h] [bp-BCh]@2 - GUIWindow v52; // [sp+ACh] [bp-68h]@42 + unsigned __int16 pTextColor; // ax@104 + GUIWindow window; // [sp+ACh] [bp-68h]@42 char *Str; // [sp+100h] [bp-14h]@104 - //int v54; // [sp+104h] [bp-10h]@2 - //unsigned __int16 *v55; // [sp+108h] [bp-Ch]@82 GUIFont *pOutString; // [sp+10Ch] [bp-8h]@39 char *pInString=NULL; // [sp+110h] [bp-4h]@32 if ( !pDialogueWindow ) return; - memcpy(&v51, pDialogueWindow, sizeof(v51)); + // Window title(Çàãîëîâîê îêíà)---- + memcpy(&window, pDialogueWindow, sizeof(window)); pNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID); pGreetType = GetGreetType(sDialogue_SpeakingActorNPC_ID); - v51.uFrameWidth -= 10; - v51.uFrameZ -= 10; - //v54 = v1; - //TargetColor(0xFFu, 0xFFu, 0xFFu); - //TargetColor(0xE1u, 0xCDu, 0x23u); - //v2 = TargetColor(0x15u, 0x99u, 0xE9u); + window.uFrameWidth -= 10; + window.uFrameZ -= 10; pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background); pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_right_panel_loop != -1 ? &pIcons_LOD->pTextures[uTextureID_right_panel_loop] : 0)); pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0)); @@ -474,7 +385,7 @@ else strcpy(pTmpBuf.data(), pNPC->pName); - v51.DrawTitleText(pFontArrus, 483, 112, ui_game_dialogue_npc_name_color, pTmpBuf.data(), 3); + window.DrawTitleText(pFontArrus, 483, 112, ui_game_dialogue_npc_name_color, pTmpBuf.data(), 3); pParty->GetPartyFame(); pInString = nullptr; @@ -532,7 +443,7 @@ } else if (pGreetType == 2)//HiredNPC_greet { - auto prof = pNPCStats->pProfessions + pNPC->uProfession - 1; + auto prof = pNPCStats->pProfessions + pNPC->uProfession; if (pNPC->Hired()) pInString = BuildDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); @@ -542,145 +453,139 @@ break; } + // Message window(Îêíî ñîîáùåíèÿ)---- if (pInString) { - pWindow.uFrameWidth = game_viewport_width; - pWindow.uFrameZ = 452; + window.uFrameWidth = game_viewport_width; + window.uFrameZ = 452; auto font = pFontArrus; - v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; - if ( 352 - v12 < 8 ) + pTextHeight = pFontArrus->CalcTextHeight(pInString, &window, 13, 0) + 7; + if ( 352 - pTextHeight < 8 ) { font = pFontCreate; - v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; + pTextHeight = pFontCreate->CalcTextHeight(pInString, &window, 13, 0) + 7; } if (uTextureID_Leather != -1) - pRenderer->_4A6A68(8, 352 - v12, &pIcons_LOD->pTextures[uTextureID_Leather], pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight - v12); - pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); - v13 = FitTextInAWindow(pInString, font, &pWindow, 0xDu, 0); - pDialogueWindow->DrawText(font, 13, 354 - v12, 0, v13, 0, 0, 0); + pRenderer->GetLeather(8, 352 - pTextHeight, &pIcons_LOD->pTextures[uTextureID_Leather], pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight - pTextHeight); + pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428); + pDialogueWindow->DrawText(font, 13, 354 - pTextHeight, 0, FitTextInAWindow(pInString, font, &window, 13, 0), 0, 0, 0); } - - - memcpy(&v52, pDialogueWindow, sizeof(v52)); - v52.uFrameX = 483; - v52.uFrameWidth = 148; - v52.uFrameZ = 334; - for (int i = v52.pStartingPosActiveItem; - i < v52.pStartingPosActiveItem + v52.pNumPresenceButton; ++i) + // Right panel(Ïðàâàÿ ïàíåëü)------- + memcpy(&window, pDialogueWindow, sizeof(window)); + window.uFrameX = 483; + window.uFrameWidth = 148; + window.uFrameZ = 334; + for (int i = window.pStartingPosActiveItem; i < window.pStartingPosActiveItem + window.pNumPresenceButton; ++i) { - v14 = v52.GetControl(i); - //v15 = v14; - if ( !v14 ) + pButton = window.GetControl(i); + if ( !pButton ) break; - v16 = v14->msg_param; - if ( v16 > 88 ) - v14->pButtonName[0] = 0; - else if (v16 == 88) - strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[581]); // Lord - else if (v16 == 87) - strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[580]); // Knight - else if (v16 == 86) - strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[579]); // Squire - else if (v16 == 85) - strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[578]); // Page - else if (v16 == 77) - strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[407]); // Details - else if (v16 == 76) + if ( pButton->msg_param > 88 ) + pButton->pButtonName[0] = 0; + else if (pButton->msg_param == 88) + strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[581]); // Lord + else if (pButton->msg_param == 87) + strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[580]); // Knight + else if (pButton->msg_param == 86) + strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[579]); // Squire + else if (pButton->msg_param == 85) + strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[578]); // Page + else if (pButton->msg_param == 77) + strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[407]); // Details + else if (pButton->msg_param == 76) { if (pNPC->Hired()) - sprintf(v14->pButtonName, (const char*)pGlobalTXT_LocalizationStrings[408], pNPC->pName); // Release %s + sprintf(pButton->pButtonName, (const char*)pGlobalTXT_LocalizationStrings[408], pNPC->pName); // Release %s else - strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[406]); // Hire + strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[406]); // Hire } - else if (v16 == 24) + else if (pButton->msg_param == 24) { __debugbreak(); // learn conditions of this event auto topic = pNPCTopics[pNPC->evt_F - 1].pTopic;//(&dword_721660)[8 * v23]; if (!topic) { - v14->pButtonName[0] = 0; - v14->msg_param = 0; + pButton->pButtonName[0] = 0; + pButton->msg_param = 0; } else - strcpy(v14->pButtonName, topic); + strcpy(pButton->pButtonName, topic); } - else if (v16 == 9) - strcpy(v14->pButtonName, GetProfessionActionText(pNPC->uProfession)); - else if (v16 == 19) - { + else if (pButton->msg_param == 9) + strcpy(pButton->pButtonName, GetProfessionActionText(pNPC->uProfession)); + else if (pButton->msg_param == 19) + { // __debugbreak(); // learn conditions of this event Scavenger Hunt auto topic = pNPCTopics[pNPC->evt_A - 1].pTopic;//(&dword_721660)[8 * v23]; if (!topic) { - v14->pButtonName[0] = 0; - v14->msg_param = 0; + pButton->pButtonName[0] = 0; + pButton->msg_param = 0; } - else strcpy(v14->pButtonName, topic); - } - else if (v16 == 20) - { + else strcpy(pButton->pButtonName, topic); + } + else if (pButton->msg_param == 20) + { //__debugbreak(); // learn conditions of this event instruments auto topic = pNPCTopics[pNPC->evt_B - 1].pTopic;//(&dword_721660)[8 * v23]; if (!topic) { - v14->pButtonName[0] = 0; - v14->msg_param = 0; + pButton->pButtonName[0] = 0; + pButton->msg_param = 0; } - else strcpy(v14->pButtonName, topic); - } - else if (v16 == 21) - { + else strcpy(pButton->pButtonName, topic); + } + else if (pButton->msg_param == 21) + { //__debugbreak(); // learn conditions of this event auto topic = pNPCTopics[pNPC->evt_C - 1].pTopic;//(&dword_721660)[8 * v23]; if (!topic) { - v14->pButtonName[0] = 0; - v14->msg_param = 0; + pButton->pButtonName[0] = 0; + pButton->msg_param = 0; } - else strcpy(v14->pButtonName, topic); - } - else if (v16 == 22) - { + else strcpy(pButton->pButtonName, topic); + } + else if (pButton->msg_param == 22) + { //__debugbreak(); // learn conditions of this event auto topic = pNPCTopics[pNPC->evt_D - 1].pTopic;//(&dword_721660)[8 * v23]; if (!topic) { - v14->pButtonName[0] = 0; - v14->msg_param = 0; + pButton->pButtonName[0] = 0; + pButton->msg_param = 0; } - else strcpy(v14->pButtonName, topic); - } - else if (v16 == 23) - { + else strcpy(pButton->pButtonName, topic); + } + else if (pButton->msg_param == 23) + { //__debugbreak(); // learn conditions of this event auto topic = pNPCTopics[pNPC->evt_E - 1].pTopic;//(&dword_721660)[8 * v23]; if (!topic) { - v14->pButtonName[0] = 0; - v14->msg_param = 0; + pButton->pButtonName[0] = 0; + pButton->msg_param = 0; } - else strcpy(v14->pButtonName, topic); - } - else if (v16 == 13) - { + else strcpy(pButton->pButtonName, topic); + } + else if (pButton->msg_param == 13) + { if (pNPC->Hired()) - sprintf(v14->pButtonName, pGlobalTXT_LocalizationStrings[408], pNPC->pName); // Release %s + sprintf(pButton->pButtonName, pGlobalTXT_LocalizationStrings[408], pNPC->pName); // Release %s else - strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[122]); // Join - } - else - v14->pButtonName[0] = 0; - + strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[122]); // Join + } + else + pButton->pButtonName[0] = 0; if (pParty->field_7B5_in_arena_quest && pParty->field_7B5_in_arena_quest != -1) { int num_dead_actors = 0; pInString = 0; - for (uint i = 0; i < uNumActors; ++i) + for ( uint i = 0; i < uNumActors; ++i ) { - if (pActors[i].uAIState == Dead || pActors[i].uAIState == Removed || - pActors[i].uAIState == Disabled) + if (pActors[i].uAIState == Dead || pActors[i].uAIState == Removed || pActors[i].uAIState == Disabled) ++num_dead_actors; else { @@ -690,29 +595,23 @@ } } if (num_dead_actors == uNumActors) - strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[658]); // Collect Prize + strcpy(pButton->pButtonName, pGlobalTXT_LocalizationStrings[658]); // Collect Prize } } - + // Install Buttons(Óñòàíîâêà êíîïîê)-------- v32 = 0; - v34 = pDialogueWindow; - //v54 = v33; - v35 = pDialogueWindow->pStartingPosActiveItem; - for ( i = v35 + pDialogueWindow->pNumPresenceButton; v35 < i; i = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ) + v35 = (uint)pDialogueWindow->pStartingPosActiveItem; + for ( uint i = v35 + pDialogueWindow->pNumPresenceButton; v35 < i; i = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ) { - v37 = v34->GetControl(v35); - if ( !v37 ) - { - v34 = pDialogueWindow; + pButton = pDialogueWindow->GetControl(v35); + if ( !pButton ) break; - } - v38 = pFontArrus->CalcTextHeight(v37->pButtonName, &v52, 0, 0); - v34 = pDialogueWindow; + v38 = pFontArrus->CalcTextHeight(pButton->pButtonName, &window, 0, 0); v32 += v38; ++v35; } - v39 = v34->pNumPresenceButton; + v39 = pDialogueWindow->pNumPresenceButton; if ( v39 ) { pOutString = (GUIFont *)((174 - v32) / v39); @@ -720,28 +619,26 @@ pOutString = (GUIFont *)32; int v55 = 1; v40 = 174 - (int)pOutString * v39 - v32; - v41 = v34->pStartingPosActiveItem; + v41 = pDialogueWindow->pStartingPosActiveItem; v42 = v40 / 2 - (signed int)pOutString / 2 + 138; if ( (signed int)v41 < (signed int)(v41 + v39) ) { do { - v43 = v34->GetControl(v41); - if ( !v43 ) + pButton = pDialogueWindow->GetControl(v41); + if ( !pButton ) break; - v43->uY = (unsigned int)((char *)pOutString + v42); - Str = v43->pButtonName; - v44 = pFontArrus->CalcTextHeight(v43->pButtonName, &v52, 0, 0); - v45 = v43->uY; - v46 = (unsigned short *)v55; - v43->uHeight = v44; - v42 = v45 + v44 - 1; - v43->uW = v42; - v47 = ui_game_dialogue_option_highlight_color; - if ( (unsigned __int16 *)pDialogueWindow->pCurrentPosActiveItem != v46 ) - v47 = ui_game_dialogue_option_normal_color; - v52.DrawTitleText(pFontArrus, 0, v45, v47, Str, 3u); - v34 = pDialogueWindow; + pButton->uY = (unsigned int)((char *)pOutString + v42); + Str = pButton->pButtonName; + pTextHeight = pFontArrus->CalcTextHeight(pButton->pButtonName, &window, 0, 0); + v45 = pButton->uY; + pButton->uHeight = pTextHeight; + v42 = v45 + pTextHeight - 1; + pButton->uW = v42; + pTextColor = ui_game_dialogue_option_highlight_color; + if ( pDialogueWindow->pCurrentPosActiveItem != v55 ) + pTextColor = ui_game_dialogue_option_normal_color; + window.DrawTitleText(pFontArrus, 0, v45, pTextColor, Str, 3); ++v55; ++v41; } @@ -751,36 +648,28 @@ pRenderer->DrawTextureIndexed(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId)); } - - //----- (00444FBE) -------------------------------------------------------- void GameUI_DrawBranchlessDialogue() { - //GUIFont *v0; // esi@1 - int v1; // esi@4 - char *v2; // eax@6 - int v3; // edi@12 + int pTextHeight; // esi@4 char Str[200]; // [sp+Ch] [bp-120h]@12 - GUIWindow v5; // [sp+D4h] [bp-58h]@4 + GUIWindow BranchlessDlg_window; // [sp+D4h] [bp-58h]@4 GUIFont *pFont; // [sp+128h] [bp-4h]@1 pFont = pFontArrus; if ( current_npc_text && !byte_5B0938[0] ) strcpy(byte_5B0938.data(), current_npc_text); - v5.uFrameWidth = game_viewport_width; - v5.uFrameZ = 452; - v1 = pFontArrus->CalcTextHeight(byte_5B0938.data(), &v5, 12, 0) + 7; - if ( 352 - v1 < 8 ) + BranchlessDlg_window.uFrameWidth = game_viewport_width; + BranchlessDlg_window.uFrameZ = 452; + pTextHeight = pFontArrus->CalcTextHeight(byte_5B0938.data(), &BranchlessDlg_window, 12, 0) + 7; + if ( 352 - pTextHeight < 8 ) { pFont = pFontCreate; - v1 = pFontCreate->CalcTextHeight(byte_5B0938.data(), &v5, 12, 0) + 7; + pTextHeight = pFontCreate->CalcTextHeight(byte_5B0938.data(), &BranchlessDlg_window, 12, 0) + 7; } - pRenderer->_4A6A68(8, 352 - v1, - pIcons_LOD->GetTexture(uTextureID_Leather), - pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - v1); - pRenderer->DrawTextureIndexed(8, 347 - v1, pTexture_591428); - v2 = FitTextInAWindow(byte_5B0938.data(), pFont, &v5, 0xCu, 0); - pGUIWindow2->DrawText(pFont, 12, 354 - v1, 0, v2, 0, 0, 0); + pRenderer->GetLeather(8, 352 - pTextHeight, pIcons_LOD->GetTexture(uTextureID_Leather), pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - pTextHeight); + pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428); + pGUIWindow2->DrawText(pFont, 12, 354 - pTextHeight, 0, FitTextInAWindow(byte_5B0938.data(), pFont, &BranchlessDlg_window, 12, 0), 0, 0, 0); pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar); if ( pGUIWindow2->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS) { @@ -788,167 +677,108 @@ { pGUIWindow2->receives_keyboard_input_2 = WINDOW_INPUT_NONE; strcpy(GameUI_Footer_TimedString.data(), (const char *)pKeyActionMap->pPressedKeysBuffer); -LABEL_16: sub_4452BB(); return; } if ( pGUIWindow2->receives_keyboard_input_2 != WINDOW_INPUT_CANCELLED) return; pGUIWindow2->receives_keyboard_input_2 = WINDOW_INPUT_NONE; -LABEL_15: memset(GameUI_Footer_TimedString.data(), 0, 0xC8u); - goto LABEL_16; + sub_4452BB(); + return; } if ( pGUIWindow2->ptr_1C == (void *)26 ) { sprintf(Str, "%s %s", GameUI_Footer_TimedString, pKeyActionMap->pPressedKeysBuffer); - v3 = pFontLucida->GetLineWidth(Str); pGUIWindow2->DrawText(pFontLucida, 13, 357, 0, Str, 0, 0, 0); - pGUIWindow2->DrawFlashingInputCursor(v3 + 13, 357, pFontLucida); + pGUIWindow2->DrawFlashingInputCursor(pFontLucida->GetLineWidth(Str) + 13, 357, pFontLucida); return; } if ( pKeyActionMap->pPressedKeysBuffer[0] ) { pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_NONE); - goto LABEL_15; + memset(GameUI_Footer_TimedString.data(), 0, 0xC8u); + sub_4452BB(); + return; } } - //----- (004443D5) -------------------------------------------------------- const char *GameUI_GetMinimapHintText() { - int v0; // ST20_4@1 - unsigned int v1; // esi@1 - signed int v2; // ebx@1 double v3; // st7@1 - int v4; // esi@3 - int v5; // edi@4 - int v6; // eax@4 int v7; // eax@4 - BSPModel *v8; // ecx@4 - unsigned __int8 v9; // zf@5 - char v10; // sf@5 - unsigned __int8 v11; // of@5 - ODMFace *v12; // eax@6 - __int16 v13; // cx@6 + ODMFace *pFace; // eax@6 const char *v14; // eax@8 - const char *v15; // edi@8 char *result; // eax@12 - unsigned int v17; // eax@14 - unsigned int v18; // [sp+Ch] [bp-20h]@1 + unsigned int pMapID; // eax@14 int v19; // [sp+10h] [bp-1Ch]@1 int v20; // [sp+14h] [bp-18h]@1 - char *v21; // [sp+18h] [bp-14h]@1 unsigned int pY; // [sp+1Ch] [bp-10h]@1 - int v23; // [sp+20h] [bp-Ch]@1 - int v24; // [sp+24h] [bp-8h]@1 - int pX; // [sp+28h] [bp-4h]@1 + unsigned int pX; // [sp+28h] [bp-4h]@1 - v24 = pParty->vPosition.x; - v0 = pParty->vPosition.y; - v1 = pOutdoor->uNumBModels; - *(float *)&v23 = (double)(signed int)viewparams->uMinimapZoom * 0.000015258789; - v2 = 0; - v18 = pOutdoor->uNumBModels; - v21 = 0; - pMouse->GetClickPos((unsigned int *)&pX, &pY); - v3 = 1.0 / *(float *)&v23; - v23 = pX - 557; - v19 = (signed __int64)((double)(pX - 557) * v3 + (double)v24); - v20 = (signed __int64)((double)v0 - (double)(signed int)(pY - 74) * v3); - if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor || (*(float *)&v23 = 0.0, (signed int)v1 <= 0) ) + result = 0; + pMouse->GetClickPos(&pX, &pY); + v3 = 1.0 / (float)((signed int)viewparams->uMinimapZoom * 0.000015258789); + v19 = (signed __int64)((double)(pX - 557) * v3 + (double)pParty->vPosition.x); + v20 = (signed __int64)((double)pParty->vPosition.y - (double)(pY - 74) * v3); + if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor || pOutdoor->uNumBModels <= 0 ) { -LABEL_14: - v17 = pMapStats->GetMapInfo(pCurrentMapName); - if ( v17 == v2 ) + pMapID = pMapStats->GetMapInfo(pCurrentMapName); + if ( pMapID == 0 ) result = "No Maze Info for this maze on file!"; else - result = pMapStats->pInfos[v17].pName; + result = pMapStats->pInfos[pMapID].pName; } else { - v4 = 0; - while ( 1 ) + for ( uint j = 0; j < (uint)pOutdoor->uNumBModels; ++j ) { - pX = pOutdoor->pBModels[v4].vBoundingCenter.x - v19; - pY = pOutdoor->pBModels[v4].vBoundingCenter.y - v20; - v5 = abs((signed)pY); - v6 = abs((signed)pX); - v7 = int_get_vector_length(v6, v5, v2); - v8 = &pOutdoor->pBModels[0]; - if ( v7 < 2 * pOutdoor->pBModels[v4].sBoundingRadius ) + v7 = int_get_vector_length(abs((signed)pOutdoor->pBModels[j].vBoundingCenter.x - v19), + abs((signed)pOutdoor->pBModels[j].vBoundingCenter.y - v20), 0); + if ( v7 < 2 * pOutdoor->pBModels[j].sBoundingRadius ) { - v11 = __OFSUB__(pOutdoor->pBModels[v4].uNumFaces, v2); - v9 = pOutdoor->pBModels[v4].uNumFaces == v2; - v10 = ((pOutdoor->pBModels[v4].uNumFaces - v2) & 0x80000000u) != 0; - v24 = v2; - if ( !((unsigned __int8)(v10 ^ v11) | v9) ) + if ( pOutdoor->pBModels[j].uNumFaces ) { - do + for ( uint i = 0; i < (uint)pOutdoor->pBModels[j].uNumFaces; ++i ) { - v12 = &v8[v4].pFaces[v2 / 0x134u]; - v13 = v12->sCogTriggeredID; - if ( v13 ) + pFace = &pOutdoor->pBModels[j].pFaces[i]; + if ( pFace->sCogTriggeredID ) { - if ( !(BYTE2(v12->uAttributes) & 0x10) ) + if ( !(BYTE2(pFace->uAttributes) & 0x10) ) { - v14 = GetEventHintString(v13); - v15 = v14; + v14 = GetEventHintString(pFace->sCogTriggeredID); if ( v14 ) { if ( _stricmp(v14, "") ) - v21 = (char *)v15; + result = (char *)v14; } } } - ++v24; - v8 = pOutdoor->pBModels; - v2 += 308; } - while ( v24 < (signed int)pOutdoor->pBModels[v4].uNumFaces ); } - result = v21; - v2 = 0; - if ( v21 ) - break; + if ( result ) + return result; } - ++v23; - ++v4; - if ( v23 >= (signed int)v18 ) - goto LABEL_14; } + pMapID = pMapStats->GetMapInfo(pCurrentMapName); + if ( pMapID == 0 ) + result = "No Maze Info for this maze on file!"; + else + result = pMapStats->pInfos[pMapID].pName; + return result; } return result; } - - - - //----- (0041D3B7) -------------------------------------------------------- void GameUI_CharacterQuickRecord_Draw(GUIWindow *window, Player *player) { - //Player *pPlayer; // esi@1 - int v6; // eax@5 - int v7; // ebx@5 - //unsigned int v8; // ecx@5 - int v9; // ebx@5 - //unsigned int v10; // eax@5 - //int v11; // eax@5 - //unsigned int v12; // ecx@5 Texture *v13; // eax@6 - unsigned int v14; // eax@12 PlayerFrame *v15; // eax@12 - //unsigned int v16; // eax@15 - unsigned int v20; // eax@15 - unsigned int v24; // eax@15 - unsigned int v25; // eax@15 - unsigned __int8 v28; // al@15 + unsigned int pTextColor; // eax@15 char *v29; // eax@16 - __int64 v35; // ST38_8@22 int v36; // esi@22 - unsigned int v38; // eax@22 char *v39; // eax@24 signed int uFramesetID; // [sp+20h] [bp-8h]@9 int uFramesetIDa; // [sp+20h] [bp-8h]@18 @@ -958,12 +788,9 @@ if (player->pPlayerBuffs[i].uExpireTime > 0) ++numActivePlayerBuffs; - v6 = pFontArrus->uFontHeight + 162; - v7 = (numActivePlayerBuffs - 1) * pFontArrus->uFontHeight; - v9 = v6 + v7; - window->uFrameHeight = v9; + window->uFrameHeight = ((pFontArrus->uFontHeight + 162) + ((numActivePlayerBuffs - 1) * pFontArrus->uFontHeight)); window->uFrameZ = window->uFrameWidth + window->uFrameX - 1; - window->uFrameW = v9 + window->uFrameY - 1; + window->uFrameW = ((pFontArrus->uFontHeight + 162) + ((numActivePlayerBuffs - 1) * pFontArrus->uFontHeight)) + window->uFrameY - 1; window->DrawMessageBox(0); if (player->IsEradicated()) @@ -976,14 +803,9 @@ if ( !uFramesetID ) uFramesetID = 1; if ( player->expression == CHARACTER_EXPRESSION_21) - { v15 = pPlayerFrameTable->GetFrameBy_y(&player->_expression21_frameset, &player->_expression21_animtime, pMiscTimer->uTimeElapsed); - } else - { - v14 = pMiscTimer->Time(); - v15 = pPlayerFrameTable->GetFrameBy_x(uFramesetID, v14); - } + v15 = pPlayerFrameTable->GetFrameBy_x(uFramesetID, pMiscTimer->Time()); player->field_1AA2 = v15->uTextureID - 1; v13 = pTextures_PlayerFaces[(unsigned int)window->ptr_1C][v15->uTextureID - 1]; } @@ -995,27 +817,23 @@ strcat(pTmpBuf.data(), pTmpBuf2.data()); strcat(pTmpBuf.data(), "\f00000\n"); - v20 = UI_GetHealthManaStringColor(player->sHealth, player->GetMaxHealth()); - sprintfex(pTmpBuf2.data(), "%s : \f%05u%d\f00000 / %d\n", - pGlobalTXT_LocalizationStrings[108], // "Hit Points" - v20, player->sHealth, player->GetMaxHealth()); + pTextColor = UI_GetHealthManaAndOtherQualitiesStringColor(player->sHealth, player->GetMaxHealth()); + sprintfex(pTmpBuf2.data(), "%s : \f%05u%d\f00000 / %d\n", pGlobalTXT_LocalizationStrings[108], // "Hit Points" + pTextColor, player->sHealth, player->GetMaxHealth()); strcat(pTmpBuf.data(), pTmpBuf2.data()); - v24 = UI_GetHealthManaStringColor(player->sMana, player->GetMaxMana()); - sprintfex(pTmpBuf2.data(), "%s : \f%05u%d\f00000 / %d\n", - pGlobalTXT_LocalizationStrings[212], // "Spell Points" - v24, player->sMana, player->GetMaxMana()); + pTextColor = UI_GetHealthManaAndOtherQualitiesStringColor(player->sMana, player->GetMaxMana()); + sprintfex(pTmpBuf2.data(), "%s : \f%05u%d\f00000 / %d\n", pGlobalTXT_LocalizationStrings[212], // "Spell Points" + pTextColor, player->sMana, player->GetMaxMana()); strcat(pTmpBuf.data(), pTmpBuf2.data()); - v25 = player->GetMajorConditionIdx(); - sprintfex(pTmpBuf2.data(), "%s: \f%05d%s\f00000\n", - pGlobalTXT_LocalizationStrings[47], // "Condition - GetConditionDrawColor(v25), aCharacterConditionNames[v25]); + pTextColor = player->GetMajorConditionIdx(); + sprintfex(pTmpBuf2.data(), "%s: \f%05d%s\f00000\n", pGlobalTXT_LocalizationStrings[47], // "Condition + GetConditionDrawColor(pTextColor), aCharacterConditionNames[pTextColor]); strcat(pTmpBuf.data(), pTmpBuf2.data()); - v28 = player->uQuickSpell; - if ( v28 ) - v29 = pSpellStats->pInfos[v28].pShortName; + if ( player->uQuickSpell ) + v29 = pSpellStats->pInfos[player->uQuickSpell].pShortName; else v29 = pGlobalTXT_LocalizationStrings[153]; sprintfex(pTmpBuf2.data(), "%s: %s", pGlobalTXT_LocalizationStrings[172], v29); // "Quick Spell" @@ -1029,11 +847,9 @@ auto buff = player->pPlayerBuffs + i; if (buff->uExpireTime > 0) { - v35 = buff->uExpireTime - pParty->uTimePlayed; v36 = uFramesetIDa++ * pFontComic->uFontHeight + 134; - v38 = ui_game_character_record_playerbuff_colors[i]; - window->DrawText(pFontComic, 52, v36, v38, aSpellNames[20 + i], 0, 0, 0); - sub_41D20D_buff_remaining_time_string(v36, window, v35, pFontComic); + window->DrawText(pFontComic, 52, v36, ui_game_character_record_playerbuff_colors[i], aSpellNames[20 + i], 0, 0, 0); + sub_41D20D_buff_remaining_time_string(v36, window, buff->uExpireTime - pParty->uTimePlayed, pFontComic); } } @@ -1044,193 +860,126 @@ window->DrawText(pFontArrus, 14, 114, 0, pTmpBuf.data(), 0, 0, 0); } - - //----- (0041A57E) -------------------------------------------------------- void GameUI_QuickRef_Draw() { - //unsigned int v0; // ebx@1 - //unsigned int v1; // eax@1 - //Player *pPlayer; // ebp@2 - //int v3; // eax@6 - //int v4; // edi@6 - unsigned int v5; // eax@7 - unsigned int v6; // edi@9 - unsigned int v7; // edi@11 - //signed int v8; // eax@13 - unsigned int v9; // eax@13 - unsigned int v10; // edi@13 - //int v11; // eax@15 - unsigned int v12; // eax@15 - unsigned int v13; // edi@15 - //int v14; // eax@17 - //int v15; // ST18_4@17 - //int v16; // ebx@17 - //int v17; // eax@17 - unsigned int v18; // eax@17 - unsigned int v19; // edi@17 - //int v20; // eax@19 - unsigned int v21; // edi@19 - char *v22; // eax@21 - unsigned int v23; // edi@21 - //int v24; // eax@23 - unsigned int v25; // edi@23 - char *v26; // eax@25 - unsigned int v27; // edi@25 - int v28; // ecx@27 - char *v29; // eax@27 - signed int v30; // edx@27 - unsigned int v31; // edi@31 - unsigned int v32; // edi@33 - const char *v33; // ST10_4@35 - unsigned int v34; // eax@35 - unsigned int v35; // edi@35 - //unsigned __int8 v36; // al@37 - char *v37; // eax@38 - int v38; // eax@41 - signed int v39; // edi@42 - //char *v40; // eax@45 - //unsigned int v41; // eax@45 - signed int v43; // [sp+10h] [bp-1Ch]@1 - unsigned int v44; // [sp+14h] [bp-18h]@2 - int v45; // [sp+18h] [bp-14h]@1 - //unsigned int v46; // [sp+1Ch] [bp-10h]@1 - //unsigned int v47; // [sp+20h] [bp-Ch]@1 - unsigned int v48; // [sp+24h] [bp-8h]@33 - //unsigned int v49; // [sp+28h] [bp-4h]@1 + unsigned int pTextColor; // eax@7 + unsigned int pX; // [sp+14h] [bp-18h]@2 + unsigned int pY; // edi@9 + int pSkillsCount; // ecx@27 + char *pText; // eax@38 + int pFontHeight; // [sp+18h] [bp-14h]@1 - //v0 = 0; - //v47 = TargetColor(0xFFu, 0xFFu, 0x9Bu); - //v49 = TargetColor(0xFFu, 0, 0); - //v46 = TargetColor(0, 0xFFu, 0); - //v1 = pIcons_LOD->LoadTexture("quikref", TEXTURE_16BIT_PALETTE); pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->LoadTexturePtr("quikref", TEXTURE_16BIT_PALETTE)); - v43 = 0; - v45 = LOBYTE(pFontArrus->uFontHeight) + 1; - do - { - auto player = &pParty->pPlayers[v43]; - v44 = 94 * v43 + 89; - if ( v43 == 0 ) - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, 0x12u, 0, pGlobalTXT_LocalizationStrings[149], 60, 0);//Name - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 94 * v43 + 89, 0x12u, ui_character_header_text_color, player->pName, 84, 0); - if ( v43 == 0 ) - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, 0x2Fu, 0, pGlobalTXT_LocalizationStrings[131], 60, 0); //Óðîâ. - sprintf(pTmpBuf.data(), "%lu", player->GetActualLevel()); - if ( player->GetActualLevel() <= player->GetBaseLevel()) - v5 = player->GetExperienceDisplayColor(); - else - v5 = ui_character_bonus_text_color; - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, 0x2Fu, v5, pTmpBuf.data(), 84, 0); - v6 = v45 + 47; - if ( v43 == 0 ) - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v45 + 47, 0, pGlobalTXT_LocalizationStrings[41], 60, 0);//Êëàññ - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v6, 0, pClassNames[player->classType], 84, 0); - v7 = v45 + v6; - if ( v43 == 0 ) - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v7, 0, pGlobalTXT_LocalizationStrings[107], 60, 0);//Çäîð. - sprintf(pTmpBuf.data(), "%d", player->sHealth); - v9 = UI_GetHealthManaStringColor(player->sHealth, player->GetMaxHealth()); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v7, v9, pTmpBuf.data(), 84, 0); - v10 = v45 + v7; - if ( v43 == 0 ) - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v10, 0, pGlobalTXT_LocalizationStrings[209], 60, 0);//Ìàíà - sprintf(pTmpBuf.data(), "%d", player->sMana); - v12 = UI_GetHealthManaStringColor(player->sMana, player->GetMaxMana()); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v10, v12, pTmpBuf.data(), 84, 0); - v13 = v45 + v10; - if ( v43 == 0 ) - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v13, 0, pGlobalTXT_LocalizationStrings[0], 60, 0);//Êëàññ áðîíè - sprintf(pTmpBuf.data(), "%d", player->GetActualAC()); - v18 = UI_GetHealthManaStringColor(player->GetActualAC(), player->GetBaseAC()); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v13, v18, pTmpBuf.data(), 84, 0); - v19 = v45 + v13; - if ( !v43 ) - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v19, 0, pGlobalTXT_LocalizationStrings[18], 60, 0);//Àòàêà - sprintf(pTmpBuf.data(), "%+d", player->GetActualAttack(0)); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v19, 0, pTmpBuf.data(), 84, 0); - v21 = v45 + v19; - if ( !v43 ) - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v21, 0, pGlobalTXT_LocalizationStrings[66], 60, 0);//Ïîâð. - v22 = player->GetMeleeDamageString(); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v21, 0, v22, 84, 0); - v23 = v45 + v21; - if ( !v43 ) - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v23, 0, pGlobalTXT_LocalizationStrings[203], 60, 0);// Ñòðåëÿòü - sprintf(pTmpBuf.data(), "%+d", player->GetRangedAttack()); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v23, 0, pTmpBuf.data(), 84, 0); - v25 = v45 + v23; - if ( !v43 ) - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v25, 0, pGlobalTXT_LocalizationStrings[66], 60, 0);//Ïîâð. - v26 = player->GetRangedDamageString(); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v25, 0, v26, 84, 0); - v27 = v45 + v25; - if ( !v43 ) - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v27, 0, pGlobalTXT_LocalizationStrings[205], 60, 0);//Íàâûêè - v28 = 0; - v29 = (char *)player->pActiveSkills; - v30 = 36; - do - { - if ( *(short *)v29 ) - ++v28; - v29 += 2; - --v30; - } - while ( v30 ); - sprintf(pTmpBuf.data(), "%lu", v28); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v27, 0, pTmpBuf.data(), 84, 0); - v31 = v45 + v27; - if ( !v43 ) - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v31, 0, pGlobalTXT_LocalizationStrings[168], 60, 0);//Î÷êè - sprintf(pTmpBuf.data(), "%lu", player->uSkillPoints); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v31, player->uSkillPoints ? ui_character_bonus_text_color : ui_character_default_text_color, pTmpBuf.data(), 84, 0); - v32 = v45 + v31; - v48 = player->GetMajorConditionIdx(); - if ( !v43 ) - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v32, 0, pGlobalTXT_LocalizationStrings[45], 60, 0);//Ñîñò. - v33 = aCharacterConditionNames[v48]; - v34 = GetConditionDrawColor(v48); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v32, v34, v33, 84, 0); - v35 = v45 + v32; - if ( !v43 ) - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v35, 0, pGlobalTXT_LocalizationStrings[170], 60, 0);//Á.Ïðèì. - if (player->uQuickSpell) - v37 = pSpellStats->pInfos[player->uQuickSpell].pShortName; - else - v37 = pGlobalTXT_LocalizationStrings[153];//Íåò - pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v35, 0, v37, 84, 0); - ++v43; - } - while ( v43 < 4 ); + pFontHeight = LOBYTE(pFontArrus->uFontHeight) + 1; + for ( uint i = 0; i < 4; ++i ) + { + auto player = &pParty->pPlayers[i]; + pX = 94 * i + 89; + if ( i == 0 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 22, 18, 0, pGlobalTXT_LocalizationStrings[149], 60, 0);//Name + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 94 * i + 89, 18, ui_character_header_text_color, player->pName, 84, 0); + if ( i == 0 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 22, 47, 0, pGlobalTXT_LocalizationStrings[131], 60, 0); //Óðîâ. + sprintf(pTmpBuf.data(), "%lu", player->GetActualLevel()); + if ( player->GetActualLevel() <= player->GetBaseLevel()) + pTextColor = player->GetExperienceDisplayColor(); + else + pTextColor = ui_character_bonus_text_color; + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, 47, pTextColor, pTmpBuf.data(), 84, 0); + pY = pFontHeight + 47; + if ( i == 0 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 22, pFontHeight + 47, 0, pGlobalTXT_LocalizationStrings[41], 60, 0);//Êëàññ + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, pY, 0, pClassNames[player->classType], 84, 0); + pY = pFontHeight + pY; + if ( i == 0 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 22, pY, 0, pGlobalTXT_LocalizationStrings[107], 60, 0);//Çäîð. + sprintf(pTmpBuf.data(), "%d", player->sHealth); + pTextColor = UI_GetHealthManaAndOtherQualitiesStringColor(player->sHealth, player->GetMaxHealth()); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, pY, pTextColor, pTmpBuf.data(), 84, 0); + pY = pFontHeight + pY; + if ( i == 0 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 22, pY, 0, pGlobalTXT_LocalizationStrings[209], 60, 0);//Ìàíà + sprintf(pTmpBuf.data(), "%d", player->sMana); + pTextColor = UI_GetHealthManaAndOtherQualitiesStringColor(player->sMana, player->GetMaxMana()); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, pY, pTextColor, pTmpBuf.data(), 84, 0); + pY = pFontHeight + pY; + if ( i == 0 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 22, pY, 0, pGlobalTXT_LocalizationStrings[0], 60, 0);//Êëàññ áðîíè + sprintf(pTmpBuf.data(), "%d", player->GetActualAC()); + pTextColor = UI_GetHealthManaAndOtherQualitiesStringColor(player->GetActualAC(), player->GetBaseAC()); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, pY, pTextColor, pTmpBuf.data(), 84, 0); + pY = pFontHeight + pY; + if ( !i ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 22, pY, 0, pGlobalTXT_LocalizationStrings[18], 60, 0);//Àòàêà + sprintf(pTmpBuf.data(), "%+d", player->GetActualAttack(0)); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, pY, 0, pTmpBuf.data(), 84, 0); + pY = pFontHeight + pY; + if ( !i ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 22, pY, 0, pGlobalTXT_LocalizationStrings[66], 60, 0);//Ïîâð. + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, pY, 0, player->GetMeleeDamageString(), 84, 0); + pY = pFontHeight + pY; + if ( !i ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 22, pY, 0, pGlobalTXT_LocalizationStrings[203], 60, 0);// Ñòðåëÿòü + sprintf(pTmpBuf.data(), "%+d", player->GetRangedAttack()); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, pY, 0, pTmpBuf.data(), 84, 0); + pY = pFontHeight + pY; + if ( !i ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 22, pY, 0, pGlobalTXT_LocalizationStrings[66], 60, 0);//Ïîâð. + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, pY, 0, player->GetRangedDamageString(), 84, 0); + pY = pFontHeight + pY; + if ( !i ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 22, pY, 0, pGlobalTXT_LocalizationStrings[205], 60, 0);//Íàâûêè + pSkillsCount = 0; + for ( uint j = 0; j <= 36; ++j ) + { + if ( player->pActiveSkills[j] ) + ++pSkillsCount; + } + sprintf(pTmpBuf.data(), "%lu", pSkillsCount); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, pY, 0, pTmpBuf.data(), 84, 0); + pY = pFontHeight + pY; + if ( !i ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 22, pY, 0, pGlobalTXT_LocalizationStrings[168], 60, 0);//Î÷êè + sprintf(pTmpBuf.data(), "%lu", player->uSkillPoints); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, pY, player->uSkillPoints ? ui_character_bonus_text_color : ui_character_default_text_color, pTmpBuf.data(), 84, 0); + pY = pFontHeight + pY; + if ( !i ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 22, pY, 0, pGlobalTXT_LocalizationStrings[45], 60, 0);//Ñîñò. + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, pY, pTextColor, aCharacterConditionNames[player->GetMajorConditionIdx()], 84, 0); + pY = pFontHeight + pY; + if ( !i ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 22, pY, 0, pGlobalTXT_LocalizationStrings[170], 60, 0);//Á.Ïðèì. + if (player->uQuickSpell) + pText = pSpellStats->pInfos[player->uQuickSpell].pShortName; + else + pText = pGlobalTXT_LocalizationStrings[153];//Íåò + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, pX, pY, 0, pText, 84, 0); + } - v38 = GetPartyReputation(); - if ( v38 >= 0 ) - { - if ( v38 <= 5 ) - v39 = ui_character_default_text_color; - else - v39 = ui_character_bonus_text_color_neg; - } - else - v39 = ui_character_bonus_text_color; + if ( GetPartyReputation() >= 0 ) + { + if ( GetPartyReputation() <= 5 ) + pTextColor = ui_character_default_text_color; + else + pTextColor = ui_character_bonus_text_color_neg; + } + else + pTextColor = ui_character_bonus_text_color; - sprintf(pTmpBuf.data(), "%s: \f%05d%s\f00000", pGlobalTXT_LocalizationStrings[180], v39, GetReputationString(v38));//Reputation - pGUIWindow_CurrentMenu->DrawText(pFontArrus, 22, 323, 0, pTmpBuf.data(), 0, 0, 0); - - sprintf(pTmpBuf.data(), "\r261%s: %d", pGlobalTXT_LocalizationStrings[84], pParty->GetPartyFame());// Fame Ñëàâà - pGUIWindow_CurrentMenu->DrawText(pFontArrus, 0, 323, 0, pTmpBuf.data(), 0, 0, 0); + sprintf(pTmpBuf.data(), "%s: \f%05d%s\f00000", pGlobalTXT_LocalizationStrings[180], pTextColor, GetReputationString(GetPartyReputation()));//Reputation + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 22, 323, 0, pTmpBuf.data(), 0, 0, 0); + sprintf(pTmpBuf.data(), "\r261%s: %d", pGlobalTXT_LocalizationStrings[84], pParty->GetPartyFame());// Fame Ñëàâà + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 0, 323, 0, pTmpBuf.data(), 0, 0, 0); } - - //----- (0041AD6E) -------------------------------------------------------- void GameUI_DrawRightPanelItems() { - if (GameUI_RightPanel_BookFlashTimer > pParty->uTimePlayed) + if ( (unsigned long long)GameUI_RightPanel_BookFlashTimer > pParty->uTimePlayed ) GameUI_RightPanel_BookFlashTimer = 0; - if (pParty->uTimePlayed - GameUI_RightPanel_BookFlashTimer > 128) + if ( pParty->uTimePlayed - GameUI_RightPanel_BookFlashTimer > 128 ) { GameUI_RightPanel_BookFlashTimer = pParty->uTimePlayed; @@ -1265,69 +1014,52 @@ } } - //----- (0041B0C9) -------------------------------------------------------- void GameUI_DrawLifeManaBars() { double v3; // st7@3 double v7; // st7@25 - Texture *v9; // [sp-4h] [bp-30h]@10 - Texture *v10; // [sp+Ch] [bp-20h]@1 + Texture *pTextureHealth; // [sp-4h] [bp-30h]@10 + Texture *pTextureMana; // [sp+Ch] [bp-20h]@1 - - v10 = pIcons_LOD->GetTexture(uTextureID_BarBlue); - + pTextureMana = pIcons_LOD->GetTexture(uTextureID_BarBlue); for (uint i = 0; i < 4; ++i) { - auto player = pParty->pPlayers + i; - - if (player->sHealth > 0) - { + if (pParty->pPlayers[i].sHealth > 0) + { int v17 = 0; if (i == 2 || i == 3) v17 = 2; - - v3 = (double)player->sHealth / (double)player->GetMaxHealth(); + v3 = (double)pParty->pPlayers[i].sHealth / (double)pParty->pPlayers[i].GetMaxHealth(); if( v3 > 0.5 ) { if ( v3 > 1.0 ) v3 = 1.0; - v9 = pIcons_LOD->GetTexture(uTextureID_BarGreen); + pTextureHealth = pIcons_LOD->GetTexture(uTextureID_BarGreen); } else if ( v3 > 0.25 ) - v9 = pIcons_LOD->GetTexture(uTextureID_BarYellow); + pTextureHealth = pIcons_LOD->GetTexture(uTextureID_BarYellow); else if ( v3 > 0.0 ) - v9 = pIcons_LOD->GetTexture(uTextureID_BarRed); - - - if( v3 > 0.0 ) - { - pRenderer->SetTextureClipRect(v17 + pHealthBarPos[i], - (signed __int64)((1.0 - v3) * v9->uTextureHeight) + 402, - v17 + pHealthBarPos[i] + v9->uTextureWidth, - v9->uTextureHeight + 402); - - pRenderer->DrawTextureIndexed(v17 + pHealthBarPos[i], 402, v9); - pRenderer->ResetTextureClipRect(); - } - } - - - if (player->sMana > 0) + pTextureHealth = pIcons_LOD->GetTexture(uTextureID_BarRed); + if( v3 > 0.0 ) + { + pRenderer->SetTextureClipRect(v17 + pHealthBarPos[i], (signed __int64)((1.0 - v3) * pTextureHealth->uTextureHeight) + 402, + v17 + pHealthBarPos[i] + pTextureHealth->uTextureWidth, pTextureHealth->uTextureHeight + 402); + pRenderer->DrawTextureIndexed(v17 + pHealthBarPos[i], 402, pTextureHealth); + pRenderer->ResetTextureClipRect(); + } + } + if (pParty->pPlayers[i].sMana > 0) { - v7 = player->sMana / (double)player->GetMaxMana(); + v7 = pParty->pPlayers[i].sMana / (double)pParty->pPlayers[i].GetMaxMana(); if ( v7 > 1.0 ) v7 = 1.0; - int v17 = 0; if (i == 2) v17 = 1; - - pRenderer->SetTextureClipRect(v17 + pManaBarPos[i], - (signed __int64)((1.0 - v7) * v10->uTextureHeight) + 402, - v17 + pManaBarPos[i] + v10->uTextureWidth, - v10->uTextureHeight + 402); - pRenderer->DrawTextureIndexed(v17 + pManaBarPos[i], 402, v10); + pRenderer->SetTextureClipRect(v17 + pManaBarPos[i], (signed __int64)((1.0 - v7) * pTextureMana->uTextureHeight) + 402, + v17 + pManaBarPos[i] + pTextureMana->uTextureWidth, pTextureMana->uTextureHeight + 402); + pRenderer->DrawTextureIndexed(v17 + pManaBarPos[i], 402, pTextureMana); pRenderer->ResetTextureClipRect(); } } @@ -1336,8 +1068,7 @@ //----- (0041B3B6) -------------------------------------------------------- void GameUI_DrawRightPanel() { - pRenderer->DrawTextureTransparent(pViewport->uViewportBR_X, 0, - pIcons_LOD->GetTexture(uTextureID_right_panel)); + pRenderer->DrawTextureTransparent(pViewport->uViewportBR_X, 0, pIcons_LOD->GetTexture(uTextureID_right_panel)); } //----- (0041B3E2) -------------------------------------------------------- @@ -1351,12 +1082,11 @@ GameUI_DrawRightPanelItems(); } - //----- (0041C047) -------------------------------------------------------- void GameUI_Footer_2() { - char *v1; // edx@2 - int v5; // eax@5 + char *v1; // edx@2 + int v5; // eax@5 pRenderer->DrawTextureRGB(0, 352, pTexture_StatusBar); if (GameUI_Footer_TimeLeft) @@ -1375,158 +1105,104 @@ //----- (0041C0B8) -------------------------------------------------------- void GameUI_SetFooterString(const char *pStr) { - const char *v1; // esi@1 - int i; // eax@7 - int j; // eax@11 + const char *v1; // esi@1 - v1 = pStr; - if ( pStr && strcmp(pStr, "test") && !IsBadStringPtrA(v1, 1) && (*v1 || GameUI_Footer_TimeLeft) ) - { - if ( GameUI_Footer_TimeLeft ) - { - for ( i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); - i > 450; - i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()) ) - GameUI_Footer_TimedString[strlen(GameUI_Footer_TimedString.data()) - 1] = 0; - } - else - { - strcpy(pFooterString.data(), v1); - for ( j = pFontLucida->GetLineWidth(pFooterString.data()); - j > 450; - j = pFontLucida->GetLineWidth(pFooterString.data()) ) - pFooterString[strlen(pFooterString.data()) - 1] = 0; - } - } + v1 = pStr; + if ( pStr && strcmp(pStr, "test") && !IsBadStringPtrA(pStr, 1) && (*v1 || GameUI_Footer_TimeLeft) ) + { + if ( GameUI_Footer_TimeLeft ) + { + for ( int i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); i > 450; i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()) ) + GameUI_Footer_TimedString[strlen(GameUI_Footer_TimedString.data()) - 1] = 0; } + else + { + strcpy(pFooterString.data(), v1); + for ( int j = pFontLucida->GetLineWidth(pFooterString.data()); j > 450; j = pFontLucida->GetLineWidth(pFooterString.data()) ) + pFooterString[strlen(pFooterString.data()) - 1] = 0; + } + } +} //----- (0041C179) -------------------------------------------------------- void GameUI_Footer() { - //unsigned int v0; // ebp@1 - char *v1; // edi@5 - int v2; // eax@5 - unsigned int v3; // esi@5 - size_t v4; // eax@6 - GUIFont *v5; // ecx@6 - int v6; // eax@9 - size_t v7; // eax@10 - GUIFont *v8; // ecx@10 - char v9; // zf@12 - //unsigned int v10; // ST08_4@13 - int v11; // eax@13 + char *v1; // edi@5 + int v2; // eax@5 + int v6; // eax@9 + char v9; // zf@12 - if ( pFooterString[0] || GameUI_Footer_TimeLeft || bForceDrawFooter ) - { - pRenderer->DrawTextureRGB(0, 352u, pTexture_StatusBar); - if ( GameUI_Footer_TimeLeft ) - { - v1 = GameUI_Footer_TimedString.data(); - v2 = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); - v3 = 450; - while ( v2 > 450 ) - { - v4 = strlen(GameUI_Footer_TimedString.data()); - v5 = pFontLucida; - GameUI_Footer_TimedString[v4 - 1] = 0; - v2 = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); - } - } - else - { - v1 = pFooterString.data(); - v6 = pFontLucida->GetLineWidth(pFooterString.data()); - v3 = 450; - while ( v6 > 450 ) - { - v7 = strlen(pFooterString.data()); - v8 = pFontLucida; - pFooterString[v7 - 1] = 0; - v6 = pFontLucida->GetLineWidth(pFooterString.data()); - } - } - v9 = *v1 == 0; - bForceDrawFooter = 0; - if ( !v9 ) - { - v11 = pFontLucida->AlignText_Center(v3, v1); - pPrimaryWindow->DrawText(pFontLucida, v11 + 11, 357, uGameUIFontMain, v1, 0, 0, uGameUIFontShadow); - } - } + if ( pFooterString[0] || GameUI_Footer_TimeLeft || bForceDrawFooter ) + { + pRenderer->DrawTextureRGB(0, 352, pTexture_StatusBar); + if ( GameUI_Footer_TimeLeft ) + { + v1 = GameUI_Footer_TimedString.data(); + v2 = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); + while ( v2 > 450 ) + { + GameUI_Footer_TimedString[strlen(GameUI_Footer_TimedString.data()) - 1] = 0; + v2 = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); + } } + else + { + v1 = pFooterString.data(); + v6 = pFontLucida->GetLineWidth(pFooterString.data()); + while ( v6 > 450 ) + { + pFooterString[strlen(pFooterString.data()) - 1] = 0; + v6 = pFontLucida->GetLineWidth(pFooterString.data()); + } + } + v9 = *v1 == 0; + bForceDrawFooter = 0; + if ( !v9 ) + pPrimaryWindow->DrawText(pFontLucida, pFontLucida->AlignText_Center(450, v1) + 11, 357, uGameUIFontMain, v1, 0, 0, uGameUIFontShadow); + } +} // 5C35BC: using guessed type int bForceDrawFooter; - - //----- (00420EFF) -------------------------------------------------------- void GameUI_WritePointedObjectStatusString() { int v1; // ebx@6 GUIWindow *pWindow; // edi@7 GUIButton *pButton; // ecx@11 - Player *pPlayer; // eax@19 - char v5; // cl@19 - unsigned int v6; // eax@19 int v7; // ecx@19 - __int16 v8; // fps@23 - unsigned __int8 v9; // c0@23 - unsigned __int8 v10; // c3@23 enum UIMessageType pMessageType1; // esi@24 - //int v12; // edx@25 - char *v13; // ecx@28 int v14; // eax@41 ItemGen *pItemGen; // ecx@44 int v16; // ecx@46 - const char *v17; // eax@49 signed int v18; // eax@55 signed int v18b; signed int v19; // ecx@63 BLVFace *pFace; // eax@69 - __int16 v21; // ax@70 - const char *v22; // eax@72 - LevelDecoration *v23; // ecx@75 - LevelDecoration *v24; // esi@75 - __int16 v25; // ax@75 - const char *v26; // ecx@79 - Actor *pActor; // ecx@82 + const char *pText; // ecx@79 char *v28; // esi@82 - int v29; // eax@82 - signed int v30; // ecx@88 - const char *v31; // eax@91 - __int16 v32; // fps@109 - //unsigned __int8 v33; // c0@109 - //unsigned __int8 v34; // c3@109 enum UIMessageType pMessageType2; // esi@110 - //int v36; // edx@111 enum UIMessageType pMessageType3; // edx@117 - //int v38; // ecx@118 - const char *v39; // [sp-8h] [bp-E8h]@20 - char *v40; // [sp-8h] [bp-E8h]@83 - int v41; // [sp-4h] [bp-E4h]@20 char Str1[200]; // [sp+Ch] [bp-D4h]@129 unsigned int pX; // [sp+D4h] [bp-Ch]@1 unsigned int pY; // [sp+D8h] [bp-8h]@1 unsigned int v45; // [sp+DCh] [bp-4h]@21 - v13 = nullptr; + int interaction_distance_limit = 512; pMouse->uPointingObjectID = 0; pMouse->GetClickPos(&pX, &pY); - if ( pX < 0 || (signed int)pX > 639 || pY < 0 || (signed int)pY > 479 )//( (pX & 0x80000000u) != 0 || (signed int)pX > 639 || (pY & 0x80000000u) != 0 || (signed int)pY > 479 ) + if ( pX < 0 || pX > 639 || pY < 0 || pY > 479 ) return; if (pCurrentScreen == SCREEN_GAME) { - if ( (signed int)pX > 467 || (signed int)pY > 351 ) + if ( pX > 467 || pY > 351 ) goto _click_on_game_ui; if ( pRenderer->pRenderD3D ) // inlined mm8::4C1E01 { v18 = pGame->pVisInstance->get_picked_object_zbuf_val(); - if ( (signed int)pX < (signed int)pViewport->uScreen_TL_X - || (signed int)pX > (signed int)pViewport->uScreen_BR_X - || (signed int)pY < (signed int)pViewport->uScreen_TL_Y - || (signed int)pY > (signed int)pViewport->uScreen_BR_Y ) + if ( pX < (unsigned int)pViewport->uScreen_TL_X || pX > (unsigned int)pViewport->uScreen_BR_X + || pY < (unsigned int)pViewport->uScreen_TL_Y || pY > (unsigned int)pViewport->uScreen_BR_Y ) v18 = -1; if ( v18 == -1 ) - //goto LABEL_61; { pMouse->uPointingObjectID = 0; if ( pMouse->uPointingObjectID == 0 ) @@ -1542,38 +1218,23 @@ } } else - { v18 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; - } pMouse->uPointingObjectID = (unsigned __int16)v18; v19 = (signed)PID_ID(v18); + //For Items------------------------------------ if (PID_TYPE(v18) == OBJECT_Item) { - v30 = v19; - if ( pObjectList->pObjects[pSpriteObjects[v30].uObjectDescID].uFlags & 0x10 ) - //goto LABEL_73; + if ( pObjectList->pObjects[pSpriteObjects[v19].uObjectDescID].uFlags & 0x10 ) { pMouse->uPointingObjectID = 0; - //goto LABEL_50; - uLastPointedObjectID = 1; - if ( pMouse->uPointingObjectID == 0 ) - { - if ( uLastPointedObjectID != 0 ) - { - pFooterString[0] = 0; - bForceDrawFooter = 1; - } - } - uLastPointedObjectID = pMouse->uPointingObjectID; + pFooterString[0] = 0; + bForceDrawFooter = 1; + uLastPointedObjectID = 0; return; } if ( v18 >= (signed int)0x2000000u || pParty->pPickedItem.uItemID ) { - v22 = pSpriteObjects[v30].stru_24.GetDisplayName(); -//LABEL_93: - v26 = v22; - //goto LABEL_87; - GameUI_SetFooterString(v26); + GameUI_SetFooterString(pSpriteObjects[v19].stru_24.GetDisplayName()); if ( pMouse->uPointingObjectID == 0 ) { if ( uLastPointedObjectID != 0 ) @@ -1585,57 +1246,73 @@ uLastPointedObjectID = pMouse->uPointingObjectID; return; } - v31 = pSpriteObjects[v30].stru_24.GetDisplayName(); v28 = pTmpBuf.data(); - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[470], v31);// "Get %s" + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[470], pSpriteObjects[v19].stru_24.GetDisplayName());// "Get %s" } - else +//For Decorations---------------------------------- + if (PID_TYPE(v18) == OBJECT_Decoration) { - if (PID_TYPE(v18) != OBJECT_Actor) + if ( !pLevelDecorations[v19].uEventID ) { - if (PID_TYPE(v18) == OBJECT_Decoration) + if ( pLevelDecorations[v19].IsInteractive() ) + pText = pNPCTopics[stru_5E4C90._decor_events[pLevelDecorations[v19]._idx_in_stru123 - 75] + 379].pTopic; + else + pText = pDecorationList->pDecorations[pLevelDecorations[v19].uDecorationDescID].field_20; + GameUI_SetFooterString(pText); + if ( pMouse->uPointingObjectID == 0 ) { - v23 = &pLevelDecorations[v19]; - v24 = v23; - v25 = v23->field_16_event_id; - if ( !v25 ) + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + if ( !GetEventHintString(pLevelDecorations[v19].uEventID) ) + { + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) { - if ( v23->IsInteractive() ) - v26 = pNPCTopics[stru_5E4C90._decor_events[v24->_idx_in_stru123 - 75] + 379].pTopic; - else - v26 = pDecorationList->pDecorations[v24->uDecorationDescID].field_20; - //goto LABEL_87; - GameUI_SetFooterString(v26); - if ( pMouse->uPointingObjectID == 0 ) - { - if ( uLastPointedObjectID != 0 ) - { - pFooterString[0] = 0; - bForceDrawFooter = 1; - } - } - uLastPointedObjectID = pMouse->uPointingObjectID; + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + GameUI_SetFooterString(GetEventHintString(pLevelDecorations[v19].uEventID)); + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + //For 3D Model------------------------------------- + if (PID_TYPE(v18) == OBJECT_BModel) + { + if ( HIWORD(v18) < interaction_distance_limit ) + { + if ( uCurrentlyLoadedLevelType != LEVEL_Indoor) + { + v18b = (signed int)(unsigned __int16)v18 >> 9; + if ( !pOutdoor->pBModels[v18b].pFaces[v19 & 0x3F].sCogTriggeredID + || !GetEventHintString(pOutdoor->pBModels[v18b].pFaces[v19 & 0x3F].sCogTriggeredID) ) + { + pMouse->uPointingObjectID = 0; + pFooterString[0] = 0; + bForceDrawFooter = 1; + uLastPointedObjectID = 0; return; } - v22 = GetEventHintString(v25); - if ( !v22 ) - //goto _return; - { - if ( pMouse->uPointingObjectID == 0 ) - { - if ( uLastPointedObjectID != 0 ) - { - pFooterString[0] = 0; - bForceDrawFooter = 1; - } - } - uLastPointedObjectID = pMouse->uPointingObjectID; - return; - } - //goto LABEL_93; - v26 = v22; - //goto LABEL_87; - GameUI_SetFooterString(v26); + GameUI_SetFooterString(GetEventHintString(pOutdoor->pBModels[v18b].pFaces[v19 & 0x3F].sCogTriggeredID)); if ( pMouse->uPointingObjectID == 0 ) { if ( uLastPointedObjectID != 0 ) @@ -1647,89 +1324,19 @@ uLastPointedObjectID = pMouse->uPointingObjectID; return; } - if (PID_TYPE(v18) == OBJECT_BModel) + pFace = &pIndoor->pFaces[v19]; + if ( BYTE3(pFace->uAttributes) & 6 ) { - if ( HIWORD(v18) < 512) + if ( !pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID + || !GetEventHintString(pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID) ) { - if ( uCurrentlyLoadedLevelType != LEVEL_Indoor) - { - v18b = (signed int)(unsigned __int16)v18 >> 9; - v21 = pOutdoor->pBModels[v18b].pFaces[v19 & 0x3F].sCogTriggeredID; - //goto LABEL_71; - if ( !v21 || (v22 = GetEventHintString(v21)) == 0 ) - //goto LABEL_73; - { - pMouse->uPointingObjectID = 0; - //goto LABEL_50; - uLastPointedObjectID = 1; - if ( pMouse->uPointingObjectID == 0 ) - { - if ( uLastPointedObjectID != 0 ) - { - pFooterString[0] = 0; - bForceDrawFooter = 1; - } - } - uLastPointedObjectID = pMouse->uPointingObjectID; - return; - } - //goto LABEL_93; - v26 = v22; - //goto LABEL_87; - GameUI_SetFooterString(v26); - if ( pMouse->uPointingObjectID == 0 ) - { - if ( uLastPointedObjectID != 0 ) - { - pFooterString[0] = 0; - bForceDrawFooter = 1; - } - } - uLastPointedObjectID = pMouse->uPointingObjectID; - return; - } - pFace = &pIndoor->pFaces[v19]; - if ( BYTE3(pFace->uAttributes) & 6 ) - { - v21 = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID; -//LABEL_71: - if ( !v21 || (v22 = GetEventHintString(v21)) == 0 ) - //goto LABEL_73; - { - pMouse->uPointingObjectID = 0; - //goto LABEL_50; - uLastPointedObjectID = 1; - if ( pMouse->uPointingObjectID == 0 ) - { - if ( uLastPointedObjectID != 0 ) - { - pFooterString[0] = 0; - bForceDrawFooter = 1; - } - } - uLastPointedObjectID = pMouse->uPointingObjectID; - return; - } - //goto LABEL_93; - v26 = v22; - //goto LABEL_87; - GameUI_SetFooterString(v26); - if ( pMouse->uPointingObjectID == 0 ) - { - if ( uLastPointedObjectID != 0 ) - { - pFooterString[0] = 0; - bForceDrawFooter = 1; - } - } - uLastPointedObjectID = pMouse->uPointingObjectID; - return; - } + pMouse->uPointingObjectID = 0; + pFooterString[0] = 0; + bForceDrawFooter = 1; + uLastPointedObjectID = 0; + return; } -//LABEL_73: - pMouse->uPointingObjectID = 0; - //goto LABEL_50; - uLastPointedObjectID = 1; + GameUI_SetFooterString(GetEventHintString(pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID)); if ( pMouse->uPointingObjectID == 0 ) { if ( uLastPointedObjectID != 0 ) @@ -1741,22 +1348,27 @@ uLastPointedObjectID = pMouse->uPointingObjectID; return; } -//LABEL_61: + } + pMouse->uPointingObjectID = 0; + pFooterString[0] = 0; + bForceDrawFooter = 1; + uLastPointedObjectID = 0; + return; + } + else + { + if (PID_TYPE(v18) != OBJECT_Actor) + { pMouse->uPointingObjectID = 0; - //goto _return; - if ( pMouse->uPointingObjectID == 0 ) + if ( uLastPointedObjectID != 0 ) { - if ( uLastPointedObjectID != 0 ) - { - pFooterString[0] = 0; - bForceDrawFooter = 1; - } + pFooterString[0] = 0; + bForceDrawFooter = 1; } uLastPointedObjectID = pMouse->uPointingObjectID; return; } if ( v18 >= 335544320 ) - //goto LABEL_61; { pMouse->uPointingObjectID = 0; if ( pMouse->uPointingObjectID == 0 ) @@ -1770,19 +1382,14 @@ uLastPointedObjectID = pMouse->uPointingObjectID; return; } - pActor = &pActors[v19]; v28 = pTmpBuf.data(); - v29 = pActor->dword_000334_unique_name; - if ( v29 ) - v40 = pMonsterStats->pPlaceStrings[v29]; + if ( pActors[v19].dword_000334_unique_name ) + pText = pMonsterStats->pPlaceStrings[pActors[v19].dword_000334_unique_name]; else - v40 = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].pName; - strncpy(pTmpBuf.data(), v40, 0x7D0u); + pText = pMonsterStats->pInfos[pActors[v19].pMonsterInfo.uID].pName; + strncpy(pTmpBuf.data(), pText, 0x7D0u); } - v26 = v28; -//LABEL_87: - GameUI_SetFooterString(v26); - //goto _return; + GameUI_SetFooterString(v28); if ( pMouse->uPointingObjectID == 0 ) { if ( uLastPointedObjectID != 0 ) @@ -1816,17 +1423,12 @@ && (signed int)pY >= (signed int)pButton->uY && (signed int)pY <= (signed int)pButton->uW ) { - //LABEL_24: pMessageType1 = (UIMessageType)pButton->field_1C; if ( pMessageType1 ) { pMessageQueue_50CBD0->AddMessage(pMessageType1, pButton->msg_param, 0); } - //LABEL_28: - v13 = pButton->pButtonName; - //_set_status_and_ret: - GameUI_SetFooterString(v13); - //LABEL_131: + GameUI_SetFooterString(pButton->pButtonName); uLastPointedObjectID = 1; return; } @@ -1846,8 +1448,7 @@ { pMessageQueue_50CBD0->AddMessage(pMessageType1, pButton->msg_param, 0); } - v13 = pButton->pButtonName; - GameUI_SetFooterString(v13); + GameUI_SetFooterString(pButton->pButtonName); uLastPointedObjectID = 1; return; //} @@ -1856,33 +1457,16 @@ } else // click on skill { - if ( pButton->uButtonType == 3 - && (signed int)pX >= (signed int)pButton->uX - && (signed int)pX <= (signed int)pButton->uZ - && (signed int)pY >= (signed int)pButton->uY - && (signed int)pY <= (signed int)pButton->uW ) - { - //LABEL_19: - pPlayer = pPlayers[uActiveCharacter]; - v5 = LOBYTE(pPlayer->pActiveSkills[pButton->msg_param]); - v6 = pPlayer->uSkillPoints; - v7 = (v5 & 0x3F) + 1; - if ( v6 < v7 ) - { - v41 = v7 - v6; - v39 = pGlobalTXT_LocalizationStrings[469];// "You need %d more Skill Points to advance here" - } - else - { - v41 = v7; - v39 = pGlobalTXT_LocalizationStrings[468];// "Clicking here will spend %d Skill Points" - } - sprintf(Str1, v39, v41); - v13 = Str1; - //goto _set_status_and_ret; - GameUI_SetFooterString(v13); - uLastPointedObjectID = 1; - return; + if ( pButton->uButtonType == 3 && pX >= pButton->uX && pX <= pButton->uZ && pY >= pButton->uY && pY <= pButton->uW ) + { + v7 = (LOBYTE(pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param]) & 0x3F) + 1; + if ( pPlayers[uActiveCharacter]->uSkillPoints < v7 ) + sprintf(Str1, pGlobalTXT_LocalizationStrings[469], v7 - pPlayers[uActiveCharacter]->uSkillPoints);// "You need %d more Skill Points to advance here" + else + sprintf(Str1, pGlobalTXT_LocalizationStrings[468], v7);// "Clicking here will spend %d Skill Points" + GameUI_SetFooterString(Str1); + uLastPointedObjectID = 1; + return; } } } @@ -1902,7 +1486,6 @@ if ( pCurrentScreen == SCREEN_CHEST ) { ChestUI_WritePointedObjectStatusString(); - //goto _return; if ( pMouse->uPointingObjectID == 0 ) { if ( uLastPointedObjectID != 0 ) @@ -1919,7 +1502,6 @@ if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD || (v16 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]], v16 == 0) || v16 == -65536 ) - //goto _return; { if ( pMouse->uPointingObjectID == 0 ) { @@ -1933,12 +1515,8 @@ return; } pItemGen = (ItemGen *)((char *)&pParty->pPickedItem + 36 * (v16 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 4); -//LABEL_49: - v17 = pItemGen->GetDisplayName(); - GameUI_SetFooterString(v17); -//LABEL_50: + GameUI_SetFooterString(pItemGen->GetDisplayName()); uLastPointedObjectID = 1; -//_return: if ( pMouse->uPointingObjectID == 0 ) { if ( uLastPointedObjectID != 0 ) @@ -1954,7 +1532,6 @@ { v14 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; if ( v14 == 0 || v14 == -65536 || (unsigned int)v14 >= 0x1388 ) - //goto _return; { if ( pMouse->uPointingObjectID == 0 ) { @@ -1968,9 +1545,7 @@ return; } pItemGen = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItemList[v14-1]; - //goto LABEL_49; - v17 = pItemGen->GetDisplayName(); - GameUI_SetFooterString(v17); + GameUI_SetFooterString(pItemGen->GetDisplayName()); uLastPointedObjectID = 1; if ( pMouse->uPointingObjectID == 0 ) { @@ -2000,16 +1575,13 @@ { pMessageType3 = (UIMessageType)pButton->field_1C; if ( pMessageType3 == 0 ) // For books - //goto LABEL_28; { - v13 = pButton->pButtonName; - GameUI_SetFooterString(v13); + GameUI_SetFooterString(pButton->pButtonName); uLastPointedObjectID = 1; return; } pMessageQueue_50CBD0->AddMessage(pMessageType3, pButton->msg_param, 0); - //goto LABEL_131; uLastPointedObjectID = 1; return; } @@ -2034,9 +1606,7 @@ if ( pMessageType2 != 0 ) pMessageQueue_50CBD0->AddMessage(pMessageType2, pButton->msg_param, 0); - //goto LABEL_28; - v13 = pButton->pButtonName; - GameUI_SetFooterString(v13); + GameUI_SetFooterString(pButton->pButtonName); uLastPointedObjectID = 1; return; //} @@ -2046,30 +1616,15 @@ else { if ( pButton->uButtonType == 3 - && (signed int)pX >= (signed int)pButton->uX - && (signed int)pX <= (signed int)pButton->uZ - && (signed int)pY >= (signed int)pButton->uY - && (signed int)pY <= (signed int)pButton->uW ) - //goto LABEL_19; + && pX >= pButton->uX && pX <= pButton->uZ + && pY >= pButton->uY && pY <= pButton->uW ) { - pPlayer = pPlayers[uActiveCharacter]; - v5 = LOBYTE(pPlayer->pActiveSkills[pButton->msg_param]); - v6 = pPlayer->uSkillPoints; - v7 = (v5 & 0x3F) + 1; - if ( v6 < v7 ) - { - v41 = v7 - v6; - v39 = pGlobalTXT_LocalizationStrings[469];// "You need %d more Skill Points to advance here" - } + v7 = (LOBYTE(pPlayers[uActiveCharacter]->pActiveSkills[pButton->msg_param]) & 0x3F) + 1; + if ( pPlayers[uActiveCharacter]->uSkillPoints < v7 ) + sprintf(Str1, pGlobalTXT_LocalizationStrings[469], v7 - pPlayers[uActiveCharacter]->uSkillPoints);// "You need %d more Skill Points to advance here" else - { - v41 = v7; - v39 = pGlobalTXT_LocalizationStrings[468];// "Clicking here will spend %d Skill Points" - } - sprintf(Str1, v39, v41); - v13 = Str1; - //goto _set_status_and_ret; - GameUI_SetFooterString(v13); + sprintf(Str1, pGlobalTXT_LocalizationStrings[468], v7);// "Clicking here will spend %d Skill Points" + GameUI_SetFooterString(Str1); uLastPointedObjectID = 1; return; } @@ -2078,7 +1633,6 @@ } } pMouse->uPointingObjectID = sub_46A99B(); - //goto _return; if ( pMouse->uPointingObjectID == 0 ) { if ( uLastPointedObjectID != 0 ) @@ -2092,7 +1646,6 @@ } } - //----- (0044158F) -------------------------------------------------------- void GameUI_DrawCharacterSelectionFrame() { @@ -2101,372 +1654,261 @@ pIcons_LOD->GetTexture(uTextureID_GameUI_CharSelectionFrame)); } - - //----- (0044162D) -------------------------------------------------------- void GameUI_DrawPartySpells() { - unsigned int v0; // ebp@1 - //signed int v1; // edi@1 - //int v2; // eax@2 - //int v3; // ecx@5 - //__int16 *v4; // ebx@25 - //Player *v5; // edi@26 - //unsigned int v6; // [sp-4h] [bp-1Ch]@11 - Texture *v7; // [sp-4h] [bp-1Ch]@12 - //unsigned int v8; // [sp-4h] [bp-1Ch]@20 - Texture *v9; // [sp-4h] [bp-1Ch]@21 - //Player **v10; // [sp+10h] [bp-8h]@25 - - v0 = (signed __int64)((double)GetTickCount() * 0.050000001); - //v1 = 0; - for (uint i = 0; i < 14; ++i) - { - //v2 = byte_4E5DD8[v1]; - if (pParty->pPartyBuffs[byte_4E5DD8[i]].uExpireTime) - { - auto tex = pIcons_LOD->GetTexture(pTextureIDs_PartyBuffIcons[i]); - //v3 = pTextureIDs_PartyBuffIcons[i]; - pRenderer->_4A65CC(pPartySpellbuffsUI_XYs[i][0], - pPartySpellbuffsUI_XYs[i][1], tex, tex, - v0 + 20 * pPartySpellbuffsUI_smthns[i], 0, 63); - } - //++v1; - } - //while ( v1 < 14 ); + unsigned int v0; // ebp@1 + Texture *v7; // [sp-4h] [bp-1Ch]@12 + Texture *v9; // [sp-4h] [bp-1Ch]@21 - if (pCurrentScreen == SCREEN_GAME || pCurrentScreen == SCREEN_NPC_DIALOGUE) - { - if (pParty->FlyActive()) - { - if ( pParty->bFlying ) - v7 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_FlySpell, v0)->uTextureID); - else - v7 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_FlySpell, 0)->uTextureID); - if ( pRenderer->pRenderD3D ) - pRenderer->DrawTextureIndexed(8, 8, v7); - else - pRenderer->DrawTextureTransparent(8, 8, v7); - } - if (pParty->WaterWalkActive()) - { - if ( pParty->uFlags & PARTY_FLAGS_1_STANDING_ON_WATER) - v9 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_WaterWalk, v0)->uTextureID); - else - v9 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_WaterWalk, 0)->uTextureID); - if ( pRenderer->pRenderD3D ) - pRenderer->DrawTextureIndexed(396u, 8u, v9); - else - pRenderer->DrawTextureTransparent(396u, 8u, v9); - } - } - - for (uint i = 0; i < 4; ++i) - { - auto player = pParty->pPlayers + i; - - if (player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uExpireTime) - pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 427, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_Hammerhands)); - if (player->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime) - pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 393, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_Bless)); - if (player->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime) - pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 410, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_Preservation)); - if (player->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].uExpireTime) - pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 444, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_PainReflection)); - } + v0 = (signed __int64)((double)GetTickCount() * 0.050000001); + //v1 = 0; + for (uint i = 0; i < 14; ++i) + { + //v2 = byte_4E5DD8[v1]; + if (pParty->pPartyBuffs[byte_4E5DD8[i]].uExpireTime) + { + auto tex = pIcons_LOD->GetTexture(pTextureIDs_PartyBuffIcons[i]); + //v3 = pTextureIDs_PartyBuffIcons[i]; + pRenderer->_4A65CC(pPartySpellbuffsUI_XYs[i][0], + pPartySpellbuffsUI_XYs[i][1], tex, tex, + v0 + 20 * pPartySpellbuffsUI_smthns[i], 0, 63); } - - + //++v1; + } + //while ( v1 < 14 ); + if (pCurrentScreen == SCREEN_GAME || pCurrentScreen == SCREEN_NPC_DIALOGUE) + { + if (pParty->FlyActive()) + { + if ( pParty->bFlying ) + v7 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_FlySpell, v0)->uTextureID); + else + v7 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_FlySpell, 0)->uTextureID); + if ( pRenderer->pRenderD3D ) + pRenderer->DrawTextureIndexed(8, 8, v7); + else + pRenderer->DrawTextureTransparent(8, 8, v7); + } + if ( pParty->WaterWalkActive() ) + { + if ( pParty->uFlags & PARTY_FLAGS_1_STANDING_ON_WATER ) + v9 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_WaterWalk, v0)->uTextureID); + else + v9 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_WaterWalk, 0)->uTextureID); + if ( pRenderer->pRenderD3D ) + pRenderer->DrawTextureIndexed(396, 8, v9); + else + pRenderer->DrawTextureTransparent(396, 8, v9); + } + } + for (uint i = 0; i < 4; ++i) + { + if ( pParty->pPlayers[i].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uExpireTime ) + pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 427, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_Hammerhands)); + if ( pParty->pPlayers[i].pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime ) + pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 393, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_Bless)); + if ( pParty->pPlayers[i].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime ) + pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 410, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_Preservation)); + if ( pParty->pPlayers[i].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].uExpireTime ) + pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 444, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_PainReflection)); + } +} //----- (004921C1) -------------------------------------------------------- void GameUI_DrawPortraits(unsigned int _this) { - Texture *pFace; // eax@10 - unsigned int v7; // eax@17 + unsigned int face_expression_ID; // eax@17 PlayerFrame *pFrame; // eax@21 - unsigned int v9; // eax@27 - bool v10; // eax@33 - bool v11; // edi@40 - bool v12; // edx@43 - bool v13; // ecx@46 - int v16; // eax@57 - int v19; // eax@62 + int pTextureID; // eax@57 Texture *pPortrait; // [sp-4h] [bp-1Ch]@27 - //unsigned int v22; // [sp+14h] [bp-4h]@1 + + if ( qword_A750D8 ) + { + qword_A750D8 -= (signed int)pMiscTimer->uTimeElapsed; + if ( qword_A750D8 <= 0 ) + { + if ( pPlayers[uSpeakingCharacter]->CanAct() ) + pPlayers[uSpeakingCharacter]->PlaySound(PlayerSpeechID, 0); + qword_A750D8 = 0i64; + } + } - //v22 = _this; - if ( qword_A750D8 ) + for (uint i = 0; i < 4; ++i) + { + Player* pPlayer = &pParty->pPlayers[i]; + if ( pPlayer->IsEradicated() ) + { + pPortrait = pTexture_PlayerFaceEradicated; + if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime ) + pRenderer->_4A6E7E(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait); + else + pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait); + if ( pPlayer->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_7].uExpireTime + | pPlayer->pPlayerBuffs[PLAYER_BUFF_8].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_13].uExpireTime + | pPlayer->pPlayerBuffs[PLAYER_BUFF_14].uExpireTime ) + sub_441A4E(i); + continue; + } + if (pPlayer->IsDead()) + { + pPortrait = pTexture_PlayerFaceDead; + if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime ) + pRenderer->_4A6E7E(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait); + else + pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait); + if ( pPlayer->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_7].uExpireTime + | pPlayer->pPlayerBuffs[PLAYER_BUFF_8].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_13].uExpireTime + | pPlayer->pPlayerBuffs[PLAYER_BUFF_14].uExpireTime ) + sub_441A4E(i); + continue; + } + face_expression_ID = 0; + for ( uint j = 0; j < pPlayerFrameTable->uNumFrames; ++j ) + if ( pPlayerFrameTable->pFrames[j].expression == pPlayer->expression ) + { + face_expression_ID = j; + break; + } + if ( face_expression_ID == 0 ) + face_expression_ID = 1; + if (pPlayer->expression == CHARACTER_EXPRESSION_21) + pFrame = pPlayerFrameTable->GetFrameBy_y(&pPlayer->_expression21_frameset, &pPlayer->_expression21_animtime, pMiscTimer->uTimeElapsed); + else + pFrame = pPlayerFrameTable->GetFrameBy_x(face_expression_ID, pPlayer->uExpressionTimePassed); + if (pPlayer->field_1AA2 != pFrame->uTextureID - 1 || _this ) + { + pPlayer->field_1AA2 = pFrame->uTextureID - 1; + pPortrait = (Texture *)pTextures_PlayerFaces[i][pPlayer->field_1AA2];//pFace = (Texture *)pTextures_PlayerFaces[i][pFrame->uTextureID]; + if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime ) + pRenderer->_4A6E7E(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i], 388, pPortrait); + else + pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 1, 388, pPortrait); + if ( pPlayer->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_7].uExpireTime + | pPlayer->pPlayerBuffs[PLAYER_BUFF_8].uExpireTime | pPlayer->pPlayerBuffs[PLAYER_BUFF_13].uExpireTime + | pPlayer->pPlayerBuffs[PLAYER_BUFF_14].uExpireTime ) + sub_441A4E(i); + continue; + } + } + if ( pParty->bTurnBasedModeOn == 1 ) + { + if ( pTurnEngine->turn_stage != 1 ) + { + if (PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player) + { + if ( pTurnEngine->uActorQueueSize > 0 ) { - qword_A750D8 -= (signed int)pMiscTimer->uTimeElapsed; - if ( qword_A750D8 <= 0 ) - { - if ( pPlayers[uSpeakingCharacter]->CanAct() ) - pPlayers[uSpeakingCharacter]->PlaySound(PlayerSpeechID, 0); - qword_A750D8 = 0i64; - } - } - - for (uint i = 0; i < 4; ++i) - { - Player* pPlayer = &pParty->pPlayers[i]; - - if (pPlayer->IsEradicated()) + for (uint i = 0; i < (uint)pTurnEngine->uActorQueueSize; ++i) + { + if (PID_TYPE(pTurnEngine->pQueue[i].uPackedID) != OBJECT_Player) + break; + pTextureID = dword_5079D0; + if ( pParty->uFlags & 0x10 ) + pTextureID = dword_5079CC; + else { - pFace = pTexture_PlayerFaceEradicated; - pPortrait = pFace; - v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i]; - if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime ) - pRenderer->_4A6E7E(v9, 0x183u, pPortrait); - else - pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, pPortrait); - auto _v1 = 0; - v10 = pPlayer->pPlayerBuffs[14].uExpireTime > 0; - if (pPlayer->pPlayerBuffs[1].uExpireTime > 0) - _v1 = 1; - v11 = pPlayer->pPlayerBuffs[8].uExpireTime > 0; - v12 = pPlayer->pPlayerBuffs[7].uExpireTime > 0; - v13 = pPlayer->pPlayerBuffs[13].uExpireTime > 0; - if ( v13 | v12 | v11 | _v1 | v10 ) - sub_441A4E(i); - continue; - } - if (pPlayer->IsDead()) - { - pFace = pTexture_PlayerFaceDead; - pPortrait = pFace; - v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i]; - if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime ) - pRenderer->_4A6E7E(v9, 0x183u, pPortrait); - else - pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, pPortrait); - auto _v1 = 0; - v10 = pPlayer->pPlayerBuffs[14].uExpireTime > 0; - if (pPlayer->pPlayerBuffs[1].uExpireTime > 0) - _v1 = 1; - v11 = pPlayer->pPlayerBuffs[8].uExpireTime > 0; - v12 = pPlayer->pPlayerBuffs[7].uExpireTime > 0; - v13 = pPlayer->pPlayerBuffs[13].uExpireTime > 0; - if ( v13 | v12 | v11 | _v1 | v10 ) - sub_441A4E(i); - continue; + if ( pParty->uFlags & 0x20 ) + pTextureID = dword_5079C8; } - v7 = 0; - for (uint j = 0; j < pPlayerFrameTable->uNumFrames; ++j) - if (pPlayerFrameTable->pFrames[j].expression == pPlayer->expression) - { - v7 = j; - break; - } - if ( v7 == 0 ) - v7 = 1; - if (pPlayer->expression == CHARACTER_EXPRESSION_21) - pFrame = pPlayerFrameTable->GetFrameBy_y(&pPlayer->_expression21_frameset, &pPlayer->_expression21_animtime, pMiscTimer->uTimeElapsed); - else - pFrame = pPlayerFrameTable->GetFrameBy_x(v7, pPlayer->uExpressionTimePassed); - if (pPlayer->field_1AA2 != pFrame->uTextureID - 1 || _this ) - { - pPlayer->field_1AA2 = pFrame->uTextureID - 1; - pFace = (Texture *)pTextures_PlayerFaces[i][pPlayer->field_1AA2];//pFace = (Texture *)pTextures_PlayerFaces[i][pFrame->uTextureID]; - pPortrait = pFace; - v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i]; - if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime ) - pRenderer->_4A6E7E(v9, 0x183u, pPortrait); - else - pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, pPortrait); - auto _v1 = 0; - v10 = pPlayer->pPlayerBuffs[14].uExpireTime > 0; - if (pPlayer->pPlayerBuffs[1].uExpireTime > 0) - _v1 = 1; - v11 = pPlayer->pPlayerBuffs[8].uExpireTime > 0; - v12 = pPlayer->pPlayerBuffs[7].uExpireTime > 0; - v13 = pPlayer->pPlayerBuffs[13].uExpireTime > 0; - if ( v13 | v12 | v11 | _v1 | v10 ) - sub_441A4E(i); - continue; - } + pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[PID_ID(pTurnEngine->pQueue[i].uPackedID)] - 4, 385, pIcons_LOD->GetTexture(pTextureID)); + } } - if ( pParty->bTurnBasedModeOn == 1 ) + } + } + } + else + { + for (uint i = 0; i < 4; ++i) + { + if (pParty->pPlayers[i].CanAct() && !pParty->pPlayers[i].uTimeToRecovery) + { + pTextureID = dword_5079D0; + if ( pParty->uFlags & 0x10 ) + pTextureID = dword_5079CC; + else { - if ( pTurnEngine->turn_stage != 1 ) - { - if (PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player) - { - //v14 = 0; - if ( pTurnEngine->uActorQueueSize > 0 ) - { - //v15 = (char *)pTurnEngine->pQueue; - for (uint i = 0; i < pTurnEngine->uActorQueueSize; ++i) - { - auto pElem = pTurnEngine->pQueue + i; - - if (PID_TYPE(pElem->uPackedID) != OBJECT_Player) - break; - v16 = dword_5079D0; - if ( pParty->uFlags & 0x10 ) - { - v16 = dword_5079CC; - } - else - { - if ( pParty->uFlags & 0x20 ) - v16 = dword_5079C8; - } - pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[PID_ID(pElem->uPackedID)] - 4, 0x181u, pIcons_LOD->GetTexture(v16)); - } - } - } - } + if ( pParty->uFlags & 0x20 ) + pTextureID = dword_5079C8; } - else - { - for (uint i = 0; i < 4; ++i) - { - auto pPlayer = pParty->pPlayers + i; - if (pPlayer->CanAct() && !pPlayer->uTimeToRecovery) - { - v19 = dword_5079D0; - if ( pParty->uFlags & 0x10 ) - { - v19 = dword_5079CC; - } - else - { - if ( pParty->uFlags & 0x20 ) - v19 = dword_5079C8; - } - pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4, 0x181u, pIcons_LOD->GetTexture(v19)); - } - } - } + pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4, 385, pIcons_LOD->GetTexture(pTextureID)); + } } + } +} //----- (00441D38) -------------------------------------------------------- void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int bRedrawOdmMinimap) { int uHeight; // ebx@6 - __int16 v11; // cx@11 - unsigned int v14; // ebx@23 + unsigned int pW; // ebx@23 int v15; // eax@23 - __int16 v17; // di@30 - double v18; // st7@30 - float v19; // ST38_4@30 double v20; // st7@30 - double v21; // st6@30 - double v22; // st5@33 signed int v27; // eax@37 unsigned __int16 *v28; // ecx@37 signed int v29; // edi@40 - //signed int v33; // ebx@50 - //unsigned int v34; // eax@50 - //signed int v35; // ecx@50 - //unsigned __int16 v36; // di@66 - int v37; // edi@72 - int v38; // ebx@72 - __int16 v39; // ax@87 - int v40; // edi@91 - int v41; // ebx@91 - unsigned int v42; // eax@101 - unsigned int v43; // ebx@101 - unsigned int v44; // ST30_4@101 - char *v45; // ebx@106 - int v46; // edi@108 - int v47; // eax@108 - unsigned int v48; // ebx@114 - unsigned int v49; // ST64_4@114 - //unsigned int v51; // [sp-10h] [bp-64h]@79 - unsigned int v52; // [sp-10h] [bp-64h]@100 - //unsigned int v53; // [sp-Ch] [bp-60h]@79 - unsigned int v54; // [sp-Ch] [bp-60h]@100 - //unsigned int v55; // [sp-8h] [bp-5Ch]@77 - unsigned int v56; // [sp-8h] [bp-5Ch]@100 - //signed int v57; // [sp-4h] [bp-58h]@54 - //unsigned __int16 v58; // [sp-4h] [bp-58h]@77 - unsigned __int16 v59; // [sp-4h] [bp-58h]@100 - //unsigned __int16 v60; // [sp+10h] [bp-44h]@66 - //unsigned int v61; // [sp+10h] [bp-44h]@85 - //unsigned int v63; // [sp+14h] [bp-40h]@85 - //unsigned int v65; // [sp+18h] [bp-3Ch]@85 + int pPoint_X; // edi@72 + int pPoint_Y; // ebx@72 unsigned int lPitch; // [sp+20h] [bp-34h]@1 - unsigned int lPitcha; // [sp+20h] [bp-34h]@23 - char *lPitchb; // [sp+20h] [bp-34h]@106 - unsigned int v69; // [sp+24h] [bp-30h]@23 + unsigned int pY; // [sp+20h] [bp-34h]@23 + unsigned int pX; // [sp+24h] [bp-30h]@23 signed int v70; // [sp+24h] [bp-30h]@37 - //unsigned __int16 uBlue; // [sp+28h] [bp-2Ch]@1 signed int uBluea; // [sp+28h] [bp-2Ch]@37 int v73; // [sp+2Ch] [bp-28h]@30 - int v76; // [sp+34h] [bp-20h]@91 - int v77; // [sp+34h] [bp-20h]@108 - //int v79; // [sp+38h] [bp-1Ch]@72 - //char *a2c; // [sp+40h] [bp-14h]@68 signed int uCenterY; // [sp+48h] [bp-Ch]@1 signed int uCenterX; // [sp+4Ch] [bp-8h]@1 signed int uWidth; // [sp+5Ch] [bp+8h]@30 - //signed int uZe; // [sp+5Ch] [bp+8h]@67 - signed int uZf; // [sp+5Ch] [bp+8h]@85 - signed int uZg; // [sp+5Ch] [bp+8h]@105 - unsigned int uWa; // [sp+60h] [bp+Ch]@23 + unsigned int pZ; // [sp+60h] [bp+Ch]@23 float uWb; // [sp+60h] [bp+Ch]@30 - unsigned int uWd; // [sp+60h] [bp+Ch]@95 - float uZooma; // [sp+64h] [bp+10h]@117 - //unsigned int flagsb; // [sp+68h] [bp+14h]@66 - Actor *flagsc; // [sp+68h] [bp+14h]@86 - //unsigned int flagsd; // [sp+68h] [bp+14h]@105 + unsigned int pColor; uCenterX = (uX + uZ) / 2; uCenterY = (uY + uW) / 2; lPitch = pRenderer->uTargetSurfacePitch; - //TargetColor(0, 0, 0); - //uBlue = TargetColor(0, 0, 0xFFu); auto bWizardEyeActive = pParty->WizardEyeActive(); auto uWizardEyeSkillLevel = pParty->WizardEyeSkillLevel(); - if (CheckHiredNPCSpeciality(Cartographer)) + if ( CheckHiredNPCSpeciality(Cartographer) ) { bWizardEyeActive = true; uWizardEyeSkillLevel = 2; } + extern bool wizard_eye; + if ( wizard_eye ) + { bWizardEyeActive = true; uWizardEyeSkillLevel = 3; + } pRenderer->SetRasterClipRect(uX, uY, uZ - 1, uW - 1); uHeight = uW - uY; uWidth = uZ - uX; - if ( uCurrentlyLoadedLevelType != LEVEL_Indoor) + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) { - v17 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2; auto pMapLod0 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask; auto pPal = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16; - v73 = (1 << (v17 + 16)) / (signed int)uZoom; - v18 = (double)(1 << (16 - v17)); - v19 = v18; - v20 = (double)(pParty->vPosition.x + 32768) / v18; - v21 = (double)(32768 - pParty->vPosition.y) / v19; - uWb = v21; + v73 = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / (signed int)uZoom; + v20 = (double)(pParty->vPosition.x + 32768) / (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2)); + uWb = (double)(32768 - pParty->vPosition.y) / (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2)); switch (uZoom) { case 512: { v20 = v20 - (double)(uWidth / 2); - v22 = (double)(uHeight / 2); - uWb = v21 - v22; + uWb = uWb - (double)(uHeight / 2); } break; - case 1024: { v20 = v20 - (double)(uWidth / 4); - v22 = (double)(uHeight / 4); - uWb = v21 - v22; + uWb = uWb - (double)(uHeight / 4); } break; - case 2048: { v20 = v20 - (double)(uWidth / 8); - v22 = (double)(uHeight / 8); - uWb = v21 - v22; + uWb = uWb - (double)(uHeight / 8); } break; - default: assert(false); } assert(sizeof(pOdmMinimap) == 137 * 117 * sizeof(short)); @@ -2480,25 +1922,23 @@ assert(uWidth == 137 && uHeight == 117); //auto pMinimap = (unsigned __int16 *)pOdmMinimap; - auto mapWidth = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth; - - v29 = v70 >> 16; + auto mapWidth = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth; - for (int y = 0; y < uHeight; ++y) - { - auto pMapLod0Line = &pMapLod0[v27 * mapWidth]; - for (int x = 0; x < uWidth; ++x) - { - //*pMinimap++ = pPal[pMapLod0Line[v29]]; - pOdmMinimap[y][x] = pPal[pMapLod0Line[v29]]; - v29 = (v70 + x * v73) >> 16; - } - - v29 = v70 >> 16; - v28 += 137 - uWidth; - uBluea += v73; - v27 = uBluea >> 16; - } + v29 = v70 >> 16; + for (int y = 0; y < uHeight; ++y) + { + auto pMapLod0Line = &pMapLod0[v27 * mapWidth]; + for (int x = 0; x < uWidth; ++x) + { + //*pMinimap++ = pPal[pMapLod0Line[v29]]; + pOdmMinimap[y][x] = pPal[pMapLod0Line[v29]]; + v29 = (v70 + x * v73) >> 16; + } + v29 = v70 >> 16; + v28 += 137 - uWidth; + uBluea += v73; + v27 = uBluea >> 16; + } } for (int y = 0; y < 117; ++y) @@ -2511,322 +1951,224 @@ } uNumBlueFacesInBLVMinimap = 0; } - else + else// uCurrentlyLoadedLevelType == LEVEL_Indoor { pRenderer->FillRectFast(uX, uY, uZ - uX, uHeight, 0xF); uNumBlueFacesInBLVMinimap = 0; - for (uint i = 0; i < pIndoor->pMapOutlines->uNumOutlines; ++i) + for (uint i = 0; i < (uint)pIndoor->pMapOutlines->uNumOutlines; ++i) { auto pOutline = &pIndoor->pMapOutlines->pOutlines[i]; - auto pFace1 = pIndoor->pFaces + pOutline->uFace1ID; auto pFace2 = pIndoor->pFaces + pOutline->uFace2ID; //v9 = pIndoor->pFaces[pMapVertex->uFace1ID].uAttributes; //v10 = pIndoor->pFaces[pMapVertex->uFace2ID].uAttributes; if (pFace1->Visible() && pFace2->Visible()) { - v11 = pOutline->uFlags; - if ( v11 & 1 ) + if ( pOutline->uFlags & 1 ) goto LABEL_15; if (pFace1->uAttributes & 0x80 || pFace2->uAttributes & 0x80) goto LABEL_ABC; - } continue; LABEL_ABC: - pOutline->uFlags = v11 | 1; - pIndoor->_visible_outlines[i >> 3] |= 1 << (7 - i % 8); + pOutline->uFlags = pOutline->uFlags | 1; + pIndoor->_visible_outlines[i >> 3] |= 1 << (7 - i % 8); LABEL_15: - //v12 = &pIndoor->pFaces[pOutline->uFace1ID]; - if (bWizardEyeActive && uWizardEyeSkillLevel >= 3 && - (pFace1->uAttributes & 0x2000 || pFace2->uAttributes & 0x2000) && - (pIndoor->pFaceExtras[pFace1->uFaceExtraID].uEventID || pIndoor->pFaceExtras[pFace2->uFaceExtraID].uEventID)) - { - if (uNumBlueFacesInBLVMinimap < 49) - pBlueFacesInBLVMinimapIDs[uNumBlueFacesInBLVMinimap++] = i; - } - else - { - auto _a = (uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x); - auto _b = ((unsigned int)((unsigned __int64)_a >> 16) << 16); - auto _c = ((signed int)(_b - uZoom * pParty->vPosition.x) >> 16); - v69 = uCenterX + _c; - v69 = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16); - lPitcha = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16); - uWa = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16); - v14 = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16); - v15 = abs(pOutline->sZ - pParty->vPosition.z) / 8; - if ( v15 > 100 ) - v15 = 100; - pRenderer->RasterLine2D(v69, lPitcha, uWa, v14, viewparams->pPalette[-v15 + 200]); - } - } - - - for (uint i = 0; i < uNumBlueFacesInBLVMinimap; ++i) - { - //v16 = (uint *)&pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[uZb]]; - auto pOutline = &pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[i]]; - pRenderer->RasterLine2D(uCenterX + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom - * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16) - - uZoom * pParty->vPosition.x) >> 16), - uCenterY - - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom - * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16) - - uZoom * pParty->vPosition.y) >> 16), - uCenterX - + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom - * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16) - - uZoom * pParty->vPosition.x) >> 16), - uCenterY - - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom - * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16) - - uZoom * pParty->vPosition.y) >> 16), - ui_game_minimap_outline_color); - } - } - - - assert(pParty->sRotationY >= 0); - float angle = (pParty->sRotationY % 2048) / 2048.0f; - const float two_pi = 2.0f * 3.14159f; - - uint arrow_idx = floorf(0.5f + 7 * angle); - pRenderer->DrawTextureTransparent(uCenterX - 3, uCenterY - 3, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[arrow_idx])); - - //flagsb = TargetColor(0, 0, 255); - //v60 = TargetColor(255, 0, 0); - if (bWizardEyeActive) - { - //uZe = 0; - if (uWizardEyeSkillLevel >= 2) - for (uint i = 0; i < uNumSpriteObjects; ++i) - //if (uNumSpriteObjects > 0) + //v12 = &pIndoor->pFaces[pOutline->uFace1ID]; + if (bWizardEyeActive && uWizardEyeSkillLevel >= 3 && + (pFace1->uAttributes & 0x2000 || pFace2->uAttributes & 0x2000) && + (pIndoor->pFaceExtras[pFace1->uFaceExtraID].uEventID || pIndoor->pFaceExtras[pFace2->uFaceExtraID].uEventID)) { - auto object = &pSpriteObjects[i]; - - //a2c = (char *)&pSpriteObjects[0].uObjectDescID; - //while ( 1 ) - //{ - if (!object->uType || !object->uObjectDescID) - continue; - //if (uWizardEyeSkillLevel == 1 - v37 = uCenterX + ((unsigned __int64)((object->vPosition.x - pParty->vPosition.x) * (signed __int64)uZoom) >> 16); - //v79 = (unsigned __int64)((object->vPosition.y - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16; - //v38 = uCenterY - v79; - v38 = uCenterY - ((signed __int64)((object->vPosition.y - pParty->vPosition.y) * (signed __int64)uZoom) >> 16); - if (v37 < pRenderer->raster_clip_x || v37 > pRenderer->raster_clip_z || - v38 < pRenderer->raster_clip_y || v38 > pRenderer->raster_clip_w) - continue; - - assert(uZoom >= 512); - if (pObjectList->pObjects[object->uObjectDescID].uFlags & OBJECT_DESC_UNPICKABLE) - { - pRenderer->RasterLine2D(v37, v38, v37, v38, ui_game_minimap_projectile_color); - } - else if (uZoom > 512) - { - pRenderer->RasterLine2D(v37 - 1, v38 - 1, v37 - 1, v38 + 1, ui_game_minimap_treasure_color); - pRenderer->RasterLine2D(v37, v38 - 2, v37, v38 + 1, ui_game_minimap_treasure_color); - pRenderer->RasterLine2D(v37 + 1, v38 - 1, v37 + 1, v38 + 1, ui_game_minimap_treasure_color); - pRenderer->RasterLine2D(v37 - 2, v38, v37 - 2, v38 + 1, ui_game_minimap_treasure_color); - pRenderer->RasterLine2D(v37 + 2, v38, - v37 + 2, v38 + 1, ui_game_minimap_treasure_color); + if (uNumBlueFacesInBLVMinimap < 49) + pBlueFacesInBLVMinimapIDs[uNumBlueFacesInBLVMinimap++] = i; } else { - pRenderer->RasterLine2D(v37 - 1, v38 - 1, - v37 - 1, v38, ui_game_minimap_treasure_color); - pRenderer->RasterLine2D(v37, v38 - 1, - v37, v38, ui_game_minimap_treasure_color); + auto _a = (uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x); + auto _b = ((unsigned int)((unsigned __int64)_a >> 16) << 16); + auto _c = ((signed int)(_b - uZoom * pParty->vPosition.x) >> 16); + pX = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16); + pY = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16); + pZ = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16); + pW = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16); + v15 = abs(pOutline->sZ - pParty->vPosition.z) / 8; + if ( v15 > 100 ) + v15 = 100; + pRenderer->RasterLine2D(pX, pY, pZ, pW, viewparams->pPalette[-v15 + 200]); } -//LABEL_82: -//LABEL_83: - //++uZe; - //a2c += 112; - //if ( uZe >= (signed int)uNumSpriteObjects ) - //{ - //goto LABEL_85; - //} - //} } - -LABEL_85: - //v63 = TargetColor(255, 0, 0); - //v61 = TargetColor(0, 255, 0); - //v65 = TargetColor(255, 255, 0); - uZf = 0; - if ( (signed int)uNumActors > 0 ) + for (uint i = 0; i < uNumBlueFacesInBLVMinimap; ++i) { - flagsc = pActors.data();//[0].uAIState; - do - { - v39 = flagsc->uAIState; - if ( flagsc->uAIState != 11 && v39 != 19 && (v39 == 5 || BYTE1(flagsc->uAttributes) & 0x80) ) - { - v40 = ((unsigned __int64)(( flagsc->vPosition.x - pParty->vPosition.x) - * (signed __int64)(signed int)uZoom) >> 16) - + uCenterX; - v76 = (unsigned __int64)(( flagsc->vPosition.y - pParty->vPosition.y) - * (signed __int64)(signed int)uZoom) >> 16; - v41 = uCenterY - v76; - if ( v40 >= pRenderer->raster_clip_x ) - { - if ( v40 <= pRenderer->raster_clip_z && v41 >= pRenderer->raster_clip_y && v41 <= pRenderer->raster_clip_w ) - { - uWd = ui_game_minimap_actor_friendly_color; - if ( BYTE3(flagsc->uAttributes) & 1 ) - uWd = ui_game_minimap_actor_hostile_color; - if ( flagsc->uAIState == Dead) - uWd = ui_game_minimap_actor_corpse_color; - if ( (signed int)uZoom > 1024 ) - { - pRenderer->RasterLine2D(v40 - 1, v41 - 2, v40 - 1, v41 + 2, uWd); - pRenderer->RasterLine2D(v40, v41 - 2, v40, v41 + 2, uWd); - pRenderer->RasterLine2D(v40 + 1, v41 - 2, v40 + 1, v41 + 2, uWd); - v42 = v41 + 1; - v43 = v41 - 1; - v44 = v42; - pRenderer->RasterLine2D(v40 - 2, v43, v40 - 2, v42, uWd); - v40 += 2; - v59 = uWd; - v56 = v44; - v54 = v40; - v52 = v43; - } - else - { - pRenderer->RasterLine2D(v40 - 1, v41 - 1, v40 - 1, uCenterY - v76, uWd); - v59 = uWd; - v56 = uCenterY - v76; - v54 = v40; - v52 = v41 - 1; - } - pRenderer->RasterLine2D(v40, v52, v54, v56, v59); - } - } - } - ++uZf; - ++flagsc; - } - while ( uZf < (signed int)uNumActors ); + auto pOutline = &pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[i]]; + pX = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16); + pY = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16); + pZ = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16); + pW = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16); + pRenderer->RasterLine2D(pX, pY, pZ, pW, ui_game_minimap_outline_color); } } + //draw arrow on the minimap(include. Ritor1) + uint arrow_idx; + unsigned int rotate = pParty->sRotationY & stru_5C6E00->uDoublePiMask; + if ( (signed int)rotate <= 1920 ) + arrow_idx = 6; + if ( (signed int)rotate < 1664 ) + arrow_idx = 5; + if ( (signed int)rotate <= 1408 ) + arrow_idx = 4; + if ( (signed int)rotate < 1152 ) + arrow_idx = 3; + if ( (signed int)rotate <= 896 ) + arrow_idx = 2; + if ( (signed int)rotate < 640 ) + arrow_idx = 1; + if ( (signed int)rotate <= 384 ) + arrow_idx = 0; + if ( (signed int)rotate < 128 || (signed int)rotate > 1920 ) + arrow_idx = 7; + pRenderer->DrawTextureTransparent(uCenterX - 3, uCenterY - 3, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[arrow_idx]));//ñòðåëêà - //flagsd = TargetColor(255, 255, 255); - uZg = 0; - if ( (signed int)uNumLevelDecorations > 0 ) + //draw objects on the minimap + if ( bWizardEyeActive ) { - v45 = (char *)&pLevelDecorations[0].vPosition; - lPitchb = (char *)&pLevelDecorations[0].vPosition; - do + if ( uWizardEyeSkillLevel >= 2 ) { - if ( *(v45 - 2) & 8 ) + for ( uint i = 0; i < uNumSpriteObjects; ++i ) { - v46 = ((unsigned __int64)((*(int *)v45 - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16) - + uCenterX; - v77 = (unsigned __int64)((*((int *)v45 + 1) - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16; - v47 = uCenterY - v77; - if ( v46 >= pRenderer->raster_clip_x ) + if ( !pSpriteObjects[i].uType || !pSpriteObjects[i].uObjectDescID ) + continue; + //if (uWizardEyeSkillLevel == 1 + pPoint_X = uCenterX + ((unsigned __int64)((pSpriteObjects[i].vPosition.x - pParty->vPosition.x) * (signed __int64)uZoom) >> 16); + pPoint_Y = uCenterY - ((signed __int64)((pSpriteObjects[i].vPosition.y - pParty->vPosition.y) * (signed __int64)uZoom) >> 16); + if ( pPoint_X >= pRenderer->raster_clip_x && pPoint_X <= pRenderer->raster_clip_z && + pPoint_Y >= pRenderer->raster_clip_y && pPoint_Y <= pRenderer->raster_clip_w) { - if ( v46 <= pRenderer->raster_clip_z && v47 >= pRenderer->raster_clip_y && v47 <= pRenderer->raster_clip_w ) + if (pObjectList->pObjects[pSpriteObjects[i].uObjectDescID].uFlags & OBJECT_DESC_UNPICKABLE) { - if ( (signed int)uZoom > 512 ) - { - v48 = v47 + 1; - v49 = v47 - 1; - pRenderer->RasterLine2D(v46 - 1, v47 - 1, v46 - 1, v47 + 1, ui_game_minimap_decoration_color_1); - pRenderer->RasterLine2D(v46, v49, v46, v48, ui_game_minimap_decoration_color_1); - pRenderer->RasterLine2D(v46 + 1, v49, v46 + 1, v48, ui_game_minimap_decoration_color_1); - v45 = lPitchb; - } - else - { - pRenderer->RasterLine2D(v46, uCenterY - v77, v46, uCenterY - v77, ui_game_minimap_decoration_color_1); - } + pRenderer->RasterLine2D(pPoint_X, pPoint_Y, pPoint_X, pPoint_Y, ui_game_minimap_projectile_color); + } + else if ( uZoom > 512 ) + { + pRenderer->RasterLine2D(pPoint_X - 2, pPoint_Y, pPoint_X - 2, pPoint_Y + 1, ui_game_minimap_treasure_color); + pRenderer->RasterLine2D(pPoint_X - 1, pPoint_Y - 1, pPoint_X - 1, pPoint_Y + 1, ui_game_minimap_treasure_color); + pRenderer->RasterLine2D(pPoint_X, pPoint_Y - 2, pPoint_X, pPoint_Y + 1, ui_game_minimap_treasure_color); + pRenderer->RasterLine2D(pPoint_X + 1, pPoint_Y - 1, pPoint_X + 1, pPoint_Y + 1, ui_game_minimap_treasure_color); + pRenderer->RasterLine2D(pPoint_X + 2, pPoint_Y, pPoint_X + 2, pPoint_Y + 1, ui_game_minimap_treasure_color); + } + else + { + pRenderer->RasterLine2D(pPoint_X - 1, pPoint_Y - 1, pPoint_X - 1, pPoint_Y, ui_game_minimap_treasure_color); + pRenderer->RasterLine2D(pPoint_X, pPoint_Y - 1, pPoint_X, pPoint_Y, ui_game_minimap_treasure_color); } } } - ++uZg; - v45 += 32; - lPitchb = v45; } - while ( uZg < (signed int)uNumLevelDecorations ); + for ( uint i = 0; i < uNumActors; ++i )//draw actors(îòðèñîâêà ìîíñòðîâ è íïñ) + { + if ( pActors[i].uAIState != Removed && pActors[i].uAIState != Disabled + && (pActors[i].uAIState == Dead || BYTE1(pActors[i].uAttributes) & 0x80) ) + { + pPoint_X = uCenterX + ((unsigned __int64)(( pActors[i].vPosition.x - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16); + pPoint_Y = uCenterY - ((unsigned __int64)(( pActors[i].vPosition.y - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16); + if ( pPoint_X >= pRenderer->raster_clip_x && pPoint_X <= pRenderer->raster_clip_z + && pPoint_Y >= pRenderer->raster_clip_y && pPoint_Y <= pRenderer->raster_clip_w ) + { + pColor = ui_game_minimap_actor_friendly_color; + if ( BYTE3(pActors[i].uAttributes) & 1 ) + pColor = ui_game_minimap_actor_hostile_color; + if ( pActors[i].uAIState == Dead) + pColor = ui_game_minimap_actor_corpse_color; + if ( uZoom > 1024 ) + { + pRenderer->RasterLine2D(pPoint_X - 2, pPoint_Y - 1, pPoint_X - 2, pPoint_Y + 1, pColor); + pRenderer->RasterLine2D(pPoint_X - 1, pPoint_Y - 2, pPoint_X - 1, pPoint_Y + 2, pColor); + pRenderer->RasterLine2D(pPoint_X, pPoint_Y - 2, pPoint_X, pPoint_Y + 2, pColor); + pRenderer->RasterLine2D(pPoint_X + 1, pPoint_Y - 2, pPoint_X + 1, pPoint_Y + 2, pColor); + pRenderer->RasterLine2D(pPoint_X + 2, pPoint_Y - 1, pPoint_X + 2, pPoint_Y + 1, pColor); + } + else + { + pRenderer->RasterLine2D(pPoint_X - 1, pPoint_Y - 1, pPoint_X - 1, pPoint_Y, pColor); + pRenderer->RasterLine2D(pPoint_X, pPoint_Y - 1, pPoint_X, pPoint_Y, pColor); + } + } + } + } + for ( uint i = 0; i < (signed int)uNumLevelDecorations; ++i )//draw items(îòðèñîâêà ïðåäìåòîâ) + { + if ( pLevelDecorations[i].uFlags & 8 ) + { + pPoint_X = uCenterX + ((unsigned __int64)((pLevelDecorations[i].vPosition.x - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16); + pPoint_Y = uCenterY - ((unsigned __int64)((pLevelDecorations[i].vPosition.y - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16); + if ( pPoint_X >= pRenderer->raster_clip_x && pPoint_X <= pRenderer->raster_clip_z + && pPoint_Y >= pRenderer->raster_clip_y && pPoint_Y <= pRenderer->raster_clip_w ) + { + if ( (signed int)uZoom > 512 ) + { + pRenderer->RasterLine2D(pPoint_X - 1, pPoint_Y - 1, pPoint_X - 1, pPoint_Y + 1, ui_game_minimap_decoration_color_1); + pRenderer->RasterLine2D(pPoint_X, pPoint_Y - 1, pPoint_X, pPoint_Y + 1, ui_game_minimap_decoration_color_1); + pRenderer->RasterLine2D(pPoint_X + 1, pPoint_Y - 1, pPoint_X + 1, pPoint_Y + 1, ui_game_minimap_decoration_color_1); + } + else + pRenderer->RasterLine2D(pPoint_X, pPoint_Y, pPoint_X, pPoint_Y, ui_game_minimap_decoration_color_1); + } + } + } } - pRenderer->DrawTextureTransparent(0x1D4u, 0, pIcons_LOD->GetTexture(dword_5079D8)); - uZooma = (double)pParty->sRotationY * 0.1171875; - //v50 = uZooma + 6.7553994e15; + pRenderer->DrawTextureTransparent(468, 0, pIcons_LOD->GetTexture(uTextureID_Minimap_Loop));//draw minimap_loop pRenderer->SetTextureClipRect(541, 0, 567, 480); - pRenderer->DrawTextureIndexed(floorf(uZooma + 0.5f) + 285, 136, pIcons_LOD->GetTexture(dword_5079B4)); + pRenderer->DrawTextureIndexed(floorf(((double)pParty->sRotationY * 0.1171875) + 0.5f) + 285, 136, pIcons_LOD->GetTexture(uTextureID_Compas));//draw compas pRenderer->ResetTextureClipRect(); } //----- (00441498) -------------------------------------------------------- void GameUI_DrawTorchlightAndWizardEye() +{ + if (pCurrentScreen == SCREEN_GAME + || pCurrentScreen == SCREEN_MENU + || pCurrentScreen == SCREEN_OPTIONS + || pCurrentScreen == SCREEN_REST + || pCurrentScreen == SCREEN_SPELL_BOOK + || pCurrentScreen == SCREEN_CHEST + || pCurrentScreen == SCREEN_SAVEGAME + || pCurrentScreen == SCREEN_LOADGAME + || pCurrentScreen == SCREEN_CHEST_INVENTORY + || pCurrentScreen == SCREEN_BOOKS + || pCurrentScreen == SCREEN_BRANCHLESS_NPC_DIALOG ) + { + if (pParty->TorchlightActive()) { - if (pCurrentScreen == SCREEN_GAME - || pCurrentScreen == SCREEN_MENU - || pCurrentScreen == SCREEN_OPTIONS - || pCurrentScreen == SCREEN_REST - || pCurrentScreen == SCREEN_SPELL_BOOK - || pCurrentScreen == SCREEN_CHEST - || pCurrentScreen == SCREEN_SAVEGAME - || pCurrentScreen == SCREEN_LOADGAME - || pCurrentScreen == SCREEN_CHEST_INVENTORY - || pCurrentScreen == SCREEN_BOOKS - || pCurrentScreen == SCREEN_BRANCHLESS_NPC_DIALOG ) - { - if (pParty->TorchlightActive()) - { - auto icon = pIconsFrameTable->GetFrame((signed __int16)pUIAnum_Torchlight->uIconID, pEventTimer->Time()); - pRenderer->DrawTextureTransparent(pUIAnum_Torchlight->x, pUIAnum_Torchlight->y, pIcons_LOD->GetTexture(icon->uTextureID)); - } - if (pParty->WizardEyeActive()) - { - auto icon = pIconsFrameTable->GetFrame((signed __int16)pUIAnim_WizardEye->uIconID, pEventTimer->Time()); - pRenderer->DrawTextureTransparent(pUIAnim_WizardEye->x, pUIAnim_WizardEye->y, pIcons_LOD->GetTexture(icon->uTextureID)); - } - } + auto icon = pIconsFrameTable->GetFrame((signed __int16)pUIAnum_Torchlight->uIconID, pEventTimer->Time()); + pRenderer->DrawTextureTransparent(pUIAnum_Torchlight->x, pUIAnum_Torchlight->y, pIcons_LOD->GetTexture(icon->uTextureID)); } + if (pParty->WizardEyeActive()) + { + auto icon = pIconsFrameTable->GetFrame((signed __int16)pUIAnim_WizardEye->uIconID, pEventTimer->Time()); + pRenderer->DrawTextureTransparent(pUIAnim_WizardEye->x, pUIAnim_WizardEye->y, pIcons_LOD->GetTexture(icon->uTextureID)); + } + } +} // 4E28F8: using guessed type int pCurrentScreen; //----- (00491F87) -------------------------------------------------------- void GameUI_DrawHiredNPCs() { - //int v6; // eax@15 - char v7; // al@17 - unsigned int v8; // eax@18 - int v9; // esi@18 - int v10; // eax@18 - unsigned int v11; // eax@19 - unsigned int v12; // esi@19 unsigned int v13; // eax@23 - IconFrame *v14; // eax@24 - unsigned int v15; // eax@26 char pContainer[20]; // [sp+Ch] [bp-30h]@18 - unsigned int v17; // [sp+20h] [bp-1Ch]@19 signed int uFrameID; // [sp+24h] [bp-18h]@19 - //int i; // [sp+28h] [bp-14h]@15 - unsigned int v20; // [sp+2Ch] [bp-10h]@20 - unsigned int v21; // [sp+30h] [bp-Ch]@19 int v22; // [sp+34h] [bp-8h]@2 - unsigned __int8 v23; // [sp+3Bh] [bp-1h]@2 + unsigned __int8 pNPC_limit_ID; // [sp+3Bh] [bp-1h]@2 if ( bNoNPCHiring != 1 ) { - v23 = 0; + pNPC_limit_ID = 0; v22 = 0; - /*for (uint i = 0; i < 2; ++i) - { - if (pParty->pHirelings[i].pName) - pTmpBuf[v22++] = i; - }*/ if (pParty->pHirelings[0].pName) pTmpBuf[v22++] = 0; if (pParty->pHirelings[1].pName) @@ -2844,89 +2186,58 @@ } } - //v6 = (unsigned __int8)pParty->field_709; - for ( int i = (unsigned __int8)pParty->field_709; i < v22 && v23 < 2; i++ ) + for ( int i = (unsigned __int8)pParty->field_709; i < v22 && pNPC_limit_ID < 2; i++ ) { - v7 = pTmpBuf[i]; - if ( (unsigned __int8)v7 >= 2 ) + if ( (unsigned __int8)pTmpBuf[i] >= 2 ) { - sprintf(pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID); - v15 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[v23], pHiredNPCsIconsOffsetsY[v23], pIcons_LOD->GetTexture(v15)); + sprintf(pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)pTmpBuf[i] + 499].uPortraitID); + pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[pNPC_limit_ID], pHiredNPCsIconsOffsetsY[pNPC_limit_ID], + pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE))); } else { - sprintf(pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID); - v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); - v9 = v23; - pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[v9], pHiredNPCsIconsOffsetsY[v9], pIcons_LOD->GetTexture(v8)); - v10 = (unsigned __int8)pTmpBuf[i]; - if ( pParty->pHirelings[v10].evt_A == 1 ) + sprintf(pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)pTmpBuf[i]].uPortraitID); + pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[pNPC_limit_ID], pHiredNPCsIconsOffsetsY[pNPC_limit_ID], + pIcons_LOD->GetTexture(pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE))); + if ( pParty->pHirelings[(unsigned __int8)pTmpBuf[i]].evt_A == 1 ) { - uFrameID = pParty->pHirelings[v10].evt_B; - v11 = pHiredNPCsIconsOffsetsX[v9]; - v12 = pHiredNPCsIconsOffsetsY[v9]; - v17 = v11; - v21 = 0; - if ( (signed int)pIconsFrameTable->uNumIcons <= 0 ) + uFrameID = pParty->pHirelings[(unsigned __int8)pTmpBuf[i]].evt_B; + v13 = 0; + if ( (signed int)pIconsFrameTable->uNumIcons ) { -LABEL_23: - v13 = 0; - } - else - { - v20 = 0; - while ( _stricmp("spell96", pIconsFrameTable->pIcons[v20 / 0x20].pAnimationName) ) + for ( v13 = 0; v13 < pIconsFrameTable->uNumIcons; ++v13 ) { - ++v21; - v20 += 32; - if ( (signed int)v21 >= (signed int)pIconsFrameTable->uNumIcons ) - goto LABEL_23; + if ( !_stricmp("spell96", pIconsFrameTable->pIcons[v13].pAnimationName) ) + break; } - v13 = v21; } - v14 = pIconsFrameTable->GetFrame(v13, uFrameID); - pRenderer->DrawTextureTransparent(v17, v12, &pIcons_LOD->pTextures[v14->uTextureID]); + pRenderer->DrawTextureTransparent(pHiredNPCsIconsOffsetsX[pNPC_limit_ID], pHiredNPCsIconsOffsetsY[pNPC_limit_ID], + &pIcons_LOD->pTextures[pIconsFrameTable->GetFrame(v13, uFrameID)->uTextureID]); } } - ++v23; + ++pNPC_limit_ID; } } } // 6BE3C5: using guessed type char bNoNPCHiring; //----- (004178FE) -------------------------------------------------------- -unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2) +unsigned int UI_GetHealthManaAndOtherQualitiesStringColor(signed int current_pos, signed int base_pos) { - unsigned __int16 v2; // dx@2 - unsigned __int16 v3; // cx@2 - int v5; // eax@5 - unsigned __int16 v6; // [sp-4h] [bp-8h]@2 + unsigned __int16 R, G, B; - if ( a1 <= a2 ) + if ( current_pos <= base_pos ) { - if ( a1 == a2 ) + if ( current_pos == base_pos )//White return 0; - v5 = 100 * a1 / a2; - v3 = 255; - if ( v5 >= 25 ) - { - v6 = 100; - v2 = 255; - } - else - { - v6 = 0; - v2 = 0; - } + if ( 100 * current_pos / base_pos >= 25 )//Yellow( current_pos > 1/4 ) + R = 255, G = 255, B = 100; + else//Red( current_pos < 1/4 ) + R = 255, G = 0, B = 0; } - else - { - v6 = 0; - v2 = 255; - v3 = 0; - } - return TargetColor(v3, v2, v6); + else//Green + R = 0, G = 255, B = 0; + return TargetColor(R, G, B); } //----- (00417939) -------------------------------------------------------- diff -r 86cb7398d2a8 -r 7d986a396092 VectorTypes.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VectorTypes.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -0,0 +1,62 @@ +#include + +#include "mm7_data.h" +#include "Math.h" + +//----- (004621DA) -------------------------------------------------------- +uint32_t int_get_vector_length(int32_t x, int32_t y, int32_t z) +{ + if (x < y) + { + std::swap(x, y); + } + if (x < z) + { + std::swap(x, z); + } + if (y < z) + { + std::swap(y, z); + } + + return x + (11 * y >> 5) + (z >> 2); +} + +//----- (0044C362) -------------------------------------------------------- +template +void Vec3::Normalize_float() +{ + double x = this->x; + double y = this->y; + double z = this->z; + double s = sqrt(x * x + y * y + z * z); + + this->x = bankersRounding(x / s); + this->y = bankersRounding(y / s); + this->z = bankersRounding(z / s); +} + +//----- (0043AA99) -------------------------------------------------------- +template +void __fastcall Vec3::Rotate(T sDepth, T sRotY, T sRotX, Vec3 v, T *outx, T *outy, T *outz) +{ + float cosf_x = cosf(3.14159265f * sRotX / 1024.0f), + sinf_x = sinf(3.14159265f * sRotX / 1024.0f), + cosf_y = cosf(3.14159265f * sRotY / 1024.0f), + sinf_y = sinf(3.14159265f * sRotY / 1024.0f); + + *outx = v.x + ((unsigned __int64)(sinf_y * (signed __int64)((unsigned __int64)(cosf_x * (signed __int64)sDepth)>> 16))); + *outy = v.y + ((unsigned __int64)(cosf_y * (signed __int64)((unsigned __int64)(cosf_x * (signed __int64)sDepth)>> 16))); + *outz = v.z + ((unsigned __int64)(sinf_x * (signed __int64)sDepth) >> 16); +} + +//----- (0043AB61) -------------------------------------------------------- +template +void Vec3::Normalize(T *x, T *y, T *z) +{ + *x *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); + *y *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); + *z *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); +} + +template Vec3; diff -r 86cb7398d2a8 -r 7d986a396092 VectorTypes.h --- a/VectorTypes.h Sat Sep 07 12:51:06 2013 +0200 +++ b/VectorTypes.h Sat Sep 07 13:03:18 2013 +0200 @@ -1,30 +1,67 @@ #pragma once -#include + +#include + +uint32_t int_get_vector_length(int32_t x, int32_t y, int32_t z); -typedef unsigned __int32 uint; +#pragma pack(push, 1) +template +struct Vec2 +{ + T x; + T y; + + inline Vec2(T a = 0, T b = 0): + x(a), y(b) + {} +}; +#pragma pack(pop) + +#define Vec2_int_ Vec2 +#define Vec2_float_ Vec2 #pragma pack(push, 1) -struct Vec2_short_ +template +struct Vec3: public Vec2 { - __int16 x; - __int16 y; + T z; + + inline Vec3(T a = 0, T b = 0, T c = 0): + Vec2(a, b), z(c) + {} + + void Normalize_float(); + template + inline uint32_t GetDistanceTo(Vec3 &o) + { + return int_get_vector_length( + abs(this->x - o.x), + abs(this->y - o.y), + abs(this->z - o.z) + ); + } + + static void __fastcall Rotate(T sDepth, T sRotY, T sRotX, Vec3 v, T *outx, T *outy, T *outz); + static void Normalize(T *x, T *y, T *z); }; #pragma pack(pop) +#define Vec3_short_ Vec3 +#define Vec3_int_ Vec3 + #pragma pack(push, 1) struct Vec3_float_ { void Normalize(); - -//----- (0049B32D) -------------------------------------------------------- -static Vec3_float_ *Vec3_float_::Cross(Vec3_float_ *v1, Vec3_float_ *pOut, float x, float y, float z) -{ - pOut->x = z * v1->y - y * v1->z; - pOut->y = x * v1->z - z * v1->x; - pOut->z = y * v1->x - x * v1->y; - return pOut; -} + //----- (0049B32D) -------------------------------------------------------- + static Vec3_float_ *Vec3_float_::Cross(Vec3_float_ *v1, Vec3_float_ *pOut, float x, float y, float z) + { + pOut->x = z * v1->y - y * v1->z; + pOut->y = x * v1->z - z * v1->x; + pOut->z = y * v1->x - x * v1->y; + return pOut; + } //----- (0049B02E) -------------------------------------------------------- inline static float NegDot(Vec3_float_ *a1, Vec3_float_ *a2, float *a3) @@ -38,54 +75,6 @@ }; #pragma pack(pop) - -#pragma pack(push, 1) -struct Vec2_int_ -{ - int x; - int y; -}; -#pragma pack(pop) - -#pragma pack(push, 1) -struct Vec2_float_ -{ - float x; - float y; -}; -#pragma pack(pop) - - -#pragma pack(push, 1) -struct Vec3_short_ -{ - __int16 x; - __int16 y; - __int16 z; -}; -#pragma pack(pop) - -#pragma pack(push, 1) -struct Vec3_int_ -{ - inline Vec3_int_(): - x(0), y(0), z(0) - {} - inline Vec3_int_(int a, int b = 0, int c = 0): - x(a), y(b), z(c) - {} - - void Normalize_float(); - - static void __fastcall Rotate(int sDepth, int sRotY, int sRotX, Vec3_int_ v, int *outx, int *outy, int *outz); - static void Normalize(int *x, int *y, int *z); - - int x; - int y; - int z; -}; -#pragma pack(pop) - #pragma pack(push, 1) struct Vec4_int_ { @@ -96,11 +85,6 @@ }; #pragma pack(pop) - - - - - /* 82 */ #pragma pack(push, 1) struct Plane_int_ @@ -110,7 +94,6 @@ }; #pragma pack(pop) - #pragma pack(push, 1) struct BBox_short_ { @@ -143,9 +126,6 @@ }; #pragma pack(pop) - - - /* 196 */ #pragma pack(push, 1) struct Matrix3x3_float_ @@ -162,4 +142,3 @@ }; }; #pragma pack(pop) - diff -r 86cb7398d2a8 -r 7d986a396092 Viewport.cpp --- a/Viewport.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/Viewport.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -533,7 +533,7 @@ pIcons_LOD->SyncLoadedFilesCount(); return; } - if ( !pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].field_16_event_id ) + if ( !pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].uEventID ) { if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() ) { @@ -544,7 +544,7 @@ } return; } - pEventID = pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].field_16_event_id; + pEventID = pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].uEventID; } if ( PID_TYPE(v0) == OBJECT_BModel && HIWORD(v0) < clickable_distance) { diff -r 86cb7398d2a8 -r 7d986a396092 Vis.cpp --- a/Vis.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/Vis.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -664,7 +664,9 @@ if ( v16 != 1 ) return false; - pFace->uAttributes |= FACE_PICKED; + extern bool show_picked_face; + if ( show_picked_face ) + pFace->uAttributes |= FACE_PICKED; return true; /* int v5; // esi@10 @@ -1431,7 +1433,7 @@ MessageBoxA(nullptr, "Unsupported \"exclusion if no event\" type in CVis::is_part_of_selection", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:207", 0); return true; } - if (pLevelDecorations[object_idx].uCog || pLevelDecorations[object_idx].field_16_event_id) + if (pLevelDecorations[object_idx].uCog || pLevelDecorations[object_idx].uEventID) return true; return pLevelDecorations[object_idx].IsInteractive(); } diff -r 86cb7398d2a8 -r 7d986a396092 _deleted.cpp --- a/_deleted.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/_deleted.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -12276,4 +12276,101 @@ while ( v16 != 1 ); } } +const wchar_t *UIMessage2String(UIMessageType msg) +{ + #define CASE(xxx) case xxx: swprintf(b, wcslen(L"%03X/%s"), L"%03X/%s", msg, L#xxx); return b; + static wchar_t b[256]; // bad for threads + switch (msg) + { + CASE(UIMSG_SelectSpell) + CASE(UIMSG_ChangeGameState) + CASE(UIMSG_Attack) + CASE(UIMSG_PlayArcomage) + CASE(UIMSG_MainMenu_ShowPartyCreationWnd) + CASE(UIMSG_MainMenu_ShowLoadWindow) + CASE(UIMSG_ShowCredits) + CASE(UIMSG_ExitToWindows) + CASE(UIMSG_PlayerCreationChangeName) + CASE(UIMSG_PlayerCreationClickPlus) + CASE(UIMSG_PlayerCreationClickMinus) + CASE(UIMSG_PlayerCreationSelectActiveSkill) + CASE(UIMSG_PlayerCreationSelectClass) + CASE(UIMSG_PlayerCreationClickOK) + CASE(UIMSG_PlayerCreationClickReset) + CASE(UIMSG_ClickBooksBtn) + CASE(UIMSG_PlayerCreationRemoveUpSkill) + CASE(UIMSG_PlayerCreationRemoveDownSkill) + CASE(UIMSG_SPellbook_ShowHightlightedSpellInfo) + CASE(UIMSG_LoadGame) + CASE(UIMSG_SaveGame) + CASE(UIMSG_ShowStatus_DateTime) + CASE(UIMSG_ShowStatus_ManaHP) + CASE(UIMSG_ShowStatus_Player) + CASE(UIMSG_Wait5Minutes) + CASE(UIMSG_Wait1Hour) + CASE(UIMSG_ShowStatus_Food) + CASE(UIMSG_ShowStatus_Funds) + CASE(UIMSG_QuickReference) + CASE(UIMSG_GameMenuButton) + CASE(UIMSG_AlreadyResting) + CASE(UIMSG_SelectCharacter) + CASE(UIMSG_ChangeSoundVolume) + CASE(UIMSG_ChangeMusicVolume) + CASE(UIMSG_Escape) + CASE(UIMSG_PlayerCreation_SelectAttribute) + CASE(UIMSG_InventoryLeftClick) + CASE(UIMSG_SkillUp) + CASE(UIMSG_GameMenu_ReturnToGame) + CASE(UIMSG_StartNewGame) + CASE(UIMSG_Game_OpenLoadGameDialog) + CASE(UIMSG_Game_OpenSaveGameDialog) + CASE(UIMSG_Game_OpenOptionsDialog) + CASE(UIMSG_SetGraphicsMode) + CASE(UIMSG_Quit) + CASE(UIMSG_StartHireling1Dialogue) + CASE(UIMSG_StartHireling2Dialogue) + CASE(UIMSG_SelectNPCDialogueOption) + CASE(UIMSG_CastSpellFromBook) + CASE(UIMSG_PlayerCreation_VoicePrev) + CASE(UIMSG_PlayerCreation_VoiceNext) + CASE(UIMSG_StartNPCDialogue) + CASE(UIMSG_ArrowUp) + CASE(UIMSG_DownArrow) + CASE(UIMSG_SaveLoadBtn) + CASE(UIMSG_SelectLoadSlot) + CASE(UIMSG_Cancel) + CASE(UIMSG_ExitRest) + CASE(UIMSG_PlayerCreation_FacePrev) + CASE(UIMSG_PlayerCreation_FaceNext) + CASE(UIMSG_CycleCharacters) + CASE(UIMSG_SetTurnSpeed) + CASE(UIMSG_ToggleWalkSound) + CASE(UIMSG_ChangeVoiceVolume) + CASE(UIMSG_ToggleShowDamage) + CASE(UIMSG_ScrollNPCPanel) + CASE(UIMSG_ShowFinalWindow) + CASE(UIMSG_OpenQuestBook) + CASE(UIMSG_OpenAutonotes) + CASE(UIMSG_OpenMapBook) + CASE(UIMSG_OpenCalendar) + CASE(UIMSG_OpenHistoryBook) + CASE(UIMSG_ToggleAlwaysRun) + CASE(UIMSG_ToggleFlipOnExit) + CASE(UIMSG_Game_Action) + CASE(UIMSG_RentRoom) + CASE(UIMSG_TransitionUI_Confirm) + CASE(UIMSG_OpenKeyMappingOptions) + CASE(UIMSG_SelectKeyPage1) + CASE(UIMSG_SelectKeyPage2) + CASE(UIMSG_ResetKeyMapping) + CASE(UIMSG_ChangeKeyButton) + CASE(UIMSG_OpenVideoOptions) + CASE(UIMSG_ToggleBloodsplats) + CASE(UIMSG_ToggleColoredLights) + CASE(UIMSG_ToggleTint) + default: + swprintf(b, wcslen(L"UIMSG_%03X") , L"UIMSG_%03X", msg); return b; + }; + #undef CASE +} */ \ No newline at end of file diff -r 86cb7398d2a8 -r 7d986a396092 mm7_1.cpp --- a/mm7_1.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/mm7_1.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -175,8 +175,8 @@ pTexture_LeftFrame->Reload("ib-l-C.pcx"); pTexture_StatusBar->Reload("IB-Foot-c.pcx"); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_right_panel], "ib-mb-C", 2); - pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079D8], "ib-autmask-c", 2); - pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079B4], "IB-COMP-C", 2); + pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Minimap_Loop], "ib-autmask-c", 2); + pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Compas], "IB-COMP-C", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079D0], "IB-InitG-c", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079C8], "IB-InitY-c", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079CC], "IB-InitR-c", 2); @@ -222,8 +222,8 @@ pTexture_LeftFrame->Load("ib-l-C.pcx", 0); pTexture_StatusBar->Load("IB-Foot-c.pcx", 0); uTextureID_right_panel = pIcons_LOD->LoadTexture("ib-mb-C", TEXTURE_16BIT_PALETTE); - dword_5079D8 = pIcons_LOD->LoadTexture("ib-autmask-c", TEXTURE_16BIT_PALETTE); - dword_5079B4 = pIcons_LOD->LoadTexture("IB-COMP-C", TEXTURE_16BIT_PALETTE); + uTextureID_Minimap_Loop = pIcons_LOD->LoadTexture("ib-autmask-c", TEXTURE_16BIT_PALETTE); + uTextureID_Compas = pIcons_LOD->LoadTexture("IB-COMP-C", TEXTURE_16BIT_PALETTE); dword_5079D0 = pIcons_LOD->LoadTexture("IB-InitG-c", TEXTURE_16BIT_PALETTE); dword_5079C8 = pIcons_LOD->LoadTexture("IB-InitY-c", TEXTURE_16BIT_PALETTE); dword_5079CC = pIcons_LOD->LoadTexture("IB-InitR-c", TEXTURE_16BIT_PALETTE); @@ -263,8 +263,8 @@ pTexture_LeftFrame->Reload("ib-l-a.pcx"); pTexture_StatusBar->Reload("IB-Foot-a.pcx"); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_right_panel], "ib-mb-a", 2); - pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079D8], "ib-autmask-a", 2); - pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079B4], "IB-COMP-a", 2); + pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Minimap_Loop], "ib-autmask-a", 2); + pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Compas], "IB-COMP-a", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079D0], "IB-InitG-a", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079C8], "IB-InitY-a", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079CC], "IB-InitR-a", 2); @@ -307,8 +307,8 @@ pTexture_LeftFrame->Load("ib-l-A.pcx", 0); pTexture_StatusBar->Load("IB-Foot-a.pcx", 0); uTextureID_right_panel = pIcons_LOD->LoadTexture("ib-mb-A", TEXTURE_16BIT_PALETTE); - dword_5079D8 = pIcons_LOD->LoadTexture("ib-autmask-a", TEXTURE_16BIT_PALETTE); - dword_5079B4 = pIcons_LOD->LoadTexture("IB-COMP-A", TEXTURE_16BIT_PALETTE); + uTextureID_Minimap_Loop = pIcons_LOD->LoadTexture("ib-autmask-a", TEXTURE_16BIT_PALETTE); + uTextureID_Compas = pIcons_LOD->LoadTexture("IB-COMP-A", TEXTURE_16BIT_PALETTE); dword_5079D0 = pIcons_LOD->LoadTexture("IB-InitG-a", TEXTURE_16BIT_PALETTE); dword_5079C8 = pIcons_LOD->LoadTexture("IB-InitY-a", TEXTURE_16BIT_PALETTE); dword_5079CC = pIcons_LOD->LoadTexture("IB-InitR-a", TEXTURE_16BIT_PALETTE); @@ -359,8 +359,8 @@ pTexture_LeftFrame->Reload("ib-l-B.pcx"); pTexture_StatusBar->Reload("IB-Foot-b.pcx"); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_right_panel], "ib-mb-B", 2); - pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079D8], "ib-autmask-b", 2); - pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079B4], "IB-COMP-B", 2); + pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Minimap_Loop], "ib-autmask-b", 2); + pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_Compas], "IB-COMP-B", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079D0], "IB-InitG-b", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079C8], "IB-InitY-b", 2); pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[dword_5079CC], "IB-InitR-b", 2); diff -r 86cb7398d2a8 -r 7d986a396092 mm7_2.cpp --- a/mm7_2.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/mm7_2.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -218,81 +218,59 @@ } //----- (004BBA85) -------------------------------------------------------- -const char *sub_4BBA85_bounties() +void CheckBountyRespawnAndAward() { - int v0; // edi@1 - signed __int64 v1; // qax@2 int i; // eax@2 - int v3; // edx@3 - int v4; // edi@14 - __int16 v5; // ax@14 - char v6; // zf@14 - Player *v7; // ebx@16 - const char *result; // eax@19 + int rand_monster_id; // edx@3 uDialogueType = 83; pDialogueWindow->Release(); pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0); - pBtn_ExitCancel = pDialogueWindow->CreateButton(471u, 445u, 169u, 35u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel" + pBtn_ExitCancel = pDialogueWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel" pIcons_LOD->GetTexture(uExitCancelTextureId), 0); pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); - pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, UIMSG_0, 0x53u, 0, "", 0); + pDialogueWindow->CreateButton(480, 160, 140, 30, 1, 0, UIMSG_0, 83, 0, "", 0); pDialogueWindow->_41D08F_set_keyboard_control_group(1, 1, 0, 2); dialog_menu_id = HOUSE_DIALOGUE_OTHER; - v0 = (int)((char *)window_SpeakInHouse->ptr_1C - 102); - if ( (signed __int64)__PAIR__(pParty->field_3C.field_0[2 * v0 + 1], pParty->field_3C.field_0[2 * v0]) < (signed __int64)pParty->uTimePlayed ) - { - pParty->field_75A[v0] = 0; - __debugbreak(); // starting year-related constant here; - v1 = (signed __int64)((double)(0x12750000 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) - * 0.033333335); - pParty->field_3C.field_0[2 * v0] = v1; - pParty->field_3C.field_0[2 * v0 + 1] = HIDWORD(v1); + //get new monster for hunting + if ( pParty->field_3C.bountyHunting_next_generation_time[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] < (signed __int64)pParty->uTimePlayed ) + { + pParty->monster_for_hunting_killed[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] = false; + pParty->field_3C.bountyHunting_next_generation_time[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] = (signed __int64)((double)(0x12750000 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) * 0.033333335); for ( i = rand(); ; i = rand() ) { - v3 = i % 258 + 1; - pParty->field_750[v0] = v3; - if ( (unsigned __int16)v3 < 0x73u || (unsigned __int16)v3 > 0x84u ) + rand_monster_id = i % 258 + 1; + pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] = rand_monster_id; + if ( (unsigned __int16)rand_monster_id < 0x73u || (unsigned __int16)rand_monster_id > 0x84u ) { - if ( ((unsigned __int16)v3 < 0xEBu || (unsigned __int16)v3 > 0xFCu) - && ((unsigned __int16)v3 < 0x85u || (unsigned __int16)v3 > 0x96u) - && ((unsigned __int16)v3 < 0x97u || (unsigned __int16)v3 > 0xBAu) - && ((unsigned __int16)v3 < 0xC4u || (unsigned __int16)v3 > 0xC6u) ) + if ( ((unsigned __int16)rand_monster_id < 0xEBu || (unsigned __int16)rand_monster_id > 0xFCu) + && ((unsigned __int16)rand_monster_id < 0x85u || (unsigned __int16)rand_monster_id > 0x96u) + && ((unsigned __int16)rand_monster_id < 0x97u || (unsigned __int16)rand_monster_id > 0xBAu) + && ((unsigned __int16)rand_monster_id < 0xC4u || (unsigned __int16)rand_monster_id > 0xC6u) ) break; } } } - v4 = v0; - v5 = pParty->field_750[v4]; - v6 = pParty->field_75A[v4] == 0; - word_F8B1A0 = pParty->field_750[v4]; - if ( v6 ) - { - v6 = v5 == 0; - result = pNPCTopics[351].pText; - if ( v6 ) - result = pNPCTopics[353].pText; - } - else - { - if ( v5 ) + bountyHunting_monster_id_for_hunting = pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)]; + if ( !pParty->monster_for_hunting_killed[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] ) + { + bountyHunting_text = pNPCTopics[351].pText; + if ( !pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] ) + bountyHunting_text = pNPCTopics[353].pText; + } + else//get prize + { + if ( pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] ) { - party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)v5].uLevel, 0); - v7 = pParty->pPlayers; - do - { - v7->SetVariable(VAR_Award, 86); - ++v7; - } - while ( (signed int)v7 < (signed int)pParty->pHirelings ); - pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v4]].uLevel; - pParty->field_750[v4] = 0; - pParty->field_75A[v4] = 0; + party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)]].uLevel, 0); + for ( uint i = 0; i < 4; ++i ) + pParty->pPlayers[i].SetVariable(VAR_Award, 86); + pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)]].uLevel; + pParty->monster_id_for_hunting[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] = 0; + pParty->monster_for_hunting_killed[(int)((char *)window_SpeakInHouse->ptr_1C - 102)] = false; } - result = pNPCTopics[352].pText; - } - dword_F8B1A4 = (char *)result; - return result; + bountyHunting_text = pNPCTopics[352].pText; + } } //----- (004BBCDD) -------------------------------------------------------- @@ -334,7 +312,7 @@ { uDialogueType = 91; v4 = pParty->pPlayers; - ++*((char *)&pParty->field_75A[3] + (unsigned __int8)pParty->field_7B5_in_arena_quest + 1); + ++*((char *)&pParty->monster_for_hunting_killed[3] + (unsigned __int8)pParty->field_7B5_in_arena_quest + 1); do { v4->SetVariable(VAR_Award, (unsigned __int8)pParty->field_7B5_in_arena_quest + 3); @@ -443,7 +421,7 @@ pRenderer->uTargetGMask | pRenderer->uTargetBMask); auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather); - pRenderer->_4A6A68(8, 352 - v0, pTex, pTex->uTextureHeight - v0); + pRenderer->GetLeather(8, 352 - v0, pTex, pTex->uTextureHeight - v0); pRenderer->DrawTextureIndexed(8u, 347 - v0, pTexture_591428); v1 = FitTextInAWindow(pGlobalTXT_LocalizationStrings[575], pFontArrus, &window, 0xDu, 0); @@ -707,7 +685,7 @@ char *v9; // eax@14 unsigned int v10; // eax@25 GUIWindow pWindow; // [sp+34h] [bp-9Ch]@1 - MSG Msg; // [sp+88h] [bp-48h]@22 + //MSG Msg; // [sp+88h] [bp-48h]@22 unsigned int v14; // [sp+A4h] [bp-2Ch]@5 void *v15; // [sp+A8h] [bp-28h]@1 char *pInString; // [sp+ACh] [bp-24h]@5 @@ -827,15 +805,12 @@ LODWORD(v23) = GetTickCount() + 5000; while ( (unsigned int)v23 > GetTickCount() ) ; - while ( 1 ) + for (MSG msg; PeekMessage(&msg, 0, 0, 0, PM_REMOVE);) { - v10 = PeekMessageA(&Msg, 0, 0, 0, 1u); - if ( !v10 ) - break; - if ( Msg.message == 18 ) + if (msg.message == WM_QUIT) Game_DeinitializeAndTerminate(0); - TranslateMessage(&Msg); - DispatchMessageA(&Msg); + TranslateMessage(&msg); + DispatchMessage(&msg); } if ( pMessageQueue_50CBD0->uNumMessages ) { @@ -846,12 +821,12 @@ pKeyActionMap->uLastKeyPressed = 0; do { - while ( PeekMessageA(&Msg, 0, 0, 0, 1u) ) + for (MSG msg; PeekMessage(&msg, 0, 0, 0, PM_REMOVE);) { - if ( Msg.message == 18 ) + if (msg.message == WM_QUIT) Game_DeinitializeAndTerminate(0); - TranslateMessage(&Msg); - DispatchMessageA(&Msg); + TranslateMessage(&msg); + DispatchMessage(&msg); } } while ( !pKeyActionMap->uLastKeyPressed ); @@ -1776,109 +1751,6 @@ return result; } -//----- (00450929) -------------------------------------------------------- -int LevelDecoration::GetGlobalEvent() -{ - LevelDecoration *v1; // esi@1 - signed int v2; // eax@1 - int v3; // eax@5 - int v4; // eax@6 - int v5; // eax@7 - int v6; // eax@8 - int v7; // eax@9 - int result; // eax@14 - int v9; // eax@18 - int v10; // eax@19 - int v11; // eax@20 - int v12; // eax@21 - int v13; // eax@22 - - switch (uDecorationDescID) - { - case 0: case 1: - case 2: case 3: - return 0; - - case 4: return 16; // dec01 "Trash Pile" - case 5: return 32; // dec02 "Campfire" - case 6: return 12 + rand() % 4; // dec03 "Cauldron" - case 7: case 8: - case 9: case 10: - return 0; - - case 11: return 34; // dec08 "Fruit plate" - case 12: - return 0; - - case 13: return 17; // dec10 "Trash Pile" - case 14: return 18; // dec11 "Filth" - case 15: case 16: case 17: - case 18: case 19: case 20: - case 21: case 22: case 23: - return 0; - - case 24: return 36; // dec21 "Keg" - case 25: case 26: case 27: case 28: case 29: - case 30: case 31: case 32: case 33: - return 0; - - case 34: return 4 + rand() % 6; // dec32 "Barrel" - case 35: case 36: case 37: case 38: case 39: - case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: - case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: - case 60: case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: case 69: - case 70: case 71: case 72: case 73: case 74: case 75: case 76: case 77: case 78: case 79: - case 80: case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88: case 89: - case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97: case 98: case 99: - case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109: - case 110: case 111: case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119: - case 120: case 121: case 122: case 123: case 124: case 125: case 126: case 127: case 128: case 129: - case 130: case 131: case 132: case 133: case 134: case 135: case 136: case 137: case 138: case 139: - case 140: case 141: case 142: case 143: case 144: case 145: case 146: case 147: case 148: case 149: - case 150: case 151: case 152: case 153: case 154: case 155: case 156: case 157: case 158: case 159: - case 160: case 161: case 162: case 163: case 164: case 165: case 166: case 167: case 168: case 169: - case 170: case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179: - case 180: case 181: case 182: case 183: - - case 184: return 33; // dec24 "Campfire" - case 185: case 186: - return 0; - - case 187: // dec88 "Mushroom" - case 190: // dec91 "Mushroom" - return 37; - - case 188: case 189: - case 191: case 192: case 193: case 194: case 195: case 196: - case 197: case 198: case 199: case 200: case 201: case 202: - case 203: case 204: case 205: - return 0; - - case 206: return 162 + rand() % 7; // dec60 - case 207: return 169 + rand() % 7; // dec61 - case 208: return 176 + rand() % 7; // dec62 - case 209: return 183 + rand() % 7; // dec63 - case 210: return 150; // dec64 "Magic Pedistal" - case 211: return 151; // dec65 "Magic Pedistal" - case 212: return 152; // dec66 "Magic Pedistal" - case 213: return 153; // dec67 "Magic Pedistal" - case 214: return 154; // dec68 "Magic Pedistal" - case 215: return 155; // dec69 "Magic Pedistal" - case 216: return 156; // dec70 "Magic Pedistal" - case 217: return 157; // dec71 "Magic Pedistal" - case 218: return 158; // dec72 "Magic Pedistal" - case 219: return 159; // dec73 "Magic Pedistal" - case 220: return 160; // dec74 "Magic Pedistal" - case 221: return 161; // dec75 "Magic Pedistal" - - case 222: case 223: case 224: - case 225: case 226: case 227: - return 0; - - default: assert(false && "Invalid Decoration"); - } -} - //----- (00450AAA) -------------------------------------------------------- void RespawnGlobalDecorations() { @@ -1889,7 +1761,7 @@ { auto decor = &pLevelDecorations[i]; - if (!decor->field_16_event_id) + if (!decor->uEventID) { if (decor->IsInteractive()) { @@ -3216,32 +3088,6 @@ event_triggers[num_event_triggers++] = i; } -//----- (004621DA) -------------------------------------------------------- -int int_get_vector_length(signed int x, signed int y, signed int z) -{ - signed int v3; // eax@2 - - if ( x < y ) - { - v3 = x; - x = y; - y = v3; - } - if ( x < z ) - { - v3 = x; - x = z; - z = v3; - } - if ( y < z ) - { - v3 = y; - y = z; - z = v3; - } - return (11 * y >> 5) + x + (z >> 2); -} - OPENFILENAMEA ofn; //----- (0046271C) -------------------------------------------------------- void CreateDefaultBLVLevel() @@ -3322,13 +3168,12 @@ pWindow = pGUIWindow_CurrentMenu; } - MSG msg; - while ( PeekMessageA(&msg, 0, 0, 0, PM_REMOVE) ) + for (MSG msg; PeekMessage(&msg, 0, 0, 0, PM_REMOVE);) { if (msg.message == WM_QUIT) Game_DeinitializeAndTerminate(0); TranslateMessage(&msg); - DispatchMessageA(&msg); + DispatchMessage(&msg); } if (dword_6BE364_game_settings_1 & 0x0100) { @@ -3409,34 +3254,40 @@ } //----- (004637EB) -------------------------------------------------------- -int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam) +int __stdcall aWinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - HANDLE v6; // eax@32 - HDC v10; // edi@50 - int v11; // esi@50 - signed int v13; // eax@135 - char v29; // dl@209 - bool v31; // ebx@211 - float v33; // ST04_4@246 - float v34; // ST04_4@254 - struct tagPAINTSTRUCT Paint; // [sp+24h] [bp-48h]@13 - int pXY[2]; // [sp+64h] [bp-8h]@261 - int a2; // [sp+7Ch] [bp+10h]@50 - - switch (Msg) - { - case WM_SIZING: return 1; + //HANDLE v6; // eax@32 + //HDC v10; // edi@50 + //int v11; // esi@50 + //signed int v13; // eax@135 + //char v29; // dl@209 + //bool v31; // ebx@211 + //float v33; // ST04_4@246 + //float v34; // ST04_4@254 + //struct tagPAINTSTRUCT Paint; // [sp+24h] [bp-48h]@13 + //int pXY[2]; // [sp+64h] [bp-8h]@261 + //int a2; // [sp+7Ch] [bp+10h]@50 + + switch (uMsg) + { + case WM_SIZING: return 1; + case WM_CREATE: case WM_NCCREATE: + case WM_GETTEXT: case WM_SETTEXT: case WM_SHOWWINDOW: - case WM_GETTEXT: - case WM_SETTEXT: return DefWindowProcW(hWnd, Msg, wParam, lParam); + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + + case WM_DESTROY: + SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); + PostQuitMessage(0); + return 0; case WM_WINDOWPOSCHANGED: { if (pVideoPlayer && pVideoPlayer->AnyMovieLoaded() && pVideoPlayer->pBinkBuffer) BinkBufferSetOffset(pVideoPlayer->pBinkBuffer, 0, 0); - return DefWindowProcW(hWnd, Msg, wParam, lParam); + return DefWindowProcW(hWnd, uMsg, wParam, lParam); } case WM_CHAR: @@ -3444,13 +3295,13 @@ if (!pKeyActionMap->_459F10(wParam) && !viewparams->field_4C) GUI_HandleHotkey(wParam); } - return DefWindowProcA(hWnd, Msg, wParam, lParam); + return DefWindowProcW(hWnd, uMsg, wParam, lParam); case WM_DEVICECHANGE: { if (wParam == 0x8000) // CD or some device has been inserted - notify InsertCD dialog - PostMessageA(hInsertCDWindow, WM_USER + 1, 0, 0); + PostMessageW(hInsertCDWindow, WM_USER + 1, 0, 0); return 0; } @@ -3462,7 +3313,7 @@ case 101: // Quit game case 40001: - SendMessageA(::hWnd, WM_DESTROY, 0, 0); + SendMessageW(hWnd, WM_DESTROY, 0, 0); return 0; @@ -3631,355 +3482,311 @@ } } - return DefWindowProcA(hWnd, Msg, wParam, lParam); - }; - - if ( Msg > WM_SYSCOMMAND ) - { - switch ( Msg ) - { - case WM_LBUTTONDOWN: - if ( pArcomageGame->bGameInProgress ) - { - pArcomageGame->stru1.field_0 = 7; - ArcomageGame::OnMouseClick(0, 1); - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - goto __handle_mouse_click; - - case WM_RBUTTONDOWN: - v31 = 0; - if ( !pArcomageGame->bGameInProgress ) - //goto LABEL_240; - { - if ( pVideoPlayer->pVideoFrame.pPixels != (unsigned __int16 *)v31 ) - pVideoPlayer->bStopBeforeSchedule = 1; - - pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); - if (pGame) - { - v33 = pGame->pIndoorCameraD3D->GetPickDepth(); - pGame->PickMouse(v33, (unsigned __int16)lParam, lParam >> 16, v31, &vis_sprite_filter_2, &vis_door_filter); - } - - sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0); - return DefWindowProcA(hWnd, Msg, wParam, lParam); - - } - + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + + case WM_LBUTTONDOWN: + if (pArcomageGame->bGameInProgress) + { + pArcomageGame->stru1.field_0 = 7; + ArcomageGame::OnMouseClick(0, true); + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + } + + goto __handle_mouse_click; + + case WM_RBUTTONDOWN: + if (pArcomageGame->bGameInProgress) + { pArcomageGame->stru1.field_0 = 8; - ArcomageGame::OnMouseClick(1, 1); - return DefWindowProcA(hWnd, Msg, wParam, lParam); - case WM_LBUTTONUP: - if ( !pArcomageGame->bGameInProgress ) - //goto LABEL_218; - { - back_to_game(); - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - pArcomageGame->stru1.field_0 = 3; - ArcomageGame::OnMouseClick(0, 0); - return DefWindowProcA(hWnd, Msg, wParam, lParam); - case WM_RBUTTONUP: - if ( !pArcomageGame->bGameInProgress ) - { -//LABEL_218: - - back_to_game(); - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - pArcomageGame->stru1.field_0 = 4; - ArcomageGame::OnMouseClick(1, false); - return DefWindowProcA(hWnd, Msg, wParam, lParam); - - case WM_LBUTTONDBLCLK: - if ( pArcomageGame->bGameInProgress ) - { - pArcomageGame->stru1.field_0 = 7; - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } + ArcomageGame::OnMouseClick(1, true); + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + } + + if (pVideoPlayer->pVideoFrame.pPixels) + pVideoPlayer->bStopBeforeSchedule = 1; + + pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam)); + + if (pGame) + { + pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), LOWORD(lParam), HIWORD(lParam), 0, &vis_sprite_filter_2, &vis_door_filter); + } + + sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0); + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + + + case WM_LBUTTONUP: + if ( !pArcomageGame->bGameInProgress ) + { + back_to_game(); + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + } + pArcomageGame->stru1.field_0 = 3; + ArcomageGame::OnMouseClick(0, 0); + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + case WM_RBUTTONUP: + if ( !pArcomageGame->bGameInProgress ) + { + back_to_game(); + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + } + pArcomageGame->stru1.field_0 = 4; + ArcomageGame::OnMouseClick(1, false); + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + + case WM_LBUTTONDBLCLK: + if ( pArcomageGame->bGameInProgress ) + { + pArcomageGame->stru1.field_0 = 7; + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + } __handle_mouse_click: - if ( pVideoPlayer->pVideoFrame.pPixels ) + if (pVideoPlayer->pVideoFrame.pPixels) + pVideoPlayer->bStopBeforeSchedule = 1; + + pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam)); + + if (GetCurrentMenuID() == MENU_CREATEPARTY) + { + UI_OnKeyDown(VK_SELECT); + } + + if (pGame) + pGame->PickMouse(512.0, LOWORD(lParam), HIWORD(lParam), false, &vis_sprite_filter_3, &vis_door_filter); + + UI_OnMouseLeftClick(0); + + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + + case WM_RBUTTONDBLCLK: + if ( !pArcomageGame->bGameInProgress ) + { + if (pVideoPlayer->pVideoFrame.pPixels) pVideoPlayer->bStopBeforeSchedule = 1; - pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); - - if (GetCurrentMenuID() != MENU_CREATEPARTY) - pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); - else + pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam)); + + if (pGame) { - UI_OnKeyDown(VK_SELECT); - pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); - } - - - if (pGame) - pGame->PickMouse(512.0, (unsigned __int16)lParam, lParam >> 16, false, &vis_sprite_filter_3, &vis_door_filter); - - UI_OnMouseLeftClick(0); - - return DefWindowProcA(hWnd, Msg, wParam, lParam); - - case WM_RBUTTONDBLCLK: - v31 = 0; - if ( !pArcomageGame->bGameInProgress ) - { -//LABEL_240: - if ( pVideoPlayer->pVideoFrame.pPixels != (unsigned __int16 *)v31 ) - pVideoPlayer->bStopBeforeSchedule = 1; - - pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); - if (pGame) - { - v33 = pGame->pIndoorCameraD3D->GetPickDepth(); - pGame->PickMouse(v33, (unsigned __int16)lParam, lParam >> 16, v31, &vis_sprite_filter_2, &vis_door_filter); - } - - sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0); - return DefWindowProcA(hWnd, Msg, wParam, lParam); - + pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), LOWORD(lParam), HIWORD(lParam), false, &vis_sprite_filter_2, &vis_door_filter); } - pArcomageGame->stru1.field_0 = 8; - return DefWindowProcA(hWnd, Msg, wParam, lParam); - case WM_MBUTTONDOWN: - if ( pRenderer->pRenderD3D ) - { - if ( pGame ) - { - v34 = pGame->pIndoorCameraD3D->GetPickDepth(); - pGame->PickMouse(v34, (unsigned __int16)lParam, lParam >> 16, 1, &vis_sprite_filter_3, &vis_face_filter); - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - } - if ( !pGame ) - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); - return DefWindowProcA(hWnd, Msg, wParam, lParam); - case WM_MOUSEMOVE: - if ( pArcomageGame->bGameInProgress ) - { - pXY[0] = (unsigned __int16)lParam; - pXY[1] = lParam >> 16; - ArcomageGame::OnMouseMove((POINT *)pXY); - ArcomageGame::OnMouseClick(0, wParam & 1); - v29 = (wParam >> 1) & 1; - ArcomageGame::OnMouseClick(1, v29 != 0); - } - else - { - pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16); - } - return DefWindowProcA(hWnd, Msg, wParam, lParam); - default: - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - } - if ( Msg == WM_SYSCOMMAND ) - { - if ( wParam == SC_SCREENSAVE || wParam == SC_MONITORPOWER ) - return 0; - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - if ( Msg > WM_ACTIVATEAPP ) - { - if ( Msg != WM_KEYFIRST && Msg != WM_WINDOWPOSCHANGED) - { - if ( Msg == WM_KEYUP && wParam == VK_CONTROL ) + + sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0); + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + } + + pArcomageGame->stru1.field_0 = 8; + + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + + case WM_MBUTTONDOWN: + if (pRenderer->pRenderD3D && pGame) + { + pGame->PickMouse(pGame->pIndoorCameraD3D->GetPickDepth(), LOWORD(lParam), HIWORD(lParam), 1, &vis_sprite_filter_3, &vis_face_filter); + } + + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + + case WM_MOUSEMOVE: + if ( pArcomageGame->bGameInProgress ) + { + ArcomageGame::OnMouseMove(LOWORD(lParam), HIWORD(lParam)); + ArcomageGame::OnMouseClick(0, wParam == MK_LBUTTON); + ArcomageGame::OnMouseClick(1, wParam == MK_RBUTTON); + } + else + { + pMouse->SetMouseClick(LOWORD(lParam), HIWORD(lParam)); + } + + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + + case WM_SYSCOMMAND: + if ( wParam == SC_SCREENSAVE || wParam == SC_MONITORPOWER ) + return 0; + + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + + case WM_KEYUP: + if (wParam == VK_CONTROL) { dword_507B98_ctrl_pressed = 0; } - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 ) - { - pKeyActionMap->_459F10(wParam); - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - if ( !pArcomageGame->bGameInProgress ) - { - if ( pVideoPlayer->pVideoFrame.pPixels ) - pVideoPlayer->bStopBeforeSchedule = 1; - if ( wParam == VK_RETURN ) - { - if ( !viewparams->field_4C ) - UI_OnKeyDown(wParam); - return 0; - } - if ( wParam == VK_CONTROL ) + + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + + case WM_KEYDOWN: + if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 ) { - dword_507B98_ctrl_pressed = 1; - return 0; - } - if ( wParam == VK_ESCAPE ) - { - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0); - return 0; + pKeyActionMap->_459F10(wParam); + return DefWindowProcW(hWnd, uMsg, wParam, lParam); } - if ( wParam <= VK_HOME ) - return 0; - if ( wParam > VK_DOWN ) + if ( !pArcomageGame->bGameInProgress ) { - if ( wParam != VK_F4 || pVideoPlayer->AnyMovieLoaded() ) - return 0; - SendMessageA(hWnd, WM_COMMAND, 104, 0); - return 0; - } - if ( wParam >= VK_LEFT && wParam <= VK_DOWN ) - { - if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW ) + if ( pVideoPlayer->pVideoFrame.pPixels ) + pVideoPlayer->bStopBeforeSchedule = 1; + if ( wParam == VK_RETURN ) { if ( !viewparams->field_4C ) UI_OnKeyDown(wParam); return 0; } - } - if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW ) - return 0; - } - - pArcomageGame->stru1.field_0 = 1; - - v13 = (unsigned __int16)MapVirtualKeyA((unsigned __int16)wParam, 2u); - set_stru1_field_8_InArcomage(v13); - if ( wParam == 27 ) - { - pArcomageGame->GameOver = 1; - pArcomageGame->field_F4 = 1; - pArcomageGame->uGameResult = 2; - pArcomageGame->field_B0 = -2; - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - if ( wParam != 114 ) - { - if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() ) - SendMessageA(hWnd, 0x111u, 0x68u, 0); - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - SendMessageA(hWnd, WM_COMMAND, 103, 0); - return 0; - } - if ( Msg == WM_ACTIVATEAPP ) - { - if ( wParam && (GetForegroundWindow() == hWnd || GetForegroundWindow() == hInsertCDWindow) ) - { - if ( BYTE1(dword_6BE364_game_settings_1) & 1 ) - { - dword_4E98BC_bApplicationActive = 1; - if ( pRenderer->bWindowMode ) + if ( wParam == VK_CONTROL ) + { + dword_507B98_ctrl_pressed = 1; + return 0; + } + if ( wParam == VK_ESCAPE ) { - v10 = GetDC(0); - a2 = GetDeviceCaps(v10, BITSPIXEL); - v11 = GetDeviceCaps(v10, PLANES); - ReleaseDC(0, v10); - if ( a2 != 16 || v11 != 1 ) - Abortf(pGlobalTXT_LocalizationStrings[62]); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, window_SpeakInHouse != 0, 0); + return 0; } - BYTE1(dword_6BE364_game_settings_1) &= 0xFEu; - - if ( pArcomageGame->bGameInProgress ) - { - pArcomageGame->field_F9 = 1; - } - else + if ( wParam <= VK_HOME ) + return 0; + if ( wParam > VK_DOWN ) { - if ( BYTE1(dword_6BE364_game_settings_1) & 2 ) - BYTE1(dword_6BE364_game_settings_1) &= 0xFDu; - else - pEventTimer->Resume(); - if ( BYTE1(dword_6BE364_game_settings_1) & 4 ) - BYTE1(dword_6BE364_game_settings_1) &= 0xFBu; - else - pMiscTimer->Resume(); - - viewparams->bRedrawGameUI = true; - if ( pVideoPlayer->pSmackerMovie ) + if ( wParam != VK_F4 || pVideoPlayer->AnyMovieLoaded() ) + return 0; + SendMessageW(hWnd, WM_COMMAND, 104, 0); + return 0; + } + if ( wParam >= VK_LEFT && wParam <= VK_DOWN ) + { + if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW ) { - pRenderer->RestoreFrontBuffer(); - pRenderer->_4A184C(); - pVideoPlayer->_4BF5B2(); + if ( !viewparams->field_4C ) + UI_OnKeyDown(wParam); + return 0; } } - if ( pAudioPlayer->hAILRedbook && !bGameoverLoop && !pVideoPlayer->pSmackerMovie ) - AIL_redbook_resume(pAudioPlayer->hAILRedbook); + if ( pCurrentScreen != SCREEN_GAME && pCurrentScreen != SCREEN_MODAL_WINDOW ) + return 0; } - } - else - { - if ( !(dword_6BE364_game_settings_1 & 0x100) ) + + pArcomageGame->stru1.field_0 = 1; + + set_stru1_field_8_InArcomage(MapVirtualKey(wParam, MAPVK_VK_TO_CHAR)); + if ( wParam == 27 ) { - while(initing); //ADDED spinlock to allow int players ets! Gloval - dword_4E98BC_bApplicationActive = 0; - if ( (pVideoPlayer->pSmackerMovie || pVideoPlayer->pBinkMovie) && pVideoPlayer->bPlayingMovie ) - pVideoPlayer->bStopBeforeSchedule = 1; - - if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 ) - SetWindowPos(::hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u); - ClipCursor(0); - dword_6BE364_game_settings_1 |= 0x100u; - if ( pEventTimer->bPaused ) - BYTE1(dword_6BE364_game_settings_1) |= 2u; - else - pEventTimer->Pause(); - if ( pMiscTimer->bPaused ) - BYTE1(dword_6BE364_game_settings_1) |= 4u; - else - pMiscTimer->Pause(); - - pAudioPlayer->StopChannels(-1, -1); - if ( pAudioPlayer->hAILRedbook ) - AIL_redbook_pause(pAudioPlayer->hAILRedbook); + pArcomageGame->GameOver = 1; + pArcomageGame->field_F4 = 1; + pArcomageGame->uGameResult = 2; + pArcomageGame->field_B0 = -2; + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + } + if ( wParam != 114 ) + { + if ( wParam == 115 && !pVideoPlayer->AnyMovieLoaded() ) + SendMessage(hWnd, WM_COMMAND, 0x68u, 0); + return DefWindowProcW(hWnd, uMsg, wParam, lParam); } - } - return 0; - } - if (Msg == WM_CREATE) - { - auto hDC = GetDC(hWnd); - { - if (GetDeviceCaps(hDC, BITSPIXEL) < 8) + SendMessageW(hWnd, WM_COMMAND, 103, 0); + return 0; + + case WM_ACTIVATEAPP: + if ( wParam && (GetForegroundWindow() == hWnd || GetForegroundWindow() == hInsertCDWindow) ) { - ReleaseDC(hWnd, hDC); - Log::Warning(L"You must be running in 256 color mode or higher."); - Abortf("You must be running in 256 color mode or higher. You can change the screen depth with the control panel display icon."); + if ( BYTE1(dword_6BE364_game_settings_1) & 1 ) + { + dword_4E98BC_bApplicationActive = 1; + if ( pRenderer->bWindowMode ) + { + HDC hDC = GetDC(hWnd); + int bitsPerPixel = GetDeviceCaps(hDC, BITSPIXEL); + int planes = GetDeviceCaps(hDC, PLANES); + ReleaseDC(hWnd, hDC); + if (bitsPerPixel != 16 || planes != 1) + Abortf(pGlobalTXT_LocalizationStrings[62]); + } + BYTE1(dword_6BE364_game_settings_1) &= 0xFEu; + + if ( pArcomageGame->bGameInProgress ) + { + pArcomageGame->field_F9 = 1; + } + else + { + if ( BYTE1(dword_6BE364_game_settings_1) & 2 ) + BYTE1(dword_6BE364_game_settings_1) &= 0xFDu; + else + pEventTimer->Resume(); + if ( BYTE1(dword_6BE364_game_settings_1) & 4 ) + BYTE1(dword_6BE364_game_settings_1) &= 0xFBu; + else + pMiscTimer->Resume(); + + viewparams->bRedrawGameUI = true; + if ( pVideoPlayer->pSmackerMovie ) + { + pRenderer->RestoreFrontBuffer(); + pRenderer->_4A184C(); + pVideoPlayer->_4BF5B2(); + } + } + if ( pAudioPlayer->hAILRedbook && !bGameoverLoop && !pVideoPlayer->pSmackerMovie ) + AIL_redbook_resume(pAudioPlayer->hAILRedbook); + } } - } - ReleaseDC(hWnd, hDC); - return 0; - } - if ( Msg == WM_DESTROY ) - { - v6 = GetCurrentProcess(); - SetPriorityClass(v6, 0x20u); - if ( pGame ) - { - - } - - PostQuitMessage(0); - return 0; - } - if ( Msg == WM_SETFOCUS ) - { - if ( ::hWnd == (HWND)wParam ) - { + else + { + if (!(dword_6BE364_game_settings_1 & 0x100)) + { + dword_4E98BC_bApplicationActive = 0; + if ( (pVideoPlayer->pSmackerMovie || pVideoPlayer->pBinkMovie) && pVideoPlayer->bPlayingMovie ) + pVideoPlayer->bStopBeforeSchedule = 1; + + if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 ) + SetWindowPos(hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u); + ClipCursor(0); + dword_6BE364_game_settings_1 |= 0x100u; + if ( pEventTimer->bPaused ) + BYTE1(dword_6BE364_game_settings_1) |= 2u; + else + pEventTimer->Pause(); + if ( pMiscTimer->bPaused ) + BYTE1(dword_6BE364_game_settings_1) |= 4u; + else + pMiscTimer->Pause(); + + pAudioPlayer->StopChannels(-1, -1); + if ( pAudioPlayer->hAILRedbook ) + AIL_redbook_pause(pAudioPlayer->hAILRedbook); + } + } + return 0; + + case WM_CREATE: + { + auto hDC = GetDC(hWnd); + { + if (GetDeviceCaps(hDC, BITSPIXEL) < 8) + { + ReleaseDC(hWnd, hDC); + Log::Warning(L"You must be running in 256 color mode or higher."); + Abortf("You must be running in 256 color mode or higher. You can change the screen depth with the control panel display icon."); + } + } + ReleaseDC(hWnd, hDC); + } + return 0; + + case WM_SETFOCUS: dword_4E98BC_bApplicationActive = 0; if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 ) - SetWindowPos(::hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u); + SetWindowPos(hWnd, (HWND)0xFFFFFFFE, 0, 0, 0, 0, 0x18u); ClipCursor(0); - - } -//_def_wnd_proc: - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - if ( Msg != WM_KILLFOCUS ) - { - if ( Msg == WM_PAINT ) - { + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + + case WM_KILLFOCUS: + dword_4E98BC_bApplicationActive = 1; + return DefWindowProcW(hWnd, uMsg, wParam, lParam); + + case WM_PAINT: if ( !GetUpdateRect(hWnd, 0, 0) || !dword_4E98BC_bApplicationActive && !pRenderer->bWindowMode ) return 0; + PAINTSTRUCT Paint; BeginPaint(hWnd, &Paint); if ( pArcomageGame->bGameInProgress ) { @@ -3996,13 +3803,10 @@ pRenderer->Present(); EndPaint(hWnd, &Paint); return 0; - } - //goto _def_wnd_proc; - return DefWindowProcA(hWnd, Msg, wParam, lParam); - } - if ( ::hWnd != (HWND)wParam || (dword_4E98BC_bApplicationActive = 1, pRenderer->bWindowMode) || true ) - return DefWindowProcA(hWnd, Msg, wParam, lParam); - + + default: + return DefWindowProcA(hWnd, uMsg, wParam, lParam); + } } //----- (00464479) -------------------------------------------------------- @@ -4046,7 +3850,7 @@ pEventTimer->Pause(); pMiscTimer->Pause(); pParty->uFlags = 2; - pCastSpellInfo.data()->_427D48(1); + CastSpellInfoHelpers::_427D48(); ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); DoPrepareWorld(0, (_0_box_loading_1_fullscreen == 0) + 1); pMiscTimer->Resume(); @@ -4536,7 +4340,6 @@ //----- (004651F4) -------------------------------------------------------- bool MM7_Initialize() { -initing=true; //ADDED Gloval wchar_t pCurrentDir[1024]; _wgetcwd(pCurrentDir, 1024); @@ -4599,7 +4402,6 @@ uWindowX, uWindowY, 640, 480, nullptr, - nullptr, wcxw.hInstance, nullptr); @@ -4810,7 +4612,6 @@ MoveWindow(hWnd, uWindowX, uWindowY, rcClient.left - rcClient.right - rcWindow.left + rcWindow.right + 640, rcClient.top - rcClient.bottom - rcWindow.top + rcWindow.bottom + 480, 0); - ShowWindow(hWnd, SW_SHOWNORMAL); pIcons_LOD = new LODFile_IconsBitmaps; if (!pIcons_LOD->Load("data\\icons.lod", "icons")) @@ -5125,7 +4926,7 @@ break; } - initing = false; //ADDED Gloval + ShowWindow(hWnd, SW_SHOWNORMAL); return true; } @@ -5366,6 +5167,10 @@ bool new_sky = false; bool change_seasons = false; bool all_magic = true; +bool wizard_eye = false; +bool debug_information = false; +bool show_picked_face = false; +bool draw_debug_line = false; //----- (00462C94) -------------------------------------------------------- bool MM_Main(const wchar_t *pCmdLine) @@ -6242,7 +6047,7 @@ } v25 = &pLevelDecorations[v20]; v26 = v25; - v27 = v25->field_16_event_id; + v27 = v25->uEventID; if ( v27 ) { v23 = GetEventHintString(v27); diff -r 86cb7398d2a8 -r 7d986a396092 mm7_3.cpp --- a/mm7_3.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/mm7_3.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -5639,45 +5639,6 @@ MM7Initialization(); } -//----- (0047A825) -------------------------------------------------------- -bool LevelDecoration::_47A825() -{ - bool v1; // ebx@1 - LevelDecoration *v2; // edi@1 - - v1 = 0; - v2 = this; - if ( pParty->uCurrentHour >= 1 || (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 178) ) - { - v1 = 0; - } - else - { - if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 164) - && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 165) - && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 166) - && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 167) - && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 168) - && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 169) - && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 170) - && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 171) - && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 172) - && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 173) - && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 174) - && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 175) - && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 176) - && (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 177) ) - { - v1 = 1; - LOBYTE(v2->field_2) &= 0xDFu; - return v1; - } - } - LOBYTE(v2->field_2) |= 0x20u; - return v1; -} - - //----- (0047C370) -------------------------------------------------------- unsigned int GetLevelFogColor() { @@ -6357,8 +6318,8 @@ char *v3; // esi@1 int v4; // edi@4 bool v5; // ecx@4 - SpriteFrame *v6; // eax@6 - SpriteFrame *v7; // edi@6 + SpriteFrame *pFrame; // eax@6 + //SpriteFrame *v7; // edi@6 int v8; // eax@6 unsigned __int16 v9; // ax@6 RenderBillboardTransform_local0 v10; // [sp+Ch] [bp-5Ch]@1 @@ -6396,24 +6357,24 @@ { if ( !pOtherOverlayList->pOverlays[i].field_0 ) { - v6 = pSpriteFrameTable->GetFrame(pOverlayList->pOverlays[pOtherOverlayList->pOverlays[i].field_2].uSpriteFramesetID, + pFrame = pSpriteFrameTable->GetFrame(pOverlayList->pOverlays[pOtherOverlayList->pOverlays[i].field_2].uSpriteFramesetID, pOtherOverlayList->pOverlays[i].field_4); - v7 = v6; + //v7 = v6; v11 = pOtherOverlayList->pOverlays[i].field_E; - v13 = v6->scale; - v13 = (unsigned __int64)(v11 * (signed __int64)v13) >> 16; + //v13 = pFrame->scale; + v13 = (unsigned __int64)(v11 * (signed __int64)pFrame->scale) >> 16; v10.uScreenSpaceX = pOtherOverlayList->pOverlays[i].field_8; v10.uScreenSpaceY = pOtherOverlayList->pOverlays[i].field_A; v10._screenspace_x_scaler_packedfloat = v13; v10._screenspace_y_scaler_packedfloat = v13; - v10.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v6->uPaletteIndex, 0, 1); + v10.pPalette = PaletteManager::Get_Dark_or_Red_LUT(pFrame->uPaletteIndex, 0, 1); v8 = pOtherOverlayList->pOverlays[i].field_2; v10.sZValue = 0; v10.uFlags = 0; v9 = pOverlayList->pOverlays[v8].uOverlayType; if ( !v9 || v9 == 2 ) - v10.uScreenSpaceY += pSprites_LOD->pSpriteHeaders[v7->pHwSpriteIDs[0]].uHeight >> 1; - result = pSprites_LOD->pSpriteHeaders[v7->pHwSpriteIDs[0]]._4AD2D1(&v10, 0); + v10.uScreenSpaceY += pSprites_LOD->pSpriteHeaders[pFrame->pHwSpriteIDs[0]].uHeight >> 1; + result = pSprites_LOD->pSpriteHeaders[pFrame->pHwSpriteIDs[0]]._4AD2D1(&v10, 0); ++v12; if ( v12 == 5 ) break; @@ -7229,40 +7190,25 @@ } //----- (0044882F) -------------------------------------------------------- -void __fastcall SetDecorationSprite(unsigned int uCog, int a2, const char *pFileName) +void __fastcall SetDecorationSprite(uint16_t uCog, bool bHide, const char *pFileName) { - signed int v3; // ebp@1 - char *v4; // esi@2 - unsigned __int16 v5; // ax@6 - unsigned int v6; // [sp+4h] [bp-8h]@1 - int v7; // [sp+8h] [bp-4h]@1 - - v3 = 0; - v7 = a2; - v6 = uCog; - if ( (signed int)uNumLevelDecorations > 0 ) - { - v4 = (char *)&pLevelDecorations[0].field_2; - do + for (size_t i = 0; i < uNumLevelDecorations; i++) + { + if (pLevelDecorations[i].uCog == uCog) { - if ( *((_WORD *)v4 + 9) == v6 ) + if (pFileName && strcmp(pFileName, "0")) { - if ( pFileName && _stricmp(pFileName, "0") ) - { - v5 = pDecorationList->GetDecorIdByName(pFileName); - *((_WORD *)v4 - 1) = v5; - pDecorationList->InitializeDecorationSprite((signed __int16)v5); - } - if ( v7 ) - *v4 &= 0xDFu; - else - *v4 |= 0x20u; - pParty->uFlags |= 2u; + pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(pFileName); + pDecorationList->InitializeDecorationSprite(pLevelDecorations[i].uDecorationDescID); } - ++v3; - v4 += 32; + + if (bHide) + pLevelDecorations[i].uFlags &= ~LEVEL_DECORATION_INVISIBLE; + else + pLevelDecorations[i].uFlags |= LEVEL_DECORATION_INVISIBLE; + + pParty->uFlags |= 2u; } - while ( v3 < (signed int)uNumLevelDecorations ); } } @@ -7619,7 +7565,7 @@ pParty->vPosition.z = _5B65B0_npcdata_rep_or_other; pParty->uFallStartY = _5B65B0_npcdata_rep_or_other; } - if ( _5B65B4_npcdata_loword_house_or_other ) + if ( _5B65B4_npcdata_loword_house_or_other != -1 ) pParty->sRotationY = _5B65B4_npcdata_loword_house_or_other; if ( _5B65B8_npcdata_hiword_house_or_other ) pParty->sRotationX = _5B65B8_npcdata_hiword_house_or_other; @@ -7799,70 +7745,6 @@ return true; } -//----- (0044C2F4) -------------------------------------------------------- -bool LevelDecoration::IsInteractive() -{ - switch (uDecorationDescID) - { - case 4: // trash pile - case 5: // campfire - case 6: // cauldron - case 11: // fruit plate - case 13: // trash pile - case 14: // dirt - case 24: // keg - case 184: // fire - case 187: // fire - case 190: // fire - return true; - } - - if (uDecorationDescID >= 206 && uDecorationDescID <= 209) // lighthouse fire - return true; - if (uDecorationDescID >= 210 && uDecorationDescID <= 221) // magic pedistal - return true; - - return false; -} - -//----- (0044C362) -------------------------------------------------------- -void Vec3_int_::Normalize_float() -{ - //Vec3_int_ *v1; // esi@1 - double v2; // st6@1 - float v3; // ST20_4@1 - double v4; // st5@1 - float v5; // ST18_4@1 - double v6; // st4@1 - float v7; // ST14_4@1 - float v8; // ST24_4@1 - float v9; // ST20_4@1 - double v10; // ST0C_8@1 - float v11; // ST18_4@1 - double v12; // ST0C_8@1 - float v13; // ST14_4@1 - double v14; // ST0C_8@1 - - assert(false); - //v1 = this; - v2 = (double)this->x * 0.000015258789; - v3 = v2; - v4 = (double)this->y * 0.000015258789; - v5 = v4; - v6 = (double)this->z * 0.000015258789; - v7 = v6; - v8 = 1.0 / sqrt(v6 * v6 + v4 * v4 + v2 * v2); - v9 = v8 * v3 * 65536.0; - v10 = v9 + 6.7553994e15; - this->x = LODWORD(v10); - v11 = v8 * v5 * 65536.0; - v12 = v11 + 6.7553994e15; - this->y = LODWORD(v12); - v13 = v8 * v7 * 65536.0; - v14 = v13 + 6.7553994e15; - this->z = LODWORD(v14); -} - //----- (00401000) -------------------------------------------------------- void mm7__vector_constructor(void *a1, int objSize, int numObjs, int ( *constructor)(int)) { diff -r 86cb7398d2a8 -r 7d986a396092 mm7_4.cpp --- a/mm7_4.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/mm7_4.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -49,165 +49,33 @@ //----- (0046CC4B) -------------------------------------------------------- void check_event_triggers() { - int v0; // eax@1 LevelDecoration *v1; // esi@2 - signed int v2; // edi@2 - int v3; // ebx@2 - int v4; // eax@3 - int v5; // ebx@3 - unsigned int v6; // ecx@3 - unsigned int v7; // edx@6 - unsigned int v8; // edx@8 - Actor *v9; // edi@13 - int v10; // ebx@14 - int v11; // eax@14 - int v12; // ebx@14 - unsigned int v13; // ecx@14 - int v14; // edx@15 - unsigned int v15; // edx@17 - unsigned int v16; // edx@19 - char *v17; // edi@25 - int v18; // ebx@26 - int v19; // eax@26 - int v20; // ebx@26 - unsigned int v21; // ecx@26 - int v22; // edx@27 - unsigned int v23; // edx@29 - unsigned int v24; // edx@31 - int v25; // [sp+0h] [bp-24h]@3 - int v26; // [sp+0h] [bp-24h]@14 - int v27; // [sp+0h] [bp-24h]@26 - int v28; // [sp+4h] [bp-20h]@3 - int v29; // [sp+4h] [bp-20h]@14 - int v30; // [sp+4h] [bp-20h]@26 - signed int v31; // [sp+8h] [bp-1Ch]@2 - int v32; // [sp+Ch] [bp-18h]@2 - int v33; // [sp+10h] [bp-14h]@2 - int i; // [sp+14h] [bp-10h]@1 - int v35; // [sp+18h] [bp-Ch]@2 - int v36; // [sp+1Ch] [bp-8h]@3 - signed int v37; // [sp+1Ch] [bp-8h]@12 - signed int v38; // [sp+20h] [bp-4h]@24 - v0 = 0; - for ( i = 0; i < num_event_triggers; ++i ) + for (size_t i = 0; i < num_event_triggers; i++) { - v1 = &pLevelDecorations[event_triggers[v0]]; - v2 = v1->field_18; - v3 = v1->vPosition.y; - v33 = v1->vPosition.x; - v32 = v1->vPosition.y; - v35 = v1->vPosition.z; - v31 = v1->field_18; - if ( v1->field_2 & 1 ) + v1 = &pLevelDecorations[event_triggers[i]]; + + if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_TOUCH + && v1->vPosition.GetDistanceTo(pParty->vPosition) < v1->uTriggerRange) { - v36 = abs(v1->vPosition.x - pParty->vPosition.x); - v25 = abs(v3 - pParty->vPosition.y); - v28 = abs(v35 - pParty->vPosition.z); - v4 = v36; - v5 = v25; - v6 = v28; - if ( v36 < v25 ) - { - v4 = v25; - v5 = v36; - } - if ( v4 < v28 ) - { - v7 = v4; - v4 = v28; - v6 = v7; - } - if ( v5 < (signed int)v6 ) - { - v8 = v6; - v6 = v5; - v5 = v8; - } - if ( (signed int)(((unsigned int)(11 * v5) >> 5) + (v6 >> 2) + v4) < v2 ) - EventProcessor(v1->field_16_event_id, PID(OBJECT_Decoration,i), 1); + EventProcessor(v1->uEventID, PID(OBJECT_Decoration,i), 1); } - if ( v1->field_2 & 2 ) + else if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_MONSTER) { - v37 = 0; - if ( (signed int)uNumActors > 0 ) + for (size_t j = 0; j < uNumActors; j++) { - v9 = pActors.data();//[0].vPosition.y; - do - { - v10 = abs(v33 - v9->vPosition.x); - v29 = abs(v32 - v9->vPosition.y); - v26 = abs(v35 - v9->vPosition.z); - v11 = v10; - v12 = v29; - v13 = v26; - if ( v11 < v29 ) - { - v14 = v11; - v11 = v29; - v12 = v14; - } - if ( v11 < v26 ) - { - v15 = v11; - v11 = v26; - v13 = v15; - } - if ( v12 < (signed int)v13 ) - { - v16 = v13; - v13 = v12; - v12 = v16; - } - if ( (signed int)(((unsigned int)(11 * v12) >> 5) + (v13 >> 2) + v11) < v31 ) - EventProcessor(v1->field_16_event_id, 0, 1); - ++v37; - ++v9; - } - while ( v37 < (signed int)uNumActors ); + if (v1->vPosition.GetDistanceTo(pActors[j].vPosition) < v1->uTriggerRange) + EventProcessor(v1->uEventID, 0, 1); } } - if ( v1->field_2 & 4 ) + else if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_OBJECT) { - v38 = 0; - if ( (signed int)uNumSpriteObjects > 0 ) + for (size_t j = 0; j < uNumSpriteObjects; j++) { - v17 = (char *)&pSpriteObjects[0].vPosition.y; - do - { - v18 = abs(v33 - *((int *)v17 - 1)); - v30 = abs(v32 - *(int *)v17); - v27 = abs(v35 - *((int *)v17 + 1)); - v19 = v18; - v20 = v30; - v21 = v27; - if ( v19 < v30 ) - { - v22 = v19; - v19 = v30; - v20 = v22; - } - if ( v19 < v27 ) - { - v23 = v19; - v19 = v27; - v21 = v23; - } - if ( v20 < (signed int)v21 ) - { - v24 = v21; - v21 = v20; - v20 = v24; - } - if ( (signed int)(((unsigned int)(11 * v20) >> 5) + (v21 >> 2) + v19) < v31 ) - EventProcessor(v1->field_16_event_id, 0, 1); - ++v38; - v17 += 112; - } - while ( v38 < (signed int)uNumSpriteObjects ); + if (v1->vPosition.GetDistanceTo(pSpriteObjects[j].vPosition) < v1->uTriggerRange) + EventProcessor(v1->uEventID, 0, 1); } } - v0 = i + 1; } } // 6836C8: using guessed type int 6836C8_num_decorations_6807E8; @@ -466,7 +334,7 @@ for ( i = 0; i < v0->uNumDecorations; ++i ) { v1 = &pLevelDecorations[v0->pDecorationIDs[i]]; - if ( !(v1->field_2 & 0x20) ) + if (!(v1->uFlags & LEVEL_DECORATION_INVISIBLE)) { v2 = &pDecorationList->pDecorations[v1->uDecorationDescID]; if (!v2->CanMoveThrough()) @@ -3761,7 +3629,7 @@ OracleDialogue(); break; case 311: - sub_4BBA85_bounties(); + CheckBountyRespawnAndAward(); break; case 399: __debugbreak(); // what kind of dialogue is that? diff -r 86cb7398d2a8 -r 7d986a396092 mm7_5.cpp --- a/mm7_5.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/mm7_5.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -1246,10 +1246,10 @@ if ( dword_506F14 ) { Rest(_506F18_num_minutes_to_sleep); - pParty->pPlayers[3].pConditions[2] = 0i64; - pParty->pPlayers[2].pConditions[2] = 0i64; - pParty->pPlayers[1].pConditions[2] = 0i64; - pParty->pPlayers[0].pConditions[2] = 0i64; + pParty->pPlayers[3].SetAsleep(false); + pParty->pPlayers[2].SetAsleep(false); + pParty->pPlayers[1].SetAsleep(false); + pParty->pPlayers[0].SetAsleep(false); } pTexture_RestUI_CurrentSkyFrame->Release(); pTexture_RestUI_CurrentHourglassFrame->Release(); @@ -1257,6 +1257,11 @@ pTexture_RestUI_CurrentSkyFrame = 0; pIcons_LOD->SyncLoadedFilesCount(); pIcons_LOD->RemoveTexturesPackFromTextureList(); + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + pOutdoor->UpdateSunlightVectors(); + pOutdoor->UpdateFog(); + } _506F18_num_minutes_to_sleep = 0; dword_506F14 = 0; dword_507B94 = 1; @@ -1275,18 +1280,18 @@ unk_50C9A0 = 0; back_to_game(); } - } - if ( (signed int)uActiveCharacter < 1 || (signed int)uActiveCharacter > 4 ) + } + if ( (signed int)uActiveCharacter < 1 || (signed int)uActiveCharacter > 4 ) uActiveCharacter = pParty->GetNextActiveCharacter(); - pGUIWindow_CurrentMenu->Release(); - if ( pGUIWindow_CurrentMenu == window_SpeakInHouse ) - window_SpeakInHouse = 0; - pGUIWindow_CurrentMenu = 0; - pEventTimer->Resume(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - pIcons_LOD->RemoveTexturesFromTextureList(); - continue; + pGUIWindow_CurrentMenu->Release(); + if ( pGUIWindow_CurrentMenu == window_SpeakInHouse ) + window_SpeakInHouse = 0; + pGUIWindow_CurrentMenu = 0; + pEventTimer->Resume(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = 1; + pIcons_LOD->RemoveTexturesFromTextureList(); + continue; case SCREEN_E: __debugbreak(); pGUIWindow_CurrentMenu->Release(); @@ -1688,7 +1693,7 @@ { pParty->field_6E4 = 0; pParty->field_6E0 = 0; - pCastSpellInfo.data()->_427D48(1); + CastSpellInfoHelpers::_427D48(); DialogueEnding(); pEventTimer->Pause(); pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_Box); @@ -1792,7 +1797,7 @@ if ( !v47 ) continue; pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; - LOBYTE(pSpellInfo->field_8) &= 0xBFu; + pSpellInfo->uFlags &= ~0x40u; pSpellInfo->uPlayerID_2 = uMessageParam; pSpellInfo->spell_target_pid = v44; pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); @@ -1810,7 +1815,7 @@ if ( !v47 ) continue; pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; - LOBYTE(pSpellInfo->field_8) &= 0xBFu; + pSpellInfo->uFlags &= ~0x40u; pSpellInfo->uPlayerID_2 = uMessageParam; pSpellInfo->spell_target_pid = v44; pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); @@ -1824,7 +1829,7 @@ } if ( v45 == 5 ) { - v48 = pLevelDecorations[v46].field_16_event_id == 0; + v48 = pLevelDecorations[v46].uEventID == 0; } else { @@ -1837,7 +1842,7 @@ continue; v44 = uNumSeconds; pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; - LOBYTE(pSpellInfo->field_8) &= 0xBFu; + pSpellInfo->uFlags &= ~0x40u; pSpellInfo->uPlayerID_2 = uMessageParam; pSpellInfo->spell_target_pid = v44; pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); @@ -1857,7 +1862,7 @@ if ( v48 ) continue; pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; - LOBYTE(pSpellInfo->field_8) &= 0xBFu; + pSpellInfo->uFlags &= ~0x40u; pSpellInfo->uPlayerID_2 = uMessageParam; pSpellInfo->spell_target_pid = v44; pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); @@ -1886,13 +1891,13 @@ switch ( uMessage ) { case UIMSG_CastSpell_Character_Big_Improvement: - LOBYTE(pSpellInfo->field_8) &= 0xFDu; + pSpellInfo->uFlags &= ~0x02u; break; case UIMSG_CastSpell_Character_Small_Improvement: - HIBYTE(pSpellInfo->field_8) &= 0xFEu; + pSpellInfo->uFlags &= ~0x0100u; break; case UIMSG_HiredNPC_CastSpell: - HIBYTE(pSpellInfo->field_8) &= 0xFDu; + pSpellInfo->uFlags &= ~0x0200u; break; } pSpellInfo->uPlayerID_2 = uMessageParam; @@ -2370,14 +2375,14 @@ pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; if ( uMessage == UIMSG_CastSpell_Shoot_Monster ) { - LOBYTE(pSpellInfo->field_8) &= 0xF7; + pSpellInfo->uFlags &= ~0x08; } else { if ( uMessage == UIMSG_CastSpell_Monster_Improvement ) - HIBYTE(pSpellInfo->field_8) &= 0xFEu; + pSpellInfo->uFlags &= ~0x0100u; else - HIBYTE(pSpellInfo->field_8) &= 0xFDu; + pSpellInfo->uFlags &= ~0x0200u; } pSpellInfo->uPlayerID_2 = uMessageParam; pSpellInfo->spell_target_pid = v44; @@ -3235,7 +3240,7 @@ } } } - pCastSpellInfo.data()->_427E01_cast_spell(); + CastSpellInfoHelpers::_427E01_cast_spell(); } //----- (004356FF) -------------------------------------------------------- @@ -3870,27 +3875,6 @@ } } -//----- (0043AA99) -------------------------------------------------------- -void __fastcall Vec3_int_::Rotate(int sDepth, int sRotY, int sRotX, Vec3_int_ v, int *outx, int *outy, int *outz) -{ - float cosf_x = cosf(3.14159265f * sRotX / 1024.0f), - sinf_x = sinf(3.14159265f * sRotX / 1024.0f), - cosf_y = cosf(3.14159265f * sRotY / 1024.0f), - sinf_y = sinf(3.14159265f * sRotY / 1024.0f); - - *outx = v.x + ((unsigned __int64)(sinf_y * (signed __int64)((unsigned __int64)(cosf_x * (signed __int64)sDepth)>> 16))); - *outy = v.y + ((unsigned __int64)(cosf_y * (signed __int64)((unsigned __int64)(cosf_x * (signed __int64)sDepth)>> 16))); - *outz = v.z + ((unsigned __int64)(sinf_x * (signed __int64)sDepth) >> 16); -} - -//----- (0043AB61) -------------------------------------------------------- -void Vec3_int_::Normalize(int *x, int *y, int *z) -{ - *x *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); - *y *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); - *z *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); -} - //----- (0043AE12) -------------------------------------------------------- double __fastcall sub_43AE12(signed int a1) { @@ -4316,14 +4300,14 @@ //----- (004070EF) -------------------------------------------------------- -bool __fastcall sub_4070EF_prolly_collide_objects(unsigned int uObjID, unsigned int uObj2ID) +bool __fastcall sub_4070EF_prolly_detect_player(unsigned int uObjID, unsigned int uObj2ID) { signed int v2; // eax@1 - unsigned int v3; // ecx@1 - signed int v4; // esi@1 + //unsigned int v3; // ecx@1 + //signed int v4; // esi@1 int v5; // ecx@2 signed int v6; // eax@4 - int v7; // eax@4 + int object1_sector; // eax@4 float v8; // ST24_4@5 double v9; // ST18_8@5 signed int v10; // eax@6 @@ -4333,18 +4317,18 @@ int v14; // esi@8 int v15; // esi@9 signed int v16; // eax@11 - int v17; // edi@11 - int v18; // esi@11 - int v19; // eax@13 + int obj2_z; // edi@11 + int obj2_x; // esi@11 + int obj2_sector; // eax@13 float v20; // ST24_4@14 double v21; // ST18_8@14 signed int v22; // eax@15 - int v23; // ebx@16 + int dist2_x; // ebx@16 signed int v24; // ecx@16 int v25; // eax@18 - int v26; // eax@28 - BLVSector *v27; // edx@31 - int v28; // ecx@31 + //int v26; // eax@28 + //BLVSector *v27; // edx@31 + //int v28; // ecx@31 BLVFace *v29; // ebx@32 Vec3_short_ *v30; // esi@32 int v31; // eax@32 @@ -4360,12 +4344,12 @@ __int16 v42; // bx@58 int v43; // [sp-8h] [bp-70h]@11 int v44; // [sp-4h] [bp-6Ch]@11 - int v45; // [sp+Ch] [bp-5Ch]@32 - __int16 v46; // [sp+10h] [bp-58h]@32 + //int v45; // [sp+Ch] [bp-5Ch]@32 + //__int16 v46; // [sp+10h] [bp-58h]@32 int v47; // [sp+18h] [bp-50h]@20 int v48; // [sp+1Ch] [bp-4Ch]@20 int v49; // [sp+20h] [bp-48h]@20 - int v50; // [sp+24h] [bp-44h]@16 + int dist2_z; // [sp+24h] [bp-44h]@16 signed int v51; // [sp+24h] [bp-44h]@27 signed int v52; // [sp+28h] [bp-40h]@26 signed int v53; // [sp+2Ch] [bp-3Ch]@23 @@ -4375,101 +4359,85 @@ signed int v57; // [sp+3Ch] [bp-2Ch]@28 int v58; // [sp+44h] [bp-24h]@50 int v59; // [sp+48h] [bp-20h]@44 - int v60; // [sp+50h] [bp-18h]@11 + int obj2_y; // [sp+50h] [bp-18h]@11 signed int v61; // [sp+50h] [bp-18h]@31 - int v62; // [sp+54h] [bp-14h]@16 - int v63; // [sp+58h] [bp-10h]@4 - int v64; // [sp+5Ch] [bp-Ch]@4 - int v65; // [sp+60h] [bp-8h]@4 + //int v62; // [sp+54h] [bp-14h]@16 + int obj_x; // [sp+58h] [bp-10h]@4 + int obj_y; // [sp+5Ch] [bp-Ch]@4 + int obj_z; // [sp+60h] [bp-8h]@4 int v66; // [sp+64h] [bp-4h]@7 v2 = PID_ID(uObjID); - v3 = PID_TYPE(uObjID) - 2; - v4 = uObj2ID; - if ( v3 ) + if ( PID_TYPE(uObjID) == 5 ) { - v5 = v3 - 1; - if ( v5 ) - { - if ( v5 != 2 ) - return 0; v6 = v2; - v63 = pLevelDecorations[v6].vPosition.x; - v64 = pLevelDecorations[v6].vPosition.y; - v65 = pLevelDecorations[v6].vPosition.z; - v7 = pIndoor->GetSector(v63, v64, v65); - } - else - { - v63 = pActors[v2].vPosition.x; - v64 = pActors[v2].vPosition.y; + obj_x = pLevelDecorations[v6].vPosition.x; + obj_y = pLevelDecorations[v6].vPosition.y; + obj_z = pLevelDecorations[v6].vPosition.z; + object1_sector = pIndoor->GetSector(obj_x, obj_y, obj_z); + } + else if ( PID_TYPE(uObjID) == 3 ) + { + obj_x = pActors[v2].vPosition.x; + obj_y = pActors[v2].vPosition.y; v8 = (double)pActors[v2].uActorHeight * 0.69999999; - v9 = v8 + 6.7553994e15; - v65 = LODWORD(v9) + pActors[v2].vPosition.z; - v7 = pActors[v2].uSectorID; - } + //v9 = v8 + 6.7553994e15; + //obj_z = LODWORD(v9) + pActors[v2].vPosition.z; + obj_z = (int)v8 + pActors[v2].vPosition.z; + object1_sector = pActors[v2].uSectorID; } - else + else if ( PID_TYPE(uObjID) == 2 ) { v10 = v2; - v63 = pSpriteObjects[v10].vPosition.x; - v64 = pSpriteObjects[v10].vPosition.y; - v11 = pSpriteObjects[v10].vPosition.z; - v7 = pSpriteObjects[v10].uSectorID; - v65 = v11; - } - v66 = v7; - v12 = PID_ID(v4); - v13 = PID_TYPE(v4) - 2; - if ( v13 ) - { - v14 = v13 - 1; - if ( v14 ) - { - v15 = v14 - 1; - if ( v15 ) - { - if ( v15 != 1 ) - return 0; - v16 = v12; - v17 = pLevelDecorations[v16].vPosition.z; - v18 = pLevelDecorations[v16].vPosition.x; - v44 = pLevelDecorations[v16].vPosition.z; - v60 = pLevelDecorations[v16].vPosition.y; - v43 = pLevelDecorations[v16].vPosition.y; - } - else - { - v18 = pParty->vPosition.x; - v17 = pParty->sEyelevel + pParty->vPosition.z; - v60 = pParty->vPosition.y; - v44 = pParty->sEyelevel + pParty->vPosition.z; - v43 = pParty->vPosition.y; - } - v19 = pIndoor->GetSector(v18, v43, v44); - } - else - { - v60 = pActors[v12].vPosition.y; - v18 = pActors[v12].vPosition.x; - v20 = (double)pActors[v12].uActorHeight * 0.69999999; - v21 = v20 + 6.7553994e15; - v17 = LODWORD(v21) + pActors[v12].vPosition.z; - v19 = pActors[v12].uSectorID; - } + obj_x = pSpriteObjects[v10].vPosition.x; + obj_y = pSpriteObjects[v10].vPosition.y; + obj_z = pSpriteObjects[v10].vPosition.z; + object1_sector = pSpriteObjects[v10].uSectorID; } else + return 0; + v66 = object1_sector; + v12 = PID_ID(uObj2ID); + if ( PID_TYPE(uObj2ID) == 5) + { + v16 = v12; + obj2_z = pLevelDecorations[v16].vPosition.z; + obj2_x = pLevelDecorations[v16].vPosition.x; + obj2_y = pLevelDecorations[v16].vPosition.y; + obj2_sector = pIndoor->GetSector(obj2_x, obj2_y, obj2_z); + } + else if ( PID_TYPE(uObj2ID) == 4) + { + obj2_x = pParty->vPosition.x; + obj2_z = pParty->sEyelevel + pParty->vPosition.z; + obj2_y = pParty->vPosition.y; + obj2_sector = pIndoor->GetSector(obj2_x, obj2_y, obj2_z); + } + + else if( PID_TYPE(uObj2ID) == 3) + { + obj2_y = pActors[v12].vPosition.y; + obj2_x = pActors[v12].vPosition.x; + v20 = (double)pActors[v12].uActorHeight * 0.69999999; + //v21 = v20 + 6.7553994e15; + //obj2_z = LODWORD(v21) + pActors[v12].vPosition.z; + obj2_z = (int)v20 + pActors[v12].vPosition.z; + obj2_sector = pActors[v12].uSectorID; + } + + else if ( PID_TYPE(uObj2ID) == 2) { v22 = v12; - v18 = pSpriteObjects[v22].vPosition.x; - v17 = pSpriteObjects[v22].vPosition.z; - v60 = pSpriteObjects[v22].vPosition.y; - v19 = pSpriteObjects[v22].uSectorID; + obj2_x = pSpriteObjects[v22].vPosition.x; + obj2_z = pSpriteObjects[v22].vPosition.z; + obj2_y = pSpriteObjects[v22].vPosition.y; + obj2_sector = pSpriteObjects[v22].uSectorID; } - v62 = v19; - v23 = v18 - v63; - v50 = v17 - v65; - v24 = integer_sqrt(v23 * v23 + (v60 - v64) * (v60 - v64) + v50 * v50); + else + return 0; + dist2_x = obj2_x - obj_x; + dist2_z = obj2_z - obj_z; + v24 = integer_sqrt(dist2_x * dist2_x + (obj2_y - obj_y) * (obj2_y - obj_y) + dist2_z * dist2_z); if ( v24 > 5120 ) return 0; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) @@ -4477,120 +4445,116 @@ v25 = 65536; if ( v24 ) v25 = 65536 / v24; - v49 = v23 * v25; - v47 = v50 * v25; - v48 = (v60 - v64) * v25; - v56 = v63; - if ( v63 < v18 ) + v49 = dist2_x * v25; + v47 = dist2_z * v25; + v48 = (obj2_y - obj_y) * v25; + if ( obj_x < obj2_x ) { - v55 = v18; + v56 = obj_x; + v55 = obj2_x; } else { - v56 = v18; - v55 = v63; + v56 = obj2_x; + v55 = obj_x; } - v54 = v64; - if ( v64 < v60 ) + if ( obj_y < obj2_y ) { - v53 = v60; + v54 = obj_y; + v53 = obj2_y; } else { - v54 = v60; - v53 = v64; + v54 = obj2_y; + v53 = obj_y; } - v52 = v65; - if ( v65 < v17 ) + if ( obj_z < obj2_z ) { - v51 = v17; + v52 = obj_z; + v51 = obj2_z; } else { - v52 = v17; - v51 = v65; + v52 = obj2_z; + v51 = obj_z; } v57 = 0; - v26 = v66; - while ( 2 ) - { - if ( v26 == v62 ) + if ( v66 == obj2_sector ) return 1; - if ( v57 >= 30 || (v27 = pIndoor->pSectors, v28 = v66, v61 = 0, pIndoor->pSectors[v66].uNumPortals <= 0) ) - break; - while ( 1 ) - { - v29 = &pIndoor->pFaces[v27[v28].pPortals[v61]]; + //for ( v57 = 0; v57 < 30; v57++ ) + if ( v57 < 30 && !(v61 = 0, pIndoor->pSectors[v66].uNumPortals <= 0) ) + for( int v61 = 0; v61 < pIndoor->pSectors[v66].uNumPortals; v61++ ) + { + v29 = &pIndoor->pFaces[pIndoor->pSectors[v66].pPortals[v61]]; v30 = &pIndoor->pVertices[*v29->pVertexIDs]; - v45 = *(int *)&v30->x; - v46 = v30->z; - v31 = v29->pFacePlane_old.vNormal.z * (v46 - v65) - + v29->pFacePlane_old.vNormal.y * (SHIWORD(v45) - v64) - + v29->pFacePlane_old.vNormal.x * ((signed __int16)v45 - v63); + //v45 = *(int *)&v30->x; + //v46 = v30->z; + //v31 = v29->pFacePlane_old.vNormal.z * (v46 - obj_z) + v31 = v29->pFacePlane_old.vNormal.z * (v30->z - obj_z) + //+ v29->pFacePlane_old.vNormal.y * (SHIWORD(v45) - obj_y) + + v29->pFacePlane_old.vNormal.y * (v30->y - obj_y) + //+ v29->pFacePlane_old.vNormal.x * ((signed __int16)v45 - obj_x); + + v29->pFacePlane_old.vNormal.x * (v30->x - obj_x); if ( v66 != v29->uSectorID ) v31 = -v31; - if ( v31 >= 0 && (signed __int16)v45 != v63 && SHIWORD(v45) != v64 && v46 != v65 + //if (!( v31 >= 0 && (signed __int16)v45 != obj_x && SHIWORD(v45) != obj_y && v46 != obj_z + if (!( v31 >= 0 && v30->x != obj_x && v30->y != obj_y && v30->z != obj_z || v56 > v29->pBounding.x2 || v55 < v29->pBounding.x1 || v54 > v29->pBounding.y2 || v53 < v29->pBounding.y1 || v52 > v29->pBounding.z2 - || v51 < v29->pBounding.z1 ) - goto LABEL_54; - v32 = (unsigned __int64)(v49 * (signed __int64)v29->pFacePlane_old.vNormal.x) >> 16; - v33 = (unsigned __int64)(v47 * (signed __int64)v29->pFacePlane_old.vNormal.z) >> 16; - v34 = (unsigned __int64)(v48 * (signed __int64)v29->pFacePlane_old.vNormal.y) >> 16; - v35 = v32 + v33 + v34 == 0; - v36 = v32 + v33 + v34; - v59 = v32 + v33 + v34; - if ( v35 ) - goto LABEL_53; - v37 = v65 * v29->pFacePlane_old.vNormal.z; - v38 = -(v29->pFacePlane_old.dist + v37 + v63 * v29->pFacePlane_old.vNormal.x + v64 * v29->pFacePlane_old.vNormal.y); - if ( v36 <= 0 ) - break; - if ( v29->pFacePlane_old.dist + v37 + v63 * v29->pFacePlane_old.vNormal.x + v64 * v29->pFacePlane_old.vNormal.y <= 0 ) - goto LABEL_49; -LABEL_53: - v27 = pIndoor->pSectors; -LABEL_54: - ++v61; - if ( v61 >= v27[v28].uNumPortals ) - goto LABEL_55; + || v51 < v29->pBounding.z1 ) ) + { + v32 = (unsigned __int64)(v49 * (signed __int64)v29->pFacePlane_old.vNormal.x) >> 16; + v33 = (unsigned __int64)(v47 * (signed __int64)v29->pFacePlane_old.vNormal.z) >> 16; + v34 = (unsigned __int64)(v48 * (signed __int64)v29->pFacePlane_old.vNormal.y) >> 16; + v35 = v32 + v33 + v34 == 0; + v36 = v32 + v33 + v34; + v59 = v32 + v33 + v34; + if ( !v35 ) + { + v37 = obj_z * v29->pFacePlane_old.vNormal.z; + v38 = -(v29->pFacePlane_old.dist + v37 + obj_x * v29->pFacePlane_old.vNormal.x + obj_y * v29->pFacePlane_old.vNormal.y); + if ( v36 <= 0 ^ v29->pFacePlane_old.dist + v37 + obj_x * v29->pFacePlane_old.vNormal.x + obj_y * v29->pFacePlane_old.vNormal.y <= 0) + { + v39 = abs(-(v29->pFacePlane_old.dist + + v37 + + obj_x * v29->pFacePlane_old.vNormal.x + + obj_y * v29->pFacePlane_old.vNormal.y)) >> 14; + if ( v39 > abs(v36) + || (LODWORD(v40) = v38 << 16, HIDWORD(v40) = v38 >> 16, v58 = v40 / v59, (signed int)(v40 / v59) < 0) + || !sub_4075DB( + obj_x + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v49) >> 16) + 32768) >> 16), + obj_y + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v48) >> 16) + 32768) >> 16), + obj_z + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v47) >> 16) + 32768) >> 16), + v29) ) + { + continue; + } + if ( v29->uSectorID == v66 ) + v42 = v29->uBackSectorID; + else + v42 = v29->uSectorID; + if ( v42 != v66 ) + { + ++v57; + v66 = v42; + if ( v42 == obj2_sector ) + return 1; + if ( v57 < 30 && pIndoor->pSectors[v66].uNumPortals > 0) + { + v61=-1; + continue; + } + + } + break; + } + } + } } - if ( v29->pFacePlane_old.dist + v37 + v63 * v29->pFacePlane_old.vNormal.x + v64 * v29->pFacePlane_old.vNormal.y < 0 ) - goto LABEL_53; -LABEL_49: - v39 = abs(-(v29->pFacePlane_old.dist - + v37 - + v63 * v29->pFacePlane_old.vNormal.x - + v64 * v29->pFacePlane_old.vNormal.y)) >> 14; - if ( v39 > abs(v36) - || (LODWORD(v40) = v38 << 16, HIDWORD(v40) = v38 >> 16, v58 = v40 / v59, (signed int)(v40 / v59) < 0) - || !sub_4075DB( - v63 + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v49) >> 16) + 32768) >> 16), - v64 + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v48) >> 16) + 32768) >> 16), - v65 + ((signed int)(((unsigned __int64)(v58 * (signed __int64)v47) >> 16) + 32768) >> 16), - v29) ) - { - v28 = v66; - goto LABEL_53; - } - if ( v29->uSectorID == v66 ) - v42 = v29->uBackSectorID; - else - v42 = v29->uSectorID; - v26 = v42; - if ( v42 != v66 ) - { - ++v57; - v66 = v42; - continue; - } - break; - } -LABEL_55: - if ( v66 != v62 ) + if ( v66 != obj2_sector ) return 0; return 1; } @@ -4621,7 +4585,7 @@ signed int a3a; // [sp+24h] [bp+8h]@14 int a4a; // [sp+28h] [bp+Ch]@2 - __debugbreak(); + //__debugbreak(); v5 = a4->uAttributes; v9 = pIndoor->pVertices; diff -r 86cb7398d2a8 -r 7d986a396092 mm7_6.cpp --- a/mm7_6.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/mm7_6.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -1110,7 +1110,7 @@ if (!player->CanAct()) return; - pCastSpellInfo.data()->_427D48(uActiveCharacter); + CastSpellInfoHelpers::_427D48(); //v3 = 0; if (pParty->Invisible()) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); @@ -2062,7 +2062,7 @@ v24 = pPlayers[uActiveCharacter]->GetAttackRecoveryTime(false); if ( !pParty->bTurnBasedModeOn ) pPlayers[uActiveCharacter]->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v24 * 2.133333333333333)); - pCastSpellInfo.data()->_427D48(uActiveCharacter); + CastSpellInfoHelpers::_427D48(); pTurnEngine->ApplyPlayerAction(); } } diff -r 86cb7398d2a8 -r 7d986a396092 mm7_data.cpp --- a/mm7_data.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/mm7_data.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -33,12 +33,6 @@ #include "MapInfo.h" struct MapStats *pMapStats; - - -#include "CastSpellInfo.h" -std::array pCastSpellInfo; -CastSpellInfo stru_50CDB4; // idb - #include "Viewport.h" struct Viewport *pViewport = new Viewport; struct ViewingParams *viewparams = new ViewingParams; @@ -942,11 +936,11 @@ int uTextureID_PlayerBuff_Preservation; // weak int uTextureID_PlayerBuff_Bless; // weak int uTextureID_Btn_QuickReference; // weak -int dword_5079B4; // weak +int uTextureID_Compas; // dword_5079B4 int dword_5079C8; // weak int dword_5079CC; // weak int dword_5079D0; // weak -int dword_5079D8; // weak +int uTextureID_Minimap_Loop; // dword_5079D8 struct GUIButton *pBtn_ZoomOut; // idb struct GUIButton *pBtn_ZoomIn; // idb unsigned int uGameUIFontShadow; @@ -1018,7 +1012,7 @@ char pStartingMapName[32]; // idb std::array IsPlayerWearingWatersuit; std::array party_has_equipment; -std::array byte_5111F6; +std::array byte_5111F6; int _unused000; // weak @@ -1141,7 +1135,7 @@ std::array _6807B8_level_decorations_ids; // idb int _6807E0_num_decorations_with_sounds_6807B8; // weak std::array event_triggers; // 6807E8 -int num_event_triggers; // 6836C8 +size_t num_event_triggers; // 6836C8 std::array dword_69B010; float flt_69B138_dist; // weak char byte_69BD41_unused; // weak @@ -1354,8 +1348,8 @@ std::array<__int16, 777> word_F8B158; // weak struct Texture *ShopTexture; // idb std::array ItemsInShopTexture; -__int16 word_F8B1A0; // weak -const char *dword_F8B1A4; // idb +__int16 bountyHunting_monster_id_for_hunting; // word_F8B1A0 +const char *bountyHunting_text; // word_F8B1A4 int contract_approved; // weak int dword_F8B1AC_award_bit_number; // idb int dword_F8B1B0; // weak @@ -1381,5 +1375,3 @@ std::array<__int16, 104> intersect_face_vertex_coords_list_b; // word_F8BD18 int dword_F93F20; // weak int dword_F93F70; // weak - -volatile bool initing; \ No newline at end of file diff -r 86cb7398d2a8 -r 7d986a396092 mm7_data.h --- a/mm7_data.h Sat Sep 07 12:51:06 2013 +0200 +++ b/mm7_data.h Sat Sep 07 13:03:18 2013 +0200 @@ -584,11 +584,11 @@ extern int uTextureID_PlayerBuff_Preservation; // weak extern int uTextureID_PlayerBuff_Bless; // weak extern int uTextureID_Btn_QuickReference; // weak -extern int dword_5079B4; // weak +extern int uTextureID_Compas; // dword_5079B4 extern int dword_5079C8; // weak extern int dword_5079CC; // weak extern int dword_5079D0; // weak -extern int dword_5079D8; // weak +extern int uTextureID_Minimap_Loop; // dword_5079D8 extern struct GUIButton *pBtn_ZoomOut; // idb extern struct GUIButton *pBtn_ZoomIn; // idb extern unsigned int uGameUIFontShadow; @@ -660,7 +660,7 @@ extern char pStartingMapName[32]; // idb extern std::array IsPlayerWearingWatersuit; extern std::array party_has_equipment; -extern std::array byte_5111F6; +extern std::array byte_5111F6; extern std::array papredoll_dbrds; extern int bRingsShownInCharScreen; // weak @@ -784,7 +784,7 @@ extern std::array _6807B8_level_decorations_ids; // idb extern int _6807E0_num_decorations_with_sounds_6807B8; // weak extern std::array event_triggers; // 6807E8 -extern int num_event_triggers; // 6836C8 +extern size_t num_event_triggers; // 6836C8 extern std::array dword_69B010; extern float flt_69B138_dist; // weak extern char byte_69BD41_unused; // weak @@ -1008,8 +1008,8 @@ extern std::array<__int16, 777> word_F8B158; // weak extern struct Texture *ShopTexture; // idb extern std::array ItemsInShopTexture; -extern __int16 word_F8B1A0; // weak -extern const char *dword_F8B1A4; // idb +extern __int16 bountyHunting_monster_id_for_hunting; // weak +extern const char *bountyHunting_text; // idb extern int contract_approved; // weak extern int dword_F8B1AC_award_bit_number; // idb extern int dword_F8B1B0; // weak @@ -1039,7 +1039,6 @@ extern int dword_F93F20; // weak extern int dword_F93F70; // weak -extern volatile bool initing; //ADDED @@ -1072,7 +1071,7 @@ void MakeActorAIList_ODM(); int MakeActorAIList_BLV(); void UpdateActorAI(); -bool __fastcall sub_4070EF_prolly_collide_objects(unsigned int uObjID, unsigned int uObj2ID); +bool __fastcall sub_4070EF_prolly_detect_player(unsigned int uObjID, unsigned int uObj2ID); bool __fastcall sub_4075DB(int a1, int a2, int a3, struct BLVFace *a4); bool __fastcall sub_4077F1(int a1, int a2, int a3, struct ODMFace *a4, struct BSPVertexBuffer *a5); bool __fastcall sub_407A1C(int x, int z, int y, struct Vec3_int_ v); // idb @@ -1099,7 +1098,7 @@ void identify_item(); void sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(struct Vec2_int_ *_this); void UI_OnMouseLeftClick(int *pXY); // idb -unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2); +unsigned int UI_GetHealthManaAndOtherQualitiesStringColor(signed int current_pos, signed int base_pos); unsigned int __fastcall GetSizeInInventorySlots(unsigned int uNumPixels); struct GUIButton *__fastcall GUI_HandleHotkey(unsigned __int8 uHotkey); // idb int __fastcall GUI_ReplaceHotkey(unsigned __int8 uOldHotkey, unsigned __int8 uNewHotkey, char bFirstCall); @@ -1198,7 +1197,6 @@ void PrepareToLoadBLV(unsigned int bLoading); void __fastcall PrepareToLoadODM(unsigned int bLoading, struct OutdoorCamera *a2); void _461103_load_level_sub(); -int int_get_vector_length(signed int x, signed int y, signed int z); void MainMenu_Loop(); char sub_4637E0_is_there_popup_onscreen(); void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); @@ -1243,7 +1241,7 @@ void _4B4224_UpdateNPCTopics(int _this); void __fastcall DrawTextAtStatusBar(const char *Str, int a5); __int64 GetExperienceRequiredForLevel(int a1); -const char *sub_4BBA85_bounties(); +void CheckBountyRespawnAndAward(); void sub_4BBCDD(); void __fastcall _4BBF61_summon_actor(int a1, __int16 x, int y, int z); // idb void ArenaFight(); @@ -1360,13 +1358,13 @@ int NPC_EventProcessor(int npc_event_id, int entry_line = 0); void __fastcall sub_448518_npc_set_item(int npc, unsigned int item, int a3); void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename); -void __fastcall SetDecorationSprite(unsigned int uCog, int a2, const char *pFileName); // idb +void __fastcall SetDecorationSprite(uint16_t uCog, bool bHide, const char *pFileName); // idb void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on); void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle); void GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide); // idb void OnTimer(int); void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName); -void __fastcall EventCastSpell(int spellnum, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz);//sub_448DF8 +void __fastcall EventCastSpell(int uSpellID, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz);//sub_448DF8 __int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2); // idb bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2); void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb diff -r 86cb7398d2a8 -r 7d986a396092 stru10.cpp --- a/stru10.cpp Sat Sep 07 12:51:06 2013 +0200 +++ b/stru10.cpp Sat Sep 07 13:03:18 2013 +0200 @@ -682,19 +682,23 @@ //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) //{ RenderVertexSoft v26; // [sp+40h] [bp-60h]@20 - if (!bDoNotDrawPortalFrustum) + extern bool draw_debug_line; + if ( draw_debug_line ) { - v26.vWorldPosition.x = pParty->vPosition.x; - v26.vWorldPosition.y = pParty->vPosition.y; - v26.vWorldPosition.z = pParty->vPosition.z + pParty->sEyelevel; // frustum + if (!bDoNotDrawPortalFrustum) + { + v26.vWorldPosition.x = pParty->vPosition.x; + v26.vWorldPosition.y = pParty->vPosition.y; + v26.vWorldPosition.z = pParty->vPosition.z + pParty->sEyelevel; // frustum - pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, &pOutBounding[0], 0xFF0000u, 0, 0); - pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, &pOutBounding[1], 0xFF00u, 0, 0); - pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFu, &pOutBounding[2], 0xFFu, 0, 0); - pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFFFFFu, &pOutBounding[3], 0xFFFFFFu, 0, 0); - bDoNotDrawPortalFrustum = true; + pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, &pOutBounding[0], 0xFF0000u, 0, 0); + pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, &pOutBounding[1], 0xFF00u, 0, 0); + pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFu, &pOutBounding[2], 0xFFu, 0, 0); + pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFFFFFu, &pOutBounding[3], 0xFFFFFFu, 0, 0); + bDoNotDrawPortalFrustum = true; + } + pGame->pIndoorCameraD3D->debug_outline_sw(pOutBounding, uNumVertices, 0x1EFF1Eu, 0.00019999999); // bounding } - pGame->pIndoorCameraD3D->debug_outline_sw(pOutBounding, uNumVertices, 0x1EFF1Eu, 0.00019999999); // bounding //} //pGame->pIndoorCameraD3D->debug_outline_sw(pFaceLimits, 4, 0xFFF14040, 0.000099999997); // limits @@ -725,7 +729,9 @@ v26.vWorldPosition.y = face_center_y + a1.y * 400.0f; v26.vWorldPosition.z = face_center_z + a1.z * 400.0f; - pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v25, 0xFFFFFFFFu, &v26, 0xFFFF00u, 0, 0); + extern bool draw_debug_line; + if ( draw_debug_line ) + pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v25, 0xFFFFFFFFu, &v26, 0xFFFF00u, 0, 0); } //} diff -r 86cb7398d2a8 -r 7d986a396092 stru367.h --- a/stru367.h Sat Sep 07 12:51:06 2013 +0200 +++ b/stru367.h Sat Sep 07 13:03:18 2013 +0200 @@ -1,6 +1,6 @@ #pragma once - +#include /* 152 */ #pragma pack(push, 1)