# HG changeset patch # User Ritor1 # Date 1411073862 -21600 # Node ID 68cdef6879a0c2aa93784fe0bc569a6aadbde714 # Parent 92eeeb5200f22983fa027d20911220b1f255507b engine folder diff -r 92eeeb5200f2 -r 68cdef6879a0 Actor.cpp --- a/Actor.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5717 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS - -#include "Engine/Graphics/PaletteManager.h" -#include "ErrorHandling.h" - -#include "Engine/Graphics/DecalBuilder.h" - -#include "Engine/Graphics/Sprites.h" -#include "stru6.h" - - -#include "Actor.h" -#include "OurMath.h" -#include "Engine/Graphics/Outdoor.h" -#include "AudioPlayer.h" -#include "Game.h" -#include "ObjectList.h" -#include "Engine/Graphics/Overlays.h" -#include "FactionTable.h" -#include "TurnEngine.h" -#include "CastSpellInfo.h" -#include "Timer.h" -#include "LOD.h" -#include "Party.h" -#include "GUIWindow.h" - -#include "MM7.h" -#include "SpriteObject.h" -#include "stru298.h" -#include "Log.h" -#include "Texts.h" -#include "Engine/Graphics/Level/Decoration.h" -#include "Engine/Graphics/Viewport.h" -#include "Engine/Graphics/Vis.h" - - - - - -std::array pActors; -size_t uNumActors; - -stru319 stru_50C198; // idb - - -std::array _4DF380_hostilityRanges = {0, 1024, 2560, 5120, 10240}; - - - - -//----- (0042FB5C) -------------------------------------------------------- -// True if monster should play attack animation when casting this spell. -bool ShouldMonsterPlayAttackAnim(signed int spell_id) -{ - switch (spell_id) - { - case SPELL_FIRE_HASTE: - case SPELL_AIR_SHIELD: - case SPELL_EARTH_STONESKIN: - case SPELL_SPIRIT_BLESS: - case SPELL_SPIRIT_FATE: - case SPELL_SPIRIT_HEROISM: - case SPELL_BODY_HAMMERHANDS: - case SPELL_BODY_POWER_CURE: - case SPELL_LIGHT_DISPEL_MAGIC: - case SPELL_LIGHT_DAY_OF_PROTECTION: - case SPELL_LIGHT_HOUR_OF_POWER: - case SPELL_DARK_PAIN_REFLECTION: - return false; - } - - return true; -} - - -//----- (0041AF52) -------------------------------------------------------- -void Actor::DrawHealthBar(Actor *actor, GUIWindow *window) -{ - unsigned int bar_length; // esi@1 - unsigned int uX; // ebx@10 - unsigned int v9; // [sp+14h] [bp-Ch]@4 - unsigned int v10; // [sp+1Ch] [bp-4h]@4 - - if (actor->pMonsterInfo.uHP <= 25) - bar_length = 25; - else if ( actor->pMonsterInfo.uHP < 200 ) - bar_length = actor->pMonsterInfo.uHP; - else - bar_length = 200; - - v10 = bar_length; - if ( actor->sCurrentHP <= (0.34 * actor->pMonsterInfo.uHP) ) - v9 = uTextureID_mhp_red; - else if ( actor->sCurrentHP <= ( 0.67 * actor->pMonsterInfo.uHP) ) - v9 = uTextureID_mhp_yel; - else - v9 = uTextureID_mhp_grn; - - if ( actor->sCurrentHP < (int)actor->pMonsterInfo.uHP ) - v10 = bar_length / actor->pMonsterInfo.uHP * actor->sCurrentHP; - - uX = window->uFrameX + (signed int)(window->uFrameWidth - bar_length) / 2; - - pRenderer->SetTextureClipRect(uX, window->uFrameY + 32, uX + bar_length, window->uFrameY + 52); - pRenderer->DrawTextureIndexed(uX, window->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_bd)); - pRenderer->SetTextureClipRect(uX, window->uFrameY + 32, uX + v10, window->uFrameY + 52); - pRenderer->DrawTextureIndexed(uX, window->uFrameY + 34, pIcons_LOD->GetTexture(v9)); - - pRenderer->ResetTextureClipRect(); - pRenderer->DrawTextureIndexed(uX - 5, window->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_capl)); - pRenderer->DrawTextureIndexed(uX + bar_length, window->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_capr)); -} - -//----- (00448A40) -------------------------------------------------------- -void Actor::ToggleFlag(signed int uActorID, unsigned int uFlag, int bToggle) -{ - if ( uActorID >= 0 && uActorID <= (signed int)(uNumActors - 1) ) - { - if ( bToggle ) - pActors[uActorID].uAttributes |= uFlag; - else - { - if ( uFlag == 0x10000 ) - { - if (pActors[uActorID].uAIState == Disabled ) - pActors[uActorID].uAIState = Standing; - } - pActors[uActorID].uAttributes &= ~uFlag; - } - } -} - -//----- (00448518) -------------------------------------------------------- -void __fastcall sub_448518_npc_set_item(int npc, unsigned int item, int a3) -{ - for (uint i = 0; i < uNumActors; i++) - { - if (pActors[uNumActors].sNPC_ID == npc) - Actor::GiveItem(i, item, a3); - } -} - -//----- (004485A7) -------------------------------------------------------- -void Actor::GiveItem(signed int uActorID, unsigned int uItemID, unsigned int bGive) -{ - if ( (uActorID >= 0) && (signed int)uActorID <= (signed int)(uNumActors - 1) ) - { - if ( bGive ) - { - if ( pActors[uActorID].uCarriedItemID == 0) - pActors[uActorID].uCarriedItemID = uItemID; - else if ( pActors[uActorID].ActorHasItems[0].uItemID == 0) - pActors[uActorID].ActorHasItems[0].uItemID = uItemID; - else if ( pActors[uActorID].ActorHasItems[1].uItemID == 0) - pActors[uActorID].ActorHasItems[1].uItemID = uItemID; - } - else - { - if ( pActors[uActorID].uCarriedItemID == uItemID ) - pActors[uActorID].uCarriedItemID = 0; - else if ( pActors[uActorID].ActorHasItems[0].uItemID == uItemID ) - pActors[uActorID].ActorHasItems[0].Reset(); - else if ( pActors[uActorID].ActorHasItems[1].uItemID == uItemID ) - pActors[uActorID].ActorHasItems[1].Reset(); - } - } -} - -//----- (0040894B) -------------------------------------------------------- -bool Actor::CanAct() -{ - bool isparalyzed; // esi@1 - bool isstoned; // edi@2 - - isstoned = (signed __int64)this->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0;// stoned - isparalyzed = (signed __int64)this->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0;// paralyzed - return !(isstoned || isparalyzed || this->uAIState == Dying || this->uAIState == Dead - || this->uAIState == Removed || this->uAIState == Summoned || this->uAIState == Disabled); -} - -//----- (004089C7) -------------------------------------------------------- -bool Actor::IsNotAlive() -{ - bool isstoned; // esi@1 - - isstoned = (signed __int64)this->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0;// stoned - return (isstoned || (uAIState == Dying) || (uAIState == Dead) || (uAIState == Removed) || (uAIState == Summoned) || (uAIState == Disabled)); -} - -//----- (004086E9) -------------------------------------------------------- -void Actor::SetRandomGoldIfTheresNoItem() -{ - int v2; // edi@1 - - v2 = 0; - if ( !this->ActorHasItems[3].uItemID ) - { - if ( this->pMonsterInfo.uTreasureDiceRolls ) - { - for (int i = 0; i < this->pMonsterInfo.uTreasureDiceRolls; i++) - v2 += rand() % this->pMonsterInfo.uTreasureDiceSides + 1; - if ( v2 ) - { - this->ActorHasItems[3].uItemID = 197; - this->ActorHasItems[3].uSpecEnchantmentType = v2; //actual gold amount - } - } - } - if ( rand() % 100 < this->pMonsterInfo.uTreasureDropChance ) - { - if ( this->pMonsterInfo.uTreasureLevel ) - pItemsTable->GenerateItem(this->pMonsterInfo.uTreasureLevel, this->pMonsterInfo.uTreasureType, &this->ActorHasItems[2]); - } - this->uAttributes |= ACTOR_HAS_ITEM; -} - -//----- (00404AC7) -------------------------------------------------------- -void Actor::AI_SpellAttack(unsigned int uActorID, AIDirection *pDir, int uSpellID, int a4, unsigned int uSkillLevel) -{ - Actor *actorPtr; // esi@1 - unsigned int realPoints; // edi@1 - unsigned int masteryLevel; // eax@1 - int v8; // edi@16 - signed int v10; // ecx@22 - int v19; // edi@34 - int v20; // eax@35 - signed int v23; // eax@41 - int v28; // st6@50 - int v30; // esi@50 - int v31; // ST3C_4@51 - unsigned int v32; // edi@51 - signed int v36; // eax@67 - int v39; // ecx@75 - int v42; // ecx@91 - int v44; // ecx@100 - int v48; // ecx@110 - int v51; // ecx@130 - int v54; // ecx@138 - int v59; // edi@146 - int v61; // edi@146 - signed int v63; // edi@146 - int v68; // edi@168 - signed int v70; // ecx@172 - int v79; // edx@185 - int v80; // eax@185 - signed int v91; // eax@200 - int v94; // ecx@208 - int v96; // ecx@217 - int pitch; // [sp+2Ch] [bp-A4h]@51 - int v114; // [sp+48h] [bp-88h]@41 - SpriteObject a1; // [sp+4Ch] [bp-84h]@1 - int v116; // [sp+BCh] [bp-14h]@49 - int v118; // [sp+C4h] [bp-Ch]@29 - int v119; // [sp+C8h] [bp-8h]@48 - int v120; // [sp+CCh] [bp-4h]@1 - int spellnuma; // [sp+D8h] [bp+8h]@29 - int spellnumb; // [sp+D8h] [bp+8h]@48 - int spellnumc; // [sp+D8h] [bp+8h]@50 - int spellnume; // [sp+D8h] [bp+8h]@179 - int a1a; // [sp+E0h] [bp+10h]@34 - int a1c; // [sp+E0h] [bp+10h]@184 - - - actorPtr = &pActors[uActorID]; - realPoints = uSkillLevel & 0x3F; - masteryLevel = SkillToMastery(uSkillLevel); - - switch (uSpellID) - { - case SPELL_FIRE_FIRE_BOLT: - case SPELL_FIRE_FIREBALL: - case SPELL_FIRE_INCINERATE: - case SPELL_AIR_LIGHNING_BOLT: - case SPELL_WATER_ICE_BOLT: - case SPELL_WATER_ACID_BURST: - case SPELL_EARTH_BLADES: - case SPELL_EARTH_ROCK_BLAST: - case SPELL_MIND_MIND_BLAST: - case SPELL_MIND_PSYCHIC_SHOCK: - case SPELL_BODY_HARM: - case SPELL_LIGHT_LIGHT_BOLT: - case SPELL_DARK_TOXIC_CLOUD: - case SPELL_DARK_DRAGON_BREATH: - a1.uType = stru_4E3ACC[uSpellID].uType; - a1.uObjectDescID = GetObjDescId(uSpellID); - a1.stru_24.Reset(); - a1.spell_id = uSpellID; - a1.spell_level = uSkillLevel; - a1.vPosition.x = actorPtr->vPosition.x; - a1.spell_skill = 0; - a1.vPosition.y = actorPtr->vPosition.y; - a1.vPosition.z = actorPtr->vPosition.z + ((signed int)actorPtr->uActorHeight >> 1); - a1.uFacing = LOWORD(pDir->uYawAngle); - a1.uSoundID = 0; - a1.uAttributes = 0; - a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = PID(OBJECT_Actor, uActorID); - a1.spell_target_pid = 0; - if ((double)pDir->uDistance < 307.2 ) - a1.field_60_distance_related_prolly_lod = 0; - else if ( pDir->uDistance < 1024 ) - a1.field_60_distance_related_prolly_lod = 1; - else if ( pDir->uDistance < 2560 ) - a1.field_60_distance_related_prolly_lod = 2; - else - a1.field_60_distance_related_prolly_lod = 3; - - a1.field_61 = 2; - v91 = a1.Create(pDir->uYawAngle, pDir->uPitchAngle, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); - if ( v91 != -1 ) - { - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], PID(OBJECT_Item, v91), 0, -1, 0, 0, 0, 0); - return; - } - return; - break; - - case SPELL_FIRE_HASTE: - if (masteryLevel == 1 || masteryLevel == 2) - v39 = 60 * (realPoints + 60); - else if (masteryLevel == 3 ) - v39 = 180 * (realPoints + 20); - else if (masteryLevel == 4 ) - v39 = 240 * (realPoints + 15); - else - v39 = 0; - actorPtr->pActorBuffs[ACTOR_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v39 << 7) * 0.033333335), - masteryLevel, 0, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xFF3C1Eu); - pAudioPlayer->PlaySound((SoundID)10040, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); - return; - - case SPELL_FIRE_METEOR_SHOWER: - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - return; - v114 = pParty->vPosition.z + 2500; - v23 = 8; - if (masteryLevel == 2) - v23 = 10; - else if (masteryLevel == 3) - v23 = 12; - else if (masteryLevel == 4) - v23 = 14; - spellnumb = 0; - v28 = 0; - for ( int i = 0; i < v23; i++) - { - v30 = rand() % 1000; - spellnumc = v30 - 2500; - v120 = v28 * v28; - v119 = spellnumb * spellnumb; - if ( sqrt((float)(spellnumc * spellnumc + v119 + v120)) <= 1.0 ) - { - v32 = 0; - pitch = 0; - } - else - { - v31 = (signed __int64)sqrt((float)(v119 + v120)); - v32 = stru_5C6E00->Atan2(spellnumb, (int)v28); - pitch = stru_5C6E00->Atan2(v31, (int)spellnumc); - } - a1.stru_24.Reset(); - a1.uType = stru_4E3ACC[uSpellID].uType; - a1.uObjectDescID = GetObjDescId(uSpellID); - a1.spell_level = uSkillLevel; - a1.vPosition.x = pParty->vPosition.x; - a1.vPosition.y = pParty->vPosition.y; - a1.vPosition.z = v30 + v114; - a1.spell_id = SPELL_FIRE_METEOR_SHOWER; - a1.spell_skill = 0; - a1.uAttributes = 0; - a1.uSectorID = 0; - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = PID(OBJECT_Actor, uActorID); - a1.spell_target_pid = 0; - a1.field_60_distance_related_prolly_lod = stru_50C198._427546(v30 + 2500); - a1.uFacing = v32; - a1.uSoundID = 0; - if (pDir->uDistance < 307.2 ) - a1.field_60_distance_related_prolly_lod = 0; - else if ( pDir->uDistance < 1024 ) - a1.field_60_distance_related_prolly_lod = 1; - else if ( pDir->uDistance < 2560 ) - a1.field_60_distance_related_prolly_lod = 2; - else - a1.field_60_distance_related_prolly_lod = 3; - a1.field_61 = 2; - v36 = a1.Create(v32, pitch, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); - if ( v36 != -1 ) - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[9], PID(OBJECT_Item, v36), 0, -1, 0, 0, 0, 0); - spellnumb = rand() % 1024 - 512; - v28 = rand() % 1024 - 512; - } - return; - break; - - case SPELL_AIR_SPARKS: - if (masteryLevel == 2 ) - v10 = 5; - else if (masteryLevel == 3 ) - v10 = 7; - else if (masteryLevel == 4 ) - v10 = 9; - else - v10 = 3; - spellnuma = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; - a1.uType = stru_4E3ACC[uSpellID].uType; - v118 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v10 - 1); - a1.uObjectDescID = GetObjDescId(uSpellID); - - a1.stru_24.Reset(); - a1.spell_id = SPELL_AIR_SPARKS; - a1.spell_level = uSkillLevel; - a1.vPosition.x = actorPtr->vPosition.x; - a1.spell_skill = 0; - a1.vPosition.y = actorPtr->vPosition.y; - a1.vPosition.z = actorPtr->vPosition.z + ((signed int)actorPtr->uActorHeight >> 1); - a1.uFacing = pDir->uYawAngle; - a1.uSoundID = 0; - a1.uAttributes = 0; - a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); - a1.spell_caster_pid = PID(OBJECT_Actor, uActorID); - a1.uSpriteFrameID = 0; - a1.spell_target_pid = 0; - a1.field_60_distance_related_prolly_lod = 3; - v19 = spellnuma / -2; - a1a = spellnuma / 2; - if ( spellnuma / -2 > spellnuma / 2 ) - v20 = spellnuma / 2; - else - { - do - { - a1.uFacing = v19 + LOWORD(pDir->uYawAngle); - v20 = a1.Create((signed __int16)a1.uFacing, pDir->uPitchAngle, - pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); - v19 += v118; - } - while ( v19 <= a1a ); - } - if ( v20 != -1 ) - { - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[15], PID(OBJECT_Item, v20), 0, -1, 0, 0, 0, 0); - return; - } - return; - break; - - case SPELL_AIR_SHIELD: - if (masteryLevel == 1 || masteryLevel == 2) - v8 = 300 * realPoints + 3840; - else if (masteryLevel == 3 ) - v8 = 900 * realPoints + 3840; - else if (masteryLevel == 4 ) - v8 = 3600 * (realPoints + 64); - else - v8 = 0; - actorPtr->pActorBuffs[ACTOR_BUFF_SHIELD].Apply( - pParty->uTimePlayed + (signed int)(signed __int64)((double)(v8 << 7) * 0.033333335), - masteryLevel, 0, 0, 0); - return; - - case SPELL_EARTH_STONESKIN: - if (masteryLevel == 1 || masteryLevel == 2) - v44 = 300 * realPoints + 3840; - else if (masteryLevel == 3 ) - v44 = 900 * realPoints + 3840; - else if (masteryLevel == 4 ) - v44 = 3600 * (realPoints + 64); - else - v44 = 0; - actorPtr->pActorBuffs[ACTOR_BUFF_STONESKIN].Apply( - pParty->uTimePlayed + (signed int)(signed __int64)((double)(v44 << 7) * 0.033333335), - masteryLevel, realPoints + 5, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0x5C310Eu); - pAudioPlayer->PlaySound((SoundID)13040, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0); - return; - - case SPELL_SPIRIT_BLESS: - if (masteryLevel == 1 || masteryLevel == 2) - v42 = 300 * realPoints + 3840; - else if (masteryLevel == 3 ) - v42 = 900 * realPoints + 3840; - else if (masteryLevel == 4 ) - v42 = 1200 * realPoints + 3840; - else - v42 = 0; - actorPtr->pActorBuffs[ACTOR_BUFF_BLESS].Apply( - pParty->uTimePlayed + (signed int)(signed __int64)((double)(v42 << 7) * 0.033333335), - masteryLevel, realPoints + 5, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0xC8C805u); - pAudioPlayer->PlaySound((SoundID)14010, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0); - return; - break; - - case SPELL_SPIRIT_FATE: - if (masteryLevel == 1 || masteryLevel == 2) - v48 = 2 * realPoints + 40; - else if (masteryLevel == 3 ) - v48 = 3 * realPoints + 60; - else if (masteryLevel == 4 ) - v48 = 2 * (3 * realPoints + 60); - else - v48 = 0; - actorPtr->pActorBuffs[ACTOR_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, masteryLevel, v48, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0xC8C805u); - pAudioPlayer->PlaySound((SoundID)14020, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); - return; - - case SPELL_SPIRIT_HEROISM: - if (masteryLevel == 1 || masteryLevel == 2) - v54 = 300 * realPoints + 3840; - else if (masteryLevel == 3 ) - v54 = 900 * realPoints + 3840; - else if (masteryLevel == 4 ) - v54 = 1200 * realPoints + 3840; - else - v54 = 0; - actorPtr->pActorBuffs[ACTOR_BUFF_HEROISM].Apply( - pParty->uTimePlayed + (signed int)(signed __int64)((double)(v54 << 7) * 0.033333335), - masteryLevel, realPoints + 5, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0xC8C805u); - pAudioPlayer->PlaySound((SoundID)14060, PID(OBJECT_Actor,uActorID), 0, -1, 0, 0, 0, 0); - return; - - case SPELL_BODY_HAMMERHANDS: - if ( (signed int)masteryLevel <= 0 || (signed int)masteryLevel > 4 ) - v51 = 0; - else - v51 = 3600 * realPoints; - actorPtr->pActorBuffs[ACTOR_BUFF_PAIN_HAMMERHANDS].Apply( - pParty->uTimePlayed + (signed int)(signed __int64)((double)(v51 << 7) * 0.033333335), - masteryLevel, - realPoints, - 0, - 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xA81376u); - pAudioPlayer->PlaySound((SoundID)16060, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); - return; - - case SPELL_BODY_POWER_CURE: - actorPtr->sCurrentHP += 5 * realPoints + 10; - if ( actorPtr->sCurrentHP >= (signed int)actorPtr->pMonsterInfo.uHP ) - actorPtr->sCurrentHP = LOWORD(actorPtr->pMonsterInfo.uHP); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xA81376u); - pAudioPlayer->PlaySound((SoundID)14020, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); - return; - - case SPELL_LIGHT_DISPEL_MAGIC: - for (int i = 0; i < 20; i++ ) - pParty->pPartyBuffs[i].Reset(); - for (int i = 1; i <= 4; i++) - { - v59 = pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualWillpower()); - v61 = (pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualIntelligence()) + v59) / 2; - v63 = v61 + pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualLuck()) + 30; - if ( rand() % v63 < 30 ) - { - for (uint k = 0; k < pPlayers[i]->pPlayerBuffs.size(); k++) - pPlayers[i]->pPlayerBuffs[k].Reset(); - pOtherOverlayList->_4418B1(11210, i + 99, 0, 65536); - } - } - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[80], PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); - return; - - case SPELL_LIGHT_DAY_OF_PROTECTION: - if (masteryLevel == 1 || masteryLevel == 2) - v96 = 300 * realPoints + 3840; - else if (masteryLevel == 3 ) - { - LOWORD(realPoints) = 3 * realPoints; - v96 = 900 * (uSkillLevel & 0x3F) + 3840; - } - else if (masteryLevel == 4 ) - { - v96 = 1200 * realPoints + 3840; - LOWORD(realPoints) = 4 * realPoints; - } - else - { - LOWORD(realPoints) = uSkillLevel; - v96 = 0; - } - actorPtr->pActorBuffs[ACTOR_BUFF_DAY_OF_PROTECTION].Apply( - pParty->uTimePlayed + (signed int)(signed __int64)((double)(v96 << 7) * 0.033333335), - masteryLevel, realPoints, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xFFFFFFu); - pAudioPlayer->PlaySound((SoundID)17070, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); - return; - - case SPELL_LIGHT_HOUR_OF_POWER: - if (masteryLevel == 1 || masteryLevel == 2) - v94 = 300 * realPoints + 3840; - else if (masteryLevel == 3) - v94 = 900 * realPoints + 3840; - else if (masteryLevel == 4) - v94 = 1200 * realPoints + 3840; - else - v94 = 0; - actorPtr->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].Apply( - pParty->uTimePlayed + (signed int)(signed __int64)((double)(v94 << 7) * 0.033333335), - masteryLevel, realPoints + 5, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr, 0xFFFFFFu); - pAudioPlayer->PlaySound((SoundID)17080, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); - return; - - case SPELL_DARK_SHARPMETAL: - if (masteryLevel == 2) - v70 = 5; - else if (masteryLevel == 3) - v70 = 7; - else if (masteryLevel == 4) - v70 = 9; - else - v70 = 3; - - spellnume = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; - a1.uType = stru_4E3ACC[uSpellID].uType; - v116 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v70 - 1); - a1.uObjectDescID = GetObjDescId(uSpellID); - a1.stru_24.Reset(); - a1.spell_id = uSpellID; - a1.spell_level = uSkillLevel; - a1.vPosition.x = actorPtr->vPosition.x; - a1.spell_skill = 0; - a1.vPosition.y = actorPtr->vPosition.y; - a1.vPosition.z = actorPtr->vPosition.z + ((signed int)actorPtr->uActorHeight >> 1); - a1.uFacing = pDir->uYawAngle; - a1.uSoundID = 0; - a1.uAttributes = 0; - a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); - a1.spell_caster_pid = PID(OBJECT_Actor, uActorID); - a1.uSpriteFrameID = 0; - a1.spell_target_pid = 0; - a1.field_60_distance_related_prolly_lod = 3; - a1c = spellnume / -2; - if ( spellnume / -2 > spellnume / 2 ) - v80 = spellnume / -2; - else - { - do - { - v79 = pDir->uYawAngle; - a1.uFacing = a1c + LOWORD(pDir->uYawAngle); - v80 = a1.Create(v79, pDir->uPitchAngle, - pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); - a1c += v116; - } - while ( a1c <= spellnume / 2 ); - } - if ( v80 != -1 ) - { - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[93], PID(OBJECT_Item, v80), 0, -1, 0, 0, 0, 0); - return; - } - return; - break; - - case SPELL_DARK_PAIN_REFLECTION: - if (masteryLevel == 0) - v68 = 0; - else if (masteryLevel == 1 || (masteryLevel == 2) || (masteryLevel == 3)) - v68 = 300 * realPoints + 3840; - else - v68 = 900 * realPoints + 3840; - actorPtr->pActorBuffs[ACTOR_BUFF_PAIN_REFLECTION].Apply( - pParty->uTimePlayed + (signed int)(signed __int64)((double)(v68 << 7) * 0.033333335), - masteryLevel, 0, 0, 0); - pGame->pStru6Instance->_4A7E89_sparkles_on_actor_after_it_casts_buff(actorPtr,0x7E7E7Eu); - pAudioPlayer->PlaySound((SoundID)18060, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); - return; - } -} - -//----- (new func) -------------------------------------------------------- -unsigned short Actor::GetObjDescId( int spellId ) -{ - for (unsigned int i = 0; i < pObjectList->uNumObjects; i++) - { - if (stru_4E3ACC[spellId].uType == pObjectList->pObjects[i].uObjectID) - { - return i; - break; - } - } - return 0; -} - - -//----- (0043ABB0) -------------------------------------------------------- -bool Actor::ArePeasantsOfSameFaction(Actor *a1, Actor *a2) -{ - unsigned int v2; // esi@1 - unsigned int v3; // edi@1 - - v2 = a1->uAlly; - if ( !a1->uAlly ) - v2 = (a1->pMonsterInfo.uID - 1) / 3 + 1; - - v3 = a2->uAlly; - if ( !a2->uAlly ) - v3 = (a2->pMonsterInfo.uID - 1) / 3 + 1; - - if ( v2 >= 39 && v2 <= 44 && v3 >= 39 && v3 <= 44 - || v2 >= 45 && v2 <= 50 && v3 >= 45 && v3 <= 50 - || v2 >= 51 && v2 <= 62 && v3 >= 51 && v3 <= 62 - || v2 >= 78 && v2 <= 83 && v3 >= 78 && v3 <= 83 - || v2 == v3 - ) - return true; - else - return false; -} - -//----- (0043AC45) -------------------------------------------------------- -void Actor::AggroSurroundingPeasants(unsigned int uActorID, int a2) -{ - int v4; // ebx@8 - int v5; // ST1C_4@8 - int v6; // eax@8 - - int x = 0; x |= 0x80000; - int y = 0; y |= 0x80000; - Actor* victim = &pActors[uActorID]; - if ( a2 == 1 ) - victim->uAttributes |= ACTOR_AGGRESSOR; - - for (uint i = 0; i < uNumActors; ++i) - { - Actor* actor = &pActors[i]; - if (!actor->CanAct() || i == uActorID) - continue; - - if (Actor::ArePeasantsOfSameFaction(victim, actor)) - { - v4 = abs(actor->vPosition.x - victim->vPosition.x); - v5 = abs(actor->vPosition.y - victim->vPosition.y); - v6 = abs(actor->vPosition.z - victim->vPosition.z); - if (int_get_vector_length(v4, v5, v6) < 4096) - { - actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - if ( a2 == 1 ) - actor->uAttributes |= ACTOR_AGGRESSOR; - - } - } - } -} - -//----- (00404874) -------------------------------------------------------- -void Actor::AI_RangedAttack( unsigned int uActorID, struct AIDirection *pDir, int type, char a4 ) -{ - char specAb; // al@1 - int v13; // edx@28 - - SpriteObject a1; // [sp+Ch] [bp-74h]@1 - - switch ( type ) - { - case 1: - a1.uType = 545; - break; - case 2: - a1.uType = 550; - break; - case 3: - a1.uType = 510; - break; - case 4: - a1.uType = 500; - break; - case 5: - a1.uType = 515; - break; - case 6: - a1.uType = 505; - break; - case 7: - a1.uType = 530; - break; - case 8: - a1.uType = 525; - break; - case 9: - a1.uType = 520; - break; - case 10: - a1.uType = 535; - break; - case 11: - a1.uType = 540; - break; - case 13: - a1.uType = 555; - break; - default: - return; - } - bool found = false; - for ( uint i = 0; i < pObjectList->uNumObjects; i++) - { - if (pObjectList->pObjects[i].uObjectID == a1.uType) - { - a1.uObjectDescID = i; - found = true; - break; - } - } - if (!found) - { - Error("Item not found"); - return; - } - a1.stru_24.Reset(); - a1.spell_id = 0; - a1.vPosition.x = pActors[uActorID].vPosition.x; - a1.vPosition.y = pActors[uActorID].vPosition.y; - a1.vPosition.z = pActors[uActorID].vPosition.z - (unsigned int)(pActors[uActorID].uActorHeight * -0.75); - a1.spell_level = 0; - a1.spell_skill = 0; - a1.uFacing = pDir->uYawAngle; - a1.uSoundID = 0; - a1.uAttributes = 0; - a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = PID(OBJECT_Actor, uActorID); - a1.spell_target_pid = 0; - if (pDir->uDistance < 307.2 ) - a1.field_60_distance_related_prolly_lod = 0; - else if ( pDir->uDistance < 1024 ) - a1.field_60_distance_related_prolly_lod = 1; - else if ( pDir->uDistance < 2560 ) - a1.field_60_distance_related_prolly_lod = 2; - else - a1.field_60_distance_related_prolly_lod = 3; - - a1.field_61 = a4; - a1.Create(pDir->uYawAngle, pDir->uPitchAngle, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); - if ( pActors[uActorID].pMonsterInfo.uSpecialAbilityType == 1 ) - { - specAb = pActors[uActorID].pMonsterInfo.uSpecialAbilityDamageDiceBonus; - if ( specAb == 2 ) - { - a1.vPosition.z += 40; - v13 = pDir->uYawAngle; - } - else - { - if ( specAb != 3 ) - return; - a1.Create(pDir->uYawAngle + 30, //TODO find out why the YawAngle change - pDir->uPitchAngle, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); - v13 = pDir->uYawAngle - 30; - } - a1.Create(v13, pDir->uPitchAngle, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); - } - return; -} - -//----- (00404736) -------------------------------------------------------- -void Actor::Explode( unsigned int uActorID ) -{ - SpriteObject a1; // [sp+Ch] [bp-78h]@1 - - a1.uType = 600; - a1.uObjectDescID = GetObjDescId(a1.uType); - a1.stru_24.Reset(); - a1.spell_id = 0; - a1.spell_level = 0; - a1.spell_skill = 0; - a1.vPosition.x = pActors[uActorID].vPosition.x; - a1.vPosition.y = pActors[uActorID].vPosition.y; - a1.vPosition.z = pActors[uActorID].vPosition.z - (unsigned int)(pActors[uActorID].uActorHeight * -0.75); - a1.uFacing = 0; - a1.uSoundID = 0; - a1.uAttributes = 0; - a1.uSectorID = pIndoor->GetSector(a1.vPosition.x, a1.vPosition.y, a1.vPosition.z); - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = PID(OBJECT_Actor, uActorID); - a1.spell_target_pid = 0; - a1.field_60_distance_related_prolly_lod = 3; - a1.field_61 = 4; - a1.Create(0, 0, 0, 0); - return; -} - -//----- (004040E9) -------------------------------------------------------- -// // Get direction vector from object1 to object2, -// // distance from object1 to object2 and Euler angles of the direction vector -// // -// // -// // object1 & object2 format : objectType | (objectID << 3) -// // objectType == 2 - SpriteObject -// // objectType == 3 - Actor -// // objectType == 4 - Party -// // objectType == 5 - Decoration -// // -// // originally this function had following prototype: -// // struct DirectionInfo GetDirectionInfo(signed int object1, signed int object2, signed int a4) -// // but compiler converts functions returning structures by value in the such way -void Actor::GetDirectionInfo( unsigned int uObj1ID, unsigned int uObj2ID, struct AIDirection *pOut, int a4 ) -{ - signed int v4; // eax@1 - signed int v5; // ecx@1 - int v18; // edx@15 - float v31; // st7@45 - float v32; // st6@45 - float v33; // st7@45 - Vec3_int_ v37; // [sp-10h] [bp-5Ch]@15 - AIDirection v41; // [sp+14h] [bp-38h]@46 - float outy2; // [sp+38h] [bp-14h]@33 - float outx2; // [sp+3Ch] [bp-10h]@33 - int outz; // [sp+40h] [bp-Ch]@6 - int outy; // [sp+44h] [bp-8h]@6 - int outx; // [sp+48h] [bp-4h]@6 - float a4a; // [sp+58h] [bp+Ch]@45 - - v4 = PID_ID(uObj1ID); - //v6 = uObj2ID; - v5 = PID_ID(uObj2ID); - switch( PID_TYPE(uObj1ID) ) - { - case OBJECT_Item: - { - outx = pSpriteObjects[v4].vPosition.x; - outy = pSpriteObjects[v4].vPosition.y; - outz = pSpriteObjects[v4].vPosition.z; - break; - } - case OBJECT_Actor: - { - outx = pActors[v4].vPosition.x; - outy = pActors[v4].vPosition.y; - outz = pActors[v4].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v4].uActorHeight * -0.75); - break; - } - case OBJECT_Player: - { - if ( !v4 ) - { - outx = pParty->vPosition.x; - outy = pParty->vPosition.y; - outz = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - break; - } - if ( v4 == 4 ) - { - v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; - v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - v37.x = pParty->vPosition.x; - v37.y = pParty->vPosition.y; - Vec3_int_::Rotate(24, v18, 0, v37, &outx, &outy, &outz); - break; - } - if ( v4 == 3 ) - { - v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; - v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - v37.x = pParty->vPosition.x; - v37.y = pParty->vPosition.y; - Vec3_int_::Rotate(8, v18, 0, v37, &outx, &outy, &outz); - break; - } - if ( v4 == 2 ) - { - v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; - v37.x = pParty->vPosition.x; - v37.y = pParty->vPosition.y; - Vec3_int_::Rotate(8, v18, 0, v37, &outx, &outy, &outz); - break; - } - if ( v4 == 1 ) - { - v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; - v37.x = pParty->vPosition.x; - v37.y = pParty->vPosition.y; - Vec3_int_::Rotate(24, v18, 0, v37, &outx, &outy, &outz); - break; - } - } - case OBJECT_Decoration: - { - outx = pLevelDecorations[v4].vPosition.x; - outy = pLevelDecorations[v4].vPosition.y; - outz = pLevelDecorations[v4].vPosition.z; - break; - } - default: - { - outz = 0; - outy = 0; - outx = 0; - break; - } - case OBJECT_BModel: - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - outx = (pIndoor->pFaces[v4].pBounding.x1 + pIndoor->pFaces[v4].pBounding.x2) >> 1; - outy = (pIndoor->pFaces[v4].pBounding.y1 + pIndoor->pFaces[v4].pBounding.y2) >> 1; - outz = (pIndoor->pFaces[v4].pBounding.z1 + pIndoor->pFaces[v4].pBounding.z2) >> 1; - } - break; - } - } - - switch( PID_TYPE(uObj2ID) ) - { - case OBJECT_Item: - { - outx2 = (float)pSpriteObjects[v5].vPosition.x; - outy2 =(float) pSpriteObjects[v5].vPosition.y; - a4 = pSpriteObjects[v5].vPosition.z; - break; - } - case OBJECT_Actor: - { - outx2 = (float)pActors[v5].vPosition.x; - outy2 = (float)pActors[v5].vPosition.y; - a4 = pActors[v5].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v5].uActorHeight * -0.75); - break; - } - case OBJECT_Player: - { - outx2 = (float)pParty->vPosition.x; - outy2 = (float)pParty->vPosition.y; - if ( !a4 ) - a4 = pParty->sEyelevel; - a4 = pParty->vPosition.z + a4; - break; - } - case OBJECT_Decoration: - { - outx2 = (float)pLevelDecorations[v5].vPosition.x; - outy2 = (float)pLevelDecorations[v5].vPosition.y; - a4 = pLevelDecorations[v5].vPosition.z; - break; - } - default: - { - outx2 = 0.0; - outy2 = 0.0; - a4 = 0; - break; - } - case OBJECT_BModel: - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - outx2 = (float)((pIndoor->pFaces[v5].pBounding.x1 + pIndoor->pFaces[v5].pBounding.x2) >> 1); - outy2 = (float)((pIndoor->pFaces[v5].pBounding.y1 + pIndoor->pFaces[v5].pBounding.y2) >> 1); - a4 = (pIndoor->pFaces[v5].pBounding.z1 + pIndoor->pFaces[v5].pBounding.z2) >> 1; - } - break; - } - } - - v31 = (float)outx2 - (float)outx; - v32 = (float)outy2 - (float)outy; - a4a = (float)a4 - (float)outz; - outx2 = v32 * v32; - outy2 = v31 * v31; - v33 = sqrt(a4a * a4a + outy2 + outx2); - if ( v33 <= 1.0 ) - { - pOut->vDirection.x = 65536; - pOut->vDirection.y = 0; - pOut->vDirection.z = 0; - pOut->uDistance = 1; - pOut->uDistanceXZ = 1; - pOut->uYawAngle = 0; - pOut->uPitchAngle = 0; - } - else - { - pOut->vDirection.x = (int32_t)(1.0 / v33 * v31 * 65536.0); - pOut->vDirection.y = (int32_t)(1.0 / v33 * v32 * 65536.0); - pOut->vDirection.z = (int32_t)(1.0 / v33 * a4a * 65536.0); - pOut->uDistance = (uint)v33; - pOut->uDistanceXZ = (uint)sqrt(outy2 + outx2); - pOut->uYawAngle = stru_5C6E00->Atan2((signed __int64)v31, (signed __int64)v32); - pOut->uPitchAngle = stru_5C6E00->Atan2(pOut->uDistanceXZ, (signed __int64)a4a); - } -} - -//----- (00404030) -------------------------------------------------------- -void Actor::AI_FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, AIDirection *a4) -{ - AIDirection *v7; // eax@3 - AIDirection v1; // eax@3 - AIDirection a3; // [sp+8h] [bp-38h]@4 - - if ( rand() % 100 >= 5 ) - { - //v9 = &pActors[uActorID]; - if ( !a4 ) - { - Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), uObjID, &v1, 0); - v7 = &v1; - } - else - v7 = a4; - pActors[uActorID].uYawAngle = v7->uYawAngle; - pActors[uActorID].uCurrentActionTime = 0; - pActors[uActorID].vVelocity.z = 0; - pActors[uActorID].vVelocity.y = 0; - pActors[uActorID].vVelocity.x = 0; - pActors[uActorID].uPitchAngle = v7->uPitchAngle; - pActors[uActorID].uCurrentActionLength = 256; - pActors[uActorID].uAIState = Interacting; - pActors[uActorID].UpdateAnimation(); - } - else - Actor::AI_Bored(uActorID, uObjID, a4); -} - -//----- (00403F58) -------------------------------------------------------- -void Actor::AI_StandOrBored(unsigned int uActorID, signed int uObjID, int uActionLength, AIDirection *a4) -{ - if (rand() % 2)//0 or 1 - AI_Bored(uActorID, uObjID, a4); - else - AI_Stand(uActorID, uObjID, uActionLength, a4); -} - -//----- (00403EB6) -------------------------------------------------------- -void Actor::AI_Stand(unsigned int uActorID, unsigned int object_to_face_pid, unsigned int uActionLength, AIDirection *a4) -{ - assert(uActorID < uNumActors); - // Actor* actor = &pActors[uActorID]; - - AIDirection a3; - if (!a4) - { - Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), object_to_face_pid, &a3, 0); - a4 = &a3; - } - - pActors[uActorID].uAIState = Standing; - if (!uActionLength) - pActors[uActorID].uCurrentActionLength = rand() % 256 + 256;// îò 256 äî 256 + 256 - else - pActors[uActorID].uCurrentActionLength = uActionLength; - pActors[uActorID].uCurrentActionTime = 0; - pActors[uActorID].uYawAngle = a4->uYawAngle; - pActors[uActorID].uPitchAngle = a4->uPitchAngle; - pActors[uActorID].vVelocity.z = 0; - pActors[uActorID].vVelocity.y = 0; - pActors[uActorID].vVelocity.x = 0; - pActors[uActorID].UpdateAnimation(); -} - -//----- (00403E61) -------------------------------------------------------- -void __fastcall Actor::StandAwhile(unsigned int uActorID) -{ - pActors[uActorID].uCurrentActionLength = rand() % 128 + 128; - pActors[uActorID].uCurrentActionTime = 0; - pActors[uActorID].uAIState = Standing; - pActors[uActorID].vVelocity.z = 0; - pActors[uActorID].vVelocity.y = 0; - pActors[uActorID].vVelocity.x = 0; - pActors[uActorID].UpdateAnimation(); -} - -//----- (00403C6C) -------------------------------------------------------- -void Actor::AI_MeleeAttack(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0) -{ - int16_t v6; // esi@6 - int16_t v7; // edi@6 - signed int v8; // eax@7 - Vec3_int_ v10; // ST04_12@9 - AIDirection *v12; // eax@11 - AIDirection a3; // [sp+Ch] [bp-48h]@12 - AIDirection v20; // [sp+28h] [bp-2Ch]@12 - int v23; // [sp+4Ch] [bp-8h]@6 - unsigned int v25; // [sp+5Ch] [bp+8h]@13 - - assert(uActorID < uNumActors); - - if ( pActors[uActorID].pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY && pActors[uActorID].pMonsterInfo.uAIType == 1 ) - { - Actor::AI_Stand(uActorID, sTargetPid, 0, arg0); - return; - } - - if ( PID_TYPE(sTargetPid) == OBJECT_Actor) - { - v8 = PID_ID(sTargetPid); - v6 = pActors[v8].vPosition.x; - v7 = pActors[v8].vPosition.y; - v23 = (int)(pActors[v8].uActorHeight * 0.75 + pActors[v8].vPosition.z); - } - else if ( PID_TYPE(sTargetPid) == OBJECT_Player) - { - v6 = pParty->vPosition.x; - v7 = pParty->vPosition.y; - v23 = pParty->vPosition.z + pParty->sEyelevel; - } - else - { - Error("Should not get here"); - return; - } - - v10.x = pActors[uActorID].vPosition.x; - v10.y = pActors[uActorID].vPosition.y; - v10.z = (int32_t)(pActors[uActorID].uActorHeight * 0.75 + pActors[uActorID].vPosition.z); - - if ( sub_407A1C((int)v6, (int)v7, v23, v10) ) - { - if (arg0 != nullptr) - v12 = arg0; - else - { - Actor::GetDirectionInfo(PID(OBJECT_Actor, uActorID), sTargetPid, &a3, 0); - v12 = &a3; - } - pActors[uActorID].uYawAngle = LOWORD(v12->uYawAngle); - pActors[uActorID].uCurrentActionLength = pSpriteFrameTable->pSpriteSFrames[pActors[uActorID].pSpriteIDs[ANIM_AtkMelee]].uAnimLength * 8; - pActors[uActorID].uCurrentActionTime = 0; - pActors[uActorID].uAIState = AttackingMelee; - Actor::PlaySound(uActorID, 0); - v25 = pMonsterStats->pInfos[pActors[uActorID].pMonsterInfo.uID].uRecoveryTime; - if ( pActors[uActorID].pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 ) - v25 *= 2; - if ( pParty->bTurnBasedModeOn != 1 ) - pActors[uActorID].pMonsterInfo.uRecoveryTime = (int)(flt_6BE3A8_debug_recmod2 * v25 * 2.133333333333333); - else - pActors[uActorID].pMonsterInfo.uRecoveryTime = v25; - pActors[uActorID].vVelocity.z = 0; - pActors[uActorID].vVelocity.y = 0; - pActors[uActorID].vVelocity.x = 0; - pActors[uActorID].UpdateAnimation(); - } - else - Actor::AI_Pursue1(uActorID, sTargetPid, rand() % 2, 64, arg0); -} - -//----- (00438CF3) -------------------------------------------------------- -void Actor::ApplyFineForKillingPeasant(unsigned int uActorID) -{ - if ( uLevelMapStatsID == 0 || !pActors[uActorID].IsPeasant()) - return; - - if ( (uLevelMapStatsID == 6 || uLevelMapStatsID == 7) && pParty->IsPartyEvil()) //celeste and bracada - return; - - if ( (uLevelMapStatsID == 5 || uLevelMapStatsID == 8) && pParty->IsPartyGood()) // the pit and deyja - return; - - pParty->uFine += 100 * (pMapStats->pInfos[uLevelMapStatsID]._steal_perm + pActors[uActorID].pMonsterInfo.uLevel + pParty->GetPartyReputation()); - if ( pParty->uFine < 0 ) - pParty->uFine = 0; - if ( pParty->uFine > 4000000 ) - pParty->uFine = 4000000; - - if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - { - if (pOutdoor->ddm.uReputation < 10000) - pOutdoor->ddm.uReputation++; - } - else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - if (pIndoor->dlv.uReputation < 10000) - pIndoor->dlv.uReputation++; - } - else assert(false); - - if ( pParty->uFine ) - { - for ( int i = 1; i <= 4; i++) - { - if ( !_449B57_test_bit(pPlayers[i]->_achieved_awards_bits, 1) ) - _449B7E_toggle_bit(pPlayers[i]->_achieved_awards_bits, 1, 1u); - } - } -} - -//----- (0043AE80) -------------------------------------------------------- -void Actor::AddBloodsplatOnDamageOverlay(unsigned int uActorID, int a2, signed int a3) -{ - unsigned int v4; // esi@1 - - v4 = PID(OBJECT_Actor,uActorID); - switch ( a2 ) - { - case 1: - if ( a3 ) - pOtherOverlayList->_4418B6(904, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0); - return; - case 2: - if ( a3 ) - pOtherOverlayList->_4418B6(905, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0); - return; - case 3: - if ( a3 ) - pOtherOverlayList->_4418B6(906, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0); - return; - case 4: - if ( a3 ) - pOtherOverlayList->_4418B6(907, v4, 0, (int)(sub_43AE12(a3) * 65536.0), 0); - return; - case 5: - pOtherOverlayList->_4418B6(901, v4, 0, PID(OBJECT_Actor,uActorID), 0); - return; - case 6: - pOtherOverlayList->_4418B6(902, v4, 0, PID(OBJECT_Actor,uActorID), 0); - return; - case 7: - pOtherOverlayList->_4418B6(903, v4, 0, PID(OBJECT_Actor,uActorID), 0); - return; - case 8: - pOtherOverlayList->_4418B6(900, v4, 0, PID(OBJECT_Actor,uActorID), 0); - return; - case 9: - pOtherOverlayList->_4418B6(909, v4, 0, PID(OBJECT_Actor,uActorID), 0); - return; - case 10: - pOtherOverlayList->_4418B6(908, v4, 0, PID(OBJECT_Actor,uActorID), 0); - return; - default: - return; - } - return; -} - -//----- (0043B3E0) -------------------------------------------------------- -int Actor::_43B3E0_CalcDamage( signed int dmgSource ) -{ - signed int v2; // ebp@1 - int v3; // eax@9 - signed int v4; // edi@9 - int v5; // esi@9 - unsigned __int16 v8; // si@21 - int v9; // edi@21 - signed int v10; // eax@23 - int v11; // [sp+10h] [bp-4h]@1 - - v2 = 0; - v11 = 0; - - switch( dmgSource ) - { - case 0: - if ( this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) - v2 = this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; - if ( this->pActorBuffs[ACTOR_BUFF_HEROISM].uExpireTime > 0 && this->pActorBuffs[ACTOR_BUFF_HEROISM].uPower > v2 ) - v2 = this->pActorBuffs[ACTOR_BUFF_HEROISM].uPower; - if ( this->pActorBuffs[ACTOR_BUFF_PAIN_HAMMERHANDS].uExpireTime > 0 ) - v2 += this->pActorBuffs[ACTOR_BUFF_PAIN_HAMMERHANDS].uPower; - v3 = this->pMonsterInfo.uAttack1DamageDiceRolls; - v4 = this->pMonsterInfo.uAttack1DamageDiceSides; - v5 = this->pMonsterInfo.uAttack1DamageBonus; - break; - case 1: - v3 = this->pMonsterInfo.uAttack2DamageDiceRolls; - v4 = this->pMonsterInfo.uAttack2DamageDiceSides; - v5 = this->pMonsterInfo.uAttack2DamageBonus; - break; - case 2: - v8 = this->pMonsterInfo.uSpellSkillAndMastery1; - v9 = this->pMonsterInfo.uSpell1ID; - v10 = SkillToMastery(v8); - return _43AFE3_calc_spell_damage(v9, v8 & 0x3F, v10, 0); - break; - case 3: - v8 = this->pMonsterInfo.uSpellSkillAndMastery2; - v9 = this->pMonsterInfo.uSpell2ID; - v10 = SkillToMastery(v8); - return _43AFE3_calc_spell_damage(v9, v8 & 0x3F, v10, 0); - break; - case 4: - v3 = this->pMonsterInfo.uSpecialAbilityDamageDiceRolls; - v4 = this->pMonsterInfo.uSpecialAbilityDamageDiceSides; - v5 = this->pMonsterInfo.uSpecialAbilityDamageDiceBonus; - default: - return 0; - } - for ( int i = 0; i < v3; i++) - v11 += rand() % v4 + 1; - return v11 + v5 + v2; -} - -//----- (00438B9B) -------------------------------------------------------- -bool Actor::IsPeasant() -{ - unsigned int InHostile_Id; // eax@1 - - InHostile_Id = this->uAlly; - if ( !this->uAlly ) - InHostile_Id = (this->pMonsterInfo.uID - 1) / 3 + 1; - return (signed int)InHostile_Id >= 39 && (signed int)InHostile_Id <= 44//Dwarfs peasants - || (signed int)InHostile_Id >= 45 && (signed int)InHostile_Id <= 50//Elves peasants - || (signed int)InHostile_Id >= 51 && (signed int)InHostile_Id <= 62//Humans peasants - || (signed int)InHostile_Id >= 78 && (signed int)InHostile_Id <= 83;//Goblins peasants -} - -//----- (0042EBEE) -------------------------------------------------------- -void Actor::StealFrom( unsigned int uActorID ) -{ - Player *pPlayer; // edi@1 - int v4; // ebx@2 - unsigned int v5; // eax@2 - DDM_DLV_Header *v6; // esi@4 - int v8; // [sp+8h] [bp-4h]@6 - - pPlayer = &pParty->pPlayers[uActiveCharacter-1]; - if ( pPlayer->CanAct() ) - { - CastSpellInfoHelpers::_427D48(); - v4 = 0; - v5 = pMapStats->GetMapInfo(pCurrentMapName); - if ( v5 ) - v4 = pMapStats->pInfos[v5]._steal_perm; - v6 = &pOutdoor->ddm; - if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor) - v6 = &pIndoor->dlv; - pPlayer->StealFromActor(uActorID, v4, v6->uReputation++); - v8 = pPlayer->GetAttackRecoveryTime(0); - if ( v8 < 30 ) - v8 = 30; - if ( !pParty->bTurnBasedModeOn ) - pPlayer->SetRecoveryTime((int)(flt_6BE3A4_debug_recmod1 * v8 * 2.133333333333333)); - pTurnEngine->ApplyPlayerAction(); - } - return; -} - -//----- (00403A60) -------------------------------------------------------- -void Actor::AI_SpellAttack2(unsigned int uActorID, signed int edx0, AIDirection *pDir) -{ - Actor *v3; // ebx@1 - int16_t v4; // esi@3 - int16_t v5; // edi@3 - signed int v6; // eax@4 - Vec3_int_ v7; // ST04_12@6 - AIDirection *v9; // eax@8 - __int16 v13; // ax@10 - AIDirection a3; // [sp+Ch] [bp-48h]@9 - AIDirection v18; // [sp+28h] [bp-2Ch]@9 - int v19; // [sp+44h] [bp-10h]@6 - signed int a2; // [sp+48h] [bp-Ch]@1 - int v21; // [sp+4Ch] [bp-8h]@3 - unsigned int pDira; // [sp+5Ch] [bp+8h]@10 - - v3 = &pActors[uActorID]; - a2 = edx0; - if ( PID_TYPE(edx0) == OBJECT_Actor) - { - v6 = PID_ID(edx0); - v4 = pActors[v6].vPosition.x; - v5 = pActors[v6].vPosition.y; - v21 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z); - } - else if ( PID_TYPE(edx0) == OBJECT_Player) - { - v4 = pParty->vPosition.x; - v5 = pParty->vPosition.y; - v21 = pParty->vPosition.z + pParty->sEyelevel; - } - else - { - Error("Should not get here"); - return; - } - v19 = v3->uActorHeight; - v7.z = v3->vPosition.z - (int)(v19 * -0.75); - v7.y = v3->vPosition.y; - v7.x = v3->vPosition.x; - if ( sub_407A1C(v4, v5, v21, v7) ) - { - if ( pDir == nullptr) - { - Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), a2, &a3, 0); - v9 = &a3; - } - else - v9 = pDir; - v3->uYawAngle = LOWORD(v9->uYawAngle); - v13 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; - v3->uCurrentActionLength = 8 * v13; - v3->uCurrentActionTime = 0; - v3->uAIState = AttackingRanged4; - Actor::PlaySound(uActorID, 0); - pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; - if (v3->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0) - pDira *= 2; - if ( pParty->bTurnBasedModeOn == 1 ) - v3->pMonsterInfo.uRecoveryTime = pDira; - else - v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength + (int)(flt_6BE3A8_debug_recmod2 * pDira * 2.133333333333333); - v3->vVelocity.z = 0; - v3->vVelocity.y = 0; - v3->vVelocity.x = 0; - if ( ShouldMonsterPlayAttackAnim(v3->pMonsterInfo.uSpell2ID) ) - { - v3->uCurrentActionLength = 64; - v3->uCurrentActionTime = 0; - v3->uAIState = Fidgeting; - v3->UpdateAnimation(); - v3->uAIState = AttackingRanged4; - } - else - v3->UpdateAnimation(); - } - else - Actor::AI_Pursue1(uActorID, a2, uActorID, 64, pDir); -} - -//----- (00403854) -------------------------------------------------------- -void Actor::AI_SpellAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) -{ - Actor *v3; // ebx@1 - int16_t v4; // esi@3 - int16_t v5; // edi@3 - signed int v6; // eax@4 - Vec3_int_ v7; // ST04_12@6 - AIDirection *v9; // eax@8 - __int16 v13; // ax@10 - signed int v16; // ecx@17 - AIDirection a3; // [sp+Ch] [bp-48h]@9 - AIDirection v18; // [sp+28h] [bp-2Ch]@9 - int v19; // [sp+44h] [bp-10h]@6 - int v21; // [sp+4Ch] [bp-8h]@3 - unsigned int pDira; // [sp+5Ch] [bp+8h]@10 - - v3 = &pActors[uActorID]; - if ( PID_TYPE(sTargetPid) == OBJECT_Actor) - { - v6 = PID_ID(sTargetPid); - v4 = pActors[v6].vPosition.x; - v5 = pActors[v6].vPosition.y; - v21 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z); - } - else if ( PID_TYPE(sTargetPid) == OBJECT_Player) - { - v4 = pParty->vPosition.x; - v5 = pParty->vPosition.y; - v21 = pParty->vPosition.z + pParty->sEyelevel; - } - else - { - Error("Should not get here"); - return; - } - v19 = v3->uActorHeight; - v7.z = v3->vPosition.z - (int)(v19 * -0.75); - v7.y = v3->vPosition.y; - v7.x = v3->vPosition.x; - if ( sub_407A1C(v4, v5, v21, v7) ) - { - if ( pDir == nullptr ) - { - Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); - v9 = &a3; - } - else - v9 = pDir; - v3->uYawAngle = LOWORD(v9->uYawAngle); - v13 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; - v3->uCurrentActionLength = 8 * v13; - v3->uCurrentActionTime = 0; - v3->uAIState = AttackingRanged3; - Actor::PlaySound(uActorID, 0); - pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; - if (v3->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0) - pDira *= 2; - if ( pParty->bTurnBasedModeOn == 1 ) - v3->pMonsterInfo.uRecoveryTime = pDira; - else - v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength + (int)(flt_6BE3A8_debug_recmod2 * pDira * 2.133333333333333); - v16 = v3->pMonsterInfo.uSpell1ID; - v3->vVelocity.z = 0; - v3->vVelocity.y = 0; - v3->vVelocity.x = 0; - if ( ShouldMonsterPlayAttackAnim(v3->pMonsterInfo.uSpell1ID) ) - { - v3->uCurrentActionLength = 64; - v3->uCurrentActionTime = 0; - v3->uAIState = Fidgeting; - v3->UpdateAnimation(); - v3->uAIState = AttackingRanged3; - } - else - v3->UpdateAnimation(); - } - else - Actor::AI_Pursue1(uActorID, sTargetPid, uActorID, 64, pDir); -} - -//----- (0040368B) -------------------------------------------------------- -void Actor::AI_MissileAttack2(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) -{ - Actor *v3; // ebx@1 - int16_t v4; // esi@3 - int16_t v5; // edi@3 - signed int v6; // eax@4 - Vec3_int_ v7; // ST04_12@6 - AIDirection *v9; // eax@8 - __int16 v13; // ax@10 - AIDirection a3; // [sp+Ch] [bp-48h]@9 - AIDirection v17; // [sp+28h] [bp-2Ch]@9 - int v18; // [sp+44h] [bp-10h]@6 - int v20; // [sp+4Ch] [bp-8h]@3 - unsigned int pDira; // [sp+5Ch] [bp+8h]@10 - - v3 = &pActors[uActorID]; - if ( PID_TYPE(sTargetPid) == OBJECT_Actor) - { - v6 = PID_ID(sTargetPid); - v4 = pActors[v6].vPosition.x; - v5 = pActors[v6].vPosition.y; - v20 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z); - } - else if ( PID_TYPE(sTargetPid) == OBJECT_Player) - { - v4 = pParty->vPosition.x; - v5 = pParty->vPosition.y; - v20 = pParty->vPosition.z + pParty->sEyelevel; - } - else - { - Error("Should not get here"); - return; - } - v18 = v3->uActorHeight; - v7.z = v3->vPosition.z - (int)(v18 * -0.75); - v7.y = v3->vPosition.y; - v7.x = v3->vPosition.x; - if ( sub_407A1C(v4, v5, v20, v7) ) - { - if ( pDir == nullptr ) - { - Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); - v9 = &a3; - } - else - v9 = pDir; - v3->uYawAngle = LOWORD(v9->uYawAngle); - v13 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; - v3->uCurrentActionLength = 8 * v13; - v3->uCurrentActionTime = 0; - v3->uAIState = AttackingRanged2; - Actor::PlaySound(uActorID, 0); - pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; - if ( v3->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 ) - pDira *= 2; - if ( pParty->bTurnBasedModeOn != 1 ) - v3->pMonsterInfo.uRecoveryTime = (int)(flt_6BE3A8_debug_recmod2 * pDira * 2.133333333333333); - else - v3->pMonsterInfo.uRecoveryTime = pDira; - v3->vVelocity.z = 0; - v3->vVelocity.y = 0; - v3->vVelocity.x = 0; - v3->UpdateAnimation(); - } - else - Actor::AI_Pursue1(uActorID, sTargetPid, uActorID, 64, pDir); -} - -//----- (00403476) -------------------------------------------------------- -void Actor::AI_MissileAttack1(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) -{ - Actor *v3; // ebx@1 - int v4; // esi@3 - int v5; // edi@3 - signed int v6; // eax@4 - Vec3_int_ v7; // ST04_12@6 - AIDirection *v10; // eax@9 - __int16 v14; // ax@11 - AIDirection a3; // [sp+Ch] [bp-48h]@10 - AIDirection v18; // [sp+28h] [bp-2Ch]@10 - int v19; // [sp+44h] [bp-10h]@6 - //signed int a2; // [sp+48h] [bp-Ch]@1 - int v22; // [sp+50h] [bp-4h]@3 - unsigned int pDira; // [sp+5Ch] [bp+8h]@11 - - v3 = &pActors[uActorID]; - //a2 = edx0; - if ( PID_TYPE(sTargetPid) == OBJECT_Actor) - { - v6 = PID_ID(sTargetPid); - v4 = pActors[v6].vPosition.x; - v5 = pActors[v6].vPosition.y; - v22 = (int)(pActors[v6].uActorHeight * 0.75 + pActors[v6].vPosition.z); - } - else - { - if ( PID_TYPE(sTargetPid) == OBJECT_Player) - { - v4 = pParty->vPosition.x; - v5 = pParty->vPosition.y; - v22 = pParty->vPosition.z + pParty->sEyelevel; - } - else - { - v4 = (int)pDir; - v5 = (int)pDir; - } - } - v19 = v3->uActorHeight; - v7.z = v3->vPosition.z - (unsigned int)(signed __int64)((double)v19 * -0.75); - v7.y = v3->vPosition.y; - v7.x = v3->vPosition.x; - if ( sub_407A1C(v4, v5, v22, v7) || sub_407A1C(v7.x, v7.y, v7.z, Vec3_int_(v4, v5, v22))) - { - if ( pDir == nullptr ) - { - Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), sTargetPid, &a3, 0); - v10 = &a3; - } - else - v10 = pDir; - v3->uYawAngle = LOWORD(v10->uYawAngle); - v14 = pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[ANIM_AtkRanged]].uAnimLength; - v3->uCurrentActionLength = 8 * v14; - v3->uCurrentActionTime = 0; - v3->uAIState = AttackingRanged1; - Actor::PlaySound(uActorID, 0); - pDira = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uRecoveryTime; - if ( v3->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0 ) - pDira *= 2; - if ( pParty->bTurnBasedModeOn == 1 ) - v3->pMonsterInfo.uRecoveryTime = pDira; - else - v3->pMonsterInfo.uRecoveryTime = v3->uCurrentActionLength - (int)(flt_6BE3A8_debug_recmod2 * pDira * -2.133333333333333); - v3->vVelocity.z = 0; - v3->vVelocity.y = 0; - v3->vVelocity.x = 0; - v3->UpdateAnimation(); - } - else - Actor::AI_Pursue1(uActorID, sTargetPid, uActorID, 64, pDir); -} - -//----- (004032B2) -------------------------------------------------------- -void Actor::AI_RandomMove( unsigned int uActor_id, unsigned int uTarget_id, int radius, int uActionLength ) -{ - int x; // ebx@1 - int absy; // eax@1 - unsigned int v9; // ebx@11 - int v10; // ebx@13 - AIDirection doNotInitializeBecauseShouldBeRandom; // [sp+Ch] [bp-30h]@7 - int y; // [sp+30h] [bp-Ch]@1 - int absx; // [sp+38h] [bp-4h]@1 - - x = pActors[uActor_id].vInitialPosition.x - pActors[uActor_id].vPosition.x; - y = pActors[uActor_id].vInitialPosition.y - pActors[uActor_id].vPosition.y; - absx = abs(x); - absy = abs(y); - if ( absx <= absy ) - absx = absy + (absx / 2 ); - else - absx = absx + absy / 2; - if ( MonsterStats::BelongsToSupertype(pActors[uActor_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) - { - if ( !uActionLength ) - uActionLength = 256; - Actor::AI_StandOrBored(uActor_id, OBJECT_Player, uActionLength, &doNotInitializeBecauseShouldBeRandom); - return; - } - if ( pActors[uActor_id].pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_GLOBAL && absx < 128 ) - { - Actor::AI_Stand(uActor_id, uTarget_id, 256, &doNotInitializeBecauseShouldBeRandom); - return; - } - absx += ((rand() & 0xF) * radius) / 16; - v9 = (stru_5C6E00->uIntegerDoublePi - 1) & stru_5C6E00->Atan2(x, y); - if ( rand() % 100 < 25 ) - { - Actor::StandAwhile(uActor_id); - return; - } - v10 = v9 + rand() % 256 - 128; - if ( abs(v10 - pActors[uActor_id].uYawAngle) > 256 && !(pActors[uActor_id].uAttributes & ACTOR_ANIMATION) ) - { - Actor::AI_Stand(uActor_id, uTarget_id, 256, &doNotInitializeBecauseShouldBeRandom); - return; - } - pActors[uActor_id].uYawAngle = v10; - if ( pActors[uActor_id].uMovementSpeed) - pActors[uActor_id].uCurrentActionLength = 32 * absx / pActors[uActor_id].uMovementSpeed; - else - pActors[uActor_id].uCurrentActionLength = 0; - pActors[uActor_id].uCurrentActionTime = 0; - pActors[uActor_id].uAIState = Tethered; - if ( rand() % 100 < 2 ) - Actor::PlaySound(uActor_id, 3); - pActors[uActor_id].UpdateAnimation(); -} - -//----- (004031C1) -------------------------------------------------------- -char __fastcall Actor::_4031C1_update_job_never_gets_called(unsigned int uActorID, signed int a2, int a3) //attempted to implement something like jobs for actors, but apparently was never finished -{ - return 0; - /*unsigned int v3; // edi@1 - Actor *v4; // esi@1 - ActorJob *v5; // eax@1 - signed int v6; // edx@2 - ActorJob *v7; // eax@2 - signed int v8; // edi@2 - ActorJob *v9; // ecx@2 - __int16 v10; // cx@15 - signed int v12; // [sp+8h] [bp-4h]@1 - - v3 = uActorID; - v12 = a2; - v4 = &pActors[uActorID]; - v5 = (ActorJob *)pActors[uActorID].CanAct(); - if ( v5 ) - { - v6 = 65535; - v7 = &v4->pScheduledJobs[v3]; - v8 = 7; - v9 = &v7[7];//(char *)&v7[7].uHour; - while ( !(v9->uAttributes & 1) || v9->uHour > v12 ) - { - --v8; - --v9; - if ( v8 < 0 ) - break; - } - if( v8 >= 0 ) - v6 = v8; - if ( !v8 && v6 == 65535 ) - v6 = 7; - v5 = &v7[v6]; - if ( v4->vInitialPosition.x != v5->vPos.x - || v4->vInitialPosition.y != v5->vPos.y - || v4->vInitialPosition.z != v5->vPos.z - || v4->pMonsterInfo.uMovementType != v5->uAction ) - { - v4->vInitialPosition.x = v5->vPos.x; - v4->vInitialPosition.y = v5->vPos.y; - v10 = v5->vPos.z; - v4->vInitialPosition.z = v10; - LOBYTE(v5) = v5->uAction; - v4->pMonsterInfo.uMovementType = MONSTER_MOVEMENT_TYPE_STAIONARY; - if ( a3 == 1 ) - { - v4->vPosition.x = v4->vInitialPosition.x; - v4->vPosition.y = v4->vInitialPosition.y; - LOBYTE(v5) = v10; - v4->vPosition.z = v10; - } - } - } - return (char)v5;*/ -} - -//----- (004030AD) -------------------------------------------------------- -void Actor::AI_Stun(unsigned int uActorID, signed int edx0, int stunRegardlessOfState) -{ - __int16 v7; // ax@16 - AIDirection a3; // [sp+Ch] [bp-40h]@16 - - if ( pActors[uActorID].uAIState == Fleeing ) - pActors[uActorID].uAttributes |= ACTOR_FLEEING; - if ( pActors[uActorID].pMonsterInfo.uHostilityType != 4 ) - { - pActors[uActorID].uAttributes &= 0xFFFFFFFB;//~0x4 - pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - } - if ( pActors[uActorID].pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) - pActors[uActorID].pActorBuffs[ACTOR_BUFF_CHARM].Reset(); - if ( pActors[uActorID].pActorBuffs[ACTOR_BUFF_AFRAID].uExpireTime > 0 ) - pActors[uActorID].pActorBuffs[ACTOR_BUFF_AFRAID].Reset(); - if ( stunRegardlessOfState || (pActors[uActorID].uAIState != Stunned - && pActors[uActorID].uAIState != AttackingRanged1 - && pActors[uActorID].uAIState != AttackingRanged2 - && pActors[uActorID].uAIState != AttackingRanged3 - && pActors[uActorID].uAIState != AttackingRanged4 - && pActors[uActorID].uAIState != AttackingMelee)) - { - Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), edx0, &a3, 0); - //v10 = &a3; - pActors[uActorID].uYawAngle = LOWORD(a3.uYawAngle); - v7 = pSpriteFrameTable->pSpriteSFrames[pActors[uActorID].pSpriteIDs[ANIM_GotHit]].uAnimLength; - pActors[uActorID].uCurrentActionTime = 0; - pActors[uActorID].uAIState = Stunned; - pActors[uActorID].uCurrentActionLength = 8 * v7; - Actor::PlaySound(uActorID, 2); - pActors[uActorID].UpdateAnimation(); - } -} - -//----- (00402F87) -------------------------------------------------------- -void Actor::AI_Bored(unsigned int uActorID, unsigned int uObjID, AIDirection *a4) -{ - unsigned int v7; // eax@3 - unsigned int v9; // eax@3 - - Actor* actor = &pActors[uActorID]; - - AIDirection a3; // [sp+Ch] [bp-5Ch]@2 - if (!a4) - { - Actor::GetDirectionInfo(PID(OBJECT_Actor,uActorID), uObjID, &a3, 0); - a4 = &a3; - } - - actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Bored]].uAnimLength; - - v7 = stru_5C6E00->Atan2(actor->vPosition.x - pGame->pIndoorCameraD3D->vPartyPos.x, actor->vPosition.y - pGame->pIndoorCameraD3D->vPartyPos.y); - v9 = stru_5C6E00->uIntegerPi + actor->uYawAngle + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v7; - - if ( v9 & 0x700 ) // turned away - just stand - Actor::AI_Stand(uActorID, uObjID, actor->uCurrentActionLength, a4); - else // facing player - play bored anim - { - actor->uAIState = Fidgeting; - actor->uCurrentActionTime = 0; - actor->uYawAngle = a4->uYawAngle; - actor->vVelocity.z = 0; - actor->vVelocity.y = 0; - actor->vVelocity.x = 0; - if ( rand() % 100 < 5 ) - Actor::PlaySound(uActorID, 3); - actor->UpdateAnimation(); - } -} - -//----- (00402F27) -------------------------------------------------------- -void Actor::Resurrect(unsigned int uActorID) -{ - Actor *pActor; // esi@1 - - pActor = &pActors[uActorID]; - pActor->uCurrentActionTime = 0; - pActor->uAIState = Resurrected; - pActor->uCurrentActionAnimation = ANIM_Dying; - pActor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[pActor->pSpriteIDs[ANIM_Dying]].uAnimLength; - pActor->sCurrentHP = LOWORD(pActor->pMonsterInfo.uHP); - Actor::PlaySound(uActorID, 1); - pActor->UpdateAnimation(); -} - -//----- (00402D6E) -------------------------------------------------------- -void Actor::Die(unsigned int uActorID) -{ - Actor* actor = &pActors[uActorID]; - - actor->uCurrentActionTime = 0; - actor->uAIState = Dying; - actor->uCurrentActionAnimation = ANIM_Dying; - actor->sCurrentHP = 0; - actor->uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[actor->pSpriteIDs[ANIM_Dying]].uAnimLength; - actor->pActorBuffs[ACTOR_BUFF_PARALYZED].Reset(); - actor->pActorBuffs[ACTOR_BUFF_STONED].Reset(); - Actor::PlaySound(uActorID, 1); - actor->UpdateAnimation(); - - for (uint i = 0; i < 5; ++i) - 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(); - - ItemGen drop; - drop.Reset(); - switch (actor->pMonsterInfo.uID) - { - case MONSTER_HARPY_1: case MONSTER_HARPY_2: case MONSTER_HARPY_3: - drop.uItemID = ITEM_HARPY_FEATHER; - break; - - case MONSTER_OOZE_1: case MONSTER_OOZE_2: case MONSTER_OOZE_3: - drop.uItemID = ITEM_OOZE_ECTOPLASM_BOTTLE; - break; - - case MONSTER_TROLL_1: case MONSTER_TROLL_2: case MONSTER_TROLL_3: - drop.uItemID = ITEM_TROLL_BLOOD; - break; - - case MONSTER_DEVIL_1: case MONSTER_DEVIL_2: case MONSTER_DEVIL_3: - drop.uItemID = ITEM_DEVIL_ICHOR; - break; - - case MONSTER_DRAGON_1: case MONSTER_DRAGON_2: case MONSTER_DRAGON_3: - drop.uItemID = ITEM_DRAGON_EYE; - break; - } - - if (rand() % 100 < 20 && drop.uItemID != 0) - { - SpriteObject::sub_42F7EB_DropItemAt(pItemsTable->pItems[drop.uItemID].uSpriteID, - actor->vPosition.x, - actor->vPosition.y, - actor->vPosition.z + 16, - rand() % 200 + 200, - 1, - 1, - 0, - &drop); - } - - if (actor->pMonsterInfo.uSpecialAbilityType == MONSTER_SPECIAL_ABILITY_EXPLODE) - Actor::Explode(uActorID); -} - -//----- (00402CED) -------------------------------------------------------- -void Actor::PlaySound(unsigned int uActorID, unsigned int uSoundID) -{ - unsigned __int16 v3; // dx@1 - - v3 = pActors[uActorID].pSoundSampleIDs[uSoundID]; - if ( v3 ) - { - if ( pActors[uActorID].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime <= 0 ) - pAudioPlayer->PlaySound((SoundID)v3, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); - else - { - switch(pActors[uActorID].pActorBuffs[ACTOR_BUFF_SHRINK].uPower) - { - case 1: - pAudioPlayer->PlaySound((SoundID)v3, PID(OBJECT_Actor, uActorID), 0, 0, 0, 0, 0, 33075); - break; - case 2: - pAudioPlayer->PlaySound((SoundID)v3, PID(OBJECT_Actor, uActorID), 0, 0, 0, 0, 0, 33075); - break; - case 3: - case 4: - pAudioPlayer->PlaySound((SoundID)v3, PID(OBJECT_Actor, uActorID), 0, 0, 0, 0, 0, 33075); - break; - default: - pAudioPlayer->PlaySound((SoundID)v3, PID(OBJECT_Actor, uActorID), 0, -1, 0, 0, 0, 0); - break; - } - } - } -} - -//----- (00402AD7) -------------------------------------------------------- -void Actor::AI_Pursue1(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, AIDirection *pDir) -{ - int v6; // eax@1 - Actor *v7; // ebx@1 - unsigned int v8; // ecx@1 - AIDirection *v10; // esi@6 - AIDirection a3; // [sp+Ch] [bp-5Ch]@7 - unsigned int v18; // [sp+64h] [bp-4h]@1 - - v6 = 0; - v7 = &pActors[uActorID]; - v8 = PID(OBJECT_Actor,uActorID); - if ( v7->pMonsterInfo.uFlying != 0 && !pParty->bFlying ) //TODO: Does v6 have a point? - { - if ( v7->pMonsterInfo.uMissleAttack1Type ) - v6 = v7->uActorRadius + 512; - else - v6 = pParty->uPartyHeight; - } - - if ( pDir == nullptr ) - { - Actor::GetDirectionInfo(v8, a2, &a3, v6); - v10 = &a3; - } - else - v10 = pDir; - if ( MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) - { - if ( !uActionLength ) - uActionLength = 256; - Actor::AI_StandOrBored(uActorID, 4, uActionLength, v10); - return; - } - if ( v10->uDistance < 307.2 ) - { - if ( !uActionLength ) - uActionLength = 256; - Actor::AI_Stand(uActorID, a2, uActionLength, v10); - return; - } - if ( v7->uMovementSpeed == 0 ) - { - Actor::AI_Stand(uActorID, a2, uActionLength, v10); - return; - } - if ( arg0 % 2 ) - v18 = -16; - else - v18 = 16; - - v7->uYawAngle = stru_5C6E00->Atan2( - pParty->vPosition.x + (int)fixpoint_mul(stru_5C6E00->Cos(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle), v10->uDistanceXZ) - v7->vPosition.x, - pParty->vPosition.y + (int)fixpoint_mul(stru_5C6E00->Sin(v18 + stru_5C6E00->uIntegerPi + v10->uYawAngle), v10->uDistanceXZ) - v7->vPosition.y); - if ( uActionLength ) - v7->uCurrentActionLength = uActionLength; - else - v7->uCurrentActionLength = 128; - v7->uPitchAngle = LOWORD(v10->uPitchAngle); - v7->uAIState = Pursuing; - v7->UpdateAnimation(); -} - -//----- (00402968) -------------------------------------------------------- -void Actor::AI_Flee(unsigned int uActorID, signed int sTargetPid, int uActionLength, AIDirection *a4) -{ - Actor *v5; // ebx@1 - int v7; // ecx@2 - unsigned __int16 v9; // ax@15 - AIDirection v10; // [sp+8h] [bp-7Ch]@4 - AIDirection a3; // [sp+24h] [bp-60h]@3 - AIDirection* v13; // [sp+5Ch] [bp-28h]@4 - - v5 = &pActors[uActorID]; - if ( v5->CanAct() ) - { - v7 = PID(OBJECT_Actor,uActorID); - if ( !a4 ) - { - Actor::GetDirectionInfo(v7, sTargetPid, &a3, v5->pMonsterInfo.uFlying); - a4 = &a3; - } - Actor::GetDirectionInfo(v7, 4u, &v10, 0); - v13 = &v10; - if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) - || PID_TYPE(sTargetPid) == OBJECT_Actor && v13->uDistance < 307.2 ) - { - if ( !uActionLength ) - uActionLength = 256; - Actor::AI_StandOrBored(uActorID, 4, uActionLength, v13); - } - else - { - if ( v5->uMovementSpeed ) - v5->uCurrentActionLength = (signed int)(a4->uDistanceXZ << 7) / v5->uMovementSpeed; - else - v5->uCurrentActionLength = 0; - if ( v5->uCurrentActionLength > 256 ) - v5->uCurrentActionLength = 256; - v5->uYawAngle = LOWORD(stru_5C6E00->uIntegerHalfPi) + LOWORD(a4->uYawAngle); - v5->uYawAngle = LOWORD(stru_5C6E00->uDoublePiMask) & (v5->uYawAngle + rand() % (signed int)stru_5C6E00->uIntegerPi); - v9 = LOWORD(a4->uPitchAngle); - v5->uCurrentActionTime = 0; - v5->uPitchAngle = v9; - v5->uAIState = Fleeing; - v5->UpdateAnimation(); - } - } -} - -//----- (0040281C) -------------------------------------------------------- -void Actor::AI_Pursue2(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *pDir, int a5) -{ - int v6; // eax@1 - Actor *v7; // ebx@1 - unsigned int v8; // ecx@1 - AIDirection *v10; // esi@7 - signed __int16 v13; // cx@19 - unsigned __int16 v14; // ax@25 - AIDirection a3; // [sp+Ch] [bp-40h]@8 - AIDirection v18; // [sp+28h] [bp-24h]@8 - - v6 = 0; - v7 = &pActors[uActorID]; - v8 = PID(OBJECT_Actor,uActorID); - if ( v7->pMonsterInfo.uFlying != 0 && !pParty->bFlying ) - { - if ( v7->pMonsterInfo.uMissleAttack1Type && uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - v6 = v7->uActorRadius + 512; - else - v6 = pParty->uPartyHeight; - } - v10 = pDir; - if ( !pDir ) - { - Actor::GetDirectionInfo(v8, a2, &a3, v6); - v10 = &a3; - } - if ( MonsterStats::BelongsToSupertype(v7->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) - { - if ( !uActionLength ) - uActionLength = 256; - Actor::AI_StandOrBored(uActorID, 4, uActionLength, v10); - return; - } - if ( (signed int)v10->uDistance < a5 ) - { - if ( !uActionLength ) - uActionLength = 256; - Actor::AI_StandOrBored(uActorID, a2, uActionLength, v10); - return; - } - if ( uActionLength ) - { - v7->uCurrentActionLength = uActionLength; - } - else - { - v13 = v7->uMovementSpeed; - if ( v13 ) - v7->uCurrentActionLength = (signed int)(v10->uDistanceXZ << 7) / v13; - else - v7->uCurrentActionLength = 0; - if ( v7->uCurrentActionLength > 32 ) - v7->uCurrentActionLength = 32; - } - v7->uYawAngle = LOWORD(v10->uYawAngle); - v14 = LOWORD(v10->uPitchAngle); - v7->uCurrentActionTime = 0; - v7->uPitchAngle = v14; - v7->uAIState = Pursuing; - v7->UpdateAnimation(); -} - -//----- (00402686) -------------------------------------------------------- -void Actor::AI_Pursue3(unsigned int uActorID, unsigned int a2, signed int uActionLength, AIDirection *a4) -{ - int v5; // eax@1 - Actor *v6; // ebx@1 - int v7; // ecx@1 - signed __int16 v12; // cx@19 - __int16 v14; // ax@25 - unsigned __int16 v16; // ax@28 - AIDirection a3; // [sp+Ch] [bp-40h]@8 - AIDirection* v20; // [sp+28h] [bp-24h]@8 - - v5 = 0; - v6 = &pActors[uActorID]; - v7 = PID(OBJECT_Actor,uActorID); - if ( v6->pMonsterInfo.uFlying != 0 && !pParty->bFlying ) - { - if ( v6->pMonsterInfo.uMissleAttack1Type && uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - v5 = v6->uActorRadius + 512; - else - v5 = pParty->uPartyHeight; - } - if ( !a4 ) - { - Actor::GetDirectionInfo(v7, a2, &a3, v5); - v20 = &a3; - } - if ( MonsterStats::BelongsToSupertype(v6->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) - { - if ( !uActionLength ) - uActionLength = 256; - return Actor::AI_StandOrBored(uActorID, 4, uActionLength, a4); - } - if ( a4->uDistance < 307.2 ) - { - if ( !uActionLength ) - uActionLength = 256; - return Actor::AI_StandOrBored(uActorID, a2, uActionLength, a4); - } - if ( uActionLength ) - v6->uCurrentActionLength = uActionLength + rand() % uActionLength; - else - { - v12 = v6->uMovementSpeed; - if ( v12 ) - v6->uCurrentActionLength = (signed int)(a4->uDistanceXZ << 7) / v12; - else - v6->uCurrentActionLength = 0; - if ( v6->uCurrentActionLength > 128 ) - v6->uCurrentActionLength = 128; - } - v14 = LOWORD(a4->uYawAngle); - if ( rand() % 2 ) - v14 += 256; - else - v14 -= 256; - v6->uYawAngle = v14; - v16 = LOWORD(a4->uPitchAngle); - v6->uCurrentActionTime = 0; - v6->uPitchAngle = v16; - v6->uAIState = Pursuing; - if ( rand() % 100 < 2 ) - Actor::PlaySound(uActorID, 2u); - v6->UpdateAnimation(); -} - -//----- (00401221) -------------------------------------------------------- -void Actor::_SelectTarget(unsigned int uActorID, int *a2, bool can_target_party) -{ - int v5; // ecx@1 - signed int v10; // eax@13 - uint v11; // ebx@16 - uint v12; // eax@16 - signed int v14; // eax@31 - uint v15; // edi@43 - uint v16; // ebx@45 - uint v17; // eax@45 - signed int closestId; // [sp+14h] [bp-1Ch]@1 - uint v23; // [sp+1Ch] [bp-14h]@16 - unsigned int lowestRadius; // [sp+24h] [bp-Ch]@1 - uint v27; // [sp+2Ch] [bp-4h]@16 - uint v28; // [sp+2Ch] [bp-4h]@45 - - lowestRadius = UINT_MAX; - v5 = 0; - *a2 = 0; - closestId = 0; - assert(uActorID < uNumActors); - Actor* thisActor = &pActors[uActorID]; - - for (uint i = 0; i < uNumActors; ++i) - { - Actor* actor = &pActors[i]; - if (actor->uAIState == Dead || actor->uAIState == Dying || - actor->uAIState == Removed || actor->uAIState == Summoned || actor->uAIState == Disabled || uActorID == i ) - continue; - - if (thisActor->uLastCharacterIDToHit == 0 || PID(OBJECT_Actor,v5) != thisActor->uLastCharacterIDToHit ) - { - v10 = thisActor->GetActorsRelation(actor); - if ( v10 == 0 ) - continue; - } - else if (thisActor->IsNotAlive()) - { - thisActor->uLastCharacterIDToHit = 0; - v10 = thisActor->GetActorsRelation(actor); - if ( v10 == 0 ) - continue; - } - else - { - if ( (actor->uGroup != 0 || thisActor->uGroup != 0) && actor->uGroup == thisActor->uGroup ) - continue; - v10 = 4; - } - if ( thisActor->pMonsterInfo.uHostilityType ) - v10 = pMonsterStats->pInfos[thisActor->pMonsterInfo.uID].uHostilityType; - v11 = _4DF380_hostilityRanges[v10]; - v23 = abs(thisActor->vPosition.x - actor->vPosition.x); - v27 = abs(thisActor->vPosition.y - actor->vPosition.y); - v12 = abs(thisActor->vPosition.z - actor->vPosition.z); - if ( v23 <= v11 - && v27 <= v11 - && v12 <= v11 - && sub_4070EF_prolly_detect_player(PID(OBJECT_Actor, i), PID(OBJECT_Actor, uActorID)) - && v23 * v23 + v27 * v27 + v12 * v12 < lowestRadius ) - { - lowestRadius = v23 * v23 + v27 * v27 + v12 * v12; - closestId = i; - } - } - - if ( lowestRadius != UINT_MAX ) - { - *a2 = PID(OBJECT_Actor, closestId); - } - - if (can_target_party && !pParty->Invisible()) - { - if ( thisActor->ActorEnemy() - && thisActor->pActorBuffs[ACTOR_BUFF_ENSLAVED].uExpireTime <= 0 - && thisActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime <= 0 - && thisActor->pActorBuffs[ACTOR_BUFF_SUMMONED].uExpireTime <= 0 ) - v14 = 4; - else - v14 = thisActor->GetActorsRelation(0); - if ( v14 != 0 ) - { - if ( !thisActor->pMonsterInfo.uHostilityType ) - v15 = _4DF380_hostilityRanges[v14]; - else - v15 = _4DF380_hostilityRanges[4]; - v16 = abs(thisActor->vPosition.x - pParty->vPosition.x); - v28 = abs(thisActor->vPosition.y - pParty->vPosition.y); - v17 = abs(thisActor->vPosition.z - pParty->vPosition.z); - if ( v16 <= v15 && v28 <= v15 && v17 <= v15 && (v16 * v16 + v28 * v28 + v17 * v17 < lowestRadius)) - { - *a2 = OBJECT_Player; - } - } - } -} -// 4DF380: using guessed type int dword_4DF380[]; -// 4DF390: using guessed type int dword_4DF390; - -//----- (0040104C) -------------------------------------------------------- -signed int Actor::GetActorsRelation(Actor *otherActPtr) -{ - unsigned int thisGroup; // ebp@19 - int otherGroup; // eax@22 - unsigned int thisAlly; // edx@25 - unsigned int otherAlly; // edx@33 - - if ( otherActPtr) - { - if ( otherActPtr->uGroup != 0 && this->uGroup != 0 && otherActPtr->uGroup == this->uGroup ) - return 0; - } - - if (this->pActorBuffs[ACTOR_BUFF_BERSERK].uExpireTime > 0) - return 4; - thisAlly = this->uAlly; - if ( this->pActorBuffs[ACTOR_BUFF_ENSLAVED].uExpireTime > 0 || thisAlly == 9999) - thisGroup = 0; - else if ( thisAlly > 0 ) - thisGroup = thisAlly; - else - thisGroup = (this->pMonsterInfo.uID - 1) / 3 + 1; - - if ( otherActPtr ) - { - if (otherActPtr->pActorBuffs[ACTOR_BUFF_BERSERK].uExpireTime > 0) - return 4; - otherAlly = otherActPtr->uAlly; - if ( otherActPtr->pActorBuffs[ACTOR_BUFF_ENSLAVED].uExpireTime > 0 || otherAlly == 9999) - otherGroup = 0; - else if ( otherAlly > 0 ) - otherGroup = otherAlly; - else - otherGroup = (otherActPtr->pMonsterInfo.uID - 1) / 3 + 1; - } - else - otherGroup = 0; - - if ( this->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 && !otherGroup - || otherActPtr && otherActPtr->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 && !thisGroup ) - return 0; - if ( this->pActorBuffs[ACTOR_BUFF_ENSLAVED].uExpireTime <= 0 && this->ActorEnemy() && !otherGroup ) - return 4; - if (thisGroup >= 89 || otherGroup >= 89) - return 0; - - if ( thisGroup == 0 ) - { - if ( (!otherActPtr || this->pActorBuffs[ACTOR_BUFF_ENSLAVED].uExpireTime > 0 && otherActPtr->ActorFriend()) && !pFactionTable->relations[otherGroup][0]) - return pFactionTable->relations[0][otherGroup]; - else - return 4; - } - else - return pFactionTable->relations[thisGroup][otherGroup]; -} - -//----- (0045976D) -------------------------------------------------------- -void Actor::UpdateAnimation() -{ - ResetAnimation(); - switch (uAIState) - { - case Tethered: - uCurrentActionAnimation = ANIM_Walking; - break; - - case AttackingMelee: - uCurrentActionAnimation = ANIM_AtkMelee; - uAttributes |= ACTOR_ANIMATION; - break; - - case AttackingRanged1: - case AttackingRanged2: - case AttackingRanged3: - case AttackingRanged4: - uCurrentActionAnimation = ANIM_AtkRanged; - uAttributes |= ACTOR_ANIMATION; - break; - - case Dying: - case Resurrected: - uCurrentActionAnimation = ANIM_Dying; - uAttributes |= ACTOR_ANIMATION; - break; - - case Pursuing: - case Fleeing: - uCurrentActionAnimation = ANIM_Walking; - uAttributes |= ACTOR_ANIMATION; - break; - - case Stunned: - uCurrentActionAnimation = ANIM_GotHit; - uAttributes |= ACTOR_ANIMATION; - break; - - case Fidgeting: - uCurrentActionAnimation = ANIM_Bored; - uAttributes |= ACTOR_ANIMATION; - break; - - case Standing: - case Interacting: - case Summoned: - uCurrentActionAnimation = ANIM_Standing; - uAttributes |= ACTOR_ANIMATION; - break; - - case Dead: - if (pSpriteFrameTable->pSpriteSFrames[pSpriteIDs[ANIM_Dead]].pHwSpriteIDs[0] <= 0) - uAIState = Removed; - else - uCurrentActionAnimation = ANIM_Dead; - break; - - case Removed: - case Disabled: - return; - - default: - assert(false); - } -} - -//----- (00459671) -------------------------------------------------------- -void Actor::Reset() -{ - this->pActorName[0] = 0; - this->word_000086_some_monster_id = 0; - this->sNPC_ID = 0; - this->vPosition.z = 0; - this->vPosition.y = 0; - this->vPosition.x = 0; - this->vVelocity.z = 0; - this->vVelocity.y = 0; - this->vVelocity.x = 0; - this->uYawAngle = 0; - this->uPitchAngle = 0; - this->uAttributes = 0; - this->uSectorID = 0; - this->uCurrentActionTime = 0; - this->vInitialPosition.z = 0; - this->vInitialPosition.y = 0; - this->vInitialPosition.x = 0; - this->vGuardingPosition.z = 0; - this->vGuardingPosition.y = 0; - this->vGuardingPosition.x = 0; - this->uTetherDistance = 256; - this->uActorRadius = 32; - this->uActorHeight = 128; - this->uAIState = Standing; - this->uCurrentActionAnimation = ANIM_Standing; - this->uMovementSpeed = 200; - this->uCarriedItemID = 0; - this->uGroup = 0; - this->uAlly = 0; - this->uSummonerID = 0; - this->uLastCharacterIDToHit = 0; - this->dword_000334_unique_name = 0; - memset(this->pSpriteIDs, 0, sizeof(pSpriteIDs)); - memset(this->pActorBuffs, 0, 0x160u); -} - -//----- (0045959A) -------------------------------------------------------- -void Actor::PrepareSprites(char load_sounds_if_bit1_set) -{ - - MonsterDesc *v3; // esi@1 - MonsterInfo *v9; // [sp+84h] [bp-10h]@1 - - v3 = &pMonsterList->pMonsters[pMonsterInfo.uID - 1]; - v9 = &pMonsterStats->pInfos[pMonsterInfo.uID - 1 + 1]; - //v12 = pSpriteIDs; - //Source = (char *)v3->pSpriteNames; - //do - for (uint i = 0; i < 8; ++i) - { - //strcpy(pSpriteName, v3->pSpriteNames[i]); - pSpriteIDs[i] = pSpriteFrameTable->FastFindSprite(v3->pSpriteNames[i]); - pSpriteFrameTable->InitializeSprite(pSpriteIDs[i]); - } - uActorHeight = v3->uMonsterHeight; - uActorRadius = v3->uMonsterRadius; - uMovementSpeed = v9->uBaseSpeed; - if ( !(load_sounds_if_bit1_set & 1) ) - { - for ( int i = 0; i < 4; ++i ) - pSoundSampleIDs[i] = v3->pSoundSampleIDs[i]; - } -} - -//----- (00459667) -------------------------------------------------------- -void Actor::Remove() -{ - this->uAIState = Removed; -} - - -//----- (0043B1B0) -------------------------------------------------------- -void Actor::ActorDamageFromMonster(signed int attacker_id, unsigned int actor_id, Vec3_int_ *pVelocity, signed int a4) -{ - int v4; // ebx@1 - int dmgToRecv; // qax@8 - signed int v12; // ecx@20 - int finalDmg; // edi@30 - int pushDistance; // [sp+20h] [bp+Ch]@34 - - v4 = 0; - if ( PID_TYPE(attacker_id) == OBJECT_Item) - { - v4 = pSpriteObjects[PID_ID(attacker_id)].field_60_distance_related_prolly_lod; - attacker_id = pSpriteObjects[PID_ID(attacker_id)].spell_caster_pid; - } - if ( PID_TYPE(attacker_id) == OBJECT_Actor) - { - if ( !pActors[actor_id].IsNotAlive() ) - { - pActors[actor_id].uLastCharacterIDToHit = attacker_id; - if ( pActors[actor_id].uAIState == Fleeing ) - pActors[actor_id].uAttributes |= ACTOR_FLEEING; - if ( pActors[PID_ID(attacker_id)]._4273BB_DoesHitOtherActor(&pActors[actor_id], v4, 0) ) - { - dmgToRecv = pActors[PID_ID(attacker_id)]._43B3E0_CalcDamage(a4); - if ( pActors[PID_ID(attacker_id)].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime > 0 ) - { - if ( pActors[PID_ID(attacker_id)].pActorBuffs[ACTOR_BUFF_SHRINK].uPower ) - dmgToRecv = dmgToRecv / pActors[PID_ID(attacker_id)].pActorBuffs[ACTOR_BUFF_SHRINK].uPower; - } - if ( pActors[actor_id].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0 ) - dmgToRecv = 0; - if ( a4 == 0 ) - v12 = pActors[PID_ID(attacker_id)].pMonsterInfo.uAttack1Type; - else if ( a4 == 1 ) - { - v12 = pActors[PID_ID(attacker_id)].pMonsterInfo.uAttack2Type; - if ( SHIDWORD(pActors[actor_id].pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime) > 0 ) - dmgToRecv = dmgToRecv / 2; - } - else if ( a4 == 2 ) - v12 = pSpellStats->pInfos[pActors[actor_id].pMonsterInfo.uSpell1ID].uSchool; - else if ( a4 == 3 ) - v12 = pSpellStats->pInfos[pActors[actor_id].pMonsterInfo.uSpell2ID].uSchool; - else if ( a4 == 4 ) - v12 = pActors[PID_ID(attacker_id)].pMonsterInfo.field_3C_some_special_attack; - else - v12 = 4; - finalDmg = pActors[actor_id].CalcMagicalDamageToActor((DAMAGE_TYPE)v12, dmgToRecv); - pActors[actor_id].sCurrentHP -= finalDmg; - if ( finalDmg ) - { - if ( pActors[actor_id].sCurrentHP > 0 ) - Actor::AI_Stun(actor_id, attacker_id, 0); - else - Actor::Die(actor_id); - Actor::AggroSurroundingPeasants(actor_id, 0); - pushDistance = 20 * finalDmg / pActors[actor_id].pMonsterInfo.uHP; - if ( pushDistance > 10 ) - pushDistance = 10; - if ( !MonsterStats::BelongsToSupertype(pActors[actor_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) - { - pVelocity->x = (int32)fixpoint_mul(pushDistance, pVelocity->x); - pVelocity->y = (int32)fixpoint_mul(pushDistance, pVelocity->y); - pVelocity->z = (int32)fixpoint_mul(pushDistance, pVelocity->z); - pActors[actor_id].vVelocity.x = 50 * LOWORD(pVelocity->x); - pActors[actor_id].vVelocity.y = 50 * LOWORD(pVelocity->y); - pActors[actor_id].vVelocity.z = 50 * LOWORD(pVelocity->z); - } - Actor::AddBloodsplatOnDamageOverlay(actor_id, 1, finalDmg); - } - else - Actor::AI_Stun(actor_id, attacker_id, 0); - return; - } - } - } -} - -//----- (0044FD29) -------------------------------------------------------- -void Actor::SummonMinion( int summonerId ) -{ - unsigned __int8 extraSummonLevel; // al@1 - int summonMonsterBaseType; // esi@1 - int v5; // edx@2 - int v7; // edi@10 - Actor *actor; // esi@10 - MonsterInfo *v9; // ebx@10 - //MonsterDesc *v10; // edi@10 - int v13; // ebx@10 - int v15; // edi@10 - int v17; // ebx@10 - unsigned int v19; // qax@10 - int result; // eax@13 - unsigned int monsterId; // [sp+10h] [bp-18h]@8 - int v27; // [sp+18h] [bp-10h]@10 - int actorSector; // [sp+1Ch] [bp-Ch]@8 - - - actorSector = 0; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - actorSector = pIndoor->GetSector(this->vPosition.x, this->vPosition.y, this->vPosition.z); - - v19 = this->uAlly; - if ( !this->uAlly ) - { - monsterId = this->pMonsterInfo.uID - 1; - v19 = (uint)(monsterId * 0.33333334); - } - v27 = uCurrentlyLoadedLevelType == LEVEL_Outdoor ? 128 : 64; - v13 = rand() % 2048; - v15 = fixpoint_mul(stru_5C6E00->Cos(v13), v27) + this->vPosition.x; - v17 = fixpoint_mul(stru_5C6E00->Sin(v13), v27) + this->vPosition.y; - - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - result = pIndoor->GetSector(v15, v17, this->vPosition.z); - if (result != actorSector) - return; - result = BLV_GetFloorLevel(v15, v17, v27, result, &monsterId); - if (result != -30000) - return; - if (abs(result - v27) > 1024) - return; - } - - extraSummonLevel = this->pMonsterInfo.uSpecialAbilityDamageDiceRolls; - summonMonsterBaseType = this->pMonsterInfo.field_3C_some_special_attack; - if ( extraSummonLevel ) - { - if ( extraSummonLevel >= 1 && extraSummonLevel <= 3 ) - summonMonsterBaseType = summonMonsterBaseType + extraSummonLevel - 1; - } - else - { - v5 = rand() % 100; - if ( v5 >= 90 ) - summonMonsterBaseType += 2; - else if ( v5 >= 60 ) - summonMonsterBaseType += 1; - } - v7 = summonMonsterBaseType - 1; - actor = &pActors[uNumActors]; - v9 = &pMonsterStats->pInfos[v7 + 1]; - pActors[uNumActors].Reset(); - strcpy(actor->pActorName, v9->pName); - actor->sCurrentHP = LOWORD(v9->uHP); - memcpy(&actor->pMonsterInfo, v9, sizeof(actor->pMonsterInfo)); - actor->word_000086_some_monster_id = summonMonsterBaseType; - actor->uActorRadius = pMonsterList->pMonsters[v7].uMonsterRadius; - actor->uActorHeight = pMonsterList->pMonsters[v7].uMonsterHeight; - actor->pMonsterInfo.uTreasureDiceRolls = 0; - actor->pMonsterInfo.uTreasureType = 0; - actor->pMonsterInfo.uExp = 0; - actor->uMovementSpeed = pMonsterList->pMonsters[v7].uMovementSpeed; - - actor->vInitialPosition.x = v15; - actor->vInitialPosition.y = v17; - actor->vInitialPosition.z = this->vPosition.z; - actor->vPosition.x = v15; - actor->vPosition.y = v17; - actor->vPosition.z = this->vPosition.z; - - actor->uTetherDistance = 256; - actor->uSectorID = actorSector; - actor->PrepareSprites(0); - actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - actor->uAlly = v19; - actor->uCurrentActionTime = 0; - actor->uGroup = this->uGroup; - actor->uAIState = Summoned; - actor->uCurrentActionLength = 256; - actor->UpdateAnimation(); - - ++uNumActors; - ++this->pMonsterInfo.uSpecialAbilityDamageDiceBonus; - if ( ActorEnemy()) - actor->uAttributes |= ACTOR_AGGRESSOR; - actor->uSummonerID = PID(OBJECT_Actor,summonerId); - -} -// 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); -//----- (0046DF1A) -------------------------------------------------------- -bool Actor::_46DF1A_collide_against_actor( int a1, int a2 ) -{ - Actor *v2; // edi@1 - unsigned __int16 v3; // ax@1 - int v4; // esi@6 - int v8; // ecx@14 - int v9; // eax@14 - int v10; // ebx@14 - int v11; // esi@14 - int v12; // ebx@15 - int v13; // ebx@17 - - v2 = &pActors[a1]; - v3 = v2->uAIState; - if ( v3 == Removed || v3 == Dying || v3 == Disabled || v3 == Dead || v3 == Summoned ) - return 0; - v4 = v2->uActorRadius; - if ( a2 ) - v4 = a2; - - if (stru_721530.sMaxX > v2->vPosition.x + v4 || - stru_721530.sMinX < v2->vPosition.x - v4 || - stru_721530.sMaxY > v2->vPosition.y + v4 || - stru_721530.sMinY < v2->vPosition.y - v4 || - stru_721530.sMaxZ > v2->vPosition.z + v2->uActorHeight || - stru_721530.sMinZ < v2->vPosition.z) - { - return false; - } - v8 = v2->vPosition.x - stru_721530.normal.x; - v9 = v2->vPosition.y - stru_721530.normal.y; - v10 = stru_721530.prolly_normal_d + v4; - v11 = (v8 * stru_721530.direction.y - v9 * stru_721530.direction.x) >> 16; - v12 = (v8 * stru_721530.direction.x + v9 * stru_721530.direction.y) >> 16; - if ( abs(v11) > v10 || v12 <= 0) - return false; - if (fixpoint_mul(stru_721530.direction.z, v12) + stru_721530.normal.z < v2->vPosition.z) - return false; - - v13 = v12 - integer_sqrt(v10 * v10 - v11 * v11); - if ( v13 < 0 ) - v13 = 0; - if ( v13 < stru_721530.field_7C ) - { - stru_721530.field_7C = v13; - stru_721530.uFaceID = PID(OBJECT_Actor,a1); - } - return true; -} -//----- (00401A91) -------------------------------------------------------- -void Actor::UpdateActorAI() -{ - signed int v4; // edi@10 - signed int sDmg; // eax@14 - Player *pPlayer; // ecx@21 - Actor *pActor; // esi@34 - //unsigned __int16 v22; // ax@86 - unsigned int v27; // ecx@123 - unsigned int v28; // eax@123 - int v33; // eax@144 - int v34; // eax@147 - char v35; // al@150 - unsigned int v36; // edi@152 - signed int v37; // eax@154 - double v42; // st7@176 - double v43; // st6@176 - int v45; // eax@192 - unsigned __int8 v46; // cl@197 - signed int v47; // st7@206 - uint v58; // st7@246 - unsigned int v65; // [sp-10h] [bp-C0h]@144 - int v70; // [sp-10h] [bp-C0h]@213 - AIDirection v72; // [sp+0h] [bp-B0h]@246 - AIDirection a3; // [sp+1Ch] [bp-94h]@129 - int target_pid_type; // [sp+70h] [bp-40h]@83 - signed int a1; // [sp+74h] [bp-3Ch]@129 - int v78; // [sp+78h] [bp-38h]@79 - AIDirection* pDir; // [sp+7Ch] [bp-34h]@129 - float radiusMultiplier; // [sp+98h] [bp-18h]@33 - int v81; // [sp+9Ch] [bp-14h]@100 - signed int target_pid; // [sp+ACh] [bp-4h]@83 - AIState uAIState; - uint v38; - - //Build AI array - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - Actor::MakeActorAIList_ODM(); - else - Actor::MakeActorAIList_BLV(); - - //Armageddon damage mechanic - if ( uCurrentlyLoadedLevelType != LEVEL_Indoor && pParty->armageddon_timer > 0 ) - { - if ( pParty->armageddon_timer > 417 ) - pParty->armageddon_timer = 0; - else - { - pParty->sRotationY = (stru_5C6E00->uIntegerDoublePi - 1) & (pParty->sRotationY + rand() % 16 - 8); - pParty->sRotationX = pParty->sRotationX + rand() % 16 - 8; - if ( pParty->sRotationX > 128) - pParty->sRotationX = 128; - else if ( pParty->sRotationX < -128 ) - pParty->sRotationX = -128; - - pParty->uFlags |= 2u; - pParty->armageddon_timer -= pMiscTimer->uTimeElapsed; - v4 = pParty->armageddonDamage + 50; - if ( pParty->armageddon_timer <= 0 ) - { - pParty->armageddon_timer = 0; - for(size_t i = 0; i < uNumActors; i++) - { - pActor=&pActors[i]; - if ( pActor->CanAct() ) - { - sDmg = pActor->CalcMagicalDamageToActor((DAMAGE_TYPE)5, v4); - pActor->sCurrentHP -= sDmg; - if ( sDmg ) - { - if ( pActor->sCurrentHP >= 0 ) - Actor::AI_Stun(i, 4, 0); - else - { - Actor::Die(i); - if ( pActor->pMonsterInfo.uExp ) - pParty->GivePartyExp(pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uExp); - } - } - } - } - for(int i = 1; i <= 4; i++) - { - pPlayer = pPlayers[i]; - if ( !pPlayer->pConditions[Condition_Dead] && !pPlayer->pConditions[Condition_Pertified] && !pPlayer->pConditions[Condition_Eradicated] ) - pPlayer->ReceiveDamage(v4, DMGT_MAGICAL); - } - } - if (pTurnEngine->pending_actions) - --pTurnEngine->pending_actions; - } - } - - //Turn-based mode: return - if (pParty->bTurnBasedModeOn) - { - pTurnEngine->AITurnBasedAction(); - return; - } - - for (uint i = 0; i < uNumActors; ++i) - { - pActor = &pActors[i]; - ai_near_actors_targets_pid[i] = OBJECT_Player; - - //Skip actor if: Dead / Removed / Disabled / uAttributes & 0x0400 - if (pActor->uAIState == Dead || pActor->uAIState == Removed || pActor->uAIState == Disabled || pActor->uAttributes & ACTOR_ALIVE) - continue; - - //Kill actor if HP == 0 - if (!pActor->sCurrentHP && pActor->uAIState != Dying) - Actor::Die(i); - - //Kill buffs if expired - for (uint j = 0; j < 22; ++j) - { - if (j != 10) - pActor->pActorBuffs[j].IsBuffExpiredToTime(pParty->uTimePlayed); - } - - //If shrink expired: reset height - if (pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0) - pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight; - - //If Charm still active: make actor friendly - if (pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0) - pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - //Else: reset hostilty - else if (pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0) - pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType; - - //If actor Paralyzed or Stoned: skip - if (pActor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0 || pActor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0) - continue; - - //Calculate RecoveryTime - pActor->pMonsterInfo.uRecoveryTime = max(pActor->pMonsterInfo.uRecoveryTime - pMiscTimer->uTimeElapsed, 0); - - pActor->uCurrentActionTime += pMiscTimer->uTimeElapsed; - if (pActor->uCurrentActionTime < pActor->uCurrentActionLength) - continue; - - if (pActor->uAIState == Dying) - pActor->uAIState = Dead; - else - { - if (pActor->uAIState != Summoned) - { - Actor::AI_StandOrBored(i, OBJECT_Player, 256, nullptr); - continue; - } - pActor->uAIState = Standing; - } - - pActor->uCurrentActionTime = 0; - pActor->uCurrentActionLength = 0; - pActor->UpdateAnimation(); - } - - for(v78 = 0; v78 < ai_arrays_size; ++v78) - { - uint actor_id = ai_near_actors_ids[v78]; - assert(actor_id < uNumActors); - - pActor = &pActors[actor_id]; - - v47 = (signed int)(pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333); - - Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); - - if (pActor->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id]) - pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - - target_pid = ai_near_actors_targets_pid[actor_id]; - target_pid_type = PID_TYPE(target_pid); - - if ( target_pid_type == OBJECT_Actor) - radiusMultiplier = 0.5; - else - radiusMultiplier = 1.0; - - //v22 = pActor->uAIState; - if ( pActor->uAIState == Dying || pActor->uAIState == Dead || pActor->uAIState == Removed - || pActor->uAIState == Disabled || pActor->uAIState == Summoned) - continue; - - if ( !pActor->sCurrentHP ) - Actor::Die(actor_id); - - for( int i = 0;i < 22; i++ ) - { - if ( i != 10 ) - pActor->pActorBuffs[i].IsBuffExpiredToTime(pParty->uTimePlayed); - } - - if ( pActor->pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime < 0 ) - pActor->uActorHeight = pMonsterList->pMonsters[pActor->pMonsterInfo.uID - 1].uMonsterHeight; - if ( pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime > 0 ) - pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - else if ( pActor->pActorBuffs[ACTOR_BUFF_CHARM].uExpireTime < 0 ) - pActor->pMonsterInfo.uHostilityType = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].uHostilityType; - - //If actor is summoned and buff expired: continue and set state to Removed - if ( pActor->pActorBuffs[ACTOR_BUFF_SUMMONED].uExpireTime < 0 ) - { - pActor->uAIState = Removed; - continue; - } - - if ( (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0 || (signed __int64)pActor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0) - { - continue; - } - - v27 = pMiscTimer->uTimeElapsed; - v28 = pActor->pMonsterInfo.uRecoveryTime; - pActor->uCurrentActionTime += pMiscTimer->uTimeElapsed; - - if ( (signed int)v28 > 0 ) - pActor->pMonsterInfo.uRecoveryTime = v28 - v27; - if ( pActor->pMonsterInfo.uRecoveryTime < 0 ) - pActor->pMonsterInfo.uRecoveryTime = 0; - if ( !pActor->ActorNearby() ) - pActor->uAttributes |= ACTOR_NEARBY; - - a1 = PID(OBJECT_Actor,actor_id); - Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), target_pid, &a3, 0); - pDir = &a3; - uAIState = pActor->uAIState; - - if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly - || (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 - || radiusMultiplier * 307.2 < pDir->uDistance - || uAIState != Pursuing && uAIState != Standing && uAIState != Tethered && uAIState != Fidgeting - && !pActor->pMonsterInfo.uMissleAttack1Type || uAIState != Stunned ) - { - if ( (signed int)pActor->uCurrentActionTime < pActor->uCurrentActionLength ) - continue; - else if ( pActor->uAIState == AttackingMelee ) - { - v35 = pActor->special_ability_use_check(actor_id); - AttackerInfo.Add(a1, 5120, pActor->vPosition.x, pActor->vPosition.y, pActor->vPosition.z + ((signed int)pActor->uActorHeight >> 1), v35, 1 ); - } - else if ( pActor->uAIState == AttackingRanged1 ) - { - v34 = pActor->pMonsterInfo.uMissleAttack1Type; - Actor::AI_RangedAttack(actor_id, pDir, v34, 0); - } - else if ( pActor->uAIState == AttackingRanged2 ) - { - v34 = pActor->pMonsterInfo.uMissleAttack2Type; - Actor::AI_RangedAttack(actor_id, pDir, v34, 1); - } - else if ( pActor->uAIState == AttackingRanged3 ) - { - v65 = pActor->pMonsterInfo.uSpellSkillAndMastery1; - v33 = pActor->pMonsterInfo.uSpell1ID; - Actor::AI_SpellAttack(actor_id, pDir, v33, 2, v65); - } - else if ( pActor->uAIState == AttackingRanged4 ) - { - v65 = pActor->pMonsterInfo.uSpellSkillAndMastery2; - v33 = pActor->pMonsterInfo.uSpell2ID; - Actor::AI_SpellAttack(actor_id, pDir, v33, 3, v65); - } - } - - v36 = pDir->uDistance; - - if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly) - { - if ( target_pid_type == OBJECT_Actor ) - { - v36 = pDir->uDistance; - v37 =pFactionTable->relations[(pActor->pMonsterInfo.uID-1) / 3 + 1][(pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3 + 1]; - } - else - v37 = 4; - v38 = 0; - if ( v37 == 2 ) - v38 = 1024; - else if ( v37 == 3 ) - v38 = 2560; - else if ( v37 == 4 ) - v38 = 5120; - if ( v37 >= 1 && v37 <= 4 && v36 < v38 || v37 == 1 ) - pActor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - } - - //If actor afraid: flee or if out of range random move - if (pActor->pActorBuffs[ACTOR_BUFF_AFRAID].uExpireTime > 0) - { - if ( (signed int)v36 >= 10240 ) - Actor::AI_RandomMove(actor_id, target_pid, 1024, 0); - else - Actor::AI_Flee(actor_id, target_pid, 0, pDir); - continue; - } - - if ( pActor->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && target_pid ) - { - if ( pActor->pMonsterInfo.uAIType == 1 ) - { - if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) - Actor::AI_Stand(actor_id, target_pid, (uint)(pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333), pDir); - else - { - Actor::AI_Flee(actor_id, target_pid, 0, pDir); - continue; - } - - } - if ( !(pActor->uAttributes & ACTOR_FLEEING) ) - { - if ( pActor->pMonsterInfo.uAIType == 2 || pActor->pMonsterInfo.uAIType == 3) - { - if ( pActor->pMonsterInfo.uAIType == 2 ) - v43 = (double)(signed int)pActor->pMonsterInfo.uHP * 0.2; - if ( pActor->pMonsterInfo.uAIType == 3 ) - v43 = (double)(signed int)pActor->pMonsterInfo.uHP * 0.1; - v42 = (double)pActor->sCurrentHP; - if ( v43 > v42 && (signed int)v36 < 10240 ) - { - Actor::AI_Flee(actor_id, target_pid, 0, pDir); - continue; - } - } - } - - v81 = v36 - pActor->uActorRadius; - if ( target_pid_type == OBJECT_Actor ) - v81 -= pActors[PID_ID(target_pid)].uActorRadius; - if ( v81 < 0 ) - v81 = 0; - rand(); - pActor->uAttributes &= ~ACTOR_UNKNOW5;//~0x40000 - if ( v81 < 5120 ) - { - v45 = pActor->special_ability_use_check(actor_id); - if ( v45 == 0 ) - { - if ( pActor->pMonsterInfo.uMissleAttack1Type ) - { - if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 ) - Actor::AI_MissileAttack1(actor_id, target_pid, pDir); - else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) - Actor::AI_Stand(actor_id, target_pid, v47, pDir); - else - { - if ( radiusMultiplier * 307.2 > (double)v81 ) - Actor::AI_Stand(actor_id, target_pid, v47, pDir); - else - Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, pDir); - } - } - else - { - if ( (double)v81 >= radiusMultiplier * 307.2 ) - { - if (pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY) - Actor::AI_Stand(actor_id, target_pid, v47, pDir); - else if ( v81 >= 1024 )//monsters - Actor::AI_Pursue3(actor_id, target_pid, 0, pDir); - else - { - v70 = (signed int)(radiusMultiplier * 307.2); - //monsters - //guard after player runs away - // follow player - Actor::AI_Pursue2(actor_id, target_pid, 0, pDir, v70); - } - } - else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) - { - Actor::AI_Stand(actor_id, target_pid, v47, pDir); - } - else - { - //monsters - Actor::AI_MeleeAttack(actor_id, target_pid, pDir); - } - } - continue; - } - else if ( v45 == 2 || v45 == 3 ) - { - if ( v45 == 2 ) - v46 = pActor->pMonsterInfo.uSpell1ID; - else - v46 = pActor->pMonsterInfo.uSpell2ID; - if ( v46 ) - { - if ( (signed int)pActor->pMonsterInfo.uRecoveryTime <= 0 ) - { - if ( v45 == 2 ) - Actor::AI_SpellAttack1(actor_id, target_pid, pDir); - else - Actor::AI_SpellAttack2(actor_id, target_pid, pDir); - } - else if ( radiusMultiplier * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) - Actor::AI_Stand(actor_id, target_pid, v47, pDir); - else - Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, pDir); - } - else - { - if ( (double)v81 >= radiusMultiplier * 307.2 ) - { - if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) - Actor::AI_Stand(actor_id, target_pid, v47, pDir); - else if ( v81 >= 1024 ) - Actor::AI_Pursue3(actor_id, target_pid, 256, pDir); - else - { - v70 = (signed int)(radiusMultiplier * 307.2); - Actor::AI_Pursue2(actor_id, target_pid, 0, pDir, v70); - } - } - else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) - { - Actor::AI_Stand(actor_id, target_pid, v47, pDir); - } - else - { - Actor::AI_MeleeAttack(actor_id, target_pid, pDir); - } - } - continue; - } - } - } - - if ( pActor->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 ) - { - if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_SHORT ) - Actor::AI_RandomMove(actor_id, 4, 1024, 0); - else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_MEDIUM ) - Actor::AI_RandomMove(actor_id, 4, 2560, 0); - else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_LONG ) - Actor::AI_RandomMove(actor_id, 4, 5120, 0); - else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_FREE ) - Actor::AI_RandomMove(actor_id, 4, 10240, 0); - else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) - { - Actor::GetDirectionInfo(a1, 4, &v72, 0); - v58 = (uint)(pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333); - Actor::AI_Stand(actor_id, 4, v58, &v72); - } - } - else if ( !pActor->pMonsterInfo.uMissleAttack2Type ) - { - if ( (double)v81 >= radiusMultiplier * 307.2 ) - { - if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) - Actor::AI_Stand(actor_id, target_pid, v47, pDir); - else if ( v81 >= 1024 ) - Actor::AI_Pursue3(actor_id, target_pid, 256, pDir); - else - { - v70 = (int)(radiusMultiplier * 307.2); - Actor::AI_Pursue2(actor_id, target_pid, 0, pDir, v70); - } - } - else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) - Actor::AI_Stand(actor_id, target_pid, v47, pDir); - else - Actor::AI_MeleeAttack(actor_id, target_pid, pDir); - } - else if ( (signed int)pActor->pMonsterInfo.uRecoveryTime > 0 ) - { - if ( radiusMultiplier * 307.2 > (double)v81 || pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) - Actor::AI_Stand(actor_id, target_pid, v47, pDir); - else - Actor::AI_Pursue1(actor_id, target_pid, actor_id, v47, pDir); - } - else - Actor::AI_MissileAttack2(actor_id, target_pid, pDir); - } -} -//----- (0044665D) -------------------------------------------------------- -// uType: 0 -> any monster -// 1 -> uParam is GroupID -// 2 -> uParam is MonsterID -// 3 -> uParam is ActorID -// uNumAlive: 0 -> all must be alive -int __fastcall IsActorAlive(unsigned int uType, unsigned int uParam, unsigned int uNumAlive) -{ - unsigned int uAliveActors; // eax@6 - unsigned int uTotalActors; // [sp+0h] [bp-4h]@1 - - uTotalActors = 0; - if ( uType ) - { - if ( uType == 1 ) - uAliveActors = Actor::SearchActorByGroup(&uTotalActors, uParam); - else - { - if ( uType == 2 ) - uAliveActors = Actor::SearchActorByMonsterID(&uTotalActors, uParam); - else - { - if ( uType != 3 ) - return 0; - uAliveActors = Actor::SearchActorByID(&uTotalActors, uParam); - } - } - } - else - uAliveActors = Actor::SearchAliveActors(&uTotalActors); - - if (uNumAlive) - return uAliveActors >= uNumAlive; - else - return uTotalActors == uAliveActors; -} -//----- (00408B54) -------------------------------------------------------- -unsigned int Actor::SearchActorByID(unsigned int *pTotalActors, unsigned int a2) -{ - //int v4; // eax@1 - unsigned int result; // ebx@1 - - //v4 = GetAlertStatus(); - *pTotalActors = 0; - result = 0; - if ( (pActors[a2].uAttributes & ACTOR_UNKNOW7) == GetAlertStatus() ) - { - *pTotalActors = 1; - if ( pActors[a2].IsNotAlive() == 1 ) - result = 1; - } - return result; -} -//----- (00408AE7) -------------------------------------------------------- -unsigned int Actor::SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup) -{ - unsigned int result; // [sp+10h] [bp-4h]@1 - - int v8 = GetAlertStatus(); - *pTotalActors = 0; - result = 0; - for ( uint i = 0; i < uNumActors; i++) - { - if ( (pActors[i].uAttributes & ACTOR_UNKNOW7) == v8 && pActors[i].uGroup == uGroup) - { - ++*pTotalActors; - if ( pActors[i].IsNotAlive() == 1 ) - ++result; - } - } - return result; -} -//----- (00408A7E) -------------------------------------------------------- -unsigned int Actor::SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID) -{ - int v8; // [sp+Ch] [bp-8h]@1 - unsigned int result; // [sp+10h] [bp-4h]@1 - - v8 = GetAlertStatus(); - *pTotalActors = 0; - result = 0; - for ( uint i = 0; i < uNumActors; i++) - { - if ( (pActors[i].uAttributes & ACTOR_UNKNOW7) == v8 && pActors[i].pMonsterInfo.field_33 == uMonsterID) - { - ++*pTotalActors; - if ( pActors[i].IsNotAlive() == 1 ) - ++result; - } - } - return result; -} -//----- (00408A27) -------------------------------------------------------- -unsigned int Actor::SearchAliveActors(unsigned int *pTotalActors) -{ - int v2; // eax@1 - unsigned int result; // ebp@1 - - v2 = GetAlertStatus(); - result = 0; - *pTotalActors = 0; - for ( uint i = 0; i < uNumActors; i++) - { - if ( (pActors[i].uAttributes & ACTOR_UNKNOW7) == v2 ) - { - ++*pTotalActors; - if ( pActors[i].IsNotAlive() == 1 ) - ++result; - } - } - return result; -} -//----- (00408768) -------------------------------------------------------- -void Actor::InitializeActors() -{ - bool evil; // [sp+Ch] [bp-10h]@1 - bool bPit; // [sp+10h] [bp-Ch]@1 - bool good; // [sp+14h] [bp-8h]@1 - bool bCelestia; // [sp+18h] [bp-4h]@1 - - bCelestia = false; - bPit = false; - good = false; - evil = false; - if ( !_stricmp(pCurrentMapName, "d25.blv") )//the Celestia - bCelestia = true; - if ( !_stricmp(pCurrentMapName, "d26.blv") )//the Pit - bPit = true; - if (pParty->IsPartyGood()) - good = true; - if (pParty->IsPartyEvil()) - evil = true; - - Log::Warning(L"%S %S %u", __FILE__, __FUNCTION__, __LINE__); // ai_near_actors_targets_pid[i] for AI_Stand seems always 0; original code behaviour is identical - for (uint i = 0; i < uNumActors; ++i) - { - Actor* actor = &pActors[i]; - - if (actor->CanAct() || actor->uAIState == Disabled) - { - actor->vPosition.x = actor->vInitialPosition.x; - actor->vPosition.y = actor->vInitialPosition.y; - actor->vPosition.z = actor->vInitialPosition.z; - actor->sCurrentHP = actor->pMonsterInfo.uHP; - if (actor->uAIState != Disabled) - { - Actor::AI_Stand(i, ai_near_actors_targets_pid[i], actor->pMonsterInfo.uRecoveryTime, 0); - } - } - - actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - - if (!bCelestia || good) - if (!bPit || evil) - if (actor->IsPeasant()) - actor->ResetAggressor();//~0x80000 - - actor->ResetHasItem();//~0x800000 - if (actor->uAttributes & ACTOR_UNKNOW9) - Actor::_4031C1_update_job_never_gets_called(i, pParty->uCurrentHour, 1); - } -} -//----- (00439474) -------------------------------------------------------- -void Actor::DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity) -{ - SpriteObject *projectileSprite; // ebx@1 - Actor *pMonster; // esi@7 - unsigned __int16 v16; // cx@25 - int v33; // eax@100 - int v40; // ebx@107 - int extraRecoveryTime; // qax@125 - unsigned __int16 v43; // ax@132 - unsigned __int16 v45; // ax@132 - unsigned __int64 v46; // [sp+Ch] [bp-60h]@6 - char *pPlayerName; // [sp+18h] [bp-54h]@12 - char *pMonsterName; // [sp+1Ch] [bp-50h]@6 - signed int a4; // [sp+44h] [bp-28h]@1 - bool IsAdditionalDamagePossible; // [sp+50h] [bp-1Ch]@1 - int v61; // [sp+58h] [bp-14h]@1 - bool isLifeStealing; // [sp+5Ch] [bp-10h]@1 - int uDamageAmount; // [sp+60h] [bp-Ch]@1 - DAMAGE_TYPE attackElement; // [sp+64h] [bp-8h]@27 - - projectileSprite = 0; - uDamageAmount = 0; - a4 = 0; - v61 = 0; - IsAdditionalDamagePossible = false; - isLifeStealing = 0; - if ( PID_TYPE(a1) == OBJECT_Item) - { - projectileSprite = &pSpriteObjects[PID_ID(a1)]; - v61 = projectileSprite->field_60_distance_related_prolly_lod; - a1 = projectileSprite->spell_caster_pid; - } - if (PID_TYPE(a1) != OBJECT_Player) - return; - - assert(PID_ID(abs(a1)) < 4); - Player* player = &pParty->pPlayers[PID_ID(a1)]; - pMonster = &pActors[uActorID_Monster]; - if (pMonster->IsNotAlive()) - return; - - pMonster->uAttributes |= 0xC000; - if ( pMonster->uAIState == Fleeing ) - pMonster->uAttributes |= ACTOR_FLEEING; - bool hit_will_stun = false, - hit_will_paralyze = false; - if ( !projectileSprite ) - { - int main_hand_idx = player->pEquipment.uMainHand; - IsAdditionalDamagePossible = true; - if ( player->HasItemEquipped(EQUIP_TWO_HANDED) ) - { - uint main_hand_skill = player->GetMainHandItem()->GetPlayerSkillType(); - uint main_hand_mastery = SkillToMastery(player->pActiveSkills[main_hand_skill]); - switch (main_hand_skill) - { - case PLAYER_SKILL_STAFF: - if (main_hand_mastery >= 3) - { - if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_STAFF) & 0x3F)) // stun chance when mastery >= 3 - hit_will_stun = true; - } - break; - - case PLAYER_SKILL_MACE: - if (main_hand_mastery >= 3) - { - if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F)) - hit_will_stun = true; - } - if (main_hand_mastery >= 4) - { - if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F)) - hit_will_paralyze = true; - } - break; - } - } - attackElement = DMGT_PHISYCAL; - uDamageAmount = player->CalculateMeleeDamageTo(false, false, pMonster->pMonsterInfo.uID); - if ( !player->PlayerHitOrMiss(pMonster, v61, a4) ) - { - player->PlaySound(SPEECH_52, 0); - return; - } - } - else - { - v61 = projectileSprite->field_60_distance_related_prolly_lod; - if ( projectileSprite->spell_id != SPELL_DARK_SOULDRINKER ) - { - int d1 = abs(pParty->vPosition.x - projectileSprite->vPosition.x); - int d2 = abs(pParty->vPosition.y - projectileSprite->vPosition.y); - int d3 = abs(pParty->vPosition.z - projectileSprite->vPosition.z); - v61 = int_get_vector_length(d1, d2, d3); - - if ( v61 >= 5120 && !(pMonster->uAttributes & ACTOR_ALIVE) )//0x400 - return; - else if ( v61 >= 2560 ) - v61 = 2; - else - v61 = 1; - } - - switch (projectileSprite->spell_id) - { - case SPELL_LASER_PROJECTILE: - v16 = player->pActiveSkills[PLAYER_SKILL_BLASTER]; - v61 = 1; - if ( SkillToMastery(v16) >= 3 ) - a4 = player->pActiveSkills[PLAYER_SKILL_BLASTER] & 0x3F; - attackElement = DMGT_PHISYCAL; - uDamageAmount = player->CalculateMeleeDamageTo(true, true, 0); - if ( !player->PlayerHitOrMiss(pMonster, v61, a4) ) - { - player->PlaySound(SPEECH_52, 0); - return; - } - break; - case SPELL_101: - attackElement = DMGT_FIRE; - uDamageAmount = player->CalculateRangedDamageTo(0); - if ( pMonster->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime > 0 ) - uDamageAmount >>= 1; - IsAdditionalDamagePossible = true; - if ( !player->PlayerHitOrMiss(pMonster, v61, a4) ) - { - player->PlaySound(SPEECH_52, 0); - return; - } - break; - case SPELL_EARTH_BLADES: - a4 = 5 * projectileSprite->spell_level; - attackElement = (DAMAGE_TYPE)player->GetSpellSchool(SPELL_EARTH_BLADES); - uDamageAmount = _43AFE3_calc_spell_damage(39, projectileSprite->spell_level, projectileSprite->spell_skill, pMonster->sCurrentHP); - if ( pMonster->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime > 0 ) - uDamageAmount >>= 1; - IsAdditionalDamagePossible = false; - if ( !player->PlayerHitOrMiss( pMonster, v61, a4) ) - { - player->PlaySound(SPEECH_52, 0); - return; - } - break; - case SPELL_EARTH_STUN: - uDamageAmount = 0; - attackElement = DMGT_PHISYCAL; - hit_will_stun = 1; - if ( !player->PlayerHitOrMiss( pMonster, v61, a4) ) - { - player->PlaySound(SPEECH_52, 0); - return; - } - break; - case SPELL_BOW_ARROW: - attackElement = DMGT_PHISYCAL; - uDamageAmount = player->CalculateRangedDamageTo(pMonster->word_000086_some_monster_id); - if ( pMonster->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime > 0 ) - uDamageAmount /= 2; - IsAdditionalDamagePossible = true; - if ( projectileSprite->stru_24.uItemID != 0 && projectileSprite->stru_24.uSpecEnchantmentType == 3 ) //of carnage - { - attackElement = DMGT_FIRE; - } - else if ( !player->PlayerHitOrMiss( pMonster, v61, a4) ) - { - player->PlaySound(SPEECH_52, 0); - return; - } - break; - - default: - attackElement = (DAMAGE_TYPE)player->GetSpellSchool(projectileSprite->spell_id); - IsAdditionalDamagePossible = false; - uDamageAmount = _43AFE3_calc_spell_damage(projectileSprite->spell_id, projectileSprite->spell_level, projectileSprite->spell_skill, pMonster->sCurrentHP); - break; - } - } - - if (player->IsWeak()) - uDamageAmount /= 2; - if ( pMonster->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0 ) - uDamageAmount = 0; - v61 = pMonster->CalcMagicalDamageToActor(attackElement, uDamageAmount); - if ( !projectileSprite && player->IsUnarmed() && player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uExpireTime > 0 ) - { - v61 += pMonster->CalcMagicalDamageToActor((DAMAGE_TYPE)8, player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uPower); - } - uDamageAmount = v61; - if ( IsAdditionalDamagePossible ) - { - if ( projectileSprite ) - { - a4 = projectileSprite->stru_24._439DF3_get_additional_damage((int*)&attackElement, &isLifeStealing); - if ( isLifeStealing && pMonster->sCurrentHP > 0 ) - { - player->sHealth += v61 / 5; - if ( player->sHealth > player->GetMaxHealth() ) - player->sHealth = player->GetMaxHealth(); - } - uDamageAmount += pMonster->CalcMagicalDamageToActor(attackElement, a4); - } - else - { - for (int i = 0; i < 2; i++) - { - if ( player->HasItemEquipped((ITEM_EQUIP_TYPE)i) ) - { - ItemGen* item; - if (i == 0) - item = player->GetOffHandItem(); - else - item = player->GetMainHandItem(); - a4 = item->_439DF3_get_additional_damage((int*)&attackElement, &isLifeStealing); - if ( isLifeStealing && pMonster->sCurrentHP > 0 ) - { - player->sHealth += v61 / 5; - if ( player->sHealth > player->GetMaxHealth() ) - player->sHealth = player->GetMaxHealth(); - } - uDamageAmount += pMonster->CalcMagicalDamageToActor(attackElement, a4); - } - } - } - } - pMonster->sCurrentHP -= uDamageAmount; - if ( uDamageAmount == 0 && !hit_will_stun ) - { - player->PlaySound(SPEECH_52, 0); - return; - } - if ( pMonster->sCurrentHP > 0 ) - { - Actor::AI_Stun(uActorID_Monster, a1, 0); - Actor::AggroSurroundingPeasants(uActorID_Monster, 1); - if ( bShowDamage ) - { - if ( projectileSprite ) - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[189], player->pName, pMonster->pActorName, uDamageAmount);// "%s shoots %s for %lu points" - else - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[164], player->pName, pMonster->pActorName, uDamageAmount);// "%s hits %s for %lu damage" - ShowStatusBarString(pTmpBuf.data(), 2u); - } - } - else - { - if ( pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].bQuestMonster & 1 ) - { - if ( /*pRenderer->pRenderD3D &&*/ pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) - { - v33 = byte_4D864C && pGame->uFlags & 0x80000 ? 10 * pMonster->uActorRadius : pMonster->uActorRadius; - pDecalBuilder->AddBloodsplat((float)pMonster->vPosition.x, (float)pMonster->vPosition.y, (float)pMonster->vPosition.z, 1.0, 0.0, 0.0, (float)v33, 0, 0); - } - } - Actor::Die(uActorID_Monster); - Actor::ApplyFineForKillingPeasant(uActorID_Monster); - Actor::AggroSurroundingPeasants(uActorID_Monster, 1); - if ( pMonster->pMonsterInfo.uExp ) - pParty->GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp); - v40 = SPEECH_51; - if ( rand() % 100 < 20 ) - v40 = ((signed int)pMonster->pMonsterInfo.uHP >= 100) + 1; - player->PlaySound((PlayerSpeech)v40, 0); - if ( bShowDamage ) - { - pMonsterName = (char *)uDamageAmount; - pPlayerName = player->pName; // "%s inflicts %lu points killing %s" - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[175], player->pName, uDamageAmount, pMonster); - ShowStatusBarString(pTmpBuf.data(), 2u); - } - } - if ( pMonster->pActorBuffs[ACTOR_BUFF_PAIN_REFLECTION].uExpireTime > 0 - && uDamageAmount != 0 ) - player->ReceiveDamage(uDamageAmount, attackElement); - int knockbackValue = 20 * v61 / (signed int)pMonster->pMonsterInfo.uHP; - if ( (player->GetSpecialItemBonus(24) || hit_will_stun) && pMonster->DoesDmgTypeDoDamage(DMGT_EARTH) ) - { - extraRecoveryTime = 20; - knockbackValue = 10; - if ( !pParty->bTurnBasedModeOn ) - extraRecoveryTime = (int)(flt_6BE3A8_debug_recmod2 * 42.66666666666666); - pMonster->pMonsterInfo.uRecoveryTime += extraRecoveryTime; - if ( bShowDamage ) - { - pMonsterName = player->pName; // "%s stuns %s" - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[635], player->pName, pMonster); - ShowStatusBarString(pTmpBuf.data(), 2u); - } - } - if ( hit_will_paralyze && pMonster->CanAct() && pMonster->DoesDmgTypeDoDamage(DMGT_EARTH)) - { - v43 = player->GetActualSkillLevel(PLAYER_SKILL_MACE); - v45 = SkillToMastery(v43); - v46 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(7680 * (v43 & 0x3F)) * 0.033333335); - pMonster->pActorBuffs[ACTOR_BUFF_PARALYZED].Apply(v46, v45, 0, 0, 0); - if ( bShowDamage ) - { - pMonsterName = player->pName; // "%s paralyzes %s" - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[636], player->pName, pMonster); - ShowStatusBarString(pTmpBuf.data(), 2u); - } - } - if ( knockbackValue > 10 ) - knockbackValue = 10; - if ( !MonsterStats::BelongsToSupertype(pMonster->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) - { - pVelocity->x = fixpoint_mul(knockbackValue, pVelocity->x); - pVelocity->y = fixpoint_mul(knockbackValue, pVelocity->y); - pVelocity->z = fixpoint_mul(knockbackValue, pVelocity->z); - pMonster->vVelocity.x = 50 * LOWORD(pVelocity->x); - pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y); - pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z); - } - Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster, 1, v61); -} -//----- (004BBF61) -------------------------------------------------------- -void Actor::Arena_summon_actor( int monster_id, __int16 x, int y, int z ) -{ - int v12; // ebx@7 - int v13; // eax@8 - __int16 v16; // [sp+10h] [bp-4h]@3 - - if (uNumActors < 500) - { - v16 = 0; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - v16 = pIndoor->GetSector(x, y, z); - pActors[uNumActors].Reset(); - strcpy(pActors[uNumActors].pActorName, pMonsterStats->pInfos[monster_id].pName); - pActors[uNumActors].sCurrentHP = LOWORD(pMonsterStats->pInfos[monster_id].uHP); - memcpy(&pActors[uNumActors].pMonsterInfo, &pMonsterStats->pInfos[monster_id], 0x58u); - pActors[uNumActors].word_000086_some_monster_id = monster_id; - pActors[uNumActors].uActorRadius = pMonsterList->pMonsters[monster_id - 1].uMonsterRadius; - pActors[uNumActors].uActorHeight = pMonsterList->pMonsters[monster_id - 1].uMonsterHeight; - pActors[uNumActors].uMovementSpeed = pMonsterList->pMonsters[monster_id - 1].uMovementSpeed; - pActors[uNumActors].vInitialPosition.x = x; - pActors[uNumActors].vPosition.x = x; - pActors[uNumActors].uAttributes |= ACTOR_AGGRESSOR; - pActors[uNumActors].pMonsterInfo.uTreasureType = 0; - pActors[uNumActors].pMonsterInfo.uTreasureLevel = 0; - pActors[uNumActors].pMonsterInfo.uTreasureDiceSides = 0; - pActors[uNumActors].pMonsterInfo.uTreasureDiceRolls = 0; - pActors[uNumActors].pMonsterInfo.uTreasureDropChance = 0; - pActors[uNumActors].vInitialPosition.y = y; - pActors[uNumActors].vPosition.y = y; - pActors[uNumActors].vInitialPosition.z = z; - pActors[uNumActors].vPosition.z = z; - pActors[uNumActors].uTetherDistance = 256; - pActors[uNumActors].uSectorID = v16; - pActors[uNumActors].uGroup = 1; - pActors[uNumActors].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - pActors[uNumActors].PrepareSprites(0); - for ( int i = 0; i < 4; i++) - pSoundList->LoadSound(pMonsterList->pMonsters[monster_id - 1].pSoundSampleIDs[i], 0); - v12 = 0; - do - { - v13 = pSoundList->LoadSound(v12 + word_4EE088_sound_ids[pMonsterStats->pInfos[monster_id].uSpell1ID], 1); - v12++; - } - while ( v13 ); - ++uNumActors; - } -} -//----- (00426E10) -------------------------------------------------------- -int stru319::which_player_to_attack(Actor *pActor) -{ - signed int v2; // ebx@1 - bool flag; // edi@37 - int v22; // [sp+8h] [bp-140h]@3 - int Victims_list[60]; // [sp+48h] [bp-100h]@48 - int for_sex; // [sp+13Ch] [bp-Ch]@1 - int for_race; // [sp+140h] [bp-8h]@1 - int for_class; // [sp+144h] [bp-4h]@1 - - for_class = -1; - for_race = -1; - for_sex = -1; - v2 = 0; - if ( pActor->pMonsterInfo.uAttackPreference ) - { - for ( uint i = 0; i < 16; i++ ) - { - v22 = pActor->pMonsterInfo.uAttackPreference & (1 << i); - if ( v22 ) - { - switch ( v22 ) - { - case 1: - for_class = 0; - break; - case 2: - for_class = 12; - break; - case 4: - for_class = 16; - break; - case 8: - for_class = 28; - break; - case 16: - for_class = 24; - break; - case 32: - for_class = 32; - break; - case 64: - for_class = 20; - break; - case 128: - for_class = 4; - break; - case 256: - for_class = 8; - break; - case 512: - for_sex = 0; - break; - case 1024: - for_sex = 1; - break; - case 2048: - for_race = 0; - break; - case 4096: - for_race = 1; - break; - case 8192: - for_race = 3; - break; - case 16384: - for_race = 2; - break; - } - v2 = 0; - for ( uint j = 0; j < 4; ++j ) - { - flag = 0; - if ( for_class != -1 && for_class == pPlayers[j + 1]->classType ) - flag = true; - if ( for_sex != -1 && for_sex == pPlayers[j + 1]->uSex ) - flag = true; - if ( for_race != -1 && for_race == pPlayers[j + 1]->GetRace() ) - flag = true; - if ( flag == true ) - { - if ( !(pPlayers[j + 1]->pConditions[Condition_Paralyzed] | pPlayers[j + 1]->pConditions[Condition_Unconcious] - | pPlayers[j + 1]->pConditions[Condition_Dead] | pPlayers[j + 1]->pConditions[Condition_Pertified] | pPlayers[j + 1]->pConditions[Condition_Eradicated]) ) - Victims_list[v2++] = j; - } - } - } - } - if ( v2 ) - return Victims_list[rand() % v2]; - } - for ( uint i = 0; i < 4; ++i ) - { - if ( !(pPlayers[i + 1]->pConditions[Condition_Paralyzed] | pPlayers[i + 1]->pConditions[Condition_Unconcious] - | pPlayers[i + 1]->pConditions[Condition_Dead] | pPlayers[i + 1]->pConditions[Condition_Pertified] | pPlayers[i + 1]->pConditions[Condition_Eradicated]) ) - Victims_list[v2++] = i; - } - if ( v2 ) - return Victims_list[rand() % v2]; - else - return 0; -} -//----- (00427546) -------------------------------------------------------- -int stru319::_427546(int a2) -{ - int result; // eax@2 - - if (a2 >= 0) - { - if (a2 >= 1) - result = (a2 >= 2) + 2; - else - result = 1; - } - else - { - result = 0; - } - return result; -} -//----- (0042F184) -------------------------------------------------------- -int stru319::FindClosestActor(int pick_depth, int a3, int a4) -{ - int v4; // edi@1 - stru319 *v5; // esi@1 - int v6; // eax@2 - int v7; // eax@4 - // int result; // eax@5 - // int *v9; // edx@8 - // signed int v10; // ebx@10 - // int v11; // edi@11 - //Actor *v12; // esi@12 - //unsigned __int16 v13; // ax@12 - // int v14; // eax@22 - //char v15; // zf@30 - // int v16; // esi@32 - // int v17; // ecx@34 - // stru319 *v18; // eax@39 - // int v19; // edx@39 - // int v20; // ecx@41 - // unsigned __int16 v21; // ax@42 - // unsigned int v22; // [sp+8h] [bp-24h]@11 - //unsigned int v23; // [sp+Ch] [bp-20h]@7 - stru319 *v24; // [sp+10h] [bp-1Ch]@1 - // unsigned int v25; // [sp+14h] [bp-18h]@8 - // int *v26; // [sp+18h] [bp-14h]@8 - // int v27; // [sp+1Ch] [bp-10h]@10 - // int *v28; // [sp+20h] [bp-Ch]@10 - //unsigned int v29; // [sp+24h] [bp-8h]@7 - // int v30; // [sp+28h] [bp-4h]@6 - // int i; // [sp+38h] [bp+Ch]@33 - // signed int v32; // [sp+3Ch] [bp+10h]@32 - - v4 = 0; - v5 = this; - v24 = this; - //if ( pRenderer->pRenderD3D ) - { - v6 = a3 != 0; - if (a4) - LOBYTE(v6) = v6 | 8; - v7 = pGame->pVisInstance->PickClosestActor(OBJECT_Actor, pick_depth, v6, 657456, -1); - if (v7 != -1) - return (unsigned __int16)v7; - else return 0; - } - /*else // software impl - { - v30 = 0; - if ( pRenderer->pActiveZBuffer ) - { - if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y ) - { - v9 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y]; - v26 = &pRenderer->pActiveZBuffer[viewparams->uScreen_topL_X + 640 * viewparams->uScreen_topL_Y]; - for ( v25 = viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y; v25; --v25 ) - { - if ( (signed int)viewparams->uScreen_topL_X < (signed int)viewparams->uScreen_BttmR_X ) - { - v28 = v9; - v10 = v4; - for ( v27 = viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X; v27; --v27 ) - { - v22 = *v28; - v11 = *v28 & 0xFFFF; - if (PID_TYPE(v11) == OBJECT_Actor) - { - if ( pActors[PID_ID(v11)].uAIState != Dead ) - { - if ( pActors[PID_ID(v11)].uAIState != Dying && pActors[PID_ID(v11)].uAIState != Removed - && pActors[PID_ID(v11)].uAIState != Summoned && pActors[PID_ID(v11)].uAIState != Disabled - && (!a3 || pActors[PID_ID(v11)].GetActorsRelation(0)) ) - { - if ( (!a4 || MonsterStats::BelongsToSupertype(pActors[PID_ID(v11)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD)) - && v22 <= pick_depth << 16 ) - { - v14 = 0; - if ( v10 > 0 ) - { - for ( v14; v14 < v30; ++v14 ) - { - if ( dword_50BDA0[v14] == v11 ) - break; - } - } - if ( v14 == v30 && v10 < 100 ) - { - ++v30; - dword_50BC10[v10] = v22; - dword_50BDA0[v10] = v11; - ++v10; - } - } - } - } - } - ++v28; - } - v4 = v30; - v5 = v24; - } - v9 = v26 + 640; - v26 += 640; - } - } - if ( v4 > 0 ) - { - v16 = (int)dword_50BC10.data(); - for ( v32 = 1; v32 - 1 < v4; ++v32 ) - { - for ( i = v32; i < v4; ++i ) - { - v17 = dword_50BC10[i]; - if ( dword_50BC10[i] < *(int *)v16 ) - { - dword_50BC10[i] = *(int *)v16; - *(int *)v16 = v17; - } - } - v16 += 4; - } - v5 = v24; - if ( v4 > 0 ) - { - v18 = v24; - for ( v19 = v4; v19; --v19 ) - { - *(int *)&v18->field_0 = (*(int *)&v18[(char *)dword_50BC10.data() - (char *)v24].field_0 >> 3) & 0x1FFF; - v18 += 4; - } - } - } - v20 = 0; - for ( *(int *)&v5[2000].field_0 = v4; v20 < v4; ++v20 ) - { - v21 = pActors[*(int *)&v5[4 * v20].field_0].uAIState; - if ( v21 != 4 && v21 != 5 ) - break; - } - if ( v20 != v4 ) - { - result = 8 * *(int *)&v5[4 * v20].field_0; - LOBYTE(result) = result | 3; - return result; - } - } - } - return 0;*/ -} - -//----- (0042F4DA) -------------------------------------------------------- -bool CheckActors_proximity() -{ - signed int distance; // edi@1 - int for_x; // ebx@5 - int for_y; // [sp+Ch] [bp-10h]@5 - int for_z; // [sp+10h] [bp-Ch]@5 - - - distance = 5120; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - distance = 2560; - - if ( (signed int)uNumActors <= 0 ) - return false; - for ( uint i = 0; i < (signed int)uNumActors; ++i ) - { - for_x = abs(pActors[i].vInitialPosition.x - pParty->vPosition.x); - for_y = abs(pActors[i].vInitialPosition.y - pParty->vPosition.y); - for_z = abs(pActors[i].vInitialPosition.z - pParty->vPosition.z); - if ( int_get_vector_length(for_x, for_y, for_z) < distance ) - { - if ( pActors[i].uAIState != Dead ) - { - if ( pActors[i].uAIState != Dying && pActors[i].uAIState != Removed - && pActors[i].uAIState != Disabled && pActors[i].uAIState != Summoned - && (pActors[i].ActorEnemy() || pActors[i].GetActorsRelation(0) ) ) - return true; - } - } - } - return false; -} - - -//----- (00426A5A) -------------------------------------------------------- -void Actor::LootActor() -{ - signed int v2; // edi@1 - unsigned __int8 v7; // al@30 - char *v9; // [sp-4h] [bp-3Ch]@10 - char *v10; // [sp-4h] [bp-3Ch]@31 - char *v11; // [sp-4h] [bp-3Ch]@38 - ItemGen Dst; // [sp+Ch] [bp-2Ch]@1 - bool itemFound; // [sp+30h] [bp-8h]@1 - int v14; // [sp+34h] [bp-4h]@1 - - pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); - Dst.Reset(); - v2 = 0; - itemFound = false; - v14 = 0; - if ( !ActorHasItem() ) - { - for (uchar i = 0; i < this->pMonsterInfo.uTreasureDiceRolls; i++ ) - v14 += rand() % this->pMonsterInfo.uTreasureDiceSides + 1; - if ( v14 ) - { - pParty->PartyFindsGold(v14, 0); - viewparams->bRedrawGameUI = 1; - } - } - else - { - if ( this->ActorHasItems[3].uItemID != 0 && this->ActorHasItems[3].GetItemEquipType() == EQUIP_GOLD ) - { - v14 = this->ActorHasItems[3].uSpecEnchantmentType; - this->ActorHasItems[3].Reset(); - if ( v14 ) - { - pParty->PartyFindsGold(v14, 0); - viewparams->bRedrawGameUI = 1; - } - } - } - if ( this->uCarriedItemID ) - { - Dst.Reset(); - Dst.uItemID = this->uCarriedItemID; - v9 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName; - if ( v14 ) - sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, v9); - else - sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v9); - ShowStatusBarString(pTmpBuf2.data(), 2); - if ( Dst.GetItemEquipType() == 12 ) - { - Dst.uNumCharges = rand() % 6 + Dst.GetDamageMod() + 1; - Dst.uMaxCharges = Dst.uNumCharges; - } - if ( pItemsTable->pItems[Dst.uItemID].uEquipType == 14 && Dst.uItemID != 220 ) - Dst.uEnchantmentType = 2 * rand() % 4 + 2; - pItemsTable->SetSpecialBonus(&Dst); - if ( !pParty->AddItemToParty(&Dst) ) - pParty->SetHoldingItem(&Dst); - this->uCarriedItemID = 0; - if ( this->ActorHasItems[0].uItemID ) - { - if ( !pParty->AddItemToParty(this->ActorHasItems) ) - { - pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); - pParty->SetHoldingItem(this->ActorHasItems); - } - this->ActorHasItems[0].Reset(); - } - if ( this->ActorHasItems[1].uItemID ) - { - if ( !pParty->AddItemToParty(&this->ActorHasItems[1]) ) - { - pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); - pParty->SetHoldingItem(&this->ActorHasItems[1]); - } - this->ActorHasItems[1].Reset(); - } - this->Remove(); - return; - } - if ( this->ActorHasItem() ) - { - if ( this->ActorHasItems[3].uItemID ) - { - memcpy(&Dst, &this->ActorHasItems[3], sizeof(Dst)); - this->ActorHasItems[3].Reset(); - //v11 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName; - if ( v14 ) - sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, pItemsTable->pItems[Dst.uItemID].pUnidentifiedName); - else - sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[Dst.uItemID].pUnidentifiedName); - ShowStatusBarString(pTmpBuf2.data(), 2); - if ( !pParty->AddItemToParty(&Dst) ) - pParty->SetHoldingItem(&Dst); - itemFound = true; - } - } - else - { - if ( rand() % 100 < this->pMonsterInfo.uTreasureDropChance && (v7 = this->pMonsterInfo.uTreasureLevel) != 0 ) - { - pItemsTable->GenerateItem(v7, this->pMonsterInfo.uTreasureType, &Dst); - v10 = pItemsTable->pItems[Dst.uItemID].pUnidentifiedName; - if ( v14 ) - sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[490], v14, v10);//Âû íàøëè ^I[%d] çîëîò^L[îé;ûõ;ûõ] è ïðåäìåò (%s)! - else - sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v10);//Âû íàøëè ^Pv[%s]! - ShowStatusBarString(pTmpBuf2.data(), 2); - if ( !pParty->AddItemToParty(&Dst) ) - pParty->SetHoldingItem(&Dst); - itemFound = true; - } - } - if ( this->ActorHasItems[0].uItemID ) - { - if ( !pParty->AddItemToParty(this->ActorHasItems) ) - { - pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); - pParty->SetHoldingItem(this->ActorHasItems); - itemFound = true; - } - this->ActorHasItems[0].Reset(); - } - if ( this->ActorHasItems[1].uItemID ) - { - if ( !pParty->AddItemToParty(&this->ActorHasItems[1]) ) - { - pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); - pParty->SetHoldingItem(&this->ActorHasItems[1]); - itemFound = true; - } - this->ActorHasItems[1].Reset(); - } - if ( !itemFound || rand() % 100 < 90 )//for repeatedly get gold and item - this->Remove(); -} - - -//----- (00427102) -------------------------------------------------------- -bool Actor::_427102_IsOkToCastSpell( signed int a2 ) -{ - switch(a2) - { - case SPELL_BODY_POWER_CURE: - { - if ( this->sCurrentHP >= (signed int)this->pMonsterInfo.uHP ) - return false; - return true; - } - case SPELL_LIGHT_DISPEL_MAGIC: - { - for (int i = 0; i < 20; i++) - { - if (pParty->pPartyBuffs[i].uExpireTime > 0) - return true; - } - for ( int i = 1; i <= 4; i++ ) - { - for ( int j = 0; j < 22; j++ ) - { - if (pPlayers[i]->pPlayerBuffs[j].uExpireTime > 0) - return true; - } - } - return false; - } - case SPELL_LIGHT_DAY_OF_PROTECTION: - { - return this->pActorBuffs[ACTOR_BUFF_DAY_OF_PROTECTION].uExpireTime <= 0; - break; - } - case SPELL_LIGHT_HOUR_OF_POWER: - { - return this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime <= 0; - break; - } - case SPELL_DARK_PAIN_REFLECTION: - { - return this->pActorBuffs[ACTOR_BUFF_PAIN_REFLECTION].uExpireTime <= 0; - break; - } - case SPELL_BODY_HAMMERHANDS: - { - return this->pActorBuffs[ACTOR_BUFF_PAIN_HAMMERHANDS].uExpireTime <= 0; - break; - } - case SPELL_FIRE_HASTE: - { - return this->pActorBuffs[ACTOR_BUFF_HASTE].uExpireTime <= 0; - break; - } - case SPELL_AIR_SHIELD: - { - return this->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime <= 0; - break; - } - case SPELL_EARTH_STONESKIN: - { - return this->pActorBuffs[ACTOR_BUFF_STONESKIN].uExpireTime <= 0; - break; - } - case SPELL_SPIRIT_BLESS: - { - return this->pActorBuffs[ACTOR_BUFF_BLESS].uExpireTime <= 0; - break; - } - case SPELL_SPIRIT_FATE: - { - return this->pActorBuffs[ACTOR_BUFF_FATE].uExpireTime <= 0; - break; - } - case SPELL_SPIRIT_HEROISM: - { - return this->pActorBuffs[ACTOR_BUFF_HEROISM].uExpireTime <= 0; - break; - } - default: - return true; - } -} - - -//----- (0042704B) -------------------------------------------------------- -ABILITY_INDEX Actor::special_ability_use_check( int a2 ) -{ - signed int okToCastSpell1; // ebx@5 - signed int okToCastSpell2; // edi@5 - - if ( this->pMonsterInfo.uSpecialAbilityType == 2 - && this->pMonsterInfo.uSpecialAbilityDamageDiceBonus < 3 - && rand() % 100 < 5 ) - this->SummonMinion(a2); - okToCastSpell1 = this->_427102_IsOkToCastSpell(this->pMonsterInfo.uSpell1ID); - okToCastSpell2 = this->_427102_IsOkToCastSpell(this->pMonsterInfo.uSpell2ID); - if ( okToCastSpell1 && this->pMonsterInfo.uSpell1UseChance && rand() % 100 < this->pMonsterInfo.uSpell1UseChance ) - return ABILITY_SPELL1; - if ( okToCastSpell2 && this->pMonsterInfo.uSpell2UseChance && rand() % 100 < this->pMonsterInfo.uSpell2UseChance ) - return ABILITY_SPELL2; - if (this->pMonsterInfo.uAttack2Chance && rand() % 100 < this->pMonsterInfo.uAttack2Chance) - return ABILITY_ATTACK2; - return ABILITY_ATTACK1; -} - - - -//----- (004273BB) -------------------------------------------------------- -bool Actor::_4273BB_DoesHitOtherActor( Actor *defender, int a3, int a4 ) -{ - signed int v6; // ebx@1 - signed int v7; // esi@1 - int armorSum; // ebx@10 - signed int a2a; // [sp+18h] [bp+Ch]@1 - - v6 = defender->pMonsterInfo.uAC; - v7 = 0; - a2a = 0; - if ( defender->pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC].uExpireTime > 0 ) - v6 /= 2; - if ( defender->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) - v7 = defender->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; - if ( defender->pActorBuffs[ACTOR_BUFF_STONESKIN].uExpireTime > 0 && defender->pActorBuffs[ACTOR_BUFF_STONESKIN].uPower > v7 ) - v7 = defender->pActorBuffs[ACTOR_BUFF_STONESKIN].uPower; - armorSum = v7 + v6; - if ( this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) - a2a = this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; - if ( this->pActorBuffs[ACTOR_BUFF_BLESS].uExpireTime > 0 && this->pActorBuffs[ACTOR_BUFF_BLESS].uPower > a2a ) - a2a = this->pActorBuffs[ACTOR_BUFF_BLESS].uPower; - if ( this->pActorBuffs[ACTOR_BUFF_FATE].uExpireTime > 0 ) - { - a2a += this->pActorBuffs[ACTOR_BUFF_FATE].uPower; - this->pActorBuffs[ACTOR_BUFF_FATE].Reset(); - } - return rand() % (armorSum + 2 * this->pMonsterInfo.uLevel + 10) + a2a + 1 > armorSum + 5; -} - -//----- (004274AD) -------------------------------------------------------- -bool Actor::ActorHitOrMiss(Player *pPlayer) -{ - signed int v3; // edi@1 - signed int v4; // esi@8 - int v5; // esi@8 - - v3 = 0; - if ( this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) - v3 = this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; - if ( this->pActorBuffs[ACTOR_BUFF_BLESS].uExpireTime > 0 && this->pActorBuffs[ACTOR_BUFF_BLESS].uPower > v3 ) - v3 = this->pActorBuffs[ACTOR_BUFF_BLESS].uPower; - if ( this->pActorBuffs[ACTOR_BUFF_FATE].uExpireTime > 0 ) - { - v3 += this->pActorBuffs[ACTOR_BUFF_FATE].uPower; - this->pActorBuffs[ACTOR_BUFF_FATE].Reset(); - } - v4 = pPlayer->GetActualAC() + 2 * this->pMonsterInfo.uLevel + 10; - v5 = rand() % v4 + 1; - return (v3 + v5 > pPlayer->GetActualAC() + 5); -} - - -//----- (0042756B) -------------------------------------------------------- -int Actor::CalcMagicalDamageToActor(DAMAGE_TYPE dmgType, signed int incomingDmg) -{ - int v4; // edx@1 - int v5; // ecx@1 - signed int v6; // eax@4 - signed int result; // eax@17 - signed int v8; // esi@18 - - v4 = 0; - v5 = 0; - if ( this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uExpireTime > 0 ) - v5 = this->pActorBuffs[ACTOR_BUFF_HOUR_OF_POWER].uPower; - switch ( dmgType ) - { - case DMGT_FIRE: - v6 = this->pMonsterInfo.uResFire; - v4 = v5; - break; - case DMGT_ELECTR: - v6 = this->pMonsterInfo.uResAir; - v4 = v5; - break; - case DMGT_COLD: - v6 = this->pMonsterInfo.uResWater; - v4 = v5; - break; - case DMGT_EARTH: - v6 = this->pMonsterInfo.uResEarth; - v4 = v5; - break; - case DMGT_PHISYCAL: - v6 = this->pMonsterInfo.uResPhysical; - break; - case DMGT_SPIRIT: - v6 = this->pMonsterInfo.uResSpirit; - break; - case DMGT_MIND: - v6 = this->pMonsterInfo.uResMind; - v4 = v5; - break; - case DMGT_BODY: - v6 = this->pMonsterInfo.uResBody; - v4 = v5; - break; - case DMGT_LIGHT: - v6 = this->pMonsterInfo.uResLight; - break; - case DMGT_DARK: - v6 = this->pMonsterInfo.uResDark; - break; - default: - v6 = 0; - break; - } - if ( v6 < 200 ) - { - v8 = v4 + v6 + 30; - for (int i = 0; i < 4; i++) - { - if ( rand() % v8 < 30 ) - break; - incomingDmg /= 2; - } - result = incomingDmg; - } - else - result = 0; - return result; -} - -//----- (00427662) -------------------------------------------------------- -bool Actor::DoesDmgTypeDoDamage(DAMAGE_TYPE uType) -{ - signed int resist; // esi@2 - bool result; // eax@13 - - switch ( uType ) - { - case 0: - resist = this->pMonsterInfo.uResFire; - break; - case 1: - resist = this->pMonsterInfo.uResAir; - break; - case 2: - resist = this->pMonsterInfo.uResWater; - break; - case 3: - resist = this->pMonsterInfo.uResEarth; - break; - case 4: - resist = this->pMonsterInfo.uResPhysical; - break; - case 6: - resist = this->pMonsterInfo.uResSpirit; - break; - case 7: - resist = this->pMonsterInfo.uResMind; - case 8: - resist = this->pMonsterInfo.uResBody; - break; - case 9: - resist = this->pMonsterInfo.uResLight; - break; - case 10: - resist = this->pMonsterInfo.uResDark; - break; - default: - return 1; - } - if ( resist < 200 ) - result = rand() % ((this->pMonsterInfo.uLevel >> 2) + resist + 30) < 30; - else - result = 0; - return result; -} - -//----- (00448A98) -------------------------------------------------------- -void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle) -{ - if ( uGroupID ) - { - if ( bToggle ) - { - for ( uint i = 0; i < (unsigned int)uNumActors; ++i ) - { - if ( pActors[i].uGroup == uGroupID ) - { - pActors[i].uAttributes |= uFlag; - if ( uFlag == 0x10000 ) - { - pActors[i].uAIState = Disabled; - pActors[i].UpdateAnimation(); - } - } - } - } - else - { - for ( uint i = 0; i < (unsigned int)uNumActors; ++i ) - { - if ( pActors[i].uGroup == uGroupID ) - { - if ( uFlag == 0x10000 ) - { - if ( pActors[i].uAIState != Dead ) - { - if ( pActors[i].uAIState != 4 && pActors[i].uAIState != 11 ) - pActors[i].uAIState = Standing; - } - } - LODWORD(pActors[i].uAttributes) &= ~uFlag; - } - } - } - } -} - -//----- (004014E6) -------------------------------------------------------- -void Actor::MakeActorAIList_ODM() -{ - int v1; // eax@4 - unsigned int v7; // ST20_4@10 - int distance; // edi@10 - int v10; // ebx@14 - int v21; // [sp+Ch] [bp-14h]@4 - int v22; // [sp+10h] [bp-10h]@4 - - pParty->uFlags &= 0xFFFFFFCF;//~0x30 - - ai_arrays_size = 0; - for (uint i = 0; i < uNumActors; ++i) - { - Actor* actor = &pActors[i]; - - actor->ResetAlive();//~0x400 - if (!actor->CanAct()) - { - actor->ResetActive(); - continue; - } - - v22 = abs(pParty->vPosition.z - actor->vPosition.z); - v21 = abs(pParty->vPosition.y - actor->vPosition.y); - v1 = abs(pParty->vPosition.x - actor->vPosition.x); - v7 = int_get_vector_length(v22, v21, v1); - distance = v7 - actor->uActorRadius; - if ( distance < 0 ) - distance = 0; - - if (distance < 5632) - { - actor->ResetHostile(); - if ( actor->ActorEnemy() || actor->GetActorsRelation(0) ) - { - //v11 = (pParty->uFlags & 0x10) == 0; - actor->uAttributes |= ACTOR_HOSTILE; - if (distance < 5120 ) - pParty->SetYellowAlert(); - if (distance < 307) - pParty->SetRedAlert(); - } - actor->uAttributes |= ACTOR_ACTIVE; - ai_near_actors_distances[ai_arrays_size] = distance; - ai_near_actors_ids[ai_arrays_size++] = i; - } - else - actor->ResetActive(); - } - - /* - result = v27; - if ( v27 > 0 ) - { - v14 = 0; - v15 = 1; - v26 = 1; - do - { - while ( 1 ) - { - v24 = v15; - if ( v15 >= result ) - break; - v16 = ai_near_actors_distances[v14]; - if ( v16 > ai_near_actors_distances[v15] ) - { - v17 = &ai_near_actors_ids[v15]; - v18 = ai_near_actors_ids[v14]; - ai_near_actors_ids[v14] = *v17; - *v17 = v18; - v15 = v24; - ai_near_actors_distances[v14] = ai_near_actors_distances[v24]; - ai_near_actors_distances[v24] = v16; - } - result = v27; - ++v15; - } - ++v14; - v15 = v26 + 1; - v26 = v15; - } - while ( v15 - 1 < result ); - }*/ - - for (uint i = 0; i < ai_arrays_size; ++i) - for (uint j = 0; j < i; ++j) - if (ai_near_actors_distances[j] > ai_near_actors_distances[i]) - { - int tmp = ai_near_actors_distances[j]; - ai_near_actors_distances[j] = ai_near_actors_distances[i]; - ai_near_actors_distances[i] = tmp; - - tmp = ai_near_actors_ids[j]; - ai_near_actors_ids[j] = ai_near_actors_ids[i]; - ai_near_actors_ids[i] = tmp; - } - - - if (ai_arrays_size > 30) - ai_arrays_size = 30; - - for (uint i = 0; i < ai_arrays_size; ++i) - pActors[ai_near_actors_ids[i]].uAttributes |= ACTOR_ALIVE;//0x400 -} - -//----- (004016FA) -------------------------------------------------------- -int Actor::MakeActorAIList_BLV() -{ - int v1; // eax@4 - int distance; // edi@10 - int v13; // edx@24 - int v15; // ebx@26 - unsigned int v17; // esi@27 - int v18; // ecx@31 - signed int v19; // edi@31 - signed int v25; // eax@40 - int j; // edi@45 - int v30; // eax@48 - int v37; // [sp+Ch] [bp-18h]@1 - int v38; // [sp+10h] [bp-14h]@4 - int v39; // [sp+14h] [bp-10h]@4 - int i; // [sp+18h] [bp-Ch]@31 - uint v45; // [sp+20h] [bp-4h]@1 - - // __debugbreak(); // refactor for blv ai - pParty->uFlags &= 0xFFFFFFCF;//~0x30 - v37 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); - v45 = 0; - for ( uint i = 0; i < (signed int)uNumActors; ++i ) - { - pActors[i].ResetAlive();//~0x0400 - if ( !pActors[i].CanAct() ) - { - pActors[i].ResetActive(); - continue; - } - v1 = abs(pParty->vPosition.x - pActors[i].vPosition.x); - v38 = abs(pParty->vPosition.y - pActors[i].vPosition.y); - v39 = abs(pParty->vPosition.z - pActors[i].vPosition.z); - - distance = int_get_vector_length(v39, v38, v1) - pActors[i].uActorRadius; - if ( distance < 0 ) - distance = 0; - if ( distance < 10240 ) - { - pActors[i].ResetHostile();//~0x01000000 - if ( pActors[i].ActorEnemy() || pActors[i].GetActorsRelation(0) ) - { - pActors[i].uAttributes |= ACTOR_HOSTILE; - if ( !(pParty->uFlags & 0x10) && (double)distance < 307.2 ) - pParty->SetRedAlert(); - if ( !(pParty->uFlags & 0x20) && distance < 5120 ) - pParty->SetYellowAlert(); - } - ai_near_actors_distances[v45] = distance; - ai_near_actors_ids[v45] = i; - v45++; - } - else - pActors[i].ResetActive(); - } - v13 = 0; - if ( v45 > 0 ) - { - for ( uint i = 1; i < v45; i++ ) - { - for ( uint j = 1; j < v45; ++j ) - { - v15 = ai_near_actors_distances[v13]; - if ( ai_near_actors_distances[v13] > ai_near_actors_distances[j] ) - { - v17 = ai_near_actors_ids[v13]; - ai_near_actors_ids[v13] = ai_near_actors_ids[j]; - ai_near_actors_ids[j] = v17; - ai_near_actors_distances[v13] = ai_near_actors_distances[j]; - ai_near_actors_distances[j] = v15; - } - } - ++v13; - } - } - v18 = 0; - v19 = 0; - for ( i = 0; i < v45; i++ ) - { - if ( pActors[ai_near_actors_ids[i]].ActorNearby() - || sub_4070EF_prolly_detect_player(PID(OBJECT_Actor,ai_near_actors_ids[i]), 4) ) - { - pActors[ai_near_actors_ids[i]].uAttributes |= ACTOR_NEARBY; - ai_array_4F6638_actor_ids[v19] = ai_near_actors_ids[i]; - ai_array_4F5E68[v19++] = ai_near_actors_distances[i]; - if ( v19 >= 30 ) - break; - } - } - ai_arrays_size = v19; - if ( (signed int)uNumActors > 0 ) - { - for ( uint i = 0; i < (signed int)uNumActors; ++i ) - { - if ( pActors[i].CanAct() && pActors[i].uSectorID == v37 ) - { - v25 = 0; - if ( v19 <= 0 ) - { - pActors[i].uAttributes |= ACTOR_ACTIVE; - ai_array_4F6638_actor_ids[ai_arrays_size++] = i; - } - else - { - while ( ai_array_4F6638_actor_ids[v25] != i ) - { - ++v25; - if ( v25 >= v19 ) - { - pActors[i].uAttributes |= ACTOR_ACTIVE; - ai_array_4F6638_actor_ids[ai_arrays_size++] = i; - break; - } - } - } - } - } - } - for ( j = 0; j < v45; ++j ) - { - if ( pActors[ai_near_actors_ids[j]].uAttributes & 0xC000 && pActors[ai_near_actors_ids[j]].CanAct() ) - { - v30 = 0; - if ( ai_arrays_size <= 0 ) - ai_array_4F6638_actor_ids[ai_arrays_size++] = ai_near_actors_ids[j]; - else - { - while ( ai_array_4F6638_actor_ids[v30] != ai_near_actors_ids[j] ) - { - ++v30; - if ( v30 >= ai_arrays_size ) - { - ai_array_4F6638_actor_ids[ai_arrays_size++] = ai_near_actors_ids[j]; - break; - } - } - } - } - } - if ( ai_arrays_size > 30 ) - ai_arrays_size = 30; - memcpy(ai_near_actors_ids.data(), ai_array_4F6638_actor_ids.data(), 4 * ai_arrays_size); - memcpy(ai_near_actors_distances.data(), ai_array_4F5E68.data(), 4 * ai_arrays_size); - for ( uint i = 0; i < ai_arrays_size; i++ ) - pActors[ai_near_actors_ids[i]].uAttributes |= ACTOR_ALIVE;//0x400 - return ai_arrays_size; -} - - -//----- (004070EF) -------------------------------------------------------- -bool __fastcall sub_4070EF_prolly_detect_player(unsigned int uObjID, unsigned int uObj2ID) -{ - signed int v2; // eax@1 - int obj1_sector; // eax@4 - float v8; // ST24_4@5 - signed int v12; // eax@7 - int obj2_z; // edi@11 - int obj2_x; // esi@11 - int obj2_sector; // eax@13 - float v20; // ST24_4@14 - int dist_x; // ebx@16 - signed int dist_3d; // ecx@16 - int v25; // eax@18 - BLVFace *v29; // ebx@32 - Vec3_short_ *v30; // esi@32 - int v31; // eax@32 - int v32; // ST50_4@44 - int v33; // ST54_4@44 - int v34; // eax@44 - signed int v38; // esi@45 - __int16 next_sector; // bx@58 - int v47; // [sp+18h] [bp-50h]@20 - int v48; // [sp+1Ch] [bp-4Ch]@20 - int v49; // [sp+20h] [bp-48h]@20 - int dist_z; // [sp+24h] [bp-44h]@16 - signed int higher_z; // [sp+24h] [bp-44h]@27 - signed int lower_z; // [sp+28h] [bp-40h]@26 - signed int higher_y; // [sp+2Ch] [bp-3Ch]@23 - signed int lower_y; // [sp+30h] [bp-38h]@22 - signed int higher_x; // [sp+34h] [bp-34h]@21 - signed int lower_x; // [sp+38h] [bp-30h]@20 - signed int sectors_visited; // [sp+3Ch] [bp-2Ch]@28 - int v58; // [sp+44h] [bp-24h]@50 - int v59; // [sp+48h] [bp-20h]@44 - int obj2_y; // [sp+50h] [bp-18h]@11 - int obj1_x; // [sp+58h] [bp-10h]@4 - int obj1_y; // [sp+5Ch] [bp-Ch]@4 - int obj1_z; // [sp+60h] [bp-8h]@4 - int current_sector; // [sp+64h] [bp-4h]@7 - int dist_y; - int v70; - - v2 = PID_ID(uObjID); - switch( PID_TYPE(uObjID) ) - { - case OBJECT_Decoration: - obj1_x = pLevelDecorations[v2].vPosition.x; - obj1_y = pLevelDecorations[v2].vPosition.y; - obj1_z = pLevelDecorations[v2].vPosition.z; - obj1_sector = pIndoor->GetSector(obj1_x, obj1_y, obj1_z); - break; - case OBJECT_Actor: - obj1_x = pActors[v2].vPosition.x; - obj1_y = pActors[v2].vPosition.y; - v8 = (double)pActors[v2].uActorHeight * 0.69999999; - //v9 = v8 + 6.7553994e15; - //obj1_z = LODWORD(v9) + pActors[v2].vPosition.z; - obj1_z = (int)v8 + pActors[v2].vPosition.z; - obj1_sector = pActors[v2].uSectorID; - break; - case OBJECT_Item: - obj1_x = pSpriteObjects[v2].vPosition.x; - obj1_y = pSpriteObjects[v2].vPosition.y; - obj1_z = pSpriteObjects[v2].vPosition.z; - obj1_sector = pSpriteObjects[v2].uSectorID; - break; - default: - return 0; - } - v12 = PID_ID(uObj2ID); - switch( PID_TYPE(uObj2ID) ) - { - case OBJECT_Decoration: - obj2_z = pLevelDecorations[v12].vPosition.z; - obj2_x = pLevelDecorations[v12].vPosition.x; - obj2_y = pLevelDecorations[v12].vPosition.y; - obj2_sector = pIndoor->GetSector(obj2_x, obj2_y, obj2_z); - break; - case OBJECT_Player: - obj2_x = pParty->vPosition.x; - obj2_z = pParty->sEyelevel + pParty->vPosition.z; - obj2_y = pParty->vPosition.y; - obj2_sector = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); - break; - case OBJECT_Actor: - 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; - break; - case OBJECT_Item: - obj2_x = pSpriteObjects[v12].vPosition.x; - obj2_z = pSpriteObjects[v12].vPosition.z; - obj2_y = pSpriteObjects[v12].vPosition.y; - obj2_sector = pSpriteObjects[v12].uSectorID; - break; - default: - return 0; - } - dist_x = obj2_x - obj1_x; - dist_z = obj2_z - obj1_z; - dist_y = obj2_y - obj1_y; - dist_3d = integer_sqrt(dist_x * dist_x + dist_y * dist_y + dist_z * dist_z); - //range check - if ( dist_3d > 5120 ) - return 0; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - return 1; - v25 = 65536; - if ( dist_3d ) - v25 = 65536 / dist_3d; - v49 = dist_x * v25; - v47 = dist_z * v25; - v48 = dist_y * v25; - if ( obj1_x < obj2_x ) - { - lower_x = obj1_x; - higher_x = obj2_x; - } - else - { - lower_x = obj2_x; - higher_x = obj1_x; - } - if ( obj1_y < obj2_y ) - { - lower_y = obj1_y; - higher_y = obj2_y; - } - else - { - lower_y = obj2_y; - higher_y = obj1_y; - } - if ( obj1_z < obj2_z ) - { - lower_z = obj1_z; - higher_z = obj2_z; - } - else - { - lower_z = obj2_z; - higher_z = obj1_z; - } - sectors_visited = 0; - //monster in same sector with player - if ( obj1_sector == obj2_sector ) - return 1; - //search starts from monster - current_sector = obj1_sector; - for( int current_portal = 0; current_portal < pIndoor->pSectors[current_sector].uNumPortals; current_portal++ ) - { - v29 = &pIndoor->pFaces[pIndoor->pSectors[current_sector].pPortals[current_portal]]; - v30 = &pIndoor->pVertices[*v29->pVertexIDs]; - v31 = v29->pFacePlane_old.vNormal.z * (v30->z - obj1_z) - + v29->pFacePlane_old.vNormal.y * (v30->y - obj1_y) - + v29->pFacePlane_old.vNormal.x * (v30->x - obj1_x); - - if ( current_sector != v29->uSectorID ) - v31 = -v31; - - if ( v31 >= 0 && v30->x != obj1_x && v30->y != obj1_y && v30->z != obj1_z) - continue; - - if( lower_x > v29->pBounding.x2 - || higher_x < v29->pBounding.x1 - || lower_y > v29->pBounding.y2 - || higher_y < v29->pBounding.y1 - || lower_z > v29->pBounding.z2 - || higher_z < v29->pBounding.z1 ) - { - continue; - } - - v32 = fixpoint_mul(v29->pFacePlane_old.vNormal.x,v49); - v34 = fixpoint_mul(v29->pFacePlane_old.vNormal.y,v48); - v33 = fixpoint_mul(v29->pFacePlane_old.vNormal.z,v47); - - v59 = v32 + v33 + v34; - if ( v59 ) - { - v70 = v29->pFacePlane_old.dist - + obj1_z * v29->pFacePlane_old.vNormal.z - + obj1_x * v29->pFacePlane_old.vNormal.x - + obj1_y * v29->pFacePlane_old.vNormal.y; - v38 = -v70; - - // if ( v59 <= 0 ^ v70 <= 0 ) - - /* TEMPORARY - if ( v59 <= 0 && v70 <= 0 ) - { - continue; - } - if ( !(v59 <= 0 && v70 <= 0) ) - { - continue; - } - */ - - if( abs(v38) >> 14 > abs(v59) ) - continue; - - v58 = fixpoint_div(v38,v59); - - if( v58 < 0 ) - continue; - - if(!sub_4075DB(obj1_x + ((fixpoint_mul(v49,v58) + 32768) >> 16), obj1_y + ((fixpoint_mul(v48,v58) + 32768) >> 16), - obj1_z + ((fixpoint_mul(v47,v58) + 32768) >> 16), v29) ) - { - continue; - } - - //if there is no next sector turn back - if ( v29->uSectorID == current_sector ) - next_sector = v29->uBackSectorID; - else - next_sector = v29->uSectorID; - - //no more portals, quit - if ( next_sector == current_sector ) - break; - - ++sectors_visited; - current_sector = next_sector; - - //found player, quit - if ( next_sector == obj2_sector ) - return 1; - - current_sector = next_sector; - - //did we hit limit for portals? - //does the next room have portals? - if ( sectors_visited < 30 && pIndoor->pSectors[current_sector].uNumPortals > 0) - { - current_portal=-1; - continue; - } - else - break; - } - } - //did we stop in the sector where player is? - if ( current_sector != obj2_sector ) - return 0; - return 1; -} - - -//----- (00450B0A) -------------------------------------------------------- -bool __fastcall SpawnActor(unsigned int uMonsterID) -{ - unsigned int v1; // ebx@1 - bool result; // eax@2 - unsigned int v6; // ecx@5 - Actor actor; // [sp+4h] [bp-350h]@5 - Vec3_int_ pOut; // [sp+348h] [bp-Ch]@5 - - v1 = uMonsterID; - if ( uNumActors == 499 ) - result = 0; - else - { - if ( (signed int)uMonsterID >= (signed int)pMonsterList->uNumMonsters ) - v1 = 0; - memset(&actor, 0, sizeof(Actor)); - strcpy(actor.pActorName, pMonsterStats->pInfos[v1 + 1].pName); - actor.sCurrentHP = LOWORD(pMonsterStats->pInfos[v1 + 1].uHP); - memcpy(&actor.pMonsterInfo, &pMonsterStats->pInfos[v1 + 1], sizeof(MonsterInfo)); - actor.word_000086_some_monster_id = v1 + 1; - actor.uActorRadius = pMonsterList->pMonsters[v1].uMonsterRadius; - actor.uActorHeight = pMonsterList->pMonsters[v1].uMonsterHeight; - actor.uMovementSpeed = pMonsterList->pMonsters[v1].uMovementSpeed; - - Vec3_int_::Rotate(200, pParty->sRotationY, 0, pParty->vPosition, &pOut.x, &pOut.z, &pOut.y); - actor.vInitialPosition.x = pOut.x; - actor.vPosition.x = pOut.x; - actor.uTetherDistance = 256; - actor.vInitialPosition.y = LOWORD(pOut.z); - actor.vPosition.y = LOWORD(pOut.z); - actor.vInitialPosition.z = LOWORD(pOut.y); - actor.vPosition.z = LOWORD(pOut.y); - pSprites_LOD->DeleteSomeSprites(); - pPaletteManager->ResetNonTestLocked(); - v6 = uNumActors - 1; - if ( dword_5C6DF8 == 1 ) - { - dword_5C6DF8 = 0; - v6 = uNumActors++; - } - memcpy(&pActors[v6], &actor, sizeof(Actor)); - pActors[v6].PrepareSprites(1); - result = 1; - } - return result; -} -// 5C6DF8: using guessed type int dword_5C6DF8; - - -//----- (0044FA4C) -------------------------------------------------------- -signed int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3) -{ - signed int result; // eax@13 - int v10; // ebx@16 - const char *v15; // [sp-4h] [bp-24h]@2 - unsigned int uFaceID; // [sp+8h] [bp-18h]@16 - int v19; // [sp+Ch] [bp-14h]@16 - size_t v20; // [sp+10h] [bp-10h]@6 - int v21; // [sp+14h] [bp-Ch]@14 - unsigned int v23; // [sp+1Ch] [bp-4h]@6 - - if ( a2 == 4 ) - v15 = "Elemental Light C"; - else if ( a2 == 3 ) - v15 = "Elemental Light B"; - else - v15 = "Elemental Light A"; - - v23 = pMonsterList->GetMonsterIDByName(v15); - v20 = 0; - for ( v20; v20 < uNumActors; v20++ ) - { - if ( pActors[v20].uAIState == Removed ) - break; - } - - result = uNumActors + 1; - if ( v20 != uNumActors || result < 500 ) - { - v21 = 0; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - v21 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); - v19 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; - pActors[v20].Reset(); - strcpy(pActors[v20].pActorName, pMonsterStats->pInfos[v23 + 1].pName); - pActors[v20].sCurrentHP = pMonsterStats->pInfos[v23 + 1].uHP; - memcpy(&pActors[v20].pMonsterInfo, &pMonsterStats->pInfos[v23 + 1], sizeof(MonsterInfo)); - pActors[v20].word_000086_some_monster_id = v23 + 1; - pActors[v20].uActorRadius = pMonsterList->pMonsters[v23].uMonsterRadius; - pActors[v20].uActorHeight = pMonsterList->pMonsters[v23].uMonsterHeight; - pActors[v20].pMonsterInfo.uTreasureDiceRolls = 0; - pActors[v20].pMonsterInfo.uTreasureType = 0; - pActors[v20].pMonsterInfo.uExp = 0; - pActors[v20].uMovementSpeed = pMonsterList->pMonsters[v23].uMovementSpeed; - v10 = rand() % 2048; - pActors[v20].vInitialPosition.x = pParty->vPosition.x + fixpoint_mul(stru_5C6E00->Cos(v10), v19); - pActors[v20].vPosition.x = pActors[v20].vInitialPosition.x; - pActors[v20].vInitialPosition.y = pParty->vPosition.y + fixpoint_mul(stru_5C6E00->Sin(v10), v19); - pActors[v20].vPosition.y = pActors[v20].vInitialPosition.y; - pActors[v20].vInitialPosition.z = pParty->vPosition.z; - pActors[v20].vPosition.z = pActors[v20].vInitialPosition.z; - pActors[v20].uTetherDistance = 256; - pActors[v20].uSectorID = v21; - pActors[v20].PrepareSprites(0); - pActors[v20].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - pActors[v20].uAlly = 9999; - pActors[v20].uGroup = 0; - pActors[v20].uCurrentActionTime = 0; - pActors[v20].uAIState = Summoned; - pActors[v20].uCurrentActionLength = 256; - pActors[v20].UpdateAnimation(); - - result = pIndoor->GetSector(pActors[v20].vPosition.x, pActors[v20].vPosition.y, pActors[v20].vPosition.z); - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor - || result == v21 - && (result = BLV_GetFloorLevel(pActors[v20].vPosition.x, pActors[v20].vPosition.y, pActors[v20].vPosition.z, result, &uFaceID), result != -30000) - && (result = abs(result - pParty->vPosition.z), result <= 1024) ) - { - if ( v20 == uNumActors ) - ++uNumActors; - pActors[v20].uSummonerID = PID(OBJECT_Player, a1); - result = pActors[v20].pActorBuffs[ACTOR_BUFF_SUMMONED].Apply(pParty->uTimePlayed + (a3 * 128) / 30.0f, a2, a1, 0, 0); - } - } - return result; -} - -//----- (0044F57C) -------------------------------------------------------- -void SpawnEncounter(MapInfo *pMapInfo, SpawnPointMM7 *spawn, int a3, int a4, int a5) -{ - int v7; // eax@2 - char v8; // zf@5 - int v12; // edx@9 - int v18; // esi@31 - Actor *pMonster; // esi@35 - int v23; // edx@36 - signed int v24; // edi@36 - int v25; // ecx@36 - MonsterDesc *v27; // edi@48 - signed int v28; // eax@48 - int v32; // eax@50 - int v37; // eax@51 - int v38; // eax@52 - int v39; // edi@52 - std::string v40; // [sp-18h] [bp-100h]@60 - const char *v44; // [sp-8h] [bp-F0h]@13 - char *pTexture; // [sp-4h] [bp-ECh]@9 - char Str[32]; // [sp+Ch] [bp-DCh]@60 - char Str2[120]; // [sp+2Ch] [bp-BCh]@29 - unsigned int uFaceID; // [sp+A4h] [bp-44h]@52 - MonsterInfo *Src; // [sp+A8h] [bp-40h]@50 - int v50; // [sp+ACh] [bp-3Ch]@47 - char Source[32]; // [sp+B0h] [bp-38h]@20 - int v52; // [sp+D0h] [bp-18h]@34 - int v53; // [sp+D4h] [bp-14h]@34 - int pSector; // [sp+D8h] [bp-10h]@32 - int pPosX; // [sp+DCh] [bp-Ch]@32 - int v56; // [sp+E0h] [bp-8h]@8 - int v57; // [sp+E4h] [bp-4h]@1 - - //auto a2 = spawn; - v57 = 0; - //v5 = pMapInfo; - //v6 = spawn; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - v7 = pOutdoor->ddm.field_C_alert; - else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - v7 = pIndoor->dlv.field_C_alert; - else - v7 = 0; - if (v7) - v8 = (spawn->uAttributes & 1) == 0; - else - v8 = (spawn->uAttributes & 1) == 1; - if (v8) - return; - //result = (void *)(spawn->uIndex - 1); - v56 = 1; - switch (spawn->uIndex - 1) - { - case 0: - //v9 = pMapInfo->uEncounterMonster1AtLeast; - //v10 = rand(); - //v11 = pMapInfo->uEncounterMonster1AtMost; - //pTexture = pMapInfo->pEncounterMonster1Texture; - v12 = rand() % (pMapInfo->uEncounterMonster1AtMost - pMapInfo->uEncounterMonster1AtLeast + 1); - //v13 = pMapInfo->Dif_M1; - v57 = pMapInfo->Dif_M1; - v56 = pMapInfo->uEncounterMonster1AtLeast + v12; - strcpy(Source, pMapInfo->pEncounterMonster1Texture); - break; - case 3: - //pTexture = pMapInfo->pEncounterMonster1Texture; - //v44 = "%s A"; - sprintf(Source, "%s A", pMapInfo->pEncounterMonster1Texture); - break; - case 4: - //pTexture = pMapInfo->pEncounterMonster2Texture; - //v44 = "%s A"; - sprintf(Source, "%s A", pMapInfo->pEncounterMonster2Texture); - break; - case 5: - //pTexture = pMapInfo->pEncounterMonster3Texture; - //v44 = "%s A"; - sprintf(Source, "%s A", pMapInfo->pEncounterMonster3Texture); - break; - case 1: - //v9 = pMapInfo->uEncounterMonster2AtLeast; - //v14 = rand(); - //v15 = pMapInfo->uEncounterMonster2AtMost; - //pTexture = pMapInfo->pEncounterMonster2Texture; - v12 = rand() % (pMapInfo->uEncounterMonster2AtMost - pMapInfo->uEncounterMonster2AtLeast + 1); - //v13 = pMapInfo->Dif_M2; - v57 = pMapInfo->Dif_M2; - v56 = pMapInfo->uEncounterMonster2AtLeast + v12; - strcpy(Source, pMapInfo->pEncounterMonster2Texture); - break; - case 6: - //pTexture = pMapInfo->pEncounterMonster1Texture; - //v44 = "%s B"; - sprintf(Source, "%s B", pMapInfo->pEncounterMonster1Texture); - break; - case 7: - //pTexture = pMapInfo->pEncounterMonster2Texture; - //v44 = "%s B"; - sprintf(Source, "%s B", pMapInfo->pEncounterMonster2Texture); - break; - case 8: - //pTexture = pMapInfo->pEncounterMonster3Texture; - //v44 = "%s B"; - sprintf(Source, "%s B", pMapInfo->pEncounterMonster3Texture); - break; - case 2: - //v9 = pMapInfo->uEncounterMonster3AtLeast; - //v16 = rand(); - //v17 = pMapInfo->uEncounterMonster3AtMost; - //pTexture = pMapInfo->pEncounterMonster3Texture; - v12 = rand() % (pMapInfo->uEncounterMonster3AtMost - pMapInfo->uEncounterMonster3AtLeast + 1); - //v13 = pMapInfo->Dif_M3; - v57 = pMapInfo->Dif_M3; - v56 = pMapInfo->uEncounterMonster3AtLeast + v12; - strcpy(Source, pMapInfo->pEncounterMonster3Texture); - break; - case 9: - //pTexture = pMapInfo->pEncounterMonster1Texture; - //v44 = "%s C"; - sprintf(Source, "%s C", pMapInfo->pEncounterMonster1Texture); - break; - case 10: - //pTexture = pMapInfo->pEncounterMonster2Texture; - //v44 = "%s C"; - sprintf(Source, "%s C", pMapInfo->pEncounterMonster2Texture); - break; - case 11: - //pTexture = pMapInfo->pEncounterMonster3Texture; - //v44 = "%s C"; - sprintf(Source, "%s C", pMapInfo->pEncounterMonster3Texture); - break; - default: - return; - } - if (Source[0] == '0') - return; - v57 += a3; - if ( v57 > 4 ) - v57 = 4; - strcpy(Str2, Source); - if ( a4 ) - v56 = a4; - v18 = v56; - if ( (signed int)(v56 + uNumActors) >= 500 ) - return; - pSector = 0; - pPosX = spawn->vPosition.x; - a4 = spawn->vPosition.y; - a3 = spawn->vPosition.z; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z); - v53 = 0; - v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; - if ( v18 <= 0 ) - return; - for (uint i = v53; i < v56; ++i) - { - pMonster = &pActors[uNumActors]; - pActors[uNumActors].Reset(); - if ( v57 ) - { - v23 = rand() % 100; - v24 = 3; - v25 = (unsigned __int16)word_4E8152[3 * v57]; - if ( v23 >= v25 ) - { - if ( v23 < v25 + (unsigned __int16)word_4E8152[3 * v57 + 1] ) - v24 = 2; - } - else - v24 = 1; - if ( v24 == 1 ) - { - pTexture = Source; - v44 = "%s A"; - } - else - { - if ( v24 == 2 ) - { - pTexture = Source; - v44 = "%s B"; - } - else - { - if ( v24 != 3 ) - continue; - pTexture = Source; - v44 = "%s C"; - } - } - sprintf(Str2, v44, pTexture); - } - v50 = pMonsterList->GetMonsterIDByName(Str2); - pTexture = Str2; - if ( (signed __int16)v50 == -1 ) - { - sprintf(Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", pTexture); - MessageBoxA(nullptr, Str, nullptr, 0); - ExitProcess(0); - } - v27 = &pMonsterList->pMonsters[(signed __int16)v50]; - v28 = pMonsterStats->FindMonsterByTextureName(pTexture); - if ( !v28 ) - v28 = 1; - Src = &pMonsterStats->pInfos[v28]; - strcpy(pMonster->pActorName, Src->pName); - pMonster->sCurrentHP = Src->uHP; - assert(sizeof(MonsterInfo) == 88); - memcpy(&pMonster->pMonsterInfo, Src, sizeof(MonsterInfo));//Uninitialized portail memory access - pMonster->word_000086_some_monster_id = v50 + 1; - pMonster->uActorRadius = v27->uMonsterRadius; - pMonster->uActorHeight = v27->uMonsterHeight; - pMonster->uMovementSpeed = v27->uMovementSpeed; - pMonster->vInitialPosition.x = spawn->vPosition.x; - pMonster->vPosition.x = spawn->vPosition.x; - pMonster->uTetherDistance = 256; - pMonster->vInitialPosition.y = a4; - pMonster->vPosition.y = a4; - pMonster->vInitialPosition.z = a3; - pMonster->vPosition.z = a3; - pMonster->uSectorID = pSector; - pMonster->uGroup = spawn->uGroup; - pMonster->PrepareSprites(0); - pMonster->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - v32 = rand(); - a3 = fixpoint_mul(stru_5C6E00->Cos(v32 % 2048), v52); - pPosX = a3 + spawn->vPosition.x; - a3 = fixpoint_mul(stru_5C6E00->Sin(v32 % 2048), v52); - a4 = a3 + spawn->vPosition.y; - a3 = spawn->vPosition.z; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - { - if ( a5 ) - pMonster->uAttributes |= ACTOR_AGGRESSOR; - ++uNumActors; - continue; - } - v37 = pIndoor->GetSector(pPosX, a4, spawn->vPosition.z); - if ( v37 == pSector ) - { - v38 = BLV_GetFloorLevel(pPosX, a4, a3, v37, &uFaceID); - v39 = v38; - if ( v38 != -30000 ) - { - if ( abs(v38 - a3) <= 1024 ) - { - a3 = v39; - if ( a5 ) - pMonster->uAttributes |= ACTOR_AGGRESSOR; - ++uNumActors; - continue; - } - } - } - ; - //v53 = (char *)v53 + 1; - //result = v53; - } - //while ( (signed int)v53 < v56 ); -} - -//----- (00438F8F) -------------------------------------------------------- -void area_of_effect__damage_evaluate() -{ - int attacker_type; // ecx@3 - signed int v3; // eax@3 - unsigned int target_id; // edi@6 - int target_type; // eax@6 - int v10; // edi@8 - Vec3_int_ attacker_coord; // ST04_12@9 - // int v12; // ST0C_4@10 - int v15; // edx@15 - int v19; // edi@15 - int v23; // edx@18 - int v24; // eax@18 - // int v30; // eax@29 - int v31; // edx@29 - int v32; // eax@29 - int v33; // ST24_4@29 - SpriteObject *v36; // [sp+0h] [bp-28h]@0 - int attacker_id; // [sp+10h] [bp-18h]@1 - int v44; // [sp+14h] [bp-14h]@15 - //Vec3_int_ *pVelocity; // [sp+1Ch] [bp-Ch]@2 - signed int a1; // [sp+20h] [bp-8h]@8 - int v48; // [sp+24h] [bp-4h]@8 - - - for (attacker_id = 0; attacker_id < AttackerInfo.count; ++attacker_id) - { - attacker_type = PID_TYPE(AttackerInfo.pIDs[attacker_id]); - v3 = PID_ID(AttackerInfo.pIDs[attacker_id]); - - if (attacker_type == 2) - { - v36 = &pSpriteObjects[v3]; - attacker_type = PID_TYPE(pSpriteObjects[v3].spell_caster_pid); - v3 = PID_ID(pSpriteObjects[v3].spell_caster_pid); - } - - if (AttackerInfo.field_3EC[attacker_id] & 1) - { - target_id = PID_ID(ai_near_actors_targets_pid[v3]); - target_type = PID_TYPE(ai_near_actors_targets_pid[v3]) - 3; - if (target_type) - { - if (target_type == 1)//party damage from monsters(ïîâðåæäåíèÿ ãðóïïå îò ìîíñòðîâ) - { - v10 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; - a1 = pParty->vPosition.x - AttackerInfo.pXs[attacker_id]; - v48 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; - if (a1 * a1 + v10 * v10 - + ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - AttackerInfo.pZs[attacker_id])) - * ((signed int)(pParty->vPosition.z + pParty->uPartyHeight) >> (1 - AttackerInfo.pZs[attacker_id])) - < (unsigned int)((AttackerInfo.field_324[attacker_id] + 32) * (AttackerInfo.field_324[attacker_id] + 32))) - { - attacker_coord.x = AttackerInfo.pXs[attacker_id]; - attacker_coord.y = AttackerInfo.pYs[attacker_id]; - attacker_coord.z = AttackerInfo.pZs[attacker_id]; - if (sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, attacker_coord)) - DamagePlayerFromMonster(AttackerInfo.pIDs[attacker_id], AttackerInfo.field_450[attacker_id], &AttackerInfo.vec_4B4[attacker_id], stru_50C198.which_player_to_attack(&pActors[v3])); - } - } - } - else//Actor damage from monsters(ïîâðåæäåíèå ìåñòíîãî æèòåëÿ) - { - if (SHIDWORD(pActors[target_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) > 0 - || SHIDWORD(pActors[target_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) >= 0 - && LODWORD(pActors[target_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime) - || pActors[target_id].CanAct()) - { - v15 = pActors[target_id].vPosition.y - AttackerInfo.pYs[attacker_id]; - a1 = pActors[target_id].vPosition.x - AttackerInfo.pXs[attacker_id]; - v44 = pActors[target_id].vPosition.z; - v19 = AttackerInfo.field_324[attacker_id] + pActors[target_id].uActorRadius; - v48 = v15; - if (a1 * a1 + v15 * v15 + (pActors[target_id].vPosition.z + (pActors[target_id].uActorHeight >> 1) - AttackerInfo.pZs[attacker_id]) - * (pActors[target_id].vPosition.z + (pActors[target_id].uActorHeight >> 1) - AttackerInfo.pZs[attacker_id]) < (unsigned int)(v19 * v19)) - { - attacker_coord.x = AttackerInfo.pXs[attacker_id]; - attacker_coord.y = AttackerInfo.pYs[attacker_id]; - attacker_coord.z = AttackerInfo.pZs[attacker_id]; - if (sub_407A1C(pActors[target_id].vPosition.x, pActors[target_id].vPosition.y, pActors[target_id].vPosition.z + 50, attacker_coord)) - { - Vec3_int_::Normalize(&a1, &v48, &v44); - AttackerInfo.vec_4B4[attacker_id].x = a1; - AttackerInfo.vec_4B4[attacker_id].y = v48; - AttackerInfo.vec_4B4[attacker_id].z = v44; - Actor::ActorDamageFromMonster(AttackerInfo.pIDs[attacker_id], target_id, &AttackerInfo.vec_4B4[attacker_id], AttackerInfo.field_450[attacker_id]); - } - } - } - } - } - else //damage from spells(ïîâðåæäåíèÿ îò çàêëîâ(ìåòåîðèòíûé äîæäü)) - { - v23 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; - v24 = ((signed int)pParty->uPartyHeight / 2) - AttackerInfo.pZs[attacker_id]; - a1 = pParty->vPosition.x - AttackerInfo.pXs[attacker_id]; - v48 = pParty->vPosition.y - AttackerInfo.pYs[attacker_id]; - if (a1 * a1 + v23 * v23 + (pParty->vPosition.z + v24) * (pParty->vPosition.z + v24) < (unsigned int)((AttackerInfo.field_324[attacker_id] + 32) * (AttackerInfo.field_324[attacker_id] + 32))) - {//party damage (ïîâðåæäåíèÿ ãðóïïå) - attacker_coord.x = AttackerInfo.pXs[attacker_id]; - attacker_coord.y = AttackerInfo.pYs[attacker_id]; - attacker_coord.z = AttackerInfo.pZs[attacker_id]; - if (sub_407A1C(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + pParty->sEyelevel, attacker_coord)) - { - for (uint i = 0; i < 4; ++i) - { - if (!(HIDWORD(pParty->pPlayers[i].pConditions[Condition_Dead]) | LODWORD(pParty->pPlayers[i].pConditions[Condition_Dead])) - && !pParty->pPlayers[i].pConditions[Condition_Pertified] && !pParty->pPlayers[i].pConditions[Condition_Eradicated]) - DamagePlayerFromMonster(AttackerInfo.pIDs[attacker_id], AttackerInfo.field_450[attacker_id], &AttackerInfo.vec_4B4[attacker_id], i); - } - } - } - if ((signed int)uNumActors > 0) - {//actors damage(ïîâðåæäåíèÿ äðóãèì ó÷àñòíèêàì) - for (int actorID = 0; (signed int)actorID < (signed int)uNumActors; ++actorID) - { - if (pActors[actorID].CanAct()) - { - //v30 = pActors[actorID].vPosition.y - AttackerInfo.pYs[attacker_id]; - a1 = pActors[actorID].vPosition.x - AttackerInfo.pXs[attacker_id]; - v31 = pActors[actorID].vPosition.z; - v48 = pActors[actorID].vPosition.y - AttackerInfo.pYs[attacker_id]; - v44 = pActors[actorID].vPosition.z; - v32 = (pActors[actorID].uActorHeight / 2) - AttackerInfo.pZs[attacker_id]; - v33 = pActors[actorID].uActorRadius + AttackerInfo.field_324[attacker_id]; - if (a1 * a1 + v48 * v48 + (v31 + v32) * (v31 + v32) < (unsigned int)(v33 * v33)) - { - attacker_coord.x = AttackerInfo.pXs[attacker_id]; - attacker_coord.y = AttackerInfo.pYs[attacker_id]; - attacker_coord.z = AttackerInfo.pZs[attacker_id]; - if (sub_407A1C(pActors[actorID].vPosition.x, pActors[actorID].vPosition.y, pActors[actorID].vPosition.z + 50, attacker_coord))//÷òî äåëàåò ô-öèÿ? - { - Vec3_int_::Normalize(&a1, &v48, &v44); - AttackerInfo.vec_4B4[attacker_id].x = a1; - AttackerInfo.vec_4B4[attacker_id].y = v48; - AttackerInfo.vec_4B4[attacker_id].z = v44; - switch (attacker_type) - { - case OBJECT_Player: - Actor::DamageMonsterFromParty(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id]); - break; - case OBJECT_Actor: - if (v36 && pActors[v3].GetActorsRelation(&pActors[actorID])) - Actor::ActorDamageFromMonster(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id], v36->field_61); - break; - case OBJECT_Item: - ItemDamageFromActor(AttackerInfo.pIDs[attacker_id], actorID, &AttackerInfo.vec_4B4[attacker_id]); - break; - } - } - } - } - } - } - } - } - AttackerInfo.count = 0; -} - -//----- (0043AE12) -------------------------------------------------------- -double __fastcall sub_43AE12(signed int a1) -{ - //signed int v1; // ST00_4@1 - signed int v2; // ecx@1 - double v3; // st7@1 - double result; // st7@6 - - v3 = (double)a1; - for (v2 = 0; v2 < 5; ++v2) - { - if (v3 < flt_4E4A80[v2 + 5]) - break; - } - if (v2 <= 0 || v2 >= 5) - { - if (v2) - result = flt_4E4A80[4]; - else - result = flt_4E4A80[0]; - } - else - result = (flt_4E4A80[v2] - flt_4E4A80[v2 - 1]) * (v3 - flt_4E4A80[v2 + 4]) / (flt_4E4A80[v2 + 5] - flt_4E4A80[v2 + 4]) + flt_4E4A80[v2]; - return result; -} - -//----- (0043B057) -------------------------------------------------------- -void ItemDamageFromActor(unsigned int uObjID, unsigned int uActorID, Vec3_int_ *pVelocity) -{ - int v6; // eax@4 - int damage; // edi@4 - int a2a; // [sp+Ch] [bp-4h]@8 - - if (!pActors[uActorID].IsNotAlive()) - { - if (PID_TYPE(uObjID) == OBJECT_Item) - { - if (pSpriteObjects[PID_ID(uObjID)].spell_id) - { - v6 = _43AFE3_calc_spell_damage(pSpriteObjects[PID_ID(uObjID)].spell_id, pSpriteObjects[PID_ID(uObjID)].spell_level, pSpriteObjects[PID_ID(uObjID)].spell_skill, pActors[uActorID].sCurrentHP); - damage = pActors[uActorID].CalcMagicalDamageToActor((DAMAGE_TYPE)0, v6); - pActors[uActorID].sCurrentHP -= damage; - if (damage) - { - if (pActors[uActorID].sCurrentHP > 0) - Actor::AI_Stun(uActorID, uObjID, 0); - else - Actor::Die(uActorID); - a2a = 20 * damage / (signed int)pActors[uActorID].pMonsterInfo.uHP; - if (20 * damage / (signed int)pActors[uActorID].pMonsterInfo.uHP > 10) - a2a = 10; - if (!MonsterStats::BelongsToSupertype(pActors[uActorID].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT)) - { - pVelocity->x = fixpoint_mul(a2a, pVelocity->x); - pVelocity->y = fixpoint_mul(a2a, pVelocity->y); - pVelocity->z = fixpoint_mul(a2a, pVelocity->z); - pActors[uActorID].vVelocity.x = 50 * LOWORD(pVelocity->x); - pActors[uActorID].vVelocity.y = 50 * LOWORD(pVelocity->y); - pActors[uActorID].vVelocity.z = 50 * LOWORD(pVelocity->z); - } - Actor::AddBloodsplatOnDamageOverlay(uActorID, 1, damage); - } - else - Actor::AI_Stun(uActorID, uObjID, 0); - } - } - } -} diff -r 92eeeb5200f2 -r 68cdef6879a0 Actor.h --- a/Actor.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,340 +0,0 @@ -#pragma once -#include "Monsters.h" -#include "Spells.h" -#include "Items.h" - - - - - - -/* 357 */ -#pragma pack(push, 1) -struct stru319 -{ - int which_player_to_attack(struct Actor *pActor); - int _427546(int a2); - int FindClosestActor(int a2, int a3, int a4); - - char field_0; -}; -#pragma pack(pop) - - -extern stru319 stru_50C198; // idb - - -enum ABILITY_INDEX -{ - ABILITY_ATTACK1 = 0, - ABILITY_ATTACK2 = 1, - ABILITY_SPELL1 = 2, - ABILITY_SPELL2 = 3, -}; - - - -/* 361 */ -enum ACTOR_BUFF_INDEX -{ - ACTOR_BUFF_CHARM = 1, - ACTOR_BUFF_SUMMONED = 2, - ACTOR_BUFF_SHRINK = 3, - ACTOR_BUFF_AFRAID = 4, - ACTOR_BUFF_STONED = 5, - ACTOR_BUFF_PARALYZED = 6, - ACTOR_BUFF_SLOWED = 7, - ACTOR_BUFF_SOMETHING_THAT_HALVES_AC = 8, - ACTOR_BUFF_BERSERK = 9, - ACTOR_BUFF_MASS_DISTORTION = 10, - ACTOR_BUFF_FATE = 11, - ACTOR_BUFF_ENSLAVED = 12, - ACTOR_BUFF_DAY_OF_PROTECTION = 13, - ACTOR_BUFF_HOUR_OF_POWER = 14, - ACTOR_BUFF_SHIELD = 15, - ACTOR_BUFF_STONESKIN = 16, - ACTOR_BUFF_BLESS = 17, - ACTOR_BUFF_HEROISM = 18, - ACTOR_BUFF_HASTE = 19, - ACTOR_BUFF_PAIN_REFLECTION = 20, - ACTOR_BUFF_PAIN_HAMMERHANDS = 21, -}; - - - - - -/* 295 */ -enum ObjectType -{ - OBJECT_Any = 0x0, - OBJECT_BLVDoor = 0x1, - OBJECT_Item = 0x2, - OBJECT_Actor = 0x3, - OBJECT_Player = 0x4, - OBJECT_Decoration = 0x5, - OBJECT_BModel = 0x6, -}; - - - - - - - -/* 264 */ -enum AIState : unsigned __int16 -{ - Standing = 0x0, - Tethered = 0x1, - AttackingMelee = 0x2, - AttackingRanged1 = 0x3, - Dying = 0x4, - Dead = 0x5, - Pursuing = 0x6, - Fleeing = 0x7, - Stunned = 0x8, - Fidgeting = 0x9, - Interacting = 10, - Removed = 11, - AttackingRanged2 = 0xC, - AttackingRanged3 = 0xD, - Stoned = 0xE, - Paralyzed = 0xF, - Resurrected = 16, - Summoned = 17, - AttackingRanged4 = 18, - Disabled = 19, -}; - -/* 265 */ -enum ActorAnimation : __int32 -{ - ANIM_Standing = 0x0, - ANIM_Walking = 0x1, - ANIM_AtkMelee = 0x2, - ANIM_AtkRanged = 0x3, - ANIM_GotHit = 0x4, - ANIM_Dying = 0x5, - ANIM_Dead = 0x6, - ANIM_Bored = 0x7, -}; -#pragma pack(pop) - -#define ACTOR_UNKNOW2 0x00000008 -#define ACTOR_STAND_IN_QUEUE 0x00000080 -#define ACTOR_ALIVE 0x00000400 -#define ACTOR_ACTIVE 0x00004000 -#define ACTOR_NEARBY 0x00008000 -#define ACTOR_UNKNOW11 0x00010000 -#define ACTOR_FLEEING 0x00020000 -#define ACTOR_UNKNOW5 0x00040000 -#define ACTOR_AGGRESSOR 0x00080000 -#define ACTOR_UNKNOW7 0x00100000 -#define ACTOR_ANIMATION 0x00200000 -#define ACTOR_UNKNOW9 0x00400000 -#define ACTOR_HAS_ITEM 0x00800000 -#define ACTOR_HOSTILE 0x01000000 - -#pragma pack(push, 1) - - - - -/* 247 */ -#pragma pack(push, 1) -struct AIDirection -{ - Vec3_int_ vDirection; - unsigned int uDistance; - unsigned int uDistanceXZ; - unsigned int uYawAngle; - unsigned int uPitchAngle; -}; -#pragma pack(pop) - - - - - -/* 71 */ -#pragma pack(push, 1) -struct ActorJob -{ - struct Vec3_short_ vPos; - unsigned __int16 uAttributes; - unsigned __int8 uAction; - unsigned __int8 uHour; - unsigned __int8 uDay; - unsigned __int8 uMonth; -}; -#pragma pack(pop) - - -/* 66 */ -#pragma pack(push, 1) -struct Actor -{ -//----- (0041F4C1) -------------------------------------------------------- - inline Actor() - { - signed int i; // edx@1 - - for ( i = 0; i < 22; i++ ) - { - this->pActorBuffs[i].uSkill = 0; - this->pActorBuffs[i].uPower = 0; - this->pActorBuffs[i].uExpireTime = 0; - this->pActorBuffs[i].uCaster = 0; - this->pActorBuffs[i].uFlags = 0; - } - for ( i = 0; i < 4; i++ ) - this->ActorHasItems[i].Reset(); - Reset(); - } - - void SummonMinion(int summonerId); - void Reset(); - void Remove(); - void PrepareSprites(char load_sounds_if_bit1_set); - void UpdateAnimation(); - signed int GetActorsRelation(Actor *a2); - void SetRandomGoldIfTheresNoItem(); - bool CanAct(); - bool IsNotAlive(); - bool IsPeasant(); - - inline void ResetAnimation(){uAttributes &= 0xFFDFFFFF;} - inline void ResetQueue(){uAttributes &= ~ACTOR_STAND_IN_QUEUE;} - inline void ResetActive(){uAttributes &= 0xFFFFBFFF;} - inline void ResetAlive(){uAttributes &= 0xFFFFFBFF;} - inline void ResetHasItem(){uAttributes &= 0xFF7FFFFF;} - inline void ResetHostile(){uAttributes &= 0xFEFFFFFF;} - inline void ResetAggressor(){uAttributes &= 0xFFF7FFFF;} - inline bool ActorEnemy()const {return(uAttributes & ACTOR_AGGRESSOR) != 0;} - inline bool ActorFriend()const {return(uAttributes & ACTOR_AGGRESSOR) == 0;} - inline bool ActorHasItem()const {return(uAttributes & ACTOR_HAS_ITEM) != 0;} - inline bool ActorNearby()const {return(uAttributes & ACTOR_NEARBY) != 0;} - - static void _SelectTarget(unsigned int uActorID, int *a2, bool can_target_party); - static void AI_Pursue3(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *a4); - static void AI_Pursue2(unsigned int uActorID, unsigned int a2, signed int uActionLength, struct AIDirection *pDir, int a5); - static void AI_Flee(unsigned int uActorID, signed int edx0, int uActionLength, struct AIDirection *a4); - static void AI_Pursue1(unsigned int uActorID, unsigned int a2, signed int arg0, signed int uActionLength, struct AIDirection *pDir); - static void PlaySound(unsigned int uActorID, unsigned int uSoundID); - static void Die(unsigned int uActorID); - static void Resurrect(unsigned int uActorID); - static void AI_Bored(unsigned int uActorID, unsigned int uObjID, struct AIDirection *a4); - static void AI_Stun(unsigned int uActorID, signed int edx0, int arg0); - static char __fastcall _4031C1_update_job_never_gets_called(unsigned int uActorID, signed int a2, int a3); - static void AI_RandomMove(unsigned int uActor_id, unsigned int uTarget_id, int radius, int uActionLength); - static void AI_MissileAttack1(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir); - static void AI_MissileAttack2(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir); - static void AI_SpellAttack1(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir); - static void AI_SpellAttack2(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir); - static void AI_MeleeAttack(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0); - static void __fastcall StandAwhile(unsigned int uActorID); - static void AI_Stand(unsigned int uActorID, unsigned int object_to_face_pid, unsigned int uActionLength, struct AIDirection *a4); - static void AI_StandOrBored(unsigned int uActorID, signed int uObjID, int uActionLength, struct AIDirection *a4); - static void AI_FaceObject(unsigned int uActorID, unsigned int uObjID, int _48, struct AIDirection *a4); - static void GetDirectionInfo(unsigned int uObj1ID, unsigned int uObj2ID, struct AIDirection *pOut, int a4); - static void Explode(unsigned int uActorID); - static void AI_RangedAttack(unsigned int uActorID, struct AIDirection *a2, int type, char a4); - static void AI_SpellAttack(unsigned int uActorID, struct AIDirection *pDir, int uSpellID, int a4, unsigned int uSkillLevel); - static void ActorDamageFromMonster(signed int attacker_id, unsigned int actor_id, struct Vec3_int_ *pVelocity, signed int a4); - - static unsigned short GetObjDescId( int spellId ); - - static void AggroSurroundingPeasants(unsigned int uActorID, int a2); - static bool ArePeasantsOfSameFaction(Actor *a1, Actor *a2); - static void StealFrom(unsigned int uActorID); - static void GiveItem(signed int uActorID, unsigned int uItemID, unsigned int bGive); - static void ToggleFlag(signed int uActorID, unsigned int uFlag, int bToggle); - static void ApplyFineForKillingPeasant(unsigned int uActorID); - static void DrawHealthBar(Actor *actor, struct GUIWindow *window); - int _43B3E0_CalcDamage(signed int dmgSource); - static void AddBloodsplatOnDamageOverlay(unsigned int uActorID, int a2, signed int a3); - - static bool _46DF1A_collide_against_actor(int a1, int a2); - static void Arena_summon_actor(int monster_id, __int16 x, int y, int z); - static void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, struct Vec3_int_ *pVelocity); - static void MakeActorAIList_ODM(); - static int MakeActorAIList_BLV(); - static void UpdateActorAI(); - static void InitializeActors(); - static unsigned int SearchAliveActors(unsigned int *pTotalActors); - static unsigned int SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID); - static unsigned int SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup); - static unsigned int SearchActorByID(unsigned int *pTotalActors, unsigned int a2); - - - void LootActor(); - bool _427102_IsOkToCastSpell(signed int a2); - ABILITY_INDEX special_ability_use_check(int a2); - bool _4273BB_DoesHitOtherActor(Actor *defender, int a3, int a4); - bool ActorHitOrMiss(Player *pPlayer); - int CalcMagicalDamageToActor(DAMAGE_TYPE dmgType, signed int incomingDmg); - bool DoesDmgTypeDoDamage(DAMAGE_TYPE uType); - - char pActorName[32]; - signed __int16 sNPC_ID; - __int16 field_22; - unsigned int uAttributes; - __int16 sCurrentHP; - char field_2A[2]; - struct MonsterInfo pMonsterInfo; - __int16 word_000084_range_attack; - __int16 word_000086_some_monster_id; - unsigned __int16 uActorRadius; - unsigned __int16 uActorHeight; - unsigned __int16 uMovementSpeed; - struct Vec3_short_ vPosition; - struct Vec3_short_ vVelocity; - unsigned __int16 uYawAngle; - unsigned __int16 uPitchAngle; - __int16 uSectorID; - unsigned __int16 uCurrentActionLength; - struct Vec3_short_ vInitialPosition; - struct Vec3_short_ vGuardingPosition; - unsigned __int16 uTetherDistance; - AIState uAIState; - unsigned __int16 uCurrentActionAnimation; - unsigned __int16 uCarriedItemID; - char field_B6; - char field_B7; - unsigned int uCurrentActionTime; - unsigned __int16 pSpriteIDs[8]; - unsigned __int16 pSoundSampleIDs[4]; // 1 die 3 bored - struct SpellBuff pActorBuffs[22]; - struct ItemGen ActorHasItems[4]; - unsigned int uGroup; - unsigned int uAlly; - struct ActorJob pScheduledJobs[8]; - unsigned int uSummonerID; - unsigned int uLastCharacterIDToHit; - int dword_000334_unique_name; - char field_338[12]; -}; -#pragma pack(pop) - - - - - - -//extern Actor pMonsterInfoUI_Doll; - -extern std::array pActors; -extern size_t uNumActors; - -bool CheckActors_proximity(); -int __fastcall IsActorAlive(unsigned int uType, unsigned int uParam, unsigned int uNumAlive); // idb -void __fastcall sub_448518_npc_set_item(int npc, unsigned int item, int a3); -void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle); -bool __fastcall sub_4070EF_prolly_detect_player(unsigned int uObjID, unsigned int uObj2ID); -bool __fastcall SpawnActor(unsigned int uMonsterID); -int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3); -void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5); -void area_of_effect__damage_evaluate(); -double __fastcall sub_43AE12(signed int a1); -void ItemDamageFromActor(unsigned int uObjID, unsigned int uActorID, struct Vec3_int_ *pVelocity); diff -r 92eeeb5200f2 -r 68cdef6879a0 Arcomage/Arcomage.cpp --- a/Arcomage/Arcomage.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Arcomage/Arcomage.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -9,15 +9,15 @@ #include "..\Engine/Graphics/Render.h" #include "Arcomage.h" #include "AudioPlayer.h" -#include "Game.h" +#include "../Engine/Game.h" #include "..\Engine/Graphics/Viewport.h" -#include "Timer.h" +#include "../Engine/Timer.h" #include "GUIFont.h" -#include "Party.h" +#include "../Engine/Party.h" #include "GUIWindow.h" -#include "texts.h" +#include "../Engine/texts.h" #include -#include "mm7_data.h" +#include "../Engine/mm7_data.h" #include "UI/UIHouses.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 AudioPlayer.cpp --- a/AudioPlayer.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/AudioPlayer.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -4,30 +4,30 @@ #define _CRT_SECURE_NO_WARNINGS #include -#include "ZlibWrapper.h" +#include "Engine/ZlibWrapper.h" -#include "mm7_data.h" +#include "Engine/mm7_data.h" #include "MediaPlayer.h" #include "AudioPlayer.h" -#include "FrameTableInc.h" +#include "Engine/Tables/FrameTableInc.h" #include "Engine/Graphics/Indoor.h" -#include "SpriteObject.h" -#include "Party.h" -#include "Actor.h" -#include "Game.h" +#include "Engine/Objects/SpriteObject.h" +#include "Engine/Party.h" +#include "Engine/Objects/Actor.h" +#include "Engine/Game.h" #include "Engine/Graphics/DecorationList.h" -#include "Timer.h" -#include "OurMath.h" -#include "MapInfo.h" +#include "Engine/Timer.h" +#include "Engine/OurMath.h" +#include "Engine/MapInfo.h" #include "GUIWindow.h" -#include "Log.h" -#include "ErrorHandling.h" +#include "Engine/Log.h" +#include "Engine/ErrorHandling.h" #include "Engine/Graphics/Level/Decoration.h" -#include "Registry.h" +#include "Engine/Registry.h" #include "Bink_Smacker.h" -#include "MM7.h" +#include "Engine/MM7.h" PCMWAVEFORMAT pcmWaveFormat; diff -r 92eeeb5200f2 -r 68cdef6879a0 Autonotes.h --- a/Autonotes.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -#pragma once -#include - - - -/* 351 */ -enum AUTONOTE_TYPE : __int32 -{ - AUTONOTE_POTION_RECEPIE = 0, - AUTONOTE_STAT_HINT = 1, - AUTONOTE_OBELISK = 2, - AUTONOTE_SEER = 3, - AUTONOTE_MISC = 4, - AUTONOTE_TEACHER = 5, -}; - -/* 350 */ -#pragma pack(push, 1) -struct Autonote -{ - const char *pText; - AUTONOTE_TYPE eType; -}; -#pragma pack(pop) -extern std::array pAutonoteTxt; // weak diff -r 92eeeb5200f2 -r 68cdef6879a0 Awards.h --- a/Awards.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,127 +0,0 @@ -#pragma once -#include - -/* 353 */ -#pragma pack(push, 1) -struct Award -{ - const char *pText; - unsigned int uPriority; -}; -#pragma pack(pop) -extern std::array pAwards; - - - -enum AwardType: unsigned __int32 -{ - Award_Invalid = 0 - , Award_Fine = 1 - , Award_EmeraldIsle_CompletedMainQuest = 2 - , Award_EmeraldIsle_FoundMissingCompetitors = 3 - , Award_Harmondale_CastleCleared = 4 - , Award_BarrowDowns_RescuedMiners = 5 - , Award_Erathia_RescuedLorenSteel = 6 - , Award_Avlee_BroughtFakeLorenSteelToErathia = 7 - , Award_Avlee_BroughtFortRiverstridePlans = 8 - , Award_Erathia_DeliveredFakePlansToElves = 9 - , Award_Promotion_Rogue = 10 - , Award_Promotion_Rogue_Honorary = 11 - , Award_Promotion_Spy = 12 - , Award_Promotion_Spy_Honorary = 13 - , Award_Promotion_Assassin = 14 - , Award_Promotion_Assassin_Honorary = 15 - , Award_Promotion_Chevalier = 16 - , Award_Promotion_Chevalier_Honorary = 17 - , Award_Promotion_Champion = 18 - , Award_Promotion_Champion_Honorary = 19 - , Award_Promotion_BlackKnight = 20 - , Award_Promotion_BlackKnight_Honorary = 21 - , Award_Promotion_Initiate = 22 - , Award_Promotion_Initiate_Honorary = 23 - , Award_Promotion_Master = 24 - , Award_Promotion_Master_Honorary = 25 - , Award_Promotion_Ninja = 26 - , Award_Promotion_Ninja_Honorary = 27 - , Award_Promotion_Hunter = 28 - , Award_Promotion_Hunter_Honorary = 29 - , Award_Promotion_RangerLord = 30 - , Award_Promotion_RangerLord_Honorary = 31 - , Award_Promotion_BountyHunter = 32 - , Award_Promotion_BountyHunter_Honorary = 33 - , Award_Promotion_WarriorMage = 34 - , Award_Promotion_WarriorMage_Honorary = 35 - , Award_Promotion_MasterArcher = 36 - , Award_Promotion_MasterArcher_Honorary = 37 - , Award_Promotion_Sniper = 38 - , Award_Promotion_Sniper_Honorary = 39 - , Award_Promotion_Crusader = 40 - , Award_Promotion_Crusader_Honorary = 41 - , Award_Promotion_Hero = 42 - , Award_Promotion_Hero_Honorary = 43 - , Award_Promotion_Villian = 44 - , Award_Promotion_Villian_Honorary = 45 - , Award_Celestia_SurvivedWallOfMist = 46 - , Award_47 = 47 - , Award_KilledXenofex = 48 - , Award_Tatalia_SolvedWineCellarMystery = 49 - , Award_Membership_ElementalGuilds = 50 - , Award_Membership_SelfGuilds = 51 - , Award_Membership_AirGuild = 52 - , Award_Membership_EarthGuild = 53 - , Award_Membership_FireGuild = 54 - , Award_Membership_WaterGuild = 55 - , Award_Membership_BodyGuild = 56 - , Award_Membership_MindGuild = 57 - , Award_Membership_SpiritGuild = 58 - , Award_Membership_LightGuild = 59 - , Award_Membership_DarkGuild = 60 - , Award_Avlee_RetrievedForestHeart = 61 - , Award_Promotion_Priest = 62 - , Award_Promotion_Priest_Honorary = 63 - , Award_Promotion_PriestOfLight = 64 - , Award_Promotion_PriestOfLight_Honorary = 65 - , Award_Promotion_PriestOfDark = 66 - , Award_Promotion_PriestOfDark_Honorary = 67 - , Award_Promotion_GreatDruid = 68 - , Award_Promotion_GreatDruid_Honorary = 69 - , Award_Promotion_ArchDruid = 70 - , Award_Promotion_ArchDruid_Honorary = 71 - , Award_Promotion_Warlock = 72 - , Award_Promotion_Warlock_Honorary = 73 - , Award_Promotion_Wizard = 74 - , Award_Promotion_Wizard_Honorary = 75 - , Award_Promotion_Archmage = 76 - , Award_Promotion_Archmage_Honorary = 77 - , Award_Promotion_Lich = 78 - , Award_Promotion_Lich_Honorary = 79 - , Award_ThePit_RetrievedSoulJars = 80 - , Award_Celestia_KilledTolberti = 81 - , Award_ThePit_ClearedKlankersLab = 82 - , Award_ThePit_KilledRobertTheWise = 83 - , Award_ThePit_SurvivedBreedingZone = 84 - , Award_Deaths = 85 - , Award_BountiesCollected = 86 - , Award_PrisonTerms = 87 - , Award_Arena_PageWins = 88 - , Award_Arena_SquireWins = 89 - , Award_Arena_KnightWins = 90 - , Award_Arena_LordWins = 91 - , Award_Harmondale_ReturnedLanterOfLight = 92 - , Award_Nighon_RetrievedHaldarsRemains = 93 - , Award_Harmondale_ReturnedDavriksSignetRing = 94 - , Award_Erathia_ReturnedParsonsQuill = 95 - , Award_RetrievedFaeriePipes = 96 - , Award_BarrowDowns_KilledTroglodytesInLowerCity = 97 - , Award_Deyja_KilledAllGriffins = 98 - , Award_Bracada_RetrievedSeasonsStole = 99 - , Award_Avlee_PlacedThreeStatuettes = 100 - , Award_101 = 101 - , Award_ArcomageChampion = 102 - , Award_ArcomageWins = 103 - , Award_ArcomageLoses = 104 - -}; -extern std::array achieved_awards; -extern int num_achieved_awards; -extern int full_num_items_in_book; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Build/Visual Studio 2012/World of Might and Magic.vcxproj --- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj Fri Sep 19 00:03:04 2014 +0600 +++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj Fri Sep 19 02:57:42 2014 +0600 @@ -95,8 +95,9 @@ - - + + + @@ -119,21 +120,45 @@ + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + + + - @@ -196,36 +221,13 @@ - - - - - - - - - - - - - - - - - - - - - - - @@ -244,19 +246,20 @@ - - - - - - + + + + + + + @@ -281,23 +284,53 @@ + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -440,46 +473,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -498,10 +499,9 @@ - - + Document @@ -518,11 +518,6 @@ - - call "../../lib/swig" "%(FileName)" %(RelativeDir) "%(FileName)%(Extension)" "%(FullPath)" "$(SolutionDir)" %(Filename)_wrap.cxx - %(Filename)_wrap.cxx - %(Filename).swig - diff -r 92eeeb5200f2 -r 68cdef6879a0 Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters --- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters Fri Sep 19 00:03:04 2014 +0600 +++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters Fri Sep 19 02:57:42 2014 +0600 @@ -291,105 +291,6 @@ - - Engine\TurnEngine - - - Engine\Tables - - - Engine\Tables - - - Engine\Tables - - - Engine\Tables - - - Engine\Tables - - - Engine\Tables - - - Engine\Spells - - - Engine\Spells - - - Engine\Objects - - - Engine\Objects - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - IO @@ -558,18 +459,115 @@ Engine\Objects + + Engine\Objects + Engine\Objects - + + Engine\Objects + + Engine\Objects Engine\Objects - + Engine\Objects + + Engine\Spells + + + Engine\Spells + + + Engine\Tables + + + Engine\Tables + + + Engine\Tables + + + Engine\Tables + + + Engine\Tables + + + Engine\Tables + + + Engine\TurnEngine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + @@ -998,141 +996,6 @@ - - Engine\TurnEngine - - - Engine\Tables - - - Engine\Tables - - - Engine\Tables - - - Engine\Tables - - - Engine\Tables - - - Engine\Tables - - - Engine\Spells - - - Engine\Spells - - - Engine\Objects - - - Engine\Objects - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - - - Engine - IO @@ -1313,12 +1176,144 @@ Engine\Objects + + Engine\Objects + Engine\Objects Engine\Objects + + Engine\Objects + + + Engine\Spells + + + Engine\Spells + + + Engine\Tables + + + Engine\Tables + + + Engine\Tables + + + Engine\Tables + + + Engine\Tables + + + Engine\Tables + + + Engine\TurnEngine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + + + Engine + @@ -1351,7 +1346,7 @@ lib - + Engine\Objects diff -r 92eeeb5200f2 -r 68cdef6879a0 CastSpellInfo.cpp --- a/CastSpellInfo.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3576 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include "CastSpellInfo.h" -#include "Actor.h" -#include "Party.h" -#include "MM7.h" -#include "Mouse.h" -#include "stru6.h" -#include "Game.h" -#include "GUIWindow.h" -#include "AudioPlayer.h" -#include "Engine/Graphics/Outdoor.h" -#include "Engine/Graphics/Overlays.h" -#include "Events.h" -#include "Engine/Graphics/Viewport.h" -#include "OurMath.h" -#include "SpriteObject.h" -#include "ObjectList.h" -#include "stru123.h" -#include "Timer.h" -#include "IconFrameTable.h" -#include "Awards.h" -#include "TurnEngine.h" -#include "texts.h" -#include "LOD.h" -#include "Engine/Graphics/Level/Decoration.h" - -#include "UI\UIPartyCreation.h" - -const size_t CastSpellInfoCount = 10; -std::array pCastSpellInfo; - -//----- (00427E01) -------------------------------------------------------- -void CastSpellInfoHelpers::_427E01_cast_spell() -{ - int spell_level; // edi@1 - CastSpellInfo *pCastSpell; // ebx@2 - signed int v6; // eax@14 - unsigned __int16 v11; // cx@45 - signed int i; // esi@76 -// Actor *pActor; // edi@177 - int v61; // ecx@184 - int v111; // eax@274 - int dist_X; // eax@278 -// int new_dist_Y; - int dist_Z; -// int v116; // edx@279 -// int v117; // edx@281 -// int v118; // edx@283 - int v169; // eax@344 - int v188; // esi@369 - int v189; // edi@369 - int v206; // eax@407 - double v241; // st7@478 - ItemGen *v245; // edi@492 - int v258; // ecx@514 - char v259; // al@516 - int v260; // eax@518 - int v261; // esi@519 - int v262; // edx@521 - int *v263; // ecx@521 - int v264; // esi@521 - int v265; // edx@521 - int *ii; // eax@522 - int v267; // eax@524 - int v268; // eax@524 - int v278; // ecx@548 - char v279; // al@550 - int v280; // eax@552 - int *v281; // esi@553 - int v282; // edx@555 - int *v283; // ecx@555 - int v284; // esi@555 - int v285; // edx@555 - int *l; // eax@556 - int v295; // edx@575 - char v313; // al@606pGame->GetStru6() - const char *v317; // ecx@617 -// int v396; // eax@752 - __int16 v448; // ax@864 - DDM_DLV_Header *v613; // eax@1108 - int v642; // edi@1156 - int v643; // eax@1156 - int v659; // [sp+0h] [bp-E84h]@123 - unsigned __int64 v663; // [sp+0h] [bp-E84h]@639 - int v666; // [sp+4h] [bp-E80h]@12 - PLAYER_SKILL_TYPE v667; // [sp+4h] [bp-E80h]@25 - int v679[800]; // [sp+14h] [bp-E70h]@515 - unsigned __int64 v685; // [sp+D08h] [bp-17Ch]@416 - unsigned __int64 v687; // [sp+D24h] [bp-160h]@327 - Vec3_int_ v688; // [sp+D2Ch] [bp-158h]@943 - Vec3_int_ v691; // [sp+D38h] [bp-14Ch]@137 - Vec3_int_ v694; // [sp+D44h] [bp-140h]@982 - Vec3_int_ v697; // [sp+D50h] [bp-134h]@129 - Vec3_int_ v700; // [sp+D5Ch] [bp-128h]@339 - Vec3_int_ v701; // [sp+D68h] [bp-11Ch]@286 - Vec3_int_ v704; // [sp+D74h] [bp-110h]@132 - Vec3_int_ v707; // [sp+D80h] [bp-104h]@1127 - int v710; // [sp+D8Ch] [bp-F8h]@1156 - int n; // [sp+DA0h] [bp-E4h]@1 - AIDirection v715; // [sp+DA4h] [bp-E0h]@21 - int mon_id; - int dist_Y; // [sp+DD8h] [bp-ACh]@163 - int v723; // [sp+E4Ch] [bp-38h]@1 - ItemGen *_this; // [sp+E50h] [bp-34h]@23 - int v725; // [sp+E54h] [bp-30h]@23 - int buff_resist; - bool spell_sound_flag; // [sp+E5Ch] [bp-28h]@1 - Player *pPlayer; // [sp+E64h] [bp-20h]@8 - int v730; // [sp+E68h] [bp-1Ch]@53 - ItemGen *v730c; - int skill_level; // [sp+E6Ch] [bp-18h]@48 - signed int v732; // [sp+E70h] [bp-14h]@325 - unsigned __int64 v733; // [sp+E74h] [bp-10h]@1 - int duration; - signed int a2; // [sp+E7Ch] [bp-8h]@14 - int amount; // [sp+E80h] [bp-4h]@1 - int obj_type; - ItemDesc* _item; - - SpriteObject pSpellSprite; // [sp+DDCh] [bp-A8h]@1 - - spell_level = 0; - amount = 0; - LODWORD(v733) = 0; - v723 = 0; - spell_sound_flag = false; - for(n = 0; n < CastSpellInfoCount; ++n) - { - pCastSpell = &pCastSpellInfo[n]; - HIDWORD(v733) = (int)pCastSpell; - if ( pCastSpell->uSpellID == 0 ) - continue; - - if (pParty->Invisible()) - pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); - - if ( pCastSpell->uFlags & 0x3CA ) - { - if ( !pParty->pPlayers[pCastSpell->uPlayerID].CanAct() ) - _427D48(); - continue; - } - pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID]; - - a2 = pCastSpell->spell_target_pid; - if (!pCastSpell->spell_target_pid) - { - if (pCastSpell->uSpellID == SPELL_LIGHT_DESTROY_UNDEAD || - pCastSpell->uSpellID == SPELL_SPIRIT_TURN_UNDEAD || - pCastSpell->uSpellID == SPELL_DARK_CONTROL_UNDEAD ) - v666 = 1; - else - v666 = 0; - - a2 = stru_50C198.FindClosestActor(5120, 1, v666); - v6 = pMouse->uPointingObjectID; - if ( pMouse->uPointingObjectID && PID_TYPE(v6) == OBJECT_Actor && pActors[PID_ID(v6)].CanAct() ) - a2 = pMouse->uPointingObjectID; - } - - - pSpellSprite.uType = stru_4E3ACC[pCastSpell->uSpellID].uType; - if (pSpellSprite.uType) - { - if (PID_TYPE(a2) == OBJECT_Actor) - { - Actor::GetDirectionInfo(PID(OBJECT_Player, pCastSpell->uPlayerID + 1), a2, &v715, 0); - spell_level = v723; - } - else - { - v715.uYawAngle = pParty->sRotationY; - v715.uPitchAngle = pParty->sRotationX; - } - } - - v725 = 0; - _this = 0; - if (pCastSpell->forced_spell_skill_level) - { - v11 = pCastSpell->forced_spell_skill_level; - v723 = v11 & 0x3F; // 6 bytes - spell_level = v723; - } - else - { - //v667 = PLAYER_SKILL_STAFF; - if (pCastSpell->uSpellID < SPELL_AIR_WIZARD_EYE) - v667 = PLAYER_SKILL_FIRE; - else if (pCastSpell->uSpellID < SPELL_WATER_AWAKEN) - v667 = PLAYER_SKILL_AIR; - else if (pCastSpell->uSpellID < SPELL_EARTH_STUN) - v667 = PLAYER_SKILL_WATER; - else if (pCastSpell->uSpellID < SPELL_SPIRIT_DETECT_LIFE) - v667 = PLAYER_SKILL_EARTH; - else if (pCastSpell->uSpellID < SPELL_MIND_REMOVE_FEAR) - v667 = PLAYER_SKILL_SPIRIT; - else if (pCastSpell->uSpellID < SPELL_BODY_CURE_WEAKNESS) - v667 = PLAYER_SKILL_MIND; - else if (pCastSpell->uSpellID < SPELL_LIGHT_LIGHT_BOLT) - v667 = PLAYER_SKILL_BODY; - else if (pCastSpell->uSpellID < SPELL_DARK_REANIMATE) - v667 = PLAYER_SKILL_LIGHT; - else if (pCastSpell->uSpellID < SPELL_BOW_ARROW) - v667 = PLAYER_SKILL_DARK; - else if (pCastSpell->uSpellID == SPELL_BOW_ARROW) - v667 = PLAYER_SKILL_BOW; - else if (pCastSpell->uSpellID == SPELL_101 || pCastSpell->uSpellID == SPELL_LASER_PROJECTILE ) - v667 = PLAYER_SKILL_BLASTER; - else assert(false && "Unknown spell"); - - v725 = v667; - v723 = pPlayer->GetActualSkillLevel(v667) & 0x3F; - spell_level = v723; - v11 = pPlayer->pActiveSkills[v725]; - } - - skill_level = SkillToMastery(v11); - if (pCastSpell->uSpellID < SPELL_BOW_ARROW ) - { - if (pCastSpell->forced_spell_skill_level) - uRequiredMana = 0; - else - uRequiredMana = pSpellDatas[pCastSpell->uSpellID].mana_per_skill[skill_level - 1]; - sRecoveryTime = pSpellDatas[pCastSpell->uSpellID].recovery_per_skill[skill_level - 1]; - } - - if (v725 == PLAYER_SKILL_DARK && pParty->uCurrentHour == 0 && pParty->uCurrentMinute == 0 || - v725 == PLAYER_SKILL_LIGHT && pParty->uCurrentHour == 12 && pParty->uCurrentMinute == 0) - uRequiredMana = 0; - - if (pCastSpell->uSpellID < SPELL_BOW_ARROW && pPlayer->sMana < uRequiredMana) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[586], 2); // "Not enough spell points" - pCastSpell->uSpellID = 0; - continue; - } - v730 = pCastSpell->uSpellID; - if (pPlayer->IsCursed() && pCastSpell->uSpellID < SPELL_BOW_ARROW && rand() % 100 < 50)//íåóäà÷íîå êàñòîâàíèå - { - if (!pParty->bTurnBasedModeOn) - pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); - else - { - pParty->pTurnBasedPlayerRecoveryTimes[pCastSpellInfo[n].uPlayerID] = 100; - pPlayer->SetRecoveryTime(sRecoveryTime); - pTurnEngine->ApplyPlayerAction(); - } - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // "Spell failed" - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpellInfo[n].uSpellID = 0; - pPlayer->sMana -= uRequiredMana; - return; - } - - switch ( pCastSpell->uSpellID ) - { - case SPELL_101: - assert(false && "Unknown spell effect #101 (prolly flaming bow arrow"); - case SPELL_BOW_ARROW://ñòðåëüáà èç ëóêà - { - amount = 1; - if ( SkillToMastery(pPlayer->pActiveSkills[PLAYER_SKILL_BOW]) >= 3 ) - amount = 2; - sRecoveryTime = pPlayer->GetAttackRecoveryTime(true); - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - if ( pPlayer->WearsItem(ITEM_ARTEFACT_ULLYSES, EQUIP_BOW) ) - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u); - pSpellSprite.vPosition.x = pParty->vPosition.x; - pSpellSprite.vPosition.y = pParty->vPosition.y; - pSpellSprite.uAttributes = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(v715.uYawAngle); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID]; - memcpy(&pSpellSprite.stru_24, &pPlayer->pInventoryItemList[pPlayer->pEquipment.uBow-1], sizeof(pSpellSprite.stru_24)); - pSpellSprite.uAttributes = 256; - if ( pParty->bTurnBasedModeOn == 1 ) - pSpellSprite.uAttributes = 260; - for ( i = 0; i < amount; ++i ) - { - if ( i ) - pSpellSprite.vPosition.z += 32; - pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z); - if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, - pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - } - break; - } - case SPELL_LASER_PROJECTILE://ñòðåëüáà èç áëàñòåðà - { - sRecoveryTime = pPlayer->GetAttackRecoveryTime(0); - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = v723; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.x = pParty->vPosition.x; - pSpellSprite.vPosition.y = pParty->vPosition.y; - pSpellSprite.uAttributes = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(v715.uYawAngle); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID]; - memcpy(&pSpellSprite.stru_24, &pPlayer->pInventoryItemList[pPlayer->pEquipment.uMainHand - 1],sizeof(pSpellSprite.stru_24)); - // &pParty->pPlayers[pCastSpell->uPlayerID].spellbook.pDarkSpellbook.bIsSpellAvailable[36 - // * pParty->pPlayers[pCastSpell->uPlayerID].pEquipment.uMainHand + 5], ); - pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z); - HIBYTE(pSpellSprite.uAttributes) |= 1; - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(pSpellSprite.uAttributes) |= 4; - if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, - pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - break; - } - case SPELL_FIRE_TORCH_LIGHT://ñâåò ôàêåëà - { - switch (skill_level) - { - case 1: amount = 2; break; - case 2: amount = 3; break; - case 3: - case 4: amount = 4; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)3600 * spell_level * 4.2666669), skill_level, amount, 0, 0); - spell_sound_flag = true; - break; - } - case SPELL_FIRE_FIRE_SPIKE://îãíåííûé øèï - { - switch (skill_level) - { - case 1: amount = 3; break; - case 2: amount = 5; break; - case 3: amount = 7; break; - case 4: amount = 9; break; - default: - assert(false); - } - int _v733 = 0; - for (uint i = 0; i < uNumSpriteObjects; ++i) - { - SpriteObject* object = &pSpriteObjects[i]; - if (object->uType && object->spell_id == SPELL_FIRE_FIRE_SPIKE && object->spell_caster_pid == PID(OBJECT_Player, pCastSpell->uPlayerID)) - ++_v733; - } - if ( _v733 > amount ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.y = pParty->vPosition.y; - pSpellSprite.vPosition.x = pParty->vPosition.x; - pSpellSprite.uAttributes = 0; - pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(v715.uYawAngle); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(pSpellSprite.uAttributes) |= 4; - v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; - if ( pSpellSprite.Create(pParty->sRotationY, pParty->sRotationX + 10, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - spell_sound_flag = true; - break; - } - case SPELL_AIR_IMPLOSION://Òî÷íûé âçðûâ - { - mon_id = PID_ID(a2); - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if (!a2) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if (PID_TYPE(a2) == OBJECT_Actor) - { - v697.x = 0; - v697.y = 0; - v697.z = 0; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.field_60_distance_related_prolly_lod = 0; - pSpellSprite.uFacing = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; - pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z; - pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; - pSpellSprite.spell_target_pid = PID(OBJECT_Actor, mon_id); - Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), mon_id, &v697); - } - spell_sound_flag = true; - break; - } - case SPELL_EARTH_MASS_DISTORTION://Èçìåíåíèå âåñà - { - mon_id = PID_ID(a2); - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if ( pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)3) ) - { - pActors[mon_id].pActorBuffs[ACTOR_BUFF_MASS_DISTORTION].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0); - v704.x = 0; - v704.y = 0; - v704.z = 0; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.field_60_distance_related_prolly_lod = 0; - pSpellSprite.uFacing = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; - pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; - pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z; - pSpellSprite.spell_target_pid = PID(OBJECT_Actor, mon_id); - Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), mon_id, &v704); - } - spell_sound_flag = true; - break; - } - case SPELL_LIGHT_DESTROY_UNDEAD://Óíè÷òîæåíèå íåæèòè - { - if ( !pPlayer->CanCastSpell(uRequiredMana) || !a2 || PID_TYPE(a2) != OBJECT_Actor) - break; - //v730 = a2 >> 3; - //HIDWORD(v733) = (int)&pActors[PID_ID(a2)]; - v691.x = 0; - v691.y = 0; - v691.z = 0; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.x = pActors[PID_ID(a2)].vPosition.x; - pSpellSprite.vPosition.y = pActors[PID_ID(a2)].vPosition.y; - pSpellSprite.vPosition.z = pActors[PID_ID(a2)].vPosition.z; - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(v715.uYawAngle); - pSpellSprite.uAttributes |= 0x80u; - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - int obj_id = pSpellSprite.Create(0, 0, 0, 0); - if ( !MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - Actor::DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v691); - spell_sound_flag = true; - break; - } - case SPELL_FIRE_FIRE_BOLT://Óäàð îãíÿ - case SPELL_FIRE_FIREBALL://Îãíåííûé øàð - case SPELL_FIRE_INCINERATE://Èñïåïåëåíèå - case SPELL_AIR_LIGHNING_BOLT://Óäàð ìîëíèè - case SPELL_WATER_ICE_BOLT://Ëüäÿíàÿ ìîëíèÿ - case SPELL_WATER_ICE_BLAST://Ëüäÿíîé âçðûâ - case SPELL_EARTH_STUN://Îãëóøèòü - case SPELL_EARTH_DEADLY_SWARM://Ðîé ñìåðòè - case SPELL_MIND_MIND_BLAST://Óäàð ìûñëè - case SPELL_MIND_PSYCHIC_SHOCK://Ïñèõè÷åñêèé øîê - case SPELL_BODY_HARM://Âðåä - case SPELL_LIGHT_LIGHT_BOLT://Ëó÷ ñâåòà - case SPELL_DARK_DRAGON_BREATH://Äûõàíèå äðàêîíà - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.y = pParty->vPosition.y; - pSpellSprite.vPosition.x = pParty->vPosition.x; - pSpellSprite.uAttributes = 0; - pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); - else - pSpellSprite.uSectorID = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(v715.uYawAngle); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(pSpellSprite.uAttributes) |= 4; - if ( pCastSpell->uSpellID == SPELL_AIR_LIGHNING_BOLT ) - LOBYTE(pSpellSprite.uAttributes) |= 0x40; - v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; - if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - spell_sound_flag = true; - break; - } - case SPELL_WATER_ACID_BURST://Âñïëåñê êèñëîòû - case SPELL_EARTH_BLADES://Ëåçâèÿ - case SPELL_BODY_FLYING_FIST://Ëåòàþùèé êóëàê - case SPELL_DARK_TOXIC_CLOUD://Îáëàêî-òîêñèí - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.vPosition.x = pParty->vPosition.x; - pSpellSprite.vPosition.y = pParty->vPosition.y; - pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2; - pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(v715.uYawAngle); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(pSpellSprite.uAttributes) |= 4; - v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; - if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - spell_sound_flag = true; - break; - } - case SPELL_LIGHT_SUNRAY://Ëó÷ Ñîëíöà - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor - || uCurrentlyLoadedLevelType == LEVEL_Outdoor && (pParty->uCurrentHour < 5 || pParty->uCurrentHour >= 21) )//òîëüêî â äíåâíîå âðåìÿ - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if ( pPlayer->CanCastSpell(uRequiredMana) ) - { - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.spell_level = spell_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.vPosition.x = pParty->vPosition.x; - pSpellSprite.vPosition.y = pParty->vPosition.y; - pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(v715.uYawAngle); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(pSpellSprite.uAttributes) |= 4; - v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; - if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - spell_sound_flag = true; - } - break; - } - case SPELL_LIGHT_PARALYZE://Ïàðàëè÷ - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - mon_id = PID_ID(a2); - if (PID_TYPE(a2) == OBJECT_Actor && pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)9) ) - { - Actor::AI_Stand(PID_ID(a2), 4, 0x80, 0); - pActors[mon_id].pActorBuffs[ACTOR_BUFF_PARALYZED].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)23040 * spell_level * 0.033333335), skill_level, 0, 0, 0); - pActors[mon_id].uAttributes |= ACTOR_AGGRESSOR; - pActors[mon_id].vVelocity.x = 0; - pActors[mon_id].vVelocity.y = 0; - pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(&pActors[mon_id], 0); - } - spell_sound_flag = true; - break; - } - case SPELL_EARTH_SLOW://Çàìåäëåíèå - { - switch (skill_level) - { - case 1: LODWORD(v733) = 180 * spell_level; amount = 2; break;//LODWORD(v733)???íå ïðèìåíÿåòñÿ äàëåå - case 2: LODWORD(v733) = 300 * spell_level; amount = 2; break; - case 3: LODWORD(v733) = 300 * spell_level; amount = 4; break; - case 4: LODWORD(v733) = 300 * spell_level; amount = 8; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - //v721 = 836 * PID_ID(a2); - mon_id = PID_ID(a2); - if (PID_TYPE(a2) == OBJECT_Actor && pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)3) ) - { - pActors[mon_id].pActorBuffs[ACTOR_BUFF_SLOWED].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)23040 * spell_level * 0.033333335), skill_level, amount, 0, 0); - pActors[mon_id].uAttributes |= ACTOR_AGGRESSOR; - pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(&pActors[mon_id], 0); - } - spell_sound_flag = true; - break; - } - case SPELL_MIND_CHARM:// Î÷àðîâàíèå - { - v61 = PID_ID(a2); - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if ( pActors[v61].DoesDmgTypeDoDamage((DAMAGE_TYPE)7) ) - { - uint power = 300 * spell_level; - if ( skill_level == 2 ) - power = 600 * spell_level; - else if ( skill_level == 3 ) - power = 29030400; - - pActors[v61].pActorBuffs[ACTOR_BUFF_BERSERK].Reset(); - pActors[v61].pActorBuffs[ACTOR_BUFF_ENSLAVED].Reset(); - pActors[v61].pActorBuffs[ACTOR_BUFF_CHARM].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(power << 7) * 0.033333335), skill_level, 0, 0, 0); - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.x = pActors[v61].vPosition.x; - pSpellSprite.vPosition.y = pActors[v61].vPosition.y; - pSpellSprite.vPosition.z = pActors[v61].vPosition.z + pActors[v61].uActorHeight; - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = pIndoor->GetSector(pActors[v61].vPosition.x, pActors[v61].vPosition.y, pSpellSprite.vPosition.z); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(v715.uYawAngle); - LOBYTE(pSpellSprite.uAttributes) |= 0x80u; - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); - } - spell_sound_flag = true; - break; - } - case SPELL_DARK_SHRINKING_RAY://Ñæèìàþùèé ëó÷ - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pSpellSprite.stru_24.Reset(); - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.x = pParty->vPosition.x; - pSpellSprite.vPosition.y = pParty->vPosition.y; - pSpellSprite.uAttributes = 0; - pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(v715.uYawAngle); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - pSpellSprite.spell_skill = skill_level; - pSpellSprite.spell_id = SPELL_FIRE_PROTECTION_FROM_FIRE; - pSpellSprite.spell_level = 300 * spell_level; - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(pSpellSprite.uAttributes) |= 4; - v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; - if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - spell_sound_flag = true; - break; - } - case SPELL_FIRE_FIRE_AURA: //Àóðà îãíÿ - { - switch (skill_level) - { - case 1: duration = 3600 * spell_level; amount = 10; break; //Îãíÿ - case 2: duration = 3600 * spell_level; amount = 11; break; //Îãíåííîãî æàðà - case 3: duration = 3600 * spell_level; amount = 12; break; - case 4: duration = 0; amount = 12; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - v730c = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2]; - _item = &pItemsTable->pItems[v730c->uItemID]; - v730c->UpdateTempBonus(pParty->uTimePlayed); - if ( v730c->uItemID < 64 || v730c->uItemID > 65 - && !v730c->IsBroken() - && !v730c->uSpecEnchantmentType - && !v730c->uEnchantmentType - && ( _item->uEquipType == EQUIP_SINGLE_HANDED || _item->uEquipType == EQUIP_TWO_HANDED || _item->uEquipType == EQUIP_BOW) - && !pItemsTable->IsMaterialNonCommon(v730c) ) - { - v730c->uSpecEnchantmentType = amount; - if ( skill_level != 4 ) - { - v730c->uExpireTime = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335); - v730c->uAttributes |= ITEM_TEMP_BONUS; - } - v730c->uAttributes |= ITEM_AURA_EFFECT_RED; - _50C9A8_item_enchantment_timer = 256; - spell_sound_flag = true; - break; - } - _50C9D0_AfterEnchClickEventId = 113; - _50C9D4_AfterEnchClickEventSecondParam = 0; - _50C9D8_AfterEnchClickEventTimeout = 1; - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - case SPELL_BODY_REGENERATION://Ðåãåíåðàöèÿ - { - switch (skill_level) - { - case 1: amount = 1; break; - case 2: amount = 1; break; - case 3: amount = 3; break; - case 4: amount = 10; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - 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)(3600 * spell_level) * 4.2666669), skill_level, amount, 0, 0); - spell_sound_flag = true; - break; - } - case SPELL_FIRE_PROTECTION_FROM_FIRE://Çàùèòà îò Îãíÿ - case SPELL_AIR_PROTECTION_FROM_AIR://Çâùèòà îò Âîçäóõà - case SPELL_WATER_PROTECTION_FROM_WATER://Çàùèòà îò Âîäû - case SPELL_EARTH_PROTECTION_FROM_EARTH://Çàùèòà îò Çåìëè - case SPELL_MIND_PROTECTION_FROM_MIND://Çàùèòà îò Ìûñëè - case SPELL_BODY_PROTECTION_FROM_BODY://Çàùèòà îò Òåëà - { - switch (skill_level) - { - case 1: - case 2: - case 3: - case 4: amount = skill_level * spell_level; break; - default: - assert(false); - } - switch (pCastSpell->uSpellID) - { - case SPELL_FIRE_PROTECTION_FROM_FIRE: - buff_resist = PARTY_BUFF_RESIST_FIRE; - break; - case SPELL_AIR_PROTECTION_FROM_AIR: - buff_resist = PARTY_BUFF_RESIST_AIR; - break; - case SPELL_WATER_PROTECTION_FROM_WATER: - buff_resist = PARTY_BUFF_RESIST_WATER; - break; - case SPELL_EARTH_PROTECTION_FROM_EARTH: - buff_resist = PARTY_BUFF_RESIST_EARTH; - break; - case SPELL_MIND_PROTECTION_FROM_MIND: - buff_resist = PARTY_BUFF_RESIST_MIND; - break; - case SPELL_BODY_PROTECTION_FROM_BODY: - buff_resist = PARTY_BUFF_RESIST_BODY; - break; - default: - assert(false); - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - 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)(3600 * spell_level) * 4.2666669; - pParty->pPartyBuffs[buff_resist].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(3600 * spell_level) * 4.2666669), skill_level, amount, 0, 0); - spell_sound_flag = true; - break; - } - case SPELL_FIRE_HASTE://Ñïåøêà - { - switch (skill_level) - { - case 1: duration = 60 * (spell_level + 60); break; - case 2: duration = 60 * (spell_level + 60); break; - case 3: duration = 180 * (spell_level + 20); break; - case 4: duration = 240 * (spell_level + 15); break; - default: - assert(false); - } - if ( pPlayer->CanCastSpell(uRequiredMana) ) - { - spell_sound_flag = true; - for ( uint pl_id = 0; pl_id < 4; pl_id++ ) - { - if ( pParty->pPlayers[pl_id].pConditions[Condition_Weak] ) - spell_sound_flag = false; - } - if ( spell_sound_flag ) - { - pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, 0, 0); - 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; - } - case SPELL_SPIRIT_BLESS://Áëàãîñëîâåíèå - { - switch (skill_level) - { - case 1: duration = 300 * (spell_level + 12); break; - case 2: duration = 300 * (spell_level + 12); break; - case 3: duration = 900 * (spell_level + 4); break; - case 4: duration = 3600 * (spell_level + 1); break; - default: - assert(false); - } - amount = spell_level + 5; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if ( skill_level == 1 ) - { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); - v111 = pOtherOverlayList->_4418B1(10000, pCastSpell->uPlayerID_2 + 310, 0, 65536); - pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed + - (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), 1, amount, v111, 0); - spell_sound_flag = true; - break; - } - for ( uint pl_id = 0; pl_id < 4; pl_id++ ) - { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id); - v111 = pOtherOverlayList->_4418B1(10000, pl_id + 310, 0, 65536); - pParty->pPlayers[pl_id].pPlayerBuffs[1].Apply(pParty->uTimePlayed + - (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, amount, v111, 0); - } - spell_sound_flag = true; - break; - } - case SPELL_SPIRIT_SPIRIT_LASH://Ïëåòü Äóõà - { - if ( pPlayer->CanCastSpell(uRequiredMana) && a2 && PID_TYPE(a2) == OBJECT_Actor) - { - int mon_id = PID_ID(a2); - dist_X = abs(pActors[mon_id].vPosition.x - pParty->vPosition.x); - dist_Y = abs(pActors[mon_id].vPosition.y - pParty->vPosition.y); - dist_Z = abs(pActors[mon_id].vPosition.z - pParty->vPosition.z); - int count = int_get_vector_length(dist_X, dist_Y, dist_Z); - if ( (double)count <= 307.2 ) - { - v701.x = 0; - v701.y = 0; - v701.z = 0; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = v723; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.field_60_distance_related_prolly_lod = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.uFacing = 0; - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; - pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; - pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z - (unsigned int)(signed __int64)((double)pActors[mon_id].uActorHeight * -0.8); - pSpellSprite.spell_target_pid = PID(OBJECT_Actor, a2); - Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), mon_id, &v701); - spell_sound_flag = true; - } - else - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);//"Íå ïîëó÷èëîñü!!!" - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - } - } - break; - } - case SPELL_AIR_SHIELD://Ùèò - case SPELL_EARTH_STONESKIN://Êàìåííàÿ êîæà - case SPELL_SPIRIT_HEROISM://Ãåðîèçì - { - switch (skill_level) - { - case 1: duration = 300 * (spell_level + 12); break; - case 2: duration = 300 * (spell_level + 12); break; - case 3: duration = 900 * (spell_level + 4); break; - case 4: duration = 3600 * (spell_level + 1); break; - default: - assert(false); - } - switch (pCastSpell->uSpellID) - { - case SPELL_AIR_SHIELD: - amount = 0; - buff_resist = PARTY_BUFF_SHIELD; - break; - case SPELL_EARTH_STONESKIN: - amount = spell_level + 5; - buff_resist = PARTY_BUFF_STONE_SKIN; - break; - case SPELL_SPIRIT_HEROISM: - amount = spell_level + 5; - buff_resist = PARTY_BUFF_HEROISM; - break; - default: - assert(false); - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - 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[buff_resist].Apply(pParty->uTimePlayed + - (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, amount, 0, 0); - spell_sound_flag = true; - break; - } - case SPELL_FIRE_IMMOLATION://Êîëüöî îãíÿ - { - if ( skill_level == 4 ) - duration = 600 * spell_level; - else - duration = 60 * spell_level; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - 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)duration << 7) * 0.033333335), skill_level, spell_level, 0, 0); - spell_sound_flag = true; - break; - } - case SPELL_FIRE_METEOR_SHOWER://Ïîòîê ìåòåîðîâ - { - //if (skill_level < 3)//äëÿ ìàñòåðà è ìàãèñòðà - //break; - int meteor_num; - if ( skill_level == 4 ) - meteor_num = 20; - else - meteor_num = 16; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[491], 2); // Can't cast Meteor Shower indoors! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - obj_type = PID_TYPE(a2); - mon_id = PID_ID(a2); - if (obj_type == OBJECT_Actor)//åñëè çàêë ïîñòàâèòü íà áûñòðîå çàêë., òî ìîæíî óêàçûâàòü êóäà êèäàòü ìåòåîðû - { - dist_X = pActors[mon_id].vPosition.x; - dist_Y = pActors[mon_id].vPosition.y; - dist_Z = pActors[mon_id].vPosition.z; - } - else - { - dist_X = pParty->vPosition.x + fixpoint_mul(2048, stru_5C6E00->Cos(pParty->sRotationY)); - dist_Y = pParty->vPosition.y + fixpoint_mul(2048, stru_5C6E00->Sin(pParty->sRotationY)); - dist_Z = pParty->vPosition.z; - } - unsigned __int64 k = 0; - int j = 0; - if ( meteor_num > 0 ) - { - v730 = obj_type == OBJECT_Actor ? a2 : 0; - for ( meteor_num; meteor_num; meteor_num-- ) - { - a2 = rand() % 1000; - if ( sqrt(((double)a2 - 2500) * ((double)a2 - 2500) + j * j + k * k) <= 1.0 ) - { - LODWORD(v687) = 0; - HIDWORD(v687) = 0; - } - else - { - HIDWORD(v687) = stru_5C6E00->Atan2((signed __int64)sqrt((float)(j * j + k * k)), (double)a2 - 2500); - LODWORD(v687) = stru_5C6E00->Atan2(j, k); - } - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.vPosition.x = dist_X; - pSpellSprite.vPosition.y = dist_Y; - pSpellSprite.vPosition.z = a2 + dist_Z; - pSpellSprite.uSectorID = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = v730; - pSpellSprite.field_60_distance_related_prolly_lod = stru_50C198._427546(a2 + 2500); - pSpellSprite.uFacing = v687; - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - pSpellSprite.uAttributes = 4; - if ( pSpellSprite.Create(v687, SHIDWORD(v687), pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, 0) != -1 && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - j = rand() % 1024 - 512; - k = rand() % 1024 - 512; - } - } - spell_sound_flag = true; - break; - } - case SPELL_FIRE_INFERNO://Àäñêèé îãîíü - { - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[492], 2); // Can't cast Inferno outdoors! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - int mon_num = pRenderer->_46À6ÀÑ_GetActorsInViewport(4096); - v700.x = 0; - v700.y = 0; - v700.z = 0; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.field_60_distance_related_prolly_lod = 0; - pSpellSprite.uFacing = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - for ( uint i = 0; i < mon_num; i++ ) - { - pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[i]].vPosition.x; - pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[i]].vPosition.y; - pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[i]].vPosition.z - (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[i]].uActorHeight * -0.8); - pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[i]); - Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), _50BF30_actors_in_viewport_ids[i], &v700); - pGame->GetStru6()->_4A81CA(&pSpellSprite); - pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFF3C1E, 0x40); - } - spell_sound_flag = true; - break; - } - case SPELL_AIR_WIZARD_EYE://Îêî ÷àðîäåÿ - { - duration = 3600 * spell_level; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - for ( uint pl_id = 0; pl_id < 4; pl_id++ ) - v169 = pOtherOverlayList->_4418B1(2000, pl_id + 100, 0, 65536); - pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, v169, 0); - spell_sound_flag = true; - break; - } - case SPELL_AIR_FEATHER_FALL://Ïàäåíèå ïåðà(ï¸ðûøêîì) - { - switch (skill_level) - { - case 1: duration = 300 * spell_level; break; - case 2: duration = 600 * spell_level; break; - case 3: duration = 3600 * spell_level; break; - case 4: duration = 3600 * spell_level; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - for ( uint pl_id = 0; pl_id < 4; pl_id++ ) - pOtherOverlayList->_4418B1(2010, pl_id + 100, 0, 65536); - 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)duration << 7) * 0.033333335), skill_level, 0, 0, 0); - spell_sound_flag = true; - break; - } - case SPELL_AIR_SPARKS://Èñêðû - { - switch (skill_level) - { - case 1: amount = 3; break; - case 2: amount = 5; break; - case 3: amount = 7; break; - case 4: amount = 9; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - int _v726 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.y = pParty->vPosition.y; - pSpellSprite.vPosition.x = pParty->vPosition.x; - pSpellSprite.uAttributes = 0; - pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, - pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(pSpellSprite.uAttributes) |= 4; - v188 = (signed int)_v726 / -2; - v189 = (signed int)_v726 / 2; - while ( v188 <= v189 ) - { - pSpellSprite.uFacing = v188 + LOWORD(v715.uYawAngle); - if ( pSpellSprite.Create((signed __int16)(v188 + LOWORD(v715.uYawAngle)), v715.uPitchAngle, - pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, pCastSpell->uPlayerID + 1) != -1 - && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - v188 += _v726 / (amount - 1); - } - spell_sound_flag = true; - break; - } - case SPELL_AIR_JUMP://Ïðûæîê - { - if ( pParty->uFlags & PARTY_FLAGS_1_FALLING) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[493], 2); // Can't cast Jump while airborne! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - break; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - for ( uint pl_id = 0; pl_id < 4; pl_id++ ) - pOtherOverlayList->_4418B1(2040, pl_id + 100, 0, 65536); - pParty->uFlags |= 0x100; - pParty->uFallSpeed = 1000; - spell_sound_flag = true; - break; - } - case SPELL_AIR_INVISIBILITY://Íåâèäèìîñòü - { - switch (skill_level) - { - case 1: duration = 600 * spell_level; amount = spell_level; break; - case 2: duration = 600 * spell_level; amount = 2 * spell_level; break; - case 3: duration = 600 * spell_level; amount = 3 * spell_level; break; - case 4: duration = 3600 * spell_level; amount = 4 * spell_level; break; - default: - assert(false); - } - if (pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW)) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[638], 2); // There are hostile creatures nearby! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if ( pPlayer->CanCastSpell(uRequiredMana) ) - { - 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)duration << 7) * 0.033333335), skill_level, amount, 0, 0); - spell_sound_flag = true; - } - break; - } - case SPELL_AIR_FLY://Ïîë¸ò - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2); // Can not cast Fly indoors! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - break; - } - if ( !pPlayers[pCastSpell->uPlayerID + 1]->GetMaxMana() ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - break; - } - if ( skill_level == 1 || skill_level == 2 || skill_level == 3 ) - amount = 1; - else - amount = 0; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - for ( uint pl_id = 0; pl_id < 4; pl_id++) - pOtherOverlayList->_4418B1(2090, pl_id + 100, 0, 65536); - v206 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536); - pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)(3600 * spell_level) << 7) - * 0.033333335), skill_level, amount, v206, pCastSpell->uPlayerID + 1); - spell_sound_flag = true; - break; - } - case SPELL_AIR_STARBURST://Çâåçäîïàä - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[495], 2); // Can't cast Starburst indoors! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - obj_type = PID_TYPE(a2); - mon_id = PID_ID(a2); - if ( obj_type == OBJECT_Actor ) - { - dist_X = pActors[mon_id].vPosition.x; - dist_Y = pActors[mon_id].vPosition.y; - dist_Z = pActors[mon_id].vPosition.z; - } - else - { - dist_X = pParty->vPosition.x + fixpoint_mul(2048, stru_5C6E00->Cos(pParty->sRotationY)); - dist_Y = pParty->vPosition.y + fixpoint_mul(2048, stru_5C6E00->Sin(pParty->sRotationY)); - dist_Z = pParty->vPosition.z; - } - unsigned __int64 k = 0; - int j = 0; - v730 = obj_type == OBJECT_Actor ? a2 : 0; - for ( uint star_num = 20; star_num; star_num-- ) - { - a2 = rand() % 1000; - if ( sqrt(((double)a2 + (double)dist_Z - (double)(dist_Z + 2500)) * ((double)a2 + (double)dist_Z - (double)(dist_Z + 2500)) - + j * j + k * k) <= 1.0 ) - { - LODWORD(v685) = 0; - HIDWORD(v685) = 0; - } - else - { - HIDWORD(v685) = stru_5C6E00->Atan2((signed __int64)sqrt((float)(j * j + k * k)), ((double)a2 + (double)dist_Z - (double)(dist_Z + 2500))); - LODWORD(v685) = stru_5C6E00->Atan2(j, k); - } - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.vPosition.x = dist_X; - pSpellSprite.vPosition.y = dist_Y; - pSpellSprite.vPosition.z = (int)(a2 + (dist_Z + 2500)); - pSpellSprite.uSectorID = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = v730; - pSpellSprite.field_60_distance_related_prolly_lod = stru_50C198._427546(a2 + 2500); - pSpellSprite.uFacing = v685; - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - pSpellSprite.uAttributes = 4; - if ( pSpellSprite.Create(v685, SHIDWORD(v685), pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, 0) != -1 - && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - j = rand() % 1024 - 512; - k = rand() % 1024 - 512; - } - spell_sound_flag = true; - break; - } - case SPELL_WATER_AWAKEN://Ïðîáóæäåíèå - { - switch (skill_level) - { - case 1: amount = 180 * spell_level; break; - case 2: amount = 3600 * spell_level; break; - case 3: amount = 86400 * spell_level; break; - case 4: amount = 0; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - for( int i=0; i < 4; i++ ) - { - if ( skill_level == 4 ) - { - if ( pParty->pPlayers[i].pConditions[Condition_Sleep] ) - { - pParty->pPlayers[i].pConditions[Condition_Sleep] = 0; - pParty->pPlayers[i].PlaySound(SPEECH_103, 0); - } - } - else - { - if ( pParty->pPlayers[i].DiscardConditionIfLastsLongerThan(Condition_Sleep, pParty->uTimePlayed - - (signed int)(signed __int64)((double)(amount << 7) * 0.033333335)) ) - pParty->pPlayers[i].PlaySound(SPEECH_103, 0); - } - } - spell_sound_flag = true; - break; - } - case SPELL_WATER_POISON_SPRAY://Ðàñïûëåíèå ÿäà - { - switch (skill_level) - { - case 1: amount = 1; break; - case 2: amount = 3; break; - case 3: amount = 5; break; - case 4: amount = 7; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - signed int _v733 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; - if ( amount == 1 ) - { - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.spell_level = spell_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.vPosition.x = pParty->vPosition.x; - pSpellSprite.vPosition.y = pParty->vPosition.y; - pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(v715.uYawAngle); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(pSpellSprite.uAttributes) |= 4; - v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; - if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - } - else - { - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.y = pParty->vPosition.y; - pSpellSprite.vPosition.x = pParty->vPosition.x; - pSpellSprite.uAttributes = 0; - pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(pSpellSprite.uAttributes) |= 4; - v188 = _v733 / -2; - v189 = _v733 / 2; - if ( v188 <= v189 ) - { - do - { - pSpellSprite.uFacing = v188 + v715.uYawAngle; - if ( pSpellSprite.Create(pSpellSprite.uFacing, v715.uPitchAngle, pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, - pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - v188 += _v733 / (amount - 1); - } - while ( v188 <= v189 ); - } - } - spell_sound_flag = true; - break; - } - case SPELL_WATER_WATER_WALK://Õîæäåíèå ïî âîäå - { - if ( !pPlayers[pCastSpell->uPlayerID + 1]->GetMaxMana() ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - break; - } - switch (skill_level) - { - case 1: //break; - case 2: duration = 600 * spell_level; break; - case 3: - case 4: duration = 3600 * spell_level; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - v169 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536); - 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)(duration << 7) * 0.033333335), - skill_level, amount, v169, pCastSpell->uPlayerID + 1); - if ( skill_level == 4 ) - pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags = 1; - spell_sound_flag = true; - break; - } - case SPELL_WATER_RECHARGE_ITEM://Ïåðåçàðÿäêà - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - v730c = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2]; - if ( v730c->GetItemEquipType() != 12 || v730c->uAttributes & 2 ) - { - _50C9D0_AfterEnchClickEventId = 113; - _50C9D4_AfterEnchClickEventSecondParam = 0; - _50C9D8_AfterEnchClickEventTimeout = 1; - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if ( skill_level == 1 || skill_level == 2 ) - v241 = (double)v723 * 0.0099999998 + 0.5;//50 % - else if ( skill_level == 3 ) - v241 = (double)v723 * 0.0099999998 + 0.69999999;//30 % - else if ( skill_level == 4 ) - v241 = (double)v723 * 0.0099999998 + 0.80000001;//20 % - else - v241 = 0.0; - if ( v241 > 1.0 ) - v241 = 1.0; - int uNewCharges = v730c->uMaxCharges * v241; - v730c->uMaxCharges = uNewCharges; - v730c->uNumCharges = uNewCharges; - if ( uNewCharges <= 0 ) - { - v730c = 0; - _50C9D0_AfterEnchClickEventId = 113; - _50C9D4_AfterEnchClickEventSecondParam = 0; - _50C9D8_AfterEnchClickEventTimeout = 1; - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);//Íå ïîëó÷èëîñü!!! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - spell_level = v723; - continue; - } - v730c->uAttributes |= 0x40u; - _50C9A8_item_enchantment_timer = 256; - spell_sound_flag = true; - break; - } - case SPELL_WATER_ENCHANT_ITEM://Òàëèñìàí - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - uRequiredMana = 0; - amount = 10 * spell_level; - bool item_not_broken = true; - int rnd = rand() % 100; - pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID_2]; - v245 = &pPlayer->pInventoryItemList[a2]; - ItemDesc *_v725 = &pItemsTable->pItems[v245->uItemID]; - if ((skill_level == 1 || skill_level == 2 /*&& _v725->uEquipType > EQUIP_BOW*/ || skill_level == 3 || skill_level == 4) && - v245->uItemID <= 134 && - v245->uSpecEnchantmentType == 0 && v245->uEnchantmentType == 0 && - v245->m_enchantmentStrength== 0 && !v245->IsBroken() ) //òðåáîâàíèÿ ê ïðåäìåòó - { - if ( (v245->GetValue() < 450 && ( skill_level == 1 || skill_level == 2 )) - || (v245->GetValue() < 450 && (skill_level == 3|| skill_level == 4 ) && _v725->uEquipType >= EQUIP_SINGLE_HANDED && _v725->uEquipType <= EQUIP_BOW) - || (v245->GetValue() < 250 && (skill_level == 3 || skill_level == 4 )&& _v725->uEquipType > EQUIP_BOW) )//Óñëîâèÿ ïîëîìêè - { - if ( !(v245->uAttributes & 0x200) )// ïðåäìåò íå ñëîìàí - { - v245->uAttributes |= 2;//òåïåðü ñëîìàí - } - item_not_broken = false; - } - else - { - if ( rnd >= 10 * spell_level )//øàíñ íà ñðàáàòûâàíèå - { - if ( !(v245->uAttributes & 0x200) )// ïðåäìåò íå ñëîìàí - v245->uAttributes |= 2;//òåïåðü ñëîìàí - } - else - { - if ( (rnd < 80 && (skill_level == 3 || skill_level == 4 )) || v245->GetValue() < 450 || (v245->GetValue() < 250 - && (skill_level == 3 || skill_level == 4) && _v725->uEquipType >= EQUIP_SINGLE_HANDED && _v725->uEquipType <= EQUIP_BOW)) - { - v313 = _v725->uEquipType; - if ( _v725->uEquipType >= EQUIP_ARMOUR && _v725->uEquipType <= EQUIP_AMULET ) - { - v295 = rand() % 10;// pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType]; - /*v245->uEnchantmentType = 0; - __debugbreak(); // castspellinfo.cpp(1971): warning C4700: uninitialized local variable 'v294' used - for ( kk = pItemsTable->pEnchantments[0].to_item[v245->GetItemEquipType() + 1]; - ; - kk += pItemsTable->pEnchantments[v294->uEnchantmentType].to_item[v245->GetItemEquipType() + 1] ) - { - ++v245->uEnchantmentType; - if ( kk >= v295 ) - break; - } - v255 = 10;//pItemsTable->field_116D8[17]; - v256 = 10;//pItemsTable->field_116D8[16]; - v245->m_enchantmentStrength = v256 + rand() % (v255 - v256 + 1);*/ - v245->uEnchantmentType = v295; - v245->m_enchantmentStrength = pItemsTable->pEnchantments[v295].to_item[_v725->uEquipType - EQUIP_ARMOUR]; - v245->uAttributes |= 0x20u; - _50C9A8_item_enchantment_timer = 256; - spell_sound_flag = true; - break; - } - else if ( skill_level == 3 || skill_level == 4)//for master & GM not refactored(äëÿ ìàñòåðà è ãðàíäà íå îòðåôàêòîðåíî) - { - v258 = 0; - v725 = 0; - int _v733; - if ( pItemsTable->pSpecialEnchantments_count > 0 ) - { - v730 = (int)&v679; - for ( _v733 = 0; _v733 < pItemsTable->pSpecialEnchantments_count; ++_v733 ) - { - v259 = LOBYTE(pItemsTable->pSpecialEnchantments[v258 + 1].pBonusStatement); - if ( !v259 || v259 == 1 ) - { - v260 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[v245->GetItemEquipType() + 4] + v258 * 28); - v725 += v260; - if ( v260 ) - { - v261 = v730; - v730 += 4; - *(int *)v261 = _v733; - } - } - ++v258; - } - } - v262 = rand() % v725; - v263 = v679; - v245->uSpecEnchantmentType = v679[0]; - v264 = pItemsTable->pSpecialEnchantments[*v263].to_item_apply[v245->GetItemEquipType() + 4]; - v265 = v262 + 1; - if ( v264 < v265 ) - { - for ( ii = v679; ; ii = (int *)v732 ) - { - v267 = (int)(ii + 1); - v732 = v267; - v268 = *(int *)v267; - *(int *)(v245 + 12) = v268; - v264 += pItemsTable->pSpecialEnchantments[v268].to_item_apply[v245->GetItemEquipType() + 4]; - if ( v264 >= v265 ) - break; - } - } - v278 = 0; - v725 = 0; - if ( pItemsTable->pSpecialEnchantments_count > 0 ) - { - int *_v730 = v679; - for ( _v733 = 0; _v733 < pItemsTable->pSpecialEnchantments_count; ++_v733 ) - { - v279 = LOBYTE(pItemsTable->pSpecialEnchantments[v278].pBonusStatement); - if ( !v279 || v279 == 1 ) - { - v280 = *(&pItemsTable->pSpecialEnchantments[v278].to_item_apply[v245->GetItemEquipType()]); - _v733 += v280; - if ( v280 ) - { - v281 = _v730; - ++_v730; - *v281 = _v733; - } - } - ++v278; - } - } - v282 = rand() % _v733; - v283 = v679; - v245->uSpecEnchantmentType = v679[0]; - v284 = pItemsTable->pSpecialEnchantments[*v283].to_item_apply[v245->GetItemEquipType() ]; - v285 = v282 + 1; - for ( l = v679; v284 < v285; ++l ) - { - v245->uSpecEnchantmentType = *(l+1); - v284 += pItemsTable->pSpecialEnchantments[*(l+1)].to_item_apply[v245->GetItemEquipType()]; - } - ++v245->uSpecEnchantmentType; - v245->uAttributes |= 0x20u; - _50C9A8_item_enchantment_timer = 256; - spell_sound_flag = true; - break; - } - } - } - } - } - if ( spell_sound_flag == 0 ) - { - v317 = pGlobalTXT_LocalizationStrings[428];//Íå ïîëó÷èëîñü!!! - if ( item_not_broken == false ) - v317 = pGlobalTXT_LocalizationStrings[585];//Ïðåäìåò íåäîñòàòî÷íî âûñîêîãî êà÷åñòâà - ShowStatusBarString(v317, 2); - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - //v318 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; - pCastSpell->uSpellID = 0; - pParty->pPlayers[pCastSpell->uPlayerID_2].PlaySound(SPEECH_43, 0); - } - break; - } - case SPELL_WATER_TOWN_PORTAL://Ïîðòàë ãîðîäà - { - amount = 10 * spell_level; - if ( pPlayer->sMana < (signed int)uRequiredMana ) - break; - if ( pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW) && skill_level != 4 - || rand() % 100 >= amount && skill_level != 4 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - town_portal_caster_id = pCastSpell->uPlayerID; - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_OnCastTownPortal, 0, 0); - spell_sound_flag = true; - break; - } - case SPELL_WATER_LLOYDS_BEACON://Ìàÿê Ëëîéäà - { - if ( !_stricmp(pCurrentMapName, "d05.blv") ) // Arena - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if ( pPlayer->sMana >= (signed int)uRequiredMana ) - { - pEventTimer->Pause(); - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_OnCastLloydsBeacon, 0, 0); - lloyds_beacon_spell_level = (signed int)(604800 * spell_level); - _506348_current_lloyd_playerid = pCastSpell->uPlayerID; - ::uRequiredMana = uRequiredMana; - ::sRecoveryTime = sRecoveryTime; - lloyds_beacon_sound_id = pCastSpell->sound_id; - lloyds_beacon_spell_id = pCastSpell->uSpellID; - pCastSpell->uFlags |= 0x20u; - } - break; - } - case SPELL_EARTH_STONE_TO_FLESH: - { - switch (skill_level) - { - case 1: amount = 3600 * spell_level; break; - case 2: amount = 3600 * spell_level; break; - case 3: amount = 86400 * spell_level; break; - case 4: break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Pertified] ) - { - if ( skill_level == 4 )//for GM - { - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Pertified] = 0; - spell_sound_flag = true; - break; - } - v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Pertified, v663); - } - spell_sound_flag = true; - break; - } - case SPELL_EARTH_ROCK_BLAST://Âçðûâ êàìíÿ - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.y = pParty->vPosition.y; - pSpellSprite.vPosition.x = pParty->vPosition.x; - pSpellSprite.uAttributes = 0; - pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(pParty->sRotationY); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(pSpellSprite.uAttributes) |= 4; - v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; - if ( pSpellSprite.Create(pParty->sRotationY, pParty->sRotationX, v659, pCastSpell->uPlayerID + 1) != -1 - && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - spell_sound_flag = true; - break; - } - case SPELL_EARTH_DEATH_BLOSSOM: //Öâåòîê ñìåðòè - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pSpellSprite.uType = 4090; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.x = pParty->vPosition.x; - pSpellSprite.vPosition.y = pParty->vPosition.y; - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - pSpellSprite.field_60_distance_related_prolly_lod = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.uFacing = LOWORD(pParty->sRotationY); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - pSpellSprite.uAttributes = 4; - v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; - if ( pSpellSprite.Create(pParty->sRotationY, stru_5C6E00->uIntegerHalfPi / 2, v659, 0) != -1 - && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - spell_sound_flag = true; - break; - } - case SPELL_SPIRIT_DETECT_LIFE: // Äåòåêòîð æèçíè - { - switch (skill_level) - { - case 1: amount = 600 * spell_level; break; - case 2: amount = 1800 * spell_level; break; - case 3: - case 4: amount = 3600 * spell_level; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - 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)amount << 7) * 0.033333335), skill_level, 0, 0, 0); - spell_sound_flag = true; - break; - } - case SPELL_SPIRIT_FATE:// Ñóäüáà - { - switch (skill_level) - { - case 1: amount = spell_level; break; - case 2: amount = 2 * spell_level; break; - case 3: amount = 4 * spell_level; break; - case 4: amount = 6 * spell_level; break; - default: - assert(false); - } - //LODWORD(v733) = 300; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if ( pCastSpell->spell_target_pid == 0 ) - { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); - pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, skill_level, amount, 0, 0); - spell_sound_flag = true; - break; - } - if (PID_TYPE(pCastSpell->spell_target_pid) == OBJECT_Actor) - { - mon_id = PID_ID(pCastSpell->spell_target_pid); - pActors[mon_id].pActorBuffs[ACTOR_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, skill_level, amount, 0, 0); - pActors[mon_id].uAttributes |= ACTOR_AGGRESSOR; - pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(&pActors[mon_id], 0); - } - spell_sound_flag = true; - break; - } - case SPELL_SPIRIT_REMOVE_CURSE:// Ñíÿòèå ïîð÷è - { - switch (skill_level) - { - case 1: amount = 3600 * spell_level; break; - case 2: amount = 3600 * spell_level; break; - case 3: amount = 86400 * spell_level; break; - case 4: amount = 0; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if ( !pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Cursed] ) - { - spell_sound_flag = true; - break; - } - if ( skill_level == 4 )//GM - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Cursed] = 0; - else - { - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(0, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Cursed] ) - { - spell_sound_flag = true; - break; - } - } - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); - spell_sound_flag = true; - break; - } - case SPELL_SPIRIT_PRESERVATION://Ñîõðàíåíèå - { - if ( skill_level == 4 ) - duration = 900 * (spell_level + 4); - else - duration = 300 * (spell_level + 12); - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if ( skill_level == 1 || skill_level == 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)duration << 7) * 0.033333335), skill_level, 0, 0, 0); - spell_sound_flag = true; - break; - } - for ( uint pl_id = 0; pl_id < 4; pl_id++ ) - { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id); - pParty->pPlayers[pl_id].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + - (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, 0, 0); - } - spell_sound_flag = true; - break; - } - case SPELL_SPIRIT_TURN_UNDEAD://Áåã ìåðòâåöîâ - { - if ( skill_level == 1 || skill_level == 2) - duration = 60 * (spell_level + 3); - else - duration = 300 * spell_level + 180; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - int mon_num = pRenderer->_46À6ÀÑ_GetActorsInViewport(4096); - pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFF, 192); - ++pSpellSprite.uType; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.field_60_distance_related_prolly_lod = 0; - pSpellSprite.uFacing = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - for ( a2 = 0; a2 < mon_num; ++a2 ) - { - if ( MonsterStats::BelongsToSupertype(pActors[_50BF30_actors_in_viewport_ids[a2]].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) - { - pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.x; - pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.y; - pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.z - (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[a2]].uActorHeight * -0.8); - pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]); - pSpellSprite.Create(0, 0, 0, 0); - pActors[_50BF30_actors_in_viewport_ids[a2]].pActorBuffs[ACTOR_BUFF_AFRAID].Apply(pParty->uTimePlayed + - (signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, 0, 0); - } - } - spell_sound_flag = true; - break; - } - case SPELL_SPIRIT_RAISE_DEAD://Îæèâëåíèå - { - if ( skill_level == 4 ) - amount = 0; - else - amount = 86400 * spell_level; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pOtherOverlayList->_4418B1(5080, pCastSpell->uPlayerID_2 + 100, 0, 65536); - if ( !pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] ) - { - spell_sound_flag = true; - break; - } - pParty->pPlayers[pCastSpell->uPlayerID_2].sHealth = 1; - if ( skill_level == 4 ) - { - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] = 0; - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Unconcious] = 0; - } - else - { - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Dead, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Unconcious, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - } - pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(Condition_Weak, 0); - spell_sound_flag = true; - break; - } - case SPELL_SPIRIT_SHARED_LIFE://Îáùàÿ æèçíü - { - if ( skill_level == 4 ) - amount = 4 * spell_level; - else - amount = 3 * spell_level; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - int active_pl_num = 0; - signed int shared_life_count = amount; - int mean_life = 0; - int pl_array[4]; - for ( uint pl_id = 1; pl_id <= 4; pl_id++ ) - { - if ( !pPlayers[pl_id]->pConditions[Condition_Dead] && !pPlayers[pl_id]->pConditions[Condition_Pertified] - && !pPlayers[pl_id]->pConditions[Condition_Eradicated] ) - pl_array[active_pl_num++] = pl_id; - } - for ( uint i = 0; i < active_pl_num; i++ ) - shared_life_count += pPlayers[pl_array[i]]->sHealth; - mean_life = (signed __int64)((double)shared_life_count / (double)active_pl_num); - for ( uint i = 0; i < active_pl_num; i++ ) - { - pPlayers[pl_array[i]]->sHealth = mean_life; - if ( pPlayers[pl_array[i]]->sHealth > pPlayers[pl_array[i]]->GetMaxHealth()) - pPlayers[pl_array[i]]->sHealth = pPlayers[pl_array[i]]->GetMaxHealth(); - if ( pPlayers[pl_array[i]]->sHealth > 0 ) - pPlayers[pl_array[i]]->SetUnconcious(0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_array[i] - 1); - } - spell_sound_flag = true; - break; - } - case SPELL_SPIRIT_RESSURECTION://Âîñêðåñåíèå - { - switch (skill_level) - { - case 1: amount = 180 * spell_level; break; - case 2: amount = 10800 * spell_level; break; - case 3: amount = 259200 * spell_level; break; - case 4: amount = 0; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Eradicated] - || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] ) - { - if ( !(pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Weak]) ) - pParty->pPlayers[pCastSpell->uPlayerID_2].PlaySound(SPEECH_25, 0); - if ( skill_level == 4 ) - { - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Eradicated] = 0; - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] = 0; - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Unconcious] = 0; - } - else - { - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan( Condition_Eradicated, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan( Condition_Dead, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan( Condition_Unconcious, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - } - pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(Condition_Weak, 1); - pParty->pPlayers[pCastSpell->uPlayerID_2].sHealth = 1; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); - } - spell_sound_flag = true; - break; - } - case SPELL_MIND_CURE_PARALYSIS://ëå÷åíèå ïàðàëè÷à - { - switch (skill_level) - { - case 1: amount = 3600 * spell_level; break; - case 2: amount = 3600 * spell_level; break; - case 3: amount = 86400 * spell_level; break; - case 4: amount = 0; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); - if ( !pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Paralyzed] ) - { - spell_sound_flag = true; - break; - } - if ( skill_level == 4 ) - { - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Paralyzed] = 0; - spell_sound_flag = true; - break; - } - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Paralyzed, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - spell_sound_flag = true; - break; - } - case SPELL_MIND_REMOVE_FEAR://Ñíÿòü ñòðàõ - { - switch (skill_level) - { - case 1: amount = 180 * spell_level; break; - case 2: amount = 3600 * spell_level; break; - case 3: amount = 86400 * spell_level; break; - case 4: amount = 0; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); - if ( !pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Fear] ) - { - spell_sound_flag = true; - break; - } - if ( skill_level == 4 ) - { - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Fear] = 0; - spell_sound_flag = true; - break; - } - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Fear, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - spell_sound_flag = true; - break; - } - case SPELL_MIND_TELEPATHY://Òåëåïàòèÿ - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if (PID_TYPE(a2) == OBJECT_Actor) - { - mon_id = PID_ID(a2); - if ( !pActors[mon_id].ActorHasItem() ) - pActors[mon_id].SetRandomGoldIfTheresNoItem(); - int gold_num = 0; - if ( pItemsTable->pItems[pActors[mon_id].ActorHasItems[3].uItemID].uEquipType == EQUIP_GOLD ) - gold_num = pActors[mon_id].ActorHasItems[3].uSpecEnchantmentType; - ItemGen item; - item.Reset(); - if (pActors[mon_id].uCarriedItemID) - item.uItemID = pActors[mon_id].uCarriedItemID; - else - { - for ( uint i = 0; i < 4; ++i ) - { - if ( pActors[mon_id].ActorHasItems[i].uItemID > 0 && pItemsTable->pItems[pActors[mon_id].ActorHasItems[i].uItemID].uEquipType != EQUIP_GOLD ) - { - memcpy(&item, &pActors[mon_id].ActorHasItems[i], sizeof(item)); - spell_level = v723; - } - } - } - if ( gold_num > 0 ) - { - if (item.uItemID) - sprintf(pTmpBuf2.data(), "(%s), and %d gold", item.GetDisplayName(), gold_num); - else - sprintf(pTmpBuf2.data(), "%d gold", gold_num); - } - else - { - if (item.uItemID) - sprintf(pTmpBuf2.data(), "(%s)", item.GetDisplayName()); - else - { - strcpy(pTmpBuf2.data(), "nothing"); - ShowStatusBarString(pTmpBuf2.data(), 2); - } - } - ShowStatusBarString(pTmpBuf2.data(), 2); - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; - pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; - pSpellSprite.vPosition.z = pActors[mon_id].uActorHeight; - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(v715.uYawAngle); - LOBYTE(pSpellSprite.uAttributes) |= 0x80; - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); - } - spell_sound_flag = true; - break; - } - case SPELL_MIND_BERSERK://Áåðñåðê - { - switch (skill_level) - { - case 1: amount = 300 * spell_level; break; - case 2: amount = 300 * spell_level; break; - case 3: amount = 600 * spell_level; break; - case 4: amount = 3600; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - mon_id = PID_ID(a2); - if (PID_TYPE(a2) == OBJECT_Actor) - { - //v730 = 836 * mon_id; - if ( pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)7) ) - { - pActors[mon_id].pActorBuffs[ACTOR_BUFF_CHARM].Reset(); - pActors[mon_id].pActorBuffs[ACTOR_BUFF_ENSLAVED].Reset(); - pActors[mon_id].pActorBuffs[ACTOR_BUFF_BERSERK].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), skill_level, 0, 0, 0); - pActors[mon_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - } - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; - pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; - pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z + pActors[mon_id].uActorHeight; - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = pIndoor->GetSector(pActors[mon_id].vPosition.x, pActors[mon_id].vPosition.y, pSpellSprite.vPosition.z); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(v715.uYawAngle); - LOBYTE(pSpellSprite.uAttributes) |= 0x80; - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); - } - spell_sound_flag = true; - break; - } - case SPELL_MIND_ENSLAVE://Ïîðàáîùåíèå - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - amount = 600 * spell_level; - if (PID_TYPE(a2) == OBJECT_Actor) - { - mon_id = PID_ID(a2); - //v730 = 836 * mon_id; - if ( MonsterStats::BelongsToSupertype(pActors[mon_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) - break; - if ( pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)7) ) - { - pActors[mon_id].pActorBuffs[ACTOR_BUFF_BERSERK].Reset(); - pActors[mon_id].pActorBuffs[ACTOR_BUFF_CHARM].Reset(); - pActors[mon_id].pActorBuffs[ACTOR_BUFF_ENSLAVED].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), - skill_level, 0, 0, 0); - } - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; - pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; - pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z + pActors[mon_id].uActorHeight; - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = pIndoor->GetSector(pActors[mon_id].vPosition.x, pActors[mon_id].vPosition.y, pSpellSprite.vPosition.z); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(v715.uYawAngle); - LOBYTE(pSpellSprite.uAttributes) |= 0x80; - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); - } - spell_sound_flag = true; - break; - } - case SPELL_MIND_MASS_FEAR://Ìàññîâûé ñòðàõ - { - if ( skill_level == 4 ) - amount = 300 * spell_level; - else - amount = 180 * spell_level; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - int mon_num = pRenderer->_46À6ÀÑ_GetActorsInViewport(4096); - pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0A, 192); - ++pSpellSprite.uType; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.field_60_distance_related_prolly_lod = 0; - pSpellSprite.uFacing = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - for ( a2 = 0; a2 < mon_num; ++a2 ) - { - if ( MonsterStats::BelongsToSupertype(pActors[_50BF30_actors_in_viewport_ids[a2]].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) - break; - pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.x; - pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.y; - pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.z - (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[a2]].uActorHeight * -0.8); - pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]); - pSpellSprite.Create(0, 0, 0, 0); - if ( pActors[_50BF30_actors_in_viewport_ids[a2]].DoesDmgTypeDoDamage((DAMAGE_TYPE)7) ) - { - pActors[_50BF30_actors_in_viewport_ids[a2]].pActorBuffs[ACTOR_BUFF_AFRAID].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), - skill_level, 0, 0, 0); - } - } - spell_sound_flag = true; - break; - } - case SPELL_MIND_CURE_INSANITY://Ëå÷åíèå Áåçóìèÿ - { - if ( skill_level == 4 ) - amount = 0; - else - amount = 86400 * spell_level; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); - if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Insane] ) - { - if ( !(pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Weak]) ) - pParty->pPlayers[pCastSpell->uPlayerID_2].PlaySound(SPEECH_25, 0); - if ( skill_level == 4 ) - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Insane] = 0; - else - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Insane, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(Condition_Weak, 0); - } - spell_sound_flag = true; - break; - } - case SPELL_EARTH_TELEKINESIS://Òåëåêèíåç - { - switch (skill_level) - { - case 1: amount = 2 * spell_level; break; - case 2: amount = 2 * spell_level; break; - case 3: amount = 3 * spell_level; break; - case 4: amount = 4 * spell_level; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - int obj_id = PID_ID(a2); - if (PID_TYPE(a2) == OBJECT_Item) - { - if ( pItemsTable->pItems[pSpriteObjects[obj_id].stru_24.uItemID].uEquipType == EQUIP_GOLD ) - { - pParty->PartyFindsGold(pSpriteObjects[obj_id].stru_24.uSpecEnchantmentType, 0); - viewparams->bRedrawGameUI = true; - } - else - { - sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[pSpriteObjects[obj_id].stru_24.uItemID].pUnidentifiedName);//Âû íàøëè ^Pv[%s]! - ShowStatusBarString(pTmpBuf2.data(), 2); - if ( !pParty->AddItemToParty(&pSpriteObjects[obj_id].stru_24) ) - pParty->SetHoldingItem(&pSpriteObjects[obj_id].stru_24); - } - SpriteObject::OnInteraction(obj_id); - } - if (PID_TYPE(a2) == OBJECT_Actor) - pActors[obj_id].LootActor(); - if (PID_TYPE(a2) == OBJECT_Decoration) - { - OpenedTelekinesis = true; - if ( pLevelDecorations[obj_id].uEventID ) - EventProcessor(pLevelDecorations[obj_id].uEventID, a2, 1); - if ( pLevelDecorations[pSpriteObjects[obj_id].stru_24.uItemID].IsInteractive() ) - { - activeLevelDecoration = &pLevelDecorations[obj_id]; - EventProcessor(stru_5E4C90_MapPersistVars._decor_events[pLevelDecorations[obj_id]._idx_in_stru123 - 75] + 380, 0, 1); - activeLevelDecoration = nullptr; - } - } - if (PID_TYPE(a2) == OBJECT_BModel) - { - OpenedTelekinesis = true; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - v448 = pIndoor->pFaceExtras[pIndoor->pFaces[obj_id].uFaceExtraID].uEventID; - else - v448 = pOutdoor->pBModels[a2 >> 9].pFaces[obj_id & 0x3F].sCogTriggeredID; - EventProcessor(v448, a2, 1); - } - spell_sound_flag = true; - break; - } - case SPELL_BODY_CURE_WEAKNESS://Ëå÷èòü Ñëàáîñòü - { - switch (skill_level) - { - case 1: amount = 180 * spell_level; break;//3 ìèíóòû * êîëè÷åñòâî î÷êîâ íàâûêà - case 2: amount = 3600 * spell_level; break;//1 ÷àñ * êîëè÷åñòâî î÷êîâ íàâûêà - case 3: amount = 86400 * spell_level; break; - case 4: amount = 0; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); - if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Weak] ) - { - if ( skill_level == 4 ) - { - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Weak] = 0; - spell_sound_flag = true; - break; - } - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Weak, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - } - spell_sound_flag = true; - break; - } - case SPELL_BODY_FIRST_AID://Ïåðâàÿ ïîìîùü - { - switch (skill_level) - { - case 1: amount = 2 * spell_level + 5; break; - case 2: amount = 3 * spell_level + 5; break; - case 3: amount = 4 * spell_level + 5; break; - case 4: amount = 5 * spell_level + 5; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if ( !pCastSpell->spell_target_pid ) - { - pParty->pPlayers[pCastSpell->uPlayerID_2].Heal(amount); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); - } - if (PID_TYPE(pCastSpell->spell_target_pid) == OBJECT_Actor) - { - mon_id = PID_ID(pCastSpell->spell_target_pid); - if ( pActors[mon_id].uAIState != Dead && pActors[mon_id].uAIState != Dying && pActors[mon_id].uAIState != Disabled - && pActors[mon_id].uAIState != Removed ) - { - pActors[mon_id].sCurrentHP += amount; - if ( pActors[mon_id].sCurrentHP > pActors[mon_id].pMonsterInfo.uHP ) - pActors[mon_id].sCurrentHP = pActors[mon_id].pMonsterInfo.uHP; - } - } - spell_sound_flag = true; - break; - } - case SPELL_BODY_CURE_POISON://Ëå÷åíèå Îòðàâëåíèÿ(Ïðîòèâîÿäèå) - { - switch (skill_level) - { - case 1: amount = 3600 * spell_level; break; - case 2: amount = 3600 * spell_level; break; - case 3: amount = 86400 * spell_level; break; - case 4: amount = 0; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); - if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Weak] - || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Medium] - || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Severe] ) - { - if ( skill_level == 4 ) - { - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Weak] = 0; - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Medium] = 0; - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Severe] = 0; - spell_sound_flag = true; - break; - } - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Poison_Weak, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Poison_Medium, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Poison_Severe, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - } - spell_sound_flag = true; - break; - } - case SPELL_BODY_PROTECTION_FROM_MAGIC://Çàùèòà îò ìàãèè - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - 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)(3600 * spell_level) << 7) * 0.033333335), skill_level, spell_level, 0, 0); - spell_sound_flag = true; - break; - } - case SPELL_BODY_HAMMERHANDS://Ðóêè-Ìîëîòû - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if ( skill_level == 4 ) - { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); - for ( uint pl_id = 0; pl_id < 4; pl_id++) - pParty->pPlayers[pl_id].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + - (signed int)(signed __int64)((double)(signed int)((int)(3600 * spell_level) << 7) * 0.033333335), 4, spell_level, spell_level, 0); - spell_sound_flag = true; - break; - } - 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)(3600 * spell_level) << 7) * 0.033333335), skill_level, spell_level, spell_level, 0); - spell_sound_flag = true; - break; - } - case SPELL_BODY_CURE_DISEASE://Ëå÷èòü Áîëåçíü - { - if ( skill_level == 4 ) - amount = 0; - else - amount = 86400 * spell_level; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); - if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Weak] - || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Medium] - || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Severe] ) - { - if ( skill_level == 4 ) - { - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Weak] = 0; - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Medium] = 0; - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Severe] = 0; - } - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Disease_Weak, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Disease_Medium, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Disease_Severe, - (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); - } - spell_sound_flag = true; - break; - } - case SPELL_BODY_POWER_CURE://Èñöåëåíèå - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - for ( uint pl_id = 0; pl_id < 4; ++pl_id ) - { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id); - pParty->pPlayers[pl_id].Heal(5 * spell_level + 10); - } - spell_sound_flag = true; - break; - } - case SPELL_LIGHT_DISPEL_MAGIC://Ñíÿòèå ÷àð - { - sRecoveryTime -= spell_level; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0A, 192); - int mon_num = pRenderer->_46À6ÀÑ_GetActorsInViewport(4096); - ++pSpellSprite.uType; - v688.x = 0; - v688.y = 0; - v688.z = 0; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.field_60_distance_related_prolly_lod = 0; - pSpellSprite.uFacing = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - for ( a2 = 0; a2 < mon_num; ++a2 ) - { - pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.x; - pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.y; - pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.z - - (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[a2]].uActorHeight * -0.8); - pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]); - Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), _50BF30_actors_in_viewport_ids[a2], &v688); - } - for ( a2 = 0; a2 < mon_num; ++a2 ) - { - pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.x; - pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.y; - pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.z - - (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[a2]].uActorHeight * -0.8); - pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]); - pSpellSprite.Create(0, 0, 0, 0); - for (int i = 0; i < 22; ++i) - pActors[_50BF30_actors_in_viewport_ids[a2]].pActorBuffs[i].Reset(); - } - spell_sound_flag = true; - break; - } - case SPELL_LIGHT_SUMMON_ELEMENTAL://Ýëåìåíòàë - { - switch (skill_level) - { - case 1: v733 = 300 * spell_level; amount = 1; break; - case 2: v733 = 300 * spell_level; amount = 1; break; - case 3: v733 = 900 * spell_level; amount = 3; break; - case 4: v733 = 900 * spell_level; amount = 5; break; - default: - assert(false); - } - int mon_num = 0; - for ( uint mon_id = 0; mon_id < uNumActors; mon_id++ ) - { - if ( pActors[mon_id].uAIState != Dead && pActors[mon_id].uAIState != Removed && pActors[mon_id].uAIState != Disabled - && PID(OBJECT_Player, pCastSpell->uPlayerID) == pActors[mon_id].uSummonerID ) - ++mon_num; - } - if ( mon_num >= amount ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[648], 2); // This character can't summon any more monsters! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - sub_44FA4C_spawn_light_elemental(pCastSpell->uPlayerID, skill_level, v733); - spell_sound_flag = true; - break; - } - case SPELL_LIGHT_DAY_OF_THE_GODS://Äåíü áîãîâ - { - switch (skill_level) - { - case 1: duration = 10800 * spell_level; amount = 3 * spell_level + 10; break; - case 2: duration = 10800 * spell_level; amount = 3 * spell_level + 10; break; - case 3: duration = 14400 * spell_level; amount = 4 * spell_level + 10; break; - case 4: duration = 18000 * spell_level; amount = 5 * spell_level + 10; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - 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)duration << 7) * 0.033333335), skill_level, amount, 0, 0); - spell_sound_flag = true; - break; - } - case SPELL_LIGHT_PRISMATIC_LIGHT://Ñâåò ïðèçìû - { - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[497], 2); // Can't cast Prismatic Light outdoors! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - int mon_num = pRenderer->_46À6ÀÑ_GetActorsInViewport(4096); - ++pSpellSprite.uType; - v694.x = 0; - v694.y = 0; - v694.z = 0; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.field_60_distance_related_prolly_lod = 0; - pSpellSprite.uFacing = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - for ( uint mon_id = 0; mon_id < mon_num; mon_id++ ) - { - pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.x; - pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.y; - pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.z - - (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[mon_id]].uActorHeight * -0.8); - pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[mon_id]); - Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), _50BF30_actors_in_viewport_ids[mon_id], &v694); - } - //v537 = pGame->GetStru6(); - pGame->GetStru6()->_4A8BFC(); - spell_sound_flag = true; - break; - } - case SPELL_LIGHT_DAY_OF_PROTECTION://Äåíü çàùèòû - { - switch (skill_level) - { - case 1: duration = 14400 * spell_level; amount = 4 * spell_level; break; - case 2: duration = 14400 * spell_level; amount = 4 * spell_level; break; - case 3: duration = 14400 * spell_level; amount = 4 * spell_level; break; - case 4: duration = 18000 * spell_level; amount = 5 * spell_level; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - 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_RESIST_BODY].Apply(pParty->uTimePlayed + - (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_RESIST_MIND].Apply(pParty->uTimePlayed + - (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_RESIST_FIRE].Apply(pParty->uTimePlayed + - (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_RESIST_WATER].Apply(pParty->uTimePlayed + - (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_RESIST_AIR].Apply(pParty->uTimePlayed + - (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_RESIST_EARTH].Apply(pParty->uTimePlayed + - (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply(pParty->uTimePlayed + - (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply(pParty->uTimePlayed + - (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0); - spell_sound_flag = true; - break; - } - case SPELL_LIGHT_HOUR_OF_POWER: //×àñ ìîãóùåñòâà - { - switch (skill_level) - { - case 1: duration = 4; amount = 4; break; - case 2: duration = 4; amount = 4; break; - case 3: duration = 12; amount = 12; break; - case 4: duration = 20; amount = 15; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - bool player_weak = false; - for ( uint pl_id = 0; pl_id < 4; pl_id++ ) - { - 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->pPlayers[pl_id].pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed + - (signed __int64)((double)((300 * amount * spell_level + 60) << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0); - if ( pParty->pPlayers[pl_id].pConditions[Condition_Weak] ) - player_weak = true; - } - pParty->pPartyBuffs[PARTY_BUFF_HEROISM].Apply(pParty->uTimePlayed + - (signed __int64)((double)((300 * amount * spell_level + 60) << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_SHIELD].Apply(pParty->uTimePlayed + - (signed __int64)((double)((300 * amount * spell_level + 60) << 7) * 0.033333335), skill_level, 0, 0, 0); - pParty->pPartyBuffs[PARTY_BUFF_STONE_SKIN].Apply(pParty->uTimePlayed + - (signed __int64)((double)((300 * amount * spell_level + 60) << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0); - if ( !player_weak ) - pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + - (signed __int64)((double)((60 * (spell_level * duration + 60)) << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0); - spell_sound_flag = true; - break; - } - case SPELL_LIGHT_DIVINE_INTERVENTION://Áîæåñòâåííîå âìåøàòåëüñòâî - { - //amount = 3; - if ( pPlayer->uNumDivineInterventionCastsThisDay >= 3 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - for ( uint pl_id = 0; pl_id < 4; pl_id++ ) - { - for ( uint buff_id = 0; buff_id <= 19; buff_id++ ) - pParty->pPlayers[pl_id].pConditions[buff_id] = 0; - pParty->pPlayers[pl_id].sHealth = pParty->pPlayers[pl_id].GetMaxHealth(); - pParty->pPlayers[pl_id].sMana = pParty->pPlayers[pl_id].GetMaxMana(); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id); - } - if ( pPlayer->sAgeModifier + 10 >= 120 ) - pPlayer->sAgeModifier = 120; - else - pPlayer->sAgeModifier = pPlayer->sAgeModifier + 10; - sRecoveryTime += -5 * spell_level; - ++pPlayer->uNumDivineInterventionCastsThisDay; - spell_sound_flag = true; - break; - } - case SPELL_DARK_REANIMATE: //Ðåàíèìàöèÿ - { - switch (skill_level) - { - case 1: amount = 2 * spell_level; break; - case 2: amount = 3 * spell_level; break; - case 3: amount = 4 * spell_level; break; - case 4: amount = 5 * spell_level; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if (!pCastSpell->spell_target_pid) - { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); - if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] ) - { - pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(Condition_Zombie, 1); - ReloadPlayerPortraits(pCastSpell->uPlayerID_2, (pParty->pPlayers[pCastSpell->uPlayerID_2].GetSexByVoice() != 0) + 23); - pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Zombie] = pParty->uTimePlayed; - } - break; - } - mon_id = PID_ID(pCastSpell->spell_target_pid); - if ( mon_id == -1 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[496], 2); // No valid target exists! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if ( pActors[mon_id].sCurrentHP > 0 - || pActors[mon_id].uAIState != Dead && pActors[mon_id].uAIState != Dying ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - ++pSpellSprite.uType; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.field_60_distance_related_prolly_lod = 0; - pSpellSprite.uFacing = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; - pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; - pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z - - (unsigned int)(signed __int64)((double)pActors[mon_id].uActorHeight * -0.8); - pSpellSprite.spell_target_pid = PID(OBJECT_Actor, mon_id); - pSpellSprite.Create(0, 0, 0, 0); - if ( pActors[mon_id].pMonsterInfo.uLevel > amount ) - break; - Actor::Resurrect(mon_id); - pActors[mon_id].pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)0; - pActors[mon_id].pMonsterInfo.uTreasureDropChance = 0; - pActors[mon_id].pMonsterInfo.uTreasureDiceRolls = 0; - pActors[mon_id].pMonsterInfo.uTreasureDiceSides = 0; - pActors[mon_id].pMonsterInfo.uTreasureLevel = 0; - pActors[mon_id].pMonsterInfo.uTreasureType = 0; - pActors[mon_id].uAlly = 9999; - pActors[mon_id].ResetAggressor();//~0x80000 - pActors[mon_id].uGroup = 0; - pActors[mon_id].pActorBuffs[ACTOR_BUFF_BERSERK].Reset(); - pActors[mon_id].pActorBuffs[ACTOR_BUFF_CHARM].Reset(); - pActors[mon_id].pActorBuffs[ACTOR_BUFF_ENSLAVED].Reset(); - if ( pActors[mon_id].sCurrentHP > 10 * amount ) - pActors[mon_id].sCurrentHP = 10 * amount; - spell_sound_flag = true; - break; - } - case SPELL_DARK_VAMPIRIC_WEAPON:// Îðóæèå-âàìïèð - { - amount = 16; - if ( skill_level == 4 ) - duration = 0; - else - duration = 3600 * spell_level; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - ItemGen *item = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2]; - item->UpdateTempBonus(pParty->uTimePlayed); - if ( item->uItemID >= 64 && item->uItemID <= 65//blasters - || LOBYTE(item->uAttributes) & 2 - || item->uSpecEnchantmentType != 0 - || item->uEnchantmentType != 0 - || pItemsTable->pItems[item->uItemID].uEquipType != EQUIP_SINGLE_HANDED - && pItemsTable->pItems[item->uItemID].uEquipType != EQUIP_TWO_HANDED - && pItemsTable->pItems[item->uItemID].uEquipType != EQUIP_BOW - || pItemsTable->IsMaterialNonCommon(item) ) - { - _50C9D0_AfterEnchClickEventId = 113; - _50C9D4_AfterEnchClickEventSecondParam = 0; - _50C9D8_AfterEnchClickEventTimeout = 1; - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - item->uSpecEnchantmentType = 16; - if ( skill_level != 4 ) - { - item->uExpireTime = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335); - item->uAttributes |= 8; - } - LOBYTE(item->uAttributes) |= 0x80; - _50C9A8_item_enchantment_timer = 256; - spell_sound_flag = true; - break; - } - case SPELL_DARK_SHARPMETAL://Øðàïíåëü - { - switch (skill_level) - { - case 1: amount = 5; break; - case 2: amount = 5; break; - case 3: amount = 7; break; - case 4: amount = 9; break; - default: - assert(false); - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - signed int _v726 = ((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360); - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.x = pParty->vPosition.x; - pSpellSprite.vPosition.y = pParty->vPosition.y; - pSpellSprite.uAttributes = 0; - pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2; - pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, - pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - if ( pParty->bTurnBasedModeOn == 1 ) - LOBYTE(pSpellSprite.uAttributes) |= 4; - v188 = (signed int)_v726 / -2; - v189 = (signed int)_v726 / 2; - if ( v188 <= v189 ) - { - do - { - pSpellSprite.uFacing = v188 + v715.uYawAngle; - if ( pSpellSprite.Create(pSpellSprite.uFacing, v715.uPitchAngle, - pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, pCastSpell->uPlayerID + 1) != -1 - && pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - v188 += _v726 / (amount - 1); - } - while ( v188 <= v189 ); - } - spell_sound_flag = true; - break; - } - case SPELL_DARK_CONTROL_UNDEAD://Ãëàâà íåæèòè - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - switch (skill_level) - { - case 1: duration = 180 * spell_level; break; - case 2: duration = 180 * spell_level; break; - case 3: duration = 300 * spell_level; break; - case 4: duration = 29030400; break; - default: - assert(false); - } - if (PID_TYPE(a2) == OBJECT_Actor) - { - mon_id = PID_ID(a2); - if ( !MonsterStats::BelongsToSupertype(pActors[mon_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) - break; - if ( !pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)10) ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - pActors[mon_id].pActorBuffs[ACTOR_BUFF_BERSERK].Reset(); - pActors[mon_id].pActorBuffs[ACTOR_BUFF_CHARM].Reset(); - pActors[mon_id].pActorBuffs[ACTOR_BUFF_ENSLAVED].Apply(pParty->uTimePlayed + - (signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, 0, 0); - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; - pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; - pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z + pActors[mon_id].uActorHeight; - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = pIndoor->GetSector(pActors[mon_id].vPosition.x, pActors[mon_id].vPosition.y, pSpellSprite.vPosition.z); - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.spell_target_pid = a2; - pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); - pSpellSprite.uFacing = LOWORD(v715.uYawAngle); - LOBYTE(pSpellSprite.uAttributes) |= 0x80; - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); - } - spell_sound_flag = true; - break; - } - case SPELL_DARK_SACRIFICE://Æåðòâà - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - int hired_npc = 0; - memset(&achieved_awards, 0, 4000); - for ( uint npc_id = 0; npc_id < 2; npc_id++ ) //êîëè÷åñòâî íàíÿòûõ ÍÏÑ - { - if ( pParty->pHirelings[npc_id].pName != 0) - achieved_awards[hired_npc++] = (AwardType)(npc_id + 1); - } - /*if ( (signed int)pNPCStats->uNumNewNPCs > 0) - { - //AwardType *_v734 = &achieved_awards[_v733]; - for ( int npc_id = 0; npc_id < pNPCStats->uNumNewNPCs; ++npc_id ) - { - if ( pNPCStats->pNewNPCData[npc_id].uFlags & 0x80//hired(íà¸ìíûé) - && (!pParty->pHirelings[0].pName - || strcmp(pNPCStats->pNewNPCData[npc_id].pName, pParty->pHirelings[0].pName)) - && (!pParty->pHirelings[1].pName - || strcmp(pNPCStats->pNewNPCData[npc_id].pName, pParty->pHirelings[1].pName)) ) - { - //v607 = _v734; - //++_v734; - achieved_awards[hired_npc++] = (AwardType)(npc_id + 3); - } - } - }*/ - if ( pCastSpell->uPlayerID_2 != 4 && pCastSpell->uPlayerID_2 != 5 - || achieved_awards[pCastSpell->uPlayerID_2 - 4] <= 0 || achieved_awards[pCastSpell->uPlayerID_2 - 4] >= 3 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - pParty->pHirelings[achieved_awards[pCastSpell->uPlayerID_2 - 4] - 1].evt_A = 1; - pParty->pHirelings[achieved_awards[pCastSpell->uPlayerID_2 - 4] - 1].evt_B = 0; - pParty->pHirelings[achieved_awards[pCastSpell->uPlayerID_2 - 4] - 1].evt_C = pIconsFrameTable->GetIconAnimLength(pIconsFrameTable->FindIcon("spell96")); - for ( uint pl_id = 0; pl_id < 4; pl_id++ ) - { - pParty->pPlayers[pl_id].sHealth = pParty->pPlayers[pl_id].GetMaxHealth(); - pParty->pPlayers[pl_id].sMana = pParty->pPlayers[pl_id].GetMaxMana(); - } - v613 = &pOutdoor->ddm; - if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor) - v613 = &pIndoor->dlv; - v613->uReputation += 15; - if ( v613->uReputation > 10000 ) - v613->uReputation = 10000; - spell_sound_flag = true; - break; - } - case SPELL_DARK_PAIN_REFLECTION://Îòðàæåíèå áîëè - { - switch (skill_level) - { - case 1: duration = 300 * (spell_level + 12); break; - case 2: duration = 300 * (spell_level + 12); break; - case 3: duration = 300 * (spell_level + 12); break; - case 4: duration = 900 * (spell_level + 4); break; - default: - assert(false); - } - amount = spell_level + 5; - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - if ( skill_level != 3 && skill_level != 4 ) - { - 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)duration << 7) * 0.033333335), skill_level, amount, 0, 0); - spell_sound_flag = true; - break; - } - for ( uint pl_id = 0; pl_id < 4; pl_id++ ) - { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id); - pParty->pPlayers[pl_id].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + - (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, amount, 0, 0); - } - spell_sound_flag = true; - break; - } - case SPELL_DARK_SOULDRINKER://Èñïèòü äóøó - { - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pGame->GetIndoorCamera(); - int mon_num = pRenderer->_46À6ÀÑ_GetActorsInViewport((signed __int64)pGame->pIndoorCameraD3D->GetPickDepth()); - v707.x = 0; - v707.y = 0; - v707.z = 0; - pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->uSpellID; - pSpellSprite.spell_level = spell_level; - pSpellSprite.spell_skill = skill_level; - pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); - pSpellSprite.uAttributes = 0; - pSpellSprite.uSectorID = 0; - pSpellSprite.uSpriteFrameID = 0; - pSpellSprite.field_60_distance_related_prolly_lod = 0; - pSpellSprite.uFacing = 0; - pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); - pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); - amount = 0; - if ( mon_num > 0 ) - { - amount = (mon_num * (7 * spell_level + 25)); - for ( uint mon_id = 0; mon_id < mon_num; mon_id++ ) - { - pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.x; - pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.y; - pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.z - - (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[mon_id]].uActorHeight * -0.8); - pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[mon_id]); - Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), _50BF30_actors_in_viewport_ids[mon_id], &v707); - } - } - int pl_num = 0; - int pl_array[4]; - for ( uint pl_id = 1; pl_id <= 4; ++pl_id ) - { - if ( !pPlayers[pl_id]->pConditions[Condition_Sleep] && !pPlayers[pl_id]->pConditions[Condition_Paralyzed] - && !pPlayers[pl_id]->pConditions[Condition_Unconcious] && !pPlayers[pl_id]->pConditions[Condition_Dead] - && !pPlayers[pl_id]->pConditions[Condition_Pertified] && !pPlayers[pl_id]->pConditions[Condition_Eradicated] ) - { - pl_array[pl_num++] = pl_id; - } - } - for ( uint j = 0; j < pl_num; j++ ) - { - pPlayers[pl_array[j]]->sHealth += (signed __int64)((double)(signed int)amount / (double)pl_num); - if ( pPlayers[pl_array[j]]->sHealth > pPlayers[pl_array[j]]->GetMaxHealth()) - pPlayers[pl_array[j]]->sHealth = pPlayers[pl_array[j]]->GetMaxHealth(); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_array[j]); - } - pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0, 64); - spell_sound_flag = true; - break; - } - case SPELL_DARK_ARMAGEDDON://Àðìàãåääîí - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[499], 2); // Can't cast Armageddon indoors! - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if ( skill_level == 4) - amount = 4; - else - amount = 3; - if ( pPlayer->uNumArmageddonCasts >= amount || pParty->armageddon_timer > 0 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed - pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->uSpellID = 0; - continue; - } - if ( !pPlayer->CanCastSpell(uRequiredMana) ) - break; - pParty->armageddon_timer = 256; - pParty->armageddonDamage = spell_level; - ++pPlayer->uNumArmageddonCasts; - if ( pParty->bTurnBasedModeOn == 1 ) - ++pTurnEngine->pending_actions; - for ( uint i = 0; i < 50; i++ ) - { - v642 = rand() % 4096 - 2048; - v643 = rand(); - v732 = GetTerrainHeightsAroundParty2(v642 + pParty->vPosition.x, pParty->vPosition.y + (v643 % 4096 - 2048), &v710, 0); - SpriteObject::sub_42F7EB_DropItemAt(4070, v642 + pParty->vPosition.x, pParty->vPosition.y + (v643 % 4096 - 2048), v732 + 16, rand() % 500 + 500, 1, 0, 0, 0); - } - spell_sound_flag = true; - break; - } - default: - break; - } - if ( pCastSpell->uFlags & 0x20 ) - { - if ( spell_sound_flag ) - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->uSpellID], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0); - } - else - { - if ( sRecoveryTime < 0 ) - sRecoveryTime = 0; - if ( pParty->bTurnBasedModeOn ) - { - //v645 = sRecoveryTime; - pParty->pTurnBasedPlayerRecoveryTimes[pCastSpell->uPlayerID] = sRecoveryTime; - pPlayer->SetRecoveryTime(sRecoveryTime); - if ( !some_active_character ) - pTurnEngine->ApplyPlayerAction(); - } - else - pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)sRecoveryTime * 2.133333333333333)); - if ( spell_sound_flag ) - { - pPlayer->PlaySound(SPEECH_49, 0); - //if ( spell_sound_flag ) - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->uSpellID], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0); - } - } - pCastSpell->uSpellID = 0; - spell_level = v723; - continue; - } - -} -//----- (00427DA0) -------------------------------------------------------- -size_t PushCastSpellInfo(uint16_t uSpellID, uint16_t uPlayerID, __int16 skill_level, uint16_t uFlags, int spell_sound_id) -{ - for (size_t i = 0; i < CastSpellInfoCount; i++) - { - if (!pCastSpellInfo[i].uSpellID) - { - 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 CastSpellInfoHelpers::_427D48() -{ - for (size_t i = 0; i < CastSpellInfoCount; i++) - { - if (pCastSpellInfo[i].uSpellID && pCastSpellInfo[i].uFlags & 0x3CA) - { - pCastSpellInfo[i].uSpellID = 0; - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - } - } -} -//----- (0042777D) -------------------------------------------------------- -void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6) -{ - unsigned __int16 v9; // cx@16 - unsigned int v10; // eax@18 - unsigned __int8 v11; // sf@18 - unsigned __int8 v12; // of@18 - unsigned __int16 v13; // cx@21 - unsigned int v14; // eax@23 - - //if ( pParty->bTurnBasedModeOn != 1 - // || (result = pTurnEngine->field_4, pTurnEngine->field_4 != 1) && pTurnEngine->field_4 != 3 ) - if (pParty->bTurnBasedModeOn) - { - if ( pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_MOVEMENT ) - return; - } - - - //v6 = a5; - //v7 = &pParty->pPlayers[uPlayerID]; - assert(uPlayerID < 4); - Player* player = &pParty->pPlayers[uPlayerID]; - if ( !(a5 & 0x10) ) - { - switch ( a1 ) - { - case SPELL_SPIRIT_FATE: - case SPELL_BODY_FIRST_AID: - case SPELL_DARK_REANIMATE: - //HIBYTE(v6) = HIBYTE(a5) | 1; - a5 |= 0x0100; - break; - - case SPELL_FIRE_FIRE_AURA: - case SPELL_WATER_RECHARGE_ITEM: - case SPELL_WATER_ENCHANT_ITEM: - case SPELL_DARK_VAMPIRIC_WEAPON: - //LOBYTE(v6) = a5 | 0x80; - a5 |= 0x0080; - break; - - case SPELL_FIRE_FIRE_BOLT: - case SPELL_FIRE_FIREBALL: - case SPELL_FIRE_INCINERATE: - case SPELL_AIR_LIGHNING_BOLT: - case SPELL_AIR_IMPLOSION: - case SPELL_WATER_POISON_SPRAY: - case SPELL_WATER_ICE_BOLT: - case SPELL_WATER_ACID_BURST: - case SPELL_WATER_ICE_BLAST: - case SPELL_EARTH_STUN: - case SPELL_EARTH_SLOW: - case SPELL_EARTH_DEADLY_SWARM: - case SPELL_EARTH_BLADES: - case SPELL_EARTH_MASS_DISTORTION: - case SPELL_SPIRIT_SPIRIT_LASH: - case SPELL_MIND_MIND_BLAST: - case SPELL_MIND_CHARM: - case SPELL_MIND_PSYCHIC_SHOCK: - case SPELL_BODY_HARM: - case SPELL_BODY_FLYING_FIST: - case SPELL_LIGHT_LIGHT_BOLT: - case SPELL_LIGHT_DESTROY_UNDEAD: - case SPELL_LIGHT_SUNRAY: - case SPELL_DARK_TOXIC_CLOUD: - case SPELL_DARK_SHRINKING_RAY: - case SPELL_DARK_SHARPMETAL: - case SPELL_DARK_DRAGON_BREATH: - if ( !a6 ) - a5 |= 0x0008; - break; - case SPELL_MIND_TELEPATHY: - case SPELL_MIND_BERSERK: - case SPELL_MIND_ENSLAVE: - case SPELL_LIGHT_PARALYZE: - case SPELL_DARK_CONTROL_UNDEAD: -//LABEL_9: - //v6 = a5 | 8; - a5 |= 0x0008; - break; - - case SPELL_EARTH_TELEKINESIS: - a5 |= 0x0040; - break; - - case SPELL_SPIRIT_BLESS: - if (a4 && ~a4 & 0x01C0) - //goto LABEL_25; - { - a5 |= 0x0002; - break; - } - else if ((player->pActiveSkills[PLAYER_SKILL_SPIRIT] & 0x1C0) == 0) - //goto LABEL_25; - { - a5 |= 0x0002; - break; - } - break; - - case SPELL_SPIRIT_PRESERVATION: - v9 = a4; - if ( !a4 ) - v9 = player->pActiveSkills[PLAYER_SKILL_SPIRIT]; - //goto LABEL_18; - v10 = SkillToMastery(v9); - v12 = __OFSUB__(v10, 3); - v11 = ((v10 - 3) & 0x80000000u) != 0; - //goto LABEL_24; - if ( v11 ^ v12 ) - { - a5 |= 0x0002; - break; - } - break; - - case SPELL_DARK_PAIN_REFLECTION: - v9 = a4; - if ( !a4 ) - v9 = player->pActiveSkills[PLAYER_SKILL_DARK]; -//LABEL_18: - v10 = SkillToMastery(v9); - v12 = __OFSUB__(v10, 3); - v11 = ((v10 - 3) & 0x80000000u) != 0; - //goto LABEL_24; - if ( v11 ^ v12 ) - { - a5 |= 0x0002; - break; - } - break; - - case SPELL_BODY_HAMMERHANDS: - v13 = a4; - if ( !a4 ) - v13 = player->pActiveSkills[PLAYER_SKILL_BODY]; - v14 = SkillToMastery(v13); - v12 = __OFSUB__(v14, 4); - v11 = ((v14 - 4) & 0x80000000u) != 0; -//LABEL_24: - if ( v11 ^ v12 ) - //goto LABEL_25; - { - a5 |= 0x0002; - break; - } - break; - - case SPELL_EARTH_STONE_TO_FLESH: - case SPELL_SPIRIT_REMOVE_CURSE: - case SPELL_SPIRIT_RAISE_DEAD: - case SPELL_SPIRIT_RESSURECTION: - case SPELL_MIND_REMOVE_FEAR: - case SPELL_MIND_CURE_PARALYSIS: - case SPELL_MIND_CURE_INSANITY: - case SPELL_BODY_CURE_WEAKNESS: - case SPELL_BODY_REGENERATION: - case SPELL_BODY_CURE_POISON: - case SPELL_BODY_CURE_DISEASE: -//LABEL_25: - //v6 = a5 | 2; - a5 |= 0x0002; - break; - - case SPELL_DARK_SACRIFICE: - //HIBYTE(v6) = HIBYTE(a5) | 2; - a5 |= 0x0200; - break; - default: - break; - } - } - - - if (a5 & 0x3CA) - { - for (uint i = 0; i < CastSpellInfoCount; ++i) - if (pCastSpellInfo[i].uFlags & 0x3CA) - { - pCastSpellInfo[i].uSpellID = 0; - break; - } - } - - for (uint i = 0; i < CastSpellInfoCount; ++i) - { - CastSpellInfo* spell = &pCastSpellInfo[i]; - if (!spell->uSpellID) - continue; - - spell->uSpellID = 0; - if (spell->uFlags & 0x3CA) - { - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = nullptr; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - } - } - - int result = PushCastSpellInfo(a1, uPlayerID, a4, a5, a6); - if ( result != -1 ) - { - if ( a5 & 2 ) - { - if ( pGUIWindow_Settings ) - return; - pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0); - pGUIWindow_Settings->CreateButton(52, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 0, 49, "", 0); - pGUIWindow_Settings->CreateButton(165, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 1, 50, "", 0); - pGUIWindow_Settings->CreateButton(280, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 2, 51, "", 0); - pGUIWindow_Settings->CreateButton(390, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 3, 52, "", 0); - pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); - return; - } - if ( a5 & 8 ) - { - if ( pGUIWindow_Settings ) - return; - - pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0); - pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Shoot_Monster, 0, 0, "", 0); - pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); - return; - } - if ( a5 & 0x40 ) - { - if ( pGUIWindow_Settings ) - return; - - pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0); - pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Telekinesis, 0, 0, "", 0); - pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); - return; - } - if ( (char)a5 < 0 ) - { - if ( pGUIWindow_Settings ) - return; - ++pIcons_LOD->uTexturePacksCount; - if ( !pIcons_LOD->uNumPrevLoadedFiles ) - pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; - pGUIWindow_Settings = pCastSpellInfo[result].GetCastSpellInInventoryWindow(); - _50C9A0_IsEnchantingInProgress = 1; - some_active_character = uActiveCharacter; - pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); - return; - } - if ( HIBYTE(a5) & 1 ) - { - if ( pGUIWindow_Settings ) - return; - pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0); - pGUIWindow_Settings->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 0, 0x31u, "", 0); - pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 1, 0x32u, "", 0); - pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 2, 0x33u, "", 0); - pGUIWindow_Settings->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 3, 0x34u, "", 0); - pGUIWindow_Settings->CreateButton(8, 8, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Monster_Improvement, 0, 0, "", NULL); - pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); - } - if ( HIBYTE(a5) & 2 && !pGUIWindow_Settings ) - { - pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0); - pBtn_NPCLeft = pGUIWindow_Settings->CreateButton(469, 178, - pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureWidth, - pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureHeight, - 1, 0, UIMSG_ScrollNPCPanel, 0, 0, "", - pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft), 0); - pBtn_NPCRight = pGUIWindow_Settings->CreateButton(626, 178, - pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureWidth, - pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureHeight, - 1, 0, UIMSG_ScrollNPCPanel, 1, 0, "", - pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight), 0); - pGUIWindow_Settings->CreateButton(491, 149, 64, 74, 1, 0, UIMSG_HiredNPC_CastSpell, 4, 0x35u, "", 0); - pGUIWindow_Settings->CreateButton(561, 149, 64, 74, 1, 0, UIMSG_HiredNPC_CastSpell, 5, 0x36u, "", 0); - } - } -} diff -r 92eeeb5200f2 -r 68cdef6879a0 CastSpellInfo.h --- a/CastSpellInfo.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -#pragma once - -#include - -#include - -namespace CastSpellInfoHelpers -{ - void _427D48(); - void _427E01_cast_spell(); -}; - -/* 271 */ -#pragma pack(push, 1) -struct CastSpellInfo -{ - //----- (00426987) -------------------------------------------------------- - inline CastSpellInfo() - { - memset(this, 0, sizeof(*this)); - } - - struct GUIWindow *GetCastSpellInInventoryWindow(); - - uint16_t uSpellID; - uint16_t uPlayerID; - uint16_t uPlayerID_2; - __int16 field_6; - uint16_t uFlags; - __int16 forced_spell_skill_level; - int spell_target_pid; - int sound_id; -}; -#pragma pack(pop) - -void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6); \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Chest.cpp --- a/Chest.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,806 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include - -#include "ErrorHandling.h" - -#include "Items.h" -#include "Chest.h" -#include "FrameTableInc.h" -#include "LOD.h" -#include "MapInfo.h" -#include "Actor.h" -#include "Engine/Graphics/Outdoor.h" -#include "Engine/Graphics/DecorationList.h" -#include "Party.h" -#include "AudioPlayer.h" -#include "OurMath.h" -#include "Texts.h" -#include "ObjectList.h" -#include "GUIWindow.h" -#include "Timer.h" - -#include "MM7.h" -#include "SpriteObject.h" -#include "Mouse.h" -#include "Engine/Graphics/Viewport.h" -#include "Engine/Graphics/Level/Decoration.h" - -size_t uNumChests; // idb -struct ChestList *pChestList; -std::array pChests; - - -const int pChestPixelOffsetX[8] = {42, 18, 18, 42, 42, 42, 18, 42}; -const int pChestPixelOffsetY[8] = {34, 30, 30, 34, 34, 34, 30, 34}; -const int pChestWidthsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9}; -const int pChestHeightsByType[8] = {9, 9, 9, 9, 9, 9, 9, 9}; - - -//----- (0042041E) -------------------------------------------------------- -bool Chest::Open( signed int uChestID ) -{ - unsigned int pMapID; // eax@8 - int pRandom; // edx@16 - int v6; // eax@16 - ODMFace *pODMFace; // eax@19 - BLVFace *pBLVFace; // eax@20 - int pObjectX; // ebx@21 - int pObjectZ; // edi@21 - double dir_x; // st7@23 - double dir_y; // st6@23 - double length_vector; // st7@23 - int pDepth; // ecx@26 - Vec3_int_ v; // ST4C_12@28 - bool flag_shout; // edi@28 - int pSpriteID[4]; // [sp+84h] [bp-40h]@16 - Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28 - int pObjectY; // [sp+B0h] [bp-14h]@21 - int sRotX; // [sp+B4h] [bp-10h]@23 - float dir_z; // [sp+BCh] [bp-8h]@23 - int sRotY; // [sp+C0h] [bp-4h]@8 - SpriteObject pSpellObject; // [sp+14h] [bp-B0h]@28 - - assert( uChestID < 20 ); - if ( ( uChestID < 0 ) && ( uChestID >= 20 ) ) - return false; - Chest* chest = &pChests[uChestID]; - - ++pIcons_LOD->uTexturePacksCount; - if (!pIcons_LOD->uNumPrevLoadedFiles) - pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; - - if (!chest->Initialized()) - Chest::PlaceItems(uChestID); - - if ( !uActiveCharacter ) - return false; - flag_shout = false; - pMapID = pMapStats->GetMapInfo(pCurrentMapName); - if ( chest->Trapped() && pMapID ) - { - if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[pMapID].LockX5 ) - { - pSpriteID[0] = 811; - pSpriteID[1] = 812; - pSpriteID[2] = 813; - pSpriteID[3] = 814; - pRandom = rand() % 4; - v6 = PID_ID(EvtTargetObj); - if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration) - { - pObjectX = pLevelDecorations[v6].vPosition.x; - pObjectY = pLevelDecorations[v6].vPosition.y; - pObjectZ = pLevelDecorations[v6].vPosition.z + ( pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight / 2 ); - } - if ( PID_TYPE(EvtTargetObj) == OBJECT_BModel) - { - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - { - pODMFace = &pOutdoor->pBModels[EvtTargetObj >> 9].pFaces[(EvtTargetObj >> 3) & 0x3F]; - pObjectX = ( pODMFace->pBoundingBox.x1 + pODMFace->pBoundingBox.x2 ) / 2; - pObjectY = ( pODMFace->pBoundingBox.y1 + pODMFace->pBoundingBox.y2 ) / 2; - pObjectZ = ( pODMFace->pBoundingBox.z1 + pODMFace->pBoundingBox.z2 ) / 2; - } - else//Indoor - { - pBLVFace = &pIndoor->pFaces[v6]; - pObjectX = ( pBLVFace->pBounding.x1 + pBLVFace->pBounding.x2 ) / 2; - pObjectY = ( pBLVFace->pBounding.y1 + pBLVFace->pBounding.y2 ) / 2; - pObjectZ = ( pBLVFace->pBounding.z1 + pBLVFace->pBounding.z2 ) / 2; - } - } - dir_x = (double)pParty->vPosition.x - (double)pObjectX; - dir_y = (double)pParty->vPosition.y - (double)pObjectY; - dir_z = ( (double)pParty->sEyelevel + (double)pParty->vPosition.z ) - (double)pObjectZ; - length_vector = sqrt( (dir_x * dir_x) + (dir_y * dir_y) + (dir_z * dir_z) ); - if ( length_vector <= 1.0 ) - { - *(float *)&sRotX = 0.0; - *(float *)&sRotY = 0.0; - } - else - { - sRotY = (signed __int64)sqrt(dir_x * dir_x + dir_y * dir_y); - sRotX = stru_5C6E00->Atan2((signed __int64)dir_x, (signed __int64)dir_y); - sRotY = stru_5C6E00->Atan2(dir_y * dir_y, (signed __int64)dir_z); - } - pDepth = 256; - if ( length_vector < 256.0 ) - pDepth = (signed __int64)length_vector / 4; - v.x = pObjectX; - v.y = pObjectY; - v.z = pObjectZ; - Vec3_int_::Rotate(pDepth, sRotX, sRotY, v, &pOut.x, &pOut.z, &pOut.y); - SpriteObject::sub_42F7EB_DropItemAt(pSpriteID[pRandom], pOut.x, pOut.z, pOut.y, 0, 1, 0, 48, 0); - - pSpellObject.stru_24.Reset(); - pSpellObject.spell_skill = 0; - pSpellObject.spell_level = 0; - pSpellObject.spell_id = 0; - pSpellObject.field_54 = 0; - pSpellObject.uType = pSpriteID[pRandom]; - pSpellObject.uObjectDescID = 0; - if ( pObjectList->uNumObjects ) - { - for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i ) - { - if ( pSpriteID[pRandom] == pObjectList->pObjects[i].uObjectID ) - pSpellObject.uObjectDescID = i; - } - } - pSpellObject.vPosition.y = pOut.z; - pSpellObject.vPosition.x = pOut.x; - pSpellObject.vPosition.z = pOut.y; - pSpellObject.uSoundID = 0; - pSpellObject.uAttributes = 48; - pSpellObject.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y); - pSpellObject.uSpriteFrameID = 0; - pSpellObject.spell_caster_pid = 0; - pSpellObject.spell_target_pid = 0; - pSpellObject.uFacing = 0; - pSpellObject.Create(0, 0, 0, 0); - pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); - pSpellObject.ExplosionTraps(); - chest->uFlags &= 0xFEu; - if ( uActiveCharacter && !_A750D8_player_speech_timer && !OpenedTelekinesis ) - { - _A750D8_player_speech_timer = 256i64; - PlayerSpeechID = SPEECH_5; - uSpeakingCharacter = uActiveCharacter; - } - pIcons_LOD->RemoveTexturesPackFromTextureList(); - OpenedTelekinesis = false; - return false; - } - chest->uFlags &= 0xFEu; - flag_shout = true; - } - pAudioPlayer->StopChannels(-1, -1); - pAudioPlayer->PlaySound(SOUND_OpenChest, 0, 0, -1, 0, 0, 0, 0); - if ( flag_shout == true ) - { - if ( !OpenedTelekinesis ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0); - } - OpenedTelekinesis = false; - pChestWindow = pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Chest, uChestID, 0); - pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);// Exit - pChestWindow->CreateButton( 7, 8, 460, 343, 1, 0, UIMSG_CHEST_ClickItem, 0, 0, "", 0); - pCurrentScreen = SCREEN_CHEST; - pEventTimer->Pause(); - return true; -} - -//----- (0042038D) -------------------------------------------------------- -void Chest::ChestUI_WritePointedObjectStatusString() -{ - int v1; // ecx@2 - POINT cursor; // [sp+8h] [bp-8h]@1 - - pMouse->GetCursorPos(&cursor); - if ( cursor.y < 350 ) - { - v1 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]]; - if ( v1 != 0 && v1 != -65536 ) - { - if ( v1 ) - { - ItemGen* item = &pChests[pChestWindow->par1C].igChestItems[pChests[pChestWindow->par1C].pInventoryIndices[(v1 & 0xFFFF) - 1] - 1]; - GameUI_SetFooterString(item->GetDisplayName()); - } - } - } -} - -//----- (0042092D) -------------------------------------------------------- -void Chest::DrawChestUI(signed int uChestID) - { - - int chestBitmapId; // eax@1 - unsigned int v5; // eax@1 - int chest_item_index; // ecx@3 - unsigned int item_texture_id; // eax@4 - Texture *item_texture; // esi@4 - signed int itemPixelWidth; // ecx@4 - signed int itemPixelHeght; // edx@4 -// signed int v11; // eax@4 - int v12; // eax@6 - int v13; // eax@6 - unsigned int itemPixelPosX; // ST34_4@8 - int itemPixelPosY; // edi@8 - int *v16; // [sp+Ch] [bp-28h]@1 -// int v17; // [sp+10h] [bp-24h]@4 - int chest_offs_y; // [sp+14h] [bp-20h]@1 - signed int chestHeghtCells; // [sp+18h] [bp-1Ch]@1 - int chest_offs_x; // [sp+1Ch] [bp-18h]@1 - signed int chestWidthCells; // [sp+20h] [bp-14h]@1 - signed int item_counter; // [sp+30h] [bp-4h]@1 - - v16 = pRenderer->pActiveZBuffer; - pRenderer->ClearZBuffer(0, 479); - chestBitmapId = pChests[uChestID].uChestBitmapID; - chest_offs_x = pChestPixelOffsetX[chestBitmapId]; - chest_offs_y = pChestPixelOffsetY[chestBitmapId]; - chestWidthCells = pChestWidthsByType[chestBitmapId]; - chestHeghtCells = pChestHeightsByType[chestBitmapId]; - sprintfex(pTmpBuf.data(), "chest%02d", pChestList->pChests[chestBitmapId].uTextureID); - v5 = pIcons_LOD->LoadTexture(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); - pRenderer->DrawTextureIndexed(8u, 8u, pIcons_LOD->GetTexture(v5)); - - for (item_counter = 0; item_counter < chestWidthCells * chestHeghtCells; ++item_counter) - { - chest_item_index = pChests[uChestID].pInventoryIndices[item_counter]; - if ( chest_item_index > 0 ) - { - item_texture_id = pIcons_LOD->LoadTexture( - //pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName, - pChests[uChestID].igChestItems[chest_item_index - 1].GetIconName(), TEXTURE_16BIT_PALETTE); - item_texture = pIcons_LOD->GetTexture(item_texture_id); - itemPixelWidth = item_texture->uTextureWidth; - itemPixelHeght = item_texture->uTextureHeight; - if ( itemPixelWidth < 14 ) - itemPixelWidth = 14; - v12 = itemPixelWidth - 14; - v12 = v12 & 0xFFFFFFE0; - v13 = v12 + 32; - if ( itemPixelHeght < 14 ) - itemPixelHeght = 14; - itemPixelPosX = chest_offs_x + 32 * (item_counter % chestWidthCells) + ((signed int)(v13 - itemPixelWidth)/2); - itemPixelPosY = chest_offs_y + 32 * (item_counter / chestHeghtCells) + - ((signed int)(((itemPixelHeght - 14) & 0xFFFFFFE0) + 32- item_texture->uTextureHeight ) /2); - pRenderer->DrawTextureTransparent( itemPixelPosX, itemPixelPosY, item_texture); - ZBuffer_DoFill2(&v16[itemPixelPosX + pSRZBufferLineOffsets[itemPixelPosY]], item_texture, item_counter + 1); - } - } - pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uExitCancelTextureId)); - } - - -//----- (0041FE71) -------------------------------------------------------- -bool Chest::CanPlaceItemAt( signed int test_cell_position, int item_id, signed int uChestID ) - { -// int v3; // eax@1 - unsigned int item_texture_id; // eax@1 - Texture *item_texture; // ecx@1 - signed int v6; // eax@1 -// signed int v7; // edi@3 - signed int v8; // eax@3 - int texture_cell_width; // edi@3 - int texture_cell_height; // ebx@5 - int _row; // esi@9 - int _cell_rows; // edx@10 - int _column; // ecx@11 -// char *v14; // eax@12 - int chest_cell_heght; // [sp+Ch] [bp-Ch]@1 -// signed int v17; // [sp+10h] [bp-8h]@1 - signed int chest_cell_width; // [sp+14h] [bp-4h]@1 - - chest_cell_heght = pChestHeightsByType[pChests[uChestID].uChestBitmapID]; - chest_cell_width = pChestWidthsByType[pChests[uChestID].uChestBitmapID]; - item_texture_id = pIcons_LOD->LoadTexture(pItemsTable->pItems[item_id].pIconName, TEXTURE_16BIT_PALETTE); - item_texture = pIcons_LOD->GetTexture(item_texture_id); - v6 = item_texture->uTextureWidth; - if ( v6 < 14 ) - v6 = 14; - texture_cell_width = ((v6 - 14) >> 5) + 1; - v8 = item_texture->uTextureHeight; - if ( v8 < 14 ) - v8 = 14; - texture_cell_height = ((v8 - 14) >> 5) + 1; - if ( !areWeLoadingTexture ) - { - item_texture->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - if ( (texture_cell_width + test_cell_position % chest_cell_width <= chest_cell_width) && - (texture_cell_height + test_cell_position / chest_cell_width <= chest_cell_heght) ) - { //we not put over borders - _row = 0; - if ( texture_cell_height <= 0 ) - return true; - _cell_rows = 0; - while ( 1 ) - { - _column = 0; - if ( texture_cell_width > 0 ) - { - while ( pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]==0) - { - ++_column; - if ( _column >= texture_cell_width ) - break; - } - if (pChests[uChestID].pInventoryIndices[test_cell_position + _cell_rows+_column]!=0) - return false; - } - _cell_rows += chest_cell_width; - ++_row; - if ( _row >= texture_cell_height ) - return true; - } - - } - return false; - } -// 506128: using guessed type int areWeLoadingTexture; - -//----- (0041FF64) -------------------------------------------------------- -int Chest::CountChestItems(signed int uChestID) -{ - signed int item_count; // eax@1 - int max_items; // edx@1 - item_count = 0; - max_items = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID]; - if ( max_items <= 0 ) - item_count = -1; - else - { - while ( pChests[uChestID].igChestItems[item_count].uItemID ) - { - ++item_count; - if ( item_count >= max_items ) - { - item_count = -1; - break; - } - } - } - return item_count; -} - -//----- (0041FFA2) -------------------------------------------------------- -int Chest::PutItemInChest(int position, ItemGen *put_item, signed int uChestID) -{//(rus: ïîëîæèòü ïðåäìåò â ÿùèê) - ItemGen *v4; // edi@1 - int v5; // esi@1 - int result; // eax@11 - unsigned int v7; // eax@12 - int v8; // edx@12 - Texture *texture; // ecx@12 - signed int v10; // eax@12 - signed int v11; // edi@14 - unsigned int v12; // esi@14 - int v13; // edi@16 - void *v14; // edi@21 - int v15; // edi@21 - int i; // ecx@21 - ItemGen *Src; // [sp+Ch] [bp-18h]@1 - signed int item_in_chest_count; // [sp+10h] [bp-14h]@2 - int v19; // [sp+14h] [bp-10h]@1 - int v20; // [sp+18h] [bp-Ch]@19 - signed int v21; // [sp+1Ch] [bp-8h]@1 -// signed int v22; // [sp+20h] [bp-4h]@3 - int v23; // [sp+20h] [bp-4h]@19 - - v21 = 0; - v4 = put_item; - v5 = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID]; - Src = put_item; - v19 = pChestWidthsByType[pChests[uChestID].uChestBitmapID]; - if ( position == -1 ) - { - item_in_chest_count = CountChestItems(uChestID); - if ( item_in_chest_count == -1 ) - return 0; - for( int _i = 0; _i < v5; _i++) - { - if ( Chest::CanPlaceItemAt(_i, v4->uItemID, pChestWindow->par1C) ) - v21 = _i; - } - if ( v21 == v5 ) - { - if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); - return 0; - } - v7 = pIcons_LOD->LoadTexture(v4->GetIconName(), TEXTURE_16BIT_PALETTE); - HIWORD(v8) = 0; - texture = pIcons_LOD->GetTexture(v7); - v10 = texture->uTextureWidth; - if ( texture->uTextureWidth < 14 ) - v10 = 14; - v12 = ((v10 - 14) >> 5) + 1; - v11 = texture->uTextureHeight; - if ( texture->uTextureHeight < 14 ) - v11 = 14; - v13 = ((v11 - 14) >> 5) + 1; - if ( !areWeLoadingTexture ) - { - texture->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - if ( v13 > 0 ) - { - v23 = 0; - v20 = v13; - do - { - if ( (signed int)v12 > 0 ) - { - v14 = &pChests[uChestID].pInventoryIndices[v21 + v23]; - LOWORD(v8) = -1 - v21; - v8 <<= 16; - LOWORD(v8) = -1 - v21; - memset32(v14, v8, v12 >> 1); - v15 = (int)((char *)v14 + 4 * (v12 >> 1)); - for ( i = v12 & 1; i; --i ) - { - *(short *)v15 = v8; - v15 += 2; - } - } - v23 += v19; - --v20; - } - while ( v20 ); - } - pChests[uChestID].pInventoryIndices[v21] = item_in_chest_count + 1; - memcpy(&pChests[uChestID].igChestItems[item_in_chest_count], put_item, sizeof(ItemGen)); - result = v21 + 1; - } - else - result = 1; - return result; -} -// 506128: using guessed type int areWeLoadingTexture; - -//----- (0042013E) -------------------------------------------------------- -void Chest::PlaceItemAt( unsigned int put_cell_pos, unsigned int item_at_cell, signed int uChestID ) -{ - int uItemID; // edi@1 - int v6; // edx@4 - unsigned int v7; // eax@5 - Texture *texture; // ecx@5 - signed int v9; // eax@5 - signed int v10; // edi@7 - unsigned int texture_cell_width; // ebx@7 - int textute_cell_height; // edi@9 - int chest_cell_row_pos; // edx@12 - int chest_cell_width; // [sp+10h] [bp-Ch]@11 - - uItemID = pChests[ uChestID].igChestItems[item_at_cell].uItemID; - pItemsTable->SetSpecialBonus(&pChests[ uChestID].igChestItems[item_at_cell]); - if ( uItemID >= 135 && uItemID <= 159 && !pChests[ uChestID].igChestItems[item_at_cell].uNumCharges) - { - v6 = rand() % 21 + 10; - pChests[ uChestID].igChestItems[item_at_cell].uNumCharges = v6; - pChests[ uChestID].igChestItems[item_at_cell].uMaxCharges = v6; - } - v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); - texture = pIcons_LOD->GetTexture(v7); - v9 = texture->uTextureWidth; - if ( texture->uTextureWidth < 14 ) - v9 = 14; - texture_cell_width = ((v9 - 14) >> 5) + 1; - v10 = texture->uTextureHeight; - if ( texture->uTextureHeight < 14 ) - v10 = 14; - textute_cell_height = ((v10 - 14) >> 5) + 1; - if ( !areWeLoadingTexture ) - { - texture->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - chest_cell_width = pChestWidthsByType[pChests[ uChestID].uChestBitmapID]; - chest_cell_row_pos = 0; - for(int i = 0; i < textute_cell_height; ++i) - { - for (int j = 0; j < texture_cell_width; ++j) - pChests[uChestID].pInventoryIndices[put_cell_pos + chest_cell_row_pos+j]=(signed __int16)-(put_cell_pos+1); - chest_cell_row_pos += chest_cell_width; - } - pChests[uChestID].pInventoryIndices[put_cell_pos] = item_at_cell + 1; -} -// 506128: using guessed type int areWeLoadingTexture; - -//----- (00420284) -------------------------------------------------------- -void Chest::PlaceItems(signed int uChestID ) - { - int uChestArea; // edi@1 - int random_chest_pos; // eax@2 - int test_position; // ebx@11 - char chest_cells_map[144]; // [sp+Ch] [bp-A0h]@1 - int chest_item_id; // [sp+9Ch] [bp-10h]@10 - unsigned int items_counter; // [sp+A4h] [bp-8h]@8 - - pRenderer->ClearZBuffer(0, 479); - uChestArea = pChestWidthsByType[pChests[uChestID].uChestBitmapID] * pChestHeightsByType[pChests[uChestID].uChestBitmapID]; - memset(chest_cells_map, 0, 144); - //fill cell map at random positions - for ( items_counter = 0; items_counter < uChestArea; ++items_counter ) - { - //get random position in chest - do - random_chest_pos = (unsigned __int8)rand(); - while ( random_chest_pos >= uChestArea ); - //if this pos occupied move to next - while ( chest_cells_map[random_chest_pos] ) - { - ++random_chest_pos; - if ( random_chest_pos == uChestArea ) - random_chest_pos = 0; - } - chest_cells_map[random_chest_pos] = items_counter; - } - items_counter = 0; - - for (items_counter = 0; items_counter= uChestArea ) - break; - } - if(test_position= 0 && uChestID <= 19 ) - { - if ( bToggle ) - pChests[uChestID].uFlags |= uFlag; - else - pChests[uChestID].uFlags &= ~uFlag; - } -} - -//----- (00458B03) -------------------------------------------------------- -void ChestList::ToFile() -{ - FILE *v2; // eax@1 - FILE *v3; // edi@1 - - v2 = fopen("data\\dchest.bin", "wb"); - v3 = v2; - if ( !v2 ) - Error("Unable to save dchest.bin!"); - - fwrite(this, 4, 1, v2); - fwrite(this->pChests, 36, this->uNumChests, v3); - fclose(v3); -} - - -//----- (00458B4F) -------------------------------------------------------- -void ChestList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) -{ - uint num_mm6_chests = data_mm6 ? *(int *)data_mm6 : 0, - num_mm7_chests = data_mm7 ? *(int *)data_mm7 : 0, - num_mm8_chests = data_mm8 ? *(int *)data_mm8 : 0; - - uNumChests = num_mm6_chests + num_mm7_chests + num_mm8_chests; - assert(uNumChests); - assert(!num_mm8_chests); - - pChests = (ChestDesc *)malloc(uNumChests * sizeof(ChestDesc)); - memcpy(pChests, (char *)data_mm7 + 4, num_mm7_chests * sizeof(ChestDesc)); - memcpy(pChests + num_mm7_chests, (char *)data_mm6 + 4, num_mm6_chests * sizeof(ChestDesc)); - memcpy(pChests + num_mm6_chests + num_mm7_chests, (char *)data_mm8 + 4, num_mm8_chests * sizeof(ChestDesc)); -} - - -//----- (00458B9C) -------------------------------------------------------- -int ChestList::FromFileTxt(const char *Args) -{ - //ChestList *v2; // ebx@1 - __int32 v3; // edi@1 - FILE *v4; // eax@1 - unsigned int v5; // esi@3 - const void *v6; // ST18_4@9 - void *v7; // eax@9 - FILE *v8; // ST0C_4@11 - char *i; // eax@11 - char v10; // al@14 - const char *v11; // ST14_4@14 - char v12; // al@14 - const char *v13; // ST10_4@14 - char Buf; // [sp+8h] [bp-2F0h]@3 - FrameTableTxtLine v16; // [sp+1FCh] [bp-FCh]@4 - FrameTableTxtLine v17; // [sp+278h] [bp-80h]@4 - FILE *File; // [sp+2F4h] [bp-4h]@1 - unsigned int Argsa; // [sp+300h] [bp+8h]@3 - - //v2 = this; - free(this->pChests); - v3 = 0; - this->pChests = 0; - this->uNumChests = 0; - v4 = fopen(Args, "r"); - File = v4; - if ( !v4 ) - Error("ChestDescriptionList::load - Unable to open file: %s."); - - v5 = 0; - Argsa = 0; - if ( fgets(&Buf, 490, v4) ) - { - do - { - *strchr(&Buf, 10) = 0; - memcpy(&v17, txt_file_frametable_parser(&Buf, &v16), sizeof(v17)); - if ( v17.uPropCount && *v17.pProperties[0] != 47 ) - ++Argsa; - } - while ( fgets(&Buf, 490, File) ); - v5 = Argsa; - v3 = 0; - } - v6 = this->pChests; - this->uNumChests = v5; - v7 = malloc(36 * v5); - this->pChests = (ChestDesc *)v7; - if ( v7 == (void *)v3 ) - Error("ChestDescriptionList::load - Out of Memory!"); - - memset(v7, v3, 36 * this->uNumChests); - v8 = File; - this->uNumChests = v3; - fseek(v8, v3, v3); - for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) - { - *strchr(&Buf, 10) = 0; - memcpy(&v17, txt_file_frametable_parser(&Buf, &v16), sizeof(v17)); - if ( v17.uPropCount && *v17.pProperties[0] != 47 ) - { - strcpy(this->pChests[this->uNumChests].pName, v17.pProperties[0]); - v10 = atoi(v17.pProperties[1]); - v11 = v17.pProperties[2]; - this->pChests[this->uNumChests].uWidth = v10; - v12 = atoi(v11); - v13 = v17.pProperties[3]; - this->pChests[this->uNumChests].uHeight = v12; - this->pChests[this->uNumChests++].uTextureID = atoi(v13); - } - } - fclose(File); - return 1; -} - -//----- (00420B13) -------------------------------------------------------- -void __fastcall sub_420B13(int a1, int a2) -{ //Give item from chest(rus: Âçÿòü ïðåäìåò èç ÿùèêà) - void *v2; // eax@1 - unsigned int v4; // eax@1 - Texture *texture; // ecx@1 - signed int v6; // eax@1 - signed int v7; // edi@3 - signed int v8; // eax@3 - int v9; // edi@3 - int v10; // eax@5 - int v11; // esi@8 - unsigned int v12; // ecx@10 - void *v13; // edi@10 - unsigned __int8 v14; // cf@10 - int v15; // edi@10 - int i; // ecx@10 - int v17; // [sp+Ch] [bp-14h]@1 - int v18; // [sp+10h] [bp-10h]@3 - int v21; // [sp+1Ch] [bp-4h]@5 - int v22; // [sp+1Ch] [bp-4h]@8 - - v2 = (void *)(5324 * (int)pChestWindow->ptr_1C); - v17 = pChestWidthsByType[pChests[(int)pChestWindow->ptr_1C].uChestBitmapID]; - v4 = pIcons_LOD->LoadTexture(pChests[(int)pChestWindow->ptr_1C].igChestItems[a1].GetIconName(), TEXTURE_16BIT_PALETTE); - texture = pIcons_LOD->GetTexture(v4); - - v6 = texture->uTextureWidth; - if ( texture->uTextureWidth < 14 ) - v6 = 14; - v7 = v6 - 14; - v9 = (v7 >> 5) + 1; - v18 = v9; - - v8 = texture->uTextureHeight; - if ( texture->uTextureHeight < 14 ) - v8 = 14; - v10 = ((v8 - 14) >> 5) + 1; - v21 = v10; - - if ( !areWeLoadingTexture ) - { - texture->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - v10 = v21; - } - if ( v10 > 0 ) - { - v11 = 0; - for ( v22 = v10; v22; --v22 ) - { - if ( v9 > 0 ) - { - v12 = v9; - v13 = &pChests[(int)pChestWindow->ptr_1C].pInventoryIndices[a2 + v11]; - v14 = v12 & 1; - v12 >>= 1; - memset(&pChests[(int)pChestWindow->ptr_1C].pInventoryIndices[a2 + v11], 0, 4 * v12); - v15 = (int)((char *)v13 + 4 * v12); - for ( i = v14; i; --i ) - { - *(short *)v15 = 0; - v15 += 2; - } - v9 = v18; - } - v11 += v17; - } - } - pChests[(int)pChestWindow->ptr_1C].igChestItems[a1].Reset(); -} -// 506128: using guessed type int areWeLoadingTexture; -//----- (00420E01) -------------------------------------------------------- -void Chest::OnChestLeftClick() -{ - int v2; // eax@2 - int v3; // ebx@4 - int v4; // esi@6 - POINT cursor; // [sp+84h] [bp-8h]@2 - - SpriteObject v6; // [sp+Ch] [bp-80h]@1 - if ( pParty->pPickedItem.uItemID ) - { - if ( Chest::PutItemInChest(-1, &pParty->pPickedItem, pGUIWindow_CurrentMenu->par1C) ) - pMouse->RemoveHoldingItem(); - } - else - { - pMouse->GetCursorPos(&cursor); - v2 = pRenderer->pActiveZBuffer[cursor.x + pSRZBufferLineOffsets[cursor.y]] & 0xFFFF; - if ( v2 ) - { - if ( v2 ) - v3 = v2 - 1; - else - v3 = -1; - v4 = pChests[(int)pGUIWindow_CurrentMenu->par1C].pInventoryIndices[v3] - 1; - if ( pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4].GetItemEquipType() == EQUIP_GOLD ) - { - pParty->PartyFindsGold(pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4].uSpecEnchantmentType, 0); - viewparams->bRedrawGameUI = 1; - } - else - pParty->SetHoldingItem(&pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4]); - sub_420B13(v4, v3); - } - } -} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Chest.h --- a/Chest.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -#pragma once - - - - -/* 348 */ -enum CHEST_FLAGS -{ - CHEST_TRAPPED = 0x1, - CHEST_ITEMS_PLACED = 0x2, - CHEST_OPENED = 0x4, -}; - - - -#pragma pack(push, 1) -struct ChestDesc -{ - char pName[32]; - char uWidth; - char uHeight; - __int16 uTextureID; -}; -#pragma pack(pop) - - - -#pragma pack(push, 1) -struct ChestList -{ - inline ChestList(): //----- (00458438) - uNumChests(0), pChests(nullptr) - {} - - void ToFile(); - void FromFile(void *data_mm6, void *data_mm7, void *data_mm8); - int FromFileTxt(const char *Args); - - - unsigned int uNumChests; - struct ChestDesc *pChests; -}; -#pragma pack(pop) - - - -/* 65 */ -#pragma pack(push, 1) -struct Chest //0x14cc -{ - inline bool Initialized() const {return (uFlags & CHEST_ITEMS_PLACED) != 0;} - inline void SetInitialized(bool b) {if (b) uFlags |= CHEST_ITEMS_PLACED; else uFlags &= ~CHEST_ITEMS_PLACED;} - inline bool Trapped() const {return (uFlags & CHEST_TRAPPED) != 0;} - - static bool CanPlaceItemAt(signed int a1, int a2, signed int uChestID); - static int CountChestItems(signed int uChestID); - static int PutItemInChest(int a1, ItemGen *a2, signed int uChestID); - static void PlaceItemAt(unsigned int put_cell_pos, unsigned int uItemIdx, signed int uChestID); - static void PlaceItems(signed int uChestID); - static bool Open(signed int uChestID); - static void DrawChestUI(signed int uChestID); - static void ToggleFlag(signed int uChestID, unsigned __int16 uFlag, unsigned int bToggle); - static void ChestUI_WritePointedObjectStatusString(); - static void OnChestLeftClick(); - - unsigned __int16 uChestBitmapID; //0 - unsigned __int16 uFlags; //2 - struct ItemGen igChestItems[140]; //4 - signed __int16 pInventoryIndices[140]; //0x13b4 -}; -#pragma pack(pop) - -void __fastcall sub_420B13(int a1, int a2); - - -extern size_t uNumChests; // idb -extern struct ChestList *pChestList; -extern std::array pChests; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Conditions.cpp --- a/Conditions.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#pragma once -#include "Conditions.h" -#include "Party.h" -std::array conditionArray = -{ - // hint: condname, protfrommagic, gmprot, enchantment, ... - ConditionProcessor(Condition_Cursed, false, false, 0), - ConditionProcessor(Condition_Weak, true, false, 0), - ConditionProcessor(Condition_Sleep, false, false, 22, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR), - ConditionProcessor(Condition_Fear, false, false, 0), - ConditionProcessor(Condition_Drunk, false, false, 0), - ConditionProcessor(Condition_Insane, false, false, 19, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), - ConditionProcessor(Condition_Poison_Weak, true, false, 21, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), - ConditionProcessor(Condition_Disease_Weak, true, false, 18, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), - ConditionProcessor(Condition_Poison_Medium, true, false, 21, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), - ConditionProcessor(Condition_Disease_Medium, true, false, 18, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), - ConditionProcessor(Condition_Poison_Severe, true, false, 21, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), - ConditionProcessor(Condition_Disease_Severe, true, false, 18, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), - ConditionProcessor(Condition_Paralyzed, false, false, 20, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK, ITEM_ARTIFACT_GHOULSBANE, EQIUP_ANY), - ConditionProcessor(Condition_Unconcious,false, false, 0), - ConditionProcessor(Condition_Dead, true, true, 0), - ConditionProcessor(Condition_Pertified, true, false, 23, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK, ITEM_RELIC_KELEBRIM, EQIUP_ANY), - ConditionProcessor(Condition_Eradicated, true, true, 0), - ConditionProcessor(Condition_Zombie, false, false, 0) -}; - -bool ConditionProcessor::IsPlayerAffected( Player* inPlayer, int condToCheck, int blockable) -{ - if ( !blockable ) - return true; - ConditionProcessor* thisProc = &conditionArray[condToCheck]; - if (thisProc->m_IsBlockedByProtFromMagic && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0) - { - if (!(thisProc->m_DoesNeedGmProtFromMagic && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uSkill < 4)) - { - --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; - if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1 ) - pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); - return false; - } - } - if (thisProc->m_WorkingEnchantment != 0) - { - if (inPlayer->HasEnchantedItemEquipped(thisProc->m_WorkingEnchantment)) - return false; - } - for (unsigned int i = 0; i < thisProc->m_equipmentPairs.size() / 2; i++) - { - if (thisProc->m_equipmentPairs[i * 2].m_ItemId == (ITEM_TYPE)0) - return true; - ITEM_TYPE itemId = thisProc->m_equipmentPairs[i * 2].m_ItemId; - ITEM_EQUIP_TYPE slot = thisProc->m_equipmentPairs[i * 2 + 1].m_EquipSlot; - if (slot == EQIUP_ANY) - { - if (inPlayer->WearsItemAnyWhere(itemId)) - return false; - } - else - { - if (inPlayer->WearsItem(itemId, slot)) - return false; - } - } - return true; -} diff -r 92eeeb5200f2 -r 68cdef6879a0 Conditions.h --- a/Conditions.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -#pragma once -#include "Items.h" -#include -enum Condition: unsigned __int32 -{ - Condition_Cursed = 0, - Condition_Weak = 1, - Condition_Sleep = 2, - Condition_Fear = 3, - Condition_Drunk = 4, - Condition_Insane = 5, - Condition_Poison_Weak = 6, - Condition_Disease_Weak = 7, - Condition_Poison_Medium = 8, - Condition_Disease_Medium = 9, - Condition_Poison_Severe = 10, - Condition_Disease_Severe = 11, - Condition_Paralyzed = 12, - Condition_Unconcious = 13, - Condition_Dead = 14, - Condition_Pertified = 15, - Condition_Eradicated = 16, - Condition_Zombie = 17, - Condition_Good = 18 -}; - - -class EquipemntPair -{ -public: - ITEM_TYPE m_ItemId; - ITEM_EQUIP_TYPE m_EquipSlot; - EquipemntPair(ITEM_TYPE type, ITEM_EQUIP_TYPE slot) - { - m_ItemId = type; - m_EquipSlot = slot; - } - EquipemntPair() - { - m_ItemId = (ITEM_TYPE)0; - m_EquipSlot = (ITEM_EQUIP_TYPE)0; - } -}; - -struct Player; - -class ConditionProcessor -{ -public: - bool m_IsBlockedByProtFromMagic; - bool m_DoesNeedGmProtFromMagic; - int m_WorkingEnchantment; - std::array m_equipmentPairs; - ConditionProcessor(int, bool isblocked, bool needsGm, int enchantment, - ITEM_TYPE itemtype1 = (ITEM_TYPE)0, ITEM_EQUIP_TYPE itemslot1 = (ITEM_EQUIP_TYPE)0, - ITEM_TYPE itemtype2 = (ITEM_TYPE)0, ITEM_EQUIP_TYPE itemslot2 = (ITEM_EQUIP_TYPE)0, - ITEM_TYPE itemtype3 = (ITEM_TYPE)0, ITEM_EQUIP_TYPE itemslot3 = (ITEM_EQUIP_TYPE)0) - { - m_IsBlockedByProtFromMagic = isblocked; - m_DoesNeedGmProtFromMagic = needsGm; - m_WorkingEnchantment = enchantment; - m_equipmentPairs[0].m_ItemId = itemtype1; - m_equipmentPairs[0].m_EquipSlot = itemslot1; - m_equipmentPairs[1].m_ItemId = itemtype2; - m_equipmentPairs[1].m_EquipSlot = itemslot2; - m_equipmentPairs[2].m_ItemId = itemtype3; - m_equipmentPairs[2].m_EquipSlot = itemslot3; - } - - static bool IsPlayerAffected(Player*, int, int); -}; - -extern std::array conditionArray; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Autonotes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Autonotes.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,25 @@ +#pragma once +#include + + + +/* 351 */ +enum AUTONOTE_TYPE : __int32 +{ + AUTONOTE_POTION_RECEPIE = 0, + AUTONOTE_STAT_HINT = 1, + AUTONOTE_OBELISK = 2, + AUTONOTE_SEER = 3, + AUTONOTE_MISC = 4, + AUTONOTE_TEACHER = 5, +}; + +/* 350 */ +#pragma pack(push, 1) +struct Autonote +{ + const char *pText; + AUTONOTE_TYPE eType; +}; +#pragma pack(pop) +extern std::array pAutonoteTxt; // weak diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Awards.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Awards.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,127 @@ +#pragma once +#include + +/* 353 */ +#pragma pack(push, 1) +struct Award +{ + const char *pText; + unsigned int uPriority; +}; +#pragma pack(pop) +extern std::array pAwards; + + + +enum AwardType: unsigned __int32 +{ + Award_Invalid = 0 + , Award_Fine = 1 + , Award_EmeraldIsle_CompletedMainQuest = 2 + , Award_EmeraldIsle_FoundMissingCompetitors = 3 + , Award_Harmondale_CastleCleared = 4 + , Award_BarrowDowns_RescuedMiners = 5 + , Award_Erathia_RescuedLorenSteel = 6 + , Award_Avlee_BroughtFakeLorenSteelToErathia = 7 + , Award_Avlee_BroughtFortRiverstridePlans = 8 + , Award_Erathia_DeliveredFakePlansToElves = 9 + , Award_Promotion_Rogue = 10 + , Award_Promotion_Rogue_Honorary = 11 + , Award_Promotion_Spy = 12 + , Award_Promotion_Spy_Honorary = 13 + , Award_Promotion_Assassin = 14 + , Award_Promotion_Assassin_Honorary = 15 + , Award_Promotion_Chevalier = 16 + , Award_Promotion_Chevalier_Honorary = 17 + , Award_Promotion_Champion = 18 + , Award_Promotion_Champion_Honorary = 19 + , Award_Promotion_BlackKnight = 20 + , Award_Promotion_BlackKnight_Honorary = 21 + , Award_Promotion_Initiate = 22 + , Award_Promotion_Initiate_Honorary = 23 + , Award_Promotion_Master = 24 + , Award_Promotion_Master_Honorary = 25 + , Award_Promotion_Ninja = 26 + , Award_Promotion_Ninja_Honorary = 27 + , Award_Promotion_Hunter = 28 + , Award_Promotion_Hunter_Honorary = 29 + , Award_Promotion_RangerLord = 30 + , Award_Promotion_RangerLord_Honorary = 31 + , Award_Promotion_BountyHunter = 32 + , Award_Promotion_BountyHunter_Honorary = 33 + , Award_Promotion_WarriorMage = 34 + , Award_Promotion_WarriorMage_Honorary = 35 + , Award_Promotion_MasterArcher = 36 + , Award_Promotion_MasterArcher_Honorary = 37 + , Award_Promotion_Sniper = 38 + , Award_Promotion_Sniper_Honorary = 39 + , Award_Promotion_Crusader = 40 + , Award_Promotion_Crusader_Honorary = 41 + , Award_Promotion_Hero = 42 + , Award_Promotion_Hero_Honorary = 43 + , Award_Promotion_Villian = 44 + , Award_Promotion_Villian_Honorary = 45 + , Award_Celestia_SurvivedWallOfMist = 46 + , Award_47 = 47 + , Award_KilledXenofex = 48 + , Award_Tatalia_SolvedWineCellarMystery = 49 + , Award_Membership_ElementalGuilds = 50 + , Award_Membership_SelfGuilds = 51 + , Award_Membership_AirGuild = 52 + , Award_Membership_EarthGuild = 53 + , Award_Membership_FireGuild = 54 + , Award_Membership_WaterGuild = 55 + , Award_Membership_BodyGuild = 56 + , Award_Membership_MindGuild = 57 + , Award_Membership_SpiritGuild = 58 + , Award_Membership_LightGuild = 59 + , Award_Membership_DarkGuild = 60 + , Award_Avlee_RetrievedForestHeart = 61 + , Award_Promotion_Priest = 62 + , Award_Promotion_Priest_Honorary = 63 + , Award_Promotion_PriestOfLight = 64 + , Award_Promotion_PriestOfLight_Honorary = 65 + , Award_Promotion_PriestOfDark = 66 + , Award_Promotion_PriestOfDark_Honorary = 67 + , Award_Promotion_GreatDruid = 68 + , Award_Promotion_GreatDruid_Honorary = 69 + , Award_Promotion_ArchDruid = 70 + , Award_Promotion_ArchDruid_Honorary = 71 + , Award_Promotion_Warlock = 72 + , Award_Promotion_Warlock_Honorary = 73 + , Award_Promotion_Wizard = 74 + , Award_Promotion_Wizard_Honorary = 75 + , Award_Promotion_Archmage = 76 + , Award_Promotion_Archmage_Honorary = 77 + , Award_Promotion_Lich = 78 + , Award_Promotion_Lich_Honorary = 79 + , Award_ThePit_RetrievedSoulJars = 80 + , Award_Celestia_KilledTolberti = 81 + , Award_ThePit_ClearedKlankersLab = 82 + , Award_ThePit_KilledRobertTheWise = 83 + , Award_ThePit_SurvivedBreedingZone = 84 + , Award_Deaths = 85 + , Award_BountiesCollected = 86 + , Award_PrisonTerms = 87 + , Award_Arena_PageWins = 88 + , Award_Arena_SquireWins = 89 + , Award_Arena_KnightWins = 90 + , Award_Arena_LordWins = 91 + , Award_Harmondale_ReturnedLanterOfLight = 92 + , Award_Nighon_RetrievedHaldarsRemains = 93 + , Award_Harmondale_ReturnedDavriksSignetRing = 94 + , Award_Erathia_ReturnedParsonsQuill = 95 + , Award_RetrievedFaeriePipes = 96 + , Award_BarrowDowns_KilledTroglodytesInLowerCity = 97 + , Award_Deyja_KilledAllGriffins = 98 + , Award_Bracada_RetrievedSeasonsStole = 99 + , Award_Avlee_PlacedThreeStatuettes = 100 + , Award_101 = 101 + , Award_ArcomageChampion = 102 + , Award_ArcomageWins = 103 + , Award_ArcomageLoses = 104 + +}; +extern std::array achieved_awards; +extern int num_achieved_awards; +extern int full_num_items_in_book; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Conditions.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Conditions.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,70 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#pragma once +#include "Conditions.h" +#include "Party.h" +std::array conditionArray = +{ + // hint: condname, protfrommagic, gmprot, enchantment, ... + ConditionProcessor(Condition_Cursed, false, false, 0), + ConditionProcessor(Condition_Weak, true, false, 0), + ConditionProcessor(Condition_Sleep, false, false, 22, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR), + ConditionProcessor(Condition_Fear, false, false, 0), + ConditionProcessor(Condition_Drunk, false, false, 0), + ConditionProcessor(Condition_Insane, false, false, 19, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), + ConditionProcessor(Condition_Poison_Weak, true, false, 21, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), + ConditionProcessor(Condition_Disease_Weak, true, false, 18, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), + ConditionProcessor(Condition_Poison_Medium, true, false, 21, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), + ConditionProcessor(Condition_Disease_Medium, true, false, 18, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), + ConditionProcessor(Condition_Poison_Severe, true, false, 21, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), + ConditionProcessor(Condition_Disease_Severe, true, false, 18, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), + ConditionProcessor(Condition_Paralyzed, false, false, 20, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK, ITEM_ARTIFACT_GHOULSBANE, EQIUP_ANY), + ConditionProcessor(Condition_Unconcious,false, false, 0), + ConditionProcessor(Condition_Dead, true, true, 0), + ConditionProcessor(Condition_Pertified, true, false, 23, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK, ITEM_RELIC_KELEBRIM, EQIUP_ANY), + ConditionProcessor(Condition_Eradicated, true, true, 0), + ConditionProcessor(Condition_Zombie, false, false, 0) +}; + +bool ConditionProcessor::IsPlayerAffected( Player* inPlayer, int condToCheck, int blockable) +{ + if ( !blockable ) + return true; + ConditionProcessor* thisProc = &conditionArray[condToCheck]; + if (thisProc->m_IsBlockedByProtFromMagic && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0) + { + if (!(thisProc->m_DoesNeedGmProtFromMagic && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uSkill < 4)) + { + --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; + if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1 ) + pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); + return false; + } + } + if (thisProc->m_WorkingEnchantment != 0) + { + if (inPlayer->HasEnchantedItemEquipped(thisProc->m_WorkingEnchantment)) + return false; + } + for (unsigned int i = 0; i < thisProc->m_equipmentPairs.size() / 2; i++) + { + if (thisProc->m_equipmentPairs[i * 2].m_ItemId == (ITEM_TYPE)0) + return true; + ITEM_TYPE itemId = thisProc->m_equipmentPairs[i * 2].m_ItemId; + ITEM_EQUIP_TYPE slot = thisProc->m_equipmentPairs[i * 2 + 1].m_EquipSlot; + if (slot == EQIUP_ANY) + { + if (inPlayer->WearsItemAnyWhere(itemId)) + return false; + } + else + { + if (inPlayer->WearsItem(itemId, slot)) + return false; + } + } + return true; +} diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Conditions.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Conditions.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,73 @@ +#pragma once +#include "Engine/Objects/Items.h" +#include +enum Condition: unsigned __int32 +{ + Condition_Cursed = 0, + Condition_Weak = 1, + Condition_Sleep = 2, + Condition_Fear = 3, + Condition_Drunk = 4, + Condition_Insane = 5, + Condition_Poison_Weak = 6, + Condition_Disease_Weak = 7, + Condition_Poison_Medium = 8, + Condition_Disease_Medium = 9, + Condition_Poison_Severe = 10, + Condition_Disease_Severe = 11, + Condition_Paralyzed = 12, + Condition_Unconcious = 13, + Condition_Dead = 14, + Condition_Pertified = 15, + Condition_Eradicated = 16, + Condition_Zombie = 17, + Condition_Good = 18 +}; + + +class EquipemntPair +{ +public: + ITEM_TYPE m_ItemId; + ITEM_EQUIP_TYPE m_EquipSlot; + EquipemntPair(ITEM_TYPE type, ITEM_EQUIP_TYPE slot) + { + m_ItemId = type; + m_EquipSlot = slot; + } + EquipemntPair() + { + m_ItemId = (ITEM_TYPE)0; + m_EquipSlot = (ITEM_EQUIP_TYPE)0; + } +}; + +struct Player; + +class ConditionProcessor +{ +public: + bool m_IsBlockedByProtFromMagic; + bool m_DoesNeedGmProtFromMagic; + int m_WorkingEnchantment; + std::array m_equipmentPairs; + ConditionProcessor(int, bool isblocked, bool needsGm, int enchantment, + ITEM_TYPE itemtype1 = (ITEM_TYPE)0, ITEM_EQUIP_TYPE itemslot1 = (ITEM_EQUIP_TYPE)0, + ITEM_TYPE itemtype2 = (ITEM_TYPE)0, ITEM_EQUIP_TYPE itemslot2 = (ITEM_EQUIP_TYPE)0, + ITEM_TYPE itemtype3 = (ITEM_TYPE)0, ITEM_EQUIP_TYPE itemslot3 = (ITEM_EQUIP_TYPE)0) + { + m_IsBlockedByProtFromMagic = isblocked; + m_DoesNeedGmProtFromMagic = needsGm; + m_WorkingEnchantment = enchantment; + m_equipmentPairs[0].m_ItemId = itemtype1; + m_equipmentPairs[0].m_EquipSlot = itemslot1; + m_equipmentPairs[1].m_ItemId = itemtype2; + m_equipmentPairs[1].m_EquipSlot = itemslot2; + m_equipmentPairs[2].m_ItemId = itemtype3; + m_equipmentPairs[2].m_EquipSlot = itemslot3; + } + + static bool IsPlayerAffected(Player*, int, int); +}; + +extern std::array conditionArray; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/ErrorHandling.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/ErrorHandling.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,65 @@ +#define _CRT_NON_CONFORMING_SWPRINTFS +#pragma once + +#define Error(format, ...) Error_impl_(__FILE__, __FUNCTION__, __LINE__, format, __VA_ARGS__) +#define Assert(condition, ...) Assert_impl_(__FILE__, __FUNCTION__, __LINE__, condition, #condition, __VA_ARGS__) + + + +#include +#include +inline __declspec(noreturn) void Error_impl_(const char *filename, const char *functionname, int line, + const char *format, ...) +{ + va_list va; + va_start(va, format); + { + char header[4096]; + sprintf(header, "Error in %s: %u\n\t%s\n\n", filename, line, functionname); + + char msg_body[8192]; + vsprintf(msg_body, format, va); + + wchar_t msg[sizeof(header) + sizeof(msg_body)]; + swprintf(msg, 8192, L"%S %S", header, msg_body); + + extern void MsgBox(const wchar_t *, const wchar_t *); + MsgBox(msg, L"Error"); + } + va_end(va); + + #ifndef NODEBUG + __debugbreak(); + #endif + exit(0); +} + + +inline void Assert_impl_(const char *filename, const char *functionname, int line, + bool condition, const char *condition_string, const char *format = nullptr, ...) +{ + if (condition) + return; + + va_list va; + va_start(va, format); + { + char header[4096]; + sprintf(header, "Assertion in %s: %u\n\t%s:\n%s\n\n", filename, line, functionname, condition_string); + + char msg_body[8192]; + vsprintf(msg_body, format, va); + + wchar_t msg[sizeof(header) + sizeof(msg_body)]; + if (format) + swprintf(msg, (sizeof(header) + sizeof(msg_body)), L"%S %S", header, msg_body); + else + swprintf(msg, (sizeof(header) + sizeof(msg_body)), L"%S", header); + + extern void MsgBox(const wchar_t *, const wchar_t *); + MsgBox(msg, L"Assertion"); + } + va_end(va); + + __debugbreak(); +} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Events.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Events.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,1365 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS + +#include "ErrorHandling.h" + +#include "Engine/Graphics/Weather.h" +#include "Engine/Graphics/Texture.h" +#include "mm7_data.h" +#include "MediaPlayer.h" +#include "Mouse.h" + +#include "MapInfo.h" +#include "Game.h" +#include "Engine/Graphics/Render.h" +#include "GUIWindow.h" +#include "GUIProgressBar.h" +#include "Engine/Objects/SpriteObject.h" +#include "Engine/Objects/Chest.h" +#include "MapsLongTimer.h" +#include "LOD.h" +#include "Engine/Objects/Actor.h" +#include "Party.h" +#include "OurMath.h" +#include "AudioPlayer.h" +#include "Engine/Graphics/Indoor.h" +#include "Engine/Graphics/Viewport.h" +#include "texts.h" +#include "stru123.h" +#include "stru159.h" +#include "Events.h" +#include "Events2D.h" +#include "UI\UIHouses.h" +#include "MM7.h" +#include "Engine/Graphics/Level/Decoration.h" +#include "LuaVM.h" +#include "Log.h" +#include "Engine/Graphics/DecorationList.h" + + +std::array pSomeOtherEVT_Events; +signed int uSomeOtherEVT_NumEvents; +char *pSomeOtherEVT; +std::array pSomeEVT_Events; +signed int uSomeEVT_NumEvents; +char *pSomeEVT; + +unsigned int uGlobalEVT_NumEvents; +unsigned int uGlobalEVT_Size; +std::array pGlobalEVT; +std::array pGlobalEVT_Index; + +std::array pLevelStrOffsets; +unsigned int uLevelStrNumStrings; +unsigned int uLevelStrFileSize; +signed int uLevelEVT_NumEvents; +unsigned int uLevelEVT_Size; +std::array pLevelStr; +std::array pLevelEVT; +std::array pLevelEVT_Index; + +_2devent p2DEvents[525]; + + + +//----- (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 + + ptr = pEvents_LOD->LoadRaw(pContainerName, 0); + pLodFile = pEvents_LOD->FindContainer(pContainerName, 0); + if ( !pLodFile ) + Error("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 ) + Error("File %s Size %lu - Buffer size %lu", pContainerName, uTextureSize, uBufferSize); + + memcpy(pBuffer, ptr, uTextureSize); + free(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; + + current_hdr=(raw_event_header *)&pGlobalEVT[offset_in]; + } + uGlobalEVT_NumEvents = events_count; + + assert(uGlobalEVT_NumEvents < 4400); +} + + + +//----- (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; + + if (!uLevelEVT_Size) + return; + + memset(MapsLongTimersList, 0, 3200); + memset(pLevelEVT_Index.data(), 80, sizeof(EventIndex)*4400); + + uLevelEVT_NumEvents = 0; + MapsLongTimers_count = 0; + + current_hdr=(raw_event_header *)pLevelEVT.data(); + offset_in=0; + for (events_count = 0, offset_in = 0; offset_in < uLevelEVT_Size; ++events_count) + { + 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; + offset_in+=current_hdr->evt_size+1; + + current_hdr=(raw_event_header *)&pLevelEVT[offset_in]; + } + uLevelEVT_NumEvents = events_count; + +/* +EmeraldIsle::Variables: +[0] ??? +[1] ??? +[2] Luck Fountain uses left +[3] Gold Fountain used this week +[4] Gold Fountain total uses + + +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 + + + +Emerald Isle #111 // ??? + 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 + } + } + +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 + +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 #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 +*/ + } + + +//----- (0044684A) -------------------------------------------------------- +void EventProcessor(int uEventID, int targetObj, int canShowMessages, int entry_line) +{ + signed int v4; // esi@7 + int v11; // eax@14 + char *v12; // eax@15 + 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 + LevelDecoration *v26; // eax@55 + int v27; // eax@57 + int pEventID; // eax@58 + int pNPC_ID; // ecx@58 + int pIndex; // esi@58 + NPCData *pNPC; // ecx@58 + int v38; // eax@78 + int v39; // ecx@78 + int v42; // eax@84 + int v43; // ecx@84 + GUIButton *v48; // ecx@93 + GUIButton *v49; // esi@94 + signed int pValue; // ebp@124 + Player *pPlayer; // esi@125 + int v83; // eax@212 + int v84; // ebp@220 + int v90; // eax@243 + const char *v91; // ecx@247 + 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 + unsigned int v102; // esi@281 + int v104; // eax@288 + int v106; // [sp-20h] [bp-4C8h]@278 + signed int v109; // [sp-14h] [bp-4BCh]@278 + signed int v110; // [sp-10h] [bp-4B8h]@278 + int curr_seq_num; // [sp+10h] [bp-498h]@4 + 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 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 + + v133 = 0; + EvtTargetObj = targetObj; + dword_5B65C4_cancelEventProcessing = 0; + if ( uEventID == 114 )//for test script + { + if (!lua->DoFile("out01.lua")) + Log::Warning(L"Error opening out01.lua\n"); + Log::Warning(L"being tested that well\n"); + return; + } + 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); + } + + for ( v4 = 0; v4 < uSomeEVT_NumEvents; ++v4 ) + { + if ( dword_5B65C4_cancelEventProcessing ) + { + if ( v133 == 1 ) + OnMapLeave(); + return; + } + if ( pSomeEVT_Events[v4].uEventID == uEventID && pSomeEVT_Events[v4].event_sequence_num == curr_seq_num ) + { + _evt_raw * _evt = (_evt_raw *)(pSomeEVT + pSomeEVT_Events[v4].uEventOffsetInEVT); + + switch (_evt->_e_type) + { + case EVENT_CheckSeason: + if ( !sub_4465DF_check_season(_evt->v5) ) + { + ++curr_seq_num; + //v4 = v124; + break; + } + v4 = -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 (pMediaPlayer->bPlaying_Movie) + pMediaPlayer->Unload(); + pMediaPlayer->bStopBeforeSchedule = 0; +// pMediaPlayer->pResetflag = 0; + + v128 = pCurrentScreen; + strcpy(Str, Source); + v16 = RemoveQuotes(Str); + pMediaPlayer->FullscreenMovieLoop(v16, 0/*, _evt->v5*/); + if ( !_stricmp(v16, "arbiter good") ) + { + pParty->alignment = PartyAlignment_Good; + v18 = 0; + LOBYTE(v17) = 1; + SetUserInterface(PartyAlignment_Good, v17); + if ( !_evt->v6 || v128 == 3 ) + { + pCurrentScreen = v128; + if ( v128 == 3 ) + pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; + if ( v128 == 13 ) + pMediaPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); + } + ++curr_seq_num; + break; + } + if ( !_stricmp(v16, "arbiter evil") ) + { + v18 = 2; + pParty->alignment = PartyAlignment_Evil; + LOBYTE(v17) = 1; + SetUserInterface(PartyAlignment_Evil, v17); + if ( !_evt->v6 || v128 == 3 ) + { + pCurrentScreen = v128; + if ( v128 == 3 ) + pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; + if ( v128 == 13 ) + pMediaPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1); + } + ++curr_seq_num; + break; + } + if ( !_stricmp(v16, "pcout01") ) // moving to harmondale from emerald isle + { + Rest(0x2760u); + pParty->RestAndHeal(); + pParty->days_played_without_rest = 0; + } + if ( !_evt->v6 || v128 == 3 ) + { + pCurrentScreen = v128; + if ( v128 == 3 ) + pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; + if ( v128 == 13 ) + pMediaPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1); + } + ++curr_seq_num; + } + 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; + break; + } + } + curr_seq_num = _evt->v11 - 1; + ++curr_seq_num; + break; + } +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) ) + { + curr_seq_num = _evt->v11 - 1; + ++curr_seq_num; + break; + } + ++curr_seq_num; + } + 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; + break; + case EVENT_ChangeEvent: + if ( EVT_DWORD(_evt->v5) ) + stru_5E4C90_MapPersistVars._decor_events[activeLevelDecoration->_idx_in_stru123] = _evt->v5 - 124; + else + { + v26 = (LevelDecoration *)activeLevelDecoration; + stru_5E4C90_MapPersistVars._decor_events[activeLevelDecoration ->_idx_in_stru123] = 0; + v26->uFlags |= LEVEL_DECORATION_INVISIBLE; + } + ++curr_seq_num; + + 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; + break; + case EVENT_SetNPCTopic: + { + //v29 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); + pEventID = _evt->v10 + ((_evt->v11 + ((_evt->v12 + ((uint)_evt->v13 << 8)) << 8)) << 8); + pNPC_ID = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); + pIndex = _evt->v9; + pNPC = &pNPCStats->pNewNPCData[pNPC_ID]; + if ( pIndex == 0 ) + pNPC->evt_A = pEventID; + if ( pIndex == 1 ) + pNPC->evt_B = pEventID; + if ( pIndex == 2 ) + pNPC->evt_C = pEventID; + if ( pIndex == 3 ) + pNPC->evt_D = pEventID; + if ( pIndex == 4 ) + pNPC->evt_E = pEventID; + if ( pIndex == 5 ) + pNPC->evt_F = pEventID; + if ( pNPC_ID == 8 ) + { + if ( pEventID == 78 ) + { + HouseDialogPressCloseBtn(); + window_SpeakInHouse->Release(); + pParty->uFlags &= ~2; + if ( EnterHouse(HOUSE_DARK_GUILD_PIT) ) + { + pAudioPlayer->StopChannels(-1, -1); + window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 170, 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); + current_npc_text = pNPCTopics[90].pText; + } + } + } + ++curr_seq_num; + } + break; + case EVENT_NPCSetItem: + sub_448518_npc_set_item(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); + ++curr_seq_num; + break; + case EVENT_SetActorItem: + Actor::GiveItem(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); + ++curr_seq_num; + 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; + 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; + 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); + __debugbreak(); + for ( uint actor_id = 0; actor_id < uNumActors; actor_id++ ) + { + if ( pActors[actor_id].uGroup == v38 ) + pActors[actor_id].uGroup = v39; + } + ++curr_seq_num; + 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); + __debugbreak(); + for ( uint actor_id = 0; actor_id < uNumActors; actor_id++ ) + { + if ( pActors[actor_id].uGroup == v42 ) + pActors[actor_id].uAlly = v43; + } + ++curr_seq_num; + break; + case EVENT_MoveNPC: + { + pNPCStats->pNewNPCData[EVT_DWORD(_evt->v5)].Location2D =EVT_DWORD(_evt->v9); + if ( window_SpeakInHouse ) + { + + if ( window_SpeakInHouse->par1C == 165 ) + { + HouseDialogPressCloseBtn(); + pMediaPlayer->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, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 165, 0); + v48 = window_SpeakInHouse->pControlsHead; + if ( window_SpeakInHouse->pControlsHead ) + { + do + { + v49 = v48->pNext; + free(v48); + v48 = v49; + } + while ( v49 ); + } + window_SpeakInHouse->pControlsHead = 0; + window_SpeakInHouse->pControlsTail = 0; + window_SpeakInHouse->uNumControls = 0; + } + } + else + { + if ( window_SpeakInHouse->par1C == 553 ) + pMediaPlayer->bLoopPlaying = 0; + } + } + + } + ++curr_seq_num; + 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; + break; + case EVENT_CharacterAnimation: + if ( _evt->v5 <= 3 ) //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; + break; + case EVENT_ForPartyMember: + player_choose = _evt->v5; + ++curr_seq_num; + break; + case EVENT_SummonItem: + SpriteObject::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; + 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 + 1]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) + { + // v124 = -1; + curr_seq_num = _evt->v11 - 1; + } + } + ++curr_seq_num; + v4 = -1; + 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 = -1; + 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.data(); + for ( v65 = 0; v65 < 126; ++v65 ) + { + v67 = &pPlayers[uActiveCharacter]->pInventoryMatrix[v65]; + if ( v67 > 0 ) + { + if ( pPlayers[uActiveCharacter]->pInventoryItemList[v67 - 1].uItemID == pValue ) + { + pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v65); + //++curr_seq_num; + //v4 = v124; + goto substract; + } + } + //v67 += 4; + } + //while ( (signed int)v65 < 126 ); + //v69 = (int)&pPlayers[uActiveCharacter]->pEquipment.pIndices; + for ( v68 = 0; v68 < 16; ++v68 ) + { + if ( pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->pEquipment.pIndices[v68]].uItemID == pValue ) + { + pPlayers[uActiveCharacter]->pEquipment.pIndices[v68] = 0; + //++curr_seq_num; + //v4 = v124; + goto substract; + } + //v69 += 4; + } + for (int i = 1; i < 5; i++) + { + //v72 = (int)pPlayers[i]->pInventoryMatrix.data(); + for ( int v71 = 0; v71 < 126; ++v71 ) + { + v72 = &pPlayers[i]->pInventoryMatrix[v71]; + if ( v72 > 0 ) + { + if ( pPlayers[i]->pInventoryItemList[v72 - 1].uItemID == pValue ) + { + pPlayers[i]->RemoveItemAtInventoryIndex(v71); + goto substract; + } + } + //v72 += 4; + } + for ( v73 = 0; v73 < 16; ++v73 ) + { + //v74 = (int)&pPlayers[i]->pEquipment; + if (pPlayers[i]->pEquipment.pIndices[v73]) + { + if (pPlayers[i]->pInventoryItemList[pPlayers[i]->pEquipment.pIndices[v73] - 1].uItemID == pValue ) + { + pPlayers[i]->pEquipment.pIndices[v73] = 0; + //v74 += 4; + goto substract; + } + } + } + } + }*/ + if ( player_choose <= 3 ) + pParty->pPlayers[player_choose].SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + else if ( player_choose == 4 ) //active + { + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + else if ( player_choose == 5 )//all + { + for(int i = 1; i < 5; ++i) + pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + else if ( player_choose == 6 ) //random + pParty->pPlayers[rand() % 4].SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + ++curr_seq_num; + break; + case EVENT_Set: + pValue = EVT_DWORD(_evt->v7); + if ( player_choose <= 3 ) + pParty->pPlayers[player_choose].SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + else if ( player_choose == 4 ) //active + { + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->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); + } + else if ( player_choose == 6 ) //random + pParty->pPlayers[rand() % 4].SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + ++curr_seq_num; + 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 ) + pPlayers[uActiveCharacter]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + else if ( player_choose == 5 )//all + { + for(int i = 1; i < 5; ++i) + pPlayers[i]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); + } + else if ( player_choose == 6 ) //random + pParty->pPlayers[rand() % 4].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 ) + { + //__debugbreak(); // bonfire + viewparams->bRedrawGameUI = true; + } + ++curr_seq_num; + break; + case EVENT_InputString: + if ( !entry_line ) + { + strcpy(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[EVT_DWORD(_evt->v5 )]]); + sub_4451A8_press_any_key(uEventID, curr_seq_num, 26); + 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; + curr_seq_num = v11 - 1; + } + ++curr_seq_num; + v4 = -1; + 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 = -1; + break; + case EVENT_ReceiveDamage: + if ( (unsigned __int8)_evt->v5 <= 3 ) + { + pParty->pPlayers[(unsigned __int8)_evt->v5].ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); + ++curr_seq_num; + break; + } + if ( _evt->v5 == 4 ) + { + if ( !uActiveCharacter ) + { + ++curr_seq_num; + break; + } + pPlayers[uActiveCharacter]->ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); + ++curr_seq_num; + break; + } + if ( _evt->v5 != 5 ) + { + pParty->pPlayers[rand() % 4].ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); + ++curr_seq_num; + break; + } + for ( uint pl_id = 0;pl_id < 4; pl_id++ ) + pParty->pPlayers[pl_id].ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); + ++curr_seq_num; + break; + case EVENT_ToggleIndoorLight: + pIndoor->ToggleLight(EVT_DWORD(_evt->v5 ), _evt->v9); + ++curr_seq_num; + break; + case EVENT_SetFacesBit: + sub_44892E_set_faces_bit(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); + ++curr_seq_num; + break; + case EVENT_ToggleChestFlag: + Chest::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); + ++curr_seq_num; + break; + case EVENT_ToggleActorFlag: + Actor::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); + ++curr_seq_num; + break; + case EVENT_ToggleActorGroupFlag: + ToggleActorGroupFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); + ++curr_seq_num; + break; + case EVENT_SetSnow: + if ( !_evt->v5 ) + pWeather->bRenderSnow = _evt->v6 != 0; + ++curr_seq_num; + 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, 2); + } + } + else + { + if ( canShowMessages == 1 ) + { + v91 = &pLevelStr[pLevelStrOffsets[v90]]; + ShowStatusBarString(v91, 2); + } + } + ++curr_seq_num; + break; + case EVENT_ShowMessage: + if ( activeLevelDecoration ) + { + current_npc_text = pNPCTopics[EVT_DWORD(_evt->v5 )-1].pText;//(&dword_721664)[8 * v92]; + byte_5B0938[0] = 0; + } + else + strcpy(byte_5B0938.data(), &pLevelStr[pLevelStrOffsets[EVT_DWORD(_evt->v5 )]]); + ++curr_seq_num; + 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; + break; + case EVENT_SetTexture: + sub_44861E_set_texture(EVT_DWORD(_evt->v5 ), (char *)&_evt->v9); + ++curr_seq_num; + break; + case EVENT_SetSprite: + SetDecorationSprite(EVT_DWORD(_evt->v5 ), _evt->v9, (char *)&_evt->v10); + ++curr_seq_num; + 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; + break; + case EVENT_MouseOver: + case EVENT_LocationName: + --curr_seq_num; + ++curr_seq_num; + break; + case EVENT_ChangeDoorState: + Door_switch_animation(_evt->v5, _evt->v6); + ++curr_seq_num; + break; + case EVENT_OpenChest: + if ( !Chest::Open(_evt->v5) ) + { + if ( v133 == 1 ) + OnMapLeave(); + return; + } + ++curr_seq_num; + 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 ) + { + pRenderer->Sub01(); + TransitionUI_Load(_evt->v29, _evt->v30, v135, v132, v126, v129, v95, v134, (char *)&_evt->v31); + dword_5C3418 = uEventID; + dword_5C341C = curr_seq_num + 1; + if ( v133 == 1 ) + OnMapLeave(); + return; + } + _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; + 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; + pAudioPlayer->PlaySound((SoundID)v106, 0, 0, -1, 0, 0, 0, 0); + } + } + else + { + pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)((activeLevelDecoration == NULL) + 1); + Transition_StopSound_Autosave(v99, MapStartPoint_Party); + v133 = 1; + if ( pCurrentScreen == SCREEN_HOUSE ) + { + if ( uGameState == GAME_STATE_CHANGE_LOCATION ) + { + pAudioPlayer->StopChannels(-1, -1); + dialog_menu_id = HOUSE_DIALOGUE_NULL; + while ( HouseDialogPressCloseBtn() ) + ; + pMediaPlayer->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; + break; + case EVENT_PlaySound: + 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); + v106 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); + pAudioPlayer->PlaySound((SoundID)v106, 0, 0, v109, v110, 0, 0, 0); + ++curr_seq_num; + break; + case EVENT_GiveItem: + item.Reset(); + 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; + break; + case EVENT_SpeakInHouse: + if ( EnterHouse((enum HOUSE_ID)EVT_DWORD(_evt->v5))) + { + pRenderer->Sub01(); + 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, window->GetWidth(), window->GetHeight(), 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; + break; + case EVENT_PressAnyKey: + sub_4451A8_press_any_key(uEventID, curr_seq_num + 1, 33); + if ( v133 == 1 ) + OnMapLeave(); + return; + case EVENT_Exit: + if ( v133 == 1 ) + OnMapLeave(); + return; + default: + ++curr_seq_num; + break; + } + } + } + if ( v133 == 1 ) + OnMapLeave(); + return; + } + +//----- (00444732) -------------------------------------------------------- +char *GetEventHintString(unsigned int uEventID) +{ + signed int event_index; // edx@1 + int event_pos; // esi@4 + char *result; // eax@6 + unsigned int str_index; // eax@9 + int i; // esi@11 + _evt_raw* test_evt; + _evt_raw* last_evt; + + 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; + event_pos = pLevelEVT_Index[event_index+1].uEventOffsetInEVT; + if ( test_evt->_e_type == EVENT_MouseOver ) + break; + } + ++event_index; + if ( event_index >= uLevelEVT_NumEvents ) + return NULL; + } + test_evt=(_evt_raw*)&pLevelEVT[event_pos]; + if ( test_evt->_e_type== EVENT_SpeakInHouse ) + { + str_index = EVT_DWORD(test_evt->v5); + result = (char *)p2DEvents[str_index - 1].pName; + } + else + { + for ( i = event_index + 1; pLevelEVT_Index[i].uEventID == uEventID; ++i ) + { + event_pos = pLevelEVT_Index[i].uEventOffsetInEVT; + test_evt=(_evt_raw*)&pLevelEVT[event_pos]; + if ( test_evt->_e_type == EVENT_SpeakInHouse ) + { + str_index = EVT_DWORD(test_evt->v5); + if ( str_index < 600 ) + return (char *)p2DEvents[str_index - 1].pName; + } + } + result = &pLevelStr[pLevelStrOffsets[EVT_BYTE(last_evt->v5)]]; + } + + return result; +} + +//----- (004613C4) -------------------------------------------------------- +void init_event_triggers() +{ + uint id = pDecorationList->GetDecorIdByName("Event Trigger"); + + num_event_triggers = 0; + for (uint i = 0; i < uNumLevelDecorations; ++i) + if (pLevelDecorations[i].uDecorationDescID == id) + event_triggers[num_event_triggers++] = i; +} + +//----- (0046CC4B) -------------------------------------------------------- +void check_event_triggers() +{ + for (size_t i = 0; i < num_event_triggers; i++) + { + if (pLevelDecorations[event_triggers[i]].uFlags & LEVEL_DECORATION_TRIGGERED_BY_TOUCH + && pLevelDecorations[event_triggers[i]].vPosition.GetDistanceTo(pParty->vPosition) < pLevelDecorations[event_triggers[i]].uTriggerRange) + { + EventProcessor(pLevelDecorations[event_triggers[i]].uEventID, PID(OBJECT_Decoration, i), 1); + } + else if (pLevelDecorations[event_triggers[i]].uFlags & LEVEL_DECORATION_TRIGGERED_BY_MONSTER) + { + for (size_t j = 0; j < uNumActors; j++) + { + if (pLevelDecorations[event_triggers[i]].vPosition.GetDistanceTo(pActors[j].vPosition) < pLevelDecorations[event_triggers[i]].uTriggerRange) + EventProcessor(pLevelDecorations[event_triggers[i]].uEventID, 0, 1); + } + } + else if (pLevelDecorations[event_triggers[i]].uFlags & LEVEL_DECORATION_TRIGGERED_BY_OBJECT) + { + for (size_t j = 0; j < uNumSpriteObjects; j++) + { + if (pLevelDecorations[event_triggers[i]].vPosition.GetDistanceTo(pSpriteObjects[j].vPosition) < pLevelDecorations[event_triggers[i]].uTriggerRange) + EventProcessor(pLevelDecorations[event_triggers[i]].uEventID, 0, 1); + } + } + } +} +// 6836C8: using guessed type int 6836C8_num_decorations_6807E8; + +//----- (004465DF) -------------------------------------------------------- +bool sub_4465DF_check_season(int a1) +{ + unsigned int monthPlusOne; // eax@1 + unsigned int daysPlusOne; // edx@1 + + monthPlusOne = pParty->uCurrentMonth + 1; + daysPlusOne = pParty->uDaysPlayed + 1; + + switch (a1) + { + case 3: //winter 12.21 -> 3.20 + return (monthPlusOne == 12 && daysPlusOne >= 21 || monthPlusOne == 1 || monthPlusOne == 2 || monthPlusOne == 3 && daysPlusOne <= 20); + break; + case 2:// autumn/fall 9.21 -> 12.20 + return (monthPlusOne == 9 && daysPlusOne >= 21 || monthPlusOne == 10 || monthPlusOne == 11 || monthPlusOne == 12 && daysPlusOne <= 20); + break; + case 1://summer 6.21 -> 9.20 + return (monthPlusOne == 6 && daysPlusOne >= 21 || monthPlusOne == 7 || monthPlusOne == 8 || monthPlusOne == 9 && daysPlusOne <= 20); + break; + case 0: //spring 3.21 -> 6.20 + return (monthPlusOne == 3 && daysPlusOne >= 21 || monthPlusOne == 4 || monthPlusOne == 5 || monthPlusOne == 6 && daysPlusOne <= 20); + break; + } + Error("Unknown season"); + return false; +} + +//----- (00448CF4) -------------------------------------------------------- +void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName) +{ + unsigned int map_id; // eax@1 + size_t old_num_actors; // ebx@2 + AIDirection v15; // [sp+28h] [bp-34h]@2 + SpawnPointMM7 pSpawnPoint; // [sp+44h] [bp-18h]@1 + + pSpawnPoint.vPosition.x = x; + pSpawnPoint.vPosition.y = y; + pSpawnPoint.vPosition.z = z; + pSpawnPoint.uGroup = group; + pSpawnPoint.uRadius = 32; + pSpawnPoint.uKind = 3; + pSpawnPoint.uIndex = typeindex + 2 * level + level; + map_id = pMapStats->GetMapInfo(pCurrentMapName); + if (map_id) + { + old_num_actors = uNumActors; + SpawnEncounter(&pMapStats->pInfos[map_id], &pSpawnPoint, 0, count, 0); + Actor::GetDirectionInfo(PID(OBJECT_Actor, old_num_actors), 4, &v15, 1); + for (uint i = (unsigned int)old_num_actors; i < (unsigned int)uNumActors; ++i) + { + pActors[i].PrepareSprites(0); + pActors[i].uYawAngle = v15.uYawAngle; + pActors[i].dword_000334_unique_name = uUniqueName; + } + } +} diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Events.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Events.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,352 @@ +#pragma once +#include + + + +/* 167 */ +#pragma pack(push, 1) +struct EventIndex +{ + int uEventID; + int event_sequence_num; + unsigned int uEventOffsetInEVT; +}; +#pragma pack(pop) + +// raw event struct +// header +// size_event 1 header+data +// event id 2 3 +// event_sequence_num +// event data +#pragma pack(push, 1) +struct _evt_raw +{ + unsigned char _e_size; + unsigned char v1; + unsigned char v2; + unsigned char v3; + + unsigned char _e_type; + unsigned char v5; + unsigned char v6; + unsigned char v7; + unsigned char v8; + unsigned char v9; + unsigned char v10; + unsigned char v11; + unsigned char v12; + unsigned char v13; + unsigned char v14; + unsigned char v15; + unsigned char v16; + unsigned char v17; + unsigned char v18; + unsigned char v19; + unsigned char v20; + unsigned char v21; + unsigned char v22; + unsigned char v23; + unsigned char v24; + unsigned char v25; + unsigned char v26; + unsigned char v27; + unsigned char v28; + unsigned char v29; + unsigned char v30; + unsigned char v31; + unsigned char v32; + unsigned char tail[128]; +}; +#pragma pack(pop) + + + +/* 310 */ +enum EventType +{ + EVENT_Exit = 0x1, + EVENT_SpeakInHouse = 0x2, + EVENT_PlaySound = 0x3, + EVENT_MouseOver = 0x4, + EVENT_LocationName = 0x5, + EVENT_MoveToMap = 0x6, + EVENT_OpenChest = 0x7, + EVENT_ShowFace = 0x8, + EVENT_ReceiveDamage = 0x9, + EVENT_SetSnow = 0xA, + EVENT_SetTexture = 0xB, + EVENT_ShowMovie = 0xC, + EVENT_SetSprite = 0xD, + EVENT_Compare = 0xE, + EVENT_ChangeDoorState = 0xF, + EVENT_Add = 0x10, + EVENT_Substract = 0x11, + EVENT_Set = 0x12, + EVENT_SummonMonsters = 0x13, + EVENT_CastSpell = 0x15, + EVENT_SpeakNPC = 0x16, + EVENT_SetFacesBit = 0x17, + EVENT_ToggleActorFlag = 0x18, + EVENT_RandomGoTo = 0x19, + EVENT_InputString = 0x1A, + EVENT_StatusText = 0x1D, + EVENT_ShowMessage = 0x1E, + EVENT_OnTimer = 0x1F, + EVENT_ToggleIndoorLight = 0x20, + EVENT_PressAnyKey = 0x21, + EVENT_SummonItem = 0x22, + EVENT_ForPartyMember = 0x23, + EVENT_Jmp = 0x24, + EVENT_OnMapReload = 0x25, + EVENT_Initialize = 0x26, + EVENT_SetNPCTopic = 0x27, + EVENT_MoveNPC = 0x28, + EVENT_GiveItem = 0x29, + EVENT_ChangeEvent = 0x2A, + EVENT_CheckSkill = 0x2B, + EVENT_OnCanShowDialogItemCmp = 44, + EVENT_EndCanShowDialogItem = 45, + EVENT_SetCanShowDialogItem = 46, + EVENT_SetNPCGroupNews = 0x2F, + EVENT_SetActorGroup = 0x30, + EVENT_NPCSetItem = 0x31, + EVENT_SetNPCGreeting = 0x32, + EVENT_IsActorAlive = 0x33, + EVENT_IsActorAssasinated =52, + EVENT_OnMapLeave = 0x35, + EVENT_ChangeGroup = 0x36, + EVENT_ChangeGroupAlly = 0x37, + EVENT_CheckSeason = 0x38, + EVENT_ToggleActorGroupFlag = 0x39, + EVENT_ToggleChestFlag = 0x3A, + EVENT_CharacterAnimation = 0x3B, + EVENT_SetActorItem = 0x3C, + EVENT_OnDateTimer = 0x3D, + EVENT_EnableDateTimer = 0x3E, + EVENT_StopAnimation = 0x3F, + EVENT_CheckItemsCount = 0x40, + EVENT_RemoveItems = 0x41, + EVENT_SpecialJump = 0x42, + EVENT_IsTotalBountyHuntingAwardInRange = 0x43, + EVENT_IsNPCInParty = 0x44, +}; + +/* 311 */ +enum VariableType +{ + VAR_Sex = 0x1, + VAR_Class = 0x2, + VAR_CurrentHP = 0x3, + VAR_MaxHP = 0x4, + VAR_CurrentSP = 0x5, + VAR_MaxSP = 0x6, + VAR_ActualAC = 0x7, + VAR_ACModifier = 0x8, + VAR_BaseLevel = 0x9, + VAR_LevelModifier = 0xA, + VAR_Age = 0xB, + VAR_Award = 0xC, + VAR_Experience = 0xD, + VAR_Race = 0xE, + VAR_QBits_QuestsDone = 0x10, + VAR_PlayerItemInHands = 0x11, + VAR_Hour = 0x12, + VAR_DayOfYear = 0x13, + VAR_DayOfWeek = 0x14, + VAR_FixedGold = 0x15, + VAR_RandomGold = 0x16, + VAR_FixedFood = 0x17, + VAR_RandomFood = 0x18, + VAR_MightBonus = 0x19, + VAR_IntellectBonus = 0x1A, + VAR_PersonalityBonus = 0x1B, + VAR_EnduranceBonus = 0x1C, + VAR_SpeedBonus = 0x1D, + VAR_AccuracyBonus = 0x1E, + VAR_LuckBonus = 0x1F, + VAR_BaseMight = 0x20, + VAR_BaseIntellect = 0x21, + VAR_BasePersonality = 0x22, + VAR_BaseEndurance = 0x23, + VAR_BaseSpeed = 0x24, + VAR_BaseAccuracy = 0x25, + VAR_BaseLuck = 0x26, + VAR_ActualMight = 0x27, + VAR_ActualIntellect = 0x28, + VAR_ActualPersonality = 0x29, + VAR_ActualEndurance = 0x2A, + VAR_ActualSpeed = 0x2B, + VAR_ActualAccuracy = 0x2C, + VAR_ActualLuck = 0x2D, + VAR_FireResistance = 0x2E, + VAR_AirResistance = 0x2F, + VAR_WaterResistance = 0x30, + VAR_EarthResistance = 0x31, + VAR_SpiritResistance = 0x32, + VAR_MindResistance = 0x33, + VAR_BodyResistance = 0x34, + VAR_LightResistance = 0x35, + VAR_DarkResistance = 0x36, + VAR_PhysicalResistance = 0x37, + VAR_MagicResistance = 0x38, + VAR_FireResistanceBonus = 0x39, + VAR_AirResistanceBonus = 0x3A, + VAR_WaterResistanceBonus = 0x3B, + VAR_EarthResistanceBonus = 0x3C, + VAR_SpiritResistanceBonus = 0x3D, + VAR_MindResistanceBonus = 0x3E, + VAR_BodyResistanceBonus = 0x3F, + VAR_LightResistanceBonus = 0x40, + VAR_DarkResistanceBonus = 0x41, + VAR_PhysicalResistanceBonus = 0x42, + VAR_MagicResistanceBonus = 0x43, + VAR_StaffSkill = 0x44, + VAR_SwordSkill = 0x45, + VAR_DaggerSkill = 0x46, + VAR_AxeSkill = 0x47, + VAR_SpearSkill = 0x48, + VAR_BowSkill = 0x49, + VAR_MaceSkill = 0x4A, + VAR_BlasterSkill = 0x4B, + VAR_ShieldSkill = 0x4C, + VAR_LeatherSkill = 0x4D, + VAR_SkillChain = 0x4E, + VAR_PlateSkill = 0x4F, + VAR_FireSkill = 0x50, + VAR_AirSkill = 0x51, + VAR_WaterSkill = 0x52, + VAR_EarthSkill = 0x53, + VAR_SpiritSkill = 0x54, + VAR_MindSkill = 0x55, + VAR_BodySkill = 0x56, + VAR_LightSkill = 0x57, + VAR_DarkSkill = 0x58, + VAR_IdentifyItemSkill = 0x59, + VAR_MerchantSkill = 0x5A, + VAR_RepairSkill = 0x5B, + VAR_BodybuildingSkill = 0x5C, + VAR_MeditationSkill = 0x5D, + VAR_PerceptionSkill = 0x5E, + VAR_DiplomacySkill = 0x5F, + VAR_ThieverySkill = 0x60, + VAR_DisarmTrapSkill = 0x61, + VAR_DodgeSkill = 0x62, + VAR_UnarmedSkill = 0x63, + VAR_IdentifyMonsterSkill = 0x64, + VAR_ArmsmasterSkill = 0x65, + VAR_StealingSkill = 0x66, + VAR_AlchemySkill = 0x67, + VAR_LearningSkill = 0x68, + VAR_Cursed = 0x69, + VAR_Weak = 0x6A, + VAR_Asleep = 0x6B, + VAR_Afraid = 0x6C, + VAR_Drunk = 0x6D, + VAR_Insane = 0x6E, + VAR_PoisonedGreen = 0x6F, + VAR_DiseasedGreen = 0x70, + VAR_PoisonedYellow = 0x71, + VAR_DiseasedYellow = 0x72, + VAR_PoisonedRed = 0x73, + VAR_DiseasedRed = 0x74, + VAR_Paralyzed = 0x75, + VAR_Unconsious = 0x76, + VAR_Dead = 0x77, + VAR_Stoned = 0x78, + VAR_Eradicated = 0x79, + VAR_MajorCondition = 0x7A, + VAR_MapPersistentVariable_0 = 123, + VAR_MapPersistentVariable_74 = 0xC5, + VAR_MapPersistentVariable_75 = 0xC6, + VAR_MapPersistentVariable_99 = 0xDE, + VAR_AutoNotes = 0xDF, + VAR_IsMightMoreThanBase = 0xE0, + VAR_IsIntellectMoreThanBase = 0xE1, + VAR_IsPersonalityMoreThanBase = 0xE2, + VAR_IsEnduranceMoreThanBase = 0xE3, + VAR_IsSpeedMoreThanBase = 0xE4, + VAR_IsAccuracyMoreThanBase = 0xE5, + VAR_IsLuckMoreThanBase = 0xE6, + VAR_PlayerBits = 0xE7, + VAR_NPCs2 = 0xE8, + VAR_IsFlying = 0xF0, + VAR_HiredNPCHasSpeciality = 0xF1, + VAR_CircusPrises = 0xF2, + VAR_NumSkillPoints = 0xF3, + VAR_MonthIs = 0xF4, + VAR_Counter1 = 0xF5, + VAR_Counter2 = 0xF6, + VAR_Counter3 = 0xF7, + VAR_Counter4 = 0xF8, + VAR_Counter5 = 0xF9, + VAR_Counter6 = 0xFa, + VAR_Counter7 = 0xFB, + VAR_Counter8 = 0xFC, + VAR_Counter9 = 0xFD, + VAR_Counter10 = 0xFE, + VAR_UnknownTimeEvent0 = 0xFF, + VAR_UnknownTimeEvent19 = 0x112, + VAR_ReputationInCurrentLocation = 0x113, + VAR_History_0 = 0x114, + VAR_History_28 = 0x130, + VAR_Unknown1 = 0x131, + VAR_GoldInBank = 0x132, + VAR_NumDeaths = 0x133, + VAR_NumBounties = 0x134, + VAR_PrisonTerms = 0x135, + VAR_ArenaWinsPage = 0x136, + VAR_ArenaWinsSquire = 0x137, + VAR_ArenaWinsKnight = 0x138, + VAR_ArenaWinsLord = 0x139, + VAR_Invisible = 0x13A, + VAR_ItemEquipped = 0x13B, +}; + +#define EVT_WORD(x) *(unsigned __int16*)&x +#define EVT_DWORD(x) *(unsigned int*)&x +#define EVT_STRING(x) (unsigned char*)&x +#define EVT_BYTE(x) (unsigned char)x + +extern std::array pSomeOtherEVT_Events; +extern signed int uSomeOtherEVT_NumEvents; +extern char *pSomeOtherEVT; +extern std::array pSomeEVT_Events; +extern signed int uSomeEVT_NumEvents; +extern char *pSomeEVT; + +extern unsigned int uGlobalEVT_NumEvents; +extern unsigned int uGlobalEVT_Size; +extern std::array pGlobalEVT; +extern std::array pGlobalEVT_Index; + +extern std::array pLevelStrOffsets; +extern unsigned int uLevelStrNumStrings; +extern unsigned int uLevelStrFileSize; +extern signed int uLevelEVT_NumEvents; +extern unsigned int uLevelEVT_Size; +extern std::array pLevelStr; +extern std::array pLevelEVT; +extern std::array pLevelEVT_Index; + + +unsigned int LoadEventsToBuffer(const char *pContainerName, char *pBuffer, unsigned int uBufferSize); +void Initialize_GlobalEVT(); +void LoadLevel_InitializeLevelEvt(); +void EventProcessor(int uEventID, int a2, int a3, int entry_line = 0); +char *GetEventHintString(unsigned int uEventID); // idb + + + +/* 312 */ +#pragma pack(push, 1) +struct ByteArray +{ + char f[65535]; +}; +#pragma pack(pop) + +void init_event_triggers(); +void check_event_triggers(); +bool sub_4465DF_check_season(int a1); +void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName); diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Events2D.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Events2D.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,66 @@ +#pragma once + +/* 296 */ +enum BuildingType: unsigned short +{ + BuildingType_WeaponShop = 1, + BuildingType_ArmorShop = 2, + BuildingType_MagicShop = 3, + BuildingType_AlchemistShop = 4, + BuildingType_FireGuild = 5, + BuildingType_AirGuild = 6, + BuildingType_WaterGuild = 7, + BuildingType_EarthGuild = 8, + BuildingType_SpiritGuild = 9, + BuildingType_MindGuild = 10, + BuildingType_BodyGuild = 11, + BuildingType_LightGuild = 12, + BuildingType_DarkGuild = 13, + BuildingType_ElementalGuild = 14, + BuildingType_SelfGuild = 15, + BuildingType_16 = 16, + BuildingType_TownHall = 17, + BuildingType_18 = 18, + BuildingType_19 = 19, + BuildingType_Throne_Room = 20, + BuildingType_Tavern = 21, + BuildingType_Bank = 22, + BuildingType_Temple = 23, + BuildingType_24 = 24, + BuildingType_Unic = 25, + BuildingType_1A = 26, + BuildingType_Stables = 27, + BuildingType_Boats = 28, + BuildingType_House = 29, + BuildingType_Training = 30, + BuildingType_Jail = 31 +}; + +/* 168 */ +#pragma pack(push, 1) +struct _2devent +{ + BuildingType uType; + unsigned __int16 uAnimationID; + char *pName; + const char *pProprieterName; + const char *pEnterText; + const char *pProprieterTitle; + __int16 field_14; + __int16 _state; + __int16 _rep; + __int16 _per; + __int16 field_1C; + __int16 field_1E; + float fPriceMultiplier; + float flt_24; + unsigned __int16 uOpenTime; + unsigned __int16 uCloseTime; + __int16 uExitPicID; + __int16 uExitMapID; + __int16 _quest_related; + __int16 field_32; +}; +#pragma pack(pop) + +extern _2devent p2DEvents[525]; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Game.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Game.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,7496 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include "Arcomage\Arcomage.h" + +#include "Engine/Graphics/Vis.h" +#include "Engine/Graphics/Weather.h" +#include "Engine/Graphics/LightmapBuilder.h" +#include "Engine/Graphics/DecalBuilder.h" +#include "Engine/Graphics/ParticleEngine.h" +#include "Mouse.h" +#include "Keyboard.h" +#include "Engine/Graphics/GammaControl.h" +#include "stru6.h" +#include "Engine/Graphics/stru9.h" +#include "Engine/Graphics/stru10.h" +#include "Engine/ErrorHandling.h" + +#include "Game.h" +#include "Party.h" +#include "Engine/Graphics/Viewport.h" +#include "Timer.h" +#include "Engine/Graphics/Outdoor.h" +#include "Engine/Graphics/Overlays.h" +#include "AudioPlayer.h" +#include "LOD.h" +#include "GUIWindow.h" +#include "Engine/TurnEngine/TurnEngine.h" +#include "Bink_Smacker.h" +#include "Engine/Events.h" +#include "texts.h" +#include "GUIFont.h" +#include "Log.h" +#include "Engine/Graphics/Lights.h" +#include "Engine/Spells/CastSpellInfo.h" +#include "Engine/Tables/FrameTableInc.h" +#include "Engine/Objects/Actor.h" +#include "GUIProgressBar.h" +#include "Engine/Objects/ObjectList.h" +#include "Engine/Graphics/Level/Decoration.h" +#include "Engine/Graphics/PaletteManager.h" +#include "UI\UIHouses.h" +#include "UI\UIShops.h" +#include "UI\UIPartyCreation.h" +#include "SaveLoad.h" +#include "Engine/Objects/SpriteObject.h" +#include "mm7.h" +#include "Engine/Graphics/Sprites.h" +#include "Registry.h" +#include "Engine/Objects/Chest.h" + +#include "UI\UIGame.h" + +#include "Engine/Graphics/DecorationList.h" +#include "Engine/Tables/IconFrameTable.h" +#include "Engine/Tables/PlayerFrameTable.h" +#include "MapsLongTimer.h" +#include "Engine/Tables/StorylineTextTable.h" +#include "Engine/Tables/FactionTable.h" +#include "stru123.h" +#include "LuaVM.h" +#include "Engine/Graphics/RenderD3D11.h" +#include "MMT.h" +#include "NewUI\MainMenu.h" +#include + + + + + +Game *pGame; + + + + + +//----- (00435694) -------------------------------------------------------- +void Game::ToggleFlags2(unsigned int uFlag) +{ + unsigned int v2; // eax@1 + + v2 = this->uFlags2; + if ( v2 & uFlag ) + this->uFlags2 = v2 & ~uFlag; + else + this->uFlags2 = uFlag | v2; +} + +//----- (0044103C) -------------------------------------------------------- +void Game::Draw() +{ + int v4; // edi@26 + + uFlags2 &= ~0x02; + if ( pParty->_497FC5_check_party_perception_against_level() ) + uFlags2 |= 2; + + pGame->pIndoorCameraD3D->sRotationX = pParty->sRotationX; + pGame->pIndoorCameraD3D->sRotationY = pParty->sRotationY; + pGame->pIndoorCameraD3D->vPartyPos.x = pParty->vPosition.x - pParty->y_rotation_granularity * cosf(2 * 3.141592653589 * pParty->sRotationY / 2048.0); + pGame->pIndoorCameraD3D->vPartyPos.y = pParty->vPosition.y - pParty->y_rotation_granularity * sinf(2 * 3.141592653589 * pParty->sRotationY / 2048.0); + pGame->pIndoorCameraD3D->vPartyPos.z = pParty->vPosition.z + pParty->sEyelevel;//193, but real 353 + + //pIndoorCamera->Initialize2(); + pIndoorCameraD3D->CalculateRotations(pParty->sRotationX, pParty->sRotationY); + pIndoorCameraD3D->CreateWorldMatrixAndSomeStuff(); + pIndoorCameraD3D->_4374E8_ProllyBuildFrustrum(); + + if ( pMovie_Track ) + { + /*if ( !pRenderer->pRenderD3D ) + { + pRenderer->BeginSceneD3D(); + pMouse->DrawCursorToTarget(); + pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); + }*/ + } + else + { + if ( pParty->vPosition.x != pParty->vPrevPosition.x || pParty->sRotationY != pParty->sPrevRotationY || pParty->vPosition.y != pParty->vPrevPosition.y + || pParty->sRotationX != pParty->sPrevRotationX || pParty->vPosition.z != pParty->vPrevPosition.z || pParty->sEyelevel != pParty->sPrevEyelevel ) + pParty->uFlags |= 2u; + pParty->vPrevPosition.x = pParty->vPosition.x; + pParty->vPrevPosition.y = pParty->vPosition.y; + pParty->vPrevPosition.z = pParty->vPosition.z; + //v0 = &pRenderer; + pParty->sPrevRotationY = pParty->sRotationY; + pParty->sPrevRotationX = pParty->sRotationX; + + pParty->sPrevEyelevel = pParty->sEyelevel; + pRenderer->BeginSceneD3D(); + + //if ( !pRenderer->pRenderD3D ) + //pMouse->DrawCursorToTarget(); + if ( !PauseGameDrawing() || viewparams->field_48 == 1 ) + { + //if ( pRenderer->pRenderD3D ) + { + float v2 = (double)(((signed int)pMiscTimer->uTotalGameTimeElapsed >> 2) & 0x1F) * 0.032258064 * 6.0; + //v3 = v2 + 6.7553994e15; + //pRenderer->field_1036A8_bitmapid = LODWORD(v3); + pRenderer->hd_water_current_frame = floorf(v2 + 0.5f); + } + + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + pIndoor->Draw(); + else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) + pOutdoor->Draw(); + else + Error("Invalid level type: %u", uCurrentlyLoadedLevelType); + + //if (pRenderer->pRenderD3D) + { + pDecalBuilder->DrawBloodsplats(); + pGame->pLightmapBuilder->DrawLightmapsType(2); + } + } + pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); + } + + //DEBUG: force redraw gui + viewparams->bRedrawGameUI = true; + + + pRenderer->BeginScene(); + //if (pRenderer->pRenderD3D) + pMouse->DrawCursorToTarget(); + if (pOtherOverlayList->bRedraw) + viewparams->bRedrawGameUI = true; + v4 = viewparams->bRedrawGameUI; + GameUI_Footer(); + if (!viewparams->bRedrawGameUI) + GameUI_DrawRightPanelItems(); + else + { + GameUI_DrawRightPanelFrames(); + GameUI_Footer_2(); + viewparams->bRedrawGameUI = false; + } + if (!pMovie_Track)//!pVideoPlayer->pSmackerMovie) + { + GameUI_DrawMinimap(488, 16, 625, 133, viewparams->uMinimapZoom, true);//redraw = pParty->uFlags & 2); + if (v4) + { + if ( !PauseGameDrawing() /*&& pRenderer->pRenderD3D*/) // clear game viewport with transparent color + pRenderer->FillRectFast(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pViewport->uViewportBR_X - pViewport->uViewportTL_X, + pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1, + 0x7FF); + viewparams->field_48 = 0; + } + } + + viewparams->bRedrawGameUI = pOtherOverlayList->bRedraw; + pOtherOverlayList->bRedraw = 0; + + GameUI_DrawPartySpells(); + if (v4 || pParty->pHirelings[0].evt_C || pParty->pHirelings[1].evt_C ) + GameUI_DrawHiredNPCs(); + GameUI_DrawPortraits(v4); + GameUI_DrawLifeManaBars(); + GameUI_DrawCharacterSelectionFrame(); + if ( _44100D_should_alter_right_panel() ) + GameUI_DrawRightPanel(); + if ( !pMovie_Track ) + { + pStru6Instance->DrawPlayerBuffAnims(); + pOtherOverlayList->DrawTurnBasedIcon(v4); + GameUI_DrawTorchlightAndWizardEye(); + } + + + static bool render_framerate = false; + static float framerate = 0.0f; + static uint frames_this_second = 0; + static uint last_frame_time = GetTickCount(); + static uint framerate_time_elapsed = 0; + + if ( pCurrentScreen == SCREEN_GAME && uCurrentlyLoadedLevelType == LEVEL_Outdoor) + pWeather->Draw();//Ritor1: my include + + //while(GetTickCount() - last_frame_time < 33 );//FPS control + uint frame_dt = GetTickCount() - last_frame_time; + last_frame_time = GetTickCount(); + + framerate_time_elapsed += frame_dt; + if (framerate_time_elapsed >= 1000) + { + framerate = frames_this_second * (1000.0f / framerate_time_elapsed); + + framerate_time_elapsed = 0; + frames_this_second = 0; + render_framerate = true; + } + + ++frames_this_second; + + if ( debug_information ) + { + if (render_framerate) + { + sprintf(pTmpBuf.data(), "FPS: % .4f", framerate); + pPrimaryWindow->DrawText(pFontArrus, 494, 0, Color16(0, 0, 0), pTmpBuf.data(), 0, 0, 0); + } + + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + int 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, Color16(255, 255, 255), pTmpBuf.data(), 0, 0, -1); + } + sprintf(pTmpBuf.data(), "Party Position: % d % d % d", pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); + pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, Color16(255, 255, 255), pTmpBuf.data(), 0, 0, -1); + + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + uint uFaceID; + int sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); + int 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; + int 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, Color16(255, 255, 255), pTmpBuf.data(), 0, 0, -1); + } + + GUI_UpdateWindows(); + pParty->UpdatePlayersAndHirelingsEmotions(); + + _unused_5B5924_is_travel_ui_drawn = false; + if (v4) + pMouse->bRedraw = true; + pMouse->ReadCursorWithItem(); + pMouse->DrawCursor(); + pMouse->Activate(); + pRenderer->EndScene(); + pRenderer->Present(); + pParty->uFlags &= ~2; +} + +//----- (0047A815) -------------------------------------------------------- +void Game::DrawParticles() +{ + pParticleEngine->Draw(); +} + +//----- (00463149) -------------------------------------------------------- +void Game::Loop() +{ + const char *pLocationName; // [sp-4h] [bp-68h]@74 + bool bLoading; // [sp+10h] [bp-54h]@1 + signed int v16; // [sp+14h] [bp-50h]@8 + MSG Msg; // [sp+28h] [bp-3Ch]@20 + char Source[64]; // [sp+44h] [bp-20h]@76 + + bLoading = sCurrentMenuID == MENU_LoadingProcInMainMenu; + SetCurrentMenuID((MENU_STATE)-1); + if (bLoading) + { + pParty->Reset(); + uGameState = GAME_STATE_PLAYING; + LoadGame(uLoadGameUI_SelectedSlot); + } + + for (uint i = 1; i < 5; ++i) + for (uint j = 1; j < 6; ++j) + { + sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j); + remove(pTmpBuf.data()); + } + + LoadPlayerPortraintsAndVoices(); + pIcons_LOD->_inlined_sub1(); + pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); + + while ( 2 ) + { + v16 = 1; + pMessageQueue_50CBD0->Flush(); + + pPartyActionQueue->uNumActions = 0; + if (pParty->bTurnBasedModeOn) + { + pTurnEngine->End(false); + pParty->bTurnBasedModeOn = false; + } + DoPrepareWorld(bLoading, 1); + pEventTimer->Resume(); + dword_6BE364_game_settings_1 |= GAME_SETTINGS_0080_SKIP_USER_INPUT_THIS_FRAME; + // uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0; + pCurrentScreen = SCREEN_GAME; + + //if ( pRenderer->pRenderD3D ) + pGame->pVisInstance->_4C1A02(); + + bool game_finished = false; + do + { + while ( PeekMessageA(&Msg, 0, 0, 0, PM_REMOVE) ) + { + if ( Msg.message == WM_QUIT ) + Game_DeinitializeAndTerminate(0); + TranslateMessage(&Msg); + DispatchMessageA(&Msg); + } + if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE) + { + WaitMessage(); + continue; + } + pGame->_44EEA7(); + GameUI_WritePointedObjectStatusString(); + Keyboard::ProcessInputActions(); + GameUI_MsgProc(); + if ( pArcomageGame->bGameInProgress ) + { + ArcomageGame::Loop(); + pRenderer->Present(); + continue; + } + + pMediaPlayer->HouseMovieLoop(); + + pEventTimer->Update(); + pMiscTimer->Update(); + + OnTimer(0); + GameUI_StatusBar_UpdateTimedString(0); + if ( pMiscTimer->bPaused && !pEventTimer->bPaused ) + pMiscTimer->Resume(); + if ( pEventTimer->bTackGameTime && !pParty->bTurnBasedModeOn ) + pEventTimer->bTackGameTime = 0; + if ( !pEventTimer->bPaused && uGameState == GAME_STATE_PLAYING) + { + if ( !pEventTimer->bTackGameTime ) + _494035_timed_effects__water_walking_damage__etc(); + + if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0001) + dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0001; + else + { + Actor::UpdateActorAI(); + UpdateUserInput_and_MapSpecificStuff(); + } + } + if ( v16 ) + { + v16 = 0; + viewparams->bRedrawGameUI = true; + } + pAudioPlayer->UpdateSounds(); + if ( (signed int)uGameState == GAME_STATE_PLAYING ) + { + pGame->Draw(); + continue; + } + if (uGameState == GAME_FINISHED) + { + game_finished = true; + continue; + } + if (uGameState == GAME_STATE_CHANGE_LOCATION)// ñìåíà ëîêàöèè + { + pAudioPlayer->StopChannels(-1, -1); + PrepareWorld(0); + uGameState = GAME_STATE_PLAYING; + continue; + } + if ( (signed int)uGameState <= GAME_STATE_5 || uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU )//GAME_STATE_NEWGAME_OUT_GAMEMENU, GAME_STATE_LOADING_GAME + { + game_finished = true; + continue; + } + if ( uGameState == GAME_STATE_FINAL_WINDOW ) + { + pRenderer->BeginScene(); + GUI_UpdateWindows(); + pRenderer->EndScene(); + pRenderer->Present(); + continue; + } + if ( uGameState != GAME_STATE_PARTY_DIED ) + { + pGame->Draw(); + continue; + } + if ( uGameState == GAME_STATE_PARTY_DIED ) + { + pAudioPlayer->StopChannels(-1, -1); + memset(&pParty->pHirelings[0], 0, 0x4Cu); + memset(&pParty->pHirelings[1], 0, 0x4Cu); + for ( int i = 0; i < (signed int)pNPCStats->uNumNewNPCs; ++i ) + { + if ( pNPCStats->pNewNPCData[i].field_24 ) + pNPCStats->pNewNPCData[i].uFlags &= 0xFFFFFF7Fu; + } + pMediaPlayer->bStopBeforeSchedule = 0; + pMediaPlayer->PlayFullscreenMovie(MOVIE_Death, true); + if ( pMovie_Track ) + pMediaPlayer->Unload(); + SaveGame(0, 0); + ++pParty->uNumDeaths; + for ( uint i = 0; i < 4; ++i ) + pParty->pPlayers[i].SetVariable(VAR_Award, 85); + pParty->days_played_without_rest = 0; + pParty->uTimePlayed += 0x276000ui64; + LOWORD(pParty->uFlags) &= ~0x204; + pParty->SetGold(0); + pOtherOverlayList->Reset(); + memset(pParty->pPartyBuffs.data(), 0, 0x140u); + + if ( pParty->bTurnBasedModeOn == 1 ) + { + pTurnEngine->End(true); + pParty->bTurnBasedModeOn = 0; + } + for( int i = 0; i < 4; ++i) + { + memset(pParty->pPlayers[i].pConditions.data(), 0, 0xA0u);//(pConditions, 0, 160) + memset(pParty->pPlayers[i].pPlayerBuffs.data(), 0, 0x180u);//(pPlayerBuffs[0], 0, 384) + pParty->pPlayers[i].sHealth = 1; + uActiveCharacter = 1; + } + if (_449B57_test_bit(pParty->_quest_bits, PARTY_QUEST_FINISHED_EMERALD_ISLE)) + { + pParty->vPosition.x = -17331; // respawn in harmondale + pParty->vPosition.y = 12547; + pParty->vPosition.z = 465; + pParty->sRotationY = 0; + pLocationName = "out02.odm"; + } + else + { + pParty->vPosition.x = 12552; // respawn on emerald isle + pParty->vPosition.y = 1816; + pParty->vPosition.z = 0; + pParty->sRotationY = 512; + pLocationName = "out01.odm"; + } + strcpy(Source, pLocationName); + pParty->uFallStartY = pParty->vPosition.z; + pParty->sRotationX = 0; + pParty->uFallSpeed = 0; + pParty->field_6E4 = 0; + pParty->field_6E0 = 0; + if ( _stricmp(Source, pCurrentMapName) ) + { + strcpy(pCurrentMapName, Source); + _5B65A8_npcdata_uflags_or_other = pParty->vPosition.x; + _5B65AC_npcdata_fame_or_other = pParty->vPosition.y; + _5B65B0_npcdata_rep_or_other = pParty->vPosition.z; + _5B65B4_npcdata_loword_house_or_other = pParty->sRotationY; + _5B65B8_npcdata_hiword_house_or_other = pParty->sRotationX; + dword_5B65C0 = 1; + PrepareWorld(1); + } + Actor::InitializeActors(); + + int num_conscious_players = 0; + int conscious_players_ids[4] = {-1, -1, -1, -1}; + for (int i = 0; i < 4; ++i) + { + if (pParty->pPlayers[i].CanAct()) + conscious_players_ids[num_conscious_players++] = i; + } + if (num_conscious_players) + { + int idx = conscious_players_ids[rand() % num_conscious_players]; + Assert(idx >= 0); + pParty->pPlayers[idx].PlaySound(SPEECH_99, 0); + } + + ShowStatusBarString(pGlobalTXT_LocalizationStrings[524], 2);// "Once again you've cheated death!.." "Âû ñíîâà îáõèòðèëè ñìåðòü! …" + uGameState = GAME_STATE_PLAYING; + } + } + while (!game_finished); + + pEventTimer->Pause(); + ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); + if ( uGameState == GAME_STATE_LOADING_GAME ) + { + sub_491E3A(); + LoadPlayerPortraintsAndVoices(); + uGameState = GAME_STATE_PLAYING; + pIcons_LOD->dword_11B84 = pIcons_LOD->uNumLoadedFiles; + bLoading = true; + continue; + } + break; + } + pCurrentScreen = SCREEN_VIDEO; + sub_491E3A(); +} + + +//----- (0044F192) -------------------------------------------------------- +void Game::PrepareBloodsplats() +{ + for (uint i = 0; i < uNumBloodsplats; ++i) + { + pBloodsplatContainer->AddBloodsplat(pBloodsplats[i].x, pBloodsplats[i].y, pBloodsplats[i].z, + pBloodsplats[i].radius, pBloodsplats[i].r, pBloodsplats[i].g, pBloodsplats[i].b); + } +} + + +//----- (0044F120) -------------------------------------------------------- +void Game::PushStationaryLights(int a2) +{ + Game__StationaryLight* pLight; + + for( int i=0; iAddLight(pLight->vPosition.x, pLight->vPosition.y, pLight->vPosition.z, + pLight->flt_18, pLight->vRGBColor.x, pLight->vRGBColor.y, pLight->vRGBColor.z, _4E94D0_light_type); + } +} +// 4E94D0: using guessed type char _4E94D0_light_type; + +//----- (0044F0FD) -------------------------------------------------------- +void Game::_44F0FD() +{ + ToggleFlags(0x40u); + + if ( !(uFlags & 0x40) ) + { + uNumBloodsplats = 0; + field_E0C = 0; + } +} + +//----- (0044F0D8) -------------------------------------------------------- +void Game::ToggleFlags(uint uMask) +{ + if (uFlags & uMask) + uFlags &= ~uMask; + else + uFlags |= uMask; +} + + +//----- (0044F07B) -------------------------------------------------------- +bool Game::_44F07B() +{ + if (!pKeyboardInstance->IsKeyBeingHeld(VK_SHIFT) && !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) && + !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) || (pKeyboardInstance->WasKeyPressed(VK_F11) == 0 && + pKeyboardInstance->WasKeyPressed(VK_F11))) + return true; + return false; +} + +//----- (0044EEA7) -------------------------------------------------------- +bool Game::_44EEA7() +{ + //Game *v1; // esi@1 + //double v2; // st7@2 + float depth; // ST00_4@9 + //bool result; // eax@9 + //unsigned int v5; // eax@14 + __int64 v6; // kr00_8@21 + //unsigned int y; // [sp+4h] [bp-24h]@2 + //unsigned int x; // [sp+8h] [bp-20h]@2 + Vis_SelectionFilter *v10; // [sp+10h] [bp-18h]@2 + Vis_SelectionFilter *v11; // [sp+14h] [bp-14h]@2 + POINT cursor; // [sp+20h] [bp-8h]@1 + + //v1 = this; + ++qword_5C6DF0; + pParticleEngine->UpdateParticles(); + pMouseInstance->GetCursorPos(&cursor); + + //x = cursor.y; + //y = cursor.x; + if ( sub_4637E0_is_there_popup_onscreen() ) + { + v11 = &vis_face_filter; + v10 = &vis_sprite_filter_2; + depth = pGame->pIndoorCameraD3D->GetPickDepth(); + } + else + { + if ( uFlags2 & GAME_FLAGS_2_TARGETING_MODE ) + { + v11 = &vis_face_filter; + v10 = &vis_sprite_filter_1; + } + else + { + v11 = &vis_face_filter; + v10 = &vis_sprite_filter_4; + } + depth = 5120.0; + } + //depth = v2; + + PickMouse(depth, cursor.x, cursor.y, false, v10, v11); + pLightmapBuilder->std__vector_000004_size = 0; + pLightmapBuilder->std__vector_183808_size = 0; + pDecalBuilder->std__vector_pDecals_size = 0; + pDecalBuilder->field_308008 = 0; + if (!_44F07B()) + return false; + + if ( uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) + pStru10Instance->bDoNotDrawPortalFrustum = false; + if ( /*pRenderer->pRenderD3D &&*/ uCurrentlyLoadedLevelType == LEVEL_Outdoor) + pRenderer->uFogColor = GetLevelFogColor() & 0xFFFFFF; + if (uFlags & 0x0400) + uFlags2 |= 0x01; + /*if ( !pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor && pMobileLightsStack->uNumLightsActive ) + { + uFlags2 |= 0x01; + field_E10 = qword_5C6DF0; + }*/ + v6 = qword_5C6DF0 - field_E10; + if ( qword_5C6DF0 - field_E10 == 1 ) + uFlags2 |= v6; + if (uNumStationaryLights_in_pStationaryLightsStack != pStationaryLightsStack->uNumLightsActive ) + { + uFlags2 |= 1; + uNumStationaryLights_in_pStationaryLightsStack = pStationaryLightsStack->uNumLightsActive; + } + _44E904(); + return true; +} + + +//----- (0044EDE4) -------------------------------------------------------- +bool Game::AlterGamma_BLV(BLVFace *pFace, signed int *pColor) +{ + if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS && + pFace->uAttributes & FACE_CAN_SATURATE_COLOR) + { + *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0); + return true; + } + else + return false; +} + +//----- (0044EE30) -------------------------------------------------------- +bool Game::AlterGamma_ODM(ODMFace *pFace, signed int *pColor) +{ + if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS && + pFace->uAttributes & FACE_CAN_SATURATE_COLOR) + { + *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0); + return true; + } + else + return false; +} + + +//----- (004645FA) -------------------------------------------------------- +void Game::Deinitialize() +{ + WriteWindowsRegistryInt("startinwindow", 1);//pRenderer->bWindowMode); + //if (pRenderer->bWindowMode) + { + WriteWindowsRegistryInt("window X", window->GetX()); + WriteWindowsRegistryInt("window Y", window->GetY()); + } + WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun); + pItemsTable->Release(); + pNPCStats->Release(); + + if (pMouse) + pMouse->Deactivate(); + + delete pRenderer; + pAudioPlayer->Release();//error + pNew_LOD->FreeSubIndexAndIO(); + pGames_LOD->FreeSubIndexAndIO(); + ClipCursor(0); + Game::Destroy(); + delete pEventTimer; +} + +//----- (0044EE7C) -------------------------------------------------------- +bool Game::draw_debug_outlines() +{ + if (uFlags & 0x04) + { + pLightmapBuilder->DrawDebugOutlines(-1); + pDecalBuilder->DrawDecalDebugOutlines(); + } + return true; +} + +//----- (0044EC23) -------------------------------------------------------- +int Game::_44EC23(struct Polygon *a2, int *a3, signed int a4) +{ + double v4; // st7@4 + //double v5; // ST00_8@4 + signed int v6; // eax@5 + //double v7; // ST00_8@6 + signed int result; // eax@8 + //double v9; // ST00_8@9 + //double v10; // ST00_8@11 + float a2a; // [sp+14h] [bp+8h]@4 + float a3a; // [sp+18h] [bp+Ch]@4 + float a3b; // [sp+18h] [bp+Ch]@6 + float a4a; // [sp+1Ch] [bp+10h]@9 + float a4b; // [sp+1Ch] [bp+10h]@11 + + if ( this->uFlags2 & 2 && a2->field_59 == 5 && a2->pODMFace->uAttributes & 2 ) + { + v4 = (double)a4; + a2a = v4; + *a3 |= 2u; + a3a = (1.0 - this->fSaturation) * v4; + //v5 = a3a + 6.7553994e15; + //if ( SLODWORD(v5) >= 0 ) + if (floorf(a3a + 0.5f) >= 0 ) + { + a3b = (1.0 - this->fSaturation) * a2a; + //v7 = a3b + 6.7553994e15; + //v6 = LODWORD(v7); + v6 = floorf(a3b + 0.5f); + } + else + v6 = 0; + if ( a4 >= v6 ) + { + a4a = (1.0 - fSaturation) * a2a; + //v9 = a4a + 6.7553994e15; + //if ( SLODWORD(v9) >= 0 ) + if (floorf(a4a + 0.5f) >= 0) + { + a4b = (1.0 - fSaturation) * a2a; + //v10 = a4b + 6.7553994e15; + //result = LODWORD(v10); + result = floorf(a4b + 0.5f); + } + else + result = 0; + } + else + result = a4; + } + else + result = -1; + return result; +} + + + +//----- (00465C8B) -------------------------------------------------------- +Game *Game::Create() +{ + return new Game; +} + +//----- (00465CF3) -------------------------------------------------------- +void Game::Destroy() +{ + delete pGame; + pGame = nullptr; +} + +//----- (0044ED0A) -------------------------------------------------------- +signed int Game::_44ED0A(BLVFace *a2, int *a3, signed int a4) +{ + double v4; // st7@3 + //double v5; // ST00_8@3 + signed int v6; // eax@4 + //double v7; // ST00_8@5 + signed int result; // eax@7 + //double v9; // ST00_8@8 + //double v10; // ST00_8@10 + float v11; // [sp+14h] [bp+8h]@3 + float v12; // [sp+18h] [bp+Ch]@3 + float v13; // [sp+18h] [bp+Ch]@5 + float v14; // [sp+1Ch] [bp+10h]@8 + float v15; // [sp+1Ch] [bp+10h]@10 + + if ( this->uFlags2 & 2 && a2->uAttributes & 2 ) + { + v4 = (double)a4; + v11 = v4; + *a3 |= 2u; + v12 = (1.0 - this->fSaturation) * v4; + //v5 = v12 + 6.7553994e15; + if (floorf(v12 + 0.5f)/* SLODWORD(v5)*/ >= 0 ) + { + v13 = (1.0 - this->fSaturation) * v11; + //v7 = v13 + 6.7553994e15; + //v6 = LODWORD(v7); + v6 = floorf(v13 + 0.5f); + } + else + v6 = 0; + if ( a4 >= v6 ) + { + v14 = (1.0 - fSaturation) * v11; + //v9 = v14 + 6.7553994e15; + if (floorf(v14 + 0.5f)/* SLODWORD(v9)*/ >= 0 ) + { + v15 = (1.0 - fSaturation) * v11; + //v10 = v15 + 6.7553994e15; + //result = LODWORD(v10); + result = floorf(v15 + 0.5f); + } + else + result = 0; + } + else + result = a4; + } + else + result = -1; + return result; +} + + +//----- (0044E4B7) -------------------------------------------------------- +Game::Game() +{ + uNumStationaryLights = 0; + uNumBloodsplats = 0; + field_E0C = 0; + field_E10 = 0; + uNumStationaryLights_in_pStationaryLightsStack = 0; + bGammaControlInitialized = false; + uFlags = 0; + uFlags2 = 0; + uSomeGammaStartTime = 0; + uSomeGammaDeltaTime = 0; + + //pThreadWardInstance = new ThreadWard; + pThreadWardInstance = nullptr; + pParticleEngine = new ParticleEngine; + pMouse = pMouseInstance = new Mouse; + pLightmapBuilder = new LightmapBuilder; + pVisInstance = new Vis; + pStru6Instance = new stru6; + pIndoorCameraD3D = new IndoorCameraD3D; + pStru9Instance = new stru9; + pStru10Instance = new stru10; + //pStru11Instance = new stru11; + pStru11Instance = nullptr; + //pStru12Instance = new stru12(pStru11Instance); + pStru12Instance = nullptr; + //pCShow = new CShow; + pCShow = nullptr; + pKeyboardInstance = new Keyboard; + pGammaController = new GammaController; + + uFlags |= 0x0800; + uFlags2 |= 0x24; + + _44F0FD(); +} + +//----- (0044E7F3) -------------------------------------------------------- +Game::~Game() +{ + delete pGammaController; + delete pKeyboardInstance; +/*delete pCShow; + delete pStru12Instance; + delete pStru11Instance;*/ + delete pStru10Instance; + delete pStru9Instance; + delete pIndoorCameraD3D; + delete pStru6Instance; + delete pVisInstance; + delete pLightmapBuilder; + delete pMouseInstance; + delete pParticleEngine; +//delete pThreadWardInstance; +} + +//----- (0044E904) -------------------------------------------------------- +void Game::_44E904() +{ + //Game *v1; // esi@1 + unsigned __int64 v2; // qax@1 + unsigned int v3; // ecx@1 + int v4; // edi@1 + unsigned __int8 v5; // cf@7 + double v6; // st7@13 + double v7; // st7@15 + signed __int64 v8; // [sp+Ch] [bp-8h]@1 + + //v1 = this; + v2 = pEventTimer->Time(); + v4 = (v2 - uSomeGammaStartTime) >> 32; + v3 = v2 - LODWORD(uSomeGammaStartTime); + v8 = v2 - uSomeGammaStartTime; + if ( v4 < 0 + || SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(uSomeGammaStartTime)) + HIDWORD(uSomeGammaStartTime) | v4 == 0 + && v3 <= 0x80 ) + { + if ( v4 < 0 ) + { + v3 = 0; + v4 = 0; + uSomeGammaStartTime = v2; + v8 = __PAIR__(v4, v3); + } + } + else + { + if ( uSomeGammaDeltaTime ) + { + LODWORD(uSomeGammaDeltaTime) = 0; + HIDWORD(uSomeGammaDeltaTime) = 0; + } + else + { + LODWORD(uSomeGammaDeltaTime) = v3; + HIDWORD(uSomeGammaDeltaTime) = v4; + } + v5 = __CFADD__(v3, -128); + v3 -= 128; + v4 = v5 + v4 - 1; + uSomeGammaStartTime = v2; + v8 = __PAIR__(v4, v3); + } + if ( uSomeGammaDeltaTime ) + v6 = (double)(signed __int64)(uSomeGammaDeltaTime - __PAIR__(v4, v3)); + else + v6 = (double)v8; + v7 = v6 * 0.0078125; + if ( v7 < 0.0 || v7 <= 1.0 ) + { + if ( v7 < 0.0 ) + v7 = 0.0; + } + else + v7 = 1.0; + //if ( pRenderer->pRenderD3D ) + fSaturation = v7; + //else + // fSaturation = (1.0 - 0.5) * v7 + 0.5; +} + +//----- (0044EA17) -------------------------------------------------------- +bool Game::InitializeGammaController() +{ + //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || + //pVersion->pVersionInfo.dwMajorVersion != 4 ) + pGammaController->InitializeFromSurface(pRenderer->pFrontBuffer4); + + bGammaControlInitialized = true; + uSomeGammaStartTime = pEventTimer->Time(); + return true; +} + +//----- (0044EA5E) -------------------------------------------------------- +bool Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) +{ + /*if (pCurrentScreen != SCREEN_GAME|| !pRenderer->pRenderD3D) + return false;*/ + + if (!pVisInstance) + { + MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0); + return false; + } + + if (uMouseX >= (signed int)pViewport->uScreen_TL_X && + uMouseX <= (signed int)pViewport->uScreen_BR_X && + uMouseY >= (signed int)pViewport->uScreen_TL_Y && + uMouseY <= (signed int)pViewport->uScreen_BR_Y) + { + pVisInstance->PickMouse(fPickDepth, uMouseX, uMouseY, sprite_filter, face_filter); + + if (bOutline) + OutlineSelection(); + } + + return true; +} +// 4E28F8: using guessed type int pCurrentScreen; + +//----- (0044EB12) -------------------------------------------------------- +bool Game::PickKeyboard(bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) +{ + if (pCurrentScreen == SCREEN_GAME && pVisInstance /*&& pRenderer->pRenderD3D*/) + { + bool r = pVisInstance->PickKeyboard(&pVisInstance->default_list, sprite_filter, face_filter); + + if (bOutline) + OutlineSelection(); + return r; + } + return false; +} +/* +Result::Code Game::PickKeyboard(bool bOutline, struct unnamed_F93E6C *a3, struct unnamed_F93E6C *a4) +{ + if (dword_4E28F8_PartyCantJumpIfTrue) + return Result::Generic; + + pVis->PickKeyboard(a3, a4); + if (bOutline) + Game_outline_selection((int)this); + return Result::Success; +} +*/ +// 4E28F8: using guessed type int pCurrentScreen; + +//----- (0044EB5A) -------------------------------------------------------- +void Game::OutlineSelection() +{ + if (!pVisInstance) + return; + + if (!pVisInstance->default_list.uNumPointers) + return; + + Vis_ObjectInfo* object_info = pVisInstance->default_list.object_pointers[0]; + if (object_info) + switch (object_info->object_type) + { + case VisObjectType_Sprite: + { + Log::Warning(L"Sprite outline currently unsupported"); + return; + } + + case VisObjectType_Face: + { + if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + ODMFace* face = (ODMFace *)object_info->object; + if (face->uAttributes & FACE_OUTLINED) + face->uAttributes &= ~FACE_OUTLINED; + else + face->uAttributes |= FACE_OUTLINED; + } + else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + BLVFace* face = (BLVFace *)object_info->object; + if (face->uAttributes & FACE_OUTLINED) + face->uAttributes &= ~FACE_OUTLINED; + else + face->uAttributes |= FACE_OUTLINED; + } + else + Error("Invalid level type", uCurrentlyLoadedLevelType); + } + break; + + default: + { + MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0); + ExitProcess(0); + } + } +} +//----- (004304E7) -------------------------------------------------------- +void GameUI_MsgProc() +{ + unsigned int v2; // edx@7 + Actor *pActor; // ecx@13 + int v4; // ecx@18 + unsigned int v10; // ecx@73 + int v14; // eax@98 + int v18; // eax@106 + float v19; // ST64_4@121 + float v21; // ST64_4@126 + float v22; // ST64_4@127 + unsigned int v24; // ecx@149 + GUIWindow *pWindow2; // ecx@248 + bool pKeyBindingFlag; // eax@269 + unsigned int v33; // eax@277 + int v37; // eax@341 + int v38; // eax@358 + SHORT v39; // ax@365 + char *v41; // eax@380 + int v42; // eax@396 + signed int v44; // eax@398 + int v45; // edx@398 + signed int v46; // ecx@398 + char v47; // zf@399 + char v48; // zf@405 + BLVFace *pBLVFace; // ecx@410 + ODMFace *pODMFace; // ecx@412 + CastSpellInfo *pSpellInfo; // ecx@415 + __int16 v53; // ax@431 + int v54; // eax@432 + int v55; // ecx@432 + int v56; // edx@432 + int v57; // eax@432 + Player *pPlayer; // edx@442 + unsigned int pMapNum; // eax@445 + signed int v60; // ST64_4@459 + __int16 v63; // dx@479 + unsigned int v64; // eax@486 + int v65; // ecx@486 + int v66; // eax@488 + char *v67; // eax@489 + __int16 v68; // dx@498 + char *v69; // eax@512 + int v70; // eax@525 + int v71; // edi@527 + NPCData *pNPCData3; // esi@527 + char *v73; // ecx@533 + signed int v74; // edi@535 + int v75; // eax@535 + int v76; // esi@535 + int v77; // eax@537 + Player *pPlayer2; // ecx@549 + signed int v81; // eax@552 + signed int v83; // ecx@554 + signed int v84; // ecx@554 + GUIButton *pButton; // eax@578 + unsigned int v86; // eax@583 + const char *v87; // ecx@595 + const char *v88; // ecx@596 + unsigned int v90; // eax@602 + int v91; // edx@605 + int v92; // eax@605 + int v93; // edx@605 + int pPlayerNum; // edx@611 + int v95; // eax@611 + unsigned int v97; // eax@624 + int v98; // eax@636 + int v103; // eax@671 + Player *pPlayer4; // ecx@718 + int v105; // eax@718 + Player *pPlayer5; // ST78_4@758 + unsigned int v107; // eax@758 + unsigned int v108; // eax@758 + unsigned int v115; // eax@764 + int v116; // eax@776 + unsigned int v118; // eax@785 + unsigned int v119; // ecx@786 + unsigned int v121; // [sp-28h] [bp-624h]@711 + unsigned int v123; // [sp-24h] [bp-620h]@711 + unsigned int v125; // [sp-20h] [bp-61Ch]@711 + int v127; // [sp-1Ch] [bp-618h]@107 + unsigned int v128; // [sp-1Ch] [bp-618h]@711 + GUIButton *pButton2; // [sp-4h] [bp-600h]@59 + const char *v161; // [sp-4h] [bp-600h]@637 + KeyToggleType pKeyToggleType; // [sp+0h] [bp-5FCh]@287 + char *v173; // [sp+0h] [bp-5FCh]@444 + char *v174; // [sp+0h] [bp-5FCh]@449 + const char *v177; // [sp+0h] [bp-5FCh]@629 + char *v178; // [sp+0h] [bp-5FCh]@637 + signed int thisb; // [sp+14h] [bp-5E8h]@272 + Player *pPlayer7; // [sp+14h] [bp-5E8h]@373 + Player *pPlayer8; // [sp+14h] [bp-5E8h]@377 + char *pMapName; // [sp+14h] [bp-5E8h]@445 + Player *pPlayer9; // [sp+14h] [bp-5E8h]@455 + int thisg; // [sp+14h] [bp-5E8h]@467 + int thish; // [sp+14h] [bp-5E8h]@528 + signed int thisi; // [sp+14h] [bp-5E8h]@535 + MapInfo *pMapInfo; // [sp+14h] [bp-5E8h]@604 + Player *pPlayer10; // [sp+14h] [bp-5E8h]@641 + int uMessageParam; // [sp+18h] [bp-5E4h]@7 + int uAction; // [sp+1Ch] [bp-5E0h]@18 + NPCData *pNPCData4; // [sp+20h] [bp-5DCh]@23 + unsigned int uNumSeconds; // [sp+24h] [bp-5D8h]@18 + char v197; // [sp+2Bh] [bp-5D1h]@101 + enum UIMessageType uMessage; // [sp+2Ch] [bp-5D0h]@7 + unsigned int v199; // [sp+30h] [bp-5CCh]@7 + char *v200; // [sp+34h] [bp-5C8h]@518 + POINT v202; // [sp+40h] [bp-5BCh]@141 + POINT a2; // [sp+48h] [bp-5B4h]@127 + POINT v205; // [sp+58h] [bp-5A4h]@171 + POINT v207; // [sp+68h] [bp-594h]@155 + POINT v211; // [sp+88h] [bp-574h]@704 + int v213; // [sp+98h] [bp-564h]@385 + char pLevelName[32]; // [sp+9Ch] [bp-560h]@380 + char pOut[32]; // [sp+BCh] [bp-540h]@370 + FrameTableTxtLine v216; // [sp+DCh] [bp-520h]@524 + int v217[9]; // [sp+158h] [bp-4A4h]@652 + FrameTableTxtLine v218; // [sp+17Ch] [bp-480h]@524 + char a1[64]; // [sp+1F8h] [bp-404h]@467 + char Str2[128]; // [sp+238h] [bp-3C4h]@527 + Actor actor; // [sp+2B8h] [bp-344h]@4 + int currHour; + + dword_50CDC8 = 0; + if ( !pEventTimer->bPaused ) + { + pParty->sEyelevel = pParty->uDefaultEyelevel; + pParty->uPartyHeight = pParty->uDefaultPartyHeight; + } + if ( bDialogueUI_InitializeActor_NPC_ID ) + { + //Actor::Actor(&actor); + memset(&actor, 0, 0x344u); + dword_5B65D0_dialogue_actor_npc_id = bDialogueUI_InitializeActor_NPC_ID; + actor.sNPC_ID = bDialogueUI_InitializeActor_NPC_ID; + GameUI_InitializeDialogue(&actor, false); + bDialogueUI_InitializeActor_NPC_ID = 0; + } + if ( pMessageQueue_50CBD0->uNumMessages ) + { + //v1 = ""; + while ( 2 ) + { + if ( !pMessageQueue_50CBD0->uNumMessages ) + break; + + pMessageQueue_50CBD0->PopMessage(&uMessage, &uMessageParam, (int *)&v199); + switch ( uMessage ) + { + case UIMSG_ChangeGameState: + uGameState = GAME_FINISHED; + continue; + case UIMSG_PlayArcomage: + BackToHouseMenu(); + pArcomageGame->bGameInProgress = 1; + ArcomageGame::PrepareArcomage(); + continue; + case UIMSG_StartNPCDialogue: + if ( !uActiveCharacter ) + continue; + viewparams->field_48 = 1; + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + dword_5B65D0_dialogue_actor_npc_id = pActors[uMessageParam].sNPC_ID; + pActor = &pActors[uMessageParam]; + //goto _actor_init_dlg; + GameUI_InitializeDialogue(pActor, true); + continue; + case UIMSG_StartHireling1Dialogue: + case UIMSG_StartHireling2Dialogue: + { + if (bNoNPCHiring || pCurrentScreen) + continue; + + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + uAction = 0; + int hireling_idx = uMessage - UIMSG_StartHireling1Dialogue; + v4 = 0; + + for (uint i = 0; i < 2; ++i) + //pNPCData0 = pParty->pHirelings; + //do + { + if (pParty->pHirelings[i].pName) + //{ + //v6 = uAction++; + pTmpBuf[uAction++] = i; + //} + //++pNPCData0; + //++v4; + } + //while ( (signed int)pNPCData0 < (signed int)&pParty->pPickedItem ); + + //_this = 0; + for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i) + { + NPCData* npc = &pNPCStats->pNewNPCData[i]; + //do + //{ + if (npc->Hired() && + (!pParty->pHirelings[0].pName || strcmp(npc->pName, pParty->pHirelings[0].pName)) && + (!pParty->pHirelings[1].pName || strcmp(npc->pName, pParty->pHirelings[1].pName)) ) + { + //v7 =; + pTmpBuf[uAction++] = i + 2; + } + //++_this; + //++pNPCData4; + //} + //while ( _this < (signed int)pNPCStats->uNumNewNPCs ); + } + + if ( (signed int)(hireling_idx + pParty->hirelingScrollPosition) < uAction ) + { + //Actor::Actor(&actor); + memset(&actor, 0, 0x344u); + actor.sNPC_ID += -1 - pParty->hirelingScrollPosition - hireling_idx; + pActor = &actor; + GameUI_InitializeDialogue(&actor, true); + } + } + continue; + + case UIMSG_BuyInShop_Identify_Repair: + UIShop_Buy_Identify_Repair(); + continue; + case UIMSG_ClickNPCTopic: + ClickNPCTopic(uMessageParam); + continue; + case UIMSG_SelectShopDialogueOption: + OnSelectShopDialogueOption(uMessageParam); + continue; + case UIMSG_SelectNPCDialogueOption: + OnSelectNPCDialogueOption((DIALOGUE_TYPE)uMessageParam); + continue; + case UIMSG_ClickHouseNPCPortrait: + _4B4224_UpdateNPCTopics(uMessageParam); + continue; + case UIMSG_StartNewGame: + if ( dword_6BE138 == 124 || uMessageParam ) + { + pIcons_LOD->SyncLoadedFilesCount(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pGUIWindow_CurrentMenu->Release(); + uGameState = GAME_STATE_NEWGAME_OUT_GAMEMENU; + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = 1; + } + else + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[201], 2);// "Are you sure? Click again to start a New Game" + pAudioPlayer->PlaySound(SOUND_20001, 0, 0, -1, 0, 0, 0, 0); + dword_6BE138 = 124; + } + stru_506E40.Release(); + continue; + case UIMSG_Game_OpenLoadGameDialog: + pIcons_LOD->SyncLoadedFilesCount(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pGUIWindow_CurrentMenu->Release(); + pCurrentScreen = SCREEN_LOADGAME; + LoadUI_Load(1); + continue; + case UIMSG_Quit: + if ( dword_6BE138 == 132 || uMessageParam ) + { + pIcons_LOD->SyncLoadedFilesCount(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pGUIWindow_CurrentMenu->Release(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = 1; + if ( !uMessageParam ) + pAudioPlayer->PlaySound((SoundID)(SOUND_EnteringAHouse|0x1), 0, 0, -1, 0, 0, 0, 0); + uGameState = GAME_STATE_GAME_QUITTING_TO_MAIN_MENU; + } + else + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[82], 2);// "Are you sure? Click again to quit" + pAudioPlayer->PlaySound(SOUND_20001, 0, 0, -1, 0, 0, 0, 0); + dword_6BE138 = 132; + } + stru_506E40.Release(); + continue; + case UIMSG_80: + __debugbreak(); + pIcons_LOD->SyncLoadedFilesCount(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); + pGUIWindow_CurrentMenu->Release(); + pCurrentScreen = SCREEN_OPTIONS; + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_8, 0, 0); + continue; + case UIMSG_ArrowUp: + --pSaveListPosition; + if ( pSaveListPosition < 0 ) + pSaveListPosition = 0; + GUIWindow::Create(215, 199, 17, 17, WINDOW_PressedButton2, (int)pBtnArrowUp, 0); + continue; + case UIMSG_DownArrow: + ++pSaveListPosition; + if ( pSaveListPosition >= uMessageParam ) + pSaveListPosition = uMessageParam - 1; + GUIWindow::Create(215, 323, 17, 17, WINDOW_PressedButton2, (int)pBtnDownArrow, 0); + continue; + case UIMSG_Cancel: + GUIWindow::Create(350, 302, 106, 42, WINDOW_CloseRestWindowBtn, (int)pBtnCancel, 0); + continue; + case UIMSG_SaveLoadBtn: + GUIWindow::Create(241, 302, 106, 42, WINDOW_SaveLoadBtn, (int)pBtnLoadSlot, 0); + continue; + case UIMSG_SelectLoadSlot: + if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) + pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_NONE); + if ( pCurrentScreen != SCREEN_SAVEGAME || uLoadGameUI_SelectedSlot != pSaveListPosition + uMessageParam ) + { + v10 = pSaveListPosition + uMessageParam; + if ( dword_6BE138 == pSaveListPosition + uMessageParam ) + { + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_SaveLoadBtn, 0, 0); + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_LoadGame, 0, 0); + } + uLoadGameUI_SelectedSlot = v10; + dword_6BE138 = v10; + } + else + { + pKeyActionMap->EnterText(0, 19, pGUIWindow_CurrentMenu); + if ( strcmp(pSavegameHeader[uLoadGameUI_SelectedSlot].pName, pGlobalTXT_LocalizationStrings[72]) )// "Empty" + strcpy(pKeyActionMap->pPressedKeysBuffer, pSavegameHeader[uLoadGameUI_SelectedSlot].pName); + pKeyActionMap->uNumKeysPressed = strlen(pKeyActionMap->pPressedKeysBuffer); + } + continue; + case UIMSG_LoadGame: + if ( pSavegameUsedSlots[uLoadGameUI_SelectedSlot] ) + { + LoadGame(uLoadGameUI_SelectedSlot); + uGameState = GAME_STATE_LOADING_GAME; + } + stru_506E40.Release(); + continue; + case UIMSG_SaveGame: + if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) + { + pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_NONE); + strcpy((char *)&pSavegameHeader[uLoadGameUI_SelectedSlot], pKeyActionMap->pPressedKeysBuffer); + } + DoSavegame(uLoadGameUI_SelectedSlot); + stru_506E40.Release(); + continue; + case UIMSG_Game_OpenSaveGameDialog: + pGUIWindow_CurrentMenu->Release(); + pCurrentScreen = SCREEN_SAVEGAME; + SaveUI_Load(); + continue; + case UIMSG_Game_OpenOptionsDialog://Open + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pGUIWindow_CurrentMenu->Release(); + viewparams->field_48 = 1; + pCurrentScreen = SCREEN_OPTIONS; + + options_menu_skin.uTextureID_Background = pIcons_LOD->LoadTexture("ControlBG", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_TurnSpeed[2] = pIcons_LOD->LoadTexture("con_16x", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_TurnSpeed[1] = pIcons_LOD->LoadTexture("con_32x", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_TurnSpeed[0] = pIcons_LOD->LoadTexture("con_Smoo", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_ArrowLeft = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_ArrowRight = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_SoundLevels[0] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_SoundLevels[1] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_SoundLevels[2] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_SoundLevels[3] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_SoundLevels[4] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_SoundLevels[5] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_SoundLevels[6] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_SoundLevels[7] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_SoundLevels[8] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_SoundLevels[9] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_FlipOnExit = pIcons_LOD->LoadTexture("option04", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_AlwaysRun = pIcons_LOD->LoadTexture("option03", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_ShowDamage = pIcons_LOD->LoadTexture("option02", TEXTURE_16BIT_PALETTE); + options_menu_skin.uTextureID_WalkSound = pIcons_LOD->LoadTexture("option01", TEXTURE_16BIT_PALETTE); + + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Options, 0, 0); + pGUIWindow_CurrentMenu->CreateButton(22, 270, + pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2])->uTextureWidth, + pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2])->uTextureHeight, + 1, 0, UIMSG_SetTurnSpeed, 0x80, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(93, 270, + pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[1])->uTextureWidth, + pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[1])->uTextureHeight, + 1, 0, UIMSG_SetTurnSpeed, 0x40u, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(164, 270, + pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[0])->uTextureWidth, + pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[0])->uTextureHeight, + 1, 0, UIMSG_SetTurnSpeed, 0, 0, "", 0); + + pGUIWindow_CurrentMenu->CreateButton(20, 303, + pIcons_LOD->GetTexture(options_menu_skin.uTextureID_WalkSound)->uTextureWidth, + pIcons_LOD->GetTexture(options_menu_skin.uTextureID_WalkSound)->uTextureHeight, + 1, 0, UIMSG_ToggleWalkSound, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(128, 303, + pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ShowDamage)->uTextureWidth, + pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ShowDamage)->uTextureHeight, + 1, 0, UIMSG_ToggleShowDamage, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(20, 325, + pIcons_LOD->GetTexture(options_menu_skin.uTextureID_AlwaysRun)->uTextureWidth, + pIcons_LOD->GetTexture(options_menu_skin.uTextureID_AlwaysRun)->uTextureHeight, + 1, 0, UIMSG_ToggleAlwaysRun, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(128, 325, + pIcons_LOD->GetTexture(options_menu_skin.uTextureID_FlipOnExit)->uTextureWidth, + pIcons_LOD->GetTexture(options_menu_skin.uTextureID_FlipOnExit)->uTextureHeight, + 1, 0, UIMSG_ToggleFlipOnExit, 0, 0, "", 0); + + pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(243, 162, 16, 16, 1, 0, UIMSG_ChangeSoundVolume, 4, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0); + pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 162, 16, 16, 1, 0, UIMSG_ChangeSoundVolume, 5, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0); + pGUIWindow_CurrentMenu->CreateButton(263, 162, 172, 17, 1, 0, UIMSG_ChangeSoundVolume, 0, 0, "", 0); + + pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(243, 216, 16, 16, 1, 0, UIMSG_ChangeMusicVolume, 4, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0); + pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 216, 16, 16, 1, 0, UIMSG_ChangeMusicVolume, 5, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0); + pGUIWindow_CurrentMenu->CreateButton(263, 216, 172, 17, 1, 0, UIMSG_ChangeMusicVolume, 0, 0, "", 0); + + pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(243, 270, 16, 16, 1, 0, UIMSG_ChangeVoiceVolume, 4, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0); + pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 270, 16, 16, 1, 0, UIMSG_ChangeVoiceVolume, 5, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0); + pGUIWindow_CurrentMenu->CreateButton(263, 270, 172, 17, 1, 0, UIMSG_ChangeVoiceVolume, 0, 0, "", 0); + + pGUIWindow_CurrentMenu->CreateButton(241, 302, 214, 40, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[619], 0); // "Return to Game" + pGUIWindow_CurrentMenu->CreateButton( 19, 140, 214, 40, 1, 0, UIMSG_OpenKeyMappingOptions, 0, 0x4Bu, "", 0); + pGUIWindow_CurrentMenu->CreateButton( 19, 194, 214, 40, 1, 0, UIMSG_OpenVideoOptions, 0, 86, "", 0); + continue; + + case UIMSG_OpenKeyMappingOptions://Open + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pGUIWindow_CurrentMenu->Release(); + viewparams->field_48 = 1; + pCurrentScreen = SCREEN_KEYBOARD_OPTIONS; + uTextureID_Optkb[0] = pIcons_LOD->LoadTexture("optkb", TEXTURE_16BIT_PALETTE); + uTextureID_Optkb[1] = pIcons_LOD->LoadTexture("optkb_h", TEXTURE_16BIT_PALETTE); + uTextureID_Optkb[2] = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE); + uTextureID_Optkb[3] = pIcons_LOD->LoadTexture("optkb_1", TEXTURE_16BIT_PALETTE); + uTextureID_Optkb[4] = pIcons_LOD->LoadTexture("optkb_2", TEXTURE_16BIT_PALETTE); + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_KeyMappingOptions, 0, 0); + + pGUIWindow_CurrentMenu->CreateButton(241, 302, 214, 40, 1, 0, UIMSG_Escape, 0, 0, "", 0); + + pGUIWindow_CurrentMenu->CreateButton(19, 302, 108, 20, 1, 0, UIMSG_SelectKeyPage1, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(127, 302, 108, 20, 1, 0, UIMSG_SelectKeyPage2, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(127, 324, 108, 20, 1, 0, UIMSG_ResetKeyMapping, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(19, 324, 108, 20, 1, 0, UIMSG_Game_OpenOptionsDialog, 0, 0, "", 0); + + pGUIWindow_CurrentMenu->CreateButton(129, 148, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(129, 167, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 1, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(129, 186, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 2, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(129, 205, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 3, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(129, 224, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 4, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(129, 243, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 5, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(129, 262, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 6, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(350, 148, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 7, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(350, 167, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 8, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(350, 186, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 9, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(350, 205, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 10, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(350, 224, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 11, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(350, 243, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 12, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(350, 262, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 13, 0, "", 0); + + uGameMenuUI_CurentlySelectedKeyIdx = -1; + KeyboardPageNum = 1; + memset(GameMenuUI_InvaligKeyBindingsFlags.data(), 0, sizeof(GameMenuUI_InvaligKeyBindingsFlags)); + //*(_WORD *)KeyButtonArray[28] = 0; + memcpy(pPrevVirtualCidesMapping.data(), pKeyActionMap->pVirtualKeyCodesMapping, 0x78u); + continue; + case UIMSG_ChangeKeyButton: + if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 ) + { + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); + continue; + } + v14 = uMessageParam; + if ( KeyboardPageNum != 1 ) + v14 = uMessageParam + 14; + uGameMenuUI_CurentlySelectedKeyIdx = v14; + pKeyActionMap->EnterText(0, 1, pGUIWindow_CurrentMenu); + continue; + case UIMSG_ResetKeyMapping: + v197 = 1; + pKeyActionMap->SetDefaultMapping(); + for ( uint i = 0; i < 28; i++ ) + { + if ( pKeyActionMap->GetActionVKey((enum InputAction)i) != pPrevVirtualCidesMapping[i] ) + { + if ( v197 ) + { + GUI_ReplaceHotkey(LOBYTE(pPrevVirtualCidesMapping[i]), pKeyActionMap->GetActionVKey((enum InputAction)i), 1); + v197 = 0; + } + else + GUI_ReplaceHotkey(LOBYTE(pPrevVirtualCidesMapping[i]), pKeyActionMap->GetActionVKey((enum InputAction)i), 0); + } + pPrevVirtualCidesMapping[i] = pKeyActionMap->GetActionVKey((enum InputAction)i); + GameMenuUI_InvaligKeyBindingsFlags[i] = false; + } + pAudioPlayer->PlaySound((SoundID)219, 0, 0, -1, 0, 0, 0, 0); + continue; + case UIMSG_SelectKeyPage1: + KeyboardPageNum = 1; + continue; + case UIMSG_SelectKeyPage2: + KeyboardPageNum = 2; + continue; + case UIMSG_OpenVideoOptions: + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pGUIWindow_CurrentMenu->Release(); + viewparams->field_48 = 1; + pCurrentScreen = SCREEN_VIDEO_OPTIONS; + optvid_base_texture_id = pIcons_LOD->LoadTexture("optvid", TEXTURE_16BIT_PALETTE); + bloodsplats_texture_id = pIcons_LOD->LoadTexture("opvdH-bs", TEXTURE_16BIT_PALETTE); + us_colored_lights_texture_id = pIcons_LOD->LoadTexture("opvdH-cl", TEXTURE_16BIT_PALETTE); + tinting_texture_id = pIcons_LOD->LoadTexture("opvdH-tn", TEXTURE_16BIT_PALETTE); + uTextureID_507C20 = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE); + uTextureID_507C24 = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE); + pTextureIDs_GammaPositions[0] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE); + pTextureIDs_GammaPositions[1] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE); + pTextureIDs_GammaPositions[2] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE); + pTextureIDs_GammaPositions[3] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE); + pTextureIDs_GammaPositions[4] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE); + pTextureIDs_GammaPositions[5] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE); + pTextureIDs_GammaPositions[6] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE); + pTextureIDs_GammaPositions[7] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE); + pTextureIDs_GammaPositions[8] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE); + pTextureIDs_GammaPositions[9] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE); + not_available_bloodsplats_texture_id = pIcons_LOD->LoadTexture("opvdG-bs", TEXTURE_16BIT_PALETTE); + not_available_us_colored_lights_texture_id = pIcons_LOD->LoadTexture("opvdG-cl", TEXTURE_16BIT_PALETTE); + not_available_tinting_texture_id = pIcons_LOD->LoadTexture("opvdG-tn", TEXTURE_16BIT_PALETTE); + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_VideoOptions, 0, 0); + pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, 1, 0, UIMSG_Escape, 0, 0, "", 0); + //if ( pRenderer->pRenderD3D ) + { + pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x118u, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleBloodsplats, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x12Eu, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleColoredLights, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x144u, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleTint, 0, 0, "", 0); + } + /*if ( !pRenderer->bWindowMode ) + { + //v0 = 1; + if ( pRenderer->IsGammaSupported() ) + { + pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0x15u, 0xA1u, 0x10u, 0x10u, 1, 0, UIMSG_1A9, 4u, 0, "", pIcons_LOD->GetTexture(uTextureID_507C20), 0); + pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0xD5u, 0xA1u, 0x10u, 0x10u, 1, 0, UIMSG_1A9, 5u, 0, "", pIcons_LOD->GetTexture(uTextureID_507C24), 0); + pGUIWindow_CurrentMenu->CreateButton(42, 162, 170, 18, 1, 0, UIMSG_1A9, 0, 0, "", 0); + } + }*/ + continue; + case UIMSG_1A9: + __debugbreak(); + if ( uMessageParam == 4 ) + { + //--uGammaPos; + if ( (uGammaPos -- -1) < 0 ) + { + uGammaPos = 0; + pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0); + continue; + } + v19 = (double)(signed int)uGammaPos * 0.1 + 0.6; + pGame->pGammaController->Initialize(v19); + GUIWindow::Create(21, 161, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, (char *)1); + pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0); + continue; + } + if ( uMessageParam == 5 ) + { + ++uGammaPos; + if ( (signed int)uGammaPos <= 9 ) + { + v21 = (double)(signed int)uGammaPos * 0.1 + 0.6; + pGame->pGammaController->Initialize(v21); + GUIWindow::Create(213, 161, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, (char *)1); + pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0); + continue; + } + uGammaPos = 9; + } + else + { + uGammaPos = (pMouse->GetCursorPos(&a2)->x - 42) / 17; + v22 = (double)(signed int)uGammaPos * 0.1 + 0.6; + pGame->pGammaController->Initialize(v22); + } + pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0); + continue; + case UIMSG_ToggleBloodsplats: + pGame->ToggleFlags2(0x20u); + continue; + case UIMSG_ToggleColoredLights: + pRenderer->ToggleColoredLights(); + continue; + case UIMSG_ToggleTint: + pRenderer->ToggleTint(); + continue; + case UIMSG_ChangeMusicVolume: + if ( uMessageParam == 4 )//- + { + --uMusicVolimeMultiplier; + if ( (char)uMusicVolimeMultiplier < 1 ) + uMusicVolimeMultiplier = 0; + GUIWindow::Create(243, 216, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, (char *)1); + if ( uMusicVolimeMultiplier ) + pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f, 0); + pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); + continue; + } + if ( uMessageParam == 5 )//+ + { + ++uMusicVolimeMultiplier; + if ( (char)uMusicVolimeMultiplier > 9 ) + uMusicVolimeMultiplier = 9; + GUIWindow::Create(435, 216, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, (char *)1); + if ( uMusicVolimeMultiplier ) + pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f, 0); + pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); + continue; + } + uMusicVolimeMultiplier = (pMouse->GetCursorPos(&v202)->x - 263) / 17;//for mouse + if ( (char)uMusicVolimeMultiplier > 9 ) + uMusicVolimeMultiplier = 9; + if ( uMusicVolimeMultiplier ) + pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f, 0); + pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); + continue; + case UIMSG_ChangeSoundVolume: + if ( uMessageParam == 4 )//reduce sound level button left + { + --uSoundVolumeMultiplier; + if ( (char)uSoundVolumeMultiplier < 1 ) + uSoundVolumeMultiplier = 0; + GUIWindow::Create(243, 162, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, (char *)1); + pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f); + pAudioPlayer->PlaySound((SoundID)218, -1, 0, -1, 0, 0, 0, 0); + //int v = AIL_redbook_volume(pAudioPlayer->hAILRedbook); + //if (v) + //__debugbreak(); + continue; + } + if ( uMessageParam == 5 )//Increase sound level button right + { + ++uSoundVolumeMultiplier; + if ( (char)uSoundVolumeMultiplier > 8 ) + uSoundVolumeMultiplier = 9; + //v168 = 1; + v24 = 435; + //v154 = (int)pBtn_SliderRight; + GUIWindow::Create(v24, 0xA2u, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, (char *)1); + pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f); + pAudioPlayer->PlaySound((SoundID)218, -1, 0, -1, 0, 0, 0, 0); + continue; + } + uSoundVolumeMultiplier = (pMouse->GetCursorPos(&v207)->x - 263) / 17; + if ( (char)uSoundVolumeMultiplier > 8 ) + uSoundVolumeMultiplier = 9; + pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f); + pAudioPlayer->PlaySound((SoundID)218, -1, 0, -1, 0, 0, 0, 0); + continue; + case UIMSG_ToggleFlipOnExit: + bFlipOnExit = bFlipOnExit == 0; + continue; + case UIMSG_ToggleAlwaysRun: + bAlwaysRun = bAlwaysRun == 0; + continue; + case UIMSG_ToggleWalkSound: + bWalkSound = bWalkSound == 0; + continue; + case UIMSG_ToggleShowDamage: + bShowDamage = bShowDamage == 0; + continue; + case UIMSG_ChangeVoiceVolume: + if ( uMessageParam == 4 ) + { + --uVoicesVolumeMultiplier; + if ( (char)uVoicesVolumeMultiplier < 1 ) + uVoicesVolumeMultiplier = 0; + GUIWindow::Create(243, 270, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, (char *)1); + if ( !uVoicesVolumeMultiplier ) + continue; + pAudioPlayer->PlaySound((SoundID)5788, -1, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0); + continue; + } + if ( uMessageParam == 5 ) + { + ++uVoicesVolumeMultiplier; + if ( (char)uVoicesVolumeMultiplier > 8 ) + uVoicesVolumeMultiplier = 9; + GUIWindow::Create(435, 270, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, (char *)1); + if ( !uVoicesVolumeMultiplier ) + continue; + pAudioPlayer->PlaySound((SoundID)5788, -1, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0); + continue; + } + uVoicesVolumeMultiplier = (pMouse->GetCursorPos(&v205)->x - 263) / 17; + if ( (char)uVoicesVolumeMultiplier > 8 ) + uVoicesVolumeMultiplier = 9; + if ( !uVoicesVolumeMultiplier ) + continue; + pAudioPlayer->PlaySound((SoundID)5788, -1, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0); + continue; + case UIMSG_SetTurnSpeed: + if ( uMessageParam ) + pParty->sRotationY = uMessageParam * pParty->sRotationY / uMessageParam; + uTurnSpeed = uMessageParam; + continue; + + case UIMSG_SetGraphicsMode: + /*if ( !bUseLoResSprites ) + { + byte_6BE388_graphicsmode = uMessageParam; + MM7Initialization(); + continue; + } + if ( uMessageParam ) + { + if ( uMessageParam == 1 ) + { + byte_6BE388_graphicsmode = 0; + } + else + { + if ( uMessageParam != 2 ) + continue; + byte_6BE388_graphicsmode = 1; + } + MM7Initialization(); + continue; + }*/ + ModalWindow(pNPCTopics[453].pText, UIMSG_0); + __debugbreak(); // Nomad: graphicsmode as it was now removed + continue; + + case UIMSG_GameMenu_ReturnToGame: + pGUIWindow_CurrentMenu->Release(); + pEventTimer->Resume(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = 1; + stru_506E40.Release(); + continue; + case UIMSG_OpenQuestBook: + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + if ( pCurrentScreen ) + pGUIWindow_CurrentMenu->Release(); + pEventTimer->Pause(); + pAudioPlayer->StopChannels(-1, -1); + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, uMessage, 0); + pBooksWindow = GUIWindow::Create(493u, 355u, 0, 0, WINDOW_BooksWindow, (int)pBtn_Quests, 0); + bFlashQuestBook = 0; + continue; + case UIMSG_OpenAutonotes: + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + if ( pCurrentScreen ) + pGUIWindow_CurrentMenu->Release(); + pEventTimer->Pause(); + pAudioPlayer->StopChannels(-1, -1); + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, uMessage, 0); + pBooksWindow = GUIWindow::Create(527u, 353u, 0, 0, WINDOW_BooksWindow, (int)pBtn_Autonotes, 0); + bFlashAutonotesBook = 0; + continue; + case UIMSG_OpenMapBook: + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + if ( pCurrentScreen ) + pGUIWindow_CurrentMenu->Release(); + pEventTimer->Pause(); + viewparams->sViewCenterX = pParty->vPosition.x; + viewparams->sViewCenterY = pParty->vPosition.y; + pAudioPlayer->StopChannels(-1, -1); + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, uMessage, 0); + pBooksWindow = GUIWindow::Create(546, 353, 0, 0, WINDOW_BooksWindow, (int)pBtn_Maps, 0); + continue; + case UIMSG_OpenCalendar: + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + if ( pCurrentScreen ) + pGUIWindow_CurrentMenu->Release(); + pEventTimer->Pause(); + pAudioPlayer->StopChannels(-1, -1); + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, uMessage, 0); + pBooksWindow = GUIWindow::Create(570, 354, 0, 0, WINDOW_BooksWindow, (int)pBtn_Calendar, 0); + continue; + case UIMSG_OpenHistoryBook: + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + if ( pCurrentScreen ) + pGUIWindow_CurrentMenu->Release(); + pEventTimer->Pause(); + pAudioPlayer->StopChannels(-1, -1); + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, uMessage, 0); + pBooksWindow = GUIWindow::Create(0x258u, 0x169u, 0, 0, WINDOW_BooksWindow, (int)pBtn_History, 0); + bFlashHistoryBook = 0; + continue; + case UIMSG_Escape:// íàæàòèå Escape and return to game + back_to_game(); + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + switch ( pCurrentScreen ) + { + case SCREEN_E: + __debugbreak(); + case SCREEN_NPC_DIALOGUE: + case SCREEN_CHEST: + case SCREEN_CHEST_INVENTORY: + case SCREEN_CHANGE_LOCATION: + case SCREEN_INPUT_BLV: + case SCREEN_QUICK_REFERENCE: + if ( dword_50CDC8 ) + break; + CloseWindowBackground(); + uMessageParam = 1; + break; + case SCREEN_HOUSE: + if ( !dword_50CDC8 ) + { + CloseWindowBackground(); + uMessageParam = 1; + break; + } + break; + } + if ( !pModalWindow ) + { + pRenderer->ClearZBuffer(0, 479); + viewparams->bRedrawGameUI = 1; + viewparams->field_48 = 1; + if ( pCurrentScreen ) + { + if ( pCurrentScreen > SCREEN_67 ) + { + if ( pCurrentScreen == SCREEN_QUICK_REFERENCE ) + { + pIcons_LOD->RemoveTexturesPackFromTextureList(); + if ( pGUIWindow_Settings ) + { + if ( pCurrentScreen == SCREEN_CHARACTERS ) + pMouse->SetCursorBitmap("MICON2"); + else + { + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + } + } + 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; + } + } + else + { + if ( pCurrentScreen < SCREEN_64 ) + { + switch ( pCurrentScreen ) + { + case SCREEN_CASTING: + pIcons_LOD->RemoveTexturesPackFromTextureList(); + if ( some_active_character ) + { + uActiveCharacter = some_active_character; + uActiveCharacter = pParty->GetNextActiveCharacter(); + some_active_character = 0; + if ( pParty->bTurnBasedModeOn ) + pTurnEngine->ApplyPlayerAction(); + _50C9D0_AfterEnchClickEventId = 0; + _50C9D4_AfterEnchClickEventSecondParam = 0; + _50C9D8_AfterEnchClickEventTimeout = 0; + } + if ( ptr_50C9A4_ItemToEnchant && ptr_50C9A4_ItemToEnchant->uItemID ) + { + LOBYTE(ptr_50C9A4_ItemToEnchant->uAttributes) &= 0xFu; + _50C9A8_item_enchantment_timer = 0; + ptr_50C9A4_ItemToEnchant = nullptr; + } + if ( pGUIWindow_Settings ) + { + if ( pCurrentScreen == SCREEN_CHARACTERS ) + pMouse->SetCursorBitmap("MICON2"); + else + { + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + } + } + 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; + case SCREEN_BOOKS: + pBooksWindow->Release(); + //crt_deconstruct_ptr_6A0118(); + pBooksWindow = 0; + pEventTimer->Resume(); + if ( pGUIWindow_Settings ) + { + if ( pCurrentScreen == SCREEN_CHARACTERS ) + pMouse->SetCursorBitmap("MICON2"); + else + { + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + } + } + 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; + case SCREEN_SAVEGAME: + case SCREEN_LOADGAME: + pIcons_LOD->RemoveTexturesPackFromTextureList(); + //crt_deconstruct_ptr_6A0118(); + stru_506E40.Release(); + break; + case SCREEN_CHEST_INVENTORY: + pCurrentScreen = SCREEN_CHEST; + continue; + case SCREEN_CHEST: + pWindow2 = pChestWindow; + pWindow2->Release(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = 1; + pEventTimer->Resume(); + continue; + case SCREEN_19: + __debugbreak(); + pWindow2 = ptr_507BC8; + pWindow2->Release(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = 1; + pEventTimer->Resume(); + continue; + case SCREEN_OPTIONS://Close + options_menu_skin.Relaease(); + pIcons_LOD->SyncLoadedFilesCount(); + WriteWindowsRegistryInt("soundflag", (char)uSoundVolumeMultiplier); + WriteWindowsRegistryInt("musicflag", (char)uMusicVolimeMultiplier); + WriteWindowsRegistryInt("CharVoices", (char)uVoicesVolumeMultiplier); + WriteWindowsRegistryInt("WalkSound", bWalkSound); + WriteWindowsRegistryInt("ShowDamage", bShowDamage); + //WriteWindowsRegistryInt("graphicsmode", (unsigned __int8)byte_6BE388_graphicsmode); + WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun); + WriteWindowsRegistryInt("FlipOnExit", bFlipOnExit); + if ( !uTurnSpeed ) + { + WriteWindowsRegistryInt("TurnDelta", 3); + stru_506E40.Release(); + break; + } + if ( uTurnSpeed == 64 ) + { + WriteWindowsRegistryInt("TurnDelta", 2); + stru_506E40.Release(); + break; + } + if ( uTurnSpeed != 128 ) + { + stru_506E40.Release(); + break; + } + WriteWindowsRegistryInt("TurnDelta", 1); + stru_506E40.Release(); + break; + case SCREEN_MENU: + pIcons_LOD->SyncLoadedFilesCount(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); + pIcons_LOD->SyncLoadedFilesCount(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); + stru_506E40.Release(); + break; + case SCREEN_VIDEO_OPTIONS: + //if ( pRenderer->pRenderD3D ) + { + WriteWindowsRegistryInt("Colored Lights", pRenderer->bUseColoredLights); + WriteWindowsRegistryInt("Tinting", pRenderer->bTinting); + WriteWindowsRegistryInt("Bloodsplats", (LOBYTE(pGame->uFlags2) >> 5) & 1); + } + /*if ( !pRenderer->bWindowMode ) + WriteWindowsRegistryInt("GammaPos", uGammaPos);*/ + + stru_506E40.Release(); + break; + + case SCREEN_KEYBOARD_OPTIONS://Return to game + v197 = 1; + pKeyBindingFlag = false; + for ( uint i = 0; i < 28; ++i ) + { + if ( GameMenuUI_InvaligKeyBindingsFlags[i] ) + pKeyBindingFlag = true; + } + if ( !pKeyBindingFlag ) + { + for ( uint i = 0; i < 5; i++ ) + { + if ( uTextureID_Optkb[i] ) + pIcons_LOD->pTextures[uTextureID_Optkb[i]].Release(); + } + memset(&uTextureID_Optkb, 0, 20); + pIcons_LOD->SyncLoadedFilesCount(); + for ( uint i = 0; i < 28; ++i ) + { + if ( pKeyActionMap->GetActionVKey((enum InputAction)i) != pPrevVirtualCidesMapping[i] ) + { + if ( v197 ) + { + GUI_ReplaceHotkey(pKeyActionMap->GetActionVKey((enum InputAction)i), LOBYTE(pPrevVirtualCidesMapping[i]), 1); + v197 = 0; + } + else + GUI_ReplaceHotkey(pKeyActionMap->GetActionVKey((enum InputAction)i), LOBYTE(pPrevVirtualCidesMapping[i]), 0); + } + if ( i > 3 && i != 25 && i != 26 ) + pKeyToggleType = TOGGLE_OneTimePress; + else + pKeyToggleType = TOGGLE_Continuously; + pKeyActionMap->SetKeyMapping(i, pPrevVirtualCidesMapping[i], pKeyToggleType); + } + pKeyActionMap->StoreMappings(); + stru_506E40.Release(); + break; + } + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); + break; + case SCREEN_REST://close rest screen + if ( dword_506F14 ) + { + Rest(_506F18_num_minutes_to_sleep); + 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(); + pTexture_RestUI_CurrentHourglassFrame = 0; + 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; + if ( pGUIWindow_Settings ) + { + if ( pCurrentScreen == SCREEN_CHARACTERS ) + pMouse->SetCursorBitmap("MICON2"); + else + { + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + } + } + 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; + case SCREEN_E: + __debugbreak(); + pGUIWindow_CurrentMenu->Release(); + pCurrentScreen = SCREEN_HOUSE; + pIcons_LOD->RemoveTexturesPackFromTextureList(); + continue; + case SCREEN_HOUSE: + if ( uDialogueType ) + uDialogueType = 0; + if ( uGameState == GAME_STATE_CHANGE_LOCATION ) + { + while ( HouseDialogPressCloseBtn() ) + ; + } + else + { + if ( HouseDialogPressCloseBtn() ) + continue; + } + GetHouseGoodbyeSpeech(); + pAudioPlayer->PlaySound(SOUND_7, 814, 0, -1, 0, 0, 0, 0); + pMediaPlayer->Unload(); + pGUIWindow_CurrentMenu = window_SpeakInHouse; + if ( pGUIWindow_Settings ) + { + if ( pCurrentScreen == SCREEN_CHARACTERS ) + pMouse->SetCursorBitmap("MICON2"); + else + { + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + } + } + 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 = true; + pIcons_LOD->RemoveTexturesFromTextureList(); + continue; + case SCREEN_INPUT_BLV://click escape + if ( uCurrentHouse_Animation == 153 ) + PlayHouseSound(0x99u, HouseSound_Greeting_2); + pMediaPlayer->Unload(); + if ( npcIdToDismissAfterDialogue ) + { + pParty->hirelingScrollPosition = 0; + LOBYTE(pNPCStats->pNewNPCData[npcIdToDismissAfterDialogue].uFlags) &= 0x7Fu; + pParty->CountHirelings(); + viewparams->bRedrawGameUI = true; + npcIdToDismissAfterDialogue = 0; + } + DialogueEnding(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = true; + continue; + case SCREEN_NPC_DIALOGUE://click escape + if ( npcIdToDismissAfterDialogue ) + { + pParty->hirelingScrollPosition = 0; + LOBYTE(pNPCStats->pNewNPCData[npcIdToDismissAfterDialogue].uFlags) &= 0x7Fu; + pParty->CountHirelings(); + viewparams->bRedrawGameUI = true; + npcIdToDismissAfterDialogue = 0; + } + //goto LABEL_317; + DialogueEnding(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = true; + continue; + case SCREEN_BRANCHLESS_NPC_DIALOG://click escape + memset(GameUI_Footer_TimedString.data(), 0, 0xC8u); + sub_4452BB(); + DialogueEnding(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = true; + continue; + case SCREEN_CHANGE_LOCATION://click escape + if ( pParty->vPosition.x < -22528 ) + pParty->vPosition.x = -22528; + if ( pParty->vPosition.x > 22528 ) + pParty->vPosition.x = 22528; + if ( pParty->vPosition.y < -22528 ) + pParty->vPosition.y = -22528; + if ( pParty->vPosition.y > 22528 ) + pParty->vPosition.y = 22528; + DialogueEnding(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = true; + continue; + case SCREEN_VIDEO: + pMediaPlayer->Unload(); + continue; + case SCREEN_CHARACTERS: + CharacterUI_ReleaseButtons(); + ReleaseAwardsScrollBar(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); + if ( pGUIWindow_Settings ) + { + if ( pCurrentScreen == SCREEN_CHARACTERS ) + pMouse->SetCursorBitmap("MICON2"); + else + { + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + } + } + 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 = true; + pIcons_LOD->RemoveTexturesFromTextureList(); + continue; + default: + if ( pGUIWindow_Settings ) + { + if ( pCurrentScreen == SCREEN_CHARACTERS ) + pMouse->SetCursorBitmap("MICON2"); + else + { + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + } + } + 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; + } + if ( pGUIWindow_Settings ) + { + if ( pCurrentScreen == SCREEN_CHARACTERS ) + pMouse->SetCursorBitmap("MICON2"); + else + { + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + } + } + 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 = true; + pIcons_LOD->RemoveTexturesFromTextureList(); + continue; + } + CharacterUI_ReleaseButtons(); + ReleaseAwardsScrollBar(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); + } + if ( pGUIWindow_Settings ) + { + if ( pCurrentScreen == SCREEN_CHARACTERS ) + pMouse->SetCursorBitmap("MICON2"); + else + { + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + } + } + 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 = true; + pIcons_LOD->RemoveTexturesFromTextureList(); + continue; + } + if ( !pGUIWindow_Settings )//Draw Menu + { + dword_6BE138 = -1; + GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_PressedButton2, (int)pBtn_GameSettings, (char *)1); + pEventTimer->Pause(); + pAudioPlayer->StopChannels(-1, -1); + pCurrentScreen = SCREEN_MENU; + + ++pIcons_LOD->uTexturePacksCount; + if ( !pIcons_LOD->uNumPrevLoadedFiles ) + pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; + + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_OptionsButtons, 0, 0); + uTextureID_Options = pIcons_LOD->LoadTexture("options", TEXTURE_16BIT_PALETTE); + uTextureID_New1 = pIcons_LOD->LoadTexture("new1", TEXTURE_16BIT_PALETTE); + uTextureID_Load1 = pIcons_LOD->LoadTexture("load1", TEXTURE_16BIT_PALETTE); + uTextureID_Save1 = pIcons_LOD->LoadTexture("save1", TEXTURE_16BIT_PALETTE); + uTextureID_Controls1 = pIcons_LOD->LoadTexture("controls1", TEXTURE_16BIT_PALETTE); + uTextureID_Resume1 = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE); + uTextureID_Quit1 = pIcons_LOD->LoadTexture("quit1", TEXTURE_16BIT_PALETTE); + pBtn_NewGame = pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x9Bu, 0xD6u, 0x28u, 1, 0, UIMSG_StartNewGame, 0, 0x4Eu, + pGlobalTXT_LocalizationStrings[614],// "New Game" + pIcons_LOD->GetTexture(uTextureID_New1), 0); + pBtn_SaveGame = pGUIWindow_CurrentMenu->CreateButton(0x13u, 0xD1u, 0xD6u, 0x28u, 1, 0, UIMSG_Game_OpenSaveGameDialog, 0, 0x53u, + pGlobalTXT_LocalizationStrings[615],// "Save Game" + pIcons_LOD->GetTexture(uTextureID_Save1), 0); + pBtn_LoadGame = pGUIWindow_CurrentMenu->CreateButton(19, 263, 0xD6u, 0x28u, 1, 0, UIMSG_Game_OpenLoadGameDialog, 0, 0x4Cu, + pGlobalTXT_LocalizationStrings[616],// "Load Game" + pIcons_LOD->GetTexture(uTextureID_Load1), 0); + pBtn_GameControls = pGUIWindow_CurrentMenu->CreateButton(241, 155, 214, 40, 1, 0, UIMSG_Game_OpenOptionsDialog, 0, 0x43u, + pGlobalTXT_LocalizationStrings[617],// ""Sound, Keyboard, Game Options:"" + pIcons_LOD->GetTexture(uTextureID_Controls1), 0); + pBtn_QuitGame = pGUIWindow_CurrentMenu->CreateButton(241, 209, 214, 40, 1, 0, UIMSG_Quit, 0, 0x51u, + pGlobalTXT_LocalizationStrings[618],// "Quit" + pIcons_LOD->GetTexture(uTextureID_Quit1), 0); + pBtn_Resume = pGUIWindow_CurrentMenu->CreateButton(241, 263, 214, 40, 1, 0, UIMSG_GameMenu_ReturnToGame, 0, 0x52u, + pGlobalTXT_LocalizationStrings[619],// "Return to Game" + pIcons_LOD->GetTexture(uTextureID_Resume1), 0); + pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(6, 1, 0, 0); + viewparams->field_48 = 1; + + stru_506E40.Release(); + pRenderer->SaveScreenshot("gamma.pcx", 155, 117); + stru_506E40.LoadPCXFile("gamma.pcx", 0); + + continue; + } + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + continue; + } + ModalWindow_Release(); + continue; + case UIMSG_ScrollNPCPanel://Right and Left button for NPCPanel + if ( uMessageParam ) + { + GUIWindow::Create(626, 179, 0, 0, WINDOW_PressedButton2, (int)pBtn_NPCRight, 0); + v37 = (pParty->pHirelings[0].pName != 0) + (pParty->pHirelings[1].pName != 0) + (unsigned __int8)pParty->field_70A - 2; + if ( pParty->hirelingScrollPosition < v37 ) + { + ++pParty->hirelingScrollPosition;//??? maybe number of the first cell??? + if ( pParty->hirelingScrollPosition >= v37 ) + pParty->hirelingScrollPosition = (pParty->pHirelings[0].pName != 0) + (pParty->pHirelings[1].pName != 0) + pParty->field_70A - 2; + } + } + else + { + GUIWindow::Create(469, 179, 0, 0, WINDOW_PressedButton2, (int)pBtn_NPCLeft, 0); + /*if ( pParty->field_709 ) + { + --pParty->field_709; + if ( pParty->field_709 < 1 ) + pParty->field_709 = 0; + }*/ + } + GameUI_DrawHiredNPCs(); + continue; + case UIMSG_TransitionUI_Confirm: + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + dword_50CDC8 = 1; + sub_42FBDD(); + PlayHouseSound(uCurrentHouse_Animation, HouseSound_NotEnoughMoney_TrainingSuccessful); + + if (pMovie_Track) + pMediaPlayer->Unload(); + DialogueEnding(); + viewparams->bRedrawGameUI = true; + if ( dword_59117C_teleportx | dword_591178_teleporty | dword_591174_teleportz | dword_591170_teleport_directiony | dword_59116C_teleport_directionx | dword_591168_teleport_speedz ) + { + if ( dword_59117C_teleportx ) + { + pParty->vPosition.x = dword_59117C_teleportx; + _5B65A8_npcdata_uflags_or_other = dword_59117C_teleportx; + } + if ( dword_591178_teleporty ) + { + pParty->vPosition.y = dword_591178_teleporty; + _5B65AC_npcdata_fame_or_other = dword_591178_teleporty; + } + if ( dword_591174_teleportz ) + { + pParty->vPosition.z = dword_591174_teleportz; + _5B65B0_npcdata_rep_or_other = dword_591174_teleportz; + pParty->uFallStartY = dword_591174_teleportz; + } + if ( dword_591170_teleport_directiony ) + { + pParty->sRotationY = dword_591170_teleport_directiony; + _5B65B4_npcdata_loword_house_or_other = dword_591170_teleport_directiony; + } + if ( dword_59116C_teleport_directionx ) + { + pParty->sRotationX = dword_59116C_teleport_directionx; + _5B65B8_npcdata_hiword_house_or_other = dword_59116C_teleport_directionx; + v38 = dword_591168_teleport_speedz; + pParty->uFallSpeed = dword_591168_teleport_speedz; + dword_5B65BC = dword_591168_teleport_speedz; + } + else + v38 = dword_5B65BC; + if ( *dword_591164_teleport_map_name != 48 ) + { + pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)2; + dword_5B65C0 = _5B65A8_npcdata_uflags_or_other | _5B65AC_npcdata_fame_or_other | _5B65B0_npcdata_rep_or_other | _5B65B4_npcdata_loword_house_or_other | _5B65B8_npcdata_hiword_house_or_other | v38; + OnMapLeave(); + Transition_StopSound_Autosave(dword_591164_teleport_map_name, MapStartPoint_Party); + } + } + else + EventProcessor(dword_5C3418, 0, 1, dword_5C341C); + if ( !_stricmp(byte_6BE3B0.data(), "d05.blv") ) + pParty->uTimePlayed += 1474560i64; + continue; + case UIMSG_TransitionWindowCloseBtn: + CloseWindowBackground(); + pMediaPlayer->Unload(); + DialogueEnding(); + viewparams->bRedrawGameUI = true; + continue; + case UIMSG_CycleCharacters: + v39 = GetAsyncKeyState(VK_SHIFT); + uActiveCharacter = CycleCharacter(v39); + viewparams->bRedrawGameUI = true; + continue; + case UIMSG_OnTravelByFoot: + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + dword_50CDC8 = 1; + sub_42FBDD(); + //pNPCData4 = (NPCData *)GetTravelTime(); + strcpy(pOutdoor->pLevelFilename, pCurrentMapName); + if ( bUnderwater != 1 && pParty->bFlying + || pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pOut, 20) != 1 ) + { + viewparams->bRedrawGameUI = 1; + CloseWindowBackground(); + if ( pParty->vPosition.x < -22528 ) + pParty->vPosition.x = -22528; + if ( pParty->vPosition.x > 22528 ) + pParty->vPosition.x = 22528; + if ( pParty->vPosition.y < -22528 ) + pParty->vPosition.y = -22528; + if ( pParty->vPosition.y > 22528 ) + pParty->vPosition.y = 22528; + DialogueEnding(); + pCurrentScreen = SCREEN_GAME; + } + else + { + pParty->field_6E4 = 0; + pParty->field_6E0 = 0; + CastSpellInfoHelpers::_427D48(); + DialogueEnding(); + pEventTimer->Pause(); + pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_Box); + ++pGameLoadingUI_ProgressBar->uProgressMax; + SaveGame(1, 0); + pGameLoadingUI_ProgressBar->Progress(); + RestAndHeal(1440 * (signed int)GetTravelTime()); + if ( pParty->uNumFoodRations ) + { + pParty->RestAndHeal(); + if ( ((pParty->uNumFoodRations - (signed int)GetTravelTime()) & 0x80000000u) != 0 ) + { + pPlayer7 = pParty->pPlayers.data(); + do + { + pPlayer7->SetCondition(1, 0); + ++pPlayer7; + } + while ( (signed int)pPlayer7 < (signed int)pParty->pHirelings.data() ); + ++pParty->days_played_without_rest; + } + Party::TakeFood((unsigned int)GetTravelTime()); + } + else + { + pPlayer8 = pParty->pPlayers.data(); + do + { + pPlayer8->SetCondition(1, 0); + ++pPlayer8; + } + while ( (signed int)pPlayer8 < (signed int)pParty->pHirelings.data() ); + ++pParty->days_played_without_rest; + } + pPaletteManager->ResetNonLocked(); + pSpriteFrameTable->ResetSomeSpriteFlags(); + strcpy(pCurrentMapName, pOut); + strcpy(pLevelName, pCurrentMapName); + v41 = strtok(pLevelName, "."); + strcpy(pLevelName, v41); + Level_LoadEvtAndStr(pLevelName); + pDecalBuilder->Reset(0); + LoadLevel_InitializeLevelEvt(); + uLevelMapStatsID = pMapStats->GetMapInfo(pCurrentMapName); + bUnderwater = 0; + bNoNPCHiring = 0; + pGame->uFlags2 &= 0xFFFFFFF7u; + if ( Is_out15odm_underwater() ) + { + bUnderwater = 1; + pGame->uFlags2 |= 8u; + } + if ( !_stricmp(pCurrentMapName, "out15.odm") || !_stricmp(pCurrentMapName, "d47.blv") ) + bNoNPCHiring = 1; + PrepareToLoadODM(1u, (ODMRenderParams *)1); + pAudioPlayer->SetMapEAX(); + bDialogueUI_InitializeActor_NPC_ID = 0; + OnMapLoad(); + pOutdoor->SetFog(); + TeleportToStartingPoint(uLevel_StartingPointType); + pParty->vPosition.z = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, &v213, 0); + pParty->uFallStartY = pParty->vPosition.z; + _461103_load_level_sub(); + pEventTimer->Resume(); + viewparams->bRedrawGameUI = 1; + pCurrentScreen = SCREEN_GAME; + pGameLoadingUI_ProgressBar->Release(); + } + viewparams->bRedrawGameUI = 1; + continue; + case UIMSG_CHANGE_LOCATION_ClickCencelBtn: + CloseWindowBackground(); + if ( pParty->vPosition.x < -22528 ) + pParty->vPosition.x = -22528; + if ( pParty->vPosition.x > 22528 ) + pParty->vPosition.x = 22528; + if ( pParty->vPosition.y < -22528 ) + pParty->vPosition.y = -22528; + if ( pParty->vPosition.y > 22528 ) + pParty->vPosition.y = 22528; + DialogueEnding(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = 1; + continue; + case UIMSG_CastSpell_Telekinesis: + //if ( pRenderer->pRenderD3D ) + LOWORD(v42) = pGame->pVisInstance->get_picked_object_zbuf_val(); + /*else + { + uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v210); + pPoint = pMouse->GetCursorPos(&v208); + v42 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint->y]]; + }*/ + v44 = (unsigned __int16)v42; + v45 = PID_TYPE(v44); + uNumSeconds = v44; + v46 = PID_ID(v44); + if ( v45 == 3 ) + { + v47 = pActors[v46].uAIState == Dead; + if ( !v47 ) + continue; + pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; + pSpellInfo->uFlags &= ~0x40u; + pSpellInfo->uPlayerID_2 = uMessageParam; + pSpellInfo->spell_target_pid = v44; + pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + continue; + } + if ( v45 == 2 ) + { + v47 = (pObjectList->pObjects[pSpriteObjects[v46].uObjectDescID].uFlags & 0x10) == 0; + if ( !v47 ) + continue; + pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; + pSpellInfo->uFlags &= ~0x40u; + pSpellInfo->uPlayerID_2 = uMessageParam; + pSpellInfo->spell_target_pid = v44; + pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + continue; + } + if ( v45 == 5 ) + { + v48 = pLevelDecorations[v46].uEventID == 0; + } + else + { + if ( v45 != 6 ) + continue; + if ( uCurrentlyLoadedLevelType != 1 ) + { + pODMFace = &pOutdoor->pBModels[v44 >> 9].pFaces[v46 & 0x3F]; + if ( !pODMFace->Clickable() || !pODMFace->sCogTriggeredID ) + continue; + v44 = uNumSeconds; + pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; + pSpellInfo->uFlags &= ~0x40u; + pSpellInfo->uPlayerID_2 = uMessageParam; + pSpellInfo->spell_target_pid = v44; + pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + continue; + } + pBLVFace = &pIndoor->pFaces[v46]; + if ( !pBLVFace->Clickable() ) + continue; + v48 = pIndoor->pFaceExtras[pBLVFace->uFaceExtraID].uEventID == 0; + } + if ( v48 ) + continue; + pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; + pSpellInfo->uFlags &= ~0x40u; + pSpellInfo->uPlayerID_2 = uMessageParam; + pSpellInfo->spell_target_pid = v44; + pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + continue; + case UIMSG_CastSpell_Character_Big_Improvement://Preservation and blessing, treatment paralysis, hand hammers(individual upgrade) + case UIMSG_CastSpell_Character_Small_Improvement://Fate, cure + case UIMSG_HiredNPC_CastSpell: + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + if ( _50C9A0_IsEnchantingInProgress ) + { + uActiveCharacter = uMessageParam; + viewparams->bRedrawGameUI = 1; + } + else + { + if ( pGUIWindow_Settings ) + { + pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; + switch ( uMessage ) + { + case UIMSG_CastSpell_Character_Big_Improvement: + pSpellInfo->uFlags &= ~0x02u; + break; + case UIMSG_CastSpell_Character_Small_Improvement: + pSpellInfo->uFlags &= ~0x0100u; + break; + case UIMSG_HiredNPC_CastSpell: + pSpellInfo->uFlags &= ~0x0200u; + break; + } + pSpellInfo->uPlayerID_2 = uMessageParam; + pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pEventTimer->Resume(); + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + } + } + continue; + case UIMSG_BF: + __debugbreak(); + dword_50CDC8 = 1; + sub_42FBDD(); + SaveGame(1, 0); + strcpy(pCurrentMapName, pMapStats->pInfos[uHouse_ExitPic].pFilename); + dword_6BE364_game_settings_1 |= GAME_SETTINGS_0001; + uGameState = GAME_STATE_CHANGE_LOCATION; + //v53 = p2DEvents_minus1_::30[26 * (unsigned int)ptr_507BC0->ptr_1C]; + v53 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1]._quest_related; + if ( v53 < 0 ) + { + v54 = abs(v53) - 1; + _5B65B8_npcdata_hiword_house_or_other = 0; + dword_5B65BC = 0; + v55 = dword_4E4560[v54]; + _5B65AC_npcdata_fame_or_other = dword_4E4578[v54]; + v56 = dword_4E4590[v54]; + v57 = dword_4E45A8[v54]; + _5B65A8_npcdata_uflags_or_other = v55; + _5B65B4_npcdata_loword_house_or_other = v57; + _5B65B0_npcdata_rep_or_other = v56; + dword_5B65C0 = v55 | _5B65AC_npcdata_fame_or_other | v56 | v57; + } + HouseDialogPressCloseBtn(); + //goto LABEL_434; + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + { + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0; + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + ++pMessageQueue_50CBD0->uNumMessages; + }*/ + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0); + continue; + + case UIMSG_OnCastTownPortal: + pAudioPlayer->StopChannels(-1, -1); + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, WINDOW_TownPortal, (char *)uMessageParam); + continue; + + case UIMSG_OnCastLloydsBeacon: + pAudioPlayer->StopChannels(-1, -1); + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, WINDOW_LloydsBeacon, 0); + continue; + + case UIMSG_LloydsBeacon_FlippingBtn: + bRecallingBeacon = uMessageParam; + v127 = uMessageParam + 204; + pAudioPlayer->PlaySound((SoundID)v127, 0, 0, -1, 0, 0, 0, 0); + continue; + case UIMSG_HintBeaconSlot: + if ( !pGUIWindow_CurrentMenu ) + continue; + pPlayer = pPlayers[_506348_current_lloyd_playerid + 1]; + uNumSeconds = (unsigned int)&pPlayer->pInstalledBeacons[uMessageParam]; + if ( bRecallingBeacon ) + { + if ( !*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels ) ) + continue; + v173 = pMapStats->pInfos[pMapStats->sub_410D99_get_map_index(pPlayer->pInstalledBeacons[uMessageParam].SaveFileID)].pName; + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[474], v173);// "Recall to %s" + GameUI_SetFooterString(pTmpBuf.data()); + continue; + } + pMapNum = pMapStats->GetMapInfo(pCurrentMapName); + pMapName = "Not in Map Stats"; + if ( pMapNum ) + pMapName = pMapStats->pInfos[pMapNum].pName; + if ( !*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels ) || !pMapNum ) + { + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[476], pMapName);// "Set to %s" + GameUI_SetFooterString(pTmpBuf.data()); + continue; + } + v174 = pMapStats->pInfos[pMapStats->sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName; + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[475], (unsigned int)pMapName, v174);// "Set %s over %s" + GameUI_SetFooterString(pTmpBuf.data()); + continue; + case UIMSG_CloseAfterInstallBeacon: + dword_50CDC8 = 1; + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) + continue; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + ++pMessageQueue_50CBD0->uNumMessages;*/ + continue; + case UIMSG_InstallBeacon: + pPlayer9 = pPlayers[_506348_current_lloyd_playerid + 1]; + if ( !pPlayer9->pInstalledBeacons[uMessageParam].uBeaconTime && bRecallingBeacon ) + continue; + byte_506360 = 1; + pPlayer9->CanCastSpell(uRequiredMana); + if ( pParty->bTurnBasedModeOn ) + { + v60 = sRecoveryTime; + pParty->pTurnBasedPlayerRecoveryTimes[_506348_current_lloyd_playerid] = sRecoveryTime; + pPlayer9->SetRecoveryTime(v60); + pTurnEngine->ApplyPlayerAction(); + } + else + { + pPlayer9->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)sRecoveryTime * 2.133333333333333)); + } + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[lloyds_beacon_spell_id], 0, 0, -1, 0, lloyds_beacon_sound_id, 0, 0); + if ( bRecallingBeacon ) + { + if ( _stricmp(pCurrentMapName, (const char *)&pGames_LOD->pSubIndices[pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID]) ) + { + SaveGame(1, 0); + OnMapLeave(); + strcpy(pCurrentMapName, (const char *)&pGames_LOD->pSubIndices[pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID]); + dword_6BE364_game_settings_1 |= GAME_SETTINGS_0001; + uGameState = GAME_STATE_CHANGE_LOCATION; + _5B65A8_npcdata_uflags_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X; + _5B65AC_npcdata_fame_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y; + _5B65B0_npcdata_rep_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z; + _5B65B4_npcdata_loword_house_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X; + _5B65B8_npcdata_hiword_house_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y; + dword_5B65C0 = 1; + } + else + { + pParty->vPosition.x = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X; + pParty->vPosition.y = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y; + pParty->vPosition.z = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z; + pParty->uFallStartY = pParty->vPosition.z; + pParty->sRotationY = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X; + pParty->sRotationX = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y; + } + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0); + pBooksWindow->Release(); + pGUIWindow_CurrentMenu->Release(); + pBooksWindow = 0; + pGUIWindow_CurrentMenu = 0; + } + else + { + sprintf(a1, "data\\lloyd%d%d.pcx", _506348_current_lloyd_playerid + 1, uMessageParam + 1); + pRenderer->SaveScreenshot(a1, 92, 68); + LoadThumbnailLloydTexture(uMessageParam, _506348_current_lloyd_playerid + 1); + pPlayer9->pInstalledBeacons[uMessageParam].uBeaconTime = pParty->uTimePlayed + (signed __int64)((double)(lloyds_beacon_spell_level << 7) * 0.033333335); + pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X = pParty->vPosition.x; + pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y = pParty->vPosition.y; + pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z = pParty->vPosition.z; + pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X = LOWORD(pParty->sRotationY); + pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y = LOWORD(pParty->sRotationX); + if ( (signed int)pGames_LOD->uNumSubDirs / 2 <= 0 ) + continue; + for ( thisg = 0; thisg < (signed int)pGames_LOD->uNumSubDirs / 2; ++thisg ) + { + if ( !_stricmp(pGames_LOD->pSubIndices[thisg].pFilename, pCurrentMapName) ) + pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID = thisg; + } + } + continue; + case UIMSG_ClickTownInTP: + if ( uMessageParam ) + { + switch ( uMessageParam ) + { + case 1: + v63 = 208; + break; + case 2: + v63 = 207; + break; + case 3: + v63 = 211; + break; + case 4: + v63 = 209; + break; + default: + if ( uMessageParam != 5 ) + { +LABEL_486: + SaveGame(1, 0); + v64 = pMapStats->GetMapInfo(pCurrentMapName); + v65 = uMessageParam; + if ( v64 == TownPortalList[uMessageParam].uMapInfoID ) + { + pParty->vPosition.x = TownPortalList[v65].pos.x; + pParty->vPosition.y = TownPortalList[v65].pos.y; + pParty->vPosition.z = TownPortalList[v65].pos.z; + pParty->uFallStartY = pParty->vPosition.z; + pParty->sRotationY = TownPortalList[v65].rot_y; + pParty->sRotationX = TownPortalList[v65].rot_x; + } + else + { + SaveGame(1, 0); + OnMapLeave(); + dword_6BE364_game_settings_1 |= GAME_SETTINGS_0001; + uGameState = GAME_STATE_CHANGE_LOCATION; + strcpy(pCurrentMapName, pMapStats->pInfos[TownPortalList[uMessageParam].uMapInfoID].pFilename); + dword_5B65C0 = 1; + _5B65A8_npcdata_uflags_or_other = TownPortalList[uMessageParam].pos.x; + _5B65AC_npcdata_fame_or_other = TownPortalList[uMessageParam].pos.y; + _5B65B0_npcdata_rep_or_other = TownPortalList[uMessageParam].pos.z; + v66 = TownPortalList[uMessageParam].rot_x; + _5B65B4_npcdata_loword_house_or_other = TownPortalList[uMessageParam].rot_y; + _5B65B8_npcdata_hiword_house_or_other = v66; + Actor::InitializeActors(); + } + v67 = (char*)pGUIWindow_CurrentMenu->Hint; + if ( v67 ) + *((int *)v67 + 17) = 1; + else + pParty->pPlayers[(unsigned __int8)town_portal_caster_id].CanCastSpell(0x14u); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + { + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0; + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + ++pMessageQueue_50CBD0->uNumMessages; + }*/ + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0); + continue; + } + v63 = 210; + break; + } + } + else + { + v63 = 206; + } + if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v63) ) + return; + goto LABEL_486; + case UIMSG_HintTownPortal: + if ( uMessageParam ) + { + switch ( uMessageParam ) + { + case 1: + v68 = 208; + break; + case 2: + v68 = 207; + break; + case 3: + v68 = 211; + break; + case 4: + v68 = 209; + break; + default: + if ( uMessageParam != 5 ) + //goto LABEL_506; + { + if ( uMessageParam ) + { + switch ( uMessageParam ) + { + case 1: + v69 = pMapStats->pInfos[4].pName; + break; + case 2: + v69 = pMapStats->pInfos[3].pName; + break; + case 3: + v69 = pMapStats->pInfos[10].pName; + break; + case 4: + v69 = pMapStats->pInfos[7].pName; + break; + default: + if ( uMessageParam != 5 ) + { + __debugbreak(); // warning C4700: uninitialized local variable 'v200' used + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[35], v200); + GameUI_SetFooterString(pTmpBuf.data()); + continue; + } + v69 = pMapStats->pInfos[8].pName; + break; + } + } + else + { + v69 = pMapStats->pInfos[21].pName; + } + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[35], v69); + GameUI_SetFooterString(pTmpBuf.data()); + continue; + } + v68 = 210; + break; + } + } + else + { + v68 = 206; + } + if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v68) ) + { + pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar); + continue; + } +//LABEL_506: + if ( uMessageParam ) + { + switch ( uMessageParam ) + { + case 1: + v69 = pMapStats->pInfos[4].pName; + break; + case 2: + v69 = pMapStats->pInfos[3].pName; + break; + case 3: + v69 = pMapStats->pInfos[10].pName; + break; + case 4: + v69 = pMapStats->pInfos[7].pName; + break; + default: + if ( uMessageParam != 5 ) + //goto LABEL_519; + { + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[35], v200); + GameUI_SetFooterString(pTmpBuf.data()); + continue; + } + v69 = pMapStats->pInfos[8].pName; + break; + } + } + else + { + v69 = pMapStats->pInfos[21].pName; + } + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[35], v69); + GameUI_SetFooterString(pTmpBuf.data()); + continue; + case UIMSG_ShowFinalWindow: + sprintfex(pFinalMessage.data(), "%s\n \n%s\n \n%s", pGlobalTXT_LocalizationStrings[151],// "Congratulations Adventurer." + pGlobalTXT_LocalizationStrings[118],// "We hope that you've enjoyed playing Might and Magic VII as much as we did making it. We have saved this screen as MM7_WIN.PCX in your MM7 directory. You can print it out as proof of your accomplishment." + pGlobalTXT_LocalizationStrings[167]);// "- The Might and Magic VII Development Team." + ModalWindow(pFinalMessage.data(), UIMSG_OnFinalWindowClose); + uGameState = GAME_STATE_FINAL_WINDOW; + continue; + case UIMSG_OnFinalWindowClose: + __debugbreak(); + uGameState = GAME_STATE_PLAYING; + strcpy((char *)pKeyActionMap->pPressedKeysBuffer, "2"); + __debugbreak(); // missed break/continue? + case UIMSG_DD: + __debugbreak(); + sprintf(pTmpBuf.data(), "%s", pKeyActionMap->pPressedKeysBuffer); + memcpy(&v216, txt_file_frametable_parser(pKeyActionMap->pPressedKeysBuffer, &v218), sizeof(v216)); + if ( v216.uPropCount == 1 ) + { + pNPCData4 = (NPCData *)((signed int)pGames_LOD->uNumSubDirs / 2); + v70 = atoi(v216.pProperties[0]); + if ( v70 <= 0 || v70 >= 77 ) + continue; + v71 = v70; + strcpy(Str2, pMapStats->pInfos[v70].pFilename); + pNPCData3 = 0; + if ( (signed int)pNPCData4 > 0 ) + { + thish = 0; + do + { + if ( !_stricmp(pGames_LOD->pSubIndices[thish].pFilename, Str2) ) + break; + ++thish; + pNPCData3 = (NPCData *)((char *)pNPCData3 + 1); + } + while ( (signed int)pNPCData3 < (signed int)pNPCData4 ); + if ( (signed int)pNPCData3 < (signed int)pNPCData4 ) + { + strcpy(pCurrentMapName, pGames_LOD->pSubIndices[(int)pNPCData3].pFilename); + dword_6BE364_game_settings_1 |= GAME_SETTINGS_0001; + uGameState = GAME_STATE_CHANGE_LOCATION; + OnMapLeave(); + continue; + } + } + sprintf(Str2, "No map found for %s", pMapStats->pInfos[v71].pName); + v73 = Str2; + } + else + { + if ( v216.uPropCount != 3 ) + continue; + v74 = atoi(v216.pProperties[0]); + thisi = atoi(v216.pProperties[1]); + v75 = atoi(v216.pProperties[2]); + v76 = v75; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + if ( pIndoor->GetSector(v74, thisi, v75) ) + { + v77 = thisi; + pParty->vPosition.x = v74; + pParty->vPosition.y = v77; + pParty->vPosition.z = v76; + pParty->uFallStartY = v76; + continue; + } + } + else + { + if ( v74 > -32768 ) + { + if ( v74 < 32768 ) + { + v77 = thisi; + if ( thisi > -32768 ) + { + if ( thisi < 32768 && v76 >= 0 && v76 < 10000 ) + { + pParty->vPosition.x = v74; + pParty->vPosition.y = v77; + pParty->vPosition.z = v76; + pParty->uFallStartY = v76; + continue; + } + } + } + } + } + pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0); + v73 = "Can't jump to that location!"; + } + ShowStatusBarString(v73, 6u); + continue; + case UIMSG_CastQuickSpell: + if ( bUnderwater == 1 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[652], 2);// "You can not do that while you are underwater!" + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); + continue; + } + if ( !uActiveCharacter || (pPlayer2 = pPlayers[uActiveCharacter], pPlayer2->uTimeToRecovery) ) + continue; + _42777D_CastSpell_UseWand_ShootArrow(pPlayer2->uQuickSpell, uActiveCharacter - 1, 0, 0, uActiveCharacter); + continue; + case UIMSG_CastSpell_Monster_Improvement: + case UIMSG_CastSpell_Shoot_Monster://FireBlow, Lightning, Ice Lightning, Swarm, + //if ( pRenderer->pRenderD3D ) + { + v81 = pGame->pVisInstance->get_picked_object_zbuf_val(); + } + /*else + { + uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v206); + pPoint2 = pMouse->GetCursorPos(&v201); + v81 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint2->y]]; + }*/ + v83 = v81; + v44 = (unsigned __int16)v81; + v84 = v83 >> 16; + if ( PID_TYPE(v44) != 3 || v84 >= 5120 ) + continue; + pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; + if ( uMessage == UIMSG_CastSpell_Shoot_Monster ) + { + pSpellInfo->uFlags &= ~0x08; + } + else + { + if ( uMessage == UIMSG_CastSpell_Monster_Improvement ) + pSpellInfo->uFlags &= ~0x0100u; + else + pSpellInfo->uFlags &= ~0x0200u; + } + pSpellInfo->uPlayerID_2 = uMessageParam; + pSpellInfo->spell_target_pid = v44; + pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + continue; + case UIMSG_1C: + __debugbreak(); + if ( !uActiveCharacter || pCurrentScreen ) + continue; + ptr_507BC8 = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_68, uMessageParam, 0); + pCurrentScreen = SCREEN_19; + pEventTimer->Pause(); + continue; + case UIMSG_STEALFROMACTOR: + if ( !uActiveCharacter ) + continue; + if ( pParty->bTurnBasedModeOn != 1 ) + { + if ( pActors[uMessageParam].uAIState == 5 ) + pActors[uMessageParam].LootActor(); + else + Actor::StealFrom(uMessageParam); + continue; + } + if ( pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_MOVEMENT ) + continue; + if ( !(pTurnEngine->field_18 & TE_HAVE_PENDING_ACTIONS) ) + { + if ( pActors[uMessageParam].uAIState == 5 ) + pActors[uMessageParam].LootActor(); + else + Actor::StealFrom(uMessageParam); + } + continue; + + case UIMSG_Attack: + if ( !uActiveCharacter ) + continue; + if ( pParty->bTurnBasedModeOn != 1 ) + { + Player::_42ECB5_PlayerAttacksActor(); + continue; + } + if ( pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_MOVEMENT ) + continue; + if ( !(pTurnEngine->field_18 & TE_HAVE_PENDING_ACTIONS) ) + Player::_42ECB5_PlayerAttacksActor(); + continue; + case UIMSG_ExitRest: + GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn, (int)pButton_RestUI_Exit, pGlobalTXT_LocalizationStrings[81]);// "Exit Rest" + continue; + case UIMSG_Wait5Minutes: + if ( dword_506F14 == 2 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!" + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); + continue; + } + GUIWindow::Create(pButton_RestUI_Wait5Minutes->uX, pButton_RestUI_Wait5Minutes->uY, 0, 0, WINDOW_PressedButton2, + (int)pButton_RestUI_Wait5Minutes, pGlobalTXT_LocalizationStrings[238]);// "Wait 5 Minutes" + dword_506F14 = 1; + _506F18_num_minutes_to_sleep = 5; + continue; + case UIMSG_Wait1Hour: + if ( dword_506F14 == 2 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!" + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); + continue; + } + GUIWindow::Create(pButton_RestUI_Wait1Hour->uX, pButton_RestUI_Wait1Hour->uY, 0, 0, WINDOW_PressedButton2, + (int)pButton_RestUI_Wait1Hour, pGlobalTXT_LocalizationStrings[239]);// "Wait 1 Hour" + dword_506F14 = 1; + _506F18_num_minutes_to_sleep = 60; + continue; + case UIMSG_RentRoom: + dword_506F14 = 2; + RestUI_Load(); + v86 = 60 * (_494820_training_time(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute; + _506F18_num_minutes_to_sleep = v86; + if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 ) // 107 = Emerald Isle tavern + _506F18_num_minutes_to_sleep = v86 + 12 * 60; + dword_506F14 = 2; + pParty->RestAndHeal(); + pParty->days_played_without_rest = 0; + pParty->pPlayers[3].SetAsleep(1); + pParty->pPlayers[2].SetAsleep(1); + pParty->pPlayers[1].SetAsleep(1); + pParty->pPlayers[0].SetAsleep(1); + continue; + case UIMSG_RestWindow: + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + if ( pCurrentScreen ) + continue; + if ( CheckActors_proximity() ) + { + if ( pParty->bTurnBasedModeOn == 1 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!" + continue; + } + v88 = pGlobalTXT_LocalizationStrings[480];// "There are hostile enemies near!" + if ( pParty->uFlags & 0x88 ) + v88 = pGlobalTXT_LocalizationStrings[479];// "You can't rest here!" + ShowStatusBarString(v88, 2); + if ( !uActiveCharacter ) + continue; + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)13, 0); + continue; + } + if ( pParty->bTurnBasedModeOn == 1 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!" + continue; + } + if ( !(pParty->uFlags & 0x88) ) + { + RestUI_Load(); + continue; + } + if ( pParty->bTurnBasedModeOn == 1 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!" + continue; + } + v88 = pGlobalTXT_LocalizationStrings[480];// "There are hostile enemies near!" + if ( pParty->uFlags & 0x88 ) + v88 = pGlobalTXT_LocalizationStrings[479];// "You can't rest here!" + ShowStatusBarString(v88, 2u); + if ( !uActiveCharacter ) + continue; + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)13, 0); + continue; + case UIMSG_Rest8Hour: + if ( dword_506F14 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!" + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); + continue; + } + if ( pParty->uNumFoodRations < uRestUI_FoodRequiredToRest ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[482], 2u);// "You don't have enough food to rest" + if ( uActiveCharacter && pPlayers[uActiveCharacter]->CanAct() ) + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_108, 0); + } + else + { + pParty->pPlayers[3].pConditions[Condition_Sleep] = pParty->uTimePlayed; + pParty->pPlayers[2].pConditions[Condition_Sleep] = pParty->uTimePlayed; + pParty->pPlayers[1].pConditions[Condition_Sleep] = pParty->uTimePlayed; + pParty->pPlayers[0].pConditions[Condition_Sleep] = pParty->uTimePlayed; + v90 = pMapStats->GetMapInfo(pCurrentMapName); + if ( !v90 ) + v90 = rand() % (signed int)pMapStats->uNumMaps + 1; + pMapInfo = &pMapStats->pInfos[v90]; + if ( rand() % 100 + 1 <= pMapInfo->Encounter_percent ) + { + v91 = rand() % 100; + v92 = pMapInfo->EncM1percent; + v93 = v91 + 1; + if ( v93 > v92 ) + pNPCData4 = (NPCData *)((v93 > v92 + pMapInfo->EncM2percent) + 2); + else + pNPCData4 = (NPCData *)1; + if ( !_45063B_spawn_some_monster(pMapInfo, (int)pNPCData4) ) + pNPCData4 = 0; + if ( pNPCData4 ) + { + pPlayerNum = rand() % 4; + pParty->pPlayers[pPlayerNum].pConditions[Condition_Sleep] = 0; + v95 = rand(); + Rest(v95 % 6 + 60); + _506F18_num_minutes_to_sleep = 0; + dword_506F14 = 0; + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + { + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + ++pMessageQueue_50CBD0->uNumMessages; + }*/ + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[481], 2);// "Encounter!" + pAudioPlayer->PlaySound((SoundID)227, 0, 0, -1, 0, 0, 0, 0); + continue; + } + } + Party::TakeFood(uRestUI_FoodRequiredToRest); + _506F18_num_minutes_to_sleep = 480; + dword_506F14 = 2; + pParty->RestAndHeal(); + pParty->days_played_without_rest = 0; + pParty->pPlayers[3].SetAsleep(1); + pParty->pPlayers[2].SetAsleep(1); + pParty->pPlayers[1].SetAsleep(1); + pParty->pPlayers[0].SetAsleep(1); + } + continue; + case UIMSG_AlreadyResting: + if ( dword_506F14 == 2 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!" + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); + continue; + } + GUIWindow::Create(pButton_RestUI_WaitUntilDawn->uX, pButton_RestUI_WaitUntilDawn->uY, 0, 0, WINDOW_PressedButton2, + (int)pButton_RestUI_WaitUntilDawn, pGlobalTXT_LocalizationStrings[237]);// "Wait until Dawn" + v97 = _494820_training_time(pParty->uCurrentHour); + dword_506F14 = 1; + _506F18_num_minutes_to_sleep = 60 * v97 - pParty->uCurrentMinute; + continue; + case UIMSG_HintSelectRemoveQuickSpellBtn: + if ( quick_spell_at_page && byte_506550 ) + { + v173 = pSpellStats->pInfos[quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage].pName; + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[483], v173); + } + else + { + if ( pPlayers[uActiveCharacter]->uQuickSpell ) + v177 = pGlobalTXT_LocalizationStrings[584];// "Click here to remove your Quick Spell" + else + v177 = pGlobalTXT_LocalizationStrings[484];// "Select a spell then click here to set a QuickSpell" + strcpy(pTmpBuf.data(), v177); + } + GameUI_SetFooterString(pTmpBuf.data()); + continue; + case UIMSG_SPellbook_ShowHightlightedSpellInfo: + if ( !uActiveCharacter || (uNumSeconds = (unsigned int)pPlayers[uActiveCharacter], + !*(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + 6734) + uMessageParam + 402)) ) + continue; + if ( sub_4637E0_is_there_popup_onscreen() ) + dword_507B00_spell_info_to_draw_in_popup = uMessageParam + 1; + v98 = *(char *)(uNumSeconds + 6734); + if ( quick_spell_at_page - 1 == uMessageParam ) + { + v178 = pSpellStats->pInfos[uMessageParam + 11 * v98 + 1].pName; + v161 = pGlobalTXT_LocalizationStrings[485]; + } + else + { + v178 = pSpellStats->pInfos[uMessageParam + 11 * v98 + 1].pName; + v161 = pGlobalTXT_LocalizationStrings[486]; + } + sprintfex(pTmpBuf.data(), v161, v178); + GameUI_SetFooterString(pTmpBuf.data()); + continue; + case UIMSG_ClickInstallRemoveQuickSpellBtn: + GUIWindow::Create(pBtn_InstallRemoveSpell->uX, pBtn_InstallRemoveSpell->uY, 0, 0, WINDOW_PressedButton2, (int)pBtn_InstallRemoveSpell, 0); + if ( !uActiveCharacter ) + continue; + pPlayer10 = pPlayers[uActiveCharacter]; + if ( !byte_506550 || !quick_spell_at_page ) + { + pPlayer10->uQuickSpell = 0; + quick_spell_at_page = 0; + pAudioPlayer->PlaySound((SoundID)203, 0, 0, -1, 0, 0, 0, 0); + continue; + } + pPlayers[uActiveCharacter]->uQuickSpell = quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage; + AA1058_PartyQuickSpellSound[uActiveCharacter - 1].AddPartySpellSound(pPlayers[uActiveCharacter]->uQuickSpell, uActiveCharacter); + if ( uActiveCharacter ) + pPlayer10->PlaySound(SPEECH_12, 0); + byte_506550 = 0; + continue; + case UIMSG_SpellBook_PressTab://ïåðåëèñòûâàíèå ñòðàíèö êëàâèøåé Tab + { + if ( !uActiveCharacter ) + continue; + int skill_count = 0; + uAction = 0; + for ( uint i = 0; i < 9; i++ ) + { + if ( pPlayers[uActiveCharacter]->pActiveSkills[PLAYER_SKILL_FIRE + i] ) + { + if ( pPlayers[uActiveCharacter]->lastOpenedSpellbookPage == i ) + uAction = skill_count; + v217[skill_count++] = i; + } + } + if ( !skill_count )//íåò ñêèëëîâ + pAudioPlayer->PlaySound((SoundID)(rand() % 2 + 204), 0, 0, -1, 0, 0, 0, 0); + else + { + if ( GetAsyncKeyState(VK_SHIFT) ) + { + --uAction; + if ( uAction < 0 ) + uAction = skill_count - 1; + } + else + { + ++uAction; + if ( uAction >= skill_count ) + uAction = 0; + } + OnCloseSpellBookPage(); + pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = LOBYTE(v217[uAction]); + pGUIWindow_CurrentMenu->OpenSpellBook(); + pAudioPlayer->PlaySound((SoundID)(rand() % 2 + 204), 0, 0, -1, 0, 0, 0, 0); + } + continue; + } + case UIMSG_OpenSpellbookPage: + if ( pTurnEngine->turn_stage == TE_MOVEMENT || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->lastOpenedSpellbookPage ) + continue; + OnCloseSpellBookPage(); + pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = uMessageParam; + pGUIWindow_CurrentMenu->OpenSpellBook(); + pAudioPlayer->PlaySound((SoundID)(rand() % 2 + 204), 0, 0, -1, 0, 0, 0, 0); + continue; + case UIMSG_SelectSpell: + { + if (pTurnEngine->turn_stage == TE_MOVEMENT) + continue; + if (!uActiveCharacter) + continue; + + // uNumSeconds = (unsigned int)pPlayers[uActiveCharacter]; + Player* player = pPlayers[uActiveCharacter]; + if (player->spellbook.pChapters[player->lastOpenedSpellbookPage].bIsSpellAvailable[uMessageParam]) + //if ( *(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + &lastOpenedSpellbookPage) + uMessageParam + 402) ) + { + if ( quick_spell_at_page - 1 == uMessageParam ) + { + pGUIWindow_CurrentMenu->Release(); + pEventTimer->Resume(); + viewparams->bRedrawGameUI = 1; + pCurrentScreen = SCREEN_GAME; + pIcons_LOD->RemoveTexturesPackFromTextureList(); + v103 = quick_spell_at_page + 11 * player->lastOpenedSpellbookPage; + /*if ( dword_50C9E8 < 40 ) + { + dword_50C9EC[3 * dword_50C9E8] = UIMSG_CastSpellFromBook; + dword_50C9EC[3 * dword_50C9E8 + 1] = v103; + dword_50C9EC[3 * dword_50C9E8 + 2] = uActiveCharacter - 1; + ++dword_50C9E8; + }*/ + pMessageQueue_50C9E8->AddGUIMessage(UIMSG_CastSpellFromBook, v103, uActiveCharacter - 1); + // pMessageQueue_50CBD0->AddGUIMessage(UIMSG_CastSpellFromBook, v103, uActiveCharacter - 1); + } + else + { + byte_506550 = 1; + quick_spell_at_page = uMessageParam + 1; + } + } + } + continue; + + case UIMSG_CastSpellFromBook: + if ( pTurnEngine->turn_stage != TE_MOVEMENT ) + _42777D_CastSpell_UseWand_ShootArrow(uMessageParam, v199, 0, 0, 0); + continue; + + case UIMSG_SpellScrollUse: + __debugbreak(); + if ( pTurnEngine->turn_stage != TE_MOVEMENT ) + _42777D_CastSpell_UseWand_ShootArrow(uMessageParam, v199, 133, 1, 0); + continue; + case UIMSG_SpellBookWindow: + if ( pTurnEngine->turn_stage == TE_MOVEMENT ) + continue; + if ( bUnderwater == true ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[652], 2);// "You can not do that while you are underwater!" + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); + } + else + { + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + if ( uActiveCharacter && !pPlayers[uActiveCharacter]->uTimeToRecovery ) + { + if ( pCurrentScreen == SCREEN_GAME ) + { + GUIWindow::Create(476, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_CastSpell, 0); + pCurrentScreen = SCREEN_SPELL_BOOK; + pEventTimer->Pause(); + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_SpellBook, 0, 0); + pAudioPlayer->PlaySound((SoundID)48, 0, 0, -1, 0, 0, 0, 0); + viewparams->field_48 = 1; + continue; + } + if ( pCurrentScreen != SCREEN_REST && pCurrentScreen != SCREEN_CHARACTERS + && (pCurrentScreen <= SCREEN_63 || pCurrentScreen > SCREEN_67) ) + { + pGUIWindow_CurrentMenu->Release(); + GUIWindow::Create(476, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_CastSpell, 0); + pCurrentScreen = SCREEN_SPELL_BOOK; + pEventTimer->Pause(); + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_SpellBook, 0, 0); + pAudioPlayer->PlaySound((SoundID)48, 0, 0, -1, 0, 0, 0, 0); + viewparams->field_48 = 1; + continue; + } + } + } + continue; + case UIMSG_QuickReference: + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + if ( pCurrentScreen ) + pGUIWindow_CurrentMenu->Release(); + ++pIcons_LOD->uTexturePacksCount; + if ( !pIcons_LOD->uNumPrevLoadedFiles ) + pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; + GUIWindow::Create(0x230u, 0x1C2u, 0, 0, WINDOW_PressedButton2, (int)pBtn_QuickReference, 0); + viewparams->bRedrawGameUI = 1; + pEventTimer->Pause(); + pAudioPlayer->StopChannels(-1, -1); + pCurrentScreen = SCREEN_QUICK_REFERENCE; + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_QuickReference, 5, 0); + papredoll_dbrds[2] = pIcons_LOD->LoadTexture("BUTTEXI1", TEXTURE_16BIT_PALETTE); + pBtn_ExitCancel = pGUIWindow_CurrentMenu->CreateButton(0x187u, 0x13Cu, 0x4Bu, 0x21u, 1, 0, UIMSG_Escape, 0, 0, + pGlobalTXT_LocalizationStrings[79],// "Exit" + pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0); //, v179); + continue; + case UIMSG_GameMenuButton: + if ( pCurrentScreen ) + { + pGUIWindow_CurrentMenu->Release(); + pEventTimer->Resume(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = 1; + } + + stru_506E40.Release(); + pRenderer->SaveScreenshot("gamma.pcx", 155, 117); + stru_506E40.LoadPCXFile("gamma.pcx", 0); + + GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_PressedButton, (int)pBtn_GameSettings, 0); +//LABEL_453: + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) + continue; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; + //goto LABEL_770; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + ++pMessageQueue_50CBD0->uNumMessages;*/ + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0); + continue; + case UIMSG_ClickAwardScrollBar: + books_page_number = 1; + if ( pMouse->GetCursorPos(&v211)->y > 178 ) + books_page_number = -1; + continue; + case UIMSG_ClickAwardsUpBtn: + GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pBtn_Up, 0); + BtnUp_flag = 1; + continue; + case UIMSG_ClickAwardsDownBtn: + GUIWindow::Create(pBtn_Down->uX, pBtn_Down->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pBtn_Down, 0); + BtnDown_flag = 1; + continue; + case UIMSG_ChangeDetaliz: + bRingsShownInCharScreen ^= 1; + pCharacterScreen_DetalizBtn->Release(); + pCharacterScreen_DollBtn->Release(); + if ( bRingsShownInCharScreen ) + { + v128 = pIcons_LOD->GetTexture(uTextureID_detaliz_close_button)->uTextureHeight; + v125 = pIcons_LOD->GetTexture(uTextureID_detaliz_close_button)->uTextureWidth; + v123 = 445; + v121 = 470; + } + else + { + v128 = 30; + v125 = 30; + v123 = 300; + v121 = 600; + } + pCharacterScreen_DetalizBtn = pGUIWindow_CurrentMenu->CreateButton(v121, v123, v125, v128, 1, 0, UIMSG_ChangeDetaliz, 0, 0, + pGlobalTXT_LocalizationStrings[64],// "Detail Toggle" + 0); + pCharacterScreen_DollBtn = pGUIWindow_CurrentMenu->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, UIMSG_ClickPaperdoll, 0, 0, "", 0); + viewparams->bRedrawGameUI = 1; + continue; + case UIMSG_ClickPaperdoll: + OnPaperdollLeftClick(); + continue; + case UIMSG_ClickStatsBtn: + pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100; + CharacterUI_ReleaseButtons(); + ReleaseAwardsScrollBar(); + GUIWindow::Create(pCharacterScreen_StatsBtn->uX, pCharacterScreen_StatsBtn->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pCharacterScreen_StatsBtn, 0); + continue; + case UIMSG_ClickSkillsBtn: + pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 101; + CharacterUI_ReleaseButtons(); + ReleaseAwardsScrollBar(); + CharacterUI_SkillsTab_CreateButtons(); + GUIWindow::Create(pCharacterScreen_SkillsBtn->uX, pCharacterScreen_SkillsBtn->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pCharacterScreen_SkillsBtn, 0); + continue; + case UIMSG_SkillUp: + pPlayer4 = pPlayers[uActiveCharacter]; + v105 = (int)&pPlayer4->pActiveSkills[uMessageParam]; + LOWORD(v2) = *(short *)v105; + uNumSeconds = v2; + if ( pPlayer4->uSkillPoints < (v2 & 0x3F) + 1 ) + { + v87 = pGlobalTXT_LocalizationStrings[488];// "You don't have enough skill points!" + } + else + { + if ( (uNumSeconds & 0x3F) < 0x3C ) + { + *(short *)v105 = uNumSeconds + 1; + pPlayer4->uSkillPoints -= pPlayer4->pActiveSkills[uMessageParam] & 0x3F; + pPlayer4->PlaySound(SPEECH_14, 0); + pAudioPlayer->PlaySound((SoundID)20001, 0, 0, -1, 0, 0, 0, 0); + continue; + } + v87 = pGlobalTXT_LocalizationStrings[487];// "You have already mastered this skill!" + } + ShowStatusBarString(v87, 2); + continue; + case UIMSG_ClickInventoryBtn: + pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; + ReleaseAwardsScrollBar(); + CharacterUI_ReleaseButtons(); + GUIWindow::Create(pCharacterScreen_InventoryBtn->uX, pCharacterScreen_InventoryBtn->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pCharacterScreen_InventoryBtn, 0); + continue; + case UIMSG_ClickExitCharacterWindowBtn: + GUIWindow::Create(pCharacterScreen_ExitBtn->uX, pCharacterScreen_ExitBtn->uY, 0, 0, WINDOW_ExitCharacterWindow, (int)pCharacterScreen_ExitBtn, 0); + continue; + case UIMSG_ClickAwardsBtn: + ReleaseAwardsScrollBar(); + CharacterUI_ReleaseButtons(); + CreateAwardsScrollBar(); + pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 102; + GUIWindow::Create(pCharacterScreen_AwardsBtn->uX, pCharacterScreen_AwardsBtn->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pCharacterScreen_AwardsBtn, 0); + FillAwardsData(); + continue; + case UIMSG_ClickBooksBtn: + switch ( uMessageParam ) + { + case 11://Page UP + BtnUp_flag = 1; + pButton = pBtn_Book_2; + break; + case 10://Page DOWN + BtnDown_flag = 1; + pButton = pBtn_Book_1; + break; + case 0://Zoom plus + pButton = pBtn_Book_1; + BtnDown_flag = 1; + break; + case 1://Zoom minus + pButton = pBtn_Book_2; + BtnUp_flag = 1; + break; + case 2://Potions + Book_PageBtn3_flag = 1; + if ( dword_506364 ) + continue; + pButton = pBtn_Book_3; + break; + case 3://fountains + Book_PageBtn4_flag = 1; + if ( dword_506364 ) + continue; + pButton = pBtn_Book_4; + break; + case 4://obelisks + Book_PageBtn5_flag = 1;//Autonotes_Obelisks_page_flag + if ( dword_506364 ) + continue; + pButton = pBtn_Book_5; + break; + case 5://seer + Book_PageBtn6_flag = 1;//Autonotes_Seer_page_flag + if ( dword_506364 ) + continue; + pButton = pBtn_Book_6; + break; + case 6://misc + pButton = pBtn_Autonotes_Misc; + Autonotes_Misc_page_flag = 1; + break; + case 7://Instructors + pButton = pBtn_Autonotes_Instructors; + Autonotes_Instructors_page_flag = 1; + break; + default: + continue; + } + GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, (char *)1); + continue; + case UIMSG_SelectCharacter: + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + GameUI_OnPlayerPortraitLeftClick(uMessageParam); + continue; + case UIMSG_ShowStatus_Funds: + v174 = (char *)pParty->uNumGoldInBank; + //v158 = pParty->uNumGold + pParty->uNumGoldInBank; + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[489], pParty->uNumGold + pParty->uNumGoldInBank, v174);// "You have %d total gold, %d in the Bank" + GameUI_SetFooterString(pTmpBuf.data()); + continue; + case UIMSG_ShowStatus_DateTime: + currHour = pParty->uCurrentHour; + uNumSeconds = 1; + if (pParty->uCurrentHour > 12 ) + { + if (pParty->uCurrentHour >= 24) + uNumSeconds = 0; + currHour = (currHour - 12); + } + else + { + if (pParty->uCurrentHour < 12) // 12:00 is PM + uNumSeconds = 0; + if (pParty->uCurrentHour == 0) + currHour = 12; + } + sprintf(pTmpBuf.data(), "%d:%02d%s %s %d %s %d", currHour, pParty->uCurrentMinute, aAMPMNames[uNumSeconds], aDayNames[pParty->uDaysPlayed % 7], + 7 * pParty->uCurrentMonthWeek + pParty->uDaysPlayed % 7 + 1, aMonthNames[pParty->uCurrentMonth], pParty->uCurrentYear); + GameUI_SetFooterString(pTmpBuf.data()); + continue; + case UIMSG_ShowStatus_Food: + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[501], pParty->uNumFoodRations); // "You have %lu food" + GameUI_SetFooterString(pTmpBuf.data()); + continue; + case UIMSG_ShowStatus_Player: + pPlayer5 = pPlayers[uMessageParam]; + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], pPlayer5->pName, pClassNames[pPlayer5->classType]);// "%s the %s" + strcat(pTmpBuf.data(), ": "); + v107 = pPlayer5->GetMajorConditionIdx(); + strcat(pTmpBuf.data(), aCharacterConditionNames[v107]); + GameUI_SetFooterString(pTmpBuf.data()); + v108 = 8 * uMessageParam - 8; + LOBYTE(v108) = v108 | 4; + pMouse->uPointingObjectID = PID(OBJECT_Player,v108); + continue; + case UIMSG_ShowStatus_ManaHP: + sprintf(pTmpBuf.data(), "%d / %d %s %d / %d %s", pPlayers[uMessageParam]->sHealth, pPlayers[uMessageParam]->GetMaxHealth(), + pGlobalTXT_LocalizationStrings[108], pPlayers[uMessageParam]->sMana, pPlayers[uMessageParam]->GetMaxMana(), + pGlobalTXT_LocalizationStrings[212]); + GameUI_SetFooterString(pTmpBuf.data()); + continue; + case UIMSG_CHEST_ClickItem: + if ( pCurrentScreen == SCREEN_CHEST_INVENTORY ) + { + pPlayers[uActiveCharacter]->OnInventoryLeftClick(); + continue; + } + Chest::OnChestLeftClick(); + continue; + case UIMSG_InventoryLeftClick: + pPlayers[uActiveCharacter]->OnInventoryLeftClick(); + continue; + case UIMSG_MouseLeftClickInGame: + /*if ( !pRenderer->pRenderD3D ) + { + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + OnGameViewportClick(); + continue; + }*/ + v115 = pMessageQueue_50CBD0->uNumMessages; + if ( !pMessageQueue_50CBD0->uNumMessages ) + { + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_MouseLeftClickInScreen, 0, 0); + /*if ( (signed int)v115 < 40 ) + //goto LABEL_769; + { + pMessageQueue_50CBD0->pMessages[v115].eType = UIMSG_MouseLeftClickInScreen; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + ++pMessageQueue_50CBD0->uNumMessages; + continue; + }*/ + continue; + } + if ( pMessageQueue_50CBD0->pMessages[0].field_8 ) + { + pMessageQueue_50CBD0->uNumMessages = 1; + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_MouseLeftClickInScreen, 0, 0); + /*v115 = v0; + pMessageQueue_50CBD0->uNumMessages = v0; + pMessageQueue_50CBD0->pMessages[v115].eType = UIMSG_MouseLeftClickInScreen; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; + //goto LABEL_771; + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + ++pMessageQueue_50CBD0->uNumMessages;*/ + continue; + } + v115 = 0; + pMessageQueue_50CBD0->uNumMessages = 0; + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_MouseLeftClickInScreen, 0, 0); + /*if ( (signed int)v115 < 40 ) + //goto LABEL_769; + { + pMessageQueue_50CBD0->pMessages[v115].eType = UIMSG_MouseLeftClickInScreen; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + ++pMessageQueue_50CBD0->uNumMessages; + continue; + }*/ + continue; + case UIMSG_MouseLeftClickInScreen://ñðàáàòûâàåò ïðè íàæàòèè íà ïðàâóþ êíîïêó ìûøè ïîñëå UIMSG_MouseLeftClickInGame + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + OnGameViewportClick(); + continue; + case UIMSG_F: + __debugbreak(); + //if ( pRenderer->pRenderD3D ) + { + LOWORD(v116) = pGame->pVisInstance->get_picked_object_zbuf_val(); + } + /*else + { + uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v209); + pPoint3 = pMouse->GetCursorPos(&v204); + v116 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint3->y]]; + }*/ + pButton2 = (GUIButton *)(unsigned __int16)v116; + GUIWindow::Create(0, 0, 0, 0, WINDOW_F, (int)pButton2, 0); + continue; + case UIMSG_54: + __debugbreak(); + pButton2 = (GUIButton *)uMessageParam; + GUIWindow::Create(0, 0, 0, 0, WINDOW_22, (int)pButton2, 0); + continue; + case UIMSG_Game_Action: + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + OnPressSpace(); + continue; + case UIMSG_ClickZoomOutBtn: + if ( pCurrentScreen ) + continue; + pParty->uFlags |= 2u; + GUIWindow::Create(519, 136, 0, 0, WINDOW_PressedButton2, (int)pBtn_ZoomOut, 0); + uNumSeconds = 131072; + v118 = 2 * viewparams->uMinimapZoom; + ++viewparams->field_28; + viewparams->uMinimapZoom *= 2; + if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor) + { + if ( (signed int)v118 > 4096 ) + { + viewparams->uMinimapZoom = 4096; + viewparams->field_28 = 12; + } + continue; + } + v119 = 2048; + if ( (signed int)v118 <= 2048 ) + { + _576E2C_current_minimap_zoom = v118; + dword_576E28 = viewparams->field_28; + break; + } + viewparams->field_28 = 11; + viewparams->uMinimapZoom = v119; + _576E2C_current_minimap_zoom = v119; + dword_576E28 = viewparams->field_28; + break; + case UIMSG_ClickZoomInBtn: + if ( pCurrentScreen ) + continue; + pParty->uFlags |= 2u; + GUIWindow::Create(574, 136, 0, 0, WINDOW_PressedButton2, (int)pBtn_ZoomIn, 0); + uNumSeconds = 32768; + v118 = (unsigned __int64)((signed __int64)(signed int)viewparams->uMinimapZoom << 15) >> 16; + --viewparams->field_28; + viewparams->uMinimapZoom = (unsigned __int64)((signed __int64)(signed int)viewparams->uMinimapZoom << 15) >> 16; + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + v119 = 512; + if ( (signed int)v118 < 512 ) + { + viewparams->field_28 = 9; + v118 = v119; + viewparams->uMinimapZoom = v119; + } + _576E2C_current_minimap_zoom = v118; + dword_576E28 = viewparams->field_28; + } + else + { + if ( (signed int)v118 < 256 ) + { + viewparams->uMinimapZoom = 256; + viewparams->field_28 = 8; + } + } + default: + continue; + } + } + } + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50C9E8->uNumMessages;//dword_50C9E8; + memcpy(pMessageQueue_50CBD0->pMessages, pMessageQueue_50C9E8->pMessages, sizeof(GUIMessage) * pMessageQueue_50C9E8->uNumMessages); + //memcpy(pMessageQueue_50CBD0->pMessages, dword_50C9EC, 12 * dword_50C9E8); + //dword_50C9E8 = 0; + + + pMessageQueue_50C9E8->uNumMessages=0; + if ( dword_50C9DC ) + { + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + { + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)dword_50C9DC; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = (int)ptr_50C9E0; + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + ++pMessageQueue_50CBD0->uNumMessages; + }*/ + pMessageQueue_50CBD0->AddGUIMessage((UIMessageType)dword_50C9DC, (int)ptr_50C9E0, 0); + dword_50C9DC = 0; + } + else + { + if ( _50C9D0_AfterEnchClickEventId > 0 ) + { + _50C9D8_AfterEnchClickEventTimeout -= pEventTimer->uTimeElapsed; + if ( _50C9D8_AfterEnchClickEventTimeout <= 0 ) + { + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + { + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)dword_50C9D0; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = dword_50C9D4; + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + ++pMessageQueue_50CBD0->uNumMessages; + }*/ + pMessageQueue_50CBD0->AddGUIMessage((UIMessageType)_50C9D0_AfterEnchClickEventId, _50C9D4_AfterEnchClickEventSecondParam, 0); + _50C9D0_AfterEnchClickEventId = 0; + _50C9D4_AfterEnchClickEventSecondParam = 0; + _50C9D8_AfterEnchClickEventTimeout = 0; + } + } + } + CastSpellInfoHelpers::_427E01_cast_spell(); +} +//----- (00435748) -------------------------------------------------------- +void GUI_MainMenuMessageProc() +{ + Player *pPlayer; // ebx@2 + void *v3; // edi@21 + signed int v4; // eax@29 +// int v5; // ecx@29 +// PLAYER_SKILL_TYPE v6; // edi@37 + GUIWindow *pWindow; // eax@56 + GUIButton *pButton; // eax@59 + int v15; // edi@70 + char v20; // dl@116 + unsigned int v21; // eax@116 + unsigned int v25; // eax@120 + unsigned int v26; // ecx@127 +// SoundID pSoundID; // [sp-2Ch] [bp-3Ch]@36 +// signed int v41; // [sp-10h] [bp-20h]@29 + int pParam; // [sp+4h] [bp-Ch]@3 + UIMessageType pUIMessageType; // [sp+8h] [bp-8h]@3 + int pSex; // [sp+Ch] [bp-4h]@3 + + if ( pMessageQueue_50CBD0->uNumMessages ) + { + pPlayer = pParty->pPlayers.data(); + do + { + int param2; + pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &pParam, ¶m2); + //auto player = &pParty->pPlayers[pParam]; + + switch (pUIMessageType) // For buttons of window MainMenu + { + case UIMSG_MainMenu_ShowPartyCreationWnd: + GUIWindow::Create(495, 172, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnNew, 0); + SetCurrentMenuID(MENU_NEWGAME); + break; + case UIMSG_MainMenu_ShowLoadWindow: + GUIWindow::Create(495, 227, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnLoad, 0); + SetCurrentMenuID(MENU_SAVELOAD); + break; + case UIMSG_ShowCredits: + GUIWindow::Create(495, 282, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnCredits, 0); + SetCurrentMenuID(MENU_CREDITS); + break; + case UIMSG_ExitToWindows: + GUIWindow::Create(495, 337, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnExit, 0); + SetCurrentMenuID(MENU_EXIT_GAME); + break; + case UIMSG_PlayerCreation_SelectAttribute: + pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) + % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; + uPlayerCreationUI_SelectedCharacter = pParam; + pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); + break; + case UIMSG_PlayerCreation_VoicePrev: + pSex = pParty->pPlayers[pParam].GetSexByVoice(); + do + { + if (pParty->pPlayers[pParam].uVoiceID == 0) + pParty->pPlayers[pParam].uVoiceID = 19; + else --pParty->pPlayers[pParam].uVoiceID; + } + while (pParty->pPlayers[pParam].GetSexByVoice() != pSex); + pButton = pCreationUI_BtnPressLeft2[pParam]; + GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, (char *)1); + pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); + pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); + break; + case UIMSG_PlayerCreation_VoiceNext: + pSex = pParty->pPlayers[pParam].GetSexByVoice(); + do + { + pParty->pPlayers[pParam].uVoiceID = (pParty->pPlayers[pParam].uVoiceID + 1) % 20; + } + while (pParty->pPlayers[pParam].GetSexByVoice() != pSex); + pButton = pCreationUI_BtnPressRight2[pParam]; + GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, (char *)1); + pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); + pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); + break; + case UIMSG_PlayerCreation_FacePrev: + //pPlayer = &pParty->pPlayers[pParam]; + if (!pParty->pPlayers[pParam].uCurrentFace) + pParty->pPlayers[pParam].uCurrentFace = 19; + else + pParty->pPlayers[pParam].uCurrentFace -= 1; + pParty->pPlayers[pParam].uVoiceID = pParty->pPlayers[pParam].uCurrentFace; + pParty->pPlayers[pParam].SetInitialStats(); + pParty->pPlayers[pParam].SetSexByVoice(); + pParty->pPlayers[pParam].RandomizeName(); + v25 = pParam; + pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) + % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; + uPlayerCreationUI_SelectedCharacter = v25; + GUIWindow::Create(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0, WINDOW_PressedButton, (int)pCreationUI_BtnPressLeft[v25], (char *)1); + pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0.0, 0); + pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); + break; + case UIMSG_PlayerCreation_FaceNext: + //pPlayer = &pParty->pPlayers[pParam]; + v20 = (char)((int)pParty->pPlayers[pParam].uCurrentFace + 1) % 20; + pParty->pPlayers[pParam].uCurrentFace = v20; + pParty->pPlayers[pParam].uVoiceID = v20; + pParty->pPlayers[pParam].SetInitialStats(); + pParty->pPlayers[pParam].SetSexByVoice(); + pParty->pPlayers[pParam].RandomizeName(); + v21 = pParam; + pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) + % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; + uPlayerCreationUI_SelectedCharacter = v21; + GUIWindow::Create(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, WINDOW_PressedButton, (int)pCreationUI_BtnPressRight[v21], (char *)1); + pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); + pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); + break; + case UIMSG_PlayerCreationClickPlus: + GUIWindow::Create(613, 393, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnPlus, (char *)1); + pPlayer[uPlayerCreationUI_SelectedCharacter].IncreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7); + pAudioPlayer->PlaySound((SoundID)20, 0, 0, -1, 0, 0, 0, 0); + break; + case UIMSG_PlayerCreationClickMinus: + GUIWindow::Create(523, 393, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnMinus, (char *)1); + pPlayer[uPlayerCreationUI_SelectedCharacter].DecreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7); + pAudioPlayer->PlaySound((SoundID)23, 0, 0, -1, 0, 0, 0, 0); + break; + case UIMSG_PlayerCreationSelectActiveSkill: + if ( pPlayer[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(3) == 37 ) + pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].pActiveSkills[pPlayer[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(pParam + 4)] = 1; + pAudioPlayer->PlaySound(SOUND_24, 0, 0, -1, 0, 0, 0, 0); + break; + case UIMSG_PlayerCreationSelectClass: + pPlayer[uPlayerCreationUI_SelectedCharacter].Reset((PLAYER_CLASS_TYPE)pParam); + pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); + break; + case UIMSG_PlayerCreationClickOK: + GUIWindow::Create(580, 431, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnOK, 0); + if ( PlayerCreation_GetUnspentAttributePointCount() || !PlayerCreation_Choose4Skills() ) + GameUI_Footer_TimeLeft = GetTickCount() + 4000; + else + uGameState = GAME_STATE_STARTING_NEW_GAME; + break; + case UIMSG_PlayerCreationClickReset: + GUIWindow::Create(527, 431, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnReset, 0); + pParty->Reset(); + break; + case UIMSG_PlayerCreationRemoveUpSkill: + v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem; + pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v4 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; + if ( pPlayer[pParam].GetSkillIdxByOrder(2) != 37 )//37 - None(Íåò) + pParty->pPlayers[pParam].pActiveSkills[pPlayer[pParam].GetSkillIdxByOrder(2)] = 0; + break; + case UIMSG_PlayerCreationRemoveDownSkill: + v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem; + pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v4 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; + if ( pPlayer[pParam].GetSkillIdxByOrder(3) != 37 )//37 - None(Íåò) + pParty->pPlayers[pParam].pActiveSkills[pPlayer[pParam].GetSkillIdxByOrder(3)] = 0; + break; + case UIMSG_PlayerCreationChangeName: + pAudioPlayer->PlaySound((SoundID)24, 0, 0, -1, 0, 0, 0, 0); + v3 = (void *)pParam; + uPlayerCreationUI_SelectedCharacter = pParam; + pKeyActionMap->EnterText(0, 15, pGUIWindow_CurrentMenu); + pGUIWindow_CurrentMenu->ptr_1C = v3; + break; + case UIMSG_ChangeGameState: + uGameState = GAME_FINISHED; + break; + case UIMSG_ChangeCursor: + pMouse->SetCursorBitmap("MICON2"); + break; + case UIMSG_3A: + SetCurrentMenuID(MENU_DebugBLVLevel); + break; + case UIMSG_LoadGame: + if (!pSavegameUsedSlots[uLoadGameUI_SelectedSlot]) + break; + SetCurrentMenuID(MENU_LoadingProcInMainMenu); + break; + case UIMSG_SelectLoadSlot: + //main menu save/load wnd clicking on savegame lines + if (pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) + pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_NONE); + if ( pCurrentScreen != SCREEN_SAVEGAME || uLoadGameUI_SelectedSlot != pParam + pSaveListPosition ) + { + //load clicked line + v26 = pParam + pSaveListPosition; + if ( dword_6BE138 == pParam + pSaveListPosition ) + { + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_SaveLoadBtn, 0, 0); + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_LoadGame, 0, 0); + } + uLoadGameUI_SelectedSlot = v26; + dword_6BE138 = v26; + } + else + { + //typing in the line + pKeyActionMap->EnterText(0, 19, pGUIWindow_CurrentMenu); + strcpy(pKeyActionMap->pPressedKeysBuffer, pSavegameHeader[uLoadGameUI_SelectedSlot].pName); + pKeyActionMap->uNumKeysPressed = strlen(pKeyActionMap->pPressedKeysBuffer); + } + break; + case UIMSG_SaveLoadBtn: + GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 241, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, WINDOW_SaveLoadBtn, (int)pBtnLoadSlot, 0); + break; + case UIMSG_DownArrow: + ++pSaveListPosition; + if ( pSaveListPosition >= pParam ) + pSaveListPosition = pParam - 1; + if ( pSaveListPosition < 1 ) + pSaveListPosition = 0; + pWindow = pGUIWindow_CurrentMenu; + GUIWindow::Create(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 323, 0, 0, WINDOW_PressedButton2, (int)pBtnDownArrow, 0); + break; + case UIMSG_Cancel: + GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 350, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, WINDOW_LoadGame_CancelBtn, (int)pBtnCancel, 0); + break; + case UIMSG_ArrowUp: + --pSaveListPosition; + if ( pSaveListPosition < 0 ) + pSaveListPosition = 0; + pWindow = pGUIWindow_CurrentMenu; + GUIWindow::Create(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 197, 0, 0, WINDOW_PressedButton2, (int)pBtnArrowUp, 0); + break; + case UIMSG_AD: + GUIWindow::Create(pMainMenu_BtnNew->uX, pMainMenu_BtnNew->uY, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnNew, 0); + SetCurrentMenuID(MENU_LoadingProcInMainMenu); + break; + case UIMSG_AE: + GUIWindow::Create(pMainMenu_BtnExit->uX, pMainMenu_BtnExit->uY, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnExit, 0); + SetCurrentMenuID(MENU_DebugBLVLevel); + break; + case UIMSG_Escape: + if ( pModalWindow ) + { + ModalWindow_Release(); + break; + } + if ( !(dword_6BE364_game_settings_1 & GAME_SETTINGS_4000)) + break; + v15 = 1; + pMediaPlayer->bStopBeforeSchedule = 1; + viewparams->bRedrawGameUI = 1; + viewparams->field_48 = 1; + if ( GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_MMT_MAIN_MENU + || GetCurrentMenuID() == MENU_CREATEPARTY || GetCurrentMenuID() == MENU_NAMEPANELESC ) + { + //if ( pCurrentScreen == SCREEN_VIDEO ) + //pVideoPlayer->FastForwardToFrame(pVideoPlayer->pResetflag); + if (GetCurrentMenuID() == MENU_NAMEPANELESC) //èç ïàíåëè èçìåíåíèÿ èìåíè + { + SetCurrentMenuID(MENU_CREATEPARTY);//â îêíî ñîçäàíèÿ ãðóïïû + break; + } + if (GetCurrentMenuID() == MENU_CREDITSPROC) //èç îêíà Ñîçäàòåëè + { + SetCurrentMenuID(MENU_CREDITSCLOSE);//â çàêðûòèå Ñîçäàòåëè + break; + } + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ChangeGameState, 0, 0); + break; + } + if ( GetCurrentMenuID() == MENU_CREDITSPROC && !pCurrentScreen ) + { + //if ( pCurrentScreen == SCREEN_VIDEO ) + //pVideoPlayer->FastForwardToFrame(pVideoPlayer->pResetflag); + if (GetCurrentMenuID() == MENU_NAMEPANELESC) + { + SetCurrentMenuID(MENU_CREATEPARTY); + break; + } + if (GetCurrentMenuID() == MENU_CREDITSPROC) + { + SetCurrentMenuID(MENU_CREDITSCLOSE); + break; + } + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ChangeGameState, 0, 0); + break; + } + if ( pCurrentScreen == SCREEN_LOADGAME ) + { + pIcons_LOD->RemoveTexturesPackFromTextureList(); + //crt_deconstruct_ptr_6A0118(); + pTexture_PCX.Release(); + pTexture_PCX.Load("title.pcx", 0); + SetCurrentMenuID(MENU_MAIN); + v15 = 1; + pGUIWindow_CurrentMenu->Release(); + pGUIWindow2->Release(); + pGUIWindow2 = 0; + pEventTimer->Resume(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = v15; + break; + } + if ( pCurrentScreen == SCREEN_VIDEO ) + { + //pVideoPlayer->Unload(); + } + else + { + if ( pCurrentScreen != SCREEN_1B ) + { + pGUIWindow_CurrentMenu->Release(); + pGUIWindow2->Release(); + pGUIWindow2 = 0; + pEventTimer->Resume(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = v15; + break; + } + //VideoPlayer::dtor(); + } + break; + default: + break; + } + } + while ( pMessageQueue_50CBD0->uNumMessages ); + } +} + + + +//----- (0042FBDD) -------------------------------------------------------- +void sub_42FBDD() +{ + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + pRenderer->DrawTextureTransparent(pBtn_YES->uX, pBtn_YES->uY, pBtn_YES->pTextures[0]); + pRenderer->Present(); +} + +//----- (0042FC15) -------------------------------------------------------- +void CloseWindowBackground() +{ + pAudioPlayer->PlaySound(SOUND_Button2, -2, 0, -1, 0, 0, 0, 0); + pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pBtn_ExitCancel->pTextures[0]); + pRenderer->Present(); +} + + +//----- (0046BDC0) -------------------------------------------------------- +void UpdateUserInput_and_MapSpecificStuff() +{ + if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0080_SKIP_USER_INPUT_THIS_FRAME) + { + dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0080_SKIP_USER_INPUT_THIS_FRAME; + return; + } + + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + BLV_UpdateUserInputAndOther(); + else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) + ODM_UpdateUserInputAndOther(); + + area_of_effect__damage_evaluate(); +} + +//----- (004646F0) -------------------------------------------------------- +void PrepareWorld(unsigned int _0_box_loading_1_fullscreen) +{ + //if ( pRenderer->pRenderD3D ) + pGame->pVisInstance->_4C1A02(); + pEventTimer->Pause(); + pMiscTimer->Pause(); + pParty->uFlags = 2; + CastSpellInfoHelpers::_427D48(); + ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); + DoPrepareWorld(0, (_0_box_loading_1_fullscreen == 0) + 1); + pMiscTimer->Resume(); + pEventTimer->Resume(); +} + +//----- (00464866) -------------------------------------------------------- +void DoPrepareWorld(unsigned int bLoading, int _1_fullscreen_loading_2_box) +{ + char *v3; // eax@1 + unsigned int v5; // eax@3 + char Str1[20]; // [sp+Ch] [bp-18h]@1 + unsigned int v9; // [sp+20h] [bp-4h]@1 + + v9 = bLoading; + ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); + pDecalBuilder->Reset(0); + pGameLoadingUI_ProgressBar->Initialize(_1_fullscreen_loading_2_box == 1 ? GUIProgressBar::TYPE_Fullscreen : + GUIProgressBar::TYPE_Box); + strcpy(Str1, pCurrentMapName); + v3 = strtok(Str1, "."); + strcpy(Str1, v3); + Level_LoadEvtAndStr(Str1); + LoadLevel_InitializeLevelEvt(); + strcpy(Str1, pCurrentMapName); + _strrev(Str1); + strtok(Str1, "."); + _strrev(Str1); + + for (uint i = 0; i < 1000; ++i) + pSpriteObjects[i].uObjectDescID = 0; + + v5 = pMapStats->GetMapInfo(pCurrentMapName); + bUnderwater = false; + uLevelMapStatsID = v5; + pGame->uFlags2 &= 0xFFFFFFF7u; + if (!_stricmp(pCurrentMapName, "out15.odm")) + { + bUnderwater = true; + pGame->uFlags2 |= GAME_FLAGS_2_ALTER_GRAVITY; + } + pParty->floor_face_pid = 0; + if (_stricmp(Str1, "blv")) + PrepareToLoadODM(v9, 0); + else + PrepareToLoadBLV(v9); + pAudioPlayer->SetMapEAX(); + _461103_load_level_sub(); + if (!_stricmp(pCurrentMapName, "d11.blv") || !_stricmp(pCurrentMapName, "d10.blv")) + { + //spawning grounds & walls of mist - no loot & exp from monsters + + for (uint i = 0; i < uNumActors; ++i) + { + pActors[i].pMonsterInfo.uTreasureType = 0; + pActors[i].pMonsterInfo.uTreasureDiceRolls = 0; + pActors[i].pMonsterInfo.uExp = 0; + } + } + bDialogueUI_InitializeActor_NPC_ID = 0; + OnMapLoad(); + pGameLoadingUI_ProgressBar->Progress(); + memset(&pRenderer->pBillboardRenderListD3D, 0, sizeof(pRenderer->pBillboardRenderListD3D)); + pGameLoadingUI_ProgressBar->Release(); + _flushall(); +} + +void IntegrityTest() +{ + static_assert(sizeof(MovieHeader) == 44, "Wrong type size"); + static_assert(sizeof(SoundDesc_mm6) == 112, "Wrong type size"); + static_assert(sizeof(SoundDesc) == 120, "Wrong type size"); + static_assert(sizeof(OverlayDesc) == 8, "Wrong type size"); + static_assert(sizeof(ChestDesc) == 36, "Wrong type size"); + static_assert(sizeof(ObjectDesc_mm6) == 52, "Wrong type size"); + static_assert(sizeof(ObjectDesc) == 56, "Wrong type size"); + static_assert(sizeof(DecorationDesc) == 84, "Wrong type size"); + static_assert(sizeof(IconFrame) == 32, "Wrong type size"); + static_assert(sizeof(PlayerFrame) == 10, "Wrong type size"); + static_assert(sizeof(TextureFrame) == 20, "Wrong type size"); + static_assert(sizeof(SpriteFrame) == 60, "Wrong type size"); + static_assert(sizeof(RenderVertexSoft) == 0x30, "Wrong type size"); + static_assert(sizeof(RenderBillboard) == 0x34, "Wrong type size"); + static_assert(sizeof(Texture) == 0x48, "Wrong type size"); + static_assert(sizeof(RGBTexture) == 0x28, "Wrong type size"); + //static_assert(sizeof(LODFile_IconsBitmaps) == 0x11BB8 + 4, "Wrong type size"); // + virtual dtor ptr + static_assert(sizeof(AudioPlayer) == 0xC84, "Wrong type size"); + static_assert(sizeof(SoundDesc) == 0x78, "Wrong type size"); + static_assert(sizeof(stru339_spell_sound) == 0xAFD8, "Wrong type size"); + //static_assert(sizeof(VideoPlayer) == 0x108 + 4, "Wrong type size"); + static_assert(sizeof(MovieHeader) == 0x2C, "Wrong type size"); + static_assert(sizeof(DecorationDesc) == 0x54, "Wrong type size"); + static_assert(sizeof(ObjectDesc) == 0x38, "Wrong type size"); + static_assert(sizeof(OverlayDesc) == 0x8, "Wrong type size"); + static_assert(sizeof(ChestDesc) == 0x24, "Wrong type size"); + static_assert(sizeof(TileDesc) == 0x1A, "Wrong type size"); + static_assert(sizeof(MonsterDesc_mm6) == 148, "Wrong type size"); + static_assert(sizeof(MonsterDesc) == 152, "Wrong type size"); + static_assert(sizeof(Timer) == 0x28, "Wrong type size"); + static_assert(sizeof(OtherOverlay) == 0x14, "Wrong type size"); + static_assert(sizeof(ItemGen) == 0x24, "Wrong type size"); + static_assert(sizeof(SpriteObject) == 0x70, "Wrong type size"); + static_assert(sizeof(ItemDesc) == 0x30, "Wrong type size"); + static_assert(sizeof(ItemsTable) == 0x117A0, "Wrong type size"); + static_assert(sizeof(Chest) == 0x14CC, "Wrong type size"); + static_assert(sizeof(MapInfo) == 0x44, "Wrong type size"); + static_assert(sizeof(SpellInfo) == 0x24, "Wrong type size"); + static_assert(sizeof(SpellData) == 0x14, "Wrong type size"); + static_assert(sizeof(SpellBuff) == 0x10, "Wrong type size"); + static_assert(sizeof(AIDirection) == 0x1C, "Wrong type size"); + static_assert(sizeof(ActorJob) == 0xC, "Wrong type size"); + static_assert(sizeof(Actor) == 0x344, "Wrong type size"); + static_assert(sizeof(LevelDecoration) == 0x20, "Wrong type size"); + static_assert(sizeof(KeyboardActionMapping) == 0x20C, "Wrong type size"); + static_assert(sizeof(UIAnimation) == 0xD, "Wrong type size"); + static_assert(sizeof(SpawnPointMM7) == 0x18, "Wrong type size"); + static_assert(sizeof(ODMFace) == 0x134, "Wrong type size"); + static_assert(sizeof(BSPNode) == 0x8, "Wrong type size"); + static_assert(sizeof(BSPModel) == 0xBC, "Wrong type size"); + static_assert(sizeof(OutdoorLocation) == 0x1C28C, "Wrong type size"); + static_assert(sizeof(BLVFace) == 0x60, "Wrong type size"); + static_assert(sizeof(BLVFaceExtra) == 0x24, "Wrong type size"); + static_assert(sizeof(BLVSector) == 0x74, "Wrong type size"); + static_assert(sizeof(BLVLightMM7) == 0x10, "Wrong type size"); + static_assert(sizeof(BLVDoor) == 0x50, "Wrong type size"); + static_assert(sizeof(IndoorLocation) == 0x690, "Wrong type size"); + //static_assert(sizeof(ODMRenderParams) == 0x74, "Wrong type size"); + static_assert(sizeof(Mouse) == 0x114, "Wrong type size"); + static_assert(sizeof(Particle_sw) == 0x68, "Wrong type size"); + static_assert(sizeof(Particle) == 0x68, "Wrong type size"); + static_assert(sizeof(ParticleEngine) == 0xE430, "Wrong type size"); + static_assert(sizeof(Lightmap) == 0xC1C, "Wrong type size"); + static_assert(sizeof(LightmapBuilder) == 0x3CBC38, "Wrong type size"); + static_assert(sizeof(Vis_SelectionList) == 0x2008, "Wrong type size"); + static_assert(sizeof(Vis) == 0x20D0, "Wrong type size"); + static_assert(sizeof(PlayerBuffAnim) == 0x10, "Wrong type size"); + static_assert(sizeof(ProjectileAnim) == 0x1C, "Wrong type size"); + static_assert(sizeof(stru6) == 0x5F8, "Wrong type size"); + static_assert(sizeof(IndoorCameraD3D_Vec3) == 0x10, "Wrong type size"); + static_assert(sizeof(IndoorCameraD3D_Vec4) == 0x18, "Wrong type size"); //should be 14 (10 vec3 + 4 vdtor) but 18 coz of his +4 from own vdtor, but it is odd since vdtor already present from vec3 + //static_assert(sizeof(IndoorCameraD3D) == 0x1A1384, "Wrong type size"); + static_assert(sizeof(StationaryLight) == 0xC, "Wrong type size"); + static_assert(sizeof(LightsStack_StationaryLight_) == 0x12C8, "Wrong type size"); + static_assert(sizeof(MobileLight) == 0x12, "Wrong type size"); + static_assert(sizeof(LightsStack_MobileLight_) == 0x1C28, "Wrong type size"); + static_assert(sizeof(Game) == 0xE78, "Wrong type size"); + static_assert(sizeof(stru141_actor_collision_object) == 0xA8, "Wrong type size"); + static_assert(sizeof(ActionQueue) == 0x7C, "Wrong type size"); + static_assert(sizeof(NPCData) == 0x4C, "Wrong type size"); + static_assert(sizeof(NPCStats) == 0x17FFC, "Wrong type size"); + static_assert(sizeof(BspRenderer) == 0x53740, "Wrong type size"); + static_assert(sizeof(PaletteManager) == 0x267AF0, "Wrong type size"); + static_assert(sizeof(ViewingParams) == 0x26C, "Wrong type size"); + //static_assert(sizeof(IndoorCamera) == 0x50, "Wrong type size"); + static_assert(sizeof(Bloodsplat) == 0x28, "Wrong type size"); + static_assert(sizeof(BloodsplatContainer) == 0xA0C, "Wrong type size"); + static_assert(sizeof(TrailParticle) == 0x18, "Wrong type size"); + static_assert(sizeof(EventIndex) == 0xC, "Wrong type size"); + static_assert(sizeof(_2devent) == 0x34, "Wrong type size"); + static_assert(sizeof(MapsLongTimer) == 0x20, "Wrong type size"); + static_assert(sizeof(SavegameHeader) == 0x64, "Wrong type size"); + static_assert(sizeof(SavegameList) == 0x3138, "Wrong type size"); + static_assert(sizeof(StorylineText) == 0x160, "Wrong type size"); + static_assert(sizeof(FactionTable) == 0x1EF1, "Wrong type size"); + static_assert(sizeof(Decal) == 0xC20, "Wrong type size"); + static_assert(sizeof(DecalBuilder) == 0x30C038, "Wrong type size"); + static_assert(sizeof(MonsterInfo) == 0x58, "Wrong type size"); + static_assert(sizeof(MonsterStats) == 0x5BA0, "Wrong type size"); + static_assert(sizeof(RenderD3D) == 0x148, "Wrong type size"); + // static_assert(sizeof(Render) == 0x129844, "Wrong type size"); + static_assert(sizeof(Player) == 0x1B3C, "Wrong type size"); + static_assert(sizeof(PartyTimeStruct) == 0x678, "Wrong type size"); + static_assert(sizeof(Party) == 0x16238, "Wrong type size"); + static_assert(sizeof(GUIButton) == 0xBC, "Wrong type size"); + static_assert(sizeof(GUIWindow) == 0x54, "Wrong type size"); + static_assert(sizeof(GUIProgressBar) == 0x1B8, "Wrong type size"); + static_assert(sizeof(GUIFont) == 0x1020, "Wrong type size"); + // static_assert(sizeof(stru262_TurnBased) == 0x40, "Wrong type size"); + static_assert(sizeof(ArcomageGame) == 0xFB, "Wrong type size"); + static_assert(sizeof(CastSpellInfo) == 0x14, "Wrong type size"); + static_assert(sizeof(ArcomageCard) == 0x6C, "Wrong type size"); + static_assert(sizeof(stru320) == 0x3FC, "Wrong type size"); + static_assert(sizeof(TravelInfo) == 0x20, "Wrong type size"); + static_assert(sizeof(stru336) == 0x798, "Wrong type size"); + static_assert(sizeof(Vec3_short_) == 6, "Wrong type size"); + static_assert(sizeof(BLVFace) == 96, "Wrong type size"); + static_assert(sizeof(BLVFaceExtra) == 36, "Wrong type size"); + static_assert(sizeof(BLVSector) == 116, "Wrong type size"); + static_assert(sizeof(LevelDecoration) == 32, "Wrong type size"); + static_assert(sizeof(BLVLightMM7) == 16, "Wrong type size"); + static_assert(sizeof(BSPNode) == 8, "Wrong type size"); + static_assert(sizeof(SpawnPointMM7) == 24, "Wrong type size"); + static_assert(sizeof(DDM_DLV_Header) == 40, "Wrong type size"); + static_assert(sizeof(Actor) == 836, "Wrong type size"); + static_assert(sizeof(SpriteObject) == 112, "Wrong type size"); + static_assert(sizeof(Chest) == 5324, "Wrong type size"); + static_assert(sizeof(stru123) == 0xC8, "Wrong type size"); + static_assert(sizeof(BLVMapOutline) == 12, "Wrong type size"); + static_assert(sizeof(LODSprite) == 0x28, "Wrong type size"); +} + + +//----- (00464761) -------------------------------------------------------- +void Game_DeinitializeAndTerminate(int exitCode) +{ + SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); + ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); + pGame->Deinitialize(); + pRenderer->Release(); + delete window; + //if ( !DestroyWindow(hWnd) ) + // GetLastError(); + exit(exitCode); +} + +//----- (004647AB) -------------------------------------------------------- +void FinalInitialization() +{ + pViewport->SetScreen(viewparams->uSomeX, viewparams->uSomeY, viewparams->uSomeZ, viewparams->uSomeW); + pViewport->SetFOV(flt_6BE3A0 * 65536.0f); + + //pIndoorCamera = new IndoorCamera; + //pIndoorCamera->Initialize(65, viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X + 1, + // viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y + 1); + + InitializeTurnBasedAnimations(&stru_50C198); + pBitmaps_LOD->_inlined_sub1(); + pSprites_LOD->_inlined_sub1(); + pIcons_LOD->_inlined_sub1(); +} +// 6BE3A0: using guessed type float flt_6BE3A0; + + + +//----- (00464E17) -------------------------------------------------------- +bool __fastcall CheckMM7CD(char c) +{ + char DstBuf[256] = { 0 }; + char strCommand[256] = { 0 }; // [sp+10Ch] [bp-118h]@1 + char Filename[20] = { 0 }; // [sp+20Ch] [bp-18h]@1 + + wchar_t pMagicPath[1024]; + swprintf(pMagicPath, wcslen(L"%C:\\anims\\magic7.vid"), L"%C:\\anims\\magic7.vid", c); + if (GetFileAttributesW(pMagicPath) == -1) + return false; + + wsprintfA(strCommand, "open %c: type cdaudio alias CD", c); + if (!mciSendStringA(strCommand, DstBuf, 255, 0))//Uninitialized memory access + + { + wsprintfA(strCommand, "info CD UPC wait"); + mciSendStringA(strCommand, DstBuf, 255, 0); + wsprintfA(strCommand, "close CD"); + mciSendStringA(strCommand, DstBuf, 255, 0); + } + + memcpy(Filename, "X:\\anims\\magic7.vid", sizeof(Filename)); + *Filename = c; + + FILE* f = fopen(Filename, "rb"); + if (!f) + return false; + + if (!fseek(f, 0, SEEK_END)) + { + if (!fseek(f, -100, SEEK_CUR)) + fread(DstBuf, 1, 0x64u, f); + + fclose(f); + return true; + } + fclose(f); + return false; +} + +//----- (00464F1B) -------------------------------------------------------- +signed int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4) +{ + char v4; // zf@3 + int v6; // eax@10 + int v7; // eax@11 + int v8; // eax@12 + int v9; // eax@13 + BOOL(__stdcall *v10)(HWND, int, LPCSTR); // edi@15 + const CHAR *v11; // [sp-Ch] [bp-Ch]@15 + INT_PTR v12; // [sp-4h] [bp-4h]@5 + + if (a2 == 272) + { + hInsertCDWindow = hDlg; + v6 = (GetUserDefaultLangID() & 0x3FF) - 7; + if (v6) + { + v7 = v6 - 3; + if (v7) + { + v8 = v7 - 2; + if (v8) + { + v9 = v8 - 4; + if (v9) + { + if (v9 != 5) + return 0; + SetWindowTextA(hDlg, "Wloz CD-ROM numer 2"); + v10 = SetDlgItemTextA; + SetDlgItemTextA(hDlg, 1010, "Wloz CD-ROM numer 2 Might and Magic® VII."); + v11 = "Odwolaj"; + } + else + { + SetWindowTextA(hDlg, "Inserire il secondo CD"); + v10 = SetDlgItemTextA; + SetDlgItemTextA(hDlg, 1010, "Inserire il secondo CD di Might and Magic® VII."); + v11 = "Annulla"; + } + } + else + { + SetWindowTextA(hDlg, "Insérez le CD 2"); + v10 = SetDlgItemTextA; + SetDlgItemTextA(hDlg, 1010, "Insérez Might & Magic® VII CD 2."); + v11 = "Supprimer"; + } + } + else + { + SetWindowTextA(hDlg, "Por favor, inserte disco 2"); + v10 = SetDlgItemTextA; + SetDlgItemTextA(hDlg, 1010, "Por favor, inserte disco 2 de Might & Magic® VII."); + v11 = "Cancelar"; + } + } + else + { + SetWindowTextA(hDlg, "Bitte CD 2 einlegen"); + v10 = SetDlgItemTextA; + SetDlgItemTextA(hDlg, 1010, "Bitte CD 2 von Might and Magic® VII einlegen."); + v11 = "Abbrechen"; + } + v10(hDlg, 2, v11); + return 0; + } + if (a2 == 273) + { + if (a3 == 2) + { + v12 = 0; + EndDialog(hDlg, v12); + return 1; + } + v4 = a3 == 1; + } + else + { + v4 = a2 == 1025; + } + if (v4) + { + v12 = 1; + EndDialog(hDlg, v12); + return 1; + } + return 0; +} + +//----- (00465061) -------------------------------------------------------- +bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive) +{ + char drive[4] = { 'X', ':', '\\', 0 }; + + bool bGotCDFromRegistry = false; + + HKEY hSoftware = nullptr, + hNWC = nullptr, + hMM7 = nullptr, + hVersion = nullptr; + if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hSoftware)) + { + if (!RegOpenKeyExA(hSoftware, "New World Computing", 0, KEY_READ|KEY_WOW64_32KEY, &hNWC)) + { + if (!RegOpenKeyExA(hNWC, "Might and Magic VII", 0, KEY_READ|KEY_WOW64_32KEY, &hMM7)) + { + if (!RegOpenKeyExA(hMM7, "1.0", 0, KEY_READ|KEY_WOW64_32KEY, &hVersion)) + { + DWORD cbData = 3; + if (!RegQueryValueExA(hVersion, "CDDrive", 0, 0, (BYTE *)drive, &cbData)) + bGotCDFromRegistry = true; + } + RegCloseKey(hVersion); + } + RegCloseKey(hMM7); + } + RegCloseKey(hNWC); + } + RegCloseKey(hSoftware); + + if (bGotCDFromRegistry) + if (CheckMM7CD(*drive)) + { + cMM7GameCDDriveLetter = *drive; + return true; + } + + while (true) + { + for (uint i = 0; i < 26; ++i) + { + drive[0] = 'A' + i; + + if (GetDriveTypeA(drive) == DRIVE_CDROM) + if (CheckMM7CD(*drive)) + { + cMM7GameCDDriveLetter = *drive; + WriteWindowsRegistryString("CDDrive", drive); + return true; + } + } + + if (DialogBoxParamA(GetModuleHandleW(nullptr), "InsertCD", hWnd, (DLGPROC)InsertMM7CDDialogFunc, 0)) + continue; + return false; + } +} + +//----- (004651F4) -------------------------------------------------------- +bool MM7_Initialize(int game_width, int game_height) +{ + wchar_t pCurrentDir[1024]; + _wgetcwd(pCurrentDir, 1024); + + wchar_t pMM6IniFile[1024]; + wsprintfW(pMM6IniFile, L"%s\\mm6.ini", pCurrentDir); + + bCanLoadFromCD = GetPrivateProfileIntW(L"settings", L"use_cd", 1, pMM6IniFile); + if (bNoCD) + bCanLoadFromCD = false; + if (bCanLoadFromCD) + { + Log::Warning(L"Checking for CD..."); + if (!FindMM7CD(nullptr, &cMM7GameCDDriveLetter)) + return false; + Log::Warning(L"...done."); + } + + + srand(GetTickCount()); + + pEventTimer = Timer::Create(); + pEventTimer->Initialize(); + window = OSWindow::Create(L"Might and Magic® Trilogy", game_width, game_height);//Create game window + + bool use_d3d11 = false; + if (use_d3d11) + pRenderer = RenderD3D11::Create(); + else + pRenderer = Render::Create();//Create DirectX + if (!pRenderer) + { + Log::Warning(L"Render creation failed"); + return false; + } + else + { + //bool bWindowMode = ReadWindowsRegistryInt("startinwindow", false); + //uint uDefaultDevice = ReadWindowsRegistryInt("D3D Device", 1); + + if (!pRenderer->Initialize(window/*, bColoredLights, uLevelOfDetail, bTinting*/)) + { + Log::Warning(L"Render failed to initialize"); + return false; + } + } + + game_starting_year = 1168; + + pParty = new Party; + memset(&pParty->pHirelings, 0, sizeof(pParty->pHirelings)); + pParty->uWalkSpeed = GetPrivateProfileIntW(L"debug", L"walkspeed", 384, pMM6IniFile); + pParty->uDefaultEyelevel = GetPrivateProfileIntW(L"party", L"eyelevel", 160, pMM6IniFile); + pParty->sEyelevel = pParty->uDefaultEyelevel; + pParty->uDefaultPartyHeight = GetPrivateProfileIntW(L"party", L"height", 192, pMM6IniFile); + pParty->uPartyHeight = pParty->uDefaultPartyHeight; + + MM6_Initialize(pMM6IniFile); + + pKeyActionMap = new KeyboardActionMapping; + + OnTimer(1); + GameUI_StatusBar_UpdateTimedString(1); + pGame = Game::Create(); + pMouse = pGame->pMouseInstance; + + + pIcons_LOD = new LODFile_IconsBitmaps; + if (!pIcons_LOD->Load("data\\icons.lod", "icons")) + { + MessageBoxW(nullptr, L"Some files are missing\n\nPlease Reinstall.", + L"Files Missing", MB_ICONEXCLAMATION); + return false; + } + pIcons_LOD->dword_011BA4 = 0; + + pEvents_LOD = new LODFile_IconsBitmaps; + if (!pEvents_LOD->Load("data\\events.lod", "icons")) + { + MessageBoxW(nullptr, L"Some files are missing\n\nPlease Reinstall.", + L"Files Missing", MB_ICONEXCLAMATION); + return false; + } + + InitializeGameText(); + + pBitmaps_LOD = new LODFile_IconsBitmaps; + if (!pBitmaps_LOD->Load("data\\bitmaps.lod", "bitmaps")) + { + MessageBoxA(nullptr, pGlobalTXT_LocalizationStrings[63], + pGlobalTXT_LocalizationStrings[184], MB_ICONEXCLAMATION); + return false; + } + + pSprites_LOD = new LODFile_Sprites; + if (!pSprites_LOD->LoadSprites("data\\sprites.lod")) + { + MessageBoxA(nullptr, + pGlobalTXT_LocalizationStrings[63], + pGlobalTXT_LocalizationStrings[184], MB_ICONEXCLAMATION); + return false; + } + + +#if 0 + if (_access("../MM_VI/data/icons.lod", 0) == 0) + { + pIcons_LOD_mm6 = new LODFile_IconsBitmaps; + if (!pIcons_LOD_mm6->Load("../MM_VI/data/icons.lod", "icons")) + { + delete pIcons_LOD_mm6; + pIcons_LOD_mm6 = nullptr; + Log::Warning(L"Unable to load mm6:icons.lod"); + } + } + else + Log::Warning(L"Unable to find mm6:icons.lod"); + + if (_access("../MM_VI/data/bitmaps.lod", 0) == 0) + { + pBitmaps_LOD_mm6 = new LODFile_IconsBitmaps; + if (!pBitmaps_LOD_mm6->Load("../MM_VI/data/bitmaps.lod", "bitmaps")) + { + delete pBitmaps_LOD_mm6; + pBitmaps_LOD_mm6 = nullptr; + Log::Warning(L"Unable to load mm6:bitmaps.lod"); + } + } + else + Log::Warning(L"Unable to find mm6:bitmaps.lod"); + + auto mm6_sprite_container_name = bUseLoResSprites ? "../MM_VI/data/spriteLO.lod" + : "../MM_VI/data/sprites.lod"; + if (_access(mm6_sprite_container_name, 0) == 0) + { + pSprites_LOD_mm6 = new LODFile_Sprites; + if (!pSprites_LOD_mm6->LoadSprites(mm6_sprite_container_name)) + { + delete pSprites_LOD_mm6; + pSprites_LOD_mm6 = nullptr; + Log::Warning(L"Unable to load mm6:sprites.lod"); + } + } + else + Log::Warning(L"Unable to find mm6:sprites.lod"); + + + if (_access("../mm8/data/icons.lod", 0) == 0) + { + pIcons_LOD_mm8 = new LODFile_IconsBitmaps; + if (!pIcons_LOD_mm8->Load("../mm8/data/icons.lod", "icons")) + { + delete pIcons_LOD_mm8; + pIcons_LOD_mm8 = nullptr; + Log::Warning(L"Unable to load mm8:icons.lod"); + } + } + else + Log::Warning(L"Unable to find mm8:icons.lod"); + + + if (_access("../mm8/data/bitmaps.lod", 0) == 0) + { + pBitmaps_LOD_mm8 = new LODFile_IconsBitmaps; + if (!pBitmaps_LOD_mm8->Load("../mm8/data/bitmaps.lod", "bitmaps")) + { + delete pBitmaps_LOD_mm8; + pBitmaps_LOD_mm8 = nullptr; + Log::Warning(L"Unable to load mm8:bitmaps.lod"); + } + } + else + Log::Warning(L"Unable to find mm8:bitmaps.lod"); + + + if (_access("../mm8/data/sprites.lod", 0) == 0) + { + pSprites_LOD_mm8 = new LODFile_Sprites; + if (!pSprites_LOD_mm8->LoadSprites("../mm8/data/sprites.lod")) + { + delete pSprites_LOD_mm8; + pSprites_LOD_mm8 = nullptr; + Log::Warning(L"Unable to load mm8:sprites.lod"); + } + } + else + Log::Warning(L"Unable to find mm8:sprites.lod"); +#endif + + { + void *sft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dsft.bin", 1) : nullptr, + *sft_mm8 = nullptr; + void *sft_mm7 = pEvents_LOD->LoadRaw("dsft.bin", 1); + pSpriteFrameTable = new SpriteFrameTable; + pSpriteFrameTable->FromFile(sft_mm6, sft_mm7, sft_mm8); + free(sft_mm6); + free(sft_mm7); + free(sft_mm8); + + void *tft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dtft.bin", 1) : nullptr, + *tft_mm8 = nullptr; + void *tft_mm7 = pEvents_LOD->LoadRaw("dtft.bin", 1); + pTextureFrameTable = new TextureFrameTable; + pTextureFrameTable->FromFile(tft_mm6, tft_mm7, tft_mm8); + free(tft_mm6); + free(tft_mm7); + free(tft_mm8); + + void *tiles_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dtile.bin", 1) : nullptr, + *tiles_mm8 = nullptr; + void *tiles_mm7 = pEvents_LOD->LoadRaw("dtile.bin", 1); + pTileTable = new TileTable; + pTileTable->FromFile(tiles_mm6, tiles_mm7, tiles_mm8); + free(tiles_mm6); + free(tiles_mm7); + free(tiles_mm8); + + void *pft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dpft.bin", 1) : nullptr, + *pft_mm8 = nullptr; + void *pft_mm7 = pEvents_LOD->LoadRaw("dpft.bin", 1); + pPlayerFrameTable = new PlayerFrameTable; + pPlayerFrameTable->FromFile(pft_mm6, pft_mm7, pft_mm8); + free(pft_mm6); + free(pft_mm7); + free(pft_mm8); + + void *ift_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dift.bin", 1) : nullptr, + *ift_mm8 = nullptr; + void *ift_mm7 = pEvents_LOD->LoadRaw("dift.bin", 1); + pIconsFrameTable = new IconFrameTable; + pIconsFrameTable->FromFile(ift_mm6, ift_mm7, ift_mm8); + free(ift_mm6); + free(ift_mm7); + free(ift_mm8); + + void *decs_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("ddeclist.bin", 1) : nullptr, + *decs_mm8 = nullptr; + void *decs_mm7 = pEvents_LOD->LoadRaw("ddeclist.bin", 1); + pDecorationList = new DecorationList; + pDecorationList->FromFile(decs_mm6, decs_mm7, decs_mm8); + free(decs_mm6); + free(decs_mm7); + free(decs_mm8); + + void *objs_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dobjlist.bin", 1) : nullptr, + *objs_mm8 = nullptr; + void *objs_mm7 = pEvents_LOD->LoadRaw("dobjlist.bin", 1); + pObjectList = new ObjectList; + pObjectList->FromFile(objs_mm6, objs_mm7, objs_mm8); + free(objs_mm6); + free(objs_mm7); + free(objs_mm8); + + void *mons_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dmonlist.bin", 1) : nullptr, + *mons_mm8 = nullptr; + void *mons_mm7 = pEvents_LOD->LoadRaw("dmonlist.bin", 1); + pMonsterList = new MonsterList; + pMonsterList->FromFile(mons_mm6, mons_mm7, mons_mm8); + free(mons_mm6); + free(mons_mm7); + free(mons_mm8); + + void *chests_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dchest.bin", 1) : nullptr, + *chests_mm8 = nullptr; + void *chests_mm7 = pEvents_LOD->LoadRaw("dchest.bin", 1); + pChestList = new ChestList; + pChestList->FromFile(chests_mm6, chests_mm7, chests_mm8); + free(chests_mm6); + free(chests_mm7); + free(chests_mm8); + + void *overlays_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("doverlay.bin", 1) : nullptr, + *overlays_mm8 = nullptr; + void *overlays_mm7 = pEvents_LOD->LoadRaw("doverlay.bin", 1); + pOverlayList = new OverlayList; + pOverlayList->FromFile(overlays_mm6, overlays_mm7, overlays_mm8); + free(overlays_mm6); + free(overlays_mm7); + free(overlays_mm8); + + void *sounds_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dsounds.bin", 1) : nullptr, + *sounds_mm8 = nullptr; + void *sounds_mm7 = pEvents_LOD->LoadRaw("dsounds.bin", 1); + pSoundList = new SoundList; + pSoundList->FromFile(sounds_mm6, sounds_mm7, sounds_mm8); + free(sounds_mm6); + free(sounds_mm7); + free(sounds_mm8); + } + + + + + if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_RUN_IN_WIDOW) + { + //window->SetWindowedMode(game_width, game_height); + pRenderer->SwitchToWindow(); + } + else + { + __debugbreak(); // Nomad + window->SetFullscreenMode(); + pRenderer->InitializeFullscreen(); + } + + uSoundVolumeMultiplier = min(9, ReadWindowsRegistryInt("soundflag", 9)); + uMusicVolimeMultiplier = min(9, ReadWindowsRegistryInt("musicflag", 9)); + uVoicesVolumeMultiplier = min(9, ReadWindowsRegistryInt("CharVoices", 9)); + bShowDamage = ReadWindowsRegistryInt("ShowDamage", 1) != 0; + + uGammaPos = min(4, ReadWindowsRegistryInt("GammaPos", 4)); + pGame->pGammaController->Initialize(uGammaPos * 0.1 + 0.6); + + if (ReadWindowsRegistryInt("Bloodsplats", 1)) + pGame->uFlags2 |= GAME_FLAGS_2_DRAW_BLOODSPLATS; + else + pGame->uFlags2 &= ~GAME_FLAGS_2_DRAW_BLOODSPLATS; + + uTurnSpeed = ReadWindowsRegistryInt("TurnDelta", 3); + + if (!bNoSound) + pAudioPlayer->Initialize(); + + pMediaPlayer = new Media::MPlayer(); + pMediaPlayer->Initialize(window); + + dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; + + switch (uTurnSpeed) + { + case 0: // undefined turn option + __debugbreak(); // really shouldn't use this mode + uTurnSpeed = (unsigned int)uCPUSpeed < 199 ? 128 : 64; // adjust turn speed to estimated fps + break; + + case 1: // 16x + Log::Warning(L"x16 Turn Speed"); // really shouldn't use this mode + uTurnSpeed = 128; + break; + + case 2: // 32x + Log::Warning(L"x32 Turn Speed"); // really shouldn't use this mode + uTurnSpeed = 64; + break; + + case 3: // smooth + uTurnSpeed = 0; + break; + } + + return true; +} + +//----- (00465D0B) -------------------------------------------------------- +void SecondaryInitialization() +{ + pMouse->Initialize(window); + + pItemsTable = new ItemsTable; + pItemsTable->Initialize(); + + //pBitmaps_LOD->can_load_hardware_sprites = 1; + //pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); + pBitmaps_LOD->SetupPalettes(5, 6, 5); + //pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); + pIcons_LOD->SetupPalettes(5, 6, 5); + //pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); + pPaletteManager->SetColorChannelInfo(5, 6, 5); + + pPaletteManager->SetMistColor(128, 128, 128); + pPaletteManager->RecalculateAll(); + //pSprites_LOD->can_load_hardware_sprites = 1; + pObjectList->InitializeSprites(); + pOverlayList->InitializeSprites(); + + if (!bNoSound) + pSoundList->Initialize(); + + + for (uint i = 0; i < 4; ++i) + { + static const char *pUIAnimNames[4] = + { + "glow03", "glow05", + "torchA", "wizeyeA" + }; + static unsigned short _4E98D0[4][4] = + { + { 479, 0, 329, 0 }, + { 585, 0, 332, 0 }, + { 468, 0, 0, 0 }, + { 606, 0, 0, 0 } + }; + + pUIAnims[i]->uIconID = pIconsFrameTable->FindIcon(pUIAnimNames[i]); + pIconsFrameTable->InitializeAnimation(pUIAnims[i]->uIconID); + + pUIAnims[i]->uAnimLength = 0; + pUIAnims[i]->uAnimTime = 0; + pUIAnims[i]->x = _4E98D0[i][0]; + pUIAnims[i]->y = _4E98D0[i][2]; + } + + for (unsigned int i = 0; i < pObjectList->uNumObjects; ++i) + { + pObjectList->pObjects[i].uParticleTrailColor = pObjectList->pObjects[i].uParticleTrailColorB | + ((unsigned int)pObjectList->pObjects[i].uParticleTrailColorG << 8) | + ((unsigned int)pObjectList->pObjects[i].uParticleTrailColorR << 16); + } + + MainMenuUI_Create(); + pGame->pStru6Instance->LoadAnimations(); + + for (uint i = 0; i < 7; ++i) + { + char container_name[64]; + sprintf(container_name, "HDWTR%03u", i); + pRenderer->pHDWaterBitmapIDs[i] = pBitmaps_LOD->LoadTexture(container_name); + } + + pNPCStats = new NPCStats; + memset(pNPCStats->pNPCData, 0, 0x94BCu); + pNPCStats->Initialize(); + + Initialize_GlobalEVT(); + pBitmaps_LOD->_inlined_sub0(); + pSprites_LOD->_inlined_sub0(); + pPaletteManager->LockAll(); + + _mkdir("Saves"); + for (uint i = 0; i < 5; ++i) + for (uint j = 0; j < 6; ++j) + { + sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j); + remove(pTmpBuf.data()); + } + + Initialize_GamesLOD_NewLOD(); + _576E2C_current_minimap_zoom = 512; + dword_576E28 = 9; +} + +bool new_sky = false; //new sky(need texture) +int max_flight_height = 4000; //maximum altitude +bool use_MMT = false; +bool for_refactoring = false; + +//----- (00462C94) -------------------------------------------------------- +bool MM_Main(const wchar_t *pCmdLine) +{ + IntegrityTest(); + + char test[1024]; + sprintfex(test, "^Pi[%s]: çíàõàð^R[ü;êà;]", "Çîëòàí"); + + lua = new LuaVM; + lua->Initialize(); + + bool bNoMargareth = false; + if (pCmdLine && *pCmdLine) + { + //if (wcsstr(pCmdLine, L"-usedefs")) + // bDebugResouces = 1; + if (wcsstr(pCmdLine, L"-window")) + dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_RUN_IN_WIDOW; + + if (wcsstr(pCmdLine, L"-nointro")) + bNoIntro = true;//dword_6BE364_game_settings_1 |= 4; + if (wcsstr(pCmdLine, L"-nologo")) + bNoLogo = true;//dword_6BE364_game_settings_1 |= 8; + if (wcsstr(pCmdLine, L"-nosound")) + bNoSound = true; //dword_6BE364_game_settings_1 |= 0x10; + + bWalkSound = ReadWindowsRegistryInt("WalkSound", 1) != 0; + if (wcsstr(pCmdLine, L"-nowalksound")) + bWalkSound = false;//dword_6BE364_game_settings_1 |= 0x20; + if (wcsstr(pCmdLine, L"-novideo")) + { + dword_6BE364_game_settings_1 |= GAME_SETTINGS_NO_HOUSE_ANIM; + bNoVideo = true; + } + if (wcsstr(pCmdLine, L"-nocd")) + bNoCD = true; + if (wcsstr(pCmdLine, L"-new_sky")) + new_sky = true; + if (wcsstr(pCmdLine, L"-nomarg")) + bNoMargareth = true; + } + + /*v8 = _4AC1C9_get_cpu_speed(0, (Vec4_int_ *)a2); + Rect.left = *(int *)v8; + Rect.top = *(int *)(v8 + 4); + Rect.right = *(int *)(v8 + 8); + Rect.bottom = *(int *)(v8 + 12); + uCPUSpeed = Rect.bottom;*/ + uCPUSpeed = 2048; // about 2GHz + + //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF );//Ritor1: for memory test + + if (!MM7_Initialize(640, 480)) + { + Log::Warning(L"MM init: failed"); + pGame->Deinitialize(); + return 1; + } + + pEventTimer->Pause(); + + SetUserInterface(PartyAlignment_Neutral, false); + + ShowLogoVideo(); + //ShowIntroVideo_and_LoadingScreen(); + WriteWindowsRegistryInt("Ran once", 1); + dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; + pGame->InitializeGammaController(); + SecondaryInitialization(); + pRenderer->SetRasterClipRect(0, 0, window->GetWidth() - 1, window->GetHeight() - 1); + FinalInitialization(); + + //Ritor1: include + if (use_MMT) + MMT_MainMenu_Loop(); + + Log::Warning(L"MM: entering main loop"); + while (1) + { + MainMenuWindow* main_menu_window = MainMenuWindow::Create(); + window->AddControl(main_menu_window); + MainMenu_Loop(); + uGameState = GAME_STATE_PLAYING; + while (1) + { + if (uGameState == GAME_FINISHED || GetCurrentMenuID() == MENU_EXIT_GAME) + { + pGame->Deinitialize(); + return true; + } + + if (GetCurrentMenuID() == MENU_NEWGAME) + { + if (pAudioPlayer->hAILRedbook) + AIL_redbook_stop(pAudioPlayer->hAILRedbook); + pParty->Reset(); + pOtherOverlayList->Reset(); + strcpy(pCurrentMapName, pStartingMapName); + pParty->CreateDefaultParty(0); + PlayerCreationUI_Initialize(); + if (PlayerCreationUI_Loop()) + { + DeleteCCharFont(); + break; + } + DeleteCCharFont(); + bFlashQuestBook = true; + pMediaPlayer->PlayFullscreenMovie(MOVIE_Emerald, true); + SaveNewGame(); + if (bNoMargareth) + _449B7E_toggle_bit(pParty->_quest_bits, PARTY_QUEST_EMERALD_MARGARETH_OFF, 1); + pGame->Loop(); + if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) + { + SetCurrentMenuID(MENU_NEWGAME); + uGameState = GAME_STATE_PLAYING; + continue; + } + else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU) + break; + assert(false && "Invalid game state"); + } + if (GetCurrentMenuID() == MENU_CREDITS) + { + if (pAudioPlayer->hAILRedbook) + AIL_redbook_stop(pAudioPlayer->hAILRedbook); + MainMenuUI_Credits_Loop(); + break; + } + if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu) + { + uGameState = GAME_STATE_PLAYING; + pGame->Loop(); + } + else + { + if (GetCurrentMenuID() == MENU_DebugBLVLevel) + { + pMouse->ChangeActivation(0); + pParty->Reset(); + pParty->CreateDefaultParty(1); + + __debugbreak(); + /*extern void CreateDefaultBLVLevel(); + CreateDefaultBLVLevel(); + + OPENFILENAMEA ofn; + if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) + { + pMouse->ChangeActivation(1); + break; + } + _chdir("..\\"); + strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/ + pMouse->ChangeActivation(1); + pGame->Loop(); + } + } + if (uGameState == GAME_STATE_LOADING_GAME) + { + SetCurrentMenuID(MENU_5); + uGameState = GAME_STATE_PLAYING; + continue; + } + if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) + { + SetCurrentMenuID(MENU_NEWGAME); + uGameState = GAME_STATE_PLAYING; + continue; + } + if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)// from the loaded game + { + pAudioPlayer->StopChannels(-1, -1); + uGameState = GAME_STATE_PLAYING; + break; + } + } + if (!bNoSound && pAudioPlayer->hAILRedbook) + { + pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); + AIL_redbook_stop(pAudioPlayer->hAILRedbook); + unsigned int startms, end_ms; + AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &startms, &end_ms); + AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms); + } + } + //lua_close(L); + pGame->Deinitialize(); + return 1; +} + + + +//----- (00466082) -------------------------------------------------------- +void MM6_Initialize(const wchar_t *pIniFilename) +{ + size_t v2; // eax@31 + size_t v3; // ebx@32 + size_t v4; // edi@36 + char pDefaultGroundTexture[16]; // [sp+FCh] [bp-8Ch]@32 + unsigned int v9; // [sp+184h] [bp-4h]@28 + + //_getcwd(v5, 120); + //sprintfex(pIniFilename, "%s\\mm6.ini", v5); + viewparams = new ViewingParams; + game_viewport_x = viewparams->uScreen_topL_X = GetPrivateProfileIntW(L"screen", L"vx1", 8, pIniFilename); + game_viewport_y = viewparams->uScreen_topL_Y = GetPrivateProfileIntW(L"screen", L"vy1", 8, pIniFilename); + game_viewport_z = viewparams->uScreen_BttmR_X = GetPrivateProfileIntW(L"screen", L"vx2", 468, pIniFilename); + game_viewport_w = viewparams->uScreen_BttmR_Y = GetPrivateProfileIntW(L"screen", L"vy2", 351, pIniFilename); + game_viewport_width = game_viewport_z - game_viewport_x; + game_viewport_height = game_viewport_w - game_viewport_y + 1; + + + pAudioPlayer = new AudioPlayer; + pAudioPlayer->uMixerChannels = GetPrivateProfileIntW(L"settings", L"mixerchannels", 16, pIniFilename); + if (pAudioPlayer->uMixerChannels > 16) + pAudioPlayer->uMixerChannels = 16; + + + if (GetPrivateProfileIntW(L"debug", L"nomonster", 0, pIniFilename)) + dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_ACTORS; + if (ReadWindowsRegistryInt("startinwindow", 0)) + dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_RUN_IN_WIDOW; + if (GetPrivateProfileIntW(L"debug", L"showFR", 0, pIniFilename)) + dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_0002_SHOW_FR; + if (GetPrivateProfileIntW(L"debug", L"nodamage", 0, pIniFilename)) + dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_DAMAGE; + if (GetPrivateProfileIntW(L"debug", L"nodecoration", 0, pIniFilename)) + dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_DECORATIONS; + + wchar_t pStartingMapNameW[1024]; + GetPrivateProfileStringW(L"file", L"startmap", L"out01.odm", pStartingMapNameW, 0x20u, pIniFilename); + sprintf(pStartingMapName, "%S", pStartingMapNameW); + + v9 = 0; + if (strlen(pStartingMapName)) + { + do + { + if (pStartingMapName[v9] == ' ') + pStartingMapName[v9] = 0; + ++v9; + v2 = strlen(pStartingMapName); + } while (v9 < v2); + } + + pODMRenderParams = new ODMRenderParams; + pODMRenderParams->outdoor_no_mist = GetPrivateProfileIntW(L"debug", L"noMist", 0, pIniFilename); + pODMRenderParams->bNoSky = GetPrivateProfileIntW(L"outdoor", L"nosky", 0, pIniFilename); + pODMRenderParams->bDoNotRenderDecorations = GetPrivateProfileIntW(L"render", L"nodecorations", 0, pIniFilename); + pODMRenderParams->outdoor_no_wavy_water = GetPrivateProfileIntW(L"outdoor", L"nowavywater", 0, pIniFilename); + outdoor_grid_band_1 = GetPrivateProfileIntW(L"outdoor", L"gridband1", 10, pIniFilename); + outdoor_grid_band_2 = GetPrivateProfileIntW(L"outdoor", L"gridband2", 15, pIniFilename); + outdoor_grid_band_3 = GetPrivateProfileIntW(L"outdoor", L"gridband3", 25, pIniFilename); + pODMRenderParams->terrain_gamma = GetPrivateProfileIntW(L"outdoor", L"ter_gamma", 0, pIniFilename); + pODMRenderParams->building_gamme = GetPrivateProfileIntW(L"outdoor", L"bld_gamma", 0, pIniFilename); + pODMRenderParams->shading_dist_shade = GetPrivateProfileIntW(L"shading", L"dist_shade", 2048, pIniFilename); + pODMRenderParams->shading_dist_shademist = GetPrivateProfileIntW(L"shading", L"dist_shademist", 4096, pIniFilename); + + pODMRenderParams->shading_dist_mist = GetPrivateProfileIntW(L"shading", L"dist_mist", 0x2000, pIniFilename);//drawing dist 0x2000 + + wchar_t pDefaultSkyTextureW[1024]; + GetPrivateProfileStringW(L"textures", L"sky", L"plansky1", pDefaultSkyTextureW, 0x10u, pIniFilename); + sprintf(pDefaultSkyTexture.data(), "%S", pDefaultSkyTextureW); + + wchar_t pDefaultGroundTextureW[1024]; + GetPrivateProfileStringW(L"textures", L"default", L"dirt", pDefaultGroundTextureW, 0x10u, pIniFilename); + sprintf(pDefaultGroundTexture, "%S", pDefaultGroundTextureW); + + wchar_t pFloat[1024]; + GetPrivateProfileStringW(L"debug", L"recmod1", L"1.0", pFloat, 0x10u, pIniFilename); + swscanf(pFloat, L"%f", &flt_6BE3A4_debug_recmod1); + + GetPrivateProfileStringW(L"debug", L"recmod2", L"1.0", pFloat, 0x10u, pIniFilename); + swscanf(pFloat, L"%f", &flt_6BE3A8_debug_recmod2); + + flt_6BE3AC_debug_recmod1_x_1_6 = flt_6BE3A4_debug_recmod1 * 1.666666666666667; + + v3 = 0; + if (strlen(pDefaultSkyTexture.data())) + { + do + { + if (pDefaultSkyTexture[v3] == ' ') + pDefaultSkyTexture[v3] = 0; + ++v3; + } while (v3 < strlen(pDefaultSkyTexture.data())); + } + v4 = 0; + if (strlen(pDefaultGroundTexture)) + { + do + { + if (pDefaultGroundTexture[v4] == ' ') + pDefaultGroundTexture[v4] = 0; + ++v4; + } while (v4 < strlen(pDefaultGroundTexture)); + } + + MM7Initialization(); +} + +//----- (004666D5) -------------------------------------------------------- +void MM7Initialization() +{ + if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + /*if (byte_6BE388_graphicsmode == 0) + { + outdoor_grid_band_1 = 10; + outdoor_grid_band_2 = 15; + outdoor_grid_band_3 = 20; + pODMRenderParams->shading_dist_mist = 8192; + pODMRenderParams->bNoSky = false; + LOBYTE(viewparams->field_20) = 0; + }*/ + pODMRenderParams->shading_dist_shade = 2048; + pODMRenderParams->terrain_gamma = 0; + pODMRenderParams->building_gamme = 0; + pODMRenderParams->shading_dist_shademist = 4096; + pODMRenderParams->outdoor_no_wavy_water = 0; + //_47F4D3_initialize_terrain_bezier_stuff(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3); + { + pODMRenderParams->outdoor_grid_band_3 = outdoor_grid_band_3; + pODMRenderParams->uPickDepth = outdoor_grid_band_3 * 512; + } + } + else + LOBYTE(viewparams->field_20) = 0; + pParty->uFlags |= 2; + viewparams->uSomeY = viewparams->uScreen_topL_Y; + viewparams->uSomeX = viewparams->uScreen_topL_X; + viewparams->uSomeZ = viewparams->uScreen_BttmR_X; + viewparams->uSomeW = viewparams->uScreen_BttmR_Y; + + pViewport->SetScreen(viewparams->uScreen_topL_X, viewparams->uScreen_topL_Y, viewparams->uScreen_BttmR_X, viewparams->uScreen_BttmR_Y); + if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) + pODMRenderParams->Initialize(); +} + +//----- (004610AA) -------------------------------------------------------- +void __fastcall PrepareToLoadODM(unsigned int bLoading, ODMRenderParams *a2) +{ + pGameLoadingUI_ProgressBar->Reset(27); + pSoundList->_4A9D79(0); + uCurrentlyLoadedLevelType = LEVEL_Outdoor; + ODM_LoadAndInitialize(pCurrentMapName, a2); + if (!bLoading) + TeleportToStartingPoint(uLevel_StartingPointType); + viewparams->_443365(); + PlayLevelMusic(); +} +// 6BE35C: using guessed type int uLevel_StartingPointType; + + +//----- (004627B7) -------------------------------------------------------- +void MainMenu_Loop() +{ + GUIButton *pButton; // eax@27 + unsigned int pControlParam; // ecx@35 + unsigned int pY; // [sp-18h] [bp-54h]@39 + Texture *pTexture; // [sp-14h] [bp-50h]@39 + GUIWindow *pWindow; // [sp+4h] [bp-38h]@11 + MSG msg; + + pCurrentScreen = SCREEN_GAME; + + pGUIWindow2 = 0; + pAudioPlayer->StopChannels(-1, -1); + pMouse->RemoveHoldingItem(); + + pIcons_LOD->_inlined_sub2(); + + pWindow_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); + Texture* pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); + Texture* pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); + Texture* pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); + Texture* pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); + + pMainMenu_BtnNew = pWindow_MainMenu->CreateButton(495, 172, pNew->uTextureWidth, pNew->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowPartyCreationWnd, 0, 'N', "", pNew, 0); + pMainMenu_BtnLoad = pWindow_MainMenu->CreateButton(495, 227, pLoad->uTextureWidth, pLoad->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowLoadWindow, 1, 'L', "", pLoad, 0); + pMainMenu_BtnCredits = pWindow_MainMenu->CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0, UIMSG_ShowCredits, 2, 'C', "", pCredits, 0); + pMainMenu_BtnExit = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 3, 0, "", pExit, 0); + + pTexture_PCX.Release(); + pTexture_PCX.Load("title.pcx", 0); + SetCurrentMenuID(MENU_MAIN); + SetForegroundWindow(window->GetApiHandle()); + SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0); + while (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_SAVELOAD) + { + POINT pt; + pMouse->GetCursorPos(&pt); + pWindow = pWindow_MainMenu; + if (GetCurrentMenuID() == MENU_SAVELOAD) + { + if (pCurrentScreen != SCREEN_LOADGAME) + { + pTexture_PCX.Release(); + pTexture_PCX.Load("lsave640.pcx", 0); + pGUIWindow2 = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); + pCurrentScreen = SCREEN_LOADGAME; + LoadUI_Load(0); + } + pWindow = pGUIWindow_CurrentMenu; + } + + while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) + { + if (msg.message == WM_QUIT) + Game_DeinitializeAndTerminate(0); + TranslateMessage(&msg); + DispatchMessageW(&msg); + } + + if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE) + { + WaitMessage(); + continue; + } + + pRenderer->BeginScene(); + pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX); + + GUI_MainMenuMessageProc(); + GUI_UpdateWindows(); + + if (GetCurrentMenuID() != MENU_MAIN) + { + if (GetCurrentMenuID() == MENU_LoadingProcInMainMenu) + { + pIcons_LOD->RemoveTexturesPackFromTextureList(); + pGUIWindow_CurrentMenu->Release(); + pGUIWindow_CurrentMenu = 0; + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = 1; + } + } + else + { + if (!pModalWindow)// ??? + { + pButton = pWindow->pControlsHead; + for (pButton = pWindow->pControlsHead; pButton; pButton = pButton->pNext) + { + if (pt.x >= (signed int)pButton->uX && pt.x <= (signed int)pButton->uZ + && pt.y >= (signed int)pButton->uY && pt.y <= (signed int)pButton->uW + && pWindow == pWindow_MainMenu) + { + pControlParam = pButton->msg_param; + switch (pControlParam) // backlight for buttons + { + case 0: + pTexture = pNew; + pY = 172; + break; + case 1: + pTexture = pLoad; + pY = 227; + break; + case 2: + pTexture = pCredits; + pY = 282; + break; + case 3: + pTexture = pExit; + pY = 337; + break; + } + pRenderer->DrawTextureIndexed(495, pY, pTexture); + } + } + } + } + pRenderer->EndScene(); + pRenderer->Present(); + } + GUI_MainMenuMessageProc(); + pRenderer->BeginScene(); + GUI_UpdateWindows(); + pRenderer->EndScene(); + pRenderer->Present(); + pTexture_PCX.Release(); + if (pGUIWindow2) + { + pGUIWindow2->Release(); + pGUIWindow2 = 0; + } + pWindow_MainMenu->Release(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); +} + +//----- (004BF91E) -------------------------------------------------------- +unsigned int GameOverMenu(void *ecx0) +{ + const char *v1; // eax@2 + unsigned int result; // eax@3 + const char *v6; // eax@10 + const char *v7; // edx@10 + const char *v8; // ecx@12 + const char *v9; // eax@14 + unsigned int v10; // eax@25 + GUIWindow pWindow; // [sp+34h] [bp-9Ch]@1 + unsigned int v14; // [sp+A4h] [bp-2Ch]@5 + void *v15; // [sp+A8h] [bp-28h]@1 + const char *pInString; // [sp+ACh] [bp-24h]@5 + unsigned int v17; // [sp+B0h] [bp-20h]@5 + unsigned int v18; // [sp+B4h] [bp-1Ch]@5 + unsigned int v19; // [sp+B8h] [bp-18h]@5 + int v20; // [sp+BCh] [bp-14h]@7 + GUIFont *pFont; // [sp+C4h] [bp-Ch]@1 + unsigned __int64 v23; // [sp+C8h] [bp-8h]@5 + MSG msg; + + v15 = ecx0; + + RGBTexture _this; // [sp+Ch] [bp-C4h]@1 + //RGBTexture::RGBTexture(&this); + + dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_4000; + bGameoverLoop = 1; + pMediaPlayer->bStopBeforeSchedule = 0; + pAudioPlayer->StopChannels(-1, -1); + pRenderer->BeginScene(); + pRenderer->ClearBlack(); + pRenderer->EndScene(); + pRenderer->Present(); + //pMediaPlayer->pResetflag = 0; + _449B57_test_bit(pParty->_quest_bits, 99); + _this.Load("winbg.pcx", 2); + pRenderer->BeginScene(); + pRenderer->DrawTextureRGB(0, 0, &_this); + pRenderer->EndScene(); + free(_this.pPixels); + _this.pPixels = 0; + window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); + pWindow.uFrameX = 75; + pWindow.uFrameY = 60; + pWindow.uFrameWidth = 469; + pWindow.uFrameHeight = 338; + pWindow.uFrameZ = 543; + pWindow.uFrameW = 397; + pFont = LoadFont("endgame.fnt", "FONTPAL", NULL); + if (pParty->IsPartyGood()) + v1 = pGlobalTXT_LocalizationStrings[675];//"Splendid job! With the activation of the Gate, a thousand worlds lie at your feet. Perhaps on one of them you will find the Ancients themselves, and return with the fruits their great civilization has to offer your world and your kingdom." + else + { + result = pParty->IsPartyEvil(); + if (!(short)result) + return result; + v1 = pGlobalTXT_LocalizationStrings[676];//"Brilliant! The completion of the Heavenly Forge has provided enough Ancient weapons to crush all resistance to your plans. Soon the world will bow to your every whim! Still, you can't help but wonder what was beyond the Gate the other side was trying so hard to build." + } + pInString = v1; + v23 = pParty->uTimePlayed - 138240; + v19 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 24; + v14 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 24 / 0x1C / 0xC; + v18 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 24 / 0x1C % 0xC; + v17 = v19 % 0x1C; + if (!v19) + v19 = 1; + pRenderer->BeginScene(); + pWindow.DrawTitleText(pFont, 1, 0x23, 1, pGlobalTXT_LocalizationStrings[9], 3);//Congratulations! + v23 = 0i64; + v20 = 0; + for (uint i = 0; i < 4; i++) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[129], pParty->pPlayers[i].pName, pParty->pPlayers[i].GetBaseLevel(), pClassNames[pParty->pPlayers[i].classType]);//%s the Level %u %s + pWindow.DrawTitleText(pFont, 1, i * (LOBYTE(pFont->uFontHeight) - 2) + LOBYTE(pFont->uFontHeight) + 46, 1, pTmpBuf.data(), 3); + v23 += pParty->pPlayers[i].uExperience;//__PAIR__(*(int *)(i - 4), *(int *)(i - 8)); + } + v23 = (signed __int64)v23 / v19; + v6 = FitTextInAWindow(pInString, pFont, &pWindow, 0xC, 0); + pWindow.DrawTitleText(pFont, 1, 5 * (LOBYTE(pFont->uFontHeight) + 11), 1, v6, 0); + strcpy(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[37]);//Total Time: + + v7 = pGlobalTXT_LocalizationStrings[56]; + if (v17 != 1) + v7 = pGlobalTXT_LocalizationStrings[57]; + + v8 = pGlobalTXT_LocalizationStrings[146];//Month + if (v18 != 1) + v8 = pGlobalTXT_LocalizationStrings[148];//Months + + v9 = pGlobalTXT_LocalizationStrings[245]; + if (v14 != 1) + v9 = pGlobalTXT_LocalizationStrings[132]; + + sprintf(pTmpBuf2.data(), " %lu %s, %lu %s, %lu %s ", v14, v9, v18, v8, v17, v7); + strcat(pTmpBuf.data(), pTmpBuf2.data()); + pWindow.DrawTitleText(pFont, 1, pWindow.uFrameHeight - 2 * LOBYTE(pFont->uFontHeight) - 5, 1, pTmpBuf.data(), 3); + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[94], v23); + pWindow.DrawTitleText(pFont, 1, pWindow.uFrameHeight, 1, pTmpBuf.data(), 3); + dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; + pRenderer->EndScene(); + pRenderer->Present(); + //if ( pRenderer->pRenderD3D ) + pRenderer->pBeforePresentFunction(); + pRenderer->SaveWinnersCertificate("MM7_Win.Pcx"); + free(pFont); + window_SpeakInHouse->Release(); + window_SpeakInHouse = 0; + if (v15 == (void *)2) + result = pMessageQueue_50CBD0->uNumMessages; + else + { + LODWORD(v23) = GetTickCount() + 5000; + while ((unsigned int)v23 > GetTickCount()) + ; + while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) + { + if (msg.message == WM_QUIT) + Game_DeinitializeAndTerminate(0); + TranslateMessage(&msg); + DispatchMessage(&msg); + } + if (pMessageQueue_50CBD0->uNumMessages) + { + LOBYTE(v10) = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pMessageQueue_50CBD0->uNumMessages = v10; + } + pKeyActionMap->ResetKeys(); + pKeyActionMap->uLastKeyPressed = 0; + do + { + while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) + { + if (msg.message == WM_QUIT) + Game_DeinitializeAndTerminate(0); + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } while (!pKeyActionMap->uLastKeyPressed); + result = pMessageQueue_50CBD0->uNumMessages; + if (pMessageQueue_50CBD0->uNumMessages) + { + result = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + } + } + if (v15) + { + /*if ( (signed int)result < 40 ) + { + pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_Quit; + }*/ + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Quit, 1, 0); + } + else + { + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ShowFinalWindow, 1, 0); + /*if ( (signed int)result < 40 ) + { + pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_C5; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; + result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; + *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; + ++pMessageQueue_50CBD0->uNumMessages; + }*/ + } + bGameoverLoop = 0; + return result; +} + +//----- (00464479) -------------------------------------------------------- +void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows() +{ + int v0; // esi@9 + + if (pMouse) + pMouse->SetCursorBitmap("MICON1"); + + pPaletteManager->ResetNonLocked(); + pBitmaps_LOD->ReleaseAll2(); + pSprites_LOD->DeleteSomeOtherSprites(); + pIcons_LOD->ReleaseAll2(); + + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + pIndoor->Release(); + else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) + pOutdoor->Release(); + + pAudioPlayer->StopChannels(-1, -1); + pSoundList->_4A9D79(0); + uCurrentlyLoadedLevelType = LEVEL_null; + pSpriteFrameTable->ResetSomeSpriteFlags(); + v0 = uNumVisibleWindows; + pParty->armageddon_timer = 0; + while (v0 > 0) + pWindowList[pVisibleWindowsIdxs[v0--] - 1].Release(); +} + +//----- (00461103) -------------------------------------------------------- +void _461103_load_level_sub() +{ + int v4; // edx@8 + signed int v6; // esi@14 + signed int v8; // ecx@16 + int v12; // esi@25 + int v13; // eax@26 + __int16 v14; // ax@41 + signed int v17; // [sp+14h] [bp-48h]@3 + signed int v18; // [sp+14h] [bp-48h]@23 + int v19; // [sp+18h] [bp-44h]@1 + signed int v20; // [sp+18h] [bp-44h]@14 + int v21[16]; // [sp+1Ch] [bp-40h]@17 + + GenerateItemsInChest(); + pGameLoadingUI_ProgressBar->Progress(); + pParty->uFlags |= 2; + pParty->field_7B5_in_arena_quest = 0; + dword_5C6DF8 = 1; + pNPCStats->uNewlNPCBufPos = 0; + v19 = pMapStats->GetMapInfo(pCurrentMapName); + + //v15 = 0; + for (uint i = 0; i < uNumActors; ++i) + //if ( (signed int)uNumActors > 0 ) + { + //Actor* pActor = &pActors[i]; + //v2 = (char *)&pActors[0].uNPC_ID; + //do + //{ + //v3 = pActors[i].pMonsterInfo.uID; + v17 = 0; + if (pActors[i].pMonsterInfo.uID >= 115 && pActors[i].pMonsterInfo.uID <= 186 + || pActors[i].pMonsterInfo.uID >= 232 && pActors[i].pMonsterInfo.uID <= 249) + v17 = 1; + //v1 = 0; + v4 = (pActors[i].pMonsterInfo.uID - 1) % 3; + if (2 == v4) + { + if (pActors[i].sNPC_ID && pActors[i].sNPC_ID < 5000) + continue; + } + else + { + if (v4 != 1) + { + if (v4 == 0 && pActors[i].sNPC_ID == 0) + pActors[i].sNPC_ID = 0; + continue; + } + } + if (pActors[i].sNPC_ID > 0 && pActors[i].sNPC_ID < 5000) + continue; + if (v17) + { + pNPCStats->InitializeAdditionalNPCs(&pNPCStats->pAdditionalNPC[pNPCStats->uNewlNPCBufPos], pActors[i].pMonsterInfo.uID, 0, v19); + v14 = LOWORD(pNPCStats->uNewlNPCBufPos) + 5000; + ++pNPCStats->uNewlNPCBufPos; + pActors[i].sNPC_ID = v14; + continue; + } + pActors[i].sNPC_ID = 0; + //++v15; + //v2 += 836; + //} + //while ( v15 < (signed int)uNumActors ); + } + + pGameLoadingUI_ProgressBar->Progress(); + + //v5 = uNumActors; + v6 = 0; + v20 = 0; + //v16 = v1; + + for (uint i = 0; i < uNumActors; ++i) + { + //v7 = (char *)&pActors[0].pMonsterInfo; + //do + //{ + for (v8 = 0; v8 < v6; ++v8) + { + if (v21[v8] == pActors[i].pMonsterInfo.uID - 1) + break; + } + + if (v8 == v6) + { + v21[v6++] = pActors[i].pMonsterInfo.uID - 1; + v20 = v6; + if (v6 == 16) + break; + } + //++v16; + //v7 += 836; + //} + //while ( v16 < (signed int)v5 ); + } + + pGameLoadingUI_ProgressBar->Progress(); + + for (int _v0 = 0; _v0 < v6; ++_v0) + { + for (v18 = 4; v18; --v18) + pSoundList->LoadSound(pMonsterList->pMonsters[v21[_v0]].pSoundSampleIDs[4 - v18], 0); + v12 = 0; + do + v13 = pSoundList->LoadSound(v12++ + word_4EE088_sound_ids[pMonsterStats->pInfos[v21[_v0] + 1].uSpell1ID], 1); + while (v13); + } + //v0 = pGameLoadingUI_ProgressBar; + //v1 = 0; + + pGameLoadingUI_ProgressBar->Progress(); + + if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_ACTORS) + uNumActors = 0; + if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_DECORATIONS) + uNumLevelDecorations = 0; + init_event_triggers(); + + pGameLoadingUI_ProgressBar->Progress(); + + pGame->pIndoorCameraD3D->vPartyPos.x = 0; + pGame->pIndoorCameraD3D->vPartyPos.y = 0; + pGame->pIndoorCameraD3D->vPartyPos.z = 100; + pGame->pIndoorCameraD3D->sRotationX = 0; + pGame->pIndoorCameraD3D->sRotationY = 0; + viewparams->bRedrawGameUI = true; + uLevel_StartingPointType = MapStartPoint_Party; + pSprites_LOD->_461397(); + pPaletteManager->LockTestAll(); + if (pParty->pPickedItem.uItemID != 0) + pMouse->SetCursorBitmapFromItemID(pParty->pPickedItem.uItemID); +} + +//----- (0042F3D6) -------------------------------------------------------- +void InitializeTurnBasedAnimations(void *_this) +{ + for (unsigned int i = 0; i < pIconIDs_Turn.size(); ++i) + { + char icon_name[32]; + sprintf(icon_name, "turn%u", i); + pIconIDs_Turn[i] = pIconsFrameTable->FindIcon(icon_name); + pIconsFrameTable->InitializeAnimation(pIconIDs_Turn[i]); + } + + uIconID_TurnStop = pIconsFrameTable->FindIcon("turnstop"); + uIconID_TurnHour = pIconsFrameTable->FindIcon("turnhour"); + uIconID_TurnStart = pIconsFrameTable->FindIcon("turnstart"); + uIconID_CharacterFrame = pIconsFrameTable->FindIcon("aframe1"); + uSpriteID_Spell11 = pSpriteFrameTable->FastFindSprite("spell11"); + + pIconsFrameTable->InitializeAnimation(uIconID_TurnHour); + pIconsFrameTable->InitializeAnimation(uIconID_TurnStop); + pIconsFrameTable->InitializeAnimation(uIconID_TurnStart); + pIconsFrameTable->InitializeAnimation(uIconID_CharacterFrame); +} + +//----- (00466C40) -------------------------------------------------------- +const wchar_t *MENU_STATE_to_string(MENU_STATE m) +{ + switch (m) + { + case -1: return L"-1"; + case MENU_MAIN: return L"MENU_MAIN"; + case MENU_NEWGAME: return L"MENU_NEWGAME"; + case MENU_CREDITS: return L"MENU_CREDITS"; + case MENU_SAVELOAD: return L"MENU_SAVELOAD"; + case MENU_EXIT_GAME: return L"MENU_EXIT_GAME"; + case MENU_5: return L"MENU_5"; + case MENU_CREATEPARTY: return L"MENU_CREATEPARTY"; + case MENU_NAMEPANELESC: return L"MENU_NAMEPANELESC"; + case MENU_CREDITSPROC: return L"MENU_CREDITSPROC"; + case MENU_LoadingProcInMainMenu: return L"MENU_LoadingProcInMainMenu"; + case MENU_DebugBLVLevel: return L"MENU_DebugBLVLevel"; + case MENU_CREDITSCLOSE: return L"MENU_CREDITSCLOSE"; + case MENU_MMT_MAIN_MENU: return L"MENU_MMT_MAIN_MENU"; + default: return L"unk"; + }; +}; +void SetCurrentMenuID(MENU_STATE uMenu) +{ + sCurrentMenuID = uMenu; + + Log::Warning(L"CurrentMenu = %s \n", MENU_STATE_to_string(uMenu)); +} + +//----- (00466CA0) -------------------------------------------------------- +MENU_STATE GetCurrentMenuID() +{ + return sCurrentMenuID; +} + +//----- (0046BDA8) -------------------------------------------------------- +unsigned int GetGravityStrength() +{ + int v0; // eax@1 + + v0 = ~LOBYTE(pGame->uFlags2) & 8; + LOBYTE(v0) = v0 | 2; + return (unsigned int)v0 >> 1; +} + +//----- (00448B45) -------------------------------------------------------- +void GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide) +{ + if (bForceHide || GameUI_Footer_TimeLeft && GetTickCount() >= GameUI_Footer_TimeLeft) + GameUI_Footer_TimeLeft = 0; +} + +//----- (0044861E) -------------------------------------------------------- +void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename) +{ + unsigned int texture; // eax@2 + + if (uFaceCog) + { + texture = pBitmaps_LOD->LoadTexture(pFilename); + if (texture != -1 ? (int)&pBitmaps_LOD->pTextures[texture] : 0) + { + pBitmaps_LOD->pTextures[texture].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[texture].palette_id1); + + if (uCurrentlyLoadedLevelType == 1) + { + if ((signed int)pIndoor->uNumFaceExtras > 1) + { + for (uint i = 1; i < (signed int)pIndoor->uNumFaceExtras; ++i) + { + if (pIndoor->pFaceExtras[i].sCogNumber == uFaceCog) + { + if (pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes & FACE_TEXTURE_FRAME) + { + pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = pTextureFrameTable->FindTextureByName(pFilename); + if (pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID) + { + pTextureFrameTable->LoadAnimationSequenceAndPalettes(pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID); + } + else + { + pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture; + pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes &= 0xFFFFBFFF; + } + } + else + { + pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture; + } + } + } + } + pParty->uFlags |= 2; + } + else + { + for (uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j) + { + for (uint i = 0; i < pOutdoor->pBModels[j].uNumFaces; ++i) + { + if (pOutdoor->pBModels[j].pFaces[i].sCogNumber == uFaceCog) + { + if (pOutdoor->pBModels[j].pFaces[i].uAttributes & FACE_TEXTURE_FRAME) + { + pOutdoor->pBModels[j].pFaces[i].uTextureID = pTextureFrameTable->FindTextureByName(pFilename); + if (pOutdoor->pBModels[j].pFaces[i].uTextureID) + pTextureFrameTable->LoadAnimationSequenceAndPalettes(pOutdoor->pBModels[j].pFaces[i].uTextureID); + else + { + pOutdoor->pBModels[j].pFaces[i].uTextureID = texture; + pOutdoor->pBModels[j].pFaces[i].uAttributes &= 0xFFFFBFFF; + } + } + else + pOutdoor->pBModels[j].pFaces[i].uTextureID = texture; + } + } + } + } + pParty->uFlags |= 2; + } + } +} + +//----- (0044892E) -------------------------------------------------------- +void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on) +{ + if (sCogNumber) + { + if (uCurrentlyLoadedLevelType == 1) + { + for (uint i = 1; i < (unsigned int)pIndoor->uNumFaceExtras; ++i) + { + if (pIndoor->pFaceExtras[i].sCogNumber == sCogNumber) + { + if (on) + pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes |= bit; + else + pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes &= ~bit; + } + } + pParty->uFlags |= 2; + } + else + { + for (uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j) + { + for (uint i = 0; i < (unsigned int)pOutdoor->pBModels[j].uNumFaces; ++i) + { + if (pOutdoor->pBModels[j].pFaces[i].sCogNumber == sCogNumber) + { + if (on) + pOutdoor->pBModels[j].pFaces[i].uAttributes |= bit; + else + pOutdoor->pBModels[j].pFaces[i].uAttributes &= ~bit; + } + } + } + } + pParty->uFlags |= 2; + } +} + +//----- (0044882F) -------------------------------------------------------- +void __fastcall SetDecorationSprite(uint16_t uCog, bool bHide, const char *pFileName) +{ + for (size_t i = 0; i < uNumLevelDecorations; i++) + { + if (pLevelDecorations[i].uCog == uCog) + { + if (pFileName && strcmp(pFileName, "0")) + { + pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(pFileName); + pDecorationList->InitializeDecorationSprite(pLevelDecorations[i].uDecorationDescID); + } + + if (bHide) + pLevelDecorations[i].uFlags &= ~LEVEL_DECORATION_INVISIBLE; + else + pLevelDecorations[i].uFlags |= LEVEL_DECORATION_INVISIBLE; + + pParty->uFlags |= 2; + } + } +} + +//----- (004356FF) -------------------------------------------------------- +void back_to_game() +{ + dword_507BF0_is_there_popup_onscreen = 0; + dword_4E455C = 1; + + extern int no_rightlick_in_inventory; + no_rightlick_in_inventory = false; + + if (pGUIWindow_ScrollWindow) + free_book_subwindow(); + if (!pCurrentScreen && !pGUIWindow_Settings) + pEventTimer->Resume(); + viewparams->bRedrawGameUI = 1; +} + +//----- (00494035) -------------------------------------------------------- +void _494035_timed_effects__water_walking_damage__etc() +{ + signed __int64 v0; // qax@1 + unsigned int v4; // edi@1 + // signed int v12; // edi@29 + int v24; // ecx@60 + int v26; // ecx@64 + int v28; // ecx@68 + int v30; // ecx@72 + int v32; // ecx@76 + int v34; // ecx@80 + int v36; // ecx@84 + int v38; // ecx@88 + int v40; // ecx@92 + int v42; // ecx@96 + bool v43; // ebx@102 + bool v46; // edi@111 + // unsigned int v56; // [sp-8h] [bp-38h]@55 + // int v59; // [sp-4h] [bp-34h]@55 + // unsigned int v61; // [sp+14h] [bp-1Ch]@1 + signed int a2a; // [sp+18h] [bp-18h]@47 + signed int old_day; // [sp+1Ch] [bp-14h]@47 + signed int old_hour; + + old_day = pParty->uDaysPlayed; + old_hour = pParty->uCurrentHour; + //auto prev_time = pEventTimer->uTimeElapsed; + pParty->uTimePlayed += pEventTimer->uTimeElapsed; + v0 = ((signed __int64)(pParty->uTimePlayed * 0.234375) / 60) / 60i64; + v4 = (unsigned int)(((unsigned int)v0 / 24) / 7) >> 2; + pParty->uCurrentTimeSecond = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) % 60; + pParty->uCurrentMinute = ((signed __int64)(pParty->uTimePlayed * 0.234375) / 60) % 60; + pParty->uCurrentHour = v0 % 24; + pParty->uCurrentMonthWeek = ((unsigned int)v0 / 24) / 7 & 3; + pParty->uDaysPlayed = (unsigned int)((unsigned int)v0 / 24) % 28; + pParty->uCurrentMonth = v4 % 12; + pParty->uCurrentYear = v4 / 0xC + game_starting_year; + if (pParty->uCurrentHour >= 3 && (old_hour < 3 || pParty->uDaysPlayed > old_day)) // new day dawns + { + pParty->pHirelings[0].bHasUsedTheAbility = false; + pParty->pHirelings[1].bHasUsedTheAbility = false; + + for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i) + pNPCStats->pNewNPCData[i].bHasUsedTheAbility = false; + + ++pParty->days_played_without_rest; + if (pParty->days_played_without_rest > 1) + { + for (uint i = 0; i < 4; ++i) + pParty->pPlayers[i].SetCondWeakWithBlockCheck(0); + + if (pParty->uNumFoodRations) + Party::TakeFood(1); + else + for (uint i = 0; i < 4; ++i) + pParty->pPlayers[i].sHealth = pParty->pPlayers[i].sHealth / (pParty->days_played_without_rest + 1) + 1; + + if (pParty->days_played_without_rest > 3) + for (uint i = 0; i < 4; ++i) + { + pParty->pPlayers[i].Zero(); + if (!pParty->pPlayers[i].IsPertified() && !pParty->pPlayers[i].IsEradicated() + && !pParty->pPlayers[i].IsDead()) + { + if (rand() % 100 < 5 * pParty->days_played_without_rest) + pParty->pPlayers[i].SetCondDeadWithBlockCheck(0); + if (rand() % 100 < 10 * pParty->days_played_without_rest) + pParty->pPlayers[i].SetCondInsaneWithBlockCheck(0); + } + } + } + if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) + pOutdoor->SetFog(); + + for (uint i = 0; i < 4; ++i) + pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0; + } + + if (pParty->uFlags & 4 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed)//water damage + { + pParty->field_6FC = (signed __int64)pParty->uTimePlayed + 128; + viewparams->bRedrawGameUI = true; + for (uint pl = 1; pl <= 4; ++pl) + { + if (pPlayers[pl]->WearsItem(ITEM_RELIC_HARECS_LEATHER, EQUIP_ARMOUR) + || pPlayers[pl]->HasEnchantedItemEquipped(71) + || pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_WATER_WALK].uExpireTime > 0) + pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_37, 0); + else + { + if (!pPlayers[pl]->HasUnderwaterSuitEquipped()) + { + pPlayers[pl]->ReceiveDamage((signed __int64)pPlayers[pl]->GetMaxHealth() * 0.1, DMGT_FIRE); + if (pParty->uFlags & 4) + { + strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[660]);// Âû òîíåòå! + GameUI_Footer_TimeLeft = 128; + } + } + else + pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_37, 0); + } + } + } + if (pParty->uFlags & 0x200 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed) //lava damage + { + viewparams->bRedrawGameUI = true; + pParty->field_6FC = (signed __int64)pParty->uTimePlayed + 128; + + for (uint pl = 1; pl <= 4; pl++) + { + pPlayers[pl]->ReceiveDamage((signed __int64)pPlayers[pl]->GetMaxHealth() * 0.1, DMGT_FIRE); + if (pParty->uFlags & 0x200) + { + strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[661]); //Âû ãîðèòå! + GameUI_Footer_TimeLeft = 128; + } + } + } + _493938_regenerate(); + uint party_condition_flag = 4; + a2a = pEventTimer->uTimeElapsed; + if (pParty->uFlags2 & PARTY_FLAGS_2_RUNNING)//çàìåäëåíèå âîññòàíîâëåíèÿ ïðè áåãå + { + a2a *= 0.5f; + if (a2a < 1) + a2a = 1; + } + + for (uint pl = 1; pl <= 4; pl++) + { + if (pPlayers[pl]->uTimeToRecovery) + pPlayers[pl]->Recover(a2a);//âîññòàíîâëåíèå àêòèâíîñòè + if (pPlayers[pl]->GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) + pPlayers[pl]->sHealth + pPlayers[pl]->uEndurance >= 1 + || (signed __int64)pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0) + { + if (pPlayers[pl]->sHealth < 1) + pPlayers[pl]->SetCondition(Condition_Unconcious, 0); + } + else + pPlayers[pl]->SetCondition(Condition_Dead, 0); + if (pPlayers[pl]->field_E0) + { + v24 = pPlayers[pl]->field_E0 - pEventTimer->uTimeElapsed; + if (v24 > 0) + pPlayers[pl]->field_E0 = v24; + else + { + pPlayers[pl]->field_E0 = 0; + viewparams->bRedrawGameUI = true; + } + } + if (pPlayers[pl]->field_E4) + { + v26 = pPlayers[pl]->field_E4 - pEventTimer->uTimeElapsed; + if (v26 > 0) + pPlayers[pl]->field_E4 = v26; + else + { + pPlayers[pl]->field_E4 = 0; + viewparams->bRedrawGameUI = true; + } + } + if (pPlayers[pl]->field_E8) + { + v28 = pPlayers[pl]->field_E8 - pEventTimer->uTimeElapsed; + if (v28 > 0) + pPlayers[pl]->field_E8 = v28; + else + { + pPlayers[pl]->field_E8 = 0; + viewparams->bRedrawGameUI = true; + } + } + if (pPlayers[pl]->field_EC) + { + v30 = pPlayers[pl]->field_EC - pEventTimer->uTimeElapsed; + if (v30 > 0) + pPlayers[pl]->field_EC = v30; + else + { + pPlayers[pl]->field_EC = 0; + viewparams->bRedrawGameUI = true; + } + } + if (pPlayers[pl]->field_F0) + { + v32 = pPlayers[pl]->field_F0 - pEventTimer->uTimeElapsed; + if (v32 > 0) + pPlayers[pl]->field_F0 = v32; + else + { + pPlayers[pl]->field_F0 = 0; + viewparams->bRedrawGameUI = true; + } + } + if (pPlayers[pl]->field_F4) + { + v34 = pPlayers[pl]->field_F4 - pEventTimer->uTimeElapsed; + if (v34 > 0) + pPlayers[pl]->field_F4 = v34; + else + { + pPlayers[pl]->field_F4 = 0; + viewparams->bRedrawGameUI = true; + } + } + if (pPlayers[pl]->field_F8) + { + v36 = pPlayers[pl]->field_F8 - pEventTimer->uTimeElapsed; + if (v36 > 0) + pPlayers[pl]->field_F8 = v36; + else + { + pPlayers[pl]->field_F8 = 0; + viewparams->bRedrawGameUI = true; + } + } + if (pPlayers[pl]->field_FC) + { + v38 = pPlayers[pl]->field_FC - pEventTimer->uTimeElapsed; + if (v38 > 0) + pPlayers[pl]->field_FC = v38; + else + { + pPlayers[pl]->field_FC = 0; + viewparams->bRedrawGameUI = true; + } + } + if (pPlayers[pl]->field_100) + { + v40 = pPlayers[pl]->field_100 - pEventTimer->uTimeElapsed; + if (v40 > 0) + pPlayers[pl]->field_100 = v40; + else + { + pPlayers[pl]->field_100 = 0; + viewparams->bRedrawGameUI = true; + } + } + if (pPlayers[pl]->field_104) + { + v42 = pPlayers[pl]->field_104 - pEventTimer->uTimeElapsed; + if (v42 > 0) + pPlayers[pl]->field_104 = v42; + else + { + pPlayers[pl]->field_104 = 0; + viewparams->bRedrawGameUI = true; + } + } + if (pPlayers[pl]->pConditions[Condition_Sleep] | pPlayers[pl]->pConditions[Condition_Paralyzed] + | pPlayers[pl]->pConditions[Condition_Unconcious] | pPlayers[pl]->pConditions[Condition_Dead] + | pPlayers[pl]->pConditions[Condition_Pertified] | pPlayers[pl]->pConditions[Condition_Eradicated]) + --party_condition_flag; + v43 = (signed __int64)pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime > 0; //ñïåøêà + + for (uint k = 0; k < 24; ++k) + pPlayers[pl]->pPlayerBuffs[k].IsBuffExpiredToTime(pParty->uTimePlayed); + + if (v43 && (signed __int64)pPlayers[pl]->pPlayerBuffs[7].uExpireTime <= 0) + pPlayers[pl]->SetCondition(Condition_Weak, 0); + } + + v46 = (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime > 0; + + for (uint i = 0; i < 20; ++i) + { + if (pParty->pPartyBuffs[i].IsBuffExpiredToTime(pParty->uTimePlayed) == 1) + viewparams->bRedrawGameUI = true; + } + + if (v46 && (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime <= 0) + { + for (uint i = 0; i < 4; ++i) + pParty->pPlayers[i].SetCondition(1, 0); + } + + for (uint i = 0; i < 2; ++i)//Ïðîâåðêà â ñîçíàíèè ëè ïåðñ ñäåëàâøèé çàêë íà ïîë¸ò è õîæäåíèå ïî âîäå + { + SpellBuff* pBuf = &pParty->pPartyBuffs[Party_Spec_Motion_status_ids[i]]; + if (pBuf->uExpireTime == 0) + continue; + + if (!(pBuf->uFlags & 1)) + { + if (!pPlayers[pBuf->uCaster]->CanAct()) + { + pBuf->Reset(); + if (Party_Spec_Motion_status_ids[i] == PARTY_BUFF_FLY) + pParty->bFlying = false; + } + } + } + + if (!party_condition_flag) + { + if (pCurrentScreen != SCREEN_REST) + { + for (uint pl = 1; pl <= 4; pl++) + { + if (pPlayers[pl]->pConditions[Condition_Sleep]) + { + pPlayers[pl]->pConditions[Condition_Sleep] = 0; + party_condition_flag = 1; + break; + } + } + if (!party_condition_flag || _5C35C0_force_party_death) + uGameState = GAME_STATE_PARTY_DIED; + } + } + + if (uActiveCharacter)//âûáîð ñëåäóþùåãî ïîñëå ïðîïóñêàþùåãî õîä + { + if (pCurrentScreen != SCREEN_REST) + { + if (pPlayers[uActiveCharacter]->pConditions[Condition_Sleep] + || pPlayers[uActiveCharacter]->pConditions[Condition_Paralyzed] + || pPlayers[uActiveCharacter]->pConditions[Condition_Unconcious] + || pPlayers[uActiveCharacter]->pConditions[Condition_Dead] + || pPlayers[uActiveCharacter]->pConditions[Condition_Pertified] + || pPlayers[uActiveCharacter]->pConditions[Condition_Eradicated]) + { + viewparams->bRedrawGameUI = true; + uActiveCharacter = pParty->GetNextActiveCharacter(); + } + } + } +} + +//----- (00493938) -------------------------------------------------------- +void _493938_regenerate() +{ + int current_time; // edi@1 + int last_reg_time; // qax@1 + int v4; // eax@2 + int v5; // edi@5 + long long *v6; // ecx@5 + char v7; // sf@5 + int *v8; // ecx@10 + int v9; // edi@15 + signed int v10; // eax@15 + // __int16 *v11; // edx@16 + // int v12; // eax@20 + int numberOfActorsAffected; // ebx@20 + unsigned int v14; // esi@21 + //unsigned int v15; // ecx@21 + //unsigned int v16; // eax@21 + // int v18; // eax@21 + signed int v19; // eax@21 + bool recovery_HP; // ebx@25 + // ITEM_EQUIP_TYPE v22; // edi@30 + signed int v25; // eax@33 + // int v26; // eax@35 + // int v27; // eax@36 + // int v28; // eax@37 + signed int v31; // ecx@53 + int actorsAffectedByImmolation[100]; // [sp+4h] [bp-22Ch]@20 + SpriteObject a1; // [sp+194h] [bp-9Ch]@15 + Vec3_int_ a3; // [sp+204h] [bp-2Ch]@15 + bool has_dragon_flag; // [sp+210h] [bp-20h]@22 + bool lich_jar_flag; // [sp+214h] [bp-1Ch]@25 + bool zombie_flag; // [sp+218h] [bp-18h]@25 + bool decrease_HP; // [sp+21Ch] [bp-14h]@25 + bool lich_flag; // [sp+220h] [bp-10h]@25 + int v49; // [sp+224h] [bp-Ch]@24 + bool recovery_SP; // [sp+228h] [bp-8h]@25 + bool redraw_flag; // [sp+22Ch] [bp-4h]@2 + + current_time = (signed int)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 60; + last_reg_time = (signed int)(signed __int64)((double)pParty->uLastRegenerationTime * 0.234375) / 60; + if (current_time >= (signed int)last_reg_time + 5) + { + redraw_flag = false; + v4 = (current_time - last_reg_time) / 5; + if (pParty->FlyActive()) + { + if (pParty->bFlying) + { + if (!(pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1)) + { + v5 = v4 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uPower; + //cursed_flag = pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].pConditions[Condition_Cursed];//cursed + //v7 = cursed_flag < v5; + //cursed_flag -= v5; + + v6 = &pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].pConditions[Condition_Cursed]; + + if (*v6 < v5) + { + v6 = 0; + pParty->uFlags &= 0xFFFFFFBFu; + pParty->bFlying = false; + redraw_flag = true; + } + } + } + } + + if (pParty->WaterWalkActive()) + { + if (pParty->uFlags & PARTY_FLAGS_1_STANDING_ON_WATER) + { + if (!(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1)) + { // taking on water + v8 = (int *)&pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].pConditions[Condition_Cursed];//&AA1058_PartyQuickSpellSound[4].pSounds[6972 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster + 2000]; + v7 = *v8 < v4; + *v8 -= v4; + if (v7) + { + *v8 = 0; + pParty->uFlags &= ~PARTY_FLAGS_1_STANDING_ON_WATER; + redraw_flag = true; + } + } + } + } + + if (pParty->ImmolationActive())//Æåðòâà + { + a3.z = 0; + a3.y = 0; + a3.x = 0; + a1.stru_24.Reset(); + a1.spell_level = pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].uPower; + a1.spell_skill = pParty->ImmolationSkillLevel(); + v10 = 0; + a1.uType = 1070; + a1.spell_id = SPELL_FIRE_IMMOLATION; + v10 = 0; + for (uint i = 0; i > pObjectList->uNumObjects; i++) + { + if (pObjectList->pObjects[i].uObjectID == stru_4E3ACC[8].uType) + v10 = i; + } + a1.uObjectDescID = v10; + a1.field_60_distance_related_prolly_lod = 0; + a1.uAttributes = 0; + a1.uSectorID = 0; + a1.uSpriteFrameID = 0; + a1.spell_caster_pid = PID(OBJECT_Player, pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].uCaster); + a1.uFacing = 0; + a1.uSoundID = 0; + numberOfActorsAffected = pParty->_46A89E_immolation_effect(actorsAffectedByImmolation, 100, 307); + for (v9 = 0; v9 < numberOfActorsAffected; ++v9) + { + v14 = actorsAffectedByImmolation[v9]; + a1.vPosition.x = pActors[v14].vPosition.x; + a1.vPosition.y = pActors[v14].vPosition.y; + a1.vPosition.z = pActors[v14].vPosition.z; + a1.spell_target_pid = PID(OBJECT_Actor, v14); + v19 = a1.Create(0, 0, 0, 0); + Actor::DamageMonsterFromParty(PID(OBJECT_Item, v19), v14, &a3); + } + } + + has_dragon_flag = false; + if (PartyHasDragon()) + has_dragon_flag = true; + + for (v49 = 0; v49 < 4; v49++) + { + recovery_HP = false; + recovery_SP = false; + decrease_HP = false; + lich_flag = false; + lich_jar_flag = false; + zombie_flag = false; + + for (int v22 = 0; (signed int)v22 < 16; v22++) + { + if (pParty->pPlayers[v49].HasItemEquipped((ITEM_EQUIP_TYPE)v22)) + { + uint _idx = pParty->pPlayers[v49].pEquipment.pIndices[v22]; + if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID > 134) + { + if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_RELIC_ETHRICS_STAFF) + decrease_HP = true; + if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_HERMES_SANDALS) + { + recovery_HP = true; + recovery_SP = true; + } + if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_MINDS_EYE) + recovery_SP = true; + if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_HEROS_BELT) + recovery_HP = true; + } + else + { + v25 = pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uSpecEnchantmentType; + if (v25 == 37 //of Regeneration("Regenerate 1hp/x while walking, etc") + || v25 == 44 //of Life("HP (+10), Regen hpts") + || v25 == 50 //of The Phoenix("Fire Res (+30), Regen hpts") && + || v25 == 54)// of The Troll("End (+15), Regen hpts") + recovery_HP = true; + if (v25 == 38 //of Mana("Regenerate 1sp/x while walking, etc") + || v25 == 47 //of The Eclipse("SP (+10), Regen spts") + || v25 == 55)//of The Unicorn("Luck (+15), Regen spts") + recovery_SP = true; + if (v25 == 66)// of Plenty("Regenerate 1 hp/x and 1 sp/x while walking, etc.") + { + recovery_HP = true; + recovery_SP = true; + } + } + + if (recovery_HP && + !pParty->pPlayers[v49].pConditions[Condition_Dead] && + !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) + { + if (pParty->pPlayers[v49].sHealth < pParty->pPlayers[v49].GetMaxHealth()) + ++pParty->pPlayers[v49].sHealth; + if (pParty->pPlayers[v49].pConditions[Condition_Unconcious] && pParty->pPlayers[v49].sHealth > 0) + pParty->pPlayers[v49].pConditions[Condition_Unconcious] = 0; + redraw_flag = true; + } + + if (recovery_SP && + !pParty->pPlayers[v49].pConditions[Condition_Dead] && + !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) + { + if (pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana()) + ++pParty->pPlayers[v49].sMana; + redraw_flag = true; + } + + if (decrease_HP && + !pParty->pPlayers[v49].pConditions[Condition_Dead] && + !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) + { + --pParty->pPlayers[v49].sHealth; + if (!(pParty->pPlayers[v49].pConditions[Condition_Unconcious]) && pParty->pPlayers[v49].sHealth < 0) + pParty->pPlayers[v49].pConditions[Condition_Unconcious] = pParty->uTimePlayed; + if (pParty->pPlayers[v49].sHealth < 1) + { + if (pParty->pPlayers[v49].sHealth + pParty->pPlayers[v49].uEndurance + pParty->pPlayers[v49].GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) >= 1 + || (signed __int64)pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0) + pParty->pPlayers[v49].pConditions[Condition_Unconcious] = pParty->uTimePlayed; + else + { + if (!pParty->pPlayers[v49].pConditions[Condition_Dead]) + pParty->pPlayers[v49].pConditions[Condition_Dead] = pParty->uTimePlayed; + } + } + redraw_flag = true; + } + } + } + + //regeneration + if (pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_REGENERATION].uExpireTime > 0 + && !pParty->pPlayers[v49].pConditions[Condition_Dead] + && !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) + { + pParty->pPlayers[v49].sHealth += 5 * pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_REGENERATION].uPower; + if (pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth()) + pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].GetMaxHealth(); + if (pParty->pPlayers[v49].pConditions[Condition_Unconcious] && pParty->pPlayers[v49].sHealth > 0) + pParty->pPlayers[v49].pConditions[Condition_Unconcious] = 0; + redraw_flag = true; + } + + //for warlock + if (has_dragon_flag && pParty->pPlayers[v49].classType == PLAYER_CLASS_WARLOCK) + { + if (pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana()) + ++pParty->pPlayers[v49].sMana; + redraw_flag = true; + } + + //for lich + if (pParty->pPlayers[v49].classType == PLAYER_CLASS_LICH) + { + for (v31 = 0; v31 < 126; ++v31) + { + if (pParty->pPlayers[v49].pInventoryItemList[v31].uItemID == ITEM_LICH_JAR_FULL) + lich_jar_flag = true; + } + lich_flag = true; + } + if (lich_flag && !pParty->pPlayers[v49].pConditions[Condition_Dead] + && !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) + { + if (pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() / 2) + pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].sHealth - 2; + if (pParty->pPlayers[v49].sMana > pParty->pPlayers[v49].GetMaxMana() / 2) + pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].sMana - 2; + } + if (lich_jar_flag) + { + if (pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana()) + ++pParty->pPlayers[v49].sMana; + } + + //for zombie + if (pParty->pPlayers[v49].pConditions[Condition_Zombie]) + zombie_flag = true; + if (zombie_flag && !pParty->pPlayers[v49].pConditions[Condition_Dead] + && !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) + { + if (pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() / 2) + pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].sHealth - 1; + if (pParty->pPlayers[v49].sMana > 0) + pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].sMana - 1; + } + } + pParty->uLastRegenerationTime = pParty->uTimePlayed; + if (!viewparams->bRedrawGameUI) + viewparams->bRedrawGameUI = redraw_flag; + } +} + +//----- (00491E3A) -------------------------------------------------------- +void sub_491E3A() +{ + signed int v1; // esi@3 + unsigned int v3; // eax@7 + unsigned int v4; // edx@8 + int v6; // edi@17 + + //__debugbreak();//Ritor1 + for (uint pl = 0; pl < 4; pl++) + { + if (SoundSetAction[24][0]) + { + v3 = 0; + for (v1 = 0; v1 < (signed int)pSoundList->sNumSounds; ++v1) + { + int ps = 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4998;//6728 + if (pSoundList->pSL_Sounds[v1].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4998) + v3 = v1; + } + pSoundList->UnloadSound(v3, 1); + for (v4 = 0; (signed int)v4 < (signed int)pSoundList->sNumSounds; ++v4) + { + if (pSoundList->pSL_Sounds[v4].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4999) + pSoundList->UnloadSound(v4, 1); + } + } + } + v6 = pIcons_LOD->uNumLoadedFiles - 1; + if (v6 >= pIcons_LOD->pFacesLock) + { + do + { + pIcons_LOD->pTextures[v6].Release(); + if (pIcons_LOD->pHardwareTextures) + { + if (pIcons_LOD->pHardwareTextures[v6]) + { + pIcons_LOD->pHardwareTextures[v6]->Release(); + pIcons_LOD->pHardwareTextures[v6] = 0; + } + } + if (pIcons_LOD->pHardwareSurfaces) + { + if (pIcons_LOD->pHardwareSurfaces[v6]) + { + pIcons_LOD->pHardwareSurfaces[v6]->Release(); + pIcons_LOD->pHardwareSurfaces[v6] = 0; + } + } + --v6; + } while (v6 >= pIcons_LOD->pFacesLock); + } + pIcons_LOD->uNumLoadedFiles = pIcons_LOD->pFacesLock; + pIcons_LOD->pFacesLock = 0; +} +// 4ED498: using guessed type char byte_4ED498; + +//----- (00494820) -------------------------------------------------------- +unsigned int __fastcall _494820_training_time(unsigned int a1) +{ + signed int v1; // eax@1 + + v1 = 5; + if (a1 % 24 >= 5) + v1 = 29; + return v1 - a1 % 24; +} + +//----- (00494836) -------------------------------------------------------- +int stru339_spell_sound::AddPartySpellSound(int uSoundID, int a6) +{ + int v3; // esi@1 + int result; // eax@1 + //stru339_spell_sound *v5; // ebx@1 + //int *v6; // edi@2 + unsigned int v7; // eax@3 + int v8; // [sp+Ch] [bp-8h]@3 + int v9; // [sp+10h] [bp-4h]@2 + int a2a; // [sp+1Ch] [bp+8h]@1 + //return 0; + v3 = 0; + result = word_4EE088_sound_ids[uSoundID]; + //v5 = this; + a2a = word_4EE088_sound_ids[uSoundID]; + if (word_4EE088_sound_ids[uSoundID]) + { + //v6 = this->pSoundsOffsets; + for (v9 = 0; v9 < 2; ++v9) + { + v7 = a2a++; + result = pSoundList->LoadSound(v7, (char *)this + v3, 44744 - v3, &v8, a6); + if (!result) + break; + a6 += 4; + result = v8 + 256; + this->pSoundsOffsets[v9] = v3; + v3 += result; + this->pSoundsSizes[v9] = v8 + 256; + //++v6; + } + } + return result; +} +// 4EE088: using guessed type __int16 word_4EE088_sound_ids[]; + +//----- (00443E31) -------------------------------------------------------- +void LoadLevel_InitializeLevelStr() +{ + + // char Args[100]; + int string_num; + int max_string_length; + // int current_string_length; + int prev_string_offset; + + if (sizeof(pLevelStrOffsets) != 2000) + Log::Warning(L"pLevelStrOffsets: deserialization warning"); + memset(pLevelStrOffsets.data(), 0, 2000); + + max_string_length = 0; + string_num = 1; + prev_string_offset = 0; + pLevelStrOffsets[0] = 0; + for (uint i = 0; i < uLevelStrFileSize; ++i) + { + if (!pLevelStr[i]) + { + pLevelStrOffsets[string_num] = i + 1; + ++string_num; + if (i - prev_string_offset > max_string_length) + max_string_length = i - prev_string_offset; + prev_string_offset = i; + } + } + + uLevelStrNumStrings = string_num - 1; + if (max_string_length > 800) + Error("MAX_EVENT_TEXT_LENGTH needs to be increased to %lu", max_string_length + 1); + + if (uLevelStrNumStrings > 0) + { + for (uint i = 0; i 0) + { + for (uint i = 0; i < uLevelEVT_NumEvents; ++i) + { + test_event = (_evt_raw*)&pLevelEVT[pLevelEVT_Index[i].uEventOffsetInEVT]; + if (test_event->_e_type == EVENT_OnMapLeave) + { + EventProcessor(pLevelEVT_Index[i].uEventID, 0, 1, pLevelEVT_Index[i].event_sequence_num); + } + } + } +} + +//----- (00443FDC) -------------------------------------------------------- +void OnMapLoad() +{ + int v6; // eax@9 + unsigned __int64 v8; // qax@26 + int hours; // ebx@26 + unsigned __int64 v18; // [sp+Ch] [bp-44h]@12 + unsigned int seconds; // [sp+14h] [bp-3Ch]@26 + unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7 + unsigned int minutes; // [sp+2Ch] [bp-24h]@26 + unsigned int years; // [sp+34h] [bp-1Ch]@26 + unsigned int weeks; // [sp+38h] [bp-18h]@26 + int v26; // [sp+3Ch] [bp-14h]@15 + unsigned int days; // [sp+3Ch] [bp-14h]@26 + unsigned int months; // [sp+40h] [bp-10h]@26 + + for (uint i = 0; i < uLevelEVT_NumEvents; ++i) + { + EventIndex pEvent = pLevelEVT_Index[i]; + + _evt_raw* _evt = (_evt_raw *)(&pLevelEVT[pEvent.uEventOffsetInEVT]); + + if (_evt->_e_type == EVENT_PlaySound) + pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0); + else if (_evt->_e_type == EVENT_OnMapReload) + EventProcessor(pEvent.uEventID, 0, 0, pEvent.event_sequence_num); + else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_Initialize) + { + //v3 = &MapsLongTimersList[MapsLongTimers_count]; + v20 = pOutdoor->loc_time.uLastVisitDay; + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + v20 = pIndoor->stru1.uLastVisitDay; + + MapsLongTimersList[MapsLongTimers_count].timer_evt_type = _evt->_e_type; + MapsLongTimersList[MapsLongTimers_count].timer_evt_ID = pEvent.uEventID; + MapsLongTimersList[MapsLongTimers_count].timer_evt_seq_num = pEvent.event_sequence_num; + + MapsLongTimersList[MapsLongTimers_count].YearsInterval = _evt->v5; + MapsLongTimersList[MapsLongTimers_count].MonthsInterval = _evt->v6; + MapsLongTimersList[MapsLongTimers_count].WeeksInterval = _evt->v7; + MapsLongTimersList[MapsLongTimers_count].HoursInterval = _evt->v8; + MapsLongTimersList[MapsLongTimers_count].MinutesInterval = _evt->v9; + MapsLongTimersList[MapsLongTimers_count].SecondsInterval = _evt->v10; + + + v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11; + + MapsLongTimersList[MapsLongTimers_count].time_left_to_fire = ((unsigned short)_evt->v12 << 8) + _evt->v11; + MapsLongTimersList[MapsLongTimers_count].IntervalHalfMins = ((unsigned short)_evt->v12 << 8) + _evt->v11; + if (MapsLongTimersList[MapsLongTimers_count].timer_evt_type == EVENT_Initialize && !(short)v6) + { + if (v20) + v18 = pParty->uTimePlayed - v20; + else + v18 = 0; + v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24; + + if (v26 / 7 / 4 / 12 != 0 && MapsLongTimersList[MapsLongTimers_count].YearsInterval || + v26 / 7 / 4 != 0 && MapsLongTimersList[MapsLongTimers_count].MonthsInterval != 0 || + v26 / 7 != 0 && MapsLongTimersList[MapsLongTimers_count].WeeksInterval != 0 || + v26 != 0 || !v20) + { + ++MapsLongTimers_count; + MapsLongTimersList[MapsLongTimers_count].NextStartTime = 0; + continue; + } + } + else + { + v8 = (__int64)((double)pParty->uTimePlayed * 0.234375); + seconds = v8 % 60; + minutes = (v8 / 60) % 60; + hours = ((v8 / 60) / 60) % 24; + days = (((v8 / 60) / 60) / 24) % 7; + weeks = ((((v8 / 60) / 60) / 24) / 7) % 4; + months = (((((v8 / 60) / 60) / 24) / 7) / 4) % 12; + years = (((((v8 / 60) / 60) / 24) / 7) / 4) / 12; + + if (MapsLongTimersList[MapsLongTimers_count].YearsInterval) + ++years; + else if (MapsLongTimersList[MapsLongTimers_count].MonthsInterval) + ++months; + else if (MapsLongTimersList[MapsLongTimers_count].WeeksInterval) + ++weeks; + else + { + ++days; + hours = MapsLongTimersList[MapsLongTimers_count].HoursInterval; + minutes = MapsLongTimersList[MapsLongTimers_count].MinutesInterval; + seconds = MapsLongTimersList[MapsLongTimers_count].SecondsInterval; + } + MapsLongTimersList[MapsLongTimers_count].NextStartTime = (signed __int64)((double)((seconds + + 60 * minutes + + 3600 * hours + + 86400 * days + + 604800 * weeks + + 2419200 * months + + 29030400 * years) << 7) + * 0.033333335); + + ++MapsLongTimers_count; + } + } + } +} + +//----- (00444360) -------------------------------------------------------- +void Level_LoadEvtAndStr(const char *pLevelName) +{ + char pContainerName[120]; // [sp+8h] [bp-98h]@1 + + sprintf(pContainerName, "%s.evt", pLevelName); + uLevelEVT_Size = LoadEventsToBuffer(pContainerName, pLevelEVT.data(), 9216); + + sprintf(pContainerName, "%s.str", pLevelName); + uLevelStrFileSize = LoadEventsToBuffer(pContainerName, pLevelStr.data(), 9216); + if (uLevelStrFileSize) + LoadLevel_InitializeLevelStr(); +} + +//----- (004452BB) -------------------------------------------------------- +void sub_4452BB() +{ + pGUIWindow2->Release(); + pGUIWindow2 = 0; + activeLevelDecoration = _591094_decoration; + EventProcessor(dword_5C3418, 0, 1, dword_5C341C); + activeLevelDecoration = nullptr; + pEventTimer->Resume(); +} + +//----- (0044100D) -------------------------------------------------------- +bool _44100D_should_alter_right_panel() +{ + return pCurrentScreen == SCREEN_NPC_DIALOGUE || pCurrentScreen == SCREEN_CHARACTERS || + pCurrentScreen == SCREEN_HOUSE || pCurrentScreen == SCREEN_E || + pCurrentScreen == SCREEN_CHANGE_LOCATION || pCurrentScreen == SCREEN_INPUT_BLV || pCurrentScreen == SCREEN_CASTING; +} + +//----- (0044987B) -------------------------------------------------------- +void Transition_StopSound_Autosave(const char *pMapName, MapStartPoint start_point) +{ + pAudioPlayer->StopChannels(-1, -1); + pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_None); + if (_stricmp(pCurrentMapName, pMapName)) + SaveGame(1, 0); + + uGameState = GAME_STATE_CHANGE_LOCATION; + strcpy(pCurrentMapName, pMapName); + uLevel_StartingPointType = start_point; +} +// 6BE35C: using guessed type int uLevel_StartingPointType; + +//----- (004451A8) -------------------------------------------------------- +void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4) +{ + if (!pGUIWindow2) + { + if (pParty->uFlags & 2) + pGame->Draw(); + pAudioPlayer->StopChannels(-1, -1); + pMiscTimer->Pause(); + pEventTimer->Pause(); + dword_5C3418 = a1; + dword_5C341C = a2; + _591094_decoration = activeLevelDecoration; + pGUIWindow2 = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_GreetingNPC, a4, 0); + pGUIWindow2->CreateButton(61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); + pGUIWindow2->CreateButton(177, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); + pGUIWindow2->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); + pGUIWindow2->CreateButton(407, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); + } +} + + + + +//----- (00448B67) -------------------------------------------------------- +void OnTimer(int) +{ + if (pEventTimer->bPaused) + return; + + long long v13 = (signed __int64)(pParty->uTimePlayed - _5773B8_event_timer) / 128; + if (!v13) + return; + + //uint _v2v3 = pParty->uTimePlayed; + //v3 = HIDWORD(pParty->uTimePlayed); + //v2 = LODWORD(pParty->uTimePlayed); + + _5773B8_event_timer = pParty->uTimePlayed; + + for (uint i = 0; i < MapsLongTimers_count; ++i) + { + //v4 = (char *)&array_5B5928_timers[0].field_C; + MapsLongTimer* timer = &MapsLongTimersList[i]; + //while ( 1 ) + //{ + //v5 = *(short *)v4; + if (timer->time_left_to_fire) + { + if (v13 < timer->time_left_to_fire) + timer->time_left_to_fire -= v13; + else + { + timer->time_left_to_fire = timer->IntervalHalfMins; + EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num); + } + } + else + { + if (timer->NextStartTime < pParty->uTimePlayed) + { + uint next_trigger_time = 1 * 60 * 60 * 24; // 1 day + if (timer->YearsInterval) + next_trigger_time = 336 * 60 * 60 * 24; // 1 year + else if (timer->MonthsInterval) + next_trigger_time = 28 * 60 * 60 * 24; // 1 month + else if (timer->WeeksInterval) + next_trigger_time = 7 * 60 * 60 * 24; // 1 week + + timer->NextStartTime += (next_trigger_time * 128) / 3.0f; + if (timer->NextStartTime < pParty->uTimePlayed) // make sure in wont fire several times in a row if big time interval has lapsed + timer->NextStartTime = pParty->uTimePlayed; + + EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num); + } + } + } +} + + + + + + + +//----- (0044C28F) -------------------------------------------------------- +bool TeleportToNWCDungeon() +{ + if (!_stricmp("nwc.blv", pCurrentMapName)) + return false; + + _5B65A8_npcdata_uflags_or_other = 0; + _5B65AC_npcdata_fame_or_other = 0; + _5B65B0_npcdata_rep_or_other = 0; + _5B65B4_npcdata_loword_house_or_other = 0; + _5B65B8_npcdata_hiword_house_or_other = 0; + dword_5B65BC = 0; + dword_5B65C0 = 0; + + pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; + Transition_StopSound_Autosave("nwc.blv", MapStartPoint_Party); + pCurrentScreen = SCREEN_GAME; + return true; +} + +//----- (00401000) -------------------------------------------------------- +void mm7__vector_constructor(void *a1, int objSize, int numObjs, int(*constructor)(int)) +{ + void *v4; // esi@2 + + if (numObjs > 0) + { + v4 = a1; + for (int i = numObjs; i; --i) + { + constructor((int)v4); + v4 = (char *)v4 + objSize; + } + } +} + + + diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Game.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Game.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,239 @@ +#pragma once +#include "VectorTypes.h" + +#include "OSAPI.h" + +#include "MapInfo.h" + + +#define GAME_FLAGS_1_01_lightmap_related 0x01 +#define GAME_FLAGS_1_DRAW_BLV_DEBUGS 0x08 +#define GAME_FLAGS_2_SATURATE_LIGHTMAPS 0x02 +#define GAME_FLAGS_2_ALTER_GRAVITY 0x08 +#define GAME_FLAGS_2_TARGETING_MODE 0x10 +#define GAME_FLAGS_2_DRAW_BLOODSPLATS 0x20 + + + +/* 320 */ +enum GAME_STATE +{ + GAME_STATE_PLAYING = 0, + GAME_FINISHED = 1, + GAME_STATE_CHANGE_LOCATION = 2, + GAME_STATE_LOADING_GAME = 3, + GAME_STATE_NEWGAME_OUT_GAMEMENU = 4, + GAME_STATE_5 = 5, + GAME_STATE_STARTING_NEW_GAME = 6, + GAME_STATE_GAME_QUITTING_TO_MAIN_MENU = 7, + GAME_STATE_PARTY_DIED = 8, + GAME_STATE_FINAL_WINDOW = 9, + GAME_STATE_A = 10 +}; + + + +/* 105 */ +#pragma pack(push, 1) +struct Game__StationaryLight +{ + Vec3_float_ vPosition; + Vec3_float_ vRGBColor; + float flt_18; +}; +#pragma pack(pop) + + +/* 108 */ +#pragma pack(push, 1) +struct Game_stru0 +{ + int field_0; + unsigned __int8 *ptr_4; + int field_8; + int field_C; +}; +#pragma pack(pop) + + +/* 279 */ +#pragma pack(push, 1) +//Game_stru1 +struct Game_Bloodsplat +{ + float x; + float y; + float z; + float r; + float g; + float b; + float radius; +}; +#pragma pack(pop) + + +class Vis; +class LightmapBuilder; +class ParticleEngine; +class Mouse; +class Keyboard; +class ThreadWard; +class CShow; +class GammaController; +struct stru9; +struct stru10; + +/* 104 */ +#pragma pack(push, 1) +struct Game +{ + static Game *Create(); + static void Destroy(); + +protected: Game(); +protected: virtual ~Game(); + + +public: + void _44E904(); + bool InitializeGammaController(); + bool PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, struct Vis_SelectionFilter *sprite_filter, struct Vis_SelectionFilter *face_filter); + bool PickKeyboard(bool bOutline, struct Vis_SelectionFilter *sprite_filter, struct Vis_SelectionFilter *face_filter); + void OutlineSelection(); + signed int _44EC23(struct Polygon *a2, int *a3, signed int a4); + signed int _44ED0A(struct BLVFace *a2, int *a3, signed int a4); + bool AlterGamma_BLV(struct BLVFace *pFace, signed int *pColor); + bool AlterGamma_ODM(struct ODMFace *pFace, signed int *pColor); + bool draw_debug_outlines(); + bool _44EEA7(); + bool _44F07B(); + void ToggleFlags(unsigned int uMask); + void ToggleFlags2(unsigned int uFlag); + void _44F0FD(); + void PushStationaryLights(int a2); + void PrepareBloodsplats(); + void Deinitialize(); + void Loop(); + void DrawParticles(); + void Draw(); + + //----- (0042EB6A) -------------------------------------------------------- + struct stru6 *GetStru6() {return this->pStru6Instance;} + //----- (0042EB71) -------------------------------------------------------- + struct IndoorCameraD3D *GetIndoorCamera() {return this->pIndoorCameraD3D;} + + + //void ( ***vdestructor_ptr)(Game *, bool); + Game__StationaryLight pStationaryLights[25]; + char field_2C0[1092]; + unsigned int uNumStationaryLights; + Game_Bloodsplat pBloodsplats[20]; + int field_938; + int field_93C; + int field_940; + int field_944; + int field_948; + int field_94C; + int field_950; + int field_954; + int field_958; + int field_95C; + int field_960; + int field_964; + int field_968; + int field_96C; + int field_970; + Mouse *pMouse; + int field_978; + Game_stru0 stru_97C; + char field_98C[1148]; + int uNumBloodsplats; + int field_E0C; + __int64 field_E10; + int uNumStationaryLights_in_pStationaryLightsStack; + unsigned int bGammaControlInitialized; + unsigned int uFlags; + unsigned int uFlags2; + float fSaturation; + unsigned __int64 uSomeGammaStartTime; + __int64 uSomeGammaDeltaTime; + void/*ThreadWard*/ *pThreadWardInstance; + ParticleEngine *pParticleEngine; + Mouse *pMouseInstance; + LightmapBuilder *pLightmapBuilder; + Vis *pVisInstance; + stru6 *pStru6Instance; + IndoorCameraD3D *pIndoorCameraD3D; + stru9 *pStru9Instance; + stru10 *pStru10Instance; + void/*stru11*/ *pStru11Instance; + void/*stru12*/ *pStru12Instance; + void/*CShow*/ *pCShow; + Keyboard *pKeyboardInstance; + GammaController *pGammaController; + int field_E74; +}; +#pragma pack(pop) + + + + + + +extern Game *pGame; + +void sub_42FBDD(); +void CloseWindowBackground(); +void GameUI_MsgProc(); +void back_to_game(); +void GUI_MainMenuMessageProc(); + +void UpdateUserInput_and_MapSpecificStuff(); +void PrepareWorld(unsigned int _0_box_loading_1_fullscreen); +void DoPrepareWorld(unsigned int bLoading, int _1_fullscreen_loading_2_box); + +//int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam); +int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4); +bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive); +//bool __fastcall Initialize(HINSTANCE hInst, char *pCmdLine); + +void Game_DeinitializeAndTerminate(int exitCode); // idb +void FinalInitialization(); +bool __fastcall CheckMM7CD(char c); +void SecondaryInitialization(); + + +void MM6_Initialize(const wchar_t *pIniFilename); +void MM7Initialization(); + +void __fastcall PrepareToLoadODM(unsigned int bLoading, struct ODMRenderParams *a2); +void MainMenu_Loop(); +unsigned int GameOverMenu(void *ecx0); +void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); +void _461103_load_level_sub(); +void InitializeTurnBasedAnimations(void *); +void SetCurrentMenuID(enum MENU_STATE); // idb +enum MENU_STATE GetCurrentMenuID(); +unsigned int GetGravityStrength(); +void GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide); // idb + +void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename); +void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on); +void __fastcall SetDecorationSprite(uint16_t uCog, bool bHide, const char *pFileName); // idb +void _494035_timed_effects__water_walking_damage__etc(); +void _493938_regenerate(); +void sub_491E3A(); +const char *GetReputationString(signed int a1); +unsigned int __fastcall _494820_training_time(unsigned int a1); +void LoadLevel_InitializeLevelStr(); +void OnMapLeave(); +void OnMapLoad(); +void Level_LoadEvtAndStr(const char *pLevelName); +void sub_4452BB(); +bool _44100D_should_alter_right_panel(); +void Transition_StopSound_Autosave(const char *pMapName, MapStartPoint point); // sub_44987B idb + +void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4); + +void OnTimer(int); +bool TeleportToNWCDungeon(); \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/BSPModel.h --- a/Engine/Graphics/BSPModel.h Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/BSPModel.h Fri Sep 19 02:57:42 2014 +0600 @@ -1,5 +1,5 @@ #pragma once -#include "VectorTypes.h" +#include "../VectorTypes.h" #pragma pack(push, 1) diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/DecalBuilder.cpp --- a/Engine/Graphics/DecalBuilder.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/DecalBuilder.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -4,15 +4,15 @@ #define _CRT_SECURE_NO_WARNINGS #include "DecalBuilder.h" -#include "Game.h" -#include "Timer.h" -#include "stru314.h" +#include "../Game.h" +#include "../Timer.h" +#include "../stru314.h" #include "Outdoor.h" -#include "Log.h" +#include "../Log.h" #include "stru9.h" -#include "OurMath.h" +#include "../OurMath.h" struct DecalBuilder *pDecalBuilder = new DecalBuilder; diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/DecorationList.cpp --- a/Engine/Graphics/DecorationList.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/DecorationList.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -5,11 +5,11 @@ #define _CRT_SECURE_NO_WARNINGS #include "Sprites.h" #include "DecorationList.h" -#include "FrameTableInc.h" -#include "mm7_data.h" -#include "ErrorHandling.h" -#include "stru123.h" -#include "Engine/Graphics/Level\Decoration.h" +#include "../Tables/FrameTableInc.h" +#include "../mm7_data.h" +#include "../ErrorHandling.h" +#include "../stru123.h" +#include "Level\Decoration.h" struct DecorationList *pDecorationList; diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/GammaControl.cpp --- a/Engine/Graphics/GammaControl.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/GammaControl.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -8,7 +8,7 @@ #include "GammaControl.h" #include "Render.h" -#include "mm7_data.h" +#include "../mm7_data.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/IRender.h --- a/Engine/Graphics/IRender.h Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/IRender.h Fri Sep 19 02:57:42 2014 +0600 @@ -3,7 +3,7 @@ #include "lib\legacy_dx\d3d.h" #include "OSWindow.h" #include "RenderStruct.h" -#include "VectorTypes.h" +#include "../VectorTypes.h" struct IRender { diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/Indoor.cpp --- a/Engine/Graphics/Indoor.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/Indoor.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -3,43 +3,43 @@ #include #define _CRT_SECURE_NO_WARNINGS -#include "ErrorHandling.h" -#include "ZlibWrapper.h" +#include "../ErrorHandling.h" +#include "../ZlibWrapper.h" #include "LightmapBuilder.h" #include "DecalBuilder.h" #include "stru9.h" #include "stru10.h" -#include "stru367.h" +#include "../stru367.h" #include "Outdoor.h" -#include "SpriteObject.h" -#include "Events.h" -#include "Game.h" +#include "../Objects/SpriteObject.h" +#include "../Events.h" +#include "../Game.h" #include "Viewport.h" -#include "Timer.h" -#include "Party.h" -#include "OurMath.h" -#include "LOD.h" +#include "../Timer.h" +#include "../Party.h" +#include "../OurMath.h" +#include "../LOD.h" #include "DecorationList.h" -#include "ObjectList.h" -#include "Actor.h" -#include "Chest.h" +#include "../Objects/ObjectList.h" +#include "../Objects/Actor.h" +#include "../Objects/Chest.h" #include "GUIProgressBar.h" -#include "stru123.h" +#include "../stru123.h" #include "AudioPlayer.h" -#include "Log.h" -#include "TurnEngine.h" +#include "../Log.h" +#include "../TurnEngine/TurnEngine.h" #include "PaletteManager.h" #include "Lights.h" -#include "MM7.h" +#include "../MM7.h" #include "Sprites.h" #include "stru6.h" #include "ParticleEngine.h" -#include "texts.h" +#include "../texts.h" #include "GUIWindow.h" -#include "Engine/Graphics/Level/Decoration.h" +#include "Level/Decoration.h" #include "Overlays.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/Indoor.h --- a/Engine/Graphics/Indoor.h Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/Indoor.h Fri Sep 19 02:57:42 2014 +0600 @@ -3,7 +3,7 @@ #include "Render.h" #include "IndoorCameraD3D.h" -#include "mm7_data.h" +#include "../mm7_data.h" /* 358 */ #pragma pack(push, 1) diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/IndoorCameraD3D.cpp --- a/Engine/Graphics/IndoorCameraD3D.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/IndoorCameraD3D.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -3,13 +3,13 @@ #include #define _CRT_SECURE_NO_WARNINGS -#include "ErrorHandling.h" +#include "../ErrorHandling.h" #include "IndoorCameraD3D.h" -#include "Game.h" +#include "../Game.h" #include "Indoor.h" #include "Viewport.h" -#include "LOD.h" -#include "OurMath.h" +#include "../LOD.h" +#include "../OurMath.h" #include "stru9.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/IndoorCameraD3D.h --- a/Engine/Graphics/IndoorCameraD3D.h Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/IndoorCameraD3D.h Fri Sep 19 02:57:42 2014 +0600 @@ -1,5 +1,5 @@ #pragma once -#include "VectorTypes.h" +#include "../VectorTypes.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/Level/Decoration.cpp --- a/Engine/Graphics/Level/Decoration.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/Level/Decoration.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -4,8 +4,8 @@ #define _CRT_SECURE_NO_WARNINGS #include "Decoration.h" -#include "../../../Party.h" -#include "../../../ErrorHandling.h" +#include "../../Party.h" +#include "../../ErrorHandling.h" std::array pLevelDecorations; size_t uNumLevelDecorations; diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/Level/Decoration.h --- a/Engine/Graphics/Level/Decoration.h Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/Level/Decoration.h Fri Sep 19 02:57:42 2014 +0600 @@ -3,7 +3,7 @@ #include #include -#include "../../../VectorTypes.h" +#include "../../VectorTypes.h" enum LEVEL_DECORATION_FLAGS: uint16_t diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/LightmapBuilder.cpp --- a/Engine/Graphics/LightmapBuilder.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/LightmapBuilder.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -4,11 +4,11 @@ #define _CRT_SECURE_NO_WARNINGS #include "LightmapBuilder.h" -#include "Game.h" -#include "stru314.h" +#include "../Game.h" +#include "../stru314.h" #include "Outdoor.h" -#include "Log.h" -#include "ErrorHandling.h" +#include "../Log.h" +#include "../ErrorHandling.h" #include "Lights.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/Lights.h --- a/Engine/Graphics/Lights.h Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/Lights.h Fri Sep 19 02:57:42 2014 +0600 @@ -1,6 +1,6 @@ #pragma once -#include "VectorTypes.h" +#include "../VectorTypes.h" /* 257 */ diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/Outdoor.cpp --- a/Engine/Graphics/Outdoor.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/Outdoor.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -3,39 +3,39 @@ #include #define _CRT_SECURE_NO_WARNINGS -#include "ErrorHandling.h" +#include "../ErrorHandling.h" #include "stru6.h" #include "Weather.h" #include "Sprites.h" #include "LightmapBuilder.h" #include "Outdoor.h" -#include "Party.h" -#include "SpriteObject.h" -#include "LOD.h" +#include "../Party.h" +#include "../Objects/SpriteObject.h" +#include "../LOD.h" #include "PaletteManager.h" #include "GUIProgressBar.h" #include "AudioPlayer.h" #include "DecorationList.h" -#include "OurMath.h" -#include "ObjectList.h" -#include "Game.h" -#include "Actor.h" -#include "Chest.h" -#include "stru123.h" -#include "Timer.h" +#include "../OurMath.h" +#include "../Objects/ObjectList.h" +#include "../Game.h" +#include "../Objects/Actor.h" +#include "../Objects/Chest.h" +#include "../stru123.h" +#include "../Timer.h" #include "Viewport.h" -#include "Events.h" +#include "../Events.h" #include "ParticleEngine.h" -#include "TurnEngine.h" - -#include "MM7.h" +#include "../TurnEngine/TurnEngine.h" + +#include "../MM7.h" #include "Lights.h" #include "GUIWindow.h" -#include "Engine/Graphics/Level/Decoration.h" -#include "ZlibWrapper.h" -#include "MMT.h" +#include "Level/Decoration.h" +#include "../ZlibWrapper.h" +#include "../MMT.h" MapStartPoint uLevel_StartingPointType; // weak diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/Outdoor.h --- a/Engine/Graphics/Outdoor.h Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/Outdoor.h Fri Sep 19 02:57:42 2014 +0600 @@ -1,8 +1,8 @@ #pragma #include "Indoor.h" -#include "TileFrameTable.h" -#include "Engine/Graphics/BSPModel.h" +#include "../Tables/TileFrameTable.h" +#include "BSPModel.h" #define DAY_ATTRIB_FOG 1 diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/Overlays.cpp --- a/Engine/Graphics/Overlays.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/Overlays.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -5,20 +5,20 @@ #define _CRT_SECURE_NO_WARNINGS #include -#include "ErrorHandling.h" +#include "../ErrorHandling.h" #include "Overlays.h" #include "Sprites.h" -#include "FrameTableInc.h" -#include "IconFrameTable.h" -#include "Timer.h" -#include "Party.h" -#include "TurnEngine.h" -#include "LOD.h" +#include "../Tables/FrameTableInc.h" +#include "../Tables/IconFrameTable.h" +#include "../Timer.h" +#include "../Party.h" +#include "../TurnEngine/TurnEngine.h" +#include "../LOD.h" #include "Render.h" #include "GUIWindow.h" -#include "mm7_data.h" +#include "../mm7_data.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/PaletteManager.cpp --- a/Engine/Graphics/PaletteManager.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/PaletteManager.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -3,14 +3,14 @@ #include #define _CRT_SECURE_NO_WARNINGS -#include "ErrorHandling.h" +#include "../ErrorHandling.h" #include "PaletteManager.h" -#include "Game.h" -#include "LOD.h" -#include "Log.h" -#include "OurMath.h" +#include "../Game.h" +#include "../LOD.h" +#include "../Log.h" +#include "../OurMath.h" -#include "mm7_data.h" +#include "../mm7_data.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/ParticleEngine.cpp --- a/Engine/Graphics/ParticleEngine.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/ParticleEngine.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -4,12 +4,12 @@ #define _CRT_SECURE_NO_WARNINGS #include "ParticleEngine.h" -#include "Timer.h" +#include "../Timer.h" #include "Viewport.h" #include "Outdoor.h" -#include "Game.h" -#include "OurMath.h" -#include "LOD.h" +#include "../Game.h" +#include "../OurMath.h" +#include "../LOD.h" #include "Sprites.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/Render.cpp --- a/Engine/Graphics/Render.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/Render.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -4,39 +4,39 @@ #define _CRT_SECURE_NO_WARNINGS -#include "ZlibWrapper.h" -#include "ErrorHandling.h" +#include "../ZlibWrapper.h" +#include "../ErrorHandling.h" #include "Render.h" #include "MediaPlayer.h" #include "Sprites.h" #include "Mouse.h" -#include "Engine/Graphics/GammaControl.h" +#include "GammaControl.h" #include "stru6.h" #include "GUIWindow.h" #include "DecalBuilder.h" #include "ParticleEngine.h" #include "Outdoor.h" -#include "Party.h" -#include "LOD.h" +#include "../Party.h" +#include "../LOD.h" #include "Viewport.h" -#include "OurMath.h" +#include "../OurMath.h" #include "PaletteManager.h" -#include "Timer.h" -#include "Game.h" +#include "../Timer.h" +#include "../Game.h" #include "LightmapBuilder.h" -#include "ObjectList.h" -#include "SpriteObject.h" +#include "../Objects/ObjectList.h" +#include "../Objects/SpriteObject.h" #include "DecorationList.h" -#include "Actor.h" -#include "Log.h" -#include "MM7.h" +#include "../Objects/Actor.h" +#include "../Log.h" +#include "../MM7.h" #include "Lights.h" -#include "Engine/Graphics/Level/Decoration.h" +#include "Level/Decoration.h" #include "Vis.h" -#include "Registry.h" +#include "../Registry.h" #include "Weather.h" -#include "MMT.h" +#include "../MMT.h" //#pragma comment(lib, "lib\\legacy_dx\\lib\\ddraw.lib") diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/Render.h --- a/Engine/Graphics/Render.h Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/Render.h Fri Sep 19 02:57:42 2014 +0600 @@ -8,7 +8,7 @@ #include "OSWindow.h" #include "RenderStruct.h" -#include "VectorTypes.h" +#include "../VectorTypes.h" #include "IRender.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/RenderD3D11.cpp --- a/Engine/Graphics/RenderD3D11.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/RenderD3D11.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -1,9 +1,9 @@ #include #include // _com_error -#include "ErrorHandling.h" +#include "../ErrorHandling.h" #include "RenderD3D11.h" -#include "mm7_data.h" +#include "../mm7_data.h" #define ErrorD3D(x)\ {\ diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/RenderD3D11.h --- a/Engine/Graphics/RenderD3D11.h Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/RenderD3D11.h Fri Sep 19 02:57:42 2014 +0600 @@ -9,7 +9,7 @@ #include "OSWindow.h" #include "RenderStruct.h" -#include "VectorTypes.h" +#include "../VectorTypes.h" #include "IRender.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/RenderStruct.h --- a/Engine/Graphics/RenderStruct.h Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/RenderStruct.h Fri Sep 19 02:57:42 2014 +0600 @@ -6,7 +6,7 @@ #include "lib\legacy_dx\d3d.h" #include "OSWindow.h" -#include "VectorTypes.h" +#include "../VectorTypes.h" #define ErrD3D(hr) \ diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/Sprites.cpp --- a/Engine/Graphics/Sprites.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/Sprites.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -5,19 +5,19 @@ #define _CRT_SECURE_NO_WARNINGS #include #include -#include "ErrorHandling.h" +#include "../ErrorHandling.h" #include "Sprites.h" #include "PaletteManager.h" -#include "LOD.h" -#include "FrameTableInc.h" +#include "../LOD.h" +#include "../Tables/FrameTableInc.h" #include "Outdoor.h" #include "DecorationList.h" -#include "MM7.h" -#include "Actor.h" -#include "Engine/Graphics/Level/Decoration.h" -#include "OurMath.h" +#include "../MM7.h" +#include "../Objects/Actor.h" +#include "Level/Decoration.h" +#include "../OurMath.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/Texture.cpp --- a/Engine/Graphics/Texture.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/Texture.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -6,15 +6,15 @@ #include #include "Texture.h" -#include "FrameTableInc.h" -#include "LOD.h" +#include "../Tables/FrameTableInc.h" +#include "../LOD.h" #include "PaletteManager.h" -#include "ErrorHandling.h" -#include "ZlibWrapper.h" +#include "../ErrorHandling.h" +#include "../ZlibWrapper.h" -#include "mm7_data.h" +#include "../mm7_data.h" -#include "OurMath.h" +#include "../OurMath.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/Viewport.cpp --- a/Engine/Graphics/Viewport.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/Viewport.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -6,24 +6,24 @@ #include "Viewport.h" -#include "Party.h" -#include "OurMath.h" -#include "Actor.h" +#include "../Party.h" +#include "../OurMath.h" +#include "../Objects/Actor.h" #include "Outdoor.h" -#include "Events.h" +#include "../Events.h" #include "Mouse.h" -#include "SpriteObject.h" -#include "ObjectList.h" +#include "../Objects/SpriteObject.h" +#include "../Objects/ObjectList.h" #include "DecorationList.h" -#include "texts.h" -#include "Game.h" +#include "../texts.h" +#include "../Game.h" #include "Vis.h" -#include "LOD.h" +#include "../LOD.h" #include "GUIWindow.h" -#include "TurnEngine.h" -#include "stru123.h" -#include "MM7.h" -#include "Engine/Graphics/Level/Decoration.h" +#include "../TurnEngine/TurnEngine.h" +#include "../stru123.h" +#include "../MM7.h" +#include "Level/Decoration.h" //----- (004C0262) -------------------------------------------------------- diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/Vis.cpp --- a/Engine/Graphics/Vis.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/Vis.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -5,17 +5,17 @@ #define _CRT_SECURE_NO_WARNINGS #include "Vis.h" #include "Sprites.h" -#include "Lod.h" +#include "../Lod.h" #include "Outdoor.h" -#include "Game.h" -#include "Actor.h" +#include "../Game.h" +#include "../Objects/Actor.h" #include "Viewport.h" -#include "OurMath.h" -#include "Log.h" -#include "ErrorHandling.h" +#include "../OurMath.h" +#include "../Log.h" +#include "../ErrorHandling.h" -#include "MM7.h" -#include "Engine/Graphics/Level/Decoration.h" +#include "../MM7.h" +#include "Level/Decoration.h" static Vis_SelectionList Vis_static_sub_4C1944_stru_F8BDE8; diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/Weather.cpp --- a/Engine/Graphics/Weather.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/Weather.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -9,7 +9,7 @@ #include "Viewport.h" #include "Render.h" -#include "mm7_data.h" ////TODO: remove this once LOWORD/HIWRD stuff is refactored +#include "../mm7_data.h" ////TODO: remove this once LOWORD/HIWRD stuff is refactored diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/stru10.cpp --- a/Engine/Graphics/stru10.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/stru10.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -5,9 +5,9 @@ #define _CRT_SECURE_NO_WARNINGS #include "stru10.h" #include "Indoor.h" -#include "Game.h" -#include "Party.h" -#include "ErrorHandling.h" +#include "../Game.h" +#include "../Party.h" +#include "../ErrorHandling.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Graphics/stru9.cpp --- a/Engine/Graphics/stru9.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Graphics/stru9.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -6,7 +6,7 @@ #include "stru9.h" #include "IndoorCameraD3D.h" -#include "mm7_data.h" +#include "../mm7_data.h" @@ -14,25 +14,9 @@ bool stru9::_498377(struct RenderVertexSoft *pPortalBounding, unsigned int uNumVertices, struct IndoorCameraD3D_Vec4 *pVertices, struct RenderVertexSoft *pVertices2, unsigned int *pOutNumVertices) { int result; // eax@7 - //unsigned int *v7; // ebx@7 - //char *v8; // esi@8 RenderVertexSoft *v9; // ecx@9 - //double v10; // st7@12 - //double v11; // st6@12 - //RenderVertexSoft *v12; // esi@13 - //int v13; // ecx@25 - //VertexBuffer *v14; // edx@26 - //char *v15; // eax@26 - //unsigned int i; // ecx@26 - //int v17; // [sp+0h] [bp-28h]@9 - //char *v18; // [sp+10h] [bp-18h]@8 RenderVertexSoft *v19; // [sp+14h] [bp-14h]@0 - //RenderVertexSoft *v20; // [sp+18h] [bp-10h]@0 signed int v21; // [sp+1Ch] [bp-Ch]@7 - //RenderVertexSoft *a2; // [sp+20h] [bp-8h]@8 - //stru9 *thisa; // [sp+24h] [bp-4h]@1 -// signed int a3a; // [sp+38h] [bp+10h]@12 - //int a3b; // [sp+38h] [bp+10h]@25 //__debugbreak(); //thisa = this; diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/LOD.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/LOD.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,2409 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include "Engine/ErrorHandling.h" +#include "LOD.h" +#include "Engine/Graphics/Render.h" +#include "Engine/Graphics/Viewport.h" +#include "mm7_data.h" +#include "ZlibWrapper.h" + +#include "Engine/Graphics/Sprites.h" + + + + + + +LODFile_IconsBitmaps *pEvents_LOD = nullptr; + +LODFile_IconsBitmaps *pIcons_LOD = nullptr; +LODFile_IconsBitmaps *pIcons_LOD_mm6 = nullptr; +LODFile_IconsBitmaps *pIcons_LOD_mm8 = nullptr; + +LODFile_IconsBitmaps *pBitmaps_LOD = nullptr; +LODFile_IconsBitmaps *pBitmaps_LOD_mm6 = nullptr; +LODFile_IconsBitmaps *pBitmaps_LOD_mm8 = nullptr; + +LODFile_Sprites *pSprites_LOD = nullptr; +LODFile_Sprites *pSprites_LOD_mm6 = nullptr; +LODFile_Sprites *pSprites_LOD_mm8 = nullptr; + +LODWriteableFile *pNew_LOD = nullptr; +LODWriteableFile *pGames_LOD = nullptr; + + + + +int _6A0CA4_lod_binary_search; // weak +int _6A0CA8_lod_unused; // weak + + +// inlined +//----- (mm6c::00408860) -------------------------------------------------- +void LODFile_IconsBitmaps::_inlined_sub2() +{ + ++uTexturePacksCount; + if (!uNumPrevLoadedFiles) + uNumPrevLoadedFiles = uNumLoadedFiles; +} + +// inlined +//----- (mm6c::0045BE60) -------------------------------------------------- +void LODFile_IconsBitmaps::_inlined_sub1() +{ + dword_11B84 = uNumLoadedFiles; +} + +// inlined +//----- (mm6c::0045C310) -------------------------------------------------- +void LODFile_Sprites::_inlined_sub1() +{ + field_ECA0 = uNumLoadedSprites; +} + +// inlined +//----- (mm6c::0045C5B0) -------------------------------------------------- +void LODFile_IconsBitmaps::_inlined_sub0() +{ + dword_11B80 = uNumLoadedFiles; + if (dword_11B84 < uNumLoadedFiles) + dword_11B84 = uNumLoadedFiles; +} + + +// inlined +//----- (mm6c::0045C660) -------------------------------------------------- +void LODFile_Sprites::_inlined_sub0() +{ + field_ECA4 = uNumLoadedSprites; + if (field_ECA0 < uNumLoadedSprites) + field_ECA0 = uNumLoadedSprites; +} + +//----- (004355F7) -------------------------------------------------------- +void LODFile_IconsBitmaps::RemoveTexturesFromTextureList() +{ + if ( this->uTexturePacksCount ) + { + if ( (this->uNumLoadedFiles - 1) >= this->uNumPrevLoadedFiles ) + { + for ( uint i = this->uNumLoadedFiles - 1; i >= this->uNumPrevLoadedFiles; --i ) + { + this->pTextures[i].Release(); + if ( this->pHardwareTextures ) + { + if ( this->pHardwareTextures[i] ) + { + this->pHardwareTextures[i]->Release(); + this->pHardwareTextures[i] = 0; + } + } + if ( this->pHardwareSurfaces ) + { + if ( this->pHardwareSurfaces[i] ) + { + this->pHardwareSurfaces[i]->Release(); + this->pHardwareSurfaces[i] = 0; + } + } + } + } + this->uNumLoadedFiles = this->uNumPrevLoadedFiles; + this->uNumPrevLoadedFiles = 0; + this->uTexturePacksCount = 0; + } +} + +//----- (004114F2) -------------------------------------------------------- +void LODFile_IconsBitmaps::RemoveTexturesPackFromTextureList() +{ + if ( this->uTexturePacksCount ) + { + this->uTexturePacksCount--; + if ( !this->uTexturePacksCount ) + { + if ( (this->uNumLoadedFiles - 1) >= this->uNumPrevLoadedFiles ) + { + for ( uint i = this->uNumLoadedFiles - 1; i >= this->uNumPrevLoadedFiles; --i ) + { + this->pTextures[i].Release(); + if ( this->pHardwareTextures ) + { + if ( this->pHardwareTextures[i] ) + { + this->pHardwareTextures[i]->Release(); + this->pHardwareTextures[i] = 0; + } + } + if ( this->pHardwareSurfaces ) + { + if ( this->pHardwareSurfaces[i] ) + { + this->pHardwareSurfaces[i]->Release(); + this->pHardwareSurfaces[i] = 0; + } + } + } + } + this->uNumLoadedFiles = this->uNumPrevLoadedFiles; + this->uNumPrevLoadedFiles = 0; + } + } +} + +//----- (004AC67E) -------------------------------------------------------- +int LODFile_Sprites::LoadSpriteFromFile(LODSprite *pSpriteHeader, const char *pContainer) +{ + FILE *File; // [sp+4h] [bp-4h]@1 + void *DstBufa; // [sp+10h] [bp+8h]@4 + int Sizea; // [sp+14h] [bp+Ch]@3 + + File = FindContainer(pContainer, 0); + if ( File ) + { + fread(pSpriteHeader, 1, 0x20u, File); + strcpy(pSpriteHeader->pName, pContainer); + Sizea = pSpriteHeader->uSpriteSize; + pSpriteHeader->pSpriteLines = (LODSprite_stru0 *)malloc(8 * pSpriteHeader->uHeight); + fread(pSpriteHeader->pSpriteLines, 1, 8 * pSpriteHeader->uHeight, File); + + if ( pSpriteHeader->uDecompressedSize ) + { + pSpriteHeader->pDecompressedBytes = malloc(pSpriteHeader->uDecompressedSize); + DstBufa = malloc(Sizea); + fread(DstBufa, 1, Sizea, File); + zlib::MemUnzip(pSpriteHeader->pDecompressedBytes, (unsigned int *)&pSpriteHeader->uDecompressedSize, DstBufa, pSpriteHeader->uSpriteSize); + pSpriteHeader->uSpriteSize = pSpriteHeader->uDecompressedSize; + free(DstBufa); + } + else + { + pSpriteHeader->pDecompressedBytes = malloc(Sizea); + fread(pSpriteHeader->pDecompressedBytes, 1, Sizea, File); + } + for ( uint i = 0; i < pSpriteHeader->uHeight; i++ ) + pSpriteHeader->pSpriteLines[i].pos += (unsigned int)pSpriteHeader->pDecompressedBytes; + return 1; + } + else + return -1; +} + +//----- (004AC795) -------------------------------------------------------- +bool LODFile_Sprites::LoadSprites(const char *pFilename) +{ + if (LoadHeader(pFilename, 1)) + return false; + else + return LoadSubIndices("sprites08") == 0; +} + +//----- (004AC7C0) -------------------------------------------------------- +int LODFile_Sprites::LoadSprite(const char *pContainerName, unsigned int uPaletteID) + { + + FILE *sprite_file; // eax@12 + LODSprite temp_sprite_hdr; // [sp+Ch] [bp-3Ch]@12 + int i;//, sprite_indx; + + //find if already loaded + //if ( pRenderer->pRenderD3D ) + { + for (i=0; i= 1500 ) + return -1; + //if not loaded - load from file + + //if ( pRenderer->pRenderD3D && can_load_hardware_sprites ) + { + if ( !pHardwareSprites ) + { + pHardwareSprites = (Sprite *)malloc(1500*sizeof(Sprite));//0xEA60u + for (i=0; i<1500;++i) + { + pHardwareSprites[i].pName=nullptr; + pHardwareSprites[i].pTextureSurface=nullptr; + pHardwareSprites[i].pTexture=nullptr; + } + } + temp_sprite_hdr.uHeight = 0; + temp_sprite_hdr.uPaletteId = 0; + temp_sprite_hdr.word_1A = 0; + temp_sprite_hdr.pSpriteLines = nullptr; + temp_sprite_hdr.pDecompressedBytes = nullptr; + sprite_file = FindContainer(pContainerName, 0); + if ( !sprite_file ) + return -1; + //fread(&temp_sprite_hdr, 1, sizeof(LODSprite), sprite_file); + fread(&temp_sprite_hdr, 1, 0x20, sprite_file); + pHardwareSprites[uNumLoadedSprites].uBufferWidth = temp_sprite_hdr.uWidth; + pHardwareSprites[uNumLoadedSprites].uBufferHeight = temp_sprite_hdr.uHeight; + pSpriteHeaders[uNumLoadedSprites].uWidth = temp_sprite_hdr.uWidth; + pSpriteHeaders[uNumLoadedSprites].uHeight = temp_sprite_hdr.uHeight; + LoadSpriteFromFile( &pSpriteHeaders[uNumLoadedSprites], pContainerName); //this line is not present here in the original. necessary for Grayface's mouse picking fix + } + /*else + { + sprite_indx = LoadSpriteFromFile( &pSpriteHeaders[uNumLoadedSprites], pContainerName); + pSpriteHeaders[uNumLoadedSprites].word_1A = 0; + + if ( sprite_indx != -1 ) + { + pSpriteHeaders[uNumLoadedSprites].uPaletteId = pPaletteManager->LoadPalette(pSpriteHeaders[uNumLoadedSprites].uPaletteId); + } + else + { + if ( uNumLoadedSprites<=0 ) + uNumLoadedSprites=0; + else + { + for (i=0; iLoadPalette(pSpriteHeaders[uNumLoadedSprites].uPaletteId); + } + }*/ + + //if ( pRenderer->pRenderD3D ) + { + pHardwareSprites[uNumLoadedSprites].pName = (const char *)malloc(20); + strcpy((char *)pHardwareSprites[uNumLoadedSprites].pName, pContainerName); + pHardwareSprites[uNumLoadedSprites].uPaletteID = uPaletteID; + pRenderer->MoveSpriteToDevice(&pHardwareSprites[uNumLoadedSprites]); + } + ++uNumLoadedSprites; + return uNumLoadedSprites - 1; + + } + +//----- (004ACADA) -------------------------------------------------------- +void LODFile_Sprites::ReleaseLostHardwareSprites() +{ + signed int v2; // ebx@2 + int v3; // edi@3 + IDirectDrawSurface *v4; // eax@4 + IDirect3DTexture2 *v5; // eax@6 + IDirectDrawSurface *v6; // ST00_4@8 + + if ( this->pHardwareSprites ) + { + v2 = 0; + if ( (signed int)this->uNumLoadedSprites > 0 ) + { + v3 = 0; + do + { + v4 = (IDirectDrawSurface *)this->pHardwareSprites[v3].pTextureSurface; + if ( v4 && v4->IsLost() == DDERR_SURFACELOST ) + { + v5 = this->pHardwareSprites[v3].pTexture; + if ( v5 ) + { + v5->Release(); + this->pHardwareSprites[v3].pTexture = nullptr; + } + v6 = (IDirectDrawSurface *)this->pHardwareSprites[v3].pTextureSurface; + v6->Release(); + this->pHardwareSprites[v3].pTextureSurface = nullptr; + pRenderer->MoveSpriteToDevice(&this->pHardwareSprites[v3]); + } + ++v2; + ++v3; + } + while ( v2 < (signed int)this->uNumLoadedSprites ); + } + } +} + +//----- (004ACB70) -------------------------------------------------------- +void LODFile_Sprites::ReleaseAll() +{ + if ( this->pHardwareSprites ) + { + for ( int i = 0; i < this->uNumLoadedSprites; ++i ) + { + if ( this->pHardwareSprites ) + { + if ( this->pHardwareSprites[i].pTexture ) + { + this->pHardwareSprites[i].pTexture->Release(); + this->pHardwareSprites[i].pTexture = nullptr; + } + if ( this->pHardwareSprites ) + { + if ( this->pHardwareSprites[i].pTextureSurface ) + { + this->pHardwareSprites[i].pTextureSurface->Release(); + this->pHardwareSprites[i].pTextureSurface = nullptr; + } + } + } + } + } +} + +//----- (004ACBE0) -------------------------------------------------------- +void LODFile_Sprites::MoveSpritesToVideoMemory() +{ + if ( this->pHardwareSprites ) + { + for ( int i = 0; i < this->uNumLoadedSprites; ++i ) + pRenderer->MoveSpriteToDevice(&this->pHardwareSprites[i]); + } +} + +//----- (004ACC38) -------------------------------------------------------- +int LODSprite::DrawSprite_sw(RenderBillboardTransform_local0 *a2, char a3) +{ + RenderBillboardTransform_local0 *v3; // edi@1 + int result; // eax@1 + int v5; // esi@2 + int v6; // ST18_4@2 + //signed int v7; // eax@2 + signed int v8; // ebx@2 + int v9; // ebx@2 + int *v10; // ecx@2 + int v11; // esi@2 + unsigned int v12; // edx@4 + int v13; // esi@13 + int v14; // esi@17 + int v15; // ecx@17 + char *v16; // edx@17 + int v17; // esi@17 + int v18; // ecx@18 + int v19; // esi@18 + LODSprite_stru0 *v20; // edx@21 + int v21; // eax@22 + int v22; // esi@22 + int v23; // eax@25 + int v24; // ecx@25 + signed __int64 v25; // qtt@27 + int v26; // eax@27 + unsigned __int16 *v27; // eax@29 + LODSprite_stru0 *v28; // edx@29 + signed int v29; // ecx@30 + int v30; // ecx@37 + int v31; // ecx@38 + signed int v32; // ecx@41 + int v33; // ecx@47 + int v34; // ecx@56 + int v35; // esi@58 + __int16 v36; // ax@58 + int v37; // ecx@59 + int v38; // eax@59 + int v39; // ecx@62 + signed int v40; // ST30_4@64 + signed __int64 v41; // qtt@64 + int v42; // ecx@64 + unsigned __int16 *v43; // eax@66 + LODSprite_stru0 *v44; // ecx@66 + int v45; // edx@69 + int v46; // edx@77 + //unsigned __int16 *pTarget; // [sp+Ch] [bp-50h]@2 + signed int v48; // [sp+10h] [bp-4Ch]@2 + signed int v49; // [sp+14h] [bp-48h]@2 + int v50; // [sp+14h] [bp-48h]@19 + int v51; // [sp+14h] [bp-48h]@57 + int v52; // [sp+18h] [bp-44h]@13 + int v53; // [sp+1Ch] [bp-40h]@2 + int v54; // [sp+1Ch] [bp-40h]@22 + int v55; // [sp+1Ch] [bp-40h]@32 + int v56; // [sp+1Ch] [bp-40h]@69 + int v57; // [sp+20h] [bp-3Ch]@2 + int v58; // [sp+24h] [bp-38h]@1 + int v59; // [sp+28h] [bp-34h]@2 + int v60; // [sp+28h] [bp-34h]@13 + unsigned __int16 *v61; // [sp+2Ch] [bp-30h]@2 + int v62; // [sp+30h] [bp-2Ch]@2 + void *v63; // [sp+30h] [bp-2Ch]@29 + void *v64; // [sp+30h] [bp-2Ch]@66 + int v65; // [sp+34h] [bp-28h]@2 + int v66; // [sp+34h] [bp-28h]@22 + int v67; // [sp+34h] [bp-28h]@59 + int v68; // [sp+38h] [bp-24h]@13 + unsigned int v69; // [sp+3Ch] [bp-20h]@2 + int v70; // [sp+40h] [bp-1Ch]@2 + signed int v71; // [sp+40h] [bp-1Ch]@15 + int v72; // [sp+44h] [bp-18h]@2 + unsigned __int16 *v73; // [sp+44h] [bp-18h]@29 + unsigned __int16 *v74; // [sp+44h] [bp-18h]@66 + int v75; // [sp+48h] [bp-14h]@4 + int v76; // [sp+48h] [bp-14h]@22 + int v77; // [sp+48h] [bp-14h]@59 + //LODSprite *v78; // [sp+4Ch] [bp-10h]@1 + int v79; // [sp+50h] [bp-Ch]@4 + int v80; // [sp+50h] [bp-Ch]@21 + int v81; // [sp+50h] [bp-Ch]@62 + int v82; // [sp+50h] [bp-Ch]@67 + int v83; // [sp+50h] [bp-Ch]@75 + int *pTargetZ; // [sp+54h] [bp-8h]@4 + int v85; // [sp+58h] [bp-4h]@18 + int v86; // [sp+58h] [bp-4h]@56 + signed int v87; // [sp+64h] [bp+8h]@2 + int v88; // [sp+68h] [bp+Ch]@18 + int v89; // [sp+68h] [bp+Ch]@56 + + v3 = a2; + //v78 = this; + result = a2->_screenspace_x_scaler_packedfloat; + v58 = a2->_screenspace_x_scaler_packedfloat; + if ( result <= 0 ) + return result; + v5 = a2->_screenspace_y_scaler_packedfloat; + v6 = a2->_screenspace_x_scaler_packedfloat; + v87 = (signed __int64)0x100000000ui64 / result; + v48 = (signed __int64)0x100000000ui64 / result; + v62 = (signed __int64)0x100000000ui64 / v5; + //v7 = this->uHeight; + v8 = (signed int)((signed __int64)0x100000000ui64 / v5) >> 1; + v53 = v8; + v70 = (this->uHeight << 16) - v8; + v49 = this->uHeight; + v69 = v3->uTargetPitch; + + __debugbreak(); // target surface will most likely be 32bit, but this sub awaits 16bits + auto pTarget = (unsigned __int16 *)v3->pTarget; + v57 = v3->sZValue; + v61 = v3->pPalette; + v9 = (v6 * this->uWidth + 0x8000) >> 16; + v72 = v3->uScreenSpaceY; + result = (v5 * this->uHeight + 0x8000) >> 16; + v10 = (int *)(v72 - result + 1); + v11 = v3->uScreenSpaceX - (v9 >> 1) + 1; + v65 = v72 - result + 1; + v59 = v11 + v9 - 1; + if ( v3->uFlags & 0x800 ) + { + v10 = (int *)((char *)v10 + (v49 >> 1)); + v72 += v49 >> 1; + v65 = (int)v10; + } + v12 = v72; + pTargetZ = v10; + v75 = v3->uScreenSpaceX - (v9 >> 1) + 1; + v79 = v11 + v9 - 1; + if ( !(v3->uFlags & 8) ) + { + if ( v65 < (signed int)v3->uViewportY ) + pTargetZ = (int *)v3->uViewportY; + if ( v72 > (signed int)v3->uViewportW ) + v12 = v3->uViewportW; + if ( v11 < (signed int)v3->uViewportX ) + v75 = v3->uViewportX; + if ( v59 > (signed int)v3->uViewportZ ) + v79 = v3->uViewportZ; + } + v68 = v75 - v11; + v13 = -v62; + v60 = v59 - v79; + v52 = -v62; + if ( v3->uFlags & 1 ) + { + v13 = v62; + v70 = v53; + v52 = v62; + } + v71 = v13 * (v72 - v12) + v70; + if ( LOBYTE(viewparams->field_20) ) + { + if ( a3 ) + return result; + } + v14 = 5 * v12; + v15 = v69 * v12; + result = v12 - v72 + result - 1; + v16 = (char *)pTargetZ - v65; + v17 = v14 << 7; + if ( v3->uFlags & 4 ) + { + v34 = v79 + v15; + v89 = v34; + v86 = v79 + v17; + if ( result < (signed int)v16 ) + return result; + v51 = result - (int)v16 + 1; + while ( 1 ) + { + v35 = v71 >> 16; + v36 = this->pSpriteLines[v35].a1; + if ( v36 == -1 ) + { + v34 -= v69; + v89 = v34; + goto LABEL_84; + } + v37 = v9 - ((unsigned __int64)(v36 * (signed __int64)v58) >> 16); + v67 = v87 * ((unsigned __int64)(this->pSpriteLines[v35].a2 * (signed __int64)v58) >> 16); + v38 = v9 - v60; + v77 = v9 - v60; + if ( v9 - v60 <= (signed int)(v9 - ((unsigned __int64)(this->pSpriteLines[v35].a2 * (signed __int64)v58) >> 16)) + || v68 >= v37 ) + { + v89 -= v69; + v34 = v89; +LABEL_84: + v86 -= window->GetWidth(); + goto LABEL_85; + } + if ( v38 < v37 ) + v81 = (v87 >> 1) + v87 * (v37 - v38); + else + { + v77 = v37; + v81 = v87 >> 1; + v39 = v37 - v9; + v89 += v39 + v60; + v86 += v60 + v39; + } + v40 = ((this->pSpriteLines[v35].a2 + 1) << 16) - v81 - v67; + LODWORD(v41) = v40 << 16; + HIDWORD(v41) = v40 >> 16; + v42 = v77 - (((signed int)((unsigned __int64)(v41 / v48) - 0x8000) >> 16) + 1); + if ( v68 >= v42 ) + v42 = v68; + v43 = &pTarget[v89]; + v74 = &v43[v42 - v77 + 1]; + v44 = &this->pSpriteLines[v35]; + v64 = v44->pos; + if ( !v57 ) + { + v83 = v67 + v81; + if ( ((v83 - (v44->a1 << 16)) & 0xFFFF0000) < 0 ) + { + v83 += v87; + --v43; + --pTargetZ; + } + while ( v43 >= v74 ) + { + v46 = (v83 - ((signed int)this->pSpriteLines[v35].a1 << 16)) >> 16; + if ( *((char *)v64 + v46) ) + *v43 = v61[*((char *)v64 + v46)]; + v83 += v87; + --v43; + } + goto LABEL_81; + } + pTargetZ = &v3->pTargetZ[v86]; + v82 = v67 + v81; + if ( ((v82 - (v44->a1 << 16)) & 0xFFFF0000) < 0 ) + goto LABEL_72; +LABEL_73: + if ( v43 >= v74 ) + break; +LABEL_81: + v89 += v9 - v77 - v60 - v69; + v34 = v89; + v86 = v86 + v9 - v77 - v60 - window->GetWidth(); +LABEL_85: + result = v52; + v71 += v52; + --v51; + if ( !v51 ) + return result; + } + v45 = (v82 - ((signed int)this->pSpriteLines[v35].a1 << 16)) >> 16; + v56 = *((char *)v64 + v45); + if ( *((char *)v64 + v45) && v57 <= (unsigned int)*pTargetZ ) + { + *pTargetZ = v57; + *v43 = v61[v56]; + } +LABEL_72: + v82 += v87; + --v43; + --pTargetZ; + goto LABEL_73; + } + v18 = v75 + v15; + v19 = v75 + v17; + v88 = v18; + v85 = v19; + if ( result >= (signed int)v16 ) + { + v50 = result - (int)v16 + 1; + while ( 1 ) + { + v20 = &this->pSpriteLines[v71 >> 16]; + v80 = v71 >> 16; + if ( v20->a1 != -1 ) + break; + v18 -= v69; + v85 = v19 - window->GetWidth(); + v88 = v18; +LABEL_54: + result = v52; + v71 += v52; + --v50; + if ( !v50 ) + return result; + v19 = v85; + } + v21 = (v58 * v20->a1 + 32768) >> 16; + v66 = v21 * v87; + v76 = v68; + v54 = v20->a2; + v22 = v9 - v60; + if ( v68 >= (v58 * v54 + 32768) >> 16 || v22 <= v21 ) + { + v88 -= v69; + v85 -= window->GetWidth(); + goto LABEL_51; + } + if ( v68 > v21 ) + { + v24 = (v87 >> 1) + v87 * (v68 - v21); + } + else + { + v76 = (v58 * v20->a1 + 0x8000) >> 16; + v23 = v21 - v68; + v88 += v23; + v24 = v87 >> 1; + v85 += v23; + } + LODWORD(v25) = (((v54 + 1) << 16) - v24 - v66) << 16; + HIDWORD(v25) = (((v54 + 1) << 16) - v24 - v66) >> 16; + v26 = v76 + ((signed int)(v25 / v48) >> 16) + 1; + if ( v22 > v26 ) + v22 = v26; + v27 = &pTarget[v88]; + v73 = &v27[v22 - v76 - 1]; + v28 = &this->pSpriteLines[v80]; + v63 = v28->pos; + if ( v57 ) + { + pTargetZ = &v3->pTargetZ[v85]; + v29 = v66 - (v28->a1 << 16) + v24; + if ( (v29 & 0xFFFF0000) >= 0 ) + goto LABEL_36; + while ( 1 ) + { + v29 += v87; + ++v27; + ++pTargetZ; +LABEL_36: + if ( v27 >= v73 ) + break; + v55 = *((char *)v63 + (v29 >> 16)); + if ( *((char *)v63 + (v29 >> 16)) && v57 <= (unsigned int)*pTargetZ ) + { + *pTargetZ = v57; + *v27 = v61[v55]; + } + } + v30 = v29 >> 16; + if ( v30 > this->pSpriteLines[v80].a2 - (signed int)this->pSpriteLines[v80].a1 + || (v31 = *((char *)v63 + v30)) == 0 + || v57 > (unsigned int)*pTargetZ ) + goto LABEL_50; + *pTargetZ = v57; + } + else + { + v32 = v66 - (v28->a1 << 16) + v24; + if ( (v32 & 0xFFFF0000) < 0 ) + { + v32 += v87; + ++v27; + ++pTargetZ; + } + while ( v27 < v73 ) + { + if ( *((char *)v63 + (v32 >> 16)) ) + *v27 = v61[*((char *)v63 + (v32 >> 16))]; + v32 += v87; + ++v27; + } + v33 = v32 >> 16; + if ( v33 > this->pSpriteLines[v80].a2 - (signed int)this->pSpriteLines[v80].a1 + || (v31 = *((char *)v63 + v33)) == 0 ) + goto LABEL_50; + } + *v27 = v61[v31]; +LABEL_50: + v88 += v68 - v76 - v69; + v85 = v85 + v68 - v76 - window->GetWidth(); +LABEL_51: + v18 = v88; + goto LABEL_54; + } + return result; +} + +//----- (004AD2D1) -------------------------------------------------------- +int LODSprite::_4AD2D1(struct RenderBillboardTransform_local0 *a2, int a3) +{ + int result; // eax@1 + unsigned int v4; // esi@1 + int v5; // edi@1 + LODSprite_stru0 *v6; // edx@2 + __int16 v7; // bx@2 + int v8; // ecx@3 + unsigned __int16 *v9; // esi@3 + int v10; // ebx@3 + void *v11; // edx@3 + unsigned __int16 *v12; // ecx@3 + int v13; // ebx@4 + //LODSprite *v14; // [sp+8h] [bp-10h]@1 + unsigned __int16 *v15; // [sp+10h] [bp-8h]@1 + unsigned __int16 *v16; // [sp+14h] [bp-4h]@1 + int i; // [sp+20h] [bp+8h]@1 + + result = (int)a2; + v4 = a2->uTargetPitch; + + __debugbreak(); // sub expects 16bit target surface, we may have 32bit + v16 = (unsigned short *)a2->pTarget; + v15 = a2->pPalette; + v5 = this->uHeight - 1; + for ( i = v4 * a2->uScreenSpaceY - (this->uWidth >> 1) + a2->uScreenSpaceX + 1; v5 >= 0; --v5 ) + { + v6 = &this->pSpriteLines[v5]; + v7 = this->pSpriteLines[v5].a1; + if ( this->pSpriteLines[v5].a1 != -1 ) + { + v8 = v7; + v9 = &v16[v7 + i]; + v10 = v6->a2; + v11 = v6->pos; + v12 = &v9[v10 - v8]; + while ( v9 <= v12 ) + { + v13 = *(char *)v11; + v11 = (char *)v11 + 1; + if ( v13 ) + *v9 = v15[v13]; + ++v9; + } + v4 = *(int *)(result + 48); + //this = v14; + } + i -= v4; + } + return result; +} + +//----- (0046454B) -------------------------------------------------------- +void LODFile_IconsBitmaps::ReleaseAll2() +{ + for ( uint i = (uint)this->dword_11B84; i < this->uNumLoadedFiles; i++ ) + { + this->pTextures[i].Release(); + if ( this->pHardwareTextures ) + { + if ( this->pHardwareTextures[i] ) + { + this->pHardwareTextures[i]->Release(); + this->pHardwareTextures[i] = 0; + } + } + if ( this->pHardwareSurfaces ) + { + if ( this->pHardwareSurfaces[i] ) + { + this->pHardwareSurfaces[i]->Release(); + this->pHardwareSurfaces[i] = 0; + } + } + } + this->uTexturePacksCount = 0; + this->uNumPrevLoadedFiles = 0; + this->uNumLoadedFiles = this->dword_11B84; +} + +//----- (004645DC) -------------------------------------------------------- +void LODFile_Sprites::DeleteSomeOtherSprites() +{ + int *v1; // esi@1 + int *v2; // edi@1 + + v1 = (int *)&this->uNumLoadedSprites; + v2 = &this->field_ECA0; + DeleteSpritesRange(field_ECA0, uNumLoadedSprites); + *v1 = *v2; +} + +//----- (00461431) -------------------------------------------------------- +void LOD::File::Close() +{ + if (isFileOpened ) + { + this->pContainerName[0] = 0; + this->uCurrentIndexDir = 0; + free(pSubIndices); + free(pRoot); + pSubIndices = nullptr; + pRoot = nullptr; + fclose(pFile); + isFileOpened = false; + _6A0CA8_lod_unused = 0; + } +} + +//----- (00461492) -------------------------------------------------------- +int LODWriteableFile::CreateNewLod(LOD::FileHeader *pHeader, LOD::Directory *pDir, const char *lod_name) +{ + if (isFileOpened) + return 1; + if ( !pDir->pFilename[0] ) + return 2; + strcpy(pHeader->pSignature, "LOD"); + pHeader->LODSize = 100; + pHeader->uNumIndices = 1; + pDir->field_F = 0; + pDir->uDataSize = 0; + pDir->uOfsetFromSubindicesStart = 288; + strcpy(pLODName, lod_name); + + pFile = fopen(pLODName, "wb+"); + if (!pFile) + return 3; + fwrite(pHeader,sizeof(LOD::FileHeader), 1, pFile); + fwrite(pDir, sizeof(LOD::Directory), 1, pFile); + fclose(pFile); + pFile = nullptr; + return 0; +} + +//----- (0046153F) -------------------------------------------------------- +void LOD::File::ResetSubIndices() +{ + if ( isFileOpened ) + { + pContainerName[0] = 0; + uCurrentIndexDir = 0; + uOffsetToSubIndex = 0; + uNumSubDirs = 0; + uLODDataSize = 0; + free(pSubIndices); + pSubIndices = nullptr; + } +} + +//----- (00450C8B) -------------------------------------------------------- +void LODFile_Sprites::DeleteSomeSprites() +{ + int *v1; // esi@1 + int *v2; // edi@1 + + v1 = (int *)&this->uNumLoadedSprites; + v2 = &this->field_ECA8; + DeleteSpritesRange(this->field_ECA8, this->uNumLoadedSprites); + *v1 = *v2; +} + +//----- (00450CA9) -------------------------------------------------------- +void LODFile_Sprites::DeleteSpritesRange(int uStartIndex, int uStopIndex) +{ + if ( this->pHardwareSprites ) + { + if ( uStartIndex < uStopIndex ) + { + for ( int i = uStartIndex; i < uStopIndex; i++ ) + { + this->pSpriteHeaders[i].Release(); + pHardwareSprites[i].Release(); + } + } + } + else + { + if ( uStartIndex < uStopIndex ) + { + for ( int i = uStartIndex; i < uStopIndex; i++ ) + this->pSpriteHeaders[i].Release(); + } + } +} + +//----- (00450D1D) -------------------------------------------------------- +void LODSprite::Release() +{ + if ( !(HIBYTE(this->word_1A) & 4) ) + { + free(this->pDecompressedBytes); + free(this->pSpriteLines); + } + this->word_1A = 0; + this->pDecompressedBytes = nullptr; + this->pSpriteLines = nullptr; + this->pName[0] = 0; + this->word_16 = 0; + this->uPaletteId = 0; + this->uTexturePitch = 0; + this->uHeight = 0; + this->uWidth = 0; + this->uSpriteSize = 0; +} + +//----- (00450D68) -------------------------------------------------------- +void Sprite::Release() +{ + free((void *)pName); + pName = nullptr; + + if (pTextureSurface) + pTextureSurface->Release(); + pTextureSurface = nullptr; + + if (pTexture) + pTexture->Release(); + pTexture = nullptr; +} + +//----- (0040FAEE) -------------------------------------------------------- +//----- (0040FA2E) -------------------------------------------------------- +bool LODFile_IconsBitmaps::Load(const char *pLODFilename, const char *pFolderName) +{ + ReleaseAll(); + + if (LoadHeader(pLODFilename, 1)) + return false; + + return LoadSubIndices(pFolderName) == 0; +} + +//----- (0040FA60) -------------------------------------------------------- +void LODFile_IconsBitmaps::ReleaseAll() +{ + for( uint i = 0; i < this->uNumLoadedFiles; i++ ) + { + this->pTextures[i].Release(); + if ( this->pHardwareTextures ) + { + if ( this->pHardwareTextures[i] ) + { + this->pHardwareTextures[i]->Release(); + this->pHardwareTextures[i] = 0; + } + } + if ( this->pHardwareSurfaces ) + { + if ( this->pHardwareSurfaces[i] ) + { + this->pHardwareSurfaces[i]->Release(); + this->pHardwareSurfaces[i] = 0; + } + } + } + this->uTexturePacksCount = 0; + this->uNumPrevLoadedFiles = 0; + this->dword_11B84 = 0; + this->dword_11B80 = 0; + this->uNumLoadedFiles = 0; +} + +//----- (0040F9F0) -------------------------------------------------------- +unsigned int LODFile_IconsBitmaps::FindTextureByName(const char *pName) +{ + for ( uint i = 0; i < this->uNumLoadedFiles; i++ ) + { + if ( !_stricmp(this->pTextures[i].pName, pName) ) + return i; + } + return -1; +} + +//----- (0040F9C5) -------------------------------------------------------- +void LODFile_IconsBitmaps::SyncLoadedFilesCount() + { + signed int loaded_files; // eax@1 + Texture *pTex; // edx@1 + + loaded_files = this->uNumLoadedFiles; + for ( pTex = &this->pTextures[loaded_files]; !pTex->pName[0]; --pTex ) + --loaded_files; + if ( loaded_files < (signed int)this->uNumLoadedFiles ) + { + ++loaded_files; + this->uNumLoadedFiles = loaded_files; + } + +} + +//----- (0046249B) -------------------------------------------------------- +LODFile_Sprites::~LODFile_Sprites() +{ + if ( this->pHardwareSprites ) + { + for ( int i = 0; i < this->uNumLoadedSprites; ++i ) + { + this->pSpriteHeaders[i].Release(); + this->pHardwareSprites[i].Release(); + } + } + else + { + for ( int i = 0; i < this->uNumLoadedSprites; ++i ) + this->pSpriteHeaders[i].Release(); + } + //_eh_vector_destructor_iterator_(v1->pSpriteHeaders, 40, 1500, LODSprite::dtor); + //LOD::File::vdtor((LOD::File *)v1); +} +// 4CC2B4: using guessed type int __stdcall _eh vector destructor iterator_(int, int, int, int); + +//----- (00462463) -------------------------------------------------------- +LODSprite::~LODSprite() +{ + if ( !(HIBYTE(this->word_1A) & 4) ) + { + free(pDecompressedBytes); + free(pSpriteLines); + } + pDecompressedBytes = nullptr; + pSpriteLines = nullptr; +} + +//----- (004623E5) -------------------------------------------------------- +LODFile_Sprites::LODFile_Sprites(): + LOD::File() +{ + /*_eh_vector_constructor_iterator_( + v1->pSpriteHeaders, + 40, + 1500, + (void ( *)(void *))LODSprite::LODSprite, + (void ( *)(void *))LODSprite::dtor);*/ + field_ECA4 = 0; + field_ECA0 = 0; + pHardwareSprites = 0; + //can_load_hardware_sprites = 0; + field_ECB4 = 0; + uNumLoadedSprites = 0; +} + +//----- (00462303) -------------------------------------------------------- +LODFile_IconsBitmaps::~LODFile_IconsBitmaps() +{ + + for ( uint i = 0; i < this->uNumLoadedFiles; i++ ) + { + this->pTextures[i].Release(); + if ( this->pHardwareTextures ) + { + if ( this->pHardwareTextures[i] ) + { + this->pHardwareTextures[i]->Release(); + this->pHardwareTextures[i] = 0; + } + } + if ( this->pHardwareSurfaces ) + { + if ( this->pHardwareSurfaces[i] ) + { + this->pHardwareSurfaces[i]->Release(); + this->pHardwareSurfaces[i] = 0; + } + } + } + free(this->pHardwareSurfaces); + free(this->pHardwareTextures); + free(this->ptr_011BB4); + //LOD::File::vdtor((LOD::File *)v1); +} + +//----- (00462272) -------------------------------------------------------- +LODFile_IconsBitmaps::LODFile_IconsBitmaps(): + LOD::File() +{ + /*v2 = v1->pTextures; + v3 = 1000; + do + { + Texture::Texture(v2); + ++v2; + --v3; + } + while ( v3 );*/ + this->uTexturePacksCount = 0; + this->uNumPrevLoadedFiles = 0; + this->dword_11B84 = 0; + this->dword_11B80 = 0; + this->uNumLoadedFiles = 0; + this->dword_011BA4 = 0; + //this->can_load_hardware_sprites = 0; + this->pHardwareSurfaces = 0; + this->pHardwareTextures = 0; + this->ptr_011BB4 = 0; + this->uTextureRedBits = 0; + this->uTextureGreenBits = 0; + this->uTextureBlueBits = 0; +} + +//----- (004621A7) -------------------------------------------------------- +bool LODWriteableFile::_4621A7()//çàêðûòü è çàãðóçèòü çàïèñûâàåìûé ô-ë(ïðè ñîõðàíåíèè) +{ + CloseWriteFile(); + return LoadFile(pLODName, 0); +} + +//----- (00461FD4) ---LODFile_sub_461FD4---text:004632EA -------------------------------------------------- +int LODWriteableFile::FixDirectoryOffsets() +{ + int total_size; // edi@1 + int temp_offset; // ecx@5 + FILE *tmp_file; // eax@9 + size_t write_size; // edi@12 + int result; + char Filename[256]; // [sp+Ch] [bp-228h]@9 + char NewFilename[256]; // [sp+10Ch] [bp-128h]@15 + int i; + + total_size = 0; + for ( i = 0; i < uNumSubDirs; i++ ) + total_size += pSubIndices[i].uDataSize; + //fix offsets + temp_offset = sizeof(LOD::Directory) * uNumSubDirs; + for ( i = 0; i < uNumSubDirs; i++ ) + { + pSubIndices[i].uOfsetFromSubindicesStart=temp_offset; + temp_offset+=pSubIndices[i].uDataSize; + } + strcpy(Filename, "lod.tmp"); + tmp_file = fopen(Filename, "wb+"); + + if ( tmp_file ) + { + fwrite((const void *)&header, sizeof(LOD::FileHeader), 1, tmp_file); + + LOD::Directory Lindx; + strcpy(Lindx.pFilename, "chapter"); + Lindx.uOfsetFromSubindicesStart = uOffsetToSubIndex; //10h 16 + Lindx.uDataSize = sizeof(LOD::Directory) * uNumSubDirs + total_size; //14h 20 + Lindx.dword_000018 = 0; //18h 24 + Lindx.uNumSubIndices = uNumSubDirs; //1ch 28 + Lindx.word_00001E = 0; // 1Eh 30 + fwrite(&Lindx, sizeof(LOD::Directory), 1, tmp_file); + fwrite(pSubIndices, sizeof(LOD::Directory), uNumSubDirs, tmp_file); + fseek(pOutputFileHandle, 0, 0); + if ( total_size > 0 ) + { + do + { + write_size = uIOBufferSize; + if ( total_size <= (signed int)uIOBufferSize ) + write_size =total_size; + fread(pIOBuffer, 1, write_size, pOutputFileHandle); + fwrite(pIOBuffer, 1, write_size, tmp_file); + total_size -= write_size; + } + while ( total_size > 0 ); + } + strcpy(NewFilename, (const char *)&pLODName); + fclose(tmp_file); + fclose(pOutputFileHandle); + CloseWriteFile(); + remove("lodapp.tmp"); + remove(NewFilename); + rename(Filename, NewFilename); + CloseWriteFile(); + LoadFile( (const char *)&pLODName, 0); + result = 0; + } + else + result = 5; + return result; +} + +//----- (00461F71) -------------------------------------------------------- +bool LOD::File::AppendDirectory(LOD::Directory *pDir, const void *pData) +{ + Assert(uNumSubDirs < 299); + + memcpy(&pSubIndices[uNumSubDirs++], pDir, sizeof(LOD::Directory)); + fwrite(pData, 1, pDir->uDataSize, pOutputFileHandle); + return true; +} + +//----- (00461F1E) -------------------------------------------------------- +int LODWriteableFile::CreateTempFile() +{ + if (!isFileOpened) + return 1; + + if (pIOBuffer && uIOBufferSize ) + { + uCurrentIndexDir = 0; + uNumSubDirs = 0; + pOutputFileHandle = fopen("lodapp.tmp", "wb+"); + return pOutputFileHandle ? 1 : 7; + } + else + return 5; +} + +//----- (00461EE9) -------------------------------------------------------- +void LODWriteableFile::CloseWriteFile() +{ + if (isFileOpened) + { + pContainerName[0] = 0; + uCurrentIndexDir = 0; + _6A0CA8_lod_unused = 0; + + isFileOpened = false; + fflush(pFile); + fclose(pFile); + pFile = nullptr; + } + //else + //__debugbreak(); +} +// 6A0CA8: using guessed type int 6A0CA8_lod_unused; + + +//----- (00461B48) -------------------------------------------------------- +unsigned int LODWriteableFile::Write(const LOD::Directory *pDir, const void *pDirData, int a4) +{ + char Filename[256]; + char NewFilename[256]; + FILE *tmp_file; + int comp_res; + bool bRewrite_data; + int offset_to_data; + int total_data_size; + int size_correction; + int to_copy_size; + int read_size; + int curr_position; + int insert_index; + + //insert new data in sorted index lod file + bRewrite_data = false; + insert_index = -1; + if ( !isFileOpened )//sometimes gives crash + return 1; + if ( !pSubIndices ) + return 2; + if ( !pIOBuffer || !uIOBufferSize ) + return 3; + + for ( int i = 0; i < uNumSubDirs; i++ ) + { + comp_res = _stricmp(pSubIndices[i].pFilename, pDir->pFilename); + if( comp_res == 0 ) + { + insert_index = i; + if ( a4 == 0 ) + { + bRewrite_data = true; + break; + } + if ( a4 == 1 ) + { + if ( pSubIndices[i].uNumSubIndices < pDir->uNumSubIndices ) + { + if ( pSubIndices[i].word_00001E < pDir->word_00001E ) + return 4; + } + else + bRewrite_data = true; + break; + } + if ( a4 == 2 ) + return 4; + } + else if ( comp_res > 0 ) + { + if ( insert_index == -1 ) + { + insert_index=i; + break; + } + } + } + strcpy(Filename, "lod.tmp"); + tmp_file = fopen(Filename, "wb+"); + if ( !tmp_file ) + return 5; + if (!bRewrite_data) + size_correction = 0; + else + size_correction = pSubIndices[insert_index].uDataSize; + + //create chapter index + LOD::Directory Lindx; + strcpy(Lindx.pFilename, "chapter"); + Lindx.dword_000018 = 0; + Lindx.word_00001E = 0; + Lindx.uNumSubIndices = uNumSubDirs; + Lindx.uOfsetFromSubindicesStart = sizeof(LOD::FileHeader) + sizeof(LOD::Directory); + total_data_size = uLODDataSize + pDir->uDataSize-size_correction; + if (!bRewrite_data) + { + total_data_size += sizeof(LOD::Directory); + Lindx.uNumSubIndices++; + } + + Lindx.uDataSize = total_data_size; + uNumSubDirs = Lindx.uNumSubIndices; + //move indexes +1 after insert point + if ( !bRewrite_data && (insert_index < uNumSubDirs) )//ïåðåçàïèñûâàíèå ôàéëîâ äëÿ îñâîáîæäåíèÿ ìåñòà äëÿ íîâîãî ô-ëà + { + for( int i = uNumSubDirs; i > insert_index; --i ) + memcpy(&pSubIndices[i], &pSubIndices[i - 1], sizeof(LOD::Directory)); //Uninitialized memory access + } + //insert + memcpy(&pSubIndices[insert_index], pDir, sizeof(LOD::Directory));//çàïèñàòü òåêóùèé ôàéë + //correct offsets to data + if (uNumSubDirs > 0) + { + offset_to_data = sizeof(LOD::Directory) * uNumSubDirs; + for ( int i = 0; i < uNumSubDirs; i++ ) + { + pSubIndices[i].uOfsetFromSubindicesStart = offset_to_data; + offset_to_data += pSubIndices[i].uDataSize; + } + } + + //construct lod file with added data + fwrite(&header, sizeof(LOD::FileHeader), 1, tmp_file); + fwrite(&Lindx, sizeof(LOD::Directory), 1, tmp_file); + fseek(pFile,Lindx.uOfsetFromSubindicesStart, SEEK_SET); + fwrite(pSubIndices, sizeof(LOD::Directory), uNumSubDirs, tmp_file); + + offset_to_data = sizeof(LOD::Directory) * uNumSubDirs; + if ( !bRewrite_data ) + offset_to_data -= sizeof(LOD::Directory); + + fseek(pFile, offset_to_data, SEEK_CUR); + //copy from open lod to temp lod first half + to_copy_size = pSubIndices[insert_index].uOfsetFromSubindicesStart - pSubIndices[0].uOfsetFromSubindicesStart; + while(to_copy_size > 0) + { + read_size = uIOBufferSize; + if ( to_copy_size <= uIOBufferSize ) + read_size = to_copy_size; + fread(pIOBuffer, 1, read_size, pFile); + fwrite(pIOBuffer, 1, read_size, tmp_file); + to_copy_size -= read_size; + } + // add container data + fwrite(pDirData, 1, pDir->uDataSize, tmp_file);// Uninitialized memory access(tmp_file) + if ( bRewrite_data ) + fseek(pFile,size_correction , SEEK_CUR); + + //add remainng data last half + curr_position = ftell(pFile); + fseek(pFile, 0, SEEK_END); + to_copy_size = ftell(pFile) - curr_position; + fseek(pFile, curr_position, SEEK_SET); + while ( to_copy_size > 0 ) + { + read_size = uIOBufferSize; + if ( to_copy_size <= uIOBufferSize ) + read_size = to_copy_size; + fread(pIOBuffer, 1, read_size, pFile); + fwrite(pIOBuffer, 1, read_size, tmp_file); + to_copy_size -= read_size; + } + //replace old file by new with added data + strcpy(NewFilename, (const char *)&pLODName); + fclose(tmp_file); + fclose(pFile); + CloseWriteFile(); + remove(NewFilename); + rename(Filename, NewFilename); + CloseWriteFile(); + //reload new + LoadFile((const char *)&pLODName, 0);//isFileOpened == true, next file + return 0; +} + +//----- (00461A43) -------------------------------------------------------- +bool LODWriteableFile::LoadFile(const char *pFilename, bool bWriting) +{ + if (bWriting & 1) + pFile = fopen(pFilename, "rb"); + else + pFile = fopen(pFilename, "rb+"); + if (!pFile) + { + __debugbreak(); + return false;// âîçìîæíî ôàéë íå çàêðûò, ïîýòîìó íå îòêðûâàåòñÿ + } + + strcpy(pLODName, pFilename); + fread(&header, sizeof(LOD::FileHeader), 1, pFile); + + LOD::Directory lod_indx; + fread( &lod_indx,sizeof(LOD::Directory), 1, pFile); + + fseek(pFile, 0, SEEK_SET); + isFileOpened = true; + strcpy(pContainerName, "chapter"); + uCurrentIndexDir = 0; + uLODDataSize = lod_indx.uDataSize; + uNumSubDirs = lod_indx.uNumSubIndices; + Assert(uNumSubDirs <= 300); + + uOffsetToSubIndex = lod_indx.uOfsetFromSubindicesStart; + fseek(pFile, uOffsetToSubIndex, SEEK_SET); + + fread(pSubIndices, sizeof(LOD::Directory), uNumSubDirs, pFile); + return true; +} + +//----- (00461A11) -------------------------------------------------------- +void LOD::File::FreeSubIndexAndIO() +{ + free(pSubIndices); + free(pIOBuffer);// delete [] pIOBuffer; + pIOBuffer = nullptr; + pSubIndices = nullptr; +} + +//----- (00461954) -------------------------------------------------------- +void LOD::File::AllocSubIndicesAndIO(unsigned int uNumSubIndices, unsigned int uBufferSize) +{ + if (pSubIndices) + { + MessageBoxA(0, "Attempt to reset a LOD subindex!", "MM6", MB_ICONEXCLAMATION); + free(pSubIndices); + pSubIndices = nullptr; + } + pSubIndices =(LOD::Directory *)malloc(32 * uNumSubIndices); + if (pIOBuffer) + { + MessageBoxA(0, "Attempt to reset a LOD IObuffer!", "MM6", MB_ICONEXCLAMATION); + free(pIOBuffer); + pIOBuffer = nullptr; + uIOBufferSize = 0; + } + if ( uBufferSize ) + { + pIOBuffer = (unsigned __int8 *)malloc(uBufferSize); + uIOBufferSize = uBufferSize; + } +} + +//----- (0046188A) -------------------------------------------------------- +int LOD::File::LoadSubIndices(const char *pContainer) +{ + unsigned int uDir; // edi@1 + LOD::Directory *curr_index; // eax@7 + + ResetSubIndices(); + uDir = 0; + + for (uDir=0; uDir uOfsetFromSubindicesStart ; + uNumSubDirs = curr_index->uNumSubIndices;// *(_WORD *)(v8 + 28); + fseek( pFile, uOffsetToSubIndex, SEEK_SET); + pSubIndices = (LOD::Directory *)malloc(sizeof(LOD::Directory)*(uNumSubDirs + 5)); + + if ( pSubIndices) + fread( pSubIndices, sizeof(LOD::Directory), uNumSubDirs, pFile); + return 0; + } + } + return 3; +} + +//----- (004617D5) -------------------------------------------------------- +bool LOD::File::LoadHeader(const char *pFilename, bool bWriting) +{ + const char *v6; // [sp-4h] [bp-Ch]@4 + + if ( this->isFileOpened ) + Close(); + if ( bWriting & 1 ) + v6 = "rb"; + else + v6 = "rb+"; + + pFile = fopen(pFilename, v6); + if ( pFile ) + { + strcpy(pLODName, pFilename); + fread(&header, sizeof(LOD::FileHeader), 1, pFile); + pRoot = (LOD::Directory *)malloc(160); + if ( pRoot ) + { + fread(pRoot, sizeof(LOD::Directory), header.uNumIndices, pFile); + fseek(pFile, 0, SEEK_SET); + isFileOpened = true; + return false; + } + else + { + fclose(pFile); + return true; + } + } + return true; +} + +//----- (00461790) -------------------------------------------------------- +LOD::File::~File() +{ + if ( this->isFileOpened ) + { + fclose(this->pFile); + free(this->pSubIndices); + } +} + +//----- (0046175B) -------------------------------------------------------- +LOD::File::File(): + pRoot(nullptr), + isFileOpened(false) +{ + memset(pLODName, 0, 256); + memset(pContainerName, 0, 16); + this->pFile = nullptr; + this->pSubIndices = nullptr; + this->pIOBuffer = nullptr; + this->isFileOpened = false; + this->uIOBufferSize = 0; + Close(); +} + +//----- (0046172B) -------------------------------------------------------- +LOD::Directory::Directory() +{ + memset(pFilename, 0, 16); + this->pFilename[0] = 0; + this->uOfsetFromSubindicesStart = 0; + this->uDataSize = 0; + this->uNumSubIndices = 0; + this->dword_000018 = 0; + this->word_00001E = 0; +} + +//----- (0046165E) -------------------------------------------------------- +int LOD::File::CalcIndexFast(int startIndex, int maxIndex, const char *pContainerName) +{ + int pCurrent_position; // esi@1 + int v5; // ebx@2 + int result; // eax@2 + + pCurrent_position = startIndex; + while ( 1 ) // binary search in LOD indices + { + + while ( 1 ) + { + v5 = maxIndex - pCurrent_position; + result = _stricmp(pContainerName, (const char *)(&this->pSubIndices[(maxIndex - pCurrent_position) / 2] + pCurrent_position)); + if ( !_stricmp(pContainerName, (const char *)(&this->pSubIndices[(maxIndex - pCurrent_position) / 2] + pCurrent_position)) ) + _6A0CA4_lod_binary_search = (maxIndex - pCurrent_position) / 2 + pCurrent_position; + if ( pCurrent_position == maxIndex ) + { + _6A0CA4_lod_binary_search = -1; + return result; + } + if ( result < 0 )//ïåðâàÿ ñòðîêà ìåíüøå âòîðîé + break; + if ( v5 <= 4 ) + { + for ( int i = pCurrent_position; i < maxIndex; ++i ) + { + result = _stricmp(pContainerName, this->pSubIndices[i].pFilename); + if ( !_stricmp(pContainerName, this->pSubIndices[i].pFilename) ) + { + _6A0CA4_lod_binary_search = i; + return 0;//ñòðîêè ðîâíû + } + } + _6A0CA4_lod_binary_search = -1; + return result; + } + pCurrent_position += (maxIndex - pCurrent_position) / 2; + } + + if ( v5 <= 4 ) + break; + maxIndex = (maxIndex - pCurrent_position) / 2 + pCurrent_position; + } + + for (int i = pCurrent_position; i < maxIndex; ++i) + { + result = _stricmp(pContainerName, this->pSubIndices[i].pFilename); + if ( !_stricmp(pContainerName, this->pSubIndices[i].pFilename) ) + { + _6A0CA4_lod_binary_search = i; + return 0; + } + } + _6A0CA4_lod_binary_search = -1; + return result; +} +// 6A0CA4: using guessed type int _6A0CA4_lod_binary_search; + +//----- (0046161C) -------------------------------------------------------- +bool LOD::File::DoesContainerExist(const char *pContainer) +{ + for ( int i = 0; i < (signed int)this->uNumSubDirs; ++i ) + { + if ( !_stricmp(pContainer, this->pSubIndices[i].pFilename) ) + return 1; + } + return 0; +} + +//----- (00461397) -------------------------------------------------------- +int LODFile_Sprites::_461397() +{ + this->field_ECA8 = this->uNumLoadedSprites; + if ( this->uNumLoadedSprites < this->field_ECA0 ) + this->field_ECA8 = this->field_ECA0; + if ( this->field_ECA0 < this->field_ECA4 ) + field_ECA0 = this->field_ECA4; + return this->uNumLoadedSprites; +} + +//----- (00461580) -------------------------------------------------------- +FILE *LOD::File::FindContainer(const char *pContainer_Name, bool bLinearSearch) +{ + if (!isFileOpened) + return 0; + + if (bLinearSearch) + { + for (uint i = 0; i < uNumSubDirs; ++i) + if (!_stricmp(pContainer_Name, pSubIndices[i].pFilename)) + { + fseek(pFile, uOffsetToSubIndex + pSubIndices[i].uOfsetFromSubindicesStart, SEEK_SET); + return pFile; + } + return nullptr; + } + else + { + CalcIndexFast(0, uNumSubDirs, pContainer_Name); + if ( _6A0CA4_lod_binary_search < 0 ) + return 0; + fseek(pFile, uOffsetToSubIndex + pSubIndices[_6A0CA4_lod_binary_search].uOfsetFromSubindicesStart, SEEK_SET); + return pFile; + } +} + +//----- (0041097D) -------------------------------------------------------- +void LODFile_IconsBitmaps::SetupPalettes(unsigned int uTargetRBits, unsigned int uTargetGBits, unsigned int uTargetBBits) +{ + FILE *File; // [sp+50h] [bp-4h]@7 + + if ( this->uTextureRedBits != uTargetRBits + || this->uTextureGreenBits != uTargetGBits + || this->uTextureBlueBits != uTargetBBits ) //Uninitialized memory access + { + this->uTextureRedBits = uTargetRBits; + this->uTextureGreenBits = uTargetGBits; + this->uTextureBlueBits = uTargetBBits; + for ( uint i = 0; i < this->uNumLoadedFiles; ++i ) + { + Texture DstBuf; // [sp+4h] [bp-50h]@6 + //Texture::Texture(&DstBuf); + if ( this->pTextures[i].pPalette16 ) + { + File = FindContainer((const char *)this->pTextures[i].pName, 0); + if ( File ) + { + fread(&DstBuf, 1, 0x30u, File); + fseek(File, DstBuf.uTextureSize, 1); + for ( uint j = 0; j < 256; ++j ) + { + fread((char *)&uTargetRBits + 3, 1, 1, File); + fread((char *)&uTargetGBits + 3, 1, 1, File); + fread((char *)&uTargetBBits + 3, 1, 1, File); + this->pTextures[i].pPalette16[j] = (BYTE3(uTargetRBits) >> (8 - LOBYTE(this->uTextureRedBits))) + << (LOBYTE(this->uTextureGreenBits) + LOBYTE(this->uTextureBlueBits)); + this->pTextures[i].pPalette16[j] |= (BYTE3(uTargetGBits) >> (8 - LOBYTE(this->uTextureGreenBits))) + << this->uTextureBlueBits; + this->pTextures[i].pPalette16[j] |= BYTE3(uTargetBBits) >> (8 - LOBYTE(this->uTextureBlueBits)); + } + } + } + } + } +} + +//----- (0041088B) -------------------------------------------------------- +void *LOD::File::LoadRaw(const char *pContainer, int a3) +{ + FILE *File; // eax@1 + void *v7; // ebx@7 + void *v8; // edi@7 + Texture DstBuf; // [sp+Ch] [bp-4Ch]@1 + + File = FindContainer(pContainer, 0); + if ( !File ) + Error("Unable to load %s", pContainer); + + fread(&DstBuf, 1, 0x30u, File); + if ( DstBuf.uDecompressedSize ) + { + if ( a3 ) + v7 = malloc(DstBuf.uDecompressedSize+1); + else + v7 = malloc(DstBuf.uDecompressedSize+1); + v8 = malloc(DstBuf.uTextureSize+1); + fread(v8, 1, DstBuf.uTextureSize, File); + zlib::MemUnzip(v7, &DstBuf.uDecompressedSize, v8, DstBuf.uTextureSize); + DstBuf.uTextureSize = DstBuf.uDecompressedSize; + free(v8); + } + else + { + if ( a3 ) + v7 = malloc(DstBuf.uTextureSize+1); + else + v7 = malloc(DstBuf.uTextureSize+1); + fread(v7, 1, DstBuf.uTextureSize, File); + } + return v7; +} + +//----- (00410522) -------------------------------------------------------- +int LODFile_IconsBitmaps::_410522(Texture *pDst, const char *pContainer, unsigned int uTextureType) +{ + void *v9; // ST2C_4@6 + int v15; // ecx@12 + int v16; // ecx@12 + int v17; // eax@12 + signed int v21; // ecx@18 + signed int v22; // ecx@23 + FILE *File; // [sp+68h] [bp-4h]@1 + unsigned int uTargetRBits; + unsigned int uTargetGBits; + unsigned int uTargetBBits; + + File = FindContainer(pContainer, 0); + if ( !File ) + { + File = FindContainer("pending", 0); + if ( !File ) + Error("Can't find %s!", pContainer); + } + + fread(pDst, 1, 0x30u, File); + strcpy(pDst->pName, pContainer); + pDst->pLevelOfDetail0_prolly_alpha_mask = 0; + if ( pDst->uDecompressedSize ) + { + pDst->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(pDst->uDecompressedSize); + v9 = malloc(pDst->uTextureSize); + fread((void *)v9, 1, (size_t)pDst->uTextureSize, File); + zlib::MemUnzip(pDst->pLevelOfDetail0_prolly_alpha_mask, &pDst->uDecompressedSize, v9, pDst->uTextureSize); + pDst->uTextureSize = pDst->uDecompressedSize; + free(v9); + } + else + { + pDst->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(0); + fread(pDst->pLevelOfDetail0_prolly_alpha_mask, 1, (size_t)pDst->uTextureSize, File); + } + pDst->pPalette16 = 0; + pDst->pPalette24 = 0; + if ( uTextureType == 1 ) + { + pDst->pPalette24 = (unsigned __int8 *)malloc(0x300u); + fread(pDst->pPalette24, 1, 0x300u, File); + } + else if ( uTextureType == 2 ) + { + pDst->pPalette16 = (unsigned __int16 *)malloc(0x400u); + for ( uint i = 0; i < 256; ++i ) + { + fread((char *)&uTargetRBits + 3, 1, 1, File); + fread((char *)&uTargetGBits + 3, 1, 1, File); + fread((char *)&uTargetBBits + 3, 1, 1, File); + pDst->pPalette16[i] = (unsigned __int8)(BYTE3(uTargetRBits) >> (8 - LOBYTE(this->uTextureRedBits))) + << (LOBYTE(this->uTextureBlueBits) + LOBYTE(this->uTextureGreenBits)); + pDst->pPalette16[i] += (unsigned __int8)(BYTE3(uTargetGBits) >> (8 - LOBYTE(this->uTextureGreenBits))) + << this->uTextureBlueBits; + pDst->pPalette16[i] += (unsigned __int8)(BYTE3(uTargetBBits) >> (8 - LOBYTE(this->uTextureBlueBits))); + } + } + + if ( pDst->pBits & 2 ) + { + v15 = (int)&pDst->pLevelOfDetail0_prolly_alpha_mask[pDst->uSizeOfMaxLevelOfDetail]; + pDst->pLevelOfDetail1 = (unsigned __int8 *)v15; + v16 = (pDst->uSizeOfMaxLevelOfDetail >> 2) + v15; + pDst->pLevelOfDetail2 = (unsigned __int8 *)v16; + v17 = v16 + (pDst->uSizeOfMaxLevelOfDetail >> 4); + } + else + { + v17 = 0; + pDst->pLevelOfDetail2 = 0; + pDst->pLevelOfDetail1 = 0; + } + pDst->pLevelOfDetail3 = (unsigned __int8 *)v17; + v21 = 1; + while ( 1 << v21 != pDst->uTextureWidth ) + { + ++v21; + if ( v21 >= 15 ) + goto LABEL_23; + } + pDst->uWidthLn2 = v21; +LABEL_23: + v22 = 1; + while ( 1 << v22 != pDst->uTextureHeight ) + { + ++v22; + if ( v22 >= 15 ) + goto LABEL_28; + } + pDst->uHeightLn2 = v22; +LABEL_28: + switch ( pDst->uWidthLn2 ) + { + case 2: + pDst->uWidthMinus1 = 3; + break; + case 3: + pDst->uWidthMinus1 = 7; + break; + case 4: + pDst->uWidthMinus1 = 15; + break; + case 5: + pDst->uWidthMinus1 = 31; + break; + case 6: + pDst->uWidthMinus1 = 63; + break; + case 7: + pDst->uWidthMinus1 = 127; + break; + case 8: + pDst->uWidthMinus1 = 255; + break; + case 9: + pDst->uWidthMinus1 = 511; + break; + case 10: + pDst->uWidthMinus1 = 1023; + break; + case 11: + pDst->uWidthMinus1 = 2047; + break; + case 12: + pDst->uWidthMinus1 = 4095; + break; + default: + break; + } + switch ( pDst->uHeightLn2 ) + { + case 2: + pDst->uHeightMinus1 = 3; + break; + case 3: + pDst->uHeightMinus1 = 7; + break; + case 4: + pDst->uHeightMinus1 = 15; + break; + case 5: + pDst->uHeightMinus1 = 31; + break; + case 6: + pDst->uHeightMinus1 = 63; + break; + case 7: + pDst->uHeightMinus1 = 127; + break; + case 8: + pDst->uHeightMinus1 = 255; + break; + case 9: + pDst->uHeightMinus1 = 511; + break; + case 10: + pDst->uHeightMinus1 = 1023; + break; + case 11: + pDst->uHeightMinus1 = 2047; + break; + case 12: + pDst->uHeightMinus1 = 4095; + break; + default: + return 1; + } + return 1; +} + +//----- (00410423) -------------------------------------------------------- +void LODFile_IconsBitmaps::_410423_move_textures_to_device() +{ + size_t v4; // eax@9 + char *v5; // ST1C_4@9 + + for ( uint i = 0; i < this->uNumLoadedFiles; i++ ) + { + if ( this->ptr_011BB4[i] ) + { + if ( this->pTextures[i].pName[0] != 'w' || this->pTextures[i].pName[1] != 't' + || this->pTextures[i].pName[2] != 'r' || this->pTextures[i].pName[3] != 'd' || this->pTextures[i].pName[4] != 'r' ) + pRenderer->LoadTexture(&this->pTextures[i].pName[0], this->pTextures[i].uTextureSize, (IDirectDrawSurface4 **)&this->pHardwareSurfaces[i], + &this->pHardwareTextures[i]); + else + { + v4 = strlen(&this->pTextures[i].pName[0]); + v5 = (char *)malloc(v4 + 2); + *v5 = 'h'; + strcpy(v5 + 1, &this->pTextures[i].pName[0]); + pRenderer->LoadTexture(v5, this->pTextures[i].uTextureSize, (IDirectDrawSurface4 **)&this->pHardwareSurfaces[i], &this->pHardwareTextures[i]); + free(v5); + } + } + } + if ( this->ptr_011BB4 ) + { + if ( this->uNumLoadedFiles > 1 ) + memset(this->ptr_011BB4, 0, this->uNumLoadedFiles - 1); + } +} + +//----- (004103BB) -------------------------------------------------------- +void LODFile_IconsBitmaps::ReleaseHardwareTextures() +{ + for ( uint i = 0; i < this->uNumLoadedFiles; i++ ) + { + if ( this->pHardwareTextures ) + { + if ( this->pHardwareTextures[i] ) + { + this->pHardwareTextures[i]->Release(); + this->pHardwareTextures[i] = 0; + this->ptr_011BB4[i] = 1; + } + } + if ( this->pHardwareSurfaces ) + { + if ( this->pHardwareSurfaces[i] ) + { + this->pHardwareSurfaces[i]->Release(); + this->pHardwareSurfaces[i] = 0; + this->ptr_011BB4[i] = 1; + } + } + } +} + +//----- (0041033D) -------------------------------------------------------- +void LODFile_IconsBitmaps::ReleaseLostHardwareTextures() +{ + for ( uint i = 0; i < this->uNumLoadedFiles; ++i ) + { + if ( this->pHardwareSurfaces ) + { + if ( this->pHardwareSurfaces[i] ) + { + if ( this->pHardwareSurfaces[i]->IsLost() == DDERR_SURFACELOST ) + { + if ( this->pHardwareTextures ) + { + if ( this->pHardwareTextures[i] ) + { + this->pHardwareTextures[i]->Release(); + this->pHardwareTextures[i] = 0; + } + } + this->pHardwareSurfaces[i]->Release(); + this->pHardwareSurfaces[i] = 0; + this->ptr_011BB4[i] = 1; + } + } + } + } +} + +//----- (004101B1) -------------------------------------------------------- +int LODFile_IconsBitmaps::ReloadTexture(Texture *pDst, const char *pContainer, int mode) +{ + Texture *v6; // esi@2 + unsigned int v7; // ebx@6 + unsigned int v8; // ecx@6 + signed int result; // eax@7 + FILE *File; // [sp+Ch] [bp-8h]@1 + unsigned __int8 v15; // [sp+11h] [bp-3h]@13 + unsigned __int8 v16; // [sp+12h] [bp-2h]@13 + unsigned __int8 DstBuf; // [sp+13h] [bp-1h]@13 + void *DstBufa; // [sp+1Ch] [bp+8h]@10 + void *Sourcea; // [sp+20h] [bp+Ch]@10 + + File = FindContainer(pContainer, 0); + v6 = pDst; + if ( File && pDst->pLevelOfDetail0_prolly_alpha_mask + && mode == 2 + && pDst->pPalette16 && !pDst->pPalette24 + && (v7 = pDst->uTextureSize, + fread(pDst, 1, 0x30u, File), + strcpy(pDst->pName, pContainer), + v8 = pDst->uTextureSize, + (signed int)v8 <= (signed int)v7) ) + { + if ( !pDst->uDecompressedSize || this->dword_011BA4 ) + { + fread(pDst->pLevelOfDetail0_prolly_alpha_mask, 1, pDst->uTextureSize, File); + } + else + { + Sourcea = malloc(pDst->uDecompressedSize); + DstBufa = malloc(pDst->uTextureSize); + fread(DstBufa, 1, pDst->uTextureSize, File); + zlib::MemUnzip(Sourcea, &v6->uDecompressedSize, DstBufa, v6->uTextureSize); + v6->uTextureSize = pDst->uDecompressedSize; + free(DstBufa); + memcpy(v6->pLevelOfDetail0_prolly_alpha_mask, Sourcea, pDst->uDecompressedSize); + free(Sourcea); + } + for( uint i = 0; i < 256; ++i ) + { + fread(&DstBuf, 1, 1, File); + fread(&v16, 1, 1, File); + fread(&v15, 1, 1, File); + v6->pPalette16[i] = (unsigned __int8)(DstBuf >> (8 - LOBYTE(this->uTextureRedBits))) + << (LOBYTE(this->uTextureBlueBits) + LOBYTE(this->uTextureGreenBits)); + v6->pPalette16[i] += (unsigned __int8)(v16 >> (8 - LOBYTE(this->uTextureGreenBits))) + << this->uTextureBlueBits; + v6->pPalette16[i] += (unsigned __int8)(v15 >> (8 - LOBYTE(this->uTextureBlueBits))); + } + result = 1; + } + else + result = -1; + return result; +} + +//----- (0040FC08) -------------------------------------------------------- +int LODFile_IconsBitmaps::LoadTextureFromLOD(Texture *pOutTex, const char *pContainer, enum TEXTURE_TYPE eTextureType) +{ + Texture *v8; // esi@3 + enum TEXTURE_TYPE v12; // eax@14 + signed int result; // esi@14 + unsigned int v14; // eax@21 + void *v19; // ST3C_4@27 + size_t v22; // ST2C_4@29 + const void *v23; // ecx@29 + void *v30; // eax@30 + signed int v41; // ecx@43 + signed int v42; // ecx@48 + + FILE* pFile = FindContainer(pContainer, false); + if (!pFile) + return -1; + v8 = pOutTex; + fread(pOutTex, 1, 0x30, pFile); + strcpy(pOutTex->pName, pContainer); + if (/*pRenderer->pRenderD3D &&*/ (pOutTex->pBits & 2) && strcmp(v8->pName, "sptext01"))//Ritor1: "&& strcmp(v8->pName, "sptext01")" - temporarily for red_aura + { + if (!pHardwareSurfaces || !pHardwareTextures) + { + pHardwareSurfaces = new IDirectDrawSurface *[1000]; + memset(pHardwareSurfaces, 0, 1000 * sizeof(IDirectDrawSurface4 *)); + + pHardwareTextures = new IDirect3DTexture2 *[1000]; + memset(pHardwareTextures, 0, 1000 * sizeof(IDirect3DTexture2 *)); + + ptr_011BB4 = new char[1000]; + memset(ptr_011BB4, 0, 1000); + } + if (_strnicmp(pContainer, "wtrdr", 5)) + { + if (_strnicmp(pContainer, "WtrTyl", 6)) + v14 = uNumLoadedFiles; + else + { + pRenderer->hd_water_tile_id = uNumLoadedFiles; + v14 = uNumLoadedFiles; + } + result = pRenderer->LoadTexture(pContainer, pOutTex->palette_id1, (IDirectDrawSurface4 **)&pHardwareSurfaces[v14], &pHardwareTextures[v14]); + } + else + { + char *temp_container; + temp_container = (char *)malloc(strlen(pContainer) + 2); + *temp_container = 104;//'h' + strcpy(temp_container + 1, pContainer); + result = pRenderer->LoadTexture((const char *)temp_container, pOutTex->palette_id1, + (IDirectDrawSurface4 **)&pHardwareSurfaces[uNumLoadedFiles], &pHardwareTextures[uNumLoadedFiles]); + free((void *)temp_container); + } + return result; + } + if ( !v8->uDecompressedSize || dword_011BA4 ) + { + v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(v8->uTextureSize); + fread(v8->pLevelOfDetail0_prolly_alpha_mask, 1, (size_t)v8->uTextureSize, pFile); + } + else + { + pContainer = (const char *)malloc(v8->uDecompressedSize); + v19 = malloc(v8->uTextureSize); + fread(v19, 1, (size_t)v8->uTextureSize, pFile); + zlib::MemUnzip((void *)pContainer, &v8->uDecompressedSize, v19, v8->uTextureSize); + v8->uTextureSize = v8->uDecompressedSize; + free(v19); + if ( /*bUseLoResSprites*/false && v8->pBits & 2 ) + { + pOutTex = (Texture *)(((signed int)v8->uSizeOfMaxLevelOfDetail >> 2) + + ((signed int)v8->uSizeOfMaxLevelOfDetail >> 4) + + ((signed int)v8->uSizeOfMaxLevelOfDetail >> 6)); + v22 = (size_t)pOutTex; + v23 = &pContainer[v8->uTextureWidth * v8->uTextureHeight]; + v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc((unsigned int)pOutTex); + memcpy(v8->pLevelOfDetail0_prolly_alpha_mask, v23, v22); + v8->uTextureWidth = (signed __int16)v8->uTextureWidth / 2; + v8->uTextureHeight = (signed __int16)v8->uTextureHeight / 2; + --v8->uWidthLn2; + --v8->uHeightLn2; + v8->uWidthMinus1 = v8->uTextureWidth - 1; + v8->uHeightMinus1 = v8->uTextureHeight - 1; + v8->uSizeOfMaxLevelOfDetail = (signed __int16)v8->uTextureWidth * (signed __int16)v8->uTextureHeight; + v8->uTextureSize = (unsigned int)pOutTex; + } + else + { + v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(v8->uDecompressedSize); + memcpy(v8->pLevelOfDetail0_prolly_alpha_mask, pContainer, v8->uDecompressedSize); + } + free((void *)pContainer); + } + + free(v8->pPalette16); + v8->pPalette16 = NULL; + + free(v8->pPalette24); + v8->pPalette24 = NULL; + + if ( eTextureType == TEXTURE_24BIT_PALETTE ) + { + v8->pPalette24 = (unsigned __int8 *)malloc(0x300); + fread(v8->pPalette24, 1, 0x300, pFile); + } + else + { + if ( eTextureType == TEXTURE_16BIT_PALETTE ) + { + v8->pPalette16 = (unsigned __int16 *)malloc(0x200); + for ( uint i = 0; i < 256; ++i ) + { + fread((char *)&eTextureType + 3, 1, 1, pFile); + fread((char *)&pContainer + 3, 1, 1, pFile); + fread((char *)&pOutTex + 3, 1, 1, pFile); + v8->pPalette16[i] = (unsigned __int8)(BYTE3(eTextureType) >> (8 - LOBYTE(this->uTextureRedBits))) //Uninitialized memory access + << (LOBYTE(this->uTextureBlueBits) + LOBYTE(this->uTextureGreenBits)); + v8->pPalette16[i] += (unsigned __int8)(BYTE3(pContainer) >> (8 - LOBYTE(this->uTextureGreenBits))) + << this->uTextureBlueBits; + v8->pPalette16[i] += (unsigned __int8)(BYTE3(pOutTex) >> (8 - LOBYTE(this->uTextureBlueBits))); + } + } + } + + if ( v8->pBits & 2 ) + { + v8->pLevelOfDetail1 = &v8->pLevelOfDetail0_prolly_alpha_mask[v8->uSizeOfMaxLevelOfDetail]; + v8->pLevelOfDetail2 = &v8->pLevelOfDetail1[v8->uSizeOfMaxLevelOfDetail >> 2]; + v8->pLevelOfDetail3 = &v8->pLevelOfDetail2[v8->uSizeOfMaxLevelOfDetail >> 4]; + } + else + { + v8->pLevelOfDetail1 = 0; + v8->pLevelOfDetail2 = 0; + v8->pLevelOfDetail3 = 0; + } + for ( v41 = 1; v41 < 15; ++v41 ) + { + if ( 1 << v41 == v8->uTextureWidth ) + v8->uWidthLn2 = v41; + } + for ( v42 = 1; v42 < 15; ++v42 ) + { + if ( 1 << v42 == v8->uTextureHeight ) + v8->uHeightLn2 = v42; + } + + switch ( v8->uWidthLn2 ) + { + case 2: + v8->uWidthMinus1 = 3; + break; + case 3: + v8->uWidthMinus1 = 7; + break; + case 4: + v8->uWidthMinus1 = 15; + break; + case 5: + v8->uWidthMinus1 = 31; + break; + case 6: + v8->uWidthMinus1 = 63; + break; + case 7: + v8->uWidthMinus1 = 127; + break; + case 8: + v8->uWidthMinus1 = 255; + break; + case 9: + v8->uWidthMinus1 = 511; + break; + case 10: + v8->uWidthMinus1 = 1023; + break; + case 11: + v8->uWidthMinus1 = 2047; + break; + case 12: + v8->uWidthMinus1 = 4095; + break; + default: + break; + } + switch ( v8->uHeightLn2 ) + { + case 2: + v8->uHeightMinus1 = 3; + break; + case 3: + v8->uHeightMinus1 = 7; + break; + case 4: + v8->uHeightMinus1 = 15; + break; + case 5: + v8->uHeightMinus1 = 31; + break; + case 6: + v8->uHeightMinus1 = 63; + break; + case 7: + v8->uHeightMinus1 = 127; + break; + case 8: + v8->uHeightMinus1 = 255; + break; + case 9: + v8->uHeightMinus1 = 511; + break; + case 10: + v8->uHeightMinus1 = 1023; + break; + case 11: + v8->uHeightMinus1 = 2047; + break; + case 12: + v8->uHeightMinus1 = 4095; + break; + default: + return 1; + } + return 1; +} + +Texture *LODFile_IconsBitmaps::LoadTexturePtr(const char *pContainer, enum TEXTURE_TYPE uTextureType) +{ + uint id = LoadTexture(pContainer, uTextureType); + + Assert(id != -1 && L"Texture not found"); + + return &pTextures[id]; +} + +//----- (0040FB20) -------------------------------------------------------- +unsigned int LODFile_IconsBitmaps::LoadTexture(const char *pContainer, enum TEXTURE_TYPE uTextureType) +{ + areWeLoadingTexture = 1; + + //check loaded texture? + for (uint i = 0; i < uNumLoadedFiles; ++i) + { + if (!_stricmp(pContainer, pTextures[i].pName)) + return i; + } + +// if (!uNumLoadedFiles) +// { +//LABEL_5: + Assert(uNumLoadedFiles < 1000); + /*if (uNumLoadedFiles >= 1000) + { + Log::Warning(L"Maximum texture number exceeded"); + AbortWithError(); + }*/ + if (LoadTextureFromLOD(&pTextures[uNumLoadedFiles], pContainer, uTextureType) == -1) + { + for ( uint i = 0; i < uNumLoadedFiles; ++i ) + { + if (!_stricmp(pTextures[i].pName, "pending")) + return i; + } + LoadTextureFromLOD(&pTextures[uNumLoadedFiles], "pending", uTextureType); + } + areWeLoadingTexture = 0; + ++uNumLoadedFiles; + return uNumLoadedFiles - 1; +// } +// v5 = pTextures; +// while ( _stricmp(v5->pName, pContainer) ) +// { +// ++v4; +// ++v5; +// if (v4 >= uNumLoadedFiles ) +// goto LABEL_5; +// } +// return v4; +} + +Texture * LODFile_IconsBitmaps::GetTexture( int idx ) +{ + Assert(idx < MAX_LOD_TEXTURES, "Texture index out of bounds (%u)", idx); + if (idx == -1) + { + //Log::Warning(L"Texture id = %d missing", idx); + return pTextures + LoadDummyTexture(); + } + return pTextures + idx; +} + +//----- (0046082C) -------------------------------------------------------- +bool Initialize_GamesLOD_NewLOD() +{ + pGames_LOD = new LODWriteableFile; + pGames_LOD->AllocSubIndicesAndIO(300, 0); + if (pGames_LOD->LoadFile("data\\games.lod", 1)) + { + pNew_LOD = new LODWriteableFile; + pNew_LOD->AllocSubIndicesAndIO(300, 100000); + return true; + } + return false; +} diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/LOD.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/LOD.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,332 @@ +#pragma once +#include +#include +#include + +#include "Engine/Graphics/Texture.h" + +class Sprite; + + +#define MAX_LOD_TEXTURES 1000 +#define MAX_LOD_SPRITES 1500 + +/* 354 */ +enum TEXTURE_TYPE +{ + TEXTURE_DEFAULT = 0, + TEXTURE_24BIT_PALETTE = 0x1, + TEXTURE_16BIT_PALETTE = 0x2, +}; + +namespace LOD +{ + #pragma pack(push, 1) + struct FileHeader + { + //----- (004617B6) -------------------------------------------------------- + inline FileHeader() + { + memset(pSignature, 0, 4); + memset(LodVersion, 0, 80); + memset(LodDescription, 0, 80); + memset(array_0000B0, 0, 28); + memset(array_0000CC, 0, 52); + + pSignature[0] = 0; + LodVersion[0] = 0; + LodDescription[0] = 0; + LODSize = 0; + dword_0000A8 = 0; + uNumIndices = 0; + } + + char pSignature[4]; + char LodVersion[80]; + //char field_C[32]; + //char field_2C[40]; + char LodDescription[80]; + int LODSize; + int dword_0000A8; + unsigned int uNumIndices; + char array_0000B0[28]; + char array_0000CC[52]; + }; + #pragma pack(pop) + + + #pragma pack(push, 1) + struct Directory + { + Directory(); + + char pFilename[15]; + char field_F; + unsigned int uOfsetFromSubindicesStart; + unsigned int uDataSize; + int dword_000018; + unsigned __int16 uNumSubIndices; + __int16 word_00001E; + }; + #pragma pack(pop) + + + #pragma pack(push, 1) + struct File + { + File(); + virtual ~File(); + void *LoadRaw(const char *pContainer, int a3); + FILE *FindContainer(const char *pContainerName, bool bLinearSearch); + bool DoesContainerExist(const char *pContainer); + int CalcIndexFast(int startIndex, int maxIndex, const char *pContainerName); + bool LoadHeader(const char *pFilename, bool bWriting); + int LoadSubIndices(const char *pContainer); + void AllocSubIndicesAndIO(unsigned int uNumSubIndices, unsigned int uBufferSize); + void FreeSubIndexAndIO(); + bool AppendDirectory(LOD::Directory *pDir, const void *pData); + void ResetSubIndices(); + void Close(); + + FILE *pFile; + char pLODName[256]; + bool isFileOpened; + unsigned __int8 *pIOBuffer; + unsigned int uIOBufferSize; + struct FileHeader header; + struct Directory *pRoot; + char pContainerName[16]; + unsigned int uCurrentIndexDir; + unsigned int uLODDataSize; + unsigned int uNumSubDirs; + struct Directory *pSubIndices; + unsigned int uOffsetToSubIndex; + FILE *pOutputFileHandle; + }; + #pragma pack(pop) +}; + + + + + + +/* 6 */ +#pragma pack(push, 1) +struct LODWriteableFile: public LOD::File +{ + bool LoadFile(const char *pFilename, bool bWriting); + unsigned int Write(const LOD::Directory *pDir, const void *pDirData, int a4); + void CloseWriteFile(); + int CreateTempFile(); + int FixDirectoryOffsets(); + bool _4621A7(); + int CreateNewLod(LOD::FileHeader *pHeader, LOD::Directory *pDir, const char *Source); + + /*FILE *pFile; + char pLODName[256]; + unsigned int isFileOpened; + unsigned __int8 *pIOBuffer; + unsigned int uIOBufferSize; + struct LOD::FileHeader header; + struct LOD::Directory *pRoot; + unsigned __int8 pContainerName[16]; + unsigned int uCurrentIndexDir; + unsigned int uLODDataSize; + unsigned int uNumSubIndices; + struct LOD::Directory *pSubIndices; + unsigned int uOffsetToSubIndex; + FILE *pOutputFileHandle;*/ +}; +#pragma pack(pop) + + + + +#pragma pack(push, 1) +struct LODFile_IconsBitmaps: public LOD::File +{ + LODFile_IconsBitmaps(); + virtual ~LODFile_IconsBitmaps(); + void SyncLoadedFilesCount(); + unsigned int FindTextureByName(const char *pName); + bool Load(const char *pFilename, const char *pFolderName); + void ReleaseAll(); + unsigned int LoadTexture(const char *pContainer, enum TEXTURE_TYPE uTextureType = TEXTURE_DEFAULT); + struct Texture *LoadTexturePtr(const char *pContainer, enum TEXTURE_TYPE uTextureType = TEXTURE_DEFAULT); + int LoadTextureFromLOD(struct Texture *pOutTex, const char *pContainer, enum TEXTURE_TYPE eTextureType); + int ReloadTexture(struct Texture *pDst, const char *pContainer, int mode); + void ReleaseHardwareTextures(); + void ReleaseLostHardwareTextures(); + void _410423_move_textures_to_device(); + int _410522(struct Texture *pDst, const char *pContainer, unsigned int uTextureType); + void SetupPalettes(unsigned int uTargetRBits, unsigned int uTargetGBits, unsigned int uTargetBBits); + void ReleaseAll2(); + void RemoveTexturesPackFromTextureList(); + void RemoveTexturesFromTextureList(); + void _inlined_sub0(); + void _inlined_sub1(); + void _inlined_sub2(); + + inline int LoadDummyTexture() + { + for (unsigned int i = 0; i < uNumLoadedFiles; ++i) + if (!strcmp(pTextures[i].pName, "pending")) + return i; + return LoadTextureFromLOD(&pTextures[uNumLoadedFiles], "pending", TEXTURE_16BIT_PALETTE); + } + + Texture *GetTexture(int idx); + + + /*FILE *pFile; + unsigned __int8 pLODName[256]; + unsigned int isFileOpened; + unsigned __int8 *pIOBuffer; + unsigned int uIOBufferSize; + struct LOD::FileHeader header; + struct LOD::Directory *pRoot; + unsigned __int8 pContainerName[16]; + unsigned int uCurrentIndexDir; + unsigned int uLODDataSize; + unsigned int uNumSubIndices; + struct LOD::Directory *pSubIndices; + unsigned int uOffsetToSubIndex; + FILE *pOutputFileHandle;*/ + Texture pTextures[MAX_LOD_TEXTURES]; + unsigned int uNumLoadedFiles; + int dword_11B80; + int dword_11B84; + int dword_11B88; + int uTextureRedBits; + int uTextureGreenBits; + int uTextureBlueBits; + int uNumPrevLoadedFiles; + int uTexturePacksCount; + int pFacesLock; + int dword_011BA4; + //int can_load_hardware_sprites; + struct IDirectDrawSurface **pHardwareSurfaces; + struct IDirect3DTexture2 **pHardwareTextures; + char *ptr_011BB4; +}; +#pragma pack(pop) + + + + + + +#pragma pack(push, 1) +struct LODSprite +{ + //----- (0046244C) -------------------------------------------------------- + inline LODSprite() + { + uHeight = 0; + uPaletteId = 0; + word_1A = 0; + pSpriteLines = nullptr; + pDecompressedBytes = nullptr; + } + ~LODSprite(); + + void Release(); + int DrawSprite_sw(struct RenderBillboardTransform_local0 *a2, char a3); + int _4AD2D1(struct RenderBillboardTransform_local0 *a2, int a3); + + char pName[12]; //0 + int uSpriteSize; //C + __int16 uWidth; //10 + __int16 uHeight; //12 + __int16 uPaletteId; //14 + __int16 word_16; //16 + __int16 uTexturePitch; //18 + __int16 word_1A; //1a + int uDecompressedSize; //1c + struct LODSprite_stru0 *pSpriteLines; //20 + void *pDecompressedBytes; //24 +}; +#pragma pack(pop) + +/* 15 */ +#pragma pack(push, 1) +struct LODFile_Sprites: public LOD::File +{ + LODFile_Sprites(); + virtual ~LODFile_Sprites(); + + void DeleteSomeSprites(); + void DeleteSpritesRange(int uStartIndex, int uStopIndex); + int _461397(); + void DeleteSomeOtherSprites(); + int LoadSpriteFromFile(LODSprite *pSpriteHeader, const char *pContainer); + bool LoadSprites(const char *pFilename); + int LoadSprite(const char *pContainerName, unsigned int uPaletteID); + void ReleaseLostHardwareSprites(); + void ReleaseAll(); + void MoveSpritesToVideoMemory(); + void _inlined_sub0(); + void _inlined_sub1(); + + + /*FILE *pFile; + unsigned __int8 pLODName[256]; + unsigned int isFileOpened; + unsigned __int8 *pIOBuffer; + unsigned int uIOBufferSize; + struct LOD::FileHeader header; + struct LOD::Directory *pRoot; + unsigned __int8 pContainerName[16]; + unsigned int uCurrentIndexDir; + unsigned int uLODDataSize; + unsigned int uNumSubIndices; + struct LOD::Directory *pSubIndices; + unsigned int uOffsetToSubIndex; + FILE *pOutputFileHandle;*/ + struct LODSprite pSpriteHeaders[MAX_LOD_SPRITES]; + signed int uNumLoadedSprites; + int field_ECA0; + int field_ECA4; + int field_ECA8; + //int can_load_hardware_sprites; + Sprite *pHardwareSprites; + int field_ECB4; +}; +#pragma pack(pop) + +/* 17 */ +#pragma pack(push, 1) +struct LODSprite_stru0 +{ + int16_t a1; + int16_t a2; + char* pos; +}; +#pragma pack(pop) + + + + +extern LODFile_IconsBitmaps *pEvents_LOD; + +extern LODFile_IconsBitmaps *pIcons_LOD; +extern LODFile_IconsBitmaps *pIcons_LOD_mm6; +extern LODFile_IconsBitmaps *pIcons_LOD_mm8; + +extern LODFile_IconsBitmaps *pBitmaps_LOD; +extern LODFile_IconsBitmaps *pBitmaps_LOD_mm6; +extern LODFile_IconsBitmaps *pBitmaps_LOD_mm8; + +extern LODFile_Sprites *pSprites_LOD; +extern LODFile_Sprites *pSprites_LOD_mm6; +extern LODFile_Sprites *pSprites_LOD_mm8; + +extern LODWriteableFile *pNew_LOD; +extern LODWriteableFile *pGames_LOD; + + + + +extern int _6A0CA4_lod_binary_search; // weak +extern int _6A0CA8_lod_unused; // weak \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Log.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Log.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,53 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include "Log.h" + +#include +#include + +HANDLE hStdOut = nullptr; + + +void Log::Initialize() +{ + if (AllocConsole()) + hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); +} + + +void Log::Warning(const wchar_t *pFormat, ...) +{ + if (!hStdOut) + return; + + va_list args; + wchar_t pMsg[8192]; + + va_start(args, pFormat); + vswprintf_s(pMsg, 8192, pFormat, args); + va_end(args); + + DWORD w; + WriteConsoleW(hStdOut, pMsg, lstrlenW(pMsg), &w, nullptr); + WriteConsoleW(hStdOut, L"\r\n", 2, &w, nullptr); +} +//----- (004BE386) -------------------------------------------------------- +void __fastcall log_error(const char *pMessage) +{ + const char *v1; // edi@1 + FILE *f; // eax@1 + FILE *v3; // esi@1 + + v1 = pMessage; + f = fopen("errorlog.txt", "a"); + v3 = f; + if ( f ) + { + fprintf(f, "%s\n", v1); + fclose(v3); + fflush(v3); + } +} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Log.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Log.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,11 @@ +#pragma once + + +#define LOG_DECOMPILATION_WARNING() Log::Warning(L"%S [%S:%u]", __FUNCTION__, __FILE__, __LINE__); + +class Log +{ + public: + static void Initialize(); + static void Warning(const wchar_t *pFormat, ...); +}; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/LuaVM.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/LuaVM.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,59 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include "LuaVM.h" +#include "lib/lua/lua.h" +#include "Log.h" +#include "OSAPI.h" + +extern "C" int luaopen_UIControl(lua_State *L); // declare the wrapped module +extern "C" int luaopen_Player(lua_State *L); // declare the wrapped module + +LuaVM *lua = nullptr; + +void LuaVM::Initialize() +{ + if (L) + Log::Warning(L"Overwriting previous Lua state"); + + L = luaL_newstate(); + if (!L) + Log::Warning(L"Error creating Lua context.\n"); + + // open default lua libs + luaL_openlibs(L); + + // open each cxx module + luaopen_UIControl(L); + + //if ( luaL_dofile(L,GetScriptFileLocation("script.lua"))) + // Log::Warning(L"Error opening script.lua\n"); +} + +bool LuaVM::DoFile(const char *filename) +{ + if (luaL_dofile(L, GetScriptFileLocation(filename))) + { + Log::Warning(L"Error opening script %s", filename); + return false; + } + return true; +} + +const char *LuaVM::GetScriptFileLocation(const char *script_name) +{ + static DWORD tls_index = TlsAlloc(); + + auto buf = (char *)TlsGetValue(tls_index); + if (!buf) + { + buf = new char[1024]; + TlsSetValue(tls_index, buf); + } + + strcpy(buf, "data/scripts/lua/core/"); + strcat(buf, script_name); + return buf; +} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/LuaVM.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/LuaVM.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,16 @@ +#pragma once + +class LuaVM +{ + public: + inline LuaVM(): L(nullptr) {} + + void Initialize(); + bool DoFile(const char *filename); + + protected: + struct lua_State *L; + + const char *GetScriptFileLocation(const char *script_name); +}; +extern LuaVM *lua; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/MM7.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/MM7.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,83 @@ +#pragma once +#include + +typedef unsigned int uint; + +#define PID(type, id) (unsigned int)((((8 * (id))) | (type)) & 0xFFFF) // packed id +#define PID_TYPE(pid) (unsigned int)((pid) & 7) // extract type +#define PID_ID(pid) (unsigned int)(((pid) & 0xFFFF) >> 3) // extract value + + +typedef unsigned __int16 _WORD; +typedef unsigned __int64 _QWORD; + + + + + + + +/* 297 */ +enum SoundType +{ + SOUND_EndTurnBasedMode = 0xCE, + SOUND_StartTurnBasedMode = 0xCF, + SOUND_FlipOnExit = 0x4E21, +}; + + + +/* 362 */ +#pragma pack(push, 1) +struct TravelInfo +{ + char uMapID; + char pSchedule[7]; + char uDaysCount; + char field_9[3]; + int x; + int y; + int z; + int direction; + int field_1C; +}; +#pragma pack(pop) + + + + + + + + + + + + +/* 374 */ +#pragma pack(push, 1) +struct stat_coord +{ + __int16 x; + __int16 y; + __int16 width; + __int16 height; +}; +#pragma pack(pop) +extern std::array stat_string_coord; + +/* 376 */ +#pragma pack(push, 1) +struct stru336 +{ + int field_0; + int field_4; + int field_8; + int field_C; + int field_10; + int field_14; + __int16 field_18[480]; + __int16 field_3D8[480]; +}; +#pragma pack(pop) + diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/MMT.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/MMT.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,411 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS + +#include "MMT.h" +#include "GUIWindow.h" + +#include "mm7_data.h" +#include "AudioPlayer.h" +#include "Mouse.h" +#include "LOD.h" +#include "Engine/Graphics/Render.h" +#include "GUIFont.h" +#include "lib/libpng/png.h" +#include "Engine/ErrorHandling.h" +#include "Bink_Smacker.h" +#include "Game.h" +#include "Log.h" + + +void ShowLogoVideo() +{ + RGBTexture tex; // [sp+Ch] [bp-30h]@1 + unsigned int uTrackStartMS; // [sp+34h] [bp-8h]@8 + unsigned int uTrackEndMS; // [sp+38h] [bp-4h]@8 + + pMediaPlayer->bStopBeforeSchedule = false; + +// pMediaPlayer->pResetflag = 0; + bGameoverLoop = 1; + if (!bNoVideo) + { + pRenderer->PresentBlackScreen(); + pMediaPlayer->PlayFullscreenMovie(MOVIE_3DOLogo, true); + if ( !pMediaPlayer->bStopBeforeSchedule ) + { + pMediaPlayer->PlayFullscreenMovie(MOVIE_NWCLogo, true); + if ( !pMediaPlayer->bStopBeforeSchedule ) + { + + if (for_refactoring) + { + MessageBoxA(nullptr, "Ritor1: MOVIE_JVC crash", "", 0); + __debugbreak(); + } + + //pMediaPlayer->PlayFullscreenMovie(MOVIE_JVC, true); + //if ( !pMediaPlayer->bStopBeforeSchedule ) + if (!use_MMT) + pMediaPlayer->PlayFullscreenMovie(MOVIE_Intro, true); + } + } + } + char pContainerName[64]; + + if (use_MMT) + { + sprintf(pContainerName, "data\\New_Icons/%s", "MMTTITLE.pcx"); + tex.LoadPCXFile(pContainerName, 0); + } + else + tex.Load("mm6title.pcx", 2); + + pRenderer->BeginScene(); + pRenderer->DrawTextureRGB(0, 0, &tex); + free(tex.pPixels); + tex.pPixels = 0; + MainMenuUI_LoadFontsAndSomeStuff(); + + if (use_MMT) + DrawMMTCopyrightWindow();//Text message in ÌÌÒ menu + else + DrawMM7CopyrightWindow(); + + pRenderer->EndScene(); + pRenderer->Present(); + + #ifndef _DEBUG + Sleep(1500); // let the copyright window stay for a while + #endif + if (!use_MMT) + { + if (!bNoSound && pAudioPlayer->hAILRedbook ) + { + pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0)); + AIL_redbook_stop(pAudioPlayer->hAILRedbook); + AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &uTrackStartMS, &uTrackEndMS); + AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS); + } + } + bGameoverLoop = 0; +} + +void abort_(const char * s, ...) +{ + va_list args; + va_start(args, s); + vfprintf(stderr, s, args); + fprintf(stderr, "\n"); + va_end(args); + abort(); +} + +Texture *LoadPNG(const char *name) +{ + int x, y; + int width, height; + png_byte color_type; + png_byte bit_depth; + png_structp png_ptr; + png_infop info_ptr; + int number_of_passes; + png_bytep * row_pointers; + uint i = 0; + Texture *tex; + + char header[8]; // 8 is the maximum size that can be checked + + /* open file and test for it being a png */ + FILE *fp = fopen(name, "rb"); + if (!fp) + abort_("[read_png_file] File %s could not be opened for reading", name); + fread(header, 1, 8, fp); + if (png_sig_cmp((png_bytep)header, 0, 8)) + abort_("[read_png_file] File %s is not recognized as a PNG file", name); + /* initialize stuff */ + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + + if (!png_ptr) + abort_("[read_png_file] png_create_read_struct failed"); + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + abort_("[read_png_file] png_create_info_struct failed"); + + if (setjmp(png_jmpbuf(png_ptr))) + abort_("[read_png_file] Error during init_io"); + + png_init_io(png_ptr, fp); + png_set_sig_bytes(png_ptr, 8); + + png_read_info(png_ptr, info_ptr); + + width = png_get_image_width(png_ptr, info_ptr); + height = png_get_image_height(png_ptr, info_ptr); + color_type = png_get_color_type(png_ptr, info_ptr); + bit_depth = png_get_bit_depth(png_ptr, info_ptr); + + number_of_passes = png_set_interlace_handling(png_ptr); + png_read_update_info(png_ptr, info_ptr); + + /* read file */ + if (setjmp(png_jmpbuf(png_ptr))) + abort_("[read_png_file] Error during read_image"); + row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * height); + for (y=0; yuTextureHeight = height; + tex->uTextureWidth = width; + tex->uSizeOfMaxLevelOfDetail = png_get_rowbytes(png_ptr, info_ptr); + tex->uTextureSize = png_get_rowbytes(png_ptr, info_ptr); + tex->uDecompressedSize = png_get_rowbytes(png_ptr, info_ptr); + tex->pPalette16 = (unsigned __int16 *) malloc(sizeof(unsigned __int16) * width * height); + tex->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *) malloc(sizeof(unsigned __int8) * width * height); + + for (y=0; ypPalette16[i] = Color16(ptr[0], ptr[1], ptr[2]); + tex->pLevelOfDetail0_prolly_alpha_mask[i] = ptr[3]; + i++; + } + } + //Ritor1: temporarily stopped, needed change RGBTexture structure + /*for (int i = 0; i < width * height; ++i) + tex->pPalette16[i] = 0x7FF; + memset(tex->pLevelOfDetail0_prolly_alpha_mask, 1, sizeof(unsigned __int8) * width * height);*/ + return tex; +} + +void MMT_MainMenu_Loop() +{ + GUIButton *pButton; // eax@27 + unsigned int pControlParam; // ecx@35 + unsigned int pX; + unsigned int pY; // [sp-18h] [bp-54h]@39 + Texture *pTexture; // [sp-14h] [bp-50h]@39 + char pContainerName[64]; + MSG msg; + + pCurrentScreen = SCREEN_GAME; + + pGUIWindow2 = 0; + pAudioPlayer->StopChannels(-1, -1); + + //if (!bNoSound ) + //PlayAudio(L"Sounds\\New_Sounds/Stronghold_Theme.mp3"); + //if (!bNoVideo ) + //pVideoPlayer->PlayMovie(L"Anims\\New_Video/3DOLOGO.smk"); + + pMouse->RemoveHoldingItem(); + + pIcons_LOD->_inlined_sub2(); + + //Create new window + //WINDOW_MainMenu included in GUIWindow.h + pWindow_MMT_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); + + //load buttons + //Texture* MMT_MM6 = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); + + sprintf(pContainerName, "data\\New_Icons/%s", "mm6_button_oval.png"); + Texture* MMT_MM6 = LoadPNG(pContainerName); + + Texture* MMT_MM7 = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); + Texture* MMT_MM8 = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); + Texture* MMT_Continue = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); + Texture* MMT_Exit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); + + pMMT_MainMenu_BtnMM6 = pWindow_MMT_MainMenu->CreateButton(0, 0, MMT_MM6->uTextureWidth, MMT_MM6->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM6, 0, 0, "", MMT_MM6, 0); + pMMT_MainMenu_BtnMM7 = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - (window->GetWidth() / 4), window->GetHeight() / 4, MMT_MM7->uTextureWidth, MMT_MM7->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM7, 1, 0, "", MMT_MM7, 0); + pMMT_MainMenu_BtnMM8 = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - (window->GetWidth() / 4), window->GetHeight() - ((window->GetHeight() / 4) + 50), MMT_MM8->uTextureWidth, MMT_MM8->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM8, 2, 0, "", MMT_MM8, 0); + pMMT_MainMenu_BtnContinue = pWindow_MMT_MainMenu->CreateButton((window->GetWidth() / 4) - 100, window->GetHeight() - ((window->GetHeight() / 4) + 50), MMT_Continue->uTextureWidth, MMT_Continue->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_Continue, 3, 0, "", MMT_Continue, 0); + pMMT_MainMenu_BtnExit = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - 130, window->GetHeight() - 35, MMT_Exit->uTextureWidth, MMT_Exit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 4, 0, "", MMT_Exit, 0); + + pTexture_PCX.Release(); + + sprintf(pContainerName, "data\\New_Icons/%s", "MMTTITLE.pcx"); + if (pTexture_PCX.LoadPCXFile(pContainerName, 0) == 1) + Error("File not found: %s", pContainerName); + + SetCurrentMenuID(MENU_MMT_MAIN_MENU);//included in enum MENU_STATE in GUIWindows.h + SetForegroundWindow(window->GetApiHandle()); + SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0); + while (GetCurrentMenuID() == MENU_MMT_MAIN_MENU ) + { + POINT cursor; + pMouse->GetCursorPos(&cursor); + + while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) + { + if (msg.message == WM_QUIT) + Game_DeinitializeAndTerminate(0); + TranslateMessage(&msg); + DispatchMessageW(&msg); + } + + if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE) + { + WaitMessage(); + continue; + } + + pRenderer->BeginScene(); + pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX); + + MMT_MenuMessageProc();//for ÌÌÒ menu + GUI_UpdateWindows(); + + if ( !pModalWindow )// ??? + { + pButton = pWindow_MMT_MainMenu->pControlsHead; + for ( pButton = pWindow_MMT_MainMenu->pControlsHead; pButton; pButton = pButton->pNext ) + { + if ( cursor.x >= (signed int)pButton->uX && cursor.x <= (signed int)pButton->uZ + && cursor.y >= (signed int)pButton->uY && cursor.y <= (signed int)pButton->uW ) + { + pControlParam = pButton->msg_param; + switch (pControlParam) // backlight for buttons + { + case 0: + pTexture = MMT_MM6; + pX = 0; + pY = 0; + break; + case 1: + pTexture = MMT_MM7; + pX = window->GetWidth() - (window->GetWidth() / 4); + pY = window->GetHeight() / 4; + break; + case 2: + pTexture = MMT_MM8; + pX = window->GetWidth() - (window->GetWidth() / 4); + pY = window->GetHeight() - ((window->GetHeight() / 4) + 50); + break; + case 3: + pTexture = MMT_Continue; + pX = (window->GetWidth() / 4) - 100; + pY = window->GetHeight() - ((window->GetHeight() / 4) + 50); + break; + case 4: + pTexture = MMT_Exit; + pX = window->GetWidth() - 130; + pY = window->GetHeight() - 35; + break; + } + pRenderer->DrawTextureIndexed(pX, pY, pTexture); + } + } + } + //} + pRenderer->EndScene(); + pRenderer->Present(); + } + MMT_MenuMessageProc(); + pRenderer->BeginScene(); + GUI_UpdateWindows(); + pRenderer->EndScene(); + pRenderer->Present(); + + //remove resource + pTexture_PCX.Release(); + if ( pGUIWindow2 ) + { + pGUIWindow2->Release(); + pGUIWindow2 = 0; + } + pWindow_MMT_MainMenu->Release(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); +} + +void MMT_MenuMessageProc() +{ + int pParam; + int pParam2; + UIMessageType pUIMessageType; + + if ( pMessageQueue_50CBD0->uNumMessages ) + { + do + { + + pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &pParam, &pParam2); + + switch (pUIMessageType) + { + case UIMSG_MMT_MainMenu_MM6: + //video + //SetCurrentMenuID(MENU_MAIN_MM6); + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);//temporarily + break; + case UIMSG_MMT_MainMenu_MM7: //new button for ÌÌ7 + //GUIWindow::Create(495, 172, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnNew, 0); + alSourceStop(mSourceID); + pMediaPlayer->ShowMM7IntroVideo_and_LoadingScreen(); + SetCurrentMenuID(MENU_MAIN); + break; + case UIMSG_MMT_MainMenu_MM8: + //video + //SetCurrentMenuID(MENU_MAIN_MM8); + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);//temporarily + break; + case UIMSG_MMT_MainMenu_Continue: + //video + //SetCurrentMenuID(MENU_MAIN_Continue); + pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);//temporarily + break; + case UIMSG_ExitToWindows: + GUIWindow::Create(495, 337, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnExit, 0); + SetCurrentMenuID(MENU_EXIT_GAME); + + default: + break; + } + } + while ( pMessageQueue_50CBD0->uNumMessages ); + } +} +void DrawMMTCopyrightWindow() +{ + GUIWindow Dst; // [sp+8h] [bp-54h]@1 + + memset(&Dst, 0, 0x54u); + Dst.uFrameWidth = 624; + Dst.uFrameHeight = 256; + Dst.uFrameX = 8; + Dst.uFrameY = 30; + Dst.uFrameHeight = pFontSmallnum->CalcTextHeight("Text Verification: Here we can write an explanation of the project", &Dst, 24, 0) + + 2 * LOBYTE(pFontSmallnum->uFontHeight) + + 24; + Dst.uFrameY = 470 - Dst.uFrameHeight; + Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1; + Dst.uFrameW = 469; + //Dst.Hint = "abcagfdsgsg ljsrengvlkjesnfkjwnef"; + Dst.DrawMessageBox(0); + + Dst.uFrameWidth -= 24; + Dst.uFrameX += 12; + Dst.uFrameY += 12; + Dst.uFrameHeight -= 12; + Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1; + Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1; + Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, ui_mainmenu_copyright_color, "Text Verification: Here we can write an explanation of the project", 3); +} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/MMT.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/MMT.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,9 @@ +#pragma once + +void ShowLogoVideo(); +void MMT_MainMenu_Loop(); +void MMT_MenuMessageProc(); +void DrawMMTCopyrightWindow(); + +extern bool use_MMT; +extern bool for_refactoring; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/MapInfo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/MapInfo.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,592 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#include "MapInfo.h" +#include "LOD.h" +#include "Engine/ErrorHandling.h" +#include "mm7_data.h" +#include "texts.h" +#include "Engine/Objects/ObjectList.h" +#include "Engine/Objects/SpriteObject.h" +#include "Engine/Graphics/Indoor.h" + + +#include "Engine/Graphics/Level/Decoration.h" +#include "Engine/Graphics/DecorationList.h" +#include "Party.h" +#include "OurMath.h" + + + +//----- (00453F62) -------------------------------------------------------- +void MapStats::Initialize() +{ + char work_str[32]; // [sp+Ch] [bp-34h]@3 + int work_str_pos; + int work_str_len; + int i; + char* test_string; + unsigned char c; + bool break_loop; + unsigned int temp_str_len; + char* tmp_pos; + int decode_step; +// int item_counter; + + free(pMapStatsTXT_Raw); + pMapStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("MapStats.txt", 0); + strtok(pMapStatsTXT_Raw, "\r"); + strtok(NULL, "\r"); + strtok(NULL, "\r"); + + for (i=1; i<77; ++i) + { + test_string = strtok(NULL, "\r") + 1; + break_loop = false; + decode_step=0; + do + { + c = *(unsigned char*)test_string; + temp_str_len = 0; + while((c!='\t')&&(c>0)) + { + ++temp_str_len; + c=test_string[temp_str_len]; + } + tmp_pos=test_string+temp_str_len; + if (*tmp_pos == 0) + break_loop = true; + *tmp_pos = 0; + if (temp_str_len) + { + switch (decode_step) + { + case 1: + pInfos[i].pName = RemoveQuotes(test_string); + break; + case 2: + pInfos[i].pFilename = RemoveQuotes(test_string); + break; + case 3: + pInfos[i].uNumResets = atoi(test_string); + break; + case 4: + pInfos[i].uFirstVisitedAt = atoi(test_string); + break; + case 5: + pInfos[i]._per = atoi(test_string); + break; + case 6: + pInfos[i].uRespawnIntervalDays = atoi(test_string); + break; + case 7: + pInfos[i]._alert_days = atoi(test_string); + break; + case 8: + pInfos[i]._steal_perm = atoi(test_string); + break; + case 9: + pInfos[i].LockX5 = atoi(test_string); + break; + case 10: + pInfos[i].Trap_D20 = atoi(test_string); + break; + case 11: + pInfos[i].Treasure_prob = atoi(test_string); + break; + case 12: + pInfos[i].Encounter_percent = atoi(test_string); + break; + case 13: + pInfos[i].EncM1percent = atoi(test_string); + break; + case 14: + pInfos[i].EncM2percent = atoi(test_string); + break; + case 15: + pInfos[i].EncM3percent = atoi(test_string); + break; + case 16: + pInfos[i].pEncounterMonster1Texture = RemoveQuotes(test_string); + break; + case 18: + pInfos[i].Dif_M1 = atoi(test_string); + break; + case 19: + pInfos[i].uEncounterMonster1AtLeast = 1; + pInfos[i].uEncounterMonster1AtMost = 1; + strcpy(work_str, test_string); + work_str_pos = 0; + work_str_len=strlen(work_str); + if (work_str_len ) + { + while (work_str[work_str_pos] != '-' ) + { + ++work_str_pos; + if (work_str_pos >= work_str_len ) + break; + } + work_str[work_str_pos] = 0; + pInfos[i].uEncounterMonster1AtLeast = atoi(work_str); + if ( work_str_pos < work_str_len ) + pInfos[i].uEncounterMonster1AtMost = atoi(&work_str[work_str_pos + 1]); + else + pInfos[i].uEncounterMonster1AtMost = pInfos[i].uEncounterMonster1AtLeast; + } + break; + case 20: + pInfos[i].pEncounterMonster2Texture = RemoveQuotes(test_string); + break; + case 22: + pInfos[i].Dif_M2 = atoi(test_string); + break; + case 23: + pInfos[i].uEncounterMonster2AtLeast = 1; + pInfos[i].uEncounterMonster2AtMost = 1; + strcpy(work_str, test_string); + work_str_pos = 0; + work_str_len=strlen(work_str); + if (work_str_len ) + { + while (work_str[work_str_pos] != '-' ) + { + ++work_str_pos; + if (work_str_pos >= work_str_len ) + break; + } + work_str[work_str_pos] = 0; + pInfos[i].uEncounterMonster2AtLeast = atoi(work_str); + if ( work_str_pos < work_str_len ) + pInfos[i].uEncounterMonster2AtMost = atoi(&work_str[work_str_pos + 1]); + else + pInfos[i].uEncounterMonster2AtMost = pInfos[i].uEncounterMonster2AtLeast; + } + break; + case 24: + pInfos[i].pEncounterMonster3Texture = RemoveQuotes(test_string); + break; + case 26: + pInfos[i].Dif_M3 = atoi(test_string); + break; + case 27: + pInfos[i].uEncounterMonster3AtLeast = 1; + pInfos[i].uEncounterMonster3AtMost = 1; + strcpy(work_str, test_string); + work_str_pos = 0; + work_str_len=strlen(work_str); + if (work_str_len ) + { + while (work_str[work_str_pos] != '-' ) + { + ++work_str_pos; + if (work_str_pos >= work_str_len ) + break; + } + work_str[work_str_pos] = 0; + pInfos[i].uEncounterMonster3AtLeast = atoi(work_str); + if ( work_str_pos < work_str_len ) + pInfos[i].uEncounterMonster3AtMost = atoi(&work_str[work_str_pos + 1]); + else + pInfos[i].uEncounterMonster3AtMost = pInfos[i].uEncounterMonster3AtLeast; + } + break; + case 28: + pInfos[i].uRedbookTrackID = atoi(test_string); + break; + case 29: + { + if ( !strcmp(test_string, "CAVE") ) + { + pInfos[i].uEAXEnv = 8; + break; + } + if ( !strcmp(test_string, "STONEROOM") ) + { + pInfos[i].uEAXEnv = 5; + break; + } + if ( !strcmp(test_string, "MOUNTAINS") ) + { + pInfos[i].uEAXEnv = 17; + break; + } + if ( !strcmp(test_string, "PLAIN") ) + { + pInfos[i].uEAXEnv = 19; + break; + } + if ( !strcmp(test_string, "FOREST") ) + { + pInfos[i].uEAXEnv = 15; + break; + } + if ( !strcmp(test_string, "CITY") ) + { + pInfos[i].uEAXEnv = 16; + break; + } + if ( !strcmp(test_string, "UNDERWATER") ) + { + pInfos[i].uEAXEnv = 22; + break; + } + if ( !strcmp(test_string, "ARENA") ) + { + pInfos[i].uEAXEnv = 9; + break; + } + if ( !strcmp(test_string, "GENERIC") ) + { + pInfos[i].uEAXEnv = 0; + break; + } + if ( !strcmp(test_string, "PADDEDCELL") ) + { + pInfos[i].uEAXEnv = 1; + break; + } + if ( !strcmp(test_string, "ROOM") ) + { + pInfos[i].uEAXEnv = 2; + break; + } + if ( !strcmp(test_string, "BATHROOM") ) + { + pInfos[i].uEAXEnv = 3; + break; + } + if ( !strcmp(test_string, "LIVINGROOM") ) + { + pInfos[i].uEAXEnv = 4; + break; + } + if ( !strcmp(test_string, "AUDITORIUM") ) + { + pInfos[i].uEAXEnv = 6; + break; + } + if ( !strcmp(test_string, "CONCERTHALL") ) + { + pInfos[i].uEAXEnv = 7; + break; + } + if ( !strcmp(test_string, "HANGAR") ) + { + pInfos[i].uEAXEnv = 10; + break; + } + if ( !strcmp(test_string, "CARPETEDHALLWAY") ) + { + pInfos[i].uEAXEnv = 11; + break; + } + if ( !strcmp(test_string, "HALLWAY") ) + { + pInfos[i].uEAXEnv = 12; + break; + } + if ( !strcmp(test_string, "STONECORRIDOR") ) + { + pInfos[i].uEAXEnv = 13; + break; + } + if ( !strcmp(test_string, "ALLEY") ) + { + pInfos[i].uEAXEnv = 14; + break; + } + if ( !strcmp(test_string, "QUARRY") ) + { + pInfos[i].uEAXEnv = 18; + break; + } + if ( !strcmp(test_string, "PARKINGLOT") ) + { + pInfos[i].uEAXEnv = 20; + break; + } + if ( !strcmp(test_string, "SEWERPIPE") ) + { + pInfos[i].uEAXEnv = 21; + break; + } + if ( !strcmp(test_string, "DRUGGED") ) + { + pInfos[i].uEAXEnv = 23; + break; + } + if ( !strcmp(test_string, "DIZZY") ) + { + pInfos[i].uEAXEnv = 24; + break; + } + if ( !strcmp(test_string, "PSYCHOTIC") ) + { + pInfos[i].uEAXEnv = 25; + break; + } + pInfos[i].uEAXEnv = 26; + + } + break; + } + } + else + { + break_loop = true; + } + ++decode_step; + test_string=tmp_pos+1; + } while ((decode_step<31)&&!break_loop); + } + + uNumMaps = 77; +} +// 453F62: using guessed type char Str[32]; + +//----- (00410D99) -------------------------------------------------------- +int MapStats::sub_410D99_get_map_index(int a1) +{ + for (int i = 1; i <= pMapStats->uNumMaps; i++) + { + if (_stricmp(pMapStats->pInfos[i].pFilename, pGames_LOD->pSubIndices[a1].pFilename) ) + return i; + } + Error("Map not found"); + return -1; +} + +//----- (004547A3) -------------------------------------------------------- +MAP_TYPE MapStats::GetMapInfo(const char *Str2) +{ + Assert(uNumMaps >= 2); + + for (uint i = 1; i < uNumMaps; ++i) + if (!_stricmp(pInfos[i].pFilename, Str2)) + return (MAP_TYPE)i; + + Error("Map not found!"); + return (MAP_TYPE)-1; +} + + +//----- (0044FFD8) -------------------------------------------------------- +int MapInfo::SpawnRandomTreasure(SpawnPointMM7 *a2) +{ + //MapInfo *v2; // ebx@1 + //SpawnPointMM7 *v3; // esi@1 + //int v4; // eax@1 + int v5; // edx@1 +// int v6; // eax@1 + int v7; // ecx@1 + int v8; // ebx@1 + int v9; // eax@1 + signed int v10; // ebx@1 + signed int result; // eax@1 + signed __int64 v12; // qtt@1 + int v13; // ebx@1 + int v14; // edx@10 + signed int v15; // ebx@20 + unsigned __int16 v16; // dx@20 +// ObjectDesc *v17; // ecx@21 + unsigned __int16 v18; // ax@24 + int v19; // ST0C_4@27 + int v20; // ST08_4@27 + int v21; // ST04_4@27 + int v22; // eax@27 + signed int v23; // ebx@29 + unsigned __int16 v24; // dx@29 +// ObjectDesc *v25; // ecx@30 + unsigned __int16 v26; // ax@33 + //int v27; // ecx@35 + //int v28; // eax@35 + //int v29; // esi@35 + //__int16 v30; // ax@35 + SpriteObject a1a; // [sp+Ch] [bp-7Ch]@1 + //int v32; // [sp+7Ch] [bp-Ch]@1 + //int v33; // [sp+80h] [bp-8h]@1 + int v34; // [sp+84h] [bp-4h]@1 + + //auto a1 = this; + //v2 = a1; + //v3 = a2; + //v4 = rand(); + v34 = 0; + v5 = rand() % 100; + // v6 = 2 * (v2->Treasure_prob + 7 * v3->uIndex) - 14; + v7 = (unsigned __int8)byte_4E8168[a2->uIndex - 1][2 * Treasure_prob]; + v8 = (unsigned __int8)byte_4E8168[a2->uIndex - 1][2 * Treasure_prob + 1]; + //v32 = v5; + //v33 = v7; + v9 = rand(); + v10 = v8 - v7 + 1; + v12 = v9; + result = v9 / v10; + v13 = v7 + (unsigned __int64)(v12 % v10); + if ( v13 < 7 ) + { + if ( v5 < 20 ) + return result; + if ( v5 >= 60 ) + { + v19 = a2->vPosition.z; + v20 = a2->vPosition.y; + v21 = a2->vPosition.x; + v22 = rand(); + return sub_450521_ProllyDropItemAt(v13, v22 % 27 + 20, v21, v20, v19, 0); + } + if ( a2->uIndex == 1 ) + { + v14 = rand() % 51 + 50; + a1a.stru_24.uItemID = 197; + v34 = v14; + } + else if ( a2->uIndex == 2 ) + { + v14 = rand() % 101 + 100; + a1a.stru_24.uItemID = 197; + v34 = v14; + } + else if ( a2->uIndex == 3 ) + { + v14 = rand() % 301 + 200; + a1a.stru_24.uItemID = 198; + v34 = v14; + } + else if ( a2->uIndex == 4 ) + { + v14 = rand() % 501 + 500; + a1a.stru_24.uItemID = 198; + v34 = v14; + } + else if ( a2->uIndex == 5 ) + { + v14 = rand() % 1001 + 1000; + a1a.stru_24.uItemID = 199; + v34 = v14; + } + else if ( a2->uIndex == 6 ) + { + v14 = rand() % 3001 + 2000; + a1a.stru_24.uItemID = 199; + v34 = v14; + } + v15 = 0; + v16 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + v18 = 0; + for( int i = 0; i < pObjectList->uNumObjects; i++ ) + { + if ( pObjectList->pObjects[i].uObjectID == v16 ) + { + v18 = i; + break; + } + } + a1a.stru_24.SetIdentified(); + a1a.uObjectDescID = v18; + a1a.stru_24.uSpecEnchantmentType = v34; + } + else + { + result = a1a.stru_24.GenerateArtifact(); + if ( !result ) + return result; + v23 = 0; + v24 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + v26 = 0; + for( int i = 0; i < pObjectList->uNumObjects; i++ ) + { + if( v24 == pObjectList->pObjects[i].uObjectID ) + { + v26 = i; + break; + } + } + a1a.uObjectDescID = v26; + a1a.stru_24.Reset(); + } + a1a.vPosition.y = a2->vPosition.y; + a1a.uAttributes = 0; + a1a.uSoundID = 0; + a1a.uFacing = 0; + a1a.vPosition.z = a2->vPosition.z; + a1a.vPosition.x = a2->vPosition.x; + a1a.spell_skill = 0; + a1a.spell_level = 0; + a1a.spell_id = 0; + a1a.spell_target_pid = 0; + a1a.spell_caster_pid = 0; + a1a.uSpriteFrameID = 0; + a1a.uSectorID = pIndoor->GetSector(a2->vPosition.x, a2->vPosition.y, a2->vPosition.z);; + return a1a.Create(0, 0, 0, 0); +} + +//----- (004498D5) -------------------------------------------------------- +void TeleportToStartingPoint(MapStartPoint point) +{ + const char *model_name; // [sp-4h] [bp-84h]@6 + char pName[128]; // [sp+8h] [bp-78h]@11 + + switch (point) + { + case MapStartPoint_Party: model_name = "Party Start"; break; + case MapStartPoint_North: model_name = "North Start"; break; + case MapStartPoint_South: model_name = "South Start"; break; + case MapStartPoint_East: model_name = "East Start"; break; + case MapStartPoint_West: model_name = "West Start"; break; + default: + Error("Invalid enum value: %u", point); + } + + strcpy(pName, model_name); + if (pDecorationList->GetDecorIdByName(pName)) + { + + if ((signed int)uNumLevelDecorations > 0) + { + for (uint i = 0; i < (signed int)uNumLevelDecorations; ++i) + { + if (pLevelDecorations[i].uDecorationDescID == (signed __int16)pDecorationList->GetDecorIdByName(pName)) + { + pParty->vPosition.x = pLevelDecorations[i].vPosition.x; + pParty->vPosition.y = pLevelDecorations[i].vPosition.y; + pParty->vPosition.z = pLevelDecorations[i].vPosition.z; + pParty->uFallStartY = pParty->vPosition.z; + pParty->sRotationY = (signed int)(stru_5C6E00->uIntegerHalfPi * pLevelDecorations[i].field_1A) / 90; + if (pLevelDecorations[i].field_10_y_rot) + pParty->sRotationY = pLevelDecorations[i].field_10_y_rot; + pParty->sRotationX = 0; + pParty->uFallSpeed = 0; + } + } + } + if (dword_5B65C0) + { + if (_5B65A8_npcdata_uflags_or_other) + pParty->vPosition.x = _5B65A8_npcdata_uflags_or_other; + if (_5B65AC_npcdata_fame_or_other) + pParty->vPosition.y = _5B65AC_npcdata_fame_or_other; + if (_5B65B0_npcdata_rep_or_other) + { + pParty->vPosition.z = _5B65B0_npcdata_rep_or_other; + pParty->uFallStartY = _5B65B0_npcdata_rep_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; + if (dword_5B65BC) + pParty->uFallSpeed = dword_5B65BC; + } + _5B65B4_npcdata_loword_house_or_other = -1; + 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; + } +} diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/MapInfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/MapInfo.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,106 @@ +#pragma once + + +enum MAP_TYPE: unsigned __int32 +{ + MAP_INVALID = 0, + MAP_EMERALD_ISLE = 1, + MAP_HARMONDALE = 2, + MAP_STEADWICK = 3, + MAP_PIERPONT = 4, + MAP_DEYJA = 5, + MAP_BRAKADA_DESERT = 6, + MAP_CELESTIA = 7, + MAP_THE_PIT = 8, + MAP_EVENMORN_ISLE = 9, + MAP_MOUNT_NIGHON = 10, + MAP_BARROW_DOWNS = 11, + MAP_LAND_OF_GIANTS = 12, + MAP_TATALIA = 13, + MAP_AVLEE = 14, + MAP_SHOALS = 15, + //... + MAP_ARENA = 76, + //... +}; + +enum MapStartPoint: unsigned __int32 +{ + MapStartPoint_Party = 0, + MapStartPoint_North = 1, + MapStartPoint_South = 2, + MapStartPoint_East = 3, + MapStartPoint_West = 4 +}; + + +/* 192 */ +#pragma pack(push, 1) +struct MapInfo +{ + int SpawnRandomTreasure(struct SpawnPointMM7 *a2); + + char *pName; + char *pFilename; + char *pEncounterMonster1Texture; + char *pEncounterMonster2Texture; + char *pEncounterMonster3Texture; + unsigned int uNumResets; + unsigned int uFirstVisitedAt; + unsigned int uRespawnIntervalDays; + int _alert_days; + int _steal_perm; + int _per; + char field_2C; + char LockX5; + char Trap_D20; + char Treasure_prob; + char Encounter_percent; + char EncM1percent; + char EncM2percent; + char EncM3percent; + char Dif_M1; + unsigned __int8 uEncounterMonster1AtLeast; + unsigned __int8 uEncounterMonster1AtMost; + char Dif_M2; + unsigned __int8 uEncounterMonster2AtLeast; + unsigned __int8 uEncounterMonster2AtMost; + char Dif_M3; + unsigned __int8 uEncounterMonster3AtLeast; + unsigned __int8 uEncounterMonster3AtMost; + char field_3D; + char field_3E; + char field_3F; + unsigned __int8 uRedbookTrackID; + unsigned __int8 uEAXEnv; + char field_42; + char field_43; +}; +#pragma pack(pop) + + + +/* 193 */ +#pragma pack(push, 1) +struct MapStats +{ + void Initialize(); + MAP_TYPE GetMapInfo(const char *Str2); + int sub_410D99_get_map_index(int a1); + MapInfo pInfos[77]; + unsigned int uNumMaps; + + +}; +#pragma pack(pop) + + + + +extern struct MapStats *pMapStats; + + +extern MapStartPoint uLevel_StartingPointType; // weak + + +void TeleportToStartingPoint(MapStartPoint point); // idb diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/MapsLongTimer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/MapsLongTimer.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,24 @@ +#pragma once + + +/* 169 */ +#pragma pack(push, 1) +struct MapsLongTimer +{ + __int64 NextStartTime; // timer will either fire event at this time (type 2, field_C == 0) + __int16 timer_evt_ID; + __int16 timer_evt_seq_num; + __int16 time_left_to_fire; + __int16 IntervalHalfMins; // or fire on these intervals (type 1) + __int16 YearsInterval; + __int16 MonthsInterval; + __int16 WeeksInterval; + __int16 HoursInterval; + __int16 MinutesInterval; + __int16 SecondsInterval; + __int16 timer_evt_type; + __int16 field_1E; +}; +#pragma pack(pop) +extern MapsLongTimer MapsLongTimersList[100]; //array_5B5928 + diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/NZIArray.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/NZIArray.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,43 @@ +#pragma once +#include +#include + + +template +class NZIArray : std::array<_Ty, _Size> +{ +public: + reference ZerothIndex() + { + return std::array<_Ty, _Size>::operator [](0); + } + + reference operator[](size_type _Pos) + { // subscript nonmutable sequence +#if _ITERATOR_DEBUG_LEVEL == 2 + assert(_Pos != 0 && "not allowed to access zeroth element"); + +#elif _ITERATOR_DEBUG_LEVEL == 1 + _SCL_SECURE_VALIDATE_RANGE(_Pos != 0); +#endif /* _ITERATOR_DEBUG_LEVEL */ + + __analysis_assume(_Pos != 0); + + return std::array<_Ty, _Size>::operator [](_Pos); + } + + const_reference operator[](size_type _Pos) const + { // subscript nonmutable sequence +#if _ITERATOR_DEBUG_LEVEL == 2 + assert(_Pos != 0 && "not allowed to access zeroth element"); + +#elif _ITERATOR_DEBUG_LEVEL == 1 + _SCL_SECURE_VALIDATE_RANGE(_Pos != 0); +#endif /* _ITERATOR_DEBUG_LEVEL */ + + __analysis_assume(_Pos != 0); + + return std::array<_Ty, _Size>::operator [](_Pos); + } +}; diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Objects/Actor.cpp --- a/Engine/Objects/Actor.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Objects/Actor.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -4,38 +4,38 @@ #define _CRT_SECURE_NO_WARNINGS -#include "Engine/Graphics/PaletteManager.h" -#include "ErrorHandling.h" - -#include "Engine/Graphics/DecalBuilder.h" - -#include "Engine/Graphics/Sprites.h" -#include "stru6.h" +#include "../Graphics/PaletteManager.h" +#include "../ErrorHandling.h" + +#include "../Graphics/DecalBuilder.h" + +#include "../Graphics/Sprites.h" +#include "../../stru6.h" #include "Actor.h" -#include "OurMath.h" -#include "Engine/Graphics/Outdoor.h" +#include "../OurMath.h" +#include "../Graphics/Outdoor.h" #include "AudioPlayer.h" -#include "Game.h" +#include "../Game.h" #include "ObjectList.h" -#include "Engine/Graphics/Overlays.h" -#include "FactionTable.h" -#include "TurnEngine.h" -#include "CastSpellInfo.h" -#include "Timer.h" -#include "LOD.h" -#include "Party.h" +#include "../Graphics/Overlays.h" +#include "../Tables/FactionTable.h" +#include "../TurnEngine/TurnEngine.h" +#include "../Spells/CastSpellInfo.h" +#include "../Timer.h" +#include "../LOD.h" +#include "../Party.h" #include "GUIWindow.h" -#include "MM7.h" +#include "../MM7.h" #include "SpriteObject.h" -#include "stru298.h" -#include "Log.h" -#include "Texts.h" -#include "Engine/Graphics/Level/Decoration.h" -#include "Engine/Graphics/Viewport.h" -#include "Engine/Graphics/Vis.h" +#include "../stru298.h" +#include "../Log.h" +#include "../Texts.h" +#include "../Graphics/Level/Decoration.h" +#include "../Graphics/Viewport.h" +#include "../Graphics/Vis.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Objects/Actor.h --- a/Engine/Objects/Actor.h Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Objects/Actor.h Fri Sep 19 02:57:42 2014 +0600 @@ -1,6 +1,6 @@ #pragma once #include "Monsters.h" -#include "Spells.h" +#include "../Spells/Spells.h" #include "Items.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Objects/Chest.cpp --- a/Engine/Objects/Chest.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Objects/Chest.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -5,29 +5,29 @@ #define _CRT_SECURE_NO_WARNINGS #include -#include "ErrorHandling.h" +#include "../ErrorHandling.h" #include "Items.h" #include "Chest.h" -#include "FrameTableInc.h" -#include "LOD.h" -#include "MapInfo.h" +#include "../Tables/FrameTableInc.h" +#include "../LOD.h" +#include "../MapInfo.h" #include "Actor.h" -#include "Engine/Graphics/Outdoor.h" -#include "Engine/Graphics/DecorationList.h" -#include "Party.h" +#include "../Graphics/Outdoor.h" +#include "../Graphics/DecorationList.h" +#include "../Party.h" #include "AudioPlayer.h" -#include "OurMath.h" -#include "Texts.h" +#include "../OurMath.h" +#include "../Texts.h" #include "ObjectList.h" #include "GUIWindow.h" -#include "Timer.h" +#include "../Timer.h" -#include "MM7.h" +#include "../MM7.h" #include "SpriteObject.h" #include "Mouse.h" -#include "Engine/Graphics/Viewport.h" -#include "Engine/Graphics/Level/Decoration.h" +#include "../Graphics/Viewport.h" +#include "../Graphics/Level/Decoration.h" size_t uNumChests; // idb struct ChestList *pChestList; diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Objects/Items.cpp --- a/Engine/Objects/Items.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Objects/Items.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -8,20 +8,20 @@ #include "UI\UIHouses.h" #include "GUIButton.h" -#include "ErrorHandling.h" +#include "../ErrorHandling.h" #include "Items.h" -#include "MapInfo.h" +#include "../MapInfo.h" #include "GUIWindow.h" #include "Chest.h" -#include "LOD.h" +#include "../LOD.h" #include "Monsters.h" -#include "Party.h" -#include "FactionTable.h" -#include "StorylineTextTable.h" -#include "texts.h" -#include "mm7_data.h" -#include "OurMath.h" +#include "../Party.h" +#include "../Tables/FactionTable.h" +#include "../Tables/StorylineTextTable.h" +#include "../texts.h" +#include "../mm7_data.h" +#include "../OurMath.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Objects/Items.h --- a/Engine/Objects/Items.h Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Objects/Items.h Fri Sep 19 02:57:42 2014 +0600 @@ -1,7 +1,7 @@ #pragma once #include #include -#include "NZIArray.h" +#include "../NZIArray.h" enum DAMAGE_TYPE:unsigned int { diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Objects/Monsters.cpp --- a/Engine/Objects/Monsters.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Objects/Monsters.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -6,13 +6,13 @@ #include #include #include -#include "ErrorHandling.h" +#include "../ErrorHandling.h" #include "Monsters.h" -#include "FrameTableInc.h" -#include "LOD.h" -#include "texts.h" -#include "mm7_data.h" +#include "../Tables/FrameTableInc.h" +#include "../LOD.h" +#include "../texts.h" +#include "../mm7_data.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Objects/NPC.cpp --- a/Engine/Objects/NPC.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Objects/NPC.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -3,21 +3,21 @@ #include #define _CRT_SECURE_NO_WARNINGS -#include "texts.h" -#include "LOD.h" -#include "Autonotes.h" -#include "Awards.h" -#include "Party.h" +#include "../texts.h" +#include "../LOD.h" +#include "../Autonotes.h" +#include "../Awards.h" +#include "../Party.h" #include "NPC.h" #include "GUIWindow.h" -#include "Events.h" +#include "../Events.h" #include "UI\UIHouses.h" -#include "Engine/Graphics/Indoor.h" -#include "MapInfo.h" +#include "../Graphics/Indoor.h" +#include "../MapInfo.h" #include "Actor.h" #include "AudioPlayer.h" -#include "CastSpellInfo.h" -#include "Engine/Graphics/Overlays.h" +#include "../Spells/CastSpellInfo.h" +#include "../Graphics/Overlays.h" int pDialogueNPCCount; std::array pDialogueNPCPortraits; diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Objects/ObjectList.cpp --- a/Engine/Objects/ObjectList.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Objects/ObjectList.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -4,10 +4,10 @@ #define _CRT_SECURE_NO_WARNINGS #include "ObjectList.h" -#include "mm7_data.h" -#include "Engine/Graphics/Sprites.h" -#include "FrameTableInc.h" -#include "ErrorHandling.h" +#include "../mm7_data.h" +#include "../Graphics/Sprites.h" +#include "../Tables/FrameTableInc.h" +#include "../ErrorHandling.h" //----- (0042EB42) -------------------------------------------------------- __int16 ObjectList::ObjectIDByItemID(unsigned __int16 uItemID) diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Objects/Player.cpp --- a/Engine/Objects/Player.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Objects/Player.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -5,35 +5,35 @@ #define _CRT_SECURE_NO_WARNINGS #include "stru6.h" -#include "ErrorHandling.h" +#include "../ErrorHandling.h" #include "Player.h" -#include "PlayerFrameTable.h" +#include "../Tables/PlayerFrameTable.h" #include "AudioPlayer.h" -#include "Party.h" -#include "LOD.h" +#include "../Party.h" +#include "../LOD.h" #include "GUIWindow.h" -#include "Engine/Graphics/Viewport.h" +#include "../Graphics/Viewport.h" #include "Actor.h" -#include "Game.h" +#include "../Game.h" #include "Mouse.h" -#include "TurnEngine.h" -#include "Events.h" -#include "Events2D.h" -#include "Engine/Graphics/Outdoor.h" -#include "StorylineTextTable.h" -#include "Autonotes.h" -#include "Awards.h" -#include "texts.h" - -#include "stru123.h" -#include "stru298.h" +#include "../TurnEngine/TurnEngine.h" +#include "../Events.h" +#include "../Events2D.h" +#include "../Graphics/Outdoor.h" +#include "../Tables/StorylineTextTable.h" +#include "../Autonotes.h" +#include "../Awards.h" +#include "../texts.h" + +#include "../stru123.h" +#include "../stru298.h" #include "ObjectList.h" -#include "MM7.h" +#include "../MM7.h" #include "SpriteObject.h" -#include "Engine/Graphics/DecalBuilder.h" -#include "CastSpellInfo.h" -#include "OurMath.h" +#include "../Graphics/DecalBuilder.h" +#include "../Spells/CastSpellInfo.h" +#include "../OurMath.h" #include "UI\UIPartyCreation.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Objects/Player.h --- a/Engine/Objects/Player.h Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Objects/Player.h Fri Sep 19 02:57:42 2014 +0600 @@ -1,7 +1,7 @@ #pragma once #include "Items.h" -#include "Spells.h" -#include "Conditions.h" +#include "../Spells/Spells.h" +#include "../Conditions.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Objects/SpriteObject.cpp --- a/Engine/Objects/SpriteObject.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Engine/Objects/SpriteObject.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -6,24 +6,24 @@ #include "Engine/Graphics/Sprites.h" #include "Engine/Graphics/BSPModel.h" #include "SpriteObject.h" -#include "Party.h" -#include "TurnEngine.h" -#include "OurMath.h" +#include "../Party.h" +#include "../TurnEngine/TurnEngine.h" +#include "../OurMath.h" #include "ObjectList.h" #include "Engine/Graphics/Outdoor.h" #include "Engine/Graphics/ParticleEngine.h" -#include "Timer.h" -#include "Game.h" -#include "LOD.h" +#include "../Timer.h" +#include "../Game.h" +#include "../LOD.h" #include "Actor.h" -#include "Events.h" +#include "../Events.h" #include "AudioPlayer.h" #include "Engine/Graphics/Level/Decoration.h" -#include "MM7.h" +#include "../MM7.h" -#include "stru298.h" -#include "Random.h" +#include "../stru298.h" +#include "../Random.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/OurMath.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/OurMath.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,256 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#include "OurMath.h" +#include "MM7_data.h" + +//----- (00452969) -------------------------------------------------------- +stru193_math::stru193_math() +{ + double v3; // ST18_8@2 + + this->pTanTable[0] = 0; + this->pCosTable[0] = 65536; + this->pInvCosTable[0] = 65536; + for(int i = 1; i < (signed int)this->uIntegerHalfPi; i++) + { + v3 = (double)i * 3.141592653589793 / (double)uIntegerPi; + pTanTable[i] = (signed __int64)(tan(v3) * (double)this->pCosTable[0] + 0.5); + pCosTable[i] = (signed __int64)(cos(v3) * (double)this->pCosTable[0] + 0.5); + pInvCosTable[i] = (signed __int64)(1.0 / cos(v3) * (double)this->pCosTable[0] + 0.5); + } + for(int i = this->uIntegerHalfPi; i < 520; i++) + { + this->pTanTable[i] = 0xEFFFFFFFu; + this->pCosTable[i] = 0; + this->pInvCosTable[i] = 0xEFFFFFFFu; + } +} + + +//----- (00402CAE) -------------------------------------------------------- +int stru193_math::Cos(int angle) +{ + int v2; // eax@1 + + //a2: (angle - uIntegerHalfPi) for sin(angle) + // (angle) for cos(angle) + + v2 = uDoublePiMask & angle; + + if ( v2 > uIntegerPi ) + v2 = uIntegerDoublePi - v2; + if ( v2 >= uIntegerHalfPi ) + return -pCosTable[uIntegerPi - v2]; + else + return pCosTable[v2]; +} + + +//----- (0045281E) -------------------------------------------------------- +// Calculates atan2(y/x) +// return value: angle in integer format (multiplier of Pi/1024) +unsigned int stru193_math::Atan2(int x, int y) +{ + signed int quadrant; + __int64 dividend; + int quotient; + int lowIdx; + int highIdx; + int angle; + + int X = x; + int Y = y; + + if ( abs(X) < 65536 ) + { + if ( (abs(Y) >> 15) >= abs(X) ) + X = 0; + } + + if ( !X ) + { + if ( Y > 0 ) + { + return uIntegerHalfPi; //Pi/2 + } + else + { + return uIntegerHalfPi + uIntegerPi; //3*(Pi/2) + } + } + + if ( Y ) + { + if ( X < 0 ) + { + X = -X; + if ( Y > 0 ) + { + quadrant = 4; + } + else + { + quadrant = 3; + } + } + else + { + if ( Y > 0 ) + { + quadrant = 1; + } + else + { + quadrant = 2; + } + } + + if ( Y < 0 ) + Y = -Y; + + LODWORD(dividend) = Y << 16; + HIDWORD(dividend) = Y >> 16; + quotient = dividend / X; + + //looks like binary search + { + int i; + highIdx = uIntegerHalfPi; + lowIdx = 0; + + for (i = 0; i < 6; ++i) + { + if (quotient <= pTanTable[(lowIdx + highIdx) / 2]) + highIdx = (lowIdx + highIdx) / 2; + else + lowIdx = (lowIdx + highIdx) / 2; + } + } + + angle = lowIdx + 1; + while ( angle < (highIdx - 1) && quotient >= pTanTable[angle] ) + ++angle; + + switch (quadrant) + { + case 1: //X > 0, Y > 0 + return angle; + + case 2: //X > 0, Y < 0 + return uIntegerDoublePi - angle; //2*Pi - angle + + case 3: //X > 0, Y < 0 + return uIntegerPi + angle; //Pi + angle + + case 4: //X < 0, Y > 0 + return uIntegerPi - angle; //Pi - angle + } + + //should newer get here + return 0; + } + + if ( X < 0 ) //Y == 0, X < 0 + return uIntegerPi; + + return 0; +} + +//----- (0042EBDB) -------------------------------------------------------- +int stru193_math::Sin(int angle) +{ + return Cos(angle - this->uIntegerHalfPi); +} + +//----- (0042EBBE) -------------------------------------------------------- +//----- (004453C0) mm6----------------------------------------------------- +//----- (004A1760) mm6_chinese--------------------------------------------- +__int64 fixpoint_mul(int a1, int a2) +{ + return ((__int64)a1 * (__int64)a2) >> 16; +} + +__int64 fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2) +{ + return fixpoint_mul(x1, x2) + + fixpoint_mul(y1, y2) + + fixpoint_mul(z1, z2); +} + +//----- (004A1780) mm6_chinese--------------------------------------------- +__int64 fixpoint_div(int a1, int a2) +{ + return ((__int64)a1 << 16) / a2; +} + +__int64 fixpoint_sub_unknown(int a1, int a2) +{ + return (((__int64)a1 << 16) * a2) >> 16; +} + +//----- (0048B561) -------------------------------------------------------- +int fixpoint_from_float(float val) +{ + // float X.Yf -> int XXXX YYYY + int left = floorf((val - 0.5f) + 0.5f); + int right = floorf((val - left) * 65536.0f); + return (left << 16) | right; +} + +int fixpoint_from_int(int lhv, int rhv) +{ + return (lhv << 16) | rhv; +} + + +//----- (00452A9E) -------------------------------------------------------- +int integer_sqrt(int val) +{ +/////////////////////////////// +//Ïîëó÷åíèå êâàäðàòíîãî êîðíÿ// +/////////////////////////////// + + signed int result; // eax@2 + unsigned int v2; // edx@3 + unsigned int v3; // edi@3 + int v5; // esi@4 + + if (val < 1) + return val; + + v2 = 0; + v3 = val; + result = 0; + for (uint i = 0; i < 16; ++i) + { + result *= 2; + v2 = (v3 >> 30) | 4 * v2; + v5 = 2 * result + 1; + v3 *= 4; + if ( v2 >= v5 ) + { + ++result; + v2 -= v5; + } + } + if ( val - result * result >= (unsigned int)(result - 1) ) + ++result; + return result; +} + +//----- (00452B2E) -------------------------------------------------------- +int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides) +{ + int v3; // esi@1 + + v3 = 0; + if ( uDiceSides ) + { + for ( uint i = 0; i < uNumDice; ++i) + v3 += rand() % uDiceSides + 1; + return v3; + } + return 0; +} diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/OurMath.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/OurMath.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,73 @@ +#pragma once + +#include +#include + +/* 186 */ +#pragma pack(push, 1) +struct stru193_math +{ + stru193_math(); + int Cos(int angle); + unsigned int Atan2(int x, int y); + int Sin(int angle); + + int pTanTable[520]; + int pCosTable[520]; + int pInvCosTable[520]; + static const unsigned int uIntegerPi = 1024; + static const unsigned int uIntegerHalfPi = 512; + static const unsigned int uIntegerDoublePi = 2048; + static const unsigned int uDoublePiMask = 2047; + static const unsigned int uPiMask = 1023; + static const unsigned int uHalfPiMask = 511; +}; +#pragma pack(pop) + +__int64 fixpoint_mul(int, int); +__int64 fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2); +__int64 fixpoint_div(int, int); +__int64 fixpoint_sub_unknown(int, int); +int fixpoint_from_float(float value); +int fixpoint_from_int(int lhv, int rhv); +int integer_sqrt(int val); +int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides); // idb +inline int round_to_int(float x) { return (int)floor(x + 0.5f); } + +template +inline int bankersRounding(const FloatType& value) +{ + assert("Method unsupported for this type" && false); + return value; +} + +template<> inline int bankersRounding(const float& inValue) +{ + union Cast + { + double d; + long l; + }; + volatile Cast c; + c.d = inValue + 6755399441055744.0; + return c.l; +} + +#pragma push_macro("max") +#undef max +template<> inline int bankersRounding(const double& inValue) +{ + double maxValue = std::numeric_limits::max(); + assert(maxValue - 6755399441055744.0 >= inValue); + union Cast + { + double d; + long l; + }; + volatile Cast c; + c.d = inValue + 6755399441055744.0; + return c.l; +} +#pragma pop_macro("max") + +extern struct stru193_math *stru_5C6E00; diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Party.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Party.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,1250 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include "Engine/ErrorHandling.h" + +#include "Party.h" +#include "Timer.h" +#include "AudioPlayer.h" +#include "Engine/Tables/IconFrameTable.h" +#include "Mouse.h" +#include "Engine/Tables/PlayerFrameTable.h" +#include "Engine/TurnEngine/TurnEngine.h" +#include "Engine/Graphics/Viewport.h" +#include "Engine/Objects/Actor.h" +#include "GUIWindow.h" +#include "texts.h" + +#include "MM7.h" +#include "Engine/Graphics/Outdoor.h" +#include "LOD.h" +#include "Engine/Objects/SpriteObject.h" +#include "Engine/Objects/ObjectList.h" + + +#include "Game.h" + +Party *pParty; // idb + +struct ActionQueue *pPartyActionQueue = new ActionQueue; + + +std::array playerAlreadyPicked; // byte_AE3368_ +char PickedPlayer2_unused; // byte_AE3369_ +char PickedPlayer3_unused; // byte_AE336A_ +char PickedPlayer4_unused; // byte_AE336B_ + + + +//----- (0044A56A) -------------------------------------------------------- +void Party::CountHirelings() +{ + field_70A = 0; + + for (unsigned int i = 0; i < pNPCStats->uNumNewNPCs; ++i) + { + NPCData* npc = &pNPCStats->pNewNPCData[i]; + if (npc->Hired() && + (!pHirelings[0].pName || strcmp(npc->pName, pHirelings[0].pName))) + { + if (!pHirelings[1].pName || strcmp(npc->pName, pHirelings[1].pName)) + ++field_70A; + } + } +} + + +// inlined +//----- (mm6c::004858D0) -------------------------------------------------- +void Party::Zero() +{ + uFlags2 = 0; + uNumGoldInBank = 0; + + uCurrentYear = 0; + uCurrentMonth = 0; + uCurrentMonthWeek = 0; + uDaysPlayed = 0; + uCurrentHour = 0; + uCurrentMinute = 0; + uCurrentTimeSecond = 0; + + field_6FC = 0; + days_played_without_rest = 0; + vPosition.x = 0; + vPosition.y = 0; + vPosition.z = 0; + uFallStartY = 0; + sRotationY = 0; + sRotationX = 0; + uFallSpeed = 0; + field_28 = 0; + uDefaultPartyHeight = 192; + field_14_radius = 37; + y_rotation_granularity = 25; + y_rotation_speed = 90; + + uWalkSpeed = 384; + walk_sound_timer = 0; + + field_24 = 5; + field_6FC = 0; + field_708 = 15; + field_0 = 25; + + uNumDeaths = 0; + uNumPrisonTerms = 0; + uNumBountiesCollected = 0; + monster_for_hunting_killed.fill(0); + monster_id_for_hunting.fill(0); + memset(_quest_bits, 0, sizeof(_quest_bits)); + pArcomageWins.fill(0); + uNumArenaPageWins = 0; + uNumArenaSquireWins = 0; + uNumArenaKnightWins = 0; + uNumArenaLordWins = 0; +} + +//inlined +//----- (mm6c::0045BE90) -------------------------------------------------- +void ActionQueue::Reset() +{ + uNumActions = 0; +} + +//----- (004760C1) -------------------------------------------------------- +void ActionQueue::Add(PartyAction action) +{ + if (uNumActions < 30) + pActions[uNumActions++] = action; +} + +//----- (00497FC5) -------------------------------------------------------- +bool Party::_497FC5_check_party_perception_against_level() +{ + int uMaxPerception; // edi@1 + signed int v5; // eax@3 + bool result; // eax@7 + + uMaxPerception = 0; + for (int i = 0; i < 4; i++) + { + if ( this->pPlayers[i].CanAct() ) + { + v5 = this->pPlayers[i].GetPerception(); + if ( v5 > uMaxPerception ) + uMaxPerception = v5; + } + } + if ( uLevelMapStatsID && (signed int)uLevelMapStatsID < 77 ) + result = uMaxPerception >= 2 * pMapStats->pInfos[uLevelMapStatsID]._per; + else + result = 0; + return result; +} + +//----- (004936E1) -------------------------------------------------------- +void Party::SetHoldingItem(ItemGen *pItem) +{ + sub_421B2C_PlaceInInventory_or_DropPickedItem(); + memcpy(&pPickedItem, pItem, sizeof(pPickedItem)); + pMouse->SetCursorBitmapFromItemID(pPickedItem.uItemID); +} + +//----- (0049370F) -------------------------------------------------------- +int Party::GetNextActiveCharacter() +{ + int v2; // eax@4 + signed int v8; // esi@23 + int v12; // [sp+Ch] [bp-4h]@1 + + v12 = 0; + if ( pParty->bTurnBasedModeOn == 1 ) + { + if ( pTurnEngine->turn_stage != TE_ATTACK || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) != OBJECT_Player) + return 0; + v2 = PID_ID(pTurnEngine->pQueue[0].uPackedID); + return v2 + 1; + } + + if ( playerAlreadyPicked[0] && playerAlreadyPicked[1] && playerAlreadyPicked[2] && playerAlreadyPicked[3] ) + playerAlreadyPicked.fill(false); + for (int i = 0; i < 4; i++) + { + if ( !this->pPlayers[i].CanAct() || this->pPlayers[i].uTimeToRecovery > 0) + playerAlreadyPicked[i] = true; + else if ( !playerAlreadyPicked[i] ) + { + playerAlreadyPicked[i] = true; + if (i > 0) //TODO check if this condition really should be here. it is equal to the original source but still seems kind of weird + return i + 1; + break; + } + } + + for (int i = 0; i < 4; i++) + { + if ( this->pPlayers[i].CanAct() && this->pPlayers[i].uTimeToRecovery == 0 ) + { + if ( v12 == 0 || this->pPlayers[i].uSpeedBonus > v8 ) + { + v8 = this->pPlayers[i].uSpeedBonus; + v12 = i + 1; + } + } + } + return v12; +} + + +//----- (00493244) -------------------------------------------------------- +bool Party::HasItem(unsigned int uItemID) +{ + for (int player = 0; player < 4; player++) + { + for (int itemPos = 0; itemPos < 138; itemPos++) + { + if (pParty->pPlayers[player].pOwnItems[itemPos].uItemID == uItemID) + return true; + } + } + return false; +} + + +//----- (00492AD5) -------------------------------------------------------- +void Party::SetFood(unsigned int uNumFood) +{ + pUIAnim_Food->uAnimTime = 0; + pParty->uNumFoodRations = uNumFood; + pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Food->uIconID].uAnimLength; +} + +//----- (00492B03) -------------------------------------------------------- +void Party::TakeFood(unsigned int uNumFood) +{ + if (pParty->uNumFoodRations <= uNumFood) + pParty->uNumFoodRations = 0; + else + pParty->uNumFoodRations -= uNumFood; + + pUIAnim_Food->uAnimTime = 0; + pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Food->uIconID].uAnimLength; +} + +//----- (00492B42) -------------------------------------------------------- +void Party::GiveFood(unsigned int _this) +{ + pParty->uNumFoodRations += _this; + pUIAnim_Food->uAnimTime = 0; + pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Food->uIconID].uAnimLength; +} + +//----- (00492B70) -------------------------------------------------------- +void Party::SetGold(unsigned int uNumGold) +{ + pParty->uNumGold = uNumGold; + pUIAnim_Gold->uAnimTime = 0; + pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Gold->uIconID].uAnimLength; + pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); +} + +//----- (00492BB6) -------------------------------------------------------- +void Party::TakeGold(unsigned int uNumGold) +{ + if ( uNumGold <= pParty->uNumGold ) + pParty->uNumGold -= uNumGold; + else + pParty->uNumGold = 0; + pUIAnim_Gold->uAnimTime = 0; + pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Gold->uIconID].uAnimLength; + pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); +} + +//----- (0049135E) -------------------------------------------------------- +unsigned int Party::GetPartyFame() +{ + unsigned __int64 total_exp = 0; + for (uint i = 0; i < 4; ++i) + total_exp += pPlayers[i].uExperience; + return (unsigned int)(min(total_exp / 1000, UINT_MAX)); //min wasn't present, but could be incorrect without it +} + +//----- (0049137D) -------------------------------------------------------- +void Party::CreateDefaultParty(char bGiveItems) +{ + Player *pCharacter; // esi@3 + int uSkillIdx; // eax@11 + unsigned int v16; // [sp-4h] [bp-44h]@26 + signed int uNumPlayers; // [sp+18h] [bp-28h]@1 + ItemGen Dst; // [sp+1Ch] [bp-24h]@10 + + pHireling1Name[0] = 0; + pHireling2Name[0] = 0; + this->hirelingScrollPosition = 0; + memset(&pHirelings, 0, sizeof(pHirelings)); + + strcpy(this->pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]); //Zoltan + this->pPlayers[0].uPrevFace = 17; + this->pPlayers[0].uCurrentFace = 17; + this->pPlayers[0].uPrevVoiceID = 17; + this->pPlayers[0].uVoiceID = 17; + this->pPlayers[0].uMight = 30; + this->pPlayers[0].uIntelligence = 5; + this->pPlayers[0].uWillpower = 5; + this->pPlayers[0].uEndurance = 13; + this->pPlayers[0].uAccuracy = 13; + this->pPlayers[0].uSpeed = 14; + this->pPlayers[0].uLuck = 7; + this->pPlayers[0].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather + this->pPlayers[0].pActiveSkills[PLAYER_SKILL_ARMSMASTER] = 1; // armsmaster + this->pPlayers[0].pActiveSkills[PLAYER_SKILL_BOW] = 1; // bow + this->pPlayers[0].pActiveSkills[PLAYER_SKILL_SWORD] = 1; // sword + this->pPlayers[1].uPrevFace = 3; + this->pPlayers[1].uCurrentFace = 3; + this->pPlayers[1].uPrevVoiceID = 3; + this->pPlayers[1].uVoiceID = 3; + strcpy(this->pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); //Roderic + this->pPlayers[1].uMight = 13; + this->pPlayers[1].uIntelligence = 9; + this->pPlayers[1].uWillpower = 9; + this->pPlayers[1].uEndurance = 13; + this->pPlayers[1].uAccuracy = 13; + this->pPlayers[1].uSpeed = 13; + this->pPlayers[1].uLuck = 13; + this->pPlayers[1].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather + this->pPlayers[1].pActiveSkills[PLAYER_SKILL_STEALING] = 1; // stealing + this->pPlayers[1].pActiveSkills[PLAYER_SKILL_DAGGER] = 1; // dagger + this->pPlayers[1].pActiveSkills[PLAYER_SKILL_TRAP_DISARM] = 1; // disarm trap + this->pPlayers[2].uPrevFace = 14; + this->pPlayers[2].uCurrentFace = 14; + this->pPlayers[2].uPrevVoiceID = 14; + this->pPlayers[2].uVoiceID = 14; + strcpy(this->pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); // Serena + this->pPlayers[2].uMight = 12; + this->pPlayers[2].uIntelligence = 9; + this->pPlayers[2].uWillpower = 20; + this->pPlayers[2].uEndurance = 22; + this->pPlayers[2].uAccuracy = 7; + this->pPlayers[2].uSpeed = 13; + this->pPlayers[2].uLuck = 7; + this->pPlayers[2].pActiveSkills[PLAYER_SKILL_ALCHEMY] = 1; // alchemy + this->pPlayers[2].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather + this->pPlayers[2].pActiveSkills[PLAYER_SKILL_BODY] = 1; // body + this->pPlayers[2].pActiveSkills[PLAYER_SKILL_MACE] = 1; // mace + strcpy(this->pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]); // Alexis + this->pPlayers[3].uPrevFace = 10; + this->pPlayers[3].uCurrentFace = 10; + this->pPlayers[3].uEndurance = 13; + this->pPlayers[3].uAccuracy = 13; + this->pPlayers[3].uSpeed = 13; + this->pPlayers[3].uPrevVoiceID = 10; + this->pPlayers[3].uVoiceID = 10; + this->pPlayers[3].uMight = 5; + this->pPlayers[3].uIntelligence = 30; + this->pPlayers[3].uWillpower = 9; + this->pPlayers[3].uLuck = 7; + this->pPlayers[3].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather + this->pPlayers[3].pActiveSkills[PLAYER_SKILL_AIR] = 1; // air + this->pPlayers[3].pActiveSkills[PLAYER_SKILL_FIRE] = 1; // fire + this->pPlayers[3].pActiveSkills[PLAYER_SKILL_STAFF] = 1; // staff + for (uNumPlayers = 0; uNumPlayers < 4; uNumPlayers++) + { + pCharacter = &pParty->pPlayers[uNumPlayers]; + if (pCharacter->classType == PLAYER_CLASS_KNIGHT) + pCharacter->sResMagicBase = 10; //player[i].pResMagicBase + pCharacter->lastOpenedSpellbookPage = 0; + for (int i = 0; i < 9; i++)//for Magic Book + { + if (pPlayers[uNumPlayers].pActiveSkills[12+i]) + { + pCharacter->lastOpenedSpellbookPage = i; + break; + } + } + pCharacter->uExpressionTimePassed = 0; + Dst.Reset(); + if ( bGiveItems ) + { + pItemsTable->GenerateItem(2, 40, &Dst); //ring + pCharacter->AddItem2(-1, &Dst); + for (uSkillIdx = 0; uSkillIdx < 36; uSkillIdx++) + { + if ( pCharacter->pActiveSkills[uSkillIdx] ) + { + switch ( uSkillIdx ) + { + case PLAYER_SKILL_STAFF: + pCharacter->WearItem(ITEM_STAFF_1); + break; + case PLAYER_SKILL_SWORD: + pCharacter->WearItem(ITEM_LONGSWORD_1); + break; + case PLAYER_SKILL_DAGGER: + pCharacter->WearItem(ITEM_DAGGER_1); + break; + case PLAYER_SKILL_AXE: + pCharacter->WearItem(ITEM_AXE_1); + break; + case PLAYER_SKILL_SPEAR: + pCharacter->WearItem(ITEM_SPEAR_1); + break; + case PLAYER_SKILL_BOW: + pCharacter->WearItem(ITEM_CROSSBOW_1); + break; + case PLAYER_SKILL_MACE: + pCharacter->WearItem(ITEM_MACE_1); + break; + case PLAYER_SKILL_SHIELD: + pCharacter->WearItem(ITEM_BUCKLER_1); + break; + case PLAYER_SKILL_LEATHER: + pCharacter->WearItem(ITEM_LEATHER_1); + break; + case PLAYER_SKILL_CHAIN: + pCharacter->WearItem(ITEM_CHAINMAIL_1); + break; + case PLAYER_SKILL_PLATE: + pCharacter->WearItem(ITEM_PLATE_1); + break; + case PLAYER_SKILL_FIRE: + pCharacter->AddItem(-1, ITEM_SPELLBOOK_FIRE_STRIKE); + break; + case PLAYER_SKILL_AIR: + pCharacter->AddItem(-1, ITEM_SPELLBOOK_AIR_FEATHER_FALL); + break; + case PLAYER_SKILL_WATER: + pCharacter->AddItem(-1, ITEM_SPELLBOOK_WATER_POISON_SPRAY); + break; + case PLAYER_SKILL_EARTH: + pCharacter->AddItem(-1, ITEM_SPELLBOOK_EARTH_SLOW); + break; + case PLAYER_SKILL_SPIRIT: + pCharacter->AddItem(-1, ITEM_SPELLBOOK_SPIRIT_BLESS); + break; + case PLAYER_SKILL_MIND: + pCharacter->AddItem(-1, ITEM_SPELLBOOK_MIND_MIND_BLAST); + break; + case PLAYER_SKILL_BODY: + pCharacter->AddItem(-1, ITEM_SPELLBOOK_BODY_FIRST_AID); + break; + case PLAYER_SKILL_ITEM_ID: + case PLAYER_SKILL_REPAIR: + case PLAYER_SKILL_MEDITATION: + case PLAYER_SKILL_PERCEPTION: + case PLAYER_SKILL_DIPLOMACY: + case PLAYER_SKILL_TRAP_DISARM: + case PLAYER_SKILL_LEARNING: + pCharacter->AddItem(-1, ITEM_POTION_BOTTLE); + v16 = 5 * (rand() % 3 + 40); // simple reagent + pCharacter->AddItem(-1, v16); + break; + case PLAYER_SKILL_DODGE: + pCharacter->AddItem(-1, ITEM_BOOTS_1); + break; + case PLAYER_SKILL_UNARMED: + pCharacter->AddItem(-1, ITEM_GAUNTLETS_1); + break; + default: + break; + } + } + } + for (int i = 0; i < 138; i++) + { + if ( pCharacter->pInventoryItemList[i].uItemID != 0) + pCharacter->pInventoryItemList[i].SetIdentified(); + } + } + pCharacter->sHealth = pCharacter->GetMaxHealth(); + pCharacter->sMana = pCharacter->GetMaxMana(); + } +} + +//----- (004917CE) -------------------------------------------------------- +int Party::Reset() +{ + Zero(); + + field_708 = 15; + sEyelevel = 160; + uNumGold = 200; + uNumFoodRations = 7; + + + alignment = PartyAlignment_Neutral; + SetUserInterface(alignment, true); + + uTimePlayed = 0x21C00u; + uLastRegenerationTime = 0x21C00; + + bTurnBasedModeOn = false; + + uActiveCharacter = 1; + ::pPlayers.ZerothIndex() = &pPlayers[0]; + for (uint i = 0; i < 4; ++i) + ::pPlayers[i + 1] = &pPlayers[i]; + + pPlayers[0].Reset(PLAYER_CLASS_KNIGHT); + pPlayers[1].Reset(PLAYER_CLASS_THEIF); + pPlayers[2].Reset(PLAYER_CLASS_CLERIC); + pPlayers[3].Reset(PLAYER_CLASS_SORCERER); + pPlayers[0].uCurrentFace = 17; + pPlayers[0].uPrevVoiceID = 17; + pPlayers[0].uVoiceID = 17; + pPlayers[0].SetInitialStats(); + + pPlayers[0].uSex = pPlayers[0].GetSexByVoice(); + pPlayers[0].RandomizeName(); + strcpy(pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]); + + + pPlayers[1].uCurrentFace = 3; + pPlayers[1].uPrevVoiceID = 3; + pPlayers[1].uVoiceID = 3; + pPlayers[1].SetInitialStats(); + pPlayers[1].uSex = pPlayers[1].GetSexByVoice(); + pPlayers[1].RandomizeName(); + strcpy(pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); + pPlayers[2].uCurrentFace = 14; + pPlayers[2].uPrevVoiceID = 14; + pPlayers[2].uVoiceID = 14; + pPlayers[2].SetInitialStats(); + pPlayers[2].uSex = pPlayers[3].GetSexByVoice(); + pPlayers[2].RandomizeName(); + strcpy(pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); + pPlayers[3].uCurrentFace = 10; + pPlayers[3].uPrevVoiceID = 10; + pPlayers[3].uVoiceID = 10; + pPlayers[3].SetInitialStats(); + pPlayers[3].uSex = pPlayers[3].GetSexByVoice(); + pPlayers[3].RandomizeName(); + strcpy(pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]); + + for (uint i = 0; i < 4; ++i) + { + pPlayers[i].uTimeToRecovery = 0; + for (uint j = 0; j < 20; ++j) + pPlayers[i].pConditions[j] = 0; + + for (uint j = 0; j < 24; ++j) + pPlayers[i].pPlayerBuffs[j].Reset(); + + pPlayers[i].expression = CHARACTER_EXPRESSION_1; + pPlayers[i].uExpressionTimePassed = 0; + pPlayers[i].uExpressionTimeLength = rand() % 256 + 128; + } + + for (uint i = 1; i < 20; ++i) + pPartyBuffs[i].Reset(); + + + pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100; // default character ui - stats + uFlags = 0; + memset(_autonote_bits, 0, sizeof(_autonote_bits)); + memset(_quest_bits, 0, sizeof(_quest_bits)); + pIsArtifactFound.fill(0); + _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_RED_POTION_ACTIVE, 1); + _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_SEASHELL_ACTIVE, 1); + _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_LONGBOW_ACTIVE, 1); + _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_PLATE_ACTIVE, 1); + _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_LUTE_ACTIVE, 1); + _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_HAT_ACTIVE, 1); + + PartyTimes._shop_ban_times.fill(0); + + memcpy(pNPCStats->pNewNPCData, pNPCStats->pNPCData, 0x94BCu); + memcpy(pNPCStats->pGroups_copy, pNPCStats->pGroups, 0x66u); + pNPCStats->pNewNPCData[3].uFlags |= 128;//|= 0x80u; Lady Margaret + _494035_timed_effects__water_walking_damage__etc(); + pEventTimer->Pause(); + return 0; +} + + +//----- (0043AD34) -------------------------------------------------------- +void Party::Yell() +{ + Actor *v0; // esi@5 + int v1; // edi@9 + int v2; // ebx@9 + int v3; // eax@9 + + if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0 ) + pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); + if ( pParty->bTurnBasedModeOn != 1 ) + { + for (unsigned int i = 0; i < uNumActors; i++) + { + v0 = &pActors[i]; + if ( v0->Actor::CanAct() && v0->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long + && v0->pMonsterInfo.uMovementType != MONSTER_MOVEMENT_TYPE_STAIONARY ) + { + v1 = abs(v0->vPosition.x - pParty->vPosition.x); + v2 = abs(v0->vPosition.y - pParty->vPosition.y); + v3 = abs(v0->vPosition.z - pParty->vPosition.z); + if (int_get_vector_length(v1, v2, v3) < 512) + Actor::AI_Flee(i, 4, 0, 0); + } + } + } +} + +//----- (00491BF9) -------------------------------------------------------- +void Party::ResetPosMiscAndSpellBuffs() +{ + this->vPosition.y = 0; + this->vPosition.z = 0; + this->vPosition.x = 0; + this->uFallStartY = 0; + this->sRotationY = 0; + this->sRotationX = 0; + this->uFallSpeed = 0; + this->field_28 = 0; + this->uDefaultPartyHeight = 120; + this->field_14_radius = 37; + this->y_rotation_granularity = 25; + this->uWalkSpeed = 384; + this->y_rotation_speed = 90; + this->field_24 = 5; + this->field_6FC = 0; + this->field_708 = 15; + this->field_0 = 25; + + for (int playerId = 0; playerId < 4; playerId++) + { + for (int buffId = 0; buffId < 24; buffId++) + { + this->pPlayers[playerId].pPlayerBuffs[buffId].Reset(); + } + } + for (int buffId = 0; buffId < 20; buffId++) + { + this->pPartyBuffs[buffId].Reset(); + } +} + +//----- (004909F4) -------------------------------------------------------- +void Party::UpdatePlayersAndHirelingsEmotions() +{ + int v4; // edx@27 + + for (int i = 0; i < 4; ++i) + { + Player* player = &pPlayers[i]; + player->uExpressionTimePassed += (unsigned short)pMiscTimer->uTimeElapsed; + + uint condition = player->GetMajorConditionIdx(); + if (condition == Condition_Good || condition == Condition_Zombie) + { + if (player->uExpressionTimePassed < player->uExpressionTimeLength) + continue; + + player->uExpressionTimePassed = 0; + if (player->expression != 1 || rand() % 5) + { + player->expression = CHARACTER_EXPRESSION_1; + player->uExpressionTimeLength = rand() % 256 + 32; + } + else + { + v4 = rand() % 100; + if (v4 < 25) player->expression = CHARACTER_EXPRESSION_13; + else if (v4 < 31) player->expression = CHARACTER_EXPRESSION_14; + else if (v4 < 37) player->expression = CHARACTER_EXPRESSION_15; + else if (v4 < 43) player->expression = CHARACTER_EXPRESSION_16; + else if (v4 < 46) player->expression = CHARACTER_EXPRESSION_17; + else if (v4 < 52) player->expression = CHARACTER_EXPRESSION_18; + else if (v4 < 58) player->expression = CHARACTER_EXPRESSION_19; + else if (v4 < 64) player->expression = CHARACTER_EXPRESSION_20; + else if (v4 < 70) player->expression = CHARACTER_EXPRESSION_54; + else if (v4 < 76) player->expression = CHARACTER_EXPRESSION_55; + else if (v4 < 82) player->expression = CHARACTER_EXPRESSION_56; + else if (v4 < 88) player->expression = CHARACTER_EXPRESSION_57; + else if (v4 < 94) player->expression = CHARACTER_EXPRESSION_29; + else player->expression = CHARACTER_EXPRESSION_30; + } + + for (unsigned int j = 0; j < pPlayerFrameTable->uNumFrames; ++j) + { + PlayerFrame* frame = &pPlayerFrameTable->pFrames[j]; + if (frame->expression == player->expression) + { + player->uExpressionTimeLength = 8 * frame->uAnimLength; + break; + } + } + } + else if (player->expression != CHARACTER_EXPRESSION_DMGRECVD_MINOR && + player->expression != CHARACTER_EXPRESSION_DMGRECVD_MODERATE && + player->expression != CHARACTER_EXPRESSION_DMGRECVD_MAJOR || + player->uExpressionTimePassed >= player->uExpressionTimeLength) + { + player->uExpressionTimeLength = 0; + player->uExpressionTimePassed = 0; + + switch (condition) + { + case Condition_Dead: player->expression = CHARACTER_EXPRESSION_DEAD; break; + case Condition_Pertified: player->expression = CHARACTER_EXPRESSION_PERTIFIED; break; + case Condition_Eradicated: player->expression = CHARACTER_EXPRESSION_ERADICATED; break; + case Condition_Cursed: player->expression = CHARACTER_EXPRESSION_CURSED; break; + case Condition_Weak: player->expression = CHARACTER_EXPRESSION_WEAK; break; + case Condition_Sleep: player->expression = CHARACTER_EXPRESSION_SLEEP; break; + case Condition_Fear: player->expression = CHARACTER_EXPRESSION_FEAR; break; + case Condition_Drunk: player->expression = CHARACTER_EXPRESSION_DRUNK; break; + case Condition_Insane: player->expression = CHARACTER_EXPRESSION_INSANE; break; + case Condition_Poison_Weak: + case Condition_Poison_Medium: + case Condition_Poison_Severe: player->expression = CHARACTER_EXPRESSION_POISONED; break; + case Condition_Disease_Weak: + case Condition_Disease_Medium: + case Condition_Disease_Severe: player->expression = CHARACTER_EXPRESSION_DISEASED; break; + case Condition_Paralyzed: player->expression = CHARACTER_EXPRESSION_PARALYZED; break; + case Condition_Unconcious: player->expression = CHARACTER_EXPRESSION_UNCONCIOUS; break; + default: + Error("Invalid condition: %u", condition); + } + } + } + + for (int i = 0; i < 2; ++i) + { + NPCData* hireling = &pParty->pHirelings[i]; + if (!hireling->evt_C) + continue; + + hireling->evt_B += pMiscTimer->uTimeElapsed; + if (hireling->evt_B >= hireling->evt_C) + { + hireling->evt_A = 0; + hireling->evt_B = 0; + hireling->evt_C = 0; + + Assert(sizeof(NPCData) == 0x4C); + memset(hireling, 0, sizeof(*hireling)); + + pParty->hirelingScrollPosition = 0; + pParty->CountHirelings(); + viewparams->bRedrawGameUI = true; + } + } +} + +//----- (00490D02) -------------------------------------------------------- +void Party::RestAndHeal() +{ + Player *pPlayer; // esi@4 + bool have_vessels_soul; // [sp+10h] [bp-8h]@10 + + for ( uint i = 0; i < 20; ++i ) + pParty->pPartyBuffs[i].Reset(); + + for ( int pPlayerID = 0; pPlayerID < 4; ++pPlayerID ) + { + pPlayer = &pParty->pPlayers[pPlayerID]; + for ( uint i = 0; i < 20; ++i ) + pPlayer->pPlayerBuffs[i].Reset(); + + pPlayer->Zero(); + if ( pPlayer->pConditions[Condition_Dead] || pPlayer->pConditions[Condition_Pertified] || pPlayer->pConditions[Condition_Eradicated] )//Dead/Petrified/Eradicated + continue; + pPlayer->pConditions[Condition_Unconcious] = 0;//Unconcious + pPlayer->pConditions[Condition_Drunk] = 0;//Drunk + pPlayer->pConditions[Condition_Fear] = 0;//Fear + pPlayer->pConditions[Condition_Sleep] = 0;//Sleep + pPlayer->pConditions[Condition_Weak] = 0;//Weak + pPlayer->uTimeToRecovery = 0; + pPlayer->sHealth = pPlayer->GetMaxHealth(); + pPlayer->sMana = pPlayer->GetMaxMana(); + if ( pPlayer->classType == PLAYER_CLASS_LICH ) + { + have_vessels_soul = false; + for ( uint i = 0; i < 126; i++ ) + { + if ( pPlayer->pInventoryItemList[i].uItemID == ITEM_LICH_JAR_FULL && pPlayer->pInventoryItemList[i].uHolderPlayer == pPlayerID + 1 ) + have_vessels_soul = true; + } + if ( !have_vessels_soul ) + { + pPlayer->sHealth = pPlayer->GetMaxHealth() / 2; + pPlayer->sMana = pPlayer->GetMaxMana() / 2; + } + } + + if (pPlayer->pConditions[Condition_Zombie]) + { + pPlayer->sMana = 0; + pPlayer->sHealth /= 2; + } + else if ( pPlayer->pConditions[Condition_Poison_Severe] || pPlayer->pConditions[Condition_Disease_Severe] ) + { + pPlayer->sHealth /= 4; + pPlayer->sMana /= 4; + } + else if ( pPlayer->pConditions[Condition_Poison_Medium] || pPlayer->pConditions[Condition_Disease_Medium] ) + { + pPlayer->sHealth /= 3; + pPlayer->sMana /= 3; + } + else if ( pPlayer->pConditions[Condition_Poison_Weak] || pPlayer->pConditions[Condition_Disease_Weak] ) + { + pPlayer->sHealth /= 2; + pPlayer->sMana /= 2; + } + if ( pPlayer->pConditions[Condition_Insane] ) + pPlayer->sMana = 0; + UpdatePlayersAndHirelingsEmotions(); + } + pParty->days_played_without_rest = 0; +} + +//----- (004938D1) -------------------------------------------------------- +void __fastcall Rest(unsigned int uHoursToSleep) +{ + signed __int64 v2; // st7@3 + + if ( uHoursToSleep > 240 ) + Actor::InitializeActors(); + v2 = (signed __int64)((7680 * uHoursToSleep) * 0.033333335); + pParty->uTimePlayed += v2; + for (int i = 1; i <= 4; i++) + { + pPlayers[i]->Recover((int)v2); + } + _494035_timed_effects__water_walking_damage__etc(); +} +//----- (004B1BDB) -------------------------------------------------------- +void RestAndHeal(__int64 uNumMinutes) +{ + signed __int64 v1; // ST2C_8@1 + signed __int64 v2; // qax@1 + unsigned __int64 v4; // qax@1 + unsigned int v5; // ebx@1 + + pParty->pHirelings[0].bHasUsedTheAbility = 0; + pParty->pHirelings[1].bHasUsedTheAbility = 0; + pParty->uTimePlayed += (signed __int64)((double)(7680 * uNumMinutes) * 0.033333335); + v1 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375); + v2 = v1 / 60 / 60; + v4 = (unsigned int)v2 / 0x18; + v5 = (unsigned int)(v4 / 7) >> 2; + pParty->uCurrentTimeSecond = v1 % 60; + pParty->uCurrentMinute = v1 / 60 % 60; + pParty->uCurrentHour = v2 % 24; + pParty->uCurrentMonthWeek = v4 / 7 & 3; + pParty->uDaysPlayed = (unsigned int)v4 % 0x1C; + pParty->uCurrentMonth = v5 % 0xC; + pParty->uCurrentYear = v5 / 0xC + game_starting_year; + pParty->RestAndHeal(); + + for (int i = 0; i < 4; i++) + { + pParty->pPlayers[i].uTimeToRecovery = 0; + pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0; + pParty->pPlayers[i].uNumArmageddonCasts = 0; + pParty->pPlayers[i].uNumFireSpikeCasts = 0; + pParty->pPlayers[i].field_1B3B = 0; + } + pParty->UpdatePlayersAndHirelingsEmotions(); +} +//----- (0041F5BE) -------------------------------------------------------- +void Party::Sleep6Hours() +{ + if ( _506F18_num_minutes_to_sleep < 6 ) + { + if ( _506F18_num_minutes_to_sleep ) + { + Rest(_506F18_num_minutes_to_sleep); + _506F18_num_minutes_to_sleep = 0; + OutdoorLocation::LoadActualSkyFrame(); + } + if ( dword_506F14 == 2 ) + { + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0); + } + } + else + { + Rest(6u); + _506F18_num_minutes_to_sleep -= 6; + OutdoorLocation::LoadActualSkyFrame(); + } + viewparams->bRedrawGameUI = 1; +} + +bool TestPartyQuestBit( PARTY_QUEST_BITS bit ) +{ + return _449B57_test_bit(pParty->_quest_bits, bit); +} + +//----- (0047752B) -------------------------------------------------------- +int Party::GetPartyReputation() +{ + DDM_DLV_Header *v0; // ebx@1 + signed int v1; // esi@3 + + v0 = &pOutdoor->ddm; + if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) + v0 = &pIndoor->dlv; + v1 = 0; + if ( CheckHiredNPCSpeciality(Pirate) ) + v1 += 5; + if ( CheckHiredNPCSpeciality(Burglar) ) + v1 += 5; + if ( CheckHiredNPCSpeciality(Gypsy) ) + v1 += 5; + if ( CheckHiredNPCSpeciality(Duper) ) + v1 += 5; + if ( CheckHiredNPCSpeciality(FallenWizard) ) + v1 += 5; + return v1 + v0->uReputation; +} +//----- (004269A2) -------------------------------------------------------- +void Party::GivePartyExp(unsigned int pEXPNum) +{ + signed int pActivePlayerCount; // ecx@1 + int pLearningPercent; // eax@13 + + if ( pEXPNum > 0) + { + pActivePlayerCount = 0; + for ( uint i = 0; i < 4; ++i ) + { + if ( !pParty->pPlayers[i].pConditions[Condition_Unconcious] && + !pParty->pPlayers[i].pConditions[Condition_Dead] && + !pParty->pPlayers[i].pConditions[Condition_Pertified] && + !pParty->pPlayers[i].pConditions[Condition_Eradicated] ) + pActivePlayerCount ++; + } + if ( pActivePlayerCount ) + { + pEXPNum = pEXPNum / pActivePlayerCount; + for ( uint i = 0; i < 4; ++i ) + { + if ( !pParty->pPlayers[i].pConditions[Condition_Unconcious] && + !pParty->pPlayers[i].pConditions[Condition_Dead] && + !pParty->pPlayers[i].pConditions[Condition_Pertified] && + !pParty->pPlayers[i].pConditions[Condition_Eradicated] ) + { + pLearningPercent = pParty->pPlayers[i].GetLearningPercent(); + pEXPNum = pEXPNum + pEXPNum * pLearningPercent / 100; + pParty->pPlayers[i].uExperience += pEXPNum; + if ( pParty->pPlayers[i].uExperience > 4000000000i64 ) + { + pParty->pPlayers[i].uExperience = 0; + } + } + } + } + } +} +//----- (00420C05) -------------------------------------------------------- +void Party::PartyFindsGold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal) +{ + int hirelingSalaries; // ebp@1 + unsigned int goldToGain; // esi@1 + NPCData *v12; // ecx@21 + unsigned int v13; // ecx@23 + signed int hirelingCount; // [sp+Ch] [bp-4h]@6 + + hirelingSalaries = 0; + goldToGain = uNumGold; + + if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 2 ) + pTmpBuf2[0] = 0; + else if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 1 ) + { + sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], uNumGold);// You found %lu gold! + } + else + { + hirelingCount = 0; + for (int i = 0; i < 2; i++) + { + if (this->pHirelings[i].pName) + { + hirelingCount++; + pTmpBuf[hirelingCount] = i; + } + } + for (uint i = 0; i < pNPCStats->uNumNewNPCs; i++) + { + if ( pNPCStats->pNewNPCData[i].uFlags & 0x80 + && (!this->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, this->pHirelings[0].pName)) + && (!this->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, this->pHirelings[1].pName)) ) + { + hirelingCount++; + pTmpBuf[hirelingCount] = i + 2; + } + } + for (int i = 0; i < hirelingCount; i++) + { + uchar thisBufId = (uchar)pTmpBuf[i]; + if (thisBufId < 2) + v12 = &this->pHirelings[thisBufId]; + else + v12 = &pNPCStats->pNPCData[thisBufId + 499]; + v13 = v12->uProfession; + if ( v13 ) + hirelingSalaries += pNPCStats->pProfessions[v13].uHirePrice;//*(&pNPCStats->field_13A58 + 5 * v13); + } + if ( CheckHiredNPCSpeciality(Factor) ) + goldToGain += (signed int)(10 * goldToGain) / 100; + if ( CheckHiredNPCSpeciality(Banker) ) + goldToGain += (signed int)(20 * goldToGain) / 100; + if ( CheckHiredNPCSpeciality(Pirate) ) + goldToGain += (signed int)(10 * goldToGain) / 100; + if ( hirelingSalaries ) + { + hirelingSalaries = (signed int)(goldToGain * hirelingSalaries / 100) / 100; + if ( hirelingSalaries < 1 ) + hirelingSalaries = 1; + sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[466], goldToGain, hirelingSalaries);// You found %lu gold (followers take %lu)! + } + else + { + sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], goldToGain);// You found %lu gold! + } + } + this->uNumGold += goldToGain - hirelingSalaries; + pUIAnim_Gold->uAnimTime = 0; + pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Gold->uIconID].uAnimLength; + if ( pTmpBuf2[0] ) + ShowStatusBarString(pTmpBuf2.data(), 2u); + pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); +} +//----- (00421B2C) -------------------------------------------------------- +void Party::sub_421B2C_PlaceInInventory_or_DropPickedItem() +{ + unsigned int v0; // eax@2 + Texture *v1; // ebx@2 + int v2; // eax@3 + int v4; // eax@6 + unsigned __int16 v5; // dx@11 + signed int v6; // eax@11 + __int16 v8; // ax@16 + SpriteObject a1; // [sp+4h] [bp-78h]@11 + int v11; // [sp+74h] [bp-8h]@2 + int v12; // [sp+78h] [bp-4h]@5 + + if ( !pParty->pPickedItem.uItemID ) + return; + v0 = pIcons_LOD->LoadTexture( + pParty->pPickedItem.GetIconName(), + TEXTURE_16BIT_PALETTE); + v1 = pIcons_LOD->GetTexture(v0); + v11 = areWeLoadingTexture; + if ( uActiveCharacter + && (v2 = ::pPlayers[uActiveCharacter]->AddItem(-1, pParty->pPickedItem.uItemID)) != 0 ) + { + memcpy(&::pPlayers[uActiveCharacter]->pInventoryItemList[v2-1], &pParty->pPickedItem, 0x24u); + pMouse->RemoveHoldingItem(); + } + else + { + for (v12 = 0; v12 < 4; v12++) + { + v4 = pParty->pPlayers[v12].AddItem(-1, pParty->pPickedItem.uItemID); + if ( v4 ) + { + memcpy(&pParty->pPlayers[v12].pInventoryItemList[v4 - 1], &pParty->pPickedItem, sizeof(ItemGen)); + pMouse->RemoveHoldingItem(); + break; + } + } + if ( v12 == 4 ) + { + v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + for ( uint i = 0; i < pObjectList->uNumObjects; i++ ) + { + if ( v5 == pObjectList->pObjects[i].uObjectID ) + { + v6 = i; + break; + } + } + a1.spell_caster_pid = OBJECT_Player; + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + v8 = pIndoor->GetSector( + pParty->vPosition.x, + pParty->vPosition.y, + pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + a1.uSectorID = v8; + memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24)); + a1.Create(pParty->sRotationY, 184, 200, 0); + pMouse->RemoveHoldingItem(); + } + } + if ( !v11 ) + { + v1->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + return; +} + + +//----- (0048C6F6) -------------------------------------------------------- +bool Party::AddItemToParty(ItemGen *pItem) +{ + unsigned int v2; // eax@1 + char *v5; // eax@8 + Texture *v7; // ebx@10 + signed int v8; // esi@10 + Player *v9; // edi@11 + int v10; // eax@11 + int v21; // [sp+24h] [bp-4h]@10 + + v2 = pItem->uItemID; + if ( !pItemsTable->pItems[v2].uItemID_Rep_St ) + pItem->SetIdentified(); + + v5 = pItemsTable->pItems[v2].pIconName; + if ( v5 ) + { + v7 = pIcons_LOD->LoadTexturePtr(v5, TEXTURE_16BIT_PALETTE); + v21 = areWeLoadingTexture; + v8 = 0; + uint current_player = uActiveCharacter; + for (int i = 0; i < 4; i++) + { + current_player = current_player + i; + if ( current_player > 4 ) + current_player = current_player - 4; + v9 = ::pPlayers[current_player]; + v10 = v9->AddItem(-1, pItem->uItemID); + if ( v10 ) + { + memcpy(&v9->pInventoryItemList[v10-1], pItem, 0x24u); + pItem->Reset(); + pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); + v9->PlaySound(SPEECH_60, 0); + if ( !v21 ) + { + v7->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + return true; + } + } + if ( !v21 ) + { + v7->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + return false; + } + else + { + MessageBoxW(nullptr, L"Invalid picture_name detected ::addItem()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Party.cpp:795", 0); + return false; + } +} +// 506128: using guessed type int areWeLoadingTexture; + +bool Party::IsPartyEvil() +{ + return _449B57_test_bit(_quest_bits, 100); +} + +bool Party::IsPartyGood() +{ + return _449B57_test_bit(_quest_bits, 99); +} + + + +//----- (0046A89E) -------------------------------------------------------- +int Party::_46A89E_immolation_effect(int* affected, int affectedArrSize, int effectRange) +{ + int v5; // ebx@3 + int v17; // [sp+Ch] [bp-10h]@3 + int v18; // [sp+10h] [bp-Ch]@3 + int affectedCount; // [sp+18h] [bp-4h]@1 + + affectedCount = 0; + for ( size_t i = 0; i < uNumActors; ++i ) + { + v5 = abs(pActors[i].vPosition.x - this->vPosition.x); + v17 = abs(pActors[i].vPosition.y - this->vPosition.y); + v18 = abs(pActors[i].vPosition.z - this->vPosition.z); + if ( int_get_vector_length(v5, v17, v18) <= effectRange ) + { + if ( pActors[i].uAIState != Dead && pActors[i].uAIState != Dying && pActors[i].uAIState != Removed + && pActors[i].uAIState != Disabled && pActors[i].uAIState != Summoned ) + { + affected[affectedCount] = i; + affectedCount++; + if ( affectedCount >= affectedArrSize ) + break; + } + } + } + return affectedCount; +} + +//----- (00444D80) -------------------------------------------------------- +int GetTravelTime() +{ + signed int new_travel_time; // esi@1 + + new_travel_time = uDefaultTravelTime_ByFoot; + if ( CheckHiredNPCSpeciality(Guide) ) + --new_travel_time; + if ( CheckHiredNPCSpeciality(Tracker) ) + new_travel_time -= 2; + if ( CheckHiredNPCSpeciality(Pathfinder) ) + new_travel_time -= 3; + if ( CheckHiredNPCSpeciality(Explorer) ) + --new_travel_time; + if ( new_travel_time < 1 ) + new_travel_time = 1; + return new_travel_time; +} +// 6BD07C: using guessed type int uDefaultTravelTime_ByFoot; + +//----- (00449B57) -------------------------------------------------------- +bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2) +{ + return (a1[(a2 - 1) >> 3] & (0x80 >> (a2 - 1) % 8)) != 0; +} + +//----- (00449B7E) -------------------------------------------------------- +void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle) +{ + signed int v3; // esi@1 + unsigned char set_bit; // edx@1 + + v3 = a2 - 1; + set_bit = 0x80 >> v3 % 8; + if (bToggle) + pArray[v3 / 8] |= set_bit; + else + pArray[v3 / 8] &= ~set_bit; +} + +//----- (004760D5) -------------------------------------------------------- +PartyAction ActionQueue::Next() +{ + if (!uNumActions) + return PARTY_INVALID; + + PartyAction result = pActions[0]; + for (unsigned int i = 0; i < uNumActions - 1; ++i) + pActions[i] = pActions[i + 1]; + --uNumActions; + + return result; +} diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Party.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Party.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,333 @@ +#pragma once +#include "Engine/Objects/Player.h" +#include "Engine/Objects/NPC.h" +#include + + + +#define PARTY_AUTONOTES_BIT__EMERALD_FIRE_FOUNTAIN 2 + +enum PARTY_QUEST_BITS: uint16_t +{ + PARTY_QUEST_EMERALD_RED_POTION_ACTIVE = 1, + PARTY_QUEST_EMERALD_SEASHELL_ACTIVE = 2, + PARTY_QUEST_EMERALD_LONGBOW_ACTIVE = 3, + PARTY_QUEST_EMERALD_PLATE_ACTIVE = 4, + PARTY_QUEST_EMERALD_LUTE_ACTIVE = 5, + PARTY_QUEST_EMERALD_HAT_ACTIVE = 6, + + PARTY_QUEST_EMERALD_MARGARETH_OFF = 17, + + 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, + PARTY_QUEST_FOUNTAIN_CELESTIA = 209, + PARTY_QUEST_FOUNTAIN_THE_PIT = 210, + PARTY_QUEST_FOUNTAIN_EVENMORN_ISLE = 211 +}; + +/* 355 */ +enum PARTY_FLAGS_1: __int32 +{ + PARTY_FLAGS_1_0002 = 0x0002, + PARTY_FLAGS_1_WATER_DAMAGE = 0x0004, + PARTY_FLAGS_1_FALLING = 0x0008, + PARTY_FLAGS_1_ALERT_RED = 0x0010, + PARTY_FLAGS_1_ALERT_YELLOW = 0x0020, + PARTY_FLAGS_1_STANDING_ON_WATER = 0x0080, + PARTY_FLAGS_1_LANDING = 0x0100, + PARTY_FLAGS_1_BURNING = 0x200 +}; +enum PARTY_FLAGS_2: __int32 +{ + PARTY_FLAGS_2_RUNNING = 0x2, +}; + +/* 347 */ +enum PARTY_BUFF_INDEX +{ + PARTY_BUFF_RESIST_AIR = 0, + PARTY_BUFF_RESIST_BODY = 1, + PARTY_BUFF_DAY_OF_GODS = 2, + PARTY_BUFF_DETECT_LIFE = 3, + PARTY_BUFF_RESIST_EARTH = 4, + PARTY_BUFF_FEATHER_FALL = 5, + PARTY_BUFF_RESIST_FIRE = 6, + PARTY_BUFF_FLY = 7, + PARTY_BUFF_HASTE = 8, + PARTY_BUFF_HEROISM = 9, + PARTY_BUFF_IMMOLATION = 10, + PARTY_BUFF_INVISIBILITY = 11, + PARTY_BUFF_RESIST_MIND = 12, + PARTY_BUFF_PROTECTION_FROM_MAGIC = 13, + PARTY_BUFF_SHIELD = 14, + PARTY_BUFF_STONE_SKIN = 15, + PARTY_BUFF_TORCHLIGHT = 16, + PARTY_BUFF_RESIST_WATER = 17, + PARTY_BUFF_WATER_WALK = 18, + PARTY_BUFF_WIZARD_EYE = 19, +}; + + + +/* 300 */ +enum PartyAction: unsigned __int32 +{ + PARTY_INVALID = 0, + PARTY_TurnLeft = 0x1, + PARTY_TurnRight = 0x2, + PARTY_StrafeLeft = 0x3, + PARTY_StrafeRight = 0x4, + PARTY_WalkForward = 0x5, + PARTY_WalkBackward = 0x6, + PARTY_LookUp = 0x7, + PARTY_LookDown = 0x8, + PARTY_CenterView = 0x9, + PARTY_unkA = 0xA, + PARTY_unkB = 0xB, + PARTY_Jump = 0xC, + PARTY_FlyUp = 0xD, + PARTY_FlyDown = 0xE, + PARTY_Land = 0xF, + PARTY_RunForward = 0x10, + PARTY_RunBackward = 0x11, + PARTY_FastTurnLeft = 0x12, + PARTY_FastTurnRight = 0x13, + + PARTY_dword = 0xFFFFFFFF +}; + + + +/* 135 */ +#pragma pack(push, 1) +struct ActionQueue +{ + inline ActionQueue(): + uNumActions(0) + {} + + void Add(PartyAction action); + void Reset(); + PartyAction Next(); + + unsigned int uNumActions; + PartyAction pActions[30]; +}; +#pragma pack(pop) + + + + + +enum PartyAlignment: unsigned __int32 +{ + PartyAlignment_Good = 0, + PartyAlignment_Neutral = 1, + PartyAlignment_Evil = 2 +}; + + + + + +/* 208 */ +#pragma pack(push, 1) +struct PartyTimeStruct +{ + std::array<__int64, 10> bountyHunting_next_generation_time; + std::array<__int64, 85> Shops_next_generation_time;//field_50 + std::array<__int64, 53> _shop_ban_times; + std::array CounterEventValues; // (0xACD314h in Silvo's binary) + std::array<__int64, 29> HistoryEventTimes; // (0xACD364h in Silvo's binary) + std::array _s_times; //5d8 440h+8*51 //(0xACD44Ch in Silvo's binary) +}; +#pragma pack(pop) + +/* 207 */ +#pragma pack(push, 1) +struct Party +{ + Party(): + uTimePlayed(0) + { + Zero(); + } + + void Zero(); + void UpdatePlayersAndHirelingsEmotions(); + void RestAndHeal(); + unsigned int GetPartyFame(); + void CreateDefaultParty(char bGiveItems); + int Reset(); + void ResetPosMiscAndSpellBuffs(); + bool HasItem(unsigned int uItemID); + void SetHoldingItem(ItemGen *pItem); + int GetNextActiveCharacter(); + bool _497FC5_check_party_perception_against_level(); + bool AddItemToParty(ItemGen *pItem); + void Yell(); + void CountHirelings(); + + void GivePartyExp(unsigned int pEXPNum); + int GetPartyReputation(); + + + void PartyFindsGold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal); + void sub_421B2C_PlaceInInventory_or_DropPickedItem(); + + static void SetGold(unsigned int uNumGold); + static void TakeGold(unsigned int uNumGold); + static void SetFood(unsigned int uNumFood); + static void TakeFood(unsigned int uNumFood); + static void GiveFood(unsigned int _this); + + static void Sleep6Hours(); + + inline bool WizardEyeActive() {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uExpireTime > 0;} + inline int WizardEyeSkillLevel() {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uSkill;} + inline bool TorchlightActive() {return pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0;} + inline bool FlyActive() {return pPartyBuffs[PARTY_BUFF_FLY].uExpireTime > 0;} + inline bool WaterWalkActive() {return pPartyBuffs[PARTY_BUFF_WATER_WALK].uExpireTime > 0;} + inline bool ImmolationActive() {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uExpireTime > 0;} + inline int ImmolationSkillLevel() {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uSkill;} + inline bool FeatherFallActive() {return pPartyBuffs[PARTY_BUFF_FEATHER_FALL].uExpireTime > 0;} + inline bool Invisible() {return pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0;} + + inline bool GetRedAlert() {return (uFlags & PARTY_FLAGS_1_ALERT_RED) != 0;} + inline void SetRedAlert() {uFlags |= PARTY_FLAGS_1_ALERT_RED;} + inline bool GetYellowAlert() {return (uFlags & PARTY_FLAGS_1_ALERT_YELLOW) != 0;} + inline void SetYellowAlert() {uFlags |= PARTY_FLAGS_1_ALERT_YELLOW;} + + bool IsPartyEvil(); + bool IsPartyGood(); + int _46A89E_immolation_effect(int* affected, int affectedArrSize, int effectRange); + int field_0; + unsigned int uPartyHeight; + unsigned int uDefaultPartyHeight; + int sEyelevel; + unsigned int uDefaultEyelevel; + int field_14_radius; + int y_rotation_granularity; + unsigned int uWalkSpeed; + int y_rotation_speed; // deg/s + int field_24; + int field_28; + unsigned __int64 uTimePlayed; + __int64 uLastRegenerationTime; + PartyTimeStruct PartyTimes; + Vec3_int_ vPosition; + int sRotationY; + int sRotationX; + Vec3_int_ vPrevPosition; + int sPrevRotationY; + int sPrevRotationX; + int sPrevEyelevel; + int field_6E0; + int field_6E4; + int uFallSpeed; + int field_6EC; + int field_6F0; + int floor_face_pid; // face we are standing at + int walk_sound_timer; + int field_6FC; + int uFallStartY; + unsigned int bFlying; + char field_708; + unsigned __int8 hirelingScrollPosition; + char field_70A; + char field_70B; + unsigned int uCurrentYear; + unsigned int uCurrentMonth; + unsigned int uCurrentMonthWeek; + unsigned int uDaysPlayed; + unsigned int uCurrentHour; + unsigned int uCurrentMinute; + unsigned int uCurrentTimeSecond; + unsigned int uNumFoodRations; + int field_72C; + int field_730; + unsigned int uNumGold; + unsigned int uNumGoldInBank; + unsigned int uNumDeaths; + int field_740; + int uNumPrisonTerms; + unsigned int uNumBountiesCollected; + int field_74C; + std::array<__int16, 5> monster_id_for_hunting; + std::array<__int16, 5> monster_for_hunting_killed; + unsigned char days_played_without_rest; + unsigned __int8 _quest_bits[64]; + std::array pArcomageWins; + char field_7B5_in_arena_quest; + char uNumArenaPageWins; + char uNumArenaSquireWins; + char uNumArenaKnightWins; + char uNumArenaLordWins; + std::array pIsArtifactFound; //7ba + std::array field_7d7; + unsigned char _autonote_bits[26]; + std::array field_818; + std::array field_854; + int uNumArcomageWins; + int uNumArcomageLoses; + unsigned int bTurnBasedModeOn; + int field_880; + int uFlags2; + PartyAlignment alignment; + std::array pPartyBuffs; + std::array pPlayers; + std::array pHirelings; + ItemGen pPickedItem; + unsigned int uFlags; + std::array, 53> StandartItemsInShops; + std::array, 53> SpecialItemsInShops; //D0EC + std::array, 32> SpellBooksInGuilds; + std::array field_1605C; + char pHireling1Name[100]; + char pHireling2Name[100]; + int armageddon_timer; + int armageddonDamage; + std::array pTurnBasedPlayerRecoveryTimes; + std::array InTheShopFlags; + int uFine; + float flt_TorchlightColorR; + float flt_TorchlightColorG; + float flt_TorchlightColorB; +}; +#pragma pack(pop) + + + +extern Party *pParty; // idb + + +extern struct ActionQueue *pPartyActionQueue; + +bool TestPartyQuestBit(PARTY_QUEST_BITS bit); +void __fastcall Rest(unsigned int uHoursToSleep); +void RestAndHeal(__int64 uNumMinutes); // idb +int GetTravelTime(); + +bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2); +void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Random.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Random.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,93 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include + +#include "Random.h" +#include "OurMath.h" + + + + +struct Random *pRnd=new Random(); // idb + + + + + +//----- (004BE59E) -------------------------------------------------------- +void Random::SetRange(int min, int max) +{ + this->min = min; + this->range = max - min; +} + +//----- (004BE5B1) -------------------------------------------------------- +double Random::GetRandom() +{ + Random *v1; // esi@1 + double v2; // st7@1 + double v3; // st7@1 + + v1 = this; + this->field_0[3] = this->field_0[2]; + this->field_0[2] = this->field_0[1]; + v2 = this->field_0[0]; + this->field_0[1] = v2; + v3 = this->field_0[3] * 1492.0 + + this->field_0[2] * 1776.0 + + this->field_0[3] * 2111111111.0 + + v2 * 5115.0 + + this->field_0[4]; + v1->field_0[0] = v3 - floor(v3); + v1->field_0[4] = floor(v3) * 2.328306436538696e-10; + return v1->field_0[0]; +} + +//----- (004BE623) -------------------------------------------------------- +int Random::GetInRange() +{ +// Random *v1; // esi@1 + float v2; // ST10_4@1 +// double v3; // ST04_8@1 + int floored_random; // ecx@1 + + v2 = GetRandom() * (double)this->range; + floored_random = bankersRounding(v2); + if ( floored_random >= this->range ) + floored_random = this->range; + return floored_random + this->min; +} + +//----- (004BE65D) -------------------------------------------------------- +void Random::Initialize(int seed) +{ + int v2; // eax@1 + Random *this_; // esi@1 + signed int v4; // ecx@3 + unsigned int v5; // eax@4 + signed int v6; // edi@5 + + v2 = seed; + this_ = this; + if ( !seed ) + v2 = -1; + v4 = 0; + do + { + v5 = (((v2 << 13) ^ (unsigned int)v2) >> 17) ^ (v2 << 13) ^ v2; + v2 = 32 * v5 ^ v5; + this_->field_0[v4++] = (double)(unsigned int)v2 * 2.328306436538696e-10; + } + while ( v4 < 5 ); + v6 = 19; + do + { + GetRandom(); + --v6; + } + while ( v6 ); +} + diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Random.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Random.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,31 @@ +#pragma once + + +/* 304 */ +#pragma pack(push, 1) +struct Random +{ + //----- (004BE365) -------------------------------------------------------- + inline Random() + { + Initialize(0x5CCE1E47u); + min = 0; + range = 99; + } + + + void SetRange(int min, int max); + double GetRandom(); + int GetInRange(); + void Initialize(int seed); + + double field_0[5]; + int min; + int range; +}; +#pragma pack(pop) + + + + +extern struct Random *pRnd; // idb \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Registry.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Registry.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,189 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include +#include +#include + +#include "Registry.h" +#include "Engine/ErrorHandling.h" + +//----- (004649EF) -------------------------------------------------------- +int __fastcall ReadWindowsRegistryInt(const char *pKey, int uDefValue) +{ + DWORD cbData; // [sp+8h] [bp-20h]@1 + LPCSTR lpValueName; // [sp+Ch] [bp-1Ch]@1 + DWORD dwDisposition; // [sp+10h] [bp-18h]@2 + BYTE Data[4]; // [sp+14h] [bp-14h]@5 + HKEY hKey; // [sp+18h] [bp-10h]@1 + HKEY phkResult; // [sp+1Ch] [bp-Ch]@1 + HKEY v10; // [sp+20h] [bp-8h]@1 + HKEY v11; // [sp+24h] [bp-4h]@1 + + lpValueName = pKey; + v11 = 0; + v10 = 0; + hKey = 0; + phkResult = 0; + cbData = 4; + if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) )// for 64 bit + { + if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition) ) + { + if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v10, &dwDisposition) ) + { + if ( !RegCreateKeyExA(v10, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v11, &dwDisposition) ) + { + LSTATUS status; + if ( status = RegQueryValueExA(v11, lpValueName, 0, 0, Data, &cbData) ) + { + status; + GetLastError(); + + *(int *)Data = uDefValue; + RegSetValueExA(v11, lpValueName, 0, 4, Data, 4); + } + RegCloseKey(v11); + } + RegCloseKey(v10); + } + RegCloseKey(phkResult); + } + RegCloseKey(hKey); + } + return *(int *)Data; +} + +//----- (00464B02) -------------------------------------------------------- +void __fastcall WriteWindowsRegistryString(const char *pKey, const char *pString) +{ + size_t v2; // eax@5 + const char *lpValueName; // [sp+4h] [bp-1Ch]@1 + const char *Str; // [sp+8h] [bp-18h]@1 + DWORD dwDisposition; // [sp+Ch] [bp-14h]@2 + HKEY hKey; // [sp+10h] [bp-10h]@1 + HKEY phkResult; // [sp+14h] [bp-Ch]@1 + HKEY v8; // [sp+18h] [bp-8h]@1 + HKEY v9; // [sp+1Ch] [bp-4h]@1 + + Str = pString; + lpValueName = pKey; + v9 = 0; + v8 = 0; + hKey = 0; + phkResult = 0; + if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) ) + { + if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition) ) + { + if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v8, &dwDisposition) ) + { + if ( !RegCreateKeyExA(v8, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v9, &dwDisposition) ) + { + v2 = strlen(Str); + RegSetValueExA(v9, lpValueName, 0, 1, (const BYTE *)Str, v2 + 1); + RegCloseKey(v9); + } + RegCloseKey(v8); + } + RegCloseKey(phkResult); + } + RegCloseKey(hKey); + } +} + +//----- (00464BEF) -------------------------------------------------------- +void __fastcall ReadWindowsRegistryString(const char *pKeyName, char *pOutString, int uBufLen, const char *pDefaultValue) +{ + LSTATUS (__stdcall *v4)(HKEY); // esi@1 + LSTATUS result; // eax@7 + DWORD Type; // [sp+Ch] [bp-24h]@5 + LPCSTR lpValueName; // [sp+10h] [bp-20h]@1 + DWORD cbData; // [sp+14h] [bp-1Ch]@1 + LPBYTE Dest; // [sp+18h] [bp-18h]@1 + DWORD dwDisposition; // [sp+1Ch] [bp-14h]@2 + HKEY phkResult; // [sp+20h] [bp-10h]@1 + HKEY hKey; // [sp+24h] [bp-Ch]@1 + HKEY v13; // [sp+28h] [bp-8h]@1 + HKEY v14; // [sp+2Ch] [bp-4h]@1 + + cbData = uBufLen; + Dest = (LPBYTE)pOutString; + lpValueName = pKeyName; + v14 = 0; + v13 = 0; + hKey = 0; + phkResult = 0; + v4 = RegCloseKey; + if ( RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) + || RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition) + || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v13, &dwDisposition) + || RegCreateKeyExA(v13, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v14, &dwDisposition) ) + { + result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen); + } + else if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) ) + { + RegCloseKey(v14); + v14 = 0; + result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen); + } + else + { + v4 = RegCloseKey; + RegCloseKey(v14); + v14 = 0; + RegCloseKey(v13); + v13 = 0; + RegCloseKey(phkResult); + phkResult = 0; + result = RegCloseKey(hKey); + hKey = 0; + } + if ( v14 ) + result = v4(v14); + if ( v13 ) + result = v4(v13); + if ( hKey ) + result = v4(hKey); + if ( phkResult ) + result = v4(phkResult); +} + +//----- (00464D32) -------------------------------------------------------- +void __fastcall WriteWindowsRegistryInt(const char *pKey, int val) +{ + const char *lpValueName; // [sp+4h] [bp-1Ch]@1 + BYTE Data[4]; // [sp+8h] [bp-18h]@1 + DWORD dwDisposition; // [sp+Ch] [bp-14h]@2 + HKEY hKey; // [sp+10h] [bp-10h]@1 + HKEY phkResult; // [sp+14h] [bp-Ch]@1 + HKEY v7; // [sp+18h] [bp-8h]@1 + HKEY v8; // [sp+1Ch] [bp-4h]@1 + + *(int *)Data = val; + lpValueName = pKey; + v8 = 0; + v7 = 0; + hKey = 0; + phkResult = 0; + if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) ) + { + if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition) ) + { + if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v7, &dwDisposition) ) + { + if ( !RegCreateKeyExA(v7, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v8, &dwDisposition) ) + { + RegSetValueExA(v8, lpValueName, 0, 4, Data, 4); + RegCloseKey(v8); + } + RegCloseKey(v7); + } + RegCloseKey(phkResult); + } + RegCloseKey(hKey); + } +} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Registry.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Registry.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,8 @@ +#pragma once + + + +int __fastcall ReadWindowsRegistryInt(const char *pKey, int uDefValue); // idb +void __fastcall WriteWindowsRegistryString(const char *pKey, const char *pString); +void __fastcall ReadWindowsRegistryString(const char *pKeyName, char *pOutString, int uBufLen, const char *pDefaultValue); +void __fastcall WriteWindowsRegistryInt(const char *pKey, int val); \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/SaveLoad.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/SaveLoad.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,633 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include +#include + +#include "Engine/ErrorHandling.h" +#include "ZlibWrapper.h" + +#include "SaveLoad.h" +#include "Party.h" +#include "LOD.h" +#include "Engine/Graphics/Outdoor.h" +#include "AudioPlayer.h" +#include "Engine/Objects/Actor.h" +#include "Engine/Objects/Chest.h" +#include "Timer.h" +#include "GUIWindow.h" +#include "GUIFont.h" +#include "Engine/Graphics/Overlays.h" +#include "Engine/Objects/SpriteObject.h" +#include "Engine/Graphics/Viewport.h" +#include "stru123.h" +#include "texts.h" +#include "Log.h" +#include "Engine/Graphics/Level/Decoration.h" + +#include "Game.h" + + + +struct SavegameList *pSavegameList = new SavegameList; +unsigned int uNumSavegameFiles; +std::array pSavegameUsedSlots; +std::array pSavegameThumbnails; +std::array pSavegameHeader; + +//----- (0045EE8A) -------------------------------------------------------- +void __fastcall LoadGame(unsigned int uSlot) +{ + bool v25; // esi@62 + bool v26; // eax@62 + SavegameHeader header; // [sp+Ch] [bp-E4h]@23 + char Str[123]; // [sp+70h] [bp-80h]@25 + + MapsLongTimers_count = 0; + if (!pSavegameUsedSlots[uSlot]) + { + pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0); + Log::Warning(L"LoadGame: slot %u is empty", uSlot); + return; + } + + for (uint i = 1; i < 5; ++i) + for (uint j = 1; j < 6; ++j) + { + sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j); + remove(pTmpBuf.data()); + } + + if (SoundSetAction[24][0]) + for (uint i = 0; i < 4; ++i) + { + for (uint j = 0; j < pSoundList->sNumSounds; ++j) + if (pSoundList->pSL_Sounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998) + { + pSoundList->UnloadSound(j, 1); + break; + } + + for (uint j = 0; j < pSoundList->sNumSounds; ++j) + if (pSoundList->pSL_Sounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999) + { + pSoundList->UnloadSound(j, 1); + break; + } + } + + sprintf(pTmpBuf.data(), "saves\\%s", pSavegameList->pFileList[uSlot].pSaveFileName); + + pNew_LOD->CloseWriteFile(); + if (!CopyFileA(pTmpBuf.data(), "data\\new.lod", 0)) + int e = GetLastError(); + + pNew_LOD->LoadFile("data\\new.lod", 0); + FILE *file = pNew_LOD->FindContainer("header.bin", 1); + if (!file) + { + sprintf(Str, pGlobalTXT_LocalizationStrings[612], 100);//Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d + Log::Warning(L"%S", Str); + MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0); + } + Assert(sizeof(SavegameHeader) == 100); + fread(&header, sizeof(SavegameHeader), 1, file); + + file = pNew_LOD->FindContainer("party.bin", 1); + if (!file) + { + sprintf(Str, pGlobalTXT_LocalizationStrings[612], 101);//Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d + Log::Warning(L"%S", Str); + MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:559", 0); + } + if (sizeof(Party) != 0x16238) + Log::Warning(L"class Party: deserialization warning"); + fread(pParty, sizeof(Party), 1, file); + + + file = pNew_LOD->FindContainer("clock.bin", 1); + if (!file) + { + sprintf(Str, pGlobalTXT_LocalizationStrings[612], 102);//Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d + Log::Warning(L"%S", Str); + MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:569", 0); + } + if (sizeof(Timer) != 0x28) + Log::Warning(L"class Timer: deserialization warning"); + fread(pEventTimer, sizeof(Timer), 1, file); + + file = pNew_LOD->FindContainer("overlay.bin", 1); + if (!file) + { + sprintf(Str, pGlobalTXT_LocalizationStrings[612], 103);//Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d + Log::Warning(L"%S", Str); + MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:579", 0); + } + if (sizeof(OtherOverlayList) != 0x3F0) + Log::Warning(L"class OtherOverlayList: deserialization warning"); + fread(pOtherOverlayList, sizeof(OtherOverlayList), 1, file); + + file = pNew_LOD->FindContainer("npcdata.bin", 0); + if (!file) + { + sprintf(Str, pGlobalTXT_LocalizationStrings[612], 104);//Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d + Log::Warning(L"%S", Str); + MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:590", 0); + } + if (sizeof(pNPCStats->pNewNPCData) != 0x94BC) + Log::Warning(L"NPCStats: deserialization warning"); + fread(pNPCStats->pNewNPCData, sizeof(pNPCStats->pNewNPCData), 1, file); + pNPCStats->_476C60(); + + file = pNew_LOD->FindContainer("npcgroup.bin", 0); + if (!file) + { + sprintf(Str, pGlobalTXT_LocalizationStrings[612], 105);//Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d + Log::Warning(L"%S", Str); + MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:600", 0); + } + if (sizeof(pNPCStats->pGroups_copy) != 0x66) + Log::Warning(L"NPCStats: deserialization warning"); + fread(pNPCStats->pGroups_copy, sizeof(pNPCStats->pGroups_copy), 1, file); + + uActiveCharacter = 0; + for (uint i = 0; i < 4; ++i) + if (pParty->pPlayers[i].CanAct()) + { + uActiveCharacter = i + 1; + break; + } + + for (uint i = 0; i < 4; ++i) + { + if ( pParty->pPlayers[i].uQuickSpell ) + AA1058_PartyQuickSpellSound[i].AddPartySpellSound(pParty->pPlayers[i].uQuickSpell, i + 1); + + for (uint j = 0; j < 2; ++j) + { + uint uEquipIdx = pParty->pPlayers[i].pEquipment.pIndices[j]; + if (uEquipIdx) + { + int pItemID = pParty->pPlayers[i].pInventoryItemList[uEquipIdx - 1].uItemID; + if (pItemsTable->pItems[pItemID].uEquipType == EQUIP_WAND && pItemID )//æåçë + { + __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 + stru_A750F8[i].AddPartySpellSound(wand_spell_ids[pItemID - ITEM_WAND_FIRE], i + 9); + } + } + } + } + + pGUIWindow_CurrentMenu->Release(); + pCurrentScreen = SCREEN_GAME; + + viewparams->bRedrawGameUI = true; + + SetUserInterface(pParty->alignment, true); + + pEventTimer->Resume(); + pEventTimer->StopGameTime(); + + v25 = pGames_LOD->DoesContainerExist(header.pLocationName); + sprintf(pTmpBuf.data(), "levels\\%s", header.pLocationName); + v26 = _access(pTmpBuf.data(), 4) != -1; + if ( !v25 && !v26 ) + Error("Unable to find: %s!", header.pLocationName); + + strcpy(pCurrentMapName, header.pLocationName); + dword_6BE364_game_settings_1 |= GAME_SETTINGS_2000 | GAME_SETTINGS_0001; + + for (uint i = 0; i < uNumSavegameFiles; ++i) + pSavegameThumbnails[i].Release(); + + pIcons_LOD->RemoveTexturesPackFromTextureList(); + pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); + pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f); + if (uTurnSpeed) + pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed; + MM7Initialization(); + bFlashQuestBook = false; + viewparams->bRedrawGameUI = true; +} + +//----- (0045F469) -------------------------------------------------------- +void SaveGame( bool IsAutoSAve, bool NotSaveWorld ) +{ + int text_pos; // eax@6 + FILE *pLLoidFile; // edi@24 + char* compressed_buf; // edi@30 + char *data_write_pos; // esi@41 + CHAR Buffer[128]; // [sp+Ch] [bp-264h]@59 + char Dir[255]; // [sp+8Ch] [bp-1E4h]@51 + char Drive[255]; // [sp+ACh] [bp-1C4h]@51 + SavegameHeader save_header; // [sp+CCh] [bp-1A4h]@10 + char Filename[255]; // [sp+130h] [bp-140h]@51 + char Ext[255]; // [sp+150h] [bp-120h]@51 + char Source[32]; // [sp+170h] [bp-100h]@51 + char work_string[120]; // [sp+190h] [bp-E0h]@8 + int pPositionY; // [sp+208h] [bp-68h]@2 + int pPositionX; // [sp+20Ch] [bp-64h]@2 + int sPRotationY; // [sp+210h] [bp-60h]@2 + int sPRotationX; // [sp+214h] [bp-5Ch]@2 + ODMHeader odm_data; // [sp+218h] [bp-58h]@30 + int res; // [sp+224h] [bp-4Ch]@30 + int pPositionZ; // [sp+228h] [bp-48h]@2 + size_t Size; // [sp+250h] [bp-20h]@26 + char *uncompressed_buff; // [sp+258h] [bp-18h]@2 + unsigned int compressed_block_size; // [sp+260h] [bp-10h]@23 + + //v66 = a2; + strcpy(byte_6BE3B0.data(), pCurrentMapName);//byte_6BE3B0 - save_map_name + if (!_stricmp(pCurrentMapName, "d05.blv")) // arena + return; + + uncompressed_buff = (char*)malloc(1000000); + + LOD::Directory pLodDirectory; // [sp+22Ch] [bp-44h]@2 + pPositionX = pParty->vPosition.x; + pPositionY = pParty->vPosition.y; + pPositionZ = pParty->vPosition.z; + sPRotationY = pParty->sRotationY; + sPRotationX = pParty->sRotationX; + pParty->vPosition.x = pParty->vPrevPosition.x; + pParty->vPosition.z = pParty->vPrevPosition.z; + pParty->vPosition.y = pParty->vPrevPosition.y; + + pParty->uFallStartY = pParty->vPrevPosition.z; + + pParty->sRotationY = pParty->sPrevRotationY; + pParty->sRotationX = pParty->sPrevRotationX; + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed; + else + pOutdoor->loc_time.uLastVisitDay = pParty->uTimePlayed; + + pRenderer->PackScreenshot(150, 112, uncompressed_buff, 1000000, &pLodDirectory.uDataSize);//ñîçäàíèå ñêðèíøîòà + strcpy(pLodDirectory.pFilename, "image.pcx"); + + if (pCurrentScreen == SCREEN_SAVEGAME) + { + pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); + pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up)); + text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[190]); + pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Ñîõðàíåíèå + text_pos = pFontSmallnum->AlignText_Center(186, pSavegameHeader[uLoadGameUI_SelectedSlot].pName); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, text_pos + 25, 259, 0, pSavegameHeader[uLoadGameUI_SelectedSlot].pName, 185, 0); + text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[165]); + pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Ïîæàëóéñòà, ïîäîæäèòå + pRenderer->Present(); + } + + if (pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0)) + { + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 200); //Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0); + } + + Assert(sizeof(SavegameHeader) == 100); + memset(save_header.pName, 0, 20); + memset(save_header.pLocationName, 0, 20); + memset(save_header.field_30, 0, 52); + strcpy(save_header.pLocationName, pCurrentMapName); + save_header.uWordTime = pParty->uTimePlayed; + strcpy(pLodDirectory.pFilename, "header.bin"); + pLodDirectory.uDataSize = sizeof(SavegameHeader); + if (pNew_LOD->Write(&pLodDirectory, &save_header, 0)) + { + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 201); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0); + } + strcpy(pLodDirectory.pFilename, "party.bin"); + pLodDirectory.uDataSize = sizeof(Party); //90680; + if ( pNew_LOD->Write(&pLodDirectory, pParty, 0) ) + { + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 202);//Save game corrupted! Code=%d + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0); + } + strcpy(pLodDirectory.pFilename, "clock.bin"); + pLodDirectory.uDataSize =sizeof(Timer);// 40; + if ( pNew_LOD->Write(&pLodDirectory, pEventTimer, 0) ) + { + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 203); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0); + } + strcpy(pLodDirectory.pFilename, "overlay.bin"); + pLodDirectory.uDataSize =sizeof(OtherOverlayList);// 1008; + if ( pNew_LOD->Write(&pLodDirectory, pOtherOverlayList, 0) ) + { + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 204); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0); + } + strcpy(pLodDirectory.pFilename, "npcdata.bin"); + pLodDirectory.uDataSize = 501 * sizeof(NPCData); + Assert(pLodDirectory.uDataSize == 38076); + if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pNewNPCData, 0) ) + { + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 205); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0); + } + strcpy(pLodDirectory.pFilename, "npcgroup.bin"); + pLodDirectory.uDataSize = 102; + if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pGroups_copy, 0) ) + { + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 206); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0); + } + for (int i = 1; i <= 4; ++i) // 4 - players + { + for (int j = 1; j <= 5; ++j) // 5 - images + { + sprintf(work_string, "data\\lloyd%d%d.pcx", i, j); + pLLoidFile = fopen(work_string, "rb"); + if ( pLLoidFile ) + { + __debugbreak(); + sprintf(work_string, "lloyd%d%d.pcx", i, j); + fseek(pLLoidFile, 0, SEEK_END); + pLodDirectory.uDataSize = ftell(pLLoidFile); + rewind(pLLoidFile); + fread(uncompressed_buff, pLodDirectory.uDataSize, 1, pLLoidFile); + strcpy(pLodDirectory.pFilename, work_string); + fclose(pLLoidFile); + remove(work_string); + if ( pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0) ) + { + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 207); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0); + Size = 5080748; + } + } + } + } + if ( !NotSaveWorld )//autosave for change location + { + //__debugbreak(); + CompactLayingItemsList(); + compressed_buf = (char*)malloc(1000000); + odm_data.uVersion = 91969; + odm_data.pMagic[0] = 'm'; + odm_data.pMagic[1] = 'v'; + odm_data.pMagic[2] = 'i'; + odm_data.pMagic[3] = 'i'; + odm_data.uCompressedSize = 0; + odm_data.uDecompressedSize = 0; + data_write_pos = uncompressed_buff; + memcpy((void *)compressed_buf, &odm_data, 0x10); + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces; + pIndoor->dlv.uNumBModels = 0; + pIndoor->dlv.uNumDecorations = uNumLevelDecorations; + memcpy(data_write_pos, &pIndoor->dlv,sizeof(DDM_DLV_Header) );//0x28 + data_write_pos += sizeof(DDM_DLV_Header); + memcpy(data_write_pos, pIndoor->_visible_outlines, 0x36B); + data_write_pos += 875; + for (int i = 0; i <(signed int)pIndoor->uNumFaces; ++i) + { + memcpy(data_write_pos, &pIndoor->pFaces[i].uAttributes, 4); + data_write_pos += 4; + } + + for (int i = 0; i <(signed int)uNumLevelDecorations; ++i) + { + memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2); + data_write_pos += 2; + } + memcpy(data_write_pos, &uNumActors, 4); + data_write_pos += 4; + memcpy(data_write_pos, &pActors, uNumActors * sizeof(Actor)); + data_write_pos += uNumActors * sizeof(Actor); + memcpy(data_write_pos, &uNumSpriteObjects, 4); + data_write_pos += 4; + memcpy(data_write_pos, pSpriteObjects.data(), 112 * uNumSpriteObjects); + data_write_pos += 112 * uNumSpriteObjects; + memcpy(data_write_pos, &uNumChests, 4); + data_write_pos += 4; + memcpy(data_write_pos, pChests.data(), sizeof(Chest)*uNumChests);//5324 * + data_write_pos += sizeof(Chest)* uNumChests; + memcpy(data_write_pos, pIndoor->pDoors, 0x3E80); + data_write_pos += 16000; + memcpy(data_write_pos, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size); + data_write_pos += pIndoor->blv.uDoors_ddata_Size; + memcpy(data_write_pos, &stru_5E4C90_MapPersistVars, 0xC8); + data_write_pos += 200; + memcpy(data_write_pos, &pIndoor->stru1, 0x38); + data_write_pos += 56; + + } + else//for Outdoor + { + pOutdoor->ddm.uNumFacesInBModels = 0; + for ( int i = 0; i < pOutdoor->uNumBModels; ++i ) + pOutdoor->ddm.uNumFacesInBModels += pOutdoor->pBModels[i].uNumFaces; + pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels; + pOutdoor->ddm.uNumDecorations = uNumLevelDecorations; + memcpy(data_write_pos, &pOutdoor->ddm, sizeof(DDM_DLV_Header));//0x28 + data_write_pos += sizeof(DDM_DLV_Header); + memcpy(data_write_pos, pOutdoor->uFullyRevealedCellOnMap, 0x3C8); + data_write_pos += 968; + memcpy(data_write_pos, pOutdoor->uPartiallyRevealedCellOnMap, 0x3C8); + data_write_pos += 968; + for (int i = 0; i < pOutdoor->uNumBModels ; ++i) + for (int j = 0; j < pOutdoor->pBModels[i].uNumFaces;++j)//*(int *)&pOutdoor->pBModels->pModelName[v24]; ++j) + { + memcpy(data_write_pos, &(pOutdoor->pBModels[i].pFaces[j].uAttributes), 4); + data_write_pos += 4; + } + + for (int i = 0; i < (signed int)uNumLevelDecorations; ++i) + { + memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2); + data_write_pos += 2; + } + memcpy(data_write_pos, &uNumActors, 4); + data_write_pos += 4; + memcpy(data_write_pos, &pActors, uNumActors * sizeof(Actor)); + data_write_pos += uNumActors * sizeof(Actor); + memcpy(data_write_pos, &uNumSpriteObjects, 4); + data_write_pos += 4; + memcpy(data_write_pos, &pSpriteObjects, uNumSpriteObjects * sizeof(SpriteObject)); + data_write_pos += uNumSpriteObjects * sizeof(SpriteObject); + memcpy(data_write_pos, &uNumChests, 4); + data_write_pos += 4; + memcpy(data_write_pos, pChests.data(), sizeof(Chest)* uNumChests); + data_write_pos += sizeof(Chest) * uNumChests; + memcpy(data_write_pos, &stru_5E4C90_MapPersistVars, 0xC8); + data_write_pos += 200; + memcpy(data_write_pos, &pOutdoor->loc_time, 0x38); + data_write_pos += 56; + } + strcpy(Source, pCurrentMapName); + _splitpath(Source, Drive, Dir, Filename, Ext); + Ext[1] = 'd'; + + Size = (int)data_write_pos - (int)uncompressed_buff; + compressed_block_size = 999984; + res = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size); + if (res || (signed int)compressed_block_size > (signed int)Size ) + { + memcpy((void *)(compressed_buf + 16), uncompressed_buff, Size); + compressed_block_size = Size; + } + compressed_block_size += 16; + memcpy(&((ODMHeader *)compressed_buf)->uCompressedSize, &compressed_block_size, 4); + memcpy(&((ODMHeader *)compressed_buf)->uDecompressedSize, &Size, 4); + sprintf(Source, "%s%s", Filename, Ext); + strcpy(pLodDirectory.pFilename, Source); + pLodDirectory.uDataSize = compressed_block_size; + if ( pNew_LOD->Write(&pLodDirectory, (const void *)compressed_buf, 0) ) + { + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 208); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0); + } + free((void *)compressed_buf); + } + free(uncompressed_buff); + if ( IsAutoSAve ) + { + if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) ) + { + FormatMessageA(0x1000, 0, GetLastError(), 0x400, Buffer, 0x80, 0); + sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 300); + MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0); + } + } + pParty->vPosition.x = pPositionX; + pParty->vPosition.y = pPositionY; + pParty->vPosition.z = pPositionZ; + pParty->uFallStartY = pPositionZ; + pParty->sRotationY = sPRotationY; + pParty->sRotationX = sPRotationX; +} + +//----- (00460078) -------------------------------------------------------- +void __fastcall DoSavegame(unsigned int uSlot) +{ + if ( _stricmp(pCurrentMapName, "d05.blv") )//Not Arena(íå Àðåíà) + { + LOD::Directory pDir; // [sp+Ch] [bp-28h]@2 + SaveGame(0, 0); + strcpy(pSavegameHeader[uSlot].pLocationName, pCurrentMapName);//äàòü íàçâàíèå êàðòû + pSavegameHeader[uSlot].uWordTime = pParty->uTimePlayed;//òåêóùåå âðåìÿ + strcpy(pDir.pFilename, "header.bin"); + pDir.uDataSize = 100; + pNew_LOD->Write(&pDir, &pSavegameHeader[uSlot], 0); + sprintf(pTmpBuf.data(), "saves\\save%03d.mm7", uSlot); + pNew_LOD->CloseWriteFile();//çàêðûòü + CopyFileA("data\\new.lod", pTmpBuf.data(), 0);//ñîõðàíåíèå ôàéëà â äèðåêòîðèþ saves + } + GUI_UpdateWindows(); + pGUIWindow_CurrentMenu->Release(); + pCurrentScreen = SCREEN_GAME; + //v3 = pSavegameThumbnails; + viewparams->bRedrawGameUI = true; + for (uint i = 0; i < 45; i++) + pSavegameThumbnails[i].Release(); + + if ( _stricmp(pCurrentMapName, "d05.blv") ) + pNew_LOD->_4621A7(); + else + ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2);// "No saving in the Arena" + pIcons_LOD->RemoveTexturesFromTextureList(); + pEventTimer->Resume(); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2);// "Game Saved!" + viewparams->bRedrawGameUI = true; +} +// 4E28F8: using guessed type int pCurrentScreen; + +//----- (0045E297) -------------------------------------------------------- +void SavegameList::Initialize(unsigned int bHideEmptySlots) +{ + //memset(pSavegameList, 0, sizeof(pSavegameList));//Ritor1: âûçûâàåò çàòèðàíèå + pSavegameList->Reset(); + uNumSavegameFiles = 0; + + _chdir("saves"); + { + if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 ) // AutoSave.MM7 + strcpy(pSavegameList->pFileList[uNumSavegameFiles++].pSaveFileName, pGlobalTXT_LocalizationStrings[613]); + + for (uint i = 0; i < 40; ++i) + { + sprintf(pTmpBuf.data(), "save%03d.mm7", i); + if (_access(pTmpBuf.data(), 0) == -1) + continue; + + uint idx = i; + if (!bHideEmptySlots) + idx = uNumSavegameFiles; + strcpy(pSavegameList->pFileList[idx].pSaveFileName, pTmpBuf.data()); + + ++uNumSavegameFiles; + } + } + _chdir(".."); +} +//----- (0046086A) -------------------------------------------------------- +void SaveNewGame() +{ + FILE *file; // eax@7 + void *pSave; // [sp+170h] [bp-8h]@3 + + if ( pMovie_Track ) + pMediaPlayer->Unload(); + pSave = malloc(1000000); + pNew_LOD->CloseWriteFile(); + remove("data\\new.lod");//óäàëèòü new.lod + + LOD::FileHeader header; // [sp+Ch] [bp-16Ch]@3 çàãîëîâîê + strcpy(header.LodVersion, "MMVII"); + strcpy(header.LodDescription, "newmaps for MMVII"); + header.LODSize = 100; + header.dword_0000A8 = 0; + + LOD::Directory a3; // [sp+14Ch] [bp-2Ch]@3 + a3.dword_000018 = 0; + a3.word_00001E = 0; + strcpy(a3.pFilename, "current"); + pNew_LOD->CreateNewLod(&header, &a3, "data\\new.lod");//ñîçäà¸òñÿ new.lod â äèððåêòîðèè + if (pNew_LOD->LoadFile("data\\new.lod", false))//çàãðóçèòü ôàéë new.lod(isFileOpened = true) + { + pNew_LOD->CreateTempFile();//ñîçäà¸òñÿ âðåìåííûé ôàéë OutputFileHandle + pNew_LOD->uNumSubDirs = 0; + + LOD::Directory pDir; // [sp+10Ch] [bp-6Ch]@4 + for (int i = pGames_LOD->uNumSubDirs / 2; i < pGames_LOD->uNumSubDirs; ++i)//êîïèðîâàíèå ôàéëîâ ñ 76 ïî 151 + { + memcpy(&pDir, &pGames_LOD->pSubIndices[i], sizeof(pDir));//êîïèðîâàíèå òåêóùåãî ôàéëà â pDir + file = pGames_LOD->FindContainer(pGames_LOD->pSubIndices[i].pFilename, 1); + fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, file); + pNew_LOD->AppendDirectory(&pDir, pSave); + } + + LOD::Directory save_game_dir; // [sp+12Ch] [bp-4Ch]@9 + strcpy(pSavegameHeader[0].pLocationName, "out01.odm"); + strcpy(save_game_dir.pFilename, "header.bin"); + save_game_dir.uDataSize = sizeof(SavegameHeader); + pNew_LOD->AppendDirectory(&save_game_dir, &pSavegameHeader[0]); + + pNew_LOD->FixDirectoryOffsets(); + + pParty->vPrevPosition.x = 12552; + pParty->vPrevPosition.y = 1816; + pParty->vPrevPosition.z = 0; + + pParty->vPosition.x = 12552; + pParty->vPosition.y = 1816; + pParty->vPosition.z = 0; + + pParty->uFallStartY = 0; + + pParty->sPrevRotationX = 0; + pParty->sPrevRotationY = 512; + + pParty->sRotationX = 0; + pParty->sRotationY = 512; + + SaveGame(1, 1); + } + free(pSave); +} + diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/SaveLoad.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/SaveLoad.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,56 @@ +#pragma once +#include + +#pragma pack(push, 1) +struct SaveFile_ + { + char field_0[20]; + char pSaveFileName[260]; + }; +#pragma pack(pop) + +/* 243 */ +#pragma pack(push, 1) +struct SavegameList +{ + static void Initialize(unsigned int a1); + SavegameList() {Reset();} + + inline void Reset() + { + for ( int j = 0; j < 45; j++ ) + { + for (int i = 0; i < 20; ++i) + this->pFileList[j].field_0[i] = 0; + for (int i = 0; i < 260; ++i) + this->pFileList[j].pSaveFileName[i] = 0; + } + } + SaveFile_ pFileList[45]; + +}; +#pragma pack(pop) + + +/* 244 */ +#pragma pack(push, 1) +struct SavegameHeader +{ + char pName[20]; + char pLocationName[20]; + unsigned __int64 uWordTime; + char field_30[52]; +}; +#pragma pack(pop) + + +void __fastcall LoadGame(unsigned int uSlot); // idb +void SaveGame(bool IsAutoSAve, bool NotSaveWorld); +void __fastcall DoSavegame(unsigned int uSlot); // idb +bool Initialize_GamesLOD_NewLOD(); +void SaveNewGame(); + +extern unsigned int uNumSavegameFiles; +extern std::array pSavegameUsedSlots; +extern struct SavegameList *pSavegameList; +extern std::array pSavegameHeader; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Spells/CastSpellInfo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Spells/CastSpellInfo.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,3576 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include "CastSpellInfo.h" +#include "../Objects/Actor.h" +#include "../Party.h" +#include "../MM7.h" +#include "Mouse.h" +#include "../../stru6.h" +#include "../Game.h" +#include "GUIWindow.h" +#include "AudioPlayer.h" +#include "../Graphics/Outdoor.h" +#include "../Graphics/Overlays.h" +#include "../Events.h" +#include "../Graphics/Viewport.h" +#include "../OurMath.h" +#include "../Objects/SpriteObject.h" +#include "../Objects/ObjectList.h" +#include "../stru123.h" +#include "../Timer.h" +#include "../Tables/IconFrameTable.h" +#include "../Awards.h" +#include "../TurnEngine/TurnEngine.h" +#include "../texts.h" +#include "../LOD.h" +#include "../Graphics/Level/Decoration.h" + +#include "UI\UIPartyCreation.h" + +const size_t CastSpellInfoCount = 10; +std::array pCastSpellInfo; + +//----- (00427E01) -------------------------------------------------------- +void CastSpellInfoHelpers::_427E01_cast_spell() +{ + int spell_level; // edi@1 + CastSpellInfo *pCastSpell; // ebx@2 + signed int v6; // eax@14 + unsigned __int16 v11; // cx@45 + signed int i; // esi@76 +// Actor *pActor; // edi@177 + int v61; // ecx@184 + int v111; // eax@274 + int dist_X; // eax@278 +// int new_dist_Y; + int dist_Z; +// int v116; // edx@279 +// int v117; // edx@281 +// int v118; // edx@283 + int v169; // eax@344 + int v188; // esi@369 + int v189; // edi@369 + int v206; // eax@407 + double v241; // st7@478 + ItemGen *v245; // edi@492 + int v258; // ecx@514 + char v259; // al@516 + int v260; // eax@518 + int v261; // esi@519 + int v262; // edx@521 + int *v263; // ecx@521 + int v264; // esi@521 + int v265; // edx@521 + int *ii; // eax@522 + int v267; // eax@524 + int v268; // eax@524 + int v278; // ecx@548 + char v279; // al@550 + int v280; // eax@552 + int *v281; // esi@553 + int v282; // edx@555 + int *v283; // ecx@555 + int v284; // esi@555 + int v285; // edx@555 + int *l; // eax@556 + int v295; // edx@575 + char v313; // al@606pGame->GetStru6() + const char *v317; // ecx@617 +// int v396; // eax@752 + __int16 v448; // ax@864 + DDM_DLV_Header *v613; // eax@1108 + int v642; // edi@1156 + int v643; // eax@1156 + int v659; // [sp+0h] [bp-E84h]@123 + unsigned __int64 v663; // [sp+0h] [bp-E84h]@639 + int v666; // [sp+4h] [bp-E80h]@12 + PLAYER_SKILL_TYPE v667; // [sp+4h] [bp-E80h]@25 + int v679[800]; // [sp+14h] [bp-E70h]@515 + unsigned __int64 v685; // [sp+D08h] [bp-17Ch]@416 + unsigned __int64 v687; // [sp+D24h] [bp-160h]@327 + Vec3_int_ v688; // [sp+D2Ch] [bp-158h]@943 + Vec3_int_ v691; // [sp+D38h] [bp-14Ch]@137 + Vec3_int_ v694; // [sp+D44h] [bp-140h]@982 + Vec3_int_ v697; // [sp+D50h] [bp-134h]@129 + Vec3_int_ v700; // [sp+D5Ch] [bp-128h]@339 + Vec3_int_ v701; // [sp+D68h] [bp-11Ch]@286 + Vec3_int_ v704; // [sp+D74h] [bp-110h]@132 + Vec3_int_ v707; // [sp+D80h] [bp-104h]@1127 + int v710; // [sp+D8Ch] [bp-F8h]@1156 + int n; // [sp+DA0h] [bp-E4h]@1 + AIDirection v715; // [sp+DA4h] [bp-E0h]@21 + int mon_id; + int dist_Y; // [sp+DD8h] [bp-ACh]@163 + int v723; // [sp+E4Ch] [bp-38h]@1 + ItemGen *_this; // [sp+E50h] [bp-34h]@23 + int v725; // [sp+E54h] [bp-30h]@23 + int buff_resist; + bool spell_sound_flag; // [sp+E5Ch] [bp-28h]@1 + Player *pPlayer; // [sp+E64h] [bp-20h]@8 + int v730; // [sp+E68h] [bp-1Ch]@53 + ItemGen *v730c; + int skill_level; // [sp+E6Ch] [bp-18h]@48 + signed int v732; // [sp+E70h] [bp-14h]@325 + unsigned __int64 v733; // [sp+E74h] [bp-10h]@1 + int duration; + signed int a2; // [sp+E7Ch] [bp-8h]@14 + int amount; // [sp+E80h] [bp-4h]@1 + int obj_type; + ItemDesc* _item; + + SpriteObject pSpellSprite; // [sp+DDCh] [bp-A8h]@1 + + spell_level = 0; + amount = 0; + LODWORD(v733) = 0; + v723 = 0; + spell_sound_flag = false; + for(n = 0; n < CastSpellInfoCount; ++n) + { + pCastSpell = &pCastSpellInfo[n]; + HIDWORD(v733) = (int)pCastSpell; + if ( pCastSpell->uSpellID == 0 ) + continue; + + if (pParty->Invisible()) + pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); + + if ( pCastSpell->uFlags & 0x3CA ) + { + if ( !pParty->pPlayers[pCastSpell->uPlayerID].CanAct() ) + _427D48(); + continue; + } + pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID]; + + a2 = pCastSpell->spell_target_pid; + if (!pCastSpell->spell_target_pid) + { + if (pCastSpell->uSpellID == SPELL_LIGHT_DESTROY_UNDEAD || + pCastSpell->uSpellID == SPELL_SPIRIT_TURN_UNDEAD || + pCastSpell->uSpellID == SPELL_DARK_CONTROL_UNDEAD ) + v666 = 1; + else + v666 = 0; + + a2 = stru_50C198.FindClosestActor(5120, 1, v666); + v6 = pMouse->uPointingObjectID; + if ( pMouse->uPointingObjectID && PID_TYPE(v6) == OBJECT_Actor && pActors[PID_ID(v6)].CanAct() ) + a2 = pMouse->uPointingObjectID; + } + + + pSpellSprite.uType = stru_4E3ACC[pCastSpell->uSpellID].uType; + if (pSpellSprite.uType) + { + if (PID_TYPE(a2) == OBJECT_Actor) + { + Actor::GetDirectionInfo(PID(OBJECT_Player, pCastSpell->uPlayerID + 1), a2, &v715, 0); + spell_level = v723; + } + else + { + v715.uYawAngle = pParty->sRotationY; + v715.uPitchAngle = pParty->sRotationX; + } + } + + v725 = 0; + _this = 0; + if (pCastSpell->forced_spell_skill_level) + { + v11 = pCastSpell->forced_spell_skill_level; + v723 = v11 & 0x3F; // 6 bytes + spell_level = v723; + } + else + { + //v667 = PLAYER_SKILL_STAFF; + if (pCastSpell->uSpellID < SPELL_AIR_WIZARD_EYE) + v667 = PLAYER_SKILL_FIRE; + else if (pCastSpell->uSpellID < SPELL_WATER_AWAKEN) + v667 = PLAYER_SKILL_AIR; + else if (pCastSpell->uSpellID < SPELL_EARTH_STUN) + v667 = PLAYER_SKILL_WATER; + else if (pCastSpell->uSpellID < SPELL_SPIRIT_DETECT_LIFE) + v667 = PLAYER_SKILL_EARTH; + else if (pCastSpell->uSpellID < SPELL_MIND_REMOVE_FEAR) + v667 = PLAYER_SKILL_SPIRIT; + else if (pCastSpell->uSpellID < SPELL_BODY_CURE_WEAKNESS) + v667 = PLAYER_SKILL_MIND; + else if (pCastSpell->uSpellID < SPELL_LIGHT_LIGHT_BOLT) + v667 = PLAYER_SKILL_BODY; + else if (pCastSpell->uSpellID < SPELL_DARK_REANIMATE) + v667 = PLAYER_SKILL_LIGHT; + else if (pCastSpell->uSpellID < SPELL_BOW_ARROW) + v667 = PLAYER_SKILL_DARK; + else if (pCastSpell->uSpellID == SPELL_BOW_ARROW) + v667 = PLAYER_SKILL_BOW; + else if (pCastSpell->uSpellID == SPELL_101 || pCastSpell->uSpellID == SPELL_LASER_PROJECTILE ) + v667 = PLAYER_SKILL_BLASTER; + else assert(false && "Unknown spell"); + + v725 = v667; + v723 = pPlayer->GetActualSkillLevel(v667) & 0x3F; + spell_level = v723; + v11 = pPlayer->pActiveSkills[v725]; + } + + skill_level = SkillToMastery(v11); + if (pCastSpell->uSpellID < SPELL_BOW_ARROW ) + { + if (pCastSpell->forced_spell_skill_level) + uRequiredMana = 0; + else + uRequiredMana = pSpellDatas[pCastSpell->uSpellID].mana_per_skill[skill_level - 1]; + sRecoveryTime = pSpellDatas[pCastSpell->uSpellID].recovery_per_skill[skill_level - 1]; + } + + if (v725 == PLAYER_SKILL_DARK && pParty->uCurrentHour == 0 && pParty->uCurrentMinute == 0 || + v725 == PLAYER_SKILL_LIGHT && pParty->uCurrentHour == 12 && pParty->uCurrentMinute == 0) + uRequiredMana = 0; + + if (pCastSpell->uSpellID < SPELL_BOW_ARROW && pPlayer->sMana < uRequiredMana) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[586], 2); // "Not enough spell points" + pCastSpell->uSpellID = 0; + continue; + } + v730 = pCastSpell->uSpellID; + if (pPlayer->IsCursed() && pCastSpell->uSpellID < SPELL_BOW_ARROW && rand() % 100 < 50)//íåóäà÷íîå êàñòîâàíèå + { + if (!pParty->bTurnBasedModeOn) + pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * 213.3333333333333)); + else + { + pParty->pTurnBasedPlayerRecoveryTimes[pCastSpellInfo[n].uPlayerID] = 100; + pPlayer->SetRecoveryTime(sRecoveryTime); + pTurnEngine->ApplyPlayerAction(); + } + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // "Spell failed" + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpellInfo[n].uSpellID = 0; + pPlayer->sMana -= uRequiredMana; + return; + } + + switch ( pCastSpell->uSpellID ) + { + case SPELL_101: + assert(false && "Unknown spell effect #101 (prolly flaming bow arrow"); + case SPELL_BOW_ARROW://ñòðåëüáà èç ëóêà + { + amount = 1; + if ( SkillToMastery(pPlayer->pActiveSkills[PLAYER_SKILL_BOW]) >= 3 ) + amount = 2; + sRecoveryTime = pPlayer->GetAttackRecoveryTime(true); + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + if ( pPlayer->WearsItem(ITEM_ARTEFACT_ULLYSES, EQUIP_BOW) ) + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(0xBD6u); + pSpellSprite.vPosition.x = pParty->vPosition.x; + pSpellSprite.vPosition.y = pParty->vPosition.y; + pSpellSprite.uAttributes = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID]; + memcpy(&pSpellSprite.stru_24, &pPlayer->pInventoryItemList[pPlayer->pEquipment.uBow-1], sizeof(pSpellSprite.stru_24)); + pSpellSprite.uAttributes = 256; + if ( pParty->bTurnBasedModeOn == 1 ) + pSpellSprite.uAttributes = 260; + for ( i = 0; i < amount; ++i ) + { + if ( i ) + pSpellSprite.vPosition.z += 32; + pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z); + if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, + pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + } + break; + } + case SPELL_LASER_PROJECTILE://ñòðåëüáà èç áëàñòåðà + { + sRecoveryTime = pPlayer->GetAttackRecoveryTime(0); + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = v723; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.x = pParty->vPosition.x; + pSpellSprite.vPosition.y = pParty->vPosition.y; + pSpellSprite.uAttributes = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID]; + memcpy(&pSpellSprite.stru_24, &pPlayer->pInventoryItemList[pPlayer->pEquipment.uMainHand - 1],sizeof(pSpellSprite.stru_24)); + // &pParty->pPlayers[pCastSpell->uPlayerID].spellbook.pDarkSpellbook.bIsSpellAvailable[36 + // * pParty->pPlayers[pCastSpell->uPlayerID].pEquipment.uMainHand + 5], ); + pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z); + HIBYTE(pSpellSprite.uAttributes) |= 1; + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(pSpellSprite.uAttributes) |= 4; + if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, + pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + break; + } + case SPELL_FIRE_TORCH_LIGHT://ñâåò ôàêåëà + { + switch (skill_level) + { + case 1: amount = 2; break; + case 2: amount = 3; break; + case 3: + case 4: amount = 4; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)3600 * spell_level * 4.2666669), skill_level, amount, 0, 0); + spell_sound_flag = true; + break; + } + case SPELL_FIRE_FIRE_SPIKE://îãíåííûé øèï + { + switch (skill_level) + { + case 1: amount = 3; break; + case 2: amount = 5; break; + case 3: amount = 7; break; + case 4: amount = 9; break; + default: + assert(false); + } + int _v733 = 0; + for (uint i = 0; i < uNumSpriteObjects; ++i) + { + SpriteObject* object = &pSpriteObjects[i]; + if (object->uType && object->spell_id == SPELL_FIRE_FIRE_SPIKE && object->spell_caster_pid == PID(OBJECT_Player, pCastSpell->uPlayerID)) + ++_v733; + } + if ( _v733 > amount ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.y = pParty->vPosition.y; + pSpellSprite.vPosition.x = pParty->vPosition.x; + pSpellSprite.uAttributes = 0; + pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(pSpellSprite.uAttributes) |= 4; + v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; + if ( pSpellSprite.Create(pParty->sRotationY, pParty->sRotationX + 10, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + spell_sound_flag = true; + break; + } + case SPELL_AIR_IMPLOSION://Òî÷íûé âçðûâ + { + mon_id = PID_ID(a2); + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if (!a2) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if (PID_TYPE(a2) == OBJECT_Actor) + { + v697.x = 0; + v697.y = 0; + v697.z = 0; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.field_60_distance_related_prolly_lod = 0; + pSpellSprite.uFacing = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; + pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z; + pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; + pSpellSprite.spell_target_pid = PID(OBJECT_Actor, mon_id); + Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), mon_id, &v697); + } + spell_sound_flag = true; + break; + } + case SPELL_EARTH_MASS_DISTORTION://Èçìåíåíèå âåñà + { + mon_id = PID_ID(a2); + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if ( pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)3) ) + { + pActors[mon_id].pActorBuffs[ACTOR_BUFF_MASS_DISTORTION].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0); + v704.x = 0; + v704.y = 0; + v704.z = 0; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.field_60_distance_related_prolly_lod = 0; + pSpellSprite.uFacing = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; + pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; + pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z; + pSpellSprite.spell_target_pid = PID(OBJECT_Actor, mon_id); + Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), mon_id, &v704); + } + spell_sound_flag = true; + break; + } + case SPELL_LIGHT_DESTROY_UNDEAD://Óíè÷òîæåíèå íåæèòè + { + if ( !pPlayer->CanCastSpell(uRequiredMana) || !a2 || PID_TYPE(a2) != OBJECT_Actor) + break; + //v730 = a2 >> 3; + //HIDWORD(v733) = (int)&pActors[PID_ID(a2)]; + v691.x = 0; + v691.y = 0; + v691.z = 0; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.x = pActors[PID_ID(a2)].vPosition.x; + pSpellSprite.vPosition.y = pActors[PID_ID(a2)].vPosition.y; + pSpellSprite.vPosition.z = pActors[PID_ID(a2)].vPosition.z; + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + pSpellSprite.uAttributes |= 0x80u; + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + int obj_id = pSpellSprite.Create(0, 0, 0, 0); + if ( !MonsterStats::BelongsToSupertype(pActors[PID_ID(a2)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + Actor::DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v691); + spell_sound_flag = true; + break; + } + case SPELL_FIRE_FIRE_BOLT://Óäàð îãíÿ + case SPELL_FIRE_FIREBALL://Îãíåííûé øàð + case SPELL_FIRE_INCINERATE://Èñïåïåëåíèå + case SPELL_AIR_LIGHNING_BOLT://Óäàð ìîëíèè + case SPELL_WATER_ICE_BOLT://Ëüäÿíàÿ ìîëíèÿ + case SPELL_WATER_ICE_BLAST://Ëüäÿíîé âçðûâ + case SPELL_EARTH_STUN://Îãëóøèòü + case SPELL_EARTH_DEADLY_SWARM://Ðîé ñìåðòè + case SPELL_MIND_MIND_BLAST://Óäàð ìûñëè + case SPELL_MIND_PSYCHIC_SHOCK://Ïñèõè÷åñêèé øîê + case SPELL_BODY_HARM://Âðåä + case SPELL_LIGHT_LIGHT_BOLT://Ëó÷ ñâåòà + case SPELL_DARK_DRAGON_BREATH://Äûõàíèå äðàêîíà + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.y = pParty->vPosition.y; + pSpellSprite.vPosition.x = pParty->vPosition.x; + pSpellSprite.uAttributes = 0; + pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); + else + pSpellSprite.uSectorID = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(pSpellSprite.uAttributes) |= 4; + if ( pCastSpell->uSpellID == SPELL_AIR_LIGHNING_BOLT ) + LOBYTE(pSpellSprite.uAttributes) |= 0x40; + v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; + if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + spell_sound_flag = true; + break; + } + case SPELL_WATER_ACID_BURST://Âñïëåñê êèñëîòû + case SPELL_EARTH_BLADES://Ëåçâèÿ + case SPELL_BODY_FLYING_FIST://Ëåòàþùèé êóëàê + case SPELL_DARK_TOXIC_CLOUD://Îáëàêî-òîêñèí + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.vPosition.x = pParty->vPosition.x; + pSpellSprite.vPosition.y = pParty->vPosition.y; + pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2; + pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(pSpellSprite.uAttributes) |= 4; + v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; + if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + spell_sound_flag = true; + break; + } + case SPELL_LIGHT_SUNRAY://Ëó÷ Ñîëíöà + { + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor + || uCurrentlyLoadedLevelType == LEVEL_Outdoor && (pParty->uCurrentHour < 5 || pParty->uCurrentHour >= 21) )//òîëüêî â äíåâíîå âðåìÿ + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if ( pPlayer->CanCastSpell(uRequiredMana) ) + { + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.spell_level = spell_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.vPosition.x = pParty->vPosition.x; + pSpellSprite.vPosition.y = pParty->vPosition.y; + pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(pSpellSprite.uAttributes) |= 4; + v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; + if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + spell_sound_flag = true; + } + break; + } + case SPELL_LIGHT_PARALYZE://Ïàðàëè÷ + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + mon_id = PID_ID(a2); + if (PID_TYPE(a2) == OBJECT_Actor && pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)9) ) + { + Actor::AI_Stand(PID_ID(a2), 4, 0x80, 0); + pActors[mon_id].pActorBuffs[ACTOR_BUFF_PARALYZED].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)23040 * spell_level * 0.033333335), skill_level, 0, 0, 0); + pActors[mon_id].uAttributes |= ACTOR_AGGRESSOR; + pActors[mon_id].vVelocity.x = 0; + pActors[mon_id].vVelocity.y = 0; + pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(&pActors[mon_id], 0); + } + spell_sound_flag = true; + break; + } + case SPELL_EARTH_SLOW://Çàìåäëåíèå + { + switch (skill_level) + { + case 1: LODWORD(v733) = 180 * spell_level; amount = 2; break;//LODWORD(v733)???íå ïðèìåíÿåòñÿ äàëåå + case 2: LODWORD(v733) = 300 * spell_level; amount = 2; break; + case 3: LODWORD(v733) = 300 * spell_level; amount = 4; break; + case 4: LODWORD(v733) = 300 * spell_level; amount = 8; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + //v721 = 836 * PID_ID(a2); + mon_id = PID_ID(a2); + if (PID_TYPE(a2) == OBJECT_Actor && pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)3) ) + { + pActors[mon_id].pActorBuffs[ACTOR_BUFF_SLOWED].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)23040 * spell_level * 0.033333335), skill_level, amount, 0, 0); + pActors[mon_id].uAttributes |= ACTOR_AGGRESSOR; + pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(&pActors[mon_id], 0); + } + spell_sound_flag = true; + break; + } + case SPELL_MIND_CHARM:// Î÷àðîâàíèå + { + v61 = PID_ID(a2); + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if ( pActors[v61].DoesDmgTypeDoDamage((DAMAGE_TYPE)7) ) + { + uint power = 300 * spell_level; + if ( skill_level == 2 ) + power = 600 * spell_level; + else if ( skill_level == 3 ) + power = 29030400; + + pActors[v61].pActorBuffs[ACTOR_BUFF_BERSERK].Reset(); + pActors[v61].pActorBuffs[ACTOR_BUFF_ENSLAVED].Reset(); + pActors[v61].pActorBuffs[ACTOR_BUFF_CHARM].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(power << 7) * 0.033333335), skill_level, 0, 0, 0); + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.x = pActors[v61].vPosition.x; + pSpellSprite.vPosition.y = pActors[v61].vPosition.y; + pSpellSprite.vPosition.z = pActors[v61].vPosition.z + pActors[v61].uActorHeight; + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = pIndoor->GetSector(pActors[v61].vPosition.x, pActors[v61].vPosition.y, pSpellSprite.vPosition.z); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + LOBYTE(pSpellSprite.uAttributes) |= 0x80u; + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); + } + spell_sound_flag = true; + break; + } + case SPELL_DARK_SHRINKING_RAY://Ñæèìàþùèé ëó÷ + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pSpellSprite.stru_24.Reset(); + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.x = pParty->vPosition.x; + pSpellSprite.vPosition.y = pParty->vPosition.y; + pSpellSprite.uAttributes = 0; + pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pSpellSprite.spell_skill = skill_level; + pSpellSprite.spell_id = SPELL_FIRE_PROTECTION_FROM_FIRE; + pSpellSprite.spell_level = 300 * spell_level; + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(pSpellSprite.uAttributes) |= 4; + v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; + if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + spell_sound_flag = true; + break; + } + case SPELL_FIRE_FIRE_AURA: //Àóðà îãíÿ + { + switch (skill_level) + { + case 1: duration = 3600 * spell_level; amount = 10; break; //Îãíÿ + case 2: duration = 3600 * spell_level; amount = 11; break; //Îãíåííîãî æàðà + case 3: duration = 3600 * spell_level; amount = 12; break; + case 4: duration = 0; amount = 12; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v730c = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2]; + _item = &pItemsTable->pItems[v730c->uItemID]; + v730c->UpdateTempBonus(pParty->uTimePlayed); + if ( v730c->uItemID < 64 || v730c->uItemID > 65 + && !v730c->IsBroken() + && !v730c->uSpecEnchantmentType + && !v730c->uEnchantmentType + && ( _item->uEquipType == EQUIP_SINGLE_HANDED || _item->uEquipType == EQUIP_TWO_HANDED || _item->uEquipType == EQUIP_BOW) + && !pItemsTable->IsMaterialNonCommon(v730c) ) + { + v730c->uSpecEnchantmentType = amount; + if ( skill_level != 4 ) + { + v730c->uExpireTime = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335); + v730c->uAttributes |= ITEM_TEMP_BONUS; + } + v730c->uAttributes |= ITEM_AURA_EFFECT_RED; + _50C9A8_item_enchantment_timer = 256; + spell_sound_flag = true; + break; + } + _50C9D0_AfterEnchClickEventId = 113; + _50C9D4_AfterEnchClickEventSecondParam = 0; + _50C9D8_AfterEnchClickEventTimeout = 1; + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + case SPELL_BODY_REGENERATION://Ðåãåíåðàöèÿ + { + switch (skill_level) + { + case 1: amount = 1; break; + case 2: amount = 1; break; + case 3: amount = 3; break; + case 4: amount = 10; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + 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)(3600 * spell_level) * 4.2666669), skill_level, amount, 0, 0); + spell_sound_flag = true; + break; + } + case SPELL_FIRE_PROTECTION_FROM_FIRE://Çàùèòà îò Îãíÿ + case SPELL_AIR_PROTECTION_FROM_AIR://Çâùèòà îò Âîçäóõà + case SPELL_WATER_PROTECTION_FROM_WATER://Çàùèòà îò Âîäû + case SPELL_EARTH_PROTECTION_FROM_EARTH://Çàùèòà îò Çåìëè + case SPELL_MIND_PROTECTION_FROM_MIND://Çàùèòà îò Ìûñëè + case SPELL_BODY_PROTECTION_FROM_BODY://Çàùèòà îò Òåëà + { + switch (skill_level) + { + case 1: + case 2: + case 3: + case 4: amount = skill_level * spell_level; break; + default: + assert(false); + } + switch (pCastSpell->uSpellID) + { + case SPELL_FIRE_PROTECTION_FROM_FIRE: + buff_resist = PARTY_BUFF_RESIST_FIRE; + break; + case SPELL_AIR_PROTECTION_FROM_AIR: + buff_resist = PARTY_BUFF_RESIST_AIR; + break; + case SPELL_WATER_PROTECTION_FROM_WATER: + buff_resist = PARTY_BUFF_RESIST_WATER; + break; + case SPELL_EARTH_PROTECTION_FROM_EARTH: + buff_resist = PARTY_BUFF_RESIST_EARTH; + break; + case SPELL_MIND_PROTECTION_FROM_MIND: + buff_resist = PARTY_BUFF_RESIST_MIND; + break; + case SPELL_BODY_PROTECTION_FROM_BODY: + buff_resist = PARTY_BUFF_RESIST_BODY; + break; + default: + assert(false); + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + 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)(3600 * spell_level) * 4.2666669; + pParty->pPartyBuffs[buff_resist].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(3600 * spell_level) * 4.2666669), skill_level, amount, 0, 0); + spell_sound_flag = true; + break; + } + case SPELL_FIRE_HASTE://Ñïåøêà + { + switch (skill_level) + { + case 1: duration = 60 * (spell_level + 60); break; + case 2: duration = 60 * (spell_level + 60); break; + case 3: duration = 180 * (spell_level + 20); break; + case 4: duration = 240 * (spell_level + 15); break; + default: + assert(false); + } + if ( pPlayer->CanCastSpell(uRequiredMana) ) + { + spell_sound_flag = true; + for ( uint pl_id = 0; pl_id < 4; pl_id++ ) + { + if ( pParty->pPlayers[pl_id].pConditions[Condition_Weak] ) + spell_sound_flag = false; + } + if ( spell_sound_flag ) + { + pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, 0, 0); + 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; + } + case SPELL_SPIRIT_BLESS://Áëàãîñëîâåíèå + { + switch (skill_level) + { + case 1: duration = 300 * (spell_level + 12); break; + case 2: duration = 300 * (spell_level + 12); break; + case 3: duration = 900 * (spell_level + 4); break; + case 4: duration = 3600 * (spell_level + 1); break; + default: + assert(false); + } + amount = spell_level + 5; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if ( skill_level == 1 ) + { + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); + v111 = pOtherOverlayList->_4418B1(10000, pCastSpell->uPlayerID_2 + 310, 0, 65536); + pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed + + (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), 1, amount, v111, 0); + spell_sound_flag = true; + break; + } + for ( uint pl_id = 0; pl_id < 4; pl_id++ ) + { + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id); + v111 = pOtherOverlayList->_4418B1(10000, pl_id + 310, 0, 65536); + pParty->pPlayers[pl_id].pPlayerBuffs[1].Apply(pParty->uTimePlayed + + (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, amount, v111, 0); + } + spell_sound_flag = true; + break; + } + case SPELL_SPIRIT_SPIRIT_LASH://Ïëåòü Äóõà + { + if ( pPlayer->CanCastSpell(uRequiredMana) && a2 && PID_TYPE(a2) == OBJECT_Actor) + { + int mon_id = PID_ID(a2); + dist_X = abs(pActors[mon_id].vPosition.x - pParty->vPosition.x); + dist_Y = abs(pActors[mon_id].vPosition.y - pParty->vPosition.y); + dist_Z = abs(pActors[mon_id].vPosition.z - pParty->vPosition.z); + int count = int_get_vector_length(dist_X, dist_Y, dist_Z); + if ( (double)count <= 307.2 ) + { + v701.x = 0; + v701.y = 0; + v701.z = 0; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = v723; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.field_60_distance_related_prolly_lod = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.uFacing = 0; + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; + pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; + pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z - (unsigned int)(signed __int64)((double)pActors[mon_id].uActorHeight * -0.8); + pSpellSprite.spell_target_pid = PID(OBJECT_Actor, a2); + Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), mon_id, &v701); + spell_sound_flag = true; + } + else + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);//"Íå ïîëó÷èëîñü!!!" + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + } + } + break; + } + case SPELL_AIR_SHIELD://Ùèò + case SPELL_EARTH_STONESKIN://Êàìåííàÿ êîæà + case SPELL_SPIRIT_HEROISM://Ãåðîèçì + { + switch (skill_level) + { + case 1: duration = 300 * (spell_level + 12); break; + case 2: duration = 300 * (spell_level + 12); break; + case 3: duration = 900 * (spell_level + 4); break; + case 4: duration = 3600 * (spell_level + 1); break; + default: + assert(false); + } + switch (pCastSpell->uSpellID) + { + case SPELL_AIR_SHIELD: + amount = 0; + buff_resist = PARTY_BUFF_SHIELD; + break; + case SPELL_EARTH_STONESKIN: + amount = spell_level + 5; + buff_resist = PARTY_BUFF_STONE_SKIN; + break; + case SPELL_SPIRIT_HEROISM: + amount = spell_level + 5; + buff_resist = PARTY_BUFF_HEROISM; + break; + default: + assert(false); + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + 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[buff_resist].Apply(pParty->uTimePlayed + + (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, amount, 0, 0); + spell_sound_flag = true; + break; + } + case SPELL_FIRE_IMMOLATION://Êîëüöî îãíÿ + { + if ( skill_level == 4 ) + duration = 600 * spell_level; + else + duration = 60 * spell_level; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + 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)duration << 7) * 0.033333335), skill_level, spell_level, 0, 0); + spell_sound_flag = true; + break; + } + case SPELL_FIRE_METEOR_SHOWER://Ïîòîê ìåòåîðîâ + { + //if (skill_level < 3)//äëÿ ìàñòåðà è ìàãèñòðà + //break; + int meteor_num; + if ( skill_level == 4 ) + meteor_num = 20; + else + meteor_num = 16; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[491], 2); // Can't cast Meteor Shower indoors! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + obj_type = PID_TYPE(a2); + mon_id = PID_ID(a2); + if (obj_type == OBJECT_Actor)//åñëè çàêë ïîñòàâèòü íà áûñòðîå çàêë., òî ìîæíî óêàçûâàòü êóäà êèäàòü ìåòåîðû + { + dist_X = pActors[mon_id].vPosition.x; + dist_Y = pActors[mon_id].vPosition.y; + dist_Z = pActors[mon_id].vPosition.z; + } + else + { + dist_X = pParty->vPosition.x + fixpoint_mul(2048, stru_5C6E00->Cos(pParty->sRotationY)); + dist_Y = pParty->vPosition.y + fixpoint_mul(2048, stru_5C6E00->Sin(pParty->sRotationY)); + dist_Z = pParty->vPosition.z; + } + unsigned __int64 k = 0; + int j = 0; + if ( meteor_num > 0 ) + { + v730 = obj_type == OBJECT_Actor ? a2 : 0; + for ( meteor_num; meteor_num; meteor_num-- ) + { + a2 = rand() % 1000; + if ( sqrt(((double)a2 - 2500) * ((double)a2 - 2500) + j * j + k * k) <= 1.0 ) + { + LODWORD(v687) = 0; + HIDWORD(v687) = 0; + } + else + { + HIDWORD(v687) = stru_5C6E00->Atan2((signed __int64)sqrt((float)(j * j + k * k)), (double)a2 - 2500); + LODWORD(v687) = stru_5C6E00->Atan2(j, k); + } + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.vPosition.x = dist_X; + pSpellSprite.vPosition.y = dist_Y; + pSpellSprite.vPosition.z = a2 + dist_Z; + pSpellSprite.uSectorID = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = v730; + pSpellSprite.field_60_distance_related_prolly_lod = stru_50C198._427546(a2 + 2500); + pSpellSprite.uFacing = v687; + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + pSpellSprite.uAttributes = 4; + if ( pSpellSprite.Create(v687, SHIDWORD(v687), pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, 0) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + j = rand() % 1024 - 512; + k = rand() % 1024 - 512; + } + } + spell_sound_flag = true; + break; + } + case SPELL_FIRE_INFERNO://Àäñêèé îãîíü + { + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[492], 2); // Can't cast Inferno outdoors! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + int mon_num = pRenderer->_46À6ÀÑ_GetActorsInViewport(4096); + v700.x = 0; + v700.y = 0; + v700.z = 0; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.field_60_distance_related_prolly_lod = 0; + pSpellSprite.uFacing = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + for ( uint i = 0; i < mon_num; i++ ) + { + pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[i]].vPosition.x; + pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[i]].vPosition.y; + pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[i]].vPosition.z - (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[i]].uActorHeight * -0.8); + pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[i]); + Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), _50BF30_actors_in_viewport_ids[i], &v700); + pGame->GetStru6()->_4A81CA(&pSpellSprite); + pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFF3C1E, 0x40); + } + spell_sound_flag = true; + break; + } + case SPELL_AIR_WIZARD_EYE://Îêî ÷àðîäåÿ + { + duration = 3600 * spell_level; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + for ( uint pl_id = 0; pl_id < 4; pl_id++ ) + v169 = pOtherOverlayList->_4418B1(2000, pl_id + 100, 0, 65536); + pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, v169, 0); + spell_sound_flag = true; + break; + } + case SPELL_AIR_FEATHER_FALL://Ïàäåíèå ïåðà(ï¸ðûøêîì) + { + switch (skill_level) + { + case 1: duration = 300 * spell_level; break; + case 2: duration = 600 * spell_level; break; + case 3: duration = 3600 * spell_level; break; + case 4: duration = 3600 * spell_level; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + for ( uint pl_id = 0; pl_id < 4; pl_id++ ) + pOtherOverlayList->_4418B1(2010, pl_id + 100, 0, 65536); + 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)duration << 7) * 0.033333335), skill_level, 0, 0, 0); + spell_sound_flag = true; + break; + } + case SPELL_AIR_SPARKS://Èñêðû + { + switch (skill_level) + { + case 1: amount = 3; break; + case 2: amount = 5; break; + case 3: amount = 7; break; + case 4: amount = 9; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + int _v726 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.y = pParty->vPosition.y; + pSpellSprite.vPosition.x = pParty->vPosition.x; + pSpellSprite.uAttributes = 0; + pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, + pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(pSpellSprite.uAttributes) |= 4; + v188 = (signed int)_v726 / -2; + v189 = (signed int)_v726 / 2; + while ( v188 <= v189 ) + { + pSpellSprite.uFacing = v188 + LOWORD(v715.uYawAngle); + if ( pSpellSprite.Create((signed __int16)(v188 + LOWORD(v715.uYawAngle)), v715.uPitchAngle, + pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, pCastSpell->uPlayerID + 1) != -1 + && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + v188 += _v726 / (amount - 1); + } + spell_sound_flag = true; + break; + } + case SPELL_AIR_JUMP://Ïðûæîê + { + if ( pParty->uFlags & PARTY_FLAGS_1_FALLING) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[493], 2); // Can't cast Jump while airborne! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + break; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + for ( uint pl_id = 0; pl_id < 4; pl_id++ ) + pOtherOverlayList->_4418B1(2040, pl_id + 100, 0, 65536); + pParty->uFlags |= 0x100; + pParty->uFallSpeed = 1000; + spell_sound_flag = true; + break; + } + case SPELL_AIR_INVISIBILITY://Íåâèäèìîñòü + { + switch (skill_level) + { + case 1: duration = 600 * spell_level; amount = spell_level; break; + case 2: duration = 600 * spell_level; amount = 2 * spell_level; break; + case 3: duration = 600 * spell_level; amount = 3 * spell_level; break; + case 4: duration = 3600 * spell_level; amount = 4 * spell_level; break; + default: + assert(false); + } + if (pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW)) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[638], 2); // There are hostile creatures nearby! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if ( pPlayer->CanCastSpell(uRequiredMana) ) + { + 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)duration << 7) * 0.033333335), skill_level, amount, 0, 0); + spell_sound_flag = true; + } + break; + } + case SPELL_AIR_FLY://Ïîë¸ò + { + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2); // Can not cast Fly indoors! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + break; + } + if ( !pPlayers[pCastSpell->uPlayerID + 1]->GetMaxMana() ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + break; + } + if ( skill_level == 1 || skill_level == 2 || skill_level == 3 ) + amount = 1; + else + amount = 0; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + for ( uint pl_id = 0; pl_id < 4; pl_id++) + pOtherOverlayList->_4418B1(2090, pl_id + 100, 0, 65536); + v206 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536); + pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)(3600 * spell_level) << 7) + * 0.033333335), skill_level, amount, v206, pCastSpell->uPlayerID + 1); + spell_sound_flag = true; + break; + } + case SPELL_AIR_STARBURST://Çâåçäîïàä + { + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[495], 2); // Can't cast Starburst indoors! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + obj_type = PID_TYPE(a2); + mon_id = PID_ID(a2); + if ( obj_type == OBJECT_Actor ) + { + dist_X = pActors[mon_id].vPosition.x; + dist_Y = pActors[mon_id].vPosition.y; + dist_Z = pActors[mon_id].vPosition.z; + } + else + { + dist_X = pParty->vPosition.x + fixpoint_mul(2048, stru_5C6E00->Cos(pParty->sRotationY)); + dist_Y = pParty->vPosition.y + fixpoint_mul(2048, stru_5C6E00->Sin(pParty->sRotationY)); + dist_Z = pParty->vPosition.z; + } + unsigned __int64 k = 0; + int j = 0; + v730 = obj_type == OBJECT_Actor ? a2 : 0; + for ( uint star_num = 20; star_num; star_num-- ) + { + a2 = rand() % 1000; + if ( sqrt(((double)a2 + (double)dist_Z - (double)(dist_Z + 2500)) * ((double)a2 + (double)dist_Z - (double)(dist_Z + 2500)) + + j * j + k * k) <= 1.0 ) + { + LODWORD(v685) = 0; + HIDWORD(v685) = 0; + } + else + { + HIDWORD(v685) = stru_5C6E00->Atan2((signed __int64)sqrt((float)(j * j + k * k)), ((double)a2 + (double)dist_Z - (double)(dist_Z + 2500))); + LODWORD(v685) = stru_5C6E00->Atan2(j, k); + } + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.vPosition.x = dist_X; + pSpellSprite.vPosition.y = dist_Y; + pSpellSprite.vPosition.z = (int)(a2 + (dist_Z + 2500)); + pSpellSprite.uSectorID = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = v730; + pSpellSprite.field_60_distance_related_prolly_lod = stru_50C198._427546(a2 + 2500); + pSpellSprite.uFacing = v685; + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + pSpellSprite.uAttributes = 4; + if ( pSpellSprite.Create(v685, SHIDWORD(v685), pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, 0) != -1 + && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + j = rand() % 1024 - 512; + k = rand() % 1024 - 512; + } + spell_sound_flag = true; + break; + } + case SPELL_WATER_AWAKEN://Ïðîáóæäåíèå + { + switch (skill_level) + { + case 1: amount = 180 * spell_level; break; + case 2: amount = 3600 * spell_level; break; + case 3: amount = 86400 * spell_level; break; + case 4: amount = 0; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + for( int i=0; i < 4; i++ ) + { + if ( skill_level == 4 ) + { + if ( pParty->pPlayers[i].pConditions[Condition_Sleep] ) + { + pParty->pPlayers[i].pConditions[Condition_Sleep] = 0; + pParty->pPlayers[i].PlaySound(SPEECH_103, 0); + } + } + else + { + if ( pParty->pPlayers[i].DiscardConditionIfLastsLongerThan(Condition_Sleep, pParty->uTimePlayed - + (signed int)(signed __int64)((double)(amount << 7) * 0.033333335)) ) + pParty->pPlayers[i].PlaySound(SPEECH_103, 0); + } + } + spell_sound_flag = true; + break; + } + case SPELL_WATER_POISON_SPRAY://Ðàñïûëåíèå ÿäà + { + switch (skill_level) + { + case 1: amount = 1; break; + case 2: amount = 3; break; + case 3: amount = 5; break; + case 4: amount = 7; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + signed int _v733 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; + if ( amount == 1 ) + { + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.spell_level = spell_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.vPosition.x = pParty->vPosition.x; + pSpellSprite.vPosition.y = pParty->vPosition.y; + pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(pSpellSprite.uAttributes) |= 4; + v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; + if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + } + else + { + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.y = pParty->vPosition.y; + pSpellSprite.vPosition.x = pParty->vPosition.x; + pSpellSprite.uAttributes = 0; + pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(pSpellSprite.uAttributes) |= 4; + v188 = _v733 / -2; + v189 = _v733 / 2; + if ( v188 <= v189 ) + { + do + { + pSpellSprite.uFacing = v188 + v715.uYawAngle; + if ( pSpellSprite.Create(pSpellSprite.uFacing, v715.uPitchAngle, pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, + pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + v188 += _v733 / (amount - 1); + } + while ( v188 <= v189 ); + } + } + spell_sound_flag = true; + break; + } + case SPELL_WATER_WATER_WALK://Õîæäåíèå ïî âîäå + { + if ( !pPlayers[pCastSpell->uPlayerID + 1]->GetMaxMana() ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + break; + } + switch (skill_level) + { + case 1: //break; + case 2: duration = 600 * spell_level; break; + case 3: + case 4: duration = 3600 * spell_level; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v169 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536); + 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)(duration << 7) * 0.033333335), + skill_level, amount, v169, pCastSpell->uPlayerID + 1); + if ( skill_level == 4 ) + pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags = 1; + spell_sound_flag = true; + break; + } + case SPELL_WATER_RECHARGE_ITEM://Ïåðåçàðÿäêà + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + v730c = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2]; + if ( v730c->GetItemEquipType() != 12 || v730c->uAttributes & 2 ) + { + _50C9D0_AfterEnchClickEventId = 113; + _50C9D4_AfterEnchClickEventSecondParam = 0; + _50C9D8_AfterEnchClickEventTimeout = 1; + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if ( skill_level == 1 || skill_level == 2 ) + v241 = (double)v723 * 0.0099999998 + 0.5;//50 % + else if ( skill_level == 3 ) + v241 = (double)v723 * 0.0099999998 + 0.69999999;//30 % + else if ( skill_level == 4 ) + v241 = (double)v723 * 0.0099999998 + 0.80000001;//20 % + else + v241 = 0.0; + if ( v241 > 1.0 ) + v241 = 1.0; + int uNewCharges = v730c->uMaxCharges * v241; + v730c->uMaxCharges = uNewCharges; + v730c->uNumCharges = uNewCharges; + if ( uNewCharges <= 0 ) + { + v730c = 0; + _50C9D0_AfterEnchClickEventId = 113; + _50C9D4_AfterEnchClickEventSecondParam = 0; + _50C9D8_AfterEnchClickEventTimeout = 1; + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);//Íå ïîëó÷èëîñü!!! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + spell_level = v723; + continue; + } + v730c->uAttributes |= 0x40u; + _50C9A8_item_enchantment_timer = 256; + spell_sound_flag = true; + break; + } + case SPELL_WATER_ENCHANT_ITEM://Òàëèñìàí + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + uRequiredMana = 0; + amount = 10 * spell_level; + bool item_not_broken = true; + int rnd = rand() % 100; + pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID_2]; + v245 = &pPlayer->pInventoryItemList[a2]; + ItemDesc *_v725 = &pItemsTable->pItems[v245->uItemID]; + if ((skill_level == 1 || skill_level == 2 /*&& _v725->uEquipType > EQUIP_BOW*/ || skill_level == 3 || skill_level == 4) && + v245->uItemID <= 134 && + v245->uSpecEnchantmentType == 0 && v245->uEnchantmentType == 0 && + v245->m_enchantmentStrength== 0 && !v245->IsBroken() ) //òðåáîâàíèÿ ê ïðåäìåòó + { + if ( (v245->GetValue() < 450 && ( skill_level == 1 || skill_level == 2 )) + || (v245->GetValue() < 450 && (skill_level == 3|| skill_level == 4 ) && _v725->uEquipType >= EQUIP_SINGLE_HANDED && _v725->uEquipType <= EQUIP_BOW) + || (v245->GetValue() < 250 && (skill_level == 3 || skill_level == 4 )&& _v725->uEquipType > EQUIP_BOW) )//Óñëîâèÿ ïîëîìêè + { + if ( !(v245->uAttributes & 0x200) )// ïðåäìåò íå ñëîìàí + { + v245->uAttributes |= 2;//òåïåðü ñëîìàí + } + item_not_broken = false; + } + else + { + if ( rnd >= 10 * spell_level )//øàíñ íà ñðàáàòûâàíèå + { + if ( !(v245->uAttributes & 0x200) )// ïðåäìåò íå ñëîìàí + v245->uAttributes |= 2;//òåïåðü ñëîìàí + } + else + { + if ( (rnd < 80 && (skill_level == 3 || skill_level == 4 )) || v245->GetValue() < 450 || (v245->GetValue() < 250 + && (skill_level == 3 || skill_level == 4) && _v725->uEquipType >= EQUIP_SINGLE_HANDED && _v725->uEquipType <= EQUIP_BOW)) + { + v313 = _v725->uEquipType; + if ( _v725->uEquipType >= EQUIP_ARMOUR && _v725->uEquipType <= EQUIP_AMULET ) + { + v295 = rand() % 10;// pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType]; + /*v245->uEnchantmentType = 0; + __debugbreak(); // castspellinfo.cpp(1971): warning C4700: uninitialized local variable 'v294' used + for ( kk = pItemsTable->pEnchantments[0].to_item[v245->GetItemEquipType() + 1]; + ; + kk += pItemsTable->pEnchantments[v294->uEnchantmentType].to_item[v245->GetItemEquipType() + 1] ) + { + ++v245->uEnchantmentType; + if ( kk >= v295 ) + break; + } + v255 = 10;//pItemsTable->field_116D8[17]; + v256 = 10;//pItemsTable->field_116D8[16]; + v245->m_enchantmentStrength = v256 + rand() % (v255 - v256 + 1);*/ + v245->uEnchantmentType = v295; + v245->m_enchantmentStrength = pItemsTable->pEnchantments[v295].to_item[_v725->uEquipType - EQUIP_ARMOUR]; + v245->uAttributes |= 0x20u; + _50C9A8_item_enchantment_timer = 256; + spell_sound_flag = true; + break; + } + else if ( skill_level == 3 || skill_level == 4)//for master & GM not refactored(äëÿ ìàñòåðà è ãðàíäà íå îòðåôàêòîðåíî) + { + v258 = 0; + v725 = 0; + int _v733; + if ( pItemsTable->pSpecialEnchantments_count > 0 ) + { + v730 = (int)&v679; + for ( _v733 = 0; _v733 < pItemsTable->pSpecialEnchantments_count; ++_v733 ) + { + v259 = LOBYTE(pItemsTable->pSpecialEnchantments[v258 + 1].pBonusStatement); + if ( !v259 || v259 == 1 ) + { + v260 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[v245->GetItemEquipType() + 4] + v258 * 28); + v725 += v260; + if ( v260 ) + { + v261 = v730; + v730 += 4; + *(int *)v261 = _v733; + } + } + ++v258; + } + } + v262 = rand() % v725; + v263 = v679; + v245->uSpecEnchantmentType = v679[0]; + v264 = pItemsTable->pSpecialEnchantments[*v263].to_item_apply[v245->GetItemEquipType() + 4]; + v265 = v262 + 1; + if ( v264 < v265 ) + { + for ( ii = v679; ; ii = (int *)v732 ) + { + v267 = (int)(ii + 1); + v732 = v267; + v268 = *(int *)v267; + *(int *)(v245 + 12) = v268; + v264 += pItemsTable->pSpecialEnchantments[v268].to_item_apply[v245->GetItemEquipType() + 4]; + if ( v264 >= v265 ) + break; + } + } + v278 = 0; + v725 = 0; + if ( pItemsTable->pSpecialEnchantments_count > 0 ) + { + int *_v730 = v679; + for ( _v733 = 0; _v733 < pItemsTable->pSpecialEnchantments_count; ++_v733 ) + { + v279 = LOBYTE(pItemsTable->pSpecialEnchantments[v278].pBonusStatement); + if ( !v279 || v279 == 1 ) + { + v280 = *(&pItemsTable->pSpecialEnchantments[v278].to_item_apply[v245->GetItemEquipType()]); + _v733 += v280; + if ( v280 ) + { + v281 = _v730; + ++_v730; + *v281 = _v733; + } + } + ++v278; + } + } + v282 = rand() % _v733; + v283 = v679; + v245->uSpecEnchantmentType = v679[0]; + v284 = pItemsTable->pSpecialEnchantments[*v283].to_item_apply[v245->GetItemEquipType() ]; + v285 = v282 + 1; + for ( l = v679; v284 < v285; ++l ) + { + v245->uSpecEnchantmentType = *(l+1); + v284 += pItemsTable->pSpecialEnchantments[*(l+1)].to_item_apply[v245->GetItemEquipType()]; + } + ++v245->uSpecEnchantmentType; + v245->uAttributes |= 0x20u; + _50C9A8_item_enchantment_timer = 256; + spell_sound_flag = true; + break; + } + } + } + } + } + if ( spell_sound_flag == 0 ) + { + v317 = pGlobalTXT_LocalizationStrings[428];//Íå ïîëó÷èëîñü!!! + if ( item_not_broken == false ) + v317 = pGlobalTXT_LocalizationStrings[585];//Ïðåäìåò íåäîñòàòî÷íî âûñîêîãî êà÷åñòâà + ShowStatusBarString(v317, 2); + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + //v318 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; + pCastSpell->uSpellID = 0; + pParty->pPlayers[pCastSpell->uPlayerID_2].PlaySound(SPEECH_43, 0); + } + break; + } + case SPELL_WATER_TOWN_PORTAL://Ïîðòàë ãîðîäà + { + amount = 10 * spell_level; + if ( pPlayer->sMana < (signed int)uRequiredMana ) + break; + if ( pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW) && skill_level != 4 + || rand() % 100 >= amount && skill_level != 4 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + town_portal_caster_id = pCastSpell->uPlayerID; + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_OnCastTownPortal, 0, 0); + spell_sound_flag = true; + break; + } + case SPELL_WATER_LLOYDS_BEACON://Ìàÿê Ëëîéäà + { + if ( !_stricmp(pCurrentMapName, "d05.blv") ) // Arena + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if ( pPlayer->sMana >= (signed int)uRequiredMana ) + { + pEventTimer->Pause(); + pMessageQueue_50CBD0->AddGUIMessage(UIMSG_OnCastLloydsBeacon, 0, 0); + lloyds_beacon_spell_level = (signed int)(604800 * spell_level); + _506348_current_lloyd_playerid = pCastSpell->uPlayerID; + ::uRequiredMana = uRequiredMana; + ::sRecoveryTime = sRecoveryTime; + lloyds_beacon_sound_id = pCastSpell->sound_id; + lloyds_beacon_spell_id = pCastSpell->uSpellID; + pCastSpell->uFlags |= 0x20u; + } + break; + } + case SPELL_EARTH_STONE_TO_FLESH: + { + switch (skill_level) + { + case 1: amount = 3600 * spell_level; break; + case 2: amount = 3600 * spell_level; break; + case 3: amount = 86400 * spell_level; break; + case 4: break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Pertified] ) + { + if ( skill_level == 4 )//for GM + { + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Pertified] = 0; + spell_sound_flag = true; + break; + } + v663 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335); + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Pertified, v663); + } + spell_sound_flag = true; + break; + } + case SPELL_EARTH_ROCK_BLAST://Âçðûâ êàìíÿ + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.y = pParty->vPosition.y; + pSpellSprite.vPosition.x = pParty->vPosition.x; + pSpellSprite.uAttributes = 0; + pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(pParty->sRotationY); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(pSpellSprite.uAttributes) |= 4; + v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; + if ( pSpellSprite.Create(pParty->sRotationY, pParty->sRotationX, v659, pCastSpell->uPlayerID + 1) != -1 + && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + spell_sound_flag = true; + break; + } + case SPELL_EARTH_DEATH_BLOSSOM: //Öâåòîê ñìåðòè + { + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pSpellSprite.uType = 4090; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.x = pParty->vPosition.x; + pSpellSprite.vPosition.y = pParty->vPosition.y; + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + pSpellSprite.field_60_distance_related_prolly_lod = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.uFacing = LOWORD(pParty->sRotationY); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + pSpellSprite.uAttributes = 4; + v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; + if ( pSpellSprite.Create(pParty->sRotationY, stru_5C6E00->uIntegerHalfPi / 2, v659, 0) != -1 + && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + spell_sound_flag = true; + break; + } + case SPELL_SPIRIT_DETECT_LIFE: // Äåòåêòîð æèçíè + { + switch (skill_level) + { + case 1: amount = 600 * spell_level; break; + case 2: amount = 1800 * spell_level; break; + case 3: + case 4: amount = 3600 * spell_level; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + 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)amount << 7) * 0.033333335), skill_level, 0, 0, 0); + spell_sound_flag = true; + break; + } + case SPELL_SPIRIT_FATE:// Ñóäüáà + { + switch (skill_level) + { + case 1: amount = spell_level; break; + case 2: amount = 2 * spell_level; break; + case 3: amount = 4 * spell_level; break; + case 4: amount = 6 * spell_level; break; + default: + assert(false); + } + //LODWORD(v733) = 300; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if ( pCastSpell->spell_target_pid == 0 ) + { + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); + pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, skill_level, amount, 0, 0); + spell_sound_flag = true; + break; + } + if (PID_TYPE(pCastSpell->spell_target_pid) == OBJECT_Actor) + { + mon_id = PID_ID(pCastSpell->spell_target_pid); + pActors[mon_id].pActorBuffs[ACTOR_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, skill_level, amount, 0, 0); + pActors[mon_id].uAttributes |= ACTOR_AGGRESSOR; + pGame->GetStru6()->_4A7E89_sparkles_on_actor_after_it_casts_buff(&pActors[mon_id], 0); + } + spell_sound_flag = true; + break; + } + case SPELL_SPIRIT_REMOVE_CURSE:// Ñíÿòèå ïîð÷è + { + switch (skill_level) + { + case 1: amount = 3600 * spell_level; break; + case 2: amount = 3600 * spell_level; break; + case 3: amount = 86400 * spell_level; break; + case 4: amount = 0; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if ( !pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Cursed] ) + { + spell_sound_flag = true; + break; + } + if ( skill_level == 4 )//GM + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Cursed] = 0; + else + { + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(0, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Cursed] ) + { + spell_sound_flag = true; + break; + } + } + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); + spell_sound_flag = true; + break; + } + case SPELL_SPIRIT_PRESERVATION://Ñîõðàíåíèå + { + if ( skill_level == 4 ) + duration = 900 * (spell_level + 4); + else + duration = 300 * (spell_level + 12); + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if ( skill_level == 1 || skill_level == 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)duration << 7) * 0.033333335), skill_level, 0, 0, 0); + spell_sound_flag = true; + break; + } + for ( uint pl_id = 0; pl_id < 4; pl_id++ ) + { + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id); + pParty->pPlayers[pl_id].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + + (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, 0, 0); + } + spell_sound_flag = true; + break; + } + case SPELL_SPIRIT_TURN_UNDEAD://Áåã ìåðòâåöîâ + { + if ( skill_level == 1 || skill_level == 2) + duration = 60 * (spell_level + 3); + else + duration = 300 * spell_level + 180; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + int mon_num = pRenderer->_46À6ÀÑ_GetActorsInViewport(4096); + pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFF, 192); + ++pSpellSprite.uType; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.field_60_distance_related_prolly_lod = 0; + pSpellSprite.uFacing = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + for ( a2 = 0; a2 < mon_num; ++a2 ) + { + if ( MonsterStats::BelongsToSupertype(pActors[_50BF30_actors_in_viewport_ids[a2]].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) + { + pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.x; + pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.y; + pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.z - (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[a2]].uActorHeight * -0.8); + pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]); + pSpellSprite.Create(0, 0, 0, 0); + pActors[_50BF30_actors_in_viewport_ids[a2]].pActorBuffs[ACTOR_BUFF_AFRAID].Apply(pParty->uTimePlayed + + (signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, 0, 0); + } + } + spell_sound_flag = true; + break; + } + case SPELL_SPIRIT_RAISE_DEAD://Îæèâëåíèå + { + if ( skill_level == 4 ) + amount = 0; + else + amount = 86400 * spell_level; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pOtherOverlayList->_4418B1(5080, pCastSpell->uPlayerID_2 + 100, 0, 65536); + if ( !pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] ) + { + spell_sound_flag = true; + break; + } + pParty->pPlayers[pCastSpell->uPlayerID_2].sHealth = 1; + if ( skill_level == 4 ) + { + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] = 0; + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Unconcious] = 0; + } + else + { + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Dead, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Unconcious, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + } + pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(Condition_Weak, 0); + spell_sound_flag = true; + break; + } + case SPELL_SPIRIT_SHARED_LIFE://Îáùàÿ æèçíü + { + if ( skill_level == 4 ) + amount = 4 * spell_level; + else + amount = 3 * spell_level; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + int active_pl_num = 0; + signed int shared_life_count = amount; + int mean_life = 0; + int pl_array[4]; + for ( uint pl_id = 1; pl_id <= 4; pl_id++ ) + { + if ( !pPlayers[pl_id]->pConditions[Condition_Dead] && !pPlayers[pl_id]->pConditions[Condition_Pertified] + && !pPlayers[pl_id]->pConditions[Condition_Eradicated] ) + pl_array[active_pl_num++] = pl_id; + } + for ( uint i = 0; i < active_pl_num; i++ ) + shared_life_count += pPlayers[pl_array[i]]->sHealth; + mean_life = (signed __int64)((double)shared_life_count / (double)active_pl_num); + for ( uint i = 0; i < active_pl_num; i++ ) + { + pPlayers[pl_array[i]]->sHealth = mean_life; + if ( pPlayers[pl_array[i]]->sHealth > pPlayers[pl_array[i]]->GetMaxHealth()) + pPlayers[pl_array[i]]->sHealth = pPlayers[pl_array[i]]->GetMaxHealth(); + if ( pPlayers[pl_array[i]]->sHealth > 0 ) + pPlayers[pl_array[i]]->SetUnconcious(0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_array[i] - 1); + } + spell_sound_flag = true; + break; + } + case SPELL_SPIRIT_RESSURECTION://Âîñêðåñåíèå + { + switch (skill_level) + { + case 1: amount = 180 * spell_level; break; + case 2: amount = 10800 * spell_level; break; + case 3: amount = 259200 * spell_level; break; + case 4: amount = 0; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Eradicated] + || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] ) + { + if ( !(pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Weak]) ) + pParty->pPlayers[pCastSpell->uPlayerID_2].PlaySound(SPEECH_25, 0); + if ( skill_level == 4 ) + { + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Eradicated] = 0; + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] = 0; + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Unconcious] = 0; + } + else + { + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan( Condition_Eradicated, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan( Condition_Dead, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan( Condition_Unconcious, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + } + pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(Condition_Weak, 1); + pParty->pPlayers[pCastSpell->uPlayerID_2].sHealth = 1; + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); + } + spell_sound_flag = true; + break; + } + case SPELL_MIND_CURE_PARALYSIS://ëå÷åíèå ïàðàëè÷à + { + switch (skill_level) + { + case 1: amount = 3600 * spell_level; break; + case 2: amount = 3600 * spell_level; break; + case 3: amount = 86400 * spell_level; break; + case 4: amount = 0; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); + if ( !pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Paralyzed] ) + { + spell_sound_flag = true; + break; + } + if ( skill_level == 4 ) + { + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Paralyzed] = 0; + spell_sound_flag = true; + break; + } + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Paralyzed, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + spell_sound_flag = true; + break; + } + case SPELL_MIND_REMOVE_FEAR://Ñíÿòü ñòðàõ + { + switch (skill_level) + { + case 1: amount = 180 * spell_level; break; + case 2: amount = 3600 * spell_level; break; + case 3: amount = 86400 * spell_level; break; + case 4: amount = 0; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); + if ( !pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Fear] ) + { + spell_sound_flag = true; + break; + } + if ( skill_level == 4 ) + { + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Fear] = 0; + spell_sound_flag = true; + break; + } + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Fear, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + spell_sound_flag = true; + break; + } + case SPELL_MIND_TELEPATHY://Òåëåïàòèÿ + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if (PID_TYPE(a2) == OBJECT_Actor) + { + mon_id = PID_ID(a2); + if ( !pActors[mon_id].ActorHasItem() ) + pActors[mon_id].SetRandomGoldIfTheresNoItem(); + int gold_num = 0; + if ( pItemsTable->pItems[pActors[mon_id].ActorHasItems[3].uItemID].uEquipType == EQUIP_GOLD ) + gold_num = pActors[mon_id].ActorHasItems[3].uSpecEnchantmentType; + ItemGen item; + item.Reset(); + if (pActors[mon_id].uCarriedItemID) + item.uItemID = pActors[mon_id].uCarriedItemID; + else + { + for ( uint i = 0; i < 4; ++i ) + { + if ( pActors[mon_id].ActorHasItems[i].uItemID > 0 && pItemsTable->pItems[pActors[mon_id].ActorHasItems[i].uItemID].uEquipType != EQUIP_GOLD ) + { + memcpy(&item, &pActors[mon_id].ActorHasItems[i], sizeof(item)); + spell_level = v723; + } + } + } + if ( gold_num > 0 ) + { + if (item.uItemID) + sprintf(pTmpBuf2.data(), "(%s), and %d gold", item.GetDisplayName(), gold_num); + else + sprintf(pTmpBuf2.data(), "%d gold", gold_num); + } + else + { + if (item.uItemID) + sprintf(pTmpBuf2.data(), "(%s)", item.GetDisplayName()); + else + { + strcpy(pTmpBuf2.data(), "nothing"); + ShowStatusBarString(pTmpBuf2.data(), 2); + } + } + ShowStatusBarString(pTmpBuf2.data(), 2); + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; + pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; + pSpellSprite.vPosition.z = pActors[mon_id].uActorHeight; + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = pIndoor->GetSector(pSpellSprite.vPosition.x, pSpellSprite.vPosition.y, pSpellSprite.vPosition.z); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + LOBYTE(pSpellSprite.uAttributes) |= 0x80; + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); + } + spell_sound_flag = true; + break; + } + case SPELL_MIND_BERSERK://Áåðñåðê + { + switch (skill_level) + { + case 1: amount = 300 * spell_level; break; + case 2: amount = 300 * spell_level; break; + case 3: amount = 600 * spell_level; break; + case 4: amount = 3600; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + mon_id = PID_ID(a2); + if (PID_TYPE(a2) == OBJECT_Actor) + { + //v730 = 836 * mon_id; + if ( pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)7) ) + { + pActors[mon_id].pActorBuffs[ACTOR_BUFF_CHARM].Reset(); + pActors[mon_id].pActorBuffs[ACTOR_BUFF_ENSLAVED].Reset(); + pActors[mon_id].pActorBuffs[ACTOR_BUFF_BERSERK].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), skill_level, 0, 0, 0); + pActors[mon_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + } + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; + pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; + pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z + pActors[mon_id].uActorHeight; + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = pIndoor->GetSector(pActors[mon_id].vPosition.x, pActors[mon_id].vPosition.y, pSpellSprite.vPosition.z); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + LOBYTE(pSpellSprite.uAttributes) |= 0x80; + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); + } + spell_sound_flag = true; + break; + } + case SPELL_MIND_ENSLAVE://Ïîðàáîùåíèå + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + amount = 600 * spell_level; + if (PID_TYPE(a2) == OBJECT_Actor) + { + mon_id = PID_ID(a2); + //v730 = 836 * mon_id; + if ( MonsterStats::BelongsToSupertype(pActors[mon_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) + break; + if ( pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)7) ) + { + pActors[mon_id].pActorBuffs[ACTOR_BUFF_BERSERK].Reset(); + pActors[mon_id].pActorBuffs[ACTOR_BUFF_CHARM].Reset(); + pActors[mon_id].pActorBuffs[ACTOR_BUFF_ENSLAVED].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), + skill_level, 0, 0, 0); + } + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; + pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; + pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z + pActors[mon_id].uActorHeight; + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = pIndoor->GetSector(pActors[mon_id].vPosition.x, pActors[mon_id].vPosition.y, pSpellSprite.vPosition.z); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + LOBYTE(pSpellSprite.uAttributes) |= 0x80; + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); + } + spell_sound_flag = true; + break; + } + case SPELL_MIND_MASS_FEAR://Ìàññîâûé ñòðàõ + { + if ( skill_level == 4 ) + amount = 300 * spell_level; + else + amount = 180 * spell_level; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + int mon_num = pRenderer->_46À6ÀÑ_GetActorsInViewport(4096); + pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0A, 192); + ++pSpellSprite.uType; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.field_60_distance_related_prolly_lod = 0; + pSpellSprite.uFacing = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + for ( a2 = 0; a2 < mon_num; ++a2 ) + { + if ( MonsterStats::BelongsToSupertype(pActors[_50BF30_actors_in_viewport_ids[a2]].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) + break; + pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.x; + pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.y; + pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.z - (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[a2]].uActorHeight * -0.8); + pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]); + pSpellSprite.Create(0, 0, 0, 0); + if ( pActors[_50BF30_actors_in_viewport_ids[a2]].DoesDmgTypeDoDamage((DAMAGE_TYPE)7) ) + { + pActors[_50BF30_actors_in_viewport_ids[a2]].pActorBuffs[ACTOR_BUFF_AFRAID].Apply(pParty->uTimePlayed + (signed __int64)((double)(amount << 7) * 0.033333335), + skill_level, 0, 0, 0); + } + } + spell_sound_flag = true; + break; + } + case SPELL_MIND_CURE_INSANITY://Ëå÷åíèå Áåçóìèÿ + { + if ( skill_level == 4 ) + amount = 0; + else + amount = 86400 * spell_level; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); + if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Insane] ) + { + if ( !(pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Weak]) ) + pParty->pPlayers[pCastSpell->uPlayerID_2].PlaySound(SPEECH_25, 0); + if ( skill_level == 4 ) + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Insane] = 0; + else + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Insane, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(Condition_Weak, 0); + } + spell_sound_flag = true; + break; + } + case SPELL_EARTH_TELEKINESIS://Òåëåêèíåç + { + switch (skill_level) + { + case 1: amount = 2 * spell_level; break; + case 2: amount = 2 * spell_level; break; + case 3: amount = 3 * spell_level; break; + case 4: amount = 4 * spell_level; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + int obj_id = PID_ID(a2); + if (PID_TYPE(a2) == OBJECT_Item) + { + if ( pItemsTable->pItems[pSpriteObjects[obj_id].stru_24.uItemID].uEquipType == EQUIP_GOLD ) + { + pParty->PartyFindsGold(pSpriteObjects[obj_id].stru_24.uSpecEnchantmentType, 0); + viewparams->bRedrawGameUI = true; + } + else + { + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[pSpriteObjects[obj_id].stru_24.uItemID].pUnidentifiedName);//Âû íàøëè ^Pv[%s]! + ShowStatusBarString(pTmpBuf2.data(), 2); + if ( !pParty->AddItemToParty(&pSpriteObjects[obj_id].stru_24) ) + pParty->SetHoldingItem(&pSpriteObjects[obj_id].stru_24); + } + SpriteObject::OnInteraction(obj_id); + } + if (PID_TYPE(a2) == OBJECT_Actor) + pActors[obj_id].LootActor(); + if (PID_TYPE(a2) == OBJECT_Decoration) + { + OpenedTelekinesis = true; + if ( pLevelDecorations[obj_id].uEventID ) + EventProcessor(pLevelDecorations[obj_id].uEventID, a2, 1); + if ( pLevelDecorations[pSpriteObjects[obj_id].stru_24.uItemID].IsInteractive() ) + { + activeLevelDecoration = &pLevelDecorations[obj_id]; + EventProcessor(stru_5E4C90_MapPersistVars._decor_events[pLevelDecorations[obj_id]._idx_in_stru123 - 75] + 380, 0, 1); + activeLevelDecoration = nullptr; + } + } + if (PID_TYPE(a2) == OBJECT_BModel) + { + OpenedTelekinesis = true; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + v448 = pIndoor->pFaceExtras[pIndoor->pFaces[obj_id].uFaceExtraID].uEventID; + else + v448 = pOutdoor->pBModels[a2 >> 9].pFaces[obj_id & 0x3F].sCogTriggeredID; + EventProcessor(v448, a2, 1); + } + spell_sound_flag = true; + break; + } + case SPELL_BODY_CURE_WEAKNESS://Ëå÷èòü Ñëàáîñòü + { + switch (skill_level) + { + case 1: amount = 180 * spell_level; break;//3 ìèíóòû * êîëè÷åñòâî î÷êîâ íàâûêà + case 2: amount = 3600 * spell_level; break;//1 ÷àñ * êîëè÷åñòâî î÷êîâ íàâûêà + case 3: amount = 86400 * spell_level; break; + case 4: amount = 0; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); + if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Weak] ) + { + if ( skill_level == 4 ) + { + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Weak] = 0; + spell_sound_flag = true; + break; + } + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Weak, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + } + spell_sound_flag = true; + break; + } + case SPELL_BODY_FIRST_AID://Ïåðâàÿ ïîìîùü + { + switch (skill_level) + { + case 1: amount = 2 * spell_level + 5; break; + case 2: amount = 3 * spell_level + 5; break; + case 3: amount = 4 * spell_level + 5; break; + case 4: amount = 5 * spell_level + 5; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if ( !pCastSpell->spell_target_pid ) + { + pParty->pPlayers[pCastSpell->uPlayerID_2].Heal(amount); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); + } + if (PID_TYPE(pCastSpell->spell_target_pid) == OBJECT_Actor) + { + mon_id = PID_ID(pCastSpell->spell_target_pid); + if ( pActors[mon_id].uAIState != Dead && pActors[mon_id].uAIState != Dying && pActors[mon_id].uAIState != Disabled + && pActors[mon_id].uAIState != Removed ) + { + pActors[mon_id].sCurrentHP += amount; + if ( pActors[mon_id].sCurrentHP > pActors[mon_id].pMonsterInfo.uHP ) + pActors[mon_id].sCurrentHP = pActors[mon_id].pMonsterInfo.uHP; + } + } + spell_sound_flag = true; + break; + } + case SPELL_BODY_CURE_POISON://Ëå÷åíèå Îòðàâëåíèÿ(Ïðîòèâîÿäèå) + { + switch (skill_level) + { + case 1: amount = 3600 * spell_level; break; + case 2: amount = 3600 * spell_level; break; + case 3: amount = 86400 * spell_level; break; + case 4: amount = 0; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); + if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Weak] + || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Medium] + || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Severe] ) + { + if ( skill_level == 4 ) + { + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Weak] = 0; + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Medium] = 0; + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Poison_Severe] = 0; + spell_sound_flag = true; + break; + } + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Poison_Weak, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Poison_Medium, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Poison_Severe, (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + } + spell_sound_flag = true; + break; + } + case SPELL_BODY_PROTECTION_FROM_MAGIC://Çàùèòà îò ìàãèè + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + 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)(3600 * spell_level) << 7) * 0.033333335), skill_level, spell_level, 0, 0); + spell_sound_flag = true; + break; + } + case SPELL_BODY_HAMMERHANDS://Ðóêè-Ìîëîòû + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if ( skill_level == 4 ) + { + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); + for ( uint pl_id = 0; pl_id < 4; pl_id++) + pParty->pPlayers[pl_id].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + + (signed int)(signed __int64)((double)(signed int)((int)(3600 * spell_level) << 7) * 0.033333335), 4, spell_level, spell_level, 0); + spell_sound_flag = true; + break; + } + 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)(3600 * spell_level) << 7) * 0.033333335), skill_level, spell_level, spell_level, 0); + spell_sound_flag = true; + break; + } + case SPELL_BODY_CURE_DISEASE://Ëå÷èòü Áîëåçíü + { + if ( skill_level == 4 ) + amount = 0; + else + amount = 86400 * spell_level; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); + if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Weak] + || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Medium] + || pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Severe] ) + { + if ( skill_level == 4 ) + { + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Weak] = 0; + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Medium] = 0; + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Disease_Severe] = 0; + } + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Disease_Weak, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Disease_Medium, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + pParty->pPlayers[pCastSpell->uPlayerID_2].DiscardConditionIfLastsLongerThan(Condition_Disease_Severe, + (signed __int64)((double)(signed __int64)pParty->uTimePlayed - (double)(amount << 7) * 0.033333335)); + } + spell_sound_flag = true; + break; + } + case SPELL_BODY_POWER_CURE://Èñöåëåíèå + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + for ( uint pl_id = 0; pl_id < 4; ++pl_id ) + { + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id); + pParty->pPlayers[pl_id].Heal(5 * spell_level + 10); + } + spell_sound_flag = true; + break; + } + case SPELL_LIGHT_DISPEL_MAGIC://Ñíÿòèå ÷àð + { + sRecoveryTime -= spell_level; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xAFF0A, 192); + int mon_num = pRenderer->_46À6ÀÑ_GetActorsInViewport(4096); + ++pSpellSprite.uType; + v688.x = 0; + v688.y = 0; + v688.z = 0; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.field_60_distance_related_prolly_lod = 0; + pSpellSprite.uFacing = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + for ( a2 = 0; a2 < mon_num; ++a2 ) + { + pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.x; + pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.y; + pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.z - + (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[a2]].uActorHeight * -0.8); + pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]); + Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), _50BF30_actors_in_viewport_ids[a2], &v688); + } + for ( a2 = 0; a2 < mon_num; ++a2 ) + { + pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.x; + pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.y; + pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[a2]].vPosition.z - + (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[a2]].uActorHeight * -0.8); + pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[a2]); + pSpellSprite.Create(0, 0, 0, 0); + for (int i = 0; i < 22; ++i) + pActors[_50BF30_actors_in_viewport_ids[a2]].pActorBuffs[i].Reset(); + } + spell_sound_flag = true; + break; + } + case SPELL_LIGHT_SUMMON_ELEMENTAL://Ýëåìåíòàë + { + switch (skill_level) + { + case 1: v733 = 300 * spell_level; amount = 1; break; + case 2: v733 = 300 * spell_level; amount = 1; break; + case 3: v733 = 900 * spell_level; amount = 3; break; + case 4: v733 = 900 * spell_level; amount = 5; break; + default: + assert(false); + } + int mon_num = 0; + for ( uint mon_id = 0; mon_id < uNumActors; mon_id++ ) + { + if ( pActors[mon_id].uAIState != Dead && pActors[mon_id].uAIState != Removed && pActors[mon_id].uAIState != Disabled + && PID(OBJECT_Player, pCastSpell->uPlayerID) == pActors[mon_id].uSummonerID ) + ++mon_num; + } + if ( mon_num >= amount ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[648], 2); // This character can't summon any more monsters! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + sub_44FA4C_spawn_light_elemental(pCastSpell->uPlayerID, skill_level, v733); + spell_sound_flag = true; + break; + } + case SPELL_LIGHT_DAY_OF_THE_GODS://Äåíü áîãîâ + { + switch (skill_level) + { + case 1: duration = 10800 * spell_level; amount = 3 * spell_level + 10; break; + case 2: duration = 10800 * spell_level; amount = 3 * spell_level + 10; break; + case 3: duration = 14400 * spell_level; amount = 4 * spell_level + 10; break; + case 4: duration = 18000 * spell_level; amount = 5 * spell_level + 10; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + 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)duration << 7) * 0.033333335), skill_level, amount, 0, 0); + spell_sound_flag = true; + break; + } + case SPELL_LIGHT_PRISMATIC_LIGHT://Ñâåò ïðèçìû + { + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[497], 2); // Can't cast Prismatic Light outdoors! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + int mon_num = pRenderer->_46À6ÀÑ_GetActorsInViewport(4096); + ++pSpellSprite.uType; + v694.x = 0; + v694.y = 0; + v694.z = 0; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.field_60_distance_related_prolly_lod = 0; + pSpellSprite.uFacing = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + for ( uint mon_id = 0; mon_id < mon_num; mon_id++ ) + { + pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.x; + pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.y; + pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.z - + (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[mon_id]].uActorHeight * -0.8); + pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[mon_id]); + Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), _50BF30_actors_in_viewport_ids[mon_id], &v694); + } + //v537 = pGame->GetStru6(); + pGame->GetStru6()->_4A8BFC(); + spell_sound_flag = true; + break; + } + case SPELL_LIGHT_DAY_OF_PROTECTION://Äåíü çàùèòû + { + switch (skill_level) + { + case 1: duration = 14400 * spell_level; amount = 4 * spell_level; break; + case 2: duration = 14400 * spell_level; amount = 4 * spell_level; break; + case 3: duration = 14400 * spell_level; amount = 4 * spell_level; break; + case 4: duration = 18000 * spell_level; amount = 5 * spell_level; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + 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_RESIST_BODY].Apply(pParty->uTimePlayed + + (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_RESIST_MIND].Apply(pParty->uTimePlayed + + (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_RESIST_FIRE].Apply(pParty->uTimePlayed + + (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_RESIST_WATER].Apply(pParty->uTimePlayed + + (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_RESIST_AIR].Apply(pParty->uTimePlayed + + (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_RESIST_EARTH].Apply(pParty->uTimePlayed + + (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, amount, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply(pParty->uTimePlayed + + (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_WIZARD_EYE].Apply(pParty->uTimePlayed + + (signed __int64)((double)(duration << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0); + spell_sound_flag = true; + break; + } + case SPELL_LIGHT_HOUR_OF_POWER: //×àñ ìîãóùåñòâà + { + switch (skill_level) + { + case 1: duration = 4; amount = 4; break; + case 2: duration = 4; amount = 4; break; + case 3: duration = 12; amount = 12; break; + case 4: duration = 20; amount = 15; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + bool player_weak = false; + for ( uint pl_id = 0; pl_id < 4; pl_id++ ) + { + 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->pPlayers[pl_id].pPlayerBuffs[PLAYER_BUFF_BLESS].Apply(pParty->uTimePlayed + + (signed __int64)((double)((300 * amount * spell_level + 60) << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0); + if ( pParty->pPlayers[pl_id].pConditions[Condition_Weak] ) + player_weak = true; + } + pParty->pPartyBuffs[PARTY_BUFF_HEROISM].Apply(pParty->uTimePlayed + + (signed __int64)((double)((300 * amount * spell_level + 60) << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_SHIELD].Apply(pParty->uTimePlayed + + (signed __int64)((double)((300 * amount * spell_level + 60) << 7) * 0.033333335), skill_level, 0, 0, 0); + pParty->pPartyBuffs[PARTY_BUFF_STONE_SKIN].Apply(pParty->uTimePlayed + + (signed __int64)((double)((300 * amount * spell_level + 60) << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0); + if ( !player_weak ) + pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + + (signed __int64)((double)((60 * (spell_level * duration + 60)) << 7) * 0.033333335), skill_level, spell_level + 5, 0, 0); + spell_sound_flag = true; + break; + } + case SPELL_LIGHT_DIVINE_INTERVENTION://Áîæåñòâåííîå âìåøàòåëüñòâî + { + //amount = 3; + if ( pPlayer->uNumDivineInterventionCastsThisDay >= 3 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + for ( uint pl_id = 0; pl_id < 4; pl_id++ ) + { + for ( uint buff_id = 0; buff_id <= 19; buff_id++ ) + pParty->pPlayers[pl_id].pConditions[buff_id] = 0; + pParty->pPlayers[pl_id].sHealth = pParty->pPlayers[pl_id].GetMaxHealth(); + pParty->pPlayers[pl_id].sMana = pParty->pPlayers[pl_id].GetMaxMana(); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id); + } + if ( pPlayer->sAgeModifier + 10 >= 120 ) + pPlayer->sAgeModifier = 120; + else + pPlayer->sAgeModifier = pPlayer->sAgeModifier + 10; + sRecoveryTime += -5 * spell_level; + ++pPlayer->uNumDivineInterventionCastsThisDay; + spell_sound_flag = true; + break; + } + case SPELL_DARK_REANIMATE: //Ðåàíèìàöèÿ + { + switch (skill_level) + { + case 1: amount = 2 * spell_level; break; + case 2: amount = 3 * spell_level; break; + case 3: amount = 4 * spell_level; break; + case 4: amount = 5 * spell_level; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if (!pCastSpell->spell_target_pid) + { + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); + if ( pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Dead] ) + { + pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(Condition_Zombie, 1); + ReloadPlayerPortraits(pCastSpell->uPlayerID_2, (pParty->pPlayers[pCastSpell->uPlayerID_2].GetSexByVoice() != 0) + 23); + pParty->pPlayers[pCastSpell->uPlayerID_2].pConditions[Condition_Zombie] = pParty->uTimePlayed; + } + break; + } + mon_id = PID_ID(pCastSpell->spell_target_pid); + if ( mon_id == -1 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[496], 2); // No valid target exists! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if ( pActors[mon_id].sCurrentHP > 0 + || pActors[mon_id].uAIState != Dead && pActors[mon_id].uAIState != Dying ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + ++pSpellSprite.uType; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.field_60_distance_related_prolly_lod = 0; + pSpellSprite.uFacing = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; + pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; + pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z - + (unsigned int)(signed __int64)((double)pActors[mon_id].uActorHeight * -0.8); + pSpellSprite.spell_target_pid = PID(OBJECT_Actor, mon_id); + pSpellSprite.Create(0, 0, 0, 0); + if ( pActors[mon_id].pMonsterInfo.uLevel > amount ) + break; + Actor::Resurrect(mon_id); + pActors[mon_id].pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)0; + pActors[mon_id].pMonsterInfo.uTreasureDropChance = 0; + pActors[mon_id].pMonsterInfo.uTreasureDiceRolls = 0; + pActors[mon_id].pMonsterInfo.uTreasureDiceSides = 0; + pActors[mon_id].pMonsterInfo.uTreasureLevel = 0; + pActors[mon_id].pMonsterInfo.uTreasureType = 0; + pActors[mon_id].uAlly = 9999; + pActors[mon_id].ResetAggressor();//~0x80000 + pActors[mon_id].uGroup = 0; + pActors[mon_id].pActorBuffs[ACTOR_BUFF_BERSERK].Reset(); + pActors[mon_id].pActorBuffs[ACTOR_BUFF_CHARM].Reset(); + pActors[mon_id].pActorBuffs[ACTOR_BUFF_ENSLAVED].Reset(); + if ( pActors[mon_id].sCurrentHP > 10 * amount ) + pActors[mon_id].sCurrentHP = 10 * amount; + spell_sound_flag = true; + break; + } + case SPELL_DARK_VAMPIRIC_WEAPON:// Îðóæèå-âàìïèð + { + amount = 16; + if ( skill_level == 4 ) + duration = 0; + else + duration = 3600 * spell_level; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + ItemGen *item = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2]; + item->UpdateTempBonus(pParty->uTimePlayed); + if ( item->uItemID >= 64 && item->uItemID <= 65//blasters + || LOBYTE(item->uAttributes) & 2 + || item->uSpecEnchantmentType != 0 + || item->uEnchantmentType != 0 + || pItemsTable->pItems[item->uItemID].uEquipType != EQUIP_SINGLE_HANDED + && pItemsTable->pItems[item->uItemID].uEquipType != EQUIP_TWO_HANDED + && pItemsTable->pItems[item->uItemID].uEquipType != EQUIP_BOW + || pItemsTable->IsMaterialNonCommon(item) ) + { + _50C9D0_AfterEnchClickEventId = 113; + _50C9D4_AfterEnchClickEventSecondParam = 0; + _50C9D8_AfterEnchClickEventTimeout = 1; + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + item->uSpecEnchantmentType = 16; + if ( skill_level != 4 ) + { + item->uExpireTime = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335); + item->uAttributes |= 8; + } + LOBYTE(item->uAttributes) |= 0x80; + _50C9A8_item_enchantment_timer = 256; + spell_sound_flag = true; + break; + } + case SPELL_DARK_SHARPMETAL://Øðàïíåëü + { + switch (skill_level) + { + case 1: amount = 5; break; + case 2: amount = 5; break; + case 3: amount = 7; break; + case 4: amount = 9; break; + default: + assert(false); + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + signed int _v726 = ((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360); + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.x = pParty->vPosition.x; + pSpellSprite.vPosition.y = pParty->vPosition.y; + pSpellSprite.uAttributes = 0; + pSpellSprite.vPosition.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2; + pSpellSprite.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, + pParty->vPosition.z + (signed int)pParty->uPartyHeight / 2); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + if ( pParty->bTurnBasedModeOn == 1 ) + LOBYTE(pSpellSprite.uAttributes) |= 4; + v188 = (signed int)_v726 / -2; + v189 = (signed int)_v726 / 2; + if ( v188 <= v189 ) + { + do + { + pSpellSprite.uFacing = v188 + v715.uYawAngle; + if ( pSpellSprite.Create(pSpellSprite.uFacing, v715.uPitchAngle, + pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed, pCastSpell->uPlayerID + 1) != -1 + && pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + v188 += _v726 / (amount - 1); + } + while ( v188 <= v189 ); + } + spell_sound_flag = true; + break; + } + case SPELL_DARK_CONTROL_UNDEAD://Ãëàâà íåæèòè + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + switch (skill_level) + { + case 1: duration = 180 * spell_level; break; + case 2: duration = 180 * spell_level; break; + case 3: duration = 300 * spell_level; break; + case 4: duration = 29030400; break; + default: + assert(false); + } + if (PID_TYPE(a2) == OBJECT_Actor) + { + mon_id = PID_ID(a2); + if ( !MonsterStats::BelongsToSupertype(pActors[mon_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) + break; + if ( !pActors[mon_id].DoesDmgTypeDoDamage((DAMAGE_TYPE)10) ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + pActors[mon_id].pActorBuffs[ACTOR_BUFF_BERSERK].Reset(); + pActors[mon_id].pActorBuffs[ACTOR_BUFF_CHARM].Reset(); + pActors[mon_id].pActorBuffs[ACTOR_BUFF_ENSLAVED].Apply(pParty->uTimePlayed + + (signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, 0, 0, 0); + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.vPosition.x = pActors[mon_id].vPosition.x; + pSpellSprite.vPosition.y = pActors[mon_id].vPosition.y; + pSpellSprite.vPosition.z = pActors[mon_id].vPosition.z + pActors[mon_id].uActorHeight; + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = pIndoor->GetSector(pActors[mon_id].vPosition.x, pActors[mon_id].vPosition.y, pSpellSprite.vPosition.z); + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.spell_target_pid = a2; + pSpellSprite.field_60_distance_related_prolly_lod = LOBYTE(v715.uDistance); + pSpellSprite.uFacing = LOWORD(v715.uYawAngle); + LOBYTE(pSpellSprite.uAttributes) |= 0x80; + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + pSpellSprite.Create(0, 0, 0, pCastSpell->uPlayerID + 1); + } + spell_sound_flag = true; + break; + } + case SPELL_DARK_SACRIFICE://Æåðòâà + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + int hired_npc = 0; + memset(&achieved_awards, 0, 4000); + for ( uint npc_id = 0; npc_id < 2; npc_id++ ) //êîëè÷åñòâî íàíÿòûõ ÍÏÑ + { + if ( pParty->pHirelings[npc_id].pName != 0) + achieved_awards[hired_npc++] = (AwardType)(npc_id + 1); + } + /*if ( (signed int)pNPCStats->uNumNewNPCs > 0) + { + //AwardType *_v734 = &achieved_awards[_v733]; + for ( int npc_id = 0; npc_id < pNPCStats->uNumNewNPCs; ++npc_id ) + { + if ( pNPCStats->pNewNPCData[npc_id].uFlags & 0x80//hired(íà¸ìíûé) + && (!pParty->pHirelings[0].pName + || strcmp(pNPCStats->pNewNPCData[npc_id].pName, pParty->pHirelings[0].pName)) + && (!pParty->pHirelings[1].pName + || strcmp(pNPCStats->pNewNPCData[npc_id].pName, pParty->pHirelings[1].pName)) ) + { + //v607 = _v734; + //++_v734; + achieved_awards[hired_npc++] = (AwardType)(npc_id + 3); + } + } + }*/ + if ( pCastSpell->uPlayerID_2 != 4 && pCastSpell->uPlayerID_2 != 5 + || achieved_awards[pCastSpell->uPlayerID_2 - 4] <= 0 || achieved_awards[pCastSpell->uPlayerID_2 - 4] >= 3 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + pParty->pHirelings[achieved_awards[pCastSpell->uPlayerID_2 - 4] - 1].evt_A = 1; + pParty->pHirelings[achieved_awards[pCastSpell->uPlayerID_2 - 4] - 1].evt_B = 0; + pParty->pHirelings[achieved_awards[pCastSpell->uPlayerID_2 - 4] - 1].evt_C = pIconsFrameTable->GetIconAnimLength(pIconsFrameTable->FindIcon("spell96")); + for ( uint pl_id = 0; pl_id < 4; pl_id++ ) + { + pParty->pPlayers[pl_id].sHealth = pParty->pPlayers[pl_id].GetMaxHealth(); + pParty->pPlayers[pl_id].sMana = pParty->pPlayers[pl_id].GetMaxMana(); + } + v613 = &pOutdoor->ddm; + if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor) + v613 = &pIndoor->dlv; + v613->uReputation += 15; + if ( v613->uReputation > 10000 ) + v613->uReputation = 10000; + spell_sound_flag = true; + break; + } + case SPELL_DARK_PAIN_REFLECTION://Îòðàæåíèå áîëè + { + switch (skill_level) + { + case 1: duration = 300 * (spell_level + 12); break; + case 2: duration = 300 * (spell_level + 12); break; + case 3: duration = 300 * (spell_level + 12); break; + case 4: duration = 900 * (spell_level + 4); break; + default: + assert(false); + } + amount = spell_level + 5; + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + if ( skill_level != 3 && skill_level != 4 ) + { + 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)duration << 7) * 0.033333335), skill_level, amount, 0, 0); + spell_sound_flag = true; + break; + } + for ( uint pl_id = 0; pl_id < 4; pl_id++ ) + { + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_id); + pParty->pPlayers[pl_id].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + + (signed int)(signed __int64)((double)(signed int)((int)duration << 7) * 0.033333335), skill_level, amount, 0, 0); + } + spell_sound_flag = true; + break; + } + case SPELL_DARK_SOULDRINKER://Èñïèòü äóøó + { + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pGame->GetIndoorCamera(); + int mon_num = pRenderer->_46À6ÀÑ_GetActorsInViewport((signed __int64)pGame->pIndoorCameraD3D->GetPickDepth()); + v707.x = 0; + v707.y = 0; + v707.z = 0; + pSpellSprite.stru_24.Reset(); + pSpellSprite.spell_id = pCastSpell->uSpellID; + pSpellSprite.spell_level = spell_level; + pSpellSprite.spell_skill = skill_level; + pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); + pSpellSprite.uAttributes = 0; + pSpellSprite.uSectorID = 0; + pSpellSprite.uSpriteFrameID = 0; + pSpellSprite.field_60_distance_related_prolly_lod = 0; + pSpellSprite.uFacing = 0; + pSpellSprite.spell_caster_pid = PID(OBJECT_Player, pCastSpell->uPlayerID); + pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); + amount = 0; + if ( mon_num > 0 ) + { + amount = (mon_num * (7 * spell_level + 25)); + for ( uint mon_id = 0; mon_id < mon_num; mon_id++ ) + { + pSpellSprite.vPosition.x = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.x; + pSpellSprite.vPosition.y = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.y; + pSpellSprite.vPosition.z = pActors[_50BF30_actors_in_viewport_ids[mon_id]].vPosition.z - + (unsigned int)(signed __int64)((double)pActors[_50BF30_actors_in_viewport_ids[mon_id]].uActorHeight * -0.8); + pSpellSprite.spell_target_pid = PID(OBJECT_Actor, _50BF30_actors_in_viewport_ids[mon_id]); + Actor::DamageMonsterFromParty(PID(OBJECT_Item, pSpellSprite.Create(0, 0, 0, 0)), _50BF30_actors_in_viewport_ids[mon_id], &v707); + } + } + int pl_num = 0; + int pl_array[4]; + for ( uint pl_id = 1; pl_id <= 4; ++pl_id ) + { + if ( !pPlayers[pl_id]->pConditions[Condition_Sleep] && !pPlayers[pl_id]->pConditions[Condition_Paralyzed] + && !pPlayers[pl_id]->pConditions[Condition_Unconcious] && !pPlayers[pl_id]->pConditions[Condition_Dead] + && !pPlayers[pl_id]->pConditions[Condition_Pertified] && !pPlayers[pl_id]->pConditions[Condition_Eradicated] ) + { + pl_array[pl_num++] = pl_id; + } + } + for ( uint j = 0; j < pl_num; j++ ) + { + pPlayers[pl_array[j]]->sHealth += (signed __int64)((double)(signed int)amount / (double)pl_num); + if ( pPlayers[pl_array[j]]->sHealth > pPlayers[pl_array[j]]->GetMaxHealth()) + pPlayers[pl_array[j]]->sHealth = pPlayers[pl_array[j]]->GetMaxHealth(); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pl_array[j]); + } + pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0, 64); + spell_sound_flag = true; + break; + } + case SPELL_DARK_ARMAGEDDON://Àðìàãåääîí + { + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[499], 2); // Can't cast Armageddon indoors! + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if ( skill_level == 4) + amount = 4; + else + amount = 3; + if ( pPlayer->uNumArmageddonCasts >= amount || pParty->armageddon_timer > 0 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed + pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); + pCastSpell->uSpellID = 0; + continue; + } + if ( !pPlayer->CanCastSpell(uRequiredMana) ) + break; + pParty->armageddon_timer = 256; + pParty->armageddonDamage = spell_level; + ++pPlayer->uNumArmageddonCasts; + if ( pParty->bTurnBasedModeOn == 1 ) + ++pTurnEngine->pending_actions; + for ( uint i = 0; i < 50; i++ ) + { + v642 = rand() % 4096 - 2048; + v643 = rand(); + v732 = GetTerrainHeightsAroundParty2(v642 + pParty->vPosition.x, pParty->vPosition.y + (v643 % 4096 - 2048), &v710, 0); + SpriteObject::sub_42F7EB_DropItemAt(4070, v642 + pParty->vPosition.x, pParty->vPosition.y + (v643 % 4096 - 2048), v732 + 16, rand() % 500 + 500, 1, 0, 0, 0); + } + spell_sound_flag = true; + break; + } + default: + break; + } + if ( pCastSpell->uFlags & 0x20 ) + { + if ( spell_sound_flag ) + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->uSpellID], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0); + } + else + { + if ( sRecoveryTime < 0 ) + sRecoveryTime = 0; + if ( pParty->bTurnBasedModeOn ) + { + //v645 = sRecoveryTime; + pParty->pTurnBasedPlayerRecoveryTimes[pCastSpell->uPlayerID] = sRecoveryTime; + pPlayer->SetRecoveryTime(sRecoveryTime); + if ( !some_active_character ) + pTurnEngine->ApplyPlayerAction(); + } + else + pPlayer->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)sRecoveryTime * 2.133333333333333)); + if ( spell_sound_flag ) + { + pPlayer->PlaySound(SPEECH_49, 0); + //if ( spell_sound_flag ) + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->uSpellID], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0); + } + } + pCastSpell->uSpellID = 0; + spell_level = v723; + continue; + } + +} +//----- (00427DA0) -------------------------------------------------------- +size_t PushCastSpellInfo(uint16_t uSpellID, uint16_t uPlayerID, __int16 skill_level, uint16_t uFlags, int spell_sound_id) +{ + for (size_t i = 0; i < CastSpellInfoCount; i++) + { + if (!pCastSpellInfo[i].uSpellID) + { + 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 CastSpellInfoHelpers::_427D48() +{ + for (size_t i = 0; i < CastSpellInfoCount; i++) + { + if (pCastSpellInfo[i].uSpellID && pCastSpellInfo[i].uFlags & 0x3CA) + { + pCastSpellInfo[i].uSpellID = 0; + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + } + } +} +//----- (0042777D) -------------------------------------------------------- +void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6) +{ + unsigned __int16 v9; // cx@16 + unsigned int v10; // eax@18 + unsigned __int8 v11; // sf@18 + unsigned __int8 v12; // of@18 + unsigned __int16 v13; // cx@21 + unsigned int v14; // eax@23 + + //if ( pParty->bTurnBasedModeOn != 1 + // || (result = pTurnEngine->field_4, pTurnEngine->field_4 != 1) && pTurnEngine->field_4 != 3 ) + if (pParty->bTurnBasedModeOn) + { + if ( pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_MOVEMENT ) + return; + } + + + //v6 = a5; + //v7 = &pParty->pPlayers[uPlayerID]; + assert(uPlayerID < 4); + Player* player = &pParty->pPlayers[uPlayerID]; + if ( !(a5 & 0x10) ) + { + switch ( a1 ) + { + case SPELL_SPIRIT_FATE: + case SPELL_BODY_FIRST_AID: + case SPELL_DARK_REANIMATE: + //HIBYTE(v6) = HIBYTE(a5) | 1; + a5 |= 0x0100; + break; + + case SPELL_FIRE_FIRE_AURA: + case SPELL_WATER_RECHARGE_ITEM: + case SPELL_WATER_ENCHANT_ITEM: + case SPELL_DARK_VAMPIRIC_WEAPON: + //LOBYTE(v6) = a5 | 0x80; + a5 |= 0x0080; + break; + + case SPELL_FIRE_FIRE_BOLT: + case SPELL_FIRE_FIREBALL: + case SPELL_FIRE_INCINERATE: + case SPELL_AIR_LIGHNING_BOLT: + case SPELL_AIR_IMPLOSION: + case SPELL_WATER_POISON_SPRAY: + case SPELL_WATER_ICE_BOLT: + case SPELL_WATER_ACID_BURST: + case SPELL_WATER_ICE_BLAST: + case SPELL_EARTH_STUN: + case SPELL_EARTH_SLOW: + case SPELL_EARTH_DEADLY_SWARM: + case SPELL_EARTH_BLADES: + case SPELL_EARTH_MASS_DISTORTION: + case SPELL_SPIRIT_SPIRIT_LASH: + case SPELL_MIND_MIND_BLAST: + case SPELL_MIND_CHARM: + case SPELL_MIND_PSYCHIC_SHOCK: + case SPELL_BODY_HARM: + case SPELL_BODY_FLYING_FIST: + case SPELL_LIGHT_LIGHT_BOLT: + case SPELL_LIGHT_DESTROY_UNDEAD: + case SPELL_LIGHT_SUNRAY: + case SPELL_DARK_TOXIC_CLOUD: + case SPELL_DARK_SHRINKING_RAY: + case SPELL_DARK_SHARPMETAL: + case SPELL_DARK_DRAGON_BREATH: + if ( !a6 ) + a5 |= 0x0008; + break; + case SPELL_MIND_TELEPATHY: + case SPELL_MIND_BERSERK: + case SPELL_MIND_ENSLAVE: + case SPELL_LIGHT_PARALYZE: + case SPELL_DARK_CONTROL_UNDEAD: +//LABEL_9: + //v6 = a5 | 8; + a5 |= 0x0008; + break; + + case SPELL_EARTH_TELEKINESIS: + a5 |= 0x0040; + break; + + case SPELL_SPIRIT_BLESS: + if (a4 && ~a4 & 0x01C0) + //goto LABEL_25; + { + a5 |= 0x0002; + break; + } + else if ((player->pActiveSkills[PLAYER_SKILL_SPIRIT] & 0x1C0) == 0) + //goto LABEL_25; + { + a5 |= 0x0002; + break; + } + break; + + case SPELL_SPIRIT_PRESERVATION: + v9 = a4; + if ( !a4 ) + v9 = player->pActiveSkills[PLAYER_SKILL_SPIRIT]; + //goto LABEL_18; + v10 = SkillToMastery(v9); + v12 = __OFSUB__(v10, 3); + v11 = ((v10 - 3) & 0x80000000u) != 0; + //goto LABEL_24; + if ( v11 ^ v12 ) + { + a5 |= 0x0002; + break; + } + break; + + case SPELL_DARK_PAIN_REFLECTION: + v9 = a4; + if ( !a4 ) + v9 = player->pActiveSkills[PLAYER_SKILL_DARK]; +//LABEL_18: + v10 = SkillToMastery(v9); + v12 = __OFSUB__(v10, 3); + v11 = ((v10 - 3) & 0x80000000u) != 0; + //goto LABEL_24; + if ( v11 ^ v12 ) + { + a5 |= 0x0002; + break; + } + break; + + case SPELL_BODY_HAMMERHANDS: + v13 = a4; + if ( !a4 ) + v13 = player->pActiveSkills[PLAYER_SKILL_BODY]; + v14 = SkillToMastery(v13); + v12 = __OFSUB__(v14, 4); + v11 = ((v14 - 4) & 0x80000000u) != 0; +//LABEL_24: + if ( v11 ^ v12 ) + //goto LABEL_25; + { + a5 |= 0x0002; + break; + } + break; + + case SPELL_EARTH_STONE_TO_FLESH: + case SPELL_SPIRIT_REMOVE_CURSE: + case SPELL_SPIRIT_RAISE_DEAD: + case SPELL_SPIRIT_RESSURECTION: + case SPELL_MIND_REMOVE_FEAR: + case SPELL_MIND_CURE_PARALYSIS: + case SPELL_MIND_CURE_INSANITY: + case SPELL_BODY_CURE_WEAKNESS: + case SPELL_BODY_REGENERATION: + case SPELL_BODY_CURE_POISON: + case SPELL_BODY_CURE_DISEASE: +//LABEL_25: + //v6 = a5 | 2; + a5 |= 0x0002; + break; + + case SPELL_DARK_SACRIFICE: + //HIBYTE(v6) = HIBYTE(a5) | 2; + a5 |= 0x0200; + break; + default: + break; + } + } + + + if (a5 & 0x3CA) + { + for (uint i = 0; i < CastSpellInfoCount; ++i) + if (pCastSpellInfo[i].uFlags & 0x3CA) + { + pCastSpellInfo[i].uSpellID = 0; + break; + } + } + + for (uint i = 0; i < CastSpellInfoCount; ++i) + { + CastSpellInfo* spell = &pCastSpellInfo[i]; + if (!spell->uSpellID) + continue; + + spell->uSpellID = 0; + if (spell->uFlags & 0x3CA) + { + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = nullptr; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + _50C9A0_IsEnchantingInProgress = 0; + back_to_game(); + } + } + + int result = PushCastSpellInfo(a1, uPlayerID, a4, a5, a6); + if ( result != -1 ) + { + if ( a5 & 2 ) + { + if ( pGUIWindow_Settings ) + return; + pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0); + pGUIWindow_Settings->CreateButton(52, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 0, 49, "", 0); + pGUIWindow_Settings->CreateButton(165, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 1, 50, "", 0); + pGUIWindow_Settings->CreateButton(280, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 2, 51, "", 0); + pGUIWindow_Settings->CreateButton(390, 422, 35, 0, 2, 0, UIMSG_CastSpell_Character_Big_Improvement, 3, 52, "", 0); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); + return; + } + if ( a5 & 8 ) + { + if ( pGUIWindow_Settings ) + return; + + pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0); + pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Shoot_Monster, 0, 0, "", 0); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); + return; + } + if ( a5 & 0x40 ) + { + if ( pGUIWindow_Settings ) + return; + + pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0); + pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Telekinesis, 0, 0, "", 0); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); + return; + } + if ( (char)a5 < 0 ) + { + if ( pGUIWindow_Settings ) + return; + ++pIcons_LOD->uTexturePacksCount; + if ( !pIcons_LOD->uNumPrevLoadedFiles ) + pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; + pGUIWindow_Settings = pCastSpellInfo[result].GetCastSpellInInventoryWindow(); + _50C9A0_IsEnchantingInProgress = 1; + some_active_character = uActiveCharacter; + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); + return; + } + if ( HIBYTE(a5) & 1 ) + { + if ( pGUIWindow_Settings ) + return; + pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0); + pGUIWindow_Settings->CreateButton(0x34u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 0, 0x31u, "", 0); + pGUIWindow_Settings->CreateButton(0xA5u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 1, 0x32u, "", 0); + pGUIWindow_Settings->CreateButton(0x118u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 2, 0x33u, "", 0); + pGUIWindow_Settings->CreateButton(0x186u, 0x1A6u, 0x23u, 0, 2, 0, UIMSG_CastSpell_Character_Small_Improvement, 3, 0x34u, "", 0); + pGUIWindow_Settings->CreateButton(8, 8, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Monster_Improvement, 0, 0, "", NULL); + pParty->sub_421B2C_PlaceInInventory_or_DropPickedItem(); + } + if ( HIBYTE(a5) & 2 && !pGUIWindow_Settings ) + { + pGUIWindow_Settings = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0); + pBtn_NPCLeft = pGUIWindow_Settings->CreateButton(469, 178, + pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureWidth, + pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureHeight, + 1, 0, UIMSG_ScrollNPCPanel, 0, 0, "", + pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft), 0); + pBtn_NPCRight = pGUIWindow_Settings->CreateButton(626, 178, + pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureWidth, + pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureHeight, + 1, 0, UIMSG_ScrollNPCPanel, 1, 0, "", + pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight), 0); + pGUIWindow_Settings->CreateButton(491, 149, 64, 74, 1, 0, UIMSG_HiredNPC_CastSpell, 4, 0x35u, "", 0); + pGUIWindow_Settings->CreateButton(561, 149, 64, 74, 1, 0, UIMSG_HiredNPC_CastSpell, 5, 0x36u, "", 0); + } + } +} diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Spells/CastSpellInfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Spells/CastSpellInfo.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,36 @@ +#pragma once + +#include + +#include + +namespace CastSpellInfoHelpers +{ + void _427D48(); + void _427E01_cast_spell(); +}; + +/* 271 */ +#pragma pack(push, 1) +struct CastSpellInfo +{ + //----- (00426987) -------------------------------------------------------- + inline CastSpellInfo() + { + memset(this, 0, sizeof(*this)); + } + + struct GUIWindow *GetCastSpellInInventoryWindow(); + + uint16_t uSpellID; + uint16_t uPlayerID; + uint16_t uPlayerID_2; + __int16 field_6; + uint16_t uFlags; + __int16 forced_spell_skill_level; + int spell_target_pid; + int sound_id; +}; +#pragma pack(pop) + +void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6); \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Spells/Spells.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Spells/Spells.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,741 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include +#include "../ErrorHandling.h" + +#include "Spells.h" +#include "Engine/Graphics/Overlays.h" +#include "../LOD.h" +#include "../texts.h" + +#include "../Party.h" +#include "../OurMath.h" +#include "Engine/Objects/SpriteObject.h" +#include "Engine/Objects/ObjectList.h" +#include "Engine/Graphics/Indoor.h" +#include "AudioPlayer.h" +#include "Engine/Objects/Actor.h" +#include "../Game.h" +#include "stru6.h" + + +std::array TownPortalList = //4ECBB8 +{{ + {Vec3_int_(-5121, 2107, 1), 1536, 0, 21, 0}, + {Vec3_int_(-15148, -10240, 1473), 0, 0, 4, 0}, + {Vec3_int_(-10519, 5375, 753), 512, 0, 3, 0}, + {Vec3_int_(3114, -11055, 513), 0, 0, 10, 0}, + {Vec3_int_(-158, 7624, 1), 512, 0, 7, 0}, + {Vec3_int_(-1837, -4247, 65), 65, 0, 8, 0} +}} ; + +struct SpellStats *pSpellStats; + + +std::array stru_4E3ACC = +{{ + {10, 0}, + {1000, 0}, {1010, 0}, {1020, 0}, {1030, 0}, {1040, 0}, {1050, 0}, {1060, 0}, {1070, 0}, {1080, 0}, {1090, 0}, {1100, 0}, + {2000, 0}, {2010, 0}, {2020, 0}, {2030, 0}, {2040, 0}, {2050, 0}, {2060, 0}, {2070, 0}, {2080, 0}, {2090, 0}, {2100, 0}, + {3000, 0}, {3010, 0}, {3020, 0}, {3030, 0}, {3040, 0}, {3050, 0}, {3060, 0}, {3070, 0}, {3080, 0}, {3090, 0}, {3100, 0}, + {4000, 0}, {4010, 0}, {4020, 0}, {4030, 0}, {4040, 0}, {4050, 0}, {4060, 0}, {4070, 0}, {4080, 0}, {4090, 0}, {4100, 0}, + {5000, 0}, {5010, 0}, {5020, 0}, {5030, 0}, {5040, 0}, {5050, 0}, {5060, 0}, {5070, 0}, {5080, 0}, {5090, 0}, {5100, 0}, + {6000, 0}, {6010, 0}, {6020, 0}, {6030, 0}, {6040, 0}, {6050, 0}, {6060, 0}, {6070, 0}, {6080, 0}, {6090, 0}, {6100, 0}, + {7000, 0}, {7010, 0}, {7020, 0}, {7030, 0}, {7040, 0}, {7050, 0}, {7060, 0}, {7070, 0}, {7080, 0}, {7090, 0}, {7100, 0}, + {8000, 0}, {8010, 0}, {8020, 0}, {8030, 0}, {8040, 0}, {8050, 0}, {8060, 0}, {8070, 0}, {8080, 0}, {8090, 0}, {8100, 0}, + {9000, 0}, {9010, 0}, {9020, 0}, {9030, 0}, {9040, 0}, {9050, 0}, {9060, 0}, {9070, 0}, {9080, 0}, {9090, 0}, {9100, 0}, + {545, 0}, + {545, 0}, + {555, 0} +}}; + + + +SpellData::SpellData( __int16 innormalMana, __int16 inExpertLevelMana, __int16 inMasterLevelMana, __int16 inMagisterLevelMana, + __int16 inNormalLevelRecovery, __int16 inExpertLevelRecovery, __int16 inMasterLevelRecovery, __int16 inMagisterLevelRecovery, + __int8 inbaseDamage, __int8 inbonusSkillDamage, __int16 instats ): +uNormalLevelMana(innormalMana), +uExpertLevelMana(inExpertLevelMana), +uMasterLevelMana(inMasterLevelMana), +uMagisterLevelMana(inMagisterLevelMana), +uNormalLevelRecovery(inNormalLevelRecovery), +uExpertLevelRecovery(inExpertLevelRecovery), +uMasterLevelRecovery(inMasterLevelRecovery), +uMagisterLevelRecovery(inMagisterLevelRecovery), +baseDamage(inbaseDamage), +bonusSkillDamage(inbonusSkillDamage), +stats(instats) +{ + +} + + //9 spellbook pages 11 spells per page 9*11 =99 +1 zero struct at 0. It counted from 1! +std::array pSpellDatas={{ + SpellData(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), + + SpellData(1, 1, 1, 1, 60, 60, 60, 40, 0, 0, 0),//0 fire + SpellData(2, 2, 2, 2, 110, 110, 100, 90, 3, 3, 0), + SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), + SpellData(4, 4, 4, 4, 120, 120, 120, 120, 0, 0, 0), + SpellData(5, 5, 5, 5, 120, 120, 120, 120, 0, 0, 0), + SpellData(8, 8, 8, 8, 100, 100, 90, 80, 0, 6, 0), + SpellData(10, 10, 10, 10, 150, 150, 150, 150, 0, 6, 0), + SpellData(15, 15, 15, 15, 120, 120, 120, 120, 0, 6, 0), + SpellData(20, 20, 20, 20, 100, 100, 100, 90, 8, 1, 0), + SpellData(25, 25, 25, 25, 100, 100, 100, 90, 12, 1, 0), + SpellData(30, 30, 30, 30, 90, 90, 90, 90, 15, 15, 0), + + SpellData(1, 1, 1, 0, 60, 60, 60, 60, 0, 0, 0), //1 air + SpellData(2, 2, 2, 2, 120, 120, 120, 100, 0, 0, 0), + SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), + SpellData(4, 4, 4, 4, 110, 100, 90, 80, 2, 1, 0), + SpellData(5, 5, 5, 5, 90, 90, 70, 50, 0, 0, 0), + SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0), + SpellData(10, 10, 10, 10, 100, 100, 90, 70, 0, 8, 0), + SpellData(15, 15, 15, 15, 200, 200, 200, 200, 0, 0, 0), + SpellData(20, 20, 20, 20, 100, 100, 100, 90, 10, 10, 0), + SpellData(25, 25, 25, 25, 250, 250, 250, 250, 0, 0, 0), + SpellData(30, 30, 30, 30, 90, 90, 90, 90, 20, 1, 0), + + SpellData(1, 1, 1, 1, 60, 60, 60, 20, 0, 0, 0), //2 water + SpellData(2, 2, 2, 2, 110, 100, 90, 70, 2, 2, 0), + SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), + SpellData(4, 4, 4, 4, 110, 100, 90, 80, 0, 4, 0), + SpellData(5, 5, 5, 5, 150, 150, 150, 150, 0, 0, 0), + SpellData(8, 8, 8, 8, 200, 200, 200, 200, 0, 0, 0), + SpellData(10, 10, 10, 10, 100, 100, 90, 80, 9, 9, 0), + SpellData(15, 15, 15, 15, 140, 140, 140, 140, 0, 0, 0), + SpellData(20, 20, 20, 20, 200, 200, 200, 200, 0, 0, 0), + SpellData(25, 25, 25, 25, 80, 80, 80, 80, 12, 3, 0), + SpellData(30, 30, 30, 30, 250, 250, 250, 250, 0, 0, 0), + + SpellData(1, 1, 1, 1, 80, 80, 80, 80, 0, 0, 0), //3 earth + SpellData(2, 2, 2, 2, 100, 100, 100, 100, 0, 0, 0), + SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), + SpellData(4, 4, 4, 4, 110, 100, 90, 80, 5, 3, 0), + SpellData(5, 5, 5, 5, 120, 120, 120, 120, 0, 0, 0), + SpellData(8, 8, 8, 8, 100, 100, 90, 80, 0, 9, 0), + SpellData(10, 10, 10, 10, 140, 140, 140, 140, 0, 0, 0), + SpellData(15, 15, 15, 15, 90, 90, 90, 80, 0, 8, 0), + SpellData(20, 20, 20, 20, 150, 150, 150, 150, 0, 0, 0), + SpellData(25, 25, 25, 25, 100, 100, 100, 90, 20, 1, 0), + SpellData(30, 30, 30, 30, 90, 90, 90, 90, 25, 0, 0), + + SpellData(1, 1, 1, 1, 100, 100, 100, 100, 0, 0, 0), //4 spirit + SpellData(2, 2, 2, 2, 100, 100, 100, 100, 0, 0, 0), + SpellData(3, 3, 3, 3, 90, 90, 90, 90, 0, 0, 0), + SpellData(4, 4, 4, 4, 120, 120, 120, 120, 0, 0, 0), + SpellData(5, 5, 5, 5, 120, 120, 120, 120, 0, 0, 0), + SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0), + SpellData(10, 10, 10, 10, 120, 120, 120, 120, 0, 0, 0), + SpellData(15, 15, 15, 15, 100, 100, 100, 100, 10, 8, 0), + SpellData(20, 20, 20, 20, 240, 240, 240, 240, 0, 0, 0), + SpellData(25, 25, 25, 25, 150, 150, 150, 150, 0, 0, 0), + SpellData(30, 30, 30, 30, 1000, 1000, 1000, 1000, 0, 0, 0), + + SpellData(1, 1, 1, 1, 120, 120, 120, 120, 0, 0, 0), //5 mind + SpellData(2, 2, 2, 2, 110, 110, 110, 110, 3, 3, 0), + SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), + SpellData(4, 4, 4, 4, 110, 100, 90, 80, 0, 0, 0), + SpellData(5, 5, 5, 5, 100, 100, 100, 100, 0, 0, 0), + SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0), + SpellData(10, 10, 10, 10, 120, 120, 120, 120, 0, 0, 0), + SpellData(15, 15, 15, 15, 80, 80, 80, 80, 0, 0, 0), + SpellData(20, 20, 20, 20, 120, 120, 120, 120, 0, 0, 0), + SpellData(25, 25, 25, 25, 110, 110, 110, 100, 12, 12, 0), + SpellData(30, 30, 30, 30, 120, 120, 120, 120, 0, 0, 0), + + SpellData(1, 1, 1, 1, 120, 120, 120, 120, 0, 0, 0), //6 body + SpellData(2, 2, 2, 2, 100, 100, 100, 100, 0, 0, 0), + SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), + SpellData(4, 4, 4, 4, 110, 100, 90, 80, 8, 2, 0), + SpellData(5, 5, 5, 5, 110, 110, 110, 110, 0, 0, 0), + SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0), + SpellData(10, 10, 10, 10, 120, 120, 120, 120, 0, 0, 0), + SpellData(15, 15, 15, 15, 120, 120, 120, 120, 0, 0, 0), + SpellData(20, 20, 20, 20, 120, 120, 120, 120, 0, 0, 0), + SpellData(25, 25, 25, 25, 110, 110, 110, 100, 30, 5, 0), + SpellData(30, 30, 30, 30, 100, 100, 100, 100, 0, 0, 0), + + SpellData(5, 5, 5, 5, 110, 100, 90, 80, 0, 4, 0), //7 light + SpellData(10, 10, 10, 10, 120, 110, 100, 90, 16, 16, 0), + SpellData(15, 15, 15, 15, 120, 110, 100, 90, 0, 0, 0), + SpellData(20, 20, 20, 20, 160, 140, 120, 100, 0, 0, 0), + SpellData(25, 25, 25, 25, 140, 140, 140, 140, 0, 0, 0), + SpellData(30, 30, 30, 30, 500, 500, 500, 500, 0, 0, 0), + SpellData(35, 35, 35, 35, 135, 135, 120, 100, 25, 1, 0), + SpellData(40, 40, 40, 40, 500, 500, 500, 500, 0, 0, 0), + SpellData(45, 45, 45, 45, 250, 250, 250, 250, 0, 0, 0), + SpellData(50, 50, 50, 50, 150, 150, 150, 135, 20, 20, 0), + SpellData(55, 55, 55, 55, 300, 300, 300, 300, 0, 0, 0), + + SpellData(10, 10, 10, 10, 140, 140, 140, 140, 0, 0, 0), //8 dark + SpellData(15, 15, 15, 15, 120, 110, 100, 90, 25, 10, 0), + SpellData(20, 20, 20, 20, 120, 100, 90, 120, 0, 0, 0), + SpellData(25, 25, 25, 25, 120, 120, 120, 120, 0, 0, 0), + SpellData(30, 30, 30, 30, 90, 90, 80, 70, 6, 6, 0), + SpellData(35, 35, 35, 35, 120, 120, 100, 80, 0, 0, 0), + SpellData(40, 40, 40, 40, 110, 110, 110, 110, 0, 0, 0), + SpellData(45, 45, 45, 45, 200, 200, 200, 150, 0, 0, 0), + SpellData(50, 50, 50, 50, 120, 120, 120, 100, 0, 25, 0), + SpellData(55, 55, 55, 55, 250, 250, 250, 250, 50, 1, 0), + SpellData(60, 60, 60, 60, 300, 300, 300, 300, 25, 8, 0) + }}; + +std::array wand_spell_ids = +{ +// 135 Wand of Fire 136 Wand of Sparks 137 Wand of Poison 138 Wand of Stunning 139 Wand of Harm + SPELL_FIRE_FIRE_BOLT, SPELL_AIR_SPARKS, SPELL_WATER_POISON_SPRAY, SPELL_EARTH_STUN, SPELL_BODY_HARM, +// 140 Fairy Wand of Light 141 Fairy Wand of Ice 142 Fairy Wand of Lashing 143 Fairy Wand of Mind 144 Fairy Wand of Swarms + SPELL_LIGHT_LIGHT_BOLT, SPELL_WATER_ICE_BOLT, SPELL_SPIRIT_SPIRIT_LASH, SPELL_MIND_MIND_BLAST, SPELL_EARTH_DEADLY_SWARM, +// 145 Alacorn Wand of Fireballs 146 Alacorn Wand of Acid 147 Alacorn Wand of Lightning 148 Alacorn Wand of Blades 149 Alacorn Wand of Charms + SPELL_FIRE_FIREBALL, SPELL_WATER_ACID_BURST, SPELL_AIR_LIGHNING_BOLT, SPELL_EARTH_BLADES, SPELL_MIND_CHARM, +// 150 Arcane Wand of Blasting 151 Arcane Wand of The Fist 152 Arcane Wand of Rocks 153 Arcane Wand of Paralyzing 154 Arcane Wand of Clouds + SPELL_WATER_ICE_BLAST, SPELL_BODY_FLYING_FIST, SPELL_EARTH_ROCK_BLAST, SPELL_LIGHT_PARALYZE, SPELL_DARK_TOXIC_CLOUD, +// 155 Mystic Wand of Implosion 156 Mystic Wand of Distortion 157 Mystic Wand of Sharpmetal 158 Mystic Wand of Shrinking 159 Mystic Wand of Incineration + SPELL_AIR_IMPLOSION, SPELL_EARTH_MASS_DISTORTION, SPELL_DARK_SHARPMETAL, SPELL_DARK_SHRINKING_RAY, SPELL_FIRE_INCINERATE +}; + + +std::array, 9> pSpellbookSpellIndices = // 4E2430 + {{ //0 1 2 3 4 5 6 7 8 9 10 11 + {0, 3, 1, 8, 11, 7, 4, 10, 6, 2, 5, 9}, + {0, 11, 2, 9, 6, 8, 5, 10, 3, 7, 1, 4}, + {0, 4, 8, 9, 1, 10, 3, 11, 7, 6, 2, 5}, + {0, 7, 10, 8, 2, 11, 1, 5, 3, 6, 4, 9}, + {0, 5, 10, 11, 7, 2, 8, 1, 4, 9, 3, 6}, + {0, 5, 9, 8, 3, 7, 6, 4, 1, 11, 2, 10}, + {0, 1, 6, 9, 3, 5, 8, 11, 7, 10, 4, 2}, + {0, 1, 10, 11, 9, 4, 3, 6, 5, 7, 8, 2}, + {0, 9, 3, 7, 1, 5, 2, 10, 11, 8, 6, 4} +}}; + + std::array, 9> pIconPos={{ + + { 0, 0, 17, 13, 115, 2, 217, 15, + 299, 6, 28, 125, 130, 133, 294, 114, + 11, 232, 134, 233, 237, 171, 296, 231}, + + { 0, 0, 19, 9, 117, 3, 206, 13, + 285, 7, 16, 123, 113, 101, 201, 118, + 317, 110, 11, 230, 149, 236, 296, 234}, + + { 0, 0, 17, 9, 140, 0, 210, 34, + 293, 5, 15, 98, 78, 121, 175, 136, + 301, 115, 15, 226, 154, 225, 272, 220}, + + { 0, 0, 7, 9, 156, 2, 277, 9, + 11, 117, 111, 82, 180, 102, 303, 108, + 10, 229, 120, 221, 201, 217, 296, 225}, + + { 0, 0, 18, 8, 89, 15, 192, 14, + 292, 7, 22, 129, 125, 146, 217, 136, + 305, 115, 22, 226, 174, 237, 290, 231}, + + { 0, 0, 18, 12, 148, 9, 292, 7, + 17, 122, 121, 99, 220, 87, 293, 112, + 13, 236, 128, 213, 220, 223, 315, 223}, + + { 0, 0, 23, 14, 127, 8, 204, 0, + 306, 8, 14, 115, 122, 132, 200, 116, + 293, 122, 20, 228, 154, 228, 294, 239}, + + { 0, 0, 19, 14, 124, 10, 283, 12, + 8, 105, 113, 89, 190, 82, 298, 108, + 18, 181, 101, 204, 204, 203, 285, 218}, + + { 0, 0, 18, 17, 110, 16, 201, 15, + 307, 15, 18, 148, 125, 166, 201, 123, + 275, 120, 28, 235, 217, 222, 324, 216}}}; + + +//----- (0042EB31) -------------------------------------------------------- +bool SpellBuff::NotExpired() +{ + return (signed __int64)this->uExpireTime > 0 ? true:false; +} + + +//----- (00458585) -------------------------------------------------------- +void SpellBuff::Reset() +{ + uSkill = 0; + uPower = 0; + uExpireTime = 0i64; + uCaster = 0; + uFlags = 0; + if (uOverlayID) + { + pOtherOverlayList->pOverlays[uOverlayID - 1].Reset(); + pOtherOverlayList->bRedraw = true; + uOverlayID = 0; + } +} + +//----- (004585CA) -------------------------------------------------------- +bool SpellBuff::IsBuffExpiredToTime( __int64 time_end ) + { + if (uExpireTime && (uExpireTime < time_end)) + { + uExpireTime = 0; + uPower = 0; + uSkill = 0; + uOverlayID = 0; + return true; + } + return false; +} + +//----- (004584E0) -------------------------------------------------------- +bool SpellBuff::Apply( signed __int64 uExpireTime, unsigned __int16 uSkillLevel, unsigned __int16 uPower, int uOverlayID, unsigned __int8 caster ) + { + if (this->uExpireTime && (uExpireTime < this->uExpireTime)) + return false; + + this->uSkill = uSkillLevel; + this->uPower = uPower; + this->uExpireTime = uExpireTime; + if (this->uOverlayID && this->uOverlayID != uOverlayID) + { + pOtherOverlayList->pOverlays[this->uOverlayID - 1].Reset(); + pOtherOverlayList->bRedraw = true; + this->uOverlayID = 0; + } + this->uOverlayID = uOverlayID; + this->uCaster = caster; + + return true; +} + +//----- (0045384A) -------------------------------------------------------- +void SpellStats::Initialize() +{ + std::map spellSchoolMaps; + spellSchoolMaps["fire"] = SPELL_SCHOOL_FIRE; + spellSchoolMaps["air"] = SPELL_SCHOOL_AIR; + spellSchoolMaps["water"] = SPELL_SCHOOL_WATER; + spellSchoolMaps["earth"] = SPELL_SCHOOL_EARTH; + spellSchoolMaps["spirit"] = SPELL_SCHOOL_SPIRIT; + spellSchoolMaps["mind"] = SPELL_SCHOOL_MIND; + spellSchoolMaps["body"] = SPELL_SCHOOL_BODY; + spellSchoolMaps["light"] = SPELL_SCHOOL_LIGHT; + spellSchoolMaps["dark"] = SPELL_SCHOOL_DARK; + spellSchoolMaps["magic"] = SPELL_SCHOOL_MAGIC; + + char* test_string; + + free(pSpellsTXT_Raw); + pSpellsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spells.txt", 0); + + strtok(pSpellsTXT_Raw, "\r"); + for(int i=1; i<100; ++i) + { + if (((i % 11) - 1 )==0) + strtok(NULL, "\r"); + test_string=strtok(NULL, "\r")+1; + auto tokens = Tokenize(test_string, '\t'); + pInfos[i].pName=RemoveQuotes(tokens[2]); + auto findResult = spellSchoolMaps.find(tokens[3]); + pInfos[i].uSchool = findResult == spellSchoolMaps.end() ? SPELL_SCHOOL_NONE : findResult->second; + pInfos[i].pShortName=RemoveQuotes(tokens[4]); + pInfos[i].pDescription=RemoveQuotes(tokens[5]); + pInfos[i].pBasicSkillDesc=RemoveQuotes(tokens[6]); + pInfos[i].pExpertSkillDesc=RemoveQuotes(tokens[7]); + pInfos[i].pMasterSkillDesc=RemoveQuotes(tokens[8]); + pInfos[i].pGrandmasterSkillDesc=RemoveQuotes(tokens[9]); + pSpellDatas[i].stats |= strchr(tokens[10], 'm') || strchr(tokens[10], 'M') ? 1 : 0; + pSpellDatas[i].stats |= strchr(tokens[10], 'e') || strchr(tokens[10], 'E') ? 2 : 0; + pSpellDatas[i].stats |= strchr(tokens[10], 'c') || strchr(tokens[10], 'C') ? 4 : 0; + pSpellDatas[i].stats |= strchr(tokens[10], 'x') || strchr(tokens[10], 'X') ? 8 : 0; + } +} +//----- (00448DF8) -------------------------------------------------------- +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 + signed __int64 v10; // st7@4 + signed __int64 v11; // st6@4 + signed __int64 v12; // st5@4 + double v13; // st7@6 + int v14; // ST44_4@7 + uint skillMasteryPlusOne; // ebx@9 + uint v16; // edx@15 + int i; // esi@42 + int j; // esi@60 + unsigned __int64 v36; // qax@99 +// SpellBuff *v37; // ecx@99 + int v38; // esi@103 + signed __int64 v39; // qax@105 + int v42; // esi@111 + int v43; // ebx@111 + int v47; // [sp-4h] [bp-B8h]@35 + int v49; // [sp+0h] [bp-B4h]@35 + int v55; // [sp+28h] [bp-8Ch]@7 + unsigned int yaw; // [sp+30h] [bp-84h]@7 + int pitch; // [sp+34h] [bp-80h]@7 + int v60; // [sp+ACh] [bp-8h]@1 + int a6_4; // [sp+C8h] [bp+14h]@117 + int a7c; // [sp+CCh] [bp+18h]@29 + int a7d; // [sp+CCh] [bp+18h]@55 + signed __int64 xSquared; // [sp+D0h] [bp+1Ch]@6 + int a8b; // [sp+D0h] [bp+1Ch]@37 + int a8c; // [sp+D0h] [bp+1Ch]@55 + signed __int64 ySquared; // [sp+D4h] [bp+20h]@6 + + v9 = 0; + skillMasteryPlusOne = uSkillLevel + 1; + //spellnum_ = uSpellID; + v60 = 0; + if ( tox || toy || toz ) + { + v10 = tox - fromx; + v11 = toy - fromy; + v12 = toz - fromz; + } + else + { + v10 = pParty->vPosition.x - fromx; + v11 = pParty->vPosition.y - fromy; + v12 = (pParty->vPosition.z + pParty->sEyelevel) - fromz; + } + v13 = sqrt(long double(v10 * v10 + v11 * v11 + v12 * v12)); + if ( v13 <= 1.0 ) + { + v55 = 1; + yaw = 0; + pitch = 0; + } + else + { + v55 = (int)v13; + ySquared = v11 * v11; + xSquared = v10 * v10; + v14 = (int)sqrt(long double(xSquared + ySquared)); + yaw = stru_5C6E00->Atan2((int)v10, (int)v11); + pitch = stru_5C6E00->Atan2(v14, (int)v12); + } + Assert(skillMasteryPlusOne > 0 && skillMasteryPlusOne <= 4, "Invalid mastery level"); + + SpriteObject a1; // [sp+38h] [bp-7Ch]@12 + //SpriteObject::SpriteObject(&a1); + + switch ( uSpellID ) + { + case SPELL_FIRE_FIRE_BOLT: + case SPELL_FIRE_FIREBALL: + case SPELL_AIR_LIGHNING_BOLT: + case SPELL_WATER_ICE_BOLT: + case SPELL_WATER_ACID_BURST: + case SPELL_WATER_ICE_BLAST: + case SPELL_EARTH_BLADES: + case SPELL_EARTH_ROCK_BLAST: + case SPELL_WATER_POISON_SPRAY: + case SPELL_AIR_SPARKS: + case SPELL_EARTH_DEATH_BLOSSOM: + a1.uType = stru_4E3ACC[uSpellID].uType; + a1.stru_24.Reset(); + a1.spell_id = uSpellID; + a1.spell_level = uSkill; + a1.spell_skill = skillMasteryPlusOne; + v16 = 0; + while (v16 < pObjectList->uNumObjects) + { + if ( a1.uType == pObjectList->pObjects[v16].uObjectID) + { + break; + } + v16++; + } + a1.uObjectDescID = v16; + a1.vPosition.x = fromx; + a1.vPosition.y = fromy; + a1.vPosition.z = fromz; + a1.uAttributes = 16; + a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz); + a1.field_60_distance_related_prolly_lod = v55; + a1.uSpriteFrameID = 0; + a1.spell_caster_pid = 8000 | OBJECT_Item; + a1.uSoundID = 0; + break; + } + + switch ( uSpellID ) + { + case SPELL_FIRE_FIRE_BOLT: + case SPELL_FIRE_FIREBALL: + case SPELL_AIR_LIGHNING_BOLT: + case SPELL_WATER_ICE_BOLT: + case SPELL_WATER_ACID_BURST: + case SPELL_WATER_ICE_BLAST: + case SPELL_EARTH_BLADES: + case SPELL_EARTH_ROCK_BLAST: + //v20 = yaw; + a1.spell_target_pid = 0; + a1.uFacing = yaw; + a1.uSoundID = 0; + v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; + a1.Create(yaw, pitch, v49, 0); + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); + return; + case SPELL_WATER_POISON_SPRAY: + switch ( skillMasteryPlusOne ) + { + case 1: + v60 = 1; + break; + case 2: + v60 = 3; + break; + case 3: + v60 = 5; + break; + case 4: + v60 = 7; + break; + } + a1.spell_target_pid = 0; + a1.uFacing = yaw; + if ( v60 == 1 ) + { + v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; + a1.Create(yaw, pitch, v49, 0); + } + else + { + a7c = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; + a8b = a7c / (v60 - 1); + for ( i = a7c / -2; i <= a7c / 2; i += a8b ) + { + a1.uFacing = i + yaw; + a1.Create((signed __int16)(i + (short)yaw), pitch, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); + } + } + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); + return; + case SPELL_AIR_SPARKS: + switch ( skillMasteryPlusOne ) + { + case 1: + v60 = 3; + break; + case 2: + v60 = 5; + break; + case 3: + v60 = 7; + break; + case 4: + v60 = 9; + break; + } + a7d = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; + a8c = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v60 - 1); + a1.spell_target_pid = 4; + for ( j = a7d / -2; j <= a7d / 2; j += a8c ) + { + a1.uFacing = j + yaw; + a1.Create((signed __int16)(j + (short)yaw), pitch, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); + } + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); + return; + case SPELL_EARTH_DEATH_BLOSSOM: + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + return; + a1.spell_target_pid = 4; + v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; + v47 = (signed int)stru_5C6E00->uIntegerHalfPi / 2; + a1.Create(yaw, v47, v49, 0); + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); + return; + + case SPELL_FIRE_HASTE: + if ( skillMasteryPlusOne > 0 ) + { + if ( skillMasteryPlusOne <= 2 ) + v9 = 60 * (uSkill + 60); + else if ( skillMasteryPlusOne == 3 ) + v9 = 180 * (uSkill + 20); + else if ( skillMasteryPlusOne == 4 ) + v9 = 240 * (uSkill + 15); + } + for (uint i = 0; i < 4; ++i) + if (pParty->pPlayers[i].IsWeak()) + return; + pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v9 * 128) * 0.033333335), skillMasteryPlusOne, 0, 0, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);//çâóê àëòàðÿ + return; + case SPELL_AIR_SHIELD: + case SPELL_EARTH_STONESKIN: + case SPELL_SPIRIT_HEROISM: + switch ( skillMasteryPlusOne ) + { + case 1: + case 2: + v9 = 300 * (uSkill + 12); + break; + case 3: + v9 = 900 * (uSkill + 4); + break; + case 4: + v9 = 3600 * (uSkill + 1); + break; + } + switch ( uSpellID ) + { + case SPELL_AIR_SHIELD: + v60 = 0; + uSkill = 14; + break; + case SPELL_EARTH_STONESKIN: + v60 = uSkill + 5; + uSkill = 15; + break; + case SPELL_SPIRIT_HEROISM: + v60 = uSkill + 5; + uSkill = 9; + break; + } + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); + v36 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(v9 << 7) * 0.033333335); + pParty->pPartyBuffs[uSkill].Apply(v36, skillMasteryPlusOne, v60, 0, 0); + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); + return; + case SPELL_FIRE_IMMOLATION: + if (skillMasteryPlusOne == 4) + v38 = 600 * uSkill; + else + v38 = 60 * uSkill; + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); + v39 = (signed __int64)((double)(v38 << 7) * 0.033333335); + v36 = pParty->uTimePlayed + v39; + pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].Apply(v36, skillMasteryPlusOne, uSkill, 0, 0); + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); + return; + case SPELL_FIRE_PROTECTION_FROM_FIRE: + case SPELL_AIR_PROTECTION_FROM_AIR: + case SPELL_WATER_PROTECTION_FROM_WATER: + case SPELL_EARTH_PROTECTION_FROM_EARTH: + case SPELL_MIND_PROTECTION_FROM_MIND: + case SPELL_BODY_PROTECTION_FROM_BODY: + a6_4 = 3600 * uSkill; + switch (skillMasteryPlusOne) + { + case 1: + v60 = uSkill; + break; + case 2: + v60 = 2 * uSkill; + break; + case 3: + v60 = 3 * uSkill; + break; + case 4: + v60 = 4 * uSkill; + break; + } + switch ( uSpellID ) + { + case SPELL_FIRE_PROTECTION_FROM_FIRE: + uSkill = PARTY_BUFF_RESIST_FIRE; + break; + case SPELL_AIR_PROTECTION_FROM_AIR: + uSkill = PARTY_BUFF_RESIST_AIR; + break; + case SPELL_WATER_PROTECTION_FROM_WATER: + uSkill = PARTY_BUFF_RESIST_WATER; + break; + case SPELL_EARTH_PROTECTION_FROM_EARTH: + uSkill = PARTY_BUFF_RESIST_EARTH; + break; + case SPELL_MIND_PROTECTION_FROM_MIND: + uSkill = PARTY_BUFF_RESIST_MIND; + break; + case SPELL_BODY_PROTECTION_FROM_BODY: + uSkill = PARTY_BUFF_RESIST_BODY; + break; + } + 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), skillMasteryPlusOne, v60, 0, 0); + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); + return; + case SPELL_LIGHT_DAY_OF_THE_GODS : + switch (skillMasteryPlusOne) + { + case 2: + v42 = 10800 * uSkill; + v43 = 3 * uSkill + 10; + break; + case 3: + v42 = 18000 * uSkill; + v43 = 5 * uSkill + 10; + break; + case 4: + v42 = 14400 * uSkill; + v43 = 4 * uSkill + 10; + break; + } + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); + v39 = (signed __int64)((double)(v42 << 7) * 0.033333335); + v36 = pParty->uTimePlayed + v39; + pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].Apply(v36, skillMasteryPlusOne, v43, 0, 0); + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); + return; + default: + return; + } +} +//----- (00427769) -------------------------------------------------------- +bool sub_427769_isSpellQuickCastableOnShiftClick(unsigned int uSpellID) +{ + return ( pSpellDatas[uSpellID].stats & 0xC ) != 0; +} +//----- (0043AFE3) -------------------------------------------------------- +int _43AFE3_calc_spell_damage(int spellId, int spellLevel, signed int skillMastery, int currentHp) +{ + int result; // eax@1 + unsigned int v5; // [sp-4h] [bp-8h]@9 + + result = 0; + if ( spellId == SPELL_FIRE_FIRE_SPIKE ) + { + switch (skillMastery) + { + case 1: + case 2: + v5 = 6; + case 3: + v5 = 8; + case 4: + v5 = 10; + default: + return 0; + } + result = GetDiceResult(spellLevel, v5); + } + else if ( spellId == SPELL_EARTH_MASS_DISTORTION ) + result = currentHp * (pSpellDatas[SPELL_EARTH_MASS_DISTORTION].baseDamage + 2 * spellLevel) / 100; + else + result = pSpellDatas[spellId].baseDamage + + GetDiceResult(spellLevel, pSpellDatas[spellId].bonusSkillDamage); + + return result; +} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Spells/Spells.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Spells/Spells.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,291 @@ +#pragma once + +#include + +#include "../VectorTypes.h" + +/* 360 */ +enum SPELL_TYPE +{ + SPELL_FIRE_TORCH_LIGHT = 1, + SPELL_FIRE_FIRE_BOLT = 2, + SPELL_FIRE_PROTECTION_FROM_FIRE = 3, + SPELL_FIRE_FIRE_AURA = 4, + SPELL_FIRE_HASTE = 5, + SPELL_FIRE_FIREBALL = 6, + SPELL_FIRE_FIRE_SPIKE = 7, + SPELL_FIRE_IMMOLATION = 8, + SPELL_FIRE_METEOR_SHOWER = 9, + SPELL_FIRE_INFERNO = 10, + SPELL_FIRE_INCINERATE = 11, + + SPELL_AIR_WIZARD_EYE = 12, + SPELL_AIR_FEATHER_FALL = 13, + SPELL_AIR_PROTECTION_FROM_AIR = 14, + SPELL_AIR_SPARKS = 15, + SPELL_AIR_JUMP = 16, + SPELL_AIR_SHIELD = 17, + SPELL_AIR_LIGHNING_BOLT = 18, + SPELL_AIR_INVISIBILITY = 19, + SPELL_AIR_IMPLOSION = 20, + SPELL_AIR_FLY = 21, + SPELL_AIR_STARBURST = 22, + + SPELL_WATER_AWAKEN = 23, + SPELL_WATER_POISON_SPRAY = 24, + SPELL_WATER_PROTECTION_FROM_WATER = 25, + SPELL_WATER_ICE_BOLT = 26, + SPELL_WATER_WATER_WALK = 27, + SPELL_WATER_RECHARGE_ITEM = 28, + SPELL_WATER_ACID_BURST = 29, + SPELL_WATER_ENCHANT_ITEM = 30, + SPELL_WATER_TOWN_PORTAL = 31, + SPELL_WATER_ICE_BLAST = 32, + SPELL_WATER_LLOYDS_BEACON = 33, + + SPELL_EARTH_STUN = 34, + SPELL_EARTH_SLOW = 35, + SPELL_EARTH_PROTECTION_FROM_EARTH = 36, + SPELL_EARTH_DEADLY_SWARM = 37, + SPELL_EARTH_STONESKIN = 38, + SPELL_EARTH_BLADES = 39, + SPELL_EARTH_STONE_TO_FLESH = 40, + SPELL_EARTH_ROCK_BLAST = 41, + SPELL_EARTH_TELEKINESIS = 42, + SPELL_EARTH_DEATH_BLOSSOM = 43, + SPELL_EARTH_MASS_DISTORTION = 44, + + SPELL_SPIRIT_DETECT_LIFE = 45, + SPELL_SPIRIT_BLESS = 46, + SPELL_SPIRIT_FATE = 47, + SPELL_SPIRIT_TURN_UNDEAD = 48, + SPELL_SPIRIT_REMOVE_CURSE = 49, + SPELL_SPIRIT_PRESERVATION = 50, + SPELL_SPIRIT_HEROISM = 51, + SPELL_SPIRIT_SPIRIT_LASH = 52, + SPELL_SPIRIT_RAISE_DEAD = 53, + SPELL_SPIRIT_SHARED_LIFE = 54, + SPELL_SPIRIT_RESSURECTION = 55, + + SPELL_MIND_REMOVE_FEAR = 56, + SPELL_MIND_MIND_BLAST = 57, + SPELL_MIND_PROTECTION_FROM_MIND = 58, + SPELL_MIND_TELEPATHY = 59, + SPELL_MIND_CHARM = 60, + SPELL_MIND_CURE_PARALYSIS = 61, + SPELL_MIND_BERSERK = 62, + SPELL_MIND_MASS_FEAR = 63, + SPELL_MIND_CURE_INSANITY = 64, + SPELL_MIND_PSYCHIC_SHOCK = 65, + SPELL_MIND_ENSLAVE = 66, + + SPELL_BODY_CURE_WEAKNESS = 67, + SPELL_BODY_FIRST_AID = 68, + SPELL_BODY_PROTECTION_FROM_BODY = 69, + SPELL_BODY_HARM = 70, + SPELL_BODY_REGENERATION = 71, + SPELL_BODY_CURE_POISON = 72, + SPELL_BODY_HAMMERHANDS = 73, + SPELL_BODY_CURE_DISEASE = 74, + SPELL_BODY_PROTECTION_FROM_MAGIC = 75, + SPELL_BODY_FLYING_FIST = 76, + SPELL_BODY_POWER_CURE = 77, + + SPELL_LIGHT_LIGHT_BOLT = 78, + SPELL_LIGHT_DESTROY_UNDEAD = 79, + SPELL_LIGHT_DISPEL_MAGIC = 80, + SPELL_LIGHT_PARALYZE = 81, + SPELL_LIGHT_SUMMON_ELEMENTAL = 82, + SPELL_LIGHT_DAY_OF_THE_GODS = 83, + SPELL_LIGHT_PRISMATIC_LIGHT = 84, + SPELL_LIGHT_DAY_OF_PROTECTION = 85, + SPELL_LIGHT_HOUR_OF_POWER = 86, + SPELL_LIGHT_SUNRAY = 87, + SPELL_LIGHT_DIVINE_INTERVENTION = 88, + + SPELL_DARK_REANIMATE = 89, + SPELL_DARK_TOXIC_CLOUD = 90, + SPELL_DARK_VAMPIRIC_WEAPON = 91, + SPELL_DARK_SHRINKING_RAY = 92, + SPELL_DARK_SHARPMETAL = 93, + SPELL_DARK_CONTROL_UNDEAD = 94, + SPELL_DARK_PAIN_REFLECTION = 95, + SPELL_DARK_SACRIFICE = 96, + SPELL_DARK_DRAGON_BREATH = 97, + SPELL_DARK_ARMAGEDDON = 98, + SPELL_DARK_SOULDRINKER = 99, + + SPELL_BOW_ARROW = 100, + SPELL_101 = 101, + SPELL_LASER_PROJECTILE = 102, + + BECOME_MAGIC_GUILD_MEMBER = 150, + SPELL_QUEST_COMPLETED = 151, + SPELL_152 = 152, + SPELL_DISEASE = 153 +}; + + +enum SPELL_SCHOOL : int +{ + SPELL_SCHOOL_FIRE = 0, + SPELL_SCHOOL_AIR = 1, + SPELL_SCHOOL_WATER = 2, + SPELL_SCHOOL_EARTH = 3, + SPELL_SCHOOL_NONE = 4, + SPELL_SCHOOL_MAGIC = 5, + SPELL_SCHOOL_SPIRIT = 6, + SPELL_SCHOOL_MIND = 7, + SPELL_SCHOOL_BODY = 8, + SPELL_SCHOOL_LIGHT = 9, + SPELL_SCHOOL_DARK = 10 +}; + + + +/* 68 */ +#pragma pack(push, 1) +struct SpellBuff +{ + inline SpellBuff() + { + uExpireTime = 0; + uPower = 0; + uSkill = 0; + uOverlayID = 0; + uCaster = 0; + uFlags = 0; + } + + bool Apply(signed __int64 uExpireTime, unsigned __int16 uSkillLevel, unsigned __int16 uPower, int uOverlayID, unsigned __int8 caster); + void Reset(); + bool IsBuffExpiredToTime(__int64 time_end); + bool NotExpired(); + + signed __int64 uExpireTime; + unsigned __int16 uPower; + unsigned __int16 uSkill; + unsigned __int16 uOverlayID; + unsigned __int8 uCaster; + unsigned __int8 uFlags; +}; +#pragma pack(pop) + + +#pragma pack(push, 1) +struct SpellInfo +{ + char *pName; + char *pShortName; + char *pDescription; + char *pBasicSkillDesc; + char *pExpertSkillDesc; + char *pMasterSkillDesc; + char *pGrandmasterSkillDesc; + SPELL_SCHOOL uSchool; + int field_20; +}; +#pragma pack(pop) + + + +#pragma pack(push, 1) +struct SpellStats +{ + void Initialize(); + + SpellInfo pInfos[100]; +}; +#pragma pack(pop) + + + + + + + + + +/* 364 */ +#pragma pack(push, 1) +struct stru324_spell +{ + __int16 uType; + __int16 field_2; +}; +#pragma pack(pop) + +/* 151 */ +#pragma pack(push, 1) +class SpellData +{ +public: + SpellData(__int16 innormalMana, __int16 inExpertLevelMana, __int16 inMasterLevelMana, __int16 inMagisterLevelMana, + __int16 inNormalLevelRecovery, __int16 inExpertLevelRecovery, __int16 inMasterLevelRecovery, __int16 inMagisterLevelRecovery, + __int8 inbaseDamage, __int8 inbonusSkillDamage, __int16 instats); + union + { + unsigned __int16 mana_per_skill[4]; + struct + { + unsigned __int16 uNormalLevelMana; + unsigned __int16 uExpertLevelMana; + unsigned __int16 uMasterLevelMana; + unsigned __int16 uMagisterLevelMana; + }; + }; + union + { + unsigned __int16 recovery_per_skill[4]; + struct + { + unsigned __int16 uNormalLevelRecovery; + unsigned __int16 uExpertLevelRecovery; + unsigned __int16 uMasterLevelRecovery; + unsigned __int16 uMagisterLevelRecovery; + }; + }; + __int8 baseDamage; + __int8 bonusSkillDamage; + __int16 stats; + // char field_12; + // char field_13; + // __int16 field_14; +}; +#pragma pack(pop) + +#pragma pack(push, 1) +struct SpellBookIconPos +{ + unsigned int Xpos; + unsigned int Ypos; +}; + +#pragma pack(pop) + +/* 154 */ +#pragma pack(push, 1) +struct TownPortalData +{ + Vec3_int_ pos; + __int16 rot_y; + __int16 rot_x; + unsigned __int16 uMapInfoID; + __int16 field_12; +}; +#pragma pack(pop) +extern std::array TownPortalList; //4ECBB8 + + +extern struct SpellStats *pSpellStats; + +extern std::array, 9> pIconPos; + +extern std::array stru_4E3ACC; +extern std::array pSpellDatas; +extern std::array wand_spell_ids; + +int _43AFE3_calc_spell_damage(int spellId, int spellLevel, signed int skillMastery, int currentHp); + +bool sub_427769_isSpellQuickCastableOnShiftClick(unsigned int uSpellID); +void __fastcall EventCastSpell(int uSpellID, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz);//sub_448DF8 diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Tables/FactionTable.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Tables/FactionTable.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,59 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include "FactionTable.h" +#include "../mm7_data.h" +#include "../LOD.h" + + + + +//----- (004547E4) -------------------------------------------------------- +void FactionTable::Initialize() +{ + int i; + char* test_string; + unsigned char c; + bool break_loop; + unsigned int temp_str_len; + char* tmp_pos; + int decode_step; + // int item_counter; + + free(pHostileTXT_Raw); + pHostileTXT_Raw = (char *)pEvents_LOD->LoadRaw("hostile.txt", 0); + strtok(pHostileTXT_Raw, "\r"); + for (i = 0; i < 89; ++i) + { + test_string = strtok(NULL, "\r") + 1; + break_loop = false; + decode_step = 0; + do + { + c = *(unsigned char*)test_string; + temp_str_len = 0; + while ((c != '\t') && (c > 0)) + { + ++temp_str_len; + c = test_string[temp_str_len]; + } + tmp_pos = test_string + temp_str_len; + if (*tmp_pos == 0) + break_loop = true; + *tmp_pos = 0; + if (temp_str_len) + { + if (decode_step >= 1 && decode_step < 90) + relations[decode_step - 1][i] = atoi(test_string); + } + else + break_loop = true; + ++decode_step; + test_string = tmp_pos + 1; + } while ((decode_step < 92) && !break_loop); + } + free(pHostileTXT_Raw); + pHostileTXT_Raw = nullptr; +} diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Tables/FactionTable.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Tables/FactionTable.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,12 @@ +#pragma once + + +/* 174 */ +#pragma pack(push, 1) +struct FactionTable +{ + void Initialize(); + + char relations[89][89]; +}; +#pragma pack(pop) diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Tables/FrameTableInc.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Tables/FrameTableInc.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,142 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include "FrameTableInc.h" +#include +//identical function to work in differnt threads + +//----- (004BE3BF) -------------------------------------------------------- +FrameTableTxtLine* txt_file_frametable_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table) + { + bool new_token_flag; // edx@3 + bool in_quotes; // [sp+Ch] [bp-4h]@3 + char* parse_pos; + unsigned char test_char; + int i; + + static char tokens_buff1[1000]; + static struct FrameTableTxtLine temp_tokens_table1; // weak + + temp_tokens_table1.uPropCount = 0; + + if ( str_to_parse && *str_to_parse ) + { + parse_pos=(char*)str_to_parse; + new_token_flag = true; + in_quotes = false; + for(i = 0; (i<1000)&&(temp_tokens_table1.uPropCount < 30) ; ++i) + { + test_char=*parse_pos; + tokens_buff1[i]=test_char; + if ( !test_char ) + break; + if ( (test_char != ' ') && (test_char != ',') && (test_char != '\t') || in_quotes ) + { + if ( test_char == '"' ) + { + tokens_buff1[i]= '\0'; + new_token_flag = true; + if ( in_quotes ) + in_quotes = false; + else + { + in_quotes = true; + if ( *(parse_pos+1) == '"' ) + { + temp_tokens_table1.pProperties[temp_tokens_table1.uPropCount] = &tokens_buff1[i]; + ++temp_tokens_table1.uPropCount; + } + } + } + else + { + if ( new_token_flag ) + { + temp_tokens_table1.pProperties[temp_tokens_table1.uPropCount] = &tokens_buff1[i]; + ++temp_tokens_table1.uPropCount; + } + new_token_flag = false; + } + } + else + { + tokens_buff1[i]= '\0'; + new_token_flag = true; + } + ++parse_pos; + } + tokens_buff1[i]= '\0'; + } + memcpy(tokens_table, &temp_tokens_table1, sizeof(FrameTableTxtLine)); + return tokens_table; + } +// F8BA58: using guessed type FrameTableTxtLine static_stru_F8BA58; + +//----- (004BE485) -------------------------------------------------------- +FrameTableTxtLine * frame_table_txt_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table) + { + bool new_token_flag; // edx@3 + bool in_quotes; // [sp+Ch] [bp-4h]@3 + char* parse_pos; + unsigned char test_char; + int i; + + static char tokens_buff2[1000]; + static struct FrameTableTxtLine temp_tokens_table2; // weak + temp_tokens_table2.uPropCount = 0; + + if ( str_to_parse && *str_to_parse ) + { + parse_pos=(char*)str_to_parse; + new_token_flag = true; + in_quotes = false; + for(i = 0; (i<1000)&&(temp_tokens_table2.uPropCount < 30); ++i) + { + test_char=*parse_pos; + tokens_buff2[i]=test_char; + if ( !test_char ) + break; + if ( (test_char != ' ') && (test_char != ',') && (test_char != '\t') || in_quotes ) + { + if ( test_char == '"' ) + { + tokens_buff2[i]= '\0'; + new_token_flag = true; + if ( in_quotes ) + in_quotes = false; + else + { + in_quotes = true; + if ( *(parse_pos+1) == '"' ) + { + temp_tokens_table2.pProperties[temp_tokens_table2.uPropCount] = &tokens_buff2[i]; + ++temp_tokens_table2.uPropCount; + } + } + } + else + { + if ( new_token_flag ) + { + temp_tokens_table2.pProperties[temp_tokens_table2.uPropCount] = &tokens_buff2[i]; + ++temp_tokens_table2.uPropCount; + } + new_token_flag = false; + } + } + else + { + tokens_buff2[i]= '\0'; + new_token_flag = true; + } + ++parse_pos; + } + + tokens_buff2[i]= '\0'; + } + memcpy(tokens_table, &temp_tokens_table2, sizeof(FrameTableTxtLine)); + return tokens_table; + } + diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Tables/FrameTableInc.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Tables/FrameTableInc.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,26 @@ +#pragma once + + + +/* 322 */ +enum FRAME_TABLE_FLAGS +{ + FRAME_TABLE_MORE_FRAMES = 0x1, + FRAME_TABLE_FIRST = 0x4, +}; + + + +/* 359 */ +#pragma pack(push, 1) +struct FrameTableTxtLine //7C +{ + int uPropCount; + const char *pProperties[30]; +}; +#pragma pack(pop) + + +FrameTableTxtLine* txt_file_frametable_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table); + +FrameTableTxtLine *frame_table_txt_parser(const char *pString, FrameTableTxtLine *a2); \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Tables/IconFrameTable.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Tables/IconFrameTable.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,217 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include "../ErrorHandling.h" +#include "IconFrameTable.h" +#include "../LOD.h" +#include "../mm7_data.h" +#include "FrameTableInc.h" + +//----- (00494F3A) -------------------------------------------------------- +unsigned int IconFrameTable::FindIcon(const char *pIconName) +{ + for ( uint i = 0; i < (signed int)this->uNumIcons; i++ ) + { + if ( !_stricmp(pIconName, this->pIcons[i].pAnimationName) ) + return i; + } + return 0; +} + +//----- (00494F70) -------------------------------------------------------- +IconFrame *IconFrameTable::GetFrame(unsigned int uIconID, unsigned int uFrameID) +{ + int v6; // edx@3 + uint i; + + if ( this->pIcons[uIconID].uFlags & 1 && this->pIcons[uIconID].uAnimLength != 0 ) + { + v6 = ((signed int)uFrameID >> 3) % (unsigned __int16)this->pIcons[uIconID].uAnimLength; + for ( i = uIconID; v6 > this->pIcons[i].uAnimTime; i++ ) + v6 -= this->pIcons[i].uAnimTime; + return &this->pIcons[i]; + } + else + return &this->pIcons[uIconID]; +} + +//----- (00494FBF) -------------------------------------------------------- +void IconFrameTable::InitializeAnimation(unsigned int uIconID) +{ + if ( uIconID && (signed int)uIconID <= (signed int)this->uNumIcons ) + { + for ( uint i = uIconID; ; ++i ) + { + this->pIcons[i].uTextureID = pIcons_LOD->LoadTexture(this->pIcons[i].pTextureName, TEXTURE_16BIT_PALETTE); + if ( !(this->pIcons[i].uFlags & 1) ) + break; + } + } +} + +//----- (0049500A) -------------------------------------------------------- +void IconFrameTable::ToFile() +{ + //IconFrameTable *v1; // esi@1 + FILE *v2; // eax@1 + //FILE *v3; // edi@1 + + //IconFrameTable* Str = this; + + //v1 = Str; + v2 = fopen("data\\dift.bin", "wb"); + //v3 = v2; + if ( !v2 ) + Error("Unable to save dift.bin!"); + fwrite(this, 4, 1, v2); + fwrite(this->pIcons, 0x20u, this->uNumIcons, v2); + fclose(v2); +} + +//----- (00495056) -------------------------------------------------------- +void IconFrameTable::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) +{ + uint num_mm6_frames = data_mm6 ? *(int *)data_mm6 : 0, + num_mm7_frames = data_mm7 ? *(int *)data_mm7 : 0, + num_mm8_frames = data_mm8 ? *(int *)data_mm8 : 0; + + uNumIcons = num_mm6_frames + num_mm7_frames + num_mm8_frames; + Assert(uNumIcons); + Assert(!num_mm8_frames); + + pIcons = (IconFrame *)malloc(uNumIcons * sizeof(IconFrame)); + memcpy(pIcons, (char *)data_mm7 + 4, num_mm7_frames * sizeof(IconFrame)); + memcpy(pIcons + num_mm7_frames, (char *)data_mm6 + 4, num_mm6_frames * sizeof(IconFrame)); + memcpy(pIcons + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 4, num_mm8_frames * sizeof(IconFrame)); +} + +//----- (0049509D) -------------------------------------------------------- +int IconFrameTable::FromFileTxt(const char *Args) +{ + //IconFrameTable *v2; // ebx@1 + FILE *v3; // eax@1 + int v4; // esi@3 + void *v5; // eax@10 + FILE *v6; // ST0C_4@12 + char *i; // eax@12 + const char *v8; // ST00_4@15 + int v9; // eax@16 + int v10; // edx@20 + int v11; // ecx@21 + int v12; // eax@22 + signed int j; // edx@25 + IconFrame *v14; // ecx@26 + int v15; // esi@26 + int k; // eax@27 + signed int result; // eax@11 + char Buf; // [sp+Ch] [bp-2F8h]@3 + FrameTableTxtLine v19; // [sp+200h] [bp-104h]@4 + FrameTableTxtLine v20; // [sp+27Ch] [bp-88h]@4 + int v21; // [sp+2F8h] [bp-Ch]@3 + int v22; // [sp+2FCh] [bp-8h]@3 + FILE *File; // [sp+300h] [bp-4h]@1 + int Argsa; // [sp+30Ch] [bp+8h]@26 + + //v2 = this; + //TileTable::dtor((TileTable *)this); + __debugbreak();//Ritor1: this function not used + v3 = fopen(Args, "r"); + File = v3; + if ( !v3 ) + Error("IconFrameTable::load - Unable to open file: %s.", Args); + v4 = 0; + v21 = 0; + v22 = 1; + if ( fgets(&Buf, 490, v3) ) + { + do + { + *strchr(&Buf, 10) = 0; + memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20)); + if ( v20.uPropCount && *v20.pProperties[0] != 47 ) + { + if ( v20.uPropCount < 3 ) + Error("IconFrameTable::loadText, too few arguments, %s line %i.", Args, v22); + ++v21; + } + ++v22; + } + while ( fgets(&Buf, 490, File) ); + v4 = v21; + } + this->uNumIcons = v4; + v5 = malloc(32 * v4);//, "I Frames"); + this->pIcons = (IconFrame *)v5; + if ( v5 ) + { + v6 = File; + this->uNumIcons = 0; + fseek(v6, 0, 0); + for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) + { + *strchr(&Buf, 10) = 0; + memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20)); + if ( v20.uPropCount && *v20.pProperties[0] != 47 ) + { + strcpy(this->pIcons[this->uNumIcons].pAnimationName, v20.pProperties[0]); + strcpy(this->pIcons[this->uNumIcons].pTextureName, v20.pProperties[1]); + v8 = v20.pProperties[2]; + this->pIcons[this->uNumIcons].uFlags = 0; + if ( !_stricmp(v8, "new") ) + { + v9 = (int)&this->pIcons[this->uNumIcons].uFlags; + *(char *)v9 |= 4u; + } + this->pIcons[this->uNumIcons].uAnimTime = atoi(v20.pProperties[3]); + this->pIcons[this->uNumIcons].uAnimLength = 0; + this->pIcons[this->uNumIcons++].uTextureID = 0; + } + } + fclose(File); + v10 = 0; + if ( (signed int)(this->uNumIcons - 1) > 0 ) + { + v11 = 0; + do + { + v12 = (int)&this->pIcons[v11]; + if ( !(*(char *)(v12 + 60) & 4) ) + *(char *)(v12 + 28) |= 1u; + ++v10; + ++v11; + } + while ( v10 < (signed int)(this->uNumIcons - 1) ); + } + for ( j = 0; j < (signed int)this->uNumIcons; *(short *)(Argsa + 26) = v15 ) + { + v14 = this->pIcons; + Argsa = (int)&v14[j]; + v15 = *(short *)(Argsa + 24); + if ( *(char *)(Argsa + 28) & 1 ) + { + ++j; + for ( k = (int)&v14[j]; *(char *)(k + 28) & 1; k += 32 ) + { + v15 += *(short *)(k + 24); + ++j; + } + LOWORD(v15) = v14[j].uAnimTime + v15; + } + ++j; + } + result = 1; + } + else + { + fclose(File); + result = 0; + } + return result; +} +//----- (0042EB78) -------------------------------------------------------- +int IconFrameTable::GetIconAnimLength(unsigned int uIconID) +{ + return 8 * this->pIcons[uIconID].uAnimLength; +} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Tables/IconFrameTable.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Tables/IconFrameTable.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,79 @@ +#pragma once +#include + + + + +/* 44 */ +#pragma pack(push, 1) +struct IconFrame +{ + char pAnimationName[12]; + char pTextureName[12]; + __int16 uAnimTime; + __int16 uAnimLength; + __int16 uFlags; + unsigned __int16 uTextureID; +}; +#pragma pack(pop) + +/* 45 */ +#pragma pack(push, 1) +struct IconFrameTable +{ + inline IconFrameTable(): + uNumIcons(0), pIcons(nullptr) + {} + + unsigned int FindIcon(const char *pIconName); + IconFrame *GetFrame(unsigned int uIconID, unsigned int uFrameID); + void InitializeAnimation(unsigned int uIconID); + void ToFile(); + void FromFile(void *data_mm6, void *data_mm7, void *data_mm8); + int FromFileTxt(const char *Args); + int GetIconAnimLength(unsigned int uIconID); + + unsigned int uNumIcons; + struct IconFrame *pIcons; +}; +#pragma pack(pop) + + + + + + + + + + + + +/* 76 */ +#pragma pack(push, 1) +struct UIAnimation +{ + unsigned __int16 uIconID; + __int16 field_2; + __int16 uAnimTime; + __int16 uAnimLength; + __int16 x; + __int16 y; + char field_C; +}; +#pragma pack(pop) + + + + + + +extern struct IconFrameTable *pIconsFrameTable; + + +extern struct UIAnimation *pUIAnim_Food; +extern struct UIAnimation *pUIAnim_Gold; +extern struct UIAnimation *pUIAnum_Torchlight; +extern struct UIAnimation *pUIAnim_WizardEye; + +extern std::array pUIAnims; diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Tables/PlayerFrameTable.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Tables/PlayerFrameTable.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,224 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS + +#include "PlayerFrameTable.h" + +#include "../ErrorHandling.h" +#include "FrameTableInc.h" +#include "../mm7_data.h" + + +//----- (00494AED) -------------------------------------------------------- +unsigned int PlayerFrameTable::GetFrameIdByExpression(CHARACTER_EXPRESSION_ID expression) +{ + for (uint i = 0; i < this->uNumFrames; i++) + { + if (this->pFrames[i].expression == expression) + return i; + } + return 0; +} + +//----- (00494B10) -------------------------------------------------------- +PlayerFrame *PlayerFrameTable::GetFrameBy_x(unsigned int uFramesetID, unsigned int uFrameID) +{ + unsigned int v3; // esi@1 + __int16 v6; // dx@2 + int v7; // edx@3 + char *i; // eax@3 + int v9; // ecx@5 + PlayerFrame *result; // eax@6 + + v3 = uFramesetID; + if (this->pFrames[uFramesetID].uFlags & 1 && (v6 = this->pFrames[uFramesetID].uAnimLength) != 0) + { + v7 = ((signed int)uFrameID >> 3) % (unsigned __int16)v6; + for (i = (char *)&this->pFrames[uFramesetID].uAnimTime;; i += 10) + { + v9 = *(short *)i; + if (v7 <= v9) + break; + v7 -= v9; + ++v3; + } + result = &this->pFrames[v3]; + } + else + result = &this->pFrames[uFramesetID]; + return result; +} + +//----- (00494B5E) -------------------------------------------------------- +PlayerFrame *PlayerFrameTable::GetFrameBy_y(int *pFramesetID, int *pAnimTime, int a4) +{ + int v5; // esi@1 + int v6; // eax@2 + + v5 = a4 + *pAnimTime; + if (v5 < 8 * this->pFrames[*pFramesetID].uAnimTime) + *pAnimTime = v5; + else + { + v6 = rand() % 4 + 21; + *pFramesetID = v6; + *pAnimTime = 8 * v5 % this->pFrames[v6].uAnimTime; + } + return &this->pFrames[*pFramesetID]; +} + +//----- (00494BC3) -------------------------------------------------------- +void PlayerFrameTable::ToFile() +{ + PlayerFrameTable *v1; // esi@1 + FILE *v2; // eax@1 + FILE *v3; // edi@1 + + PlayerFrameTable* Str = this; + + v1 = Str; + v2 = fopen("data\\dpft.bin", "wb"); + v3 = v2; + if (!v2) + Error("Unable to save dpft.bin"); + fwrite(v1, 4, 1, v2); + fwrite(v1->pFrames, 0xAu, v1->uNumFrames, v3); + fclose(v3); +} + +//----- (00494C0F) -------------------------------------------------------- +void PlayerFrameTable::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) +{ + uint num_mm6_frames = data_mm6 ? *(int *)data_mm6 : 0, + num_mm7_frames = data_mm7 ? *(int *)data_mm7 : 0, + num_mm8_frames = data_mm8 ? *(int *)data_mm8 : 0; + uNumFrames = num_mm6_frames + num_mm7_frames + num_mm8_frames; + assert(uNumFrames); + assert(!num_mm8_frames); + + pFrames = (PlayerFrame *)malloc(uNumFrames * sizeof(PlayerFrame)); + memcpy(pFrames, (char *)data_mm7 + 4, num_mm7_frames * sizeof(PlayerFrame)); + memcpy(pFrames + num_mm7_frames, (char *)data_mm6 + 4, num_mm6_frames * sizeof(PlayerFrame)); + memcpy(pFrames + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 4, num_mm8_frames * sizeof(PlayerFrame)); +} + +//----- (00494C5A) -------------------------------------------------------- +int PlayerFrameTable::FromFileTxt(const char *Args) +{ + //PlayerFrameTable *v2; // ebx@1 + FILE *v3; // eax@1 + int v4; // esi@3 + void *v5; // eax@10 + FILE *v6; // ST0C_4@12 + char *i; // eax@12 + // __int16 v8; // ax@15 + // const char *v9; // ST10_4@15 + // unsigned __int16 v10; // ax@15 + // const char *v11; // ST0C_4@15 + int j; // esi@15 + // int v13; // eax@17 + int v14; // edx@22 + int v15; // ecx@23 + int v16; // eax@24 + signed int k; // eax@27 + //PlayerFrame *v18; // edx@28 + int v19; // esi@28 + int l; // ecx@29 + char Buf; // [sp+Ch] [bp-2F8h]@3 + FrameTableTxtLine v23; // [sp+200h] [bp-104h]@4 + FrameTableTxtLine v24; // [sp+27Ch] [bp-88h]@4 + int v25; // [sp+2F8h] [bp-Ch]@3 + int v26; // [sp+2FCh] [bp-8h]@3 + FILE *File; // [sp+300h] [bp-4h]@1 + int Argsa; // [sp+30Ch] [bp+8h]@28 + + __debugbreak();//Ritor1; + //TileTable::dtor((TileTable *)this); + v3 = fopen(Args, "r"); + File = v3; + if (!v3) + Error("PlayerFrameTable::load - Unable to open file: %s.", Args); + v4 = 0; + v25 = 0; + v26 = 1; + if (fgets(&Buf, 490, v3)) + { + do + { + *strchr(&Buf, 10) = 0; + memcpy(&v24, txt_file_frametable_parser(&Buf, &v23), sizeof(v24)); + if (v24.uPropCount && *v24.pProperties[0] != 47) + { + if (v24.uPropCount < 3) + Error("PlayerFrameTable::load, too few arguments, %s line %i.", Args, v26); + ++v25; + } + ++v26; + } while (fgets(&Buf, 490, File)); + v4 = v25; + } + this->uNumFrames = v4; + v5 = malloc(10 * v4); + this->pFrames = (PlayerFrame *)v5; + if (!v5) + Error("PlayerFrameTable::load - Out of Memory!"); + v6 = File; + this->uNumFrames = 0; + fseek(v6, 0, 0); + for (i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File)) + { + *strchr(&Buf, 10) = 0; + memcpy(&v24, txt_file_frametable_parser(&Buf, &v23), sizeof(v24)); + if (v24.uPropCount && *v24.pProperties[0] != 47) + { + //v8 = atoi(v24.pProperties[0]); + //v9 = v24.pProperties[1]; + this->pFrames[this->uNumFrames].expression = (CHARACTER_EXPRESSION_ID)atoi(v24.pProperties[0]); + //v10 = atoi(v9); + //v11 = v24.pProperties[2]; + this->pFrames[this->uNumFrames].uTextureID = atoi(v24.pProperties[1]); + this->pFrames[this->uNumFrames].uAnimTime = atoi(v24.pProperties[2]); + this->pFrames[this->uNumFrames].uAnimLength = 0; + this->pFrames[this->uNumFrames].uFlags = 0; + for (j = 3; j < v24.uPropCount; ++j) + { + if (!_stricmp(v24.pProperties[j], "New")) + this->pFrames[this->uNumFrames].uFlags |= 4; + } + ++this->uNumFrames; + } + } + fclose(File); + + if ((signed int)(this->uNumFrames - 1) > 0) + { + v15 = 0; + for (v14 = 0; v14 < this->uNumFrames - 1; ++v14) + { + v16 = (int)&this->pFrames[v15]; + if (!(*(char *)(v16 + 18) & 4)) + this->pFrames[v14].uFlags |= 1; + ++v15; + } + } + for (k = 0; k < (signed int)this->uNumFrames; *(short *)(Argsa + 6) = v19) + { + //v18 = this->pFrames; + Argsa = (int)&this->pFrames[k]; + v19 = *(short *)(Argsa + 4); + if (this->pFrames[k].uFlags & 1) + { + ++k; + for (l = (int)&this->pFrames[k]; this->pFrames[k].uFlags & 1; l += 10) + { + v19 += *(short *)(l + 4); + ++k; + } + LOWORD(v19) = this->pFrames[k].uAnimTime + v19; + } + ++k; + } + return 1; +} diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Tables/PlayerFrameTable.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Tables/PlayerFrameTable.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,40 @@ +#pragma once + +#include "Engine/Objects/Player.h" + +/* 46 */ +#pragma pack(push, 1) +struct PlayerFrame +{ + CHARACTER_EXPRESSION_ID expression; + unsigned __int16 uTextureID; + __int16 uAnimTime; + __int16 uAnimLength; + __int16 uFlags; +}; +#pragma pack(pop) + + +/* 47 */ +#pragma pack(push, 1) +struct PlayerFrameTable +{ + inline PlayerFrameTable(): + uNumFrames(0), pFrames(nullptr) + {} + + unsigned int GetFrameIdByExpression(CHARACTER_EXPRESSION_ID expression); + PlayerFrame *GetFrameBy_x(unsigned int uFramesetID, unsigned int uFrameID); + PlayerFrame *GetFrameBy_y(int *a2, int *a3, int a4); + void ToFile(); + void FromFile(void *data_mm6, void *data_mm7, void *data_mm8); + int FromFileTxt(const char *Args); + + unsigned int uNumFrames; + struct PlayerFrame *pFrames; +}; +#pragma pack(pop) + + + +extern struct PlayerFrameTable *pPlayerFrameTable; // idb \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Tables/StorylineTextTable.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Tables/StorylineTextTable.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,42 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include +#include + +#include "../LOD.h" +#include "../texts.h" +#include "StorylineTextTable.h" + +char *pHistoryTXT_Raw; +struct StorylineText *pStorylineText; + +//----- (00453E6D) -------------------------------------------------------- +void StorylineText::Initialize() +{ + char* test_string; + + free(pHistoryTXT_Raw); + pHistoryTXT_Raw = (char *)pEvents_LOD->LoadRaw("history.txt", 0); + strtok(pHistoryTXT_Raw, "\r"); + + StoreLine[0].pText=nullptr; + StoreLine[0].pPageTitle=nullptr; + StoreLine[0].uTime=0; + StoreLine[0].f_9=0; + StoreLine[0].f_A=0; + StoreLine[0].f_B=0; + + for (int i=0;i<28;++i) + { + test_string = strtok(NULL, "\r") + 1; + auto tokens = Tokenize(test_string, '\t'); + + StoreLine[i+1].pText = RemoveQuotes(tokens[1]); + StoreLine[i+1].uTime = atoi(tokens[2]); //strange but in text here string not digit + StoreLine[i+1].pPageTitle = RemoveQuotes(tokens[3]); + } + +} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Tables/StorylineTextTable.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Tables/StorylineTextTable.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,28 @@ +#pragma once + +#pragma pack(push, 1) +struct StorylineRecord +{ + char* pText; //0 + char* pPageTitle; //4 + unsigned __int8 uTime; //8 + char f_9; + char f_A; + char f_B; +}; +#pragma pack(pop) + +/* 173 */ +#pragma pack(push, 1) +struct StorylineText +{ + void Initialize(); + StorylineRecord StoreLine[29]; + int field_15C; + //int field_0; + // int field_4[87]; +}; +#pragma pack(pop) + +extern char *pHistoryTXT_Raw; +extern struct StorylineText *pStorylineText; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Tables/TileFrameTable.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Tables/TileFrameTable.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,78 @@ +#pragma once + + + +/* 327 */ +enum TILE_DESC_FLAGS +{ + TILE_DESC_BURNS = 0x1, + TILE_DESC_WATER = 0x2, + TILE_DESC_BLOCK = 0x4, + TILE_DESC_REPULSE = 0x8, + TILE_DESC_FLAT = 0x10, + TILE_DESC_WAVY = 0x20, + TILE_DESC_DONT_DRAW = 0x40, + TILE_DESC_WATER_2 = 0x100, + TILE_DESC_TRANSITION = 0x200, + TILE_DESC_SCROLL_DOWN = 0x400, + TILE_DESC_SCROLL_UP = 0x800, + TILE_DESC_SCROLL_LEFT = 0x1000, + TILE_DESC_SCROLL_RIGHT = 0x2000, +}; + +#pragma warning( push ) +#pragma warning( disable: 4341 ) +enum Tileset: signed __int16 +{ + Tileset_Grass = 0, + Tileset_Snow = 1, + Tilset_Desert = 2, + Tileset_3 = 3, + Tileset_Dirt = 4, + Tileset_Water = 5, + Tileset_6 = 6, + Tileset_Swamp = 7, + Tileset_8 = 8, + Tileset_9 = 9, + Tileset_RoadGrassCobble = 10, + Tileset_NULL =-1 +}; +#pragma warning( pop ) + +/* 48 */ +#pragma pack(push, 1) +struct TileDesc //26 +{ + char pTileName[16]; + unsigned __int16 uTileID; + unsigned __int16 uBitmapID; + Tileset tileset; + unsigned __int16 uSection; + unsigned __int16 uAttributes; +}; +#pragma pack(pop) + +/* 49 */ +#pragma pack(push, 1) +struct TileTable +{ + //----- (00487E13) -------------------------------------------------------- + TileTable() + { + this->pTiles = nullptr; + this->sNumTiles = 0; + } + ~TileTable(); + + TileDesc *GetTileById(unsigned int uTileID); + void InitializeTileset(Tileset tileset); + int GetTileForTerrainType(signed int a1, bool a2); + unsigned int GetTileId(unsigned int uTerrainType, unsigned int uSection); + void ToFile(); + void FromFile(void *data_mm6, void *data_mm7, void *data_mm8); + int FromFileTxt(const char *pFilename); + + signed int sNumTiles; + struct TileDesc *pTiles; +}; +#pragma pack(pop) diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Tables/TileTable.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Tables/TileTable.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,795 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include +#include +#include + +#include "../ErrorHandling.h" +#include "TileFrameTable.h" +#include "FrameTableInc.h" +#include "Engine/Graphics/PaletteManager.h" +#include "../LOD.h" + +#include "../mm7_data.h" + + +//----- (00487E1D) -------------------------------------------------------- +TileTable::~TileTable() +{ + free(pTiles); + pTiles = nullptr; + sNumTiles = 0; +} + +//----- (00487E3B) -------------------------------------------------------- +TileDesc *TileTable::GetTileById(unsigned int uTileID) +{ + Assert(uTileID < sNumTiles); + return &pTiles[uTileID]; +} + +//----- (00487E58) -------------------------------------------------------- +void TileTable::InitializeTileset(Tileset tileset) +{ + for (int i = 0; i < sNumTiles; ++i ) + { + if (pTiles[i].tileset == tileset && pTiles[i].pTileName[0] ) + { + pTiles[i].uBitmapID = pBitmaps_LOD->LoadTexture(pTiles[i].pTileName); + if ( pTiles[i].uBitmapID != -1 ) + pBitmaps_LOD->pTextures[pTiles[i].uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pTiles[i].uBitmapID].palette_id1); + } + } +} + +//----- (00487ED6) -------------------------------------------------------- +int TileTable::GetTileForTerrainType( signed int terrain_type, bool not_random ) + { + int v5; // edx@3 + int v6; // edx@11 + + if ( not_random || terrain_type > 8 ) + { + return GetTileId(terrain_type, 0); + } + v5 = rand() % 50; + if ( v5 < 20) + { + return GetTileId(terrain_type, 0); + } + else if ( v5 < 30 ) + { + return GetTileId(terrain_type, 1); + } + else if ( v5 < 40 ) + { + return GetTileId(terrain_type, 2); + } + else if ( v5 < 48 ) + { + return GetTileId(terrain_type, 3); + } + v6 = rand() % 8; + return GetTileId(terrain_type, v6+4); + return 0; +} + +//----- (00487F84) -------------------------------------------------------- +unsigned int TileTable::GetTileId(unsigned int uTerrainType, unsigned int uSection) +{ + for (int i=0; ipTiles, 0x1Au, v1->sNumTiles, v3); + fclose(v3); +} + +//----- (00488000) -------------------------------------------------------- +void TileTable::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) +{ + uint num_mm6_tiles = data_mm6 ? *(int *)data_mm6 : 0, + num_mm7_tiles = data_mm7 ? *(int *)data_mm7 : 0, + num_mm8_tiles = data_mm8 ? *(int *)data_mm8 : 0; + sNumTiles = num_mm6_tiles + num_mm7_tiles + num_mm8_tiles; + Assert(sNumTiles); + Assert(!num_mm8_tiles); + + pTiles = (TileDesc *)malloc(sNumTiles * sizeof(TileDesc)); + memcpy(pTiles, (char *)data_mm7 + 4, num_mm7_tiles * sizeof(TileDesc)); + memcpy(pTiles + num_mm7_tiles, (char *)data_mm6 + 4, num_mm6_tiles * sizeof(TileDesc)); + memcpy(pTiles + num_mm6_tiles + num_mm7_tiles, (char *)data_mm8 + 4, num_mm8_tiles * sizeof(TileDesc)); +} + +//----- (00488047) -------------------------------------------------------- +int TileTable::FromFileTxt(const char *pFilename) +{ + TileTable *v2; // ebp@1 + FILE *v3; // eax@1 + unsigned int v4; // ebx@3 + void *v5; // eax@9 + unsigned __int16 v6; // ax@14 + const char *v7; // ST14_4@14 + unsigned __int16 v8; // ax@14 + const char *v9; // esi@14 + int v10; // eax@17 + int v11; // eax@20 + int v12; // eax@22 + int v13; // eax@24 + int v14; // eax@26 + int v15; // eax@28 + int v16; // eax@30 + int v17; // eax@32 + int v18; // eax@34 + int v19; // eax@36 + int v20; // eax@38 + int v21; // eax@40 + int v22; // eax@42 + int v23; // eax@44 + int v24; // eax@46 + int v25; // eax@48 + int v26; // eax@50 + int v27; // eax@52 + int v28; // eax@54 + int v29; // eax@56 + int v30; // eax@58 + int v31; // eax@60 + int v32; // eax@62 + int v33; // eax@64 + int v34; // eax@66 + const char *v35; // esi@67 + int v36; // eax@70 + int v37; // eax@73 + int v38; // eax@75 + int v39; // eax@77 + int v40; // eax@79 + int v41; // eax@81 + int v42; // eax@83 + int v43; // eax@85 + int v44; // eax@87 + int v45; // eax@89 + int v46; // eax@91 + int v47; // eax@93 + int v48; // eax@108 + int v49; // eax@110 + int v50; // eax@112 + int v51; // eax@114 + int v52; // eax@116 + int v53; // eax@118 + int v54; // eax@120 + int v55; // eax@122 + int v56; // eax@124 + int v57; // eax@126 + int v58; // eax@128 + int v59; // eax@130 + int v60; // eax@132 + int v61; // eax@134 + int v62; // eax@136 + int v63; // eax@138 + int v64; // eax@140 + int v65; // eax@142 + int v66; // eax@144 + int v67; // eax@146 + int v68; // eax@148 + int v69; // eax@150 + int v70; // eax@151 + int j; // edi@152 + const char *v72; // esi@153 + int v73; // eax@154 + int v74; // eax@156 + int v75; // eax@160 + int v76; // eax@162 + int v77; // eax@164 + int v78; // eax@166 + int v79; // eax@168 + int v80; // eax@170 + FILE *i; // [sp-10h] [bp-304h]@3 + FILE *File; // [sp+4h] [bp-2F0h]@1 + FrameTableTxtLine v84; // [sp+8h] [bp-2ECh]@4 + FrameTableTxtLine v85; // [sp+84h] [bp-270h]@4 + char Buf; // [sp+100h] [bp-1F4h]@4 + + v2 = this; + v3 = fopen(pFilename, "r"); + File = v3; + if ( !v3 ) + Error("TileTable::load - Unable to open file: %s."); + v4 = 0; + for ( i = v3; fgets(&Buf, 490, i); i = File ) + { + *strchr(&Buf, 10) = 0; + memcpy(&v84, txt_file_frametable_parser(&Buf, &v85), sizeof(v84)); + if ( v84.uPropCount && *v84.pProperties[0] != 47 ) + ++v4; + } + v2->sNumTiles = v4; + v5 = malloc(26 * v4); + v2->pTiles = (TileDesc *)v5; + if ( !v5 ) + Error("TileTable::Load - Out of Memory!"); + memset(v5, 0, 26 * v2->sNumTiles); + v2->sNumTiles = 0; + fseek(File, 0, 0); + if ( fgets(&Buf, 490, File) ) + { + while ( 1 ) + { + *strchr(&Buf, 10) = 0; + memcpy(&v84, txt_file_frametable_parser(&Buf, &v85), sizeof(v84)); + if ( v84.uPropCount ) + { + if ( *v84.pProperties[0] != 47 ) + break; + } +LABEL_173: + if ( !fgets(&Buf, 490, File) ) + goto LABEL_174; + } + strcpy(v2->pTiles[v2->sNumTiles].pTileName, v84.pProperties[0]); + v6 = atoi(v84.pProperties[1]); + v7 = v84.pProperties[2]; + v2->pTiles[v2->sNumTiles].uTileID = v6; + v8 = atoi(v7); + v9 = v84.pProperties[3]; + v2->pTiles[v2->sNumTiles].uBitmapID = v8; + v2->pTiles[v2->sNumTiles].tileset = Tileset_Grass; + if ( _stricmp(v9, "TTtype_NULL") ) + { + if ( _stricmp(v9, "TTtype_Start") ) + { + if ( _stricmp(v9, "TTtype_Grass") ) + { + if ( _stricmp(v9, "TTtype_Cracked") ) + { + if ( _stricmp(v9, "TTtype_Snow") ) + { + if ( _stricmp(v9, "TTtype_Sand") ) + { + if ( _stricmp(v9, "TTtype_Volcano") ) + { + if ( _stricmp(v9, "TTtype_Dirt") ) + { + if ( _stricmp(v9, "TTtype_Water") ) + { + if ( _stricmp(v9, "TTtype_Tropical") ) + { + if ( _stricmp(v9, "TTtype_Swamp") ) + { + if ( _stricmp(v9, "TTtype_City") ) + { + if ( _stricmp(v9, "TTtype_RoadGrassCobble") ) + { + if ( _stricmp(v9, "TTtype_RoadGrassDirt") ) + { + if ( _stricmp(v9, "TTtype_RoadCrackedCobble") ) + { + if ( _stricmp(v9, "TTtype_RoadCrackedDirt") ) + { + if ( _stricmp(v9, "TTtype_RoadSandCobble") ) + { + if ( _stricmp(v9, "TTtype_RoadSandDirt") ) + { + if ( _stricmp(v9, "TTtype_RoadVolcanoCobble") ) + { + if ( _stricmp(v9, "TTtype_RoadVolcanoDirt") ) + { + if ( _stricmp(v9, "TTtype_RoadSwampCobble") ) + { + if ( _stricmp(v9, "TTtype_RoadSwampDirt") ) + { + if ( _stricmp(v9, "TTtype_RoadTropicalCobble") ) + { + if ( _stricmp(v9, "TTtype_RoadTropicalDirt") ) + { + if ( _stricmp(v9, "TTtype_RoadSnowCobble") ) + { + if ( _stricmp(v9, "TTtype_RoadSnowDirt") ) + { + if ( !_stricmp(v9, "TTtype_RoadCityStone") ) + { + v34 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v34 |= 0x1Cu; + } + } + else + { + v33 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v33 |= 0xDu; + } + } + else + { + v32 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v32 |= 0xCu; + } + } + else + { + v31 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v31 |= 0x1Bu; + } + } + else + { + v30 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v30 |= 0x1Au; + } + } + else + { + v29 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v29 |= 0x19u; + } + } + else + { + v28 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v28 |= 0x18u; + } + } + else + { + v27 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v27 |= 0x11u; + } + } + else + { + v26 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v26 |= 0x10u; + } + } + else + { + v25 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v25 |= 0xFu; + } + } + else + { + v24 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v24 |= 0xEu; + } + } + else + { + v23 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v23 |= 0x17u; + } + } + else + { + v22 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v22 |= 0x16u; + } + } + else + { + v21 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v21 |= 0xBu; + } + } + else + { + v20 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v20 |= 0xAu; + } + } + else + { + v19 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v19 |= 9u; + } + } + else + { + v18 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v18 |= 7u; + } + } + else + { + v17 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v17 |= 8u; + } + } + else + { + v16 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v16 |= 5u; + } + } + else + { + v15 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v15 |= 4u; + } + } + else + { + v14 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v14 |= 3u; + } + } + else + { + v13 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v13 |= 2u; + } + } + else + { + v12 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v12 |= 1u; + } + } + else + { + v11 = (int)&v2->pTiles[v2->sNumTiles].tileset; + *(char *)v11 |= 6u; + } + } + } + else + { + v10 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v10 |= 0xFEu; + } + } + else + { + LOBYTE(v2->pTiles[v2->sNumTiles].tileset) = -1; + } + v35 = v84.pProperties[4]; + v2->pTiles[v2->sNumTiles].uSection = 0; + v2->pTiles[v2->sNumTiles].uAttributes = 0; + if ( !_stricmp(v35, "TTsect_NULL") ) + { + LOBYTE(v2->pTiles[v2->sNumTiles].uSection) = -1; +LABEL_152: + for ( j = 5; j < v84.uPropCount; ++j ) + { + v72 = v84.pProperties[j]; + if ( _stricmp(v84.pProperties[j], "TTattr_Burn") ) + { + if ( _stricmp(v72, "TTattr_Water") ) + { + if ( _stricmp(v72, "TTattr_Water2") ) + { + if ( _stricmp(v72, "TTattr_Block") ) + { + if ( _stricmp(v72, "TTattr_Repulse") ) + { + if ( _stricmp(v72, "TTattr_Flat") ) + { + if ( _stricmp(v72, "TTattr_Wave") ) + { + if ( _stricmp(v72, "TTattr_NoDraw") ) + { + if ( !_stricmp(v72, "TTattr_Transition") ) + { + v80 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(short *)v80 |= 0x200u; + } + } + else + { + v79 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(char *)v79 |= 0x40u; + } + } + else + { + v78 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(char *)v78 |= 0x20u; + } + } + else + { + v77 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(char *)v77 |= 0x10u; + } + } + else + { + v76 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(char *)v76 |= 8u; + } + } + else + { + v75 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(char *)v75 |= 4; + } + } + else + HIBYTE(v2->pTiles[v2->sNumTiles].uAttributes) |= 1; + } + else + { + v74 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(char *)v74 |= 2; + } + } + else + { + v73 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(char *)v73 |= 1u; + } + } + ++v2->sNumTiles; + goto LABEL_173; + } + if ( !_stricmp(v35, "TTsect_Start") ) + { + v36 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v36 |= 0xFEu; + goto LABEL_152; + } + if ( !_stricmp(v35, "TTsect_Base1") ) + goto LABEL_152; + if ( !_stricmp(v35, "TTsect_Base2") ) + { + v37 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v37 |= 1u; + goto LABEL_152; + } + if ( !_stricmp(v35, "TTsect_Base3") ) + { + v38 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v38 |= 2u; + goto LABEL_152; + } + if ( !_stricmp(v35, "TTsect_Base4") ) + { + v39 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v39 |= 3u; + goto LABEL_152; + } + if ( !_stricmp(v35, "TTsect_Special1") ) + { + v40 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v40 |= 4u; + goto LABEL_152; + } + if ( !_stricmp(v35, "TTsect_Special2") ) + { + v41 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v41 |= 5u; + goto LABEL_152; + } + if ( !_stricmp(v35, "TTsect_Special3") ) + { + v42 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v42 |= 6u; + goto LABEL_152; + } + if ( !_stricmp(v35, "TTsect_Special4") ) + { + v43 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v43 |= 7u; + goto LABEL_152; + } + if ( !_stricmp(v35, "TTsect_Special5") ) + { + v44 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v44 |= 8u; + goto LABEL_152; + } + if ( !_stricmp(v35, "TTsect_Special6") ) + { + v45 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v45 |= 9u; + goto LABEL_152; + } + if ( !_stricmp(v35, "TTsect_Special7") ) + { + v46 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v46 |= 0xAu; + goto LABEL_152; + } + if ( !_stricmp(v35, "TTsect_Special8") ) + { + v47 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v47 |= 0xBu; + goto LABEL_152; + } + if ( !_stricmp(v35, "TTsect_NE1") ) + goto LABEL_130; + if ( !_stricmp(v35, "TTsect_NW1") ) + goto LABEL_134; + if ( !_stricmp(v35, "TTsect_SE1") ) + goto LABEL_130; + if ( !_stricmp(v35, "TTsect_SW1") ) + goto LABEL_134; + if ( !_stricmp(v35, "TTsect_E1") ) + goto LABEL_138; + if ( !_stricmp(v35, "TTsect_W1") ) + goto LABEL_140; + if ( !_stricmp(v35, "TTsect_N1") ) + goto LABEL_142; + if ( !_stricmp(v35, "TTsect_S1") ) + goto LABEL_144; + if ( !_stricmp(v35, "TTsect_XNE1") ) + goto LABEL_146; + if ( _stricmp(v35, "TTsect_XNW1") ) + { + if ( !_stricmp(v35, "TTsect_XSE1") ) + goto LABEL_146; + if ( _stricmp(v35, "TTsect_XSW1") ) + { + if ( !_stricmp(v35, "TTsect_CROS") ) + { +LABEL_151: + v70 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; + *(short *)v70 |= 0x200u; + goto LABEL_152; + } + if ( !_stricmp(v35, "TTsect_NS") ) + { + v48 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v48 |= 1u; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_EW") ) + { + v49 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v49 |= 2u; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_N_E") ) + { + v50 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v50 |= 3u; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_N_W") ) + { + v51 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v51 |= 4u; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_S_E") ) + { + v52 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v52 |= 5u; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_S_W") ) + { + v53 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v53 |= 6u; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_NS_E") ) + { + v54 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v54 |= 7u; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_NS_W") ) + { + v55 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v55 |= 8u; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_EW_N") ) + { + v56 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v56 |= 9u; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_EW_S") ) + { + v57 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v57 |= 0xAu; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_NCAP") ) + { + v58 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v58 |= 0xBu; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_ECAP") ) + { +LABEL_130: + v59 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v59 |= 0xCu; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_SCAP") ) + { + v60 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v60 |= 0xDu; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_WCAP") ) + { +LABEL_134: + v61 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v61 |= 0xEu; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_DN") ) + { + v62 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v62 |= 0xFu; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_DS") ) + { +LABEL_138: + v63 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v63 |= 0x10u; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_DW") ) + { +LABEL_140: + v64 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v64 |= 0x11u; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_DE") ) + { +LABEL_142: + v65 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v65 |= 0x12u; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_DSW") ) + { +LABEL_144: + v66 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v66 |= 0x13u; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_DNE") ) + { +LABEL_146: + v67 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v67 |= 0x14u; + goto LABEL_151; + } + if ( !_stricmp(v35, "TTsect_DSE") ) + { + v68 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v68 |= 0x15u; + goto LABEL_151; + } + if ( _stricmp(v35, "TTsect_DNW") ) + goto LABEL_152; + } + } + v69 = (int)&v2->pTiles[v2->sNumTiles].uSection; + *(char *)v69 |= 0x16u; + goto LABEL_151; + } +LABEL_174: + fclose(File); + return 1; +} + diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Timer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Timer.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,108 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS + +#include "Timer.h" +#include "Keyboard.h" + +#include "OSAPI.h" + + + + + +Timer *pMiscTimer = new Timer; +Timer *pEventTimer; + + + + + + +//----- (00426317) -------------------------------------------------------- +unsigned __int64 Timer::Time() +{ + unsigned __int64 v2 = TimeQuant * timeGetTime() / 1000; + if (v2 < uStartTime) + uStartTime = 0; + return v2; +} + + + +//----- (00426349) -------------------------------------------------------- +void Timer::Pause() +{ + if (!bPaused) + { + uStopTime = Time(); + bPaused = true; + } +} + +//----- (00426363) -------------------------------------------------------- +void Timer::Resume() +{ + if (bPaused) + { + pKeyActionMap->ResetKeys();//Unhandled application exception + + bPaused = 0; + uStartTime = Time(); + } +} + +//----- (00426386) -------------------------------------------------------- +void Timer::TrackGameTime() +{ + if (!bTackGameTime) + { + uGameTimeStart = Time(); + bTackGameTime = true; + } +} + + + +//----- (004263A0) -------------------------------------------------------- +void Timer::StopGameTime() +{ + if (bTackGameTime) + { + bTackGameTime = 0; + uStartTime = Time(); + } +} + +//----- (004263B7) -------------------------------------------------------- +void Timer::Update() +{ + //Timer *v1; // esi@1 + //unsigned int v2; // eax@2 + //signed int v3; // eax@3 + //char v4; // zf@5 + + + unsigned __int64 new_time = Time(); + while (new_time <= uStartTime) + new_time = Time(); + + uTimeElapsed = new_time - uStartTime; + uStartTime = new_time; + + if (uTimeElapsed > 32) + uTimeElapsed = 32; + + if (!bPaused && !bTackGameTime) + uTotalGameTimeElapsed += uTimeElapsed; + dt_in_some_format = (uTimeElapsed << 16) / 128; +} + +//----- (00426402) -------------------------------------------------------- +void Timer::Initialize() +{ + uTotalGameTimeElapsed = 0; + bReady = true; +} diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/Timer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/Timer.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,58 @@ +#pragma once + + + + +/* 61 */ +#pragma pack(push, 1) +struct Timer +{ + static Timer *Create() {return new Timer;} + + Timer(): + bReady(false), bPaused(false) + { + bTackGameTime = 0; + uStartTime = 0; + uStopTime = 0; + uGameTimeStart = 0; + field_18 = 0; + uTimeElapsed = 0; + dt_in_some_format = 0; + uTotalGameTimeElapsed = 0; + } + + void Initialize(); + unsigned __int64 Time(); + void Update(); + void Pause(); + void Resume(); + void TrackGameTime(); + void StopGameTime(); + + unsigned int bReady; + unsigned int bPaused; + int bTackGameTime; + unsigned int uStartTime; + unsigned int uStopTime; + int uGameTimeStart; + int field_18; + unsigned int uTimeElapsed; + int dt_in_some_format; + unsigned int uTotalGameTimeElapsed; + + static const unsigned int TimeQuant = 128; + static const unsigned int Minute = 2 * TimeQuant; + static const unsigned int Hour = 60 * Minute; + static const unsigned int Day = 24 * Hour; + static const unsigned int Week = 7 * Day; + static const unsigned int Month = 4 * Week; + static const unsigned int Year = 12 * Month; +}; + +#pragma pack(pop) + + + +extern Timer *pMiscTimer; +extern Timer *pEventTimer; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/TurnEngine/TurnEngine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/TurnEngine/TurnEngine.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,1103 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS + + +#include "../MM7.h" +#include "../mm7_data.h" +#include "Engine/Objects/Actor.h" +#include "../Party.h" +#include "AudioPlayer.h" +#include "Engine/Objects/SpriteObject.h" +#include "../Timer.h" +#include "../stru298.h" +#include "Engine/Tables/IconFrameTable.h" +#include "Engine/Graphics/Viewport.h" +#include "Engine/Tables/FactionTable.h" + +#include "TurnEngine.h" + + +#include "../Game.h" +struct stru262_TurnBased *pTurnEngine = new stru262_TurnBased; + + +//----- (00404544) -------------------------------------------------------- +void stru262_TurnBased::SortTurnQueue() +{ + int active_actors; + TurnBased_QueueElem *current_top; // eax@16 + TurnBased_QueueElem *test_element; // ecx@18 + TurnBased_QueueElem temp_elem; + int i,j; + unsigned int p_type; + unsigned int p_id; + + active_actors = this->uActorQueueSize; + //set non active actors in queue initiative that not allow them to paticipate + for( i = 0; i < uActorQueueSize; ++i) + { + p_type = PID_TYPE(pQueue[i].uPackedID); + p_id = PID_ID(pQueue[i].uPackedID); + + if ( p_type == OBJECT_Actor ) + { + pActors[p_id].uAttributes |= ACTOR_STAND_IN_QUEUE;//0x80 + if ( !pActors[p_id].CanAct() ) + { + --active_actors; + pQueue[i].actor_initiative = 1001; + pActors[p_id].ResetQueue(); + } + } + else if ( p_type == OBJECT_Player) + { + if ( !pParty->pPlayers[p_id].CanAct() ) + { + --active_actors; + pQueue[i].actor_initiative = 1001; + } + } + } + //sort + if (uActorQueueSize > 0) + { + for( i = 0; i < uActorQueueSize-1; ++i) + { + current_top=&pQueue[i]; + for ( j = i+1; j < uActorQueueSize; ++j ) + { + test_element=&pQueue[j]; + if ( test_element->actor_initiative < current_top->actor_initiative || // if less initiative -> top + ((test_element->actor_initiative == current_top->actor_initiative) && + (((PID_TYPE(test_element->uPackedID) == OBJECT_Player) && (PID_TYPE(current_top->uPackedID) == OBJECT_Actor)) || //player preferable + ((PID_TYPE(test_element->uPackedID) == PID_TYPE(current_top->uPackedID)) && (PID_ID(test_element->uPackedID) < PID_ID(current_top->uPackedID)))))) //less id preferable + { //swap + memcpy(&temp_elem,current_top,sizeof(TurnBased_QueueElem)); + memcpy(current_top,test_element, sizeof(TurnBased_QueueElem)); + memcpy(test_element, &temp_elem, sizeof(TurnBased_QueueElem)); + } + } + } + } + uActorQueueSize = active_actors; + if ( PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) //we have player at queue top + { + uActiveCharacter = PID_ID(pQueue[0].uPackedID)+1; + field_18 |= TE_PLAYER_TURN; + } + else + { + uActiveCharacter = 0; + field_18 &= ~TE_PLAYER_TURN; + } + for ( i = 0; i < uActorQueueSize; ++i) + { + if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) //set recovery times + pParty->pPlayers[PID_ID(pQueue[i].uPackedID)].uTimeToRecovery = (unsigned __int16)((double)pQueue[i].actor_initiative * 0.46875); + } +} +//----- (0040471C) -------------------------------------------------------- +void stru262_TurnBased::ApplyPlayerAction() +{ + if ( pParty->bTurnBasedModeOn == 1 ) + { + if ( pTurnEngine->turn_stage == TE_ATTACK ) + _406457(0); + } +} + +//----- (004059DB) -------------------------------------------------------- +void stru262_TurnBased::Start() +{ + int v17; // edx@22 + AIDirection v30; // [sp+Ch] [bp-68h]@10 + AIDirection v31; // [sp+28h] [bp-4Ch]@10 + AIDirection a3; // [sp+44h] [bp-30h]@10 + int activ_players[4]; + int players_recovery_time[4]; + int a_players_count; + int i,j; + int temp; + + pTurnEngine->field_18 &= ~TE_HAVE_PENDING_ACTIONS; + pEventTimer->TrackGameTime(); + pAudioPlayer->StopChannels(-1, -1); + pAudioPlayer->PlaySound(SOUND_207, 0, 0, -1, 0, 0, 0, 0); + //pPlayer = pParty->pPlayers.data(); + dword_50C998_turnbased_icon_1A = 8 * pIconsFrameTable->pIcons[uIconID_TurnStart].uAnimLength; + dword_50C994 = 0; + + this->turn_initiative = 100; + this->turns_count = 0; + this->ai_turn_timer = 64; + this->turn_stage = TE_WAIT; + this->uActorQueueSize = 0; + + for ( uint pl_id = 0; pl_id < 4 ; ++pl_id ) + { + if ( pParty->pPlayers[pl_id].CanAct() ) + { + this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Player,pl_id); + this->pQueue[this->uActorQueueSize].AI_action_type = TE_AI_PURSUE; + this->pQueue[this->uActorQueueSize].uActionLength = 0; + pParty->pTurnBasedPlayerRecoveryTimes[this->uActorQueueSize] = 0; + ++this->uActorQueueSize; + } + } + + for ( int i = 0; i < ai_arrays_size ; ++i ) + { + if (ai_near_actors_ids[i] == 10) + continue; + if ( pActors[ai_near_actors_ids[i]].CanAct() ) + { + if ( pActors[ai_near_actors_ids[i]].ActorNearby() ) + { + pActors[ai_near_actors_ids[i]].uAttributes |= ACTOR_STAND_IN_QUEUE;//0x80 + Actor::GetDirectionInfo(PID(OBJECT_Actor,ai_near_actors_ids[i]), ai_near_actors_targets_pid[ai_near_actors_ids[i]], &v31, 0); + memcpy(&v30, &v31, sizeof(AIDirection)); + Actor::AI_StandOrBored(ai_near_actors_ids[i], 4, 32, &v30); + this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Actor,ai_near_actors_ids[i]); + this->pQueue[this->uActorQueueSize].AI_action_type = TE_AI_PURSUE; + this->pQueue[this->uActorQueueSize].uActionLength = 0; + ++this->uActorQueueSize; + } + } + } + + a_players_count = 0; + for ( int k = 0; k < this->uActorQueueSize; ++k ) + { + //set initial initiative for turn actors + if ( PID_TYPE(this->pQueue[k].uPackedID) == OBJECT_Player ) + { + if ( pPlayers[PID_ID(this->pQueue[k].uPackedID) + 1]->uTimeToRecovery != 0 ) + this->pQueue[k].actor_initiative = (signed int)((double)pPlayers[PID_ID(this->pQueue[k].uPackedID) + 1]->uTimeToRecovery * 0.46875); + else + { + activ_players[a_players_count] = k; + ++a_players_count; + } + } + else if ( PID_TYPE(this->pQueue[k].uPackedID) == OBJECT_Actor ) + { + v17 = rand() % 99; + if ( v17 < 33 ) + this->pQueue[k].actor_initiative = 1; + else + this->pQueue[k].actor_initiative= (v17 >= 66)? 5 : 3; + } + else //fot non player and actor + this->pQueue[k].actor_initiative = 666; + this->pQueue[k].actor_initiative += 16; + } + + if ( a_players_count > 0 ) + { + for ( i = 0; i < a_players_count; ++i) + players_recovery_time[i] = pParty->pPlayers[PID_ID(this->pQueue[activ_players[i]].uPackedID)].GetAttackRecoveryTime(0); + //sort players by recovery time + for ( i = 0; i < a_players_count-1; ++i) + { + for ( j = i + 1; j < a_players_count; ++j ) + { + if (players_recovery_time[j] < players_recovery_time[i]) //swap values + { + temp = players_recovery_time[i]; + players_recovery_time[i] = players_recovery_time[j]; + players_recovery_time[j] = temp; + temp = activ_players[i]; + activ_players[i] = activ_players[j]; + activ_players[j] = temp; + } + } + } + for ( i = 0; i < a_players_count; ++i) + this->pQueue[activ_players[i]].actor_initiative = i + 2; + } + this->SortTurnQueue(); +} + +//----- (00405CFF) -------------------------------------------------------- +void stru262_TurnBased::End(bool bPlaySound) +{ + ObjectType objType; // eax@13 + int objID; // esi@13 + int i; + + this->turn_stage = TE_NONE; + for( i = 0; i < uActorQueueSize; ++i) + { + if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor ) + pActors[PID_ID(pQueue[i].uPackedID)].ResetQueue(); + } + + for( uint i = 0; i < uNumSpriteObjects; ++i) + { + if (pSpriteObjects[i].uAttributes & 4) + pSpriteObjects[i].uAttributes &= ~0x04; + } + + for( i = 0; i < uActorQueueSize; ++i) + { + objType = (ObjectType)PID_TYPE(pQueue[i].uPackedID); + objID = PID_ID(pQueue[i].uPackedID); + if ( objType == OBJECT_Player ) + pPlayers[objID + 1]->uTimeToRecovery = (unsigned __int16)((double)pQueue[i].actor_initiative * 2.133333333333333); + else if ( objType == OBJECT_Actor ) + pActors[objID].pMonsterInfo.uRecoveryTime = (unsigned __int16)((double)pQueue[i].actor_initiative * 2.133333333333333); + } + pAudioPlayer->StopChannels(-1, -1); + if ( bPlaySound != 0 ) + pAudioPlayer->PlaySound(SOUND_206, 0, 0, -1, 0, 0, 0, 0); + pTurnEngine->field_18 &= ~TE_HAVE_PENDING_ACTIONS; + pEventTimer->StopGameTime(); + dword_50C994 = 0; + dword_50C998_turnbased_icon_1A = 0; +} +// 50C994: using guessed type int dword_50C994; +// 50C998: using guessed type int dword_50C998_turnbased_icon_1A; + +//----- (00405E14) -------------------------------------------------------- +void stru262_TurnBased::AITurnBasedAction() +{ + AIDirection v6; // esi@21 + AIDirection a3; // [sp+4h] [bp-68h]@21 + AIDirection v14; // [sp+20h] [bp-4Ch]@21 + AIDirection v15; // [sp+3Ch] [bp-30h]@21 + Actor *curr_actor; // [sp+58h] [bp-14h]@2 + int target_pid; // [sp+5Ch] [bp-10h]@6 + int shrinked; + int j; + + for (uint i = 0; i < uNumActors; ++i ) + { + curr_actor=&pActors[i]; + shrinked=pActors[i].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime > 0; + for (j = 0; j < 22; ++j) //check expired spell Buffs + { + if (j != 10) + pActors[i].pActorBuffs[j].IsBuffExpiredToTime(pParty->uTimePlayed); + } + if (shrinked && pActors[i].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime <= 0) //buff 3 expired + pActors[i].uActorHeight = pMonsterList->pMonsters[pActors[i].pMonsterInfo.uID - 1].uMonsterHeight; + if (!(curr_actor->uAttributes & 0x80) && (!curr_actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) && + (!curr_actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime)) + { + curr_actor->uCurrentActionTime += pMiscTimer->uTimeElapsed; + if (curr_actor->uCurrentActionTime>=curr_actor->uCurrentActionLength) + { + target_pid = ai_near_actors_targets_pid[i]; + Actor::GetDirectionInfo(PID(OBJECT_Actor,i), target_pid, &v6, 0); + memcpy(&v15, &v6, sizeof(AIDirection)); + memcpy(&v14, &v15, sizeof(AIDirection)); + if ( curr_actor->uAIState == Dying ) + { + curr_actor->uCurrentActionTime = 0; + curr_actor->uCurrentActionLength = 0; + curr_actor->uAIState = Dead; + curr_actor->UpdateAnimation(); + } + else if ( (curr_actor->uAIState > Removed) && (curr_actor->uAIState < Disabled)) + Actor::AI_StandOrBored(i, target_pid, 32, &v14); + } + } + } + if ( turn_stage == TE_WAIT ) + { + if ( ai_turn_timer == 64 ) + ActorAISetMovementDecision(); + else if ( ai_turn_timer > 0 ) + ActorAIDoAdditionalMove(); + else + { + ActorAIStopMovement(); + turn_initiative = 100; + } + ai_turn_timer -= pEventTimer->uTimeElapsed; + } + else if ( turn_stage == TE_ATTACK ) + { + if ( !(field_18 &TE_FLAG_1)) + { + if ( turn_initiative == 100 ) + { + StartTurn(); + SetAIRecoveryTimes(); + return; + } + if ( turn_initiative > 0 || pQueue[0].actor_initiative <= 0 ) + { + _4065B0(); + SetAIRecoveryTimes(); + return; + } + } + NextTurn(); + } + else if ( turn_stage == TE_MOVEMENT ) + { + if ( (uActionPointsLeft > 0) && (!(field_18 & TE_FLAG_8)) ) + ActorAIChooseNewTargets(); + else + { + field_18 &= ~TE_FLAG_8; + turn_stage = TE_WAIT; + ai_turn_timer = 64; + } + } +} + + +//----- (00406051) -------------------------------------------------------- +void stru262_TurnBased::StartTurn() +{ + int player_num, actor_num, i, j; + + pending_actions = 0; + //add player to queue if he can act + for ( player_num = 0; player_num < 4; ++player_num) + { + for ( j = 0; j < uActorQueueSize; ++j ) + { + if (PID_TYPE(pQueue[j].uPackedID) == OBJECT_Player) + { + if (pPlayers[PID_ID(pQueue[j].uPackedID) + 1]->CanAct() && (player_num != PID_ID(pQueue[j].uPackedID)) ) + break; + } + } + if ( j == uActorQueueSize ) + { + pQueue[uActorQueueSize].uPackedID = PID(OBJECT_Player,player_num); + pQueue[uActorQueueSize].actor_initiative = 100; + pQueue[uActorQueueSize].uActionLength = 0; + pQueue[uActorQueueSize].AI_action_type = TE_AI_STAND; + ++uActorQueueSize; + } + } + //add new arrived actors + for ( actor_num = 0; actor_num < ai_arrays_size; ++actor_num ) + { + for ( j = 0; j < uActorQueueSize; ++j ) + { + if ((PID_TYPE(pQueue[j].uPackedID)== OBJECT_Actor)&& + ai_near_actors_ids[actor_num] == PID_ID(pQueue[j].uPackedID)) + break; + } + if ( j == uActorQueueSize ) + { + pQueue[uActorQueueSize].uPackedID = PID(OBJECT_Actor,ai_near_actors_ids[actor_num]); + pQueue[uActorQueueSize].actor_initiative = 1; + pQueue[uActorQueueSize].uActionLength = 0; + pQueue[uActorQueueSize].AI_action_type = TE_AI_STAND; + ++uActorQueueSize; + } + } + ++turns_count; + turn_initiative = 100; + for ( i = 0; i < uActorQueueSize; ++i ) + { + if (pQueue[i].actor_initiative == 0 ) + pQueue[i].actor_initiative = 100; + } + StepTurnQueue(); + for ( i = 0; i < uActorQueueSize; ++i ) + { + if ((PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) || (pQueue[i].actor_initiative > 0)) + break; + AI_Action_(i); + } +} +// 4F75D8: using guessed type int ai_arrays_size; + + //----- (004061CA) -------------------------------------------------------- + void stru262_TurnBased::NextTurn() +{ + int v13; // [sp+10h] [bp-4h]@7 + int monster_id; // eax@5 + + SortTurnQueue(); + if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) + uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1; + else + uActiveCharacter = 0; + viewparams->bRedrawGameUI = true; + + if ( pending_actions ) + { + pTurnEngine->field_18 |= TE_HAVE_PENDING_ACTIONS; + return; + } + pTurnEngine->field_18 &= ~TE_HAVE_PENDING_ACTIONS; + if ( pQueue[0].actor_initiative <= 0 ) + return; + + v13 = 0; + if (uActorQueueSize > 0 ) + { + for ( int i = 0; i < uActorQueueSize; ++i ) + { + if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) + { + monster_id = PID_ID(pQueue[i].uPackedID); + if ( (pActors[monster_id].uAIState == Dying) || (pActors[monster_id].uAIState == Stunned) + || (pActors[monster_id].uAIState == AttackingMelee) || (pActors[monster_id].uAIState == AttackingRanged1) + || (pActors[monster_id].uAIState == AttackingRanged2) || (pActors[monster_id].uAIState == AttackingRanged3) + || (pActors[monster_id].uAIState == AttackingRanged4) || (pActors[monster_id].uAIState == Summoned)) + { + pActors[monster_id].uCurrentActionTime += pEventTimer->uTimeElapsed; + if ( pActors[monster_id].uCurrentActionTime < pActors[monster_id].uCurrentActionLength ) + v13 = 1; + else if ( pActors[monster_id].uAIState == Dying )// Dying + { + pActors[monster_id].uAIState = Dead; + pActors[monster_id].uCurrentActionTime = 0; + pActors[monster_id].uCurrentActionLength = 0; + pActors[monster_id].UpdateAnimation(); + } + else + { + if ( pActors[monster_id].uAIState == Stunned ) //Stunned + Actor::AI_StandOrBored(monster_id, ai_near_actors_targets_pid[monster_id], 32, 0); + } + } + } + } + if ( v13 != 0 ) + { + field_18 |= TE_FLAG_1; + return; + } + } + + field_18 &= ~TE_FLAG_1; + //set all actors to stay + for ( int i = 0; i < uActorQueueSize; ++i ) + { + if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) + { + monster_id = PID_ID(pQueue[i].uPackedID); + if ((pActors[monster_id].uAIState != Dead) && (pActors[monster_id].uAIState != Dying) && + (pActors[monster_id].uAIState != Removed) && (pActors[monster_id].uAIState != Summoned) && + (pActors[monster_id].uAIState != Disabled)) + { + pQueue[i].uActionLength = 0; + Actor::AI_StandOrBored(monster_id, ai_near_actors_targets_pid[monster_id], 32, nullptr); + } + } + } + // turn tick + turn_stage = TE_MOVEMENT; + pParty->uTimePlayed += 213i64; + _494035_timed_effects__water_walking_damage__etc(); + uActionPointsLeft = 130; +} + +//----- (004063A1) -------------------------------------------------------- +bool stru262_TurnBased::StepTurnQueue() +{ + int v9; // dx@12 + int j; + + SortTurnQueue(); + viewparams->bRedrawGameUI = 1; + if ( pQueue[0].actor_initiative != 0 ) + { + if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) + { + do + { + for (j = 0; j < uActorQueueSize; ++j ) + --pQueue[j].actor_initiative; + --turn_initiative; + if (turn_initiative == 0) + return true; + } + while (pQueue[0].actor_initiative != 0); + } + else + { + if ( pQueue[0].actor_initiative > 0 ) + { + v9 = pActors[PID_ID(pQueue[0].uPackedID)].uAIState; + if (!(v9 == Dying || v9 == Dead || + v9 == Disabled || v9 == Removed)) + { + do + { + for ( j = 0; j < uActorQueueSize; ++j ) + { + --pQueue[j].actor_initiative; + if (pQueue[j].actor_initiative == 0) + pQueue[j].uActionLength = 0; + } + --turn_initiative; + if (turn_initiative == 0) + return true; + } + while (pQueue[0].actor_initiative > 0); + } + } + } + } + return false; +} + +//----- (00406457) -------------------------------------------------------- +void stru262_TurnBased::_406457( int a2 ) +{ + signed int v4; // ecx@2 + signed int v6; // eax@2 + int i; + v6 = 0; + if ( PID_TYPE(pQueue[a2].uPackedID) == OBJECT_Player) + { + v4 = PID_ID(pQueue[a2].uPackedID); + if ( pParty->pTurnBasedPlayerRecoveryTimes[v4] ) + pParty->pTurnBasedPlayerRecoveryTimes[v4] = 0; + else + v6 = pPlayers[v4 + 1]->GetAttackRecoveryTime(0); + if ( v6 < 30 ) + v6 = 30; + } + else + v6 = pMonsterStats->pInfos[pActors[PID_ID(pQueue[a2].uPackedID)].pMonsterInfo.uID].uRecoveryTime; + + pQueue[a2].actor_initiative = v6; + SortTurnQueue(); + if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) + uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1; + else + uActiveCharacter = 0; + viewparams->bRedrawGameUI = 1; + while ( (pQueue[0].actor_initiative > 0) && (turn_initiative > 0) ) + { + for ( i = 0; i < uActorQueueSize; ++i) + { + --pQueue[i].actor_initiative; + if (pQueue[i].actor_initiative == 0) + pQueue[i].uActionLength=0; + } + --turn_initiative; + } +} + +//----- (0040652A) -------------------------------------------------------- +void stru262_TurnBased::SetAIRecoveryTimes() +{ + int i; + int monster_ai_state; + Actor *monster; // eax@5 + + for ( i = 0; i < uActorQueueSize; ++i ) + { + if (pQueue[i].actor_initiative == 0) + { + if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) + break; + monster=&pActors[PID_ID(pQueue[i].uPackedID)]; + monster_ai_state=monster->uAIState; + if (monster_ai_state == Standing || + monster_ai_state == Fleeing || + monster_ai_state == Fidgeting) + { + pQueue[i].actor_initiative = pMonsterStats->pInfos[monster->pMonsterInfo.uID].uRecoveryTime; + if (monster->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0) + pQueue[i].actor_initiative*=2; + } + } + } +} + +//----- (004065B0) -------------------------------------------------------- +void stru262_TurnBased::_4065B0() +{ + int i; + + SortTurnQueue(); + if (pQueue[0].actor_initiative <= 0) + { + for ( i = 0; i < uActorQueueSize; ++i ) + { + if ((PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player)|| (pQueue[i].actor_initiative > 0) ) + break; + if ((pQueue[i].uActionLength <= 0) && (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)) + AI_Action_(i); + } + } + else + { + StepTurnQueue(); + if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) + uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1; + else + uActiveCharacter = 0; + viewparams->bRedrawGameUI = 1; + } + for ( i = 0; i < uActorQueueSize; ++i ) + AIAttacks(i); +} + +//----- (00406648) -------------------------------------------------------- +void stru262_TurnBased::AIAttacks( unsigned int queue_index ) +{ + //TurnBased_QueueElem *v1; // ecx@1 + //int v3; // eax@1 + unsigned int actor_id; // ebx@2 + //Actor *v5; // esi@2 + char v19; // al@24 + AIDirection a3; // [sp+Ch] [bp-3Ch]@2 + AIDirection a4; // [sp+28h] [bp-20h]@2 + //TurnBased_QueueElem *v28; // [sp+44h] [bp-4h]@1 + //unsigned int a2a; // [sp+50h] [bp+8h]@2 + + //v1 = &pQueue[queue_index]; + //v28 = v1; + //v3 = pQueue[queue_index].uPackedID; + if (PID_TYPE(pQueue[queue_index].uPackedID) == OBJECT_Actor) + { + actor_id = PID_ID(pQueue[queue_index].uPackedID); + //a2a = ai_near_actors_targets_pid[v4]; + Actor::GetDirectionInfo(pQueue[queue_index].uPackedID, ai_near_actors_targets_pid[actor_id], &a3, 0); + memcpy(&a4, &a3, sizeof(a4)); + //v5 = &pActors[v4]; + //LOWORD(v3) = v5->uAIState; + if (( pActors[actor_id].uAIState != Dead ) && ( pActors[actor_id].uAIState != Disabled ) + &&( pActors[actor_id].uAIState != Removed )) + { + pActors[actor_id].uCurrentActionTime += pEventTimer->uTimeElapsed; + if ( (signed int)pActors[actor_id].uCurrentActionTime >= pActors[actor_id].uCurrentActionLength ) + { + switch (pActors[actor_id].uAIState) + { + case AttackingMelee: + v19 = pActors[actor_id].special_ability_use_check(actor_id); + AttackerInfo.Add( pQueue[queue_index].uPackedID, 5120, pActors[actor_id].vPosition.x, pActors[actor_id].vPosition.y, + pActors[actor_id].vPosition.z + ((signed int)pActors[actor_id].uActorHeight >> 1), v19, 1); + Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0, &a4); + break; + case AttackingRanged1: + Actor::AI_RangedAttack(actor_id, &a4, pActors[actor_id].pMonsterInfo.uMissleAttack1Type, 0); + Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0,&a4); + break; + case Dying: + pActors[actor_id].uCurrentActionTime = 0; + pActors[actor_id].uCurrentActionLength = 0; + pActors[actor_id].uAIState = Dead; + pActors[actor_id].UpdateAnimation(); + break; + case Stunned: + Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0,&a4); + break; + case AttackingRanged2: + Actor::AI_RangedAttack(actor_id, &a4, pActors[actor_id].pMonsterInfo.uMissleAttack2Type, 1); + Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0,&a4); + break; + case AttackingRanged3: + Actor::AI_SpellAttack(actor_id, &a4, pActors[actor_id].pMonsterInfo.uSpell1ID, 2, pActors[actor_id].pMonsterInfo.uSpellSkillAndMastery1); + Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0, &a4); + break; + case AttackingRanged4: + Actor::AI_SpellAttack(actor_id, &a4, pActors[actor_id].pMonsterInfo.uSpell2ID, 3, pActors[actor_id].pMonsterInfo.uSpellSkillAndMastery2); + Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0, &a4); + break; + default: + if ( !(rand() % 2) ) + Actor::AI_Bored(actor_id, ai_near_actors_targets_pid[actor_id], &a4); + else + Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 64,&a4); + } + } + } + } +} +// 50FE08: using guessed type stru298 AttackerInfo; + +//----- (0040680F) -------------------------------------------------------- +void stru262_TurnBased::AI_Action_( int queue_index ) +{ + unsigned int actor_id; // edi@2 + AIDirection v7; // esi@10 + int v9; // ecx@10 + signed int v10; // eax@13 + int v14; // eax@29 + AIDirection a3; // [sp+Ch] [bp-44h]@10 + AIDirection v18; // [sp+28h] [bp-28h]@10 + signed int v22; // [sp+58h] [bp+8h]@10 + + pQueue[queue_index].uActionLength = 0; + if (PID_TYPE(pQueue[queue_index].uPackedID) == OBJECT_Actor) + { + actor_id = PID_ID(pQueue[queue_index].uPackedID); + if (!(pActors[actor_id].uAIState == Dying || pActors[actor_id].uAIState == Dead || pActors[actor_id].uAIState == Summoned || + pActors[actor_id].uAIState == Disabled || pActors[actor_id].uAIState == Removed)) + { + Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); + v22 = ai_near_actors_targets_pid[actor_id]; + if ( pActors[actor_id].pMonsterInfo.uHostilityType && !v22) + pActors[actor_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), v22, &v7, 0); + memcpy(&a3, &v7, sizeof(AIDirection)); + memcpy(&v18, &a3, sizeof(AIDirection)); + v9 = a3.uDistance - pActors[actor_id].uActorRadius; + if ( v9 < 0 ) + v9 = 0; + if (PID_TYPE(v22) == OBJECT_Actor) + //v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3); + v10 = pFactionTable->relations[(pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID) / 3 + 1][(pActors[actor_id].pMonsterInfo.uID - 1) / 3 + 1]; + else + v10 = 4; + switch (v10) + { + case 1: + if ( (double)(signed int)v9 < 307.2 ) + pActors[actor_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + break; + case 2: + if ( v9 < 1024 ) + pActors[actor_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + break; + case 3: + if ( v9 < 2560 ) + pActors[actor_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + break; + case 4: + if ( v9 < 5120 ) + pActors[actor_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + break; + } + if ( pActors[actor_id].pMonsterInfo.uHostilityType == 4 && v22 && (signed int)v9 < 5120 ) + { + v14 = pActors[actor_id].special_ability_use_check(actor_id); + pQueue[queue_index].AI_action_type = TE_AI_STAND; + switch (v14) + { + case 1: + if ( pActors[actor_id].pMonsterInfo.uMissleAttack2Type ) + { + Actor::AI_MissileAttack2(actor_id, v22, &v18); + pQueue[queue_index].AI_action_type = TE_AI_RANGED_ATTACK; + } + break; + case 2: + if ( pActors[actor_id].pMonsterInfo.uSpell1ID ) + { + Actor::AI_SpellAttack1(actor_id, v22, &v18); + pQueue[queue_index].AI_action_type = TE_AI_RANGED_ATTACK; + } + break; + case 3: + if (pActors[actor_id].pMonsterInfo.uSpell2ID) + { + Actor::AI_SpellAttack2(actor_id, v22, &v18); + pQueue[queue_index].AI_action_type = TE_AI_RANGED_ATTACK; + } + break; + default: + if ( pActors[actor_id].pMonsterInfo.uMissleAttack1Type ) + { + Actor::AI_MissileAttack1(actor_id, v22, &v18); + pQueue[queue_index].AI_action_type = TE_AI_RANGED_ATTACK; + } + } + //if (!pQueue[queue_index].AI_action_type) + if ( (double)v9 < 307.2) + { + Actor::AI_MeleeAttack(actor_id, v22, &v18); + pQueue[queue_index].AI_action_type = TE_AI_MELEE_ATTACK; + pQueue[queue_index].uActionLength = pActors[actor_id].uCurrentActionLength; + return; + } + else + { + Actor::AI_Stand(actor_id, v22, 64, &v18); + pQueue[queue_index].AI_action_type = TE_AI_STAND; + pQueue[queue_index].uActionLength = pActors[actor_id].uCurrentActionLength; + return; + } + } + else + { + Actor::AI_Stand(actor_id, v22, 64, &v18); + pQueue[queue_index].AI_action_type = TE_AI_STAND; + } + pQueue[queue_index].uActionLength = pActors[actor_id].uCurrentActionLength; + } + } +} + +//----- (00406A63) -------------------------------------------------------- +void stru262_TurnBased::ActorAISetMovementDecision() +{ + AIDirection a3; // [sp+8h] [bp-44h]@5 + AIDirection v7; // [sp+24h] [bp-28h]@5 + unsigned int target_pid; // [sp+40h] [bp-Ch]@5 + int i; + + this->ai_turn_timer = 64; + dword_50C994 = 0; + uActiveCharacter = 0; + for ( i = 0; i < uActorQueueSize; ++i ) + { + if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) + { + target_pid = ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)]; + Actor::GetDirectionInfo(pQueue[i].uPackedID, target_pid, &v7, 0); + if ( !ActorMove(i) ) + Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), target_pid, 32, &v7); + } + } +} +// 50C994: using guessed type int dword_50C994; + +//----- (00406AFE) -------------------------------------------------------- +void stru262_TurnBased::ActorAIStopMovement() +{ + AIDirection a3; // [sp+4h] [bp-48h]@5 + AIDirection v7; // [sp+20h] [bp-2Ch]@5 + unsigned int target_pid; + int i; + + for ( i = 0; i < uActorQueueSize; ++i ) + { + if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) + { + target_pid = ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)]; + Actor::GetDirectionInfo(pQueue[i].uPackedID, target_pid, &v7, 0); + Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), target_pid, 32, &v7); + pQueue[i].AI_action_type = TE_AI_STAND; + pQueue[i].uActionLength = 0; + } + } + turn_stage = TE_ATTACK; + ai_turn_timer = 100; +} + +//----- (00406B9F) -------------------------------------------------------- +void stru262_TurnBased::ActorAIDoAdditionalMove() +{ + AIDirection a3; // [sp+0h] [bp-50h]@15 + AIDirection v9; // [sp+1Ch] [bp-34h]@15 + unsigned int v13; // [sp+44h] [bp-Ch]@8 + unsigned int monster_id; + + for ( int i = 0; i < uActorQueueSize; ++i ) + { + if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) + { + monster_id = PID_ID(pQueue[i].uPackedID); + if ( !(pActors[monster_id].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0|| (pActors[monster_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0) || + pActors[monster_id].uAIState == Dead || pActors[monster_id].uAIState == Removed || pActors[monster_id].uAIState == Disabled) ) + { + v13 = ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)]; + Actor::GetDirectionInfo(pQueue[i].uPackedID, v13, &v9, 0); + if ( pActors[monster_id].uAIState == Pursuing || pActors[monster_id].uAIState == Tethered ) + { + if ( (double)(signed int)v9.uDistance < 307.2 ) + Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), v13, 32, &v9); + } + else + { + pActors[monster_id].uCurrentActionTime += pEventTimer->uTimeElapsed; + if ( pActors[monster_id].uCurrentActionTime > pActors[monster_id].uCurrentActionLength ) + { + if ( pActors[monster_id].uAIState == Dying ) + { + pActors[monster_id].uCurrentActionTime = 0; + pActors[monster_id].uCurrentActionLength = 0; + pActors[monster_id].uAIState = Dead; + pActors[monster_id].UpdateAnimation(); + } + if ( !ActorMove(i) ) + Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), v13, 32, &v9); + } + } + } + } + } +} + +//----- (00406D10) -------------------------------------------------------- +bool stru262_TurnBased::ActorMove(signed int queue_position) +{ + AIDirection v9; // esi@10 + int v11; // ecx@10 + unsigned __int8 pHostileType; // al@12 + AIDirection a3; // [sp+Ch] [bp-48h]@10 + AIDirection pDir; // [sp+28h] [bp-2Ch]@10 + unsigned int uActorID; // [sp+50h] [bp-4h]@2 + + if (PID_TYPE(pQueue[queue_position].uPackedID) == OBJECT_Player) + return 0; + uActorID = PID_ID(pQueue[queue_position].uPackedID); + if ( pActors[uActorID].uAIState == Dead || pActors[uActorID].uAIState == Dying || + pActors[uActorID].uAIState == Removed|| pActors[uActorID].uAIState == Disabled || + pActors[uActorID].uAIState == Summoned ) + return 1; + Actor::_SelectTarget(uActorID, &ai_near_actors_targets_pid[uActorID], true); + if ( pActors[uActorID].pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[uActorID] ) + pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + Actor::GetDirectionInfo(pQueue[queue_position].uPackedID, ai_near_actors_targets_pid[uActorID], &v9, 0); + memcpy(&a3, &v9, sizeof(AIDirection)); + memcpy(&pDir, &a3, sizeof(AIDirection)); + v11 = a3.uDistance - pActors[uActorID].uActorRadius; + if ( v11 < 0 ) + v11 = 0; + pHostileType = pActors[uActorID].pMonsterInfo.uHostilityType; + switch (pHostileType) + { + case 1: + if ( (double)v11 < 307.2 ) + pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + break; + case 2: + if ( v11 < 1024 ) + pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + break; + case 3: + if ( v11 < 2560 ) + pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + break; + } + if ( pActors[uActorID].pActorBuffs[ACTOR_BUFF_AFRAID].uExpireTime > 0 ) + { + if (v11 < 10240 ) + { + Actor::AI_Flee(uActorID, ai_near_actors_targets_pid[uActorID], 0, &pDir); + pTurnEngine->pQueue[queue_position].AI_action_type = 4; + } + else + { + Actor::AI_RandomMove(uActorID, ai_near_actors_targets_pid[uActorID], 1024, 0); + pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_PURSUE; + } + pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength; + return true; + } + if ( pActors[uActorID].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long ) + { + if ( !(pActors[uActorID].uAttributes & ACTOR_FLEEING) || pActors[uActorID].pMonsterInfo.uAIType == 1 ) + { + if ( pActors[uActorID].pMonsterInfo.uAIType == 1 ) + { + if ( pActors[uActorID].pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) + Actor::AI_Stand(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0); + else + Actor::AI_Flee(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0); + pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_FLEE; + pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength; + return true; + } + if ( pActors[uActorID].pMonsterInfo.uAIType == 2 ) + { + if (((double)pActors[uActorID].pMonsterInfo.uHP * 0.2) > (double)pActors[uActorID].sCurrentHP && (v11 < 10240 ) ) + { + if ( pActors[uActorID].pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) + Actor::AI_Stand(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0); + else + Actor::AI_Flee(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0); + pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_FLEE; + pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength; + return true; + } + } + if ( pActors[uActorID].pMonsterInfo.uAIType == 3 ) + { + if ( ((double)pActors[uActorID].pMonsterInfo.uHP * 0.1) > (double)pActors[uActorID].sCurrentHP && (v11 < 10240 )) + { + if ( pActors[uActorID].pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) + Actor::AI_Stand(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0); + else + Actor::AI_Flee(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0); + pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_FLEE; + pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength; + return true; + } + } + } + if ( (double)(signed int)v11 < 307.2 ) + return 0; + if ( (signed int)v11 < 5120 ) + { + if ( pActors[uActorID].pMonsterInfo.uMissleAttack1Type && (signed int)v11 < 1024 ) + Actor::AI_Pursue1(uActorID, ai_near_actors_targets_pid[uActorID], uActorID, 32, &pDir); + else + Actor::AI_Pursue2(uActorID, ai_near_actors_targets_pid[uActorID], 32, &pDir, 307); + pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_PURSUE; + pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength; + return true; + } + } + switch(pActors[uActorID].pMonsterInfo.uMovementType) + { + case MONSTER_MOVEMENT_TYPE_SHORT: + Actor::AI_RandomMove(uActorID, ai_near_actors_targets_pid[uActorID], 1024, 32); + break; + case MONSTER_MOVEMENT_TYPE_MEDIUM: + Actor::AI_RandomMove(uActorID, ai_near_actors_targets_pid[uActorID], 2560, 32); + break; + case MONSTER_MOVEMENT_TYPE_LONG: + Actor::AI_RandomMove(uActorID, ai_near_actors_targets_pid[uActorID], 5120, 32); + break; + case MONSTER_MOVEMENT_TYPE_FREE: + Actor::AI_RandomMove(uActorID, ai_near_actors_targets_pid[uActorID], 10240, 32); + break; + case MONSTER_MOVEMENT_TYPE_STAIONARY: + Actor::AI_Stand(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0); + break; + default: + return true; + } + pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_PURSUE; + pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength; + return true; +} + + //----- (00406FA8) -------------------------------------------------------- +void stru262_TurnBased::ActorAIChooseNewTargets() +{ + Actor *curr_acror; // ebx@4 + AIDirection a3; // [sp+Ch] [bp-6Ch]@8 + AIDirection v9; // [sp+28h] [bp-50h]@8 + AIDirection a4; // [sp+44h] [bp-34h]@8 + unsigned int target_pid; // [sp+60h] [bp-18h]@1 + int uActorID; // [sp+68h] [bp-10h]@4 + int i; + + for ( i = 0; i < uActorQueueSize; ++i ) + { + if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) + { + uActorID=PID_ID(pQueue[i].uPackedID); + curr_acror = &pActors[uActorID]; + if ( !( curr_acror->uAIState == Summoned|| curr_acror->uAIState == Dead || + curr_acror->uAIState == Removed || curr_acror->uAIState == Disabled) ) + { + target_pid = ai_near_actors_targets_pid[uActorID]; + Actor::_SelectTarget(uActorID, &ai_near_actors_targets_pid[uActorID], true); + Actor::GetDirectionInfo(pQueue[i].uPackedID, target_pid, &v9, 0); + memcpy(&a4, &v9, sizeof(AIDirection)); + curr_acror->uCurrentActionTime += pEventTimer->uTimeElapsed; + if ( curr_acror->uCurrentActionTime > curr_acror->uCurrentActionLength ) + { + if ( curr_acror->uAIState == Dying ) + { + curr_acror->uCurrentActionTime = 0; + curr_acror->uCurrentActionLength = 0; + curr_acror->uAIState = Dead; + curr_acror->UpdateAnimation(); + break; + } + if ( rand() % 2 ) + Actor::AI_Stand(uActorID, target_pid, 64, &a4); + else + Actor::AI_Bored(uActorID, target_pid, &a4); + } + } + } + } +} + diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/TurnEngine/TurnEngine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/TurnEngine/TurnEngine.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,97 @@ +#pragma once + + +enum TURN_ENGINE_FLAGS +{ + TE_FLAG_1 = 1, + TE_HAVE_PENDING_ACTIONS = 2, + TE_PLAYER_TURN = 4, + TE_FLAG_8 = 8 +}; + +enum TURN_ENGINE_AI_ACTION +{ + TE_AI_STAND = 0, + TE_AI_RANGED_ATTACK = 1, + TE_AI_PURSUE = 2, + TE_AI_MELEE_ATTACK = 3, + TE_AI_FLEE = 4 +}; + +enum TURN_ENGINE_TURN_STAGE +{ + TE_NONE = 0, + TE_WAIT = 1, + TE_ATTACK = 2, + TE_MOVEMENT = 3, +}; + +/* 299 */ +#pragma pack(push, 1) +struct TurnBased_QueueElem +{ + inline TurnBased_QueueElem() + { + uPackedID = 0; + actor_initiative = 0; + uActionLength = 0; + AI_action_type = 0; + } + int uPackedID; + int actor_initiative; //act first who have less + int uActionLength; + int AI_action_type; +}; +#pragma pack(pop) + +/* 254 */ +#pragma pack(push, 1) +struct stru262_TurnBased +{ + inline stru262_TurnBased() + { + turns_count = 0; + turn_stage = 0; + ai_turn_timer = 0; + uActorQueueSize = 0; + turn_initiative = 0; + uActionPointsLeft = 0; + field_18 = 0; + pending_actions = 0; + } + + void SortTurnQueue(); + void ApplyPlayerAction(); + void Start(); + void End(bool bPlaySound); + void AITurnBasedAction(); + void StartTurn(); + void NextTurn(); + bool StepTurnQueue(); + void _406457(int a2); + void SetAIRecoveryTimes(); + void _4065B0(); + void AIAttacks(unsigned int queue_index); + void AI_Action_(int queue_index); + void ActorAISetMovementDecision(); + void ActorAIStopMovement(); + void ActorAIDoAdditionalMove(); + bool ActorMove(signed int a2); + void ActorAIChooseNewTargets(); + + + int turns_count; + int turn_stage; //if = 2 - action + int ai_turn_timer; + int uActorQueueSize; //c + int turn_initiative; + int uActionPointsLeft; //14 + int field_18; + int pending_actions; + TurnBased_QueueElem pQueue[530]; //20 +}; +#pragma pack(pop) + + + +extern struct stru262_TurnBased *pTurnEngine; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/VectorTypes.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/VectorTypes.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,76 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include + +#include "mm7_data.h" +#include "OurMath.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) +{ + extern int integer_sqrt(int val); + *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; + +//----- (004369DB) -------------------------------------------------------- +void Vec3_float_::Normalize() +{ + this->x = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->x; + this->y = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->y; + this->z = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->z; +} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/VectorTypes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/VectorTypes.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,144 @@ +#pragma once + +#include + +uint32_t int_get_vector_length(int32_t x, int32_t y, int32_t z); + +#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) +template +struct Vec3: public Vec2 +{ + 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; + } + + //----- (0049B02E) -------------------------------------------------------- + inline static float NegDot(Vec3_float_ *a1, Vec3_float_ *a2, float *a3) + { + return *a3 = -(a1->z * a2->z + a1->y * a2->y + a1->x * a2->x); + } + + float x; + float y; + float z; +}; +#pragma pack(pop) + +#pragma pack(push, 1) +struct Vec4_int_ +{ + int x; + int y; + int z; + int w; +}; +#pragma pack(pop) + +/* 82 */ +#pragma pack(push, 1) +struct Plane_int_ +{ + Vec3_int_ vNormal; + int dist; +}; +#pragma pack(pop) + +#pragma pack(push, 1) +struct BBox_short_ +{ + __int16 x1; + __int16 x2; + __int16 y1; + __int16 y2; + __int16 z1; + __int16 z2; +}; +#pragma pack(pop) + +#pragma pack(push, 1) +struct BBox_int_ +{ + int x1; + int x2; + int y1; + int y2; + int z1; + int z2; +}; +#pragma pack(pop) + +#pragma pack(push, 1) +struct Plane_float_ +{ + struct Vec3_float_ vNormal; + float dist; +}; +#pragma pack(pop) + +/* 196 */ +#pragma pack(push, 1) +struct Matrix3x3_float_ +{ + union + { + struct + { + float _11; float _12; float _13; + float _21; float _22; float _23; + float _31; float _32; float _33; + }; + float v[3][3]; + }; +}; +#pragma pack(pop) diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/ZlibWrapper.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/ZlibWrapper.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,18 @@ + +namespace zlib +{ +#include "lib\zlib\zlib.h" + int MemUnzip(void *dest, unsigned int *destLen, const void *source, unsigned int sourceLen) + { + //return uncompress((zlib::Bytef *)dest, (zlib::uLongf *)destLen, (zlib::Bytef *)source, sourceLen); + return uncompress((Bytef *)dest, (uLongf *)destLen, (Bytef *)source, sourceLen); + return 0; + } + + int MemZip(void *dest, unsigned int *destLen, void *source, unsigned int sourceLen) + { + //return compress((zlib::Bytef *)dest, (zlib::uLongf *)destLen, (zlib::Bytef *)source, sourceLen); + return compress((Bytef *)dest, (uLongf *)destLen, (Bytef *)source, sourceLen); + return 0; + } +}; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/ZlibWrapper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/ZlibWrapper.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,7 @@ +#pragma once + +namespace zlib +{ + int MemZip(void *dest, unsigned int *destLen, void *source, unsigned int sourceLen); + int MemUnzip(void *dest, unsigned int *destLen, const void *source, unsigned int sourceLen); +}; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/mm7_7.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/mm7_7.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,492 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS + +/* +GUIProgressBar *__cdecl crt_construct_576E30() +{ + RGBTexture::RGBTexture(&pGameLoadingUI_ProgressBar.pLoadingBg); + RGBTexture::RGBTexture(&pGameLoadingUI_ProgressBar.field_40); + RGBTexture::RGBTexture(&pGameLoadingUI_ProgressBar.field_68); + RGBTexture::RGBTexture(&pGameLoadingUI_ProgressBar.field_90); + RGBTexture::RGBTexture(&pGameLoadingUI_ProgressBar.field_B8); + Texture::Texture(&pGameLoadingUI_ProgressBar.field_E0); + Texture::Texture(&pGameLoadingUI_ProgressBar.pBardata); + Texture::Texture(&pGameLoadingUI_ProgressBar.pLoadingProgress); + pGameLoadingUI_ProgressBar.uProgressCurrent = 0; + pGameLoadingUI_ProgressBar.uProgressMax = 0; + pGameLoadingUI_ProgressBar.field_9 = 0; + pGameLoadingUI_ProgressBar.field_8 = 0; + pGameLoadingUI_ProgressBar.uHeight = 0; + pGameLoadingUI_ProgressBar.uWidth = 0; + pGameLoadingUI_ProgressBar.uY = 0; + pGameLoadingUI_ProgressBar.uX = 0; + pGameLoadingUI_ProgressBar.field_17 = 0; + pGameLoadingUI_ProgressBar.field_16 = 0; + pGameLoadingUI_ProgressBar.field_15 = 0; + pGameLoadingUI_ProgressBar.field_14 = 0; + pGameLoadingUI_ProgressBar.field_13 = 0; + pGameLoadingUI_ProgressBar.field_12 = 0; + pGameLoadingUI_ProgressBar.field_11 = 0; + pGameLoadingUI_ProgressBar.field_10 = 0; + return &pGameLoadingUI_ProgressBar; +} +*/ + +/*void constructors() +{ + //no call to these anywhere + uGameUIFontMain_initialize(); + uGameUIFontShadow_initialize(); +}*/ + +/* + +X = called already in our code +byte = constructor byte setter + +.data:004DF004 dd offset sub_4C9A95 +IOStream + +.data:004DF008 dd offset sub_4C9B06 +IOStream + +.data:004DF00C dd offset sub_401022 +achieved by zero initializing dword_4F8580, dword_4F8580[0] = 1; is unused anyway + +.data:004DF010 dd offset sub_408B98 +.data:004DF014 dd offset sub_409BCC +.data:004DF018 dd offset crt_sub_40D6EB +byte + +.data:004DF01C dd offset crt_construct_40D707_ptr_pArcomageGame +X + +.data:004DF020 dd offset crt_sub_40E4A6 +.data:004DF024 dd offset crt_deconstruct_40E503 +.data:004DF028 dd offset crt_sub_40F760 +.data:004DF02C dd offset crt_sub_40F7EA +.data:004DF030 dd offset crt_sub_40F9A9 +.data:004DF034 dd offset crt_sub_410AD9 +byte + +.data:004DF038 dd offset SetMoonPhaseNames +X + +.data:004DF03C dd offset crt_sub_413FD0 +byte + +.data:004DF040 dd offset j_SetMonthNames +.data:004DF044 dd offset j_SetDayNames +.data:004DF048 dd offset j_SetSpellSchoolNames +.data:004DF04C dd offset j_SetAttributeNames +X InitializeGameText + +.data:004DF050 dd offset uGameUIFontMain_initialize +.data:004DF054 dd offset uGameUIFontShadow_initialize +X called in SetUserInterface(Neutral) + +.data:004DF058 dd offset crt_construct_507ABC +.data:004DF05C dd offset crt_construct_507A94 +.data:004DF060 dd offset crt_construct_507A6C +.data:004DF064 dd offset crt_construct_507A44 +.data:004DF068 dd offset crt_construct_507A1C +.data:004DF06C dd offset crt_construct_506F20 +.data:004DF070 dd offset crt_construct_414D90_ptr_506E40 +X (RGBTexture constructor) + +.data:004DF074 dd offset crt_sub_423903 +byte + +.data:004DF078 dd offset IndoorCamera__IndoorCamera +X + +.data:004DF07C dd offset crt_sub_423ACD +byte + +.data:004DF080 dd offset j_reset_some_strus_flt_2Cs +deleted + +.data:004DF084 dd offset j_sub_423B4A +byte + +.data:004DF088 dd offset crt_sub_4262DD +byte + +.data:004DF08C dd offset crt_construct_pEventTimer +.data:004DF090 dd offset crt_construct_pMiscTimer +X + +.data:004DF094 dd offset crt_sub_42640D +.data:004DF098 dd offset crt_sub_4268C7 +.data:004DF09C dd offset crt_sub_42692B +byte + +.data:004DF0A0 dd offset sub_426947 +X initialized + +.data:004DF0A4 dd offset crt_construct_50C0C8 +X CastSpellInfo + +.data:004DF0A8 dd offset crt_sub_42FBB7 +byte + +.data:004DF0AC dd offset crt_construct_50CDB4 +seems unused CastSpellInfo variable + +.data:004DF0B0 dd offset sub_4361D3 +.data:004DF0B4 dd offset sub_4382A0 +.data:004DF0B8 dd offset sub_43850A +.data:004DF0BC dd offset crt_438AEF +.data:004DF0C0 dd offset crt_438B7F +.data:004DF0C4 dd offset ctr_deconstruct_43B4E0 +byte + +.data:004DF0C8 dd offset crt_43B4FC +deleted, constructor for stru_51076C + +.data:004DF0CC dd offset crt_deconstruct_43B51C +.data:004DF0D0 dd offset crt_deconstruct_43B5F0 +.data:004DF0D4 dd offset crt_deconstruct_43B64C +byte + +.data:004DF0D8 dd offset _crt_construct_stru165 +X BloodsplatContainer + +.data:004DF0DC dd offset crt_deconstruct_43B751 +.data:004DF0E0 dd offset crt_deconstruct_43B9E3 +.data:004DF0E4 dd offset crt_deconstruct_43BC8B +.data:004DF0E8 dd offset crt_deconstruct_43F22A +byte + +.data:004DF0EC dd offset crt_construct_51B778 +X BspRenderer + +.data:004DF0F0 dd offset crt_construct_519AB8 +X LightsStack_MobileLight + +.data:004DF0F4 dd offset crt_construct_5187F0 +X LightsStack_StationaryLight + + +.data:004DF0F8 dd offset crt_deconstruct_440B28 +.data:004DF0FC dd offset crt_deconstruct_440F5C +byte + +.data:004DF100 dd offset crt_construct_576E30 +added but have to RECHECK + +.data:004DF104 dd offset crt_deconstruct_4437E5 +byte + +.data:004DF108 dd offset sub_446219 +X InitializeGameText + +.data:004DF10C dd offset crt_construct_5773C4 +unused RGBTexture + +.data:004DF110 dd offset sub_44C346 +.data:004DF114 dd offset crt_deconstruct_44C42C +.data:004DF118 dd offset crt_deconstruct_44D49E +byte + +.data:004DF11C dd offset _inline_SpriteFrameTable__SpriteFrameTable_global +.data:004DF120 dd offset _inline_TextureFrameTable__TextureFrameTable_global +X + +.data:004DF124 dd offset sub_44E49B +.data:004DF128 dd offset sub_44F1F9 +.data:004DF12C dd offset sub_44F560 +.data:004DF130 dd offset sub_450DC2 +.data:004DF134 dd offset crt_deconstruct_45232B +byte + +.data:004DF138 dd offset crt_construct_stru193_math@5C6E00 +X + +.data:004DF13C dd offset crt_452B74 +byte + +.data:004DF140 dd offset j_SetSomeItemsNames +added + +.data:004DF144 dd offset crt_deconstruct_458364 +byte + +.data:004DF148 dd offset _intline_DecorationList__DecorationList_global +X + +.data:004DF14C dd offset j_crt_construct_6836D0 +X LevelDecorations + +.data:004DF150 dd offset _inline_ObjectList__ObjectList_global +X + +.data:004DF154 dd offset j_crt_construct_665230 +X SpriteObjects + +.data:004DF158 dd offset j_crt_construct_5FF158 +X Actors + +.data:004DF15C dd offset _inline_MonsterList__MonsterList_global +X + +.data:004DF160 dd offset _inline_ChestList__ChestList_global +X + +.data:004DF164 dd offset j_crt_construct_5E5150 +X Chests + +.data:004DF168 dd offset _inline_OverlayList__OverlayList_global +X + +.data:004DF16C dd offset crt_construct_5E4D58 +X OverlayList + +.data:004DF170 dd offset sub_459C05 +byte + +.data:004DF174 dd offset sub_459C21 +X KeyboardActionMapping + +.data:004DF178 dd offset crt_deconstruct_45AFBD +.data:004DF17C dd offset crt_deconstruct_45B0EE +.data:004DF180 dd offset sub_45BA89 +byte + +.data:004DF184 dd offset crt_call_global_ctor_45BAA5 +stru_69BD44 = "effpar03" , need RECHECK + +.data:004DF188 dd offset crt_deconstruct_45DEF7 +.data:004DF18C dd offset crt_deconstruct_45DF53 +.data:004DF190 dd offset crt_deconstruct_45DF6F +.data:004DF194 dd offset crt_deconstruct_45DF8B +byte + +.data:004DF198 dd offset crt_construct_ptr_6A0A60 +X LODFile + +.data:004DF19C dd offset crt_construct_ptr_6A0820 +X LODFile + +.data:004DF1A0 dd offset j_crt_construct_ptr_6A0118 +X RGBTexture + +.data:004DF1A4 dd offset sub_461415 +.data:004DF1A8 dd offset crt_deconstruct_4621BE +.data:004DF1AC dd offset crt_deconstruct_46220E +byte + +.data:004DF1B0 dd offset crt_construct_ptr_702B28 +X Allocator + +.data:004DF1B4 dd offset sub_46224A +X unused + +.data:004DF1B8 dd offset crt_construct_ptr_06F0E80 +X LODFile_IconsBitmaps + +.data:004DF1BC dd offset sub_4623CF +X LODFile_Sprites + +.data:004DF1C0 dd offset crt_call_ctors__pIcons_LOD +.data:004DF1C4 dd offset crt_call_ctors__pEvents_LOD +.data:004DF1C8 dd offset _inline_IndoorLocation__IndoorLocation_global +X + +.data:004DF1CC dd offset crt_init_globals_462620 +X initialized + +.data:004DF1D0 dd offset crt_construct_ptr_6BE158 +unused stru289 + +.data:004DF1D4 dd offset j_crt_init_globals_462659 +X initialized + +.data:004DF1D8 dd offset crt_construct_ptr_06BE070 +X ODMRenderParams + +.data:004DF1DC dd offset crt_init_globals_46269B +unused SW variable + +.data:004DF1E0 dd offset crt_construct_ptr_6BE048 +X TileTable + +.data:004DF1E4 dd offset crt_construct_ptr_6A0DF0 +X OutdoorLocation + +.data:004DF1E8 dd offset sub_466CA6 +.data:004DF1EC dd offset crt_deconstruct_467D29 +.data:004DF1F0 dd offset sub_467E32 +.data:004DF1F4 dd offset crt_deconstruct_46AC2C +byte + +.data:004DF1F8 dd offset crt_construct_46AC48_ptr_720990 +X std__string_720990 = "micon1" , need RECHECK + +.data:004DF1FC dd offset crt_deconstruct_46BD83 +byte + +.data:004DF200 dd offset crt_init_globals_46BD9F +added + +.data:004DF204 dd offset nullsub_26 +X + +.data:004DF208 dd offset sub_476102 +byte + +.data:004DF20C dd offset sub_47611E +X Texture + +.data:004DF210 dd offset sub_476128 +dword_7241C8 = 1 RECHECK + +.data:004DF214 dd offset sub_476133 +X InitializeGameText + +.data:004DF218 dd offset sub_477595 +.data:004DF21C dd offset sub_47836D +.data:004DF220 dd offset crt_sub_4783D9 +byte + +.data:004DF224 dd offset j__sub_4783FA_construct_global_73D150 + + +.data:004DF228 dd offset sub_47A368 +.data:004DF22C dd offset sub_47C778 +.data:004DF230 dd offset sub_47CDBE +byte + +.data:004DF234 dd offset sub_47CDDA + + +.data:004DF238 dd offset sub_47F483 +byte + +.data:004DF23C dd offset sub_47F49F + + +.data:004DF240 dd offset sub_47F4B9 + + +.data:004DF244 dd offset sub_482A74 +.data:004DF248 dd offset sub_485F37 +.data:004DF24C dd offset sub_486A0C +.data:004DF250 dd offset crt_deconstruct_487DF7 +.data:004DF254 dd offset sub_488E07 +.data:004DF258 dd offset sub_489572 +.data:004DF25C dd offset crt_deconstruct_489B44 +.data:004DF260 dd offset crt_deconstruct_489BBA +byte + +.data:004DF264 dd offset crt_construct_489BD6_ptr_080D198 +X PaletteManager + +.data:004DF268 dd offset sub_48AAA9 +.data:004DF26C dd offset sub_48C20E +byte + +.data:004DF270 dd offset sub_48C22A +.data:004DF274 dd offset loc_48C234 +.data:004DF278 dd offset loc_48C243 +.data:004DF27C dd offset loc_48C252 +.data:004DF280 dd offset loc_48C3C0 +.data:004DF284 dd offset loc_48C474 +Party constructor + +.data:004DF288 dd offset sub_49801C +.data:004DF28C dd offset sub_498077 +.data:004DF290 dd offset sub_498A25 +.data:004DF294 dd offset sub_49AFE5 +.data:004DF298 dd offset crt_deconstruct_49B36B +byte + +.data:004DF29C dd offset crt_construct_stru187@AE5BA8 +X DecalBuilder + +.data:004DF2A0 dd offset crt_construct_ptr_AE5B94 +std__string_AE5B94 = "hwsplat04", need RECHECK + +.data:004DF2A4 dd offset sub_49C594 +.data:004DF2A8 dd offset sub_49D6C8 +.data:004DF2AC dd offset sub_49D6E4 +.data:004DF2B0 dd offset sub_49E71A +byte + +.data:004DF2B4 dd offset sub_49E736 +X Render + +.data:004DF2B8 dd offset sub_4A198F +byte + +.data:004DF2BC dd offset sub_4A19AB +added + +.data:004DF2C0 dd offset sub_4A51AF +.data:004DF2C4 dd offset sub_4A7047 +.data:004DF2C8 dd offset sub_4A94EB +.data:004DF2CC dd offset sub_4A963E +byte + +.data:004DF2D0 dd offset sub_4A965A +X pSoundList + +.data:004DF2D4 dd offset AudioPlayer__AudioPlayer +X + +.data:004DF2D8 dd offset sub_4AC1AD +.data:004DF2DC dd offset sub_4AC662 +.data:004DF2E0 dd offset sub_4ACC1C +.data:004DF2E4 dd offset sub_4AD369 +.data:004DF2E8 dd offset crt_deconstruct_4AD44B +byte + +.data:004DF2EC dd offset crt_construct_4AD467_ptr_F79D68 +X OSVersion + +.data:004DF2F0 dd offset crt_deconstruct_4AD4DE +byte + +.data:004DF2F4 dd offset crt_construct_ptr_F7CE30 +X Texture + +.data:004DF2F8 dd offset sub_4B142B +.data:004DF2FC dd offset crt_sub_4BE344 +byte + +.data:004DF300 dd offset j_Random__ctor +X + +.data:004DF304 dd offset crt_sub_4BE6B5 +.data:004DF308 dd offset crt_sub_4BE6D4 +byte + +.data:004DF30C dd offset crt_j_VideoPlayer__ctor +RECHECK + +.data:004DF310 dd offset sub_4C021E +byte + +.data:004DF314 dd offset sub_4C023A +added + +.data:004DF318 dd offset sub_4C035A +.data:004DF31C dd offset sub_4C03A3 +byte + +.data:004DF320 dd offset sub_4C03BF +.data:004DF324 dd offset sub_4C03F1 +.data:004DF328 dd offset sub_4C0423 +.data:004DF32C dd offset sub_4C044B +.data:004DF330 dd offset sub_4C047D +X vis filters + +.data:004DF334 dd offset sub_4C2A6E +.data:004DF338 dd offset sub_4C2A8A +.data:004DF33C dd offset sub_4C2F7C +byte + +*/ \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/mm7_data.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/mm7_data.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,1094 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include "mm7_data.h" + +#include "GUIWindow.h" +#include "Party.h" + + +void ErrHR(HRESULT hr, const char *pAPI, const char *pFunction, const char *pFile, int line) +{ + if (SUCCEEDED(hr)) + return; + + char msg[4096]; + sprintf(msg, "%s error (%08X) in\n\t%s\nin\n\t%s:%u", + pAPI, hr, pFunction, pFile, line); + + char caption[1024]; + sprintf(caption, "%s error", pAPI); + + MessageBoxA(nullptr, msg, caption, MB_ICONEXCLAMATION); +} + + + + +#include "OurMath.h" +struct stru193_math *stru_5C6E00 = new stru193_math; + +#include "MapInfo.h" +struct MapStats *pMapStats; + +#include "Engine/Graphics/Viewport.h" +struct Viewport *pViewport = new Viewport; +struct ViewingParams *viewparams = new ViewingParams; + + + +#include "stru123.h" +stru123 stru_5E4C90_MapPersistVars; + +#include "stru298.h" +stru298 AttackerInfo; // weak + +#include "Engine/Autonotes.h" +std::array pAutonoteTxt; // weak + +#include "Engine/Awards.h" +std::array pAwards; +std::array achieved_awards; +int num_achieved_awards; +int full_num_items_in_book; + +#include "stru160.h" +std::array array_4EB8B8 = +{{ + stru160( 0.0000000f, 0.0000000f, 1.0000000f), + stru160( 0.0000000f, 0.3826830f, 0.9238799f), + stru160( 0.3826830f, 0.0000000f, 0.9238799f), + stru160( 0.4082480f, 0.4082480f, 0.8164970f), + stru160( 0.0000000f, 0.7071070f, 0.7071070f), + stru160( 0.7071070f, 0.0000000f, 0.7071070f), + stru160( 0.4082480f, 0.8164970f, 0.4082480f), + stru160( 0.8164970f, 0.4082480f, 0.4082480f), + stru160( 0.7071070f, 0.7071070f, 0.0000000f), + stru160( 0.0000000f, 0.9238799f, 0.3826830f), + stru160( 0.3826830f, 0.9238799f, 0.0000000f), + stru160( 0.0000000f, 1.0000000f, 0.0000000f), + stru160( 0.9238799f, 0.3826830f, 0.0000000f), + stru160( 0.9238799f, 0.0000000f, 0.3826830f), + stru160( 1.0000000f, 0.0000000f, 0.0000000f), + stru160( 0.0000000f, -0.3826830f, 0.9238799f), + stru160( 0.4082480f, -0.4082480f, 0.8164970f), + stru160( 0.0000000f, -0.7071070f, 0.7071070f), + stru160( 0.8164970f, -0.4082480f, 0.4082480f), + stru160( 0.4082480f, -0.8164970f, 0.4082480f), + stru160( 0.7071070f, -0.7071070f, 0.0000000f), + stru160( 0.9238799f, -0.3826830f, 0.0000000f), + stru160( 0.3826830f, -0.9238799f, 0.0000000f), + stru160( 0.0000000f, -0.9238799f, 0.3826830f), + stru160( 0.0000000f, -1.0000000f, 0.0000000f), + stru160(-0.3826830f, 0.0000000f, 0.9238799f), + stru160(-0.4082480f, -0.4082480f, 0.8164970f), + stru160(-0.7071070f, 0.0000000f, 0.7071070f), + stru160(-0.4082480f, -0.8164970f, 0.4082480f), + stru160(-0.8164970f, -0.4082480f, 0.4082480f), + stru160(-0.7071070f, -0.7071070f, 0.0000000f), + stru160(-0.3826830f, -0.9238799f, 0.0000000f), + stru160(-0.9238799f, -0.3826830f, 0.0000000f), + stru160(-0.9238799f, 0.0000000f, 0.3826830f), + stru160(-1.0000000f, 0.0000000f, 0.0000000f), + stru160(-0.4082480f, 0.4082480f, 0.8164970f), + stru160(-0.8164970f, 0.4082480f, 0.4082480f), + stru160(-0.4082480f, 0.8164970f, 0.4082480f), + stru160(-0.7071070f, 0.7071070f, 0.0000000f), + stru160(-0.9238799f, 0.3826830f, 0.0000000f), + stru160(-0.3826830f, 0.9238799f, 0.0000000f), + stru160( 0.0000000f, 0.0000000f, -1.0000000f), + stru160( 0.0000000f, 0.3826830f, -0.9238799f), + stru160( 0.3826830f, 0.0000000f, -0.9238799f), + stru160( 0.4082480f, 0.4082480f, -0.8164970f), + stru160( 0.0000000f, 0.7071070f, -0.7071070f), + stru160( 0.7071070f, 0.0000000f, -0.7071070f), + stru160( 0.4082480f, 0.8164970f, -0.4082480f), + stru160( 0.8164970f, 0.4082480f, -0.4082480f), + stru160( 0.0000000f, 0.9238799f, -0.3826830f), + stru160( 0.9238799f, 0.0000000f, -0.3826830f), + stru160( 0.0000000f, -0.3826830f, -0.9238799f), + stru160( 0.4082480f, -0.4082480f, -0.8164970f), + stru160( 0.0000000f, -0.7071070f, -0.7071070f), + stru160( 0.8164970f, -0.4082480f, -0.4082480f), + stru160( 0.4082480f, -0.8164970f, -0.4082480f), + stru160( 0.0000000f, -0.9238799f, -0.3826830f), + stru160(-0.3826830f, 0.0000000f, -0.9238799f), + stru160(-0.4082480f, -0.4082480f, -0.8164970f), + stru160(-0.7071070f, 0.0000000f, -0.7071070f), + stru160(-0.4082480f, -0.8164970f, -0.4082480f), + stru160(-0.8164970f, -0.4082480f, -0.4082480f), + stru160(-0.9238799f, 0.0000000f, -0.3826830f), + stru160(-0.4082480f, 0.4082480f, -0.8164970f), + stru160(-0.8164970f, 0.4082480f, -0.4082480f), + stru160(-0.4082480f, 0.8164970f, -0.4082480f) +}}; +std::array array_4EBBD0; +std::array<__int32, 128*3> array_4EBBD0_x = +{{ + 0x00000000, 0x00000001, 0x00000002, 0x00000001, + 0x00000003, 0x00000002, 0x00000001, 0x00000004, + 0x00000003, 0x00000003, 0x00000005, 0x00000002, + 0x00000004, 0x00000006, 0x00000003, 0x00000006, + 0x00000007, 0x00000003, 0x00000006, 0x00000008, + 0x00000007, 0x00000007, 0x00000005, 0x00000003, + 0x00000004, 0x00000009, 0x00000006, 0x00000009, + 0x0000000A, 0x00000006, 0x00000009, 0x0000000B, + 0x0000000A, 0x0000000A, 0x00000008, 0x00000006, + 0x00000008, 0x0000000C, 0x00000007, 0x0000000C, + 0x0000000D, 0x00000007, 0x0000000C, 0x0000000E, + 0x0000000D, 0x0000000D, 0x00000005, 0x00000007, + 0x00000000, 0x00000002, 0x0000000F, 0x00000002, + 0x00000010, 0x0000000F, 0x00000002, 0x00000005, + 0x00000010, 0x00000010, 0x00000011, 0x0000000F, + 0x00000005, 0x00000012, 0x00000010, 0x00000012, + 0x00000013, 0x00000010, 0x00000012, 0x00000014, + 0x00000013, 0x00000013, 0x00000011, 0x00000010, + 0x00000005, 0x0000000D, 0x00000012, 0x0000000D, + 0x00000015, 0x00000012, 0x0000000D, 0x0000000E, + 0x00000015, 0x00000015, 0x00000014, 0x00000012, + 0x00000014, 0x00000016, 0x00000013, 0x00000016, + 0x00000017, 0x00000013, 0x00000016, 0x00000018, + 0x00000017, 0x00000017, 0x00000011, 0x00000013, + 0x00000000, 0x0000000F, 0x00000019, 0x0000000F, + 0x0000001A, 0x00000019, 0x0000000F, 0x00000011, + 0x0000001A, 0x0000001A, 0x0000001B, 0x00000019, + 0x00000011, 0x0000001C, 0x0000001A, 0x0000001C, + 0x0000001D, 0x0000001A, 0x0000001C, 0x0000001E, + 0x0000001D, 0x0000001D, 0x0000001B, 0x0000001A, + 0x00000011, 0x00000017, 0x0000001C, 0x00000017, + 0x0000001F, 0x0000001C, 0x00000017, 0x00000018, + 0x0000001F, 0x0000001F, 0x0000001E, 0x0000001C, + 0x0000001E, 0x00000020, 0x0000001D, 0x00000020, + 0x00000021, 0x0000001D, 0x00000020, 0x00000022, + 0x00000021, 0x00000021, 0x0000001B, 0x0000001D, + 0x00000000, 0x00000019, 0x00000001, 0x00000019, + 0x00000023, 0x00000001, 0x00000019, 0x0000001B, + 0x00000023, 0x00000023, 0x00000004, 0x00000001, + 0x0000001B, 0x00000024, 0x00000023, 0x00000024, + 0x00000025, 0x00000023, 0x00000024, 0x00000026, + 0x00000025, 0x00000025, 0x00000004, 0x00000023, + 0x0000001B, 0x00000021, 0x00000024, 0x00000021, + 0x00000027, 0x00000024, 0x00000021, 0x00000022, + 0x00000027, 0x00000027, 0x00000026, 0x00000024, + 0x00000026, 0x00000028, 0x00000025, 0x00000028, + 0x00000009, 0x00000025, 0x00000028, 0x0000000B, + 0x00000009, 0x00000009, 0x00000004, 0x00000025, + 0x00000029, 0x0000002A, 0x0000002B, 0x0000002A, + 0x0000002C, 0x0000002B, 0x0000002A, 0x0000002D, + 0x0000002C, 0x0000002C, 0x0000002E, 0x0000002B, + 0x0000002D, 0x0000002F, 0x0000002C, 0x0000002F, + 0x00000030, 0x0000002C, 0x0000002F, 0x00000008, + 0x00000030, 0x00000030, 0x0000002E, 0x0000002C, + 0x0000002D, 0x00000031, 0x0000002F, 0x00000031, + 0x0000000A, 0x0000002F, 0x00000031, 0x0000000B, + 0x0000000A, 0x0000000A, 0x00000008, 0x0000002F, + 0x00000008, 0x0000000C, 0x00000030, 0x0000000C, + 0x00000032, 0x00000030, 0x0000000C, 0x0000000E, + 0x00000032, 0x00000032, 0x0000002E, 0x00000030, + 0x00000029, 0x0000002B, 0x00000033, 0x0000002B, + 0x00000034, 0x00000033, 0x0000002B, 0x0000002E, + 0x00000034, 0x00000034, 0x00000035, 0x00000033, + 0x0000002E, 0x00000036, 0x00000034, 0x00000036, + 0x00000037, 0x00000034, 0x00000036, 0x00000014, + 0x00000037, 0x00000037, 0x00000035, 0x00000034, + 0x0000002E, 0x00000032, 0x00000036, 0x00000032, + 0x00000015, 0x00000036, 0x00000032, 0x0000000E, + 0x00000015, 0x00000015, 0x00000014, 0x00000036, + 0x00000014, 0x00000016, 0x00000037, 0x00000016, + 0x00000038, 0x00000037, 0x00000016, 0x00000018, + 0x00000038, 0x00000038, 0x00000035, 0x00000037, + 0x00000029, 0x00000033, 0x00000039, 0x00000033, + 0x0000003A, 0x00000039, 0x00000033, 0x00000035, + 0x0000003A, 0x0000003A, 0x0000003B, 0x00000039, + 0x00000035, 0x0000003C, 0x0000003A, 0x0000003C, + 0x0000003D, 0x0000003A, 0x0000003C, 0x0000001E, + 0x0000003D, 0x0000003D, 0x0000003B, 0x0000003A, + 0x00000035, 0x00000038, 0x0000003C, 0x00000038, + 0x0000001F, 0x0000003C, 0x00000038, 0x00000018, + 0x0000001F, 0x0000001F, 0x0000001E, 0x0000003C, + 0x0000001E, 0x00000020, 0x0000003D, 0x00000020, + 0x0000003E, 0x0000003D, 0x00000020, 0x00000022, + 0x0000003E, 0x0000003E, 0x0000003B, 0x0000003D, + 0x00000029, 0x00000039, 0x0000002A, 0x00000039, + 0x0000003F, 0x0000002A, 0x00000039, 0x0000003B, + 0x0000003F, 0x0000003F, 0x0000002D, 0x0000002A, + 0x0000003B, 0x00000040, 0x0000003F, 0x00000040, + 0x00000041, 0x0000003F, 0x00000040, 0x00000026, + 0x00000041, 0x00000041, 0x0000002D, 0x0000003F, + 0x0000003B, 0x0000003E, 0x00000040, 0x0000003E, + 0x00000027, 0x00000040, 0x0000003E, 0x00000022, + 0x00000027, 0x00000027, 0x00000026, 0x00000040, + 0x00000026, 0x00000028, 0x00000041, 0x00000028, + 0x00000031, 0x00000041, 0x00000028, 0x0000000B, + 0x00000031, 0x00000031, 0x0000002D, 0x00000041 +}}; + +#include "MapsLongTimer.h" +MapsLongTimer MapsLongTimersList[100]; + +#include "Engine/Objects/ObjectList.h" +struct ObjectList *pObjectList; + +#include "Engine/Tables/IconFrameTable.h" +struct IconFrameTable *pIconsFrameTable; + +struct +{ + struct UIAnimation _pUIAnim_Food; + struct UIAnimation _pUIAnim_Gold; + struct UIAnimation _pUIAnum_Torchlight; + struct UIAnimation _pUIAnim_WizardEye; +} _uianim; + +struct UIAnimation *pUIAnim_Food = &_uianim._pUIAnim_Food; +struct UIAnimation *pUIAnim_Gold = &_uianim._pUIAnim_Gold; +struct UIAnimation *pUIAnum_Torchlight = &_uianim._pUIAnum_Torchlight; +struct UIAnimation *pUIAnim_WizardEye = &_uianim._pUIAnim_WizardEye; + +std::array pUIAnims = +{ + &_uianim._pUIAnim_Food, + &_uianim._pUIAnim_Gold, + &_uianim._pUIAnum_Torchlight, + &_uianim._pUIAnim_WizardEye +}; + + + +#include "Engine/Tables/PlayerFrameTable.h" +struct PlayerFrameTable *pPlayerFrameTable; // idb + +#include "MM7.h" + + +std::array stat_string_coord = //4E2940 +{{ + {0x1A, 0x39, 0xDC, 0x12}, + {0x1A, 0x4A, 0xDC, 0x12}, + {0x1A, 0x5B, 0xDC, 0x12}, + {0x1A, 0x6C, 0xDC, 0x12}, + {0x1A, 0x7D, 0xDC, 0x12}, + {0x1A, 0x8E, 0xDC, 0x12}, + {0x1A, 0x9F, 0xDC, 0x12}, + {0x1A, 0xC6, 0xDC, 0x12}, + {0x1A, 0xD7, 0xDC, 0x12}, + {0x1A, 0xE8, 0xDC, 0x12}, + {0x1A, 0x10C, 0xDC, 0x12}, + {0x1A, 0x11E, 0xDC, 0x12}, + {0x111, 0x36, 0xBA, 0x12}, + {0x111, 0x47, 0xBA, 0x12}, + {0x111, 0x58, 0xBA, 0x12}, + {0x111, 0x7E, 0xBA, 0x12}, + {0x111, 0x8F, 0xBA, 0x12}, + {0x111, 0xA0, 0xBA, 0x12}, + {0x111, 0xB1, 0xBA, 0x12}, + {0x111, 0xCA, 0xBA, 0x12}, + {0x111, 0xDD, 0xBA, 0x12}, + {0x111, 0xF0, 0xBA, 0x12}, + {0x111, 0x103, 0xBA, 0x12}, + {0x111, 0x116, 0xBA, 0x12}, + {0x111, 0x129, 0xBA, 0x12}, + {0x13E, 0x12, 0x89, 0x12}, +} +}; + + + + + +#include "stru314.h" +#include "stru367.h" + + + +//------------------------------------------------------------------------- +// Data declarations + +int game_starting_year = 0; +unsigned int game_viewport_width; +unsigned int game_viewport_height; +int game_viewport_x; +int game_viewport_y; +int game_viewport_z; +int game_viewport_w; + + + +std::array saveload_dlg_xs = {82, 0}; +std::array saveload_dlg_ys = {60, 0}; +std::array saveload_dlg_zs = {460, 640}; +std::array saveload_dlg_ws = {344, 480}; +int pWindowList_at_506F50_minus1_indexing[1]; +int dword_4C9890[10]; // weak +int dword_4C9920[16]; // weak +char byte_4D864C; // weak +float flt_4D86CC = 1.0f; // weak +int dword_4D86D8 = 0x40000000; // weak + + + + + + + +float flt_4D84E8 = 0.0f; + +int pCurrentScreen = SCREEN_VIDEO; // 004E28F8 +unsigned int uGammaPos; +std::array BtnTurnCoord = +{{ + 0xA4, 0x5D, 0x16, 0xB, 0x5, 0xD, 0x7, 0x3B, +}}; // weak +std::array<__int16, 4> RightClickPortraitXmin={{0x14, 0x83, 0xF2, 0x165}}; +std::array<__int16, 4> RightClickPortraitXmax={{0x53, 0xC6, 0x138, 0x1A7}}; + +std::array pHealthBarPos = {{22, 137, 251, 366}}; +std::array pManaBarPos = {{102, 217, 331, 447}}; + +std::array monster_popup_y_offsets = +{{ + -20, 20, 0, -40, 0, 0, 0, 0, 0, 0, -50, + 20, 0, -10, -10, -20, 10, -10, 0, 0, 0, -20, + 10, -10, 0, 0, 0, -20, -10, 0, 0, 0, -40, + -20, 0, 0, 0, -50, -30, -30, -30, -30, -30, -30, + 0, 0, 0, 0, 0, 0, -20, -20, -20, 20, 20, + 20, 10, 10, 10, 10, 10, 10, -90, -60, -40, -20, + -20, -80, -10, 0, 0, -40, 0, 0, 0, -20, 10, + 0, 0, 0, 0, 0, 0, -60, 0, 0, 0, 0 +}}; +unsigned char hourglass_icon_idx = 12; // weak + + +const char *format_4E2D80 = "\f%05d%s\f00000\n"; +//const char *format_4E2DC8 = "\f%05d"; +const char *format_4E2DE8 = "\f%05d%s\f00000 - "; +const char *Stat_string_format_2_column_text = "%s\f%05u\r180%s\n"; +const char *Stat_string_format_2_column_less_100 = "%s\f%05u\t110%d\f00000 / %d\n"; +const char *Stat_string_format_2_column_over_100 = "%s\f%05u\r180%d\f00000 / %d\n"; +int dword_4E455C; // weak +std::array dword_4E4560; +std::array dword_4E4578; +std::array dword_4E4590; +std::array dword_4E45A8; +std::array flt_4E4A80 = +{ + 0.050000001, 0.1, 0.30000001, 0.5, 0.60000002, + 1.0, 6.0, 25.0, 50.0, 100.0 +}; + + +std::array< std::array, 14> pPartySpellbuffsUI_XYs = +{{ + {477, 247}, {497, 247}, {522, 247}, {542, 247}, {564, 247}, {581, 247}, {614, 247}, + {477, 279}, {497, 279}, {522, 279}, {542, 279}, {564, 279}, {589, 279}, {612, 279} +}}; +std::array byte_4E5DD8 = +{{ + PARTY_BUFF_FEATHER_FALL, PARTY_BUFF_RESIST_FIRE, PARTY_BUFF_RESIST_AIR, PARTY_BUFF_RESIST_WATER, PARTY_BUFF_RESIST_MIND, PARTY_BUFF_RESIST_EARTH, PARTY_BUFF_RESIST_BODY, + PARTY_BUFF_HEROISM, PARTY_BUFF_HASTE, PARTY_BUFF_SHIELD, PARTY_BUFF_STONE_SKIN, PARTY_BUFF_PROTECTION_FROM_MAGIC, PARTY_BUFF_IMMOLATION, PARTY_BUFF_DAY_OF_GODS +}}; +std::array pPartySpellbuffsUI_smthns = +{{ + 14, 1, 10, 4, 7, 2, 9, + 3, 6, 15, 8, 3, 12, 0 +}}; + +std::array< std::array, 6> pNPCPortraits_x = // 004E5E50 +{{ + {521, 0, 0, 0, 0, 0}, + {521, 521, 0, 0, 0, 0}, + {521, 521, 521, 0, 0, 0}, + {521, 486, 564, 521, 0, 0}, + {521, 486, 564, 486, 564, 0}, + {486, 564, 486, 564, 486, 564} +}}; +std::array< std::array, 6> pNPCPortraits_y = // 004E5EE0 +{{ + {38, 0, 0, 0, 0, 0}, + {38, 165, 0, 0, 0, 0}, + {38, 133, 228, 0, 0, 0}, + {38, 133, 133, 228, 0, 0}, + {38, 133, 133, 228, 228, 0}, + {38, 38, 133, 133, 228, 228} +}}; +std::array pHouse_ExitPictures= +{ + "", + "ticon01", + "ticon02", + "ticon03", + "ticon04", + "ticon05", + "istairup", + "itrap", + "outside", + "idoor", + "isecdoor" +}; + +std::array<__int16, 11> word_4E8152 = {0, 0, 0, 90, 8, 2, 70, 20, 10, 50, 30}; + +char _4E94D0_light_type = 5; // weak +char _4E94D2_light_type = 6; // weak +char _4E94D3_light_type = 10; // weak +int dword_4E98BC_bApplicationActive; // weak +//char *off_4EB080; // idb +std::array pTransitionStrings = {"", nullptr}; // 004EB080 +std::array pPlayerPortraitsNames = +{{ + "pc01-", "pc02", "pc03", "pc04", "pc05-", + "pc06", "pc07", "pc08", "pc09-", "pc10", + "pc11-", "pc12", "pc13", "pc14", "pc15", + "pc16", "pc17-", "pc18", "pc19", "pc20", + "pc21-", "pc22-", "pc23", "pc24-", "pc25-" +}}; + + + +std::array< std::array, 48> byte_4ECF08 = // 4ECF08 +{{ + {2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1},//1 + {2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},//2 + {2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//3 + {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//4 + {2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//5 + {2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//6 + {2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//7 + {2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1},//8 + {2, 1, 2, 2, 2, 2, 1, 2, 1, 2, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2},//9 + {2, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//10 + {2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},//11 + {1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2},//12 + {2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//13 + {1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 2},//14 + {2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2},//15 + {1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1},//16 + {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//17 + {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1},//18 + {1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//19 + {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//20 + {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//21 + {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//22 + {2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1},//23 + {2, 2, 2, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2},//24 + {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 2, 2, 2, 1, 2, 1, 1},//25 + {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//26 + {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2},//27 + {1, 2, 2, 1, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//28 + {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 1, 1},//29 + {1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1},//30 + {1, 1, 2, 1, 2, 1, 2, 2, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 2, 2, 2, 1, 2, 1, 1},//31 + {1, 1, 2, 1, 1, 2, 2, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},//32 + {1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1},//33 + {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1},//34 + {1, 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2},//35 + {1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2},//36 + {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2},//37 + {2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 1, 1},//38 + {1, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1},//39 + {1, 2, 2, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//40 + {2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1},//41 + {1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 1},//42 + {1, 2, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//43 + {1, 2, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 2},//44 + {2, 1, 1, 1, 2, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2},//45 + {1, 1, 1, 2, 2, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 2, 2, 1, 1, 2, 1, 2, 1, 2, 2},//46 + {1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1},//47 + {1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1},//48 +}}; +std::array, 110> SoundSetAction = // 4ED3D8 +{{ + { 0, 0, 0, 0, 0, 0, 0, 0}, + {38, 0, 0, 37, 38, 45, 0, 0}, + {37, 0, 0, 47, 53, 0, 0, 0}, + { 2, 0, 0, 25, 0, 0, 0, 0}, + { 1, 0, 0, 47, 0, 0, 0, 0}, + { 3, 0, 0, 41, 42, 0, 0, 0}, + { 0, 0, 0, 33, 0, 0, 0, 0}, + { 5, 0, 0, 21, 22, 23, 24, 45}, + { 6, 0, 0, 47, 0, 0, 0, 0}, + { 7, 0, 0, 43, 48, 0, 0, 0}, + { 8, 0, 0, 38, 0, 0, 0, 0}, + { 9, 0, 0, 39, 0, 0, 0, 0}, + {13, 0, 0, 37, 38, 0, 0, 0}, + {23, 0, 0, 25, 0, 0, 0, 0}, + { 0, 0, 0, 37, 38, 45, 0, 0}, + {25, 0, 0, 25, 0, 0, 0, 0}, + {26, 0, 0, 38, 47, 0, 0, 0}, + {27, 0, 0, 41, 42, 0, 0, 0}, + {28, 0, 0, 25, 0, 0, 0, 0}, + { 0, 0, 0, 51, 0, 0, 0, 0}, + {30, 0, 0, 25, 0, 0, 0, 0}, + {29, 0, 0, 27, 0, 0, 0, 0}, + {32, 33, 0, 37, 38, 0, 0, 0}, + {34, 0, 0, 53, 0, 0, 0, 0}, + {15, 0, 0, 34, 35, 36, 0, 0}, + { 0, 0, 0, 3, 0, 0, 0, 0}, + {22, 0, 0, 5, 0, 0, 0, 0}, + {20, 0, 0, 8, 0, 0, 0, 0}, + {20, 0, 0, 9, 0, 0, 0, 0}, + {19, 0, 0, 7, 0, 0, 0, 0}, + {21, 0, 0, 2, 0, 0, 0, 0}, + {18, 0, 0, 6, 0, 0, 0, 0}, + { 0, 0, 0, 11, 0, 0, 0, 0}, + {17, 0, 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 12, 0, 0, 0, 0}, + {17, 0, 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 37, 0, 0, 0, 0}, + { 0, 0, 0, 49, 0, 0, 0, 0}, + {24, 0, 0, 25, 0, 0, 0, 0}, + {31, 0, 0, 25, 0, 0, 0, 0}, + { 0, 0, 0, 41, 42, 0, 0, 0}, + { 0, 0, 0, 39, 48, 0, 0, 0}, + { 0, 0, 0, 46, 0, 0, 0, 0}, + { 0, 0, 0, 39, 48, 0, 0, 0}, + { 0, 0, 0, 41, 42, 0, 0, 0}, + { 0, 0, 0, 39, 48, 0, 0, 0}, + {41, 0, 0, 21, 0, 0, 0, 0}, + {40, 0, 0, 21, 0, 0, 0, 0}, + {16, 0, 0, 46, 0, 0, 0, 0}, + { 0, 0, 0, 40, 0, 0, 0, 0}, + { 0, 0, 0, 39, 0, 0, 0, 0}, + { 0, 0, 0, 37, 38, 0, 0, 0}, + { 0, 0, 0, 48, 49, 50, 0, 0}, + { 0, 0, 0, 44, 0, 0, 0, 0}, + { 0, 0, 0, 48, 0, 0, 0, 0}, + { 0, 0, 0, 37, 38, 45, 0, 0}, + { 0, 0, 0, 41, 42, 0, 0, 0}, + { 0, 0, 0, 47, 0, 0, 0, 0}, + { 0, 0, 0, 39, 48, 0, 0, 0}, + { 0, 0, 0, 39, 48, 0, 0, 0}, + { 0, 0, 0, 37, 38, 0, 0, 0}, + { 0, 0, 0, 37, 38, 0, 0, 0}, + { 0, 0, 0, 37, 38, 0, 0, 0}, + { 0, 0, 0, 31, 0, 0, 0, 0}, + { 0, 0, 0, 32, 0, 0, 0, 0}, + {47, 0, 0, 46, 0, 0, 0, 0}, + {22, 0, 0, 5, 0, 0, 0, 0}, + { 0, 0, 0, 25, 0, 0, 0, 0}, + { 0, 0, 0, 37, 0, 0, 0, 0}, + { 0, 0, 0, 52, 0, 0, 0, 0}, + { 0, 0, 0, 45, 0, 0, 0, 0}, + { 0, 0, 0, 27, 0, 0, 0, 0}, + { 0, 0, 0, 37, 38, 0, 0, 0}, + { 0, 0, 0, 49, 0, 0, 0, 0}, + { 0, 0, 0, 48, 0, 0, 0, 0}, + { 0, 0, 0, 37, 38, 45, 0, 0}, + { 0, 0, 0, 48, 0, 0, 0, 0}, + { 0, 0, 0, 37, 38, 45, 0, 0}, + { 0, 0, 0, 47, 0, 0, 0, 0}, + { 0, 0, 0, 48, 0, 0, 0, 0}, + {44, 0, 0, 39, 48, 0, 0, 0}, + { 0, 0, 0, 48, 49, 0, 0, 0}, + { 0, 0, 0, 38, 0, 0, 0, 0}, + { 0, 0, 0, 31, 0, 0, 0, 0}, + {32, 33, 0, 37, 38, 0, 0, 0}, + { 0, 0, 0, 37, 38, 0, 0, 0}, + { 0, 0, 0, 37, 38, 0, 0, 0}, + { 0, 0, 0, 47, 0, 0, 0, 0}, + { 0, 0, 0, 38, 0, 0, 0, 0}, + { 0, 0, 0, 48, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 38, 0, 0, 0, 0}, + { 0, 0, 0, 47, 0, 0, 0, 0}, + { 0, 0, 0, 38, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 38, 0, 0, 0, 0}, + { 0, 0, 0, 38, 0, 0, 0, 0}, + { 0, 0, 0, 5, 0, 0, 0, 0}, + { 0, 0, 0, 37, 38, 0, 0, 0}, + { 0, 0, 0, 44, 0, 0, 0, 0}, + { 0, 0, 0, 48, 0, 0, 0, 0}, + { 4, 0, 0, 0, 0, 0, 0, 0}, + { 0, 0, 0, 58, 0, 0, 0, 0}, + {10, 0, 0, 45, 0, 0, 0, 0}, + {11, 0, 0, 47, 0, 0, 0, 0}, + {12, 0, 0, 43, 48, 0, 0, 0}, + {39, 0, 0, 48, 0, 0, 0, 0}, + {14, 0, 0, 48, 0, 0, 0, 0}, + {17, 0, 0, 0, 0, 0, 0, 0} +}}; +std::array<__int16, 4> pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing = {34, 149, 264, 379}; +std::array< std::array, 36> byte_4ED970_skill_learn_ability_by_class_table = +{{ + 2, 3, 2, 3, 3, 2, 3, 4, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 3, 0, 2, 1, 0, 1, 2, 2, 0, 3, 0, 0, 1,//Knight + 2, 3, 2, 3, 3, 2, 3, 4, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 3, 0, 2, 1, 0, 1, 2, 2, 0, 3, 0, 0, 1, + 2, 4, 2, 3, 4, 2, 3, 4, 4, 3, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 0, 2, 1, 0, 1, 2, 2, 0, 4, 0, 0, 1, + 2, 4, 2, 3, 4, 2, 3, 4, 4, 3, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 0, 2, 1, 0, 1, 2, 2, 0, 4, 0, 0, 1, + + 0, 3, 3, 0, 0, 2, 2, 4, 1, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 1, 2, 0, 3, 0, 0, 3, 3, 2, 0, 3, 3, 2, 2,//Thief + 0, 3, 3, 0, 0, 2, 2, 4, 1, 3, 2, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 3, 3, 1, 2, 0, 3, 0, 0, 3, 3, 2, 0, 3, 3, 2, 2, + 0, 3, 4, 0, 0, 2, 2, 4, 1, 4, 2, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 3, 3, 1, 2, 0, 3, 0, 0, 4, 3, 2, 0, 3, 4, 2, 2, + 0, 3, 4, 0, 0, 2, 2, 4, 1, 4, 2, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 3, 3, 1, 2, 0, 3, 0, 0, 4, 3, 2, 0, 3, 4, 2, 2, + + 3, 2, 2, 0, 2, 1, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 2, 1, 0, 1, 3, 3, 2, 3, 1, 0, 3,//Monk + 3, 2, 2, 0, 2, 1, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 3, 0, 2, 1, 0, 2, 3, 3, 2, 3, 1, 0, 3, + 4, 2, 2, 0, 2, 1, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 4, 0, 2, 1, 0, 2, 4, 4, 2, 3, 1, 0, 4, + 4, 2, 2, 0, 2, 1, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 4, 0, 2, 1, 0, 3, 4, 4, 2, 3, 2, 0, 4, + + 1, 3, 2, 2, 2, 2, 3, 4, 3, 2, 2, 3, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 2, 3, 3, 2, 1, 3, 0, 0, 1, 1, 0, 2, 0, 0, 1,//Paladin + 1, 3, 2, 2, 2, 2, 3, 4, 3, 2, 2, 3, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 2, 3, 3, 2, 1, 3, 0, 0, 1, 1, 0, 2, 0, 0, 1, + 1, 3, 2, 2, 2, 2, 4, 4, 4, 2, 2, 3, 0, 0, 0, 0, 3, 3, 3, 1, 0, 0, 2, 4, 3, 2, 1, 4, 0, 0, 1, 1, 0, 2, 0, 0, 1, + 1, 3, 2, 2, 2, 2, 4, 4, 4, 2, 2, 3, 0, 0, 0, 0, 3, 3, 3, 0, 1, 0, 2, 4, 3, 2, 1, 4, 0, 0, 1, 1, 0, 2, 0, 0, 1, + + 1, 2, 2, 2, 3, 3, 0, 4, 0, 3, 3, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 0, 0, 1, 2, 1, 0, 2, 0, 0, 3,//Archer + 1, 2, 2, 2, 3, 3, 0, 4, 0, 3, 3, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 0, 0, 1, 2, 1, 0, 2, 0, 0, 3, + 1, 2, 2, 2, 3, 4, 0, 4, 0, 3, 4, 0, 3, 3, 3, 3, 0, 0, 0, 1, 0, 0, 2, 2, 2, 2, 4, 0, 0, 2, 2, 1, 0, 2, 0, 0, 3, + 1, 2, 2, 2, 3, 4, 0, 4, 0, 3, 4, 0, 3, 3, 3, 3, 0, 0, 0, 0, 1, 0, 2, 2, 2, 2, 4, 0, 0, 2, 2, 1, 0, 2, 0, 0, 3, + + 1, 2, 2, 3, 2, 3, 0, 4, 2, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 1, 3, 2, 0, 2, 2, 1, 3, 2, 2, 1, 2,//Ranger + 1, 2, 2, 3, 2, 3, 0, 4, 2, 3, 3, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 2, 1, 3, 2, 0, 2, 2, 1, 3, 2, 2, 1, 2, + 1, 2, 2, 4, 2, 3, 0, 4, 2, 3, 3, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 1, 1, 1, 2, 1, 3, 2, 0, 2, 2, 1, 4, 2, 2, 1, 2, + 1, 2, 2, 4, 2, 3, 0, 4, 2, 3, 3, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 1, 1, 1, 2, 1, 3, 2, 0, 2, 2, 1, 4, 2, 2, 1, 2, + + 1, 0, 0, 0, 0, 2, 3, 4, 3, 2, 2, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 3, 3, 1, 3, 2, 3, 0, 0, 0, 0, 2, 0, 0, 2, 3,//Cleric + 1, 0, 0, 0, 0, 2, 3, 4, 3, 2, 2, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 3, 3, 1, 3, 2, 3, 0, 0, 0, 0, 2, 0, 0, 2, 3, + 1, 0, 0, 0, 0, 2, 3, 4, 3, 2, 2, 0, 0, 0, 0, 0, 4, 4, 4, 4, 0, 0, 4, 3, 1, 3, 2, 3, 0, 0, 0, 0, 2, 0, 0, 2, 3, + 1, 0, 0, 0, 0, 2, 3, 4, 3, 2, 2, 0, 0, 0, 0, 0, 4, 4, 4, 0, 4, 0, 4, 3, 1, 3, 2, 3, 0, 0, 0, 0, 2, 0, 0, 2, 3, + + 1, 0, 3, 0, 0, 1, 2, 4, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 0, 0, 3, 2, 0, 0, 0, 0, 0, 2, 1, 0, 3, 3,//Druid + 1, 0, 3, 0, 0, 1, 2, 4, 2, 2, 0, 0, 3, 3, 3, 3, 3, 3, 3, 0, 0, 2, 2, 0, 0, 3, 2, 0, 0, 0, 0, 0, 2, 1, 0, 3, 3, + 1, 0, 3, 0, 0, 1, 2, 4, 2, 2, 0, 0, 3, 3, 3, 3, 3, 3, 3, 0, 0, 2, 2, 0, 0, 4, 2, 0, 0, 0, 0, 0, 2, 1, 0, 4, 3, + 1, 0, 3, 0, 0, 1, 2, 4, 2, 2, 0, 0, 3, 3, 3, 3, 3, 3, 3, 0, 0, 2, 2, 0, 0, 4, 2, 0, 0, 0, 0, 0, 2, 1, 0, 4, 3, + + 3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 3, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 3, 0, 0, 3, 3,//Sorcerer + 3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 3, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 3, 0, 0, 3, 3, + 3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 4, 4, 4, 4, 0, 0, 0, 4, 0, 4, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 4, 0, 0, 3, 3, + 3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 4, 0, 0, 3, 3, +}}; +std::array pHiredNPCsIconsOffsetsX = {489, 559}; +std::array pHiredNPCsIconsOffsetsY = {152, 152}; +std::array Party_Spec_Motion_status_ids = {7, 18}; //dword_4EE07C +std::array<__int16, 101> word_4EE088_sound_ids = +{{ + 0, 10000, 10010, 10020, 10030, 10040, 10050, 10060, 10070, 10080, + 10090, 10100, 11000, 11010, 11020, 11030, 11040, 11050, 11060, 11070, + 11080, 11090, 11100, 12000, 12010, 12020, 12030, 12040, 12050, 12060, + 12070, 12080, 12090, 12100, 13000, 13010, 13020, 13030, 13040, 13050, + 13060, 13070, 13080, 13090, 13100, 14000, 14010, 14020, 14030, 14040, + 14050, 14060, 14070, 14080, 14090, 14100, 15000, 15010, 15020, 15030, + 15040, 15050, 15060, 15070, 15080, 15090, 15100, 16000, 16010, 16020, + 16030, 16040, 16050, 16060, 16070, 16080, 16090, 16100, 17000, 17010, + 17020, 17030, 17040, 17050, 17060, 17070, 17080, 17090, 17100, 18000, + 18010, 18020, 18030, 18040, 18050, 18060, 18070, 18080, 18090, 18100, + 1 +}}; +std::array word_4EE150 = +{{ + 1, 2, 3, 4, 5, 7, 32, 33, 36, 37, 38, 40, 41, 42, 43, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 60 +}}; + +int ScreenshotFileNumber; // dword_4EFA80 +std::array off_4F03B8 = +{{ + "", "WEPNTABL", "ARMORY", "MAGSHELF", + "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", + "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", + "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", + "MAGSHELF", "MAGSHELF", "MAGSHELF" +}}; + +std::array guild_mambership_flags={{ + 54, 54, 54, 54, 52, 52, 52, 52, 55, 55, 55, 55, 53, 53, + 53, 53, 58, 58, 58, 58, 57, 57, 57, 57, 56, 56, + 56, 56, 59, 59, 60, 60}}; +std::array<__int16, 49> word_4F0754; +std::array<__int16, 54> _4F0882_evt_VAR_PlayerItemInHands_vals = +{{ + 0x0D4, 0x270, 0x0D5, 0x21C, 0x0D6, 0x2BE, 0x0D7, 0x2BD, 0x0D8, 0x289, + 0x0D9, 0x258, 0x0DA, 0x2AB, 0x0DB, 0x281, 0x0DC, 0x280, 0x0DD, + 0x284, 0x0DE, 0x285, 0x0DF, 0x283, 0x0E0, 0x282, 0x0E1, 0x27F, + 0x0E2, 0x1E7, 0x0E3, 0x287, 0x0E4, 0x272, 0x0E5, 0x267, 0x0E6, + 0x275, 0x0E7, 0x25A, 0x0E8, 0x2A4, 0x0E9, 0x2A5, 0x0EA, 0x2A3, + 0x0EB, 0x25C, 0x0EC, 0x25D, 0x0ED, 0x259, 0x0F1, 0x21E +}}; +std::array pMaxLevelPerTrainingHallType = {5, 15, 25, 25, 200, 200}; + +std::array price_for_membership={100, 100, 50, 50, 50, 50, 50, 50, 50, 1000, 1000}; // weak + + +std::array<__int16, 32> word_4F0F30 ={{ 4, 7, 10, 11, + 4, 7, 10, 11, + 4, 7, 10, 11, + 4, 7, 10, 11, + 4, 7, 10, 11, + 4, 7, 10, 11, + 4, 7, 10, 11, + 7, 11, + 7, 11}}; +std::array ai_array_4F5E68; +std::array ai_array_4F6638_actor_ids; +std::array ai_near_actors_targets_pid; +int ai_arrays_size; // weak +std::array ai_near_actors_distances; +std::array ai_near_actors_ids; +std::array dword_4F8580 = {}; // weak + +char byte_4FAA24; // weak +//HWND dword_4FAA28; // idb + +std::array pSRZBufferLineOffsets; +int areWeLoadingTexture; // weak +std::array books_num_items_per_page; // weak +int lloyds_beacon_spell_id; // dword_506338 +int lloyds_beacon_sound_id; // dword_50633C +signed int sRecoveryTime; // idb +unsigned int uRequiredMana; // idb +int _506348_current_lloyd_playerid; // weak +__int64 lloyds_beacon_spell_level; // qword_506350 +char byte_506360; // weak +int dword_506364; // weak +unsigned int uExitCancelTextureId; +int books_page_number; // weak +int books_primary_item_per_page; // weak +int Autonotes_Instructors_page_flag; // dword_50652C +int Autonotes_Misc_page_flag; //dword_506530 +int Book_PageBtn6_flag; //dword_506534 +int Book_PageBtn5_flag; //dword_506538 +int Book_PageBtn4_flag; // dword_50653C +int Book_PageBtn3_flag; //dword_506540 +int BtnDown_flag; //BtnDown_flag +int BtnUp_flag; //BtnUp_flag +int quick_spell_at_page; // weak +char byte_506550; // weak +std::array aMoonPhaseNames; +int _506568_autonote_type; // weak +char bRecallingBeacon; // weak +int uLastPointedObjectID; // weak +//unsigned __int8 bMonsterInfoUI_bDollInitialized; +std::array aSpellNames; +int pMainScreenNum; // weak +int dword_506980_uW; // weak +int dword_506984_uZ; // weak +int dword_506988_uY; // weak +int dword_50698C_uX; // weak +int uGameMenuUI_CurentlySelectedKeyIdx; // 506E68 +std::array pPrevVirtualCidesMapping; +int KeyboardPageNum; // weak +int uRestUI_FoodRequiredToRest; +int dword_506F14; // weak +int _506F18_num_minutes_to_sleep; // weak +int dword_506F1C; // weak +std::array pVisibleWindowsIdxs; // weak +int uNumVisibleWindows; +char bFlashHistoryBook; // weak +char bFlashAutonotesBook; // weak +char bFlashQuestBook; // weak +int uTextureID_PlayerBuff_PainReflection; // weak +int uTextureID_PlayerBuff_Hammerhands; // weak +int uTextureID_PlayerBuff_Preservation; // weak +int uTextureID_PlayerBuff_Bless; // weak +int uTextureID_Btn_QuickReference; // weak +int uTextureID_Compas; // dword_5079B4 +int dword_5079C8; // weak +int dword_5079CC; // weak +int dword_5079D0; // weak +int uTextureID_Minimap_Loop; // dword_5079D8 +struct GUIButton *pBtn_ZoomOut; // idb +struct GUIButton *pBtn_ZoomIn; // idb +unsigned int uGameUIFontShadow; +unsigned int uGameUIFontMain; +int dword_507B00_spell_info_to_draw_in_popup; // weak +std::array aMonthNames; +std::array aDayNames; +std::array aSpellSchoolNames; +std::array aAttributeNames; +unsigned int uActiveCharacter; +int dword_507BF0_is_there_popup_onscreen; // weak +int awards_scroll_bar_created; // weak +int dword_507CC0_activ_ch; // weak +__int64 GameUI_RightPanel_BookFlashTimer; // weak +int _507CD4_RestUI_hourglass_anim_controller; // weak +bool OpenedTelekinesis; +std::array dword_50B570; // weak +std::array dword_50B638; // weak +stru367 PortalFace; +std::array dword_50BC10; // weak +std::array dword_50BDA0; // weak +std::array _50BF30_actors_in_viewport_ids; // weak +char town_portal_caster_id; // weak +int some_active_character; // weak +std::array pIconIDs_Turn; +unsigned int uIconID_TurnStop; +unsigned int uIconID_TurnHour; +int uIconID_CharacterFrame; // idb +unsigned int uIconID_TurnStart; +int dword_50C994 = 0; // weak +int dword_50C998_turnbased_icon_1A = 0; // weak +int uSpriteID_Spell11; // idb +bool _50C9A0_IsEnchantingInProgress; // weak +int _50C9A8_item_enchantment_timer = 0; // weak +int _50C9D0_AfterEnchClickEventId; // weak +int _50C9D4_AfterEnchClickEventSecondParam; // weak +int _50C9D8_AfterEnchClickEventTimeout; // weak +int dword_50C9DC; // weak +struct NPCData *ptr_50C9E0; +//int dword_50C9E8; // idb +//int dword_50C9EC[120]; // weak +int dword_50CDC8; +Vec3_int_ layingitem_vel_50FDFC; +char pStartingMapName[32]; // idb +std::array IsPlayerWearingWatersuit; +std::array party_has_equipment; +std::array byte_5111F6_OwnedArtifacts; + +unsigned int uNumBlueFacesInBLVMinimap; +std::array pBlueFacesInBLVMinimapIDs; +std::array pTextureIDs_PartyBuffIcons; +unsigned int uIconIdx_FlySpell; +unsigned int uIconIdx_WaterWalk; +int dword_576E28; // weak +int _576E2C_current_minimap_zoom; // weak +__int64 _5773B8_event_timer; // weak + + +int dword_591084; // weak +struct Actor *pDialogue_SpeakingActor; +unsigned int uDialogueType; +int sDialogue_SpeakingActorNPC_ID; +struct LevelDecoration *_591094_decoration; +std::array sHouseName; // idb +int uCurrentHouse_Animation; // weak +char *dword_591164_teleport_map_name; // idb +int dword_591168_teleport_speedz; // weak +int dword_59116C_teleport_directionx; // weak +int dword_591170_teleport_directiony; // weak +int dword_591174_teleportz; // weak +int dword_591178_teleporty; // weak +int dword_59117C_teleportx; // weak +std::array, 6> byte_591180; // idb +std::array HouseNPCData;//0 zero element holds standart house npc +GUIButton* HouseNPCPortraitsButtonsList[6];//dword_5913F4 +struct Texture *pTexture_591428; +struct Texture *pTexture_outside; // idb +struct Texture *pTexture_Dialogue_Background; +std::array byte_5B0938; +int EvtTargetObj; // 0x5B5920 +int _unused_5B5924_is_travel_ui_drawn = false; // 005B5924 +int _5B65A8_npcdata_uflags_or_other; // weak +int _5B65AC_npcdata_fame_or_other; // weak +int _5B65B0_npcdata_rep_or_other; // weak +int _5B65B4_npcdata_loword_house_or_other; // weak +int _5B65B8_npcdata_hiword_house_or_other; // weak +int dword_5B65BC; // weak +int dword_5B65C0; // weak +int dword_5B65C4_cancelEventProcessing; // weak +int MapsLongTimers_count; // dword_5B65C8 ñ÷¸ò÷èê òàéìåðîâ äëÿ êîëîäöåâ, ôàåðâîëîâ-ëîâóøåê +int npcIdToDismissAfterDialogue; // weak +signed int dword_5B65D0_dialogue_actor_npc_id; // weak +int dword_5C3418; // weak +int dword_5C341C; // weak +//std::array byte_5C3427; // weak +std::array GameUI_Footer_TimedString; +std::array pFooterString; +unsigned int GameUI_Footer_TimeLeft; +int bForceDrawFooter; // weak +int _5C35C0_force_party_death = false; // weak +int bDialogueUI_InitializeActor_NPC_ID; // weak +char *p2DEventsTXT_Raw; + +int dword_5C35D4; // weak +std::array aAMPMNames; +char byte_5C45AF[777]; // weak + +std::array pFinalMessage; // idb +std::array pTmpBuf; +std::array pTmpBuf2; +std::array Journal_limitation_factor; // weak +int ui_current_text_color; // weak +__int64 qword_5C6DF0; // weak +int dword_5C6DF8; // weak +std::array item__getname_buffer; // idb +std::array pClassDescriptions; +std::array pAttributeDescriptions; +std::array pGrandSkillDesc; +std::array pMasterSkillDesc; +std::array pExpertSkillDesc; +std::array pNormalSkillDesc; +std::array pSkillDesc; +char *pHealthPointsAttributeDescription; +char *pSpellPointsAttributeDescription; +char *pArmourClassAttributeDescription; +char *pPlayerConditionAttributeDescription; // idb +char *pFastSpellAttributeDescription; +char *pPlayerAgeAttributeDescription; +char *pPlayerLevelAttributeDescription; +char *pPlayerExperienceAttributeDescription; +char *pAttackBonusAttributeDescription; +char *pAttackDamageAttributeDescription; +char *pMissleBonusAttributeDescription; +char *pMissleDamageAttributeDescription; +char *pFireResistanceAttributeDescription; +char *pAirResistanceAttributeDescription; +char *pWaterResistanceAttributeDescription; +char *pEarthResistanceAttributeDescription; +char *pMindResistanceAttributeDescription; +char *pBodyResistanceAttributeDescription; +char *pSkillPointsAttributeDescription; +char *pClassTXT_Raw; +char *pStatsTXT_Raw; +char *pSkillDescTXT_Raw; + +struct FactionTable *pFactionTable; +//std::array byte_5C8D1A; // weak + +std::array byte_5E4C15; // weak +std::array pSomeItemsNames; + +char *pMonstersTXT_Raw; +char *pMonsterPlacementTXT_Raw; +char *pSpellsTXT_Raw; +char *pMapStatsTXT_Raw; +char *pHostileTXT_Raw; +char *pPotionsTXT_Raw; +char *pPotionNotesTXT_Raw; + +std::array _6807B8_level_decorations_ids; // idb +int _6807E0_num_decorations_with_sounds_6807B8; // weak +std::array event_triggers; // 6807E8 +size_t num_event_triggers; // 6836C8 +std::array dword_69B010; +float flt_69B138_dist; // weak +char byte_69BD41_unused; // weak +unsigned int uTextureID_x_u; +unsigned int uTextureID_LS_saveU; +unsigned int uTextureID_LS_loadU; +unsigned int uTextureID_AR_DN_DN; +unsigned int uTextureID_AR_UP_DN; +unsigned int uTextureID_LS_; +unsigned int uTextureID_x_d; +unsigned int uTextureID_save_up; +unsigned int uTextureID_load_up; +unsigned int uTextureID_loadsave; +int pSaveListPosition; // weak +unsigned int uLoadGameUI_SelectedSlot; +HWND hInsertCDWindow; // idb +int uCPUSpeed; // weak +char cMM7GameCDDriveLetter; // idb +MENU_STATE sCurrentMenuID; +unsigned int uGameState; +int uDefaultTravelTime_ByFoot; // weak +int day_attrib; // weak +int day_fogrange_1; // weak +int day_fogrange_2; // weak +struct TileTable *pTileTable; // idb +int outdoor_grid_band_1; // idb +int outdoor_grid_band_2; // idb +int outdoor_grid_band_3; // idb +std::array pDefaultSkyTexture; // idb +std::array byte_6BE124_cfg_textures_DefaultGroundTexture; // idb +int _6BE134_odm_main_tile_group; // weak +int dword_6BE138; // weak +int dword_6BE13C_uCurrentlyLoadedLocationID; // weak +float fWalkSpeedMultiplier = 1.0f; // weak +float fBackwardWalkSpeedMultiplier = 1.0f; // weak +float fTurnSpeedMultiplier = 1.0f; // weak +float flt_6BE150_look_up_down_dangle = 1.0f; // weak +//HWND hWnd; // idb +bool FORCE_16_BITS = false; +class OSWindow *window = nullptr; +char pCurrentMapName[32]; // idb +unsigned int uLevelMapStatsID; +int dword_6BE364_game_settings_1 = 0; +int dword_6BE368_debug_settings_2 = 0; +unsigned __int8 bCanLoadFromCD = false; +int bShowDamage; // idb +unsigned int bAlwaysRun; +unsigned int bFlipOnExit; +unsigned int uTurnSpeed; +float flt_6BE3A0 = 0.55000001f; // weak +float flt_6BE3A4_debug_recmod1; +float flt_6BE3A8_debug_recmod2; +float flt_6BE3AC_debug_recmod1_x_1_6; +std::array byte_6BE3B0; // idb +char bUnderwater = false; // weak +char bNoNPCHiring = false; // weak +unsigned int bNoVideo = false; +bool bNoIntro = false; +bool bNoLogo = false; +bool bNoCD = false; +bool bNoSound = false; +std::array dword_720020_zvalues; +std::array dword_7201B0_zvalues; +int uTextureID_720980; // weak +std::array<__int16, 104> word_7209A0_intercepts_ys_plus_ys; +std::array<__int16, 104> word_720A70_intercepts_xs_plus_xs; +std::array<__int16, 104> word_720B40_intercepts_zs; +std::array<__int16, 102> word_720C10_intercepts_xs; +std::array<__int16, 777> word_720CE0_ys; // idb +std::array<__int16, 777> word_720DB0_xs; // idb +std::array dword_720E80; +std::array dword_720ED0; +std::array ceiling_height_level; +std::array<__int16, 104> odm_floor_face_vert_coord_Y; // word_720F70 +std::array<__int16, 104> odm_floor_face_vert_coord_X; // word_721040 +std::array current_Face_id; // dword_721110 +std::array current_BModel_id; // dword_721160 +std::array odm_floor_level; // idb +int blv_prev_party_x; // weak +int blv_prev_party_z; // weak +int blv_prev_party_y; // weak +std::array pNPCTopics; +std::array pQuestTable; +char *dword_723718_autonote_related; // idb +std::array pScrolls; +int dword_7241C8; // weak +std::array aNPCProfessionNames; +char *pAwardsTXT_Raw; +char *pScrollsTXT_Raw; +char *pMerchantsTXT_Raw; +std::array pMerchantsBuyPhrases; +std::array pMerchantsSellPhrases; +std::array pMerchantsRepairPhrases; +std::array pMerchantsIdentifyPhrases; +char *pTransitionsTXT_Raw; +char *pAutonoteTXT_Raw; +char *pQuestsTXT_Raw; +unsigned int uNumTerrainNormals; +struct Vec3_float_ *pTerrainNormals; +std::array pTerrainNormalIndices; +std::array pTerrainSomeOtherData; +int dword_A74C88; // weak +unsigned int uPlayerCreationUI_SkySliderPos; +int uPlayerCreationUI_ArrowAnim; +unsigned int uPlayerCreationUI_SelectedCharacter; +int dword_A74CDC; // weak +struct Texture *pTexture_PlayerFaceMask; +struct Texture *pTexture_PlayerFaceEradicated; +struct Texture *pTexture_PlayerFaceDead; +std::array< std::array, 4> pTextures_PlayerFaces; +__int64 _A750D8_player_speech_timer; // qword_A750D8 +enum PlayerSpeech PlayerSpeechID; +int uSpeakingCharacter; // weak +std::array pClassNames; +std::array aCharacterConditionNames; +std::array pSkillNames; +char byte_AE5B91; // weak +std::array dword_F1B430; // weak +//int dword_F8B144; // nexindex [-1] to the following +std::array player_levels = {{1, 1, 1, 1}}; +std::array<__int16, 6> weapons_Ypos; // word_F8B158 +struct Texture *ShopTexture; // idb +std::array ItemsInShopTexture; +__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_MasteryBeingTaught; // weak +int gold_transaction_amount; // F8B1B4 +std::array pShopOptions; +int dword_F8B1D8; // weak +int dword_F8B1E0; // weak +int dword_F8B1E4; // weak +const char *current_npc_text; // idb +char dialogue_show_profession_details = false; // F8B1EC +std::array byte_F8B1EF; // weak +std::array byte_F8B1F0; + +int bGameoverLoop = 0; // weak +std::array<__int16, 104> intersect_face_vertex_coords_list_a; // word_F8BC48 +std::array<__int16, 104> intersect_face_vertex_coords_list_b; // word_F8BD18 \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/mm7_data.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/mm7_data.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,791 @@ +#pragma once +#include +#include "VectorTypes.h" +#include "OSAPI.h" +#include +#include +#include "NZIArray.h" + +//typedef char _UNKNOWN; +typedef unsigned int uint; + + +inline void __fastcall memset32(void *ptr, unsigned __int32 value, int count) +{ + unsigned __int32* p = (unsigned __int32 *)ptr; + for (int i = 0; i < count; i++) + *p++ = value; +} + + + + + + + + + + + +#if defined(__GNUC__) + typedef long long ll; + typedef unsigned long long ull; + #define __int64 long long + #define __int32 int + #define __int16 short + #define __int8 char + #define MAKELL(num) num ## LL + #define FMT_64 "ll" +#elif defined(_MSC_VER) + typedef __int64 ll; + typedef unsigned __int64 ull; + #define MAKELL(num) num ## i64 + #define FMT_64 "I64" +#elif defined (__BORLANDC__) + typedef __int64 ll; + typedef unsigned __int64 ull; + #define MAKELL(num) num ## i64 + #define FMT_64 "L" +#else + #error "unknown compiler" +#endif +typedef unsigned int uint; +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned long ulong; + +typedef char int8; +typedef signed char sint8; +typedef unsigned char uint8; +typedef short int16; +typedef signed short sint16; +typedef unsigned short uint16; +typedef int int32; +typedef signed int sint32; +typedef unsigned int uint32; +typedef ll int64; +typedef ll sint64; +typedef ull uint64; + +// Partially defined types: +#define _BYTE uint8 +#define _WORD uint16 +#define _DWORD uint32 +#define _QWORD uint64 +#if !defined(_MSC_VER) +#define _LONGLONG __int128 +#endif + +#ifndef _WINDOWS_ +typedef int8 BYTE; +typedef int16 WORD; +typedef int32 DWORD; +typedef int32 LONG; +#endif +typedef int64 QWORD; +#ifndef __cplusplus +typedef int bool; // we want to use bool in our C programs +#endif + +// Some convenience macros to make partial accesses nicer +// first unsigned macros: +#ifdef HIBYTE +#undef HIBYTE +#endif // HIBYTE +#ifdef HIWORD +#undef HIWORD +#endif // HIWORD +#ifdef LOBYTE +#undef LOBYTE +#endif // LOBYTE +#ifdef LOWORD +#undef LOWORD +#endif // LOWORD + +#define LOBYTE(x) (*((_BYTE*)&(x))) // low byte +#define LOWORD(x) (*((_WORD*)&(x))) // low word +#define LODWORD(x) (*((_DWORD*)&(x))) // low dword +#define HIBYTE(x) (*((_BYTE*)&(x)+1)) +#define HIWORD(x) (*((_WORD*)&(x)+1)) +#define HIDWORD(x) (*((_DWORD*)&(x)+1)) +#define BYTEn(x, n) (*((_BYTE*)&(x)+n)) +#define WORDn(x, n) (*((_WORD*)&(x)+n)) +#define BYTE1(x) BYTEn(x, 1) // byte 1 (counting from 0) +#define BYTE2(x) BYTEn(x, 2) +#define BYTE3(x) BYTEn(x, 3) +#define BYTE4(x) BYTEn(x, 4) +#define BYTE5(x) BYTEn(x, 5) +#define BYTE6(x) BYTEn(x, 6) +#define BYTE7(x) BYTEn(x, 7) +#define BYTE8(x) BYTEn(x, 8) +#define BYTE9(x) BYTEn(x, 9) +#define BYTE10(x) BYTEn(x, 10) +#define BYTE11(x) BYTEn(x, 11) +#define BYTE12(x) BYTEn(x, 12) +#define BYTE13(x) BYTEn(x, 13) +#define BYTE14(x) BYTEn(x, 14) +#define BYTE15(x) BYTEn(x, 15) +#define WORD1(x) WORDn(x, 1) +#define WORD2(x) WORDn(x, 2) // third word of the object, unsigned +#define WORD3(x) WORDn(x, 3) +#define WORD4(x) WORDn(x, 4) +#define WORD5(x) WORDn(x, 5) +#define WORD6(x) WORDn(x, 6) +#define WORD7(x) WORDn(x, 7) + +// now signed macros (the same but with sign extension) +#define SLOBYTE(x) (*((int8*)&(x))) +#define SLOWORD(x) (*((int16*)&(x))) +#define SLODWORD(x) (*((int32*)&(x))) +#define SHIBYTE(x) (*((int8*)&(x)+1)) +#define SHIWORD(x) (*((int16*)&(x)+1)) +#define SHIDWORD(x) (*((int32*)&(x)+1)) +#define SBYTEn(x, n) (*((int8*)&(x)+n)) +#define SWORDn(x, n) (*((int16*)&(x)+n)) +#define SBYTE1(x) SBYTEn(x, 1) +#define SBYTE2(x) SBYTEn(x, 2) +#define SBYTE3(x) SBYTEn(x, 3) +#define SBYTE4(x) SBYTEn(x, 4) +#define SBYTE5(x) SBYTEn(x, 5) +#define SBYTE6(x) SBYTEn(x, 6) +#define SBYTE7(x) SBYTEn(x, 7) +#define SBYTE8(x) SBYTEn(x, 8) +#define SBYTE9(x) SBYTEn(x, 9) +#define SBYTE10(x) SBYTEn(x, 10) +#define SBYTE11(x) SBYTEn(x, 11) +#define SBYTE12(x) SBYTEn(x, 12) +#define SBYTE13(x) SBYTEn(x, 13) +#define SBYTE14(x) SBYTEn(x, 14) +#define SBYTE15(x) SBYTEn(x, 15) +#define SWORD1(x) SWORDn(x, 1) +#define SWORD2(x) SWORDn(x, 2) +#define SWORD3(x) SWORDn(x, 3) +#define SWORD4(x) SWORDn(x, 4) +#define SWORD5(x) SWORDn(x, 5) +#define SWORD6(x) SWORDn(x, 6) +#define SWORD7(x) SWORDn(x, 7) + + + +// Generate a reference to pair of operands +template int16 __PAIR__( int8 high, T low) { return ((( int16)high) << sizeof(high)*8) | uint8(low); } +template int32 __PAIR__( int16 high, T low) { return ((( int32)high) << sizeof(high)*8) | uint16(low); } +template int64 __PAIR__( int32 high, T low) { return ((( int64)high) << sizeof(high)*8) | uint32(low); } +template uint16 __PAIR__(uint8 high, T low) { return (((uint16)high) << sizeof(high)*8) | uint8(low); } +template uint32 __PAIR__(uint16 high, T low) { return (((uint32)high) << sizeof(high)*8) | uint16(low); } +template uint64 __PAIR__(uint32 high, T low) { return (((uint64)high) << sizeof(high)*8) | uint32(low); } + +// rotate left +template T __ROL__(T value, uint count) +{ + const uint nbits = sizeof(T) * 8; + count %= nbits; + + T high = value >> (nbits - count); + value <<= count; + value |= high; + return value; +} + +// rotate right +template T __ROR__(T value, uint count) +{ + const uint nbits = sizeof(T) * 8; + count %= nbits; + + T low = value << (nbits - count); + value >>= count; + value |= low; + return value; +} + +// carry flag of left shift +template int8 __MKCSHL__(T value, uint count) +{ + const uint nbits = sizeof(T) * 8; + count %= nbits; + + return (value >> (nbits-count)) & 1; +} + +// carry flag of right shift +template int8 __MKCSHR__(T value, uint count) +{ + return (value >> (count-1)) & 1; +} + +// sign flag +template int8 __SETS__(T x) +{ + if ( sizeof(T) == 1 ) + return int8(x) < 0; + if ( sizeof(T) == 2 ) + return int16(x) < 0; + if ( sizeof(T) == 4 ) + return int32(x) < 0; + return int64(x) < 0; +} + +// overflow flag of subtraction (x-y) +template int8 __OFSUB__(T x, U y) +{ + if ( sizeof(T) < sizeof(U) ) + { + U x2 = x; + int8 sx = __SETS__(x2); + return (sx ^ __SETS__(y)) & (sx ^ __SETS__(x2-y)); + } + else + { + T y2 = y; + int8 sx = __SETS__(x); + return (sx ^ __SETS__(y2)) & (sx ^ __SETS__(x-y2)); + } +} + +// overflow flag of addition (x+y) +template int8 __OFADD__(T x, U y) +{ + if ( sizeof(T) < sizeof(U) ) + { + U x2 = x; + int8 sx = __SETS__(x2); + return ((1 ^ sx) ^ __SETS__(y)) & (sx ^ __SETS__(x2+y)); + } + else + { + T y2 = y; + int8 sx = __SETS__(x); + return ((1 ^ sx) ^ __SETS__(y2)) & (sx ^ __SETS__(x+y2)); + } +} + +// carry flag of subtraction (x-y) +template int8 __CFSUB__(T x, U y) +{ + int size = sizeof(T) > sizeof(U) ? sizeof(T) : sizeof(U); + if ( size == 1 ) + return uint8(x) < uint8(y); + if ( size == 2 ) + return uint16(x) < uint16(y); + if ( size == 4 ) + return uint32(x) < uint32(y); + return uint64(x) < uint64(y); +} + +// carry flag of addition (x+y) +template int8 __CFADD__(T x, U y) +{ + int size = sizeof(T) > sizeof(U) ? sizeof(T) : sizeof(U); + if ( size == 1 ) + return uint8(x) > uint8(x+y); + if ( size == 2 ) + return uint16(x) > uint16(x+y); + if ( size == 4 ) + return uint32(x) > uint32(x+y); + return uint64(x) > uint64(x+y); +} + + +//------------------------------------------------------------------------- +// Data declarations + +extern int game_starting_year; +extern unsigned int game_viewport_width; +extern unsigned int game_viewport_height; +extern int game_viewport_x; +extern int game_viewport_y; +extern int game_viewport_z; +extern int game_viewport_w; + +extern int pWindowList_at_506F50_minus1_indexing[1]; +extern int dword_4C9890[10]; // weak +extern int dword_4C9920[16]; // weak +extern char byte_4D864C; // weak +extern float flt_4D86CC; // weak +extern int dword_4D86D8; // weak + + +extern float flt_4D84E8; + +extern int pCurrentScreen; // 004E28F8 +extern unsigned int uGammaPos; +extern std::array BtnTurnCoord; +extern std::array<__int16, 4> RightClickPortraitXmin; +extern std::array<__int16, 4> RightClickPortraitXmax; +//extern int pArmorSkills[5]; +//extern int pWeaponSkills[9]; +//extern int pMiscSkills[12]; +//extern int pMagicSkills[9]; +extern std::array pHealthBarPos; +extern std::array pManaBarPos; +//extern std::array _4E2B21_buff_spell_tooltip_colors; +extern std::array monster_popup_y_offsets; // weak +extern unsigned char hourglass_icon_idx; // weak + + +extern const char *format_4E2D80; +extern char format_4E2D90[8]; +extern const char *format_4E2DE8; // idb +extern const char *Stat_string_format_2_column_text; +extern const char *Stat_string_format_2_column_less_100; // format text of resistance in Stats screen +extern const char *Stat_string_format_2_column_over_100; +extern int dword_4E455C; // weak +extern std::array dword_4E4560; +extern std::array dword_4E4578; +extern std::array dword_4E4590; +extern std::array dword_4E45A8; +extern std::array flt_4E4A80; + +extern std::array< std::array, 14> pPartySpellbuffsUI_XYs; +extern std::array byte_4E5DD8; // weak +extern std::array pPartySpellbuffsUI_smthns; +extern std::array< std::array, 6> pNPCPortraits_x; // 004E5E50 +extern std::array< std::array, 6> pNPCPortraits_y; // 004E5EE0 +extern std::array pHouse_ExitPictures; +extern std::array _4E6BDC_loc_names; +extern std::array<__int16, 11> word_4E8152; +extern std::array< std::array, 7> byte_4E8168; +extern char _4E94D0_light_type; // weak +extern char _4E94D2_light_type; // weak +extern char _4E94D3_light_type; // weak +extern std::array saveload_dlg_xs; +extern std::array saveload_dlg_ys; +extern std::array saveload_dlg_zs; +extern std::array saveload_dlg_ws; +extern int dword_4E98BC_bApplicationActive; // weak +extern std::array pTransitionStrings; // 4EB080 +extern std::array dword_4EC268; // weak +extern std::array dword_4EC28C; // weak +extern std::array pPlayerPortraitsNames; + +extern std::array< std::array, 48> byte_4ECF08; +extern std::array, 110> SoundSetAction; // weak +extern std::array<__int16, 4> pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing; +extern std::array< std::array, 36> byte_4ED970_skill_learn_ability_by_class_table; +extern std::array pHiredNPCsIconsOffsetsX; +extern std::array pHiredNPCsIconsOffsetsY; +extern std::array Party_Spec_Motion_status_ids; //dword_4EE07C +extern std::array<__int16, 101> word_4EE088_sound_ids; // weak +extern std::array word_4EE150; +extern int ScreenshotFileNumber; // dword_4EFA80 +extern std::array off_4F03B8; // idb +extern __int16 word_4F0576[]; // weak + +extern std::array guild_mambership_flags; +extern std::array<__int16, 49> word_4F0754; +extern std::array<__int16, 54> _4F0882_evt_VAR_PlayerItemInHands_vals; +extern std::array pMaxLevelPerTrainingHallType; +extern std::array price_for_membership; // weak +extern std::array<__int16, 32> word_4F0F30; // weak +extern std::array ai_array_4F5E68; +extern std::array ai_array_4F6638_actor_ids; +extern std::array ai_near_actors_targets_pid; +extern int ai_arrays_size; // weak +extern std::array ai_near_actors_distances; +extern std::array ai_near_actors_ids; +extern std::array dword_4F8580; // weak +extern int dword_4FA9B0[]; // weak +extern int dword_4FA9B4[]; // weak + +extern char byte_4FAA24; // weak +//extern HWND dword_4FAA28; // idb + +extern std::array pSRZBufferLineOffsets; +extern int areWeLoadingTexture; // weak +extern std::array books_num_items_per_page; // weak +extern int lloyds_beacon_spell_id; // dword_506338 +extern int lloyds_beacon_sound_id; // dword_50633C +extern signed int sRecoveryTime; // idb +extern unsigned int uRequiredMana; // idb +extern int _506348_current_lloyd_playerid; // weak +extern __int64 lloyds_beacon_spell_level; // qword_506350 +extern char byte_506360; // weak +extern int dword_506364; // weak +//extern Texture *dword_50640C[]; // weak +extern unsigned int uExitCancelTextureId; +extern int books_page_number; // number for page in books(íîìåð ñòðàíèöû â êíèãàõ) +extern int books_primary_item_per_page; // number primary item in book page(íîìåð íà÷àëüíîé çàïèñè íà ñòðàíèöå) +extern int Autonotes_Instructors_page_flag; // dword_50652C +extern int Autonotes_Misc_page_flag; //dword_506530 +extern int Book_PageBtn6_flag; //dword_506534 +extern int Book_PageBtn5_flag; //dword_506538 +extern int Book_PageBtn4_flag; //dword_50653C +extern int Book_PageBtn3_flag; //dword_506540 +extern int BtnDown_flag; //BtnDown_flag +extern int BtnUp_flag; //BtnUp_flag +extern int quick_spell_at_page; // weak +extern char byte_506550; // weak +extern std::array aMoonPhaseNames; +extern int _506568_autonote_type; // 506568 +extern char bRecallingBeacon; // weak +extern int uLastPointedObjectID; // weak +//extern unsigned __int8 bMonsterInfoUI_bDollInitialized; +extern std::array aSpellNames; +extern int pMainScreenNum; // weak +extern int dword_506980_uW; // weak +extern int dword_506984_uZ; // weak +extern int dword_506988_uY; // weak +extern int dword_50698C_uX; // weak +extern int uGameMenuUI_CurentlySelectedKeyIdx; // 506E68 +extern std::array GameMenuUI_InvaligKeyBindingsFlags; // 506E6C +extern std::array pPrevVirtualCidesMapping; +extern int KeyboardPageNum; // weak +extern int uRestUI_FoodRequiredToRest; +extern int dword_506F14; // weak +extern int _506F18_num_minutes_to_sleep; // weak +extern int dword_506F1C; // weak +extern std::array pVisibleWindowsIdxs; // weak +extern int uNumVisibleWindows; +extern char bFlashHistoryBook; // weak +extern char bFlashAutonotesBook; // weak +extern char bFlashQuestBook; // weak +extern int uTextureID_PlayerBuff_PainReflection; // weak +extern int uTextureID_PlayerBuff_Hammerhands; // weak +extern int uTextureID_PlayerBuff_Preservation; // weak +extern int uTextureID_PlayerBuff_Bless; // weak +extern int uTextureID_Btn_QuickReference; // weak +extern int uTextureID_Compas; // dword_5079B4 +extern int dword_5079C8; // weak +extern int dword_5079CC; // weak +extern int dword_5079D0; // weak +extern int uTextureID_Minimap_Loop; // dword_5079D8 +extern struct GUIButton *pBtn_ZoomOut; // idb +extern struct GUIButton *pBtn_ZoomIn; // idb +extern unsigned int uGameUIFontShadow; +extern unsigned int uGameUIFontMain; +extern int dword_507B00_spell_info_to_draw_in_popup; // weak +extern std::array aMonthNames; +extern std::array aDayNames; +extern std::array aSpellSchoolNames; +extern std::array aAttributeNames; +extern unsigned int uActiveCharacter; +extern int dword_507BF0_is_there_popup_onscreen; // weak +extern int awards_scroll_bar_created; // weak +extern int dword_507CC0_activ_ch; // weak +extern __int64 GameUI_RightPanel_BookFlashTimer; // weak +extern int _507CD4_RestUI_hourglass_anim_controller; // weak +extern bool OpenedTelekinesis; // weak +extern std::array dword_50B570; // weak +extern std::array dword_50B638; // weak +extern struct stru367 PortalFace; +extern std::array dword_50BC10; // weak +extern std::array dword_50BDA0; // weak +extern std::array _50BF30_actors_in_viewport_ids; // weak +extern char town_portal_caster_id; // weak +extern int some_active_character; // weak +extern std::array pIconIDs_Turn; +extern unsigned int uIconID_TurnStop; +extern unsigned int uIconID_TurnHour; +extern int uIconID_CharacterFrame; // idb +extern unsigned int uIconID_TurnStart; +extern int dword_50C994; // weak +extern int dword_50C998_turnbased_icon_1A; // weak +extern int uSpriteID_Spell11; // idb +extern bool _50C9A0_IsEnchantingInProgress; // weak +extern int _50C9A8_item_enchantment_timer; // weak +extern int _50C9D0_AfterEnchClickEventId; // weak +extern int _50C9D4_AfterEnchClickEventSecondParam; // weak +extern int _50C9D8_AfterEnchClickEventTimeout; // weak +extern int dword_50C9DC; // weak +extern struct NPCData *ptr_50C9E0; +//extern int dword_50C9E8; // idb +//extern int dword_50C9EC[]; // 50C9EC +extern int dword_50CDC8; +extern Vec3_int_ layingitem_vel_50FDFC; +extern char pStartingMapName[32]; // idb +extern std::array IsPlayerWearingWatersuit; +extern std::array party_has_equipment; +extern std::array byte_5111F6_OwnedArtifacts; +extern std::array papredoll_dbrds; + +extern int bRingsShownInCharScreen; // weak + +extern unsigned int uNumBlueFacesInBLVMinimap; +extern std::array pBlueFacesInBLVMinimapIDs; +extern std::array pTextureIDs_PartyBuffIcons; +extern unsigned int uIconIdx_FlySpell; +extern unsigned int uIconIdx_WaterWalk; +extern int dword_576E28; // weak +extern int _576E2C_current_minimap_zoom; // weak +extern __int64 _5773B8_event_timer; // weak + +extern int dword_591084; // weak +extern struct Actor *pDialogue_SpeakingActor; +extern unsigned int uDialogueType; +extern signed int sDialogue_SpeakingActorNPC_ID; +extern struct LevelDecoration *_591094_decoration; +extern std::array sHouseName; // idb +extern int uCurrentHouse_Animation; // weak +extern char *dword_591164_teleport_map_name; // idb +extern int dword_591168_teleport_speedz; // weak +extern int dword_59116C_teleport_directionx; // weak +extern int dword_591170_teleport_directiony; // weak +extern int dword_591174_teleportz; // weak +extern int dword_591178_teleporty; // weak +extern int dword_59117C_teleportx; // weak +extern std::array, 6> byte_591180; // idb +extern std::array HouseNPCData; //0this array size temporarily increased to 60 from 6 to work aroud house overflow +extern GUIButton* HouseNPCPortraitsButtonsList[6]; +extern struct Texture *pTexture_591428; +extern struct Texture *pTexture_outside; // idb +extern struct Texture *pTexture_Dialogue_Background; +extern std::array byte_5B0938; +extern int EvtTargetObj; // weak +extern int _unused_5B5924_is_travel_ui_drawn; // 005B5924 +extern int _5B65A8_npcdata_uflags_or_other; // weak +extern int _5B65AC_npcdata_fame_or_other; // weak +extern int _5B65B0_npcdata_rep_or_other; // weak +extern int _5B65B4_npcdata_loword_house_or_other; // weak +extern int _5B65B8_npcdata_hiword_house_or_other; // weak +extern int dword_5B65BC; // weak +extern int dword_5B65C0; // weak +extern int dword_5B65C4_cancelEventProcessing; // weak +extern int MapsLongTimers_count; // dword_5B65C8 +extern int npcIdToDismissAfterDialogue; // weak +extern int dword_5B65D0_dialogue_actor_npc_id; // weak +extern int dword_5C3418; // weak +extern int dword_5C341C; // weak +//extern std::array byte_5C3427; // weak +extern std::array GameUI_Footer_TimedString; +extern std::array pFooterString; +extern unsigned int GameUI_Footer_TimeLeft; +extern int bForceDrawFooter; // weak +extern int _5C35C0_force_party_death; // weak +extern int bDialogueUI_InitializeActor_NPC_ID; // weak +extern char *p2DEventsTXT_Raw; + +extern int dword_5C35D4; // weak +extern std::array aAMPMNames; +extern char byte_5C45AF[]; // weak +extern std::array pTmpBuf3; +extern std::array pFinalMessage; // idb +extern std::array pTmpBuf; +extern std::array pTmpBuf2; +extern std::array Journal_limitation_factor; // weak +extern int ui_current_text_color; // weak +extern __int64 qword_5C6DF0; // weak +extern int dword_5C6DF8; // weak +extern std::array item__getname_buffer; // idb +extern std::array pClassDescriptions; +extern std::array pAttributeDescriptions; +extern std::array pGrandSkillDesc; +extern std::array pMasterSkillDesc; +extern std::array pExpertSkillDesc; +extern std::array pNormalSkillDesc; +extern std::array pSkillDesc; +extern char *pHealthPointsAttributeDescription; +extern char *pSpellPointsAttributeDescription; +extern char *pArmourClassAttributeDescription; +extern char *pPlayerConditionAttributeDescription; // idb +extern char *pFastSpellAttributeDescription; +extern char *pPlayerAgeAttributeDescription; +extern char *pPlayerLevelAttributeDescription; +extern char *pPlayerExperienceAttributeDescription; +extern char *pAttackBonusAttributeDescription; +extern char *pAttackDamageAttributeDescription; +extern char *pMissleBonusAttributeDescription; +extern char *pMissleDamageAttributeDescription; +extern char *pFireResistanceAttributeDescription; +extern char *pAirResistanceAttributeDescription; +extern char *pWaterResistanceAttributeDescription; +extern char *pEarthResistanceAttributeDescription; +extern char *pMindResistanceAttributeDescription; +extern char *pBodyResistanceAttributeDescription; +extern char *pSkillPointsAttributeDescription; +extern char *pClassTXT_Raw; +extern char *pStatsTXT_Raw; +extern char *pSkillDescTXT_Raw; +extern struct FactionTable *pFactionTable; +//extern std::array byte_5C8D1A; // weak + +extern std::array byte_5E4C15; // weak +extern std::array pSomeItemsNames; + +extern char *pMonstersTXT_Raw; +extern char *pMonsterPlacementTXT_Raw; +extern char *pSpellsTXT_Raw; +extern char *pMapStatsTXT_Raw; +extern char *pHostileTXT_Raw; +extern char *pPotionsTXT_Raw; +extern char *pPotionNotesTXT_Raw; + +extern std::array _6807B8_level_decorations_ids; // idb +extern int _6807E0_num_decorations_with_sounds_6807B8; // weak +extern std::array event_triggers; // 6807E8 +extern size_t num_event_triggers; // 6836C8 +extern std::array dword_69B010; +extern float flt_69B138_dist; // weak +extern char byte_69BD41_unused; // weak +extern unsigned int uTextureID_x_u; +extern unsigned int uTextureID_LS_saveU; +extern unsigned int uTextureID_LS_loadU; +extern unsigned int uTextureID_AR_DN_DN; +extern unsigned int uTextureID_AR_UP_DN; +extern unsigned int uTextureID_LS_; +extern unsigned int uTextureID_x_d; +extern unsigned int uTextureID_save_up; +extern unsigned int uTextureID_load_up; +extern unsigned int uTextureID_loadsave; +extern int pSaveListPosition; // weak +extern unsigned int uLoadGameUI_SelectedSlot; +extern HWND hInsertCDWindow; // idb +extern int uCPUSpeed; // weak +extern char cMM7GameCDDriveLetter; // idb +extern enum MENU_STATE sCurrentMenuID; +extern unsigned int uGameState; +extern int uDefaultTravelTime_ByFoot; // weak +extern int day_attrib; // weak +extern int day_fogrange_1; // weak +extern int day_fogrange_2; // weak +extern struct TileTable *pTileTable; // idb +extern int outdoor_grid_band_1; // idb +extern int outdoor_grid_band_2; // idb +extern int outdoor_grid_band_3; // idb +extern std::array pDefaultSkyTexture; // idb +extern std::array byte_6BE124_cfg_textures_DefaultGroundTexture; // idb +extern int _6BE134_odm_main_tile_group; // weak +extern int dword_6BE138; // weak +extern int dword_6BE13C_uCurrentlyLoadedLocationID; // weak +extern float fWalkSpeedMultiplier; // weak +extern float fBackwardWalkSpeedMultiplier; // weak +extern float fTurnSpeedMultiplier; // weak +extern float flt_6BE150_look_up_down_dangle; // weak +//extern char pMM7WindowClassName[]; // idb +//extern HINSTANCE hInstance; // idb +//extern char *pCmdLine; +//extern HWND hWnd; // idb +extern char pCurrentMapName[32]; // idb +extern unsigned int uLevelMapStatsID; + +extern bool FORCE_16_BITS; // related to GAME_SETTINGS_INVALID_RESOLUTION +#define GAME_SETTINGS_0001 0x0001 +#define GAME_SETTINGS_INVALID_RESOLUTION 0x0002 +#define GAME_SETTINGS_NO_INTRO 0x0004 +#define GAME_SETTINGS_NO_LOGO 0x0008 +#define GAME_SETTINGS_NO_SOUND 0x0010 +#define GAME_SETTINGS_NO_WALK_SOUND 0x0020 +#define GAME_SETTINGS_NO_HOUSE_ANIM 0x0040 +#define GAME_SETTINGS_0080_SKIP_USER_INPUT_THIS_FRAME 0x0080 +#define GAME_SETTINGS_APP_INACTIVE 0x0100 +#define GAME_SETTINGS_0200_EVENT_TIMER 0x0200 +#define GAME_SETTINGS_0400_MISC_TIMER 0x0400 +#define GAME_SETTINGS_0800 0x0800 +#define GAME_SETTINGS_1000 0x1000 +#define GAME_SETTINGS_2000 0x2000 +#define GAME_SETTINGS_4000 0x4000 +extern int dword_6BE364_game_settings_1; // GAME_SETTINGS_* + +#define DEBUG_SETTINGS_RUN_IN_WIDOW 0x0001 +#define DEBUG_SETTINGS_0002_SHOW_FR 0x0002 +#define DEBUG_SETTINGS_NO_ACTORS 0x0004 +#define DEBUG_SETTINGS_NO_DECORATIONS 0x0008 +#define DEBUG_SETTINGS_NO_DAMAGE 0x0010 +extern int dword_6BE368_debug_settings_2; // DEBUG_SETTINGS_* + +extern unsigned __int8 bCanLoadFromCD; +extern int bShowDamage; // idb +extern unsigned int bAlwaysRun; +extern unsigned int bFlipOnExit; +extern unsigned int uTurnSpeed; +extern float flt_6BE3A0; // weak +extern float flt_6BE3A4_debug_recmod1; +extern float flt_6BE3A8_debug_recmod2; +extern float flt_6BE3AC_debug_recmod1_x_1_6; +extern std::array byte_6BE3B0; // idb +extern char bUnderwater; // weak +extern char bNoNPCHiring; // weak +extern unsigned int bNoVideo; +extern bool bNoIntro; +extern bool bNoLogo; +extern bool bNoCD; +extern bool bNoSound; +extern std::array dword_720020_zvalues; +extern std::array dword_7201B0_zvalues; +extern int uTextureID_720980; // weak +extern std::array<__int16, 104> word_7209A0_intercepts_ys_plus_ys; +extern std::array<__int16, 104> word_720A70_intercepts_xs_plus_xs; +extern std::array<__int16, 104> word_720B40_intercepts_zs; +extern std::array<__int16, 102> word_720C10_intercepts_xs; +extern std::array<__int16, 777> word_720CE0_ys; // idb +extern std::array<__int16, 777> word_720DB0_xs; // idb +extern std::array dword_720E80; +extern std::array dword_720ED0; +extern std::array ceiling_height_level; +extern std::array<__int16, 104> odm_floor_face_vert_coord_Y; // word_720F70 +extern std::array<__int16, 104> odm_floor_face_vert_coord_X; // word_721040 +extern std::array current_Face_id; // dword_721110 +extern std::array current_BModel_id; // dword_721160 +extern std::array odm_floor_level; // idb dword_7211B0 +extern int blv_prev_party_x; // weak +extern int blv_prev_party_z; // weak +extern int blv_prev_party_y; // weak +extern char *dword_722F10; // idb +extern std::array pQuestTable; +extern char *dword_723718_autonote_related; // idb +extern std::array pScrolls; +extern int dword_7241C8; // weak + +extern std::array aNPCProfessionNames; +extern char *pAwardsTXT_Raw; +extern char *pScrollsTXT_Raw; +extern char *pMerchantsTXT_Raw; +extern std::array pMerchantsBuyPhrases; +extern std::array pMerchantsSellPhrases; +extern std::array pMerchantsRepairPhrases; +extern std::array pMerchantsIdentifyPhrases; +extern char *pTransitionsTXT_Raw; +extern char *pAutonoteTXT_Raw; +extern char *pQuestsTXT_Raw; +extern unsigned int uNumTerrainNormals; +extern struct Vec3_float_ *pTerrainNormals; +extern std::array pTerrainNormalIndices; +extern std::array pTerrainSomeOtherData; +extern int dword_A74C88; // weak +extern unsigned int uPlayerCreationUI_SkySliderPos; +extern int uPlayerCreationUI_ArrowAnim; +extern unsigned int uPlayerCreationUI_SelectedCharacter; +extern int dword_A74CDC; // weak +extern struct Texture *pTexture_PlayerFaceMask; +extern struct Texture *pTexture_PlayerFaceEradicated; +extern struct Texture *pTexture_PlayerFaceDead; +extern std::array< std::array, 4> pTextures_PlayerFaces; +extern __int64 _A750D8_player_speech_timer; // qword_A750D8 +extern enum PlayerSpeech PlayerSpeechID; +extern int uSpeakingCharacter; // weak +extern std::array pClassNames; +extern std::array aCharacterConditionNames; +extern std::array pSkillNames; +extern char byte_AE5B91; // weak +extern std::array dword_F1B430; // weak +extern std::array player_levels; +extern std::array<__int16, 6> weapons_Ypos; // word_F8B158 +extern struct Texture *ShopTexture; // idb +extern std::array ItemsInShopTexture; +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_MasteryBeingTaught; // weak +extern int gold_transaction_amount; // F8B1B4 +extern std::array pShopOptions; +extern int dword_F8B1D8; // weak +extern int dword_F8B1E0; // weak +extern int dword_F8B1E4; // weak +extern const char *current_npc_text; // 0xF8B1E8 +extern char dialogue_show_profession_details; // weak +extern std::array byte_F8B1EF; // weak +extern std::array byte_F8B1F0; + +extern int bGameoverLoop; // weak +extern std::array<__int16, 104> intersect_face_vertex_coords_list_a; // word_F8BC48 +extern std::array<__int16, 104> intersect_face_vertex_coords_list_b; // word_F8BD18 +extern bool wizard_eye; +extern bool change_seasons; +extern bool all_magic; +extern bool debug_information; +extern bool show_picked_face; +extern bool draw_portals_loops; +extern bool new_speed; +extern bool bSnow; +extern bool draw_terrain_dist_mist; diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/mm7text_ru.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/mm7text_ru.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,1439 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include +#include +#include + +#include "Log.h" +#include "Engine/ErrorHandling.h" + + +struct GenderTableEntry +{ + const char *name; + int gender; +} gender_table_caps[] = +{ + {"Àâåëü", 0}, + {"Àäàì", 0}, + {"Àäðèàí", 0}, + {"Àäðèàíèñ", 0}, + {"Àäñêàÿ", 1}, + {"Àéð", 0}, + {"Àêèî", 0}, + {"Àêèðà", 0}, + {"Àëàí", 0}, + {"Àëåéí", 0}, + {"Àëåê", 0}, + {"Àëåêñàíäð", 0}, + {"Àëåêñèñ", 1}, + {"Àëåí", 0}, + {"Àëåõàíäðî", 0}, + {"Àëèñà", 1}, + {"Àëüáåðò", 0}, + {"Àëüòîí", 0}, + {"Àëüòðåä", 0}, + {"Àëüôðåä", 0}, + {"Àìàíäà", 1}, + {"Àìáåð", 1}, + {"Àìáðîçèé", 0}, + {"Àìåëèÿ", 1}, + {"Àìîñ", 0}, + {"Àíãåë", 0}, + {"Àíäðåà", 1}, + {"Àíäðåé", 0}, + {"Àíæåëà", 1}, + {"Àíèòà", 1}, + {"Àííà", 1}, + {"Àíòîí", 0}, + {"Àíòîíèé", 0}, + {"Àðáè", 0}, + {"Àðäà", 0}, + {"Àðäåí", 0}, + {"Àðåíà", 1}, + {"Àðèñòåé", 0}, + {"Àðèñòèäèñ", 0}, + {"Àðèõ", 0}, + {"Àðèýëü", 0}, + {"Àðëåí", 0}, + {"Àðëî", 0}, + {"Àðìàíä", 0}, + {"Àðíîëüä", 0}, + {"Àðîí", 0}, + {"Àðòóð", 0}, + {"Àðõàíãåë", 0}, + {"Àðõèìàã", 0}, + {"Àõìåä", 0}, + {"Á¸ðòîí", 0}, + {"Áàä", 0}, + {"Áàéðîí", 0}, + {"Áàíäèò", 0}, + {"Áàð", 0}, + {"Áàðáàðà", 1}, + {"Áàðåòò", 0}, + {"Áàðò", 0}, + {"Áàò÷", 0}, + {"Áåàòðèñ", 1}, + {"Áåâåðëè", 1}, + {"Áåêè", 1}, + {"Áåëèíäà", 1}, + {"Áåí", 0}, + {"Áåíäæàìèí", 0}, + {"Áåíåäèêò", 0}, + {"Áåíèòî", 0}, + {"Áåííåò", 0}, + {"Áåííè", 0}, + {"Áåíóà", 0}, + {"Áåðíàäåòòà", 1}, + {"Áåðíàðä", 0}, + {"Áåðíè", 0}, + {"Áåðíèñ", 1}, + {"Áåðíó÷î", 0}, + {"Áåðò", 0}, + {"Áåðòðàí", 0}, + {"Áåò", 1}, + {"Áåòñè", 1}, + {"Áåòòè", 1}, + {"Áèëëè", 0}, + {"Áèëëèñ", 1}, + {"Áèøîï", 0}, + {"Áëåéê", 0}, + {"Áëåéí", 0}, + {"Áëîíäî", 0}, + {"Áî", 0}, + {"Áîá", 0}, + {"Áîááè", 0}, + {"Áîäî", 0}, + {"Áîëîòíûé", 0}, + {"Áîëüøîé", 0}, + {"Áîííè", 1}, + {"Áîðåãàðä", 0}, + {"Áîðèñ", 0}, + {"Áðàäåí", 0}, + {"Áðàéñ", 0}, + {"Áðàò", 0}, + {"Áðåéí", 0}, + {"Áðåíäà", 1}, + {"Áðåíäîí", 0}, + {"Áðåíò", 0}, + {"Áðåò", 0}, + {"Áðîíâèí", 0}, + {"Áðîíçîâûé", 0}, + {"Áðóê", 0}, + {"Áðóíî", 0}, + {"Áðýä", 0}, + {"Áðýäëè", 0}, + {"Áðýäôîðä", 0}, + {"Áðýíäîí", 0}, + {"Áðþñ", 0}, + {"Áóôîðä", 0}, + {"Âàäèì", 0}, + {"Âàë", 0}, + {"Âàëåðèÿ", 1}, + {"Âàëüòåð", 0}, + {"Âàíäà", 1}, + {"Âàíåññà", 1}, + {"Âàíåòòà", 1}, + {"Âàíñ", 0}, + {"Âåéí", 0}, + {"Âåëèêèé", 0}, + {"Âåíäåëë", 0}, + {"Âåíäè", 1}, + {"Âåðà", 1}, + {"Âåðí", 0}, + {"Âåðíîí", 0}, + {"Âåðîíèêà", 1}, + {"Âåðõîâíàÿ", 1}, + {"Âåñëè", 0}, + {"Âèâåðí", 0}, + {"Âèâüåí", 1}, + {"Âèêè", 1}, + {"Âèêòîð", 0}, + {"Âèêòîðèñ", 0}, + {"Âèêòîðèÿ", 1}, + {"Âèëàì", 0}, + {"Âèëë", 0}, + {"Âèëëàðä", 0}, + {"Âèëüìà", 1}, + {"Âèëüôðåä", 0}, + {"Âèëüÿì", 0}, + {"Âèííûé", 0}, + {"Âèíñòîí", 0}, + {"Âèí÷åíöî", 0}, + {"Âèîëåò", 1}, + {"Âèðãèëèé", 0}, + {"Âèðãèíèÿ", 1}, + {"Âèõðü", 0}, + {"Âëàäèìèð", 0}, + {"Âëàñòåëèí", 0}, + {"Âîäíûé", 0}, + {"Âîåííîå", 2}, + {"Âîçäóøíàÿ", 1}, + {"Âîçäóøíûé", 0}, + {"Âîëõâ", 0}, + {"Âîëüã", 0}, + {"Âîññòàâøèé", 0}, + {"Âðàòà", 1}, + {"Âóäðî", 0}, + {"Âóðäàëàê", 0}, + {"Âûñøàÿ", 1}, + {"Âýéä", 0}, + {"Ãàáðèýëü", 0}, + {"Ãàé", 0}, + {"Ãàíñ", 0}, + {"Ãàðåò", 0}, + {"Ãàðè", 0}, + {"Ãàðïèÿ", 1}, + {"Ãàððè", 0}, + {"Ãâåíäîëèí", 1}, + {"Ãâåíí", 1}, + {"Ãåéá", 0}, + {"Ãåéë", 1}, + {"Ãåêòîð", 0}, + {"Ãåëüìóò", 0}, + {"Ãåíèêêè", 1}, + {"Ãåíðè", 0}, + {"Ãåîðãèíà", 1}, + {"Ãåðá", 0}, + {"Ãåðáåðò", 0}, + {"Ãåðìàí", 0}, + {"Ãåðòðóäà", 1}, + {"Ãåðö", 0}, + {"Ãèãàíòñêàÿ", 1}, + {"Ãèëüäèÿ", 1}, + {"Ãèëüåðìî", 0}, + {"Ãèëüìîð", 0}, + {"Ãèìíàñòè÷åñêèé", 0}, + {"Ãëàçèùå", 2}, + {"Ãëåí", 0}, + {"Ãëåíäà", 1}, + {"Ãëèíÿíûé", 0}, + {"Ãëîðèÿ", 1}, + {"Ãíèþùèé", 0}, + {"Ãíîì", 0}, + {"Ãîáëèí", 0}, + {"Ãîâàðä", 0}, + {"Ãîã", 0}, + {"Ãîìåð", 0}, + {"Ãîíçàëî", 0}, + {"Ãîðàöèé", 0}, + {"Ãîðäîí", 0}, + {"Ãîðíûé", 0}, + {"Ãðàáèòåëü", 0}, + {"Ãðàíò", 0}, + {"Ãðàõýì", 0}, + {"Ãðåã", 0}, + {"Ãðåãîðè", 0}, + {"Ãðåé", 0}, + {"Ãðåòõåí", 1}, + {"Ãðèôîí", 0}, + {"Ãðîçîâîé", 0}, + {"Ãóñ", 0}, + {"Äàâèä", 0}, + {"Äàéàíà", 1}, + {"Äàë", 0}, + {"Äàëëàñ", 0}, + {"Äàìèàí", 0}, + {"Äàíà", 1}, + {"Äàíèýëü", 0}, + {"Äàíòå", 0}, + {"Äàðà", 1}, + {"Äàðëèí", 1}, + {"Äàðîí", 0}, + {"Äàðñè", 1}, + {"Äàñòèí", 0}, + {"Äàôíà", 1}, + {"Äâàéò", 0}, + {"Äâåéí", 0}, + {"Äåàííà", 1}, + {"Äåááè", 1}, + {"Äåáîðà", 1}, + {"Äåâîí", 0}, + {"Äåéâ", 0}, + {"Äåéë", 0}, + {"Äåë", 0}, + {"Äåëîðèñ", 1}, + {"Äåíèñ", 1}, + {"Äåííè", 0}, + {"Äåïîçèòàðèé", 0}, + {"Äåðåâî", 2}, + {"Äåðåê", 0}, + {"Äåñìîíä", 0}, + {"Äæàíèñ", 1}, + {"Äæàñòèí", 0}, + {"Äæåä", 0}, + {"Äæåäàé", 0}, + {"Äæåé", 0}, + {"Äæåéê", 0}, + {"Äæåéìñ", 0}, + {"Äæåéí", 1}, + {"Äæåéñîí", 0}, + {"Äæåê", 0}, + {"Äæåêè", 1}, + {"Äæåìè", 0}, + {"Äæåíèôåð", 1}, + {"Äæåííè", 1}, + {"Äæåðàëüä", 0}, + {"Äæåðàëüäèíà", 1}, + {"Äæåðîì", 0}, + {"Äæåðîìè", 0}, + {"Äæåððè", 0}, + {"Äæåññ", 0}, + {"Äæåññà", 1}, + {"Äæåññèêà", 1}, + {"Äæåòàíî", 0}, + {"Äæèì", 0}, + {"Äæèí", 1}, + {"Äæèíà", 1}, + {"Äæèíæåð", 1}, + {"Äæèííè", 1}, + {"Äæèíî", 0}, + {"Äæî", 2}, + {"Äæîàí", 1}, + {"Äæîàíí", 1}, + {"Äæîàííà", 1}, + {"Äæîçåô", 0}, + {"Äæîé", 0}, + {"Äæîéñ", 1}, + {"Äæîéñèí", 1}, + {"Äæîí", 0}, + {"Äæîíàòàí", 0}, + {"Äæîðäæ", 0}, + {"Äæîó", 0}, + {"Äæîøóà", 0}, + {"Äæîýëü", 0}, + {"Äæóä", 0}, + {"Äæóäè", 1}, + {"Äæóäèñ", 1}, + {"Äæóëè", 1}, + {"Äæóí", 1}, + {"Äèàíà", 1}, + {"Äèëàí", 0}, + {"Äèí", 0}, + {"Äèòåð", 0}, + {"Äîäðèäæ", 0}, + {"Äîê", 0}, + {"Äîëîðåñ", 1}, + {"Äîëüô", 0}, + {"Äîì", 0}, + {"Äîìèíèê", 0}, + {"Äîìèíèêà", 1}, + {"Äîí", 0}, + {"Äîíàéñ", 1}, + {"Äîíàëüä", 0}, + {"Äîííà", 1}, + {"Äîðèí", 1}, + {"Äîðèñ", 1}, + {"Äîðîòè", 1}, + {"Äðàêîíîâàÿ", 1}, + {"Äðåâíåå", 2}, + {"Äðåâíèé", 0}, + {"Äðóèä", 0}, + {"Äðþ", 0}, + {"Äóãëàñ", 0}, + {"Äóíêàí", 0}, + {"Äüÿâîë", 0}, + {"Äýâè", 0}, + {"Äýí", 0}, + {"Äýíèñ", 0}, + {"Äýííè", 0}, + {"Äþê", 0}, + {"Åâà", 1}, + {"Åâãåíèé", 0}, + {"Åëèçàâåòà", 1}, + {"Æàí-Ïîëü", 0}, + {"Æàí-Ïüåð", 0}, + {"Æàíåòà", 1}, + {"Æàíåòò", 1}, + {"Æàíåòòà", 1}, + {"Æàíèí", 1}, + {"Æàíèñ", 1}, + {"Æàííà", 1}, + {"Æàñìèí", 1}, + {"Æåéí", 1}, + {"Æåííà", 1}, + {"Æèëüáåð", 0}, + {"Æîôðåé", 0}, + {"Æóëü", 0}, + {"Çàê", 0}, + {"Çàìîê", 0}, + {"Çàìîðîæåííûå", 2}, + {"Çàõàðèé", 0}, + {"Çåáóëîí", 0}, + {"Çåëåíûé", 0}, + {"Çåìíîé", 0}, + {"Çèããè", 0}, + {"Çèê", 0}, + {"Çëàòûå", 2}, + {"Çîä", 0}, + {"Çîëîòîé", 0}, + {"Çîëòàí", 0}, + {"Çîðåêñ", 0}, + {"Èâ", 0}, + {"Èâàí", 0}, + {"Èâàð", 0}, + {"Èâåðñîí", 0}, + {"Èâîííà", 1}, + {"Èãíàñèî", 0}, + {"Èãîðü", 0}, + {"Èäà", 1}, + {"Èåðåìèÿ", 0}, + {"Èçìàèë", 0}, + {"Èçóìðóäíûé", 0}, + {"Èêå", 0}, + {"Èëåíà", 1}, + {"Èëüÿ", 0}, + {"Èìåíèå", 2}, + {"Èíêóáàòîð", 0}, + {"Èîëàíäà", 1}, + {"Èîí", 0}, + {"Èîíà", 0}, + {"Èîõàíí", 0}, + {"Èðâèí", 0}, + {"Èðâèíã", 0}, + {"Èðåíà", 1}, + {"Èðèíà", 1}, + {"Èðèñ", 1}, + {"Èðìà", 1}, + {"Èñààê", 0}, + {"Èñàî", 0}, + {"Éîðäàí", 0}, + {"Êààî", 0}, + {"Êàé", 0}, + {"Êàëåá", 0}, + {"Êàëüâèí", 0}, + {"Êàìåííàÿ", 1}, + {"Êàìåííûé", 0}, + {"Êàíäåéñ", 1}, + {"Êàïèòàí", 0}, + {"Êàðåí", 1}, + {"Êàðè", 0}, + {"Êàðèí", 0}, + {"Êàðë", 0}, + {"Êàðëè", 1}, + {"Êàðëî", 0}, + {"Êàðëîí", 0}, + {"Êàðëîñ", 0}, + {"Êàðìåí", 1}, + {"Êàðòåð", 0}, + {"Êàñàíäðà", 1}, + {"Êàòåðèíà", 1}, + {"Êàòè", 1}, + {"Êàòëèí", 1}, + {"Êâàí", 0}, + {"Êâåíòèí", 0}, + {"Êâèíí", 0}, + {"Êåâèí", 0}, + {"Êåâèíóñ", 0}, + {"Êåéëèí", 1}, + {"Êåéò", 0}, + {"Êåë", 0}, + {"Êåëëè", 1}, + {"Êåí", 0}, + {"Êåííåò", 0}, + {"Êåðè", 1}, + {"Êåðí", 0}, + {"Êèãàí", 0}, + {"Êèì", 1}, + {"Êèìáåðëè", 1}, + {"Êèðê", 0}, + {"Êèðóñ", 0}, + {"Êëàéä", 0}, + {"Êëàðåíñ", 0}, + {"Êëàðê", 0}, + {"Êëèðèê", 0}, + {"Êëèôôîðä", 0}, + {"Êëýé", 0}, + {"Êëýð", 1}, + {"Êîäè", 0}, + {"Êîëèí", 0}, + {"Êîëîíèÿ", 1}, + {"Êîííè", 1}, + {"Êîííîð", 0}, + {"Êîíðàä", 0}, + {"Êîíñòàíòèí", 0}, + {"Êîíñòàíöèÿ", 1}, + {"Êîïè", 2}, + {"Êîðà", 1}, + {"Êîðáåò", 0}, + {"Êîðä", 0}, + {"Êîðè", 0}, + {"Êîðèñî", 0}, + {"Êîðíåëèÿ", 1}, + {"Êîðíèëèé", 0}, + {"Êîðîëåâà", 1}, + {"Êîðîëåâñêèé", 0}, + {"Êîðîëü", 0}, + {"Êîøêà", 1}, + {"Êðàñíûé", 0}, + {"Êðåéã", 0}, + {"Êðèñ", 0}, + {"Êðèñòà", 1}, + {"Êðèñòåí", 1}, + {"Êðèñòèíà", 1}, + {"Êðèñòèñ", 1}, + {"Êðèñòîôåð", 0}, + {"Êðîâàâûé", 0}, + {"Êñóàí", 0}, + {"Êóëàê", 0}, + {"Êóðãàí", 0}, + {"Êóðèöà", 1}, + {"Êýé", 1}, + {"Êýéñ", 1}, + {"Êýë", 0}, + {"Êýëëî", 0}, + {"Êýìåðîí", 0}, + {"Êýíäè", 1}, + {"Êýðè", 1}, + {"Êýðîë", 1}, + {"Êýðîëàí", 1}, + {"Êýðîëèí", 1}, + {"Êýððè", 1}, + {"Êýñè", 0}, + {"Ëàáèðèíò", 0}, + {"Ëàáîðàòîðèÿ", 1}, + {"Ëàçàðü", 0}, + {"Ëàéîíåë", 0}, + {"Ëàêè", 0}, + {"Ëàíà", 1}, + {"Ëàíñ", 0}, + {"Ëàðà", 1}, + {"Ëàððè", 0}, + {"Ëàðñ", 0}, + {"Ëàóðà", 1}, + {"Ëàóðè", 1}, + {"Ëåà", 1}, + {"Ëåàñà", 1}, + {"Ëåéô", 0}, + {"Ëåî", 0}, + {"Ëåîíàðä", 0}, + {"Ëåîðà", 1}, + {"Ëåðîé", 0}, + {"Ëåñëè", 1}, + {"Ëåñòåð", 0}, + {"Ëåòó÷àÿ", 1}, + {"Ëè", 0}, + {"Ëè", 1}, + {"Ëèàì", 0}, + {"Ëèâèÿ", 1}, + {"Ëèçà", 1}, + {"Ëèëà", 1}, + {"Ëèëàíä", 0}, + {"Ëèëëè", 1}, + {"Ëèìàí", 0}, + {"Ëèíäà", 1}, + {"Ëèíäåí", 0}, + {"Ëèíäñåé", 0}, + {"Ëèíí", 1}, + {"Ëèîí", 0}, + {"Ëè÷", 0}, + {"Ëëîéä", 0}, + {"Ëîâ÷èé", 0}, + {"Ëîãàí", 0}, + {"Ëîãîâî", 2}, + {"Ëîí", 0}, + {"Ëîííè", 0}, + {"Ëîðà", 1}, + {"Ëîðä", 0}, + {"Ëîðåí", 1}, + {"Ëîðåíà", 1}, + {"Ëîó", 0}, + {"Ëîóâåëë", 0}, + {"Ëîÿëüíûé", 0}, + {"Ëóè", 0}, + {"Ëóèäæè", 0}, + {"Ëóèçà", 1}, + {"Ëóèñ", 0}, + {"Ëóèñà", 1}, + {"Ëó÷íèê", 0}, + {"Ëüþèñ", 0}, + {"Ëþäâèã", 0}, + {"Ëþê", 0}, + {"Ëþñèëü", 1}, + {"Ëþòåð", 0}, + {"Ìàäåëåíà", 1}, + {"Ìàéê", 0}, + {"Ìàéëç", 0}, + {"Ìàéëñ", 0}, + {"Ìàê", 0}, + {"Ìàêðî", 0}, + {"Ìàêñ", 0}, + {"Ìàêñâåëë", 0}, + {"Ìàëêîëüì", 0}, + {"Ìàëûé", 0}, + {"Ìàìè", 1}, + {"Ìàííè", 0}, + {"Ìàíòèêîðà", 1}, + {"Ìàíôðåä", 0}, + {"Ìàðâèí", 0}, + {"Ìàðãàðèòà", 1}, + {"Ìàðäæîðè", 1}, + {"Ìàðæ", 1}, + {"Ìàðèàíà", 1}, + {"Ìàðèàííà", 1}, + {"Ìàðèî", 0}, + {"Ìàðèîí", 0}, + {"Ìàðèñ", 1}, + {"Ìàðèñà", 1}, + {"Ìàðèøàëü", 1}, + {"Ìàðèÿ", 1}, + {"Ìàðê", 0}, + {"Ìàðêî", 0}, + {"Ìàðêîíè", 0}, + {"Ìàðêóñ", 0}, + {"Ìàðëåí", 1}, + {"Ìàðëîí", 0}, + {"Ìàðíè", 1}, + {"Ìàðñè", 1}, + {"Ìàðñèÿ", 1}, + {"Ìàðòà", 1}, + {"Ìàðòèë", 1}, + {"Ìàðòèí", 0}, + {"Ìàðõýì", 0}, + {"Ìàð÷åëëî", 0}, + {"Ìàðøà", 1}, + {"Ìàðøàë", 0}, + {"Ìàñòåð", 0}, + {"Ìàòâåé", 0}, + {"Ìàòåðèàëüíûå", 2}, + {"Ìàòò", 0}, + {"Ìåãàäðàêîí", 0}, + {"Ìåäíûé", 0}, + {"Ìåäóçà", 1}, + {"Ìåéì", 1}, + {"Ìåëàíè", 1}, + {"Ìåëâèí", 0}, + {"Ìåëèíäà", 1}, + {"Ìåëèññà", 1}, + {"Ìåëêîâîäüå", 2}, + {"Ìåëîäè", 1}, + {"Ìåðòâåö", 0}, + {"Ìåðòâûé", 0}, + {"Ìåñòíàÿ", 1}, + {"Ìåñòíûé", 0}, + {"Ìèê", 0}, + {"Ìèíäè", 1}, + {"Ìèíåðàëüíûå", 2}, + {"Ìèíèêîðà", 1}, + {"Ìèííè", 1}, + {"Ìèðèàì", 1}, + {"Ìèò÷", 0}, + {"Ìèøåëü", 1}, + {"Ìîãó÷èé", 0}, + {"Ìîéðà", 1}, + {"Ìîíàõ", 0}, + {"Ìîíèêà", 1}, + {"Ìîíòå", 0}, + {"Ìîðåë", 0}, + {"Ìîðèíà", 1}, + {"Ìîððèñ", 0}, + {"Ìîðòîí", 0}, + {"Ìîõàììåä", 0}, + {"Ìðàìîðíàÿ", 1}, + {"Ìóäðûé", 0}, + {"Ìýë", 0}, + {"Ìýíäè", 1}, + {"Ìýðè", 1}, + {"Ìýðè", 1}, + {"Ìýðèëèí", 1}, + {"Ìþðåëü", 1}, + {"Ìþððåé", 0}, + {"Íàäèíà", 1}, + {"Íàë¸ò÷èê", 0}, + {"Íàîìè", 1}, + {"Íàòàëè", 1}, + {"Íàòàí", 0}, + {"Íàòàíèýëü", 0}, + {"Íà÷àëüíàÿ", 1}, + {"Íåáåñà", 1}, + {"Íåä", 0}, + {"Íåêðîìàíò", 0}, + {"Íåëüñîí", 0}, + {"Íåóñòðàøèìûé", 0}, + {"Íèê", 0}, + {"Íèêè", 1}, + {"Íèêîëàé", 0}, + {"Íèêîëàñ", 0}, + {"Íèêîëü", 1}, + {"Íèë", 0}, + {"Íîâîáðàíåö", 0}, + {"Íîé", 0}, + {"Íîðèíà", 1}, + {"Íîðì", 0}, + {"Íîðìà", 1}, + {"Íîðìàí", 0}, + {"Íîððèñ", 0}, + {"Íüþò", 0}, + {"Íýéò", 0}, + {"Íýíñè", 1}, + {"Íýíñèñ", 1}, + {"Îáñèäèàíîâàÿ", 1}, + {"Îãíåííûé", 0}, + {"Îëàô", 0}, + {"Îëèâåð", 0}, + {"Îëèâèÿ", 1}, + {"Îðäåí", 0}, + {"Îñîáíÿê", 0}, + {"Îñòèí", 0}, + {"Îòèñ", 0}, + {"Îóâåí", 0}, + {"Îõîòíèê", 0}, + {"Ïàâåë", 0}, + {"Ïàì", 1}, + {"Ïàìåëà", 1}, + {"Ïàðêåð", 0}, + {"Ïàðòè", 1}, + {"Ïàòðèê", 0}, + {"Ïàòðèñèÿ", 1}, + {"Ïåã", 1}, + {"Ïåããè", 1}, + {"Ïåéäæ", 1}, + {"Ïåííè", 1}, + {"Ïåððè", 0}, + {"Ïåðñè", 0}, + {"Ïåðñèâàëü", 0}, + {"Ïåòåð", 0}, + {"Ïèêñè", 1}, + {"Ïèðñ", 0}, + {"Ïèò", 0}, + {"Ïëàâó÷èé", 0}, + {"Ïîêîè", 2}, + {"Ïîë", 0}, + {"Ïîñâÿù¸ííûé", 0}, + {"Ïîñâÿùåííûé", 0}, + {"Ïîñëåäíèé", 0}, + {"Ïîñëóøíèê", 0}, + {"Ïîñòîÿëûé", 0}, + {"Ïðåäâîäèòåëü", 0}, + {"Ïðåñòîí", 0}, + {"Ïðèâèäåíèå", 2}, + {"Ïðèäîðîæíûé", 0}, + {"Ïðèçðàê", 0}, + {"Ïðèðîäíûå", 2}, + {"Ïüåð", 0}, + {"Ïýò", 0}, + {"Ïýòòè", 1}, + {"Ðàäó", 0}, + {"Ðàçáîéíèê", 0}, + {"Ðàéàí", 0}, + {"Ðàéìîíä", 0}, + {"Ðàëüô", 0}, + {"Ðàìåé", 0}, + {"Ðàìñè", 0}, + {"Ðàíäîëüô", 0}, + {"Ðàññåë", 0}, + {"Ðàñòè", 0}, + {"Ðàòóøà", 1}, + {"Ðàóëü", 0}, + {"Ðàôàýëü", 0}, + {"Ðàøåëü", 1}, + {"Ðåáåêêà", 1}, + {"Ðåâè", 1}, + {"Ðåã", 0}, + {"Ðåãèíà", 1}, + {"Ðåäæèíàëüä", 0}, + {"Ðåêñ", 0}, + {"Ðåíå", 0}, + {"Ðåíè", 1}, + {"Ðåíöî", 0}, + {"Ðåñàíäà", 1}, + {"Ðå÷íîé", 0}, + {"Ðèêè", 0}, + {"Ðèíàëüäî", 0}, + {"Ðèòà", 1}, + {"Ðè÷àðä", 0}, + {"Ðîá", 0}, + {"Ðîááè", 0}, + {"Ðîáåðò", 0}, + {"Ðîáåðòà", 1}, + {"Ðîáèí", 0}, + {"Ðîãàòûé", 0}, + {"Ðîäåðèê", 0}, + {"Ðîäíè", 0}, + {"Ðîçà", 1}, + {"Ðîçàëè", 1}, + {"Ðîçàííà", 1}, + {"Ðîçè", 1}, + {"Ðîçìàðè", 1}, + {"Ðîçìàðèíà", 1}, + {"Ðîé", 0}, + {"Ðîêè", 0}, + {"Ðîëàíä", 0}, + {"Ðîìîíà", 1}, + {"Ðîí", 0}, + {"Ðîíàëüä", 0}, + {"Ðîíäà", 1}, + {"Ðîðè", 0}, + {"Ðîññ", 0}, + {"Ðîóç", 1}, + {"Ðîøåëü", 1}, + {"Ðóáèíà", 1}, + {"Ðóäè", 0}, + {"Ðóïåðò", 0}, + {"Ðóò", 1}, + {"Ðóòè", 1}, + {"Ðýíäàë", 0}, + {"Ðýíäè", 0}, + {"Ñààä", 0}, + {"Ñàáðèíà", 1}, + {"Ñàäè", 1}, + {"Ñàë", 0}, + {"Ñàëëè", 1}, + {"Ñàëüâàòîðå", 0}, + {"Ñàìþýëü", 0}, + {"Ñàíäèï", 0}, + {"Ñàíäðà", 1}, + {"Ñàíòîñ", 0}, + {"Ñàïôèðîâûé", 0}, + {"Ñàðà", 1}, + {"Ñâåí", 0}, + {"Ñâåò", 0}, + {"Ñâåòëàíà", 1}, + {"Ñâåòÿùèéñÿ", 0}, + {"Ñâÿòèëèùå", 2}, + {"Ñâÿùåííàÿ", 1}, + {"Ñâÿùåííèê", 0}, + {"Ñåáàñòüÿí", 0}, + {"Ñåäðèê", 0}, + {"Ñåéìóð", 0}, + {"Ñåêëèÿ", 1}, + {"Ñåëåíà", 1}, + {"Ñåðãèî", 0}, + {"Ñåðåíà", 1}, + {"Ñåðûé", 0}, + {"Ñåñèëü", 0}, + {"Ñåò", 0}, + {"Ñèäíåé", 0}, + {"Ñèëüâåñòð", 0}, + {"Ñèëüôèäà", 1}, + {"Ñèìîí", 0}, + {"Ñèìîíà", 1}, + {"Ñèíäè", 1}, + {"Ñèíäèñ", 1}, + {"Ñèíèé", 0}, + {"Ñèíòèÿ", 1}, + {"Ñêàëèñ", 0}, + {"Ñêåëåò", 0}, + {"Ñêîðïèêîðà", 1}, + {"Ñêîòò", 0}, + {"Ñëàáûé", 0}, + {"Ñëåéä", 0}, + {"Ñîáàêà", 1}, + {"Ñîáîð", 0}, + {"Ñîë", 0}, + {"Ñîëíöå", 2}, + {"Ñîííè", 0}, + {"Ñïåíñåð", 0}, + {"Ñòàðøèé", 0}, + {"Ñòåéñè", 1}, + {"Ñòåëñ", 0}, + {"Ñòåôàí", 0}, + {"Ñòåôàíè", 1}, + {"Ñòèâ", 0}, + {"Ñòèâåí", 0}, + {"Ñòîðîæåâàÿ", 1}, + {"Ñòðàæ", 0}, + {"Ñòðàæíèê", 0}, + {"Ñòðåêîçàâð", 0}, + {"Ñòðåëîê", 0}, + {"Ñòýí", 0}, + {"Ñòýíëè", 0}, + {"Ñòþàðò", 0}, + {"Ñóàííà", 1}, + {"Ñóäüÿ", 0}, + {"Ñóëåéìàí", 0}, + {"Ñóìåðå÷íûé", 0}, + {"Ñüþçàí", 1}, + {"Ñüþçè", 1}, + {"Ñýì", 0}, + {"Ñýíäè", 1}, + {"Ñýíäèí", 1}, + {"Ñýðà", 1}, + {"Ñþçàííà", 1}, + {"Òàäåóñ", 0}, + {"Òàéëåð", 0}, + {"Òàéñîí", 0}, + {"Òàêà", 0}, + {"Òàìàðà", 1}, + {"Òàììè", 1}, + {"Òàíÿ", 1}, + {"Òàðà", 1}, + {"Òåéí", 0}, + {"Òåîäîð", 0}, + {"Òåðåçà", 1}, + {"Òåðåñà", 1}, + {"Òåððàíñ", 0}, + {"Òåððè", 1}, + {"Òèì", 0}, + {"Òèìîòè", 0}, + {"Òèíà", 1}, + {"Òèôôàíè", 1}, + {"Òîáèàñ", 0}, + {"Òîää", 0}, + {"Òîì", 0}, + {"Òîìàñ", 0}, + {"Òîí", 0}, + {"Òîíè", 0}, + {"Òîð", 0}, + {"Òðàí", 0}, + {"Òðàÿí", 0}, + {"Òðåéñè", 1}, + {"Òðåíò", 0}, + {"Òðåíòîí", 0}, + {"Òðèíà", 1}, + {"Òðèï", 0}, + {"Òðèñèÿ", 1}, + {"Òðîãëîäèò", 0}, + {"Òðîííûé", 0}, + {"Òðóâîð", 0}, + {"Òðýâèñ", 0}, + {"Òóìàííûé", 0}, + {"Òýä", 0}, + {"Òýððè", 1}, + {"Òþðüìà", 1}, + {"Óàëüäî", 0}, + {"Óèëáåðò", 0}, + {"Óèëüñîí", 0}, + {"Óíäèíà", 1}, + {"Óîëëåñ", 0}, + {"Óîððåí", 0}, + {"Óïûðü", 0}, + {"Ó÷åáíûé", 0}, + {"Óýáá", 0}, + {"Ôàáèàí", 0}, + {"Ôàìèëüíûé", 0}, + {"Ôàðåëë", 0}, + {"Ôåäðóñ", 0}, + {"Ôåéò", 1}, + {"Ôåëèêñ", 0}, + {"Ôåëèöèÿ", 1}, + {"Ôåðäèíàíä", 0}, + {"Ôèë", 0}, + {"Ôèëèï", 0}, + {"Ôèëëèñ", 1}, + {"Ôèëîìåíà", 1}, + {"Ôëåò÷åð", 0}, + {"Ôëîéä", 0}, + {"Ôëîðåíöèÿ", 1}, + {"Ôëîññè", 1}, + {"Ôîððåñò", 0}, + {"Ôðàíê", 0}, + {"Ôðàíêëèí", 0}, + {"Ôðàíö", 0}, + {"Ôðàíöèñê", 0}, + {"Ôðàí÷åñêà", 1}, + {"Ôðåä", 0}, + {"Ôðåäåðèê", 0}, + {"Õàâüåð", 0}, + {"Õàéäåí", 0}, + {"Õàéäè", 1}, + {"Õàí", 0}, + {"Õàíê", 0}, + {"Õàíí", 0}, + {"Õàîñ", 0}, + {"Õàðâè", 0}, + {"Õàðäè", 0}, + {"Õàðèåòòà", 1}, + {"Õàðëàí", 0}, + {"Õàðëåé", 0}, + {"Õàðîëüä", 0}, + {"Õàððèñîí", 0}, + {"Õåëåí", 1}, + {"Õèëüäà", 1}, + {"Õèò", 0}, + {"Õèòåð", 1}, + {"Õèòåò", 0}, + {"Õèòîìè", 1}, + {"Õîäÿ÷èé", 0}, + {"Õîê", 0}, + {"Õîëäåí", 0}, + {"Õîëëè", 1}, + {"Õðàì", 0}, + {"Õðàíèëèùå", 2}, + {"Õüþ", 0}, + {"Õüþãî", 0}, + {"Õýë", 0}, + {"Õýìïòîí", 0}, + {"Öàðü", 0}, + {"Öåçàðü", 0}, + {"Öèêëîí", 0}, + {"Öèòàäåëü", 1}, + {"×àä", 0}, + {"×àê", 0}, + {"×àí", 0}, + {"×àíäðà", 1}, + {"×àðëè", 0}, + {"×àðëüç", 0}, + {"×àðîäåé", 0}, + {"×àñîâîé", 0}, + {"×åìïèîí", 0}, + {"×åðíàÿ", 1}, + {"×åðíîêíèæíèê", 0}, + {"×åðòîã", 0}, + {"×åñòåð", 0}, + {"×åò", 0}, + {"×èï", 0}, + {"×óäèùå", 2}, + {"Øàòåð", 0}, + {"Øàõòåðñêàÿ", 1}, + {"Øåéëà", 1}, + {"Øåéëàíè", 1}, + {"Øåëäîí", 0}, + {"Øåëë", 0}, + {"Øåëëè", 1}, + {"Øåëëèñ", 1}, + {"Øåðäîí", 0}, + {"Øåðèë", 1}, + {"Øåðìàí", 0}, + {"Øåððè", 1}, + {"Øåððèí", 1}, + {"Øèìîí", 0}, + {"Øêîëà", 1}, + {"Øîí", 0}, + {"Øîóíà", 1}, + {"Øòàá", 0}, + {"Øýíîí", 1}, + {"Øýðè", 1}, + {"Øýðîí", 1}, + {"Ýâàí", 0}, + {"Ýâåëèí", 1}, + {"Ýä", 0}, + {"Ýäãàð", 0}, + {"Ýääè", 0}, + {"Ýäèñîí", 0}, + {"Ýäèò", 1}, + {"Ýäìîíä", 0}, + {"Ýäíà", 1}, + {"Ýéá", 0}, + {"Ýéëèí", 1}, + {"Ýéïðèë", 1}, + {"Ýêñïåðòíàÿ", 1}, + {"Ýë", 0}, + {"Ýëâèí", 0}, + {"Ýëåãàíòíûé", 0}, + {"Ýëåí", 1}, + {"Ýëåîíîðà", 1}, + {"Ýëèîò", 0}, + {"Ýëèñîí", 1}, + {"Ýëèññà", 1}, + {"Ýëèòíûé", 0}, + {"Ýëëà", 1}, + {"Ýëëåí", 1}, + {"Ýëñè", 1}, + {"Ýëòîí", 0}, + {"Ýëüô", 0}, + {"Ýìè", 1}, + {"Ýìèëü", 0}, + {"Ýììà", 1}, + {"Ýììàíóèë", 0}, + {"Ýììåò", 0}, + {"Ýíäæè", 1}, + {"Ýíäè", 0}, + {"Ýíí", 1}, + {"Ýíí", 2}, + {"Ýíîê", 0}, + {"Ýðâèí", 0}, + {"Ýðèê", 0}, + {"Ýðèí", 1}, + {"Ýðë", 0}, + {"Ýðíåñò", 0}, + {"Ýðíè", 0}, + {"Ýðíèí", 0}, + {"Ýðîë", 0}, + {"Ýòàí", 0}, + {"Ýòåëü", 1}, + {"Ýø", 0}, + {"Ýøòîí", 0}, + {"Þäèôü", 1}, + {"Þðèé", 0}, + {"ßäîâèòûé", 0}, + {"ßêîá", 0}, + {"ßí", 0}, + {"ßíñè", 0}, + {"ßðîä", 0}, + {"ßñïåð", 0} +}, + gender_table[] = +{ + {"àä", 0}, {"àêóëà", 1}, {"áàíê", 0}, {"áàøíÿ", 1}, {"áëàñòåð", 0}, {"âàìïèð", 0}, {"âäîâà", 1}, {"âåäüìà", 1}, {"âèòåðñìèò", 0}, {"âëàäûêà", 0}, {"âëàäû÷èöà", 1}, + {"âîèí", 0}, {"âîð", 0}, {"ãèäðà", 1}, {"ãëàç", 0}, {"ãîëåì", 0}, {"ãîðà", 1}, {"ãîðãóëüÿ", 1}, {"ãîðîä", 0}, {"ãðîìîâàÿ", 1}, {"äâîð", 0}, {"äæèíí", 0}, + {"äðàêîí", 0}, {"äóõ", 0}, {"æèòåëü", 0}, {"æèòåëüíèöà", 1}, {"çàë", 0}, {"çàùèòíèê", 0}, {"çåìëÿ", 1}, {"èñêàòåëü", 0}, {"èôðèò", 0}, {"êâàðòèðà", 1}, {"êîëü÷óãà", 1}, + {"êîìàíäèð", 0}, {"êðûñà", 1}, {"ëåéòåíàíò", 0}, {"ëóíà", 1}, {"ëþäîåä", 0}, {"ìàãîã", 0}, {"ìå÷", 0}, {"ìå÷íèê", 0}, {"ìèíîòàâð", 0}, {"ìûøü", 1}, {"íàåìíèê", 0}, + {"îãíåííàÿ", 1}, {"îãîíü", 0}, {"îðê", 0}, {"ïàóê", 0}, {"ïåùåðà", 1}, {"ïåùåðû", 1}, {"ïîâåëèòåëü", 0}, {"ïîãðåá", 0}, {"ïîëèãîí", 0}, {"ïðèþò", 0}, {"ïòèöà", 1}, + {"ïòè÷èé", 0}, {"ðàáîòíèê", 0}, {"ðàé", 0}, {"ðåéíäæåð", 0}, {"ðóõ", 0}, {"ñëèçåíü", 0}, {"ñîëäàò", 0}, {"òèòàí", 0}, {"òðàêòèð", 0}, {"òðîëëü", 0}, {"óáèéöà", 0}, + {"óëàí", 0}, {"ó÷èëèùå", 2}, {"øëÿïà", 1}, {"ýëåìåíòàë", 0} +}; + + + +#include + +int GetGender(char *ansi_name, int name_len) +{ + auto name = (unsigned char *)ansi_name; + + GenderTableEntry *table = nullptr; + unsigned int table_size = 0; + if (name[0] >= (unsigned char)'à' && name[0] <= (unsigned char)'ÿ') + { + table = gender_table; + table_size = sizeof(gender_table) / sizeof(*gender_table); + } + else if (name[0] >= (unsigned char)'À' && name[0] <= (unsigned char)'ß') + { + table = gender_table_caps; + table_size = sizeof(gender_table_caps) / sizeof(*gender_table_caps); + } + else return 0; + + int left = 0, + right = table_size - 1, + match = 0; + while (left < right - 1) + { + match = left + (right - left) / 2; + int rval = _mbsncmp(name, (unsigned char *)table[match].name, name_len); + if (rval < 0) + right = match; + else if (!rval) + return table[match].gender; + else + left = match; + } + + Log::Warning(L"sprintfex: unknown gender: %S", name); + return 0; +} + + +bool IsSpecialName(const char *ansi_name) +{ + auto name = (unsigned char *)ansi_name; + return !_mbsncmp(name, (unsigned char *)"Ìýðè Äæî", 8) || !_mbsncmp(name, (unsigned char *)"Ëè Ýíí", 6) || + !_mbsncmp(name, (unsigned char *)"Âðàòà â Áåçäíó", 14) || !_mbsncmp(name, (unsigned char *)"Ñòåíû òóìàíà", 12); +} +int GetSpecialGender(const char *ansi_name) +{ + auto name = (unsigned char *)ansi_name; + if (!_mbsncmp(name, (unsigned char *)"Ìýðè Äæî", 8)) + return 1; + if (!_mbsncmp(name, (unsigned char *)"Ëè Ýíí", 6)) + return 1; + if (!_mbsncmp(name, (unsigned char *)"Âðàòà â Áåçäíó", 14)) + return 1; + if (!!_mbsncmp(name, (unsigned char *)"Ñòåíû òóìàíà", 12)) + return 0; + return 0; +} +const char *GetSpecialCase(const char *ansi_name, char c) +{ + auto name = (unsigned char *)ansi_name; + + if (!_mbsncmp(name, (unsigned char *)"Ìýðè Äæî", 8)) + return "Ìýðè Äæî"; + if (!_mbsncmp(name, (unsigned char *)"Ëè Ýíí", 6)) + return "Ëè Ýíí"; + + if (!_mbsncmp(name, (unsigned char *)"Âðàòà â Áåçäíó", 14)) + switch (c) + { + case 'I': case 'i': return "Âðàòà â Áåçäíó"; + case 'R': case 'r': return "Âðàò â Áåçäíó"; + case 'D': case 'd': return "Âðàòàì â Áåçäíó"; + case 'V': case 'v': return "Âðàò â Áåçäíó"; + case 'T': case 't': return "Âðàòàìè â Áåçäíó"; + case 'P': case 'p': return "Âðàòàõ â Áåçäíó"; + } + + if (!_mbsncmp(name, (unsigned char *)"Ñòåíû òóìàíà", 12)) + switch (c) + { + case 'I': case 'i': return "Ñòåíû òóìàíà"; + case 'R': case 'r': return "Ñòåí òóìàíà"; + case 'D': case 'd': return "Ñòåíàì òóìàíà"; + case 'V': case 'v': return "Ñòåíû òóìàíà"; + case 'T': case 't': return "Ñòåíàìè òóìàíà"; + case 'P': case 'p': return "Ñòåíàõ òóìàíà"; + } + + return nullptr; +} + +int sprintfex_internal(char *str) +{ + auto p = strstr(str, "^"); + if (!p) + return strlen(str); + + char buf[8192]; + Assert(strlen(str) < sizeof(buf)); + + int next_integer_token = 0; + bool integer_tokens_defined[10] = {false, false, false, false, false, false, false, false, false, false}; + int integer_tokens[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + bool gender_token_defined = false; + int gender_token = 0; + + auto src = buf, + dst = p; + strcpy(buf, str + (p - str)); + while (true) + { + switch (src[1]) + { + case 'I': + { + if (src[2] != '[') + goto _invalid_token; + src += 3; // ^I[ + + Assert(next_integer_token < 10); + if (sscanf(src, "%d", &integer_tokens[next_integer_token])) + integer_tokens_defined[next_integer_token++] = true; + + auto int_begin = src; + while (*src++ != ']'); + + int int_len = src - int_begin - 1; + strncpy(dst, int_begin, int_len); + dst += int_len; + } + break; + + case 'L': + { + int integer_token_idx = 0; + if (src[2] >= '1' && src[2] <= '9') + { + if (src[3] != '[') + goto _invalid_token; + integer_token_idx = src[2] - '1'; + + src += 1; + } + else if (src[2] != '[') + goto _invalid_token; + + Assert(integer_tokens_defined[integer_token_idx]); + src += 3; // ^L[ + + auto ending1 = src; + while (*src++ != ';'); + auto ending2 = src; + while (*src++ != ';'); + auto ending3 = src; + while (*src++ != ']'); + + char *actual_ending = nullptr; + int actual_ending_len = 0; + + int modulo = abs(integer_tokens[integer_token_idx]) % 10; + if (modulo == 1) + { + actual_ending = ending1; + actual_ending_len = ending2 - ending1 - 1; + } + else if (modulo >= 2 && modulo <= 4) + { + actual_ending = ending2; + actual_ending_len = ending3 - ending2 - 1; + } + else + { + actual_ending = ending3; + actual_ending_len = src - ending3 - 1; + } + + strncpy(dst, actual_ending, actual_ending_len); + dst += actual_ending_len; + } + break; + + case 'R': + { + if (src[2] != '[') + goto _invalid_token; + Assert(gender_token_defined); + + src += 3; // ^R[ + + auto ending1 = src; + while (*src++ != ';'); + auto ending2 = src; + while (*src++ != ';'); + auto ending3 = src; + while (*src++ != ']'); + + char *actual_ending = nullptr; + int actual_ending_len = 0; + + if (gender_token == 0) + { + actual_ending = ending1; + actual_ending_len = ending2 - ending1 - 1; + } + else if (gender_token == 1) + { + actual_ending = ending2; + actual_ending_len = ending3 - ending2 - 1; + } + else if (gender_token == 2) + { + actual_ending = ending3; + actual_ending_len = src - ending3 - 1; + } + else Error("Invalid gender token"); + + strncpy(dst, actual_ending, actual_ending_len); + dst += actual_ending_len; + } + break; + + case 'P': + { + if (src[3] != '[') + goto _invalid_token; + switch (src[2]) + { + case 'I': case 'i': + case 'R': case 'r': + case 'D': case 'd': + case 'V': case 'v': + case 'T': case 't': + case 'P': case 'p': break; + default: + goto _invalid_token; + } + + if (IsSpecialName(src + 4)) + { + auto name = GetSpecialCase(src + 4, src[2]); + int name_len = strlen(name); + + gender_token = GetSpecialGender(src + 4); + gender_token_defined = true; + + strncpy(dst, name, name_len); + dst += name_len; + while (*src++ != ']'); + break; + } + + auto name_begin = src + 4; + int name_len = 0; + for (int i = 0; name_begin[i] != ']'; ++i) + name_len++; + gender_token = GetGender(name_begin, name_len); + gender_token_defined = true; + + switch (src[2]) + { + case 'I': case 'i': + case 'V': case 'v': + case 'R': case 'r': + case 'D': case 'd': + case 'T': case 't': + { + strncpy(dst, name_begin, name_len); + dst += name_len; + } + break; + + case 'P': case 'p': + { + auto token_begin = src; + int token_len = 1; + for (int i = 0; token_begin[i] != ']'; ++i) + token_len++; + strncpy(dst, token_begin, token_len); + dst += token_len; + } + } + while (*src++ != ']'); + } + break; + + default: + { +_invalid_token: + auto token_begin = src; + while (*src++ != ']'); + + int token_len = src - token_begin; + char token[1024]; + strncpy(token, token_begin, token_len); + token[token_len] = 0; + + Error("Invalid format token: %s", token); + } + break; + } + + *dst = 0; + + auto copy_begin = src; + src = strstr(src, "^"); + if (!src) + { + strcpy(dst, copy_begin); // just copy the rest + break; + } + + int copy_len = src - copy_begin; + strncpy(dst, copy_begin, copy_len); + dst += copy_len; + } + + return dst - str; +} + + + + + + +//mm6text.non -> c structure array + /*FILE *f = fopen("_1.txt", "w+t"); + FILE *in = fopen("mm6text.non", "rt"); + fscanf(in, "%*[^\n]\n"); + + int idx = 0; + auto pairs = new NameGender[8000]; + + char line[1024]; + while (fscanf(in, "%[^\n]\n", line) && !feof(in)) + { + char name1[100], name2[100], name3[100]; + int e = sscanf(line, "%s\t%s\t%s", pairs[idx].name, pairs[idx + 1].name, pairs[idx + 2].name); + pairs[idx].gender = 0; + pairs[idx+1].gender = 1; + pairs[idx+2].gender = 2; + idx += e; + } + + for (int i = 0; i < idx; ++i) + for (int j = 0; j < i; ++j) + { + if (_mbsicmp(pairs[i].name, pairs[j].name) < 0) + { + char n[1024]; + strcpy(n, (char *)pairs[j].name); + auto g = pairs[j].gender; + + strcpy((char *)pairs[j].name, (char *)pairs[i].name); + pairs[j].gender = pairs[i].gender; + + strcpy((char *)pairs[i].name, n); + pairs[i].gender = g; + } + } + + for (int i = 0; i < idx; ++i) + { + fprintf(f, " {\"%s\", %u},\n", pairs[i].name, pairs[i].gender); + } + fclose(f);*/ \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/resource.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/resource.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Might and Magic Trilogy.rc + +// Ñëåäóþùèå ñòàíäàðòíûå çíà÷åíèÿ äëÿ íîâûõ îáúåêòîâ +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/stru123.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/stru123.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,13 @@ +#pragma once +#include + + +/* 62 */ +#pragma pack(push, 1) +struct stru123 +{ + std::array field_0; + std::array _decor_events; +}; +#pragma pack(pop) +extern stru123 stru_5E4C90_MapPersistVars; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/stru159.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/stru159.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,19 @@ +#pragma once + + + +/* 152 */ +#pragma pack(push, 1) +struct stru159 +{ + char *video_name; + int field_4; + int house_npc_id; + unsigned __int8 uBuildingType; // enum BuildingType + unsigned __int8 uRoomSoundId; + unsigned __int16 padding_e; +}; +#pragma pack(pop) + + +extern std::array pAnimatedRooms; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/stru160.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/stru160.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,26 @@ +#pragma once + + +/* 153 */ +#pragma pack(push, 1) +struct stru160 +{ + inline stru160() {} + inline stru160(float a, float b, float c): field_0(a), field_4(b), field_8(c) {} + + float field_0; + float field_4; + float field_8; +}; +#pragma pack(pop) + +#pragma pack(push, 1) +struct stru16x: public stru160 +{ + float field_C; +}; +#pragma pack(pop) + +extern std::array array_4EB8B8; +extern std::array array_4EBBD0; +extern std::array<__int32, 128*3> array_4EBBD0_x; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/stru298.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/stru298.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,21 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#include "stru298.h" + + +//----- (0040261D) -------------------------------------------------------- +void stru298::Add(__int16 uID, __int16 a3, __int16 x, __int16 y, __int16 z, char a7, char a8) +{ + if (count < 100) + { + pIDs[count] = uID; + pXs[count] = x; + pYs[count] = y; + pZs[count] = z; + field_324[count] = a3; + field_3EC[count] = a8; + field_450[count++] = a7; + } +} diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/stru298.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/stru298.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,22 @@ +#pragma once +#include "VectorTypes.h" + +/* 303 */ +#pragma pack(push, 1) +struct stru298 +{ + void Add(__int16 uID, __int16 a3, __int16 x, __int16 y, __int16 z, char a7, char a8); + + int count; + __int16 pIDs[100]; + __int16 pXs[100]; + __int16 pYs[100]; + __int16 pZs[100]; + __int16 field_324[100]; + char field_3EC[100]; + char field_450[100]; + Vec3_int_ vec_4B4[100]; +}; +#pragma pack(pop) + +extern stru298 AttackerInfo; // weak \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/stru314.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/stru314.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,34 @@ +#pragma once + + +/* 179 */ +#pragma pack(push, 1) +struct stru314 +{ + //----- (00489B60) -------------------------------------------------------- + stru314() + { + this->field_4.x = 0.0; + this->field_4.y = 0.0; + this->field_4.z = 0.0; + this->field_10.x = 0.0; + this->field_10.y = 0.0; + this->field_10.z = 0.0; + this->field_1C.x = 0.0; + this->field_1C.y = 0.0; + this->field_1C.z = 0.0; + //this->vdestructor_ptr = &stru314_pvdtor; + } + + //----- (00489B96) -------------------------------------------------------- + inline ~stru314() + {} + + + void (__fastcall ***vdestructor_ptr)(stru314 *, bool); + Vec3_float_ field_4; + Vec3_float_ field_10; + Vec3_float_ field_1C; + float dist; +}; +#pragma pack(pop) diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/stru367.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/stru367.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,20 @@ +#pragma once + +#include + +/* 152 */ +#pragma pack(push, 1) +struct stru367 +{ + bool direction; + std::array field_4; + std::array _view_transformed_x; + std::array _view_transformed_y; + std::array _view_transformed_z; + std::array _screen_space_y; + std::array _screen_space_x; +}; +#pragma pack(pop) + + +//extern const stru367 stru_367; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/stuff.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/stuff.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,46 @@ +#pragma once +#include +#include + + + +inline void Assert(bool condition, const char *format, ...) +{ + if (condition) + return; + + va_list va; + va_start(va, format); + char msg[4096]; + vsprintf(msg, format, va); + MessageBoxA(nullptr, msg, "Assert", 0); + va_end(va); + + __debugbreak(); +} + +inline void Error(const char *format, ...) +{ + va_list va; + va_start(va, format); + char msg[4096]; + vsprintf(msg, format, va); + MessageBoxA(nullptr, msg, "Error", 0); + va_end(va); + + __debugbreak(); +} + + + +inline void log(char *format, ...) +{ + va_list va; + va_start(va, format); + char msg[256]; + vsprintf(msg, format, va); + va_end(va); + DWORD w; + + WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), msg, strlen(msg), &w, 0); +} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/texts.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/texts.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,468 @@ +#define _CRTDBG_MAP_ALLOC +#include +#include + +#define _CRT_SECURE_NO_WARNINGS +#include + +#include "LOD.h" +#include "mm7_data.h" +#include "texts.h" + + +std::vector Tokenize( char* input, const char separator ) +{ + std::vector retVect; + retVect.push_back(input); + while (*input) + { + if (*input == separator) + { + *input = '\0'; + retVect.push_back(input + 1); + } + ++input; + } + return retVect; +} + + + +static char *pGlobalTXT_Raw=nullptr; + +std::array pGlobalTXT_LocalizationStrings; + + + +int sprintfex(char *buf, const char *format, ...) +{ + va_list args_ptr; + va_start(args_ptr, format); + { + vsprintf(buf, format, args_ptr); + } + va_end(args_ptr); + + extern int sprintfex_internal(char *buf); + return sprintfex_internal(buf); +} + +//----- (00452B95) -------------------------------------------------------- +void SetSomeItemsNames() +{ + pSomeItemsNames[0] = pGlobalTXT_LocalizationStrings[568]; + pSomeItemsNames[1] = pGlobalTXT_LocalizationStrings[271]; + pSomeItemsNames[2] = pGlobalTXT_LocalizationStrings[272]; + pSomeItemsNames[3] = pGlobalTXT_LocalizationStrings[273]; + pSomeItemsNames[4] = pGlobalTXT_LocalizationStrings[274]; + pSomeItemsNames[5] = pGlobalTXT_LocalizationStrings[275]; + pSomeItemsNames[6] = pGlobalTXT_LocalizationStrings[276]; + pSomeItemsNames[7] = pGlobalTXT_LocalizationStrings[277]; + pSomeItemsNames[8] = pGlobalTXT_LocalizationStrings[278]; + pSomeItemsNames[9] = pGlobalTXT_LocalizationStrings[279]; + pSomeItemsNames[10] = pGlobalTXT_LocalizationStrings[280]; + pSomeItemsNames[11] = pGlobalTXT_LocalizationStrings[281]; + pSomeItemsNames[12] = pGlobalTXT_LocalizationStrings[282]; + pSomeItemsNames[13] = pGlobalTXT_LocalizationStrings[143]; +} + +//----- (00452C30) -------------------------------------------------------- +char *RemoveQuotes(char *pStr) + { + if ( *pStr == '"' ) + { + pStr[strlen(pStr) - 1] = 0; + return pStr + 1; + } + return pStr; + } + +//----- (00452C49) -------------------------------------------------------- +void InitializeGameText() + { + //char *v0; // ebx@1 + /*char *v1; // eax@3 + int v2; // ebp@4 + char v3; // dl@5 + char *v4; // ecx@5 + int v5; // esi@9 + //char **v6; // [sp+10h] [bp-8h]@3 + signed int v7; // [sp+14h] [bp-4h]@4*/ + char *test_string; // eax@3 + char *tmp_pos; // eax@3 + int step; // ebp@4 + unsigned char c; // dl@5 + int temp_str_len; // ecx@5 + bool string_end; // [sp+14h] [bp-4h]@4 + //v0 = 0; + free(pGlobalTXT_Raw); + pGlobalTXT_Raw = (char *)pEvents_LOD->LoadRaw("global.txt", 0); + +/* strtok(pGlobalTXT_Raw, "\r"); + strtok(nullptr, "\r"); + v1 = strtok(nullptr, "\r") + 1; + + for (uint i = 0; i < 677; ++i) + { + char *p = v1; + while (*++p != '\t' && *p); + + pGlobalTXT_LocalizationStrings[i] = RemoveQuotes(p + 1); + + v1 = strtok(nullptr, "\r") + 1; + }*/ + strtok((char *)pGlobalTXT_Raw, "\r"); //Carriage Return 0D 13 + strtok(NULL, "\r"); //Carriage Return 0D 13 + + for (int i = 0; i < MAX_LOC_STRINGS; ++i) + { + test_string = strtok(NULL, "\r") + 1; //Carriage Return 0D 13 + step = 0; + string_end = false; + do + { + c = *(unsigned char*)test_string; + temp_str_len = 0; + if (c!= '\t' ) // Horizontal tab 09 + { + do + { + if ( !c ) + break; + c = *(test_string+temp_str_len+1); + temp_str_len++; + } + while ( c != '\t' ); // Horizontal tab 09 + } + tmp_pos=test_string+temp_str_len; + if (*tmp_pos == 0) + string_end = true; + *tmp_pos = 0; + if ( temp_str_len == 0) + string_end = true; + else + { + if ( step == 1 ) + pGlobalTXT_LocalizationStrings[i] = RemoveQuotes(test_string); + } + ++step; + test_string=tmp_pos+1; + } + while ( step <= 2 && !string_end); + } + + SetSomeItemsNames(); + aMonthNames[0] = pGlobalTXT_LocalizationStrings[415]; aMonthNames[1] = pGlobalTXT_LocalizationStrings[416]; + aMonthNames[2] = pGlobalTXT_LocalizationStrings[417]; aMonthNames[3] = pGlobalTXT_LocalizationStrings[418]; + aMonthNames[4] = pGlobalTXT_LocalizationStrings[419]; aMonthNames[5] = pGlobalTXT_LocalizationStrings[420]; + aMonthNames[6] = pGlobalTXT_LocalizationStrings[421]; aMonthNames[7] = pGlobalTXT_LocalizationStrings[422]; + aMonthNames[8] = pGlobalTXT_LocalizationStrings[423]; aMonthNames[9] = pGlobalTXT_LocalizationStrings[424]; + aMonthNames[10] = pGlobalTXT_LocalizationStrings[425]; aMonthNames[11] = pGlobalTXT_LocalizationStrings[426]; + + aDayNames[0] = pGlobalTXT_LocalizationStrings[145]; aDayNames[1] = pGlobalTXT_LocalizationStrings[230]; + aDayNames[2] = pGlobalTXT_LocalizationStrings[243]; aDayNames[3] = pGlobalTXT_LocalizationStrings[227]; + aDayNames[4] = pGlobalTXT_LocalizationStrings[91]; aDayNames[5] = pGlobalTXT_LocalizationStrings[188]; + aDayNames[6] = pGlobalTXT_LocalizationStrings[222]; + + + pClassNames [0] = pGlobalTXT_LocalizationStrings[LOCSTR_KNIGHT]; + pClassNames [1] = pGlobalTXT_LocalizationStrings[LOCSTR_CAVALIER]; + pClassNames [2] = pGlobalTXT_LocalizationStrings[LOCSTR_CHAMPION]; + pClassNames [3] = pGlobalTXT_LocalizationStrings[LOCSTR_BLK_KNIGHT]; + + pClassNames [4] = pGlobalTXT_LocalizationStrings[LOCSTR_THIEF]; + pClassNames [5] = pGlobalTXT_LocalizationStrings[LOCSTR_ROGUE]; + pClassNames [6] = pGlobalTXT_LocalizationStrings[LOCSTR_SPY]; + pClassNames [7] = pGlobalTXT_LocalizationStrings[LOCSTR_ASSASIN]; + + pClassNames [8] = pGlobalTXT_LocalizationStrings[LOCSTR_MONK]; + pClassNames [9] = pGlobalTXT_LocalizationStrings[26]; + pClassNames [10] = pGlobalTXT_LocalizationStrings[432]; + pClassNames [11] = pGlobalTXT_LocalizationStrings[27]; + + pClassNames [12] = pGlobalTXT_LocalizationStrings[LOCSTR_PALADIN]; + pClassNames [13] = pGlobalTXT_LocalizationStrings[263]; + pClassNames [14] = pGlobalTXT_LocalizationStrings[264]; + pClassNames [15] = pGlobalTXT_LocalizationStrings[28]; + + pClassNames [16] = pGlobalTXT_LocalizationStrings[LOCSTR_ARCHER]; + pClassNames [17] = pGlobalTXT_LocalizationStrings[267]; + pClassNames [18] = pGlobalTXT_LocalizationStrings[119]; + pClassNames [19] = pGlobalTXT_LocalizationStrings[124]; + + pClassNames [20] = pGlobalTXT_LocalizationStrings[LOCSTR_RANGER]; + pClassNames [21] = pGlobalTXT_LocalizationStrings[370]; + pClassNames [22] = pGlobalTXT_LocalizationStrings[33]; + pClassNames [23] = pGlobalTXT_LocalizationStrings[40]; + + pClassNames [24] = pGlobalTXT_LocalizationStrings[LOCSTR_CLERIC]; + pClassNames [25] = pGlobalTXT_LocalizationStrings[257]; + pClassNames [26] = pGlobalTXT_LocalizationStrings[44]; + pClassNames [27] = pGlobalTXT_LocalizationStrings[46]; + + pClassNames [28] = pGlobalTXT_LocalizationStrings[LOCSTR_DRUID]; + pClassNames [29] = pGlobalTXT_LocalizationStrings[269]; + pClassNames [30] = pGlobalTXT_LocalizationStrings[270]; + pClassNames [31] = pGlobalTXT_LocalizationStrings[48]; + + pClassNames [32] = pGlobalTXT_LocalizationStrings[LOCSTR_SORCERER]; + pClassNames [33] = pGlobalTXT_LocalizationStrings[260]; + pClassNames [34] = pGlobalTXT_LocalizationStrings[261]; + pClassNames [35] = pGlobalTXT_LocalizationStrings[49]; + + aCharacterConditionNames[0] = pGlobalTXT_LocalizationStrings[52]; + aCharacterConditionNames[1] = pGlobalTXT_LocalizationStrings[241]; + aCharacterConditionNames[2] = pGlobalTXT_LocalizationStrings[14]; + aCharacterConditionNames[3] = pGlobalTXT_LocalizationStrings[4]; + aCharacterConditionNames[4] = pGlobalTXT_LocalizationStrings[69]; + aCharacterConditionNames[5] = pGlobalTXT_LocalizationStrings[117]; + aCharacterConditionNames[6] = pGlobalTXT_LocalizationStrings[166]; + aCharacterConditionNames[7] = pGlobalTXT_LocalizationStrings[65]; + aCharacterConditionNames[8] = pGlobalTXT_LocalizationStrings[166]; + aCharacterConditionNames[9] = pGlobalTXT_LocalizationStrings[65]; + aCharacterConditionNames[10] = pGlobalTXT_LocalizationStrings[166]; + aCharacterConditionNames[11] = pGlobalTXT_LocalizationStrings[65]; + aCharacterConditionNames[12] = pGlobalTXT_LocalizationStrings[162]; + aCharacterConditionNames[13] = pGlobalTXT_LocalizationStrings[231]; + aCharacterConditionNames[14] = pGlobalTXT_LocalizationStrings[58]; + aCharacterConditionNames[15] = pGlobalTXT_LocalizationStrings[220]; + aCharacterConditionNames[16] = pGlobalTXT_LocalizationStrings[76]; + aCharacterConditionNames[17] = pGlobalTXT_LocalizationStrings[601]; + aCharacterConditionNames[18] = pGlobalTXT_LocalizationStrings[98]; + + pSkillNames[0] = pGlobalTXT_LocalizationStrings[271]; + pSkillNames[1] = pGlobalTXT_LocalizationStrings[272]; + pSkillNames[2] = pGlobalTXT_LocalizationStrings[273]; + pSkillNames[3] = pGlobalTXT_LocalizationStrings[274]; + pSkillNames[4] = pGlobalTXT_LocalizationStrings[275]; + pSkillNames[5] = pGlobalTXT_LocalizationStrings[276]; + pSkillNames[6] = pGlobalTXT_LocalizationStrings[277]; + pSkillNames[7] = pGlobalTXT_LocalizationStrings[278]; + pSkillNames[8] = pGlobalTXT_LocalizationStrings[279]; + pSkillNames[9] = pGlobalTXT_LocalizationStrings[280]; + pSkillNames[10] = pGlobalTXT_LocalizationStrings[281]; + pSkillNames[11] = pGlobalTXT_LocalizationStrings[282]; + pSkillNames[12] = pGlobalTXT_LocalizationStrings[283]; + pSkillNames[13] = pGlobalTXT_LocalizationStrings[284]; + pSkillNames[14] = pGlobalTXT_LocalizationStrings[285]; + pSkillNames[15] = pGlobalTXT_LocalizationStrings[286]; + pSkillNames[16] = pGlobalTXT_LocalizationStrings[289]; + pSkillNames[17] = pGlobalTXT_LocalizationStrings[290]; + pSkillNames[18] = pGlobalTXT_LocalizationStrings[291]; + pSkillNames[19] = pGlobalTXT_LocalizationStrings[287]; + pSkillNames[20] = pGlobalTXT_LocalizationStrings[288]; + pSkillNames[21] = pGlobalTXT_LocalizationStrings[292]; + pSkillNames[22] = pGlobalTXT_LocalizationStrings[293]; + pSkillNames[23] = pGlobalTXT_LocalizationStrings[294]; + pSkillNames[24] = pGlobalTXT_LocalizationStrings[295]; + pSkillNames[25] = pGlobalTXT_LocalizationStrings[296]; + pSkillNames[26] = pGlobalTXT_LocalizationStrings[297]; + pSkillNames[27] = pGlobalTXT_LocalizationStrings[298]; + pSkillNames[28] = pGlobalTXT_LocalizationStrings[299]; + pSkillNames[29] = pGlobalTXT_LocalizationStrings[300]; + pSkillNames[30] = pGlobalTXT_LocalizationStrings[50]; + pSkillNames[31] = pGlobalTXT_LocalizationStrings[77]; + pSkillNames[32] = pGlobalTXT_LocalizationStrings[88]; + pSkillNames[33] = pGlobalTXT_LocalizationStrings[89]; + pSkillNames[34] = pGlobalTXT_LocalizationStrings[90]; + pSkillNames[35] = pGlobalTXT_LocalizationStrings[95]; + pSkillNames[36] = pGlobalTXT_LocalizationStrings[301]; + pSkillNames[37] = pGlobalTXT_LocalizationStrings[153]; + + aSpellSchoolNames[0] = pGlobalTXT_LocalizationStrings[87]; + aSpellSchoolNames[1] = pGlobalTXT_LocalizationStrings[6]; + aSpellSchoolNames[2] = pGlobalTXT_LocalizationStrings[240]; + aSpellSchoolNames[3] = pGlobalTXT_LocalizationStrings[70]; + aSpellSchoolNames[4] = pGlobalTXT_LocalizationStrings[214]; + aSpellSchoolNames[5] = pGlobalTXT_LocalizationStrings[142]; + aSpellSchoolNames[6] = pGlobalTXT_LocalizationStrings[29]; + aSpellSchoolNames[7] = pGlobalTXT_LocalizationStrings[133]; + aSpellSchoolNames[8] = pGlobalTXT_LocalizationStrings[54]; + + aAttributeNames[0] = pGlobalTXT_LocalizationStrings[144]; + aAttributeNames[1] = pGlobalTXT_LocalizationStrings[116]; + aAttributeNames[2] = pGlobalTXT_LocalizationStrings[163]; + aAttributeNames[3] = pGlobalTXT_LocalizationStrings[75]; + aAttributeNames[4] = pGlobalTXT_LocalizationStrings[1]; + aAttributeNames[5] = pGlobalTXT_LocalizationStrings[211]; + aAttributeNames[6] = pGlobalTXT_LocalizationStrings[136]; + + aAMPMNames[0] = pGlobalTXT_LocalizationStrings[472]; + aAMPMNames[1] = pGlobalTXT_LocalizationStrings[473]; + + aNPCProfessionNames[0] = pGlobalTXT_LocalizationStrings[153]; + aNPCProfessionNames[1] = pGlobalTXT_LocalizationStrings[308]; + aNPCProfessionNames[2] = pGlobalTXT_LocalizationStrings[309]; + aNPCProfessionNames[3] = pGlobalTXT_LocalizationStrings[7]; + aNPCProfessionNames[4] = pGlobalTXT_LocalizationStrings[306]; + aNPCProfessionNames[5] = pGlobalTXT_LocalizationStrings[310]; + aNPCProfessionNames[6] = pGlobalTXT_LocalizationStrings[311]; + aNPCProfessionNames[7] = pGlobalTXT_LocalizationStrings[312]; + aNPCProfessionNames[8] = pGlobalTXT_LocalizationStrings[313]; + aNPCProfessionNames[9] = pGlobalTXT_LocalizationStrings[314]; + aNPCProfessionNames[10] = pGlobalTXT_LocalizationStrings[105]; + aNPCProfessionNames[11] = pGlobalTXT_LocalizationStrings[315]; + aNPCProfessionNames[12] = pGlobalTXT_LocalizationStrings[316]; + aNPCProfessionNames[13] = pGlobalTXT_LocalizationStrings[317]; + aNPCProfessionNames[14] = pGlobalTXT_LocalizationStrings[115]; + aNPCProfessionNames[15] = pGlobalTXT_LocalizationStrings[318]; + aNPCProfessionNames[16] = pGlobalTXT_LocalizationStrings[319]; + aNPCProfessionNames[17] = pGlobalTXT_LocalizationStrings[320]; + aNPCProfessionNames[18] = pGlobalTXT_LocalizationStrings[321]; + aNPCProfessionNames[19] = pGlobalTXT_LocalizationStrings[322]; + aNPCProfessionNames[20] = pGlobalTXT_LocalizationStrings[323]; + aNPCProfessionNames[21] = pGlobalTXT_LocalizationStrings[293]; + aNPCProfessionNames[22] = pGlobalTXT_LocalizationStrings[324]; + aNPCProfessionNames[23] = pGlobalTXT_LocalizationStrings[498]; + aNPCProfessionNames[24] = pGlobalTXT_LocalizationStrings[525]; + aNPCProfessionNames[25] = pGlobalTXT_LocalizationStrings[327]; + aNPCProfessionNames[26] = pGlobalTXT_LocalizationStrings[328]; + aNPCProfessionNames[27] = pGlobalTXT_LocalizationStrings[329]; + aNPCProfessionNames[28] = pGlobalTXT_LocalizationStrings[330]; + aNPCProfessionNames[29] = pGlobalTXT_LocalizationStrings[331]; + aNPCProfessionNames[30] = pGlobalTXT_LocalizationStrings[332]; + aNPCProfessionNames[31] = pGlobalTXT_LocalizationStrings[333]; + aNPCProfessionNames[32] = pGlobalTXT_LocalizationStrings[334]; + aNPCProfessionNames[33] = pGlobalTXT_LocalizationStrings[335]; + aNPCProfessionNames[34] = pGlobalTXT_LocalizationStrings[336]; + aNPCProfessionNames[35] = pGlobalTXT_LocalizationStrings[337]; + aNPCProfessionNames[36] = pGlobalTXT_LocalizationStrings[338]; + aNPCProfessionNames[37] = pGlobalTXT_LocalizationStrings[339]; + aNPCProfessionNames[38] = pGlobalTXT_LocalizationStrings[340]; + aNPCProfessionNames[39] = pGlobalTXT_LocalizationStrings[341]; + aNPCProfessionNames[40] = pGlobalTXT_LocalizationStrings[342]; + aNPCProfessionNames[41] = pGlobalTXT_LocalizationStrings[343]; + aNPCProfessionNames[42] = pGlobalTXT_LocalizationStrings[596]; + aNPCProfessionNames[43] = pGlobalTXT_LocalizationStrings[345]; + aNPCProfessionNames[44] = pGlobalTXT_LocalizationStrings[346]; + aNPCProfessionNames[45] = pGlobalTXT_LocalizationStrings[347]; + aNPCProfessionNames[46] = pGlobalTXT_LocalizationStrings[348]; + aNPCProfessionNames[47] = pGlobalTXT_LocalizationStrings[349]; + aNPCProfessionNames[48] = pGlobalTXT_LocalizationStrings[350]; + aNPCProfessionNames[49] = pGlobalTXT_LocalizationStrings[597]; + aNPCProfessionNames[50] = pGlobalTXT_LocalizationStrings[352]; + aNPCProfessionNames[51] = pGlobalTXT_LocalizationStrings[353]; + aNPCProfessionNames[52] = pGlobalTXT_LocalizationStrings[598]; + aNPCProfessionNames[53] = pGlobalTXT_LocalizationStrings[344]; + aNPCProfessionNames[54] = pGlobalTXT_LocalizationStrings[26]; + aNPCProfessionNames[55] = pGlobalTXT_LocalizationStrings[599]; + aNPCProfessionNames[56] = pGlobalTXT_LocalizationStrings[21]; + aNPCProfessionNames[57] = pGlobalTXT_LocalizationStrings[600]; + aNPCProfessionNames[58] = pGlobalTXT_LocalizationStrings[370]; + + aMoonPhaseNames[0] = pGlobalTXT_LocalizationStrings[150]; + aMoonPhaseNames[1] = pGlobalTXT_LocalizationStrings[171]; + aMoonPhaseNames[2] = pGlobalTXT_LocalizationStrings[102]; + aMoonPhaseNames[3] = pGlobalTXT_LocalizationStrings[169]; + aMoonPhaseNames[4] = pGlobalTXT_LocalizationStrings[92]; + + aSpellNames[0] = pGlobalTXT_LocalizationStrings[202]; + aSpellNames[1] = pGlobalTXT_LocalizationStrings[204]; + aSpellNames[2] = pGlobalTXT_LocalizationStrings[219]; + aSpellNames[3] = pGlobalTXT_LocalizationStrings[215]; + aSpellNames[4] = pGlobalTXT_LocalizationStrings[208]; + aSpellNames[5] = pGlobalTXT_LocalizationStrings[454]; + aSpellNames[6] = pGlobalTXT_LocalizationStrings[24]; + aSpellNames[7] = pGlobalTXT_LocalizationStrings[455]; + aSpellNames[8] = pGlobalTXT_LocalizationStrings[441]; + aSpellNames[9] = pGlobalTXT_LocalizationStrings[440]; + aSpellNames[10] = pGlobalTXT_LocalizationStrings[218]; + aSpellNames[11] = pGlobalTXT_LocalizationStrings[217]; + aSpellNames[12] = pGlobalTXT_LocalizationStrings[213]; + aSpellNames[13] = pGlobalTXT_LocalizationStrings[462]; + aSpellNames[14] = pGlobalTXT_LocalizationStrings[279]; + aSpellNames[15] = pGlobalTXT_LocalizationStrings[442]; + aSpellNames[16] = pGlobalTXT_LocalizationStrings[452]; + aSpellNames[17] = pGlobalTXT_LocalizationStrings[194]; + aSpellNames[18] = pGlobalTXT_LocalizationStrings[456]; + aSpellNames[19] = pGlobalTXT_LocalizationStrings[453]; + aSpellNames[20] = pGlobalTXT_LocalizationStrings[202]; + aSpellNames[21] = pGlobalTXT_LocalizationStrings[443]; + aSpellNames[22] = pGlobalTXT_LocalizationStrings[204]; + aSpellNames[23] = pGlobalTXT_LocalizationStrings[208]; + aSpellNames[24] = pGlobalTXT_LocalizationStrings[221]; + aSpellNames[25] = pGlobalTXT_LocalizationStrings[24]; + aSpellNames[26] = pGlobalTXT_LocalizationStrings[228]; + aSpellNames[27] = pGlobalTXT_LocalizationStrings[441]; + aSpellNames[28] = pGlobalTXT_LocalizationStrings[440]; + aSpellNames[29] = pGlobalTXT_LocalizationStrings[213]; + aSpellNames[30] = pGlobalTXT_LocalizationStrings[229]; + aSpellNames[31] = pGlobalTXT_LocalizationStrings[233]; + aSpellNames[32] = pGlobalTXT_LocalizationStrings[234]; + aSpellNames[33] = pGlobalTXT_LocalizationStrings[279]; + aSpellNames[34] = pGlobalTXT_LocalizationStrings[442]; + aSpellNames[35] = pGlobalTXT_LocalizationStrings[235]; + aSpellNames[36] = pGlobalTXT_LocalizationStrings[246]; + aSpellNames[37] = pGlobalTXT_LocalizationStrings[247]; + aSpellNames[38] = pGlobalTXT_LocalizationStrings[248]; + aSpellNames[39] = pGlobalTXT_LocalizationStrings[674]; + aSpellNames[40] = pGlobalTXT_LocalizationStrings[249]; + aSpellNames[41] = pGlobalTXT_LocalizationStrings[258]; + aSpellNames[42] = pGlobalTXT_LocalizationStrings[194]; + aSpellNames[43] = pGlobalTXT_LocalizationStrings[657]; + } +//----- (00413FF1) -------------------------------------------------------- +void SetMonthNames() +{ + aMonthNames[0] = pGlobalTXT_LocalizationStrings[415]; + aMonthNames[1] = pGlobalTXT_LocalizationStrings[416]; + aMonthNames[2] = pGlobalTXT_LocalizationStrings[417]; + aMonthNames[3] = pGlobalTXT_LocalizationStrings[418]; + aMonthNames[4] = pGlobalTXT_LocalizationStrings[419]; + aMonthNames[5] = pGlobalTXT_LocalizationStrings[420]; + aMonthNames[6] = pGlobalTXT_LocalizationStrings[421]; + aMonthNames[7] = pGlobalTXT_LocalizationStrings[422]; + aMonthNames[8] = pGlobalTXT_LocalizationStrings[423]; + aMonthNames[9] = pGlobalTXT_LocalizationStrings[424]; + aMonthNames[10] = pGlobalTXT_LocalizationStrings[425]; + aMonthNames[11] = pGlobalTXT_LocalizationStrings[426]; +} + +//----- (0041406F) -------------------------------------------------------- +void SetDayNames() +{ + aDayNames[0] = pGlobalTXT_LocalizationStrings[145]; + aDayNames[1] = pGlobalTXT_LocalizationStrings[230]; + aDayNames[2] = pGlobalTXT_LocalizationStrings[243]; + aDayNames[3] = pGlobalTXT_LocalizationStrings[227]; + aDayNames[4] = pGlobalTXT_LocalizationStrings[91]; + aDayNames[5] = pGlobalTXT_LocalizationStrings[188]; + aDayNames[6] = pGlobalTXT_LocalizationStrings[222]; +} + +//----- (004140BB) -------------------------------------------------------- +void SetSpellSchoolNames() +{ + aSpellSchoolNames[0] = pGlobalTXT_LocalizationStrings[87]; + aSpellSchoolNames[1] = pGlobalTXT_LocalizationStrings[6]; + aSpellSchoolNames[2] = pGlobalTXT_LocalizationStrings[240]; + aSpellSchoolNames[3] = pGlobalTXT_LocalizationStrings[70]; + aSpellSchoolNames[4] = pGlobalTXT_LocalizationStrings[214]; + aSpellSchoolNames[5] = pGlobalTXT_LocalizationStrings[142]; + aSpellSchoolNames[6] = pGlobalTXT_LocalizationStrings[29]; + aSpellSchoolNames[7] = pGlobalTXT_LocalizationStrings[133]; + aSpellSchoolNames[8] = pGlobalTXT_LocalizationStrings[54]; +} + +//----- (0041411B) -------------------------------------------------------- +void SetAttributeNames() +{ + aAttributeNames[0] = pGlobalTXT_LocalizationStrings[144]; + aAttributeNames[1] = pGlobalTXT_LocalizationStrings[116]; + aAttributeNames[2] = pGlobalTXT_LocalizationStrings[163]; + aAttributeNames[3] = pGlobalTXT_LocalizationStrings[75]; + aAttributeNames[4] = pGlobalTXT_LocalizationStrings[1]; + aAttributeNames[5] = pGlobalTXT_LocalizationStrings[211]; + aAttributeNames[6] = pGlobalTXT_LocalizationStrings[136]; +} +//----- (00410AF5) -------------------------------------------------------- +void SetMoonPhaseNames() +{ + aMoonPhaseNames[0] = pGlobalTXT_LocalizationStrings[150]; + aMoonPhaseNames[1] = pGlobalTXT_LocalizationStrings[171]; + aMoonPhaseNames[2] = pGlobalTXT_LocalizationStrings[102]; + aMoonPhaseNames[3] = pGlobalTXT_LocalizationStrings[169]; + aMoonPhaseNames[4] = pGlobalTXT_LocalizationStrings[92]; +} + + diff -r 92eeeb5200f2 -r 68cdef6879a0 Engine/texts.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Engine/texts.h Fri Sep 19 02:57:42 2014 +0600 @@ -0,0 +1,863 @@ +#pragma once +#include +#include + + +int sprintfex(char *buf, const char *format, ...); + + +void SetSomeItemsNames(); +char *RemoveQuotes(char *Str); +void InitializeGameText(); +void SetMoonPhaseNames(); +void SetAttributeNames(); + +struct ci_less : std::binary_function //case insensitive comparator for dictionaries +{ + // case-independent (ci) compare_less binary function + struct nocase_compare : public std::binary_function + { + bool operator() (const unsigned char& c1, const unsigned char& c2) const { + return tolower (c1) < tolower (c2); + } + }; + bool operator() (const std::string & s1, const std::string & s2) const { + return std::lexicographical_compare + (s1.begin (), s1.end (), // source range + s2.begin (), s2.end (), // dest range + nocase_compare ()); // comparison + } +}; +std::vector Tokenize(char* input, const char separator); + +enum GLOBAL_LOCALIZ_INDEX + { + + LOCSTR_AC = 0, //"AC" + LOCSTR_ACCURACY = 1, //"Accuracy" + LOCSTR_BLK_KNIGHT = 2, //"Black Knight" + LOCSTR_SPY = 3, // "Spy" + + LOCSTR_TOWN_PORTAL = 10, // "Town Portal" + + LOCSTR_ASSASIN = 13, // "Assassin" + + LOCSTR_AUTOSAVE = 16, // "Autosave" + + LOCSTR_ATTACK = 18, // "Attack" + LOCSTR_AVAILABLE = 19, //"Available" + + LOCSTR_MONK = 21, //"Monk" + + LOCSTR_AVARDS_FOR = 23, //"Awards for" + + + LOCSTR_RANGER = 31, //"Ranger" + + LOCSTR_CANCEL = 34, //"Cancel" + + + LOCSTR_SELECT_TGT = 39, ///"Select Target" + + LOCSTR_CLASS = 41, // "Class" + + LOCSTR_CONDITION = 47, //"Condition" + + LOCSTR_CREATE_PARTY = 51, //"C R E A T E P A R T Y" + + LOCSTR_DAWN = 55, //"Dawn" + LOCSTR_DAY = 56, //"Day" + LOCSTR_DAYS = 57, /// "Days" + + LOCSTR_PRESS_ESCAPE = 61, // "Press Escape" + + LOCSTR_TROUBLE_LOAD = 63,//"Might and Magic VII is having trouble loading files. + // Please re-install to fix this problem. Note: Re-installing will not destroy your save games." + LOCSTR_DETAIL_TOGGLE = 64, //"Detail Toggle" + + LOCSTR_DMG = 66, /// "Dmg" + + LOCSTR_EMPTY = 72, // "Empty" + + LOCSTR_EXIT = 79, // "Exit" + LOCSTR_EXIT_BLDNG = 80, // "Exit Building" + + LOCSTR_EXPIRIENCE = 83, //"Experience" + + LOCSTR_GRAND = 96, // "Grand" + + LOCSTR_HP = 107, // "HP" + LOCSTR_HIT_POINTS = 108, // "Hit Points" + LOCSTR_HOUR = 109, //"Hour" + LOCSTR_HOURS = 110, //"Hours" + + LOCSTR_ROGUE = 114, //"Rogue" + + LOCSTR_LEVEL = 131, // "Level" + + LOCSTR_LOADING = 135, //"Loading" + + LOCSTR_MIGHT = 144, //"Might" + + LOCSTR_NAME = 149, // "Name" + + LOCSTR_YOU_TO_TRAIN = 147, // "You are eligible to train to %u." + + LOCSTR_STAY_IN_AREA = 156, //"Stay in this Area" + LOCSTR_3DO_COPYRHT = 157, // ""© 1999 The 3DO Company. + + LOCSTR_PLEASE_WAIT = 165, // "Please Wait" + + LOCSTR_REPUTATION = 180, //"Reputation" + + LOCSTR_REST_HEAL_8 = 183, //"Rest & Heal 8 Hours" + + LOCSTR_TIME_ERATHIA = 186, // "Time in Erathia" + + LOCSTR_SAVING = 190, // "Saving" + + LOCSTR_SKILL_POINTS = 207, /// "Skill Points" + + LOCSTR_KNIGHT = 253, //"Knight" + LOCSTR_CAVALIER = 254, //"Cavalier" + LOCSTR_CHAMPION = 255, //"Champion" + LOCSTR_CLERIC = 256, //"Cleric" + LOCSTR_PRIEST = 257, //"Priest" + + LOCSTR_SORCERER = 259, // "Sorcerer" + + LOCSTR_PALADIN = 262, // "Paladin" + + LOCSTR_ARCHER = 265, /// "Archer" + + LOCSTR_DRUID = 268, // "Druid" + + LOCSTR_THIEF = 307, //"Thief" + + LOCSTR_SET_BEACON = 375, // "Set Beacon" + + LOCSTR_HATED = 379,// "Hated" + + LOCSTR_UNFRENDLY = 392, //"Unfriendly" + + LOCSTR_NEITRAL = 399, // "Neutral" + + LOCSTR_FRENDLY = 402, // "Friendly" + + LOCSTR_D_DAYS_TO_S = 404, //"%d days to %s" + LOCSTR_TRAVEL_COST = 405, //"Travel Cost %d gold" + + LOCSTR_ENTER_S = 411, // "Enter %s" + + LOCSTR_IS_IN_NO_COND = 427, // "%s is in no condition to %s" + + LOCSTR_S_THE_S = 429, //"%s the %s" + + LOCSTR_NORMAL = 431, //"Normal" + LOCSTR_MASTER = 432, //"Master" + LOCSTR_EXPERT = 433, //"Expert" + LOCSTR_LIKED = 434, //"Liked" + + LOCSTR_ACTIVE_SPELL = 450, // "Active Spells: %s" + + LOCSTR_READING = 505, ///"Reading..." + + LOCSTR_NOTHING_HERE = 521, // "Nothing here" + + LOCSTR_SP_COST = 522, //"SP Cost" + LOCSTR_RECALL_BEACON = 523, // "Recall Beacon" + + LOCSTR_TIME = 526, //"Time" + + LOCSTR_NEED_MORE_EXP = 538, //"You need %d more experience to train to level %d" + + LOCSTR_IDENT_ITEM = 541, // "Identify Items" + + LOCSTR_DUSK = 566, //"Dusk" + LOCSTR_NIGHT = 567, // "Night" + + LOCSTR_NO_SAVING = 583, //"No saving in the Arena" + + LOCSTR_AUTOSAVE_MM7 = 613, // "AutoSave.MM7" + + LOCSTR_BONUS = 623, //"Bonus" + + LOCSTR_GAME_SAVED = 656, // "Game Saved!" + + MAX_LOC_STRINGS =677 + + }; + + extern std::array pGlobalTXT_LocalizationStrings; + +/* + ++ [4] 0x04102dab "Afraid" unsigned char * ++ [5] 0x04102db5 "Age" unsigned char * ++ [6] 0x04102dbc "Air" unsigned char * ++ [7] 0x04102dc3 "Alchemist" unsigned char * ++ [8] 0x04102dd0 "Obelisk Notes" unsigned char * ++ [9] 0x04102de1 "Congratulations!" unsigned char * + ++ [11] 0x04102e06 "Armor" unsigned char * ++ [0xc] 0x04102e10 "Armor Class" unsigned char * + ++ [0xe] 0x04102e2d "Asleep" unsigned char * ++ [0xf] 0x04102e38 "Assertion failed at %d in %s" unsigned char * + ++ [17] 0x04102e66 "Exp." unsigned char * + + ++ [20] 0x04102e88 "Available Skills" unsigned char * + ++ [22] 0x04102ea6 "Awards" unsigned char * + ++ [24] 0x04102ec0 "Fire Res" unsigned char * ++ [25] 0x04102ecd "Balance" unsigned char * ++ [26] 0x04102ed9 "Initiate" unsigned char * ++ [27] 0x04102ee6 "Ninja" unsigned char * ++ [28] 0x04102ef0 "Villain" unsigned char * ++ [29] 0x04102efc "Body" unsigned char * ++ [30] 0x04102f05 "Bonus" unsigned char * + ++ [32] 0x04102f1a "Broken Item" unsigned char * ++ [33] 0x04102f2a "Ranger Lord" unsigned char * ++ [34] 0x04102f3a "Cancel" unsigned char * ++ [35] 0x04102f45 "Town Portal to %s" unsigned char * ++ [36] 0x04102f5b "%s can not be used that way" unsigned char * ++ [37] 0x04102f7b "Total Time:" unsigned char * ++ [38] 0x04102f8b "Cast Spell" unsigned char * + ++ [0x28] 0x04102fac "Bounty Hunter" unsigned char * + ++ [0x2a] 0x04102fc8 "Clerk" unsigned char * ++ [0x2b] 0x04102fd2 "Cold" unsigned char * ++ [0x2c] 0x04102fdb "Priest of Light" unsigned char * ++ [45] 0x04102fef "Cond" unsigned char * ++ [46] 0x04102ff8 "Priest of Dark" unsigned char * + ++ [48] 0x04103019 "Warlock" unsigned char * ++ [49] 0x04103025 "Lich" unsigned char * ++ [50] 0x0410302e "Dodging" unsigned char * + ++ [52] 0x04103056 "Cursed" unsigned char * ++ [0x35] 0x04103061 "Damage" unsigned char * ++ [0x36] 0x0410306c "Dark" unsigned char * + + + ++ [58] 0x0410308f "Dead" unsigned char * ++ [59] 0x04103098 "Internal Error" unsigned char * ++ [60] 0x041030ab "Deposit" unsigned char * + ++ [62] 0x041030c8 "Might and Magic VII requires your desktop to be in 16bit (32k or 65k) Color mode in order to operate in a window." unsigned char * + + ++ [65] 0x041031e6 "Diseased" unsigned char * + ++ [0x43] 0x041031fb "%s does not have the skill" unsigned char * ++ [68] 0x0410321a "Donate" unsigned char * ++ [69] 0x04103225 "Drunk" unsigned char * ++ [70] 0x0410322f "Earth" unsigned char * ++ [71] 0x04103239 "Electricity" unsigned char * + ++ [73] 0x04103253 "Enter" unsigned char * ++ [74] 0x0410325d "End Conversation" unsigned char * ++ [75] 0x04103272 "Endurance" unsigned char * ++ [0x4c] 0x04103280 "Eradicated" unsigned char * ++ [0x4d] 0x0410328f "Unarmed" unsigned char * ++ [0x4e] 0x0410329b "Calendar" unsigned char * ++ [0x4f] 0x041032a8 "Exit" unsigned char * + ++ [81] 0x041032c3 "Exit Rest" unsigned char * ++ [82] 0x041032d1 "Are you sure? Click again to quit" unsigned char * + ++ [84] 0x04103307 "Fame" unsigned char * ++ [85] 0x04103310 "Potion Notes" unsigned char * ++ [86] 0x04103321 "Fill Packs to %d days for %d gold" unsigned char * ++ [87] 0x04103347 "Fire" unsigned char * ++ [88] 0x04103350 "Identify Monster" unsigned char * ++ [89] 0x04103365 "Armsmaster" unsigned char * ++ [90] 0x04103374 "Stealing" unsigned char * ++ [91] 0x04103381 "Friday" unsigned char * ++ [92] 0x0410338c "Full" unsigned char * ++ [93] 0x04103395 "Game Options" unsigned char * ++ [94] 0x041033a6 "Your score: %lu" unsigned char * ++ [95] 0x041033ba "Alchemy" unsigned char * + + + ++ [97] 0x041033d0 "Gold" unsigned char * ++ [98] 0x041033d9 "Good" unsigned char * ++ [99] 0x041033e2 "Human" unsigned char * ++ [100] 0x041033ed "Guard" unsigned char * ++ [101] 0x041033f8 "Dwarf" unsigned char * ++ [102] 0x04103403 "Half" unsigned char * ++ [103] 0x0410340d "Elf" unsigned char * ++ [104] 0x04103416 "Heal" unsigned char * ++ [105] 0x04103420 "Healer" unsigned char * ++ [106] 0x0410342c "Goblin" unsigned char * + ++ [108] 0x04103440 "Hit Points" unsigned char * + ++ [111] 0x04103465 "Grand" unsigned char * ++ [112] 0x04103470 "How Much?" unsigned char * ++ [113] 0x0410347f "Identify" unsigned char * + ++ [115] 0x04103498 "Instructor" unsigned char * ++ [116] 0x041034a8 "Intellect" unsigned char * ++ [117] 0x041034b7 "Insane" unsigned char * ++ [118] 0x041034c3 "We hope that you've enjoyed playing Might and Magic VII as much as we did making it. We have saved this screen as MM7_WIN.PCX in your MM7 directory. You can print it out as proof of your accomplishment." unsigned char * ++ [119] 0x04103593 "Master Archer" unsigned char * ++ [120] 0x041035a6 "Inventory" unsigned char * ++ [121] 0x041035b5 "Permanent" unsigned char * ++ [122] 0x041035c4 "Join" unsigned char * ++ [123] 0x041035ce "Miscellaneous Notes" unsigned char * ++ [124] 0x041035e7 "Sniper" unsigned char * ++ [125] 0x041035f3 "+2 Skill Points!" unsigned char * ++ [126] 0x04103609 "Do you wish to leave %s?" unsigned char * ++ [127] 0x04103627 "No Text!" unsigned char * ++ [128] 0x04103635 "It will take %d days to travel to %s." unsigned char * ++ [129] 0x04103660 "%s the Level %u %s" unsigned char * ++ [130] 0x04103678 "Player" unsigned char * + ++ [132] 0x0410368f "Years" unsigned char * ++ [133] 0x0410369a "Light" unsigned char * ++ [134] 0x041036a5 "Buy Standard" unsigned char * + ++ [136] 0x041036c4 "Luck" unsigned char * ++ [137] 0x041036ce "Fountain Notes" unsigned char * ++ [138] 0x041036e2 "Magic" unsigned char * ++ [139] 0x041036ed "Maps" unsigned char * ++ [140] 0x041036f7 "Your packs are already full!" unsigned char * ++ [141] 0x04103719 "Seer Notes" unsigned char * ++ [142] 0x04103729 "Mind" unsigned char * ++ [143] 0x04103733 "Misc" unsigned char * + ++ [145] 0x04103748 "Monday" unsigned char * ++ [146] 0x04103754 "Month" unsigned char * + ++ [148] 0x04103785 "Months" unsigned char * + ++ [150] 0x0410379b "New" unsigned char * ++ [151] 0x041037a4 "Congratulations Adventurer." unsigned char * ++ [152] 0x041037c5 "Buy Special" unsigned char * ++ [153] 0x041037d6 "None" unsigned char * ++ [154] 0x041037e0 "Auto Notes" unsigned char * ++ [155] 0x041037f0 "You don't have enough gold" unsigned char * + ++ [157] 0x04103827 ""© 1999 The 3DO Company. All Rights Reserved. Might and Magic, Blood and Honor, New World Computing, 3DO, and their respective logos, are trademarks and/or service marks of The 3DO Company in the U.S. and other countries. All other trademarks belong to their respective owners. New World Computing is a division of The 3DO Company."" unsigned char * ++ [158] 0x0410397d "Bootleg Bay East" unsigned char * ++ [159] 0x04103993 "Display Inventory" unsigned char * ++ [160] 0x041039aa "Learn Skills" unsigned char * ++ [161] 0x041039bc "Steal" unsigned char * ++ [162] 0x041039c7 "Paralyzed" unsigned char * ++ [163] 0x041039d6 "Personality" unsigned char * ++ [164] 0x041039e7 "%s hits %s for %lu damage" unsigned char * + ++ [166] 0x04103a17 "Poison" unsigned char * ++ [167] 0x04103a23 "- The Might and Magic VII Development Team." unsigned char * ++ [168] 0x04103a54 "Points" unsigned char * ++ [169] 0x04103a60 "Three Quarter" unsigned char * ++ [170] 0x04103a73 "QSpell" unsigned char * ++ [171] 0x04103a7f "Quarter" unsigned char * ++ [172] 0x04103a8c "Quick Spell" unsigned char * ++ [173] 0x04103a9d "Quick Reference" unsigned char * ++ [174] 0x04103ab2 "Current Quests" unsigned char * ++ [175] 0x04103ac6 "%s inflicts %lu points killing %s" unsigned char * ++ [176] 0x04103aed "Might and Magic VII has detected an internal error and will be forced to close. Would you like us to autosave your game before closing?" unsigned char * ++ [177] 0x04103b7b "Standard" unsigned char * ++ [178] 0x04103b89 "Rent Room for %d gold" unsigned char * ++ [179] 0x04103ba4 "Repair" unsigned char * + ++ [181] 0x04103bc0 "Steal %24" unsigned char * ++ [182] 0x04103bcf "Rest" unsigned char * + ++ [184] 0x04103bf2 "Reinstall Necessary" unsigned char * ++ [185] 0x04103c0b "Steal item" unsigned char * + ++ [187] 0x04103c30 "Stolen" unsigned char * ++ [188] 0x04103c3c "Saturday" unsigned char * ++ [189] 0x04103c4a "%s shoots %s for %lu points" unsigned char * + ++ [191] 0x04103c77 "You've been banned from this shop!" unsigned char * ++ [192] 0x04103c9f "Scroll Up" unsigned char * ++ [193] 0x04103cae "Scroll Down" unsigned char * ++ [194] 0x04103cbf "Water Res" unsigned char * ++ [195] 0x04103cce "Select the Item to Buy" unsigned char * ++ [196] 0x04103cea "Select the Special Item to Buy" unsigned char * ++ [197] 0x04103d0e "Select the Item to Identify" unsigned char * ++ [198] 0x04103d2f "Select the Item to Repair" unsigned char * ++ [199] 0x04103d4e "Select the Item to Sell" unsigned char * ++ [200] 0x04103d6b "Sell" unsigned char * ++ [201] 0x04103d75 "Are you sure? Click again to start a New Game" unsigned char * ++ [202] 0x04103da9 "Air Res" unsigned char * ++ [203] 0x04103db6 "Shoot" unsigned char * ++ [204] 0x04103dc1 "Body Res" unsigned char * ++ [205] 0x04103dcf "Skills" unsigned char * ++ [206] 0x04103ddb "Skills for" unsigned char * + ++ [208] 0x04103dfd "Earth Res" unsigned char * ++ [209] 0x04103e0c "SP" unsigned char * ++ [210] 0x04103e14 "Special" unsigned char * ++ [211] 0x04103e21 "Speed" unsigned char * ++ [212] 0x04103e2c "Spell Points" unsigned char * ++ [213] 0x04103e3e "Mind Res" unsigned char * ++ [214] 0x04103e4c "Spirit" unsigned char * ++ [215] 0x04103e58 "Detect Life" unsigned char * ++ [216] 0x04103e69 "Stats" unsigned char * ++ [217] 0x04103e74 "Invisibility" unsigned char * ++ [218] 0x04103e86 "Immolation" unsigned char * ++ [219] 0x04103e96 "Day of the Gods" unsigned char * ++ [220] 0x04103eab "Stoned" unsigned char * ++ [221] 0x04103eb7 "Fate" unsigned char * ++ [222] 0x04103ec1 "Sunday" unsigned char * ++ [223] 0x00000000 unsigned char * ++ [224] 0x00000000 unsigned char * ++ [225] 0x04103ed9 "Grandmaster" unsigned char * ++ [226] 0x04103eea ""Gamma controls the relative ""brightness"" of the game. May vary depending on your monitor."" unsigned char * ++ [227] 0x04103f4e "Thursday" unsigned char * ++ [228] 0x04103f5c "Hammerhands" unsigned char * ++ [229] 0x04103f6d "Pain Reflection" unsigned char * ++ [230] 0x04103f82 "Tuesday" unsigned char * ++ [231] 0x04103f8f "Unconscious" unsigned char * ++ [232] 0x04103fa0 "Not Identified" unsigned char * ++ [233] 0x04103fb4 "Preservation" unsigned char * ++ [234] 0x04103fc6 "Regeneration" unsigned char * ++ [235] 0x04103fd8 "Temp Accuracy" unsigned char * ++ [236] 0x04103feb "Wait without healing" unsigned char * ++ [237] 0x04104005 "Wait until Dawn" unsigned char * ++ [238] 0x0410401a "Wait 5 Minutes" unsigned char * ++ [239] 0x0410402e "Wait 1 Hour" unsigned char * ++ [240] 0x0410403f "Water" unsigned char * ++ [241] 0x0410404a "Weak" unsigned char * ++ [242] 0x04104054 "Weapons" unsigned char * ++ [243] 0x04104061 "Wednesday" unsigned char * ++ [244] 0x04104070 "Withdraw" unsigned char * ++ [245] 0x0410407e "Year" unsigned char * ++ [246] 0x04104088 "Temp Endurance" unsigned char * ++ [247] 0x0410409c "Temp Intelligence" unsigned char * ++ [248] 0x041040b3 "Temp Luck" unsigned char * ++ [249] 0x041040c2 "Temp Personality" unsigned char * ++ [250] 0x041040d8 "You need %s" unsigned char * ++ [251] 0x041040e9 "Zoom In" unsigned char * ++ [252] 0x041040f6 "Zoom Out" unsigned char * + + ++ [258] 0x04104144 "Temp Speed" unsigned char * + ++ [260] 0x04104162 "Wizard" unsigned char * ++ [261] 0x0410416e "Archmage" unsigned char * + ++ [263] 0x04104189 "Crusader" unsigned char * ++ [264] 0x04104197 "Hero" unsigned char * + ++ [266] 0x041041ad "DISCARD A CARD" unsigned char * ++ [267] 0x041041c1 "Warrior Mage" unsigned char * + ++ [269] 0x041041de "Greater Druid" unsigned char * ++ [270] 0x041041f1 "Arch Druid" unsigned char * ++ [271] 0x04104201 "Staff" unsigned char * ++ [272] 0x0410420c "Sword" unsigned char * ++ [273] 0x04104217 "Dagger" unsigned char * ++ [274] 0x04104223 "Axe" unsigned char * ++ [275] 0x0410422c "Spear" unsigned char * ++ [276] 0x04104237 "Bow" unsigned char * ++ [277] 0x04104240 "Mace" unsigned char * ++ [278] 0x0410424a "Blaster" unsigned char * ++ [279] 0x04104257 "Shield" unsigned char * ++ [280] 0x04104263 "Leather" unsigned char * ++ [281] 0x04104270 "Chain" unsigned char * ++ [282] 0x0410427b "Plate" unsigned char * ++ [283] 0x04104286 "Fire Magic" unsigned char * ++ [284] 0x04104296 "Air Magic" unsigned char * ++ [285] 0x041042a5 "Water Magic" unsigned char * ++ [286] 0x041042b6 "Earth Magic" unsigned char * ++ [287] 0x041042c7 "Light Magic" unsigned char * ++ [288] 0x041042d8 "Dark Magic" unsigned char * ++ [289] 0x041042e8 "Spirit Magic" unsigned char * ++ [290] 0x041042fa "Mind Magic" unsigned char * ++ [291] 0x0410430a "Body Magic" unsigned char * ++ [292] 0x0410431a "Identify Item" unsigned char * ++ [293] 0x0410432d "Merchant" unsigned char * ++ [294] 0x0410433b "Repair Item" unsigned char * ++ [295] 0x0410434c "Body Building" unsigned char * ++ [296] 0x0410435f "Meditation" unsigned char * ++ [297] 0x0410436f "Perception" unsigned char * ++ [298] 0x0410437f "Diplomacy" unsigned char * ++ [299] 0x0410438e "Thievery" unsigned char * ++ [300] 0x0410439c "Disarm Trap" unsigned char * ++ [301] 0x041043ad "Learning" unsigned char * ++ [302] 0x041043bb "%s stole %d gold!" unsigned char * ++ [303] 0x041043d2 "Noble" unsigned char * ++ [304] 0x041043dd "Official" unsigned char * ++ [305] 0x041043eb "Peasant" unsigned char * ++ [306] 0x041043f8 "Scholar" unsigned char * + ++ [308] 0x04104410 "Smith" unsigned char * ++ [309] 0x0410441b "Armorer" unsigned char * ++ [310] 0x04104428 "Guide" unsigned char * ++ [311] 0x04104433 "Tracker" unsigned char * ++ [312] 0x04104440 "Pathfinder" unsigned char * ++ [313] 0x04104450 "Sailor" unsigned char * ++ [314] 0x0410445c "Navigator" unsigned char * ++ [315] 0x0410446b "Expert Healer" unsigned char * ++ [316] 0x0410447e "Master Healer" unsigned char * ++ [317] 0x04104491 "Teacher" unsigned char * ++ [318] 0x0410449e "Arms Master" unsigned char * ++ [319] 0x041044af "Weapons Master" unsigned char * ++ [320] 0x041044c3 "Apprentice" unsigned char * ++ [321] 0x041044d3 "Mystic" unsigned char * ++ [322] 0x041044df "Spell Master" unsigned char * ++ [323] 0x041044f1 "Trader" unsigned char * ++ [324] 0x041044fd "Scout" unsigned char * ++ [325] 0x04104508 "Counselor" unsigned char * ++ [326] 0x04104517 "Barrister" unsigned char * ++ [327] 0x04104526 "Tinker" unsigned char * ++ [328] 0x04104532 "Locksmith" unsigned char * ++ [329] 0x04104541 "Fool" unsigned char * ++ [330] 0x0410454b "Chimney Sweep" unsigned char * ++ [331] 0x0410455e "Porter" unsigned char * ++ [332] 0x0410456a "Quarter Master" unsigned char * ++ [333] 0x0410457e "Factor" unsigned char * ++ [334] 0x0410458a "Banker" unsigned char * ++ [335] 0x04104596 "Cook" unsigned char * ++ [336] 0x041045a0 "Chef" unsigned char * ++ [337] 0x041045aa "Horseman" unsigned char * ++ [338] 0x041045b8 "Bard" unsigned char * ++ [339] 0x041045c2 "Enchanter" unsigned char * ++ [340] 0x041045d1 "Cartographer" unsigned char * ++ [341] 0x041045e3 "Wind Master" unsigned char * ++ [342] 0x041045f4 "Water Master" unsigned char * ++ [343] 0x04104606 "Gate Master" unsigned char * ++ [344] 0x04104617 "Acolyte" unsigned char * ++ [345] 0x04104624 "Piper" unsigned char * ++ [346] 0x0410462f "Explorer" unsigned char * ++ [347] 0x0410463d "Pirate" unsigned char * ++ [348] 0x04104649 "Squire" unsigned char * ++ [349] 0x04104655 "Psychic" unsigned char * ++ [350] 0x04104662 "Gypsy" unsigned char * ++ [351] 0x0410466d "Negotiator" unsigned char * ++ [352] 0x0410467d "Duper" unsigned char * ++ [353] 0x04104688 "Burglar" unsigned char * ++ [354] 0x04104695 "Serf" unsigned char * ++ [355] 0x0410469f "Tailor" unsigned char * ++ [356] 0x041046ab "Laborer" unsigned char * ++ [357] 0x041046b8 "Farmer" unsigned char * ++ [358] 0x041046c4 "Cooper" unsigned char * ++ [359] 0x041046d0 "Potter" unsigned char * ++ [360] 0x041046dc "Weaver" unsigned char * ++ [361] 0x041046e8 "Cobbler" unsigned char * ++ [362] 0x041046f5 "Ditch Digger" unsigned char * ++ [363] 0x04104707 "Miller" unsigned char * ++ [364] 0x04104713 "Carpenter" unsigned char * ++ [365] 0x04104722 "Stone Cutter" unsigned char * ++ [366] 0x04104734 "Jester" unsigned char * ++ [367] 0x04104740 "Trapper" unsigned char * ++ [368] 0x0410474d "Beggar" unsigned char * ++ [369] 0x04104759 "Rustler" unsigned char * ++ [370] 0x04104766 "Hunter" unsigned char * ++ [371] 0x04104772 "Scribe" unsigned char * ++ [372] 0x0410477e "Missionary" unsigned char * ++ [373] 0x0410478e "Follower of Baa" unsigned char * ++ [374] 0x041047a3 "Gambler" unsigned char * + ++ [376] 0x041047c0 "%s was caught stealing!" unsigned char * ++ [377] 0x041047dd "%s failed to steal anything!" unsigned char * ++ [378] 0x041047ff ""%s %d, %d"" unsigned char * + ++ [380] 0x0410481b "You already know the %s spell" unsigned char * ++ [381] 0x0410483e "You don't have the skill to learn %s" unsigned char * ++ [382] 0x04104868 "That player is %s" unsigned char * ++ [383] 0x0410487f "his" unsigned char * ++ [384] 0x04104888 "her" unsigned char * ++ [385] 0x04104891 "sir" unsigned char * ++ [386] 0x0410489a "Sir" unsigned char * ++ [387] 0x041048a3 "lady" unsigned char * ++ [388] 0x041048ad "Lord" unsigned char * ++ [389] 0x041048b7 "Lady" unsigned char * ++ [390] 0x041048c1 "brother" unsigned char * ++ [391] 0x041048ce "sister" unsigned char * + ++ [393] 0x041048ea "daughter" unsigned char * ++ [394] 0x041048f8 "Unknown" unsigned char * ++ [395] 0x04104905 "morning" unsigned char * ++ [396] 0x04104912 "day" unsigned char * ++ [397] 0x0410491b "evening" unsigned char * ++ [398] 0x04104928 "Have a Drink" unsigned char * + ++ [400] 0x04104947 "Buy Spells" unsigned char * ++ [401] 0x04104957 "Skill Cost: %lu" unsigned char * + ++ [403] 0x0410497a "You already know the %s skill" unsigned char * + ++ [406] 0x041049c9 "Hire" unsigned char * ++ [407] 0x041049d3 "More Information" unsigned char * ++ [408] 0x041049e9 "Dismiss %s" unsigned char * ++ [409] 0x041049f9 "Do you wish to leave %s?" unsigned char * ++ [410] 0x04104a17 "Leave %s" unsigned char * + ++ [412] 0x04104a33 "Create Party cannot be completed unless you have assigned all characters 2 extra skills and have spent all of your bonus points." unsigned char * ++ [413] 0x04104ab9 "You can't spend more than 50 points." unsigned char * ++ [414] 0x04104ae3 "This place is open from %d%s to %d%s" unsigned char * ++ [415] 0x04104b0d "January" unsigned char * ++ [416] 0x04104b1a "February" unsigned char * ++ [417] 0x04104b28 "March" unsigned char * ++ [418] 0x04104b33 "April" unsigned char * ++ [419] 0x04104b3e "May" unsigned char * ++ [420] 0x04104b47 "June" unsigned char * ++ [421] 0x04104b51 "July" unsigned char * ++ [422] 0x04104b5b "August" unsigned char * ++ [423] 0x04104b67 "September" unsigned char * ++ [424] 0x04104b76 "October" unsigned char * ++ [425] 0x04104b83 "November" unsigned char * ++ [426] 0x04104b91 "December" unsigned char * + ++ [428] 0x04104bc0 "Spell failed" unsigned char * + ++ [430] 0x04104be1 "%s is now Level %lu and has earned %lu Skill Points!" unsigned char * + + ++ [435] 0x04104c4a "Converse with %s" unsigned char * ++ [436] 0x04104c60 "Minutes" unsigned char * ++ [437] 0x04104c6d "Minute" unsigned char * ++ [438] 0x04104c79 "Seconds" unsigned char * ++ [439] 0x04104c86 "Second" unsigned char * ++ [440] 0x04104c92 "Heroism" unsigned char * ++ [441] 0x04104c9f "Haste" unsigned char * ++ [442] 0x04104caa "Stoneskin" unsigned char * ++ [443] 0x04104cb9 "Bless" unsigned char * ++ [444] 0x04104cc4 "Ooops!" unsigned char * ++ [445] 0x04104cd0 "Lucky Day" unsigned char * ++ [446] 0x04104cdf "Identify Failed" unsigned char * ++ [447] 0x04104cf4 "Precision" unsigned char * ++ [448] 0x04104d03 "Repair Failed" unsigned char * ++ [449] 0x04104d16 "Power" unsigned char * ++ [450] 0x04104d21 "Active Spells: %s" unsigned char * ++ [451] 0x04104d38 "Active Party Spells" unsigned char * ++ [452] 0x04104d51 "Torch Light" unsigned char * ++ [453] 0x04104d62 "Wizard Eye" unsigned char * ++ [454] 0x04104d72 "Feather Fall" unsigned char * ++ [455] 0x04104d84 "Fly" unsigned char * ++ [456] 0x04104d8d "Water Walk" unsigned char * ++ [457] 0x04104d9d "Guardian" unsigned char * ++ [458] 0x04104dab "Prot Fire" unsigned char * ++ [459] 0x04104dba "Prot Elec" unsigned char * ++ [460] 0x04104dc9 "Prot Cold" unsigned char * ++ [461] 0x04104dd8 "Prot Poison" unsigned char * ++ [462] 0x04104de9 "Prot Magic" unsigned char * ++ [463] 0x04104df9 "Type: %s" unsigned char * ++ [464] 0x04104e07 "Charges" unsigned char * ++ [465] 0x04104e14 "Value" unsigned char * ++ [466] 0x04104e1f "You found %lu gold (followers take %lu)!" unsigned char * ++ [467] 0x04104e4d "You found %lu gold!" unsigned char * ++ [468] 0x04104e66 "Clicking here will spend %d Skill Points" unsigned char * ++ [469] 0x04104e94 "You need %d more Skill Points to advance here" unsigned char * ++ [470] 0x04104ec7 "Get %s" unsigned char * ++ [471] 0x04104ed3 "You found an item (%s)!" unsigned char * ++ [472] 0x04104ef0 "am" unsigned char * ++ [473] 0x04104ef8 "pm" unsigned char * ++ [474] 0x04104f00 "Recall to %s" unsigned char * ++ [475] 0x04104f12 "Set %s over %s" unsigned char * ++ [476] 0x04104f26 "Set to %s" unsigned char * ++ [477] 0x04104f35 "You are already resting!" unsigned char * ++ [478] 0x04104f53 "You can't rest in turn-based mode!" unsigned char * ++ [479] 0x04104f7b "You can't rest here!" unsigned char * ++ [480] 0x04104f95 "There are hostile enemies near!" unsigned char * ++ [481] 0x04104fba "Encounter!" unsigned char * ++ [482] 0x04104fca "You don't have enough food to rest" unsigned char * ++ [483] 0x04104ff2 "Set %s as the Ready Spell" unsigned char * ++ [484] 0x04105011 "Select a spell then click here to set a QuickSpell" unsigned char * ++ [485] 0x04105049 "Cast %s" unsigned char * ++ [486] 0x04105056 "Select %s" unsigned char * ++ [487] 0x04105065 "You have already mastered this skill!" unsigned char * ++ [488] 0x04105090 "You don't have enough skill points!" unsigned char * ++ [489] 0x041050b9 ""You have %d total gold, %d in the Bank"" unsigned char * ++ [490] 0x041050e7 "You found %d gold and an item (%s)!" unsigned char * ++ [491] 0x04105110 "Can't cast Meteor Shower indoors!" unsigned char * ++ [492] 0x04105137 "Can't cast Inferno outdoors!" unsigned char * ++ [493] 0x04105159 "Can't cast Jump while airborne! " unsigned char * ++ [494] 0x0410517f "Can not cast Fly indoors!" unsigned char * ++ [495] 0x0410519e "Can't cast Starburst indoors!" unsigned char * ++ [496] 0x041051c1 "No valid target exists! " unsigned char * ++ [497] 0x041051df "Can't cast Prismatic Light outdoors!" unsigned char * ++ [498] 0x04105209 "Herbalist" unsigned char * ++ [499] 0x04105218 "Can't cast Armageddon indoors!" unsigned char * ++ [500] 0x0410523c "You have %lu gold" unsigned char * ++ [501] 0x04105253 "You have %lu food" unsigned char * ++ [502] 0x0410526a "You find %lu food" unsigned char * ++ [503] 0x04105281 "You lose %lu gold" unsigned char * ++ [504] 0x04105298 "You lose %lu food" unsigned char * + ++ [506] 0x041052bf "Roderick" unsigned char * ++ [507] 0x041052cd "Alexis" unsigned char * ++ [508] 0x041052d9 "Serena" unsigned char * ++ [509] 0x041052e5 "Zoltan" unsigned char * + ++ [510] 0x041052f1 "Saintly" unsigned char * ++ [511] 0x041052fe "Angelic" unsigned char * ++ [512] 0x0410530b "Glorious" unsigned char * ++ [513] 0x04105319 "Honorable" unsigned char * ++ [514] 0x04105328 "Respectable" unsigned char * ++ [515] 0x04105339 "Average" unsigned char * ++ [516] 0x04105346 "Bad" unsigned char * ++ [517] 0x0410534f "Vile" unsigned char * ++ [518] 0x04105359 "Despicable" unsigned char * ++ [519] 0x04105369 "Monstrous" unsigned char * ++ [520] 0x04105378 "Notorious" unsigned char * + + + ++ [524] 0x041053b9 "Once again you've cheated death! …" unsigned char * ++ [525] 0x041053e1 "Apothecary" unsigned char * + ++ [527] 0x041053fb "Thank You!" unsigned char * ++ [528] 0x0410540b "I can offer you nothing further." unsigned char * ++ [529] 0x04105431 ""Sorry, but we are unable to train you."" unsigned char * ++ [530] 0x0410545f "Moon" unsigned char * ++ [531] 0x04105469 "Location" unsigned char * ++ [532] 0x04105477 "Please try back in " unsigned char * ++ [533] 0x04105490 ""I cannot join you, you're party is full"" unsigned char * ++ [534] 0x041054bf "Become %s in %s for %lu gold" unsigned char * ++ [535] 0x041054e1 "Learn" unsigned char * ++ [536] 0x041054ec ""With your skills, you should be working here as a teacher."" unsigned char * ++ [537] 0x0410552e "Train to level %d for %d gold" unsigned char * + ++ [539] 0x04105587 "Buy Items" unsigned char * ++ [540] 0x04105596 "Sell Items" unsigned char * + ++ [542] 0x041055ba "Repair Items" unsigned char * ++ [543] 0x041055cc "Special Items" unsigned char * ++ [544] 0x041055df "Seek knowledge elsewhere %s the %s" unsigned char * ++ [545] 0x04105607 "Castle Ironfist" unsigned char * ++ [546] 0x0410561c "New Sorpigal" unsigned char * ++ [547] 0x0410562e "Free Haven" unsigned char * ++ [548] 0x0410563e "Arena" unsigned char * ++ [549] 0x04105649 "Blackshire" unsigned char * ++ [550] 0x04105659 "Kriegspire" unsigned char * ++ [551] 0x04105669 "White Cap" unsigned char * ++ [552] 0x04105678 "Silver Cove" unsigned char * ++ [553] 0x04105689 "Darkmoor" unsigned char * ++ [554] 0x04105697 "Mist" unsigned char * ++ [555] 0x041056a1 "Bootleg Bay West" unsigned char * ++ [556] 0x041056b7 "Volcano" unsigned char * ++ [557] 0x041056c4 "Hermit's Isle" unsigned char * ++ [558] 0x041056d7 "Child" unsigned char * ++ [559] 0x041056e2 "Island North" unsigned char * ++ [560] 0x041056f4 "Island South" unsigned char * ++ [561] 0x04105706 ""Sorry, come back another day"" unsigned char * ++ [562] 0x0410572a "do anything" unsigned char * ++ [563] 0x0410573b "Pack is Full!" unsigned char * ++ [564] 0x0410574e "Hic..." unsigned char * ++ [565] 0x0410575a "Have a Drink first..." unsigned char * + ++ [568] 0x0410578a "Club" unsigned char * ++ [569] 0x04105794 "Done!" unsigned char * ++ [570] 0x0410579f "Good as New!" unsigned char * ++ [571] 0x041057b1 "Ready Spell: %s" unsigned char * ++ [572] 0x041057c6 "Scroll Left" unsigned char * ++ [573] 0x041057d7 "Scroll Right" unsigned char * ++ [574] 0x041057e9 ""Welcome to the Arena of Life and Death. Remember, you are only allowed one arena combat per visit. To fight an arena battle, select the option that best describes your abilities and return to me- if you survive…"" unsigned char * ++ [575] 0x041058c6 "Please wait while I summon the monsters. Good luck." unsigned char * ++ [576] 0x04105900 "Congratulations on your win… here's your stuff… %u gold." unsigned char * ++ [577] 0x0410593e "Get back in there you wimps…" unsigned char * ++ [578] 0x04105960 "Page" unsigned char * ++ [579] 0x0410596a "Squire" unsigned char * ++ [580] 0x04105976 "Knight" unsigned char * ++ [581] 0x04105982 "Lord" unsigned char * ++ [582] 0x0410598c "You already won this trip to the Arena…" unsigned char * + ++ [584] 0x041059d5 "Click here to remove your Quick Spell" unsigned char * ++ [585] 0x04105a00 "Item is not of high enough quality" unsigned char * ++ [586] 0x04105a28 "Not enough spell points" unsigned char * ++ [587] 0x04105a45 "Attack Bonus" unsigned char * ++ [588] 0x04105a57 "Attack Damage" unsigned char * ++ [589] 0x04105a6a "Shoot Bonus" unsigned char * ++ [590] 0x04105a7b "Shoot Damage" unsigned char * ++ [591] 0x04105a8d "Charmed" unsigned char * ++ [592] 0x04105a9a "Shrunk" unsigned char * ++ [593] 0x04105aa6 "Slowed" unsigned char * ++ [594] 0x04105ab2 "Feebleminded" unsigned char * ++ [595] 0x04105ac4 "Wand" unsigned char * ++ [596] 0x04105ace "Chaplain" unsigned char * ++ [597] 0x04105adc "Diplomat" unsigned char * ++ [598] 0x04105aea "Fallen Wizard" unsigned char * ++ [599] 0x04105afd "Prelate" unsigned char * ++ [600] 0x04105b0a "Sage" unsigned char * ++ [601] 0x04105b14 "Zombie" unsigned char * ++ [602] 0x04105b20 "History" unsigned char * ++ [603] 0x04105b2d "Pay Fine" unsigned char * ++ [604] 0x04105b3b "Bounty Hunt" unsigned char * ++ [605] 0x04105b4c "Current Fine" unsigned char * ++ [606] 0x04105b5e "Pay" unsigned char * ++ [607] 0x04105b67 "Enslaved" unsigned char * ++ [608] 0x04105b75 "Berserk" unsigned char * ++ [609] 0x04105b82 "Hour of Power" unsigned char * ++ [610] 0x04105b95 "Day of Protection" unsigned char * ++ [611] 0x04105bac "Play ArcoMage" unsigned char * ++ [612] 0x04105bbf "Save game corrupted! Code=%d" unsigned char * + ++ [614] 0x04105bf4 "New Game" unsigned char * ++ [615] 0x04105c02 "Save Game" unsigned char * ++ [616] 0x04105c11 "Load Game" unsigned char * ++ [617] 0x04105c20 ""Sound, Keyboard, Game Options…"" unsigned char * ++ [618] 0x04105c46 "Quit" unsigned char * ++ [619] 0x04105c50 "Return to Game" unsigned char * ++ [620] 0x04105c64 "Rules" unsigned char * ++ [621] 0x04105c6f "Play" unsigned char * ++ [622] 0x04105c79 "Victory Conditions" unsigned char * + ++ [624] 0x04105c9c "Physical" unsigned char * ++ [625] 0x04105caa "Immune" unsigned char * ++ [626] 0x04105cb6 "Resistances" unsigned char * ++ [627] 0x04105cc7 "Resistant" unsigned char * ++ [628] 0x04105cd6 "Spell" unsigned char * ++ [629] 0x04105ce1 "Spells" unsigned char * ++ [630] 0x04105ced "?" unsigned char * ++ [631] 0x04105cf4 "Effects" unsigned char * ++ [632] 0x04105d01 "This skill level can not be learned by the %s class." unsigned char * ++ [633] 0x04105d3b "You have to be promoted to %s to learn this skill level." unsigned char * ++ [634] 0x04105d79 "You have to be promoted to %s or %s to learn this skill level." unsigned char * ++ [635] 0x04105dbd "%s stuns %s" unsigned char * ++ [636] 0x04105dce "%s paralyzes %s" unsigned char * ++ [637] 0x04105de3 "%s evades damage" unsigned char * ++ [638] 0x04105df9 "There are hostile creatures nearby!" unsigned char * ++ [639] 0x04105e22 "A tie!" unsigned char * ++ [640] 0x04105e2e "You won!" unsigned char * ++ [641] 0x04105e3c "You lost!" unsigned char * ++ [642] 0x04105e4b "Error" unsigned char * ++ [643] 0x04105e56 "by a Tower Building Victory!" unsigned char * ++ [644] 0x04105e78 "by Wall Building due to a Tower Building Tie!" unsigned char * ++ [645] 0x04105eab "by a Tower Destruction Victory!" unsigned char * ++ [646] 0x04105ed0 "by a Resource Victory!" unsigned char * ++ [647] 0x04105eec "by a Resource Victory due to a Tower & Wall Building Tie!" unsigned char * ++ [648] 0x04105f2b "This character can't summon any more monsters!" unsigned char * ++ [649] 0x04105f5f "Summoned" unsigned char * ++ [650] 0x04105f6d "Current Hit Points" unsigned char * ++ [651] 0x04105f85 "Hardened" unsigned char * ++ [652] 0x04105f93 "You can not do that while you are underwater!" unsigned char * ++ [653] 0x04105fc6 "Food" unsigned char * ++ [654] 0x04105fd0 "%s's Jar" unsigned char * ++ [655] 0x04105fde "%s' Jar" unsigned char * + ++ [657] 0x04105ffc "Water Breathing" unsigned char * ++ [658] 0x04106011 "Collect Prize" unsigned char * ++ [659] 0x04106024 "x: %d y: %d" unsigned char * ++ [660] 0x04106036 "You are drowning!" unsigned char * ++ [661] 0x0410604d "You are burning!" unsigned char * ++ [662] 0x04106063 "Instructors" unsigned char * ++ [663] 0x04106074 "It will take %d day to cross to %s." unsigned char * ++ [664] 0x0410609d "Click here to accept this party and continue to the game." unsigned char * ++ [665] 0x041060dc "Ok Button" unsigned char * ++ [666] 0x041060eb "Clears all party stats and skills." unsigned char * ++ [667] 0x04106113 "Clear Button" unsigned char * ++ [668] 0x04106125 "Subtract" unsigned char * ++ [669] 0x04106133 ""Subtracts a point from the highlighted skill, returning it to the bonus pool"" unsigned char * ++ [670] 0x04106187 "Add" unsigned char * ++ [671] 0x04106190 ""Adds a point from the highlighted skill, taking it from the bonus pool"" unsigned char * ++ [672] 0x041061de ""For your numerous crimes and evil deeds, you have been sentenced to one year in prison."" unsigned char * ++ [673] 0x0410623d "You have an outstanding fine of %lu gold. Pay your fine now or be sentenced to jail for 1 year?" unsigned char * ++ [674] 0x041062a3 "Temp Might" unsigned char * ++ [675] 0x041062b3 ""Splendid job! With the activation of the Gate, a thousand worlds lie at your feet. Perhaps on one of them you will find the Ancients themselves, and return with the fruits their great civilization has to offer your world and your kingdom."" unsigned char * ++ [676] 0x041063ab ""Brilliant! The completion of the Heavenly Forge has provided enough Ancient weapons to crush all resistance to your plans. Soon the world will bow to your every whim! Still, you can't help but wonder what was beyond the Gate the other side was trying so hard to build."" unsigned char * + */ \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 ErrorHandling.h --- a/ErrorHandling.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -#define _CRT_NON_CONFORMING_SWPRINTFS -#pragma once - -#define Error(format, ...) Error_impl_(__FILE__, __FUNCTION__, __LINE__, format, __VA_ARGS__) -#define Assert(condition, ...) Assert_impl_(__FILE__, __FUNCTION__, __LINE__, condition, #condition, __VA_ARGS__) - - - -#include -#include -inline __declspec(noreturn) void Error_impl_(const char *filename, const char *functionname, int line, - const char *format, ...) -{ - va_list va; - va_start(va, format); - { - char header[4096]; - sprintf(header, "Error in %s: %u\n\t%s\n\n", filename, line, functionname); - - char msg_body[8192]; - vsprintf(msg_body, format, va); - - wchar_t msg[sizeof(header) + sizeof(msg_body)]; - swprintf(msg, 8192, L"%S %S", header, msg_body); - - extern void MsgBox(const wchar_t *, const wchar_t *); - MsgBox(msg, L"Error"); - } - va_end(va); - - #ifndef NODEBUG - __debugbreak(); - #endif - exit(0); -} - - -inline void Assert_impl_(const char *filename, const char *functionname, int line, - bool condition, const char *condition_string, const char *format = nullptr, ...) -{ - if (condition) - return; - - va_list va; - va_start(va, format); - { - char header[4096]; - sprintf(header, "Assertion in %s: %u\n\t%s:\n%s\n\n", filename, line, functionname, condition_string); - - char msg_body[8192]; - vsprintf(msg_body, format, va); - - wchar_t msg[sizeof(header) + sizeof(msg_body)]; - if (format) - swprintf(msg, (sizeof(header) + sizeof(msg_body)), L"%S %S", header, msg_body); - else - swprintf(msg, (sizeof(header) + sizeof(msg_body)), L"%S", header); - - extern void MsgBox(const wchar_t *, const wchar_t *); - MsgBox(msg, L"Assertion"); - } - va_end(va); - - __debugbreak(); -} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Events.cpp --- a/Events.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1365 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS - -#include "ErrorHandling.h" - -#include "Engine/Graphics/Weather.h" -#include "Engine/Graphics/Texture.h" -#include "mm7_data.h" -#include "MediaPlayer.h" -#include "Mouse.h" - -#include "MapInfo.h" -#include "Game.h" -#include "Engine/Graphics/Render.h" -#include "GUIWindow.h" -#include "GUIProgressBar.h" -#include "SpriteObject.h" -#include "Chest.h" -#include "MapsLongTimer.h" -#include "LOD.h" -#include "Actor.h" -#include "Party.h" -#include "OurMath.h" -#include "AudioPlayer.h" -#include "Engine/Graphics/Indoor.h" -#include "Engine/Graphics/Viewport.h" -#include "texts.h" -#include "stru123.h" -#include "stru159.h" -#include "Events.h" -#include "Events2D.h" -#include "UI\UIHouses.h" -#include "MM7.h" -#include "Engine/Graphics/Level/Decoration.h" -#include "LuaVM.h" -#include "Log.h" -#include "Engine/Graphics/DecorationList.h" - - -std::array pSomeOtherEVT_Events; -signed int uSomeOtherEVT_NumEvents; -char *pSomeOtherEVT; -std::array pSomeEVT_Events; -signed int uSomeEVT_NumEvents; -char *pSomeEVT; - -unsigned int uGlobalEVT_NumEvents; -unsigned int uGlobalEVT_Size; -std::array pGlobalEVT; -std::array pGlobalEVT_Index; - -std::array pLevelStrOffsets; -unsigned int uLevelStrNumStrings; -unsigned int uLevelStrFileSize; -signed int uLevelEVT_NumEvents; -unsigned int uLevelEVT_Size; -std::array pLevelStr; -std::array pLevelEVT; -std::array pLevelEVT_Index; - -_2devent p2DEvents[525]; - - - -//----- (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 - - ptr = pEvents_LOD->LoadRaw(pContainerName, 0); - pLodFile = pEvents_LOD->FindContainer(pContainerName, 0); - if ( !pLodFile ) - Error("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 ) - Error("File %s Size %lu - Buffer size %lu", pContainerName, uTextureSize, uBufferSize); - - memcpy(pBuffer, ptr, uTextureSize); - free(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; - - current_hdr=(raw_event_header *)&pGlobalEVT[offset_in]; - } - uGlobalEVT_NumEvents = events_count; - - assert(uGlobalEVT_NumEvents < 4400); -} - - - -//----- (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; - - if (!uLevelEVT_Size) - return; - - memset(MapsLongTimersList, 0, 3200); - memset(pLevelEVT_Index.data(), 80, sizeof(EventIndex)*4400); - - uLevelEVT_NumEvents = 0; - MapsLongTimers_count = 0; - - current_hdr=(raw_event_header *)pLevelEVT.data(); - offset_in=0; - for (events_count = 0, offset_in = 0; offset_in < uLevelEVT_Size; ++events_count) - { - 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; - offset_in+=current_hdr->evt_size+1; - - current_hdr=(raw_event_header *)&pLevelEVT[offset_in]; - } - uLevelEVT_NumEvents = events_count; - -/* -EmeraldIsle::Variables: -[0] ??? -[1] ??? -[2] Luck Fountain uses left -[3] Gold Fountain used this week -[4] Gold Fountain total uses - - -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 - - - -Emerald Isle #111 // ??? - 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 - } - } - -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 - -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 #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 -*/ - } - - -//----- (0044684A) -------------------------------------------------------- -void EventProcessor(int uEventID, int targetObj, int canShowMessages, int entry_line) -{ - signed int v4; // esi@7 - int v11; // eax@14 - char *v12; // eax@15 - 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 - LevelDecoration *v26; // eax@55 - int v27; // eax@57 - int pEventID; // eax@58 - int pNPC_ID; // ecx@58 - int pIndex; // esi@58 - NPCData *pNPC; // ecx@58 - int v38; // eax@78 - int v39; // ecx@78 - int v42; // eax@84 - int v43; // ecx@84 - GUIButton *v48; // ecx@93 - GUIButton *v49; // esi@94 - signed int pValue; // ebp@124 - Player *pPlayer; // esi@125 - int v83; // eax@212 - int v84; // ebp@220 - int v90; // eax@243 - const char *v91; // ecx@247 - 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 - unsigned int v102; // esi@281 - int v104; // eax@288 - int v106; // [sp-20h] [bp-4C8h]@278 - signed int v109; // [sp-14h] [bp-4BCh]@278 - signed int v110; // [sp-10h] [bp-4B8h]@278 - int curr_seq_num; // [sp+10h] [bp-498h]@4 - 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 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 - - v133 = 0; - EvtTargetObj = targetObj; - dword_5B65C4_cancelEventProcessing = 0; - if ( uEventID == 114 )//for test script - { - if (!lua->DoFile("out01.lua")) - Log::Warning(L"Error opening out01.lua\n"); - Log::Warning(L"being tested that well\n"); - return; - } - 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); - } - - for ( v4 = 0; v4 < uSomeEVT_NumEvents; ++v4 ) - { - if ( dword_5B65C4_cancelEventProcessing ) - { - if ( v133 == 1 ) - OnMapLeave(); - return; - } - if ( pSomeEVT_Events[v4].uEventID == uEventID && pSomeEVT_Events[v4].event_sequence_num == curr_seq_num ) - { - _evt_raw * _evt = (_evt_raw *)(pSomeEVT + pSomeEVT_Events[v4].uEventOffsetInEVT); - - switch (_evt->_e_type) - { - case EVENT_CheckSeason: - if ( !sub_4465DF_check_season(_evt->v5) ) - { - ++curr_seq_num; - //v4 = v124; - break; - } - v4 = -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 (pMediaPlayer->bPlaying_Movie) - pMediaPlayer->Unload(); - pMediaPlayer->bStopBeforeSchedule = 0; -// pMediaPlayer->pResetflag = 0; - - v128 = pCurrentScreen; - strcpy(Str, Source); - v16 = RemoveQuotes(Str); - pMediaPlayer->FullscreenMovieLoop(v16, 0/*, _evt->v5*/); - if ( !_stricmp(v16, "arbiter good") ) - { - pParty->alignment = PartyAlignment_Good; - v18 = 0; - LOBYTE(v17) = 1; - SetUserInterface(PartyAlignment_Good, v17); - if ( !_evt->v6 || v128 == 3 ) - { - pCurrentScreen = v128; - if ( v128 == 3 ) - pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; - if ( v128 == 13 ) - pMediaPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); - } - ++curr_seq_num; - break; - } - if ( !_stricmp(v16, "arbiter evil") ) - { - v18 = 2; - pParty->alignment = PartyAlignment_Evil; - LOBYTE(v17) = 1; - SetUserInterface(PartyAlignment_Evil, v17); - if ( !_evt->v6 || v128 == 3 ) - { - pCurrentScreen = v128; - if ( v128 == 3 ) - pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; - if ( v128 == 13 ) - pMediaPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1); - } - ++curr_seq_num; - break; - } - if ( !_stricmp(v16, "pcout01") ) // moving to harmondale from emerald isle - { - Rest(0x2760u); - pParty->RestAndHeal(); - pParty->days_played_without_rest = 0; - } - if ( !_evt->v6 || v128 == 3 ) - { - pCurrentScreen = v128; - if ( v128 == 3 ) - pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; - if ( v128 == 13 ) - pMediaPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1); - } - ++curr_seq_num; - } - 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; - break; - } - } - curr_seq_num = _evt->v11 - 1; - ++curr_seq_num; - break; - } -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) ) - { - curr_seq_num = _evt->v11 - 1; - ++curr_seq_num; - break; - } - ++curr_seq_num; - } - 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; - break; - case EVENT_ChangeEvent: - if ( EVT_DWORD(_evt->v5) ) - stru_5E4C90_MapPersistVars._decor_events[activeLevelDecoration->_idx_in_stru123] = _evt->v5 - 124; - else - { - v26 = (LevelDecoration *)activeLevelDecoration; - stru_5E4C90_MapPersistVars._decor_events[activeLevelDecoration ->_idx_in_stru123] = 0; - v26->uFlags |= LEVEL_DECORATION_INVISIBLE; - } - ++curr_seq_num; - - 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; - break; - case EVENT_SetNPCTopic: - { - //v29 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); - pEventID = _evt->v10 + ((_evt->v11 + ((_evt->v12 + ((uint)_evt->v13 << 8)) << 8)) << 8); - pNPC_ID = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); - pIndex = _evt->v9; - pNPC = &pNPCStats->pNewNPCData[pNPC_ID]; - if ( pIndex == 0 ) - pNPC->evt_A = pEventID; - if ( pIndex == 1 ) - pNPC->evt_B = pEventID; - if ( pIndex == 2 ) - pNPC->evt_C = pEventID; - if ( pIndex == 3 ) - pNPC->evt_D = pEventID; - if ( pIndex == 4 ) - pNPC->evt_E = pEventID; - if ( pIndex == 5 ) - pNPC->evt_F = pEventID; - if ( pNPC_ID == 8 ) - { - if ( pEventID == 78 ) - { - HouseDialogPressCloseBtn(); - window_SpeakInHouse->Release(); - pParty->uFlags &= ~2; - if ( EnterHouse(HOUSE_DARK_GUILD_PIT) ) - { - pAudioPlayer->StopChannels(-1, -1); - window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 170, 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); - current_npc_text = pNPCTopics[90].pText; - } - } - } - ++curr_seq_num; - } - break; - case EVENT_NPCSetItem: - sub_448518_npc_set_item(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); - ++curr_seq_num; - break; - case EVENT_SetActorItem: - Actor::GiveItem(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); - ++curr_seq_num; - 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; - 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; - 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); - __debugbreak(); - for ( uint actor_id = 0; actor_id < uNumActors; actor_id++ ) - { - if ( pActors[actor_id].uGroup == v38 ) - pActors[actor_id].uGroup = v39; - } - ++curr_seq_num; - 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); - __debugbreak(); - for ( uint actor_id = 0; actor_id < uNumActors; actor_id++ ) - { - if ( pActors[actor_id].uGroup == v42 ) - pActors[actor_id].uAlly = v43; - } - ++curr_seq_num; - break; - case EVENT_MoveNPC: - { - pNPCStats->pNewNPCData[EVT_DWORD(_evt->v5)].Location2D =EVT_DWORD(_evt->v9); - if ( window_SpeakInHouse ) - { - - if ( window_SpeakInHouse->par1C == 165 ) - { - HouseDialogPressCloseBtn(); - pMediaPlayer->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, window->GetWidth(), window->GetHeight(), WINDOW_HouseInterior, 165, 0); - v48 = window_SpeakInHouse->pControlsHead; - if ( window_SpeakInHouse->pControlsHead ) - { - do - { - v49 = v48->pNext; - free(v48); - v48 = v49; - } - while ( v49 ); - } - window_SpeakInHouse->pControlsHead = 0; - window_SpeakInHouse->pControlsTail = 0; - window_SpeakInHouse->uNumControls = 0; - } - } - else - { - if ( window_SpeakInHouse->par1C == 553 ) - pMediaPlayer->bLoopPlaying = 0; - } - } - - } - ++curr_seq_num; - 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; - break; - case EVENT_CharacterAnimation: - if ( _evt->v5 <= 3 ) //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; - break; - case EVENT_ForPartyMember: - player_choose = _evt->v5; - ++curr_seq_num; - break; - case EVENT_SummonItem: - SpriteObject::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; - 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 + 1]->CompareVariable((enum VariableType)EVT_WORD(_evt->v5), pValue) ) - { - // v124 = -1; - curr_seq_num = _evt->v11 - 1; - } - } - ++curr_seq_num; - v4 = -1; - 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 = -1; - 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.data(); - for ( v65 = 0; v65 < 126; ++v65 ) - { - v67 = &pPlayers[uActiveCharacter]->pInventoryMatrix[v65]; - if ( v67 > 0 ) - { - if ( pPlayers[uActiveCharacter]->pInventoryItemList[v67 - 1].uItemID == pValue ) - { - pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v65); - //++curr_seq_num; - //v4 = v124; - goto substract; - } - } - //v67 += 4; - } - //while ( (signed int)v65 < 126 ); - //v69 = (int)&pPlayers[uActiveCharacter]->pEquipment.pIndices; - for ( v68 = 0; v68 < 16; ++v68 ) - { - if ( pPlayers[uActiveCharacter]->pInventoryItemList[pPlayers[uActiveCharacter]->pEquipment.pIndices[v68]].uItemID == pValue ) - { - pPlayers[uActiveCharacter]->pEquipment.pIndices[v68] = 0; - //++curr_seq_num; - //v4 = v124; - goto substract; - } - //v69 += 4; - } - for (int i = 1; i < 5; i++) - { - //v72 = (int)pPlayers[i]->pInventoryMatrix.data(); - for ( int v71 = 0; v71 < 126; ++v71 ) - { - v72 = &pPlayers[i]->pInventoryMatrix[v71]; - if ( v72 > 0 ) - { - if ( pPlayers[i]->pInventoryItemList[v72 - 1].uItemID == pValue ) - { - pPlayers[i]->RemoveItemAtInventoryIndex(v71); - goto substract; - } - } - //v72 += 4; - } - for ( v73 = 0; v73 < 16; ++v73 ) - { - //v74 = (int)&pPlayers[i]->pEquipment; - if (pPlayers[i]->pEquipment.pIndices[v73]) - { - if (pPlayers[i]->pInventoryItemList[pPlayers[i]->pEquipment.pIndices[v73] - 1].uItemID == pValue ) - { - pPlayers[i]->pEquipment.pIndices[v73] = 0; - //v74 += 4; - goto substract; - } - } - } - } - }*/ - if ( player_choose <= 3 ) - pParty->pPlayers[player_choose].SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - else if ( player_choose == 4 ) //active - { - if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } - else if ( player_choose == 5 )//all - { - for(int i = 1; i < 5; ++i) - pPlayers[i]->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } - else if ( player_choose == 6 ) //random - pParty->pPlayers[rand() % 4].SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - ++curr_seq_num; - break; - case EVENT_Set: - pValue = EVT_DWORD(_evt->v7); - if ( player_choose <= 3 ) - pParty->pPlayers[player_choose].SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - else if ( player_choose == 4 ) //active - { - if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->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); - } - else if ( player_choose == 6 ) //random - pParty->pPlayers[rand() % 4].SetVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - ++curr_seq_num; - 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 ) - pPlayers[uActiveCharacter]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } - else if ( player_choose == 5 )//all - { - for(int i = 1; i < 5; ++i) - pPlayers[i]->AddVariable((enum VariableType)EVT_WORD(_evt->v5), pValue); - } - else if ( player_choose == 6 ) //random - pParty->pPlayers[rand() % 4].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 ) - { - //__debugbreak(); // bonfire - viewparams->bRedrawGameUI = true; - } - ++curr_seq_num; - break; - case EVENT_InputString: - if ( !entry_line ) - { - strcpy(GameUI_Footer_TimedString.data(), &pLevelStr[pLevelStrOffsets[EVT_DWORD(_evt->v5 )]]); - sub_4451A8_press_any_key(uEventID, curr_seq_num, 26); - 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; - curr_seq_num = v11 - 1; - } - ++curr_seq_num; - v4 = -1; - 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 = -1; - break; - case EVENT_ReceiveDamage: - if ( (unsigned __int8)_evt->v5 <= 3 ) - { - pParty->pPlayers[(unsigned __int8)_evt->v5].ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); - ++curr_seq_num; - break; - } - if ( _evt->v5 == 4 ) - { - if ( !uActiveCharacter ) - { - ++curr_seq_num; - break; - } - pPlayers[uActiveCharacter]->ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); - ++curr_seq_num; - break; - } - if ( _evt->v5 != 5 ) - { - pParty->pPlayers[rand() % 4].ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); - ++curr_seq_num; - break; - } - for ( uint pl_id = 0;pl_id < 4; pl_id++ ) - pParty->pPlayers[pl_id].ReceiveDamage(EVT_DWORD(_evt->v7 ), (DAMAGE_TYPE)_evt->v6); - ++curr_seq_num; - break; - case EVENT_ToggleIndoorLight: - pIndoor->ToggleLight(EVT_DWORD(_evt->v5 ), _evt->v9); - ++curr_seq_num; - break; - case EVENT_SetFacesBit: - sub_44892E_set_faces_bit(EVT_DWORD(_evt->v5),EVT_DWORD(_evt->v9), _evt->v13); - ++curr_seq_num; - break; - case EVENT_ToggleChestFlag: - Chest::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); - ++curr_seq_num; - break; - case EVENT_ToggleActorFlag: - Actor::ToggleFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); - ++curr_seq_num; - break; - case EVENT_ToggleActorGroupFlag: - ToggleActorGroupFlag(EVT_DWORD(_evt->v5 ), EVT_DWORD(_evt->v9 ), _evt->v13); - ++curr_seq_num; - break; - case EVENT_SetSnow: - if ( !_evt->v5 ) - pWeather->bRenderSnow = _evt->v6 != 0; - ++curr_seq_num; - 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, 2); - } - } - else - { - if ( canShowMessages == 1 ) - { - v91 = &pLevelStr[pLevelStrOffsets[v90]]; - ShowStatusBarString(v91, 2); - } - } - ++curr_seq_num; - break; - case EVENT_ShowMessage: - if ( activeLevelDecoration ) - { - current_npc_text = pNPCTopics[EVT_DWORD(_evt->v5 )-1].pText;//(&dword_721664)[8 * v92]; - byte_5B0938[0] = 0; - } - else - strcpy(byte_5B0938.data(), &pLevelStr[pLevelStrOffsets[EVT_DWORD(_evt->v5 )]]); - ++curr_seq_num; - 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; - break; - case EVENT_SetTexture: - sub_44861E_set_texture(EVT_DWORD(_evt->v5 ), (char *)&_evt->v9); - ++curr_seq_num; - break; - case EVENT_SetSprite: - SetDecorationSprite(EVT_DWORD(_evt->v5 ), _evt->v9, (char *)&_evt->v10); - ++curr_seq_num; - 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; - break; - case EVENT_MouseOver: - case EVENT_LocationName: - --curr_seq_num; - ++curr_seq_num; - break; - case EVENT_ChangeDoorState: - Door_switch_animation(_evt->v5, _evt->v6); - ++curr_seq_num; - break; - case EVENT_OpenChest: - if ( !Chest::Open(_evt->v5) ) - { - if ( v133 == 1 ) - OnMapLeave(); - return; - } - ++curr_seq_num; - 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 ) - { - pRenderer->Sub01(); - TransitionUI_Load(_evt->v29, _evt->v30, v135, v132, v126, v129, v95, v134, (char *)&_evt->v31); - dword_5C3418 = uEventID; - dword_5C341C = curr_seq_num + 1; - if ( v133 == 1 ) - OnMapLeave(); - return; - } - _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; - 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; - pAudioPlayer->PlaySound((SoundID)v106, 0, 0, -1, 0, 0, 0, 0); - } - } - else - { - pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)((activeLevelDecoration == NULL) + 1); - Transition_StopSound_Autosave(v99, MapStartPoint_Party); - v133 = 1; - if ( pCurrentScreen == SCREEN_HOUSE ) - { - if ( uGameState == GAME_STATE_CHANGE_LOCATION ) - { - pAudioPlayer->StopChannels(-1, -1); - dialog_menu_id = HOUSE_DIALOGUE_NULL; - while ( HouseDialogPressCloseBtn() ) - ; - pMediaPlayer->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; - break; - case EVENT_PlaySound: - 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); - v106 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); - pAudioPlayer->PlaySound((SoundID)v106, 0, 0, v109, v110, 0, 0, 0); - ++curr_seq_num; - break; - case EVENT_GiveItem: - item.Reset(); - 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; - break; - case EVENT_SpeakInHouse: - if ( EnterHouse((enum HOUSE_ID)EVT_DWORD(_evt->v5))) - { - pRenderer->Sub01(); - 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, window->GetWidth(), window->GetHeight(), 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; - break; - case EVENT_PressAnyKey: - sub_4451A8_press_any_key(uEventID, curr_seq_num + 1, 33); - if ( v133 == 1 ) - OnMapLeave(); - return; - case EVENT_Exit: - if ( v133 == 1 ) - OnMapLeave(); - return; - default: - ++curr_seq_num; - break; - } - } - } - if ( v133 == 1 ) - OnMapLeave(); - return; - } - -//----- (00444732) -------------------------------------------------------- -char *GetEventHintString(unsigned int uEventID) -{ - signed int event_index; // edx@1 - int event_pos; // esi@4 - char *result; // eax@6 - unsigned int str_index; // eax@9 - int i; // esi@11 - _evt_raw* test_evt; - _evt_raw* last_evt; - - 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; - event_pos = pLevelEVT_Index[event_index+1].uEventOffsetInEVT; - if ( test_evt->_e_type == EVENT_MouseOver ) - break; - } - ++event_index; - if ( event_index >= uLevelEVT_NumEvents ) - return NULL; - } - test_evt=(_evt_raw*)&pLevelEVT[event_pos]; - if ( test_evt->_e_type== EVENT_SpeakInHouse ) - { - str_index = EVT_DWORD(test_evt->v5); - result = (char *)p2DEvents[str_index - 1].pName; - } - else - { - for ( i = event_index + 1; pLevelEVT_Index[i].uEventID == uEventID; ++i ) - { - event_pos = pLevelEVT_Index[i].uEventOffsetInEVT; - test_evt=(_evt_raw*)&pLevelEVT[event_pos]; - if ( test_evt->_e_type == EVENT_SpeakInHouse ) - { - str_index = EVT_DWORD(test_evt->v5); - if ( str_index < 600 ) - return (char *)p2DEvents[str_index - 1].pName; - } - } - result = &pLevelStr[pLevelStrOffsets[EVT_BYTE(last_evt->v5)]]; - } - - return result; -} - -//----- (004613C4) -------------------------------------------------------- -void init_event_triggers() -{ - uint id = pDecorationList->GetDecorIdByName("Event Trigger"); - - num_event_triggers = 0; - for (uint i = 0; i < uNumLevelDecorations; ++i) - if (pLevelDecorations[i].uDecorationDescID == id) - event_triggers[num_event_triggers++] = i; -} - -//----- (0046CC4B) -------------------------------------------------------- -void check_event_triggers() -{ - for (size_t i = 0; i < num_event_triggers; i++) - { - if (pLevelDecorations[event_triggers[i]].uFlags & LEVEL_DECORATION_TRIGGERED_BY_TOUCH - && pLevelDecorations[event_triggers[i]].vPosition.GetDistanceTo(pParty->vPosition) < pLevelDecorations[event_triggers[i]].uTriggerRange) - { - EventProcessor(pLevelDecorations[event_triggers[i]].uEventID, PID(OBJECT_Decoration, i), 1); - } - else if (pLevelDecorations[event_triggers[i]].uFlags & LEVEL_DECORATION_TRIGGERED_BY_MONSTER) - { - for (size_t j = 0; j < uNumActors; j++) - { - if (pLevelDecorations[event_triggers[i]].vPosition.GetDistanceTo(pActors[j].vPosition) < pLevelDecorations[event_triggers[i]].uTriggerRange) - EventProcessor(pLevelDecorations[event_triggers[i]].uEventID, 0, 1); - } - } - else if (pLevelDecorations[event_triggers[i]].uFlags & LEVEL_DECORATION_TRIGGERED_BY_OBJECT) - { - for (size_t j = 0; j < uNumSpriteObjects; j++) - { - if (pLevelDecorations[event_triggers[i]].vPosition.GetDistanceTo(pSpriteObjects[j].vPosition) < pLevelDecorations[event_triggers[i]].uTriggerRange) - EventProcessor(pLevelDecorations[event_triggers[i]].uEventID, 0, 1); - } - } - } -} -// 6836C8: using guessed type int 6836C8_num_decorations_6807E8; - -//----- (004465DF) -------------------------------------------------------- -bool sub_4465DF_check_season(int a1) -{ - unsigned int monthPlusOne; // eax@1 - unsigned int daysPlusOne; // edx@1 - - monthPlusOne = pParty->uCurrentMonth + 1; - daysPlusOne = pParty->uDaysPlayed + 1; - - switch (a1) - { - case 3: //winter 12.21 -> 3.20 - return (monthPlusOne == 12 && daysPlusOne >= 21 || monthPlusOne == 1 || monthPlusOne == 2 || monthPlusOne == 3 && daysPlusOne <= 20); - break; - case 2:// autumn/fall 9.21 -> 12.20 - return (monthPlusOne == 9 && daysPlusOne >= 21 || monthPlusOne == 10 || monthPlusOne == 11 || monthPlusOne == 12 && daysPlusOne <= 20); - break; - case 1://summer 6.21 -> 9.20 - return (monthPlusOne == 6 && daysPlusOne >= 21 || monthPlusOne == 7 || monthPlusOne == 8 || monthPlusOne == 9 && daysPlusOne <= 20); - break; - case 0: //spring 3.21 -> 6.20 - return (monthPlusOne == 3 && daysPlusOne >= 21 || monthPlusOne == 4 || monthPlusOne == 5 || monthPlusOne == 6 && daysPlusOne <= 20); - break; - } - Error("Unknown season"); - return false; -} - -//----- (00448CF4) -------------------------------------------------------- -void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName) -{ - unsigned int map_id; // eax@1 - size_t old_num_actors; // ebx@2 - AIDirection v15; // [sp+28h] [bp-34h]@2 - SpawnPointMM7 pSpawnPoint; // [sp+44h] [bp-18h]@1 - - pSpawnPoint.vPosition.x = x; - pSpawnPoint.vPosition.y = y; - pSpawnPoint.vPosition.z = z; - pSpawnPoint.uGroup = group; - pSpawnPoint.uRadius = 32; - pSpawnPoint.uKind = 3; - pSpawnPoint.uIndex = typeindex + 2 * level + level; - map_id = pMapStats->GetMapInfo(pCurrentMapName); - if (map_id) - { - old_num_actors = uNumActors; - SpawnEncounter(&pMapStats->pInfos[map_id], &pSpawnPoint, 0, count, 0); - Actor::GetDirectionInfo(PID(OBJECT_Actor, old_num_actors), 4, &v15, 1); - for (uint i = (unsigned int)old_num_actors; i < (unsigned int)uNumActors; ++i) - { - pActors[i].PrepareSprites(0); - pActors[i].uYawAngle = v15.uYawAngle; - pActors[i].dword_000334_unique_name = uUniqueName; - } - } -} diff -r 92eeeb5200f2 -r 68cdef6879a0 Events.h --- a/Events.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,352 +0,0 @@ -#pragma once -#include - - - -/* 167 */ -#pragma pack(push, 1) -struct EventIndex -{ - int uEventID; - int event_sequence_num; - unsigned int uEventOffsetInEVT; -}; -#pragma pack(pop) - -// raw event struct -// header -// size_event 1 header+data -// event id 2 3 -// event_sequence_num -// event data -#pragma pack(push, 1) -struct _evt_raw -{ - unsigned char _e_size; - unsigned char v1; - unsigned char v2; - unsigned char v3; - - unsigned char _e_type; - unsigned char v5; - unsigned char v6; - unsigned char v7; - unsigned char v8; - unsigned char v9; - unsigned char v10; - unsigned char v11; - unsigned char v12; - unsigned char v13; - unsigned char v14; - unsigned char v15; - unsigned char v16; - unsigned char v17; - unsigned char v18; - unsigned char v19; - unsigned char v20; - unsigned char v21; - unsigned char v22; - unsigned char v23; - unsigned char v24; - unsigned char v25; - unsigned char v26; - unsigned char v27; - unsigned char v28; - unsigned char v29; - unsigned char v30; - unsigned char v31; - unsigned char v32; - unsigned char tail[128]; -}; -#pragma pack(pop) - - - -/* 310 */ -enum EventType -{ - EVENT_Exit = 0x1, - EVENT_SpeakInHouse = 0x2, - EVENT_PlaySound = 0x3, - EVENT_MouseOver = 0x4, - EVENT_LocationName = 0x5, - EVENT_MoveToMap = 0x6, - EVENT_OpenChest = 0x7, - EVENT_ShowFace = 0x8, - EVENT_ReceiveDamage = 0x9, - EVENT_SetSnow = 0xA, - EVENT_SetTexture = 0xB, - EVENT_ShowMovie = 0xC, - EVENT_SetSprite = 0xD, - EVENT_Compare = 0xE, - EVENT_ChangeDoorState = 0xF, - EVENT_Add = 0x10, - EVENT_Substract = 0x11, - EVENT_Set = 0x12, - EVENT_SummonMonsters = 0x13, - EVENT_CastSpell = 0x15, - EVENT_SpeakNPC = 0x16, - EVENT_SetFacesBit = 0x17, - EVENT_ToggleActorFlag = 0x18, - EVENT_RandomGoTo = 0x19, - EVENT_InputString = 0x1A, - EVENT_StatusText = 0x1D, - EVENT_ShowMessage = 0x1E, - EVENT_OnTimer = 0x1F, - EVENT_ToggleIndoorLight = 0x20, - EVENT_PressAnyKey = 0x21, - EVENT_SummonItem = 0x22, - EVENT_ForPartyMember = 0x23, - EVENT_Jmp = 0x24, - EVENT_OnMapReload = 0x25, - EVENT_Initialize = 0x26, - EVENT_SetNPCTopic = 0x27, - EVENT_MoveNPC = 0x28, - EVENT_GiveItem = 0x29, - EVENT_ChangeEvent = 0x2A, - EVENT_CheckSkill = 0x2B, - EVENT_OnCanShowDialogItemCmp = 44, - EVENT_EndCanShowDialogItem = 45, - EVENT_SetCanShowDialogItem = 46, - EVENT_SetNPCGroupNews = 0x2F, - EVENT_SetActorGroup = 0x30, - EVENT_NPCSetItem = 0x31, - EVENT_SetNPCGreeting = 0x32, - EVENT_IsActorAlive = 0x33, - EVENT_IsActorAssasinated =52, - EVENT_OnMapLeave = 0x35, - EVENT_ChangeGroup = 0x36, - EVENT_ChangeGroupAlly = 0x37, - EVENT_CheckSeason = 0x38, - EVENT_ToggleActorGroupFlag = 0x39, - EVENT_ToggleChestFlag = 0x3A, - EVENT_CharacterAnimation = 0x3B, - EVENT_SetActorItem = 0x3C, - EVENT_OnDateTimer = 0x3D, - EVENT_EnableDateTimer = 0x3E, - EVENT_StopAnimation = 0x3F, - EVENT_CheckItemsCount = 0x40, - EVENT_RemoveItems = 0x41, - EVENT_SpecialJump = 0x42, - EVENT_IsTotalBountyHuntingAwardInRange = 0x43, - EVENT_IsNPCInParty = 0x44, -}; - -/* 311 */ -enum VariableType -{ - VAR_Sex = 0x1, - VAR_Class = 0x2, - VAR_CurrentHP = 0x3, - VAR_MaxHP = 0x4, - VAR_CurrentSP = 0x5, - VAR_MaxSP = 0x6, - VAR_ActualAC = 0x7, - VAR_ACModifier = 0x8, - VAR_BaseLevel = 0x9, - VAR_LevelModifier = 0xA, - VAR_Age = 0xB, - VAR_Award = 0xC, - VAR_Experience = 0xD, - VAR_Race = 0xE, - VAR_QBits_QuestsDone = 0x10, - VAR_PlayerItemInHands = 0x11, - VAR_Hour = 0x12, - VAR_DayOfYear = 0x13, - VAR_DayOfWeek = 0x14, - VAR_FixedGold = 0x15, - VAR_RandomGold = 0x16, - VAR_FixedFood = 0x17, - VAR_RandomFood = 0x18, - VAR_MightBonus = 0x19, - VAR_IntellectBonus = 0x1A, - VAR_PersonalityBonus = 0x1B, - VAR_EnduranceBonus = 0x1C, - VAR_SpeedBonus = 0x1D, - VAR_AccuracyBonus = 0x1E, - VAR_LuckBonus = 0x1F, - VAR_BaseMight = 0x20, - VAR_BaseIntellect = 0x21, - VAR_BasePersonality = 0x22, - VAR_BaseEndurance = 0x23, - VAR_BaseSpeed = 0x24, - VAR_BaseAccuracy = 0x25, - VAR_BaseLuck = 0x26, - VAR_ActualMight = 0x27, - VAR_ActualIntellect = 0x28, - VAR_ActualPersonality = 0x29, - VAR_ActualEndurance = 0x2A, - VAR_ActualSpeed = 0x2B, - VAR_ActualAccuracy = 0x2C, - VAR_ActualLuck = 0x2D, - VAR_FireResistance = 0x2E, - VAR_AirResistance = 0x2F, - VAR_WaterResistance = 0x30, - VAR_EarthResistance = 0x31, - VAR_SpiritResistance = 0x32, - VAR_MindResistance = 0x33, - VAR_BodyResistance = 0x34, - VAR_LightResistance = 0x35, - VAR_DarkResistance = 0x36, - VAR_PhysicalResistance = 0x37, - VAR_MagicResistance = 0x38, - VAR_FireResistanceBonus = 0x39, - VAR_AirResistanceBonus = 0x3A, - VAR_WaterResistanceBonus = 0x3B, - VAR_EarthResistanceBonus = 0x3C, - VAR_SpiritResistanceBonus = 0x3D, - VAR_MindResistanceBonus = 0x3E, - VAR_BodyResistanceBonus = 0x3F, - VAR_LightResistanceBonus = 0x40, - VAR_DarkResistanceBonus = 0x41, - VAR_PhysicalResistanceBonus = 0x42, - VAR_MagicResistanceBonus = 0x43, - VAR_StaffSkill = 0x44, - VAR_SwordSkill = 0x45, - VAR_DaggerSkill = 0x46, - VAR_AxeSkill = 0x47, - VAR_SpearSkill = 0x48, - VAR_BowSkill = 0x49, - VAR_MaceSkill = 0x4A, - VAR_BlasterSkill = 0x4B, - VAR_ShieldSkill = 0x4C, - VAR_LeatherSkill = 0x4D, - VAR_SkillChain = 0x4E, - VAR_PlateSkill = 0x4F, - VAR_FireSkill = 0x50, - VAR_AirSkill = 0x51, - VAR_WaterSkill = 0x52, - VAR_EarthSkill = 0x53, - VAR_SpiritSkill = 0x54, - VAR_MindSkill = 0x55, - VAR_BodySkill = 0x56, - VAR_LightSkill = 0x57, - VAR_DarkSkill = 0x58, - VAR_IdentifyItemSkill = 0x59, - VAR_MerchantSkill = 0x5A, - VAR_RepairSkill = 0x5B, - VAR_BodybuildingSkill = 0x5C, - VAR_MeditationSkill = 0x5D, - VAR_PerceptionSkill = 0x5E, - VAR_DiplomacySkill = 0x5F, - VAR_ThieverySkill = 0x60, - VAR_DisarmTrapSkill = 0x61, - VAR_DodgeSkill = 0x62, - VAR_UnarmedSkill = 0x63, - VAR_IdentifyMonsterSkill = 0x64, - VAR_ArmsmasterSkill = 0x65, - VAR_StealingSkill = 0x66, - VAR_AlchemySkill = 0x67, - VAR_LearningSkill = 0x68, - VAR_Cursed = 0x69, - VAR_Weak = 0x6A, - VAR_Asleep = 0x6B, - VAR_Afraid = 0x6C, - VAR_Drunk = 0x6D, - VAR_Insane = 0x6E, - VAR_PoisonedGreen = 0x6F, - VAR_DiseasedGreen = 0x70, - VAR_PoisonedYellow = 0x71, - VAR_DiseasedYellow = 0x72, - VAR_PoisonedRed = 0x73, - VAR_DiseasedRed = 0x74, - VAR_Paralyzed = 0x75, - VAR_Unconsious = 0x76, - VAR_Dead = 0x77, - VAR_Stoned = 0x78, - VAR_Eradicated = 0x79, - VAR_MajorCondition = 0x7A, - VAR_MapPersistentVariable_0 = 123, - VAR_MapPersistentVariable_74 = 0xC5, - VAR_MapPersistentVariable_75 = 0xC6, - VAR_MapPersistentVariable_99 = 0xDE, - VAR_AutoNotes = 0xDF, - VAR_IsMightMoreThanBase = 0xE0, - VAR_IsIntellectMoreThanBase = 0xE1, - VAR_IsPersonalityMoreThanBase = 0xE2, - VAR_IsEnduranceMoreThanBase = 0xE3, - VAR_IsSpeedMoreThanBase = 0xE4, - VAR_IsAccuracyMoreThanBase = 0xE5, - VAR_IsLuckMoreThanBase = 0xE6, - VAR_PlayerBits = 0xE7, - VAR_NPCs2 = 0xE8, - VAR_IsFlying = 0xF0, - VAR_HiredNPCHasSpeciality = 0xF1, - VAR_CircusPrises = 0xF2, - VAR_NumSkillPoints = 0xF3, - VAR_MonthIs = 0xF4, - VAR_Counter1 = 0xF5, - VAR_Counter2 = 0xF6, - VAR_Counter3 = 0xF7, - VAR_Counter4 = 0xF8, - VAR_Counter5 = 0xF9, - VAR_Counter6 = 0xFa, - VAR_Counter7 = 0xFB, - VAR_Counter8 = 0xFC, - VAR_Counter9 = 0xFD, - VAR_Counter10 = 0xFE, - VAR_UnknownTimeEvent0 = 0xFF, - VAR_UnknownTimeEvent19 = 0x112, - VAR_ReputationInCurrentLocation = 0x113, - VAR_History_0 = 0x114, - VAR_History_28 = 0x130, - VAR_Unknown1 = 0x131, - VAR_GoldInBank = 0x132, - VAR_NumDeaths = 0x133, - VAR_NumBounties = 0x134, - VAR_PrisonTerms = 0x135, - VAR_ArenaWinsPage = 0x136, - VAR_ArenaWinsSquire = 0x137, - VAR_ArenaWinsKnight = 0x138, - VAR_ArenaWinsLord = 0x139, - VAR_Invisible = 0x13A, - VAR_ItemEquipped = 0x13B, -}; - -#define EVT_WORD(x) *(unsigned __int16*)&x -#define EVT_DWORD(x) *(unsigned int*)&x -#define EVT_STRING(x) (unsigned char*)&x -#define EVT_BYTE(x) (unsigned char)x - -extern std::array pSomeOtherEVT_Events; -extern signed int uSomeOtherEVT_NumEvents; -extern char *pSomeOtherEVT; -extern std::array pSomeEVT_Events; -extern signed int uSomeEVT_NumEvents; -extern char *pSomeEVT; - -extern unsigned int uGlobalEVT_NumEvents; -extern unsigned int uGlobalEVT_Size; -extern std::array pGlobalEVT; -extern std::array pGlobalEVT_Index; - -extern std::array pLevelStrOffsets; -extern unsigned int uLevelStrNumStrings; -extern unsigned int uLevelStrFileSize; -extern signed int uLevelEVT_NumEvents; -extern unsigned int uLevelEVT_Size; -extern std::array pLevelStr; -extern std::array pLevelEVT; -extern std::array pLevelEVT_Index; - - -unsigned int LoadEventsToBuffer(const char *pContainerName, char *pBuffer, unsigned int uBufferSize); -void Initialize_GlobalEVT(); -void LoadLevel_InitializeLevelEvt(); -void EventProcessor(int uEventID, int a2, int a3, int entry_line = 0); -char *GetEventHintString(unsigned int uEventID); // idb - - - -/* 312 */ -#pragma pack(push, 1) -struct ByteArray -{ - char f[65535]; -}; -#pragma pack(pop) - -void init_event_triggers(); -void check_event_triggers(); -bool sub_4465DF_check_season(int a1); -void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName); diff -r 92eeeb5200f2 -r 68cdef6879a0 Events2D.h --- a/Events2D.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -#pragma once - -/* 296 */ -enum BuildingType: unsigned short -{ - BuildingType_WeaponShop = 1, - BuildingType_ArmorShop = 2, - BuildingType_MagicShop = 3, - BuildingType_AlchemistShop = 4, - BuildingType_FireGuild = 5, - BuildingType_AirGuild = 6, - BuildingType_WaterGuild = 7, - BuildingType_EarthGuild = 8, - BuildingType_SpiritGuild = 9, - BuildingType_MindGuild = 10, - BuildingType_BodyGuild = 11, - BuildingType_LightGuild = 12, - BuildingType_DarkGuild = 13, - BuildingType_ElementalGuild = 14, - BuildingType_SelfGuild = 15, - BuildingType_16 = 16, - BuildingType_TownHall = 17, - BuildingType_18 = 18, - BuildingType_19 = 19, - BuildingType_Throne_Room = 20, - BuildingType_Tavern = 21, - BuildingType_Bank = 22, - BuildingType_Temple = 23, - BuildingType_24 = 24, - BuildingType_Unic = 25, - BuildingType_1A = 26, - BuildingType_Stables = 27, - BuildingType_Boats = 28, - BuildingType_House = 29, - BuildingType_Training = 30, - BuildingType_Jail = 31 -}; - -/* 168 */ -#pragma pack(push, 1) -struct _2devent -{ - BuildingType uType; - unsigned __int16 uAnimationID; - char *pName; - const char *pProprieterName; - const char *pEnterText; - const char *pProprieterTitle; - __int16 field_14; - __int16 _state; - __int16 _rep; - __int16 _per; - __int16 field_1C; - __int16 field_1E; - float fPriceMultiplier; - float flt_24; - unsigned __int16 uOpenTime; - unsigned __int16 uCloseTime; - __int16 uExitPicID; - __int16 uExitMapID; - __int16 _quest_related; - __int16 field_32; -}; -#pragma pack(pop) - -extern _2devent p2DEvents[525]; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 FactionTable.cpp --- a/FactionTable.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include "FactionTable.h" -#include "mm7_data.h" -#include "LOD.h" - - - - -//----- (004547E4) -------------------------------------------------------- -void FactionTable::Initialize() -{ - int i; - char* test_string; - unsigned char c; - bool break_loop; - unsigned int temp_str_len; - char* tmp_pos; - int decode_step; - // int item_counter; - - free(pHostileTXT_Raw); - pHostileTXT_Raw = (char *)pEvents_LOD->LoadRaw("hostile.txt", 0); - strtok(pHostileTXT_Raw, "\r"); - for (i = 0; i < 89; ++i) - { - test_string = strtok(NULL, "\r") + 1; - break_loop = false; - decode_step = 0; - do - { - c = *(unsigned char*)test_string; - temp_str_len = 0; - while ((c != '\t') && (c > 0)) - { - ++temp_str_len; - c = test_string[temp_str_len]; - } - tmp_pos = test_string + temp_str_len; - if (*tmp_pos == 0) - break_loop = true; - *tmp_pos = 0; - if (temp_str_len) - { - if (decode_step >= 1 && decode_step < 90) - relations[decode_step - 1][i] = atoi(test_string); - } - else - break_loop = true; - ++decode_step; - test_string = tmp_pos + 1; - } while ((decode_step < 92) && !break_loop); - } - free(pHostileTXT_Raw); - pHostileTXT_Raw = nullptr; -} diff -r 92eeeb5200f2 -r 68cdef6879a0 FactionTable.h --- a/FactionTable.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ -#pragma once - - -/* 174 */ -#pragma pack(push, 1) -struct FactionTable -{ - void Initialize(); - - char relations[89][89]; -}; -#pragma pack(pop) diff -r 92eeeb5200f2 -r 68cdef6879a0 FrameTableInc.cpp --- a/FrameTableInc.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,142 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include "FrameTableInc.h" -#include -//identical function to work in differnt threads - -//----- (004BE3BF) -------------------------------------------------------- -FrameTableTxtLine* txt_file_frametable_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table) - { - bool new_token_flag; // edx@3 - bool in_quotes; // [sp+Ch] [bp-4h]@3 - char* parse_pos; - unsigned char test_char; - int i; - - static char tokens_buff1[1000]; - static struct FrameTableTxtLine temp_tokens_table1; // weak - - temp_tokens_table1.uPropCount = 0; - - if ( str_to_parse && *str_to_parse ) - { - parse_pos=(char*)str_to_parse; - new_token_flag = true; - in_quotes = false; - for(i = 0; (i<1000)&&(temp_tokens_table1.uPropCount < 30) ; ++i) - { - test_char=*parse_pos; - tokens_buff1[i]=test_char; - if ( !test_char ) - break; - if ( (test_char != ' ') && (test_char != ',') && (test_char != '\t') || in_quotes ) - { - if ( test_char == '"' ) - { - tokens_buff1[i]= '\0'; - new_token_flag = true; - if ( in_quotes ) - in_quotes = false; - else - { - in_quotes = true; - if ( *(parse_pos+1) == '"' ) - { - temp_tokens_table1.pProperties[temp_tokens_table1.uPropCount] = &tokens_buff1[i]; - ++temp_tokens_table1.uPropCount; - } - } - } - else - { - if ( new_token_flag ) - { - temp_tokens_table1.pProperties[temp_tokens_table1.uPropCount] = &tokens_buff1[i]; - ++temp_tokens_table1.uPropCount; - } - new_token_flag = false; - } - } - else - { - tokens_buff1[i]= '\0'; - new_token_flag = true; - } - ++parse_pos; - } - tokens_buff1[i]= '\0'; - } - memcpy(tokens_table, &temp_tokens_table1, sizeof(FrameTableTxtLine)); - return tokens_table; - } -// F8BA58: using guessed type FrameTableTxtLine static_stru_F8BA58; - -//----- (004BE485) -------------------------------------------------------- -FrameTableTxtLine * frame_table_txt_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table) - { - bool new_token_flag; // edx@3 - bool in_quotes; // [sp+Ch] [bp-4h]@3 - char* parse_pos; - unsigned char test_char; - int i; - - static char tokens_buff2[1000]; - static struct FrameTableTxtLine temp_tokens_table2; // weak - temp_tokens_table2.uPropCount = 0; - - if ( str_to_parse && *str_to_parse ) - { - parse_pos=(char*)str_to_parse; - new_token_flag = true; - in_quotes = false; - for(i = 0; (i<1000)&&(temp_tokens_table2.uPropCount < 30); ++i) - { - test_char=*parse_pos; - tokens_buff2[i]=test_char; - if ( !test_char ) - break; - if ( (test_char != ' ') && (test_char != ',') && (test_char != '\t') || in_quotes ) - { - if ( test_char == '"' ) - { - tokens_buff2[i]= '\0'; - new_token_flag = true; - if ( in_quotes ) - in_quotes = false; - else - { - in_quotes = true; - if ( *(parse_pos+1) == '"' ) - { - temp_tokens_table2.pProperties[temp_tokens_table2.uPropCount] = &tokens_buff2[i]; - ++temp_tokens_table2.uPropCount; - } - } - } - else - { - if ( new_token_flag ) - { - temp_tokens_table2.pProperties[temp_tokens_table2.uPropCount] = &tokens_buff2[i]; - ++temp_tokens_table2.uPropCount; - } - new_token_flag = false; - } - } - else - { - tokens_buff2[i]= '\0'; - new_token_flag = true; - } - ++parse_pos; - } - - tokens_buff2[i]= '\0'; - } - memcpy(tokens_table, &temp_tokens_table2, sizeof(FrameTableTxtLine)); - return tokens_table; - } - diff -r 92eeeb5200f2 -r 68cdef6879a0 FrameTableInc.h --- a/FrameTableInc.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -#pragma once - - - -/* 322 */ -enum FRAME_TABLE_FLAGS -{ - FRAME_TABLE_MORE_FRAMES = 0x1, - FRAME_TABLE_FIRST = 0x4, -}; - - - -/* 359 */ -#pragma pack(push, 1) -struct FrameTableTxtLine //7C -{ - int uPropCount; - const char *pProperties[30]; -}; -#pragma pack(pop) - - -FrameTableTxtLine* txt_file_frametable_parser(const char *str_to_parse, FrameTableTxtLine *tokens_table); - -FrameTableTxtLine *frame_table_txt_parser(const char *pString, FrameTableTxtLine *a2); \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 GUIButton.cpp --- a/GUIButton.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/GUIButton.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -7,9 +7,9 @@ #include "GUIWindow.h" #include "GUIFont.h" -#include "mm7_data.h" -#include "LOD.h" -#include "Texts.h" +#include "Engine/mm7_data.h" +#include "Engine/LOD.h" +#include "Engine/Texts.h" #include "OSWindow.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 GUIFont.cpp --- a/GUIFont.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/GUIFont.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -4,14 +4,14 @@ #define _CRT_SECURE_NO_WARNINGS #include -#include "ErrorHandling.h" +#include "Engine/ErrorHandling.h" -#include "LOD.h" +#include "Engine/LOD.h" #include "GUIFont.h" #include "GUIWindow.h" #include "Engine/Graphics/Render.h" -#include "mm7_data.h" +#include "Engine/mm7_data.h" extern LODFile_IconsBitmaps *pIcons_LOD; diff -r 92eeeb5200f2 -r 68cdef6879a0 GUIProgressBar.cpp --- a/GUIProgressBar.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/GUIProgressBar.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -4,13 +4,13 @@ #define _CRT_SECURE_NO_WARNINGS #include "GUIProgressBar.h" -#include "ErrorHandling.h" -#include "LOD.h" -#include "Party.h" +#include "Engine/ErrorHandling.h" +#include "Engine/LOD.h" +#include "Engine/Party.h" #include "Engine/Graphics/Render.h" -#include "IconFrameTable.h" +#include "Engine/Tables/IconFrameTable.h" -#include "mm7_data.h" +#include "Engine/mm7_data.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 GUIWindow.cpp --- a/GUIWindow.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/GUIWindow.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -3,32 +3,32 @@ #include #define _CRT_SECURE_NO_WARNINGS -#include "ErrorHandling.h" +#include "Engine/ErrorHandling.h" #include "GUIWindow.h" #include "GUIFont.h" -#include "Party.h" -#include "LOD.h" +#include "Engine/Party.h" +#include "Engine/LOD.h" #include "Keyboard.h" -#include "OurMath.h" -#include "Timer.h" +#include "Engine/OurMath.h" +#include "Engine/Timer.h" #include "AudioPlayer.h" #include "Mouse.h" #include "Engine/Graphics/Viewport.h" -#include "StorylineTextTable.h" +#include "Engine/Tables/StorylineTextTable.h" #include "UI\UIHouses.h" #include "UI\UIBooks.h" -#include "texts.h" -#include "Autonotes.h" -#include "Awards.h" -#include "Chest.h" +#include "Engine/texts.h" +#include "Engine/Autonotes.h" +#include "Engine/Awards.h" +#include "Engine/Objects/Chest.h" #include "Engine/Graphics/Outdoor.h" -#include "Game.h" -#include "IconFrameTable.h" -#include "Actor.h" +#include "Engine/Game.h" +#include "Engine/Tables/IconFrameTable.h" +#include "Engine/Objects/Actor.h" #include "UI\UIArena.h" -#include "Events.h" +#include "Engine/Events.h" #include "Engine/Graphics/Level\Decoration.h" typedef struct _RGBColor diff -r 92eeeb5200f2 -r 68cdef6879a0 GUIWindow.h --- a/GUIWindow.h Fri Sep 19 00:03:04 2014 +0600 +++ b/GUIWindow.h Fri Sep 19 02:57:42 2014 +0600 @@ -3,7 +3,7 @@ #include #include -#include "Player.h" +#include "Engine/Objects/Player.h" enum UIMessageType: unsigned __int32 { diff -r 92eeeb5200f2 -r 68cdef6879a0 Game.cpp --- a/Game.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7496 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include "Arcomage\Arcomage.h" - -#include "Engine/Graphics/Vis.h" -#include "Engine/Graphics/Weather.h" -#include "Engine/Graphics/LightmapBuilder.h" -#include "Engine/Graphics/DecalBuilder.h" -#include "Engine/Graphics/ParticleEngine.h" -#include "Mouse.h" -#include "Keyboard.h" -#include "Engine/Graphics/GammaControl.h" -#include "stru6.h" -#include "Engine/Graphics/stru9.h" -#include "Engine/Graphics/stru10.h" -#include "ErrorHandling.h" - -#include "Game.h" -#include "Party.h" -#include "Engine/Graphics/Viewport.h" -#include "Timer.h" -#include "Engine/Graphics/Outdoor.h" -#include "Engine/Graphics/Overlays.h" -#include "AudioPlayer.h" -#include "LOD.h" -#include "GUIWindow.h" -#include "TurnEngine.h" -#include "Bink_Smacker.h" -#include "Events.h" -#include "texts.h" -#include "GUIFont.h" -#include "Log.h" -#include "Engine/Graphics/Lights.h" -#include "CastSpellInfo.h" -#include "FrameTableInc.h" -#include "Actor.h" -#include "GUIProgressBar.h" -#include "ObjectList.h" -#include "Engine/Graphics/Level/Decoration.h" -#include "Engine/Graphics/PaletteManager.h" -#include "UI\UIHouses.h" -#include "UI\UIShops.h" -#include "UI\UIPartyCreation.h" -#include "SaveLoad.h" -#include "SpriteObject.h" -#include "mm7.h" -#include "Engine/Graphics/Sprites.h" -#include "Registry.h" -#include "Chest.h" - -#include "UI\UIGame.h" - -#include "Engine/Graphics/DecorationList.h" -#include "IconFrameTable.h" -#include "PlayerFrameTable.h" -#include "MapsLongTimer.h" -#include "StorylineTextTable.h" -#include "FactionTable.h" -#include "stru123.h" -#include "LuaVM.h" -#include "Engine/Graphics/RenderD3D11.h" -#include "MMT.h" -#include "NewUI\MainMenu.h" -#include - - - - - -Game *pGame; - - - - - -//----- (00435694) -------------------------------------------------------- -void Game::ToggleFlags2(unsigned int uFlag) -{ - unsigned int v2; // eax@1 - - v2 = this->uFlags2; - if ( v2 & uFlag ) - this->uFlags2 = v2 & ~uFlag; - else - this->uFlags2 = uFlag | v2; -} - -//----- (0044103C) -------------------------------------------------------- -void Game::Draw() -{ - int v4; // edi@26 - - uFlags2 &= ~0x02; - if ( pParty->_497FC5_check_party_perception_against_level() ) - uFlags2 |= 2; - - pGame->pIndoorCameraD3D->sRotationX = pParty->sRotationX; - pGame->pIndoorCameraD3D->sRotationY = pParty->sRotationY; - pGame->pIndoorCameraD3D->vPartyPos.x = pParty->vPosition.x - pParty->y_rotation_granularity * cosf(2 * 3.141592653589 * pParty->sRotationY / 2048.0); - pGame->pIndoorCameraD3D->vPartyPos.y = pParty->vPosition.y - pParty->y_rotation_granularity * sinf(2 * 3.141592653589 * pParty->sRotationY / 2048.0); - pGame->pIndoorCameraD3D->vPartyPos.z = pParty->vPosition.z + pParty->sEyelevel;//193, but real 353 - - //pIndoorCamera->Initialize2(); - pIndoorCameraD3D->CalculateRotations(pParty->sRotationX, pParty->sRotationY); - pIndoorCameraD3D->CreateWorldMatrixAndSomeStuff(); - pIndoorCameraD3D->_4374E8_ProllyBuildFrustrum(); - - if ( pMovie_Track ) - { - /*if ( !pRenderer->pRenderD3D ) - { - pRenderer->BeginSceneD3D(); - pMouse->DrawCursorToTarget(); - pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); - }*/ - } - else - { - if ( pParty->vPosition.x != pParty->vPrevPosition.x || pParty->sRotationY != pParty->sPrevRotationY || pParty->vPosition.y != pParty->vPrevPosition.y - || pParty->sRotationX != pParty->sPrevRotationX || pParty->vPosition.z != pParty->vPrevPosition.z || pParty->sEyelevel != pParty->sPrevEyelevel ) - pParty->uFlags |= 2u; - pParty->vPrevPosition.x = pParty->vPosition.x; - pParty->vPrevPosition.y = pParty->vPosition.y; - pParty->vPrevPosition.z = pParty->vPosition.z; - //v0 = &pRenderer; - pParty->sPrevRotationY = pParty->sRotationY; - pParty->sPrevRotationX = pParty->sRotationX; - - pParty->sPrevEyelevel = pParty->sEyelevel; - pRenderer->BeginSceneD3D(); - - //if ( !pRenderer->pRenderD3D ) - //pMouse->DrawCursorToTarget(); - if ( !PauseGameDrawing() || viewparams->field_48 == 1 ) - { - //if ( pRenderer->pRenderD3D ) - { - float v2 = (double)(((signed int)pMiscTimer->uTotalGameTimeElapsed >> 2) & 0x1F) * 0.032258064 * 6.0; - //v3 = v2 + 6.7553994e15; - //pRenderer->field_1036A8_bitmapid = LODWORD(v3); - pRenderer->hd_water_current_frame = floorf(v2 + 0.5f); - } - - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - pIndoor->Draw(); - else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - pOutdoor->Draw(); - else - Error("Invalid level type: %u", uCurrentlyLoadedLevelType); - - //if (pRenderer->pRenderD3D) - { - pDecalBuilder->DrawBloodsplats(); - pGame->pLightmapBuilder->DrawLightmapsType(2); - } - } - pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); - } - - //DEBUG: force redraw gui - viewparams->bRedrawGameUI = true; - - - pRenderer->BeginScene(); - //if (pRenderer->pRenderD3D) - pMouse->DrawCursorToTarget(); - if (pOtherOverlayList->bRedraw) - viewparams->bRedrawGameUI = true; - v4 = viewparams->bRedrawGameUI; - GameUI_Footer(); - if (!viewparams->bRedrawGameUI) - GameUI_DrawRightPanelItems(); - else - { - GameUI_DrawRightPanelFrames(); - GameUI_Footer_2(); - viewparams->bRedrawGameUI = false; - } - if (!pMovie_Track)//!pVideoPlayer->pSmackerMovie) - { - GameUI_DrawMinimap(488, 16, 625, 133, viewparams->uMinimapZoom, true);//redraw = pParty->uFlags & 2); - if (v4) - { - if ( !PauseGameDrawing() /*&& pRenderer->pRenderD3D*/) // clear game viewport with transparent color - pRenderer->FillRectFast(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pViewport->uViewportBR_X - pViewport->uViewportTL_X, - pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1, - 0x7FF); - viewparams->field_48 = 0; - } - } - - viewparams->bRedrawGameUI = pOtherOverlayList->bRedraw; - pOtherOverlayList->bRedraw = 0; - - GameUI_DrawPartySpells(); - if (v4 || pParty->pHirelings[0].evt_C || pParty->pHirelings[1].evt_C ) - GameUI_DrawHiredNPCs(); - GameUI_DrawPortraits(v4); - GameUI_DrawLifeManaBars(); - GameUI_DrawCharacterSelectionFrame(); - if ( _44100D_should_alter_right_panel() ) - GameUI_DrawRightPanel(); - if ( !pMovie_Track ) - { - pStru6Instance->DrawPlayerBuffAnims(); - pOtherOverlayList->DrawTurnBasedIcon(v4); - GameUI_DrawTorchlightAndWizardEye(); - } - - - static bool render_framerate = false; - static float framerate = 0.0f; - static uint frames_this_second = 0; - static uint last_frame_time = GetTickCount(); - static uint framerate_time_elapsed = 0; - - if ( pCurrentScreen == SCREEN_GAME && uCurrentlyLoadedLevelType == LEVEL_Outdoor) - pWeather->Draw();//Ritor1: my include - - //while(GetTickCount() - last_frame_time < 33 );//FPS control - uint frame_dt = GetTickCount() - last_frame_time; - last_frame_time = GetTickCount(); - - framerate_time_elapsed += frame_dt; - if (framerate_time_elapsed >= 1000) - { - framerate = frames_this_second * (1000.0f / framerate_time_elapsed); - - framerate_time_elapsed = 0; - frames_this_second = 0; - render_framerate = true; - } - - ++frames_this_second; - - if ( debug_information ) - { - if (render_framerate) - { - sprintf(pTmpBuf.data(), "FPS: % .4f", framerate); - pPrimaryWindow->DrawText(pFontArrus, 494, 0, Color16(0, 0, 0), pTmpBuf.data(), 0, 0, 0); - } - - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - int 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, Color16(255, 255, 255), pTmpBuf.data(), 0, 0, -1); - } - sprintf(pTmpBuf.data(), "Party Position: % d % d % d", pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); - pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, Color16(255, 255, 255), pTmpBuf.data(), 0, 0, -1); - - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - uint uFaceID; - int sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); - int 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; - int 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, Color16(255, 255, 255), pTmpBuf.data(), 0, 0, -1); - } - - GUI_UpdateWindows(); - pParty->UpdatePlayersAndHirelingsEmotions(); - - _unused_5B5924_is_travel_ui_drawn = false; - if (v4) - pMouse->bRedraw = true; - pMouse->ReadCursorWithItem(); - pMouse->DrawCursor(); - pMouse->Activate(); - pRenderer->EndScene(); - pRenderer->Present(); - pParty->uFlags &= ~2; -} - -//----- (0047A815) -------------------------------------------------------- -void Game::DrawParticles() -{ - pParticleEngine->Draw(); -} - -//----- (00463149) -------------------------------------------------------- -void Game::Loop() -{ - const char *pLocationName; // [sp-4h] [bp-68h]@74 - bool bLoading; // [sp+10h] [bp-54h]@1 - signed int v16; // [sp+14h] [bp-50h]@8 - MSG Msg; // [sp+28h] [bp-3Ch]@20 - char Source[64]; // [sp+44h] [bp-20h]@76 - - bLoading = sCurrentMenuID == MENU_LoadingProcInMainMenu; - SetCurrentMenuID((MENU_STATE)-1); - if (bLoading) - { - pParty->Reset(); - uGameState = GAME_STATE_PLAYING; - LoadGame(uLoadGameUI_SelectedSlot); - } - - for (uint i = 1; i < 5; ++i) - for (uint j = 1; j < 6; ++j) - { - sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j); - remove(pTmpBuf.data()); - } - - LoadPlayerPortraintsAndVoices(); - pIcons_LOD->_inlined_sub1(); - pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); - - while ( 2 ) - { - v16 = 1; - pMessageQueue_50CBD0->Flush(); - - pPartyActionQueue->uNumActions = 0; - if (pParty->bTurnBasedModeOn) - { - pTurnEngine->End(false); - pParty->bTurnBasedModeOn = false; - } - DoPrepareWorld(bLoading, 1); - pEventTimer->Resume(); - dword_6BE364_game_settings_1 |= GAME_SETTINGS_0080_SKIP_USER_INPUT_THIS_FRAME; - // uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions = 0; - pCurrentScreen = SCREEN_GAME; - - //if ( pRenderer->pRenderD3D ) - pGame->pVisInstance->_4C1A02(); - - bool game_finished = false; - do - { - while ( PeekMessageA(&Msg, 0, 0, 0, PM_REMOVE) ) - { - if ( Msg.message == WM_QUIT ) - Game_DeinitializeAndTerminate(0); - TranslateMessage(&Msg); - DispatchMessageA(&Msg); - } - if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE) - { - WaitMessage(); - continue; - } - pGame->_44EEA7(); - GameUI_WritePointedObjectStatusString(); - Keyboard::ProcessInputActions(); - GameUI_MsgProc(); - if ( pArcomageGame->bGameInProgress ) - { - ArcomageGame::Loop(); - pRenderer->Present(); - continue; - } - - pMediaPlayer->HouseMovieLoop(); - - pEventTimer->Update(); - pMiscTimer->Update(); - - OnTimer(0); - GameUI_StatusBar_UpdateTimedString(0); - if ( pMiscTimer->bPaused && !pEventTimer->bPaused ) - pMiscTimer->Resume(); - if ( pEventTimer->bTackGameTime && !pParty->bTurnBasedModeOn ) - pEventTimer->bTackGameTime = 0; - if ( !pEventTimer->bPaused && uGameState == GAME_STATE_PLAYING) - { - if ( !pEventTimer->bTackGameTime ) - _494035_timed_effects__water_walking_damage__etc(); - - if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0001) - dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0001; - else - { - Actor::UpdateActorAI(); - UpdateUserInput_and_MapSpecificStuff(); - } - } - if ( v16 ) - { - v16 = 0; - viewparams->bRedrawGameUI = true; - } - pAudioPlayer->UpdateSounds(); - if ( (signed int)uGameState == GAME_STATE_PLAYING ) - { - pGame->Draw(); - continue; - } - if (uGameState == GAME_FINISHED) - { - game_finished = true; - continue; - } - if (uGameState == GAME_STATE_CHANGE_LOCATION)// ñìåíà ëîêàöèè - { - pAudioPlayer->StopChannels(-1, -1); - PrepareWorld(0); - uGameState = GAME_STATE_PLAYING; - continue; - } - if ( (signed int)uGameState <= GAME_STATE_5 || uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU )//GAME_STATE_NEWGAME_OUT_GAMEMENU, GAME_STATE_LOADING_GAME - { - game_finished = true; - continue; - } - if ( uGameState == GAME_STATE_FINAL_WINDOW ) - { - pRenderer->BeginScene(); - GUI_UpdateWindows(); - pRenderer->EndScene(); - pRenderer->Present(); - continue; - } - if ( uGameState != GAME_STATE_PARTY_DIED ) - { - pGame->Draw(); - continue; - } - if ( uGameState == GAME_STATE_PARTY_DIED ) - { - pAudioPlayer->StopChannels(-1, -1); - memset(&pParty->pHirelings[0], 0, 0x4Cu); - memset(&pParty->pHirelings[1], 0, 0x4Cu); - for ( int i = 0; i < (signed int)pNPCStats->uNumNewNPCs; ++i ) - { - if ( pNPCStats->pNewNPCData[i].field_24 ) - pNPCStats->pNewNPCData[i].uFlags &= 0xFFFFFF7Fu; - } - pMediaPlayer->bStopBeforeSchedule = 0; - pMediaPlayer->PlayFullscreenMovie(MOVIE_Death, true); - if ( pMovie_Track ) - pMediaPlayer->Unload(); - SaveGame(0, 0); - ++pParty->uNumDeaths; - for ( uint i = 0; i < 4; ++i ) - pParty->pPlayers[i].SetVariable(VAR_Award, 85); - pParty->days_played_without_rest = 0; - pParty->uTimePlayed += 0x276000ui64; - LOWORD(pParty->uFlags) &= ~0x204; - pParty->SetGold(0); - pOtherOverlayList->Reset(); - memset(pParty->pPartyBuffs.data(), 0, 0x140u); - - if ( pParty->bTurnBasedModeOn == 1 ) - { - pTurnEngine->End(true); - pParty->bTurnBasedModeOn = 0; - } - for( int i = 0; i < 4; ++i) - { - memset(pParty->pPlayers[i].pConditions.data(), 0, 0xA0u);//(pConditions, 0, 160) - memset(pParty->pPlayers[i].pPlayerBuffs.data(), 0, 0x180u);//(pPlayerBuffs[0], 0, 384) - pParty->pPlayers[i].sHealth = 1; - uActiveCharacter = 1; - } - if (_449B57_test_bit(pParty->_quest_bits, PARTY_QUEST_FINISHED_EMERALD_ISLE)) - { - pParty->vPosition.x = -17331; // respawn in harmondale - pParty->vPosition.y = 12547; - pParty->vPosition.z = 465; - pParty->sRotationY = 0; - pLocationName = "out02.odm"; - } - else - { - pParty->vPosition.x = 12552; // respawn on emerald isle - pParty->vPosition.y = 1816; - pParty->vPosition.z = 0; - pParty->sRotationY = 512; - pLocationName = "out01.odm"; - } - strcpy(Source, pLocationName); - pParty->uFallStartY = pParty->vPosition.z; - pParty->sRotationX = 0; - pParty->uFallSpeed = 0; - pParty->field_6E4 = 0; - pParty->field_6E0 = 0; - if ( _stricmp(Source, pCurrentMapName) ) - { - strcpy(pCurrentMapName, Source); - _5B65A8_npcdata_uflags_or_other = pParty->vPosition.x; - _5B65AC_npcdata_fame_or_other = pParty->vPosition.y; - _5B65B0_npcdata_rep_or_other = pParty->vPosition.z; - _5B65B4_npcdata_loword_house_or_other = pParty->sRotationY; - _5B65B8_npcdata_hiword_house_or_other = pParty->sRotationX; - dword_5B65C0 = 1; - PrepareWorld(1); - } - Actor::InitializeActors(); - - int num_conscious_players = 0; - int conscious_players_ids[4] = {-1, -1, -1, -1}; - for (int i = 0; i < 4; ++i) - { - if (pParty->pPlayers[i].CanAct()) - conscious_players_ids[num_conscious_players++] = i; - } - if (num_conscious_players) - { - int idx = conscious_players_ids[rand() % num_conscious_players]; - Assert(idx >= 0); - pParty->pPlayers[idx].PlaySound(SPEECH_99, 0); - } - - ShowStatusBarString(pGlobalTXT_LocalizationStrings[524], 2);// "Once again you've cheated death!.." "Âû ñíîâà îáõèòðèëè ñìåðòü! …" - uGameState = GAME_STATE_PLAYING; - } - } - while (!game_finished); - - pEventTimer->Pause(); - ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); - if ( uGameState == GAME_STATE_LOADING_GAME ) - { - sub_491E3A(); - LoadPlayerPortraintsAndVoices(); - uGameState = GAME_STATE_PLAYING; - pIcons_LOD->dword_11B84 = pIcons_LOD->uNumLoadedFiles; - bLoading = true; - continue; - } - break; - } - pCurrentScreen = SCREEN_VIDEO; - sub_491E3A(); -} - - -//----- (0044F192) -------------------------------------------------------- -void Game::PrepareBloodsplats() -{ - for (uint i = 0; i < uNumBloodsplats; ++i) - { - pBloodsplatContainer->AddBloodsplat(pBloodsplats[i].x, pBloodsplats[i].y, pBloodsplats[i].z, - pBloodsplats[i].radius, pBloodsplats[i].r, pBloodsplats[i].g, pBloodsplats[i].b); - } -} - - -//----- (0044F120) -------------------------------------------------------- -void Game::PushStationaryLights(int a2) -{ - Game__StationaryLight* pLight; - - for( int i=0; iAddLight(pLight->vPosition.x, pLight->vPosition.y, pLight->vPosition.z, - pLight->flt_18, pLight->vRGBColor.x, pLight->vRGBColor.y, pLight->vRGBColor.z, _4E94D0_light_type); - } -} -// 4E94D0: using guessed type char _4E94D0_light_type; - -//----- (0044F0FD) -------------------------------------------------------- -void Game::_44F0FD() -{ - ToggleFlags(0x40u); - - if ( !(uFlags & 0x40) ) - { - uNumBloodsplats = 0; - field_E0C = 0; - } -} - -//----- (0044F0D8) -------------------------------------------------------- -void Game::ToggleFlags(uint uMask) -{ - if (uFlags & uMask) - uFlags &= ~uMask; - else - uFlags |= uMask; -} - - -//----- (0044F07B) -------------------------------------------------------- -bool Game::_44F07B() -{ - if (!pKeyboardInstance->IsKeyBeingHeld(VK_SHIFT) && !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) && - !pKeyboardInstance->IsKeyBeingHeld(VK_LSHIFT) || (pKeyboardInstance->WasKeyPressed(VK_F11) == 0 && - pKeyboardInstance->WasKeyPressed(VK_F11))) - return true; - return false; -} - -//----- (0044EEA7) -------------------------------------------------------- -bool Game::_44EEA7() -{ - //Game *v1; // esi@1 - //double v2; // st7@2 - float depth; // ST00_4@9 - //bool result; // eax@9 - //unsigned int v5; // eax@14 - __int64 v6; // kr00_8@21 - //unsigned int y; // [sp+4h] [bp-24h]@2 - //unsigned int x; // [sp+8h] [bp-20h]@2 - Vis_SelectionFilter *v10; // [sp+10h] [bp-18h]@2 - Vis_SelectionFilter *v11; // [sp+14h] [bp-14h]@2 - POINT cursor; // [sp+20h] [bp-8h]@1 - - //v1 = this; - ++qword_5C6DF0; - pParticleEngine->UpdateParticles(); - pMouseInstance->GetCursorPos(&cursor); - - //x = cursor.y; - //y = cursor.x; - if ( sub_4637E0_is_there_popup_onscreen() ) - { - v11 = &vis_face_filter; - v10 = &vis_sprite_filter_2; - depth = pGame->pIndoorCameraD3D->GetPickDepth(); - } - else - { - if ( uFlags2 & GAME_FLAGS_2_TARGETING_MODE ) - { - v11 = &vis_face_filter; - v10 = &vis_sprite_filter_1; - } - else - { - v11 = &vis_face_filter; - v10 = &vis_sprite_filter_4; - } - depth = 5120.0; - } - //depth = v2; - - PickMouse(depth, cursor.x, cursor.y, false, v10, v11); - pLightmapBuilder->std__vector_000004_size = 0; - pLightmapBuilder->std__vector_183808_size = 0; - pDecalBuilder->std__vector_pDecals_size = 0; - pDecalBuilder->field_308008 = 0; - if (!_44F07B()) - return false; - - if ( uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) - pStru10Instance->bDoNotDrawPortalFrustum = false; - if ( /*pRenderer->pRenderD3D &&*/ uCurrentlyLoadedLevelType == LEVEL_Outdoor) - pRenderer->uFogColor = GetLevelFogColor() & 0xFFFFFF; - if (uFlags & 0x0400) - uFlags2 |= 0x01; - /*if ( !pRenderer->pRenderD3D && uCurrentlyLoadedLevelType == LEVEL_Outdoor && pMobileLightsStack->uNumLightsActive ) - { - uFlags2 |= 0x01; - field_E10 = qword_5C6DF0; - }*/ - v6 = qword_5C6DF0 - field_E10; - if ( qword_5C6DF0 - field_E10 == 1 ) - uFlags2 |= v6; - if (uNumStationaryLights_in_pStationaryLightsStack != pStationaryLightsStack->uNumLightsActive ) - { - uFlags2 |= 1; - uNumStationaryLights_in_pStationaryLightsStack = pStationaryLightsStack->uNumLightsActive; - } - _44E904(); - return true; -} - - -//----- (0044EDE4) -------------------------------------------------------- -bool Game::AlterGamma_BLV(BLVFace *pFace, signed int *pColor) -{ - if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS && - pFace->uAttributes & FACE_CAN_SATURATE_COLOR) - { - *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0); - return true; - } - else - return false; -} - -//----- (0044EE30) -------------------------------------------------------- -bool Game::AlterGamma_ODM(ODMFace *pFace, signed int *pColor) -{ - if (uFlags2 & GAME_FLAGS_2_SATURATE_LIGHTMAPS && - pFace->uAttributes & FACE_CAN_SATURATE_COLOR) - { - *pColor = ReplaceHSV(*pColor, 1.0, fSaturation, -1.0); - return true; - } - else - return false; -} - - -//----- (004645FA) -------------------------------------------------------- -void Game::Deinitialize() -{ - WriteWindowsRegistryInt("startinwindow", 1);//pRenderer->bWindowMode); - //if (pRenderer->bWindowMode) - { - WriteWindowsRegistryInt("window X", window->GetX()); - WriteWindowsRegistryInt("window Y", window->GetY()); - } - WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun); - pItemsTable->Release(); - pNPCStats->Release(); - - if (pMouse) - pMouse->Deactivate(); - - delete pRenderer; - pAudioPlayer->Release();//error - pNew_LOD->FreeSubIndexAndIO(); - pGames_LOD->FreeSubIndexAndIO(); - ClipCursor(0); - Game::Destroy(); - delete pEventTimer; -} - -//----- (0044EE7C) -------------------------------------------------------- -bool Game::draw_debug_outlines() -{ - if (uFlags & 0x04) - { - pLightmapBuilder->DrawDebugOutlines(-1); - pDecalBuilder->DrawDecalDebugOutlines(); - } - return true; -} - -//----- (0044EC23) -------------------------------------------------------- -int Game::_44EC23(struct Polygon *a2, int *a3, signed int a4) -{ - double v4; // st7@4 - //double v5; // ST00_8@4 - signed int v6; // eax@5 - //double v7; // ST00_8@6 - signed int result; // eax@8 - //double v9; // ST00_8@9 - //double v10; // ST00_8@11 - float a2a; // [sp+14h] [bp+8h]@4 - float a3a; // [sp+18h] [bp+Ch]@4 - float a3b; // [sp+18h] [bp+Ch]@6 - float a4a; // [sp+1Ch] [bp+10h]@9 - float a4b; // [sp+1Ch] [bp+10h]@11 - - if ( this->uFlags2 & 2 && a2->field_59 == 5 && a2->pODMFace->uAttributes & 2 ) - { - v4 = (double)a4; - a2a = v4; - *a3 |= 2u; - a3a = (1.0 - this->fSaturation) * v4; - //v5 = a3a + 6.7553994e15; - //if ( SLODWORD(v5) >= 0 ) - if (floorf(a3a + 0.5f) >= 0 ) - { - a3b = (1.0 - this->fSaturation) * a2a; - //v7 = a3b + 6.7553994e15; - //v6 = LODWORD(v7); - v6 = floorf(a3b + 0.5f); - } - else - v6 = 0; - if ( a4 >= v6 ) - { - a4a = (1.0 - fSaturation) * a2a; - //v9 = a4a + 6.7553994e15; - //if ( SLODWORD(v9) >= 0 ) - if (floorf(a4a + 0.5f) >= 0) - { - a4b = (1.0 - fSaturation) * a2a; - //v10 = a4b + 6.7553994e15; - //result = LODWORD(v10); - result = floorf(a4b + 0.5f); - } - else - result = 0; - } - else - result = a4; - } - else - result = -1; - return result; -} - - - -//----- (00465C8B) -------------------------------------------------------- -Game *Game::Create() -{ - return new Game; -} - -//----- (00465CF3) -------------------------------------------------------- -void Game::Destroy() -{ - delete pGame; - pGame = nullptr; -} - -//----- (0044ED0A) -------------------------------------------------------- -signed int Game::_44ED0A(BLVFace *a2, int *a3, signed int a4) -{ - double v4; // st7@3 - //double v5; // ST00_8@3 - signed int v6; // eax@4 - //double v7; // ST00_8@5 - signed int result; // eax@7 - //double v9; // ST00_8@8 - //double v10; // ST00_8@10 - float v11; // [sp+14h] [bp+8h]@3 - float v12; // [sp+18h] [bp+Ch]@3 - float v13; // [sp+18h] [bp+Ch]@5 - float v14; // [sp+1Ch] [bp+10h]@8 - float v15; // [sp+1Ch] [bp+10h]@10 - - if ( this->uFlags2 & 2 && a2->uAttributes & 2 ) - { - v4 = (double)a4; - v11 = v4; - *a3 |= 2u; - v12 = (1.0 - this->fSaturation) * v4; - //v5 = v12 + 6.7553994e15; - if (floorf(v12 + 0.5f)/* SLODWORD(v5)*/ >= 0 ) - { - v13 = (1.0 - this->fSaturation) * v11; - //v7 = v13 + 6.7553994e15; - //v6 = LODWORD(v7); - v6 = floorf(v13 + 0.5f); - } - else - v6 = 0; - if ( a4 >= v6 ) - { - v14 = (1.0 - fSaturation) * v11; - //v9 = v14 + 6.7553994e15; - if (floorf(v14 + 0.5f)/* SLODWORD(v9)*/ >= 0 ) - { - v15 = (1.0 - fSaturation) * v11; - //v10 = v15 + 6.7553994e15; - //result = LODWORD(v10); - result = floorf(v15 + 0.5f); - } - else - result = 0; - } - else - result = a4; - } - else - result = -1; - return result; -} - - -//----- (0044E4B7) -------------------------------------------------------- -Game::Game() -{ - uNumStationaryLights = 0; - uNumBloodsplats = 0; - field_E0C = 0; - field_E10 = 0; - uNumStationaryLights_in_pStationaryLightsStack = 0; - bGammaControlInitialized = false; - uFlags = 0; - uFlags2 = 0; - uSomeGammaStartTime = 0; - uSomeGammaDeltaTime = 0; - - //pThreadWardInstance = new ThreadWard; - pThreadWardInstance = nullptr; - pParticleEngine = new ParticleEngine; - pMouse = pMouseInstance = new Mouse; - pLightmapBuilder = new LightmapBuilder; - pVisInstance = new Vis; - pStru6Instance = new stru6; - pIndoorCameraD3D = new IndoorCameraD3D; - pStru9Instance = new stru9; - pStru10Instance = new stru10; - //pStru11Instance = new stru11; - pStru11Instance = nullptr; - //pStru12Instance = new stru12(pStru11Instance); - pStru12Instance = nullptr; - //pCShow = new CShow; - pCShow = nullptr; - pKeyboardInstance = new Keyboard; - pGammaController = new GammaController; - - uFlags |= 0x0800; - uFlags2 |= 0x24; - - _44F0FD(); -} - -//----- (0044E7F3) -------------------------------------------------------- -Game::~Game() -{ - delete pGammaController; - delete pKeyboardInstance; -/*delete pCShow; - delete pStru12Instance; - delete pStru11Instance;*/ - delete pStru10Instance; - delete pStru9Instance; - delete pIndoorCameraD3D; - delete pStru6Instance; - delete pVisInstance; - delete pLightmapBuilder; - delete pMouseInstance; - delete pParticleEngine; -//delete pThreadWardInstance; -} - -//----- (0044E904) -------------------------------------------------------- -void Game::_44E904() -{ - //Game *v1; // esi@1 - unsigned __int64 v2; // qax@1 - unsigned int v3; // ecx@1 - int v4; // edi@1 - unsigned __int8 v5; // cf@7 - double v6; // st7@13 - double v7; // st7@15 - signed __int64 v8; // [sp+Ch] [bp-8h]@1 - - //v1 = this; - v2 = pEventTimer->Time(); - v4 = (v2 - uSomeGammaStartTime) >> 32; - v3 = v2 - LODWORD(uSomeGammaStartTime); - v8 = v2 - uSomeGammaStartTime; - if ( v4 < 0 - || SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(uSomeGammaStartTime)) + HIDWORD(uSomeGammaStartTime) | v4 == 0 - && v3 <= 0x80 ) - { - if ( v4 < 0 ) - { - v3 = 0; - v4 = 0; - uSomeGammaStartTime = v2; - v8 = __PAIR__(v4, v3); - } - } - else - { - if ( uSomeGammaDeltaTime ) - { - LODWORD(uSomeGammaDeltaTime) = 0; - HIDWORD(uSomeGammaDeltaTime) = 0; - } - else - { - LODWORD(uSomeGammaDeltaTime) = v3; - HIDWORD(uSomeGammaDeltaTime) = v4; - } - v5 = __CFADD__(v3, -128); - v3 -= 128; - v4 = v5 + v4 - 1; - uSomeGammaStartTime = v2; - v8 = __PAIR__(v4, v3); - } - if ( uSomeGammaDeltaTime ) - v6 = (double)(signed __int64)(uSomeGammaDeltaTime - __PAIR__(v4, v3)); - else - v6 = (double)v8; - v7 = v6 * 0.0078125; - if ( v7 < 0.0 || v7 <= 1.0 ) - { - if ( v7 < 0.0 ) - v7 = 0.0; - } - else - v7 = 1.0; - //if ( pRenderer->pRenderD3D ) - fSaturation = v7; - //else - // fSaturation = (1.0 - 0.5) * v7 + 0.5; -} - -//----- (0044EA17) -------------------------------------------------------- -bool Game::InitializeGammaController() -{ - //if (pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || - //pVersion->pVersionInfo.dwMajorVersion != 4 ) - pGammaController->InitializeFromSurface(pRenderer->pFrontBuffer4); - - bGammaControlInitialized = true; - uSomeGammaStartTime = pEventTimer->Time(); - return true; -} - -//----- (0044EA5E) -------------------------------------------------------- -bool Game::PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) -{ - /*if (pCurrentScreen != SCREEN_GAME|| !pRenderer->pRenderD3D) - return false;*/ - - if (!pVisInstance) - { - MessageBoxW(nullptr, L"The 'Vis' object pointer has not been instatiated, but CGame::Pick() is trying to call through it.", nullptr, 0); - return false; - } - - if (uMouseX >= (signed int)pViewport->uScreen_TL_X && - uMouseX <= (signed int)pViewport->uScreen_BR_X && - uMouseY >= (signed int)pViewport->uScreen_TL_Y && - uMouseY <= (signed int)pViewport->uScreen_BR_Y) - { - pVisInstance->PickMouse(fPickDepth, uMouseX, uMouseY, sprite_filter, face_filter); - - if (bOutline) - OutlineSelection(); - } - - return true; -} -// 4E28F8: using guessed type int pCurrentScreen; - -//----- (0044EB12) -------------------------------------------------------- -bool Game::PickKeyboard(bool bOutline, Vis_SelectionFilter *sprite_filter, Vis_SelectionFilter *face_filter) -{ - if (pCurrentScreen == SCREEN_GAME && pVisInstance /*&& pRenderer->pRenderD3D*/) - { - bool r = pVisInstance->PickKeyboard(&pVisInstance->default_list, sprite_filter, face_filter); - - if (bOutline) - OutlineSelection(); - return r; - } - return false; -} -/* -Result::Code Game::PickKeyboard(bool bOutline, struct unnamed_F93E6C *a3, struct unnamed_F93E6C *a4) -{ - if (dword_4E28F8_PartyCantJumpIfTrue) - return Result::Generic; - - pVis->PickKeyboard(a3, a4); - if (bOutline) - Game_outline_selection((int)this); - return Result::Success; -} -*/ -// 4E28F8: using guessed type int pCurrentScreen; - -//----- (0044EB5A) -------------------------------------------------------- -void Game::OutlineSelection() -{ - if (!pVisInstance) - return; - - if (!pVisInstance->default_list.uNumPointers) - return; - - Vis_ObjectInfo* object_info = pVisInstance->default_list.object_pointers[0]; - if (object_info) - switch (object_info->object_type) - { - case VisObjectType_Sprite: - { - Log::Warning(L"Sprite outline currently unsupported"); - return; - } - - case VisObjectType_Face: - { - if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - { - ODMFace* face = (ODMFace *)object_info->object; - if (face->uAttributes & FACE_OUTLINED) - face->uAttributes &= ~FACE_OUTLINED; - else - face->uAttributes |= FACE_OUTLINED; - } - else if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - BLVFace* face = (BLVFace *)object_info->object; - if (face->uAttributes & FACE_OUTLINED) - face->uAttributes &= ~FACE_OUTLINED; - else - face->uAttributes |= FACE_OUTLINED; - } - else - Error("Invalid level type", uCurrentlyLoadedLevelType); - } - break; - - default: - { - MessageBoxW(nullptr, L"Undefined CObjectInfo type requested in CGame::outline_selection()", nullptr, 0); - ExitProcess(0); - } - } -} -//----- (004304E7) -------------------------------------------------------- -void GameUI_MsgProc() -{ - unsigned int v2; // edx@7 - Actor *pActor; // ecx@13 - int v4; // ecx@18 - unsigned int v10; // ecx@73 - int v14; // eax@98 - int v18; // eax@106 - float v19; // ST64_4@121 - float v21; // ST64_4@126 - float v22; // ST64_4@127 - unsigned int v24; // ecx@149 - GUIWindow *pWindow2; // ecx@248 - bool pKeyBindingFlag; // eax@269 - unsigned int v33; // eax@277 - int v37; // eax@341 - int v38; // eax@358 - SHORT v39; // ax@365 - char *v41; // eax@380 - int v42; // eax@396 - signed int v44; // eax@398 - int v45; // edx@398 - signed int v46; // ecx@398 - char v47; // zf@399 - char v48; // zf@405 - BLVFace *pBLVFace; // ecx@410 - ODMFace *pODMFace; // ecx@412 - CastSpellInfo *pSpellInfo; // ecx@415 - __int16 v53; // ax@431 - int v54; // eax@432 - int v55; // ecx@432 - int v56; // edx@432 - int v57; // eax@432 - Player *pPlayer; // edx@442 - unsigned int pMapNum; // eax@445 - signed int v60; // ST64_4@459 - __int16 v63; // dx@479 - unsigned int v64; // eax@486 - int v65; // ecx@486 - int v66; // eax@488 - char *v67; // eax@489 - __int16 v68; // dx@498 - char *v69; // eax@512 - int v70; // eax@525 - int v71; // edi@527 - NPCData *pNPCData3; // esi@527 - char *v73; // ecx@533 - signed int v74; // edi@535 - int v75; // eax@535 - int v76; // esi@535 - int v77; // eax@537 - Player *pPlayer2; // ecx@549 - signed int v81; // eax@552 - signed int v83; // ecx@554 - signed int v84; // ecx@554 - GUIButton *pButton; // eax@578 - unsigned int v86; // eax@583 - const char *v87; // ecx@595 - const char *v88; // ecx@596 - unsigned int v90; // eax@602 - int v91; // edx@605 - int v92; // eax@605 - int v93; // edx@605 - int pPlayerNum; // edx@611 - int v95; // eax@611 - unsigned int v97; // eax@624 - int v98; // eax@636 - int v103; // eax@671 - Player *pPlayer4; // ecx@718 - int v105; // eax@718 - Player *pPlayer5; // ST78_4@758 - unsigned int v107; // eax@758 - unsigned int v108; // eax@758 - unsigned int v115; // eax@764 - int v116; // eax@776 - unsigned int v118; // eax@785 - unsigned int v119; // ecx@786 - unsigned int v121; // [sp-28h] [bp-624h]@711 - unsigned int v123; // [sp-24h] [bp-620h]@711 - unsigned int v125; // [sp-20h] [bp-61Ch]@711 - int v127; // [sp-1Ch] [bp-618h]@107 - unsigned int v128; // [sp-1Ch] [bp-618h]@711 - GUIButton *pButton2; // [sp-4h] [bp-600h]@59 - const char *v161; // [sp-4h] [bp-600h]@637 - KeyToggleType pKeyToggleType; // [sp+0h] [bp-5FCh]@287 - char *v173; // [sp+0h] [bp-5FCh]@444 - char *v174; // [sp+0h] [bp-5FCh]@449 - const char *v177; // [sp+0h] [bp-5FCh]@629 - char *v178; // [sp+0h] [bp-5FCh]@637 - signed int thisb; // [sp+14h] [bp-5E8h]@272 - Player *pPlayer7; // [sp+14h] [bp-5E8h]@373 - Player *pPlayer8; // [sp+14h] [bp-5E8h]@377 - char *pMapName; // [sp+14h] [bp-5E8h]@445 - Player *pPlayer9; // [sp+14h] [bp-5E8h]@455 - int thisg; // [sp+14h] [bp-5E8h]@467 - int thish; // [sp+14h] [bp-5E8h]@528 - signed int thisi; // [sp+14h] [bp-5E8h]@535 - MapInfo *pMapInfo; // [sp+14h] [bp-5E8h]@604 - Player *pPlayer10; // [sp+14h] [bp-5E8h]@641 - int uMessageParam; // [sp+18h] [bp-5E4h]@7 - int uAction; // [sp+1Ch] [bp-5E0h]@18 - NPCData *pNPCData4; // [sp+20h] [bp-5DCh]@23 - unsigned int uNumSeconds; // [sp+24h] [bp-5D8h]@18 - char v197; // [sp+2Bh] [bp-5D1h]@101 - enum UIMessageType uMessage; // [sp+2Ch] [bp-5D0h]@7 - unsigned int v199; // [sp+30h] [bp-5CCh]@7 - char *v200; // [sp+34h] [bp-5C8h]@518 - POINT v202; // [sp+40h] [bp-5BCh]@141 - POINT a2; // [sp+48h] [bp-5B4h]@127 - POINT v205; // [sp+58h] [bp-5A4h]@171 - POINT v207; // [sp+68h] [bp-594h]@155 - POINT v211; // [sp+88h] [bp-574h]@704 - int v213; // [sp+98h] [bp-564h]@385 - char pLevelName[32]; // [sp+9Ch] [bp-560h]@380 - char pOut[32]; // [sp+BCh] [bp-540h]@370 - FrameTableTxtLine v216; // [sp+DCh] [bp-520h]@524 - int v217[9]; // [sp+158h] [bp-4A4h]@652 - FrameTableTxtLine v218; // [sp+17Ch] [bp-480h]@524 - char a1[64]; // [sp+1F8h] [bp-404h]@467 - char Str2[128]; // [sp+238h] [bp-3C4h]@527 - Actor actor; // [sp+2B8h] [bp-344h]@4 - int currHour; - - dword_50CDC8 = 0; - if ( !pEventTimer->bPaused ) - { - pParty->sEyelevel = pParty->uDefaultEyelevel; - pParty->uPartyHeight = pParty->uDefaultPartyHeight; - } - if ( bDialogueUI_InitializeActor_NPC_ID ) - { - //Actor::Actor(&actor); - memset(&actor, 0, 0x344u); - dword_5B65D0_dialogue_actor_npc_id = bDialogueUI_InitializeActor_NPC_ID; - actor.sNPC_ID = bDialogueUI_InitializeActor_NPC_ID; - GameUI_InitializeDialogue(&actor, false); - bDialogueUI_InitializeActor_NPC_ID = 0; - } - if ( pMessageQueue_50CBD0->uNumMessages ) - { - //v1 = ""; - while ( 2 ) - { - if ( !pMessageQueue_50CBD0->uNumMessages ) - break; - - pMessageQueue_50CBD0->PopMessage(&uMessage, &uMessageParam, (int *)&v199); - switch ( uMessage ) - { - case UIMSG_ChangeGameState: - uGameState = GAME_FINISHED; - continue; - case UIMSG_PlayArcomage: - BackToHouseMenu(); - pArcomageGame->bGameInProgress = 1; - ArcomageGame::PrepareArcomage(); - continue; - case UIMSG_StartNPCDialogue: - if ( !uActiveCharacter ) - continue; - viewparams->field_48 = 1; - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - dword_5B65D0_dialogue_actor_npc_id = pActors[uMessageParam].sNPC_ID; - pActor = &pActors[uMessageParam]; - //goto _actor_init_dlg; - GameUI_InitializeDialogue(pActor, true); - continue; - case UIMSG_StartHireling1Dialogue: - case UIMSG_StartHireling2Dialogue: - { - if (bNoNPCHiring || pCurrentScreen) - continue; - - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - uAction = 0; - int hireling_idx = uMessage - UIMSG_StartHireling1Dialogue; - v4 = 0; - - for (uint i = 0; i < 2; ++i) - //pNPCData0 = pParty->pHirelings; - //do - { - if (pParty->pHirelings[i].pName) - //{ - //v6 = uAction++; - pTmpBuf[uAction++] = i; - //} - //++pNPCData0; - //++v4; - } - //while ( (signed int)pNPCData0 < (signed int)&pParty->pPickedItem ); - - //_this = 0; - for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i) - { - NPCData* npc = &pNPCStats->pNewNPCData[i]; - //do - //{ - if (npc->Hired() && - (!pParty->pHirelings[0].pName || strcmp(npc->pName, pParty->pHirelings[0].pName)) && - (!pParty->pHirelings[1].pName || strcmp(npc->pName, pParty->pHirelings[1].pName)) ) - { - //v7 =; - pTmpBuf[uAction++] = i + 2; - } - //++_this; - //++pNPCData4; - //} - //while ( _this < (signed int)pNPCStats->uNumNewNPCs ); - } - - if ( (signed int)(hireling_idx + pParty->hirelingScrollPosition) < uAction ) - { - //Actor::Actor(&actor); - memset(&actor, 0, 0x344u); - actor.sNPC_ID += -1 - pParty->hirelingScrollPosition - hireling_idx; - pActor = &actor; - GameUI_InitializeDialogue(&actor, true); - } - } - continue; - - case UIMSG_BuyInShop_Identify_Repair: - UIShop_Buy_Identify_Repair(); - continue; - case UIMSG_ClickNPCTopic: - ClickNPCTopic(uMessageParam); - continue; - case UIMSG_SelectShopDialogueOption: - OnSelectShopDialogueOption(uMessageParam); - continue; - case UIMSG_SelectNPCDialogueOption: - OnSelectNPCDialogueOption((DIALOGUE_TYPE)uMessageParam); - continue; - case UIMSG_ClickHouseNPCPortrait: - _4B4224_UpdateNPCTopics(uMessageParam); - continue; - case UIMSG_StartNewGame: - if ( dword_6BE138 == 124 || uMessageParam ) - { - pIcons_LOD->SyncLoadedFilesCount(); - pIcons_LOD->RemoveTexturesPackFromTextureList(); - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pGUIWindow_CurrentMenu->Release(); - uGameState = GAME_STATE_NEWGAME_OUT_GAMEMENU; - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - } - else - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[201], 2);// "Are you sure? Click again to start a New Game" - pAudioPlayer->PlaySound(SOUND_20001, 0, 0, -1, 0, 0, 0, 0); - dword_6BE138 = 124; - } - stru_506E40.Release(); - continue; - case UIMSG_Game_OpenLoadGameDialog: - pIcons_LOD->SyncLoadedFilesCount(); - pIcons_LOD->RemoveTexturesPackFromTextureList(); - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pGUIWindow_CurrentMenu->Release(); - pCurrentScreen = SCREEN_LOADGAME; - LoadUI_Load(1); - continue; - case UIMSG_Quit: - if ( dword_6BE138 == 132 || uMessageParam ) - { - pIcons_LOD->SyncLoadedFilesCount(); - pIcons_LOD->RemoveTexturesPackFromTextureList(); - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pGUIWindow_CurrentMenu->Release(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - if ( !uMessageParam ) - pAudioPlayer->PlaySound((SoundID)(SOUND_EnteringAHouse|0x1), 0, 0, -1, 0, 0, 0, 0); - uGameState = GAME_STATE_GAME_QUITTING_TO_MAIN_MENU; - } - else - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[82], 2);// "Are you sure? Click again to quit" - pAudioPlayer->PlaySound(SOUND_20001, 0, 0, -1, 0, 0, 0, 0); - dword_6BE138 = 132; - } - stru_506E40.Release(); - continue; - case UIMSG_80: - __debugbreak(); - pIcons_LOD->SyncLoadedFilesCount(); - pIcons_LOD->RemoveTexturesPackFromTextureList(); - pGUIWindow_CurrentMenu->Release(); - pCurrentScreen = SCREEN_OPTIONS; - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_8, 0, 0); - continue; - case UIMSG_ArrowUp: - --pSaveListPosition; - if ( pSaveListPosition < 0 ) - pSaveListPosition = 0; - GUIWindow::Create(215, 199, 17, 17, WINDOW_PressedButton2, (int)pBtnArrowUp, 0); - continue; - case UIMSG_DownArrow: - ++pSaveListPosition; - if ( pSaveListPosition >= uMessageParam ) - pSaveListPosition = uMessageParam - 1; - GUIWindow::Create(215, 323, 17, 17, WINDOW_PressedButton2, (int)pBtnDownArrow, 0); - continue; - case UIMSG_Cancel: - GUIWindow::Create(350, 302, 106, 42, WINDOW_CloseRestWindowBtn, (int)pBtnCancel, 0); - continue; - case UIMSG_SaveLoadBtn: - GUIWindow::Create(241, 302, 106, 42, WINDOW_SaveLoadBtn, (int)pBtnLoadSlot, 0); - continue; - case UIMSG_SelectLoadSlot: - if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) - pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_NONE); - if ( pCurrentScreen != SCREEN_SAVEGAME || uLoadGameUI_SelectedSlot != pSaveListPosition + uMessageParam ) - { - v10 = pSaveListPosition + uMessageParam; - if ( dword_6BE138 == pSaveListPosition + uMessageParam ) - { - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_SaveLoadBtn, 0, 0); - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_LoadGame, 0, 0); - } - uLoadGameUI_SelectedSlot = v10; - dword_6BE138 = v10; - } - else - { - pKeyActionMap->EnterText(0, 19, pGUIWindow_CurrentMenu); - if ( strcmp(pSavegameHeader[uLoadGameUI_SelectedSlot].pName, pGlobalTXT_LocalizationStrings[72]) )// "Empty" - strcpy(pKeyActionMap->pPressedKeysBuffer, pSavegameHeader[uLoadGameUI_SelectedSlot].pName); - pKeyActionMap->uNumKeysPressed = strlen(pKeyActionMap->pPressedKeysBuffer); - } - continue; - case UIMSG_LoadGame: - if ( pSavegameUsedSlots[uLoadGameUI_SelectedSlot] ) - { - LoadGame(uLoadGameUI_SelectedSlot); - uGameState = GAME_STATE_LOADING_GAME; - } - stru_506E40.Release(); - continue; - case UIMSG_SaveGame: - if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) - { - pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_NONE); - strcpy((char *)&pSavegameHeader[uLoadGameUI_SelectedSlot], pKeyActionMap->pPressedKeysBuffer); - } - DoSavegame(uLoadGameUI_SelectedSlot); - stru_506E40.Release(); - continue; - case UIMSG_Game_OpenSaveGameDialog: - pGUIWindow_CurrentMenu->Release(); - pCurrentScreen = SCREEN_SAVEGAME; - SaveUI_Load(); - continue; - case UIMSG_Game_OpenOptionsDialog://Open - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pGUIWindow_CurrentMenu->Release(); - viewparams->field_48 = 1; - pCurrentScreen = SCREEN_OPTIONS; - - options_menu_skin.uTextureID_Background = pIcons_LOD->LoadTexture("ControlBG", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_TurnSpeed[2] = pIcons_LOD->LoadTexture("con_16x", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_TurnSpeed[1] = pIcons_LOD->LoadTexture("con_32x", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_TurnSpeed[0] = pIcons_LOD->LoadTexture("con_Smoo", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_ArrowLeft = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_ArrowRight = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_SoundLevels[0] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_SoundLevels[1] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_SoundLevels[2] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_SoundLevels[3] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_SoundLevels[4] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_SoundLevels[5] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_SoundLevels[6] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_SoundLevels[7] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_SoundLevels[8] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_SoundLevels[9] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_FlipOnExit = pIcons_LOD->LoadTexture("option04", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_AlwaysRun = pIcons_LOD->LoadTexture("option03", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_ShowDamage = pIcons_LOD->LoadTexture("option02", TEXTURE_16BIT_PALETTE); - options_menu_skin.uTextureID_WalkSound = pIcons_LOD->LoadTexture("option01", TEXTURE_16BIT_PALETTE); - - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Options, 0, 0); - pGUIWindow_CurrentMenu->CreateButton(22, 270, - pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2])->uTextureWidth, - pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2])->uTextureHeight, - 1, 0, UIMSG_SetTurnSpeed, 0x80, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(93, 270, - pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[1])->uTextureWidth, - pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[1])->uTextureHeight, - 1, 0, UIMSG_SetTurnSpeed, 0x40u, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(164, 270, - pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[0])->uTextureWidth, - pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[0])->uTextureHeight, - 1, 0, UIMSG_SetTurnSpeed, 0, 0, "", 0); - - pGUIWindow_CurrentMenu->CreateButton(20, 303, - pIcons_LOD->GetTexture(options_menu_skin.uTextureID_WalkSound)->uTextureWidth, - pIcons_LOD->GetTexture(options_menu_skin.uTextureID_WalkSound)->uTextureHeight, - 1, 0, UIMSG_ToggleWalkSound, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(128, 303, - pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ShowDamage)->uTextureWidth, - pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ShowDamage)->uTextureHeight, - 1, 0, UIMSG_ToggleShowDamage, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(20, 325, - pIcons_LOD->GetTexture(options_menu_skin.uTextureID_AlwaysRun)->uTextureWidth, - pIcons_LOD->GetTexture(options_menu_skin.uTextureID_AlwaysRun)->uTextureHeight, - 1, 0, UIMSG_ToggleAlwaysRun, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(128, 325, - pIcons_LOD->GetTexture(options_menu_skin.uTextureID_FlipOnExit)->uTextureWidth, - pIcons_LOD->GetTexture(options_menu_skin.uTextureID_FlipOnExit)->uTextureHeight, - 1, 0, UIMSG_ToggleFlipOnExit, 0, 0, "", 0); - - pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(243, 162, 16, 16, 1, 0, UIMSG_ChangeSoundVolume, 4, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0); - pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 162, 16, 16, 1, 0, UIMSG_ChangeSoundVolume, 5, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0); - pGUIWindow_CurrentMenu->CreateButton(263, 162, 172, 17, 1, 0, UIMSG_ChangeSoundVolume, 0, 0, "", 0); - - pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(243, 216, 16, 16, 1, 0, UIMSG_ChangeMusicVolume, 4, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0); - pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 216, 16, 16, 1, 0, UIMSG_ChangeMusicVolume, 5, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0); - pGUIWindow_CurrentMenu->CreateButton(263, 216, 172, 17, 1, 0, UIMSG_ChangeMusicVolume, 0, 0, "", 0); - - pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(243, 270, 16, 16, 1, 0, UIMSG_ChangeVoiceVolume, 4, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0); - pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 270, 16, 16, 1, 0, UIMSG_ChangeVoiceVolume, 5, 0, "", pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0); - pGUIWindow_CurrentMenu->CreateButton(263, 270, 172, 17, 1, 0, UIMSG_ChangeVoiceVolume, 0, 0, "", 0); - - pGUIWindow_CurrentMenu->CreateButton(241, 302, 214, 40, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[619], 0); // "Return to Game" - pGUIWindow_CurrentMenu->CreateButton( 19, 140, 214, 40, 1, 0, UIMSG_OpenKeyMappingOptions, 0, 0x4Bu, "", 0); - pGUIWindow_CurrentMenu->CreateButton( 19, 194, 214, 40, 1, 0, UIMSG_OpenVideoOptions, 0, 86, "", 0); - continue; - - case UIMSG_OpenKeyMappingOptions://Open - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pGUIWindow_CurrentMenu->Release(); - viewparams->field_48 = 1; - pCurrentScreen = SCREEN_KEYBOARD_OPTIONS; - uTextureID_Optkb[0] = pIcons_LOD->LoadTexture("optkb", TEXTURE_16BIT_PALETTE); - uTextureID_Optkb[1] = pIcons_LOD->LoadTexture("optkb_h", TEXTURE_16BIT_PALETTE); - uTextureID_Optkb[2] = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE); - uTextureID_Optkb[3] = pIcons_LOD->LoadTexture("optkb_1", TEXTURE_16BIT_PALETTE); - uTextureID_Optkb[4] = pIcons_LOD->LoadTexture("optkb_2", TEXTURE_16BIT_PALETTE); - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_KeyMappingOptions, 0, 0); - - pGUIWindow_CurrentMenu->CreateButton(241, 302, 214, 40, 1, 0, UIMSG_Escape, 0, 0, "", 0); - - pGUIWindow_CurrentMenu->CreateButton(19, 302, 108, 20, 1, 0, UIMSG_SelectKeyPage1, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(127, 302, 108, 20, 1, 0, UIMSG_SelectKeyPage2, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(127, 324, 108, 20, 1, 0, UIMSG_ResetKeyMapping, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(19, 324, 108, 20, 1, 0, UIMSG_Game_OpenOptionsDialog, 0, 0, "", 0); - - pGUIWindow_CurrentMenu->CreateButton(129, 148, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(129, 167, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 1, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(129, 186, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 2, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(129, 205, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 3, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(129, 224, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 4, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(129, 243, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 5, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(129, 262, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 6, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(350, 148, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 7, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(350, 167, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 8, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(350, 186, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 9, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(350, 205, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 10, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(350, 224, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 11, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(350, 243, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 12, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(350, 262, 70, 19, 1, 0, UIMSG_ChangeKeyButton, 13, 0, "", 0); - - uGameMenuUI_CurentlySelectedKeyIdx = -1; - KeyboardPageNum = 1; - memset(GameMenuUI_InvaligKeyBindingsFlags.data(), 0, sizeof(GameMenuUI_InvaligKeyBindingsFlags)); - //*(_WORD *)KeyButtonArray[28] = 0; - memcpy(pPrevVirtualCidesMapping.data(), pKeyActionMap->pVirtualKeyCodesMapping, 0x78u); - continue; - case UIMSG_ChangeKeyButton: - if ( uGameMenuUI_CurentlySelectedKeyIdx != -1 ) - { - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); - continue; - } - v14 = uMessageParam; - if ( KeyboardPageNum != 1 ) - v14 = uMessageParam + 14; - uGameMenuUI_CurentlySelectedKeyIdx = v14; - pKeyActionMap->EnterText(0, 1, pGUIWindow_CurrentMenu); - continue; - case UIMSG_ResetKeyMapping: - v197 = 1; - pKeyActionMap->SetDefaultMapping(); - for ( uint i = 0; i < 28; i++ ) - { - if ( pKeyActionMap->GetActionVKey((enum InputAction)i) != pPrevVirtualCidesMapping[i] ) - { - if ( v197 ) - { - GUI_ReplaceHotkey(LOBYTE(pPrevVirtualCidesMapping[i]), pKeyActionMap->GetActionVKey((enum InputAction)i), 1); - v197 = 0; - } - else - GUI_ReplaceHotkey(LOBYTE(pPrevVirtualCidesMapping[i]), pKeyActionMap->GetActionVKey((enum InputAction)i), 0); - } - pPrevVirtualCidesMapping[i] = pKeyActionMap->GetActionVKey((enum InputAction)i); - GameMenuUI_InvaligKeyBindingsFlags[i] = false; - } - pAudioPlayer->PlaySound((SoundID)219, 0, 0, -1, 0, 0, 0, 0); - continue; - case UIMSG_SelectKeyPage1: - KeyboardPageNum = 1; - continue; - case UIMSG_SelectKeyPage2: - KeyboardPageNum = 2; - continue; - case UIMSG_OpenVideoOptions: - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pGUIWindow_CurrentMenu->Release(); - viewparams->field_48 = 1; - pCurrentScreen = SCREEN_VIDEO_OPTIONS; - optvid_base_texture_id = pIcons_LOD->LoadTexture("optvid", TEXTURE_16BIT_PALETTE); - bloodsplats_texture_id = pIcons_LOD->LoadTexture("opvdH-bs", TEXTURE_16BIT_PALETTE); - us_colored_lights_texture_id = pIcons_LOD->LoadTexture("opvdH-cl", TEXTURE_16BIT_PALETTE); - tinting_texture_id = pIcons_LOD->LoadTexture("opvdH-tn", TEXTURE_16BIT_PALETTE); - uTextureID_507C20 = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE); - uTextureID_507C24 = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE); - pTextureIDs_GammaPositions[0] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE); - pTextureIDs_GammaPositions[1] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE); - pTextureIDs_GammaPositions[2] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE); - pTextureIDs_GammaPositions[3] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE); - pTextureIDs_GammaPositions[4] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE); - pTextureIDs_GammaPositions[5] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE); - pTextureIDs_GammaPositions[6] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE); - pTextureIDs_GammaPositions[7] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE); - pTextureIDs_GammaPositions[8] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE); - pTextureIDs_GammaPositions[9] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE); - not_available_bloodsplats_texture_id = pIcons_LOD->LoadTexture("opvdG-bs", TEXTURE_16BIT_PALETTE); - not_available_us_colored_lights_texture_id = pIcons_LOD->LoadTexture("opvdG-cl", TEXTURE_16BIT_PALETTE); - not_available_tinting_texture_id = pIcons_LOD->LoadTexture("opvdG-tn", TEXTURE_16BIT_PALETTE); - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_VideoOptions, 0, 0); - pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, 1, 0, UIMSG_Escape, 0, 0, "", 0); - //if ( pRenderer->pRenderD3D ) - { - pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x118u, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleBloodsplats, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x12Eu, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleColoredLights, 0, 0, "", 0); - pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x144u, 0xD6u, 0x12u, 1, 0, UIMSG_ToggleTint, 0, 0, "", 0); - } - /*if ( !pRenderer->bWindowMode ) - { - //v0 = 1; - if ( pRenderer->IsGammaSupported() ) - { - pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0x15u, 0xA1u, 0x10u, 0x10u, 1, 0, UIMSG_1A9, 4u, 0, "", pIcons_LOD->GetTexture(uTextureID_507C20), 0); - pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0xD5u, 0xA1u, 0x10u, 0x10u, 1, 0, UIMSG_1A9, 5u, 0, "", pIcons_LOD->GetTexture(uTextureID_507C24), 0); - pGUIWindow_CurrentMenu->CreateButton(42, 162, 170, 18, 1, 0, UIMSG_1A9, 0, 0, "", 0); - } - }*/ - continue; - case UIMSG_1A9: - __debugbreak(); - if ( uMessageParam == 4 ) - { - //--uGammaPos; - if ( (uGammaPos -- -1) < 0 ) - { - uGammaPos = 0; - pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0); - continue; - } - v19 = (double)(signed int)uGammaPos * 0.1 + 0.6; - pGame->pGammaController->Initialize(v19); - GUIWindow::Create(21, 161, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, (char *)1); - pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0); - continue; - } - if ( uMessageParam == 5 ) - { - ++uGammaPos; - if ( (signed int)uGammaPos <= 9 ) - { - v21 = (double)(signed int)uGammaPos * 0.1 + 0.6; - pGame->pGammaController->Initialize(v21); - GUIWindow::Create(213, 161, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, (char *)1); - pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0); - continue; - } - uGammaPos = 9; - } - else - { - uGammaPos = (pMouse->GetCursorPos(&a2)->x - 42) / 17; - v22 = (double)(signed int)uGammaPos * 0.1 + 0.6; - pGame->pGammaController->Initialize(v22); - } - pAudioPlayer->PlaySound((SoundID)21, 0, 0, -1, 0, 0, 0, 0); - continue; - case UIMSG_ToggleBloodsplats: - pGame->ToggleFlags2(0x20u); - continue; - case UIMSG_ToggleColoredLights: - pRenderer->ToggleColoredLights(); - continue; - case UIMSG_ToggleTint: - pRenderer->ToggleTint(); - continue; - case UIMSG_ChangeMusicVolume: - if ( uMessageParam == 4 )//- - { - --uMusicVolimeMultiplier; - if ( (char)uMusicVolimeMultiplier < 1 ) - uMusicVolimeMultiplier = 0; - GUIWindow::Create(243, 216, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, (char *)1); - if ( uMusicVolimeMultiplier ) - pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f, 0); - pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); - continue; - } - if ( uMessageParam == 5 )//+ - { - ++uMusicVolimeMultiplier; - if ( (char)uMusicVolimeMultiplier > 9 ) - uMusicVolimeMultiplier = 9; - GUIWindow::Create(435, 216, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, (char *)1); - if ( uMusicVolimeMultiplier ) - pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f, 0); - pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); - continue; - } - uMusicVolimeMultiplier = (pMouse->GetCursorPos(&v202)->x - 263) / 17;//for mouse - if ( (char)uMusicVolimeMultiplier > 9 ) - uMusicVolimeMultiplier = 9; - if ( uMusicVolimeMultiplier ) - pAudioPlayer->PlaySound(SOUND_Bell, -1, 0, -1, 0, 0, pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f, 0); - pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); - continue; - case UIMSG_ChangeSoundVolume: - if ( uMessageParam == 4 )//reduce sound level button left - { - --uSoundVolumeMultiplier; - if ( (char)uSoundVolumeMultiplier < 1 ) - uSoundVolumeMultiplier = 0; - GUIWindow::Create(243, 162, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, (char *)1); - pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f); - pAudioPlayer->PlaySound((SoundID)218, -1, 0, -1, 0, 0, 0, 0); - //int v = AIL_redbook_volume(pAudioPlayer->hAILRedbook); - //if (v) - //__debugbreak(); - continue; - } - if ( uMessageParam == 5 )//Increase sound level button right - { - ++uSoundVolumeMultiplier; - if ( (char)uSoundVolumeMultiplier > 8 ) - uSoundVolumeMultiplier = 9; - //v168 = 1; - v24 = 435; - //v154 = (int)pBtn_SliderRight; - GUIWindow::Create(v24, 0xA2u, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, (char *)1); - pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f); - pAudioPlayer->PlaySound((SoundID)218, -1, 0, -1, 0, 0, 0, 0); - continue; - } - uSoundVolumeMultiplier = (pMouse->GetCursorPos(&v207)->x - 263) / 17; - if ( (char)uSoundVolumeMultiplier > 8 ) - uSoundVolumeMultiplier = 9; - pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f); - pAudioPlayer->PlaySound((SoundID)218, -1, 0, -1, 0, 0, 0, 0); - continue; - case UIMSG_ToggleFlipOnExit: - bFlipOnExit = bFlipOnExit == 0; - continue; - case UIMSG_ToggleAlwaysRun: - bAlwaysRun = bAlwaysRun == 0; - continue; - case UIMSG_ToggleWalkSound: - bWalkSound = bWalkSound == 0; - continue; - case UIMSG_ToggleShowDamage: - bShowDamage = bShowDamage == 0; - continue; - case UIMSG_ChangeVoiceVolume: - if ( uMessageParam == 4 ) - { - --uVoicesVolumeMultiplier; - if ( (char)uVoicesVolumeMultiplier < 1 ) - uVoicesVolumeMultiplier = 0; - GUIWindow::Create(243, 270, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, (char *)1); - if ( !uVoicesVolumeMultiplier ) - continue; - pAudioPlayer->PlaySound((SoundID)5788, -1, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0); - continue; - } - if ( uMessageParam == 5 ) - { - ++uVoicesVolumeMultiplier; - if ( (char)uVoicesVolumeMultiplier > 8 ) - uVoicesVolumeMultiplier = 9; - GUIWindow::Create(435, 270, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderRight, (char *)1); - if ( !uVoicesVolumeMultiplier ) - continue; - pAudioPlayer->PlaySound((SoundID)5788, -1, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0); - continue; - } - uVoicesVolumeMultiplier = (pMouse->GetCursorPos(&v205)->x - 263) / 17; - if ( (char)uVoicesVolumeMultiplier > 8 ) - uVoicesVolumeMultiplier = 9; - if ( !uVoicesVolumeMultiplier ) - continue; - pAudioPlayer->PlaySound((SoundID)5788, -1, 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0); - continue; - case UIMSG_SetTurnSpeed: - if ( uMessageParam ) - pParty->sRotationY = uMessageParam * pParty->sRotationY / uMessageParam; - uTurnSpeed = uMessageParam; - continue; - - case UIMSG_SetGraphicsMode: - /*if ( !bUseLoResSprites ) - { - byte_6BE388_graphicsmode = uMessageParam; - MM7Initialization(); - continue; - } - if ( uMessageParam ) - { - if ( uMessageParam == 1 ) - { - byte_6BE388_graphicsmode = 0; - } - else - { - if ( uMessageParam != 2 ) - continue; - byte_6BE388_graphicsmode = 1; - } - MM7Initialization(); - continue; - }*/ - ModalWindow(pNPCTopics[453].pText, UIMSG_0); - __debugbreak(); // Nomad: graphicsmode as it was now removed - continue; - - case UIMSG_GameMenu_ReturnToGame: - pGUIWindow_CurrentMenu->Release(); - pEventTimer->Resume(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - stru_506E40.Release(); - continue; - case UIMSG_OpenQuestBook: - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - if ( pCurrentScreen ) - pGUIWindow_CurrentMenu->Release(); - pEventTimer->Pause(); - pAudioPlayer->StopChannels(-1, -1); - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, uMessage, 0); - pBooksWindow = GUIWindow::Create(493u, 355u, 0, 0, WINDOW_BooksWindow, (int)pBtn_Quests, 0); - bFlashQuestBook = 0; - continue; - case UIMSG_OpenAutonotes: - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - if ( pCurrentScreen ) - pGUIWindow_CurrentMenu->Release(); - pEventTimer->Pause(); - pAudioPlayer->StopChannels(-1, -1); - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, uMessage, 0); - pBooksWindow = GUIWindow::Create(527u, 353u, 0, 0, WINDOW_BooksWindow, (int)pBtn_Autonotes, 0); - bFlashAutonotesBook = 0; - continue; - case UIMSG_OpenMapBook: - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - if ( pCurrentScreen ) - pGUIWindow_CurrentMenu->Release(); - pEventTimer->Pause(); - viewparams->sViewCenterX = pParty->vPosition.x; - viewparams->sViewCenterY = pParty->vPosition.y; - pAudioPlayer->StopChannels(-1, -1); - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, uMessage, 0); - pBooksWindow = GUIWindow::Create(546, 353, 0, 0, WINDOW_BooksWindow, (int)pBtn_Maps, 0); - continue; - case UIMSG_OpenCalendar: - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - if ( pCurrentScreen ) - pGUIWindow_CurrentMenu->Release(); - pEventTimer->Pause(); - pAudioPlayer->StopChannels(-1, -1); - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, uMessage, 0); - pBooksWindow = GUIWindow::Create(570, 354, 0, 0, WINDOW_BooksWindow, (int)pBtn_Calendar, 0); - continue; - case UIMSG_OpenHistoryBook: - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - if ( pCurrentScreen ) - pGUIWindow_CurrentMenu->Release(); - pEventTimer->Pause(); - pAudioPlayer->StopChannels(-1, -1); - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, uMessage, 0); - pBooksWindow = GUIWindow::Create(0x258u, 0x169u, 0, 0, WINDOW_BooksWindow, (int)pBtn_History, 0); - bFlashHistoryBook = 0; - continue; - case UIMSG_Escape:// íàæàòèå Escape and return to game - back_to_game(); - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - switch ( pCurrentScreen ) - { - case SCREEN_E: - __debugbreak(); - case SCREEN_NPC_DIALOGUE: - case SCREEN_CHEST: - case SCREEN_CHEST_INVENTORY: - case SCREEN_CHANGE_LOCATION: - case SCREEN_INPUT_BLV: - case SCREEN_QUICK_REFERENCE: - if ( dword_50CDC8 ) - break; - CloseWindowBackground(); - uMessageParam = 1; - break; - case SCREEN_HOUSE: - if ( !dword_50CDC8 ) - { - CloseWindowBackground(); - uMessageParam = 1; - break; - } - break; - } - if ( !pModalWindow ) - { - pRenderer->ClearZBuffer(0, 479); - viewparams->bRedrawGameUI = 1; - viewparams->field_48 = 1; - if ( pCurrentScreen ) - { - if ( pCurrentScreen > SCREEN_67 ) - { - if ( pCurrentScreen == SCREEN_QUICK_REFERENCE ) - { - pIcons_LOD->RemoveTexturesPackFromTextureList(); - if ( pGUIWindow_Settings ) - { - if ( pCurrentScreen == SCREEN_CHARACTERS ) - pMouse->SetCursorBitmap("MICON2"); - else - { - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - } - } - 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; - } - } - else - { - if ( pCurrentScreen < SCREEN_64 ) - { - switch ( pCurrentScreen ) - { - case SCREEN_CASTING: - pIcons_LOD->RemoveTexturesPackFromTextureList(); - if ( some_active_character ) - { - uActiveCharacter = some_active_character; - uActiveCharacter = pParty->GetNextActiveCharacter(); - some_active_character = 0; - if ( pParty->bTurnBasedModeOn ) - pTurnEngine->ApplyPlayerAction(); - _50C9D0_AfterEnchClickEventId = 0; - _50C9D4_AfterEnchClickEventSecondParam = 0; - _50C9D8_AfterEnchClickEventTimeout = 0; - } - if ( ptr_50C9A4_ItemToEnchant && ptr_50C9A4_ItemToEnchant->uItemID ) - { - LOBYTE(ptr_50C9A4_ItemToEnchant->uAttributes) &= 0xFu; - _50C9A8_item_enchantment_timer = 0; - ptr_50C9A4_ItemToEnchant = nullptr; - } - if ( pGUIWindow_Settings ) - { - if ( pCurrentScreen == SCREEN_CHARACTERS ) - pMouse->SetCursorBitmap("MICON2"); - else - { - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - } - } - 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; - case SCREEN_BOOKS: - pBooksWindow->Release(); - //crt_deconstruct_ptr_6A0118(); - pBooksWindow = 0; - pEventTimer->Resume(); - if ( pGUIWindow_Settings ) - { - if ( pCurrentScreen == SCREEN_CHARACTERS ) - pMouse->SetCursorBitmap("MICON2"); - else - { - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - } - } - 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; - case SCREEN_SAVEGAME: - case SCREEN_LOADGAME: - pIcons_LOD->RemoveTexturesPackFromTextureList(); - //crt_deconstruct_ptr_6A0118(); - stru_506E40.Release(); - break; - case SCREEN_CHEST_INVENTORY: - pCurrentScreen = SCREEN_CHEST; - continue; - case SCREEN_CHEST: - pWindow2 = pChestWindow; - pWindow2->Release(); - pIcons_LOD->RemoveTexturesPackFromTextureList(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - pEventTimer->Resume(); - continue; - case SCREEN_19: - __debugbreak(); - pWindow2 = ptr_507BC8; - pWindow2->Release(); - pIcons_LOD->RemoveTexturesPackFromTextureList(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - pEventTimer->Resume(); - continue; - case SCREEN_OPTIONS://Close - options_menu_skin.Relaease(); - pIcons_LOD->SyncLoadedFilesCount(); - WriteWindowsRegistryInt("soundflag", (char)uSoundVolumeMultiplier); - WriteWindowsRegistryInt("musicflag", (char)uMusicVolimeMultiplier); - WriteWindowsRegistryInt("CharVoices", (char)uVoicesVolumeMultiplier); - WriteWindowsRegistryInt("WalkSound", bWalkSound); - WriteWindowsRegistryInt("ShowDamage", bShowDamage); - //WriteWindowsRegistryInt("graphicsmode", (unsigned __int8)byte_6BE388_graphicsmode); - WriteWindowsRegistryInt("valAlwaysRun", bAlwaysRun); - WriteWindowsRegistryInt("FlipOnExit", bFlipOnExit); - if ( !uTurnSpeed ) - { - WriteWindowsRegistryInt("TurnDelta", 3); - stru_506E40.Release(); - break; - } - if ( uTurnSpeed == 64 ) - { - WriteWindowsRegistryInt("TurnDelta", 2); - stru_506E40.Release(); - break; - } - if ( uTurnSpeed != 128 ) - { - stru_506E40.Release(); - break; - } - WriteWindowsRegistryInt("TurnDelta", 1); - stru_506E40.Release(); - break; - case SCREEN_MENU: - pIcons_LOD->SyncLoadedFilesCount(); - pIcons_LOD->RemoveTexturesPackFromTextureList(); - pIcons_LOD->SyncLoadedFilesCount(); - pIcons_LOD->RemoveTexturesPackFromTextureList(); - stru_506E40.Release(); - break; - case SCREEN_VIDEO_OPTIONS: - //if ( pRenderer->pRenderD3D ) - { - WriteWindowsRegistryInt("Colored Lights", pRenderer->bUseColoredLights); - WriteWindowsRegistryInt("Tinting", pRenderer->bTinting); - WriteWindowsRegistryInt("Bloodsplats", (LOBYTE(pGame->uFlags2) >> 5) & 1); - } - /*if ( !pRenderer->bWindowMode ) - WriteWindowsRegistryInt("GammaPos", uGammaPos);*/ - - stru_506E40.Release(); - break; - - case SCREEN_KEYBOARD_OPTIONS://Return to game - v197 = 1; - pKeyBindingFlag = false; - for ( uint i = 0; i < 28; ++i ) - { - if ( GameMenuUI_InvaligKeyBindingsFlags[i] ) - pKeyBindingFlag = true; - } - if ( !pKeyBindingFlag ) - { - for ( uint i = 0; i < 5; i++ ) - { - if ( uTextureID_Optkb[i] ) - pIcons_LOD->pTextures[uTextureID_Optkb[i]].Release(); - } - memset(&uTextureID_Optkb, 0, 20); - pIcons_LOD->SyncLoadedFilesCount(); - for ( uint i = 0; i < 28; ++i ) - { - if ( pKeyActionMap->GetActionVKey((enum InputAction)i) != pPrevVirtualCidesMapping[i] ) - { - if ( v197 ) - { - GUI_ReplaceHotkey(pKeyActionMap->GetActionVKey((enum InputAction)i), LOBYTE(pPrevVirtualCidesMapping[i]), 1); - v197 = 0; - } - else - GUI_ReplaceHotkey(pKeyActionMap->GetActionVKey((enum InputAction)i), LOBYTE(pPrevVirtualCidesMapping[i]), 0); - } - if ( i > 3 && i != 25 && i != 26 ) - pKeyToggleType = TOGGLE_OneTimePress; - else - pKeyToggleType = TOGGLE_Continuously; - pKeyActionMap->SetKeyMapping(i, pPrevVirtualCidesMapping[i], pKeyToggleType); - } - pKeyActionMap->StoreMappings(); - stru_506E40.Release(); - break; - } - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); - break; - case SCREEN_REST://close rest screen - if ( dword_506F14 ) - { - Rest(_506F18_num_minutes_to_sleep); - 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(); - pTexture_RestUI_CurrentHourglassFrame = 0; - 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; - if ( pGUIWindow_Settings ) - { - if ( pCurrentScreen == SCREEN_CHARACTERS ) - pMouse->SetCursorBitmap("MICON2"); - else - { - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - } - } - 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; - case SCREEN_E: - __debugbreak(); - pGUIWindow_CurrentMenu->Release(); - pCurrentScreen = SCREEN_HOUSE; - pIcons_LOD->RemoveTexturesPackFromTextureList(); - continue; - case SCREEN_HOUSE: - if ( uDialogueType ) - uDialogueType = 0; - if ( uGameState == GAME_STATE_CHANGE_LOCATION ) - { - while ( HouseDialogPressCloseBtn() ) - ; - } - else - { - if ( HouseDialogPressCloseBtn() ) - continue; - } - GetHouseGoodbyeSpeech(); - pAudioPlayer->PlaySound(SOUND_7, 814, 0, -1, 0, 0, 0, 0); - pMediaPlayer->Unload(); - pGUIWindow_CurrentMenu = window_SpeakInHouse; - if ( pGUIWindow_Settings ) - { - if ( pCurrentScreen == SCREEN_CHARACTERS ) - pMouse->SetCursorBitmap("MICON2"); - else - { - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - } - } - 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 = true; - pIcons_LOD->RemoveTexturesFromTextureList(); - continue; - case SCREEN_INPUT_BLV://click escape - if ( uCurrentHouse_Animation == 153 ) - PlayHouseSound(0x99u, HouseSound_Greeting_2); - pMediaPlayer->Unload(); - if ( npcIdToDismissAfterDialogue ) - { - pParty->hirelingScrollPosition = 0; - LOBYTE(pNPCStats->pNewNPCData[npcIdToDismissAfterDialogue].uFlags) &= 0x7Fu; - pParty->CountHirelings(); - viewparams->bRedrawGameUI = true; - npcIdToDismissAfterDialogue = 0; - } - DialogueEnding(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = true; - continue; - case SCREEN_NPC_DIALOGUE://click escape - if ( npcIdToDismissAfterDialogue ) - { - pParty->hirelingScrollPosition = 0; - LOBYTE(pNPCStats->pNewNPCData[npcIdToDismissAfterDialogue].uFlags) &= 0x7Fu; - pParty->CountHirelings(); - viewparams->bRedrawGameUI = true; - npcIdToDismissAfterDialogue = 0; - } - //goto LABEL_317; - DialogueEnding(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = true; - continue; - case SCREEN_BRANCHLESS_NPC_DIALOG://click escape - memset(GameUI_Footer_TimedString.data(), 0, 0xC8u); - sub_4452BB(); - DialogueEnding(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = true; - continue; - case SCREEN_CHANGE_LOCATION://click escape - if ( pParty->vPosition.x < -22528 ) - pParty->vPosition.x = -22528; - if ( pParty->vPosition.x > 22528 ) - pParty->vPosition.x = 22528; - if ( pParty->vPosition.y < -22528 ) - pParty->vPosition.y = -22528; - if ( pParty->vPosition.y > 22528 ) - pParty->vPosition.y = 22528; - DialogueEnding(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = true; - continue; - case SCREEN_VIDEO: - pMediaPlayer->Unload(); - continue; - case SCREEN_CHARACTERS: - CharacterUI_ReleaseButtons(); - ReleaseAwardsScrollBar(); - pIcons_LOD->RemoveTexturesPackFromTextureList(); - if ( pGUIWindow_Settings ) - { - if ( pCurrentScreen == SCREEN_CHARACTERS ) - pMouse->SetCursorBitmap("MICON2"); - else - { - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - } - } - 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 = true; - pIcons_LOD->RemoveTexturesFromTextureList(); - continue; - default: - if ( pGUIWindow_Settings ) - { - if ( pCurrentScreen == SCREEN_CHARACTERS ) - pMouse->SetCursorBitmap("MICON2"); - else - { - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - } - } - 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; - } - if ( pGUIWindow_Settings ) - { - if ( pCurrentScreen == SCREEN_CHARACTERS ) - pMouse->SetCursorBitmap("MICON2"); - else - { - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - } - } - 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 = true; - pIcons_LOD->RemoveTexturesFromTextureList(); - continue; - } - CharacterUI_ReleaseButtons(); - ReleaseAwardsScrollBar(); - pIcons_LOD->RemoveTexturesPackFromTextureList(); - } - if ( pGUIWindow_Settings ) - { - if ( pCurrentScreen == SCREEN_CHARACTERS ) - pMouse->SetCursorBitmap("MICON2"); - else - { - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - } - } - 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 = true; - pIcons_LOD->RemoveTexturesFromTextureList(); - continue; - } - if ( !pGUIWindow_Settings )//Draw Menu - { - dword_6BE138 = -1; - GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_PressedButton2, (int)pBtn_GameSettings, (char *)1); - pEventTimer->Pause(); - pAudioPlayer->StopChannels(-1, -1); - pCurrentScreen = SCREEN_MENU; - - ++pIcons_LOD->uTexturePacksCount; - if ( !pIcons_LOD->uNumPrevLoadedFiles ) - pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; - - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_OptionsButtons, 0, 0); - uTextureID_Options = pIcons_LOD->LoadTexture("options", TEXTURE_16BIT_PALETTE); - uTextureID_New1 = pIcons_LOD->LoadTexture("new1", TEXTURE_16BIT_PALETTE); - uTextureID_Load1 = pIcons_LOD->LoadTexture("load1", TEXTURE_16BIT_PALETTE); - uTextureID_Save1 = pIcons_LOD->LoadTexture("save1", TEXTURE_16BIT_PALETTE); - uTextureID_Controls1 = pIcons_LOD->LoadTexture("controls1", TEXTURE_16BIT_PALETTE); - uTextureID_Resume1 = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE); - uTextureID_Quit1 = pIcons_LOD->LoadTexture("quit1", TEXTURE_16BIT_PALETTE); - pBtn_NewGame = pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x9Bu, 0xD6u, 0x28u, 1, 0, UIMSG_StartNewGame, 0, 0x4Eu, - pGlobalTXT_LocalizationStrings[614],// "New Game" - pIcons_LOD->GetTexture(uTextureID_New1), 0); - pBtn_SaveGame = pGUIWindow_CurrentMenu->CreateButton(0x13u, 0xD1u, 0xD6u, 0x28u, 1, 0, UIMSG_Game_OpenSaveGameDialog, 0, 0x53u, - pGlobalTXT_LocalizationStrings[615],// "Save Game" - pIcons_LOD->GetTexture(uTextureID_Save1), 0); - pBtn_LoadGame = pGUIWindow_CurrentMenu->CreateButton(19, 263, 0xD6u, 0x28u, 1, 0, UIMSG_Game_OpenLoadGameDialog, 0, 0x4Cu, - pGlobalTXT_LocalizationStrings[616],// "Load Game" - pIcons_LOD->GetTexture(uTextureID_Load1), 0); - pBtn_GameControls = pGUIWindow_CurrentMenu->CreateButton(241, 155, 214, 40, 1, 0, UIMSG_Game_OpenOptionsDialog, 0, 0x43u, - pGlobalTXT_LocalizationStrings[617],// ""Sound, Keyboard, Game Options:"" - pIcons_LOD->GetTexture(uTextureID_Controls1), 0); - pBtn_QuitGame = pGUIWindow_CurrentMenu->CreateButton(241, 209, 214, 40, 1, 0, UIMSG_Quit, 0, 0x51u, - pGlobalTXT_LocalizationStrings[618],// "Quit" - pIcons_LOD->GetTexture(uTextureID_Quit1), 0); - pBtn_Resume = pGUIWindow_CurrentMenu->CreateButton(241, 263, 214, 40, 1, 0, UIMSG_GameMenu_ReturnToGame, 0, 0x52u, - pGlobalTXT_LocalizationStrings[619],// "Return to Game" - pIcons_LOD->GetTexture(uTextureID_Resume1), 0); - pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(6, 1, 0, 0); - viewparams->field_48 = 1; - - stru_506E40.Release(); - pRenderer->SaveScreenshot("gamma.pcx", 155, 117); - stru_506E40.LoadPCXFile("gamma.pcx", 0); - - continue; - } - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - continue; - } - ModalWindow_Release(); - continue; - case UIMSG_ScrollNPCPanel://Right and Left button for NPCPanel - if ( uMessageParam ) - { - GUIWindow::Create(626, 179, 0, 0, WINDOW_PressedButton2, (int)pBtn_NPCRight, 0); - v37 = (pParty->pHirelings[0].pName != 0) + (pParty->pHirelings[1].pName != 0) + (unsigned __int8)pParty->field_70A - 2; - if ( pParty->hirelingScrollPosition < v37 ) - { - ++pParty->hirelingScrollPosition;//??? maybe number of the first cell??? - if ( pParty->hirelingScrollPosition >= v37 ) - pParty->hirelingScrollPosition = (pParty->pHirelings[0].pName != 0) + (pParty->pHirelings[1].pName != 0) + pParty->field_70A - 2; - } - } - else - { - GUIWindow::Create(469, 179, 0, 0, WINDOW_PressedButton2, (int)pBtn_NPCLeft, 0); - /*if ( pParty->field_709 ) - { - --pParty->field_709; - if ( pParty->field_709 < 1 ) - pParty->field_709 = 0; - }*/ - } - GameUI_DrawHiredNPCs(); - continue; - case UIMSG_TransitionUI_Confirm: - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - dword_50CDC8 = 1; - sub_42FBDD(); - PlayHouseSound(uCurrentHouse_Animation, HouseSound_NotEnoughMoney_TrainingSuccessful); - - if (pMovie_Track) - pMediaPlayer->Unload(); - DialogueEnding(); - viewparams->bRedrawGameUI = true; - if ( dword_59117C_teleportx | dword_591178_teleporty | dword_591174_teleportz | dword_591170_teleport_directiony | dword_59116C_teleport_directionx | dword_591168_teleport_speedz ) - { - if ( dword_59117C_teleportx ) - { - pParty->vPosition.x = dword_59117C_teleportx; - _5B65A8_npcdata_uflags_or_other = dword_59117C_teleportx; - } - if ( dword_591178_teleporty ) - { - pParty->vPosition.y = dword_591178_teleporty; - _5B65AC_npcdata_fame_or_other = dword_591178_teleporty; - } - if ( dword_591174_teleportz ) - { - pParty->vPosition.z = dword_591174_teleportz; - _5B65B0_npcdata_rep_or_other = dword_591174_teleportz; - pParty->uFallStartY = dword_591174_teleportz; - } - if ( dword_591170_teleport_directiony ) - { - pParty->sRotationY = dword_591170_teleport_directiony; - _5B65B4_npcdata_loword_house_or_other = dword_591170_teleport_directiony; - } - if ( dword_59116C_teleport_directionx ) - { - pParty->sRotationX = dword_59116C_teleport_directionx; - _5B65B8_npcdata_hiword_house_or_other = dword_59116C_teleport_directionx; - v38 = dword_591168_teleport_speedz; - pParty->uFallSpeed = dword_591168_teleport_speedz; - dword_5B65BC = dword_591168_teleport_speedz; - } - else - v38 = dword_5B65BC; - if ( *dword_591164_teleport_map_name != 48 ) - { - pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)2; - dword_5B65C0 = _5B65A8_npcdata_uflags_or_other | _5B65AC_npcdata_fame_or_other | _5B65B0_npcdata_rep_or_other | _5B65B4_npcdata_loword_house_or_other | _5B65B8_npcdata_hiword_house_or_other | v38; - OnMapLeave(); - Transition_StopSound_Autosave(dword_591164_teleport_map_name, MapStartPoint_Party); - } - } - else - EventProcessor(dword_5C3418, 0, 1, dword_5C341C); - if ( !_stricmp(byte_6BE3B0.data(), "d05.blv") ) - pParty->uTimePlayed += 1474560i64; - continue; - case UIMSG_TransitionWindowCloseBtn: - CloseWindowBackground(); - pMediaPlayer->Unload(); - DialogueEnding(); - viewparams->bRedrawGameUI = true; - continue; - case UIMSG_CycleCharacters: - v39 = GetAsyncKeyState(VK_SHIFT); - uActiveCharacter = CycleCharacter(v39); - viewparams->bRedrawGameUI = true; - continue; - case UIMSG_OnTravelByFoot: - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - dword_50CDC8 = 1; - sub_42FBDD(); - //pNPCData4 = (NPCData *)GetTravelTime(); - strcpy(pOutdoor->pLevelFilename, pCurrentMapName); - if ( bUnderwater != 1 && pParty->bFlying - || pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pOut, 20) != 1 ) - { - viewparams->bRedrawGameUI = 1; - CloseWindowBackground(); - if ( pParty->vPosition.x < -22528 ) - pParty->vPosition.x = -22528; - if ( pParty->vPosition.x > 22528 ) - pParty->vPosition.x = 22528; - if ( pParty->vPosition.y < -22528 ) - pParty->vPosition.y = -22528; - if ( pParty->vPosition.y > 22528 ) - pParty->vPosition.y = 22528; - DialogueEnding(); - pCurrentScreen = SCREEN_GAME; - } - else - { - pParty->field_6E4 = 0; - pParty->field_6E0 = 0; - CastSpellInfoHelpers::_427D48(); - DialogueEnding(); - pEventTimer->Pause(); - pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_Box); - ++pGameLoadingUI_ProgressBar->uProgressMax; - SaveGame(1, 0); - pGameLoadingUI_ProgressBar->Progress(); - RestAndHeal(1440 * (signed int)GetTravelTime()); - if ( pParty->uNumFoodRations ) - { - pParty->RestAndHeal(); - if ( ((pParty->uNumFoodRations - (signed int)GetTravelTime()) & 0x80000000u) != 0 ) - { - pPlayer7 = pParty->pPlayers.data(); - do - { - pPlayer7->SetCondition(1, 0); - ++pPlayer7; - } - while ( (signed int)pPlayer7 < (signed int)pParty->pHirelings.data() ); - ++pParty->days_played_without_rest; - } - Party::TakeFood((unsigned int)GetTravelTime()); - } - else - { - pPlayer8 = pParty->pPlayers.data(); - do - { - pPlayer8->SetCondition(1, 0); - ++pPlayer8; - } - while ( (signed int)pPlayer8 < (signed int)pParty->pHirelings.data() ); - ++pParty->days_played_without_rest; - } - pPaletteManager->ResetNonLocked(); - pSpriteFrameTable->ResetSomeSpriteFlags(); - strcpy(pCurrentMapName, pOut); - strcpy(pLevelName, pCurrentMapName); - v41 = strtok(pLevelName, "."); - strcpy(pLevelName, v41); - Level_LoadEvtAndStr(pLevelName); - pDecalBuilder->Reset(0); - LoadLevel_InitializeLevelEvt(); - uLevelMapStatsID = pMapStats->GetMapInfo(pCurrentMapName); - bUnderwater = 0; - bNoNPCHiring = 0; - pGame->uFlags2 &= 0xFFFFFFF7u; - if ( Is_out15odm_underwater() ) - { - bUnderwater = 1; - pGame->uFlags2 |= 8u; - } - if ( !_stricmp(pCurrentMapName, "out15.odm") || !_stricmp(pCurrentMapName, "d47.blv") ) - bNoNPCHiring = 1; - PrepareToLoadODM(1u, (ODMRenderParams *)1); - pAudioPlayer->SetMapEAX(); - bDialogueUI_InitializeActor_NPC_ID = 0; - OnMapLoad(); - pOutdoor->SetFog(); - TeleportToStartingPoint(uLevel_StartingPointType); - pParty->vPosition.z = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, &v213, 0); - pParty->uFallStartY = pParty->vPosition.z; - _461103_load_level_sub(); - pEventTimer->Resume(); - viewparams->bRedrawGameUI = 1; - pCurrentScreen = SCREEN_GAME; - pGameLoadingUI_ProgressBar->Release(); - } - viewparams->bRedrawGameUI = 1; - continue; - case UIMSG_CHANGE_LOCATION_ClickCencelBtn: - CloseWindowBackground(); - if ( pParty->vPosition.x < -22528 ) - pParty->vPosition.x = -22528; - if ( pParty->vPosition.x > 22528 ) - pParty->vPosition.x = 22528; - if ( pParty->vPosition.y < -22528 ) - pParty->vPosition.y = -22528; - if ( pParty->vPosition.y > 22528 ) - pParty->vPosition.y = 22528; - DialogueEnding(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - continue; - case UIMSG_CastSpell_Telekinesis: - //if ( pRenderer->pRenderD3D ) - LOWORD(v42) = pGame->pVisInstance->get_picked_object_zbuf_val(); - /*else - { - uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v210); - pPoint = pMouse->GetCursorPos(&v208); - v42 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint->y]]; - }*/ - v44 = (unsigned __int16)v42; - v45 = PID_TYPE(v44); - uNumSeconds = v44; - v46 = PID_ID(v44); - if ( v45 == 3 ) - { - v47 = pActors[v46].uAIState == Dead; - if ( !v47 ) - continue; - pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; - pSpellInfo->uFlags &= ~0x40u; - pSpellInfo->uPlayerID_2 = uMessageParam; - pSpellInfo->spell_target_pid = v44; - pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - continue; - } - if ( v45 == 2 ) - { - v47 = (pObjectList->pObjects[pSpriteObjects[v46].uObjectDescID].uFlags & 0x10) == 0; - if ( !v47 ) - continue; - pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; - pSpellInfo->uFlags &= ~0x40u; - pSpellInfo->uPlayerID_2 = uMessageParam; - pSpellInfo->spell_target_pid = v44; - pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - continue; - } - if ( v45 == 5 ) - { - v48 = pLevelDecorations[v46].uEventID == 0; - } - else - { - if ( v45 != 6 ) - continue; - if ( uCurrentlyLoadedLevelType != 1 ) - { - pODMFace = &pOutdoor->pBModels[v44 >> 9].pFaces[v46 & 0x3F]; - if ( !pODMFace->Clickable() || !pODMFace->sCogTriggeredID ) - continue; - v44 = uNumSeconds; - pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; - pSpellInfo->uFlags &= ~0x40u; - pSpellInfo->uPlayerID_2 = uMessageParam; - pSpellInfo->spell_target_pid = v44; - pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - continue; - } - pBLVFace = &pIndoor->pFaces[v46]; - if ( !pBLVFace->Clickable() ) - continue; - v48 = pIndoor->pFaceExtras[pBLVFace->uFaceExtraID].uEventID == 0; - } - if ( v48 ) - continue; - pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; - pSpellInfo->uFlags &= ~0x40u; - pSpellInfo->uPlayerID_2 = uMessageParam; - pSpellInfo->spell_target_pid = v44; - pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - continue; - case UIMSG_CastSpell_Character_Big_Improvement://Preservation and blessing, treatment paralysis, hand hammers(individual upgrade) - case UIMSG_CastSpell_Character_Small_Improvement://Fate, cure - case UIMSG_HiredNPC_CastSpell: - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - if ( _50C9A0_IsEnchantingInProgress ) - { - uActiveCharacter = uMessageParam; - viewparams->bRedrawGameUI = 1; - } - else - { - if ( pGUIWindow_Settings ) - { - pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; - switch ( uMessage ) - { - case UIMSG_CastSpell_Character_Big_Improvement: - pSpellInfo->uFlags &= ~0x02u; - break; - case UIMSG_CastSpell_Character_Small_Improvement: - pSpellInfo->uFlags &= ~0x0100u; - break; - case UIMSG_HiredNPC_CastSpell: - pSpellInfo->uFlags &= ~0x0200u; - break; - } - pSpellInfo->uPlayerID_2 = uMessageParam; - pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pEventTimer->Resume(); - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - } - } - continue; - case UIMSG_BF: - __debugbreak(); - dword_50CDC8 = 1; - sub_42FBDD(); - SaveGame(1, 0); - strcpy(pCurrentMapName, pMapStats->pInfos[uHouse_ExitPic].pFilename); - dword_6BE364_game_settings_1 |= GAME_SETTINGS_0001; - uGameState = GAME_STATE_CHANGE_LOCATION; - //v53 = p2DEvents_minus1_::30[26 * (unsigned int)ptr_507BC0->ptr_1C]; - v53 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1]._quest_related; - if ( v53 < 0 ) - { - v54 = abs(v53) - 1; - _5B65B8_npcdata_hiword_house_or_other = 0; - dword_5B65BC = 0; - v55 = dword_4E4560[v54]; - _5B65AC_npcdata_fame_or_other = dword_4E4578[v54]; - v56 = dword_4E4590[v54]; - v57 = dword_4E45A8[v54]; - _5B65A8_npcdata_uflags_or_other = v55; - _5B65B4_npcdata_loword_house_or_other = v57; - _5B65B0_npcdata_rep_or_other = v56; - dword_5B65C0 = v55 | _5B65AC_npcdata_fame_or_other | v56 | v57; - } - HouseDialogPressCloseBtn(); - //goto LABEL_434; - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0); - continue; - - case UIMSG_OnCastTownPortal: - pAudioPlayer->StopChannels(-1, -1); - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, WINDOW_TownPortal, (char *)uMessageParam); - continue; - - case UIMSG_OnCastLloydsBeacon: - pAudioPlayer->StopChannels(-1, -1); - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Book, WINDOW_LloydsBeacon, 0); - continue; - - case UIMSG_LloydsBeacon_FlippingBtn: - bRecallingBeacon = uMessageParam; - v127 = uMessageParam + 204; - pAudioPlayer->PlaySound((SoundID)v127, 0, 0, -1, 0, 0, 0, 0); - continue; - case UIMSG_HintBeaconSlot: - if ( !pGUIWindow_CurrentMenu ) - continue; - pPlayer = pPlayers[_506348_current_lloyd_playerid + 1]; - uNumSeconds = (unsigned int)&pPlayer->pInstalledBeacons[uMessageParam]; - if ( bRecallingBeacon ) - { - if ( !*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels ) ) - continue; - v173 = pMapStats->pInfos[pMapStats->sub_410D99_get_map_index(pPlayer->pInstalledBeacons[uMessageParam].SaveFileID)].pName; - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[474], v173);// "Recall to %s" - GameUI_SetFooterString(pTmpBuf.data()); - continue; - } - pMapNum = pMapStats->GetMapInfo(pCurrentMapName); - pMapName = "Not in Map Stats"; - if ( pMapNum ) - pMapName = pMapStats->pInfos[pMapNum].pName; - if ( !*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels ) || !pMapNum ) - { - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[476], pMapName);// "Set to %s" - GameUI_SetFooterString(pTmpBuf.data()); - continue; - } - v174 = pMapStats->pInfos[pMapStats->sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName; - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[475], (unsigned int)pMapName, v174);// "Set %s over %s" - GameUI_SetFooterString(pTmpBuf.data()); - continue; - case UIMSG_CloseAfterInstallBeacon: - dword_50CDC8 = 1; - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) - continue; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages;*/ - continue; - case UIMSG_InstallBeacon: - pPlayer9 = pPlayers[_506348_current_lloyd_playerid + 1]; - if ( !pPlayer9->pInstalledBeacons[uMessageParam].uBeaconTime && bRecallingBeacon ) - continue; - byte_506360 = 1; - pPlayer9->CanCastSpell(uRequiredMana); - if ( pParty->bTurnBasedModeOn ) - { - v60 = sRecoveryTime; - pParty->pTurnBasedPlayerRecoveryTimes[_506348_current_lloyd_playerid] = sRecoveryTime; - pPlayer9->SetRecoveryTime(v60); - pTurnEngine->ApplyPlayerAction(); - } - else - { - pPlayer9->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)sRecoveryTime * 2.133333333333333)); - } - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[lloyds_beacon_spell_id], 0, 0, -1, 0, lloyds_beacon_sound_id, 0, 0); - if ( bRecallingBeacon ) - { - if ( _stricmp(pCurrentMapName, (const char *)&pGames_LOD->pSubIndices[pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID]) ) - { - SaveGame(1, 0); - OnMapLeave(); - strcpy(pCurrentMapName, (const char *)&pGames_LOD->pSubIndices[pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID]); - dword_6BE364_game_settings_1 |= GAME_SETTINGS_0001; - uGameState = GAME_STATE_CHANGE_LOCATION; - _5B65A8_npcdata_uflags_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X; - _5B65AC_npcdata_fame_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y; - _5B65B0_npcdata_rep_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z; - _5B65B4_npcdata_loword_house_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X; - _5B65B8_npcdata_hiword_house_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y; - dword_5B65C0 = 1; - } - else - { - pParty->vPosition.x = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X; - pParty->vPosition.y = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y; - pParty->vPosition.z = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z; - pParty->uFallStartY = pParty->vPosition.z; - pParty->sRotationY = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X; - pParty->sRotationX = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y; - } - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0); - pBooksWindow->Release(); - pGUIWindow_CurrentMenu->Release(); - pBooksWindow = 0; - pGUIWindow_CurrentMenu = 0; - } - else - { - sprintf(a1, "data\\lloyd%d%d.pcx", _506348_current_lloyd_playerid + 1, uMessageParam + 1); - pRenderer->SaveScreenshot(a1, 92, 68); - LoadThumbnailLloydTexture(uMessageParam, _506348_current_lloyd_playerid + 1); - pPlayer9->pInstalledBeacons[uMessageParam].uBeaconTime = pParty->uTimePlayed + (signed __int64)((double)(lloyds_beacon_spell_level << 7) * 0.033333335); - pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X = pParty->vPosition.x; - pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y = pParty->vPosition.y; - pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z = pParty->vPosition.z; - pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X = LOWORD(pParty->sRotationY); - pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y = LOWORD(pParty->sRotationX); - if ( (signed int)pGames_LOD->uNumSubDirs / 2 <= 0 ) - continue; - for ( thisg = 0; thisg < (signed int)pGames_LOD->uNumSubDirs / 2; ++thisg ) - { - if ( !_stricmp(pGames_LOD->pSubIndices[thisg].pFilename, pCurrentMapName) ) - pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID = thisg; - } - } - continue; - case UIMSG_ClickTownInTP: - if ( uMessageParam ) - { - switch ( uMessageParam ) - { - case 1: - v63 = 208; - break; - case 2: - v63 = 207; - break; - case 3: - v63 = 211; - break; - case 4: - v63 = 209; - break; - default: - if ( uMessageParam != 5 ) - { -LABEL_486: - SaveGame(1, 0); - v64 = pMapStats->GetMapInfo(pCurrentMapName); - v65 = uMessageParam; - if ( v64 == TownPortalList[uMessageParam].uMapInfoID ) - { - pParty->vPosition.x = TownPortalList[v65].pos.x; - pParty->vPosition.y = TownPortalList[v65].pos.y; - pParty->vPosition.z = TownPortalList[v65].pos.z; - pParty->uFallStartY = pParty->vPosition.z; - pParty->sRotationY = TownPortalList[v65].rot_y; - pParty->sRotationX = TownPortalList[v65].rot_x; - } - else - { - SaveGame(1, 0); - OnMapLeave(); - dword_6BE364_game_settings_1 |= GAME_SETTINGS_0001; - uGameState = GAME_STATE_CHANGE_LOCATION; - strcpy(pCurrentMapName, pMapStats->pInfos[TownPortalList[uMessageParam].uMapInfoID].pFilename); - dword_5B65C0 = 1; - _5B65A8_npcdata_uflags_or_other = TownPortalList[uMessageParam].pos.x; - _5B65AC_npcdata_fame_or_other = TownPortalList[uMessageParam].pos.y; - _5B65B0_npcdata_rep_or_other = TownPortalList[uMessageParam].pos.z; - v66 = TownPortalList[uMessageParam].rot_x; - _5B65B4_npcdata_loword_house_or_other = TownPortalList[uMessageParam].rot_y; - _5B65B8_npcdata_hiword_house_or_other = v66; - Actor::InitializeActors(); - } - v67 = (char*)pGUIWindow_CurrentMenu->Hint; - if ( v67 ) - *((int *)v67 + 17) = 1; - else - pParty->pPlayers[(unsigned __int8)town_portal_caster_id].CanCastSpell(0x14u); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 1, 0); - continue; - } - v63 = 210; - break; - } - } - else - { - v63 = 206; - } - if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v63) ) - return; - goto LABEL_486; - case UIMSG_HintTownPortal: - if ( uMessageParam ) - { - switch ( uMessageParam ) - { - case 1: - v68 = 208; - break; - case 2: - v68 = 207; - break; - case 3: - v68 = 211; - break; - case 4: - v68 = 209; - break; - default: - if ( uMessageParam != 5 ) - //goto LABEL_506; - { - if ( uMessageParam ) - { - switch ( uMessageParam ) - { - case 1: - v69 = pMapStats->pInfos[4].pName; - break; - case 2: - v69 = pMapStats->pInfos[3].pName; - break; - case 3: - v69 = pMapStats->pInfos[10].pName; - break; - case 4: - v69 = pMapStats->pInfos[7].pName; - break; - default: - if ( uMessageParam != 5 ) - { - __debugbreak(); // warning C4700: uninitialized local variable 'v200' used - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[35], v200); - GameUI_SetFooterString(pTmpBuf.data()); - continue; - } - v69 = pMapStats->pInfos[8].pName; - break; - } - } - else - { - v69 = pMapStats->pInfos[21].pName; - } - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[35], v69); - GameUI_SetFooterString(pTmpBuf.data()); - continue; - } - v68 = 210; - break; - } - } - else - { - v68 = 206; - } - if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v68) ) - { - pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar); - continue; - } -//LABEL_506: - if ( uMessageParam ) - { - switch ( uMessageParam ) - { - case 1: - v69 = pMapStats->pInfos[4].pName; - break; - case 2: - v69 = pMapStats->pInfos[3].pName; - break; - case 3: - v69 = pMapStats->pInfos[10].pName; - break; - case 4: - v69 = pMapStats->pInfos[7].pName; - break; - default: - if ( uMessageParam != 5 ) - //goto LABEL_519; - { - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[35], v200); - GameUI_SetFooterString(pTmpBuf.data()); - continue; - } - v69 = pMapStats->pInfos[8].pName; - break; - } - } - else - { - v69 = pMapStats->pInfos[21].pName; - } - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[35], v69); - GameUI_SetFooterString(pTmpBuf.data()); - continue; - case UIMSG_ShowFinalWindow: - sprintfex(pFinalMessage.data(), "%s\n \n%s\n \n%s", pGlobalTXT_LocalizationStrings[151],// "Congratulations Adventurer." - pGlobalTXT_LocalizationStrings[118],// "We hope that you've enjoyed playing Might and Magic VII as much as we did making it. We have saved this screen as MM7_WIN.PCX in your MM7 directory. You can print it out as proof of your accomplishment." - pGlobalTXT_LocalizationStrings[167]);// "- The Might and Magic VII Development Team." - ModalWindow(pFinalMessage.data(), UIMSG_OnFinalWindowClose); - uGameState = GAME_STATE_FINAL_WINDOW; - continue; - case UIMSG_OnFinalWindowClose: - __debugbreak(); - uGameState = GAME_STATE_PLAYING; - strcpy((char *)pKeyActionMap->pPressedKeysBuffer, "2"); - __debugbreak(); // missed break/continue? - case UIMSG_DD: - __debugbreak(); - sprintf(pTmpBuf.data(), "%s", pKeyActionMap->pPressedKeysBuffer); - memcpy(&v216, txt_file_frametable_parser(pKeyActionMap->pPressedKeysBuffer, &v218), sizeof(v216)); - if ( v216.uPropCount == 1 ) - { - pNPCData4 = (NPCData *)((signed int)pGames_LOD->uNumSubDirs / 2); - v70 = atoi(v216.pProperties[0]); - if ( v70 <= 0 || v70 >= 77 ) - continue; - v71 = v70; - strcpy(Str2, pMapStats->pInfos[v70].pFilename); - pNPCData3 = 0; - if ( (signed int)pNPCData4 > 0 ) - { - thish = 0; - do - { - if ( !_stricmp(pGames_LOD->pSubIndices[thish].pFilename, Str2) ) - break; - ++thish; - pNPCData3 = (NPCData *)((char *)pNPCData3 + 1); - } - while ( (signed int)pNPCData3 < (signed int)pNPCData4 ); - if ( (signed int)pNPCData3 < (signed int)pNPCData4 ) - { - strcpy(pCurrentMapName, pGames_LOD->pSubIndices[(int)pNPCData3].pFilename); - dword_6BE364_game_settings_1 |= GAME_SETTINGS_0001; - uGameState = GAME_STATE_CHANGE_LOCATION; - OnMapLeave(); - continue; - } - } - sprintf(Str2, "No map found for %s", pMapStats->pInfos[v71].pName); - v73 = Str2; - } - else - { - if ( v216.uPropCount != 3 ) - continue; - v74 = atoi(v216.pProperties[0]); - thisi = atoi(v216.pProperties[1]); - v75 = atoi(v216.pProperties[2]); - v76 = v75; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - if ( pIndoor->GetSector(v74, thisi, v75) ) - { - v77 = thisi; - pParty->vPosition.x = v74; - pParty->vPosition.y = v77; - pParty->vPosition.z = v76; - pParty->uFallStartY = v76; - continue; - } - } - else - { - if ( v74 > -32768 ) - { - if ( v74 < 32768 ) - { - v77 = thisi; - if ( thisi > -32768 ) - { - if ( thisi < 32768 && v76 >= 0 && v76 < 10000 ) - { - pParty->vPosition.x = v74; - pParty->vPosition.y = v77; - pParty->vPosition.z = v76; - pParty->uFallStartY = v76; - continue; - } - } - } - } - } - pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0); - v73 = "Can't jump to that location!"; - } - ShowStatusBarString(v73, 6u); - continue; - case UIMSG_CastQuickSpell: - if ( bUnderwater == 1 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[652], 2);// "You can not do that while you are underwater!" - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); - continue; - } - if ( !uActiveCharacter || (pPlayer2 = pPlayers[uActiveCharacter], pPlayer2->uTimeToRecovery) ) - continue; - _42777D_CastSpell_UseWand_ShootArrow(pPlayer2->uQuickSpell, uActiveCharacter - 1, 0, 0, uActiveCharacter); - continue; - case UIMSG_CastSpell_Monster_Improvement: - case UIMSG_CastSpell_Shoot_Monster://FireBlow, Lightning, Ice Lightning, Swarm, - //if ( pRenderer->pRenderD3D ) - { - v81 = pGame->pVisInstance->get_picked_object_zbuf_val(); - } - /*else - { - uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v206); - pPoint2 = pMouse->GetCursorPos(&v201); - v81 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint2->y]]; - }*/ - v83 = v81; - v44 = (unsigned __int16)v81; - v84 = v83 >> 16; - if ( PID_TYPE(v44) != 3 || v84 >= 5120 ) - continue; - pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; - if ( uMessage == UIMSG_CastSpell_Shoot_Monster ) - { - pSpellInfo->uFlags &= ~0x08; - } - else - { - if ( uMessage == UIMSG_CastSpell_Monster_Improvement ) - pSpellInfo->uFlags &= ~0x0100u; - else - pSpellInfo->uFlags &= ~0x0200u; - } - pSpellInfo->uPlayerID_2 = uMessageParam; - pSpellInfo->spell_target_pid = v44; - pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - _50C9A0_IsEnchantingInProgress = 0; - back_to_game(); - continue; - case UIMSG_1C: - __debugbreak(); - if ( !uActiveCharacter || pCurrentScreen ) - continue; - ptr_507BC8 = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_68, uMessageParam, 0); - pCurrentScreen = SCREEN_19; - pEventTimer->Pause(); - continue; - case UIMSG_STEALFROMACTOR: - if ( !uActiveCharacter ) - continue; - if ( pParty->bTurnBasedModeOn != 1 ) - { - if ( pActors[uMessageParam].uAIState == 5 ) - pActors[uMessageParam].LootActor(); - else - Actor::StealFrom(uMessageParam); - continue; - } - if ( pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_MOVEMENT ) - continue; - if ( !(pTurnEngine->field_18 & TE_HAVE_PENDING_ACTIONS) ) - { - if ( pActors[uMessageParam].uAIState == 5 ) - pActors[uMessageParam].LootActor(); - else - Actor::StealFrom(uMessageParam); - } - continue; - - case UIMSG_Attack: - if ( !uActiveCharacter ) - continue; - if ( pParty->bTurnBasedModeOn != 1 ) - { - Player::_42ECB5_PlayerAttacksActor(); - continue; - } - if ( pTurnEngine->turn_stage == TE_WAIT || pTurnEngine->turn_stage == TE_MOVEMENT ) - continue; - if ( !(pTurnEngine->field_18 & TE_HAVE_PENDING_ACTIONS) ) - Player::_42ECB5_PlayerAttacksActor(); - continue; - case UIMSG_ExitRest: - GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn, (int)pButton_RestUI_Exit, pGlobalTXT_LocalizationStrings[81]);// "Exit Rest" - continue; - case UIMSG_Wait5Minutes: - if ( dword_506F14 == 2 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!" - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); - continue; - } - GUIWindow::Create(pButton_RestUI_Wait5Minutes->uX, pButton_RestUI_Wait5Minutes->uY, 0, 0, WINDOW_PressedButton2, - (int)pButton_RestUI_Wait5Minutes, pGlobalTXT_LocalizationStrings[238]);// "Wait 5 Minutes" - dword_506F14 = 1; - _506F18_num_minutes_to_sleep = 5; - continue; - case UIMSG_Wait1Hour: - if ( dword_506F14 == 2 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!" - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); - continue; - } - GUIWindow::Create(pButton_RestUI_Wait1Hour->uX, pButton_RestUI_Wait1Hour->uY, 0, 0, WINDOW_PressedButton2, - (int)pButton_RestUI_Wait1Hour, pGlobalTXT_LocalizationStrings[239]);// "Wait 1 Hour" - dword_506F14 = 1; - _506F18_num_minutes_to_sleep = 60; - continue; - case UIMSG_RentRoom: - dword_506F14 = 2; - RestUI_Load(); - v86 = 60 * (_494820_training_time(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute; - _506F18_num_minutes_to_sleep = v86; - if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 ) // 107 = Emerald Isle tavern - _506F18_num_minutes_to_sleep = v86 + 12 * 60; - dword_506F14 = 2; - pParty->RestAndHeal(); - pParty->days_played_without_rest = 0; - pParty->pPlayers[3].SetAsleep(1); - pParty->pPlayers[2].SetAsleep(1); - pParty->pPlayers[1].SetAsleep(1); - pParty->pPlayers[0].SetAsleep(1); - continue; - case UIMSG_RestWindow: - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - if ( pCurrentScreen ) - continue; - if ( CheckActors_proximity() ) - { - if ( pParty->bTurnBasedModeOn == 1 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!" - continue; - } - v88 = pGlobalTXT_LocalizationStrings[480];// "There are hostile enemies near!" - if ( pParty->uFlags & 0x88 ) - v88 = pGlobalTXT_LocalizationStrings[479];// "You can't rest here!" - ShowStatusBarString(v88, 2); - if ( !uActiveCharacter ) - continue; - pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)13, 0); - continue; - } - if ( pParty->bTurnBasedModeOn == 1 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!" - continue; - } - if ( !(pParty->uFlags & 0x88) ) - { - RestUI_Load(); - continue; - } - if ( pParty->bTurnBasedModeOn == 1 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[478], 2);// "You can't rest in turn-based mode!" - continue; - } - v88 = pGlobalTXT_LocalizationStrings[480];// "There are hostile enemies near!" - if ( pParty->uFlags & 0x88 ) - v88 = pGlobalTXT_LocalizationStrings[479];// "You can't rest here!" - ShowStatusBarString(v88, 2u); - if ( !uActiveCharacter ) - continue; - pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)13, 0); - continue; - case UIMSG_Rest8Hour: - if ( dword_506F14 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!" - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); - continue; - } - if ( pParty->uNumFoodRations < uRestUI_FoodRequiredToRest ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[482], 2u);// "You don't have enough food to rest" - if ( uActiveCharacter && pPlayers[uActiveCharacter]->CanAct() ) - pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_108, 0); - } - else - { - pParty->pPlayers[3].pConditions[Condition_Sleep] = pParty->uTimePlayed; - pParty->pPlayers[2].pConditions[Condition_Sleep] = pParty->uTimePlayed; - pParty->pPlayers[1].pConditions[Condition_Sleep] = pParty->uTimePlayed; - pParty->pPlayers[0].pConditions[Condition_Sleep] = pParty->uTimePlayed; - v90 = pMapStats->GetMapInfo(pCurrentMapName); - if ( !v90 ) - v90 = rand() % (signed int)pMapStats->uNumMaps + 1; - pMapInfo = &pMapStats->pInfos[v90]; - if ( rand() % 100 + 1 <= pMapInfo->Encounter_percent ) - { - v91 = rand() % 100; - v92 = pMapInfo->EncM1percent; - v93 = v91 + 1; - if ( v93 > v92 ) - pNPCData4 = (NPCData *)((v93 > v92 + pMapInfo->EncM2percent) + 2); - else - pNPCData4 = (NPCData *)1; - if ( !_45063B_spawn_some_monster(pMapInfo, (int)pNPCData4) ) - pNPCData4 = 0; - if ( pNPCData4 ) - { - pPlayerNum = rand() % 4; - pParty->pPlayers[pPlayerNum].pConditions[Condition_Sleep] = 0; - v95 = rand(); - Rest(v95 % 6 + 60); - _506F18_num_minutes_to_sleep = 0; - dword_506F14 = 0; - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0); - ShowStatusBarString(pGlobalTXT_LocalizationStrings[481], 2);// "Encounter!" - pAudioPlayer->PlaySound((SoundID)227, 0, 0, -1, 0, 0, 0, 0); - continue; - } - } - Party::TakeFood(uRestUI_FoodRequiredToRest); - _506F18_num_minutes_to_sleep = 480; - dword_506F14 = 2; - pParty->RestAndHeal(); - pParty->days_played_without_rest = 0; - pParty->pPlayers[3].SetAsleep(1); - pParty->pPlayers[2].SetAsleep(1); - pParty->pPlayers[1].SetAsleep(1); - pParty->pPlayers[0].SetAsleep(1); - } - continue; - case UIMSG_AlreadyResting: - if ( dword_506F14 == 2 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[477], 2);// "You are already resting!" - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); - continue; - } - GUIWindow::Create(pButton_RestUI_WaitUntilDawn->uX, pButton_RestUI_WaitUntilDawn->uY, 0, 0, WINDOW_PressedButton2, - (int)pButton_RestUI_WaitUntilDawn, pGlobalTXT_LocalizationStrings[237]);// "Wait until Dawn" - v97 = _494820_training_time(pParty->uCurrentHour); - dword_506F14 = 1; - _506F18_num_minutes_to_sleep = 60 * v97 - pParty->uCurrentMinute; - continue; - case UIMSG_HintSelectRemoveQuickSpellBtn: - if ( quick_spell_at_page && byte_506550 ) - { - v173 = pSpellStats->pInfos[quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage].pName; - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[483], v173); - } - else - { - if ( pPlayers[uActiveCharacter]->uQuickSpell ) - v177 = pGlobalTXT_LocalizationStrings[584];// "Click here to remove your Quick Spell" - else - v177 = pGlobalTXT_LocalizationStrings[484];// "Select a spell then click here to set a QuickSpell" - strcpy(pTmpBuf.data(), v177); - } - GameUI_SetFooterString(pTmpBuf.data()); - continue; - case UIMSG_SPellbook_ShowHightlightedSpellInfo: - if ( !uActiveCharacter || (uNumSeconds = (unsigned int)pPlayers[uActiveCharacter], - !*(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + 6734) + uMessageParam + 402)) ) - continue; - if ( sub_4637E0_is_there_popup_onscreen() ) - dword_507B00_spell_info_to_draw_in_popup = uMessageParam + 1; - v98 = *(char *)(uNumSeconds + 6734); - if ( quick_spell_at_page - 1 == uMessageParam ) - { - v178 = pSpellStats->pInfos[uMessageParam + 11 * v98 + 1].pName; - v161 = pGlobalTXT_LocalizationStrings[485]; - } - else - { - v178 = pSpellStats->pInfos[uMessageParam + 11 * v98 + 1].pName; - v161 = pGlobalTXT_LocalizationStrings[486]; - } - sprintfex(pTmpBuf.data(), v161, v178); - GameUI_SetFooterString(pTmpBuf.data()); - continue; - case UIMSG_ClickInstallRemoveQuickSpellBtn: - GUIWindow::Create(pBtn_InstallRemoveSpell->uX, pBtn_InstallRemoveSpell->uY, 0, 0, WINDOW_PressedButton2, (int)pBtn_InstallRemoveSpell, 0); - if ( !uActiveCharacter ) - continue; - pPlayer10 = pPlayers[uActiveCharacter]; - if ( !byte_506550 || !quick_spell_at_page ) - { - pPlayer10->uQuickSpell = 0; - quick_spell_at_page = 0; - pAudioPlayer->PlaySound((SoundID)203, 0, 0, -1, 0, 0, 0, 0); - continue; - } - pPlayers[uActiveCharacter]->uQuickSpell = quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage; - AA1058_PartyQuickSpellSound[uActiveCharacter - 1].AddPartySpellSound(pPlayers[uActiveCharacter]->uQuickSpell, uActiveCharacter); - if ( uActiveCharacter ) - pPlayer10->PlaySound(SPEECH_12, 0); - byte_506550 = 0; - continue; - case UIMSG_SpellBook_PressTab://ïåðåëèñòûâàíèå ñòðàíèö êëàâèøåé Tab - { - if ( !uActiveCharacter ) - continue; - int skill_count = 0; - uAction = 0; - for ( uint i = 0; i < 9; i++ ) - { - if ( pPlayers[uActiveCharacter]->pActiveSkills[PLAYER_SKILL_FIRE + i] ) - { - if ( pPlayers[uActiveCharacter]->lastOpenedSpellbookPage == i ) - uAction = skill_count; - v217[skill_count++] = i; - } - } - if ( !skill_count )//íåò ñêèëëîâ - pAudioPlayer->PlaySound((SoundID)(rand() % 2 + 204), 0, 0, -1, 0, 0, 0, 0); - else - { - if ( GetAsyncKeyState(VK_SHIFT) ) - { - --uAction; - if ( uAction < 0 ) - uAction = skill_count - 1; - } - else - { - ++uAction; - if ( uAction >= skill_count ) - uAction = 0; - } - OnCloseSpellBookPage(); - pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = LOBYTE(v217[uAction]); - pGUIWindow_CurrentMenu->OpenSpellBook(); - pAudioPlayer->PlaySound((SoundID)(rand() % 2 + 204), 0, 0, -1, 0, 0, 0, 0); - } - continue; - } - case UIMSG_OpenSpellbookPage: - if ( pTurnEngine->turn_stage == TE_MOVEMENT || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->lastOpenedSpellbookPage ) - continue; - OnCloseSpellBookPage(); - pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = uMessageParam; - pGUIWindow_CurrentMenu->OpenSpellBook(); - pAudioPlayer->PlaySound((SoundID)(rand() % 2 + 204), 0, 0, -1, 0, 0, 0, 0); - continue; - case UIMSG_SelectSpell: - { - if (pTurnEngine->turn_stage == TE_MOVEMENT) - continue; - if (!uActiveCharacter) - continue; - - // uNumSeconds = (unsigned int)pPlayers[uActiveCharacter]; - Player* player = pPlayers[uActiveCharacter]; - if (player->spellbook.pChapters[player->lastOpenedSpellbookPage].bIsSpellAvailable[uMessageParam]) - //if ( *(char *)(uNumSeconds + 11 * *(char *)(uNumSeconds + &lastOpenedSpellbookPage) + uMessageParam + 402) ) - { - if ( quick_spell_at_page - 1 == uMessageParam ) - { - pGUIWindow_CurrentMenu->Release(); - pEventTimer->Resume(); - viewparams->bRedrawGameUI = 1; - pCurrentScreen = SCREEN_GAME; - pIcons_LOD->RemoveTexturesPackFromTextureList(); - v103 = quick_spell_at_page + 11 * player->lastOpenedSpellbookPage; - /*if ( dword_50C9E8 < 40 ) - { - dword_50C9EC[3 * dword_50C9E8] = UIMSG_CastSpellFromBook; - dword_50C9EC[3 * dword_50C9E8 + 1] = v103; - dword_50C9EC[3 * dword_50C9E8 + 2] = uActiveCharacter - 1; - ++dword_50C9E8; - }*/ - pMessageQueue_50C9E8->AddGUIMessage(UIMSG_CastSpellFromBook, v103, uActiveCharacter - 1); - // pMessageQueue_50CBD0->AddGUIMessage(UIMSG_CastSpellFromBook, v103, uActiveCharacter - 1); - } - else - { - byte_506550 = 1; - quick_spell_at_page = uMessageParam + 1; - } - } - } - continue; - - case UIMSG_CastSpellFromBook: - if ( pTurnEngine->turn_stage != TE_MOVEMENT ) - _42777D_CastSpell_UseWand_ShootArrow(uMessageParam, v199, 0, 0, 0); - continue; - - case UIMSG_SpellScrollUse: - __debugbreak(); - if ( pTurnEngine->turn_stage != TE_MOVEMENT ) - _42777D_CastSpell_UseWand_ShootArrow(uMessageParam, v199, 133, 1, 0); - continue; - case UIMSG_SpellBookWindow: - if ( pTurnEngine->turn_stage == TE_MOVEMENT ) - continue; - if ( bUnderwater == true ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[652], 2);// "You can not do that while you are underwater!" - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0); - } - else - { - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - if ( uActiveCharacter && !pPlayers[uActiveCharacter]->uTimeToRecovery ) - { - if ( pCurrentScreen == SCREEN_GAME ) - { - GUIWindow::Create(476, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_CastSpell, 0); - pCurrentScreen = SCREEN_SPELL_BOOK; - pEventTimer->Pause(); - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_SpellBook, 0, 0); - pAudioPlayer->PlaySound((SoundID)48, 0, 0, -1, 0, 0, 0, 0); - viewparams->field_48 = 1; - continue; - } - if ( pCurrentScreen != SCREEN_REST && pCurrentScreen != SCREEN_CHARACTERS - && (pCurrentScreen <= SCREEN_63 || pCurrentScreen > SCREEN_67) ) - { - pGUIWindow_CurrentMenu->Release(); - GUIWindow::Create(476, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_CastSpell, 0); - pCurrentScreen = SCREEN_SPELL_BOOK; - pEventTimer->Pause(); - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_SpellBook, 0, 0); - pAudioPlayer->PlaySound((SoundID)48, 0, 0, -1, 0, 0, 0, 0); - viewparams->field_48 = 1; - continue; - } - } - } - continue; - case UIMSG_QuickReference: - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - if ( pCurrentScreen ) - pGUIWindow_CurrentMenu->Release(); - ++pIcons_LOD->uTexturePacksCount; - if ( !pIcons_LOD->uNumPrevLoadedFiles ) - pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; - GUIWindow::Create(0x230u, 0x1C2u, 0, 0, WINDOW_PressedButton2, (int)pBtn_QuickReference, 0); - viewparams->bRedrawGameUI = 1; - pEventTimer->Pause(); - pAudioPlayer->StopChannels(-1, -1); - pCurrentScreen = SCREEN_QUICK_REFERENCE; - pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_QuickReference, 5, 0); - papredoll_dbrds[2] = pIcons_LOD->LoadTexture("BUTTEXI1", TEXTURE_16BIT_PALETTE); - pBtn_ExitCancel = pGUIWindow_CurrentMenu->CreateButton(0x187u, 0x13Cu, 0x4Bu, 0x21u, 1, 0, UIMSG_Escape, 0, 0, - pGlobalTXT_LocalizationStrings[79],// "Exit" - pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0); //, v179); - continue; - case UIMSG_GameMenuButton: - if ( pCurrentScreen ) - { - pGUIWindow_CurrentMenu->Release(); - pEventTimer->Resume(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - } - - stru_506E40.Release(); - pRenderer->SaveScreenshot("gamma.pcx", 155, 117); - stru_506E40.LoadPCXFile("gamma.pcx", 0); - - GUIWindow::Create(0x25Au, 0x1C2u, 0, 0, WINDOW_PressedButton, (int)pBtn_GameSettings, 0); -//LABEL_453: - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) - continue; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; - //goto LABEL_770; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages;*/ - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0); - continue; - case UIMSG_ClickAwardScrollBar: - books_page_number = 1; - if ( pMouse->GetCursorPos(&v211)->y > 178 ) - books_page_number = -1; - continue; - case UIMSG_ClickAwardsUpBtn: - GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pBtn_Up, 0); - BtnUp_flag = 1; - continue; - case UIMSG_ClickAwardsDownBtn: - GUIWindow::Create(pBtn_Down->uX, pBtn_Down->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pBtn_Down, 0); - BtnDown_flag = 1; - continue; - case UIMSG_ChangeDetaliz: - bRingsShownInCharScreen ^= 1; - pCharacterScreen_DetalizBtn->Release(); - pCharacterScreen_DollBtn->Release(); - if ( bRingsShownInCharScreen ) - { - v128 = pIcons_LOD->GetTexture(uTextureID_detaliz_close_button)->uTextureHeight; - v125 = pIcons_LOD->GetTexture(uTextureID_detaliz_close_button)->uTextureWidth; - v123 = 445; - v121 = 470; - } - else - { - v128 = 30; - v125 = 30; - v123 = 300; - v121 = 600; - } - pCharacterScreen_DetalizBtn = pGUIWindow_CurrentMenu->CreateButton(v121, v123, v125, v128, 1, 0, UIMSG_ChangeDetaliz, 0, 0, - pGlobalTXT_LocalizationStrings[64],// "Detail Toggle" - 0); - pCharacterScreen_DollBtn = pGUIWindow_CurrentMenu->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, UIMSG_ClickPaperdoll, 0, 0, "", 0); - viewparams->bRedrawGameUI = 1; - continue; - case UIMSG_ClickPaperdoll: - OnPaperdollLeftClick(); - continue; - case UIMSG_ClickStatsBtn: - pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100; - CharacterUI_ReleaseButtons(); - ReleaseAwardsScrollBar(); - GUIWindow::Create(pCharacterScreen_StatsBtn->uX, pCharacterScreen_StatsBtn->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pCharacterScreen_StatsBtn, 0); - continue; - case UIMSG_ClickSkillsBtn: - pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 101; - CharacterUI_ReleaseButtons(); - ReleaseAwardsScrollBar(); - CharacterUI_SkillsTab_CreateButtons(); - GUIWindow::Create(pCharacterScreen_SkillsBtn->uX, pCharacterScreen_SkillsBtn->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pCharacterScreen_SkillsBtn, 0); - continue; - case UIMSG_SkillUp: - pPlayer4 = pPlayers[uActiveCharacter]; - v105 = (int)&pPlayer4->pActiveSkills[uMessageParam]; - LOWORD(v2) = *(short *)v105; - uNumSeconds = v2; - if ( pPlayer4->uSkillPoints < (v2 & 0x3F) + 1 ) - { - v87 = pGlobalTXT_LocalizationStrings[488];// "You don't have enough skill points!" - } - else - { - if ( (uNumSeconds & 0x3F) < 0x3C ) - { - *(short *)v105 = uNumSeconds + 1; - pPlayer4->uSkillPoints -= pPlayer4->pActiveSkills[uMessageParam] & 0x3F; - pPlayer4->PlaySound(SPEECH_14, 0); - pAudioPlayer->PlaySound((SoundID)20001, 0, 0, -1, 0, 0, 0, 0); - continue; - } - v87 = pGlobalTXT_LocalizationStrings[487];// "You have already mastered this skill!" - } - ShowStatusBarString(v87, 2); - continue; - case UIMSG_ClickInventoryBtn: - pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; - ReleaseAwardsScrollBar(); - CharacterUI_ReleaseButtons(); - GUIWindow::Create(pCharacterScreen_InventoryBtn->uX, pCharacterScreen_InventoryBtn->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pCharacterScreen_InventoryBtn, 0); - continue; - case UIMSG_ClickExitCharacterWindowBtn: - GUIWindow::Create(pCharacterScreen_ExitBtn->uX, pCharacterScreen_ExitBtn->uY, 0, 0, WINDOW_ExitCharacterWindow, (int)pCharacterScreen_ExitBtn, 0); - continue; - case UIMSG_ClickAwardsBtn: - ReleaseAwardsScrollBar(); - CharacterUI_ReleaseButtons(); - CreateAwardsScrollBar(); - pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 102; - GUIWindow::Create(pCharacterScreen_AwardsBtn->uX, pCharacterScreen_AwardsBtn->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pCharacterScreen_AwardsBtn, 0); - FillAwardsData(); - continue; - case UIMSG_ClickBooksBtn: - switch ( uMessageParam ) - { - case 11://Page UP - BtnUp_flag = 1; - pButton = pBtn_Book_2; - break; - case 10://Page DOWN - BtnDown_flag = 1; - pButton = pBtn_Book_1; - break; - case 0://Zoom plus - pButton = pBtn_Book_1; - BtnDown_flag = 1; - break; - case 1://Zoom minus - pButton = pBtn_Book_2; - BtnUp_flag = 1; - break; - case 2://Potions - Book_PageBtn3_flag = 1; - if ( dword_506364 ) - continue; - pButton = pBtn_Book_3; - break; - case 3://fountains - Book_PageBtn4_flag = 1; - if ( dword_506364 ) - continue; - pButton = pBtn_Book_4; - break; - case 4://obelisks - Book_PageBtn5_flag = 1;//Autonotes_Obelisks_page_flag - if ( dword_506364 ) - continue; - pButton = pBtn_Book_5; - break; - case 5://seer - Book_PageBtn6_flag = 1;//Autonotes_Seer_page_flag - if ( dword_506364 ) - continue; - pButton = pBtn_Book_6; - break; - case 6://misc - pButton = pBtn_Autonotes_Misc; - Autonotes_Misc_page_flag = 1; - break; - case 7://Instructors - pButton = pBtn_Autonotes_Instructors; - Autonotes_Instructors_page_flag = 1; - break; - default: - continue; - } - GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, (char *)1); - continue; - case UIMSG_SelectCharacter: - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - GameUI_OnPlayerPortraitLeftClick(uMessageParam); - continue; - case UIMSG_ShowStatus_Funds: - v174 = (char *)pParty->uNumGoldInBank; - //v158 = pParty->uNumGold + pParty->uNumGoldInBank; - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[489], pParty->uNumGold + pParty->uNumGoldInBank, v174);// "You have %d total gold, %d in the Bank" - GameUI_SetFooterString(pTmpBuf.data()); - continue; - case UIMSG_ShowStatus_DateTime: - currHour = pParty->uCurrentHour; - uNumSeconds = 1; - if (pParty->uCurrentHour > 12 ) - { - if (pParty->uCurrentHour >= 24) - uNumSeconds = 0; - currHour = (currHour - 12); - } - else - { - if (pParty->uCurrentHour < 12) // 12:00 is PM - uNumSeconds = 0; - if (pParty->uCurrentHour == 0) - currHour = 12; - } - sprintf(pTmpBuf.data(), "%d:%02d%s %s %d %s %d", currHour, pParty->uCurrentMinute, aAMPMNames[uNumSeconds], aDayNames[pParty->uDaysPlayed % 7], - 7 * pParty->uCurrentMonthWeek + pParty->uDaysPlayed % 7 + 1, aMonthNames[pParty->uCurrentMonth], pParty->uCurrentYear); - GameUI_SetFooterString(pTmpBuf.data()); - continue; - case UIMSG_ShowStatus_Food: - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[501], pParty->uNumFoodRations); // "You have %lu food" - GameUI_SetFooterString(pTmpBuf.data()); - continue; - case UIMSG_ShowStatus_Player: - pPlayer5 = pPlayers[uMessageParam]; - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], pPlayer5->pName, pClassNames[pPlayer5->classType]);// "%s the %s" - strcat(pTmpBuf.data(), ": "); - v107 = pPlayer5->GetMajorConditionIdx(); - strcat(pTmpBuf.data(), aCharacterConditionNames[v107]); - GameUI_SetFooterString(pTmpBuf.data()); - v108 = 8 * uMessageParam - 8; - LOBYTE(v108) = v108 | 4; - pMouse->uPointingObjectID = PID(OBJECT_Player,v108); - continue; - case UIMSG_ShowStatus_ManaHP: - sprintf(pTmpBuf.data(), "%d / %d %s %d / %d %s", pPlayers[uMessageParam]->sHealth, pPlayers[uMessageParam]->GetMaxHealth(), - pGlobalTXT_LocalizationStrings[108], pPlayers[uMessageParam]->sMana, pPlayers[uMessageParam]->GetMaxMana(), - pGlobalTXT_LocalizationStrings[212]); - GameUI_SetFooterString(pTmpBuf.data()); - continue; - case UIMSG_CHEST_ClickItem: - if ( pCurrentScreen == SCREEN_CHEST_INVENTORY ) - { - pPlayers[uActiveCharacter]->OnInventoryLeftClick(); - continue; - } - Chest::OnChestLeftClick(); - continue; - case UIMSG_InventoryLeftClick: - pPlayers[uActiveCharacter]->OnInventoryLeftClick(); - continue; - case UIMSG_MouseLeftClickInGame: - /*if ( !pRenderer->pRenderD3D ) - { - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - OnGameViewportClick(); - continue; - }*/ - v115 = pMessageQueue_50CBD0->uNumMessages; - if ( !pMessageQueue_50CBD0->uNumMessages ) - { - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_MouseLeftClickInScreen, 0, 0); - /*if ( (signed int)v115 < 40 ) - //goto LABEL_769; - { - pMessageQueue_50CBD0->pMessages[v115].eType = UIMSG_MouseLeftClickInScreen; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - continue; - }*/ - continue; - } - if ( pMessageQueue_50CBD0->pMessages[0].field_8 ) - { - pMessageQueue_50CBD0->uNumMessages = 1; - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_MouseLeftClickInScreen, 0, 0); - /*v115 = v0; - pMessageQueue_50CBD0->uNumMessages = v0; - pMessageQueue_50CBD0->pMessages[v115].eType = UIMSG_MouseLeftClickInScreen; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - //goto LABEL_771; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages;*/ - continue; - } - v115 = 0; - pMessageQueue_50CBD0->uNumMessages = 0; - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_MouseLeftClickInScreen, 0, 0); - /*if ( (signed int)v115 < 40 ) - //goto LABEL_769; - { - pMessageQueue_50CBD0->pMessages[v115].eType = UIMSG_MouseLeftClickInScreen; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - continue; - }*/ - continue; - case UIMSG_MouseLeftClickInScreen://ñðàáàòûâàåò ïðè íàæàòèè íà ïðàâóþ êíîïêó ìûøè ïîñëå UIMSG_MouseLeftClickInGame - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - OnGameViewportClick(); - continue; - case UIMSG_F: - __debugbreak(); - //if ( pRenderer->pRenderD3D ) - { - LOWORD(v116) = pGame->pVisInstance->get_picked_object_zbuf_val(); - } - /*else - { - uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v209); - pPoint3 = pMouse->GetCursorPos(&v204); - v116 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint3->y]]; - }*/ - pButton2 = (GUIButton *)(unsigned __int16)v116; - GUIWindow::Create(0, 0, 0, 0, WINDOW_F, (int)pButton2, 0); - continue; - case UIMSG_54: - __debugbreak(); - pButton2 = (GUIButton *)uMessageParam; - GUIWindow::Create(0, 0, 0, 0, WINDOW_22, (int)pButton2, 0); - continue; - case UIMSG_Game_Action: - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - OnPressSpace(); - continue; - case UIMSG_ClickZoomOutBtn: - if ( pCurrentScreen ) - continue; - pParty->uFlags |= 2u; - GUIWindow::Create(519, 136, 0, 0, WINDOW_PressedButton2, (int)pBtn_ZoomOut, 0); - uNumSeconds = 131072; - v118 = 2 * viewparams->uMinimapZoom; - ++viewparams->field_28; - viewparams->uMinimapZoom *= 2; - if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor) - { - if ( (signed int)v118 > 4096 ) - { - viewparams->uMinimapZoom = 4096; - viewparams->field_28 = 12; - } - continue; - } - v119 = 2048; - if ( (signed int)v118 <= 2048 ) - { - _576E2C_current_minimap_zoom = v118; - dword_576E28 = viewparams->field_28; - break; - } - viewparams->field_28 = 11; - viewparams->uMinimapZoom = v119; - _576E2C_current_minimap_zoom = v119; - dword_576E28 = viewparams->field_28; - break; - case UIMSG_ClickZoomInBtn: - if ( pCurrentScreen ) - continue; - pParty->uFlags |= 2u; - GUIWindow::Create(574, 136, 0, 0, WINDOW_PressedButton2, (int)pBtn_ZoomIn, 0); - uNumSeconds = 32768; - v118 = (unsigned __int64)((signed __int64)(signed int)viewparams->uMinimapZoom << 15) >> 16; - --viewparams->field_28; - viewparams->uMinimapZoom = (unsigned __int64)((signed __int64)(signed int)viewparams->uMinimapZoom << 15) >> 16; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - { - v119 = 512; - if ( (signed int)v118 < 512 ) - { - viewparams->field_28 = 9; - v118 = v119; - viewparams->uMinimapZoom = v119; - } - _576E2C_current_minimap_zoom = v118; - dword_576E28 = viewparams->field_28; - } - else - { - if ( (signed int)v118 < 256 ) - { - viewparams->uMinimapZoom = 256; - viewparams->field_28 = 8; - } - } - default: - continue; - } - } - } - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50C9E8->uNumMessages;//dword_50C9E8; - memcpy(pMessageQueue_50CBD0->pMessages, pMessageQueue_50C9E8->pMessages, sizeof(GUIMessage) * pMessageQueue_50C9E8->uNumMessages); - //memcpy(pMessageQueue_50CBD0->pMessages, dword_50C9EC, 12 * dword_50C9E8); - //dword_50C9E8 = 0; - - - pMessageQueue_50C9E8->uNumMessages=0; - if ( dword_50C9DC ) - { - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)dword_50C9DC; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = (int)ptr_50C9E0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - pMessageQueue_50CBD0->AddGUIMessage((UIMessageType)dword_50C9DC, (int)ptr_50C9E0, 0); - dword_50C9DC = 0; - } - else - { - if ( _50C9D0_AfterEnchClickEventId > 0 ) - { - _50C9D8_AfterEnchClickEventTimeout -= pEventTimer->uTimeElapsed; - if ( _50C9D8_AfterEnchClickEventTimeout <= 0 ) - { - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = (UIMessageType)dword_50C9D0; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = dword_50C9D4; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - pMessageQueue_50CBD0->AddGUIMessage((UIMessageType)_50C9D0_AfterEnchClickEventId, _50C9D4_AfterEnchClickEventSecondParam, 0); - _50C9D0_AfterEnchClickEventId = 0; - _50C9D4_AfterEnchClickEventSecondParam = 0; - _50C9D8_AfterEnchClickEventTimeout = 0; - } - } - } - CastSpellInfoHelpers::_427E01_cast_spell(); -} -//----- (00435748) -------------------------------------------------------- -void GUI_MainMenuMessageProc() -{ - Player *pPlayer; // ebx@2 - void *v3; // edi@21 - signed int v4; // eax@29 -// int v5; // ecx@29 -// PLAYER_SKILL_TYPE v6; // edi@37 - GUIWindow *pWindow; // eax@56 - GUIButton *pButton; // eax@59 - int v15; // edi@70 - char v20; // dl@116 - unsigned int v21; // eax@116 - unsigned int v25; // eax@120 - unsigned int v26; // ecx@127 -// SoundID pSoundID; // [sp-2Ch] [bp-3Ch]@36 -// signed int v41; // [sp-10h] [bp-20h]@29 - int pParam; // [sp+4h] [bp-Ch]@3 - UIMessageType pUIMessageType; // [sp+8h] [bp-8h]@3 - int pSex; // [sp+Ch] [bp-4h]@3 - - if ( pMessageQueue_50CBD0->uNumMessages ) - { - pPlayer = pParty->pPlayers.data(); - do - { - int param2; - pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &pParam, ¶m2); - //auto player = &pParty->pPlayers[pParam]; - - switch (pUIMessageType) // For buttons of window MainMenu - { - case UIMSG_MainMenu_ShowPartyCreationWnd: - GUIWindow::Create(495, 172, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnNew, 0); - SetCurrentMenuID(MENU_NEWGAME); - break; - case UIMSG_MainMenu_ShowLoadWindow: - GUIWindow::Create(495, 227, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnLoad, 0); - SetCurrentMenuID(MENU_SAVELOAD); - break; - case UIMSG_ShowCredits: - GUIWindow::Create(495, 282, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnCredits, 0); - SetCurrentMenuID(MENU_CREDITS); - break; - case UIMSG_ExitToWindows: - GUIWindow::Create(495, 337, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnExit, 0); - SetCurrentMenuID(MENU_EXIT_GAME); - break; - case UIMSG_PlayerCreation_SelectAttribute: - pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) - % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; - uPlayerCreationUI_SelectedCharacter = pParam; - pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); - break; - case UIMSG_PlayerCreation_VoicePrev: - pSex = pParty->pPlayers[pParam].GetSexByVoice(); - do - { - if (pParty->pPlayers[pParam].uVoiceID == 0) - pParty->pPlayers[pParam].uVoiceID = 19; - else --pParty->pPlayers[pParam].uVoiceID; - } - while (pParty->pPlayers[pParam].GetSexByVoice() != pSex); - pButton = pCreationUI_BtnPressLeft2[pParam]; - GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, (char *)1); - pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); - pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); - break; - case UIMSG_PlayerCreation_VoiceNext: - pSex = pParty->pPlayers[pParam].GetSexByVoice(); - do - { - pParty->pPlayers[pParam].uVoiceID = (pParty->pPlayers[pParam].uVoiceID + 1) % 20; - } - while (pParty->pPlayers[pParam].GetSexByVoice() != pSex); - pButton = pCreationUI_BtnPressRight2[pParam]; - GUIWindow::Create(pButton->uX, pButton->uY, 0, 0, WINDOW_PressedButton, (int)pButton, (char *)1); - pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); - pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); - break; - case UIMSG_PlayerCreation_FacePrev: - //pPlayer = &pParty->pPlayers[pParam]; - if (!pParty->pPlayers[pParam].uCurrentFace) - pParty->pPlayers[pParam].uCurrentFace = 19; - else - pParty->pPlayers[pParam].uCurrentFace -= 1; - pParty->pPlayers[pParam].uVoiceID = pParty->pPlayers[pParam].uCurrentFace; - pParty->pPlayers[pParam].SetInitialStats(); - pParty->pPlayers[pParam].SetSexByVoice(); - pParty->pPlayers[pParam].RandomizeName(); - v25 = pParam; - pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) - % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; - uPlayerCreationUI_SelectedCharacter = v25; - GUIWindow::Create(pCreationUI_BtnPressLeft[v25]->uX, pCreationUI_BtnPressLeft[v25]->uY, 0, 0, WINDOW_PressedButton, (int)pCreationUI_BtnPressLeft[v25], (char *)1); - pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0.0, 0); - pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); - break; - case UIMSG_PlayerCreation_FaceNext: - //pPlayer = &pParty->pPlayers[pParam]; - v20 = (char)((int)pParty->pPlayers[pParam].uCurrentFace + 1) % 20; - pParty->pPlayers[pParam].uCurrentFace = v20; - pParty->pPlayers[pParam].uVoiceID = v20; - pParty->pPlayers[pParam].SetInitialStats(); - pParty->pPlayers[pParam].SetSexByVoice(); - pParty->pPlayers[pParam].RandomizeName(); - v21 = pParam; - pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) - % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; - uPlayerCreationUI_SelectedCharacter = v21; - GUIWindow::Create(pCreationUI_BtnPressRight[v21]->uX, pCreationUI_BtnPressRight[v21]->uY, 0, 0, WINDOW_PressedButton, (int)pCreationUI_BtnPressRight[v21], (char *)1); - pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); - pParty->pPlayers[pParam].PlaySound(SPEECH_PickMe, 0); - break; - case UIMSG_PlayerCreationClickPlus: - GUIWindow::Create(613, 393, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnPlus, (char *)1); - pPlayer[uPlayerCreationUI_SelectedCharacter].IncreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7); - pAudioPlayer->PlaySound((SoundID)20, 0, 0, -1, 0, 0, 0, 0); - break; - case UIMSG_PlayerCreationClickMinus: - GUIWindow::Create(523, 393, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnMinus, (char *)1); - pPlayer[uPlayerCreationUI_SelectedCharacter].DecreaseAttribute((pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7); - pAudioPlayer->PlaySound((SoundID)23, 0, 0, -1, 0, 0, 0, 0); - break; - case UIMSG_PlayerCreationSelectActiveSkill: - if ( pPlayer[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(3) == 37 ) - pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].pActiveSkills[pPlayer[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(pParam + 4)] = 1; - pAudioPlayer->PlaySound(SOUND_24, 0, 0, -1, 0, 0, 0, 0); - break; - case UIMSG_PlayerCreationSelectClass: - pPlayer[uPlayerCreationUI_SelectedCharacter].Reset((PLAYER_CLASS_TYPE)pParam); - pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); - break; - case UIMSG_PlayerCreationClickOK: - GUIWindow::Create(580, 431, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnOK, 0); - if ( PlayerCreation_GetUnspentAttributePointCount() || !PlayerCreation_Choose4Skills() ) - GameUI_Footer_TimeLeft = GetTickCount() + 4000; - else - uGameState = GAME_STATE_STARTING_NEW_GAME; - break; - case UIMSG_PlayerCreationClickReset: - GUIWindow::Create(527, 431, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnReset, 0); - pParty->Reset(); - break; - case UIMSG_PlayerCreationRemoveUpSkill: - v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem; - pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v4 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; - if ( pPlayer[pParam].GetSkillIdxByOrder(2) != 37 )//37 - None(Íåò) - pParty->pPlayers[pParam].pActiveSkills[pPlayer[pParam].GetSkillIdxByOrder(2)] = 0; - break; - case UIMSG_PlayerCreationRemoveDownSkill: - v4 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem; - pGUIWindow_CurrentMenu->pCurrentPosActiveItem = v4 % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; - if ( pPlayer[pParam].GetSkillIdxByOrder(3) != 37 )//37 - None(Íåò) - pParty->pPlayers[pParam].pActiveSkills[pPlayer[pParam].GetSkillIdxByOrder(3)] = 0; - break; - case UIMSG_PlayerCreationChangeName: - pAudioPlayer->PlaySound((SoundID)24, 0, 0, -1, 0, 0, 0, 0); - v3 = (void *)pParam; - uPlayerCreationUI_SelectedCharacter = pParam; - pKeyActionMap->EnterText(0, 15, pGUIWindow_CurrentMenu); - pGUIWindow_CurrentMenu->ptr_1C = v3; - break; - case UIMSG_ChangeGameState: - uGameState = GAME_FINISHED; - break; - case UIMSG_ChangeCursor: - pMouse->SetCursorBitmap("MICON2"); - break; - case UIMSG_3A: - SetCurrentMenuID(MENU_DebugBLVLevel); - break; - case UIMSG_LoadGame: - if (!pSavegameUsedSlots[uLoadGameUI_SelectedSlot]) - break; - SetCurrentMenuID(MENU_LoadingProcInMainMenu); - break; - case UIMSG_SelectLoadSlot: - //main menu save/load wnd clicking on savegame lines - if (pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) - pKeyActionMap->SetWindowInputStatus(WINDOW_INPUT_NONE); - if ( pCurrentScreen != SCREEN_SAVEGAME || uLoadGameUI_SelectedSlot != pParam + pSaveListPosition ) - { - //load clicked line - v26 = pParam + pSaveListPosition; - if ( dword_6BE138 == pParam + pSaveListPosition ) - { - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_SaveLoadBtn, 0, 0); - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_LoadGame, 0, 0); - } - uLoadGameUI_SelectedSlot = v26; - dword_6BE138 = v26; - } - else - { - //typing in the line - pKeyActionMap->EnterText(0, 19, pGUIWindow_CurrentMenu); - strcpy(pKeyActionMap->pPressedKeysBuffer, pSavegameHeader[uLoadGameUI_SelectedSlot].pName); - pKeyActionMap->uNumKeysPressed = strlen(pKeyActionMap->pPressedKeysBuffer); - } - break; - case UIMSG_SaveLoadBtn: - GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 241, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, WINDOW_SaveLoadBtn, (int)pBtnLoadSlot, 0); - break; - case UIMSG_DownArrow: - ++pSaveListPosition; - if ( pSaveListPosition >= pParam ) - pSaveListPosition = pParam - 1; - if ( pSaveListPosition < 1 ) - pSaveListPosition = 0; - pWindow = pGUIWindow_CurrentMenu; - GUIWindow::Create(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 323, 0, 0, WINDOW_PressedButton2, (int)pBtnDownArrow, 0); - break; - case UIMSG_Cancel: - GUIWindow::Create(pGUIWindow_CurrentMenu->uFrameX + 350, pGUIWindow_CurrentMenu->uFrameY + 302, 61, 28, WINDOW_LoadGame_CancelBtn, (int)pBtnCancel, 0); - break; - case UIMSG_ArrowUp: - --pSaveListPosition; - if ( pSaveListPosition < 0 ) - pSaveListPosition = 0; - pWindow = pGUIWindow_CurrentMenu; - GUIWindow::Create(pWindow->uFrameX + 215, pGUIWindow_CurrentMenu->uFrameY + 197, 0, 0, WINDOW_PressedButton2, (int)pBtnArrowUp, 0); - break; - case UIMSG_AD: - GUIWindow::Create(pMainMenu_BtnNew->uX, pMainMenu_BtnNew->uY, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnNew, 0); - SetCurrentMenuID(MENU_LoadingProcInMainMenu); - break; - case UIMSG_AE: - GUIWindow::Create(pMainMenu_BtnExit->uX, pMainMenu_BtnExit->uY, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnExit, 0); - SetCurrentMenuID(MENU_DebugBLVLevel); - break; - case UIMSG_Escape: - if ( pModalWindow ) - { - ModalWindow_Release(); - break; - } - if ( !(dword_6BE364_game_settings_1 & GAME_SETTINGS_4000)) - break; - v15 = 1; - pMediaPlayer->bStopBeforeSchedule = 1; - viewparams->bRedrawGameUI = 1; - viewparams->field_48 = 1; - if ( GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_MMT_MAIN_MENU - || GetCurrentMenuID() == MENU_CREATEPARTY || GetCurrentMenuID() == MENU_NAMEPANELESC ) - { - //if ( pCurrentScreen == SCREEN_VIDEO ) - //pVideoPlayer->FastForwardToFrame(pVideoPlayer->pResetflag); - if (GetCurrentMenuID() == MENU_NAMEPANELESC) //èç ïàíåëè èçìåíåíèÿ èìåíè - { - SetCurrentMenuID(MENU_CREATEPARTY);//â îêíî ñîçäàíèÿ ãðóïïû - break; - } - if (GetCurrentMenuID() == MENU_CREDITSPROC) //èç îêíà Ñîçäàòåëè - { - SetCurrentMenuID(MENU_CREDITSCLOSE);//â çàêðûòèå Ñîçäàòåëè - break; - } - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ChangeGameState, 0, 0); - break; - } - if ( GetCurrentMenuID() == MENU_CREDITSPROC && !pCurrentScreen ) - { - //if ( pCurrentScreen == SCREEN_VIDEO ) - //pVideoPlayer->FastForwardToFrame(pVideoPlayer->pResetflag); - if (GetCurrentMenuID() == MENU_NAMEPANELESC) - { - SetCurrentMenuID(MENU_CREATEPARTY); - break; - } - if (GetCurrentMenuID() == MENU_CREDITSPROC) - { - SetCurrentMenuID(MENU_CREDITSCLOSE); - break; - } - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ChangeGameState, 0, 0); - break; - } - if ( pCurrentScreen == SCREEN_LOADGAME ) - { - pIcons_LOD->RemoveTexturesPackFromTextureList(); - //crt_deconstruct_ptr_6A0118(); - pTexture_PCX.Release(); - pTexture_PCX.Load("title.pcx", 0); - SetCurrentMenuID(MENU_MAIN); - v15 = 1; - pGUIWindow_CurrentMenu->Release(); - pGUIWindow2->Release(); - pGUIWindow2 = 0; - pEventTimer->Resume(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = v15; - break; - } - if ( pCurrentScreen == SCREEN_VIDEO ) - { - //pVideoPlayer->Unload(); - } - else - { - if ( pCurrentScreen != SCREEN_1B ) - { - pGUIWindow_CurrentMenu->Release(); - pGUIWindow2->Release(); - pGUIWindow2 = 0; - pEventTimer->Resume(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = v15; - break; - } - //VideoPlayer::dtor(); - } - break; - default: - break; - } - } - while ( pMessageQueue_50CBD0->uNumMessages ); - } -} - - - -//----- (0042FBDD) -------------------------------------------------------- -void sub_42FBDD() -{ - pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); - pRenderer->DrawTextureTransparent(pBtn_YES->uX, pBtn_YES->uY, pBtn_YES->pTextures[0]); - pRenderer->Present(); -} - -//----- (0042FC15) -------------------------------------------------------- -void CloseWindowBackground() -{ - pAudioPlayer->PlaySound(SOUND_Button2, -2, 0, -1, 0, 0, 0, 0); - pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pBtn_ExitCancel->pTextures[0]); - pRenderer->Present(); -} - - -//----- (0046BDC0) -------------------------------------------------------- -void UpdateUserInput_and_MapSpecificStuff() -{ - if (dword_6BE364_game_settings_1 & GAME_SETTINGS_0080_SKIP_USER_INPUT_THIS_FRAME) - { - dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_0080_SKIP_USER_INPUT_THIS_FRAME; - return; - } - - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - BLV_UpdateUserInputAndOther(); - else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - ODM_UpdateUserInputAndOther(); - - area_of_effect__damage_evaluate(); -} - -//----- (004646F0) -------------------------------------------------------- -void PrepareWorld(unsigned int _0_box_loading_1_fullscreen) -{ - //if ( pRenderer->pRenderD3D ) - pGame->pVisInstance->_4C1A02(); - pEventTimer->Pause(); - pMiscTimer->Pause(); - pParty->uFlags = 2; - CastSpellInfoHelpers::_427D48(); - ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); - DoPrepareWorld(0, (_0_box_loading_1_fullscreen == 0) + 1); - pMiscTimer->Resume(); - pEventTimer->Resume(); -} - -//----- (00464866) -------------------------------------------------------- -void DoPrepareWorld(unsigned int bLoading, int _1_fullscreen_loading_2_box) -{ - char *v3; // eax@1 - unsigned int v5; // eax@3 - char Str1[20]; // [sp+Ch] [bp-18h]@1 - unsigned int v9; // [sp+20h] [bp-4h]@1 - - v9 = bLoading; - ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); - pDecalBuilder->Reset(0); - pGameLoadingUI_ProgressBar->Initialize(_1_fullscreen_loading_2_box == 1 ? GUIProgressBar::TYPE_Fullscreen : - GUIProgressBar::TYPE_Box); - strcpy(Str1, pCurrentMapName); - v3 = strtok(Str1, "."); - strcpy(Str1, v3); - Level_LoadEvtAndStr(Str1); - LoadLevel_InitializeLevelEvt(); - strcpy(Str1, pCurrentMapName); - _strrev(Str1); - strtok(Str1, "."); - _strrev(Str1); - - for (uint i = 0; i < 1000; ++i) - pSpriteObjects[i].uObjectDescID = 0; - - v5 = pMapStats->GetMapInfo(pCurrentMapName); - bUnderwater = false; - uLevelMapStatsID = v5; - pGame->uFlags2 &= 0xFFFFFFF7u; - if (!_stricmp(pCurrentMapName, "out15.odm")) - { - bUnderwater = true; - pGame->uFlags2 |= GAME_FLAGS_2_ALTER_GRAVITY; - } - pParty->floor_face_pid = 0; - if (_stricmp(Str1, "blv")) - PrepareToLoadODM(v9, 0); - else - PrepareToLoadBLV(v9); - pAudioPlayer->SetMapEAX(); - _461103_load_level_sub(); - if (!_stricmp(pCurrentMapName, "d11.blv") || !_stricmp(pCurrentMapName, "d10.blv")) - { - //spawning grounds & walls of mist - no loot & exp from monsters - - for (uint i = 0; i < uNumActors; ++i) - { - pActors[i].pMonsterInfo.uTreasureType = 0; - pActors[i].pMonsterInfo.uTreasureDiceRolls = 0; - pActors[i].pMonsterInfo.uExp = 0; - } - } - bDialogueUI_InitializeActor_NPC_ID = 0; - OnMapLoad(); - pGameLoadingUI_ProgressBar->Progress(); - memset(&pRenderer->pBillboardRenderListD3D, 0, sizeof(pRenderer->pBillboardRenderListD3D)); - pGameLoadingUI_ProgressBar->Release(); - _flushall(); -} - -void IntegrityTest() -{ - static_assert(sizeof(MovieHeader) == 44, "Wrong type size"); - static_assert(sizeof(SoundDesc_mm6) == 112, "Wrong type size"); - static_assert(sizeof(SoundDesc) == 120, "Wrong type size"); - static_assert(sizeof(OverlayDesc) == 8, "Wrong type size"); - static_assert(sizeof(ChestDesc) == 36, "Wrong type size"); - static_assert(sizeof(ObjectDesc_mm6) == 52, "Wrong type size"); - static_assert(sizeof(ObjectDesc) == 56, "Wrong type size"); - static_assert(sizeof(DecorationDesc) == 84, "Wrong type size"); - static_assert(sizeof(IconFrame) == 32, "Wrong type size"); - static_assert(sizeof(PlayerFrame) == 10, "Wrong type size"); - static_assert(sizeof(TextureFrame) == 20, "Wrong type size"); - static_assert(sizeof(SpriteFrame) == 60, "Wrong type size"); - static_assert(sizeof(RenderVertexSoft) == 0x30, "Wrong type size"); - static_assert(sizeof(RenderBillboard) == 0x34, "Wrong type size"); - static_assert(sizeof(Texture) == 0x48, "Wrong type size"); - static_assert(sizeof(RGBTexture) == 0x28, "Wrong type size"); - //static_assert(sizeof(LODFile_IconsBitmaps) == 0x11BB8 + 4, "Wrong type size"); // + virtual dtor ptr - static_assert(sizeof(AudioPlayer) == 0xC84, "Wrong type size"); - static_assert(sizeof(SoundDesc) == 0x78, "Wrong type size"); - static_assert(sizeof(stru339_spell_sound) == 0xAFD8, "Wrong type size"); - //static_assert(sizeof(VideoPlayer) == 0x108 + 4, "Wrong type size"); - static_assert(sizeof(MovieHeader) == 0x2C, "Wrong type size"); - static_assert(sizeof(DecorationDesc) == 0x54, "Wrong type size"); - static_assert(sizeof(ObjectDesc) == 0x38, "Wrong type size"); - static_assert(sizeof(OverlayDesc) == 0x8, "Wrong type size"); - static_assert(sizeof(ChestDesc) == 0x24, "Wrong type size"); - static_assert(sizeof(TileDesc) == 0x1A, "Wrong type size"); - static_assert(sizeof(MonsterDesc_mm6) == 148, "Wrong type size"); - static_assert(sizeof(MonsterDesc) == 152, "Wrong type size"); - static_assert(sizeof(Timer) == 0x28, "Wrong type size"); - static_assert(sizeof(OtherOverlay) == 0x14, "Wrong type size"); - static_assert(sizeof(ItemGen) == 0x24, "Wrong type size"); - static_assert(sizeof(SpriteObject) == 0x70, "Wrong type size"); - static_assert(sizeof(ItemDesc) == 0x30, "Wrong type size"); - static_assert(sizeof(ItemsTable) == 0x117A0, "Wrong type size"); - static_assert(sizeof(Chest) == 0x14CC, "Wrong type size"); - static_assert(sizeof(MapInfo) == 0x44, "Wrong type size"); - static_assert(sizeof(SpellInfo) == 0x24, "Wrong type size"); - static_assert(sizeof(SpellData) == 0x14, "Wrong type size"); - static_assert(sizeof(SpellBuff) == 0x10, "Wrong type size"); - static_assert(sizeof(AIDirection) == 0x1C, "Wrong type size"); - static_assert(sizeof(ActorJob) == 0xC, "Wrong type size"); - static_assert(sizeof(Actor) == 0x344, "Wrong type size"); - static_assert(sizeof(LevelDecoration) == 0x20, "Wrong type size"); - static_assert(sizeof(KeyboardActionMapping) == 0x20C, "Wrong type size"); - static_assert(sizeof(UIAnimation) == 0xD, "Wrong type size"); - static_assert(sizeof(SpawnPointMM7) == 0x18, "Wrong type size"); - static_assert(sizeof(ODMFace) == 0x134, "Wrong type size"); - static_assert(sizeof(BSPNode) == 0x8, "Wrong type size"); - static_assert(sizeof(BSPModel) == 0xBC, "Wrong type size"); - static_assert(sizeof(OutdoorLocation) == 0x1C28C, "Wrong type size"); - static_assert(sizeof(BLVFace) == 0x60, "Wrong type size"); - static_assert(sizeof(BLVFaceExtra) == 0x24, "Wrong type size"); - static_assert(sizeof(BLVSector) == 0x74, "Wrong type size"); - static_assert(sizeof(BLVLightMM7) == 0x10, "Wrong type size"); - static_assert(sizeof(BLVDoor) == 0x50, "Wrong type size"); - static_assert(sizeof(IndoorLocation) == 0x690, "Wrong type size"); - //static_assert(sizeof(ODMRenderParams) == 0x74, "Wrong type size"); - static_assert(sizeof(Mouse) == 0x114, "Wrong type size"); - static_assert(sizeof(Particle_sw) == 0x68, "Wrong type size"); - static_assert(sizeof(Particle) == 0x68, "Wrong type size"); - static_assert(sizeof(ParticleEngine) == 0xE430, "Wrong type size"); - static_assert(sizeof(Lightmap) == 0xC1C, "Wrong type size"); - static_assert(sizeof(LightmapBuilder) == 0x3CBC38, "Wrong type size"); - static_assert(sizeof(Vis_SelectionList) == 0x2008, "Wrong type size"); - static_assert(sizeof(Vis) == 0x20D0, "Wrong type size"); - static_assert(sizeof(PlayerBuffAnim) == 0x10, "Wrong type size"); - static_assert(sizeof(ProjectileAnim) == 0x1C, "Wrong type size"); - static_assert(sizeof(stru6) == 0x5F8, "Wrong type size"); - static_assert(sizeof(IndoorCameraD3D_Vec3) == 0x10, "Wrong type size"); - static_assert(sizeof(IndoorCameraD3D_Vec4) == 0x18, "Wrong type size"); //should be 14 (10 vec3 + 4 vdtor) but 18 coz of his +4 from own vdtor, but it is odd since vdtor already present from vec3 - //static_assert(sizeof(IndoorCameraD3D) == 0x1A1384, "Wrong type size"); - static_assert(sizeof(StationaryLight) == 0xC, "Wrong type size"); - static_assert(sizeof(LightsStack_StationaryLight_) == 0x12C8, "Wrong type size"); - static_assert(sizeof(MobileLight) == 0x12, "Wrong type size"); - static_assert(sizeof(LightsStack_MobileLight_) == 0x1C28, "Wrong type size"); - static_assert(sizeof(Game) == 0xE78, "Wrong type size"); - static_assert(sizeof(stru141_actor_collision_object) == 0xA8, "Wrong type size"); - static_assert(sizeof(ActionQueue) == 0x7C, "Wrong type size"); - static_assert(sizeof(NPCData) == 0x4C, "Wrong type size"); - static_assert(sizeof(NPCStats) == 0x17FFC, "Wrong type size"); - static_assert(sizeof(BspRenderer) == 0x53740, "Wrong type size"); - static_assert(sizeof(PaletteManager) == 0x267AF0, "Wrong type size"); - static_assert(sizeof(ViewingParams) == 0x26C, "Wrong type size"); - //static_assert(sizeof(IndoorCamera) == 0x50, "Wrong type size"); - static_assert(sizeof(Bloodsplat) == 0x28, "Wrong type size"); - static_assert(sizeof(BloodsplatContainer) == 0xA0C, "Wrong type size"); - static_assert(sizeof(TrailParticle) == 0x18, "Wrong type size"); - static_assert(sizeof(EventIndex) == 0xC, "Wrong type size"); - static_assert(sizeof(_2devent) == 0x34, "Wrong type size"); - static_assert(sizeof(MapsLongTimer) == 0x20, "Wrong type size"); - static_assert(sizeof(SavegameHeader) == 0x64, "Wrong type size"); - static_assert(sizeof(SavegameList) == 0x3138, "Wrong type size"); - static_assert(sizeof(StorylineText) == 0x160, "Wrong type size"); - static_assert(sizeof(FactionTable) == 0x1EF1, "Wrong type size"); - static_assert(sizeof(Decal) == 0xC20, "Wrong type size"); - static_assert(sizeof(DecalBuilder) == 0x30C038, "Wrong type size"); - static_assert(sizeof(MonsterInfo) == 0x58, "Wrong type size"); - static_assert(sizeof(MonsterStats) == 0x5BA0, "Wrong type size"); - static_assert(sizeof(RenderD3D) == 0x148, "Wrong type size"); - // static_assert(sizeof(Render) == 0x129844, "Wrong type size"); - static_assert(sizeof(Player) == 0x1B3C, "Wrong type size"); - static_assert(sizeof(PartyTimeStruct) == 0x678, "Wrong type size"); - static_assert(sizeof(Party) == 0x16238, "Wrong type size"); - static_assert(sizeof(GUIButton) == 0xBC, "Wrong type size"); - static_assert(sizeof(GUIWindow) == 0x54, "Wrong type size"); - static_assert(sizeof(GUIProgressBar) == 0x1B8, "Wrong type size"); - static_assert(sizeof(GUIFont) == 0x1020, "Wrong type size"); - // static_assert(sizeof(stru262_TurnBased) == 0x40, "Wrong type size"); - static_assert(sizeof(ArcomageGame) == 0xFB, "Wrong type size"); - static_assert(sizeof(CastSpellInfo) == 0x14, "Wrong type size"); - static_assert(sizeof(ArcomageCard) == 0x6C, "Wrong type size"); - static_assert(sizeof(stru320) == 0x3FC, "Wrong type size"); - static_assert(sizeof(TravelInfo) == 0x20, "Wrong type size"); - static_assert(sizeof(stru336) == 0x798, "Wrong type size"); - static_assert(sizeof(Vec3_short_) == 6, "Wrong type size"); - static_assert(sizeof(BLVFace) == 96, "Wrong type size"); - static_assert(sizeof(BLVFaceExtra) == 36, "Wrong type size"); - static_assert(sizeof(BLVSector) == 116, "Wrong type size"); - static_assert(sizeof(LevelDecoration) == 32, "Wrong type size"); - static_assert(sizeof(BLVLightMM7) == 16, "Wrong type size"); - static_assert(sizeof(BSPNode) == 8, "Wrong type size"); - static_assert(sizeof(SpawnPointMM7) == 24, "Wrong type size"); - static_assert(sizeof(DDM_DLV_Header) == 40, "Wrong type size"); - static_assert(sizeof(Actor) == 836, "Wrong type size"); - static_assert(sizeof(SpriteObject) == 112, "Wrong type size"); - static_assert(sizeof(Chest) == 5324, "Wrong type size"); - static_assert(sizeof(stru123) == 0xC8, "Wrong type size"); - static_assert(sizeof(BLVMapOutline) == 12, "Wrong type size"); - static_assert(sizeof(LODSprite) == 0x28, "Wrong type size"); -} - - -//----- (00464761) -------------------------------------------------------- -void Game_DeinitializeAndTerminate(int exitCode) -{ - SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); - ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); - pGame->Deinitialize(); - pRenderer->Release(); - delete window; - //if ( !DestroyWindow(hWnd) ) - // GetLastError(); - exit(exitCode); -} - -//----- (004647AB) -------------------------------------------------------- -void FinalInitialization() -{ - pViewport->SetScreen(viewparams->uSomeX, viewparams->uSomeY, viewparams->uSomeZ, viewparams->uSomeW); - pViewport->SetFOV(flt_6BE3A0 * 65536.0f); - - //pIndoorCamera = new IndoorCamera; - //pIndoorCamera->Initialize(65, viewparams->uScreen_BttmR_X - viewparams->uScreen_topL_X + 1, - // viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y + 1); - - InitializeTurnBasedAnimations(&stru_50C198); - pBitmaps_LOD->_inlined_sub1(); - pSprites_LOD->_inlined_sub1(); - pIcons_LOD->_inlined_sub1(); -} -// 6BE3A0: using guessed type float flt_6BE3A0; - - - -//----- (00464E17) -------------------------------------------------------- -bool __fastcall CheckMM7CD(char c) -{ - char DstBuf[256] = { 0 }; - char strCommand[256] = { 0 }; // [sp+10Ch] [bp-118h]@1 - char Filename[20] = { 0 }; // [sp+20Ch] [bp-18h]@1 - - wchar_t pMagicPath[1024]; - swprintf(pMagicPath, wcslen(L"%C:\\anims\\magic7.vid"), L"%C:\\anims\\magic7.vid", c); - if (GetFileAttributesW(pMagicPath) == -1) - return false; - - wsprintfA(strCommand, "open %c: type cdaudio alias CD", c); - if (!mciSendStringA(strCommand, DstBuf, 255, 0))//Uninitialized memory access - - { - wsprintfA(strCommand, "info CD UPC wait"); - mciSendStringA(strCommand, DstBuf, 255, 0); - wsprintfA(strCommand, "close CD"); - mciSendStringA(strCommand, DstBuf, 255, 0); - } - - memcpy(Filename, "X:\\anims\\magic7.vid", sizeof(Filename)); - *Filename = c; - - FILE* f = fopen(Filename, "rb"); - if (!f) - return false; - - if (!fseek(f, 0, SEEK_END)) - { - if (!fseek(f, -100, SEEK_CUR)) - fread(DstBuf, 1, 0x64u, f); - - fclose(f); - return true; - } - fclose(f); - return false; -} - -//----- (00464F1B) -------------------------------------------------------- -signed int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4) -{ - char v4; // zf@3 - int v6; // eax@10 - int v7; // eax@11 - int v8; // eax@12 - int v9; // eax@13 - BOOL(__stdcall *v10)(HWND, int, LPCSTR); // edi@15 - const CHAR *v11; // [sp-Ch] [bp-Ch]@15 - INT_PTR v12; // [sp-4h] [bp-4h]@5 - - if (a2 == 272) - { - hInsertCDWindow = hDlg; - v6 = (GetUserDefaultLangID() & 0x3FF) - 7; - if (v6) - { - v7 = v6 - 3; - if (v7) - { - v8 = v7 - 2; - if (v8) - { - v9 = v8 - 4; - if (v9) - { - if (v9 != 5) - return 0; - SetWindowTextA(hDlg, "Wloz CD-ROM numer 2"); - v10 = SetDlgItemTextA; - SetDlgItemTextA(hDlg, 1010, "Wloz CD-ROM numer 2 Might and Magic® VII."); - v11 = "Odwolaj"; - } - else - { - SetWindowTextA(hDlg, "Inserire il secondo CD"); - v10 = SetDlgItemTextA; - SetDlgItemTextA(hDlg, 1010, "Inserire il secondo CD di Might and Magic® VII."); - v11 = "Annulla"; - } - } - else - { - SetWindowTextA(hDlg, "Insérez le CD 2"); - v10 = SetDlgItemTextA; - SetDlgItemTextA(hDlg, 1010, "Insérez Might & Magic® VII CD 2."); - v11 = "Supprimer"; - } - } - else - { - SetWindowTextA(hDlg, "Por favor, inserte disco 2"); - v10 = SetDlgItemTextA; - SetDlgItemTextA(hDlg, 1010, "Por favor, inserte disco 2 de Might & Magic® VII."); - v11 = "Cancelar"; - } - } - else - { - SetWindowTextA(hDlg, "Bitte CD 2 einlegen"); - v10 = SetDlgItemTextA; - SetDlgItemTextA(hDlg, 1010, "Bitte CD 2 von Might and Magic® VII einlegen."); - v11 = "Abbrechen"; - } - v10(hDlg, 2, v11); - return 0; - } - if (a2 == 273) - { - if (a3 == 2) - { - v12 = 0; - EndDialog(hDlg, v12); - return 1; - } - v4 = a3 == 1; - } - else - { - v4 = a2 == 1025; - } - if (v4) - { - v12 = 1; - EndDialog(hDlg, v12); - return 1; - } - return 0; -} - -//----- (00465061) -------------------------------------------------------- -bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive) -{ - char drive[4] = { 'X', ':', '\\', 0 }; - - bool bGotCDFromRegistry = false; - - HKEY hSoftware = nullptr, - hNWC = nullptr, - hMM7 = nullptr, - hVersion = nullptr; - if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hSoftware)) - { - if (!RegOpenKeyExA(hSoftware, "New World Computing", 0, KEY_READ|KEY_WOW64_32KEY, &hNWC)) - { - if (!RegOpenKeyExA(hNWC, "Might and Magic VII", 0, KEY_READ|KEY_WOW64_32KEY, &hMM7)) - { - if (!RegOpenKeyExA(hMM7, "1.0", 0, KEY_READ|KEY_WOW64_32KEY, &hVersion)) - { - DWORD cbData = 3; - if (!RegQueryValueExA(hVersion, "CDDrive", 0, 0, (BYTE *)drive, &cbData)) - bGotCDFromRegistry = true; - } - RegCloseKey(hVersion); - } - RegCloseKey(hMM7); - } - RegCloseKey(hNWC); - } - RegCloseKey(hSoftware); - - if (bGotCDFromRegistry) - if (CheckMM7CD(*drive)) - { - cMM7GameCDDriveLetter = *drive; - return true; - } - - while (true) - { - for (uint i = 0; i < 26; ++i) - { - drive[0] = 'A' + i; - - if (GetDriveTypeA(drive) == DRIVE_CDROM) - if (CheckMM7CD(*drive)) - { - cMM7GameCDDriveLetter = *drive; - WriteWindowsRegistryString("CDDrive", drive); - return true; - } - } - - if (DialogBoxParamA(GetModuleHandleW(nullptr), "InsertCD", hWnd, (DLGPROC)InsertMM7CDDialogFunc, 0)) - continue; - return false; - } -} - -//----- (004651F4) -------------------------------------------------------- -bool MM7_Initialize(int game_width, int game_height) -{ - wchar_t pCurrentDir[1024]; - _wgetcwd(pCurrentDir, 1024); - - wchar_t pMM6IniFile[1024]; - wsprintfW(pMM6IniFile, L"%s\\mm6.ini", pCurrentDir); - - bCanLoadFromCD = GetPrivateProfileIntW(L"settings", L"use_cd", 1, pMM6IniFile); - if (bNoCD) - bCanLoadFromCD = false; - if (bCanLoadFromCD) - { - Log::Warning(L"Checking for CD..."); - if (!FindMM7CD(nullptr, &cMM7GameCDDriveLetter)) - return false; - Log::Warning(L"...done."); - } - - - srand(GetTickCount()); - - pEventTimer = Timer::Create(); - pEventTimer->Initialize(); - window = OSWindow::Create(L"Might and Magic® Trilogy", game_width, game_height);//Create game window - - bool use_d3d11 = false; - if (use_d3d11) - pRenderer = RenderD3D11::Create(); - else - pRenderer = Render::Create();//Create DirectX - if (!pRenderer) - { - Log::Warning(L"Render creation failed"); - return false; - } - else - { - //bool bWindowMode = ReadWindowsRegistryInt("startinwindow", false); - //uint uDefaultDevice = ReadWindowsRegistryInt("D3D Device", 1); - - if (!pRenderer->Initialize(window/*, bColoredLights, uLevelOfDetail, bTinting*/)) - { - Log::Warning(L"Render failed to initialize"); - return false; - } - } - - game_starting_year = 1168; - - pParty = new Party; - memset(&pParty->pHirelings, 0, sizeof(pParty->pHirelings)); - pParty->uWalkSpeed = GetPrivateProfileIntW(L"debug", L"walkspeed", 384, pMM6IniFile); - pParty->uDefaultEyelevel = GetPrivateProfileIntW(L"party", L"eyelevel", 160, pMM6IniFile); - pParty->sEyelevel = pParty->uDefaultEyelevel; - pParty->uDefaultPartyHeight = GetPrivateProfileIntW(L"party", L"height", 192, pMM6IniFile); - pParty->uPartyHeight = pParty->uDefaultPartyHeight; - - MM6_Initialize(pMM6IniFile); - - pKeyActionMap = new KeyboardActionMapping; - - OnTimer(1); - GameUI_StatusBar_UpdateTimedString(1); - pGame = Game::Create(); - pMouse = pGame->pMouseInstance; - - - pIcons_LOD = new LODFile_IconsBitmaps; - if (!pIcons_LOD->Load("data\\icons.lod", "icons")) - { - MessageBoxW(nullptr, L"Some files are missing\n\nPlease Reinstall.", - L"Files Missing", MB_ICONEXCLAMATION); - return false; - } - pIcons_LOD->dword_011BA4 = 0; - - pEvents_LOD = new LODFile_IconsBitmaps; - if (!pEvents_LOD->Load("data\\events.lod", "icons")) - { - MessageBoxW(nullptr, L"Some files are missing\n\nPlease Reinstall.", - L"Files Missing", MB_ICONEXCLAMATION); - return false; - } - - InitializeGameText(); - - pBitmaps_LOD = new LODFile_IconsBitmaps; - if (!pBitmaps_LOD->Load("data\\bitmaps.lod", "bitmaps")) - { - MessageBoxA(nullptr, pGlobalTXT_LocalizationStrings[63], - pGlobalTXT_LocalizationStrings[184], MB_ICONEXCLAMATION); - return false; - } - - pSprites_LOD = new LODFile_Sprites; - if (!pSprites_LOD->LoadSprites("data\\sprites.lod")) - { - MessageBoxA(nullptr, - pGlobalTXT_LocalizationStrings[63], - pGlobalTXT_LocalizationStrings[184], MB_ICONEXCLAMATION); - return false; - } - - -#if 0 - if (_access("../MM_VI/data/icons.lod", 0) == 0) - { - pIcons_LOD_mm6 = new LODFile_IconsBitmaps; - if (!pIcons_LOD_mm6->Load("../MM_VI/data/icons.lod", "icons")) - { - delete pIcons_LOD_mm6; - pIcons_LOD_mm6 = nullptr; - Log::Warning(L"Unable to load mm6:icons.lod"); - } - } - else - Log::Warning(L"Unable to find mm6:icons.lod"); - - if (_access("../MM_VI/data/bitmaps.lod", 0) == 0) - { - pBitmaps_LOD_mm6 = new LODFile_IconsBitmaps; - if (!pBitmaps_LOD_mm6->Load("../MM_VI/data/bitmaps.lod", "bitmaps")) - { - delete pBitmaps_LOD_mm6; - pBitmaps_LOD_mm6 = nullptr; - Log::Warning(L"Unable to load mm6:bitmaps.lod"); - } - } - else - Log::Warning(L"Unable to find mm6:bitmaps.lod"); - - auto mm6_sprite_container_name = bUseLoResSprites ? "../MM_VI/data/spriteLO.lod" - : "../MM_VI/data/sprites.lod"; - if (_access(mm6_sprite_container_name, 0) == 0) - { - pSprites_LOD_mm6 = new LODFile_Sprites; - if (!pSprites_LOD_mm6->LoadSprites(mm6_sprite_container_name)) - { - delete pSprites_LOD_mm6; - pSprites_LOD_mm6 = nullptr; - Log::Warning(L"Unable to load mm6:sprites.lod"); - } - } - else - Log::Warning(L"Unable to find mm6:sprites.lod"); - - - if (_access("../mm8/data/icons.lod", 0) == 0) - { - pIcons_LOD_mm8 = new LODFile_IconsBitmaps; - if (!pIcons_LOD_mm8->Load("../mm8/data/icons.lod", "icons")) - { - delete pIcons_LOD_mm8; - pIcons_LOD_mm8 = nullptr; - Log::Warning(L"Unable to load mm8:icons.lod"); - } - } - else - Log::Warning(L"Unable to find mm8:icons.lod"); - - - if (_access("../mm8/data/bitmaps.lod", 0) == 0) - { - pBitmaps_LOD_mm8 = new LODFile_IconsBitmaps; - if (!pBitmaps_LOD_mm8->Load("../mm8/data/bitmaps.lod", "bitmaps")) - { - delete pBitmaps_LOD_mm8; - pBitmaps_LOD_mm8 = nullptr; - Log::Warning(L"Unable to load mm8:bitmaps.lod"); - } - } - else - Log::Warning(L"Unable to find mm8:bitmaps.lod"); - - - if (_access("../mm8/data/sprites.lod", 0) == 0) - { - pSprites_LOD_mm8 = new LODFile_Sprites; - if (!pSprites_LOD_mm8->LoadSprites("../mm8/data/sprites.lod")) - { - delete pSprites_LOD_mm8; - pSprites_LOD_mm8 = nullptr; - Log::Warning(L"Unable to load mm8:sprites.lod"); - } - } - else - Log::Warning(L"Unable to find mm8:sprites.lod"); -#endif - - { - void *sft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dsft.bin", 1) : nullptr, - *sft_mm8 = nullptr; - void *sft_mm7 = pEvents_LOD->LoadRaw("dsft.bin", 1); - pSpriteFrameTable = new SpriteFrameTable; - pSpriteFrameTable->FromFile(sft_mm6, sft_mm7, sft_mm8); - free(sft_mm6); - free(sft_mm7); - free(sft_mm8); - - void *tft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dtft.bin", 1) : nullptr, - *tft_mm8 = nullptr; - void *tft_mm7 = pEvents_LOD->LoadRaw("dtft.bin", 1); - pTextureFrameTable = new TextureFrameTable; - pTextureFrameTable->FromFile(tft_mm6, tft_mm7, tft_mm8); - free(tft_mm6); - free(tft_mm7); - free(tft_mm8); - - void *tiles_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dtile.bin", 1) : nullptr, - *tiles_mm8 = nullptr; - void *tiles_mm7 = pEvents_LOD->LoadRaw("dtile.bin", 1); - pTileTable = new TileTable; - pTileTable->FromFile(tiles_mm6, tiles_mm7, tiles_mm8); - free(tiles_mm6); - free(tiles_mm7); - free(tiles_mm8); - - void *pft_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dpft.bin", 1) : nullptr, - *pft_mm8 = nullptr; - void *pft_mm7 = pEvents_LOD->LoadRaw("dpft.bin", 1); - pPlayerFrameTable = new PlayerFrameTable; - pPlayerFrameTable->FromFile(pft_mm6, pft_mm7, pft_mm8); - free(pft_mm6); - free(pft_mm7); - free(pft_mm8); - - void *ift_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dift.bin", 1) : nullptr, - *ift_mm8 = nullptr; - void *ift_mm7 = pEvents_LOD->LoadRaw("dift.bin", 1); - pIconsFrameTable = new IconFrameTable; - pIconsFrameTable->FromFile(ift_mm6, ift_mm7, ift_mm8); - free(ift_mm6); - free(ift_mm7); - free(ift_mm8); - - void *decs_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("ddeclist.bin", 1) : nullptr, - *decs_mm8 = nullptr; - void *decs_mm7 = pEvents_LOD->LoadRaw("ddeclist.bin", 1); - pDecorationList = new DecorationList; - pDecorationList->FromFile(decs_mm6, decs_mm7, decs_mm8); - free(decs_mm6); - free(decs_mm7); - free(decs_mm8); - - void *objs_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dobjlist.bin", 1) : nullptr, - *objs_mm8 = nullptr; - void *objs_mm7 = pEvents_LOD->LoadRaw("dobjlist.bin", 1); - pObjectList = new ObjectList; - pObjectList->FromFile(objs_mm6, objs_mm7, objs_mm8); - free(objs_mm6); - free(objs_mm7); - free(objs_mm8); - - void *mons_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dmonlist.bin", 1) : nullptr, - *mons_mm8 = nullptr; - void *mons_mm7 = pEvents_LOD->LoadRaw("dmonlist.bin", 1); - pMonsterList = new MonsterList; - pMonsterList->FromFile(mons_mm6, mons_mm7, mons_mm8); - free(mons_mm6); - free(mons_mm7); - free(mons_mm8); - - void *chests_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dchest.bin", 1) : nullptr, - *chests_mm8 = nullptr; - void *chests_mm7 = pEvents_LOD->LoadRaw("dchest.bin", 1); - pChestList = new ChestList; - pChestList->FromFile(chests_mm6, chests_mm7, chests_mm8); - free(chests_mm6); - free(chests_mm7); - free(chests_mm8); - - void *overlays_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("doverlay.bin", 1) : nullptr, - *overlays_mm8 = nullptr; - void *overlays_mm7 = pEvents_LOD->LoadRaw("doverlay.bin", 1); - pOverlayList = new OverlayList; - pOverlayList->FromFile(overlays_mm6, overlays_mm7, overlays_mm8); - free(overlays_mm6); - free(overlays_mm7); - free(overlays_mm8); - - void *sounds_mm6 = pIcons_LOD_mm6 ? pIcons_LOD_mm6->LoadRaw("dsounds.bin", 1) : nullptr, - *sounds_mm8 = nullptr; - void *sounds_mm7 = pEvents_LOD->LoadRaw("dsounds.bin", 1); - pSoundList = new SoundList; - pSoundList->FromFile(sounds_mm6, sounds_mm7, sounds_mm8); - free(sounds_mm6); - free(sounds_mm7); - free(sounds_mm8); - } - - - - - if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_RUN_IN_WIDOW) - { - //window->SetWindowedMode(game_width, game_height); - pRenderer->SwitchToWindow(); - } - else - { - __debugbreak(); // Nomad - window->SetFullscreenMode(); - pRenderer->InitializeFullscreen(); - } - - uSoundVolumeMultiplier = min(9, ReadWindowsRegistryInt("soundflag", 9)); - uMusicVolimeMultiplier = min(9, ReadWindowsRegistryInt("musicflag", 9)); - uVoicesVolumeMultiplier = min(9, ReadWindowsRegistryInt("CharVoices", 9)); - bShowDamage = ReadWindowsRegistryInt("ShowDamage", 1) != 0; - - uGammaPos = min(4, ReadWindowsRegistryInt("GammaPos", 4)); - pGame->pGammaController->Initialize(uGammaPos * 0.1 + 0.6); - - if (ReadWindowsRegistryInt("Bloodsplats", 1)) - pGame->uFlags2 |= GAME_FLAGS_2_DRAW_BLOODSPLATS; - else - pGame->uFlags2 &= ~GAME_FLAGS_2_DRAW_BLOODSPLATS; - - uTurnSpeed = ReadWindowsRegistryInt("TurnDelta", 3); - - if (!bNoSound) - pAudioPlayer->Initialize(); - - pMediaPlayer = new Media::MPlayer(); - pMediaPlayer->Initialize(window); - - dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; - - switch (uTurnSpeed) - { - case 0: // undefined turn option - __debugbreak(); // really shouldn't use this mode - uTurnSpeed = (unsigned int)uCPUSpeed < 199 ? 128 : 64; // adjust turn speed to estimated fps - break; - - case 1: // 16x - Log::Warning(L"x16 Turn Speed"); // really shouldn't use this mode - uTurnSpeed = 128; - break; - - case 2: // 32x - Log::Warning(L"x32 Turn Speed"); // really shouldn't use this mode - uTurnSpeed = 64; - break; - - case 3: // smooth - uTurnSpeed = 0; - break; - } - - return true; -} - -//----- (00465D0B) -------------------------------------------------------- -void SecondaryInitialization() -{ - pMouse->Initialize(window); - - pItemsTable = new ItemsTable; - pItemsTable->Initialize(); - - //pBitmaps_LOD->can_load_hardware_sprites = 1; - //pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); - pBitmaps_LOD->SetupPalettes(5, 6, 5); - //pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); - pIcons_LOD->SetupPalettes(5, 6, 5); - //pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits); - pPaletteManager->SetColorChannelInfo(5, 6, 5); - - pPaletteManager->SetMistColor(128, 128, 128); - pPaletteManager->RecalculateAll(); - //pSprites_LOD->can_load_hardware_sprites = 1; - pObjectList->InitializeSprites(); - pOverlayList->InitializeSprites(); - - if (!bNoSound) - pSoundList->Initialize(); - - - for (uint i = 0; i < 4; ++i) - { - static const char *pUIAnimNames[4] = - { - "glow03", "glow05", - "torchA", "wizeyeA" - }; - static unsigned short _4E98D0[4][4] = - { - { 479, 0, 329, 0 }, - { 585, 0, 332, 0 }, - { 468, 0, 0, 0 }, - { 606, 0, 0, 0 } - }; - - pUIAnims[i]->uIconID = pIconsFrameTable->FindIcon(pUIAnimNames[i]); - pIconsFrameTable->InitializeAnimation(pUIAnims[i]->uIconID); - - pUIAnims[i]->uAnimLength = 0; - pUIAnims[i]->uAnimTime = 0; - pUIAnims[i]->x = _4E98D0[i][0]; - pUIAnims[i]->y = _4E98D0[i][2]; - } - - for (unsigned int i = 0; i < pObjectList->uNumObjects; ++i) - { - pObjectList->pObjects[i].uParticleTrailColor = pObjectList->pObjects[i].uParticleTrailColorB | - ((unsigned int)pObjectList->pObjects[i].uParticleTrailColorG << 8) | - ((unsigned int)pObjectList->pObjects[i].uParticleTrailColorR << 16); - } - - MainMenuUI_Create(); - pGame->pStru6Instance->LoadAnimations(); - - for (uint i = 0; i < 7; ++i) - { - char container_name[64]; - sprintf(container_name, "HDWTR%03u", i); - pRenderer->pHDWaterBitmapIDs[i] = pBitmaps_LOD->LoadTexture(container_name); - } - - pNPCStats = new NPCStats; - memset(pNPCStats->pNPCData, 0, 0x94BCu); - pNPCStats->Initialize(); - - Initialize_GlobalEVT(); - pBitmaps_LOD->_inlined_sub0(); - pSprites_LOD->_inlined_sub0(); - pPaletteManager->LockAll(); - - _mkdir("Saves"); - for (uint i = 0; i < 5; ++i) - for (uint j = 0; j < 6; ++j) - { - sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j); - remove(pTmpBuf.data()); - } - - Initialize_GamesLOD_NewLOD(); - _576E2C_current_minimap_zoom = 512; - dword_576E28 = 9; -} - -bool new_sky = false; //new sky(need texture) -int max_flight_height = 4000; //maximum altitude -bool use_MMT = false; -bool for_refactoring = false; - -//----- (00462C94) -------------------------------------------------------- -bool MM_Main(const wchar_t *pCmdLine) -{ - IntegrityTest(); - - char test[1024]; - sprintfex(test, "^Pi[%s]: çíàõàð^R[ü;êà;]", "Çîëòàí"); - - lua = new LuaVM; - lua->Initialize(); - - bool bNoMargareth = false; - if (pCmdLine && *pCmdLine) - { - //if (wcsstr(pCmdLine, L"-usedefs")) - // bDebugResouces = 1; - if (wcsstr(pCmdLine, L"-window")) - dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_RUN_IN_WIDOW; - - if (wcsstr(pCmdLine, L"-nointro")) - bNoIntro = true;//dword_6BE364_game_settings_1 |= 4; - if (wcsstr(pCmdLine, L"-nologo")) - bNoLogo = true;//dword_6BE364_game_settings_1 |= 8; - if (wcsstr(pCmdLine, L"-nosound")) - bNoSound = true; //dword_6BE364_game_settings_1 |= 0x10; - - bWalkSound = ReadWindowsRegistryInt("WalkSound", 1) != 0; - if (wcsstr(pCmdLine, L"-nowalksound")) - bWalkSound = false;//dword_6BE364_game_settings_1 |= 0x20; - if (wcsstr(pCmdLine, L"-novideo")) - { - dword_6BE364_game_settings_1 |= GAME_SETTINGS_NO_HOUSE_ANIM; - bNoVideo = true; - } - if (wcsstr(pCmdLine, L"-nocd")) - bNoCD = true; - if (wcsstr(pCmdLine, L"-new_sky")) - new_sky = true; - if (wcsstr(pCmdLine, L"-nomarg")) - bNoMargareth = true; - } - - /*v8 = _4AC1C9_get_cpu_speed(0, (Vec4_int_ *)a2); - Rect.left = *(int *)v8; - Rect.top = *(int *)(v8 + 4); - Rect.right = *(int *)(v8 + 8); - Rect.bottom = *(int *)(v8 + 12); - uCPUSpeed = Rect.bottom;*/ - uCPUSpeed = 2048; // about 2GHz - - //_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF );//Ritor1: for memory test - - if (!MM7_Initialize(640, 480)) - { - Log::Warning(L"MM init: failed"); - pGame->Deinitialize(); - return 1; - } - - pEventTimer->Pause(); - - SetUserInterface(PartyAlignment_Neutral, false); - - ShowLogoVideo(); - //ShowIntroVideo_and_LoadingScreen(); - WriteWindowsRegistryInt("Ran once", 1); - dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; - pGame->InitializeGammaController(); - SecondaryInitialization(); - pRenderer->SetRasterClipRect(0, 0, window->GetWidth() - 1, window->GetHeight() - 1); - FinalInitialization(); - - //Ritor1: include - if (use_MMT) - MMT_MainMenu_Loop(); - - Log::Warning(L"MM: entering main loop"); - while (1) - { - MainMenuWindow* main_menu_window = MainMenuWindow::Create(); - window->AddControl(main_menu_window); - MainMenu_Loop(); - uGameState = GAME_STATE_PLAYING; - while (1) - { - if (uGameState == GAME_FINISHED || GetCurrentMenuID() == MENU_EXIT_GAME) - { - pGame->Deinitialize(); - return true; - } - - if (GetCurrentMenuID() == MENU_NEWGAME) - { - if (pAudioPlayer->hAILRedbook) - AIL_redbook_stop(pAudioPlayer->hAILRedbook); - pParty->Reset(); - pOtherOverlayList->Reset(); - strcpy(pCurrentMapName, pStartingMapName); - pParty->CreateDefaultParty(0); - PlayerCreationUI_Initialize(); - if (PlayerCreationUI_Loop()) - { - DeleteCCharFont(); - break; - } - DeleteCCharFont(); - bFlashQuestBook = true; - pMediaPlayer->PlayFullscreenMovie(MOVIE_Emerald, true); - SaveNewGame(); - if (bNoMargareth) - _449B7E_toggle_bit(pParty->_quest_bits, PARTY_QUEST_EMERALD_MARGARETH_OFF, 1); - pGame->Loop(); - if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) - { - SetCurrentMenuID(MENU_NEWGAME); - uGameState = GAME_STATE_PLAYING; - continue; - } - else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU) - break; - assert(false && "Invalid game state"); - } - if (GetCurrentMenuID() == MENU_CREDITS) - { - if (pAudioPlayer->hAILRedbook) - AIL_redbook_stop(pAudioPlayer->hAILRedbook); - MainMenuUI_Credits_Loop(); - break; - } - if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu) - { - uGameState = GAME_STATE_PLAYING; - pGame->Loop(); - } - else - { - if (GetCurrentMenuID() == MENU_DebugBLVLevel) - { - pMouse->ChangeActivation(0); - pParty->Reset(); - pParty->CreateDefaultParty(1); - - __debugbreak(); - /*extern void CreateDefaultBLVLevel(); - CreateDefaultBLVLevel(); - - OPENFILENAMEA ofn; - if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) - { - pMouse->ChangeActivation(1); - break; - } - _chdir("..\\"); - strcpy(pCurrentMapName, ofn.lpstrFileTitle);*/ - pMouse->ChangeActivation(1); - pGame->Loop(); - } - } - if (uGameState == GAME_STATE_LOADING_GAME) - { - SetCurrentMenuID(MENU_5); - uGameState = GAME_STATE_PLAYING; - continue; - } - if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) - { - SetCurrentMenuID(MENU_NEWGAME); - uGameState = GAME_STATE_PLAYING; - continue; - } - if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)// from the loaded game - { - pAudioPlayer->StopChannels(-1, -1); - uGameState = GAME_STATE_PLAYING; - break; - } - } - if (!bNoSound && pAudioPlayer->hAILRedbook) - { - pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); - AIL_redbook_stop(pAudioPlayer->hAILRedbook); - unsigned int startms, end_ms; - AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &startms, &end_ms); - AIL_redbook_play(pAudioPlayer->hAILRedbook, startms + 1, end_ms); - } - } - //lua_close(L); - pGame->Deinitialize(); - return 1; -} - - - -//----- (00466082) -------------------------------------------------------- -void MM6_Initialize(const wchar_t *pIniFilename) -{ - size_t v2; // eax@31 - size_t v3; // ebx@32 - size_t v4; // edi@36 - char pDefaultGroundTexture[16]; // [sp+FCh] [bp-8Ch]@32 - unsigned int v9; // [sp+184h] [bp-4h]@28 - - //_getcwd(v5, 120); - //sprintfex(pIniFilename, "%s\\mm6.ini", v5); - viewparams = new ViewingParams; - game_viewport_x = viewparams->uScreen_topL_X = GetPrivateProfileIntW(L"screen", L"vx1", 8, pIniFilename); - game_viewport_y = viewparams->uScreen_topL_Y = GetPrivateProfileIntW(L"screen", L"vy1", 8, pIniFilename); - game_viewport_z = viewparams->uScreen_BttmR_X = GetPrivateProfileIntW(L"screen", L"vx2", 468, pIniFilename); - game_viewport_w = viewparams->uScreen_BttmR_Y = GetPrivateProfileIntW(L"screen", L"vy2", 351, pIniFilename); - game_viewport_width = game_viewport_z - game_viewport_x; - game_viewport_height = game_viewport_w - game_viewport_y + 1; - - - pAudioPlayer = new AudioPlayer; - pAudioPlayer->uMixerChannels = GetPrivateProfileIntW(L"settings", L"mixerchannels", 16, pIniFilename); - if (pAudioPlayer->uMixerChannels > 16) - pAudioPlayer->uMixerChannels = 16; - - - if (GetPrivateProfileIntW(L"debug", L"nomonster", 0, pIniFilename)) - dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_ACTORS; - if (ReadWindowsRegistryInt("startinwindow", 0)) - dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_RUN_IN_WIDOW; - if (GetPrivateProfileIntW(L"debug", L"showFR", 0, pIniFilename)) - dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_0002_SHOW_FR; - if (GetPrivateProfileIntW(L"debug", L"nodamage", 0, pIniFilename)) - dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_DAMAGE; - if (GetPrivateProfileIntW(L"debug", L"nodecoration", 0, pIniFilename)) - dword_6BE368_debug_settings_2 |= DEBUG_SETTINGS_NO_DECORATIONS; - - wchar_t pStartingMapNameW[1024]; - GetPrivateProfileStringW(L"file", L"startmap", L"out01.odm", pStartingMapNameW, 0x20u, pIniFilename); - sprintf(pStartingMapName, "%S", pStartingMapNameW); - - v9 = 0; - if (strlen(pStartingMapName)) - { - do - { - if (pStartingMapName[v9] == ' ') - pStartingMapName[v9] = 0; - ++v9; - v2 = strlen(pStartingMapName); - } while (v9 < v2); - } - - pODMRenderParams = new ODMRenderParams; - pODMRenderParams->outdoor_no_mist = GetPrivateProfileIntW(L"debug", L"noMist", 0, pIniFilename); - pODMRenderParams->bNoSky = GetPrivateProfileIntW(L"outdoor", L"nosky", 0, pIniFilename); - pODMRenderParams->bDoNotRenderDecorations = GetPrivateProfileIntW(L"render", L"nodecorations", 0, pIniFilename); - pODMRenderParams->outdoor_no_wavy_water = GetPrivateProfileIntW(L"outdoor", L"nowavywater", 0, pIniFilename); - outdoor_grid_band_1 = GetPrivateProfileIntW(L"outdoor", L"gridband1", 10, pIniFilename); - outdoor_grid_band_2 = GetPrivateProfileIntW(L"outdoor", L"gridband2", 15, pIniFilename); - outdoor_grid_band_3 = GetPrivateProfileIntW(L"outdoor", L"gridband3", 25, pIniFilename); - pODMRenderParams->terrain_gamma = GetPrivateProfileIntW(L"outdoor", L"ter_gamma", 0, pIniFilename); - pODMRenderParams->building_gamme = GetPrivateProfileIntW(L"outdoor", L"bld_gamma", 0, pIniFilename); - pODMRenderParams->shading_dist_shade = GetPrivateProfileIntW(L"shading", L"dist_shade", 2048, pIniFilename); - pODMRenderParams->shading_dist_shademist = GetPrivateProfileIntW(L"shading", L"dist_shademist", 4096, pIniFilename); - - pODMRenderParams->shading_dist_mist = GetPrivateProfileIntW(L"shading", L"dist_mist", 0x2000, pIniFilename);//drawing dist 0x2000 - - wchar_t pDefaultSkyTextureW[1024]; - GetPrivateProfileStringW(L"textures", L"sky", L"plansky1", pDefaultSkyTextureW, 0x10u, pIniFilename); - sprintf(pDefaultSkyTexture.data(), "%S", pDefaultSkyTextureW); - - wchar_t pDefaultGroundTextureW[1024]; - GetPrivateProfileStringW(L"textures", L"default", L"dirt", pDefaultGroundTextureW, 0x10u, pIniFilename); - sprintf(pDefaultGroundTexture, "%S", pDefaultGroundTextureW); - - wchar_t pFloat[1024]; - GetPrivateProfileStringW(L"debug", L"recmod1", L"1.0", pFloat, 0x10u, pIniFilename); - swscanf(pFloat, L"%f", &flt_6BE3A4_debug_recmod1); - - GetPrivateProfileStringW(L"debug", L"recmod2", L"1.0", pFloat, 0x10u, pIniFilename); - swscanf(pFloat, L"%f", &flt_6BE3A8_debug_recmod2); - - flt_6BE3AC_debug_recmod1_x_1_6 = flt_6BE3A4_debug_recmod1 * 1.666666666666667; - - v3 = 0; - if (strlen(pDefaultSkyTexture.data())) - { - do - { - if (pDefaultSkyTexture[v3] == ' ') - pDefaultSkyTexture[v3] = 0; - ++v3; - } while (v3 < strlen(pDefaultSkyTexture.data())); - } - v4 = 0; - if (strlen(pDefaultGroundTexture)) - { - do - { - if (pDefaultGroundTexture[v4] == ' ') - pDefaultGroundTexture[v4] = 0; - ++v4; - } while (v4 < strlen(pDefaultGroundTexture)); - } - - MM7Initialization(); -} - -//----- (004666D5) -------------------------------------------------------- -void MM7Initialization() -{ - if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - { - /*if (byte_6BE388_graphicsmode == 0) - { - outdoor_grid_band_1 = 10; - outdoor_grid_band_2 = 15; - outdoor_grid_band_3 = 20; - pODMRenderParams->shading_dist_mist = 8192; - pODMRenderParams->bNoSky = false; - LOBYTE(viewparams->field_20) = 0; - }*/ - pODMRenderParams->shading_dist_shade = 2048; - pODMRenderParams->terrain_gamma = 0; - pODMRenderParams->building_gamme = 0; - pODMRenderParams->shading_dist_shademist = 4096; - pODMRenderParams->outdoor_no_wavy_water = 0; - //_47F4D3_initialize_terrain_bezier_stuff(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3); - { - pODMRenderParams->outdoor_grid_band_3 = outdoor_grid_band_3; - pODMRenderParams->uPickDepth = outdoor_grid_band_3 * 512; - } - } - else - LOBYTE(viewparams->field_20) = 0; - pParty->uFlags |= 2; - viewparams->uSomeY = viewparams->uScreen_topL_Y; - viewparams->uSomeX = viewparams->uScreen_topL_X; - viewparams->uSomeZ = viewparams->uScreen_BttmR_X; - viewparams->uSomeW = viewparams->uScreen_BttmR_Y; - - pViewport->SetScreen(viewparams->uScreen_topL_X, viewparams->uScreen_topL_Y, viewparams->uScreen_BttmR_X, viewparams->uScreen_BttmR_Y); - if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - pODMRenderParams->Initialize(); -} - -//----- (004610AA) -------------------------------------------------------- -void __fastcall PrepareToLoadODM(unsigned int bLoading, ODMRenderParams *a2) -{ - pGameLoadingUI_ProgressBar->Reset(27); - pSoundList->_4A9D79(0); - uCurrentlyLoadedLevelType = LEVEL_Outdoor; - ODM_LoadAndInitialize(pCurrentMapName, a2); - if (!bLoading) - TeleportToStartingPoint(uLevel_StartingPointType); - viewparams->_443365(); - PlayLevelMusic(); -} -// 6BE35C: using guessed type int uLevel_StartingPointType; - - -//----- (004627B7) -------------------------------------------------------- -void MainMenu_Loop() -{ - GUIButton *pButton; // eax@27 - unsigned int pControlParam; // ecx@35 - unsigned int pY; // [sp-18h] [bp-54h]@39 - Texture *pTexture; // [sp-14h] [bp-50h]@39 - GUIWindow *pWindow; // [sp+4h] [bp-38h]@11 - MSG msg; - - pCurrentScreen = SCREEN_GAME; - - pGUIWindow2 = 0; - pAudioPlayer->StopChannels(-1, -1); - pMouse->RemoveHoldingItem(); - - pIcons_LOD->_inlined_sub2(); - - pWindow_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); - Texture* pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); - Texture* pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); - Texture* pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); - Texture* pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); - - pMainMenu_BtnNew = pWindow_MainMenu->CreateButton(495, 172, pNew->uTextureWidth, pNew->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowPartyCreationWnd, 0, 'N', "", pNew, 0); - pMainMenu_BtnLoad = pWindow_MainMenu->CreateButton(495, 227, pLoad->uTextureWidth, pLoad->uTextureHeight, 1, 0, UIMSG_MainMenu_ShowLoadWindow, 1, 'L', "", pLoad, 0); - pMainMenu_BtnCredits = pWindow_MainMenu->CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0, UIMSG_ShowCredits, 2, 'C', "", pCredits, 0); - pMainMenu_BtnExit = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 3, 0, "", pExit, 0); - - pTexture_PCX.Release(); - pTexture_PCX.Load("title.pcx", 0); - SetCurrentMenuID(MENU_MAIN); - SetForegroundWindow(window->GetApiHandle()); - SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0); - while (GetCurrentMenuID() == MENU_MAIN || GetCurrentMenuID() == MENU_SAVELOAD) - { - POINT pt; - pMouse->GetCursorPos(&pt); - pWindow = pWindow_MainMenu; - if (GetCurrentMenuID() == MENU_SAVELOAD) - { - if (pCurrentScreen != SCREEN_LOADGAME) - { - pTexture_PCX.Release(); - pTexture_PCX.Load("lsave640.pcx", 0); - pGUIWindow2 = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); - pCurrentScreen = SCREEN_LOADGAME; - LoadUI_Load(0); - } - pWindow = pGUIWindow_CurrentMenu; - } - - while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) - { - if (msg.message == WM_QUIT) - Game_DeinitializeAndTerminate(0); - TranslateMessage(&msg); - DispatchMessageW(&msg); - } - - if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE) - { - WaitMessage(); - continue; - } - - pRenderer->BeginScene(); - pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX); - - GUI_MainMenuMessageProc(); - GUI_UpdateWindows(); - - if (GetCurrentMenuID() != MENU_MAIN) - { - if (GetCurrentMenuID() == MENU_LoadingProcInMainMenu) - { - pIcons_LOD->RemoveTexturesPackFromTextureList(); - pGUIWindow_CurrentMenu->Release(); - pGUIWindow_CurrentMenu = 0; - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - } - } - else - { - if (!pModalWindow)// ??? - { - pButton = pWindow->pControlsHead; - for (pButton = pWindow->pControlsHead; pButton; pButton = pButton->pNext) - { - if (pt.x >= (signed int)pButton->uX && pt.x <= (signed int)pButton->uZ - && pt.y >= (signed int)pButton->uY && pt.y <= (signed int)pButton->uW - && pWindow == pWindow_MainMenu) - { - pControlParam = pButton->msg_param; - switch (pControlParam) // backlight for buttons - { - case 0: - pTexture = pNew; - pY = 172; - break; - case 1: - pTexture = pLoad; - pY = 227; - break; - case 2: - pTexture = pCredits; - pY = 282; - break; - case 3: - pTexture = pExit; - pY = 337; - break; - } - pRenderer->DrawTextureIndexed(495, pY, pTexture); - } - } - } - } - pRenderer->EndScene(); - pRenderer->Present(); - } - GUI_MainMenuMessageProc(); - pRenderer->BeginScene(); - GUI_UpdateWindows(); - pRenderer->EndScene(); - pRenderer->Present(); - pTexture_PCX.Release(); - if (pGUIWindow2) - { - pGUIWindow2->Release(); - pGUIWindow2 = 0; - } - pWindow_MainMenu->Release(); - pIcons_LOD->RemoveTexturesPackFromTextureList(); -} - -//----- (004BF91E) -------------------------------------------------------- -unsigned int GameOverMenu(void *ecx0) -{ - const char *v1; // eax@2 - unsigned int result; // eax@3 - const char *v6; // eax@10 - const char *v7; // edx@10 - const char *v8; // ecx@12 - const char *v9; // eax@14 - unsigned int v10; // eax@25 - GUIWindow pWindow; // [sp+34h] [bp-9Ch]@1 - unsigned int v14; // [sp+A4h] [bp-2Ch]@5 - void *v15; // [sp+A8h] [bp-28h]@1 - const char *pInString; // [sp+ACh] [bp-24h]@5 - unsigned int v17; // [sp+B0h] [bp-20h]@5 - unsigned int v18; // [sp+B4h] [bp-1Ch]@5 - unsigned int v19; // [sp+B8h] [bp-18h]@5 - int v20; // [sp+BCh] [bp-14h]@7 - GUIFont *pFont; // [sp+C4h] [bp-Ch]@1 - unsigned __int64 v23; // [sp+C8h] [bp-8h]@5 - MSG msg; - - v15 = ecx0; - - RGBTexture _this; // [sp+Ch] [bp-C4h]@1 - //RGBTexture::RGBTexture(&this); - - dword_6BE364_game_settings_1 &= ~GAME_SETTINGS_4000; - bGameoverLoop = 1; - pMediaPlayer->bStopBeforeSchedule = 0; - pAudioPlayer->StopChannels(-1, -1); - pRenderer->BeginScene(); - pRenderer->ClearBlack(); - pRenderer->EndScene(); - pRenderer->Present(); - //pMediaPlayer->pResetflag = 0; - _449B57_test_bit(pParty->_quest_bits, 99); - _this.Load("winbg.pcx", 2); - pRenderer->BeginScene(); - pRenderer->DrawTextureRGB(0, 0, &_this); - pRenderer->EndScene(); - free(_this.pPixels); - _this.pPixels = 0; - window_SpeakInHouse = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); - pWindow.uFrameX = 75; - pWindow.uFrameY = 60; - pWindow.uFrameWidth = 469; - pWindow.uFrameHeight = 338; - pWindow.uFrameZ = 543; - pWindow.uFrameW = 397; - pFont = LoadFont("endgame.fnt", "FONTPAL", NULL); - if (pParty->IsPartyGood()) - v1 = pGlobalTXT_LocalizationStrings[675];//"Splendid job! With the activation of the Gate, a thousand worlds lie at your feet. Perhaps on one of them you will find the Ancients themselves, and return with the fruits their great civilization has to offer your world and your kingdom." - else - { - result = pParty->IsPartyEvil(); - if (!(short)result) - return result; - v1 = pGlobalTXT_LocalizationStrings[676];//"Brilliant! The completion of the Heavenly Forge has provided enough Ancient weapons to crush all resistance to your plans. Soon the world will bow to your every whim! Still, you can't help but wonder what was beyond the Gate the other side was trying so hard to build." - } - pInString = v1; - v23 = pParty->uTimePlayed - 138240; - v19 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 24; - v14 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 24 / 0x1C / 0xC; - v18 = (unsigned int)((signed __int64)((double)(pParty->uTimePlayed - 138240) * 0.234375) / 60 / 60) / 24 / 0x1C % 0xC; - v17 = v19 % 0x1C; - if (!v19) - v19 = 1; - pRenderer->BeginScene(); - pWindow.DrawTitleText(pFont, 1, 0x23, 1, pGlobalTXT_LocalizationStrings[9], 3);//Congratulations! - v23 = 0i64; - v20 = 0; - for (uint i = 0; i < 4; i++) - { - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[129], pParty->pPlayers[i].pName, pParty->pPlayers[i].GetBaseLevel(), pClassNames[pParty->pPlayers[i].classType]);//%s the Level %u %s - pWindow.DrawTitleText(pFont, 1, i * (LOBYTE(pFont->uFontHeight) - 2) + LOBYTE(pFont->uFontHeight) + 46, 1, pTmpBuf.data(), 3); - v23 += pParty->pPlayers[i].uExperience;//__PAIR__(*(int *)(i - 4), *(int *)(i - 8)); - } - v23 = (signed __int64)v23 / v19; - v6 = FitTextInAWindow(pInString, pFont, &pWindow, 0xC, 0); - pWindow.DrawTitleText(pFont, 1, 5 * (LOBYTE(pFont->uFontHeight) + 11), 1, v6, 0); - strcpy(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[37]);//Total Time: - - v7 = pGlobalTXT_LocalizationStrings[56]; - if (v17 != 1) - v7 = pGlobalTXT_LocalizationStrings[57]; - - v8 = pGlobalTXT_LocalizationStrings[146];//Month - if (v18 != 1) - v8 = pGlobalTXT_LocalizationStrings[148];//Months - - v9 = pGlobalTXT_LocalizationStrings[245]; - if (v14 != 1) - v9 = pGlobalTXT_LocalizationStrings[132]; - - sprintf(pTmpBuf2.data(), " %lu %s, %lu %s, %lu %s ", v14, v9, v18, v8, v17, v7); - strcat(pTmpBuf.data(), pTmpBuf2.data()); - pWindow.DrawTitleText(pFont, 1, pWindow.uFrameHeight - 2 * LOBYTE(pFont->uFontHeight) - 5, 1, pTmpBuf.data(), 3); - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[94], v23); - pWindow.DrawTitleText(pFont, 1, pWindow.uFrameHeight, 1, pTmpBuf.data(), 3); - dword_6BE364_game_settings_1 |= GAME_SETTINGS_4000; - pRenderer->EndScene(); - pRenderer->Present(); - //if ( pRenderer->pRenderD3D ) - pRenderer->pBeforePresentFunction(); - pRenderer->SaveWinnersCertificate("MM7_Win.Pcx"); - free(pFont); - window_SpeakInHouse->Release(); - window_SpeakInHouse = 0; - if (v15 == (void *)2) - result = pMessageQueue_50CBD0->uNumMessages; - else - { - LODWORD(v23) = GetTickCount() + 5000; - while ((unsigned int)v23 > GetTickCount()) - ; - while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) - { - if (msg.message == WM_QUIT) - Game_DeinitializeAndTerminate(0); - TranslateMessage(&msg); - DispatchMessage(&msg); - } - if (pMessageQueue_50CBD0->uNumMessages) - { - LOBYTE(v10) = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pMessageQueue_50CBD0->uNumMessages = v10; - } - pKeyActionMap->ResetKeys(); - pKeyActionMap->uLastKeyPressed = 0; - do - { - while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) - { - if (msg.message == WM_QUIT) - Game_DeinitializeAndTerminate(0); - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } while (!pKeyActionMap->uLastKeyPressed); - result = pMessageQueue_50CBD0->uNumMessages; - if (pMessageQueue_50CBD0->uNumMessages) - { - result = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - } - } - if (v15) - { - /*if ( (signed int)result < 40 ) - { - pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_Quit; - }*/ - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Quit, 1, 0); - } - else - { - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_ShowFinalWindow, 1, 0); - /*if ( (signed int)result < 40 ) - { - pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_C5; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; - result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; - *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - } - bGameoverLoop = 0; - return result; -} - -//----- (00464479) -------------------------------------------------------- -void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows() -{ - int v0; // esi@9 - - if (pMouse) - pMouse->SetCursorBitmap("MICON1"); - - pPaletteManager->ResetNonLocked(); - pBitmaps_LOD->ReleaseAll2(); - pSprites_LOD->DeleteSomeOtherSprites(); - pIcons_LOD->ReleaseAll2(); - - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - pIndoor->Release(); - else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - pOutdoor->Release(); - - pAudioPlayer->StopChannels(-1, -1); - pSoundList->_4A9D79(0); - uCurrentlyLoadedLevelType = LEVEL_null; - pSpriteFrameTable->ResetSomeSpriteFlags(); - v0 = uNumVisibleWindows; - pParty->armageddon_timer = 0; - while (v0 > 0) - pWindowList[pVisibleWindowsIdxs[v0--] - 1].Release(); -} - -//----- (00461103) -------------------------------------------------------- -void _461103_load_level_sub() -{ - int v4; // edx@8 - signed int v6; // esi@14 - signed int v8; // ecx@16 - int v12; // esi@25 - int v13; // eax@26 - __int16 v14; // ax@41 - signed int v17; // [sp+14h] [bp-48h]@3 - signed int v18; // [sp+14h] [bp-48h]@23 - int v19; // [sp+18h] [bp-44h]@1 - signed int v20; // [sp+18h] [bp-44h]@14 - int v21[16]; // [sp+1Ch] [bp-40h]@17 - - GenerateItemsInChest(); - pGameLoadingUI_ProgressBar->Progress(); - pParty->uFlags |= 2; - pParty->field_7B5_in_arena_quest = 0; - dword_5C6DF8 = 1; - pNPCStats->uNewlNPCBufPos = 0; - v19 = pMapStats->GetMapInfo(pCurrentMapName); - - //v15 = 0; - for (uint i = 0; i < uNumActors; ++i) - //if ( (signed int)uNumActors > 0 ) - { - //Actor* pActor = &pActors[i]; - //v2 = (char *)&pActors[0].uNPC_ID; - //do - //{ - //v3 = pActors[i].pMonsterInfo.uID; - v17 = 0; - if (pActors[i].pMonsterInfo.uID >= 115 && pActors[i].pMonsterInfo.uID <= 186 - || pActors[i].pMonsterInfo.uID >= 232 && pActors[i].pMonsterInfo.uID <= 249) - v17 = 1; - //v1 = 0; - v4 = (pActors[i].pMonsterInfo.uID - 1) % 3; - if (2 == v4) - { - if (pActors[i].sNPC_ID && pActors[i].sNPC_ID < 5000) - continue; - } - else - { - if (v4 != 1) - { - if (v4 == 0 && pActors[i].sNPC_ID == 0) - pActors[i].sNPC_ID = 0; - continue; - } - } - if (pActors[i].sNPC_ID > 0 && pActors[i].sNPC_ID < 5000) - continue; - if (v17) - { - pNPCStats->InitializeAdditionalNPCs(&pNPCStats->pAdditionalNPC[pNPCStats->uNewlNPCBufPos], pActors[i].pMonsterInfo.uID, 0, v19); - v14 = LOWORD(pNPCStats->uNewlNPCBufPos) + 5000; - ++pNPCStats->uNewlNPCBufPos; - pActors[i].sNPC_ID = v14; - continue; - } - pActors[i].sNPC_ID = 0; - //++v15; - //v2 += 836; - //} - //while ( v15 < (signed int)uNumActors ); - } - - pGameLoadingUI_ProgressBar->Progress(); - - //v5 = uNumActors; - v6 = 0; - v20 = 0; - //v16 = v1; - - for (uint i = 0; i < uNumActors; ++i) - { - //v7 = (char *)&pActors[0].pMonsterInfo; - //do - //{ - for (v8 = 0; v8 < v6; ++v8) - { - if (v21[v8] == pActors[i].pMonsterInfo.uID - 1) - break; - } - - if (v8 == v6) - { - v21[v6++] = pActors[i].pMonsterInfo.uID - 1; - v20 = v6; - if (v6 == 16) - break; - } - //++v16; - //v7 += 836; - //} - //while ( v16 < (signed int)v5 ); - } - - pGameLoadingUI_ProgressBar->Progress(); - - for (int _v0 = 0; _v0 < v6; ++_v0) - { - for (v18 = 4; v18; --v18) - pSoundList->LoadSound(pMonsterList->pMonsters[v21[_v0]].pSoundSampleIDs[4 - v18], 0); - v12 = 0; - do - v13 = pSoundList->LoadSound(v12++ + word_4EE088_sound_ids[pMonsterStats->pInfos[v21[_v0] + 1].uSpell1ID], 1); - while (v13); - } - //v0 = pGameLoadingUI_ProgressBar; - //v1 = 0; - - pGameLoadingUI_ProgressBar->Progress(); - - if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_ACTORS) - uNumActors = 0; - if (dword_6BE368_debug_settings_2 & DEBUG_SETTINGS_NO_DECORATIONS) - uNumLevelDecorations = 0; - init_event_triggers(); - - pGameLoadingUI_ProgressBar->Progress(); - - pGame->pIndoorCameraD3D->vPartyPos.x = 0; - pGame->pIndoorCameraD3D->vPartyPos.y = 0; - pGame->pIndoorCameraD3D->vPartyPos.z = 100; - pGame->pIndoorCameraD3D->sRotationX = 0; - pGame->pIndoorCameraD3D->sRotationY = 0; - viewparams->bRedrawGameUI = true; - uLevel_StartingPointType = MapStartPoint_Party; - pSprites_LOD->_461397(); - pPaletteManager->LockTestAll(); - if (pParty->pPickedItem.uItemID != 0) - pMouse->SetCursorBitmapFromItemID(pParty->pPickedItem.uItemID); -} - -//----- (0042F3D6) -------------------------------------------------------- -void InitializeTurnBasedAnimations(void *_this) -{ - for (unsigned int i = 0; i < pIconIDs_Turn.size(); ++i) - { - char icon_name[32]; - sprintf(icon_name, "turn%u", i); - pIconIDs_Turn[i] = pIconsFrameTable->FindIcon(icon_name); - pIconsFrameTable->InitializeAnimation(pIconIDs_Turn[i]); - } - - uIconID_TurnStop = pIconsFrameTable->FindIcon("turnstop"); - uIconID_TurnHour = pIconsFrameTable->FindIcon("turnhour"); - uIconID_TurnStart = pIconsFrameTable->FindIcon("turnstart"); - uIconID_CharacterFrame = pIconsFrameTable->FindIcon("aframe1"); - uSpriteID_Spell11 = pSpriteFrameTable->FastFindSprite("spell11"); - - pIconsFrameTable->InitializeAnimation(uIconID_TurnHour); - pIconsFrameTable->InitializeAnimation(uIconID_TurnStop); - pIconsFrameTable->InitializeAnimation(uIconID_TurnStart); - pIconsFrameTable->InitializeAnimation(uIconID_CharacterFrame); -} - -//----- (00466C40) -------------------------------------------------------- -const wchar_t *MENU_STATE_to_string(MENU_STATE m) -{ - switch (m) - { - case -1: return L"-1"; - case MENU_MAIN: return L"MENU_MAIN"; - case MENU_NEWGAME: return L"MENU_NEWGAME"; - case MENU_CREDITS: return L"MENU_CREDITS"; - case MENU_SAVELOAD: return L"MENU_SAVELOAD"; - case MENU_EXIT_GAME: return L"MENU_EXIT_GAME"; - case MENU_5: return L"MENU_5"; - case MENU_CREATEPARTY: return L"MENU_CREATEPARTY"; - case MENU_NAMEPANELESC: return L"MENU_NAMEPANELESC"; - case MENU_CREDITSPROC: return L"MENU_CREDITSPROC"; - case MENU_LoadingProcInMainMenu: return L"MENU_LoadingProcInMainMenu"; - case MENU_DebugBLVLevel: return L"MENU_DebugBLVLevel"; - case MENU_CREDITSCLOSE: return L"MENU_CREDITSCLOSE"; - case MENU_MMT_MAIN_MENU: return L"MENU_MMT_MAIN_MENU"; - default: return L"unk"; - }; -}; -void SetCurrentMenuID(MENU_STATE uMenu) -{ - sCurrentMenuID = uMenu; - - Log::Warning(L"CurrentMenu = %s \n", MENU_STATE_to_string(uMenu)); -} - -//----- (00466CA0) -------------------------------------------------------- -MENU_STATE GetCurrentMenuID() -{ - return sCurrentMenuID; -} - -//----- (0046BDA8) -------------------------------------------------------- -unsigned int GetGravityStrength() -{ - int v0; // eax@1 - - v0 = ~LOBYTE(pGame->uFlags2) & 8; - LOBYTE(v0) = v0 | 2; - return (unsigned int)v0 >> 1; -} - -//----- (00448B45) -------------------------------------------------------- -void GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide) -{ - if (bForceHide || GameUI_Footer_TimeLeft && GetTickCount() >= GameUI_Footer_TimeLeft) - GameUI_Footer_TimeLeft = 0; -} - -//----- (0044861E) -------------------------------------------------------- -void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename) -{ - unsigned int texture; // eax@2 - - if (uFaceCog) - { - texture = pBitmaps_LOD->LoadTexture(pFilename); - if (texture != -1 ? (int)&pBitmaps_LOD->pTextures[texture] : 0) - { - pBitmaps_LOD->pTextures[texture].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[texture].palette_id1); - - if (uCurrentlyLoadedLevelType == 1) - { - if ((signed int)pIndoor->uNumFaceExtras > 1) - { - for (uint i = 1; i < (signed int)pIndoor->uNumFaceExtras; ++i) - { - if (pIndoor->pFaceExtras[i].sCogNumber == uFaceCog) - { - if (pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes & FACE_TEXTURE_FRAME) - { - pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = pTextureFrameTable->FindTextureByName(pFilename); - if (pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID) - { - pTextureFrameTable->LoadAnimationSequenceAndPalettes(pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID); - } - else - { - pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture; - pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes &= 0xFFFFBFFF; - } - } - else - { - pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uBitmapID = texture; - } - } - } - } - pParty->uFlags |= 2; - } - else - { - for (uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j) - { - for (uint i = 0; i < pOutdoor->pBModels[j].uNumFaces; ++i) - { - if (pOutdoor->pBModels[j].pFaces[i].sCogNumber == uFaceCog) - { - if (pOutdoor->pBModels[j].pFaces[i].uAttributes & FACE_TEXTURE_FRAME) - { - pOutdoor->pBModels[j].pFaces[i].uTextureID = pTextureFrameTable->FindTextureByName(pFilename); - if (pOutdoor->pBModels[j].pFaces[i].uTextureID) - pTextureFrameTable->LoadAnimationSequenceAndPalettes(pOutdoor->pBModels[j].pFaces[i].uTextureID); - else - { - pOutdoor->pBModels[j].pFaces[i].uTextureID = texture; - pOutdoor->pBModels[j].pFaces[i].uAttributes &= 0xFFFFBFFF; - } - } - else - pOutdoor->pBModels[j].pFaces[i].uTextureID = texture; - } - } - } - } - pParty->uFlags |= 2; - } - } -} - -//----- (0044892E) -------------------------------------------------------- -void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on) -{ - if (sCogNumber) - { - if (uCurrentlyLoadedLevelType == 1) - { - for (uint i = 1; i < (unsigned int)pIndoor->uNumFaceExtras; ++i) - { - if (pIndoor->pFaceExtras[i].sCogNumber == sCogNumber) - { - if (on) - pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes |= bit; - else - pIndoor->pFaces[pIndoor->pFaceExtras[i].field_C].uAttributes &= ~bit; - } - } - pParty->uFlags |= 2; - } - else - { - for (uint j = 0; j < (unsigned int)pOutdoor->uNumBModels; ++j) - { - for (uint i = 0; i < (unsigned int)pOutdoor->pBModels[j].uNumFaces; ++i) - { - if (pOutdoor->pBModels[j].pFaces[i].sCogNumber == sCogNumber) - { - if (on) - pOutdoor->pBModels[j].pFaces[i].uAttributes |= bit; - else - pOutdoor->pBModels[j].pFaces[i].uAttributes &= ~bit; - } - } - } - } - pParty->uFlags |= 2; - } -} - -//----- (0044882F) -------------------------------------------------------- -void __fastcall SetDecorationSprite(uint16_t uCog, bool bHide, const char *pFileName) -{ - for (size_t i = 0; i < uNumLevelDecorations; i++) - { - if (pLevelDecorations[i].uCog == uCog) - { - if (pFileName && strcmp(pFileName, "0")) - { - pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(pFileName); - pDecorationList->InitializeDecorationSprite(pLevelDecorations[i].uDecorationDescID); - } - - if (bHide) - pLevelDecorations[i].uFlags &= ~LEVEL_DECORATION_INVISIBLE; - else - pLevelDecorations[i].uFlags |= LEVEL_DECORATION_INVISIBLE; - - pParty->uFlags |= 2; - } - } -} - -//----- (004356FF) -------------------------------------------------------- -void back_to_game() -{ - dword_507BF0_is_there_popup_onscreen = 0; - dword_4E455C = 1; - - extern int no_rightlick_in_inventory; - no_rightlick_in_inventory = false; - - if (pGUIWindow_ScrollWindow) - free_book_subwindow(); - if (!pCurrentScreen && !pGUIWindow_Settings) - pEventTimer->Resume(); - viewparams->bRedrawGameUI = 1; -} - -//----- (00494035) -------------------------------------------------------- -void _494035_timed_effects__water_walking_damage__etc() -{ - signed __int64 v0; // qax@1 - unsigned int v4; // edi@1 - // signed int v12; // edi@29 - int v24; // ecx@60 - int v26; // ecx@64 - int v28; // ecx@68 - int v30; // ecx@72 - int v32; // ecx@76 - int v34; // ecx@80 - int v36; // ecx@84 - int v38; // ecx@88 - int v40; // ecx@92 - int v42; // ecx@96 - bool v43; // ebx@102 - bool v46; // edi@111 - // unsigned int v56; // [sp-8h] [bp-38h]@55 - // int v59; // [sp-4h] [bp-34h]@55 - // unsigned int v61; // [sp+14h] [bp-1Ch]@1 - signed int a2a; // [sp+18h] [bp-18h]@47 - signed int old_day; // [sp+1Ch] [bp-14h]@47 - signed int old_hour; - - old_day = pParty->uDaysPlayed; - old_hour = pParty->uCurrentHour; - //auto prev_time = pEventTimer->uTimeElapsed; - pParty->uTimePlayed += pEventTimer->uTimeElapsed; - v0 = ((signed __int64)(pParty->uTimePlayed * 0.234375) / 60) / 60i64; - v4 = (unsigned int)(((unsigned int)v0 / 24) / 7) >> 2; - pParty->uCurrentTimeSecond = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) % 60; - pParty->uCurrentMinute = ((signed __int64)(pParty->uTimePlayed * 0.234375) / 60) % 60; - pParty->uCurrentHour = v0 % 24; - pParty->uCurrentMonthWeek = ((unsigned int)v0 / 24) / 7 & 3; - pParty->uDaysPlayed = (unsigned int)((unsigned int)v0 / 24) % 28; - pParty->uCurrentMonth = v4 % 12; - pParty->uCurrentYear = v4 / 0xC + game_starting_year; - if (pParty->uCurrentHour >= 3 && (old_hour < 3 || pParty->uDaysPlayed > old_day)) // new day dawns - { - pParty->pHirelings[0].bHasUsedTheAbility = false; - pParty->pHirelings[1].bHasUsedTheAbility = false; - - for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i) - pNPCStats->pNewNPCData[i].bHasUsedTheAbility = false; - - ++pParty->days_played_without_rest; - if (pParty->days_played_without_rest > 1) - { - for (uint i = 0; i < 4; ++i) - pParty->pPlayers[i].SetCondWeakWithBlockCheck(0); - - if (pParty->uNumFoodRations) - Party::TakeFood(1); - else - for (uint i = 0; i < 4; ++i) - pParty->pPlayers[i].sHealth = pParty->pPlayers[i].sHealth / (pParty->days_played_without_rest + 1) + 1; - - if (pParty->days_played_without_rest > 3) - for (uint i = 0; i < 4; ++i) - { - pParty->pPlayers[i].Zero(); - if (!pParty->pPlayers[i].IsPertified() && !pParty->pPlayers[i].IsEradicated() - && !pParty->pPlayers[i].IsDead()) - { - if (rand() % 100 < 5 * pParty->days_played_without_rest) - pParty->pPlayers[i].SetCondDeadWithBlockCheck(0); - if (rand() % 100 < 10 * pParty->days_played_without_rest) - pParty->pPlayers[i].SetCondInsaneWithBlockCheck(0); - } - } - } - if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - pOutdoor->SetFog(); - - for (uint i = 0; i < 4; ++i) - pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0; - } - - if (pParty->uFlags & 4 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed)//water damage - { - pParty->field_6FC = (signed __int64)pParty->uTimePlayed + 128; - viewparams->bRedrawGameUI = true; - for (uint pl = 1; pl <= 4; ++pl) - { - if (pPlayers[pl]->WearsItem(ITEM_RELIC_HARECS_LEATHER, EQUIP_ARMOUR) - || pPlayers[pl]->HasEnchantedItemEquipped(71) - || pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_WATER_WALK].uExpireTime > 0) - pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_37, 0); - else - { - if (!pPlayers[pl]->HasUnderwaterSuitEquipped()) - { - pPlayers[pl]->ReceiveDamage((signed __int64)pPlayers[pl]->GetMaxHealth() * 0.1, DMGT_FIRE); - if (pParty->uFlags & 4) - { - strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[660]);// Âû òîíåòå! - GameUI_Footer_TimeLeft = 128; - } - } - else - pPlayers[pl]->PlayEmotion(CHARACTER_EXPRESSION_37, 0); - } - } - } - if (pParty->uFlags & 0x200 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed) //lava damage - { - viewparams->bRedrawGameUI = true; - pParty->field_6FC = (signed __int64)pParty->uTimePlayed + 128; - - for (uint pl = 1; pl <= 4; pl++) - { - pPlayers[pl]->ReceiveDamage((signed __int64)pPlayers[pl]->GetMaxHealth() * 0.1, DMGT_FIRE); - if (pParty->uFlags & 0x200) - { - strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[661]); //Âû ãîðèòå! - GameUI_Footer_TimeLeft = 128; - } - } - } - _493938_regenerate(); - uint party_condition_flag = 4; - a2a = pEventTimer->uTimeElapsed; - if (pParty->uFlags2 & PARTY_FLAGS_2_RUNNING)//çàìåäëåíèå âîññòàíîâëåíèÿ ïðè áåãå - { - a2a *= 0.5f; - if (a2a < 1) - a2a = 1; - } - - for (uint pl = 1; pl <= 4; pl++) - { - if (pPlayers[pl]->uTimeToRecovery) - pPlayers[pl]->Recover(a2a);//âîññòàíîâëåíèå àêòèâíîñòè - if (pPlayers[pl]->GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) + pPlayers[pl]->sHealth + pPlayers[pl]->uEndurance >= 1 - || (signed __int64)pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0) - { - if (pPlayers[pl]->sHealth < 1) - pPlayers[pl]->SetCondition(Condition_Unconcious, 0); - } - else - pPlayers[pl]->SetCondition(Condition_Dead, 0); - if (pPlayers[pl]->field_E0) - { - v24 = pPlayers[pl]->field_E0 - pEventTimer->uTimeElapsed; - if (v24 > 0) - pPlayers[pl]->field_E0 = v24; - else - { - pPlayers[pl]->field_E0 = 0; - viewparams->bRedrawGameUI = true; - } - } - if (pPlayers[pl]->field_E4) - { - v26 = pPlayers[pl]->field_E4 - pEventTimer->uTimeElapsed; - if (v26 > 0) - pPlayers[pl]->field_E4 = v26; - else - { - pPlayers[pl]->field_E4 = 0; - viewparams->bRedrawGameUI = true; - } - } - if (pPlayers[pl]->field_E8) - { - v28 = pPlayers[pl]->field_E8 - pEventTimer->uTimeElapsed; - if (v28 > 0) - pPlayers[pl]->field_E8 = v28; - else - { - pPlayers[pl]->field_E8 = 0; - viewparams->bRedrawGameUI = true; - } - } - if (pPlayers[pl]->field_EC) - { - v30 = pPlayers[pl]->field_EC - pEventTimer->uTimeElapsed; - if (v30 > 0) - pPlayers[pl]->field_EC = v30; - else - { - pPlayers[pl]->field_EC = 0; - viewparams->bRedrawGameUI = true; - } - } - if (pPlayers[pl]->field_F0) - { - v32 = pPlayers[pl]->field_F0 - pEventTimer->uTimeElapsed; - if (v32 > 0) - pPlayers[pl]->field_F0 = v32; - else - { - pPlayers[pl]->field_F0 = 0; - viewparams->bRedrawGameUI = true; - } - } - if (pPlayers[pl]->field_F4) - { - v34 = pPlayers[pl]->field_F4 - pEventTimer->uTimeElapsed; - if (v34 > 0) - pPlayers[pl]->field_F4 = v34; - else - { - pPlayers[pl]->field_F4 = 0; - viewparams->bRedrawGameUI = true; - } - } - if (pPlayers[pl]->field_F8) - { - v36 = pPlayers[pl]->field_F8 - pEventTimer->uTimeElapsed; - if (v36 > 0) - pPlayers[pl]->field_F8 = v36; - else - { - pPlayers[pl]->field_F8 = 0; - viewparams->bRedrawGameUI = true; - } - } - if (pPlayers[pl]->field_FC) - { - v38 = pPlayers[pl]->field_FC - pEventTimer->uTimeElapsed; - if (v38 > 0) - pPlayers[pl]->field_FC = v38; - else - { - pPlayers[pl]->field_FC = 0; - viewparams->bRedrawGameUI = true; - } - } - if (pPlayers[pl]->field_100) - { - v40 = pPlayers[pl]->field_100 - pEventTimer->uTimeElapsed; - if (v40 > 0) - pPlayers[pl]->field_100 = v40; - else - { - pPlayers[pl]->field_100 = 0; - viewparams->bRedrawGameUI = true; - } - } - if (pPlayers[pl]->field_104) - { - v42 = pPlayers[pl]->field_104 - pEventTimer->uTimeElapsed; - if (v42 > 0) - pPlayers[pl]->field_104 = v42; - else - { - pPlayers[pl]->field_104 = 0; - viewparams->bRedrawGameUI = true; - } - } - if (pPlayers[pl]->pConditions[Condition_Sleep] | pPlayers[pl]->pConditions[Condition_Paralyzed] - | pPlayers[pl]->pConditions[Condition_Unconcious] | pPlayers[pl]->pConditions[Condition_Dead] - | pPlayers[pl]->pConditions[Condition_Pertified] | pPlayers[pl]->pConditions[Condition_Eradicated]) - --party_condition_flag; - v43 = (signed __int64)pPlayers[pl]->pPlayerBuffs[PLAYER_BUFF_HASTE].uExpireTime > 0; //ñïåøêà - - for (uint k = 0; k < 24; ++k) - pPlayers[pl]->pPlayerBuffs[k].IsBuffExpiredToTime(pParty->uTimePlayed); - - if (v43 && (signed __int64)pPlayers[pl]->pPlayerBuffs[7].uExpireTime <= 0) - pPlayers[pl]->SetCondition(Condition_Weak, 0); - } - - v46 = (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime > 0; - - for (uint i = 0; i < 20; ++i) - { - if (pParty->pPartyBuffs[i].IsBuffExpiredToTime(pParty->uTimePlayed) == 1) - viewparams->bRedrawGameUI = true; - } - - if (v46 && (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_HASTE].uExpireTime <= 0) - { - for (uint i = 0; i < 4; ++i) - pParty->pPlayers[i].SetCondition(1, 0); - } - - for (uint i = 0; i < 2; ++i)//Ïðîâåðêà â ñîçíàíèè ëè ïåðñ ñäåëàâøèé çàêë íà ïîë¸ò è õîæäåíèå ïî âîäå - { - SpellBuff* pBuf = &pParty->pPartyBuffs[Party_Spec_Motion_status_ids[i]]; - if (pBuf->uExpireTime == 0) - continue; - - if (!(pBuf->uFlags & 1)) - { - if (!pPlayers[pBuf->uCaster]->CanAct()) - { - pBuf->Reset(); - if (Party_Spec_Motion_status_ids[i] == PARTY_BUFF_FLY) - pParty->bFlying = false; - } - } - } - - if (!party_condition_flag) - { - if (pCurrentScreen != SCREEN_REST) - { - for (uint pl = 1; pl <= 4; pl++) - { - if (pPlayers[pl]->pConditions[Condition_Sleep]) - { - pPlayers[pl]->pConditions[Condition_Sleep] = 0; - party_condition_flag = 1; - break; - } - } - if (!party_condition_flag || _5C35C0_force_party_death) - uGameState = GAME_STATE_PARTY_DIED; - } - } - - if (uActiveCharacter)//âûáîð ñëåäóþùåãî ïîñëå ïðîïóñêàþùåãî õîä - { - if (pCurrentScreen != SCREEN_REST) - { - if (pPlayers[uActiveCharacter]->pConditions[Condition_Sleep] - || pPlayers[uActiveCharacter]->pConditions[Condition_Paralyzed] - || pPlayers[uActiveCharacter]->pConditions[Condition_Unconcious] - || pPlayers[uActiveCharacter]->pConditions[Condition_Dead] - || pPlayers[uActiveCharacter]->pConditions[Condition_Pertified] - || pPlayers[uActiveCharacter]->pConditions[Condition_Eradicated]) - { - viewparams->bRedrawGameUI = true; - uActiveCharacter = pParty->GetNextActiveCharacter(); - } - } - } -} - -//----- (00493938) -------------------------------------------------------- -void _493938_regenerate() -{ - int current_time; // edi@1 - int last_reg_time; // qax@1 - int v4; // eax@2 - int v5; // edi@5 - long long *v6; // ecx@5 - char v7; // sf@5 - int *v8; // ecx@10 - int v9; // edi@15 - signed int v10; // eax@15 - // __int16 *v11; // edx@16 - // int v12; // eax@20 - int numberOfActorsAffected; // ebx@20 - unsigned int v14; // esi@21 - //unsigned int v15; // ecx@21 - //unsigned int v16; // eax@21 - // int v18; // eax@21 - signed int v19; // eax@21 - bool recovery_HP; // ebx@25 - // ITEM_EQUIP_TYPE v22; // edi@30 - signed int v25; // eax@33 - // int v26; // eax@35 - // int v27; // eax@36 - // int v28; // eax@37 - signed int v31; // ecx@53 - int actorsAffectedByImmolation[100]; // [sp+4h] [bp-22Ch]@20 - SpriteObject a1; // [sp+194h] [bp-9Ch]@15 - Vec3_int_ a3; // [sp+204h] [bp-2Ch]@15 - bool has_dragon_flag; // [sp+210h] [bp-20h]@22 - bool lich_jar_flag; // [sp+214h] [bp-1Ch]@25 - bool zombie_flag; // [sp+218h] [bp-18h]@25 - bool decrease_HP; // [sp+21Ch] [bp-14h]@25 - bool lich_flag; // [sp+220h] [bp-10h]@25 - int v49; // [sp+224h] [bp-Ch]@24 - bool recovery_SP; // [sp+228h] [bp-8h]@25 - bool redraw_flag; // [sp+22Ch] [bp-4h]@2 - - current_time = (signed int)(signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375) / 60; - last_reg_time = (signed int)(signed __int64)((double)pParty->uLastRegenerationTime * 0.234375) / 60; - if (current_time >= (signed int)last_reg_time + 5) - { - redraw_flag = false; - v4 = (current_time - last_reg_time) / 5; - if (pParty->FlyActive()) - { - if (pParty->bFlying) - { - if (!(pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags & 1)) - { - v5 = v4 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uPower; - //cursed_flag = pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].pConditions[Condition_Cursed];//cursed - //v7 = cursed_flag < v5; - //cursed_flag -= v5; - - v6 = &pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_FLY].uCaster - 1].pConditions[Condition_Cursed]; - - if (*v6 < v5) - { - v6 = 0; - pParty->uFlags &= 0xFFFFFFBFu; - pParty->bFlying = false; - redraw_flag = true; - } - } - } - } - - if (pParty->WaterWalkActive()) - { - if (pParty->uFlags & PARTY_FLAGS_1_STANDING_ON_WATER) - { - if (!(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1)) - { // taking on water - v8 = (int *)&pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].pConditions[Condition_Cursed];//&AA1058_PartyQuickSpellSound[4].pSounds[6972 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster + 2000]; - v7 = *v8 < v4; - *v8 -= v4; - if (v7) - { - *v8 = 0; - pParty->uFlags &= ~PARTY_FLAGS_1_STANDING_ON_WATER; - redraw_flag = true; - } - } - } - } - - if (pParty->ImmolationActive())//Æåðòâà - { - a3.z = 0; - a3.y = 0; - a3.x = 0; - a1.stru_24.Reset(); - a1.spell_level = pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].uPower; - a1.spell_skill = pParty->ImmolationSkillLevel(); - v10 = 0; - a1.uType = 1070; - a1.spell_id = SPELL_FIRE_IMMOLATION; - v10 = 0; - for (uint i = 0; i > pObjectList->uNumObjects; i++) - { - if (pObjectList->pObjects[i].uObjectID == stru_4E3ACC[8].uType) - v10 = i; - } - a1.uObjectDescID = v10; - a1.field_60_distance_related_prolly_lod = 0; - a1.uAttributes = 0; - a1.uSectorID = 0; - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = PID(OBJECT_Player, pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].uCaster); - a1.uFacing = 0; - a1.uSoundID = 0; - numberOfActorsAffected = pParty->_46A89E_immolation_effect(actorsAffectedByImmolation, 100, 307); - for (v9 = 0; v9 < numberOfActorsAffected; ++v9) - { - v14 = actorsAffectedByImmolation[v9]; - a1.vPosition.x = pActors[v14].vPosition.x; - a1.vPosition.y = pActors[v14].vPosition.y; - a1.vPosition.z = pActors[v14].vPosition.z; - a1.spell_target_pid = PID(OBJECT_Actor, v14); - v19 = a1.Create(0, 0, 0, 0); - Actor::DamageMonsterFromParty(PID(OBJECT_Item, v19), v14, &a3); - } - } - - has_dragon_flag = false; - if (PartyHasDragon()) - has_dragon_flag = true; - - for (v49 = 0; v49 < 4; v49++) - { - recovery_HP = false; - recovery_SP = false; - decrease_HP = false; - lich_flag = false; - lich_jar_flag = false; - zombie_flag = false; - - for (int v22 = 0; (signed int)v22 < 16; v22++) - { - if (pParty->pPlayers[v49].HasItemEquipped((ITEM_EQUIP_TYPE)v22)) - { - uint _idx = pParty->pPlayers[v49].pEquipment.pIndices[v22]; - if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID > 134) - { - if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_RELIC_ETHRICS_STAFF) - decrease_HP = true; - if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_HERMES_SANDALS) - { - recovery_HP = true; - recovery_SP = true; - } - if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_MINDS_EYE) - recovery_SP = true; - if (pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uItemID == ITEM_ARTIFACT_HEROS_BELT) - recovery_HP = true; - } - else - { - v25 = pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uSpecEnchantmentType; - if (v25 == 37 //of Regeneration("Regenerate 1hp/x while walking, etc") - || v25 == 44 //of Life("HP (+10), Regen hpts") - || v25 == 50 //of The Phoenix("Fire Res (+30), Regen hpts") && - || v25 == 54)// of The Troll("End (+15), Regen hpts") - recovery_HP = true; - if (v25 == 38 //of Mana("Regenerate 1sp/x while walking, etc") - || v25 == 47 //of The Eclipse("SP (+10), Regen spts") - || v25 == 55)//of The Unicorn("Luck (+15), Regen spts") - recovery_SP = true; - if (v25 == 66)// of Plenty("Regenerate 1 hp/x and 1 sp/x while walking, etc.") - { - recovery_HP = true; - recovery_SP = true; - } - } - - if (recovery_HP && - !pParty->pPlayers[v49].pConditions[Condition_Dead] && - !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) - { - if (pParty->pPlayers[v49].sHealth < pParty->pPlayers[v49].GetMaxHealth()) - ++pParty->pPlayers[v49].sHealth; - if (pParty->pPlayers[v49].pConditions[Condition_Unconcious] && pParty->pPlayers[v49].sHealth > 0) - pParty->pPlayers[v49].pConditions[Condition_Unconcious] = 0; - redraw_flag = true; - } - - if (recovery_SP && - !pParty->pPlayers[v49].pConditions[Condition_Dead] && - !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) - { - if (pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana()) - ++pParty->pPlayers[v49].sMana; - redraw_flag = true; - } - - if (decrease_HP && - !pParty->pPlayers[v49].pConditions[Condition_Dead] && - !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) - { - --pParty->pPlayers[v49].sHealth; - if (!(pParty->pPlayers[v49].pConditions[Condition_Unconcious]) && pParty->pPlayers[v49].sHealth < 0) - pParty->pPlayers[v49].pConditions[Condition_Unconcious] = pParty->uTimePlayed; - if (pParty->pPlayers[v49].sHealth < 1) - { - if (pParty->pPlayers[v49].sHealth + pParty->pPlayers[v49].uEndurance + pParty->pPlayers[v49].GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE) >= 1 - || (signed __int64)pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime > 0) - pParty->pPlayers[v49].pConditions[Condition_Unconcious] = pParty->uTimePlayed; - else - { - if (!pParty->pPlayers[v49].pConditions[Condition_Dead]) - pParty->pPlayers[v49].pConditions[Condition_Dead] = pParty->uTimePlayed; - } - } - redraw_flag = true; - } - } - } - - //regeneration - if (pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_REGENERATION].uExpireTime > 0 - && !pParty->pPlayers[v49].pConditions[Condition_Dead] - && !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) - { - pParty->pPlayers[v49].sHealth += 5 * pParty->pPlayers[v49].pPlayerBuffs[PLAYER_BUFF_REGENERATION].uPower; - if (pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth()) - pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].GetMaxHealth(); - if (pParty->pPlayers[v49].pConditions[Condition_Unconcious] && pParty->pPlayers[v49].sHealth > 0) - pParty->pPlayers[v49].pConditions[Condition_Unconcious] = 0; - redraw_flag = true; - } - - //for warlock - if (has_dragon_flag && pParty->pPlayers[v49].classType == PLAYER_CLASS_WARLOCK) - { - if (pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana()) - ++pParty->pPlayers[v49].sMana; - redraw_flag = true; - } - - //for lich - if (pParty->pPlayers[v49].classType == PLAYER_CLASS_LICH) - { - for (v31 = 0; v31 < 126; ++v31) - { - if (pParty->pPlayers[v49].pInventoryItemList[v31].uItemID == ITEM_LICH_JAR_FULL) - lich_jar_flag = true; - } - lich_flag = true; - } - if (lich_flag && !pParty->pPlayers[v49].pConditions[Condition_Dead] - && !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) - { - if (pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() / 2) - pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].sHealth - 2; - if (pParty->pPlayers[v49].sMana > pParty->pPlayers[v49].GetMaxMana() / 2) - pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].sMana - 2; - } - if (lich_jar_flag) - { - if (pParty->pPlayers[v49].sMana < pParty->pPlayers[v49].GetMaxMana()) - ++pParty->pPlayers[v49].sMana; - } - - //for zombie - if (pParty->pPlayers[v49].pConditions[Condition_Zombie]) - zombie_flag = true; - if (zombie_flag && !pParty->pPlayers[v49].pConditions[Condition_Dead] - && !pParty->pPlayers[v49].pConditions[Condition_Eradicated]) - { - if (pParty->pPlayers[v49].sHealth > pParty->pPlayers[v49].GetMaxHealth() / 2) - pParty->pPlayers[v49].sHealth = pParty->pPlayers[v49].sHealth - 1; - if (pParty->pPlayers[v49].sMana > 0) - pParty->pPlayers[v49].sMana = pParty->pPlayers[v49].sMana - 1; - } - } - pParty->uLastRegenerationTime = pParty->uTimePlayed; - if (!viewparams->bRedrawGameUI) - viewparams->bRedrawGameUI = redraw_flag; - } -} - -//----- (00491E3A) -------------------------------------------------------- -void sub_491E3A() -{ - signed int v1; // esi@3 - unsigned int v3; // eax@7 - unsigned int v4; // edx@8 - int v6; // edi@17 - - //__debugbreak();//Ritor1 - for (uint pl = 0; pl < 4; pl++) - { - if (SoundSetAction[24][0]) - { - v3 = 0; - for (v1 = 0; v1 < (signed int)pSoundList->sNumSounds; ++v1) - { - int ps = 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4998;//6728 - if (pSoundList->pSL_Sounds[v1].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4998) - v3 = v1; - } - pSoundList->UnloadSound(v3, 1); - for (v4 = 0; (signed int)v4 < (signed int)pSoundList->sNumSounds; ++v4) - { - if (pSoundList->pSL_Sounds[v4].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[pl].uVoiceID) + 4999) - pSoundList->UnloadSound(v4, 1); - } - } - } - v6 = pIcons_LOD->uNumLoadedFiles - 1; - if (v6 >= pIcons_LOD->pFacesLock) - { - do - { - pIcons_LOD->pTextures[v6].Release(); - if (pIcons_LOD->pHardwareTextures) - { - if (pIcons_LOD->pHardwareTextures[v6]) - { - pIcons_LOD->pHardwareTextures[v6]->Release(); - pIcons_LOD->pHardwareTextures[v6] = 0; - } - } - if (pIcons_LOD->pHardwareSurfaces) - { - if (pIcons_LOD->pHardwareSurfaces[v6]) - { - pIcons_LOD->pHardwareSurfaces[v6]->Release(); - pIcons_LOD->pHardwareSurfaces[v6] = 0; - } - } - --v6; - } while (v6 >= pIcons_LOD->pFacesLock); - } - pIcons_LOD->uNumLoadedFiles = pIcons_LOD->pFacesLock; - pIcons_LOD->pFacesLock = 0; -} -// 4ED498: using guessed type char byte_4ED498; - -//----- (00494820) -------------------------------------------------------- -unsigned int __fastcall _494820_training_time(unsigned int a1) -{ - signed int v1; // eax@1 - - v1 = 5; - if (a1 % 24 >= 5) - v1 = 29; - return v1 - a1 % 24; -} - -//----- (00494836) -------------------------------------------------------- -int stru339_spell_sound::AddPartySpellSound(int uSoundID, int a6) -{ - int v3; // esi@1 - int result; // eax@1 - //stru339_spell_sound *v5; // ebx@1 - //int *v6; // edi@2 - unsigned int v7; // eax@3 - int v8; // [sp+Ch] [bp-8h]@3 - int v9; // [sp+10h] [bp-4h]@2 - int a2a; // [sp+1Ch] [bp+8h]@1 - //return 0; - v3 = 0; - result = word_4EE088_sound_ids[uSoundID]; - //v5 = this; - a2a = word_4EE088_sound_ids[uSoundID]; - if (word_4EE088_sound_ids[uSoundID]) - { - //v6 = this->pSoundsOffsets; - for (v9 = 0; v9 < 2; ++v9) - { - v7 = a2a++; - result = pSoundList->LoadSound(v7, (char *)this + v3, 44744 - v3, &v8, a6); - if (!result) - break; - a6 += 4; - result = v8 + 256; - this->pSoundsOffsets[v9] = v3; - v3 += result; - this->pSoundsSizes[v9] = v8 + 256; - //++v6; - } - } - return result; -} -// 4EE088: using guessed type __int16 word_4EE088_sound_ids[]; - -//----- (00443E31) -------------------------------------------------------- -void LoadLevel_InitializeLevelStr() -{ - - // char Args[100]; - int string_num; - int max_string_length; - // int current_string_length; - int prev_string_offset; - - if (sizeof(pLevelStrOffsets) != 2000) - Log::Warning(L"pLevelStrOffsets: deserialization warning"); - memset(pLevelStrOffsets.data(), 0, 2000); - - max_string_length = 0; - string_num = 1; - prev_string_offset = 0; - pLevelStrOffsets[0] = 0; - for (uint i = 0; i < uLevelStrFileSize; ++i) - { - if (!pLevelStr[i]) - { - pLevelStrOffsets[string_num] = i + 1; - ++string_num; - if (i - prev_string_offset > max_string_length) - max_string_length = i - prev_string_offset; - prev_string_offset = i; - } - } - - uLevelStrNumStrings = string_num - 1; - if (max_string_length > 800) - Error("MAX_EVENT_TEXT_LENGTH needs to be increased to %lu", max_string_length + 1); - - if (uLevelStrNumStrings > 0) - { - for (uint i = 0; i 0) - { - for (uint i = 0; i < uLevelEVT_NumEvents; ++i) - { - test_event = (_evt_raw*)&pLevelEVT[pLevelEVT_Index[i].uEventOffsetInEVT]; - if (test_event->_e_type == EVENT_OnMapLeave) - { - EventProcessor(pLevelEVT_Index[i].uEventID, 0, 1, pLevelEVT_Index[i].event_sequence_num); - } - } - } -} - -//----- (00443FDC) -------------------------------------------------------- -void OnMapLoad() -{ - int v6; // eax@9 - unsigned __int64 v8; // qax@26 - int hours; // ebx@26 - unsigned __int64 v18; // [sp+Ch] [bp-44h]@12 - unsigned int seconds; // [sp+14h] [bp-3Ch]@26 - unsigned __int64 v20; // [sp+1Ch] [bp-34h]@7 - unsigned int minutes; // [sp+2Ch] [bp-24h]@26 - unsigned int years; // [sp+34h] [bp-1Ch]@26 - unsigned int weeks; // [sp+38h] [bp-18h]@26 - int v26; // [sp+3Ch] [bp-14h]@15 - unsigned int days; // [sp+3Ch] [bp-14h]@26 - unsigned int months; // [sp+40h] [bp-10h]@26 - - for (uint i = 0; i < uLevelEVT_NumEvents; ++i) - { - EventIndex pEvent = pLevelEVT_Index[i]; - - _evt_raw* _evt = (_evt_raw *)(&pLevelEVT[pEvent.uEventOffsetInEVT]); - - if (_evt->_e_type == EVENT_PlaySound) - pSoundList->LoadSound(EVT_DWORD(_evt->v5), 0); - else if (_evt->_e_type == EVENT_OnMapReload) - EventProcessor(pEvent.uEventID, 0, 0, pEvent.event_sequence_num); - else if (_evt->_e_type == EVENT_OnTimer || _evt->_e_type == EVENT_Initialize) - { - //v3 = &MapsLongTimersList[MapsLongTimers_count]; - v20 = pOutdoor->loc_time.uLastVisitDay; - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - v20 = pIndoor->stru1.uLastVisitDay; - - MapsLongTimersList[MapsLongTimers_count].timer_evt_type = _evt->_e_type; - MapsLongTimersList[MapsLongTimers_count].timer_evt_ID = pEvent.uEventID; - MapsLongTimersList[MapsLongTimers_count].timer_evt_seq_num = pEvent.event_sequence_num; - - MapsLongTimersList[MapsLongTimers_count].YearsInterval = _evt->v5; - MapsLongTimersList[MapsLongTimers_count].MonthsInterval = _evt->v6; - MapsLongTimersList[MapsLongTimers_count].WeeksInterval = _evt->v7; - MapsLongTimersList[MapsLongTimers_count].HoursInterval = _evt->v8; - MapsLongTimersList[MapsLongTimers_count].MinutesInterval = _evt->v9; - MapsLongTimersList[MapsLongTimers_count].SecondsInterval = _evt->v10; - - - v6 = ((unsigned short)_evt->v12 << 8) + _evt->v11; - - MapsLongTimersList[MapsLongTimers_count].time_left_to_fire = ((unsigned short)_evt->v12 << 8) + _evt->v11; - MapsLongTimersList[MapsLongTimers_count].IntervalHalfMins = ((unsigned short)_evt->v12 << 8) + _evt->v11; - if (MapsLongTimersList[MapsLongTimers_count].timer_evt_type == EVENT_Initialize && !(short)v6) - { - if (v20) - v18 = pParty->uTimePlayed - v20; - else - v18 = 0; - v26 = (signed int)(signed __int64)((double)(signed __int64)v18 * 0.234375) / 60 / 60 / 24; - - if (v26 / 7 / 4 / 12 != 0 && MapsLongTimersList[MapsLongTimers_count].YearsInterval || - v26 / 7 / 4 != 0 && MapsLongTimersList[MapsLongTimers_count].MonthsInterval != 0 || - v26 / 7 != 0 && MapsLongTimersList[MapsLongTimers_count].WeeksInterval != 0 || - v26 != 0 || !v20) - { - ++MapsLongTimers_count; - MapsLongTimersList[MapsLongTimers_count].NextStartTime = 0; - continue; - } - } - else - { - v8 = (__int64)((double)pParty->uTimePlayed * 0.234375); - seconds = v8 % 60; - minutes = (v8 / 60) % 60; - hours = ((v8 / 60) / 60) % 24; - days = (((v8 / 60) / 60) / 24) % 7; - weeks = ((((v8 / 60) / 60) / 24) / 7) % 4; - months = (((((v8 / 60) / 60) / 24) / 7) / 4) % 12; - years = (((((v8 / 60) / 60) / 24) / 7) / 4) / 12; - - if (MapsLongTimersList[MapsLongTimers_count].YearsInterval) - ++years; - else if (MapsLongTimersList[MapsLongTimers_count].MonthsInterval) - ++months; - else if (MapsLongTimersList[MapsLongTimers_count].WeeksInterval) - ++weeks; - else - { - ++days; - hours = MapsLongTimersList[MapsLongTimers_count].HoursInterval; - minutes = MapsLongTimersList[MapsLongTimers_count].MinutesInterval; - seconds = MapsLongTimersList[MapsLongTimers_count].SecondsInterval; - } - MapsLongTimersList[MapsLongTimers_count].NextStartTime = (signed __int64)((double)((seconds - + 60 * minutes - + 3600 * hours - + 86400 * days - + 604800 * weeks - + 2419200 * months - + 29030400 * years) << 7) - * 0.033333335); - - ++MapsLongTimers_count; - } - } - } -} - -//----- (00444360) -------------------------------------------------------- -void Level_LoadEvtAndStr(const char *pLevelName) -{ - char pContainerName[120]; // [sp+8h] [bp-98h]@1 - - sprintf(pContainerName, "%s.evt", pLevelName); - uLevelEVT_Size = LoadEventsToBuffer(pContainerName, pLevelEVT.data(), 9216); - - sprintf(pContainerName, "%s.str", pLevelName); - uLevelStrFileSize = LoadEventsToBuffer(pContainerName, pLevelStr.data(), 9216); - if (uLevelStrFileSize) - LoadLevel_InitializeLevelStr(); -} - -//----- (004452BB) -------------------------------------------------------- -void sub_4452BB() -{ - pGUIWindow2->Release(); - pGUIWindow2 = 0; - activeLevelDecoration = _591094_decoration; - EventProcessor(dword_5C3418, 0, 1, dword_5C341C); - activeLevelDecoration = nullptr; - pEventTimer->Resume(); -} - -//----- (0044100D) -------------------------------------------------------- -bool _44100D_should_alter_right_panel() -{ - return pCurrentScreen == SCREEN_NPC_DIALOGUE || pCurrentScreen == SCREEN_CHARACTERS || - pCurrentScreen == SCREEN_HOUSE || pCurrentScreen == SCREEN_E || - pCurrentScreen == SCREEN_CHANGE_LOCATION || pCurrentScreen == SCREEN_INPUT_BLV || pCurrentScreen == SCREEN_CASTING; -} - -//----- (0044987B) -------------------------------------------------------- -void Transition_StopSound_Autosave(const char *pMapName, MapStartPoint start_point) -{ - pAudioPlayer->StopChannels(-1, -1); - pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_None); - if (_stricmp(pCurrentMapName, pMapName)) - SaveGame(1, 0); - - uGameState = GAME_STATE_CHANGE_LOCATION; - strcpy(pCurrentMapName, pMapName); - uLevel_StartingPointType = start_point; -} -// 6BE35C: using guessed type int uLevel_StartingPointType; - -//----- (004451A8) -------------------------------------------------------- -void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4) -{ - if (!pGUIWindow2) - { - if (pParty->uFlags & 2) - pGame->Draw(); - pAudioPlayer->StopChannels(-1, -1); - pMiscTimer->Pause(); - pEventTimer->Pause(); - dword_5C3418 = a1; - dword_5C341C = a2; - _591094_decoration = activeLevelDecoration; - pGUIWindow2 = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_GreetingNPC, a4, 0); - pGUIWindow2->CreateButton(61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); - pGUIWindow2->CreateButton(177, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); - pGUIWindow2->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); - pGUIWindow2->CreateButton(407, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); - } -} - - - - -//----- (00448B67) -------------------------------------------------------- -void OnTimer(int) -{ - if (pEventTimer->bPaused) - return; - - long long v13 = (signed __int64)(pParty->uTimePlayed - _5773B8_event_timer) / 128; - if (!v13) - return; - - //uint _v2v3 = pParty->uTimePlayed; - //v3 = HIDWORD(pParty->uTimePlayed); - //v2 = LODWORD(pParty->uTimePlayed); - - _5773B8_event_timer = pParty->uTimePlayed; - - for (uint i = 0; i < MapsLongTimers_count; ++i) - { - //v4 = (char *)&array_5B5928_timers[0].field_C; - MapsLongTimer* timer = &MapsLongTimersList[i]; - //while ( 1 ) - //{ - //v5 = *(short *)v4; - if (timer->time_left_to_fire) - { - if (v13 < timer->time_left_to_fire) - timer->time_left_to_fire -= v13; - else - { - timer->time_left_to_fire = timer->IntervalHalfMins; - EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num); - } - } - else - { - if (timer->NextStartTime < pParty->uTimePlayed) - { - uint next_trigger_time = 1 * 60 * 60 * 24; // 1 day - if (timer->YearsInterval) - next_trigger_time = 336 * 60 * 60 * 24; // 1 year - else if (timer->MonthsInterval) - next_trigger_time = 28 * 60 * 60 * 24; // 1 month - else if (timer->WeeksInterval) - next_trigger_time = 7 * 60 * 60 * 24; // 1 week - - timer->NextStartTime += (next_trigger_time * 128) / 3.0f; - if (timer->NextStartTime < pParty->uTimePlayed) // make sure in wont fire several times in a row if big time interval has lapsed - timer->NextStartTime = pParty->uTimePlayed; - - EventProcessor(timer->timer_evt_ID, 0, 1, timer->timer_evt_seq_num); - } - } - } -} - - - - - - - -//----- (0044C28F) -------------------------------------------------------- -bool TeleportToNWCDungeon() -{ - if (!_stricmp("nwc.blv", pCurrentMapName)) - return false; - - _5B65A8_npcdata_uflags_or_other = 0; - _5B65AC_npcdata_fame_or_other = 0; - _5B65B0_npcdata_rep_or_other = 0; - _5B65B4_npcdata_loword_house_or_other = 0; - _5B65B8_npcdata_hiword_house_or_other = 0; - dword_5B65BC = 0; - dword_5B65C0 = 0; - - pGameLoadingUI_ProgressBar->uType = GUIProgressBar::TYPE_Fullscreen; - Transition_StopSound_Autosave("nwc.blv", MapStartPoint_Party); - pCurrentScreen = SCREEN_GAME; - return true; -} - -//----- (00401000) -------------------------------------------------------- -void mm7__vector_constructor(void *a1, int objSize, int numObjs, int(*constructor)(int)) -{ - void *v4; // esi@2 - - if (numObjs > 0) - { - v4 = a1; - for (int i = numObjs; i; --i) - { - constructor((int)v4); - v4 = (char *)v4 + objSize; - } - } -} - - - diff -r 92eeeb5200f2 -r 68cdef6879a0 Game.h --- a/Game.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,239 +0,0 @@ -#pragma once -#include "VectorTypes.h" - -#include "OSAPI.h" - -#include "MapInfo.h" - - -#define GAME_FLAGS_1_01_lightmap_related 0x01 -#define GAME_FLAGS_1_DRAW_BLV_DEBUGS 0x08 -#define GAME_FLAGS_2_SATURATE_LIGHTMAPS 0x02 -#define GAME_FLAGS_2_ALTER_GRAVITY 0x08 -#define GAME_FLAGS_2_TARGETING_MODE 0x10 -#define GAME_FLAGS_2_DRAW_BLOODSPLATS 0x20 - - - -/* 320 */ -enum GAME_STATE -{ - GAME_STATE_PLAYING = 0, - GAME_FINISHED = 1, - GAME_STATE_CHANGE_LOCATION = 2, - GAME_STATE_LOADING_GAME = 3, - GAME_STATE_NEWGAME_OUT_GAMEMENU = 4, - GAME_STATE_5 = 5, - GAME_STATE_STARTING_NEW_GAME = 6, - GAME_STATE_GAME_QUITTING_TO_MAIN_MENU = 7, - GAME_STATE_PARTY_DIED = 8, - GAME_STATE_FINAL_WINDOW = 9, - GAME_STATE_A = 10 -}; - - - -/* 105 */ -#pragma pack(push, 1) -struct Game__StationaryLight -{ - Vec3_float_ vPosition; - Vec3_float_ vRGBColor; - float flt_18; -}; -#pragma pack(pop) - - -/* 108 */ -#pragma pack(push, 1) -struct Game_stru0 -{ - int field_0; - unsigned __int8 *ptr_4; - int field_8; - int field_C; -}; -#pragma pack(pop) - - -/* 279 */ -#pragma pack(push, 1) -//Game_stru1 -struct Game_Bloodsplat -{ - float x; - float y; - float z; - float r; - float g; - float b; - float radius; -}; -#pragma pack(pop) - - -class Vis; -class LightmapBuilder; -class ParticleEngine; -class Mouse; -class Keyboard; -class ThreadWard; -class CShow; -class GammaController; -struct stru9; -struct stru10; - -/* 104 */ -#pragma pack(push, 1) -struct Game -{ - static Game *Create(); - static void Destroy(); - -protected: Game(); -protected: virtual ~Game(); - - -public: - void _44E904(); - bool InitializeGammaController(); - bool PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, struct Vis_SelectionFilter *sprite_filter, struct Vis_SelectionFilter *face_filter); - bool PickKeyboard(bool bOutline, struct Vis_SelectionFilter *sprite_filter, struct Vis_SelectionFilter *face_filter); - void OutlineSelection(); - signed int _44EC23(struct Polygon *a2, int *a3, signed int a4); - signed int _44ED0A(struct BLVFace *a2, int *a3, signed int a4); - bool AlterGamma_BLV(struct BLVFace *pFace, signed int *pColor); - bool AlterGamma_ODM(struct ODMFace *pFace, signed int *pColor); - bool draw_debug_outlines(); - bool _44EEA7(); - bool _44F07B(); - void ToggleFlags(unsigned int uMask); - void ToggleFlags2(unsigned int uFlag); - void _44F0FD(); - void PushStationaryLights(int a2); - void PrepareBloodsplats(); - void Deinitialize(); - void Loop(); - void DrawParticles(); - void Draw(); - - //----- (0042EB6A) -------------------------------------------------------- - struct stru6 *GetStru6() {return this->pStru6Instance;} - //----- (0042EB71) -------------------------------------------------------- - struct IndoorCameraD3D *GetIndoorCamera() {return this->pIndoorCameraD3D;} - - - //void ( ***vdestructor_ptr)(Game *, bool); - Game__StationaryLight pStationaryLights[25]; - char field_2C0[1092]; - unsigned int uNumStationaryLights; - Game_Bloodsplat pBloodsplats[20]; - int field_938; - int field_93C; - int field_940; - int field_944; - int field_948; - int field_94C; - int field_950; - int field_954; - int field_958; - int field_95C; - int field_960; - int field_964; - int field_968; - int field_96C; - int field_970; - Mouse *pMouse; - int field_978; - Game_stru0 stru_97C; - char field_98C[1148]; - int uNumBloodsplats; - int field_E0C; - __int64 field_E10; - int uNumStationaryLights_in_pStationaryLightsStack; - unsigned int bGammaControlInitialized; - unsigned int uFlags; - unsigned int uFlags2; - float fSaturation; - unsigned __int64 uSomeGammaStartTime; - __int64 uSomeGammaDeltaTime; - void/*ThreadWard*/ *pThreadWardInstance; - ParticleEngine *pParticleEngine; - Mouse *pMouseInstance; - LightmapBuilder *pLightmapBuilder; - Vis *pVisInstance; - stru6 *pStru6Instance; - IndoorCameraD3D *pIndoorCameraD3D; - stru9 *pStru9Instance; - stru10 *pStru10Instance; - void/*stru11*/ *pStru11Instance; - void/*stru12*/ *pStru12Instance; - void/*CShow*/ *pCShow; - Keyboard *pKeyboardInstance; - GammaController *pGammaController; - int field_E74; -}; -#pragma pack(pop) - - - - - - -extern Game *pGame; - -void sub_42FBDD(); -void CloseWindowBackground(); -void GameUI_MsgProc(); -void back_to_game(); -void GUI_MainMenuMessageProc(); - -void UpdateUserInput_and_MapSpecificStuff(); -void PrepareWorld(unsigned int _0_box_loading_1_fullscreen); -void DoPrepareWorld(unsigned int bLoading, int _1_fullscreen_loading_2_box); - -//int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam); -int __stdcall InsertMM7CDDialogFunc(HWND hDlg, int a2, __int16 a3, int a4); -bool __fastcall FindMM7CD(HWND hWnd, char *pCDDrive); -//bool __fastcall Initialize(HINSTANCE hInst, char *pCmdLine); - -void Game_DeinitializeAndTerminate(int exitCode); // idb -void FinalInitialization(); -bool __fastcall CheckMM7CD(char c); -void SecondaryInitialization(); - - -void MM6_Initialize(const wchar_t *pIniFilename); -void MM7Initialization(); - -void __fastcall PrepareToLoadODM(unsigned int bLoading, struct ODMRenderParams *a2); -void MainMenu_Loop(); -unsigned int GameOverMenu(void *ecx0); -void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); -void _461103_load_level_sub(); -void InitializeTurnBasedAnimations(void *); -void SetCurrentMenuID(enum MENU_STATE); // idb -enum MENU_STATE GetCurrentMenuID(); -unsigned int GetGravityStrength(); -void GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide); // idb - -void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename); -void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on); -void __fastcall SetDecorationSprite(uint16_t uCog, bool bHide, const char *pFileName); // idb -void _494035_timed_effects__water_walking_damage__etc(); -void _493938_regenerate(); -void sub_491E3A(); -const char *GetReputationString(signed int a1); -unsigned int __fastcall _494820_training_time(unsigned int a1); -void LoadLevel_InitializeLevelStr(); -void OnMapLeave(); -void OnMapLoad(); -void Level_LoadEvtAndStr(const char *pLevelName); -void sub_4452BB(); -bool _44100D_should_alter_right_panel(); -void Transition_StopSound_Autosave(const char *pMapName, MapStartPoint point); // sub_44987B idb - -void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4); - -void OnTimer(int); -bool TeleportToNWCDungeon(); \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 IconFrameTable.cpp --- a/IconFrameTable.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,217 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include "ErrorHandling.h" -#include "IconFrameTable.h" -#include "LOD.h" -#include "mm7_data.h" -#include "FrameTableInc.h" - -//----- (00494F3A) -------------------------------------------------------- -unsigned int IconFrameTable::FindIcon(const char *pIconName) -{ - for ( uint i = 0; i < (signed int)this->uNumIcons; i++ ) - { - if ( !_stricmp(pIconName, this->pIcons[i].pAnimationName) ) - return i; - } - return 0; -} - -//----- (00494F70) -------------------------------------------------------- -IconFrame *IconFrameTable::GetFrame(unsigned int uIconID, unsigned int uFrameID) -{ - int v6; // edx@3 - uint i; - - if ( this->pIcons[uIconID].uFlags & 1 && this->pIcons[uIconID].uAnimLength != 0 ) - { - v6 = ((signed int)uFrameID >> 3) % (unsigned __int16)this->pIcons[uIconID].uAnimLength; - for ( i = uIconID; v6 > this->pIcons[i].uAnimTime; i++ ) - v6 -= this->pIcons[i].uAnimTime; - return &this->pIcons[i]; - } - else - return &this->pIcons[uIconID]; -} - -//----- (00494FBF) -------------------------------------------------------- -void IconFrameTable::InitializeAnimation(unsigned int uIconID) -{ - if ( uIconID && (signed int)uIconID <= (signed int)this->uNumIcons ) - { - for ( uint i = uIconID; ; ++i ) - { - this->pIcons[i].uTextureID = pIcons_LOD->LoadTexture(this->pIcons[i].pTextureName, TEXTURE_16BIT_PALETTE); - if ( !(this->pIcons[i].uFlags & 1) ) - break; - } - } -} - -//----- (0049500A) -------------------------------------------------------- -void IconFrameTable::ToFile() -{ - //IconFrameTable *v1; // esi@1 - FILE *v2; // eax@1 - //FILE *v3; // edi@1 - - //IconFrameTable* Str = this; - - //v1 = Str; - v2 = fopen("data\\dift.bin", "wb"); - //v3 = v2; - if ( !v2 ) - Error("Unable to save dift.bin!"); - fwrite(this, 4, 1, v2); - fwrite(this->pIcons, 0x20u, this->uNumIcons, v2); - fclose(v2); -} - -//----- (00495056) -------------------------------------------------------- -void IconFrameTable::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) -{ - uint num_mm6_frames = data_mm6 ? *(int *)data_mm6 : 0, - num_mm7_frames = data_mm7 ? *(int *)data_mm7 : 0, - num_mm8_frames = data_mm8 ? *(int *)data_mm8 : 0; - - uNumIcons = num_mm6_frames + num_mm7_frames + num_mm8_frames; - Assert(uNumIcons); - Assert(!num_mm8_frames); - - pIcons = (IconFrame *)malloc(uNumIcons * sizeof(IconFrame)); - memcpy(pIcons, (char *)data_mm7 + 4, num_mm7_frames * sizeof(IconFrame)); - memcpy(pIcons + num_mm7_frames, (char *)data_mm6 + 4, num_mm6_frames * sizeof(IconFrame)); - memcpy(pIcons + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 4, num_mm8_frames * sizeof(IconFrame)); -} - -//----- (0049509D) -------------------------------------------------------- -int IconFrameTable::FromFileTxt(const char *Args) -{ - //IconFrameTable *v2; // ebx@1 - FILE *v3; // eax@1 - int v4; // esi@3 - void *v5; // eax@10 - FILE *v6; // ST0C_4@12 - char *i; // eax@12 - const char *v8; // ST00_4@15 - int v9; // eax@16 - int v10; // edx@20 - int v11; // ecx@21 - int v12; // eax@22 - signed int j; // edx@25 - IconFrame *v14; // ecx@26 - int v15; // esi@26 - int k; // eax@27 - signed int result; // eax@11 - char Buf; // [sp+Ch] [bp-2F8h]@3 - FrameTableTxtLine v19; // [sp+200h] [bp-104h]@4 - FrameTableTxtLine v20; // [sp+27Ch] [bp-88h]@4 - int v21; // [sp+2F8h] [bp-Ch]@3 - int v22; // [sp+2FCh] [bp-8h]@3 - FILE *File; // [sp+300h] [bp-4h]@1 - int Argsa; // [sp+30Ch] [bp+8h]@26 - - //v2 = this; - //TileTable::dtor((TileTable *)this); - __debugbreak();//Ritor1: this function not used - v3 = fopen(Args, "r"); - File = v3; - if ( !v3 ) - Error("IconFrameTable::load - Unable to open file: %s.", Args); - v4 = 0; - v21 = 0; - v22 = 1; - if ( fgets(&Buf, 490, v3) ) - { - do - { - *strchr(&Buf, 10) = 0; - memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20)); - if ( v20.uPropCount && *v20.pProperties[0] != 47 ) - { - if ( v20.uPropCount < 3 ) - Error("IconFrameTable::loadText, too few arguments, %s line %i.", Args, v22); - ++v21; - } - ++v22; - } - while ( fgets(&Buf, 490, File) ); - v4 = v21; - } - this->uNumIcons = v4; - v5 = malloc(32 * v4);//, "I Frames"); - this->pIcons = (IconFrame *)v5; - if ( v5 ) - { - v6 = File; - this->uNumIcons = 0; - fseek(v6, 0, 0); - for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) - { - *strchr(&Buf, 10) = 0; - memcpy(&v20, frame_table_txt_parser(&Buf, &v19), sizeof(v20)); - if ( v20.uPropCount && *v20.pProperties[0] != 47 ) - { - strcpy(this->pIcons[this->uNumIcons].pAnimationName, v20.pProperties[0]); - strcpy(this->pIcons[this->uNumIcons].pTextureName, v20.pProperties[1]); - v8 = v20.pProperties[2]; - this->pIcons[this->uNumIcons].uFlags = 0; - if ( !_stricmp(v8, "new") ) - { - v9 = (int)&this->pIcons[this->uNumIcons].uFlags; - *(char *)v9 |= 4u; - } - this->pIcons[this->uNumIcons].uAnimTime = atoi(v20.pProperties[3]); - this->pIcons[this->uNumIcons].uAnimLength = 0; - this->pIcons[this->uNumIcons++].uTextureID = 0; - } - } - fclose(File); - v10 = 0; - if ( (signed int)(this->uNumIcons - 1) > 0 ) - { - v11 = 0; - do - { - v12 = (int)&this->pIcons[v11]; - if ( !(*(char *)(v12 + 60) & 4) ) - *(char *)(v12 + 28) |= 1u; - ++v10; - ++v11; - } - while ( v10 < (signed int)(this->uNumIcons - 1) ); - } - for ( j = 0; j < (signed int)this->uNumIcons; *(short *)(Argsa + 26) = v15 ) - { - v14 = this->pIcons; - Argsa = (int)&v14[j]; - v15 = *(short *)(Argsa + 24); - if ( *(char *)(Argsa + 28) & 1 ) - { - ++j; - for ( k = (int)&v14[j]; *(char *)(k + 28) & 1; k += 32 ) - { - v15 += *(short *)(k + 24); - ++j; - } - LOWORD(v15) = v14[j].uAnimTime + v15; - } - ++j; - } - result = 1; - } - else - { - fclose(File); - result = 0; - } - return result; -} -//----- (0042EB78) -------------------------------------------------------- -int IconFrameTable::GetIconAnimLength(unsigned int uIconID) -{ - return 8 * this->pIcons[uIconID].uAnimLength; -} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 IconFrameTable.h --- a/IconFrameTable.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -#pragma once -#include - - - - -/* 44 */ -#pragma pack(push, 1) -struct IconFrame -{ - char pAnimationName[12]; - char pTextureName[12]; - __int16 uAnimTime; - __int16 uAnimLength; - __int16 uFlags; - unsigned __int16 uTextureID; -}; -#pragma pack(pop) - -/* 45 */ -#pragma pack(push, 1) -struct IconFrameTable -{ - inline IconFrameTable(): - uNumIcons(0), pIcons(nullptr) - {} - - unsigned int FindIcon(const char *pIconName); - IconFrame *GetFrame(unsigned int uIconID, unsigned int uFrameID); - void InitializeAnimation(unsigned int uIconID); - void ToFile(); - void FromFile(void *data_mm6, void *data_mm7, void *data_mm8); - int FromFileTxt(const char *Args); - int GetIconAnimLength(unsigned int uIconID); - - unsigned int uNumIcons; - struct IconFrame *pIcons; -}; -#pragma pack(pop) - - - - - - - - - - - - -/* 76 */ -#pragma pack(push, 1) -struct UIAnimation -{ - unsigned __int16 uIconID; - __int16 field_2; - __int16 uAnimTime; - __int16 uAnimLength; - __int16 x; - __int16 y; - char field_C; -}; -#pragma pack(pop) - - - - - - -extern struct IconFrameTable *pIconsFrameTable; - - -extern struct UIAnimation *pUIAnim_Food; -extern struct UIAnimation *pUIAnim_Gold; -extern struct UIAnimation *pUIAnum_Torchlight; -extern struct UIAnimation *pUIAnim_WizardEye; - -extern std::array pUIAnims; diff -r 92eeeb5200f2 -r 68cdef6879a0 Items.cpp --- a/Items.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2286 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include -#include -#include "UI\UIHouses.h" -#include "GUIButton.h" - -#include "ErrorHandling.h" - -#include "Items.h" -#include "MapInfo.h" -#include "GUIWindow.h" -#include "Chest.h" -#include "LOD.h" -#include "Monsters.h" -#include "Party.h" -#include "FactionTable.h" -#include "StorylineTextTable.h" -#include "texts.h" -#include "mm7_data.h" -#include "OurMath.h" - - - -struct ITEM_VARIATION - { - unsigned __int16 treasure_level; - unsigned __int16 item_class[4]; - }; - - -std::array uItemsAmountPerShopType={ 0, 6, 8, 12, 12}; - -const ITEM_VARIATION shopWeap_variation_ord[15] ={ - { 0, { 0, 0, 0, 0 }}, - { 1, { 23, 27, 20, 20 }}, - { 1, { 23, 24, 28, 20 }}, - { 2, { 23, 24, 25, 20 }}, - { 2, { 27, 27, 26, 26 }}, - { 4, { 24, 30, 25, 27 }}, - { 4, { 24, 30, 25, 27 }}, - { 3, { 30, 24, 20, 20 }}, - { 2, { 20, 20, 20, 20 }}, - { 3, { 27, 27, 26, 26 }}, - { 3, { 28, 28, 25, 25 }}, - { 2, { 23, 23, 24, 24 }}, - { 3, { 23, 23, 26, 26 }}, - { 2, { 30, 26, 26, 26 }}, - { 2, { 28, 25, 28, 29 }}}; - -const ITEM_VARIATION shopArmr_variation_ord[28] ={ - { 1, { 35, 35, 38, 38 }}, - { 1, { 31, 31, 31, 34 }}, - { 1, { 35, 35, 38, 38 }}, - { 1, { 31, 31, 32, 34 }}, - { 2, { 35, 35, 38, 38 }}, - { 2, { 31, 32, 32, 33 }}, - { 2, { 35, 35, 38, 38 }}, - { 2, { 31, 31, 32, 32 }}, - { 4, { 35, 35, 38, 38 }}, - { 4, { 31, 32, 33, 34 }}, - { 4, { 35, 35, 38, 38 }}, - { 4, { 31, 32, 33, 34 }}, - { 3, { 35, 35, 38, 38 }}, - { 3, { 31, 31, 31, 31 }}, - { 2, { 35, 35, 38, 38 }}, - { 2, { 31, 32, 34, 34 }}, - { 3, { 35, 35, 38, 38 }}, - { 3, { 31, 31, 32, 32 }}, - { 3, { 35, 35, 38, 38 }}, - { 3, { 32, 32, 32, 33 }}, - { 3, { 35, 35, 38, 38 }}, - { 3, { 31, 31, 31, 32 }}, - { 3, { 35, 35, 38, 38 }}, - { 3, { 33, 31, 32, 34 }}, - { 3, { 35, 35, 38, 38 }}, - { 3, { 33, 31, 32, 34 }}, - { 4, { 35, 35, 38, 38 }}, - { 4, { 33, 31, 32, 34 }}}; - - - -const unsigned __int16 shopMagic_treasure_lvl[14]= {0, 1, 1, 2, 2, 4, 4, 3, 2, 2, 2, 2, 2, 2}; -const unsigned __int16 shopAlch_treasure_lvl[13] = {0, 1, 1, 2, 2, 3, 3, 4, 4, 2, 2, 2, 2}; - -const ITEM_VARIATION shopWeap_variation_spc[15]={ - { 0, { 0, 0, 0, 0 }}, - { 2, { 25, 30, 20, 20}}, - { 2, { 23, 24, 28, 20}}, - { 3, { 23, 24, 25, 20}}, - { 3, { 27, 27, 26, 26}}, - { 5, { 23, 26, 28, 27}}, - { 5, { 23, 26, 28, 27}}, - { 4, { 30, 24, 20, 20}}, - { 3, { 20, 20, 20, 20}}, - { 4, { 27, 27, 26, 26}}, - { 4, { 28, 28, 25, 25}}, - { 4, { 23, 23, 24, 24}}, - { 4, { 24, 24, 27, 20}}, - { 4, { 30, 26, 26, 26}}, - { 4, { 28, 25, 28, 29}}}; - -const ITEM_VARIATION shopArmr_variation_spc[28]={ - { 2, { 35, 35, 38, 38 }}, - { 2, { 31, 31, 31, 34 }}, - { 2, { 35, 35, 38, 38 }}, - { 2, { 31, 31, 32, 34 }}, - { 3, { 35, 35, 38, 38 }}, - { 3, { 31, 32, 32, 33 }}, - { 3, { 35, 35, 38, 38 }}, - { 3, { 31, 31, 32, 32 }}, - { 5, { 35, 35, 38, 38 }}, - { 5, { 31, 32, 33, 34 }}, - { 5, { 35, 35, 38, 38 }}, - { 5, { 31, 32, 33, 34 }}, - { 4, { 35, 35, 38, 38 }}, - { 4, { 31, 31, 31, 31 }}, - { 3, { 35, 35, 38, 38 }}, - { 3, { 31, 32, 34, 34 }}, - { 4, { 35, 35, 38, 38 }}, - { 4, { 31, 31, 32, 33 }}, - { 4, { 35, 35, 38, 38 }}, - { 4, { 32, 32, 33, 34 }}, - { 4, { 35, 35, 38, 38 }}, - { 4, { 31, 31, 31, 32 }}, - { 4, { 35, 35, 38, 38 }}, - { 4, { 32, 32, 32, 32 }}, - { 4, { 35, 35, 38, 38 }}, - { 4, { 34, 34, 34, 34 }}, - { 5, { 35, 35, 38, 38 }}, - { 5, { 33, 33, 33, 33 }} - }; - -const unsigned __int16 shopMagicSpc_treasure_lvl[14] = {0, 2, 2, 3, 3, 5, 5, 4, 3, 3, 3, 3, 3, 3}; -const unsigned __int16 shopAlchSpc_treasure_lvl[13] = {0, 2, 2, 3, 3, 4, 4, 5, 5, 3, 2, 2, 2}; - - -std::array< std::array, 7> byte_4E8168={{ //byte_4E8178 - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, - { 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, - { 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3}, - { 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4}, - { 2, 2, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5}, - { 2, 2, 2, 2, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6}, - { 2, 2, 2, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}}}; - -int sub_4BE571_AddItemToSet(int valueToAdd, int *outPutSet, int elemsAlreadyPresent, int elemsNeeded); -int dword_F8B1DC_currentShopOption; // weak - -ItemGen *ptr_50C9A4_ItemToEnchant; - -struct ItemsTable *pItemsTable; // 005D29E0 - - - - - -//----- (00439DF3) -------------------------------------------------------- -int ItemGen::_439DF3_get_additional_damage(int *damage_type, bool *draintargetHP) - { - *draintargetHP = false; - *damage_type = 0; - if ( !uItemID ) - return 0; - UpdateTempBonus(pParty->uTimePlayed); - if (uItemID == 501 ) //Iron Feather -sword - { - *damage_type = 1; - return rand() % 10 + 6; - } - if (uItemID == 507 ) //Ghoulsbane -axe - { - *damage_type = 0; - return rand() % 16 + 3; - } - if ( uItemID == 510 ) //Ullyses -bow - { - *damage_type = 2; - return rand() % 4 + 9; - } - if ( uItemID == 517 ) //Old Nick -dagger - { - *damage_type = 8; - return 8; - } - - switch (uSpecEnchantmentType) - { - case 4: //Adds 3-4 points of Cold damage. - *damage_type = 2; - return rand() % 2 + 3; - break; - case 5: //Adds 6-8 points of Cold damage. - *damage_type = 2; - return rand() % 3 + 6; - break; - case 6: //Adds 9-12 points of Cold damage. - *damage_type = 2; - return rand() % 4 + 9; - break; - case 7: //Adds 2-5 points of Electrical damage. - *damage_type = 1; - return rand() % 4 + 2; - break; - case 8: //Adds 4-10 points of Electrical damage. - *damage_type = 1; - return rand() % 7 + 4; - break; - case 9: //Adds 6-15 points of Electrical damage. - *damage_type = 1; - return rand() % 10 + 6; - break; - case 10: //Adds 1-6 points of Fire damage. - *damage_type = 0; - return GetDiceResult(1, 6); - break; - case 11: //Adds 2-12 points of Fire damage. - *damage_type = 0; - return GetDiceResult(2, 6); - break; - case 12: //Adds 3-18 points of Fire damage. - *damage_type = 0; - return GetDiceResult(3, 6); - break; - case 13: //Adds 5 points of Body damage. - *damage_type = 8; - return 5; - break; - case 14: //Adds 8 points of Body damage. - *damage_type = 8; - return 8; - break; - case 15: //Adds 12 points of Body damage. - *damage_type = 8; - return 12; - break; - case 16: //Drain Hit Points from target. - case 41: //Drain Hit Points from target and Increased Weapon speed. - *damage_type = 10; - *draintargetHP = true; - return 0; - break; - case 46: //Adds 10-20 points of Fire damage and +25 Might. - *damage_type = 0; - return rand() % 11 + 10; - break; - default: - *damage_type = 0; - return 0; - - } - - } - - -//----- (00402F07) -------------------------------------------------------- -void ItemGen::Reset() -{ - this->uHolderPlayer = 0; - this->uAttributes = 0; - this->uNumCharges = 0; - this->uSpecEnchantmentType = 0; - this->m_enchantmentStrength = 0; - this->uEnchantmentType = 0; - this->uItemID = 0; - this->uBodyAnchor = 0; - this->uExpireTime = 0i64; -} - -//----- (00458260) -------------------------------------------------------- -void ItemGen::UpdateTempBonus(__int64 uTimePlayed) -{ - if ( this->uAttributes & ITEM_TEMP_BONUS ) - { - if ( uTimePlayed > (signed __int64)this->uExpireTime ) - { - this->uEnchantmentType = 0; - this->uSpecEnchantmentType = 0; - this->uAttributes = this->uAttributes&(~ITEM_TEMP_BONUS); - } - } -} - -//----- (0045814E) -------------------------------------------------------- -void ItemsTable::Release() -{ - free(pMonstersTXT_Raw); - free(pMonsterPlacementTXT_Raw); - free(pSkillDescTXT_Raw); - free(pSpcItemsTXT_Raw); - free(pStdItemsTXT_Raw); - free(pRndItemsTXT_Raw); - free(pItemsTXT_Raw); - free(pHostileTXT_Raw); - free(pHistoryTXT_Raw); - free(pPotionsTXT_Raw); - free(pPotionNotesTXT_Raw); - pMonstersTXT_Raw = nullptr; - pMonsterPlacementTXT_Raw = nullptr; - pSpcItemsTXT_Raw = nullptr; - pSkillDescTXT_Raw = nullptr; - pStdItemsTXT_Raw = nullptr; - pRndItemsTXT_Raw = nullptr; - pItemsTXT_Raw = nullptr; - pHostileTXT_Raw = nullptr; - pHistoryTXT_Raw = nullptr; - pPotionsTXT_Raw = nullptr; - pPotionNotesTXT_Raw = nullptr; -} - - -//----- (00456D84) -------------------------------------------------------- -void ItemsTable::Initialize() -{ - std::map equipStatMap; - equipStatMap["weapon"] = EQUIP_SINGLE_HANDED; - equipStatMap["weapon2"] = EQUIP_TWO_HANDED; - equipStatMap["weapon1or2"] = EQUIP_SINGLE_HANDED; - equipStatMap["missile"] = EQUIP_BOW; - equipStatMap["bow"] = EQUIP_BOW; - equipStatMap["armor"] = EQUIP_ARMOUR; - equipStatMap["shield"] = EQUIP_SHIELD; - equipStatMap["helm"] = EQUIP_HELMET; - equipStatMap["belt"] = EQUIP_BELT; - equipStatMap["cloak"] = EQUIP_CLOAK; - equipStatMap["gauntlets"] = EQUIP_GAUNTLETS; - equipStatMap["boots"] = EQUIP_BOOTS; - equipStatMap["ring"] = EQUIP_RING; - equipStatMap["amulet"] = EQUIP_AMULET; - equipStatMap["weaponw"] = EQUIP_WAND; - equipStatMap["herb"] = EQUIP_REAGENT; - equipStatMap["reagent"] = EQUIP_REAGENT; - equipStatMap["bottle"] = EQUIP_POTION; - equipStatMap["sscroll"] = EQUIP_SPELL_SCROLL; - equipStatMap["book"] = EQUIP_BOOK; - equipStatMap["mscroll"] = EQUIP_MESSAGE_SCROLL; - equipStatMap["gold"] = EQUIP_GOLD; - equipStatMap["gem"] = EQUIP_GEM; - - std::map equipSkillMap; - equipSkillMap["staff"] = PLAYER_SKILL_STAFF; - equipSkillMap["sword"] = PLAYER_SKILL_SWORD; - equipSkillMap["dagger"] = PLAYER_SKILL_DAGGER; - equipSkillMap["axe"] = PLAYER_SKILL_AXE; - equipSkillMap["spear"] = PLAYER_SKILL_SPEAR; - equipSkillMap["bow"] = PLAYER_SKILL_BOW; - equipSkillMap["mace"] = PLAYER_SKILL_MACE; - equipSkillMap["blaster"] = PLAYER_SKILL_BLASTER; - equipSkillMap["shield"] = PLAYER_SKILL_SHIELD; - equipSkillMap["leather"] = PLAYER_SKILL_LEATHER; - equipSkillMap["chain"] = PLAYER_SKILL_CHAIN; - equipSkillMap["plate"] = PLAYER_SKILL_PLATE; - equipSkillMap["club"] = PLAYER_SKILL_CLUB; - - std::map materialMap; - materialMap["artifact"] = MATERIAL_ARTEFACT; - materialMap["relic"] = MATERIAL_RELIC; - materialMap["special"] = MATERIAL_SPECIAL; - - char* test_string; - int item_counter; - - pMapStats = new MapStats; - pMapStats->Initialize(); - - pMonsterStats = new MonsterStats; - pMonsterStats->Initialize(); - pMonsterStats->InitializePlacements(); - - pSpellStats = new SpellStats; - pSpellStats->Initialize(); - - LoadPotions(); - LoadPotionNotes(); - - pFactionTable = new FactionTable; - pFactionTable->Initialize(); - - pStorylineText = new StorylineText; - pStorylineText->Initialize(); - - pStdItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stditems.txt", 0); - strtok(pStdItemsTXT_Raw, "\r"); - strtok(NULL, "\r"); - strtok(NULL, "\r"); - strtok(NULL, "\r"); - //Standard Bonuses by Group - for (int i=0;i<24;++i) - { - test_string = strtok(NULL, "\r") + 1; - auto tokens = Tokenize(test_string, '\t'); - pEnchantments[i].pBonusStat=RemoveQuotes(tokens[0]); - pEnchantments[i].pOfName=RemoveQuotes(tokens[1]); - for (int j = 0; j < 9; j++) - { - pEnchantments[i].to_item[j]=atoi(tokens[j+2]); - } - } - - memset(&pEnchantmentsSumm, 0, 36); - for(int i=0;i<9;++i) - { - for (int j=0;j<24;++j) - pEnchantmentsSumm[i]+=pEnchantments[j].to_item[i]; - } - - //Bonus range for Standard by Level - strtok(NULL, "\r"); - strtok(NULL, "\r"); - strtok(NULL, "\r"); - strtok(NULL, "\r"); - strtok(NULL, "\r"); - for(int i=0;i<6;++i) //counted from 1 - { - test_string = strtok(NULL, "\r") + 1; - auto tokens = Tokenize(test_string, '\t'); - Assert(tokens.size() == 4, "Invalid number of tokens"); - bonus_ranges[i].minR = atoi(tokens[2]); - bonus_ranges[i].maxR =atoi(tokens[3]); - } - - - pSpcItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spcitems.txt", 0); - strtok(pSpcItemsTXT_Raw, "\r"); - strtok(NULL, "\r"); - strtok(NULL, "\r"); - strtok(NULL, "\r"); - for (int i=0;i<72;++i) - { - test_string = strtok(NULL, "\r") + 1; - auto tokens = Tokenize(test_string, '\t'); - Assert(tokens.size() >= 17, "Invalid number of tokens"); - pSpecialEnchantments[i].pBonusStatement=RemoveQuotes(tokens[0]); - pSpecialEnchantments[i].pNameAdd= RemoveQuotes(tokens[1]); - for (int j = 0; j < 12; j++) - { - pSpecialEnchantments[i].to_item_apply[j]=atoi(tokens[j+2]); - } - int res; - res=atoi(tokens[14]); - if(!res) - { - ++tokens[14]; - while (*tokens[14]==' ')//fix X 2 case - ++tokens[14]; - res=atoi(tokens[14]); - } - pSpecialEnchantments[i].iValue=res; - pSpecialEnchantments[i].iTreasureLevel= tolower(tokens[15][0]) - 97; - } - - pSpecialEnchantments_count = 71; - memset(&pSpecialEnchantmentsSumm, 0, 96); - for(int i=0;i<12;++i) - { - for (unsigned int j=0;j<=pSpecialEnchantments_count;++j) - pSpecialEnchantmentsSumm[i]+=pSpecialEnchantments[j].to_item_apply[i]; - } - - InitializeBuildingResidents(); - - pItemsTXT_Raw = (char*) pEvents_LOD->LoadRaw("items.txt", 0); - strtok(pItemsTXT_Raw, "\r"); - strtok(NULL, "\r"); - uAllItemsCount = 0; - item_counter = 0; - while (item_counter < 800) - { - test_string = strtok(NULL, "\r") + 1; - auto tokens = Tokenize(test_string, '\t'); - item_counter=atoi(tokens[0]); - uAllItemsCount=item_counter; - pItems[item_counter].pIconName = RemoveQuotes(tokens[1]); - pItems[item_counter].pName = RemoveQuotes(tokens[2]); - pItems[item_counter].uValue=atoi(tokens[3]); - auto findResult = equipStatMap.find(tokens[4]); - pItems[item_counter].uEquipType = findResult == equipStatMap.end() ? EQUIP_NONE : findResult->second; - auto findResult2 = equipSkillMap.find(tokens[5]); - pItems[item_counter].uSkillType = findResult2 == equipSkillMap.end() ? PLAYER_SKILL_MISC : findResult2->second; - auto tokens2 = Tokenize(tokens[6], 'd'); - if (tokens2.size() == 2) - { - pItems[item_counter].uDamageDice=atoi(tokens2[0]); - pItems[item_counter].uDamageRoll=atoi(tokens2[1]); - } - else if (tolower(tokens2[0][0]) != 's') - { - pItems[item_counter].uDamageDice=atoi(tokens2[0]); - pItems[item_counter].uDamageRoll=1; - } - else - { - pItems[item_counter].uDamageDice=0; - pItems[item_counter].uDamageRoll=0; - } - pItems[item_counter].uDamageMod=atoi(tokens[7]); - auto findResult3 = materialMap.find(tokens[8]); - pItems[item_counter].uMaterial = findResult3 == materialMap.end() ? MATERIAL_COMMON : findResult3->second; - pItems[item_counter].uItemID_Rep_St=atoi(tokens[9]); - pItems[item_counter].pUnidentifiedName = RemoveQuotes(tokens[10]); - pItems[item_counter].uSpriteID=atoi(tokens[11]); - - pItems[item_counter]._additional_value=0; - pItems[item_counter]._bonus_type=0; - if (pItems[item_counter].uMaterial==MATERIAL_SPECIAL) - { - for(int ii=0; ii<24; ++ii) - { - if (!_stricmp(tokens[12],pEnchantments[ii].pOfName)) - { - pItems[item_counter]._bonus_type=ii+1; - break; - } - } - if (!pItems[item_counter]._bonus_type) - { - for(int ii=0; ii<72; ++ii) - { - if (!_stricmp(tokens[12],pSpecialEnchantments[ii].pNameAdd)) - { - pItems[item_counter]._additional_value=ii+1; - } - } - } - } - - if ((pItems[item_counter].uMaterial==MATERIAL_SPECIAL)&&(pItems[item_counter]._bonus_type)) - { - char b_s=atoi(tokens[13]); - if (b_s) - pItems[item_counter]._bonus_strength=b_s; - else - pItems[item_counter]._bonus_strength=1; - } - else - pItems[item_counter]._bonus_strength=0; - pItems[item_counter].uEquipX=atoi(tokens[14]); - pItems[item_counter].uEquipY=atoi(tokens[15]); - pItems[item_counter].pDescription = RemoveQuotes(tokens[16]); - item_counter++; - } - - uAllItemsCount = item_counter; - pRndItemsTXT_Raw = (char *)pEvents_LOD->LoadRaw("rnditems.txt", 0); - strtok(pRndItemsTXT_Raw, "\r"); - strtok(NULL, "\r"); - strtok(NULL, "\r"); - strtok(NULL, "\r"); - for (item_counter = 0; item_counter < 619; item_counter++) - { - test_string = strtok(NULL, "\r") + 1; - auto tokens = Tokenize(test_string, '\t'); - Assert(tokens.size() > 7, "Invalid number of tokens"); - item_counter = atoi(tokens[0]); - pItems[item_counter].uChanceByTreasureLvl1=atoi(tokens[2]); - pItems[item_counter].uChanceByTreasureLvl2=atoi(tokens[3]); - pItems[item_counter].uChanceByTreasureLvl3=atoi(tokens[4]); - pItems[item_counter].uChanceByTreasureLvl4=atoi(tokens[5]); - pItems[item_counter].uChanceByTreasureLvl5=atoi(tokens[6]); - pItems[item_counter].uChanceByTreasureLvl6=atoi(tokens[7]); - } - - //ChanceByTreasureLvl Summ - to calculate chance - memset(&uChanceByTreasureLvlSumm, 0, 24); - for(int i=0;i<6;++i) - { - for (int j=1;j 7, "Invalid number of tokens"); - switch (i) - { - case 0: - uBonusChanceStandart[0]=atoi(tokens[2]); - uBonusChanceStandart[1]=atoi(tokens[3]); - uBonusChanceStandart[2]=atoi(tokens[4]); - uBonusChanceStandart[3]=atoi(tokens[5]); - uBonusChanceStandart[4]=atoi(tokens[6]); - uBonusChanceStandart[5]=atoi(tokens[7]); - break; - case 1: - uBonusChanceSpecial[0]=atoi(tokens[2]); - uBonusChanceSpecial[1]=atoi(tokens[3]); - uBonusChanceSpecial[2]=atoi(tokens[4]); - uBonusChanceSpecial[3]=atoi(tokens[5]); - uBonusChanceSpecial[4]=atoi(tokens[6]); - uBonusChanceSpecial[5]=atoi(tokens[7]); - break; - case 2: - uBonusChanceWpSpecial[0]=atoi(tokens[2]); - uBonusChanceWpSpecial[1]=atoi(tokens[3]); - uBonusChanceWpSpecial[2]=atoi(tokens[4]); - uBonusChanceWpSpecial[3]=atoi(tokens[5]); - uBonusChanceWpSpecial[4]=atoi(tokens[6]); - uBonusChanceWpSpecial[5]=atoi(tokens[7]); - break; - } - } - free(pRndItemsTXT_Raw); - pRndItemsTXT_Raw = nullptr; - - pSkillDescTXT_Raw = (char *)pEvents_LOD->LoadRaw("skilldes.txt", 0); - strtok(pSkillDescTXT_Raw, "\r"); - for (int i=0; i<37; ++i) - { - test_string = strtok(NULL, "\r") + 1; - auto tokens = Tokenize(test_string, '\t'); - Assert(tokens.size() >= 6, "Invalid number of tokens"); - pSkillDesc[i] = RemoveQuotes(tokens[1]); - pNormalSkillDesc[i] = RemoveQuotes(tokens[2]); - pExpertSkillDesc[i] = RemoveQuotes(tokens[3]); - pMasterSkillDesc[i] = RemoveQuotes(tokens[4]); - pGrandSkillDesc[i] = RemoveQuotes(tokens[5]); - } - - pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0); - strtok(pStatsTXT_Raw, "\r"); - for (int i=0; i<26; ++i) - { - test_string = strtok(NULL, "\r") + 1; - auto tokens = Tokenize(test_string, '\t'); - Assert(tokens.size() == 2, "Invalid number of tokens"); - switch (i) - { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - pAttributeDescriptions[i] = RemoveQuotes(tokens[1]); - break; - case 7: - pHealthPointsAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 8: - pArmourClassAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 9: - pSpellPointsAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 10: - pPlayerConditionAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 11: - pFastSpellAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 12: - pPlayerAgeAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 13: - pPlayerLevelAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 14: - pPlayerExperienceAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 15: - pAttackBonusAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 16: - pAttackDamageAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 17: - pMissleBonusAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 18: - pMissleDamageAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 19: - pFireResistanceAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 20: - pAirResistanceAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 21: - pWaterResistanceAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 22: - pEarthResistanceAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 23: - pMindResistanceAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 24: - pBodyResistanceAttributeDescription = RemoveQuotes(tokens[1]); - break; - case 25: - pSkillPointsAttributeDescription = RemoveQuotes(tokens[1]); - break; - } - } - - pClassTXT_Raw = 0; - pClassTXT_Raw = (char *)pEvents_LOD->LoadRaw("class.txt", 0); - strtok(pClassTXT_Raw, "\r"); - for (int i=0; i<36; ++i) - { - test_string = strtok(NULL, "\r") + 1; - auto tokens = Tokenize(test_string, '\t'); - Assert(tokens.size() == 3, "Invalid number of tokens"); - pClassDescriptions[i]=RemoveQuotes(tokens[1]); - } - - - - ItemGen::PopulateSpecialBonusMap(); - ItemGen::PopulateArtifactBonusMap(); - ItemGen::PopulateRegularBonusMap(); - - - } - -//----- (00456D17) -------------------------------------------------------- -void ItemsTable::SetSpecialBonus(ItemGen *pItem) -{ - if ( pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL ) - { - pItem->uEnchantmentType = pItems[pItem->uItemID]._bonus_type; - pItem->uSpecEnchantmentType = pItems[pItem->uItemID]._additional_value; - pItem->m_enchantmentStrength = pItems[pItem->uItemID]._bonus_strength; - } -} - -//----- (00456D43) -------------------------------------------------------- -bool ItemsTable::IsMaterialSpecial(ItemGen *pItem) -{ - return this->pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL; -} - -//----- (00456D5E) -------------------------------------------------------- -bool ItemsTable::IsMaterialNonCommon(ItemGen *pItem) -{ - return pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL || - pItems[pItem->uItemID].uMaterial == MATERIAL_RELIC || - pItems[pItem->uItemID].uMaterial == MATERIAL_ARTEFACT; -} - - -//----- (00453B3C) -------------------------------------------------------- -void ItemsTable::LoadPotions() -{ - - CHAR Text[90]; - char* test_string; - unsigned int uRow; - unsigned int uColumn; - unsigned __int8 potion_value; - - free(pPotionNotesTXT_Raw); - auto tokens = Tokenize("", '\t'); - char* pPotionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("potion.txt", 0); - test_string = strtok(pPotionsTXT_Raw ,"\r") + 1; - while (test_string) - { - tokens = Tokenize(test_string, '\t'); - if (!strcmp(tokens[0], "222")) - break; - test_string = strtok(NULL ,"\r") + 1; - } - if (!test_string) - { - MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); - return; - } - - for (uRow = 0;uRow < 50; ++uRow) - { - if (tokens.size() < 50) - { - wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, tokens.size()); - MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); - return; - } - for (uColumn = 0; uColumn < 50; ++uColumn) - { - char* currValue = tokens[uColumn + 7]; - potion_value = atoi(currValue); - if ( !potion_value && tolower(currValue[0]) == 'e') - { - potion_value = atoi(currValue + 1); - } - this->potion_data[uRow][uColumn]=potion_value; - } - - test_string = strtok(NULL ,"\r") + 1; - if (!test_string) - { - wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, 0); - MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); - return; - } - tokens = Tokenize(test_string, '\t'); - } -} - -//----- (00453CE5) -------------------------------------------------------- -void ItemsTable::LoadPotionNotes() -{ - - CHAR Text[90]; - char* test_string; - unsigned int uRow; - unsigned int uColumn; - unsigned __int8 potion_note; - - free(pPotionNotesTXT_Raw); - auto tokens = Tokenize("", '\t'); - char* pPotionNotesTXT_Raw = (char *)pEvents_LOD->LoadRaw("potnotes.txt", 0); - test_string = strtok(pPotionNotesTXT_Raw ,"\r") + 1; - while (test_string) - { - tokens = Tokenize(test_string, '\t'); - if (!strcmp(tokens[0], "222")) - break; - test_string = strtok(NULL ,"\r") + 1; - } - if (!test_string) - { - MessageBoxA(0, "Error Pre-Parsing Potion Table", "Load Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); - return; - } - - for (uRow = 0;uRow < 50; ++uRow) - { - if (tokens.size() < 50) - { - wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, tokens.size()); - MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); - return; - } - for (uColumn = 0; uColumn < 50; ++uColumn) - { - char* currValue = tokens[uColumn + 7]; - potion_note = atoi(currValue); - if ( !potion_note && tolower(currValue[0]) == 'e') - { - potion_note = atoi(currValue + 1); - } - this->potion_note[uRow][uColumn]=potion_note; - } - - test_string = strtok(NULL ,"\r") + 1; - if (!test_string) - { - wsprintfA(Text, "Error Parsing Potion Table at Row: %d Column: %d", uRow, 0); - MessageBoxA(0, Text, "Parsing Error", MB_ICONHAND|MB_CANCELTRYCONTINUE); - return; - } - tokens = Tokenize(test_string, '\t'); - } - - - } - - -//----- (00456442) -------------------------------------------------------- -unsigned int ItemGen::GetValue() - { - unsigned int uBaseValue; // edi@1 - unsigned int bonus; - - uBaseValue = pItemsTable->pItems[this->uItemID].uValue; - if ( this->uAttributes & ITEM_TEMP_BONUS || pItemsTable->IsMaterialNonCommon(this) ) - return uBaseValue; - if (uEnchantmentType ) - return uBaseValue + 100 * m_enchantmentStrength;; - if (uSpecEnchantmentType ) - { - bonus = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType].iTreasureLevel; - if ( bonus > 10 ) - return uBaseValue + bonus; - else - return uBaseValue * bonus; - } - return uBaseValue; - } - -//----- (00456499) -------------------------------------------------------- -const char *ItemGen::GetDisplayName() -{ - if (IsIdentified()) - return GetIdentifiedName(); - else - return pItemsTable->pItems[uItemID].pUnidentifiedName; -} - -//----- (004564B3) -------------------------------------------------------- -const char *ItemGen::GetIdentifiedName() -{ - unsigned __int8 equip_type; - const char *player_name; - const char *nameModificator; - const char *format_str; - - equip_type = GetItemEquipType(); - if ( (equip_type == EQUIP_REAGENT) || (equip_type == EQUIP_POTION) || (equip_type == EQUIP_GOLD) ) - { - sprintf(item__getname_buffer.data(), "%s", pItemsTable->pItems[uItemID].pName); - return item__getname_buffer.data(); - } - sprintf(item__getname_buffer.data(), "%s", pItemsTable->pItems[uItemID].pName); - if ( uItemID == ITEM_LICH_JAR_FULL ) //Lich Jar - { - if ( (uHolderPlayer >0 )&& (uHolderPlayer <= 4) ) - { - player_name = pPlayers[uHolderPlayer]->pName; - if ( player_name[strlen(player_name) - 1] == 's' ) - format_str = pGlobalTXT_LocalizationStrings[655]; //"%s' Jar" - else - format_str = pGlobalTXT_LocalizationStrings[654]; //"%s's Jar" - sprintf(item__getname_buffer.data(), format_str, pPlayers[uHolderPlayer]->pName); - return item__getname_buffer.data(); - } - } - if ( !pItemsTable->IsMaterialNonCommon(this) ) - { - if ( uEnchantmentType ) - { - strcat(item__getname_buffer.data(), " "); - nameModificator = pItemsTable->pEnchantments[uEnchantmentType-1].pOfName; - } - else - { - if ( !uSpecEnchantmentType ) - return item__getname_buffer.data(); - if ( uSpecEnchantmentType == 16 //Drain Hit Points from target. - || uSpecEnchantmentType == 39 //Double damage vs Demons. - || uSpecEnchantmentType == 40 //Double damage vs Dragons - || uSpecEnchantmentType == 45 //+5 Speed and Accuracy - || uSpecEnchantmentType == 56 //+5 Might and Endurance. - || uSpecEnchantmentType == 57 //+5 Intellect and Personality. - || uSpecEnchantmentType == 58 //Increased Value. - || uSpecEnchantmentType == 60 //+3 Unarmed and Dodging skills - || uSpecEnchantmentType == 61 //+3 Stealing and Disarm skills. - || uSpecEnchantmentType == 59 //Increased Weapon speed. - || uSpecEnchantmentType == 63 //Double Damage vs. Elves. - || uSpecEnchantmentType == 64 //Double Damage vs. Undead. - || uSpecEnchantmentType == 67 //Adds 5 points of Body damage and +2 Disarm skill. - || uSpecEnchantmentType == 68 ) //Adds 6-8 points of Cold damage and +5 Armor Class. - { //enchantment and name positions inverted! - sprintf( item__getname_buffer.data(), "%s %s", - pItemsTable->pSpecialEnchantments[uSpecEnchantmentType-1].pNameAdd, - pItemsTable->pItems[uItemID].pName); - return item__getname_buffer.data(); - } - strcat(item__getname_buffer.data(), " "); - nameModificator = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType-1].pNameAdd; - } - strcat(item__getname_buffer.data(), nameModificator); - } - return item__getname_buffer.data(); -} - - -//----- (00456620) -------------------------------------------------------- -void ItemsTable::GenerateItem(int treasure_level, unsigned int uTreasureType, ItemGen *out_item) - { - int treasureLevelMinus1; // ebx@3 - int current_chance; // ebx@43 - int tmp_chance; // ecx@47 - int v17; // ebx@57 - int v18; // edx@62 - unsigned int special_chance; // edx@86 - unsigned int v26; // edx@89 - unsigned int v27; // eax@89 - int v32; // ecx@91 - int v33; // eax@91 -// unsigned int v34; // eax@97 - int v45; // eax@120 - int v46; // edx@120 - int j; // eax@121 - int val_list[800]; // [sp+Ch] [bp-C88h]@33 - int total_chance; // [sp+C8Ch] [bp-8h]@33 - signed int v56; // [sp+CA0h] [bp+Ch]@55 - int v57; // [sp+CA0h] [bp+Ch]@62 - - if (!out_item) - out_item = (ItemGen *)malloc(sizeof(ItemGen)); - memset(out_item, 0, sizeof(*out_item)); - - - treasureLevelMinus1 = treasure_level - 1; - if ( uTreasureType ) //generate known treasure type - { - ITEM_EQUIP_TYPE requested_equip; - PLAYER_SKILL_TYPE requested_skill = PLAYER_SKILL_INVALID; - switch (uTreasureType) - { - case 20: requested_equip = EQUIP_SINGLE_HANDED; break; - case 21: requested_equip = EQUIP_ARMOUR; break; - case 22: requested_skill = PLAYER_SKILL_MISC; break; - case 23: requested_skill = PLAYER_SKILL_SWORD; break; - case 24: requested_skill = PLAYER_SKILL_DAGGER; break; - case 25: requested_skill = PLAYER_SKILL_AXE; break; - case 26: requested_skill = PLAYER_SKILL_SPEAR; break; - case 27: requested_skill = PLAYER_SKILL_BOW; break; - case 28: requested_skill = PLAYER_SKILL_MACE; break; - case 29: requested_skill = PLAYER_SKILL_CLUB; break; - case 30: requested_skill = PLAYER_SKILL_STAFF; break; - case 31: requested_skill = PLAYER_SKILL_LEATHER; break; - case 32: requested_skill = PLAYER_SKILL_CHAIN; break; - case 33: requested_skill = PLAYER_SKILL_PLATE; break; - case 34: requested_equip = EQUIP_SHIELD; break; - case 35: requested_equip = EQUIP_HELMET; break; - case 36: requested_equip = EQUIP_BELT; break; - case 37: requested_equip = EQUIP_CLOAK; break; - case 38: requested_equip = EQUIP_GAUNTLETS; break; - case 39: requested_equip = EQUIP_BOOTS; break; - case 40: requested_equip = EQUIP_RING; break; - case 41: requested_equip = EQUIP_AMULET; break; - case 42: requested_equip = EQUIP_WAND; break; - case 43: requested_equip = EQUIP_SPELL_SCROLL; break; - case 44: requested_equip = EQUIP_POTION; break; - case 45: requested_equip = EQUIP_REAGENT; break; - case 46: requested_equip = EQUIP_GEM; break; - default: - __debugbreak(); // check this condition - requested_equip = (ITEM_EQUIP_TYPE)(uTreasureType - 1); - break; - } - memset(val_list, 0, sizeof(val_list)); - total_chance = 0; - j=0; - //a2a = 1; - if (requested_skill == PLAYER_SKILL_INVALID) // no skill for this item needed - { - for (uint i = 1; i < 500; ++i) - { - if (pItems[i].uEquipType == requested_equip) - { - val_list[j] = i; - ++j; - total_chance += pItems[i].uChanceByTreasureLvl[treasure_level - 1]; - } - } - } - else //have needed skill - { - for (uint i = 1; i < 500; ++i) - { - if (pItems[i].uSkillType == requested_skill) - { - val_list[j] = i; - ++j; - total_chance += pItems[i].uChanceByTreasureLvl[treasure_level - 1]; - } - } - } - - current_chance = 0; - if ( total_chance ) - { - current_chance = rand() % total_chance + 1; - tmp_chance = 0; - j=0; - while(tmp_chance < current_chance) - { - out_item->uItemID = val_list[j]; - tmp_chance += pItems[val_list[j]].uChanceByTreasureLvl[treasure_level - 1]; - ++j; - } - } - else - { - out_item->uItemID = 1; - } - } - else - { - //artifact - if ( treasureLevelMinus1 == 5 ) - { - v56 = 0; - for(int i=0; i<29; ++i) - v56 += pParty->pIsArtifactFound[i]; - v17 = rand() % 29; - if ((rand() % 100 < 5) && !pParty->pIsArtifactFound[v17] && v56 < 13) - { - pParty->pIsArtifactFound[v17] = 1; - out_item->uAttributes = 0; - out_item->uItemID = v17 + 500; - SetSpecialBonus(out_item); - return; - } - } - - v57 = 0; - v18 = rand() % this->uChanceByTreasureLvlSumm[treasure_level - 1] + 1; - while (v57 < v18) - { - ++out_item->uItemID; - v57 += pItems[out_item->uItemID].uChanceByTreasureLvl[treasureLevelMinus1]; - } - } - if (out_item->GetItemEquipType() == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE ) - {// if it potion set potion spec - out_item->uEnchantmentType = 0; - for (int i=0; i<2; ++i) - out_item->uEnchantmentType += rand() % 4 + 1; - out_item->uEnchantmentType = out_item->uEnchantmentType * treasure_level; - } - - if ( out_item->uItemID == ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION - && !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) ) - out_item->uItemID = ITEM_SPELLBOOK_LIGHT_SUN_BURST; - if ( pItemsTable->pItems[out_item->uItemID].uItemID_Rep_St ) - out_item->uAttributes = 0; - else - out_item->uAttributes = 1; - - if ( out_item->GetItemEquipType() != EQUIP_POTION ) - { - out_item->uSpecEnchantmentType = 0; - out_item->uEnchantmentType = 0; - } - //try get special enhansment - switch (out_item->GetItemEquipType()) - { - case EQUIP_SINGLE_HANDED: - case EQUIP_TWO_HANDED : - case EQUIP_BOW : - if ( !uBonusChanceWpSpecial[treasureLevelMinus1] ) - return; - if ((uint)(rand() % 100)>=uBonusChanceWpSpecial[treasureLevelMinus1]) - return; - break; - case EQUIP_ARMOUR : - case EQUIP_SHIELD : - case EQUIP_HELMET : - case EQUIP_BELT : - case EQUIP_CLOAK : - case EQUIP_GAUNTLETS : - case EQUIP_BOOTS : - case EQUIP_RING : - - if ( !uBonusChanceStandart[treasureLevelMinus1] ) - return; - special_chance = rand() % 100; - if ( special_chance < uBonusChanceStandart[treasureLevelMinus1]) - { - v26 = rand() %pEnchantmentsSumm[out_item->GetItemEquipType()-3] + 1; - v27 = 0; - while(v27 < v26) - { - ++out_item->uEnchantmentType; - v27+=pEnchantments[out_item->uEnchantmentType].to_item[out_item->GetItemEquipType()-3]; - } - - v33 = rand() % (bonus_ranges[treasureLevelMinus1].maxR - bonus_ranges[treasureLevelMinus1].minR + 1); - out_item->m_enchantmentStrength = v33 + bonus_ranges[treasureLevelMinus1].minR; - v32 = out_item->uEnchantmentType - 1; - if ( v32 == 21 || v32 == 22 || v32 == 23 ) //Armsmaster skill, Dodge skill, Unarmed skill - out_item->m_enchantmentStrength = out_item->m_enchantmentStrength/2; - if ( out_item->m_enchantmentStrength <= 0 ) - out_item->m_enchantmentStrength = 1; - return; - - } - else if ( special_chance >= uBonusChanceStandart[treasureLevelMinus1] + uBonusChanceSpecial[treasureLevelMinus1] ) - return; - break; - case EQUIP_WAND: - out_item->uNumCharges = rand() % 6 + out_item->GetDamageMod() + 1; - out_item->uMaxCharges = out_item->uNumCharges; - return; - default: - return; - } - - j=0; - int spc_sum=0; - int spc; - memset(&val_list, 0, 3200); - for (unsigned int i=0; iGetItemEquipType()]; - spc_sum+=spc; - if(spc) - { - val_list[j++]=i; - } - } - } - - v46 = rand()%spc_sum+1;//ñëó÷àéíûå çíà÷åíèÿ îò 1 äî spc_sum - j=0; - v45 = 0; - while (v45uSpecEnchantmentType=val_list[j]; - v45+=pSpecialEnchantments[val_list[j]].to_item_apply[out_item->GetItemEquipType()]; - } -} - -//----- (004505CC) -------------------------------------------------------- -bool ItemGen::GenerateArtifact() -{ - signed int uNumArtifactsNotFound; // esi@1 - int artifacts_list[32]; - - memset(artifacts_list, 0,sizeof(artifacts_list)); - uNumArtifactsNotFound = 0; - - for (int i=500;i<529;++i) - if ( !pParty->pIsArtifactFound[i-500] ) - artifacts_list[uNumArtifactsNotFound++] = i; - - Reset(); - if ( uNumArtifactsNotFound ) - { - uItemID = artifacts_list[rand() % uNumArtifactsNotFound]; - pItemsTable->SetSpecialBonus(this); - return true; - } - else - return false; - -} - -std::map* >ItemGen::regularBonusMap; -std::map* >ItemGen::specialBonusMap; -std::map* >ItemGen::artifactBonusMap; - -#define NEWBONUSINTOSPECIALLIST(x,y) AddToMap(ItemGen::specialBonusMap, enchId, x, y); -#define NEWBONUSINTOSPECIALLIST2(x,y,z) AddToMap(ItemGen::specialBonusMap, enchId, x, y, z); - -#define NEWBONUSINTOREGULARLIST(x) AddToMap(ItemGen::regularBonusMap, enchId, x); - -#define NEWBONUSINTOARTIFACTLIST(x,y) AddToMap(ItemGen::artifactBonusMap, itemId, x, y); -#define NEWBONUSINTOARTIFACTLIST2(x,y,z) AddToMap(ItemGen::artifactBonusMap, itemId, x, y, z); - -void ItemGen::AddToMap( std::map* > &maptoadd, int enchId, CHARACTER_ATTRIBUTE_TYPE attrId, int bonusValue /*= 0*/, unsigned __int16 Player::* skillPtr /*= NULL*/ ) -{ - auto key = maptoadd.find(enchId); - std::map* currMap; - if (key == maptoadd.end()) - { - currMap = new std::map; - maptoadd[enchId] = currMap; - } - else - { - currMap = key->second; - } - Assert(currMap->find(attrId) == currMap->end(), "Attribute %d already present for enchantment %d", attrId, enchId); - (*currMap)[attrId] = new CEnchantment(bonusValue, skillPtr); -} - -void ItemGen::PopulateSpecialBonusMap() -{ - int enchId = 1;// of Protection, +10 to all Resistances - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE, 10); - NEWBONUSINTOSPECIALLIST( CHARACTER_ATTRIBUTE_RESIST_AIR, 10); - NEWBONUSINTOSPECIALLIST( CHARACTER_ATTRIBUTE_RESIST_WATER, 10); - NEWBONUSINTOSPECIALLIST( CHARACTER_ATTRIBUTE_RESIST_EARTH, 10); - NEWBONUSINTOSPECIALLIST( CHARACTER_ATTRIBUTE_RESIST_MIND, 10); - NEWBONUSINTOSPECIALLIST( CHARACTER_ATTRIBUTE_RESIST_BODY, 10); - - enchId = 2;//of The Gods, +10 to all Seven Statistics - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_STRENGTH, 10); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 10); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 10); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 10); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ACCURACY, 10); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_SPEED, 10); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_LUCK, 10); - - enchId = 26;//of Air Magic - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_AIR,0, &Player::skillAir); - - enchId = 27;//of Body Magic - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_BODY,0, &Player::skillBody); - - enchId = 28;//of Dark Magic - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_DARK,0, &Player::skillDark); - - enchId = 29;//of Earth Magic - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_EARTH,0, &Player::skillEarth); - - enchId = 30;//of Fire Magic - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_FIRE,0, &Player::skillFire); - - enchId = 31;//of Light Magic - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_LIGHT,0, &Player::skillLight); - - enchId = 32;//of Mind Magic - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_MIND,0, &Player::skillMind); - - enchId = 33;//of Spirit Magic - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_SPIRIT,0, &Player::skillSpirit); - - enchId = 34;//of Water Magic - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_WATER,0, &Player::skillWater); - - enchId = 42;//of Doom - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_STRENGTH, 1); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 1); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 1); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 1); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ACCURACY, 1); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_SPEED, 1); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_LUCK, 1); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_HEALTH, 1); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_MANA, 1); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_AC_BONUS, 1); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE, 1); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_AIR, 1); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_WATER, 1); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_EARTH, 1); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_MIND, 1); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_BODY, 1); - - enchId = 43;//of Earth - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 10); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_AC_BONUS, 10); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_HEALTH, 10); - - enchId = 44;//of Life - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_HEALTH, 10); - - enchId = 45;//Rogues - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_SPEED, 5); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ACCURACY, 5); - - enchId = 46;//of The Dragon - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_STRENGTH, 25); - - enchId = 47;//of The Eclipse - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_MANA, 10); - - enchId = 48;//of The Golem - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 15); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_AC_BONUS, 5); - - enchId = 49;//of The Moon - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 10); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_LUCK, 10); - - enchId = 50;//of The Phoenix - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE, 30); - - enchId = 51;//of The Sky - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_MANA, 10); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_SPEED, 10); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 10); - - enchId = 52;//of The Stars - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 10); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ACCURACY, 10); - - enchId = 53;//of The Sun - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_STRENGTH, 10); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 10); - - enchId = 54;//of The Troll - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 15); - - enchId = 55;//of The Unicorn - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_LUCK, 15); - - enchId = 56;//Warriors - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_STRENGTH, 5); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 5); - - enchId = 57;//Wizards - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 5); - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 5); - - enchId = 60;//Monks' - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_DODGE, 3, &Player::skillDodge); - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_UNARMED, 3, &Player::skillUnarmed); - - enchId = 61;//Thieves' - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM, 3, &Player::skillStealing); - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_STEALING, 3, &Player::skillDisarmTrap); - - enchId = 62;//of Identifying - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_ITEM_ID, 3, &Player::skillItemId); - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID, 3, &Player::skillMonsterId); - - enchId = 67;//Assassins' - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM, 2, &Player::skillDisarmTrap); - - enchId = 68;//Barbarians' - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_AC_BONUS, 5); - - enchId = 69;//of the Storm - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_AIR, 20); - - enchId = 70;//of the Ocean - NEWBONUSINTOSPECIALLIST(CHARACTER_ATTRIBUTE_RESIST_WATER, 10); - NEWBONUSINTOSPECIALLIST2(CHARACTER_ATTRIBUTE_SKILL_ALCHEMY, 2, &Player::skillAlchemy); -} - -void ItemGen::PopulateRegularBonusMap() -{ - int enchId = 1;//of Might - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_STRENGTH); - - enchId = 2;//of Thought - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE); - - enchId = 3;//of Charm - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_WILLPOWER); - - enchId = 4;//of Vigor - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_ENDURANCE); - - enchId = 5;//of Precision - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_ACCURACY); - - enchId = 6;//of Speed - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SPEED); - - enchId = 7;//of Luck - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_LUCK); - - enchId = 8;//of Health - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_HEALTH); - - enchId = 9;//of Magic - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_MANA); - - enchId = 10;//of Defense - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_AC_BONUS); - - enchId = 11;//of Fire Resistance - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE); - - enchId = 12;//of Air Resistance - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_AIR); - - enchId = 13;//of Water Resistance - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_WATER); - - enchId = 14;//of Earth Resistance - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_EARTH); - - enchId = 15;//of Mind Resistance - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_MIND); - - enchId = 16;//of Body Resistance - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_RESIST_BODY); - - enchId = 17;//of Alchemy - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_ALCHEMY); - - enchId = 18;//of Stealing - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_STEALING); - - enchId = 19;//of Disarming - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM); - - enchId = 20;//of Items - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_ITEM_ID); - - enchId = 21;//of Monsters - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_MONSTER_ID); - - enchId = 22;//of Arms - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER); - - enchId = 23;//of Dodging - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_DODGE); - - enchId = 24;//of the Fist - NEWBONUSINTOREGULARLIST(CHARACTER_ATTRIBUTE_SKILL_UNARMED); -} - -void ItemGen::PopulateArtifactBonusMap() -{ - int itemId; - itemId = ITEM_ARTIFACT_PUCK; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 40); - - itemId = ITEM_ARTIFACT_IRON_FEATHER; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 40); - - itemId = ITEM_ARTIFACT_WALLACE; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 40); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER, 10); - - itemId = ITEM_ARTIFACT_CORSAIR; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_LUCK, 40); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM, 5); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_STEALING, 5); - - itemId = ITEM_ARTIFACT_GOVERNORS_ARMOR; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_ACCURACY, 10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SPEED, 10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_LUCK, 10); - - itemId = ITEM_ARTIFACT_YORUBA; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 25); - - itemId = ITEM_ARTIFACT_SPLITTER; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE, 50); - - itemId = ITEM_ARTEFACT_ULLYSES, - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_ACCURACY, 50); - - itemId = ITEM_ARTEFACT_HANDS_OF_THE_MASTER, - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_DODGE, 10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_UNARMED, 10); - - itemId = ITEM_ARTIFACT_LEAGUE_BOOTS; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SPEED, 40); - NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_WATER, 0, &Player::skillWater); - - itemId = ITEM_ARTIFACT_RULERS_RING; - NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_MIND, 0, &Player::skillMind); - NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_DARK, 0, &Player::skillDark); - - itemId = ITEM_RELIC_MASH; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 150); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, -40); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_WILLPOWER, -40); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SPEED, -40); - - itemId = ITEM_RELIC_ETHRICS_STAFF; - NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_DARK, 0, &Player::skillDark); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_MEDITATION, 15); - - itemId = ITEM_RELIC_HARECS_LEATHER; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM, 5); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_STEALING, 5); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_LUCK, 50); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE, -10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_WATER, -10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_AIR, -10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_EARTH, -10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_MIND, -10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_BODY, -10); - - itemId = ITEM_RELIC_OLD_NICK; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_TRAP_DISARM, 5); - - itemId = ITEM_RELIC_AMUCK; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 100); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 100); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_AC_BONUS, -15); - - itemId = ITEM_RELIC_GLORY_SHIELD; - NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_SPIRIT, 0, &Player::skillSpirit); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_SHIELD, 5); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_MIND, -10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_BODY, -10); - - itemId = ITEM_RELIC_KELEBRIM; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 50); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_EARTH, -30); - - itemId = ITEM_RELIC_TALEDONS_HELM; - NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_LIGHT, 0, &Player::skillLight); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 15); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 15); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_LUCK, -40); - - itemId = ITEM_RELIC_SCHOLARS_CAP; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_LEARNING, +15); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_ENDURANCE, -50); - - itemId = ITEM_RELIC_PHYNAXIAN_CROWN; - NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_FIRE, 0, &Player::skillFire); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_WATER, +50); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 30); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_AC_BONUS, -20); - - itemId = ITEM_RILIC_TITANS_BELT; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 75); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SPEED, -40); - - itemId = ITEM_RELIC_TWILIGHT; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SPEED, 50); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_LUCK, 50); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE, -15); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_WATER, -15); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_AIR, -15); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_EARTH, -15); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_MIND, -15); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_BODY, -15); - - itemId = ITEM_RELIC_ANIA_SELVING; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_ACCURACY, 150); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_BOW, 5); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_AC_BONUS, -25); - - itemId = ITEM_RELIC_JUSTICE; - NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_MIND, 0, &Player::skillMind); - NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_BODY, 0, &Player::skillBody); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SPEED, -40); - - itemId = ITEM_RELIC_MEKORIGS_HAMMER; - NEWBONUSINTOARTIFACTLIST2(CHARACTER_ATTRIBUTE_SKILL_SPIRIT, 0, &Player::skillSpirit); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 75); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_AIR, -50); - - itemId = ITEM_ARTIFACT_HERMES_SANDALS; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SPEED, 100); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_ACCURACY, 50); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_AIR, 50); - - itemId = ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_WILLPOWER, -20); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, -20); - - itemId = ITEM_ARTIFACT_MINDS_EYE; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_WILLPOWER, 15); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_INTELLIGENCE, 15); - - itemId = ITEM_ELVEN_CHAINMAIL; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SPEED, 15); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_ACCURACY, 15); - - itemId = ITEM_FORGE_GAUNTLETS; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 15); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_ENDURANCE, 15); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE, 30); - - itemId = ITEM_ARTIFACT_HEROS_BELT; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_STRENGTH, 15); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_SKILL_ARMSMASTER, 5); - - itemId = ITEM_ARTIFACT_LADYS_ESCORT; - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_FIRE, 10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_AIR, 10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_WATER, 10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_EARTH, 10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_MIND, 10); - NEWBONUSINTOARTIFACTLIST(CHARACTER_ATTRIBUTE_RESIST_BODY, 10); -} - -void ItemGen::GetItemBonusSpecialEnchantment( Player* owner, CHARACTER_ATTRIBUTE_TYPE attrToGet, int* additiveBonus, int* halfSkillBonus ) -{ - auto bonusList = ItemGen::specialBonusMap.find(this->uSpecEnchantmentType); - if (bonusList == ItemGen::specialBonusMap.end()) - { - return; - } - std::map* currList = bonusList->second; - if (currList->find(attrToGet) != currList->end()) - { - CEnchantment* currBonus = (*currList)[attrToGet]; - if (currBonus->statPtr != NULL) - { - if (currBonus->statBonus == 0) - { - *halfSkillBonus = owner->*currBonus->statPtr / 2; - } - else - { - if (*additiveBonus < currBonus->statBonus) - { - *additiveBonus = currBonus->statBonus; - } - } - } - else - { - *additiveBonus += currBonus->statBonus; - } - } -} - -void ItemGen::GetItemBonusArtifact( Player* owner, CHARACTER_ATTRIBUTE_TYPE attrToGet, int* bonusSum ) -{ - auto bonusList = ItemGen::artifactBonusMap.find(this->uItemID); - if (bonusList == ItemGen::artifactBonusMap.end()) - { - return; - } - std::map* currList = bonusList->second; - if (currList->find(attrToGet) != currList->end()) - { - CEnchantment* currBonus = (*currList)[attrToGet]; - if (currBonus->statPtr != NULL) - { - *bonusSum = owner->*currBonus->statPtr / 2; - } - else - { - *bonusSum += currBonus->statBonus; - } - } -} - -bool ItemGen::IsRegularEnchanmentForAttribute( CHARACTER_ATTRIBUTE_TYPE attrToGet ) -{ - auto bonusList = ItemGen::specialBonusMap.find(this->uEnchantmentType); - if (bonusList == ItemGen::specialBonusMap.end()) - { - return false; - } - std::map* currList = bonusList->second; - return (currList->find(attrToGet) != currList->end()); -} - -ITEM_EQUIP_TYPE ItemGen::GetItemEquipType() -{ - return pItemsTable->pItems[this->uItemID].uEquipType; -} - -unsigned char ItemGen::GetPlayerSkillType() -{ - return pItemsTable->pItems[this->uItemID].uSkillType; -} - -char* ItemGen::GetIconName() -{ - return pItemsTable->pItems[this->uItemID].pIconName; -} - -unsigned __int8 ItemGen::GetDamageDice() -{ - return pItemsTable->pItems[this->uItemID].uDamageDice; -} - -unsigned __int8 ItemGen::GetDamageRoll() -{ - return pItemsTable->pItems[this->uItemID].uDamageRoll; -} - -unsigned __int8 ItemGen::GetDamageMod() -{ - return pItemsTable->pItems[this->uItemID].uDamageMod; -} -//----- (004B8E3D) -------------------------------------------------------- -void GenerateStandartShopItems() -{ - signed int item_count; - signed int shop_index; - int treasure_lvl; - int item_class; - int mdf; - - shop_index = (signed int)window_SpeakInHouse->ptr_1C; - if ( uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType] ) - { - for (item_count = 0; item_count < uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType]; ++item_count ) - { - if (shop_index <= 14) //weapon shop - { - treasure_lvl = shopWeap_variation_ord[shop_index].treasure_level; - item_class = shopWeap_variation_ord[shop_index].item_class[rand() % 4]; - } - else if (shop_index <= 28) //armor shop - { - mdf = 0; - if (item_count > 3) - ++mdf;// rechek offsets - treasure_lvl = shopArmr_variation_ord[2*(shop_index - 15) + mdf].treasure_level; - item_class = shopArmr_variation_ord[2*(shop_index - 15) + mdf].item_class[rand() % 4]; - } - else if (shop_index <= 41) //magic shop - { - treasure_lvl = shopMagic_treasure_lvl[shop_index - 28]; - item_class = 22; //misc - } - else if (shop_index <= 53) //alchemist shop - { - if (item_count < 6) - { - pParty->StandartItemsInShops[shop_index][item_count].Reset(); - pParty->StandartItemsInShops[shop_index][item_count].uItemID = 220; //potion bottle - continue; - } - else - { - treasure_lvl = shopAlch_treasure_lvl[shop_index - 41]; - item_class = 45; //reagent - } - } - pItemsTable->GenerateItem(treasure_lvl, item_class, &pParty->StandartItemsInShops[shop_index][item_count]); - pParty->StandartItemsInShops[shop_index][item_count].SetIdentified(); //identified - } - } - pParty->InTheShopFlags[shop_index] = 0; -} - -//----- (004B8F94) -------------------------------------------------------- -void GenerateSpecialShopItems() -{ - signed int item_count; - signed int shop_index; - int treasure_lvl; - int item_class; - int mdf; - - shop_index = (signed int)window_SpeakInHouse->ptr_1C; - if ( uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType] ) - { - for ( item_count = 0; item_count < uItemsAmountPerShopType[p2DEvents[shop_index - 1].uType]; ++item_count ) - { - if (shop_index <= 14) //weapon shop - { - treasure_lvl = shopWeap_variation_spc[shop_index].treasure_level; - item_class = shopWeap_variation_spc[shop_index].item_class[rand() % 4]; - } - else if (shop_index <= 28) //armor shop - { - mdf = 0; - if (item_count > 3) - ++mdf; - treasure_lvl = shopArmr_variation_spc[2*(shop_index - 15) + mdf].treasure_level; - item_class = shopArmr_variation_spc[2*(shop_index - 15) + mdf].item_class[rand() % 4]; - } - else if (shop_index <= 41) //magic shop - { - treasure_lvl = shopMagicSpc_treasure_lvl[shop_index - 28]; - item_class = 22; //misc - } - else if (shop_index <= 53) //alchemist shop - { - if (item_count < 6) - { - pParty->SpecialItemsInShops[shop_index][item_count].Reset(); - pParty->SpecialItemsInShops[shop_index][item_count].uItemID = rand() % 32 + 740; //mscrool - continue; - } - else - { - treasure_lvl = shopAlchSpc_treasure_lvl[shop_index - 41]; - item_class = 44; //potion - } - } - pItemsTable->GenerateItem(treasure_lvl, item_class, &pParty->SpecialItemsInShops[shop_index][item_count]); - pParty->SpecialItemsInShops[shop_index][item_count].SetIdentified(); //identified - } - } - pParty->InTheShopFlags[shop_index] = 0; -} - - -//----- (00450218) -------------------------------------------------------- -void GenerateItemsInChest() - { - unsigned int mapType; // eax@1 - MapInfo *currMapInfo; // esi@1 - ItemGen *currItem; // ebx@2 - int additionaItemCount; // ebp@4 - int treasureLevelBot; // edi@4 - int treasureLevelTop; // esi@4 - signed int treasureLevelRange; // esi@4 - int resultTreasureLevel; // edx@4 - int goldAmount; // esi@8 - int v11; // ebp@25 - int v12; // esi@25 - signed int whatToGenerateProb; // [sp+10h] [bp-18h]@1 - - mapType = pMapStats->GetMapInfo(pCurrentMapName); - currMapInfo = &pMapStats->pInfos[mapType]; - for(int i=1; i<20;++i) - { - for(int j=0; j<140;++j) - { - - currItem = &pChests[i].igChestItems[j]; - if ( currItem->uItemID < 0 ) - { - additionaItemCount = rand() % 5; //additional items in chect - treasureLevelBot = byte_4E8168[abs(currItem->uItemID)-1][2*currMapInfo->Treasure_prob]; - treasureLevelTop = byte_4E8168[abs(currItem->uItemID)-1][2*currMapInfo->Treasure_prob+1]; - treasureLevelRange = treasureLevelTop - treasureLevelBot + 1; - resultTreasureLevel = treasureLevelBot + rand() % treasureLevelRange; //treasure level - if (resultTreasureLevel<7) - { - v11 = 0; - do - { - whatToGenerateProb = rand() % 100; - if (whatToGenerateProb<20) - { - currItem->Reset(); - } - else if (whatToGenerateProb<60) //generate gold - { - goldAmount=0; - currItem->Reset(); - switch (resultTreasureLevel) - { - case 1: //small gold - goldAmount = rand() % 51 + 50; - currItem->uItemID = 197; - break; - case 2://small gold - goldAmount = rand() % 101 + 100; - currItem->uItemID = 197; - break; - case 3: //medium - goldAmount = rand() % 301 + 200; - currItem->uItemID = 198; - break; - case 4: //medium - goldAmount = rand() % 501 + 500; - currItem->uItemID = 198; - break; - case 5: //big - goldAmount = rand() % 1001 + 1000; - currItem->uItemID = 199; - break; - case 6: //big - goldAmount = rand() % 3001 + 2000; - currItem->uItemID = 199; - break; - } - currItem->SetIdentified(); - currItem->uSpecEnchantmentType = goldAmount; - } - else - { - pItemsTable->GenerateItem(resultTreasureLevel, 0, currItem); - } - v12 = 0; - while ( !(pChests[i].igChestItems[v12].uItemID==0) &&(v12<140)) - { - ++v12; - } - if (v12 >= 140) - break; - currItem=&pChests[i].igChestItems[v12]; - v11++; - } while (v11 < additionaItemCount + 1); // + 1 because it's the item at pChests[i].igChestItems[j] and the additional ones - } - else - currItem->GenerateArtifact(); - } - } - } - -} - - - - -// 4505CC: using guessed type int var_A0[32]; - //----- (004B3703) -------------------------------------------------------- -void FillAviableSkillsToTeach( int _this ) - { - const char *v30; // ecx@65 - unsigned int v29; // edx@56 - int v15; // ecx@19 - int v33; // [sp-4h] [bp-2Ch]@23 - int v34; // [sp-4h] [bp-2Ch]@43 - int v21; // ecx@34 - int v35[5]; // [sp+Ch] [bp-1Ch]@8 - int v37=0; // [sp+24h] [bp-4h]@1* - int i=0; - - dword_F8B1DC_currentShopOption = 0; - - switch (_this) - { - case 1: //shop weapon - for (int i=0; i<2; ++i) - { - for (int j=0; j<4; ++j) - { - if ( i ) - v21 = shopWeap_variation_spc[(unsigned int)window_SpeakInHouse->ptr_1C].item_class[j]; - else - v21 = shopWeap_variation_ord[(unsigned int)window_SpeakInHouse->ptr_1C].item_class[j]; - - switch (v21) - { - case 23: v34 = 37; break; - case 24: v34 = 38; break; - case 25: v34 = 39; break; - case 26: v34 = 40; break; - case 27: v34 = 41; break; - case 28: v34 = 42; break; - case 30: v34 = 36; break; - default: - continue; - } - v37 = sub_4BE571_AddItemToSet(v34, v35, v37, 5); - } - } - break; - case 2: //shop armor - - for (int i=0; i<2; ++i) - { - for (int j=0; j<2; ++j) - { - for (int k=0; k<4; ++k) - { - if ( i ) - v15 = shopArmr_variation_spc[(unsigned int)window_SpeakInHouse->ptr_1C-15+j].item_class[k]; - else - v15 = shopArmr_variation_ord[(unsigned int)window_SpeakInHouse->ptr_1C-15+j].item_class[k]; - switch (v15) - { - case 31: v33 = 45; break; - case 32: v33 = 46; break; - case 33: v33 = 47; break; - case 34: v33 = 44; break; - default: - continue; - } - v37 = sub_4BE571_AddItemToSet(v33, v35, v37, 5); - } - } - } - break; - case 3: //shop magic - v37 = 2; - v35[0] = 57; - v35[1] = 59; - break; - case 4: //shop alchemist - v37 = 2; - v35[0] = 71; - v35[1] = 68; - break; - case 21: //tavern - v37 = 3; - v35[0] = 70; - v35[1] = 65; - v35[2] = 62; - break; - case 23: //temple - v37 = 3; - v35[0] = 67; - v35[1] = 66; - v35[2] = 58; - break; - case 30: ///trainig - v37 = 2; - v35[0] = 69; - v35[1] = 60; - break; - } - for(i=0;i(v30); - ++dword_F8B1DC_currentShopOption; - CreateButtonInColumn(i+1, v29); - } - pDialogueWindow->_41D08F_set_keyboard_control_group(i, 1, 0, 2); - dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; - } - - //----- (004BE571) -------------------------------------------------------- -int sub_4BE571_AddItemToSet(int valueToAdd, int *outPutSet, int elemsAlreadyPresent, int elemsNeeded) -{ - int i; // esi@3 - - if ( elemsAlreadyPresent < elemsNeeded ) - { - for ( i = 0; i < elemsAlreadyPresent; ++i ) - { - if ( valueToAdd == outPutSet[i] ) - return elemsAlreadyPresent; - } - outPutSet[elemsAlreadyPresent] = valueToAdd; - return elemsAlreadyPresent + 1; - } - return elemsNeeded; -} -//----- (0043C91D) -------------------------------------------------------- -int GetItemTextureFilename(char *pOut, signed int item_id, int index, int shoulder) -{ - int result; // eax@2 - ITEM_EQUIP_TYPE pEquipType; - - result = 0; //BUG fn is void - pEquipType = pItemsTable->pItems[item_id].uEquipType; - if ( item_id > 500 ) - { - switch ( item_id ) - { - case ITEM_RELIC_HARECS_LEATHER: - if (byte_5111F6_OwnedArtifacts[2] != 0) - item_id = 234; - break; - case ITEM_ARTIFACT_YORUBA: - if (byte_5111F6_OwnedArtifacts[1] != 0) - item_id = 236; - break; - case ITEM_ARTIFACT_GOVERNORS_ARMOR: - if (byte_5111F6_OwnedArtifacts[0] != 0) - item_id = 235; - break; - case ITEM_ELVEN_CHAINMAIL: - if (byte_5111F6_OwnedArtifacts[16] != 0) - item_id = 73; - break; - case ITEM_ARTIFACT_LEAGUE_BOOTS: - if (byte_5111F6_OwnedArtifacts[3] != 0) - item_id = 312; - break; - case ITEM_RELIC_TALEDONS_HELM: - if (byte_5111F6_OwnedArtifacts[4] != 0) - item_id = 239; - break; - case ITEM_RELIC_SCHOLARS_CAP: - if (byte_5111F6_OwnedArtifacts[5] != 0) - item_id = 240; - break; - case ITEM_RELIC_PHYNAXIAN_CROWN: - if (byte_5111F6_OwnedArtifacts[6] != 0) - item_id = 241; - break; - case ITEM_ARTIFACT_MINDS_EYE: - if (byte_5111F6_OwnedArtifacts[7] != 0) - item_id = 93; - break; - case ITEM_RARE_SHADOWS_MASK: - if (byte_5111F6_OwnedArtifacts[8] != 0) - item_id = 344; - break; - case ITEM_RILIC_TITANS_BELT: - if (byte_5111F6_OwnedArtifacts[9] != 0) - item_id = 324; - break; - case ITEM_ARTIFACT_HEROS_BELT: - if (byte_5111F6_OwnedArtifacts[10] != 0) - item_id = 104; - break; - case ITEM_RELIC_TWILIGHT: - if (byte_5111F6_OwnedArtifacts[11] != 0) - item_id = 325; - break; - case ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP: - if (byte_5111F6_OwnedArtifacts[12] != 0) - item_id = 330; - break; - case ITEM_RARE_SUN_CLOAK: - if (byte_5111F6_OwnedArtifacts[13] != 0) - item_id = 347; - break; - case ITEM_RARE_MOON_CLOAK: - if (byte_5111F6_OwnedArtifacts[14] != 0) - item_id = 348; - break; - case ITEM_RARE_VAMPIRES_CAPE: - if (byte_5111F6_OwnedArtifacts[15] != 0) - item_id = 350; - break; - default: - return 0; - } - } - - switch (pEquipType) - { - case EQUIP_ARMOUR: - if ( !shoulder ) - return sprintf(pOut, "item%3.3dv%d", item_id, index); - else if ( shoulder == 1 ) - return sprintf(pOut, "item%3.3dv%da1", item_id, index); - else if ( shoulder == 2 ) - return sprintf(pOut, "item%3.3dv%da2", item_id, index); - break; - case EQUIP_CLOAK: - if ( !shoulder ) - return sprintf(pOut, "item%3.3dv%d", item_id, index); - else - return sprintf(pOut, "item%3.3dv%da1", item_id, index); - default: - return sprintf(pOut, "item%3.3dv%d", item_id, index); - } - - result = item_id - 504; - return result; -} - - -//----- (004BDAAF) -------------------------------------------------------- -bool ItemGen::MerchandiseTest(int _2da_idx) -{ - bool test; - - if ( (p2DEvents[_2da_idx - 1].uType != 4 || (signed int)this->uItemID < 740 || (signed int)this->uItemID > 771) - && ((signed int)this->uItemID >= 600 || (signed int)this->uItemID >= 529 && (signed int)this->uItemID <= 599) || this->IsStolen()) - return false; - switch( p2DEvents[_2da_idx - 1].uType ) - { - case BuildingType_WeaponShop: - { - test = this->GetItemEquipType() <= EQUIP_BOW; - break; - } - case BuildingType_ArmorShop: - { - test = this->GetItemEquipType() >= EQUIP_ARMOUR && this->GetItemEquipType() <= EQUIP_BOOTS; - break; - } - case BuildingType_MagicShop: - { - test = this->GetPlayerSkillType() == PLAYER_SKILL_MISC || this->GetItemEquipType() == EQIUP_ANY; - break; - } - case BuildingType_AlchemistShop: - { - test = this->GetItemEquipType() == EQUIP_REAGENT || this->GetItemEquipType() == EQUIP_POTION - || (this->GetItemEquipType() > EQUIP_POTION && !(this->GetItemEquipType() != EQUIP_MESSAGE_SCROLL - || (signed int)this->uItemID < 740) && this->uItemID != 771); - break; - } - default: - { - test = false; - break; - } - } - return test; -} - -//----- (00493F79) -------------------------------------------------------- -void init_summoned_item(stru351_summoned_item *_this, __int64 duration) -{ - signed __int64 v2; // ST2C_8@1 - signed __int64 v3; // qax@1 - //signed __int64 v4; // ST1C_8@1 - unsigned __int64 v5; // qax@1 - unsigned int v6; // ebx@1 - - v2 = (signed __int64)((double)duration * 0.234375); - v3 = v2 / 60 / 60; - //v4 = v3; - v5 = (unsigned int)v3 / 0x18; - v6 = (unsigned int)(v5 / 7) >> 2; - _this->field_0_expire_second = v2 % 60; - _this->field_4_expire_minute = v2 / 60 % 60; - _this->field_8_expire_hour = v3 % 24; - _this->field_10_expire_week = v5 / 7 & 3; - _this->field_C_expire_day = (unsigned int)v5 % 0x1C; - _this->field_14_exprie_month = v6 % 0xC; - _this->field_18_expire_year = v6 / 0xC + game_starting_year; -} diff -r 92eeeb5200f2 -r 68cdef6879a0 Items.h --- a/Items.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,530 +0,0 @@ -#pragma once -#include -#include -#include "NZIArray.h" - -enum DAMAGE_TYPE:unsigned int - { - DMGT_FIRE = 0, - DMGT_ELECTR = 1, - DMGT_COLD = 2, - DMGT_EARTH = 3, - DMGT_PHISYCAL= 4, - DMGT_MAGICAL = 5, - DMGT_SPIRIT = 6, - DMGT_MIND = 7, - DMGT_BODY = 8, - DMGT_LIGHT = 9, - DMGT_DARK =10 - }; - - - -/* 338 */ -enum ITEM_FLAGS :unsigned int -{ - ITEM_IDENTIFIED = 0x1, - ITEM_BROKEN = 0x2, - ITEM_TEMP_BONUS = 0x8, - ITEM_AURA_EFFECT_RED = 0x10, - ITEM_AURA_EFFECT_BLUE = 0x20, - ITEM_AURA_EFFECT_GREEN = 0x40, - ITEM_AURA_EFFECT_PURPLE = 0x80, - ITEM_ENCHANT_ANIMATION = 0xF0, - ITEM_STOLEN = 0x100, - ITEM_HARDENED = 0x200, -}; - - -enum ITEM_MATERIAL -{ - MATERIAL_COMMON =0, - MATERIAL_ARTEFACT = 1, - MATERIAL_RELIC = 2, - MATERIAL_SPECIAL = 3 -}; - -/* 330 */ -enum ITEM_TYPE -{ - ITEM_LONGSWORD_1 = 0x1, - ITEM_DAGGER_1 = 0xF, - ITEM_AXE_1 = 0x17, - ITEM_SPEAR_1 = 0x1F, - ITEM_CROSSBOW_1 = 0x2F, - ITEM_MACE_1 = 0x32, - ITEM_STAFF_1 = 0x3D, - ITEM_BLASTER = 64, - ITEM_LASER_RIFLE = 65, - ITEM_LEATHER_1 = 0x42, - ITEM_CHAINMAIL_1 = 0x47, - ITEM_PLATE_1 = 0x4C, - ITEM_BUCKLER_1 = 0x54, - ITEM_GAUNTLETS_1 = 0x6E, - ITEM_BOOTS_1 = 0x73, - ITEM_WAND_FIRE = 135, - ITEM_WAND_STUN = 138, - ITEM_WAND_INCENERATION = 0x9F, - ITEM_REAGENT_WIDOWSWEEP_BERRIES = 200, - ITEM_TROLL_BLOOD = 0xCA, - ITEM_DRAGON_EYE = 0xCC, - ITEM_HARPY_FEATHER = 0xCF, - ITEM_DEVIL_ICHOR = 0xD6, - ITEM_OOZE_ECTOPLASM_BOTTLE = 0xD9, - ITEM_REAGENT_PHILOSOPHERS_STONE = 219, - ITEM_POTION_BOTTLE = 220, - ITEM_POTION_CATALYST = 221, - ITEM_POTION_CURE_WOUNDS = 222, - ITEM_POTION_CURE_DISEASE = 225, - ITEM_POTION_AWAKEN = 227, - ITEM_POTION_HASTE = 228, - ITEM_POTION_RECHARGE_ITEM = 233, - ITEM_POTION_HARDEN_ITEM = 236, - ITEM_POTION_CURE_INSANITY = 239, - ITEM_POTION_MIGHT_BOOST = 240, - ITEM_POTION_ACCURACY_BOOST = 245, - ITEM_POTION_FLAMING_POTION = 246, - ITEM_POTION_SWIFT_POTION = 250, - ITEM_POTION_BODY_RESISTANE = 261, - ITEM_POTION_STONE_TO_FLESH = 262, - ITEM_POTION_SLAYING_POTION = 263, - ITEM_POTION_REJUVENATION = 271, - ITEM_SPELLBOOK_TORCHLIGHT = 400,//0x190 - ITEM_SPELLBOOK_FIRE_STRIKE = 401,//0x191, - ITEM_SPELLBOOK_AIR_FEATHER_FALL = 0x19C, - ITEM_SPELLBOOK_WATER_POISON_SPRAY = 0x1A7, - ITEM_SPELLBOOK_EARTH_SLOW = 0x1B2, - ITEM_SPELLBOOK_SPIRIT_BLESS = 0x1BD, - ITEM_SPELLBOOK_MIND_MIND_BLAST = 0x1C8, - ITEM_SPELLBOOK_BODY_FIRST_AID = 0x1D3, - ITEM_SPELLBOOK_BODY_HEAL = 0x1D6, - ITEM_SPELLBOOK_BODY_BREAK_POISON = 0x1D7, - ITEM_SPELLBOOK_LIGHT_LIGHT_BOLT = 0x1DD, - ITEM_SPELLBOOK_LIGHT_SUN_BURST = 0x1E6, - ITEM_SPELLBOOK_LIGHT_DIVINE_INTERVENTION = 0x1E7, - ITEM_ARTIFACT_PUCK = 500,//0x1F4, - ITEM_ARTIFACT_IRON_FEATHER = 501, - ITEM_ARTIFACT_WALLACE = 502, - ITEM_ARTIFACT_CORSAIR = 503, - ITEM_ARTIFACT_GOVERNORS_ARMOR = 504,//1F8 - ITEM_ARTIFACT_YORUBA = 505,//1F9 - ITEM_ARTIFACT_SPLITTER = 506,//1FA - ITEM_ARTIFACT_GHOULSBANE = 507,//1FA - ITEM_ARTIFACT_GIBBET = 508,//1FA - ITEM_ARTIFACT_CHARELE = 509,//1FA - ITEM_ARTEFACT_ULLYSES =510, - ITEM_ARTEFACT_HANDS_OF_THE_MASTER =511, - ITEM_ARTIFACT_LEAGUE_BOOTS = 512,//200 - ITEM_ARTIFACT_RULERS_RING = 513, - ITEM_RELIC_MASH = 514, - ITEM_RELIC_ETHRICS_STAFF = 515,//204 - ITEM_RELIC_HARECS_LEATHER = 516,//204 - ITEM_RELIC_OLD_NICK = 517, - ITEM_RELIC_AMUCK = 518, - ITEM_RELIC_GLORY_SHIELD = 519, - ITEM_RELIC_KELEBRIM = 520,//208 - ITEM_RELIC_TALEDONS_HELM = 521,//209 - ITEM_RELIC_SCHOLARS_CAP = 522,//20A - ITEM_RELIC_PHYNAXIAN_CROWN = 523,//20B - ITEM_RILIC_TITANS_BELT = 524,//20C - ITEM_RELIC_TWILIGHT = 525,//20D - ITEM_RELIC_ANIA_SELVING = 526, - ITEM_RELIC_JUSTICE = 527, - ITEM_RELIC_MEKORIGS_HAMMER = 528, - ITEM_ARTIFACT_HERMES_SANDALS = 529, - ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP = 530,//212 - ITEM_ARTIFACT_ELFBANE = 531,//212 - ITEM_ARTIFACT_MINDS_EYE = 532,//214 - ITEM_ELVEN_CHAINMAIL = 533,//215 - ITEM_FORGE_GAUNTLETS = 534, - ITEM_ARTIFACT_HEROS_BELT = 535,//217 - ITEM_ARTIFACT_LADYS_ESCORT = 536, - ITEM_RARE_CLANKERS_AMULET = 537, - ITEM_RARE_LIETENANTS_CUTLASS = 538, - ITEM_RARE_MEDUSAS_MIRROR = 539, - ITEM_RARE_LADY_CARMINES_DAGGER = 540, - ITEM_RARE_VILLAINS_BLADE = 541, - ITEM_RARE_PERFECT_BOW = 542, - ITEM_RARE_PERFECT_BOW_FIXED = 543, - ITEM_RARE_SHADOWS_MASK = 544,//220 - ITEM_RARE_GHOST_RING = 545,//220 - ITEM_RARE_FAERIE_RING = 546,//220 - ITEM_RARE_SUN_CLOAK = 547,//223 - ITEM_RARE_MOON_CLOAK = 548,//224 - ITEM_RARE_ZOKKARS_AXE = 549,//224 - ITEM_RARE_VAMPIRES_CAPE = 550,//226 - ITEM_RARE_MINOTAURS_AXE = 551,//226 - ITEM_RARE_GROGNARDS_CUTLASS = 552,//226 - ITEM_LICH_JAR_FULL = 601, - ITEM_WETSUIT = 604, - ITEM_LICH_JAR_EMPTY = 615, - ITEM_RECIPE_REJUVENATION = 740, - ITEM_RECIPE_BODY_RESISTANCE = 771, -}; - -/* 331 */ -enum ITEM_EQUIP_TYPE: unsigned __int8 -{ - EQUIP_SINGLE_HANDED = 0, - EQUIP_TWO_HANDED = 1, - EQUIP_BOW = 2, - EQUIP_ARMOUR = 3, - EQUIP_SHIELD = 4, - EQUIP_HELMET = 5, - EQUIP_BELT = 6, - EQUIP_CLOAK = 7, - EQUIP_GAUNTLETS = 8, - EQUIP_BOOTS = 9, - EQUIP_RING = 10, - EQUIP_AMULET = 11, - EQUIP_WAND = 12, - EQUIP_REAGENT = 13, - EQUIP_POTION = 14, - EQUIP_SPELL_SCROLL = 15, - EQUIP_BOOK = 16, - EQIUP_ANY = 16, - EQUIP_MESSAGE_SCROLL = 17, - EQUIP_GOLD = 18, - EQUIP_GEM = 19, - EQUIP_NONE = 20 -}; - -enum CHARACTER_ATTRIBUTE_TYPE; -struct Player; - -typedef struct CEnchantment -{ - unsigned __int16 Player::* statPtr; - int statBonus; - CEnchantment(int bonus, unsigned __int16 Player::* skillPtr = nullptr): - statBonus(bonus), - statPtr(skillPtr) - { - } -} CEnchantment; - -/* 64 */ -#pragma pack(push, 1) -struct ItemGen //0x24 -{ - //----- (0042EB25) -------------------------------------------------------- - // inline ItemGen() - // { - // Reset(); - // } - static void AddToMap(std::map* > &maptoadd, - int enchId, - CHARACTER_ATTRIBUTE_TYPE attrId, - int bonusValue = 0, - unsigned __int16 Player::* skillPtr = nullptr); - - static std::map* > regularBonusMap; - static std::map* > specialBonusMap; - static std::map* > artifactBonusMap; - - static void PopulateSpecialBonusMap(); - static void PopulateRegularBonusMap(); - static void PopulateArtifactBonusMap(); - static void ClearItemBonusMaps(); - - inline void ResetEnchantAnimation(){uAttributes &= 0xFFFFFF0F;} - inline bool ItemEnchanted()const {return(uAttributes & ITEM_ENCHANT_ANIMATION) != 0;} - inline bool AuraEffectRed()const {return(uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_RED;} - inline bool AuraEffectBlue()const {return(uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_BLUE;} - inline bool AuraEffectGreen()const {return(uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_GREEN;} - inline bool AuraEffectPurple()const {return(uAttributes & ITEM_ENCHANT_ANIMATION) == ITEM_AURA_EFFECT_PURPLE;} - - void GetItemBonusSpecialEnchantment(Player* owner, CHARACTER_ATTRIBUTE_TYPE attrToGet, int* additiveBonus, int* halfSkillBonus); - void GetItemBonusArtifact(Player* owner, CHARACTER_ATTRIBUTE_TYPE attrToGet, int* bonusSum); - bool IsRegularEnchanmentForAttribute(CHARACTER_ATTRIBUTE_TYPE attrToGet); - - inline bool IsBroken() {return (uAttributes & ITEM_BROKEN) != 0;} - inline void SetBroken() {uAttributes |= ITEM_BROKEN;} - inline bool IsIdentified() {return (uAttributes & ITEM_IDENTIFIED) != 0;} - inline void SetIdentified() {uAttributes |= ITEM_IDENTIFIED;} - inline bool IsStolen() {return (uAttributes & ITEM_STOLEN) != 0;} - inline void SetStolen() {uAttributes |= ITEM_STOLEN;} - - bool GenerateArtifact(); - unsigned int GetValue(); - const char *GetDisplayName(); - const char *GetIdentifiedName(); - void UpdateTempBonus(__int64 uTimePlayed); - void Reset(); - int _439DF3_get_additional_damage(int *a2, bool *vampiyr); - - ITEM_EQUIP_TYPE GetItemEquipType(); - unsigned char GetPlayerSkillType(); - char* GetIconName(); - unsigned __int8 GetDamageDice(); - unsigned __int8 GetDamageRoll(); - unsigned __int8 GetDamageMod(); - bool MerchandiseTest(int _2da_idx); - int uItemID; //0 - int uEnchantmentType; //4 - int m_enchantmentStrength; //8 - int uSpecEnchantmentType; // 25 +5 levels //0c - // 16 Drain Hit Points from target. - // 35 Increases chance of disarming. - // 39 Double damage vs Demons. - // 40 Double damage vs Dragons - // 45 +5 Speed and Accuracy - // 56 +5 Might and Endurance. - // 57 +5 Intellect and Personality. - // 58 Increased Value. - // 60 +3 Unarmed and Dodging skills - // 61 +3 Stealing and Disarm skills. - // 59 Increased Weapon speed. - // 63 Double Damage vs. Elves. - // 64 Double Damage vs. Undead. - // 67 Adds 5 points of Body damage and +2 Disarm skill. - // 68 Adds 6-8 points of Cold damage and +5 Armor Class. - // 71 Prevents drowning damage. - // 72 Prevents falling damage. - int uNumCharges; //10 - unsigned int uAttributes; //14 - unsigned __int8 uBodyAnchor; //18 - char uMaxCharges; //19 - char uHolderPlayer; //1A - char field_1B; //1B - unsigned __int64 uExpireTime; //1C -}; -#pragma pack(pop) - - - -/* 175 */ -#pragma pack(push, 1) -struct ItemDesc //30h - { //Item # |Pic File|Name|Value|Equip Stat|Skill Group|Mod1|Mod2|material| - ///ID/Rep/St|Not identified name|Sprite Index|VarA|VarB|Equip X|Equip Y|Notes - char *pIconName; //0 4 - char *pName; //4 8 - char *pUnidentifiedName; //8 c - char *pDescription; //0c 10 - unsigned int uValue; //10 14 - unsigned __int16 uSpriteID; //14 18 - __int16 field_1A; //16 - signed __int16 uEquipX; //18 1c - signed __int16 uEquipY; //1a 1e - ITEM_EQUIP_TYPE uEquipType; //1c 20 - unsigned __int8 uSkillType; //1d 21 - unsigned __int8 uDamageDice; //1e 22 - unsigned __int8 uDamageRoll; //1f 23 - unsigned __int8 uDamageMod; //20 24 - unsigned __int8 uMaterial; //21 25 - char _additional_value; //22 26 - char _bonus_type; //23 27 - char _bonus_strength; //24 28 - char field_25; // 25 29 - char field_26; //26 2A - char field_27; // 27 2b - union - { - unsigned __int8 uChanceByTreasureLvl[6]; - struct { - unsigned __int8 uChanceByTreasureLvl1; // 28 2c - unsigned __int8 uChanceByTreasureLvl2; // 29 2d - unsigned __int8 uChanceByTreasureLvl3; // 2A 2e - unsigned __int8 uChanceByTreasureLvl4; // 2B 2f - unsigned __int8 uChanceByTreasureLvl5; // 2C 30 - unsigned __int8 uChanceByTreasureLvl6; // 2D 32 - }; - }; - unsigned char uItemID_Rep_St; //2e 32 - char field_2f; -}; -#pragma pack(pop) - - - -/* 177 */ -#pragma pack(push, 1) -struct ItemEnchantment - { //Bonus|Sta|Of Name|Arm|Shld|Helm|Belt|Cape|Gaunt|Boot|Ring|Amul - char *pBonusStat; - char *pOfName; -/* union{ - struct { - unsigned char to_arm; - unsigned char to_shld; - unsigned char to_helm; - unsigned char to_belt; - unsigned char to_cape; - unsigned char to_gaunt; - unsigned char to_boot; - unsigned char to_ring; - unsigned char to_amul; - }; */ - unsigned char to_item[12]; - // }; - }; -#pragma pack(pop) - -/* 178 */ -#pragma pack(push, 1) -struct ItemSpecialEnchantment //1Ch -{ //Bonus Stat|Name Add|W1|W2|Miss|Arm|Shld|Helm|Belt|Cape|Gaunt|Boot|Ring|Amul|Value|Lvl|Description fo special Bonuses and values - - char *pBonusStatement; //0 - char *pNameAdd; //4 - char to_item_apply[12]; //8 - int iValue; //14 - int iTreasureLevel; //18 -}; -#pragma pack(pop) - -#pragma pack(push, 1) -struct BonusRange -{ - unsigned int minR; - unsigned int maxR; -}; -#pragma pack(pop) - -/* 176 */ -#pragma pack(push, 1) -struct ItemsTable -{ - void Initialize(); - void LoadPotions(); - void LoadPotionNotes(); - void GenerateItem(int treasure_level, unsigned int uTreasureType, ItemGen *pItem); - void SetSpecialBonus(ItemGen *pItem); - bool IsMaterialSpecial(ItemGen *pItem); - bool IsMaterialNonCommon(ItemGen *pItem); - void Release(); - - int uAllItemsCount; - NZIArray pItems; //4-9604h - ItemEnchantment pEnchantments[24]; //9604h - ItemSpecialEnchantment pSpecialEnchantments[72]; //97E4h -9FC4h - char field_9FC4[5000]; - char field_B348[5000]; - char field_C6D0[5000]; - char field_DA58[5000]; - char field_EDE0[384]; - unsigned __int16 potion_data[50][50]; // 77B2h*2=EF64h -102ECh - unsigned __int16 potion_note[50][50]; // 8176h*2=102ECh -11674h - char *pItemsTXT_Raw; //11674h - char *pRndItemsTXT_Raw; - char *pStdItemsTXT_Raw; //1167Ch - char *pSpcItemsTXT_Raw; //11680h - unsigned int uChanceByTreasureLvlSumm[6]; //11684 - unsigned int uBonusChanceStandart[6]; //1169c - unsigned int uBonusChanceSpecial[6]; //116B4 - unsigned int uBonusChanceWpSpecial[6]; //116cc -116e4 - unsigned int pEnchantmentsSumm[9]; //116E4h -11708h - BonusRange bonus_ranges[6]; //45C2h*4 =11708h - unsigned int pSpecialEnchantmentsSumm[24]; //11738h - unsigned int pSpecialEnchantments_count; //11798h - char field_1179C; - char field_1179D; - char field_1179E; - char field_1179F; -}; -#pragma pack(pop) - -void GenerateStandartShopItems(); -void GenerateSpecialShopItems(); -void GenerateItemsInChest(); - -extern std::array uItemsAmountPerShopType; // weak -extern ItemGen *ptr_50C9A4_ItemToEnchant; - -extern struct ItemsTable *pItemsTable; - -/* -+10 to all Resistances. 1 - +10 to all Seven Statistics. 2 - Explosive Impact! 3 - Adds 3-4 points of Cold damage. 4 - Adds 6-8 points of Cold damage. 5 - Adds 9-12 points of Cold damage. 6 - Adds 2-5 points of Electrical damage. 7 - Adds 4-10 points of Electrical damage. 8 - Adds 6-15 points of Electrical damage. 9 - Adds 1-6 points of Fire damage. 10 - Adds 2-12 points of Fire damage. 11 - Adds 3-18 points of Fire damage. 12 - Adds 5 points of Body damage. 13 - Adds 8 points of Body damage. 14 - Adds 12 points of Body damage. 15 - Drain Hit Points from target. 16 - Increases rate of Recovery. 17 - Wearer resistant to Diseases. 18 - Wearer resistant to Insanity. 19 - Wearer resistant to Paralysis. 20 - Wearer resistant to Poison. 21 - Wearer resistant to Sleep. 22 - Wearer resistant to Stone. 23 - Increased Knockback. 24 - +5 Level. 25 - Increases effect of all Air spells. 26 - Increases effect of all Body spells. 27 - Increases effect of all Dark spells. 28 - Increases effect of all Earth spells. 29 - Increases effect of all Fire spells. 30 - Increases effect of all Light spells. 31 - Increases effect of all Mind spells. 32 - Increases effect of all Spirit spells. 33 - Increases effect of all Water spells. 34 - Increases chance of Disarming. 35 - Half damage from all missile attacks. 36 - Regenerate Hit points over time. 37 - Regenerate Spell points over time. 38 - Double damage vs Demons. 39 - Double damage vs Dragons 40 - Drain Hit Points from target and Increased Weapon speed. 41 - +1 to Seven Stats, HP, SP, Armor, Resistances. 42 - +10 to Endurance, Armor, Hit points. 43 - +10 Hit points and Regenerate Hit points over time. 44 - +5 Speed and Accuracy. 45 - Adds 10-20 points of Fire damage and +25 Might. 46 - +10 Spell points and Regenerate Spell points over time. 47 - +15 Endurance and +5 Armor. 48 - +10 Intellect and Luck. 49 - +30 Fire Resistance and Regenerate Hit points over time. 50 - +10 Spell points, Speed, Intellect. 51 - +10 Endurance and Accuracy. 52 - +10 Might and Personality. 53 - +15 Endurance and Regenerate Hit points over time. 54 - +15 Luck and Regenerate Spell points over time. 55 - +5 Might and Endurance. 56 - +5 Intellect and Personality. 57 - Increased Value. 58 - Increased Weapon speed. 59 - +3 Unarmed and Dodging skills. 60 - +3 Stealing and Disarm skills. 61 - +3 ID Item and ID Monster skills. 62 - Double Damage vs. Elves. 63 - Double Damage vs. Undead. 64 - Double Damage vs. Titans. 65 - Regenerate Spell points and Hit points over time. 66 - Adds 5 points of Body damage and +2 Disarm skill. 67 - Adds 6-8 points of Cold damage and +5 Armor Class. 68 - +20 Air Resistance and Shielding. 69 - +10 Water Resistance and +2 Alchemy skill. 70 - Prevents damage from drowning. 71 - Prevents damage from falling. 72 -*/ - - -/* 391 */ -#pragma pack(push, 1) -struct stru351_summoned_item -{ - int field_0_expire_second; - int field_4_expire_minute; - int field_8_expire_hour; - int field_C_expire_day; - int field_10_expire_week; - int field_14_exprie_month; - int field_18_expire_year; -}; -#pragma pack(pop) - - -int GetItemTextureFilename(char *pOut, signed int item_id, int index, int shoulder); -void FillAviableSkillsToTeach(int _this); -void init_summoned_item(struct stru351_summoned_item *_this, __int64 duration); diff -r 92eeeb5200f2 -r 68cdef6879a0 Keyboard.cpp --- a/Keyboard.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Keyboard.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -5,18 +5,18 @@ #define _CRT_SECURE_NO_WARNINGS #include "Keyboard.h" #include "GUIWindow.h" -#include "Game.h" +#include "Engine/Game.h" #include "Engine/Graphics/Vis.h" -#include "MM7.h" -#include "Actor.h" -#include "Party.h" -#include "Timer.h" -#include "TurnEngine.h" +#include "Engine/MM7.h" +#include "Engine/Objects/Actor.h" +#include "Engine/Party.h" +#include "Engine/Timer.h" +#include "Engine/TurnEngine/TurnEngine.h" #include "Engine/Graphics/Weather.h" -#include "CastSpellInfo.h" +#include "Engine/Spells/CastSpellInfo.h" #include "Engine/Graphics/Indoor.h" -#include "Registry.h" +#include "Engine/Registry.h" #include #include diff -r 92eeeb5200f2 -r 68cdef6879a0 LOD.cpp --- a/LOD.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2409 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include "ErrorHandling.h" -#include "LOD.h" -#include "Engine/Graphics/Render.h" -#include "Engine/Graphics/Viewport.h" -#include "mm7_data.h" -#include "ZlibWrapper.h" - -#include "Engine/Graphics/Sprites.h" - - - - - - -LODFile_IconsBitmaps *pEvents_LOD = nullptr; - -LODFile_IconsBitmaps *pIcons_LOD = nullptr; -LODFile_IconsBitmaps *pIcons_LOD_mm6 = nullptr; -LODFile_IconsBitmaps *pIcons_LOD_mm8 = nullptr; - -LODFile_IconsBitmaps *pBitmaps_LOD = nullptr; -LODFile_IconsBitmaps *pBitmaps_LOD_mm6 = nullptr; -LODFile_IconsBitmaps *pBitmaps_LOD_mm8 = nullptr; - -LODFile_Sprites *pSprites_LOD = nullptr; -LODFile_Sprites *pSprites_LOD_mm6 = nullptr; -LODFile_Sprites *pSprites_LOD_mm8 = nullptr; - -LODWriteableFile *pNew_LOD = nullptr; -LODWriteableFile *pGames_LOD = nullptr; - - - - -int _6A0CA4_lod_binary_search; // weak -int _6A0CA8_lod_unused; // weak - - -// inlined -//----- (mm6c::00408860) -------------------------------------------------- -void LODFile_IconsBitmaps::_inlined_sub2() -{ - ++uTexturePacksCount; - if (!uNumPrevLoadedFiles) - uNumPrevLoadedFiles = uNumLoadedFiles; -} - -// inlined -//----- (mm6c::0045BE60) -------------------------------------------------- -void LODFile_IconsBitmaps::_inlined_sub1() -{ - dword_11B84 = uNumLoadedFiles; -} - -// inlined -//----- (mm6c::0045C310) -------------------------------------------------- -void LODFile_Sprites::_inlined_sub1() -{ - field_ECA0 = uNumLoadedSprites; -} - -// inlined -//----- (mm6c::0045C5B0) -------------------------------------------------- -void LODFile_IconsBitmaps::_inlined_sub0() -{ - dword_11B80 = uNumLoadedFiles; - if (dword_11B84 < uNumLoadedFiles) - dword_11B84 = uNumLoadedFiles; -} - - -// inlined -//----- (mm6c::0045C660) -------------------------------------------------- -void LODFile_Sprites::_inlined_sub0() -{ - field_ECA4 = uNumLoadedSprites; - if (field_ECA0 < uNumLoadedSprites) - field_ECA0 = uNumLoadedSprites; -} - -//----- (004355F7) -------------------------------------------------------- -void LODFile_IconsBitmaps::RemoveTexturesFromTextureList() -{ - if ( this->uTexturePacksCount ) - { - if ( (this->uNumLoadedFiles - 1) >= this->uNumPrevLoadedFiles ) - { - for ( uint i = this->uNumLoadedFiles - 1; i >= this->uNumPrevLoadedFiles; --i ) - { - this->pTextures[i].Release(); - if ( this->pHardwareTextures ) - { - if ( this->pHardwareTextures[i] ) - { - this->pHardwareTextures[i]->Release(); - this->pHardwareTextures[i] = 0; - } - } - if ( this->pHardwareSurfaces ) - { - if ( this->pHardwareSurfaces[i] ) - { - this->pHardwareSurfaces[i]->Release(); - this->pHardwareSurfaces[i] = 0; - } - } - } - } - this->uNumLoadedFiles = this->uNumPrevLoadedFiles; - this->uNumPrevLoadedFiles = 0; - this->uTexturePacksCount = 0; - } -} - -//----- (004114F2) -------------------------------------------------------- -void LODFile_IconsBitmaps::RemoveTexturesPackFromTextureList() -{ - if ( this->uTexturePacksCount ) - { - this->uTexturePacksCount--; - if ( !this->uTexturePacksCount ) - { - if ( (this->uNumLoadedFiles - 1) >= this->uNumPrevLoadedFiles ) - { - for ( uint i = this->uNumLoadedFiles - 1; i >= this->uNumPrevLoadedFiles; --i ) - { - this->pTextures[i].Release(); - if ( this->pHardwareTextures ) - { - if ( this->pHardwareTextures[i] ) - { - this->pHardwareTextures[i]->Release(); - this->pHardwareTextures[i] = 0; - } - } - if ( this->pHardwareSurfaces ) - { - if ( this->pHardwareSurfaces[i] ) - { - this->pHardwareSurfaces[i]->Release(); - this->pHardwareSurfaces[i] = 0; - } - } - } - } - this->uNumLoadedFiles = this->uNumPrevLoadedFiles; - this->uNumPrevLoadedFiles = 0; - } - } -} - -//----- (004AC67E) -------------------------------------------------------- -int LODFile_Sprites::LoadSpriteFromFile(LODSprite *pSpriteHeader, const char *pContainer) -{ - FILE *File; // [sp+4h] [bp-4h]@1 - void *DstBufa; // [sp+10h] [bp+8h]@4 - int Sizea; // [sp+14h] [bp+Ch]@3 - - File = FindContainer(pContainer, 0); - if ( File ) - { - fread(pSpriteHeader, 1, 0x20u, File); - strcpy(pSpriteHeader->pName, pContainer); - Sizea = pSpriteHeader->uSpriteSize; - pSpriteHeader->pSpriteLines = (LODSprite_stru0 *)malloc(8 * pSpriteHeader->uHeight); - fread(pSpriteHeader->pSpriteLines, 1, 8 * pSpriteHeader->uHeight, File); - - if ( pSpriteHeader->uDecompressedSize ) - { - pSpriteHeader->pDecompressedBytes = malloc(pSpriteHeader->uDecompressedSize); - DstBufa = malloc(Sizea); - fread(DstBufa, 1, Sizea, File); - zlib::MemUnzip(pSpriteHeader->pDecompressedBytes, (unsigned int *)&pSpriteHeader->uDecompressedSize, DstBufa, pSpriteHeader->uSpriteSize); - pSpriteHeader->uSpriteSize = pSpriteHeader->uDecompressedSize; - free(DstBufa); - } - else - { - pSpriteHeader->pDecompressedBytes = malloc(Sizea); - fread(pSpriteHeader->pDecompressedBytes, 1, Sizea, File); - } - for ( uint i = 0; i < pSpriteHeader->uHeight; i++ ) - pSpriteHeader->pSpriteLines[i].pos += (unsigned int)pSpriteHeader->pDecompressedBytes; - return 1; - } - else - return -1; -} - -//----- (004AC795) -------------------------------------------------------- -bool LODFile_Sprites::LoadSprites(const char *pFilename) -{ - if (LoadHeader(pFilename, 1)) - return false; - else - return LoadSubIndices("sprites08") == 0; -} - -//----- (004AC7C0) -------------------------------------------------------- -int LODFile_Sprites::LoadSprite(const char *pContainerName, unsigned int uPaletteID) - { - - FILE *sprite_file; // eax@12 - LODSprite temp_sprite_hdr; // [sp+Ch] [bp-3Ch]@12 - int i;//, sprite_indx; - - //find if already loaded - //if ( pRenderer->pRenderD3D ) - { - for (i=0; i= 1500 ) - return -1; - //if not loaded - load from file - - //if ( pRenderer->pRenderD3D && can_load_hardware_sprites ) - { - if ( !pHardwareSprites ) - { - pHardwareSprites = (Sprite *)malloc(1500*sizeof(Sprite));//0xEA60u - for (i=0; i<1500;++i) - { - pHardwareSprites[i].pName=nullptr; - pHardwareSprites[i].pTextureSurface=nullptr; - pHardwareSprites[i].pTexture=nullptr; - } - } - temp_sprite_hdr.uHeight = 0; - temp_sprite_hdr.uPaletteId = 0; - temp_sprite_hdr.word_1A = 0; - temp_sprite_hdr.pSpriteLines = nullptr; - temp_sprite_hdr.pDecompressedBytes = nullptr; - sprite_file = FindContainer(pContainerName, 0); - if ( !sprite_file ) - return -1; - //fread(&temp_sprite_hdr, 1, sizeof(LODSprite), sprite_file); - fread(&temp_sprite_hdr, 1, 0x20, sprite_file); - pHardwareSprites[uNumLoadedSprites].uBufferWidth = temp_sprite_hdr.uWidth; - pHardwareSprites[uNumLoadedSprites].uBufferHeight = temp_sprite_hdr.uHeight; - pSpriteHeaders[uNumLoadedSprites].uWidth = temp_sprite_hdr.uWidth; - pSpriteHeaders[uNumLoadedSprites].uHeight = temp_sprite_hdr.uHeight; - LoadSpriteFromFile( &pSpriteHeaders[uNumLoadedSprites], pContainerName); //this line is not present here in the original. necessary for Grayface's mouse picking fix - } - /*else - { - sprite_indx = LoadSpriteFromFile( &pSpriteHeaders[uNumLoadedSprites], pContainerName); - pSpriteHeaders[uNumLoadedSprites].word_1A = 0; - - if ( sprite_indx != -1 ) - { - pSpriteHeaders[uNumLoadedSprites].uPaletteId = pPaletteManager->LoadPalette(pSpriteHeaders[uNumLoadedSprites].uPaletteId); - } - else - { - if ( uNumLoadedSprites<=0 ) - uNumLoadedSprites=0; - else - { - for (i=0; iLoadPalette(pSpriteHeaders[uNumLoadedSprites].uPaletteId); - } - }*/ - - //if ( pRenderer->pRenderD3D ) - { - pHardwareSprites[uNumLoadedSprites].pName = (const char *)malloc(20); - strcpy((char *)pHardwareSprites[uNumLoadedSprites].pName, pContainerName); - pHardwareSprites[uNumLoadedSprites].uPaletteID = uPaletteID; - pRenderer->MoveSpriteToDevice(&pHardwareSprites[uNumLoadedSprites]); - } - ++uNumLoadedSprites; - return uNumLoadedSprites - 1; - - } - -//----- (004ACADA) -------------------------------------------------------- -void LODFile_Sprites::ReleaseLostHardwareSprites() -{ - signed int v2; // ebx@2 - int v3; // edi@3 - IDirectDrawSurface *v4; // eax@4 - IDirect3DTexture2 *v5; // eax@6 - IDirectDrawSurface *v6; // ST00_4@8 - - if ( this->pHardwareSprites ) - { - v2 = 0; - if ( (signed int)this->uNumLoadedSprites > 0 ) - { - v3 = 0; - do - { - v4 = (IDirectDrawSurface *)this->pHardwareSprites[v3].pTextureSurface; - if ( v4 && v4->IsLost() == DDERR_SURFACELOST ) - { - v5 = this->pHardwareSprites[v3].pTexture; - if ( v5 ) - { - v5->Release(); - this->pHardwareSprites[v3].pTexture = nullptr; - } - v6 = (IDirectDrawSurface *)this->pHardwareSprites[v3].pTextureSurface; - v6->Release(); - this->pHardwareSprites[v3].pTextureSurface = nullptr; - pRenderer->MoveSpriteToDevice(&this->pHardwareSprites[v3]); - } - ++v2; - ++v3; - } - while ( v2 < (signed int)this->uNumLoadedSprites ); - } - } -} - -//----- (004ACB70) -------------------------------------------------------- -void LODFile_Sprites::ReleaseAll() -{ - if ( this->pHardwareSprites ) - { - for ( int i = 0; i < this->uNumLoadedSprites; ++i ) - { - if ( this->pHardwareSprites ) - { - if ( this->pHardwareSprites[i].pTexture ) - { - this->pHardwareSprites[i].pTexture->Release(); - this->pHardwareSprites[i].pTexture = nullptr; - } - if ( this->pHardwareSprites ) - { - if ( this->pHardwareSprites[i].pTextureSurface ) - { - this->pHardwareSprites[i].pTextureSurface->Release(); - this->pHardwareSprites[i].pTextureSurface = nullptr; - } - } - } - } - } -} - -//----- (004ACBE0) -------------------------------------------------------- -void LODFile_Sprites::MoveSpritesToVideoMemory() -{ - if ( this->pHardwareSprites ) - { - for ( int i = 0; i < this->uNumLoadedSprites; ++i ) - pRenderer->MoveSpriteToDevice(&this->pHardwareSprites[i]); - } -} - -//----- (004ACC38) -------------------------------------------------------- -int LODSprite::DrawSprite_sw(RenderBillboardTransform_local0 *a2, char a3) -{ - RenderBillboardTransform_local0 *v3; // edi@1 - int result; // eax@1 - int v5; // esi@2 - int v6; // ST18_4@2 - //signed int v7; // eax@2 - signed int v8; // ebx@2 - int v9; // ebx@2 - int *v10; // ecx@2 - int v11; // esi@2 - unsigned int v12; // edx@4 - int v13; // esi@13 - int v14; // esi@17 - int v15; // ecx@17 - char *v16; // edx@17 - int v17; // esi@17 - int v18; // ecx@18 - int v19; // esi@18 - LODSprite_stru0 *v20; // edx@21 - int v21; // eax@22 - int v22; // esi@22 - int v23; // eax@25 - int v24; // ecx@25 - signed __int64 v25; // qtt@27 - int v26; // eax@27 - unsigned __int16 *v27; // eax@29 - LODSprite_stru0 *v28; // edx@29 - signed int v29; // ecx@30 - int v30; // ecx@37 - int v31; // ecx@38 - signed int v32; // ecx@41 - int v33; // ecx@47 - int v34; // ecx@56 - int v35; // esi@58 - __int16 v36; // ax@58 - int v37; // ecx@59 - int v38; // eax@59 - int v39; // ecx@62 - signed int v40; // ST30_4@64 - signed __int64 v41; // qtt@64 - int v42; // ecx@64 - unsigned __int16 *v43; // eax@66 - LODSprite_stru0 *v44; // ecx@66 - int v45; // edx@69 - int v46; // edx@77 - //unsigned __int16 *pTarget; // [sp+Ch] [bp-50h]@2 - signed int v48; // [sp+10h] [bp-4Ch]@2 - signed int v49; // [sp+14h] [bp-48h]@2 - int v50; // [sp+14h] [bp-48h]@19 - int v51; // [sp+14h] [bp-48h]@57 - int v52; // [sp+18h] [bp-44h]@13 - int v53; // [sp+1Ch] [bp-40h]@2 - int v54; // [sp+1Ch] [bp-40h]@22 - int v55; // [sp+1Ch] [bp-40h]@32 - int v56; // [sp+1Ch] [bp-40h]@69 - int v57; // [sp+20h] [bp-3Ch]@2 - int v58; // [sp+24h] [bp-38h]@1 - int v59; // [sp+28h] [bp-34h]@2 - int v60; // [sp+28h] [bp-34h]@13 - unsigned __int16 *v61; // [sp+2Ch] [bp-30h]@2 - int v62; // [sp+30h] [bp-2Ch]@2 - void *v63; // [sp+30h] [bp-2Ch]@29 - void *v64; // [sp+30h] [bp-2Ch]@66 - int v65; // [sp+34h] [bp-28h]@2 - int v66; // [sp+34h] [bp-28h]@22 - int v67; // [sp+34h] [bp-28h]@59 - int v68; // [sp+38h] [bp-24h]@13 - unsigned int v69; // [sp+3Ch] [bp-20h]@2 - int v70; // [sp+40h] [bp-1Ch]@2 - signed int v71; // [sp+40h] [bp-1Ch]@15 - int v72; // [sp+44h] [bp-18h]@2 - unsigned __int16 *v73; // [sp+44h] [bp-18h]@29 - unsigned __int16 *v74; // [sp+44h] [bp-18h]@66 - int v75; // [sp+48h] [bp-14h]@4 - int v76; // [sp+48h] [bp-14h]@22 - int v77; // [sp+48h] [bp-14h]@59 - //LODSprite *v78; // [sp+4Ch] [bp-10h]@1 - int v79; // [sp+50h] [bp-Ch]@4 - int v80; // [sp+50h] [bp-Ch]@21 - int v81; // [sp+50h] [bp-Ch]@62 - int v82; // [sp+50h] [bp-Ch]@67 - int v83; // [sp+50h] [bp-Ch]@75 - int *pTargetZ; // [sp+54h] [bp-8h]@4 - int v85; // [sp+58h] [bp-4h]@18 - int v86; // [sp+58h] [bp-4h]@56 - signed int v87; // [sp+64h] [bp+8h]@2 - int v88; // [sp+68h] [bp+Ch]@18 - int v89; // [sp+68h] [bp+Ch]@56 - - v3 = a2; - //v78 = this; - result = a2->_screenspace_x_scaler_packedfloat; - v58 = a2->_screenspace_x_scaler_packedfloat; - if ( result <= 0 ) - return result; - v5 = a2->_screenspace_y_scaler_packedfloat; - v6 = a2->_screenspace_x_scaler_packedfloat; - v87 = (signed __int64)0x100000000ui64 / result; - v48 = (signed __int64)0x100000000ui64 / result; - v62 = (signed __int64)0x100000000ui64 / v5; - //v7 = this->uHeight; - v8 = (signed int)((signed __int64)0x100000000ui64 / v5) >> 1; - v53 = v8; - v70 = (this->uHeight << 16) - v8; - v49 = this->uHeight; - v69 = v3->uTargetPitch; - - __debugbreak(); // target surface will most likely be 32bit, but this sub awaits 16bits - auto pTarget = (unsigned __int16 *)v3->pTarget; - v57 = v3->sZValue; - v61 = v3->pPalette; - v9 = (v6 * this->uWidth + 0x8000) >> 16; - v72 = v3->uScreenSpaceY; - result = (v5 * this->uHeight + 0x8000) >> 16; - v10 = (int *)(v72 - result + 1); - v11 = v3->uScreenSpaceX - (v9 >> 1) + 1; - v65 = v72 - result + 1; - v59 = v11 + v9 - 1; - if ( v3->uFlags & 0x800 ) - { - v10 = (int *)((char *)v10 + (v49 >> 1)); - v72 += v49 >> 1; - v65 = (int)v10; - } - v12 = v72; - pTargetZ = v10; - v75 = v3->uScreenSpaceX - (v9 >> 1) + 1; - v79 = v11 + v9 - 1; - if ( !(v3->uFlags & 8) ) - { - if ( v65 < (signed int)v3->uViewportY ) - pTargetZ = (int *)v3->uViewportY; - if ( v72 > (signed int)v3->uViewportW ) - v12 = v3->uViewportW; - if ( v11 < (signed int)v3->uViewportX ) - v75 = v3->uViewportX; - if ( v59 > (signed int)v3->uViewportZ ) - v79 = v3->uViewportZ; - } - v68 = v75 - v11; - v13 = -v62; - v60 = v59 - v79; - v52 = -v62; - if ( v3->uFlags & 1 ) - { - v13 = v62; - v70 = v53; - v52 = v62; - } - v71 = v13 * (v72 - v12) + v70; - if ( LOBYTE(viewparams->field_20) ) - { - if ( a3 ) - return result; - } - v14 = 5 * v12; - v15 = v69 * v12; - result = v12 - v72 + result - 1; - v16 = (char *)pTargetZ - v65; - v17 = v14 << 7; - if ( v3->uFlags & 4 ) - { - v34 = v79 + v15; - v89 = v34; - v86 = v79 + v17; - if ( result < (signed int)v16 ) - return result; - v51 = result - (int)v16 + 1; - while ( 1 ) - { - v35 = v71 >> 16; - v36 = this->pSpriteLines[v35].a1; - if ( v36 == -1 ) - { - v34 -= v69; - v89 = v34; - goto LABEL_84; - } - v37 = v9 - ((unsigned __int64)(v36 * (signed __int64)v58) >> 16); - v67 = v87 * ((unsigned __int64)(this->pSpriteLines[v35].a2 * (signed __int64)v58) >> 16); - v38 = v9 - v60; - v77 = v9 - v60; - if ( v9 - v60 <= (signed int)(v9 - ((unsigned __int64)(this->pSpriteLines[v35].a2 * (signed __int64)v58) >> 16)) - || v68 >= v37 ) - { - v89 -= v69; - v34 = v89; -LABEL_84: - v86 -= window->GetWidth(); - goto LABEL_85; - } - if ( v38 < v37 ) - v81 = (v87 >> 1) + v87 * (v37 - v38); - else - { - v77 = v37; - v81 = v87 >> 1; - v39 = v37 - v9; - v89 += v39 + v60; - v86 += v60 + v39; - } - v40 = ((this->pSpriteLines[v35].a2 + 1) << 16) - v81 - v67; - LODWORD(v41) = v40 << 16; - HIDWORD(v41) = v40 >> 16; - v42 = v77 - (((signed int)((unsigned __int64)(v41 / v48) - 0x8000) >> 16) + 1); - if ( v68 >= v42 ) - v42 = v68; - v43 = &pTarget[v89]; - v74 = &v43[v42 - v77 + 1]; - v44 = &this->pSpriteLines[v35]; - v64 = v44->pos; - if ( !v57 ) - { - v83 = v67 + v81; - if ( ((v83 - (v44->a1 << 16)) & 0xFFFF0000) < 0 ) - { - v83 += v87; - --v43; - --pTargetZ; - } - while ( v43 >= v74 ) - { - v46 = (v83 - ((signed int)this->pSpriteLines[v35].a1 << 16)) >> 16; - if ( *((char *)v64 + v46) ) - *v43 = v61[*((char *)v64 + v46)]; - v83 += v87; - --v43; - } - goto LABEL_81; - } - pTargetZ = &v3->pTargetZ[v86]; - v82 = v67 + v81; - if ( ((v82 - (v44->a1 << 16)) & 0xFFFF0000) < 0 ) - goto LABEL_72; -LABEL_73: - if ( v43 >= v74 ) - break; -LABEL_81: - v89 += v9 - v77 - v60 - v69; - v34 = v89; - v86 = v86 + v9 - v77 - v60 - window->GetWidth(); -LABEL_85: - result = v52; - v71 += v52; - --v51; - if ( !v51 ) - return result; - } - v45 = (v82 - ((signed int)this->pSpriteLines[v35].a1 << 16)) >> 16; - v56 = *((char *)v64 + v45); - if ( *((char *)v64 + v45) && v57 <= (unsigned int)*pTargetZ ) - { - *pTargetZ = v57; - *v43 = v61[v56]; - } -LABEL_72: - v82 += v87; - --v43; - --pTargetZ; - goto LABEL_73; - } - v18 = v75 + v15; - v19 = v75 + v17; - v88 = v18; - v85 = v19; - if ( result >= (signed int)v16 ) - { - v50 = result - (int)v16 + 1; - while ( 1 ) - { - v20 = &this->pSpriteLines[v71 >> 16]; - v80 = v71 >> 16; - if ( v20->a1 != -1 ) - break; - v18 -= v69; - v85 = v19 - window->GetWidth(); - v88 = v18; -LABEL_54: - result = v52; - v71 += v52; - --v50; - if ( !v50 ) - return result; - v19 = v85; - } - v21 = (v58 * v20->a1 + 32768) >> 16; - v66 = v21 * v87; - v76 = v68; - v54 = v20->a2; - v22 = v9 - v60; - if ( v68 >= (v58 * v54 + 32768) >> 16 || v22 <= v21 ) - { - v88 -= v69; - v85 -= window->GetWidth(); - goto LABEL_51; - } - if ( v68 > v21 ) - { - v24 = (v87 >> 1) + v87 * (v68 - v21); - } - else - { - v76 = (v58 * v20->a1 + 0x8000) >> 16; - v23 = v21 - v68; - v88 += v23; - v24 = v87 >> 1; - v85 += v23; - } - LODWORD(v25) = (((v54 + 1) << 16) - v24 - v66) << 16; - HIDWORD(v25) = (((v54 + 1) << 16) - v24 - v66) >> 16; - v26 = v76 + ((signed int)(v25 / v48) >> 16) + 1; - if ( v22 > v26 ) - v22 = v26; - v27 = &pTarget[v88]; - v73 = &v27[v22 - v76 - 1]; - v28 = &this->pSpriteLines[v80]; - v63 = v28->pos; - if ( v57 ) - { - pTargetZ = &v3->pTargetZ[v85]; - v29 = v66 - (v28->a1 << 16) + v24; - if ( (v29 & 0xFFFF0000) >= 0 ) - goto LABEL_36; - while ( 1 ) - { - v29 += v87; - ++v27; - ++pTargetZ; -LABEL_36: - if ( v27 >= v73 ) - break; - v55 = *((char *)v63 + (v29 >> 16)); - if ( *((char *)v63 + (v29 >> 16)) && v57 <= (unsigned int)*pTargetZ ) - { - *pTargetZ = v57; - *v27 = v61[v55]; - } - } - v30 = v29 >> 16; - if ( v30 > this->pSpriteLines[v80].a2 - (signed int)this->pSpriteLines[v80].a1 - || (v31 = *((char *)v63 + v30)) == 0 - || v57 > (unsigned int)*pTargetZ ) - goto LABEL_50; - *pTargetZ = v57; - } - else - { - v32 = v66 - (v28->a1 << 16) + v24; - if ( (v32 & 0xFFFF0000) < 0 ) - { - v32 += v87; - ++v27; - ++pTargetZ; - } - while ( v27 < v73 ) - { - if ( *((char *)v63 + (v32 >> 16)) ) - *v27 = v61[*((char *)v63 + (v32 >> 16))]; - v32 += v87; - ++v27; - } - v33 = v32 >> 16; - if ( v33 > this->pSpriteLines[v80].a2 - (signed int)this->pSpriteLines[v80].a1 - || (v31 = *((char *)v63 + v33)) == 0 ) - goto LABEL_50; - } - *v27 = v61[v31]; -LABEL_50: - v88 += v68 - v76 - v69; - v85 = v85 + v68 - v76 - window->GetWidth(); -LABEL_51: - v18 = v88; - goto LABEL_54; - } - return result; -} - -//----- (004AD2D1) -------------------------------------------------------- -int LODSprite::_4AD2D1(struct RenderBillboardTransform_local0 *a2, int a3) -{ - int result; // eax@1 - unsigned int v4; // esi@1 - int v5; // edi@1 - LODSprite_stru0 *v6; // edx@2 - __int16 v7; // bx@2 - int v8; // ecx@3 - unsigned __int16 *v9; // esi@3 - int v10; // ebx@3 - void *v11; // edx@3 - unsigned __int16 *v12; // ecx@3 - int v13; // ebx@4 - //LODSprite *v14; // [sp+8h] [bp-10h]@1 - unsigned __int16 *v15; // [sp+10h] [bp-8h]@1 - unsigned __int16 *v16; // [sp+14h] [bp-4h]@1 - int i; // [sp+20h] [bp+8h]@1 - - result = (int)a2; - v4 = a2->uTargetPitch; - - __debugbreak(); // sub expects 16bit target surface, we may have 32bit - v16 = (unsigned short *)a2->pTarget; - v15 = a2->pPalette; - v5 = this->uHeight - 1; - for ( i = v4 * a2->uScreenSpaceY - (this->uWidth >> 1) + a2->uScreenSpaceX + 1; v5 >= 0; --v5 ) - { - v6 = &this->pSpriteLines[v5]; - v7 = this->pSpriteLines[v5].a1; - if ( this->pSpriteLines[v5].a1 != -1 ) - { - v8 = v7; - v9 = &v16[v7 + i]; - v10 = v6->a2; - v11 = v6->pos; - v12 = &v9[v10 - v8]; - while ( v9 <= v12 ) - { - v13 = *(char *)v11; - v11 = (char *)v11 + 1; - if ( v13 ) - *v9 = v15[v13]; - ++v9; - } - v4 = *(int *)(result + 48); - //this = v14; - } - i -= v4; - } - return result; -} - -//----- (0046454B) -------------------------------------------------------- -void LODFile_IconsBitmaps::ReleaseAll2() -{ - for ( uint i = (uint)this->dword_11B84; i < this->uNumLoadedFiles; i++ ) - { - this->pTextures[i].Release(); - if ( this->pHardwareTextures ) - { - if ( this->pHardwareTextures[i] ) - { - this->pHardwareTextures[i]->Release(); - this->pHardwareTextures[i] = 0; - } - } - if ( this->pHardwareSurfaces ) - { - if ( this->pHardwareSurfaces[i] ) - { - this->pHardwareSurfaces[i]->Release(); - this->pHardwareSurfaces[i] = 0; - } - } - } - this->uTexturePacksCount = 0; - this->uNumPrevLoadedFiles = 0; - this->uNumLoadedFiles = this->dword_11B84; -} - -//----- (004645DC) -------------------------------------------------------- -void LODFile_Sprites::DeleteSomeOtherSprites() -{ - int *v1; // esi@1 - int *v2; // edi@1 - - v1 = (int *)&this->uNumLoadedSprites; - v2 = &this->field_ECA0; - DeleteSpritesRange(field_ECA0, uNumLoadedSprites); - *v1 = *v2; -} - -//----- (00461431) -------------------------------------------------------- -void LOD::File::Close() -{ - if (isFileOpened ) - { - this->pContainerName[0] = 0; - this->uCurrentIndexDir = 0; - free(pSubIndices); - free(pRoot); - pSubIndices = nullptr; - pRoot = nullptr; - fclose(pFile); - isFileOpened = false; - _6A0CA8_lod_unused = 0; - } -} - -//----- (00461492) -------------------------------------------------------- -int LODWriteableFile::CreateNewLod(LOD::FileHeader *pHeader, LOD::Directory *pDir, const char *lod_name) -{ - if (isFileOpened) - return 1; - if ( !pDir->pFilename[0] ) - return 2; - strcpy(pHeader->pSignature, "LOD"); - pHeader->LODSize = 100; - pHeader->uNumIndices = 1; - pDir->field_F = 0; - pDir->uDataSize = 0; - pDir->uOfsetFromSubindicesStart = 288; - strcpy(pLODName, lod_name); - - pFile = fopen(pLODName, "wb+"); - if (!pFile) - return 3; - fwrite(pHeader,sizeof(LOD::FileHeader), 1, pFile); - fwrite(pDir, sizeof(LOD::Directory), 1, pFile); - fclose(pFile); - pFile = nullptr; - return 0; -} - -//----- (0046153F) -------------------------------------------------------- -void LOD::File::ResetSubIndices() -{ - if ( isFileOpened ) - { - pContainerName[0] = 0; - uCurrentIndexDir = 0; - uOffsetToSubIndex = 0; - uNumSubDirs = 0; - uLODDataSize = 0; - free(pSubIndices); - pSubIndices = nullptr; - } -} - -//----- (00450C8B) -------------------------------------------------------- -void LODFile_Sprites::DeleteSomeSprites() -{ - int *v1; // esi@1 - int *v2; // edi@1 - - v1 = (int *)&this->uNumLoadedSprites; - v2 = &this->field_ECA8; - DeleteSpritesRange(this->field_ECA8, this->uNumLoadedSprites); - *v1 = *v2; -} - -//----- (00450CA9) -------------------------------------------------------- -void LODFile_Sprites::DeleteSpritesRange(int uStartIndex, int uStopIndex) -{ - if ( this->pHardwareSprites ) - { - if ( uStartIndex < uStopIndex ) - { - for ( int i = uStartIndex; i < uStopIndex; i++ ) - { - this->pSpriteHeaders[i].Release(); - pHardwareSprites[i].Release(); - } - } - } - else - { - if ( uStartIndex < uStopIndex ) - { - for ( int i = uStartIndex; i < uStopIndex; i++ ) - this->pSpriteHeaders[i].Release(); - } - } -} - -//----- (00450D1D) -------------------------------------------------------- -void LODSprite::Release() -{ - if ( !(HIBYTE(this->word_1A) & 4) ) - { - free(this->pDecompressedBytes); - free(this->pSpriteLines); - } - this->word_1A = 0; - this->pDecompressedBytes = nullptr; - this->pSpriteLines = nullptr; - this->pName[0] = 0; - this->word_16 = 0; - this->uPaletteId = 0; - this->uTexturePitch = 0; - this->uHeight = 0; - this->uWidth = 0; - this->uSpriteSize = 0; -} - -//----- (00450D68) -------------------------------------------------------- -void Sprite::Release() -{ - free((void *)pName); - pName = nullptr; - - if (pTextureSurface) - pTextureSurface->Release(); - pTextureSurface = nullptr; - - if (pTexture) - pTexture->Release(); - pTexture = nullptr; -} - -//----- (0040FAEE) -------------------------------------------------------- -//----- (0040FA2E) -------------------------------------------------------- -bool LODFile_IconsBitmaps::Load(const char *pLODFilename, const char *pFolderName) -{ - ReleaseAll(); - - if (LoadHeader(pLODFilename, 1)) - return false; - - return LoadSubIndices(pFolderName) == 0; -} - -//----- (0040FA60) -------------------------------------------------------- -void LODFile_IconsBitmaps::ReleaseAll() -{ - for( uint i = 0; i < this->uNumLoadedFiles; i++ ) - { - this->pTextures[i].Release(); - if ( this->pHardwareTextures ) - { - if ( this->pHardwareTextures[i] ) - { - this->pHardwareTextures[i]->Release(); - this->pHardwareTextures[i] = 0; - } - } - if ( this->pHardwareSurfaces ) - { - if ( this->pHardwareSurfaces[i] ) - { - this->pHardwareSurfaces[i]->Release(); - this->pHardwareSurfaces[i] = 0; - } - } - } - this->uTexturePacksCount = 0; - this->uNumPrevLoadedFiles = 0; - this->dword_11B84 = 0; - this->dword_11B80 = 0; - this->uNumLoadedFiles = 0; -} - -//----- (0040F9F0) -------------------------------------------------------- -unsigned int LODFile_IconsBitmaps::FindTextureByName(const char *pName) -{ - for ( uint i = 0; i < this->uNumLoadedFiles; i++ ) - { - if ( !_stricmp(this->pTextures[i].pName, pName) ) - return i; - } - return -1; -} - -//----- (0040F9C5) -------------------------------------------------------- -void LODFile_IconsBitmaps::SyncLoadedFilesCount() - { - signed int loaded_files; // eax@1 - Texture *pTex; // edx@1 - - loaded_files = this->uNumLoadedFiles; - for ( pTex = &this->pTextures[loaded_files]; !pTex->pName[0]; --pTex ) - --loaded_files; - if ( loaded_files < (signed int)this->uNumLoadedFiles ) - { - ++loaded_files; - this->uNumLoadedFiles = loaded_files; - } - -} - -//----- (0046249B) -------------------------------------------------------- -LODFile_Sprites::~LODFile_Sprites() -{ - if ( this->pHardwareSprites ) - { - for ( int i = 0; i < this->uNumLoadedSprites; ++i ) - { - this->pSpriteHeaders[i].Release(); - this->pHardwareSprites[i].Release(); - } - } - else - { - for ( int i = 0; i < this->uNumLoadedSprites; ++i ) - this->pSpriteHeaders[i].Release(); - } - //_eh_vector_destructor_iterator_(v1->pSpriteHeaders, 40, 1500, LODSprite::dtor); - //LOD::File::vdtor((LOD::File *)v1); -} -// 4CC2B4: using guessed type int __stdcall _eh vector destructor iterator_(int, int, int, int); - -//----- (00462463) -------------------------------------------------------- -LODSprite::~LODSprite() -{ - if ( !(HIBYTE(this->word_1A) & 4) ) - { - free(pDecompressedBytes); - free(pSpriteLines); - } - pDecompressedBytes = nullptr; - pSpriteLines = nullptr; -} - -//----- (004623E5) -------------------------------------------------------- -LODFile_Sprites::LODFile_Sprites(): - LOD::File() -{ - /*_eh_vector_constructor_iterator_( - v1->pSpriteHeaders, - 40, - 1500, - (void ( *)(void *))LODSprite::LODSprite, - (void ( *)(void *))LODSprite::dtor);*/ - field_ECA4 = 0; - field_ECA0 = 0; - pHardwareSprites = 0; - //can_load_hardware_sprites = 0; - field_ECB4 = 0; - uNumLoadedSprites = 0; -} - -//----- (00462303) -------------------------------------------------------- -LODFile_IconsBitmaps::~LODFile_IconsBitmaps() -{ - - for ( uint i = 0; i < this->uNumLoadedFiles; i++ ) - { - this->pTextures[i].Release(); - if ( this->pHardwareTextures ) - { - if ( this->pHardwareTextures[i] ) - { - this->pHardwareTextures[i]->Release(); - this->pHardwareTextures[i] = 0; - } - } - if ( this->pHardwareSurfaces ) - { - if ( this->pHardwareSurfaces[i] ) - { - this->pHardwareSurfaces[i]->Release(); - this->pHardwareSurfaces[i] = 0; - } - } - } - free(this->pHardwareSurfaces); - free(this->pHardwareTextures); - free(this->ptr_011BB4); - //LOD::File::vdtor((LOD::File *)v1); -} - -//----- (00462272) -------------------------------------------------------- -LODFile_IconsBitmaps::LODFile_IconsBitmaps(): - LOD::File() -{ - /*v2 = v1->pTextures; - v3 = 1000; - do - { - Texture::Texture(v2); - ++v2; - --v3; - } - while ( v3 );*/ - this->uTexturePacksCount = 0; - this->uNumPrevLoadedFiles = 0; - this->dword_11B84 = 0; - this->dword_11B80 = 0; - this->uNumLoadedFiles = 0; - this->dword_011BA4 = 0; - //this->can_load_hardware_sprites = 0; - this->pHardwareSurfaces = 0; - this->pHardwareTextures = 0; - this->ptr_011BB4 = 0; - this->uTextureRedBits = 0; - this->uTextureGreenBits = 0; - this->uTextureBlueBits = 0; -} - -//----- (004621A7) -------------------------------------------------------- -bool LODWriteableFile::_4621A7()//çàêðûòü è çàãðóçèòü çàïèñûâàåìûé ô-ë(ïðè ñîõðàíåíèè) -{ - CloseWriteFile(); - return LoadFile(pLODName, 0); -} - -//----- (00461FD4) ---LODFile_sub_461FD4---text:004632EA -------------------------------------------------- -int LODWriteableFile::FixDirectoryOffsets() -{ - int total_size; // edi@1 - int temp_offset; // ecx@5 - FILE *tmp_file; // eax@9 - size_t write_size; // edi@12 - int result; - char Filename[256]; // [sp+Ch] [bp-228h]@9 - char NewFilename[256]; // [sp+10Ch] [bp-128h]@15 - int i; - - total_size = 0; - for ( i = 0; i < uNumSubDirs; i++ ) - total_size += pSubIndices[i].uDataSize; - //fix offsets - temp_offset = sizeof(LOD::Directory) * uNumSubDirs; - for ( i = 0; i < uNumSubDirs; i++ ) - { - pSubIndices[i].uOfsetFromSubindicesStart=temp_offset; - temp_offset+=pSubIndices[i].uDataSize; - } - strcpy(Filename, "lod.tmp"); - tmp_file = fopen(Filename, "wb+"); - - if ( tmp_file ) - { - fwrite((const void *)&header, sizeof(LOD::FileHeader), 1, tmp_file); - - LOD::Directory Lindx; - strcpy(Lindx.pFilename, "chapter"); - Lindx.uOfsetFromSubindicesStart = uOffsetToSubIndex; //10h 16 - Lindx.uDataSize = sizeof(LOD::Directory) * uNumSubDirs + total_size; //14h 20 - Lindx.dword_000018 = 0; //18h 24 - Lindx.uNumSubIndices = uNumSubDirs; //1ch 28 - Lindx.word_00001E = 0; // 1Eh 30 - fwrite(&Lindx, sizeof(LOD::Directory), 1, tmp_file); - fwrite(pSubIndices, sizeof(LOD::Directory), uNumSubDirs, tmp_file); - fseek(pOutputFileHandle, 0, 0); - if ( total_size > 0 ) - { - do - { - write_size = uIOBufferSize; - if ( total_size <= (signed int)uIOBufferSize ) - write_size =total_size; - fread(pIOBuffer, 1, write_size, pOutputFileHandle); - fwrite(pIOBuffer, 1, write_size, tmp_file); - total_size -= write_size; - } - while ( total_size > 0 ); - } - strcpy(NewFilename, (const char *)&pLODName); - fclose(tmp_file); - fclose(pOutputFileHandle); - CloseWriteFile(); - remove("lodapp.tmp"); - remove(NewFilename); - rename(Filename, NewFilename); - CloseWriteFile(); - LoadFile( (const char *)&pLODName, 0); - result = 0; - } - else - result = 5; - return result; -} - -//----- (00461F71) -------------------------------------------------------- -bool LOD::File::AppendDirectory(LOD::Directory *pDir, const void *pData) -{ - Assert(uNumSubDirs < 299); - - memcpy(&pSubIndices[uNumSubDirs++], pDir, sizeof(LOD::Directory)); - fwrite(pData, 1, pDir->uDataSize, pOutputFileHandle); - return true; -} - -//----- (00461F1E) -------------------------------------------------------- -int LODWriteableFile::CreateTempFile() -{ - if (!isFileOpened) - return 1; - - if (pIOBuffer && uIOBufferSize ) - { - uCurrentIndexDir = 0; - uNumSubDirs = 0; - pOutputFileHandle = fopen("lodapp.tmp", "wb+"); - return pOutputFileHandle ? 1 : 7; - } - else - return 5; -} - -//----- (00461EE9) -------------------------------------------------------- -void LODWriteableFile::CloseWriteFile() -{ - if (isFileOpened) - { - pContainerName[0] = 0; - uCurrentIndexDir = 0; - _6A0CA8_lod_unused = 0; - - isFileOpened = false; - fflush(pFile); - fclose(pFile); - pFile = nullptr; - } - //else - //__debugbreak(); -} -// 6A0CA8: using guessed type int 6A0CA8_lod_unused; - - -//----- (00461B48) -------------------------------------------------------- -unsigned int LODWriteableFile::Write(const LOD::Directory *pDir, const void *pDirData, int a4) -{ - char Filename[256]; - char NewFilename[256]; - FILE *tmp_file; - int comp_res; - bool bRewrite_data; - int offset_to_data; - int total_data_size; - int size_correction; - int to_copy_size; - int read_size; - int curr_position; - int insert_index; - - //insert new data in sorted index lod file - bRewrite_data = false; - insert_index = -1; - if ( !isFileOpened )//sometimes gives crash - return 1; - if ( !pSubIndices ) - return 2; - if ( !pIOBuffer || !uIOBufferSize ) - return 3; - - for ( int i = 0; i < uNumSubDirs; i++ ) - { - comp_res = _stricmp(pSubIndices[i].pFilename, pDir->pFilename); - if( comp_res == 0 ) - { - insert_index = i; - if ( a4 == 0 ) - { - bRewrite_data = true; - break; - } - if ( a4 == 1 ) - { - if ( pSubIndices[i].uNumSubIndices < pDir->uNumSubIndices ) - { - if ( pSubIndices[i].word_00001E < pDir->word_00001E ) - return 4; - } - else - bRewrite_data = true; - break; - } - if ( a4 == 2 ) - return 4; - } - else if ( comp_res > 0 ) - { - if ( insert_index == -1 ) - { - insert_index=i; - break; - } - } - } - strcpy(Filename, "lod.tmp"); - tmp_file = fopen(Filename, "wb+"); - if ( !tmp_file ) - return 5; - if (!bRewrite_data) - size_correction = 0; - else - size_correction = pSubIndices[insert_index].uDataSize; - - //create chapter index - LOD::Directory Lindx; - strcpy(Lindx.pFilename, "chapter"); - Lindx.dword_000018 = 0; - Lindx.word_00001E = 0; - Lindx.uNumSubIndices = uNumSubDirs; - Lindx.uOfsetFromSubindicesStart = sizeof(LOD::FileHeader) + sizeof(LOD::Directory); - total_data_size = uLODDataSize + pDir->uDataSize-size_correction; - if (!bRewrite_data) - { - total_data_size += sizeof(LOD::Directory); - Lindx.uNumSubIndices++; - } - - Lindx.uDataSize = total_data_size; - uNumSubDirs = Lindx.uNumSubIndices; - //move indexes +1 after insert point - if ( !bRewrite_data && (insert_index < uNumSubDirs) )//ïåðåçàïèñûâàíèå ôàéëîâ äëÿ îñâîáîæäåíèÿ ìåñòà äëÿ íîâîãî ô-ëà - { - for( int i = uNumSubDirs; i > insert_index; --i ) - memcpy(&pSubIndices[i], &pSubIndices[i - 1], sizeof(LOD::Directory)); //Uninitialized memory access - } - //insert - memcpy(&pSubIndices[insert_index], pDir, sizeof(LOD::Directory));//çàïèñàòü òåêóùèé ôàéë - //correct offsets to data - if (uNumSubDirs > 0) - { - offset_to_data = sizeof(LOD::Directory) * uNumSubDirs; - for ( int i = 0; i < uNumSubDirs; i++ ) - { - pSubIndices[i].uOfsetFromSubindicesStart = offset_to_data; - offset_to_data += pSubIndices[i].uDataSize; - } - } - - //construct lod file with added data - fwrite(&header, sizeof(LOD::FileHeader), 1, tmp_file); - fwrite(&Lindx, sizeof(LOD::Directory), 1, tmp_file); - fseek(pFile,Lindx.uOfsetFromSubindicesStart, SEEK_SET); - fwrite(pSubIndices, sizeof(LOD::Directory), uNumSubDirs, tmp_file); - - offset_to_data = sizeof(LOD::Directory) * uNumSubDirs; - if ( !bRewrite_data ) - offset_to_data -= sizeof(LOD::Directory); - - fseek(pFile, offset_to_data, SEEK_CUR); - //copy from open lod to temp lod first half - to_copy_size = pSubIndices[insert_index].uOfsetFromSubindicesStart - pSubIndices[0].uOfsetFromSubindicesStart; - while(to_copy_size > 0) - { - read_size = uIOBufferSize; - if ( to_copy_size <= uIOBufferSize ) - read_size = to_copy_size; - fread(pIOBuffer, 1, read_size, pFile); - fwrite(pIOBuffer, 1, read_size, tmp_file); - to_copy_size -= read_size; - } - // add container data - fwrite(pDirData, 1, pDir->uDataSize, tmp_file);// Uninitialized memory access(tmp_file) - if ( bRewrite_data ) - fseek(pFile,size_correction , SEEK_CUR); - - //add remainng data last half - curr_position = ftell(pFile); - fseek(pFile, 0, SEEK_END); - to_copy_size = ftell(pFile) - curr_position; - fseek(pFile, curr_position, SEEK_SET); - while ( to_copy_size > 0 ) - { - read_size = uIOBufferSize; - if ( to_copy_size <= uIOBufferSize ) - read_size = to_copy_size; - fread(pIOBuffer, 1, read_size, pFile); - fwrite(pIOBuffer, 1, read_size, tmp_file); - to_copy_size -= read_size; - } - //replace old file by new with added data - strcpy(NewFilename, (const char *)&pLODName); - fclose(tmp_file); - fclose(pFile); - CloseWriteFile(); - remove(NewFilename); - rename(Filename, NewFilename); - CloseWriteFile(); - //reload new - LoadFile((const char *)&pLODName, 0);//isFileOpened == true, next file - return 0; -} - -//----- (00461A43) -------------------------------------------------------- -bool LODWriteableFile::LoadFile(const char *pFilename, bool bWriting) -{ - if (bWriting & 1) - pFile = fopen(pFilename, "rb"); - else - pFile = fopen(pFilename, "rb+"); - if (!pFile) - { - __debugbreak(); - return false;// âîçìîæíî ôàéë íå çàêðûò, ïîýòîìó íå îòêðûâàåòñÿ - } - - strcpy(pLODName, pFilename); - fread(&header, sizeof(LOD::FileHeader), 1, pFile); - - LOD::Directory lod_indx; - fread( &lod_indx,sizeof(LOD::Directory), 1, pFile); - - fseek(pFile, 0, SEEK_SET); - isFileOpened = true; - strcpy(pContainerName, "chapter"); - uCurrentIndexDir = 0; - uLODDataSize = lod_indx.uDataSize; - uNumSubDirs = lod_indx.uNumSubIndices; - Assert(uNumSubDirs <= 300); - - uOffsetToSubIndex = lod_indx.uOfsetFromSubindicesStart; - fseek(pFile, uOffsetToSubIndex, SEEK_SET); - - fread(pSubIndices, sizeof(LOD::Directory), uNumSubDirs, pFile); - return true; -} - -//----- (00461A11) -------------------------------------------------------- -void LOD::File::FreeSubIndexAndIO() -{ - free(pSubIndices); - free(pIOBuffer);// delete [] pIOBuffer; - pIOBuffer = nullptr; - pSubIndices = nullptr; -} - -//----- (00461954) -------------------------------------------------------- -void LOD::File::AllocSubIndicesAndIO(unsigned int uNumSubIndices, unsigned int uBufferSize) -{ - if (pSubIndices) - { - MessageBoxA(0, "Attempt to reset a LOD subindex!", "MM6", MB_ICONEXCLAMATION); - free(pSubIndices); - pSubIndices = nullptr; - } - pSubIndices =(LOD::Directory *)malloc(32 * uNumSubIndices); - if (pIOBuffer) - { - MessageBoxA(0, "Attempt to reset a LOD IObuffer!", "MM6", MB_ICONEXCLAMATION); - free(pIOBuffer); - pIOBuffer = nullptr; - uIOBufferSize = 0; - } - if ( uBufferSize ) - { - pIOBuffer = (unsigned __int8 *)malloc(uBufferSize); - uIOBufferSize = uBufferSize; - } -} - -//----- (0046188A) -------------------------------------------------------- -int LOD::File::LoadSubIndices(const char *pContainer) -{ - unsigned int uDir; // edi@1 - LOD::Directory *curr_index; // eax@7 - - ResetSubIndices(); - uDir = 0; - - for (uDir=0; uDir uOfsetFromSubindicesStart ; - uNumSubDirs = curr_index->uNumSubIndices;// *(_WORD *)(v8 + 28); - fseek( pFile, uOffsetToSubIndex, SEEK_SET); - pSubIndices = (LOD::Directory *)malloc(sizeof(LOD::Directory)*(uNumSubDirs + 5)); - - if ( pSubIndices) - fread( pSubIndices, sizeof(LOD::Directory), uNumSubDirs, pFile); - return 0; - } - } - return 3; -} - -//----- (004617D5) -------------------------------------------------------- -bool LOD::File::LoadHeader(const char *pFilename, bool bWriting) -{ - const char *v6; // [sp-4h] [bp-Ch]@4 - - if ( this->isFileOpened ) - Close(); - if ( bWriting & 1 ) - v6 = "rb"; - else - v6 = "rb+"; - - pFile = fopen(pFilename, v6); - if ( pFile ) - { - strcpy(pLODName, pFilename); - fread(&header, sizeof(LOD::FileHeader), 1, pFile); - pRoot = (LOD::Directory *)malloc(160); - if ( pRoot ) - { - fread(pRoot, sizeof(LOD::Directory), header.uNumIndices, pFile); - fseek(pFile, 0, SEEK_SET); - isFileOpened = true; - return false; - } - else - { - fclose(pFile); - return true; - } - } - return true; -} - -//----- (00461790) -------------------------------------------------------- -LOD::File::~File() -{ - if ( this->isFileOpened ) - { - fclose(this->pFile); - free(this->pSubIndices); - } -} - -//----- (0046175B) -------------------------------------------------------- -LOD::File::File(): - pRoot(nullptr), - isFileOpened(false) -{ - memset(pLODName, 0, 256); - memset(pContainerName, 0, 16); - this->pFile = nullptr; - this->pSubIndices = nullptr; - this->pIOBuffer = nullptr; - this->isFileOpened = false; - this->uIOBufferSize = 0; - Close(); -} - -//----- (0046172B) -------------------------------------------------------- -LOD::Directory::Directory() -{ - memset(pFilename, 0, 16); - this->pFilename[0] = 0; - this->uOfsetFromSubindicesStart = 0; - this->uDataSize = 0; - this->uNumSubIndices = 0; - this->dword_000018 = 0; - this->word_00001E = 0; -} - -//----- (0046165E) -------------------------------------------------------- -int LOD::File::CalcIndexFast(int startIndex, int maxIndex, const char *pContainerName) -{ - int pCurrent_position; // esi@1 - int v5; // ebx@2 - int result; // eax@2 - - pCurrent_position = startIndex; - while ( 1 ) // binary search in LOD indices - { - - while ( 1 ) - { - v5 = maxIndex - pCurrent_position; - result = _stricmp(pContainerName, (const char *)(&this->pSubIndices[(maxIndex - pCurrent_position) / 2] + pCurrent_position)); - if ( !_stricmp(pContainerName, (const char *)(&this->pSubIndices[(maxIndex - pCurrent_position) / 2] + pCurrent_position)) ) - _6A0CA4_lod_binary_search = (maxIndex - pCurrent_position) / 2 + pCurrent_position; - if ( pCurrent_position == maxIndex ) - { - _6A0CA4_lod_binary_search = -1; - return result; - } - if ( result < 0 )//ïåðâàÿ ñòðîêà ìåíüøå âòîðîé - break; - if ( v5 <= 4 ) - { - for ( int i = pCurrent_position; i < maxIndex; ++i ) - { - result = _stricmp(pContainerName, this->pSubIndices[i].pFilename); - if ( !_stricmp(pContainerName, this->pSubIndices[i].pFilename) ) - { - _6A0CA4_lod_binary_search = i; - return 0;//ñòðîêè ðîâíû - } - } - _6A0CA4_lod_binary_search = -1; - return result; - } - pCurrent_position += (maxIndex - pCurrent_position) / 2; - } - - if ( v5 <= 4 ) - break; - maxIndex = (maxIndex - pCurrent_position) / 2 + pCurrent_position; - } - - for (int i = pCurrent_position; i < maxIndex; ++i) - { - result = _stricmp(pContainerName, this->pSubIndices[i].pFilename); - if ( !_stricmp(pContainerName, this->pSubIndices[i].pFilename) ) - { - _6A0CA4_lod_binary_search = i; - return 0; - } - } - _6A0CA4_lod_binary_search = -1; - return result; -} -// 6A0CA4: using guessed type int _6A0CA4_lod_binary_search; - -//----- (0046161C) -------------------------------------------------------- -bool LOD::File::DoesContainerExist(const char *pContainer) -{ - for ( int i = 0; i < (signed int)this->uNumSubDirs; ++i ) - { - if ( !_stricmp(pContainer, this->pSubIndices[i].pFilename) ) - return 1; - } - return 0; -} - -//----- (00461397) -------------------------------------------------------- -int LODFile_Sprites::_461397() -{ - this->field_ECA8 = this->uNumLoadedSprites; - if ( this->uNumLoadedSprites < this->field_ECA0 ) - this->field_ECA8 = this->field_ECA0; - if ( this->field_ECA0 < this->field_ECA4 ) - field_ECA0 = this->field_ECA4; - return this->uNumLoadedSprites; -} - -//----- (00461580) -------------------------------------------------------- -FILE *LOD::File::FindContainer(const char *pContainer_Name, bool bLinearSearch) -{ - if (!isFileOpened) - return 0; - - if (bLinearSearch) - { - for (uint i = 0; i < uNumSubDirs; ++i) - if (!_stricmp(pContainer_Name, pSubIndices[i].pFilename)) - { - fseek(pFile, uOffsetToSubIndex + pSubIndices[i].uOfsetFromSubindicesStart, SEEK_SET); - return pFile; - } - return nullptr; - } - else - { - CalcIndexFast(0, uNumSubDirs, pContainer_Name); - if ( _6A0CA4_lod_binary_search < 0 ) - return 0; - fseek(pFile, uOffsetToSubIndex + pSubIndices[_6A0CA4_lod_binary_search].uOfsetFromSubindicesStart, SEEK_SET); - return pFile; - } -} - -//----- (0041097D) -------------------------------------------------------- -void LODFile_IconsBitmaps::SetupPalettes(unsigned int uTargetRBits, unsigned int uTargetGBits, unsigned int uTargetBBits) -{ - FILE *File; // [sp+50h] [bp-4h]@7 - - if ( this->uTextureRedBits != uTargetRBits - || this->uTextureGreenBits != uTargetGBits - || this->uTextureBlueBits != uTargetBBits ) //Uninitialized memory access - { - this->uTextureRedBits = uTargetRBits; - this->uTextureGreenBits = uTargetGBits; - this->uTextureBlueBits = uTargetBBits; - for ( uint i = 0; i < this->uNumLoadedFiles; ++i ) - { - Texture DstBuf; // [sp+4h] [bp-50h]@6 - //Texture::Texture(&DstBuf); - if ( this->pTextures[i].pPalette16 ) - { - File = FindContainer((const char *)this->pTextures[i].pName, 0); - if ( File ) - { - fread(&DstBuf, 1, 0x30u, File); - fseek(File, DstBuf.uTextureSize, 1); - for ( uint j = 0; j < 256; ++j ) - { - fread((char *)&uTargetRBits + 3, 1, 1, File); - fread((char *)&uTargetGBits + 3, 1, 1, File); - fread((char *)&uTargetBBits + 3, 1, 1, File); - this->pTextures[i].pPalette16[j] = (BYTE3(uTargetRBits) >> (8 - LOBYTE(this->uTextureRedBits))) - << (LOBYTE(this->uTextureGreenBits) + LOBYTE(this->uTextureBlueBits)); - this->pTextures[i].pPalette16[j] |= (BYTE3(uTargetGBits) >> (8 - LOBYTE(this->uTextureGreenBits))) - << this->uTextureBlueBits; - this->pTextures[i].pPalette16[j] |= BYTE3(uTargetBBits) >> (8 - LOBYTE(this->uTextureBlueBits)); - } - } - } - } - } -} - -//----- (0041088B) -------------------------------------------------------- -void *LOD::File::LoadRaw(const char *pContainer, int a3) -{ - FILE *File; // eax@1 - void *v7; // ebx@7 - void *v8; // edi@7 - Texture DstBuf; // [sp+Ch] [bp-4Ch]@1 - - File = FindContainer(pContainer, 0); - if ( !File ) - Error("Unable to load %s", pContainer); - - fread(&DstBuf, 1, 0x30u, File); - if ( DstBuf.uDecompressedSize ) - { - if ( a3 ) - v7 = malloc(DstBuf.uDecompressedSize+1); - else - v7 = malloc(DstBuf.uDecompressedSize+1); - v8 = malloc(DstBuf.uTextureSize+1); - fread(v8, 1, DstBuf.uTextureSize, File); - zlib::MemUnzip(v7, &DstBuf.uDecompressedSize, v8, DstBuf.uTextureSize); - DstBuf.uTextureSize = DstBuf.uDecompressedSize; - free(v8); - } - else - { - if ( a3 ) - v7 = malloc(DstBuf.uTextureSize+1); - else - v7 = malloc(DstBuf.uTextureSize+1); - fread(v7, 1, DstBuf.uTextureSize, File); - } - return v7; -} - -//----- (00410522) -------------------------------------------------------- -int LODFile_IconsBitmaps::_410522(Texture *pDst, const char *pContainer, unsigned int uTextureType) -{ - void *v9; // ST2C_4@6 - int v15; // ecx@12 - int v16; // ecx@12 - int v17; // eax@12 - signed int v21; // ecx@18 - signed int v22; // ecx@23 - FILE *File; // [sp+68h] [bp-4h]@1 - unsigned int uTargetRBits; - unsigned int uTargetGBits; - unsigned int uTargetBBits; - - File = FindContainer(pContainer, 0); - if ( !File ) - { - File = FindContainer("pending", 0); - if ( !File ) - Error("Can't find %s!", pContainer); - } - - fread(pDst, 1, 0x30u, File); - strcpy(pDst->pName, pContainer); - pDst->pLevelOfDetail0_prolly_alpha_mask = 0; - if ( pDst->uDecompressedSize ) - { - pDst->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(pDst->uDecompressedSize); - v9 = malloc(pDst->uTextureSize); - fread((void *)v9, 1, (size_t)pDst->uTextureSize, File); - zlib::MemUnzip(pDst->pLevelOfDetail0_prolly_alpha_mask, &pDst->uDecompressedSize, v9, pDst->uTextureSize); - pDst->uTextureSize = pDst->uDecompressedSize; - free(v9); - } - else - { - pDst->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(0); - fread(pDst->pLevelOfDetail0_prolly_alpha_mask, 1, (size_t)pDst->uTextureSize, File); - } - pDst->pPalette16 = 0; - pDst->pPalette24 = 0; - if ( uTextureType == 1 ) - { - pDst->pPalette24 = (unsigned __int8 *)malloc(0x300u); - fread(pDst->pPalette24, 1, 0x300u, File); - } - else if ( uTextureType == 2 ) - { - pDst->pPalette16 = (unsigned __int16 *)malloc(0x400u); - for ( uint i = 0; i < 256; ++i ) - { - fread((char *)&uTargetRBits + 3, 1, 1, File); - fread((char *)&uTargetGBits + 3, 1, 1, File); - fread((char *)&uTargetBBits + 3, 1, 1, File); - pDst->pPalette16[i] = (unsigned __int8)(BYTE3(uTargetRBits) >> (8 - LOBYTE(this->uTextureRedBits))) - << (LOBYTE(this->uTextureBlueBits) + LOBYTE(this->uTextureGreenBits)); - pDst->pPalette16[i] += (unsigned __int8)(BYTE3(uTargetGBits) >> (8 - LOBYTE(this->uTextureGreenBits))) - << this->uTextureBlueBits; - pDst->pPalette16[i] += (unsigned __int8)(BYTE3(uTargetBBits) >> (8 - LOBYTE(this->uTextureBlueBits))); - } - } - - if ( pDst->pBits & 2 ) - { - v15 = (int)&pDst->pLevelOfDetail0_prolly_alpha_mask[pDst->uSizeOfMaxLevelOfDetail]; - pDst->pLevelOfDetail1 = (unsigned __int8 *)v15; - v16 = (pDst->uSizeOfMaxLevelOfDetail >> 2) + v15; - pDst->pLevelOfDetail2 = (unsigned __int8 *)v16; - v17 = v16 + (pDst->uSizeOfMaxLevelOfDetail >> 4); - } - else - { - v17 = 0; - pDst->pLevelOfDetail2 = 0; - pDst->pLevelOfDetail1 = 0; - } - pDst->pLevelOfDetail3 = (unsigned __int8 *)v17; - v21 = 1; - while ( 1 << v21 != pDst->uTextureWidth ) - { - ++v21; - if ( v21 >= 15 ) - goto LABEL_23; - } - pDst->uWidthLn2 = v21; -LABEL_23: - v22 = 1; - while ( 1 << v22 != pDst->uTextureHeight ) - { - ++v22; - if ( v22 >= 15 ) - goto LABEL_28; - } - pDst->uHeightLn2 = v22; -LABEL_28: - switch ( pDst->uWidthLn2 ) - { - case 2: - pDst->uWidthMinus1 = 3; - break; - case 3: - pDst->uWidthMinus1 = 7; - break; - case 4: - pDst->uWidthMinus1 = 15; - break; - case 5: - pDst->uWidthMinus1 = 31; - break; - case 6: - pDst->uWidthMinus1 = 63; - break; - case 7: - pDst->uWidthMinus1 = 127; - break; - case 8: - pDst->uWidthMinus1 = 255; - break; - case 9: - pDst->uWidthMinus1 = 511; - break; - case 10: - pDst->uWidthMinus1 = 1023; - break; - case 11: - pDst->uWidthMinus1 = 2047; - break; - case 12: - pDst->uWidthMinus1 = 4095; - break; - default: - break; - } - switch ( pDst->uHeightLn2 ) - { - case 2: - pDst->uHeightMinus1 = 3; - break; - case 3: - pDst->uHeightMinus1 = 7; - break; - case 4: - pDst->uHeightMinus1 = 15; - break; - case 5: - pDst->uHeightMinus1 = 31; - break; - case 6: - pDst->uHeightMinus1 = 63; - break; - case 7: - pDst->uHeightMinus1 = 127; - break; - case 8: - pDst->uHeightMinus1 = 255; - break; - case 9: - pDst->uHeightMinus1 = 511; - break; - case 10: - pDst->uHeightMinus1 = 1023; - break; - case 11: - pDst->uHeightMinus1 = 2047; - break; - case 12: - pDst->uHeightMinus1 = 4095; - break; - default: - return 1; - } - return 1; -} - -//----- (00410423) -------------------------------------------------------- -void LODFile_IconsBitmaps::_410423_move_textures_to_device() -{ - size_t v4; // eax@9 - char *v5; // ST1C_4@9 - - for ( uint i = 0; i < this->uNumLoadedFiles; i++ ) - { - if ( this->ptr_011BB4[i] ) - { - if ( this->pTextures[i].pName[0] != 'w' || this->pTextures[i].pName[1] != 't' - || this->pTextures[i].pName[2] != 'r' || this->pTextures[i].pName[3] != 'd' || this->pTextures[i].pName[4] != 'r' ) - pRenderer->LoadTexture(&this->pTextures[i].pName[0], this->pTextures[i].uTextureSize, (IDirectDrawSurface4 **)&this->pHardwareSurfaces[i], - &this->pHardwareTextures[i]); - else - { - v4 = strlen(&this->pTextures[i].pName[0]); - v5 = (char *)malloc(v4 + 2); - *v5 = 'h'; - strcpy(v5 + 1, &this->pTextures[i].pName[0]); - pRenderer->LoadTexture(v5, this->pTextures[i].uTextureSize, (IDirectDrawSurface4 **)&this->pHardwareSurfaces[i], &this->pHardwareTextures[i]); - free(v5); - } - } - } - if ( this->ptr_011BB4 ) - { - if ( this->uNumLoadedFiles > 1 ) - memset(this->ptr_011BB4, 0, this->uNumLoadedFiles - 1); - } -} - -//----- (004103BB) -------------------------------------------------------- -void LODFile_IconsBitmaps::ReleaseHardwareTextures() -{ - for ( uint i = 0; i < this->uNumLoadedFiles; i++ ) - { - if ( this->pHardwareTextures ) - { - if ( this->pHardwareTextures[i] ) - { - this->pHardwareTextures[i]->Release(); - this->pHardwareTextures[i] = 0; - this->ptr_011BB4[i] = 1; - } - } - if ( this->pHardwareSurfaces ) - { - if ( this->pHardwareSurfaces[i] ) - { - this->pHardwareSurfaces[i]->Release(); - this->pHardwareSurfaces[i] = 0; - this->ptr_011BB4[i] = 1; - } - } - } -} - -//----- (0041033D) -------------------------------------------------------- -void LODFile_IconsBitmaps::ReleaseLostHardwareTextures() -{ - for ( uint i = 0; i < this->uNumLoadedFiles; ++i ) - { - if ( this->pHardwareSurfaces ) - { - if ( this->pHardwareSurfaces[i] ) - { - if ( this->pHardwareSurfaces[i]->IsLost() == DDERR_SURFACELOST ) - { - if ( this->pHardwareTextures ) - { - if ( this->pHardwareTextures[i] ) - { - this->pHardwareTextures[i]->Release(); - this->pHardwareTextures[i] = 0; - } - } - this->pHardwareSurfaces[i]->Release(); - this->pHardwareSurfaces[i] = 0; - this->ptr_011BB4[i] = 1; - } - } - } - } -} - -//----- (004101B1) -------------------------------------------------------- -int LODFile_IconsBitmaps::ReloadTexture(Texture *pDst, const char *pContainer, int mode) -{ - Texture *v6; // esi@2 - unsigned int v7; // ebx@6 - unsigned int v8; // ecx@6 - signed int result; // eax@7 - FILE *File; // [sp+Ch] [bp-8h]@1 - unsigned __int8 v15; // [sp+11h] [bp-3h]@13 - unsigned __int8 v16; // [sp+12h] [bp-2h]@13 - unsigned __int8 DstBuf; // [sp+13h] [bp-1h]@13 - void *DstBufa; // [sp+1Ch] [bp+8h]@10 - void *Sourcea; // [sp+20h] [bp+Ch]@10 - - File = FindContainer(pContainer, 0); - v6 = pDst; - if ( File && pDst->pLevelOfDetail0_prolly_alpha_mask - && mode == 2 - && pDst->pPalette16 && !pDst->pPalette24 - && (v7 = pDst->uTextureSize, - fread(pDst, 1, 0x30u, File), - strcpy(pDst->pName, pContainer), - v8 = pDst->uTextureSize, - (signed int)v8 <= (signed int)v7) ) - { - if ( !pDst->uDecompressedSize || this->dword_011BA4 ) - { - fread(pDst->pLevelOfDetail0_prolly_alpha_mask, 1, pDst->uTextureSize, File); - } - else - { - Sourcea = malloc(pDst->uDecompressedSize); - DstBufa = malloc(pDst->uTextureSize); - fread(DstBufa, 1, pDst->uTextureSize, File); - zlib::MemUnzip(Sourcea, &v6->uDecompressedSize, DstBufa, v6->uTextureSize); - v6->uTextureSize = pDst->uDecompressedSize; - free(DstBufa); - memcpy(v6->pLevelOfDetail0_prolly_alpha_mask, Sourcea, pDst->uDecompressedSize); - free(Sourcea); - } - for( uint i = 0; i < 256; ++i ) - { - fread(&DstBuf, 1, 1, File); - fread(&v16, 1, 1, File); - fread(&v15, 1, 1, File); - v6->pPalette16[i] = (unsigned __int8)(DstBuf >> (8 - LOBYTE(this->uTextureRedBits))) - << (LOBYTE(this->uTextureBlueBits) + LOBYTE(this->uTextureGreenBits)); - v6->pPalette16[i] += (unsigned __int8)(v16 >> (8 - LOBYTE(this->uTextureGreenBits))) - << this->uTextureBlueBits; - v6->pPalette16[i] += (unsigned __int8)(v15 >> (8 - LOBYTE(this->uTextureBlueBits))); - } - result = 1; - } - else - result = -1; - return result; -} - -//----- (0040FC08) -------------------------------------------------------- -int LODFile_IconsBitmaps::LoadTextureFromLOD(Texture *pOutTex, const char *pContainer, enum TEXTURE_TYPE eTextureType) -{ - Texture *v8; // esi@3 - enum TEXTURE_TYPE v12; // eax@14 - signed int result; // esi@14 - unsigned int v14; // eax@21 - void *v19; // ST3C_4@27 - size_t v22; // ST2C_4@29 - const void *v23; // ecx@29 - void *v30; // eax@30 - signed int v41; // ecx@43 - signed int v42; // ecx@48 - - FILE* pFile = FindContainer(pContainer, false); - if (!pFile) - return -1; - v8 = pOutTex; - fread(pOutTex, 1, 0x30, pFile); - strcpy(pOutTex->pName, pContainer); - if (/*pRenderer->pRenderD3D &&*/ (pOutTex->pBits & 2) && strcmp(v8->pName, "sptext01"))//Ritor1: "&& strcmp(v8->pName, "sptext01")" - temporarily for red_aura - { - if (!pHardwareSurfaces || !pHardwareTextures) - { - pHardwareSurfaces = new IDirectDrawSurface *[1000]; - memset(pHardwareSurfaces, 0, 1000 * sizeof(IDirectDrawSurface4 *)); - - pHardwareTextures = new IDirect3DTexture2 *[1000]; - memset(pHardwareTextures, 0, 1000 * sizeof(IDirect3DTexture2 *)); - - ptr_011BB4 = new char[1000]; - memset(ptr_011BB4, 0, 1000); - } - if (_strnicmp(pContainer, "wtrdr", 5)) - { - if (_strnicmp(pContainer, "WtrTyl", 6)) - v14 = uNumLoadedFiles; - else - { - pRenderer->hd_water_tile_id = uNumLoadedFiles; - v14 = uNumLoadedFiles; - } - result = pRenderer->LoadTexture(pContainer, pOutTex->palette_id1, (IDirectDrawSurface4 **)&pHardwareSurfaces[v14], &pHardwareTextures[v14]); - } - else - { - char *temp_container; - temp_container = (char *)malloc(strlen(pContainer) + 2); - *temp_container = 104;//'h' - strcpy(temp_container + 1, pContainer); - result = pRenderer->LoadTexture((const char *)temp_container, pOutTex->palette_id1, - (IDirectDrawSurface4 **)&pHardwareSurfaces[uNumLoadedFiles], &pHardwareTextures[uNumLoadedFiles]); - free((void *)temp_container); - } - return result; - } - if ( !v8->uDecompressedSize || dword_011BA4 ) - { - v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(v8->uTextureSize); - fread(v8->pLevelOfDetail0_prolly_alpha_mask, 1, (size_t)v8->uTextureSize, pFile); - } - else - { - pContainer = (const char *)malloc(v8->uDecompressedSize); - v19 = malloc(v8->uTextureSize); - fread(v19, 1, (size_t)v8->uTextureSize, pFile); - zlib::MemUnzip((void *)pContainer, &v8->uDecompressedSize, v19, v8->uTextureSize); - v8->uTextureSize = v8->uDecompressedSize; - free(v19); - if ( /*bUseLoResSprites*/false && v8->pBits & 2 ) - { - pOutTex = (Texture *)(((signed int)v8->uSizeOfMaxLevelOfDetail >> 2) - + ((signed int)v8->uSizeOfMaxLevelOfDetail >> 4) - + ((signed int)v8->uSizeOfMaxLevelOfDetail >> 6)); - v22 = (size_t)pOutTex; - v23 = &pContainer[v8->uTextureWidth * v8->uTextureHeight]; - v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc((unsigned int)pOutTex); - memcpy(v8->pLevelOfDetail0_prolly_alpha_mask, v23, v22); - v8->uTextureWidth = (signed __int16)v8->uTextureWidth / 2; - v8->uTextureHeight = (signed __int16)v8->uTextureHeight / 2; - --v8->uWidthLn2; - --v8->uHeightLn2; - v8->uWidthMinus1 = v8->uTextureWidth - 1; - v8->uHeightMinus1 = v8->uTextureHeight - 1; - v8->uSizeOfMaxLevelOfDetail = (signed __int16)v8->uTextureWidth * (signed __int16)v8->uTextureHeight; - v8->uTextureSize = (unsigned int)pOutTex; - } - else - { - v8->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *)malloc(v8->uDecompressedSize); - memcpy(v8->pLevelOfDetail0_prolly_alpha_mask, pContainer, v8->uDecompressedSize); - } - free((void *)pContainer); - } - - free(v8->pPalette16); - v8->pPalette16 = NULL; - - free(v8->pPalette24); - v8->pPalette24 = NULL; - - if ( eTextureType == TEXTURE_24BIT_PALETTE ) - { - v8->pPalette24 = (unsigned __int8 *)malloc(0x300); - fread(v8->pPalette24, 1, 0x300, pFile); - } - else - { - if ( eTextureType == TEXTURE_16BIT_PALETTE ) - { - v8->pPalette16 = (unsigned __int16 *)malloc(0x200); - for ( uint i = 0; i < 256; ++i ) - { - fread((char *)&eTextureType + 3, 1, 1, pFile); - fread((char *)&pContainer + 3, 1, 1, pFile); - fread((char *)&pOutTex + 3, 1, 1, pFile); - v8->pPalette16[i] = (unsigned __int8)(BYTE3(eTextureType) >> (8 - LOBYTE(this->uTextureRedBits))) //Uninitialized memory access - << (LOBYTE(this->uTextureBlueBits) + LOBYTE(this->uTextureGreenBits)); - v8->pPalette16[i] += (unsigned __int8)(BYTE3(pContainer) >> (8 - LOBYTE(this->uTextureGreenBits))) - << this->uTextureBlueBits; - v8->pPalette16[i] += (unsigned __int8)(BYTE3(pOutTex) >> (8 - LOBYTE(this->uTextureBlueBits))); - } - } - } - - if ( v8->pBits & 2 ) - { - v8->pLevelOfDetail1 = &v8->pLevelOfDetail0_prolly_alpha_mask[v8->uSizeOfMaxLevelOfDetail]; - v8->pLevelOfDetail2 = &v8->pLevelOfDetail1[v8->uSizeOfMaxLevelOfDetail >> 2]; - v8->pLevelOfDetail3 = &v8->pLevelOfDetail2[v8->uSizeOfMaxLevelOfDetail >> 4]; - } - else - { - v8->pLevelOfDetail1 = 0; - v8->pLevelOfDetail2 = 0; - v8->pLevelOfDetail3 = 0; - } - for ( v41 = 1; v41 < 15; ++v41 ) - { - if ( 1 << v41 == v8->uTextureWidth ) - v8->uWidthLn2 = v41; - } - for ( v42 = 1; v42 < 15; ++v42 ) - { - if ( 1 << v42 == v8->uTextureHeight ) - v8->uHeightLn2 = v42; - } - - switch ( v8->uWidthLn2 ) - { - case 2: - v8->uWidthMinus1 = 3; - break; - case 3: - v8->uWidthMinus1 = 7; - break; - case 4: - v8->uWidthMinus1 = 15; - break; - case 5: - v8->uWidthMinus1 = 31; - break; - case 6: - v8->uWidthMinus1 = 63; - break; - case 7: - v8->uWidthMinus1 = 127; - break; - case 8: - v8->uWidthMinus1 = 255; - break; - case 9: - v8->uWidthMinus1 = 511; - break; - case 10: - v8->uWidthMinus1 = 1023; - break; - case 11: - v8->uWidthMinus1 = 2047; - break; - case 12: - v8->uWidthMinus1 = 4095; - break; - default: - break; - } - switch ( v8->uHeightLn2 ) - { - case 2: - v8->uHeightMinus1 = 3; - break; - case 3: - v8->uHeightMinus1 = 7; - break; - case 4: - v8->uHeightMinus1 = 15; - break; - case 5: - v8->uHeightMinus1 = 31; - break; - case 6: - v8->uHeightMinus1 = 63; - break; - case 7: - v8->uHeightMinus1 = 127; - break; - case 8: - v8->uHeightMinus1 = 255; - break; - case 9: - v8->uHeightMinus1 = 511; - break; - case 10: - v8->uHeightMinus1 = 1023; - break; - case 11: - v8->uHeightMinus1 = 2047; - break; - case 12: - v8->uHeightMinus1 = 4095; - break; - default: - return 1; - } - return 1; -} - -Texture *LODFile_IconsBitmaps::LoadTexturePtr(const char *pContainer, enum TEXTURE_TYPE uTextureType) -{ - uint id = LoadTexture(pContainer, uTextureType); - - Assert(id != -1 && L"Texture not found"); - - return &pTextures[id]; -} - -//----- (0040FB20) -------------------------------------------------------- -unsigned int LODFile_IconsBitmaps::LoadTexture(const char *pContainer, enum TEXTURE_TYPE uTextureType) -{ - areWeLoadingTexture = 1; - - //check loaded texture? - for (uint i = 0; i < uNumLoadedFiles; ++i) - { - if (!_stricmp(pContainer, pTextures[i].pName)) - return i; - } - -// if (!uNumLoadedFiles) -// { -//LABEL_5: - Assert(uNumLoadedFiles < 1000); - /*if (uNumLoadedFiles >= 1000) - { - Log::Warning(L"Maximum texture number exceeded"); - AbortWithError(); - }*/ - if (LoadTextureFromLOD(&pTextures[uNumLoadedFiles], pContainer, uTextureType) == -1) - { - for ( uint i = 0; i < uNumLoadedFiles; ++i ) - { - if (!_stricmp(pTextures[i].pName, "pending")) - return i; - } - LoadTextureFromLOD(&pTextures[uNumLoadedFiles], "pending", uTextureType); - } - areWeLoadingTexture = 0; - ++uNumLoadedFiles; - return uNumLoadedFiles - 1; -// } -// v5 = pTextures; -// while ( _stricmp(v5->pName, pContainer) ) -// { -// ++v4; -// ++v5; -// if (v4 >= uNumLoadedFiles ) -// goto LABEL_5; -// } -// return v4; -} - -Texture * LODFile_IconsBitmaps::GetTexture( int idx ) -{ - Assert(idx < MAX_LOD_TEXTURES, "Texture index out of bounds (%u)", idx); - if (idx == -1) - { - //Log::Warning(L"Texture id = %d missing", idx); - return pTextures + LoadDummyTexture(); - } - return pTextures + idx; -} - -//----- (0046082C) -------------------------------------------------------- -bool Initialize_GamesLOD_NewLOD() -{ - pGames_LOD = new LODWriteableFile; - pGames_LOD->AllocSubIndicesAndIO(300, 0); - if (pGames_LOD->LoadFile("data\\games.lod", 1)) - { - pNew_LOD = new LODWriteableFile; - pNew_LOD->AllocSubIndicesAndIO(300, 100000); - return true; - } - return false; -} diff -r 92eeeb5200f2 -r 68cdef6879a0 LOD.h --- a/LOD.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,332 +0,0 @@ -#pragma once -#include -#include -#include - -#include "Engine/Graphics/Texture.h" - -class Sprite; - - -#define MAX_LOD_TEXTURES 1000 -#define MAX_LOD_SPRITES 1500 - -/* 354 */ -enum TEXTURE_TYPE -{ - TEXTURE_DEFAULT = 0, - TEXTURE_24BIT_PALETTE = 0x1, - TEXTURE_16BIT_PALETTE = 0x2, -}; - -namespace LOD -{ - #pragma pack(push, 1) - struct FileHeader - { - //----- (004617B6) -------------------------------------------------------- - inline FileHeader() - { - memset(pSignature, 0, 4); - memset(LodVersion, 0, 80); - memset(LodDescription, 0, 80); - memset(array_0000B0, 0, 28); - memset(array_0000CC, 0, 52); - - pSignature[0] = 0; - LodVersion[0] = 0; - LodDescription[0] = 0; - LODSize = 0; - dword_0000A8 = 0; - uNumIndices = 0; - } - - char pSignature[4]; - char LodVersion[80]; - //char field_C[32]; - //char field_2C[40]; - char LodDescription[80]; - int LODSize; - int dword_0000A8; - unsigned int uNumIndices; - char array_0000B0[28]; - char array_0000CC[52]; - }; - #pragma pack(pop) - - - #pragma pack(push, 1) - struct Directory - { - Directory(); - - char pFilename[15]; - char field_F; - unsigned int uOfsetFromSubindicesStart; - unsigned int uDataSize; - int dword_000018; - unsigned __int16 uNumSubIndices; - __int16 word_00001E; - }; - #pragma pack(pop) - - - #pragma pack(push, 1) - struct File - { - File(); - virtual ~File(); - void *LoadRaw(const char *pContainer, int a3); - FILE *FindContainer(const char *pContainerName, bool bLinearSearch); - bool DoesContainerExist(const char *pContainer); - int CalcIndexFast(int startIndex, int maxIndex, const char *pContainerName); - bool LoadHeader(const char *pFilename, bool bWriting); - int LoadSubIndices(const char *pContainer); - void AllocSubIndicesAndIO(unsigned int uNumSubIndices, unsigned int uBufferSize); - void FreeSubIndexAndIO(); - bool AppendDirectory(LOD::Directory *pDir, const void *pData); - void ResetSubIndices(); - void Close(); - - FILE *pFile; - char pLODName[256]; - bool isFileOpened; - unsigned __int8 *pIOBuffer; - unsigned int uIOBufferSize; - struct FileHeader header; - struct Directory *pRoot; - char pContainerName[16]; - unsigned int uCurrentIndexDir; - unsigned int uLODDataSize; - unsigned int uNumSubDirs; - struct Directory *pSubIndices; - unsigned int uOffsetToSubIndex; - FILE *pOutputFileHandle; - }; - #pragma pack(pop) -}; - - - - - - -/* 6 */ -#pragma pack(push, 1) -struct LODWriteableFile: public LOD::File -{ - bool LoadFile(const char *pFilename, bool bWriting); - unsigned int Write(const LOD::Directory *pDir, const void *pDirData, int a4); - void CloseWriteFile(); - int CreateTempFile(); - int FixDirectoryOffsets(); - bool _4621A7(); - int CreateNewLod(LOD::FileHeader *pHeader, LOD::Directory *pDir, const char *Source); - - /*FILE *pFile; - char pLODName[256]; - unsigned int isFileOpened; - unsigned __int8 *pIOBuffer; - unsigned int uIOBufferSize; - struct LOD::FileHeader header; - struct LOD::Directory *pRoot; - unsigned __int8 pContainerName[16]; - unsigned int uCurrentIndexDir; - unsigned int uLODDataSize; - unsigned int uNumSubIndices; - struct LOD::Directory *pSubIndices; - unsigned int uOffsetToSubIndex; - FILE *pOutputFileHandle;*/ -}; -#pragma pack(pop) - - - - -#pragma pack(push, 1) -struct LODFile_IconsBitmaps: public LOD::File -{ - LODFile_IconsBitmaps(); - virtual ~LODFile_IconsBitmaps(); - void SyncLoadedFilesCount(); - unsigned int FindTextureByName(const char *pName); - bool Load(const char *pFilename, const char *pFolderName); - void ReleaseAll(); - unsigned int LoadTexture(const char *pContainer, enum TEXTURE_TYPE uTextureType = TEXTURE_DEFAULT); - struct Texture *LoadTexturePtr(const char *pContainer, enum TEXTURE_TYPE uTextureType = TEXTURE_DEFAULT); - int LoadTextureFromLOD(struct Texture *pOutTex, const char *pContainer, enum TEXTURE_TYPE eTextureType); - int ReloadTexture(struct Texture *pDst, const char *pContainer, int mode); - void ReleaseHardwareTextures(); - void ReleaseLostHardwareTextures(); - void _410423_move_textures_to_device(); - int _410522(struct Texture *pDst, const char *pContainer, unsigned int uTextureType); - void SetupPalettes(unsigned int uTargetRBits, unsigned int uTargetGBits, unsigned int uTargetBBits); - void ReleaseAll2(); - void RemoveTexturesPackFromTextureList(); - void RemoveTexturesFromTextureList(); - void _inlined_sub0(); - void _inlined_sub1(); - void _inlined_sub2(); - - inline int LoadDummyTexture() - { - for (unsigned int i = 0; i < uNumLoadedFiles; ++i) - if (!strcmp(pTextures[i].pName, "pending")) - return i; - return LoadTextureFromLOD(&pTextures[uNumLoadedFiles], "pending", TEXTURE_16BIT_PALETTE); - } - - Texture *GetTexture(int idx); - - - /*FILE *pFile; - unsigned __int8 pLODName[256]; - unsigned int isFileOpened; - unsigned __int8 *pIOBuffer; - unsigned int uIOBufferSize; - struct LOD::FileHeader header; - struct LOD::Directory *pRoot; - unsigned __int8 pContainerName[16]; - unsigned int uCurrentIndexDir; - unsigned int uLODDataSize; - unsigned int uNumSubIndices; - struct LOD::Directory *pSubIndices; - unsigned int uOffsetToSubIndex; - FILE *pOutputFileHandle;*/ - Texture pTextures[MAX_LOD_TEXTURES]; - unsigned int uNumLoadedFiles; - int dword_11B80; - int dword_11B84; - int dword_11B88; - int uTextureRedBits; - int uTextureGreenBits; - int uTextureBlueBits; - int uNumPrevLoadedFiles; - int uTexturePacksCount; - int pFacesLock; - int dword_011BA4; - //int can_load_hardware_sprites; - struct IDirectDrawSurface **pHardwareSurfaces; - struct IDirect3DTexture2 **pHardwareTextures; - char *ptr_011BB4; -}; -#pragma pack(pop) - - - - - - -#pragma pack(push, 1) -struct LODSprite -{ - //----- (0046244C) -------------------------------------------------------- - inline LODSprite() - { - uHeight = 0; - uPaletteId = 0; - word_1A = 0; - pSpriteLines = nullptr; - pDecompressedBytes = nullptr; - } - ~LODSprite(); - - void Release(); - int DrawSprite_sw(struct RenderBillboardTransform_local0 *a2, char a3); - int _4AD2D1(struct RenderBillboardTransform_local0 *a2, int a3); - - char pName[12]; //0 - int uSpriteSize; //C - __int16 uWidth; //10 - __int16 uHeight; //12 - __int16 uPaletteId; //14 - __int16 word_16; //16 - __int16 uTexturePitch; //18 - __int16 word_1A; //1a - int uDecompressedSize; //1c - struct LODSprite_stru0 *pSpriteLines; //20 - void *pDecompressedBytes; //24 -}; -#pragma pack(pop) - -/* 15 */ -#pragma pack(push, 1) -struct LODFile_Sprites: public LOD::File -{ - LODFile_Sprites(); - virtual ~LODFile_Sprites(); - - void DeleteSomeSprites(); - void DeleteSpritesRange(int uStartIndex, int uStopIndex); - int _461397(); - void DeleteSomeOtherSprites(); - int LoadSpriteFromFile(LODSprite *pSpriteHeader, const char *pContainer); - bool LoadSprites(const char *pFilename); - int LoadSprite(const char *pContainerName, unsigned int uPaletteID); - void ReleaseLostHardwareSprites(); - void ReleaseAll(); - void MoveSpritesToVideoMemory(); - void _inlined_sub0(); - void _inlined_sub1(); - - - /*FILE *pFile; - unsigned __int8 pLODName[256]; - unsigned int isFileOpened; - unsigned __int8 *pIOBuffer; - unsigned int uIOBufferSize; - struct LOD::FileHeader header; - struct LOD::Directory *pRoot; - unsigned __int8 pContainerName[16]; - unsigned int uCurrentIndexDir; - unsigned int uLODDataSize; - unsigned int uNumSubIndices; - struct LOD::Directory *pSubIndices; - unsigned int uOffsetToSubIndex; - FILE *pOutputFileHandle;*/ - struct LODSprite pSpriteHeaders[MAX_LOD_SPRITES]; - signed int uNumLoadedSprites; - int field_ECA0; - int field_ECA4; - int field_ECA8; - //int can_load_hardware_sprites; - Sprite *pHardwareSprites; - int field_ECB4; -}; -#pragma pack(pop) - -/* 17 */ -#pragma pack(push, 1) -struct LODSprite_stru0 -{ - int16_t a1; - int16_t a2; - char* pos; -}; -#pragma pack(pop) - - - - -extern LODFile_IconsBitmaps *pEvents_LOD; - -extern LODFile_IconsBitmaps *pIcons_LOD; -extern LODFile_IconsBitmaps *pIcons_LOD_mm6; -extern LODFile_IconsBitmaps *pIcons_LOD_mm8; - -extern LODFile_IconsBitmaps *pBitmaps_LOD; -extern LODFile_IconsBitmaps *pBitmaps_LOD_mm6; -extern LODFile_IconsBitmaps *pBitmaps_LOD_mm8; - -extern LODFile_Sprites *pSprites_LOD; -extern LODFile_Sprites *pSprites_LOD_mm6; -extern LODFile_Sprites *pSprites_LOD_mm8; - -extern LODWriteableFile *pNew_LOD; -extern LODWriteableFile *pGames_LOD; - - - - -extern int _6A0CA4_lod_binary_search; // weak -extern int _6A0CA8_lod_unused; // weak \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Log.cpp --- a/Log.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include "Log.h" - -#include -#include - -HANDLE hStdOut = nullptr; - - -void Log::Initialize() -{ - if (AllocConsole()) - hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); -} - - -void Log::Warning(const wchar_t *pFormat, ...) -{ - if (!hStdOut) - return; - - va_list args; - wchar_t pMsg[8192]; - - va_start(args, pFormat); - vswprintf_s(pMsg, 8192, pFormat, args); - va_end(args); - - DWORD w; - WriteConsoleW(hStdOut, pMsg, lstrlenW(pMsg), &w, nullptr); - WriteConsoleW(hStdOut, L"\r\n", 2, &w, nullptr); -} -//----- (004BE386) -------------------------------------------------------- -void __fastcall log_error(const char *pMessage) -{ - const char *v1; // edi@1 - FILE *f; // eax@1 - FILE *v3; // esi@1 - - v1 = pMessage; - f = fopen("errorlog.txt", "a"); - v3 = f; - if ( f ) - { - fprintf(f, "%s\n", v1); - fclose(v3); - fflush(v3); - } -} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Log.h --- a/Log.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -#pragma once - - -#define LOG_DECOMPILATION_WARNING() Log::Warning(L"%S [%S:%u]", __FUNCTION__, __FILE__, __LINE__); - -class Log -{ - public: - static void Initialize(); - static void Warning(const wchar_t *pFormat, ...); -}; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 LuaVM.cpp --- a/LuaVM.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include "LuaVM.h" -#include "lib/lua/lua.h" -#include "Log.h" -#include "OSAPI.h" - -extern "C" int luaopen_UIControl(lua_State *L); // declare the wrapped module -extern "C" int luaopen_Player(lua_State *L); // declare the wrapped module - -LuaVM *lua = nullptr; - -void LuaVM::Initialize() -{ - if (L) - Log::Warning(L"Overwriting previous Lua state"); - - L = luaL_newstate(); - if (!L) - Log::Warning(L"Error creating Lua context.\n"); - - // open default lua libs - luaL_openlibs(L); - - // open each cxx module - luaopen_UIControl(L); - - //if ( luaL_dofile(L,GetScriptFileLocation("script.lua"))) - // Log::Warning(L"Error opening script.lua\n"); -} - -bool LuaVM::DoFile(const char *filename) -{ - if (luaL_dofile(L, GetScriptFileLocation(filename))) - { - Log::Warning(L"Error opening script %s", filename); - return false; - } - return true; -} - -const char *LuaVM::GetScriptFileLocation(const char *script_name) -{ - static DWORD tls_index = TlsAlloc(); - - auto buf = (char *)TlsGetValue(tls_index); - if (!buf) - { - buf = new char[1024]; - TlsSetValue(tls_index, buf); - } - - strcpy(buf, "data/scripts/lua/core/"); - strcat(buf, script_name); - return buf; -} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 LuaVM.h --- a/LuaVM.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,16 +0,0 @@ -#pragma once - -class LuaVM -{ - public: - inline LuaVM(): L(nullptr) {} - - void Initialize(); - bool DoFile(const char *filename); - - protected: - struct lua_State *L; - - const char *GetScriptFileLocation(const char *script_name); -}; -extern LuaVM *lua; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 MM7.h --- a/MM7.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -#pragma once -#include - -typedef unsigned int uint; - -#define PID(type, id) (unsigned int)((((8 * (id))) | (type)) & 0xFFFF) // packed id -#define PID_TYPE(pid) (unsigned int)((pid) & 7) // extract type -#define PID_ID(pid) (unsigned int)(((pid) & 0xFFFF) >> 3) // extract value - - -typedef unsigned __int16 _WORD; -typedef unsigned __int64 _QWORD; - - - - - - - -/* 297 */ -enum SoundType -{ - SOUND_EndTurnBasedMode = 0xCE, - SOUND_StartTurnBasedMode = 0xCF, - SOUND_FlipOnExit = 0x4E21, -}; - - - -/* 362 */ -#pragma pack(push, 1) -struct TravelInfo -{ - char uMapID; - char pSchedule[7]; - char uDaysCount; - char field_9[3]; - int x; - int y; - int z; - int direction; - int field_1C; -}; -#pragma pack(pop) - - - - - - - - - - - - -/* 374 */ -#pragma pack(push, 1) -struct stat_coord -{ - __int16 x; - __int16 y; - __int16 width; - __int16 height; -}; -#pragma pack(pop) -extern std::array stat_string_coord; - -/* 376 */ -#pragma pack(push, 1) -struct stru336 -{ - int field_0; - int field_4; - int field_8; - int field_C; - int field_10; - int field_14; - __int16 field_18[480]; - __int16 field_3D8[480]; -}; -#pragma pack(pop) - diff -r 92eeeb5200f2 -r 68cdef6879a0 MMT.cpp --- a/MMT.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,411 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS - -#include "MMT.h" -#include "GUIWindow.h" - -#include "mm7_data.h" -#include "AudioPlayer.h" -#include "Mouse.h" -#include "LOD.h" -#include "Engine/Graphics/Render.h" -#include "GUIFont.h" -#include "lib/libpng/png.h" -#include "ErrorHandling.h" -#include "Bink_Smacker.h" -#include "Game.h" -#include "Log.h" - - -void ShowLogoVideo() -{ - RGBTexture tex; // [sp+Ch] [bp-30h]@1 - unsigned int uTrackStartMS; // [sp+34h] [bp-8h]@8 - unsigned int uTrackEndMS; // [sp+38h] [bp-4h]@8 - - pMediaPlayer->bStopBeforeSchedule = false; - -// pMediaPlayer->pResetflag = 0; - bGameoverLoop = 1; - if (!bNoVideo) - { - pRenderer->PresentBlackScreen(); - pMediaPlayer->PlayFullscreenMovie(MOVIE_3DOLogo, true); - if ( !pMediaPlayer->bStopBeforeSchedule ) - { - pMediaPlayer->PlayFullscreenMovie(MOVIE_NWCLogo, true); - if ( !pMediaPlayer->bStopBeforeSchedule ) - { - - if (for_refactoring) - { - MessageBoxA(nullptr, "Ritor1: MOVIE_JVC crash", "", 0); - __debugbreak(); - } - - //pMediaPlayer->PlayFullscreenMovie(MOVIE_JVC, true); - //if ( !pMediaPlayer->bStopBeforeSchedule ) - if (!use_MMT) - pMediaPlayer->PlayFullscreenMovie(MOVIE_Intro, true); - } - } - } - char pContainerName[64]; - - if (use_MMT) - { - sprintf(pContainerName, "data\\New_Icons/%s", "MMTTITLE.pcx"); - tex.LoadPCXFile(pContainerName, 0); - } - else - tex.Load("mm6title.pcx", 2); - - pRenderer->BeginScene(); - pRenderer->DrawTextureRGB(0, 0, &tex); - free(tex.pPixels); - tex.pPixels = 0; - MainMenuUI_LoadFontsAndSomeStuff(); - - if (use_MMT) - DrawMMTCopyrightWindow();//Text message in ÌÌÒ menu - else - DrawMM7CopyrightWindow(); - - pRenderer->EndScene(); - pRenderer->Present(); - - #ifndef _DEBUG - Sleep(1500); // let the copyright window stay for a while - #endif - if (!use_MMT) - { - if (!bNoSound && pAudioPlayer->hAILRedbook ) - { - pAudioPlayer->SetMusicVolume((signed __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0)); - AIL_redbook_stop(pAudioPlayer->hAILRedbook); - AIL_redbook_track_info(pAudioPlayer->hAILRedbook, 14, &uTrackStartMS, &uTrackEndMS); - AIL_redbook_play(pAudioPlayer->hAILRedbook, uTrackStartMS + 1, uTrackEndMS); - } - } - bGameoverLoop = 0; -} - -void abort_(const char * s, ...) -{ - va_list args; - va_start(args, s); - vfprintf(stderr, s, args); - fprintf(stderr, "\n"); - va_end(args); - abort(); -} - -Texture *LoadPNG(const char *name) -{ - int x, y; - int width, height; - png_byte color_type; - png_byte bit_depth; - png_structp png_ptr; - png_infop info_ptr; - int number_of_passes; - png_bytep * row_pointers; - uint i = 0; - Texture *tex; - - char header[8]; // 8 is the maximum size that can be checked - - /* open file and test for it being a png */ - FILE *fp = fopen(name, "rb"); - if (!fp) - abort_("[read_png_file] File %s could not be opened for reading", name); - fread(header, 1, 8, fp); - if (png_sig_cmp((png_bytep)header, 0, 8)) - abort_("[read_png_file] File %s is not recognized as a PNG file", name); - /* initialize stuff */ - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - - if (!png_ptr) - abort_("[read_png_file] png_create_read_struct failed"); - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - abort_("[read_png_file] png_create_info_struct failed"); - - if (setjmp(png_jmpbuf(png_ptr))) - abort_("[read_png_file] Error during init_io"); - - png_init_io(png_ptr, fp); - png_set_sig_bytes(png_ptr, 8); - - png_read_info(png_ptr, info_ptr); - - width = png_get_image_width(png_ptr, info_ptr); - height = png_get_image_height(png_ptr, info_ptr); - color_type = png_get_color_type(png_ptr, info_ptr); - bit_depth = png_get_bit_depth(png_ptr, info_ptr); - - number_of_passes = png_set_interlace_handling(png_ptr); - png_read_update_info(png_ptr, info_ptr); - - /* read file */ - if (setjmp(png_jmpbuf(png_ptr))) - abort_("[read_png_file] Error during read_image"); - row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * height); - for (y=0; yuTextureHeight = height; - tex->uTextureWidth = width; - tex->uSizeOfMaxLevelOfDetail = png_get_rowbytes(png_ptr, info_ptr); - tex->uTextureSize = png_get_rowbytes(png_ptr, info_ptr); - tex->uDecompressedSize = png_get_rowbytes(png_ptr, info_ptr); - tex->pPalette16 = (unsigned __int16 *) malloc(sizeof(unsigned __int16) * width * height); - tex->pLevelOfDetail0_prolly_alpha_mask = (unsigned __int8 *) malloc(sizeof(unsigned __int8) * width * height); - - for (y=0; ypPalette16[i] = Color16(ptr[0], ptr[1], ptr[2]); - tex->pLevelOfDetail0_prolly_alpha_mask[i] = ptr[3]; - i++; - } - } - //Ritor1: temporarily stopped, needed change RGBTexture structure - /*for (int i = 0; i < width * height; ++i) - tex->pPalette16[i] = 0x7FF; - memset(tex->pLevelOfDetail0_prolly_alpha_mask, 1, sizeof(unsigned __int8) * width * height);*/ - return tex; -} - -void MMT_MainMenu_Loop() -{ - GUIButton *pButton; // eax@27 - unsigned int pControlParam; // ecx@35 - unsigned int pX; - unsigned int pY; // [sp-18h] [bp-54h]@39 - Texture *pTexture; // [sp-14h] [bp-50h]@39 - char pContainerName[64]; - MSG msg; - - pCurrentScreen = SCREEN_GAME; - - pGUIWindow2 = 0; - pAudioPlayer->StopChannels(-1, -1); - - //if (!bNoSound ) - //PlayAudio(L"Sounds\\New_Sounds/Stronghold_Theme.mp3"); - //if (!bNoVideo ) - //pVideoPlayer->PlayMovie(L"Anims\\New_Video/3DOLOGO.smk"); - - pMouse->RemoveHoldingItem(); - - pIcons_LOD->_inlined_sub2(); - - //Create new window - //WINDOW_MainMenu included in GUIWindow.h - pWindow_MMT_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); - - //load buttons - //Texture* MMT_MM6 = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); - - sprintf(pContainerName, "data\\New_Icons/%s", "mm6_button_oval.png"); - Texture* MMT_MM6 = LoadPNG(pContainerName); - - Texture* MMT_MM7 = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); - Texture* MMT_MM8 = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); - Texture* MMT_Continue = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); - Texture* MMT_Exit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); - - pMMT_MainMenu_BtnMM6 = pWindow_MMT_MainMenu->CreateButton(0, 0, MMT_MM6->uTextureWidth, MMT_MM6->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM6, 0, 0, "", MMT_MM6, 0); - pMMT_MainMenu_BtnMM7 = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - (window->GetWidth() / 4), window->GetHeight() / 4, MMT_MM7->uTextureWidth, MMT_MM7->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM7, 1, 0, "", MMT_MM7, 0); - pMMT_MainMenu_BtnMM8 = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - (window->GetWidth() / 4), window->GetHeight() - ((window->GetHeight() / 4) + 50), MMT_MM8->uTextureWidth, MMT_MM8->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM8, 2, 0, "", MMT_MM8, 0); - pMMT_MainMenu_BtnContinue = pWindow_MMT_MainMenu->CreateButton((window->GetWidth() / 4) - 100, window->GetHeight() - ((window->GetHeight() / 4) + 50), MMT_Continue->uTextureWidth, MMT_Continue->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_Continue, 3, 0, "", MMT_Continue, 0); - pMMT_MainMenu_BtnExit = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - 130, window->GetHeight() - 35, MMT_Exit->uTextureWidth, MMT_Exit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 4, 0, "", MMT_Exit, 0); - - pTexture_PCX.Release(); - - sprintf(pContainerName, "data\\New_Icons/%s", "MMTTITLE.pcx"); - if (pTexture_PCX.LoadPCXFile(pContainerName, 0) == 1) - Error("File not found: %s", pContainerName); - - SetCurrentMenuID(MENU_MMT_MAIN_MENU);//included in enum MENU_STATE in GUIWindows.h - SetForegroundWindow(window->GetApiHandle()); - SendMessageW(window->GetApiHandle(), WM_ACTIVATEAPP, 1, 0); - while (GetCurrentMenuID() == MENU_MMT_MAIN_MENU ) - { - POINT cursor; - pMouse->GetCursorPos(&cursor); - - while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) - { - if (msg.message == WM_QUIT) - Game_DeinitializeAndTerminate(0); - TranslateMessage(&msg); - DispatchMessageW(&msg); - } - - if (dword_6BE364_game_settings_1 & GAME_SETTINGS_APP_INACTIVE) - { - WaitMessage(); - continue; - } - - pRenderer->BeginScene(); - pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX); - - MMT_MenuMessageProc();//for ÌÌÒ menu - GUI_UpdateWindows(); - - if ( !pModalWindow )// ??? - { - pButton = pWindow_MMT_MainMenu->pControlsHead; - for ( pButton = pWindow_MMT_MainMenu->pControlsHead; pButton; pButton = pButton->pNext ) - { - if ( cursor.x >= (signed int)pButton->uX && cursor.x <= (signed int)pButton->uZ - && cursor.y >= (signed int)pButton->uY && cursor.y <= (signed int)pButton->uW ) - { - pControlParam = pButton->msg_param; - switch (pControlParam) // backlight for buttons - { - case 0: - pTexture = MMT_MM6; - pX = 0; - pY = 0; - break; - case 1: - pTexture = MMT_MM7; - pX = window->GetWidth() - (window->GetWidth() / 4); - pY = window->GetHeight() / 4; - break; - case 2: - pTexture = MMT_MM8; - pX = window->GetWidth() - (window->GetWidth() / 4); - pY = window->GetHeight() - ((window->GetHeight() / 4) + 50); - break; - case 3: - pTexture = MMT_Continue; - pX = (window->GetWidth() / 4) - 100; - pY = window->GetHeight() - ((window->GetHeight() / 4) + 50); - break; - case 4: - pTexture = MMT_Exit; - pX = window->GetWidth() - 130; - pY = window->GetHeight() - 35; - break; - } - pRenderer->DrawTextureIndexed(pX, pY, pTexture); - } - } - } - //} - pRenderer->EndScene(); - pRenderer->Present(); - } - MMT_MenuMessageProc(); - pRenderer->BeginScene(); - GUI_UpdateWindows(); - pRenderer->EndScene(); - pRenderer->Present(); - - //remove resource - pTexture_PCX.Release(); - if ( pGUIWindow2 ) - { - pGUIWindow2->Release(); - pGUIWindow2 = 0; - } - pWindow_MMT_MainMenu->Release(); - pIcons_LOD->RemoveTexturesPackFromTextureList(); -} - -void MMT_MenuMessageProc() -{ - int pParam; - int pParam2; - UIMessageType pUIMessageType; - - if ( pMessageQueue_50CBD0->uNumMessages ) - { - do - { - - pMessageQueue_50CBD0->PopMessage(&pUIMessageType, &pParam, &pParam2); - - switch (pUIMessageType) - { - case UIMSG_MMT_MainMenu_MM6: - //video - //SetCurrentMenuID(MENU_MAIN_MM6); - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);//temporarily - break; - case UIMSG_MMT_MainMenu_MM7: //new button for ÌÌ7 - //GUIWindow::Create(495, 172, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnNew, 0); - alSourceStop(mSourceID); - pMediaPlayer->ShowMM7IntroVideo_and_LoadingScreen(); - SetCurrentMenuID(MENU_MAIN); - break; - case UIMSG_MMT_MainMenu_MM8: - //video - //SetCurrentMenuID(MENU_MAIN_MM8); - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);//temporarily - break; - case UIMSG_MMT_MainMenu_Continue: - //video - //SetCurrentMenuID(MENU_MAIN_Continue); - pAudioPlayer->PlaySound((SoundID)27, 0, 0, -1, 0, 0, 0, 0);//temporarily - break; - case UIMSG_ExitToWindows: - GUIWindow::Create(495, 337, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnExit, 0); - SetCurrentMenuID(MENU_EXIT_GAME); - - default: - break; - } - } - while ( pMessageQueue_50CBD0->uNumMessages ); - } -} -void DrawMMTCopyrightWindow() -{ - GUIWindow Dst; // [sp+8h] [bp-54h]@1 - - memset(&Dst, 0, 0x54u); - Dst.uFrameWidth = 624; - Dst.uFrameHeight = 256; - Dst.uFrameX = 8; - Dst.uFrameY = 30; - Dst.uFrameHeight = pFontSmallnum->CalcTextHeight("Text Verification: Here we can write an explanation of the project", &Dst, 24, 0) - + 2 * LOBYTE(pFontSmallnum->uFontHeight) - + 24; - Dst.uFrameY = 470 - Dst.uFrameHeight; - Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1; - Dst.uFrameW = 469; - //Dst.Hint = "abcagfdsgsg ljsrengvlkjesnfkjwnef"; - Dst.DrawMessageBox(0); - - Dst.uFrameWidth -= 24; - Dst.uFrameX += 12; - Dst.uFrameY += 12; - Dst.uFrameHeight -= 12; - Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1; - Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1; - Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, ui_mainmenu_copyright_color, "Text Verification: Here we can write an explanation of the project", 3); -} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 MMT.h --- a/MMT.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -#pragma once - -void ShowLogoVideo(); -void MMT_MainMenu_Loop(); -void MMT_MenuMessageProc(); -void DrawMMTCopyrightWindow(); - -extern bool use_MMT; -extern bool for_refactoring; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 MapInfo.cpp --- a/MapInfo.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,592 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#include "MapInfo.h" -#include "LOD.h" -#include "ErrorHandling.h" -#include "mm7_data.h" -#include "texts.h" -#include "ObjectList.h" -#include "SpriteObject.h" -#include "Engine/Graphics/Indoor.h" - - -#include "Engine/Graphics/Level/Decoration.h" -#include "Engine/Graphics/DecorationList.h" -#include "Party.h" -#include "OurMath.h" - - - -//----- (00453F62) -------------------------------------------------------- -void MapStats::Initialize() -{ - char work_str[32]; // [sp+Ch] [bp-34h]@3 - int work_str_pos; - int work_str_len; - int i; - char* test_string; - unsigned char c; - bool break_loop; - unsigned int temp_str_len; - char* tmp_pos; - int decode_step; -// int item_counter; - - free(pMapStatsTXT_Raw); - pMapStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("MapStats.txt", 0); - strtok(pMapStatsTXT_Raw, "\r"); - strtok(NULL, "\r"); - strtok(NULL, "\r"); - - for (i=1; i<77; ++i) - { - test_string = strtok(NULL, "\r") + 1; - break_loop = false; - decode_step=0; - do - { - c = *(unsigned char*)test_string; - temp_str_len = 0; - while((c!='\t')&&(c>0)) - { - ++temp_str_len; - c=test_string[temp_str_len]; - } - tmp_pos=test_string+temp_str_len; - if (*tmp_pos == 0) - break_loop = true; - *tmp_pos = 0; - if (temp_str_len) - { - switch (decode_step) - { - case 1: - pInfos[i].pName = RemoveQuotes(test_string); - break; - case 2: - pInfos[i].pFilename = RemoveQuotes(test_string); - break; - case 3: - pInfos[i].uNumResets = atoi(test_string); - break; - case 4: - pInfos[i].uFirstVisitedAt = atoi(test_string); - break; - case 5: - pInfos[i]._per = atoi(test_string); - break; - case 6: - pInfos[i].uRespawnIntervalDays = atoi(test_string); - break; - case 7: - pInfos[i]._alert_days = atoi(test_string); - break; - case 8: - pInfos[i]._steal_perm = atoi(test_string); - break; - case 9: - pInfos[i].LockX5 = atoi(test_string); - break; - case 10: - pInfos[i].Trap_D20 = atoi(test_string); - break; - case 11: - pInfos[i].Treasure_prob = atoi(test_string); - break; - case 12: - pInfos[i].Encounter_percent = atoi(test_string); - break; - case 13: - pInfos[i].EncM1percent = atoi(test_string); - break; - case 14: - pInfos[i].EncM2percent = atoi(test_string); - break; - case 15: - pInfos[i].EncM3percent = atoi(test_string); - break; - case 16: - pInfos[i].pEncounterMonster1Texture = RemoveQuotes(test_string); - break; - case 18: - pInfos[i].Dif_M1 = atoi(test_string); - break; - case 19: - pInfos[i].uEncounterMonster1AtLeast = 1; - pInfos[i].uEncounterMonster1AtMost = 1; - strcpy(work_str, test_string); - work_str_pos = 0; - work_str_len=strlen(work_str); - if (work_str_len ) - { - while (work_str[work_str_pos] != '-' ) - { - ++work_str_pos; - if (work_str_pos >= work_str_len ) - break; - } - work_str[work_str_pos] = 0; - pInfos[i].uEncounterMonster1AtLeast = atoi(work_str); - if ( work_str_pos < work_str_len ) - pInfos[i].uEncounterMonster1AtMost = atoi(&work_str[work_str_pos + 1]); - else - pInfos[i].uEncounterMonster1AtMost = pInfos[i].uEncounterMonster1AtLeast; - } - break; - case 20: - pInfos[i].pEncounterMonster2Texture = RemoveQuotes(test_string); - break; - case 22: - pInfos[i].Dif_M2 = atoi(test_string); - break; - case 23: - pInfos[i].uEncounterMonster2AtLeast = 1; - pInfos[i].uEncounterMonster2AtMost = 1; - strcpy(work_str, test_string); - work_str_pos = 0; - work_str_len=strlen(work_str); - if (work_str_len ) - { - while (work_str[work_str_pos] != '-' ) - { - ++work_str_pos; - if (work_str_pos >= work_str_len ) - break; - } - work_str[work_str_pos] = 0; - pInfos[i].uEncounterMonster2AtLeast = atoi(work_str); - if ( work_str_pos < work_str_len ) - pInfos[i].uEncounterMonster2AtMost = atoi(&work_str[work_str_pos + 1]); - else - pInfos[i].uEncounterMonster2AtMost = pInfos[i].uEncounterMonster2AtLeast; - } - break; - case 24: - pInfos[i].pEncounterMonster3Texture = RemoveQuotes(test_string); - break; - case 26: - pInfos[i].Dif_M3 = atoi(test_string); - break; - case 27: - pInfos[i].uEncounterMonster3AtLeast = 1; - pInfos[i].uEncounterMonster3AtMost = 1; - strcpy(work_str, test_string); - work_str_pos = 0; - work_str_len=strlen(work_str); - if (work_str_len ) - { - while (work_str[work_str_pos] != '-' ) - { - ++work_str_pos; - if (work_str_pos >= work_str_len ) - break; - } - work_str[work_str_pos] = 0; - pInfos[i].uEncounterMonster3AtLeast = atoi(work_str); - if ( work_str_pos < work_str_len ) - pInfos[i].uEncounterMonster3AtMost = atoi(&work_str[work_str_pos + 1]); - else - pInfos[i].uEncounterMonster3AtMost = pInfos[i].uEncounterMonster3AtLeast; - } - break; - case 28: - pInfos[i].uRedbookTrackID = atoi(test_string); - break; - case 29: - { - if ( !strcmp(test_string, "CAVE") ) - { - pInfos[i].uEAXEnv = 8; - break; - } - if ( !strcmp(test_string, "STONEROOM") ) - { - pInfos[i].uEAXEnv = 5; - break; - } - if ( !strcmp(test_string, "MOUNTAINS") ) - { - pInfos[i].uEAXEnv = 17; - break; - } - if ( !strcmp(test_string, "PLAIN") ) - { - pInfos[i].uEAXEnv = 19; - break; - } - if ( !strcmp(test_string, "FOREST") ) - { - pInfos[i].uEAXEnv = 15; - break; - } - if ( !strcmp(test_string, "CITY") ) - { - pInfos[i].uEAXEnv = 16; - break; - } - if ( !strcmp(test_string, "UNDERWATER") ) - { - pInfos[i].uEAXEnv = 22; - break; - } - if ( !strcmp(test_string, "ARENA") ) - { - pInfos[i].uEAXEnv = 9; - break; - } - if ( !strcmp(test_string, "GENERIC") ) - { - pInfos[i].uEAXEnv = 0; - break; - } - if ( !strcmp(test_string, "PADDEDCELL") ) - { - pInfos[i].uEAXEnv = 1; - break; - } - if ( !strcmp(test_string, "ROOM") ) - { - pInfos[i].uEAXEnv = 2; - break; - } - if ( !strcmp(test_string, "BATHROOM") ) - { - pInfos[i].uEAXEnv = 3; - break; - } - if ( !strcmp(test_string, "LIVINGROOM") ) - { - pInfos[i].uEAXEnv = 4; - break; - } - if ( !strcmp(test_string, "AUDITORIUM") ) - { - pInfos[i].uEAXEnv = 6; - break; - } - if ( !strcmp(test_string, "CONCERTHALL") ) - { - pInfos[i].uEAXEnv = 7; - break; - } - if ( !strcmp(test_string, "HANGAR") ) - { - pInfos[i].uEAXEnv = 10; - break; - } - if ( !strcmp(test_string, "CARPETEDHALLWAY") ) - { - pInfos[i].uEAXEnv = 11; - break; - } - if ( !strcmp(test_string, "HALLWAY") ) - { - pInfos[i].uEAXEnv = 12; - break; - } - if ( !strcmp(test_string, "STONECORRIDOR") ) - { - pInfos[i].uEAXEnv = 13; - break; - } - if ( !strcmp(test_string, "ALLEY") ) - { - pInfos[i].uEAXEnv = 14; - break; - } - if ( !strcmp(test_string, "QUARRY") ) - { - pInfos[i].uEAXEnv = 18; - break; - } - if ( !strcmp(test_string, "PARKINGLOT") ) - { - pInfos[i].uEAXEnv = 20; - break; - } - if ( !strcmp(test_string, "SEWERPIPE") ) - { - pInfos[i].uEAXEnv = 21; - break; - } - if ( !strcmp(test_string, "DRUGGED") ) - { - pInfos[i].uEAXEnv = 23; - break; - } - if ( !strcmp(test_string, "DIZZY") ) - { - pInfos[i].uEAXEnv = 24; - break; - } - if ( !strcmp(test_string, "PSYCHOTIC") ) - { - pInfos[i].uEAXEnv = 25; - break; - } - pInfos[i].uEAXEnv = 26; - - } - break; - } - } - else - { - break_loop = true; - } - ++decode_step; - test_string=tmp_pos+1; - } while ((decode_step<31)&&!break_loop); - } - - uNumMaps = 77; -} -// 453F62: using guessed type char Str[32]; - -//----- (00410D99) -------------------------------------------------------- -int MapStats::sub_410D99_get_map_index(int a1) -{ - for (int i = 1; i <= pMapStats->uNumMaps; i++) - { - if (_stricmp(pMapStats->pInfos[i].pFilename, pGames_LOD->pSubIndices[a1].pFilename) ) - return i; - } - Error("Map not found"); - return -1; -} - -//----- (004547A3) -------------------------------------------------------- -MAP_TYPE MapStats::GetMapInfo(const char *Str2) -{ - Assert(uNumMaps >= 2); - - for (uint i = 1; i < uNumMaps; ++i) - if (!_stricmp(pInfos[i].pFilename, Str2)) - return (MAP_TYPE)i; - - Error("Map not found!"); - return (MAP_TYPE)-1; -} - - -//----- (0044FFD8) -------------------------------------------------------- -int MapInfo::SpawnRandomTreasure(SpawnPointMM7 *a2) -{ - //MapInfo *v2; // ebx@1 - //SpawnPointMM7 *v3; // esi@1 - //int v4; // eax@1 - int v5; // edx@1 -// int v6; // eax@1 - int v7; // ecx@1 - int v8; // ebx@1 - int v9; // eax@1 - signed int v10; // ebx@1 - signed int result; // eax@1 - signed __int64 v12; // qtt@1 - int v13; // ebx@1 - int v14; // edx@10 - signed int v15; // ebx@20 - unsigned __int16 v16; // dx@20 -// ObjectDesc *v17; // ecx@21 - unsigned __int16 v18; // ax@24 - int v19; // ST0C_4@27 - int v20; // ST08_4@27 - int v21; // ST04_4@27 - int v22; // eax@27 - signed int v23; // ebx@29 - unsigned __int16 v24; // dx@29 -// ObjectDesc *v25; // ecx@30 - unsigned __int16 v26; // ax@33 - //int v27; // ecx@35 - //int v28; // eax@35 - //int v29; // esi@35 - //__int16 v30; // ax@35 - SpriteObject a1a; // [sp+Ch] [bp-7Ch]@1 - //int v32; // [sp+7Ch] [bp-Ch]@1 - //int v33; // [sp+80h] [bp-8h]@1 - int v34; // [sp+84h] [bp-4h]@1 - - //auto a1 = this; - //v2 = a1; - //v3 = a2; - //v4 = rand(); - v34 = 0; - v5 = rand() % 100; - // v6 = 2 * (v2->Treasure_prob + 7 * v3->uIndex) - 14; - v7 = (unsigned __int8)byte_4E8168[a2->uIndex - 1][2 * Treasure_prob]; - v8 = (unsigned __int8)byte_4E8168[a2->uIndex - 1][2 * Treasure_prob + 1]; - //v32 = v5; - //v33 = v7; - v9 = rand(); - v10 = v8 - v7 + 1; - v12 = v9; - result = v9 / v10; - v13 = v7 + (unsigned __int64)(v12 % v10); - if ( v13 < 7 ) - { - if ( v5 < 20 ) - return result; - if ( v5 >= 60 ) - { - v19 = a2->vPosition.z; - v20 = a2->vPosition.y; - v21 = a2->vPosition.x; - v22 = rand(); - return sub_450521_ProllyDropItemAt(v13, v22 % 27 + 20, v21, v20, v19, 0); - } - if ( a2->uIndex == 1 ) - { - v14 = rand() % 51 + 50; - a1a.stru_24.uItemID = 197; - v34 = v14; - } - else if ( a2->uIndex == 2 ) - { - v14 = rand() % 101 + 100; - a1a.stru_24.uItemID = 197; - v34 = v14; - } - else if ( a2->uIndex == 3 ) - { - v14 = rand() % 301 + 200; - a1a.stru_24.uItemID = 198; - v34 = v14; - } - else if ( a2->uIndex == 4 ) - { - v14 = rand() % 501 + 500; - a1a.stru_24.uItemID = 198; - v34 = v14; - } - else if ( a2->uIndex == 5 ) - { - v14 = rand() % 1001 + 1000; - a1a.stru_24.uItemID = 199; - v34 = v14; - } - else if ( a2->uIndex == 6 ) - { - v14 = rand() % 3001 + 2000; - a1a.stru_24.uItemID = 199; - v34 = v14; - } - v15 = 0; - v16 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - v18 = 0; - for( int i = 0; i < pObjectList->uNumObjects; i++ ) - { - if ( pObjectList->pObjects[i].uObjectID == v16 ) - { - v18 = i; - break; - } - } - a1a.stru_24.SetIdentified(); - a1a.uObjectDescID = v18; - a1a.stru_24.uSpecEnchantmentType = v34; - } - else - { - result = a1a.stru_24.GenerateArtifact(); - if ( !result ) - return result; - v23 = 0; - v24 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - v26 = 0; - for( int i = 0; i < pObjectList->uNumObjects; i++ ) - { - if( v24 == pObjectList->pObjects[i].uObjectID ) - { - v26 = i; - break; - } - } - a1a.uObjectDescID = v26; - a1a.stru_24.Reset(); - } - a1a.vPosition.y = a2->vPosition.y; - a1a.uAttributes = 0; - a1a.uSoundID = 0; - a1a.uFacing = 0; - a1a.vPosition.z = a2->vPosition.z; - a1a.vPosition.x = a2->vPosition.x; - a1a.spell_skill = 0; - a1a.spell_level = 0; - a1a.spell_id = 0; - a1a.spell_target_pid = 0; - a1a.spell_caster_pid = 0; - a1a.uSpriteFrameID = 0; - a1a.uSectorID = pIndoor->GetSector(a2->vPosition.x, a2->vPosition.y, a2->vPosition.z);; - return a1a.Create(0, 0, 0, 0); -} - -//----- (004498D5) -------------------------------------------------------- -void TeleportToStartingPoint(MapStartPoint point) -{ - const char *model_name; // [sp-4h] [bp-84h]@6 - char pName[128]; // [sp+8h] [bp-78h]@11 - - switch (point) - { - case MapStartPoint_Party: model_name = "Party Start"; break; - case MapStartPoint_North: model_name = "North Start"; break; - case MapStartPoint_South: model_name = "South Start"; break; - case MapStartPoint_East: model_name = "East Start"; break; - case MapStartPoint_West: model_name = "West Start"; break; - default: - Error("Invalid enum value: %u", point); - } - - strcpy(pName, model_name); - if (pDecorationList->GetDecorIdByName(pName)) - { - - if ((signed int)uNumLevelDecorations > 0) - { - for (uint i = 0; i < (signed int)uNumLevelDecorations; ++i) - { - if (pLevelDecorations[i].uDecorationDescID == (signed __int16)pDecorationList->GetDecorIdByName(pName)) - { - pParty->vPosition.x = pLevelDecorations[i].vPosition.x; - pParty->vPosition.y = pLevelDecorations[i].vPosition.y; - pParty->vPosition.z = pLevelDecorations[i].vPosition.z; - pParty->uFallStartY = pParty->vPosition.z; - pParty->sRotationY = (signed int)(stru_5C6E00->uIntegerHalfPi * pLevelDecorations[i].field_1A) / 90; - if (pLevelDecorations[i].field_10_y_rot) - pParty->sRotationY = pLevelDecorations[i].field_10_y_rot; - pParty->sRotationX = 0; - pParty->uFallSpeed = 0; - } - } - } - if (dword_5B65C0) - { - if (_5B65A8_npcdata_uflags_or_other) - pParty->vPosition.x = _5B65A8_npcdata_uflags_or_other; - if (_5B65AC_npcdata_fame_or_other) - pParty->vPosition.y = _5B65AC_npcdata_fame_or_other; - if (_5B65B0_npcdata_rep_or_other) - { - pParty->vPosition.z = _5B65B0_npcdata_rep_or_other; - pParty->uFallStartY = _5B65B0_npcdata_rep_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; - if (dword_5B65BC) - pParty->uFallSpeed = dword_5B65BC; - } - _5B65B4_npcdata_loword_house_or_other = -1; - 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; - } -} diff -r 92eeeb5200f2 -r 68cdef6879a0 MapInfo.h --- a/MapInfo.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -#pragma once - - -enum MAP_TYPE: unsigned __int32 -{ - MAP_INVALID = 0, - MAP_EMERALD_ISLE = 1, - MAP_HARMONDALE = 2, - MAP_STEADWICK = 3, - MAP_PIERPONT = 4, - MAP_DEYJA = 5, - MAP_BRAKADA_DESERT = 6, - MAP_CELESTIA = 7, - MAP_THE_PIT = 8, - MAP_EVENMORN_ISLE = 9, - MAP_MOUNT_NIGHON = 10, - MAP_BARROW_DOWNS = 11, - MAP_LAND_OF_GIANTS = 12, - MAP_TATALIA = 13, - MAP_AVLEE = 14, - MAP_SHOALS = 15, - //... - MAP_ARENA = 76, - //... -}; - -enum MapStartPoint: unsigned __int32 -{ - MapStartPoint_Party = 0, - MapStartPoint_North = 1, - MapStartPoint_South = 2, - MapStartPoint_East = 3, - MapStartPoint_West = 4 -}; - - -/* 192 */ -#pragma pack(push, 1) -struct MapInfo -{ - int SpawnRandomTreasure(struct SpawnPointMM7 *a2); - - char *pName; - char *pFilename; - char *pEncounterMonster1Texture; - char *pEncounterMonster2Texture; - char *pEncounterMonster3Texture; - unsigned int uNumResets; - unsigned int uFirstVisitedAt; - unsigned int uRespawnIntervalDays; - int _alert_days; - int _steal_perm; - int _per; - char field_2C; - char LockX5; - char Trap_D20; - char Treasure_prob; - char Encounter_percent; - char EncM1percent; - char EncM2percent; - char EncM3percent; - char Dif_M1; - unsigned __int8 uEncounterMonster1AtLeast; - unsigned __int8 uEncounterMonster1AtMost; - char Dif_M2; - unsigned __int8 uEncounterMonster2AtLeast; - unsigned __int8 uEncounterMonster2AtMost; - char Dif_M3; - unsigned __int8 uEncounterMonster3AtLeast; - unsigned __int8 uEncounterMonster3AtMost; - char field_3D; - char field_3E; - char field_3F; - unsigned __int8 uRedbookTrackID; - unsigned __int8 uEAXEnv; - char field_42; - char field_43; -}; -#pragma pack(pop) - - - -/* 193 */ -#pragma pack(push, 1) -struct MapStats -{ - void Initialize(); - MAP_TYPE GetMapInfo(const char *Str2); - int sub_410D99_get_map_index(int a1); - MapInfo pInfos[77]; - unsigned int uNumMaps; - - -}; -#pragma pack(pop) - - - - -extern struct MapStats *pMapStats; - - -extern MapStartPoint uLevel_StartingPointType; // weak - - -void TeleportToStartingPoint(MapStartPoint point); // idb diff -r 92eeeb5200f2 -r 68cdef6879a0 MapsLongTimer.h --- a/MapsLongTimer.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -#pragma once - - -/* 169 */ -#pragma pack(push, 1) -struct MapsLongTimer -{ - __int64 NextStartTime; // timer will either fire event at this time (type 2, field_C == 0) - __int16 timer_evt_ID; - __int16 timer_evt_seq_num; - __int16 time_left_to_fire; - __int16 IntervalHalfMins; // or fire on these intervals (type 1) - __int16 YearsInterval; - __int16 MonthsInterval; - __int16 WeeksInterval; - __int16 HoursInterval; - __int16 MinutesInterval; - __int16 SecondsInterval; - __int16 timer_evt_type; - __int16 field_1E; -}; -#pragma pack(pop) -extern MapsLongTimer MapsLongTimersList[100]; //array_5B5928 - diff -r 92eeeb5200f2 -r 68cdef6879a0 MediaPlayer.cpp --- a/MediaPlayer.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/MediaPlayer.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -10,15 +10,15 @@ #include "Mouse.h" #include "GUIWindow.h" -#include "mm7_data.h" +#include "Engine/mm7_data.h" #include "OpenALSoundProvider.h" -#include "Log.h" +#include "Engine/Log.h" #include "MediaPlayer.h" #include "Bink_Smacker.h" #include "AudioPlayer.h" -#include "Timer.h" +#include "Engine/Timer.h" #include "Engine/Graphics/Render.h" -#include "Game.h" +#include "Engine/Game.h" #pragma comment(lib, "Version.lib") diff -r 92eeeb5200f2 -r 68cdef6879a0 MediaPlayer.h --- a/MediaPlayer.h Fri Sep 19 00:03:04 2014 +0600 +++ b/MediaPlayer.h Fri Sep 19 02:57:42 2014 +0600 @@ -1,7 +1,7 @@ #pragma once #include "OSWindow.h" #include "Engine/Graphics/Texture.h" -#include "ErrorHandling.h" +#include "Engine/ErrorHandling.h" #pragma pack(push, 1) diff -r 92eeeb5200f2 -r 68cdef6879a0 Monsters.cpp --- a/Monsters.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1245 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include -#include -#include -#include "ErrorHandling.h" - -#include "Monsters.h" -#include "FrameTableInc.h" -#include "LOD.h" -#include "texts.h" -#include "mm7_data.h" - - - - - -struct MonsterStats *pMonsterStats; -struct MonsterList *pMonsterList; - -unsigned int ParseSpellType(struct FrameTableTxtLine* tbl, int* next_token); - -int ParseAttackType(const char *damage_type_str); -void ParseDamage( char *damage_str, unsigned __int8* dice_rolls, unsigned __int8* dice_sides, unsigned __int8* dmg_bonus ); -int ParseMissleAttackType(const char *missle_attack_str); -int ParseSpecialAttack(const char *spec_att_str); - -//----- (004548E2) -------------------------------------------------------- -unsigned int ParseSpellType( struct FrameTableTxtLine * tbl, int* next_token ) - { - - if (!tbl->pProperties[0] ) - { - ++*next_token; - return 0; - } - if ( !_stricmp(tbl->pProperties[0], "Dispel") ) //dispel magic - { - ++*next_token; - return 80; - } - else if ( !_stricmp(tbl->pProperties[0], "Day") ) //day of protection - { - *next_token+=2;; - return 85; - } - else if ( !_stricmp(tbl->pProperties[0], "Hour") ) //hour of power - { - *next_token+=2;; - return 86; - } - else if ( !_stricmp(tbl->pProperties[0], "Shield") ) - return 17; - else if ( !_stricmp(tbl->pProperties[0], "Spirit") ) - { - ++*next_token; - return 52; - } - else if ( !_stricmp(tbl->pProperties[0], "Power") ) //power cure - { - ++*next_token; - return 77; - } - else if ( !_stricmp(tbl->pProperties[0], "Meteor") ) //meteot shower - { - ++*next_token; - return 9; - } - else if ( !_stricmp(tbl->pProperties[0], "Lightning") ) //Lightning bolt - { - ++*next_token; - return 18; - } - else if ( !_stricmp(tbl->pProperties[0], "Implosion") ) - return 20; - else if ( !_stricmp(tbl->pProperties[0], "Stone") ) - { - ++*next_token; - return 38; - } - else if ( !_stricmp(tbl->pProperties[0], "Haste") ) - return 5; - else if ( !_stricmp(tbl->pProperties[0], "Heroism") ) - return 51; - else if ( !_stricmp(tbl->pProperties[0], "Pain") ) //pain reflection - { - ++*next_token; - return 95; - } - else if ( !_stricmp(tbl->pProperties[0], "Sparks") ) - return 15; - else if ( !_stricmp(tbl->pProperties[0], "Light") ) - { - ++*next_token; - return 78; - } - else if ( !_stricmp(tbl->pProperties[0], "Toxic") ) //toxic cloud - { - ++*next_token; - return 90; - } - else if ( !_stricmp(tbl->pProperties[0], "ShrapMetal") ) - return 93; - else if ( !_stricmp(tbl->pProperties[0], "Paralyze") ) - return 81; - else if ( !_stricmp(tbl->pProperties[0], "Fireball") ) - return 6; - else if ( !_stricmp(tbl->pProperties[0], "Incinerate") ) - return 11; - else if ( !_stricmp(tbl->pProperties[0], "Fire") ) - { - ++*next_token; - return 2; - } - else if ( !_stricmp(tbl->pProperties[0], "Rock") ) - { - ++*next_token; - return 41; - } - else if ( !_stricmp(tbl->pProperties[0], "Mass") ) - { - ++*next_token; - return 44; - } - else if ( !_stricmp(tbl->pProperties[0], "Ice") ) - { - ++*next_token; - return 26; - } - else if ( !_stricmp(tbl->pProperties[0], "Acid") ) - { - ++*next_token; - return 29; - } - else if ( !_stricmp(tbl->pProperties[0], "Bless") ) - return 46; - else if ( !_stricmp(tbl->pProperties[0], "Dragon") ) - { - ++*next_token; - return 97; - } - else if ( !_stricmp(tbl->pProperties[0], "Reanimate") ) - return 89; - else if ( !_stricmp(tbl->pProperties[0], "Summon") ) - { - ++*next_token; - return 82; - } - else if ( !_stricmp(tbl->pProperties[0], "Fate") ) - return 47; - else if ( !_stricmp(tbl->pProperties[0], "Harm") ) - return 70; - else if ( !_stricmp(tbl->pProperties[0], "Mind") ) - { - ++*next_token; - return 57; - } - else if ( !_stricmp(tbl->pProperties[0], "Blades") ) - return 39; - else if ( !_stricmp(tbl->pProperties[0], "Psychic") ) - { - ++*next_token; - return 65; - } - else if ( !_stricmp(tbl->pProperties[0], "Hammerhands") ) - return 73; - else - { - sprintf(pTmpBuf.data(), "Unknown monster spell %s", tbl->pProperties[0]); - MessageBoxA(nullptr, pTmpBuf.data(), "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Itemdata.cpp:1562", 0); - ++*next_token; - return 0; - } - } - -//----- (00454CB4) -------------------------------------------------------- -int ParseAttackType( const char *damage_type_str ) - { - - switch (tolower(*damage_type_str)) - { - case 'f': return 0; //fire - case 'a': return 1; //air - case 'w': return 2; //water - case 'e': return 3; //earth - - case 's': return 6; //spirit - case 'm': return 7; //mind - //m ?? 8 - case 'l': return 9; //light - case 'd': return 10; //dark - // d?? 11 - } - return 4; //phis - - } - -//----- (00454D7D) -------------------------------------------------------- -void ParseDamage( char *damage_str, unsigned __int8* dice_rolls, unsigned __int8* dice_sides, unsigned __int8* dmg_bonus ) - { - int str_len=0; - int str_pos=0; - bool dice_flag=false; - - *dice_rolls = 0; - *dice_sides = 1; - *dmg_bonus = 0; - - str_len = strlen(damage_str); - if (str_len<=0) - return; - for (str_pos=0;str_pos='0')&&(*damage_str<='9')) - { - *dice_rolls =atoi(damage_str); - *dice_sides = 1; - } - } - } - -//----- (00454E3A) -------------------------------------------------------- -int ParseMissleAttackType(const char *missle_attack_str) - { - if ( !_stricmp(missle_attack_str, "ARROW") ) - return 1; - else if ( !_stricmp(missle_attack_str, "ARROWF") ) - return 2; - else if ( !_stricmp(missle_attack_str, "FIRE") ) - return 3; - else if ( !_stricmp(missle_attack_str, "AIR") ) - return 4; - else if ( !_stricmp(missle_attack_str, "WATER") ) - return 5; - else if ( !_stricmp(missle_attack_str, "EARTH") ) - return 6; - else if ( !_stricmp(missle_attack_str, "SPIRIT") ) - return 7; - else if ( !_stricmp(missle_attack_str, "MIND") ) - return 8; - else if ( !_stricmp(missle_attack_str, "BODY") ) - return 9; - else if ( !_stricmp(missle_attack_str, "LIGHT") ) - return 10; - else if ( !_stricmp(missle_attack_str, "DARK") ) - return 11; - else if ( !_stricmp(missle_attack_str, "ENER") ) - return 13; - else return 0; - } - - -int ParseSpecialAttack(char *spec_att_str) - { - _strlwr(spec_att_str); - if ( strstr(spec_att_str, "curse") ) - return 1; - else if ( strstr(spec_att_str, "weak") ) - return 2; - else if ( strstr(spec_att_str, "asleep") ) - return 3; - else if ( strstr(spec_att_str, "afraid") ) - return 23; - else if ( strstr(spec_att_str, "drunk") ) - return 4; - else if ( strstr(spec_att_str, "insane") ) - return 5; - else if ( strstr(spec_att_str, "poison weak") ) - return 6; - else if ( strstr(spec_att_str, "poison medium") ) - return 7; - else if ( strstr(spec_att_str, "poison severe") ) - return 8; - else if ( strstr(spec_att_str, "disease weak") ) - return 9; - else if ( strstr(spec_att_str, "disease medium") ) - return 10; - else if ( strstr(spec_att_str, "disease severe") ) - return 11; - else if ( strstr(spec_att_str, "paralyze") ) - return 12; - else if ( strstr(spec_att_str, "uncon") ) - return 13; - else if ( strstr(spec_att_str, "dead") ) - return 14; - else if ( strstr(spec_att_str, "stone") ) - return 15; - else if ( strstr(spec_att_str, "errad") ) - return 16; - else if ( strstr(spec_att_str, "brkitem") ) - return 17; - else if ( strstr(spec_att_str, "brkarmor") ) - return 18; - else if ( strstr(spec_att_str, "brkweapon") ) - return 19; - else if ( strstr(spec_att_str, "steal") ) - return 20; - else if ( strstr(spec_att_str, "age") ) - return 21; - else if ( strstr(spec_att_str, "drainsp") ) - return 22; - else return 0; - } - -//----- (004598FC) -------------------------------------------------------- -bool MonsterList::FromFileTxt(const char *Args) -{ - MonsterList *v2; // ebx@1 - FILE *v3; // eax@1 - unsigned int v4; // esi@3 - void *v5; // eax@9 - FILE *v6; // ST14_4@11 - char *i; // eax@11 - signed int v8; // esi@12 - unsigned __int16 v9; // ax@16 - const char *v10; // ST18_4@16 - unsigned __int16 v11; // ax@16 - const char *v12; // ST14_4@16 - unsigned __int16 v13; // ax@16 - const char *v14; // ST10_4@16 - __int16 v15; // ax@16 - const char *v16; // ST0C_4@16 - int v17; // esi@16 - unsigned __int8 v18; // al@16 - signed int v19; // esi@16 - unsigned __int16 v20; // ax@17 - int v21; // ecx@17 - char Buf; // [sp+4h] [bp-304h]@3 - FrameTableTxtLine v24; // [sp+1F8h] [bp-110h]@4 - FrameTableTxtLine v25; // [sp+274h] [bp-94h]@4 - int v26; // [sp+2F0h] [bp-18h]@16 - char v27; // [sp+2F4h] [bp-14h]@14 - char v28; // [sp+2F5h] [bp-13h]@14 - char v29; // [sp+2F6h] [bp-12h]@14 - char v30; // [sp+2F7h] [bp-11h]@14 - char v31; // [sp+2F8h] [bp-10h]@14 - char v32; // [sp+2F9h] [bp-Fh]@14 - char v33; // [sp+2FAh] [bp-Eh]@14 - char v34; // [sp+2FBh] [bp-Dh]@14 - char v35; // [sp+2FCh] [bp-Ch]@14 - char v36; // [sp+2FDh] [bp-Bh]@14 - char v37; // [sp+2FEh] [bp-Ah]@14 - char v38; // [sp+2FFh] [bp-9h]@14 - char v39; // [sp+300h] [bp-8h]@14 - char v40; // [sp+301h] [bp-7h]@14 - char v41; // [sp+302h] [bp-6h]@14 - char v42; // [sp+303h] [bp-5h]@14 - FILE *File; // [sp+304h] [bp-4h]@1 - unsigned int Argsa; // [sp+310h] [bp+8h]@3 - int Argsb; // [sp+310h] [bp+8h]@16 - - v2 = this; - v3 = fopen(Args, "r"); - File = v3; - if ( !v3 ) - Error("MonsterRaceListStruct::load - Unable to open file: %s."); - - v4 = 0; - Argsa = 0; - if ( fgets(&Buf, 490, v3) ) - { - do - { - *strchr(&Buf, 10) = 0; - memcpy(&v25, frame_table_txt_parser(&Buf, &v24), sizeof(v25)); - if ( v25.uPropCount && *v25.pProperties[0] != 47 ) - ++Argsa; - } - while ( fgets(&Buf, 490, File) ); - v4 = Argsa; - } - v2->uNumMonsters = v4; - v5 = malloc(152 * v4); - v2->pMonsters = (MonsterDesc *)v5; - if ( !v5 ) - Error("MonsterRaceListStruct::load - Out of Memory!"); - - v6 = File; - v2->uNumMonsters = 0; - fseek(v6, 0, 0); - for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) - { - *strchr(&Buf, 10) = 0; - memcpy(&v25, frame_table_txt_parser(&Buf, &v24), sizeof(v25)); - v8 = 0; - if ( v25.uPropCount && *v25.pProperties[0] != 47 ) - { - strcpy(v2->pMonsters[v2->uNumMonsters].pMonsterName, v25.pProperties[0]); - v35 = 0; - v36 = 1; - v37 = 7; - v38 = 2; - v39 = 3; - v40 = 4; - v41 = 5; - v42 = 6; - v27 = 1; - v28 = 2; - v29 = 3; - v30 = 4; - v31 = 4; - v32 = 5; - v33 = 6; - v34 = 7; - do - { - strcpy( - v2->pMonsters[v2->uNumMonsters].pSpriteNames[(unsigned __int8)*(&v35 + v8)], - v25.pProperties[(unsigned __int8)*(&v27 + v8)]); - ++v8; - } - while ( v8 < 8 ); - v9 = atoi(v25.pProperties[8]); - v10 = v25.pProperties[9]; - v2->pMonsters[v2->uNumMonsters].uMonsterHeight = v9; - v11 = atoi(v10); - v12 = v25.pProperties[10]; - v2->pMonsters[v2->uNumMonsters].uMovementSpeed = v11; - v13 = atoi(v12); - v14 = v25.pProperties[11]; - v2->pMonsters[v2->uNumMonsters].uMonsterRadius = v13; - v15 = atoi(v14); - v16 = v25.pProperties[12]; - v2->pMonsters[v2->uNumMonsters].uToHitRadius = v15; - v17 = (unsigned __int8)atoi(v16); - Argsb = atoi(v25.pProperties[13]) & 0xFF; - v26 = atoi(v25.pProperties[14]) & 0xFF; - v18 = atoi(v25.pProperties[15]); - v2->pMonsters[v2->uNumMonsters].sTintColor = v18 | ((v26 | ((Argsb | (v17 << 8)) << 8)) << 8); - v19 = 0; - do - { - v20 = atoi(v25.pProperties[v19 + 16]); - v21 = v19++ ; - v2->pMonsters[v2->uNumMonsters].pSoundSampleIDs[v21] = v20; - } - while ( v19 < 4 ); - ++v2->uNumMonsters; - } - } - fclose(File); - return 1; -} - -//----- (004598AF) -------------------------------------------------------- -void MonsterList::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) -{ - uint num_mm6_monsters = data_mm6 ? *(int *)data_mm6 : 0, - num_mm7_monsters = data_mm7 ? *(int *)data_mm7 : 0, - num_mm8_monsters = data_mm8 ? *(int *)data_mm8 : 0; - - uNumMonsters = num_mm6_monsters + num_mm7_monsters + num_mm8_monsters; - Assert(uNumMonsters); - Assert(!num_mm8_monsters); - - pMonsters = (MonsterDesc *)malloc(sizeof(MonsterDesc) * uNumMonsters); - memcpy(pMonsters, (char *)data_mm7 + 4, num_mm7_monsters * sizeof(MonsterDesc)); - for (uint i = 0; i < num_mm6_monsters; ++i) - { - auto src = (MonsterDesc_mm6 *)((char *)data_mm6 + 4) + i; - MonsterDesc* dst = &pMonsters[num_mm7_monsters + i]; - - dst->uMonsterHeight = src->uMonsterHeight; - dst->uMonsterRadius = src->uMonsterRadius; - dst->uMovementSpeed = src->uMovementSpeed; - dst->uToHitRadius = src->uToHitRadius; - dst->sTintColor = -1; - memcpy(dst->pSoundSampleIDs, src->pSoundSampleIDs, sizeof(src->pSoundSampleIDs)); - memcpy(dst->pMonsterName, src->pMonsterName, sizeof(src->pMonsterName)); - memcpy(dst->pSpriteNames, src->pSpriteNames, sizeof(src->pSpriteNames)); - } - memcpy(pMonsters + num_mm6_monsters + num_mm7_monsters, (char *)data_mm8 + 4, num_mm8_monsters * sizeof(MonsterDesc)); -} - -//----- (00459860) -------------------------------------------------------- -void MonsterList::ToFile() -{ - MonsterList *v1; // esi@1 - FILE *v2; // eax@1 - FILE *v3; // edi@1 - - v1 = this; - v2 = fopen("data\\dmonlist.bin", "wb"); - v3 = v2; - if ( !v2 ) - Error("Unable to save dmonlist.bin!"); - fwrite(v1, 4u, 1u, v2); - fwrite(v1->pMonsters, 0x98u, v1->uNumMonsters, v3); - fclose(v3); -} - - -//----- (004563FF) -------------------------------------------------------- -signed int MonsterStats::FindMonsterByTextureName(const char *monster_textr_name) -{ - for (int i=1; iLoadRaw("placemon.txt", 0); - strtok(pMonsterPlacementTXT_Raw, "\r"); - for (i=1; i<31; ++i) - { - test_string = strtok(NULL, "\r") + 1; - break_loop = false; - decode_step=0; - do - { - c = *(unsigned char*)test_string; - temp_str_len = 0; - while((c!='\t')&&(c>0)) - { - ++temp_str_len; - c=test_string[temp_str_len]; - } - tmp_pos=test_string+temp_str_len; - if (*tmp_pos == 0) - break_loop = true; - *tmp_pos = 0; - if (temp_str_len) - { - if (decode_step==1) - pPlaceStrings[i]=RemoveQuotes(test_string); - } - else - { - break_loop = true; - } - ++decode_step; - test_string=tmp_pos+1; - } while ((decode_step<3)&&!break_loop); - } - uNumPlacements = 31; -} - -//----- (0045501E) -------------------------------------------------------- -void MonsterStats::Initialize() - { - int i;//,j; - char* test_string; - unsigned char c; - bool break_loop; - unsigned int temp_str_len; - char* tmp_pos; - int decode_step; -// int item_counter; - int curr_rec_num; - char parse_str[64]; - char Src[120]; - FrameTableTxtLine parsed_field; - - free(pMonstersTXT_Raw); - pMonstersTXT_Raw = (char *)pEvents_LOD->LoadRaw("monsters.txt", 0); - strtok(pMonstersTXT_Raw, "\r"); - strtok(NULL, "\r"); - strtok(NULL, "\r"); - strtok(NULL, "\r"); - uNumMonsters = 265; - curr_rec_num=0; - for (i=0;i0)) - { - ++temp_str_len; - c=test_string[temp_str_len]; - } - tmp_pos=test_string+temp_str_len; - if (*tmp_pos == 0) - break_loop = true; - *tmp_pos = 0; - if (temp_str_len) - { - switch (decode_step) - { - case 0: - curr_rec_num=atoi(test_string); - pInfos[curr_rec_num].uID=curr_rec_num; - break; - case 1: - pInfos[curr_rec_num].pName=RemoveQuotes(test_string); - break; - case 2: - pInfos[curr_rec_num].pPictureName=RemoveQuotes(test_string); - break; - case 3: - pInfos[curr_rec_num].uLevel=atoi(test_string); - break; - case 4: - { - int str_len=0; - int str_pos=0; - pInfos[curr_rec_num].uHP=0; - if (test_string[0]=='"') - test_string[0]=' '; - str_len=strlen(test_string); - if (str_len==0) - break; - while ((test_string[str_pos]!=',')&&(str_pos1) - { - for (str_pos=0;str_pos2) - { - param_num=1; - pInfos[curr_rec_num].uSpell1ID=ParseSpellType(&parsed_field,¶m_num); - type_flag=*parsed_field.pProperties[param_num]; - pInfos[curr_rec_num].uSpellSkillAndMastery1=atoi(parsed_field.pProperties[param_num+1])&0x003F; - switch(type_flag) - { - case 'E': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0040; break; - case 'M': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0080; break; - case 'G': pInfos[curr_rec_num].uSpellSkillAndMastery1|=0x0100; break; - } - } - else - { - pInfos[curr_rec_num].uSpell1ID=0; - pInfos[curr_rec_num].uSpellSkillAndMastery1=0; - } - - } - break; - case 26: - pInfos[curr_rec_num].uSpell2UseChance=atoi(test_string); - break; - case 27: - { - int param_num; - char type_flag; - strcpy(parse_str,test_string); - parse_str[0]=' '; - parse_str[strlen(parse_str)-1]=' '; - frame_table_txt_parser(parse_str,&parsed_field); - if (parsed_field.uPropCount>2) - { - param_num=1; - pInfos[curr_rec_num].uSpell2ID=ParseSpellType(&parsed_field,¶m_num); - type_flag=*parsed_field.pProperties[param_num]; - pInfos[curr_rec_num].uSpellSkillAndMastery2=atoi(parsed_field.pProperties[param_num+1])&0x003F; - switch(type_flag) - { - case 'E': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0040; break; - case 'M': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0080; break; - case 'G': pInfos[curr_rec_num].uSpellSkillAndMastery2|=0x0100; break; - } - } - else - { - pInfos[curr_rec_num].uSpell2ID=0; - pInfos[curr_rec_num].uSpellSkillAndMastery2=0; - } - } - break; - case 28: - { - if (tolower(test_string[0])=='i') - pInfos[curr_rec_num].uResFire=200; - else - pInfos[curr_rec_num].uResFire=atoi(test_string); - } - break; - case 29: - { - if (tolower(test_string[0])=='i') - pInfos[curr_rec_num].uResAir=200; - else - pInfos[curr_rec_num].uResAir=atoi(test_string); - } - break; - case 30: - { - if (tolower(test_string[0])=='i') - pInfos[curr_rec_num].uResWater=200; - else - pInfos[curr_rec_num].uResWater=atoi(test_string); - } - break; - case 31: - { - if (tolower(test_string[0])=='i') - pInfos[curr_rec_num].uResEarth=200; - else - pInfos[curr_rec_num].uResEarth=atoi(test_string); - } - break; - case 32: - { - if (tolower(test_string[0])=='i') - pInfos[curr_rec_num].uResMind=200; - else - pInfos[curr_rec_num].uResMind=atoi(test_string); - } - break; - case 33: - { - if (tolower(test_string[0])=='i') - pInfos[curr_rec_num].uResSpirit=200; - else - pInfos[curr_rec_num].uResSpirit=atoi(test_string); - } - break; - case 34: - { - if (tolower(test_string[0])=='i') - pInfos[curr_rec_num].uResBody=200; - else - pInfos[curr_rec_num].uResBody=atoi(test_string); - } - break; - case 35: - { - if (tolower(test_string[0])=='i') - pInfos[curr_rec_num].uResLight=200; - else - pInfos[curr_rec_num].uResLight=atoi(test_string); - } - break; - case 36: - { - if (tolower(test_string[0])=='i') - pInfos[curr_rec_num].uResDark=200; - else - pInfos[curr_rec_num].uResDark=atoi(test_string); - } - break; - case 37: - { - if (tolower(test_string[0])=='i') - pInfos[curr_rec_num].uResPhysical=200; - else - pInfos[curr_rec_num].uResPhysical=atoi(test_string); - } - break; - case 38: - { -// int param_num; -// char type_flag; - pInfos[curr_rec_num].uSpecialAbilityType=0; - pInfos[curr_rec_num].uSpecialAbilityDamageDiceBonus=0; - strcpy(parse_str,test_string); - parse_str[0]=' '; - parse_str[strlen(parse_str)-1]=' '; - frame_table_txt_parser(parse_str,&parsed_field); - if ( parsed_field.uPropCount ) - { - // v74 = v94.field_0; - if ( parsed_field.uPropCount < 10 ) - { - if (! _stricmp(parsed_field.pProperties[0], "shot") ) - { - pInfos[curr_rec_num].uSpecialAbilityType=1; - pInfos[curr_rec_num].uSpecialAbilityDamageDiceBonus=atoi((char *)(parsed_field.pProperties[1] + 1)); - } - else if (!_stricmp(parsed_field.pProperties[0], "summon") ) - { - pInfos[curr_rec_num].uSpecialAbilityType=2; - if ( parsed_field.uPropCount > 1 ) - { - pTmpBuf[0] = 0; - strcpy(pTmpBuf.data(), parsed_field.pProperties[2]); - if ( parsed_field.uPropCount > 2 ) - { - int prop_cnt = 3; - if ( parsed_field.uPropCount > 3 ) - { - do - { - strcat(pTmpBuf.data(), " "); - char test_char = parsed_field.pProperties[prop_cnt][0]; - strcat(pTmpBuf.data(), parsed_field.pProperties[prop_cnt]); - if ( prop_cnt == (parsed_field.uPropCount - 1) ) - { - switch (tolower(test_char)) - { - case 'a': pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 1; break; - case 'b': pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 2; break; - case 'c': pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 3; break; - default: - pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 0; - } - - } - ++prop_cnt; - } - while ( prop_cnt < parsed_field.uPropCount ); - } - } - else - { - pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls = 0; - } - if ( pMonsterList->uNumMonsters ) - { - pInfos[curr_rec_num].field_3C_some_special_attack = pMonsterList->GetMonsterIDByName(pTmpBuf.data()) + 1; - if ( pInfos[curr_rec_num].field_3C_some_special_attack == -1 ) - { - sprintf(Src, "Can't create random monster: '%s' See MapStats!", pTmpBuf.data()); - MessageBoxA(nullptr, Src, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Itemdata.cpp:2239", 0); - } - } - pInfos[curr_rec_num].uSpecialAbilityDamageDiceSides = 0; - if ( !_stricmp(parsed_field.pProperties[1], "ground") ) - pInfos[curr_rec_num].uSpecialAbilityDamageDiceSides = 1; - if ( pInfos[curr_rec_num].field_3C_some_special_attack == -1 ) - pInfos[curr_rec_num].uSpecialAbilityType = 0; - } - } - else if (!_stricmp(parsed_field.pProperties[0], "explode") ) - { - pInfos[curr_rec_num].uSpecialAbilityType = 3; - ParseDamage((char*)parsed_field.pProperties[1], &pInfos[curr_rec_num].uSpecialAbilityDamageDiceRolls, - &pInfos[curr_rec_num].uSpecialAbilityDamageDiceSides, - &pInfos[curr_rec_num].uSpecialAbilityDamageDiceBonus); - pInfos[curr_rec_num].field_3C_some_special_attack = ParseAttackType(test_string); - } - } - } - } - break; - } - } - else - { - break_loop = true; - } - ++decode_step; - test_string=tmp_pos+1; - } while ((decode_step<39)&&!break_loop); - } - uNumMonsters = i; -} - - -//----- (0044FA08) -------------------------------------------------------- -signed __int16 MonsterList::GetMonsterIDByName( const char *pMonsterName ) - { - if (!pMonsterName) - return -1; - for (signed __int16 i=1; i<=uNumMonsters; ++i) - { - if( (!_stricmp(pMonsters[i].pMonsterName, pMonsterName))) - return i; - } - Error("Monster not found: %s", pMonsterName); -} -//----- (00438BDF) -------------------------------------------------------- -bool MonsterStats::BelongsToSupertype(unsigned int uMonsterInfoID, enum MONSTER_SUPERTYPE eSupertype) -{ - switch ( eSupertype ) - { - case MONSTER_SUPERTYPE_UNDEAD: - if ( (signed int)uMonsterInfoID >= MONSTER_GHOST_1 && (signed int)uMonsterInfoID <= MONSTER_GHOST_3 //70<=id<=72 - || (signed int)uMonsterInfoID >= MONSTER_LICH_1 && (signed int)uMonsterInfoID <= MONSTER_LICH_3 //91-93 - || (signed int)uMonsterInfoID >= MONSTER_SKELETON_1 && (signed int)uMonsterInfoID <= MONSTER_SKELETON_3 //199-201 - || (signed int)uMonsterInfoID >= MONSTER_VAMPIRE_1 && (signed int)uMonsterInfoID <= MONSTER_VAMPIRE_3 //217-219 - || (signed int)uMonsterInfoID >= MONSTER_WIGHT_1 && (signed int)uMonsterInfoID <= MONSTER_WIGHT_3 //223-225 - || (signed int)uMonsterInfoID >= MONSTER_ZOMBIE_1 && (signed int)uMonsterInfoID <= MONSTER_ZOMBIE_3 //229-231 - || (signed int)uMonsterInfoID >= MONSTER_GHOUL_1 && (signed int)uMonsterInfoID <= MONSTER_GHOUL_3) //256-258 - return true; - return false; - case MONSTER_SUPERTYPE_KREEGAN: - if ( (signed int)uMonsterInfoID >= MONSTER_DEVIL_1 && (signed int)uMonsterInfoID <= MONSTER_DEVIL_3 )//22-24 - return true; - return false; - case MONSTER_SUPERTYPE_ELF: - if ( (signed int)uMonsterInfoID >= MONSTER_PEASANT_ELF_FEMALE_1_1 && (signed int)uMonsterInfoID <= MONSTER_PEASANT_ELF_MALE_3_3//133 - 150 - || (signed int)uMonsterInfoID >= MONSTER_ELF_ARCHER_1 && (signed int)uMonsterInfoID <= MONSTER_ELF_ARCHER_3//49-51 - || (signed int)uMonsterInfoID >= MONSTER_ELF_SPEARMAN_1 && (signed int)uMonsterInfoID <= MONSTER_ELF_SPEARMAN_3)//52-54 - return true; - return false; - case MONSTER_SUPERTYPE_DRAGON: - if ( (signed int)uMonsterInfoID >= MONSTER_DRAGON_1 && (signed int)uMonsterInfoID <= MONSTER_DRAGON_3 )//25-27 - return true; - return false; - case MONSTER_SUPERTYPE_WATER_ELEMENTAL: - if ( (signed int)uMonsterInfoID >= MONSTER_ELEMENTAL_WATER_1 && (signed int)uMonsterInfoID <= MONSTER_ELEMENTAL_WATER_3)//46-48 - return true; - return false; - case MONSTER_SUPERTYPE_TREANT: - if ( (signed int)uMonsterInfoID >= MONSTER_TREANT_1 && (signed int)uMonsterInfoID <= MONSTER_TREANT_3 )//253-255 - return true; - return false; - case MONSTER_SUPERTYPE_TITAN: - if ( (signed int)uMonsterInfoID >= MONSTER_TITAN_1 && (signed int)uMonsterInfoID <= MONSTER_TITAN_3 )//211-213 - return true; - return false; - default: - return false; - } - return false; -} - diff -r 92eeeb5200f2 -r 68cdef6879a0 Monsters.h --- a/Monsters.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,261 +0,0 @@ -#pragma once - - - -/* 334 */ -enum MONSTER_TYPE -{ - MONSTER_DEVIL_1 = 0x16, - MONSTER_DEVIL_2 = 0x17, - MONSTER_DEVIL_3 = 0x18, - MONSTER_DRAGON_1 = 0x19, - MONSTER_DRAGON_2 = 0x1A, - MONSTER_DRAGON_3 = 0x1B, - MONSTER_ELEMENTAL_WATER_1 = 0x2E, - MONSTER_ELEMENTAL_WATER_3 = 0x30, - MONSTER_ELF_ARCHER_1 = 0x31, - MONSTER_ELF_ARCHER_3 = 0x33, - MONSTER_ELF_SPEARMAN_1 = 0x34, - MONSTER_ELF_SPEARMAN_3 = 0x36, - MONSTER_GHOST_1 = 0x46, - MONSTER_GHOST_3 = 0x48, - MONSTER_HARPY_1 = 0x55, - MONSTER_HARPY_2 = 0x56, - MONSTER_HARPY_3 = 0x57, - MONSTER_LICH_1 = 0x5B, - MONSTER_LICH_3 = 0x5D, - MONSTER_OOZE_1 = 0x70, - MONSTER_OOZE_2 = 0x71, - MONSTER_OOZE_3 = 0x72, - MONSTER_PEASANT_ELF_FEMALE_1_1 = 0x85, - MONSTER_PEASANT_ELF_MALE_3_3 = 0x96, - MONSTER_SKELETON_1 = 0xC7, - MONSTER_SKELETON_3 = 0xC9, - MONSTER_TITAN_1 = 0xD3, - MONSTER_TITAN_3 = 0xD5, - MONSTER_VAMPIRE_1 = 0xD9, - MONSTER_VAMPIRE_3 = 0xDB, - MONSTER_WIGHT_1 = 0xDF, - MONSTER_WIGHT_3 = 0xE1, - MONSTER_ZOMBIE_1 = 0xE5, - MONSTER_ZOMBIE_3 = 0xE7, - MONSTER_PEASANT_GOBLIN_MALE_3_3 = 0xF9, - MONSTER_TROLL_1 = 0xFA, - MONSTER_TROLL_2 = 0xFB, - MONSTER_TROLL_3 = 0xFC, - MONSTER_TREANT_1 = 0xFD, - MONSTER_TREANT_3 = 0xFF, - MONSTER_GHOUL_1 = 0x100, - MONSTER_GHOUL_3 = 0x102, -}; - -/* 335 */ -enum MONSTER_SPECIAL_ABILITY_TYPE -{ - MONSTER_SPECIAL_ABILITY_NONE = 0x0, - MONSTER_SPECIAL_ABILITY_SHOT = 0x1, - MONSTER_SPECIAL_ABILITY_SUMMON = 0x2, - MONSTER_SPECIAL_ABILITY_EXPLODE = 0x3, -}; - -enum MONSTER_MOVEMENT_TYPE - { - MONSTER_MOVEMENT_TYPE_SHORT = 0x0, - MONSTER_MOVEMENT_TYPE_MEDIUM = 0x1, - MONSTER_MOVEMENT_TYPE_LONG = 0x2, - MONSTER_MOVEMENT_TYPE_GLOBAL = 0x3, - MONSTER_MOVEMENT_TYPE_FREE = 0x4, - MONSTER_MOVEMENT_TYPE_STAIONARY = 0x5, - }; - - -/* 336 */ -enum MONSTER_SUPERTYPE -{ - MONSTER_SUPERTYPE_UNDEAD = 0x1, - MONSTER_SUPERTYPE_KREEGAN = 0x2, - MONSTER_SUPERTYPE_DRAGON = 0x3, - MONSTER_SUPERTYPE_ELF = 0x4, - MONSTER_SUPERTYPE_WATER_ELEMENTAL = 0x5, - MONSTER_SUPERTYPE_TREANT = 0x6, - MONSTER_SUPERTYPE_TITAN = 0x7, - MONSTER_SUPERTYPE_8 = 0x8, -}; - -enum SPECIAL_ATTACK_TYPE : unsigned __int8 -{ - SPECIAL_ATTACK_NONE = 0, - SPECIAL_ATTACK_CURSE = 1, - SPECIAL_ATTACK_WEAK = 2, - SPECIAL_ATTACK_SLEEP = 3, - SPECIAL_ATTACK_DRUNK = 4, - SPECIAL_ATTACK_INSANE = 5, - SPECIAL_ATTACK_POISON_WEAK = 6, - SPECIAL_ATTACK_POISON_MEDIUM = 7, - SPECIAL_ATTACK_POISON_SEVERE = 8, - SPECIAL_ATTACK_DISEASE_WEAK = 9, - SPECIAL_ATTACK_DISEASE_MEDIUM = 10, - SPECIAL_ATTACK_DISEASE_SEVERE = 11, - SPECIAL_ATTACK_PARALYZED = 12, - SPECIAL_ATTACK_UNCONSCIOUS = 13, - SPECIAL_ATTACK_DEAD = 14, - SPECIAL_ATTACK_PETRIFIED = 15, - SPECIAL_ATTACK_ERADICATED = 16, - SPECIAL_ATTACK_BREAK_ANY = 17, - SPECIAL_ATTACK_BREAK_ARMOR = 18, - SPECIAL_ATTACK_BREAK_WEAPON = 19, - SPECIAL_ATTACK_STEAL = 20, - SPECIAL_ATTACK_AGING = 21, - SPECIAL_ATTACK_MANA_DRAIN = 22, - SPECIAL_ATTACK_FEAR = 23, -}; - - -/* 187 */ -#pragma pack(push, 1) -struct MonsterInfo -{ - enum HostilityRadius: unsigned __int8 - { - Hostility_Friendly = 0, - Hostility_Close = 1, - Hostility_Short = 2, - Hostility_Medium = 3, - Hostility_Long = 4 - }; - - inline MonsterInfo(): - pName(nullptr), pPictureName(nullptr) - {} - - char *pName; - char *pPictureName; - unsigned __int8 uLevel; - unsigned __int8 uTreasureDropChance; - unsigned __int8 uTreasureDiceRolls; - unsigned __int8 uTreasureDiceSides; - unsigned __int8 uTreasureLevel; - unsigned __int8 uTreasureType; - unsigned __int8 uFlying; - unsigned __int8 uMovementType; - unsigned __int8 uAIType; - HostilityRadius uHostilityType; - char field_12; - SPECIAL_ATTACK_TYPE uSpecialAttackType; - unsigned __int8 uSpecialAttackLevel; - unsigned __int8 uAttack1Type; - unsigned __int8 uAttack1DamageDiceRolls; - unsigned __int8 uAttack1DamageDiceSides; - unsigned __int8 uAttack1DamageBonus; - unsigned __int8 uMissleAttack1Type; - unsigned __int8 uAttack2Chance; - unsigned __int8 uAttack2Type; - unsigned __int8 uAttack2DamageDiceRolls; - unsigned __int8 uAttack2DamageDiceSides; - unsigned __int8 uAttack2DamageBonus; - unsigned __int8 uMissleAttack2Type; - unsigned __int8 uSpell1UseChance; - unsigned __int8 uSpell1ID; - unsigned __int8 uSpell2UseChance; - unsigned __int8 uSpell2ID; - unsigned __int8 uResFire; - unsigned __int8 uResAir; - unsigned __int8 uResWater; - unsigned __int8 uResEarth; - unsigned __int8 uResMind; - unsigned __int8 uResSpirit; - unsigned __int8 uResBody; - unsigned __int8 uResLight; - unsigned __int8 uResDark; - unsigned __int8 uResPhysical; - unsigned __int8 uSpecialAbilityType; // 0 SPECIAL_ABILITY_TYPE_NONE - // 1 SPECIAL_ABILITY_TYPE_SHOT - // 2 SPECIAL_ABILITY_TYPE_SUMMON - // 3 SPECIAL_ABILITY_TYPE_EXPLODE - unsigned __int8 uSpecialAbilityDamageDiceRolls; - unsigned __int8 uSpecialAbilityDamageDiceSides; - unsigned __int8 uSpecialAbilityDamageDiceBonus; - unsigned __int8 uNumCharactersAttackedPerSpecialAbility; - char field_33; - unsigned __int16 uID; - unsigned __int16 bQuestMonster; - unsigned __int16 uSpellSkillAndMastery1; - unsigned __int16 uSpellSkillAndMastery2; - __int16 field_3C_some_special_attack; - __int16 field_3E; - unsigned int uHP; - unsigned int uAC; - unsigned int uExp; - unsigned int uBaseSpeed; - signed int uRecoveryTime; - unsigned int uAttackPreference; -}; -#pragma pack(pop) - - - -/* 189 */ -#pragma pack(push, 1) -struct MonsterStats -{ - void Initialize(); - void InitializePlacements(); - signed int FindMonsterByTextureName(const char *Str2); - - static bool BelongsToSupertype(unsigned int uMonsterInfoID, enum MONSTER_SUPERTYPE eSupertype); - - MonsterInfo pInfos[265]; //0 - 5b18h - char *pPlaceStrings[31]; //5B18h placement counts from 1 - unsigned int uNumMonsters; //5B94h - unsigned int uNumPlacements; //5B98h - int field_5B9C; -}; -#pragma pack(pop) - - - -#pragma pack(push, 1) -struct MonsterDesc_mm6 -{ - unsigned __int16 uMonsterHeight; - unsigned __int16 uMonsterRadius; - unsigned __int16 uMovementSpeed; - __int16 uToHitRadius; - unsigned __int16 pSoundSampleIDs[4]; - char pMonsterName[32]; - char pSpriteNames[10][10]; -}; - -struct MonsterDesc -{ - unsigned __int16 uMonsterHeight; - unsigned __int16 uMonsterRadius; - unsigned __int16 uMovementSpeed; - __int16 uToHitRadius; - signed int sTintColor; - unsigned __int16 pSoundSampleIDs[4]; - char pMonsterName[32]; - char pSpriteNames[10][10]; -}; -#pragma pack(pop) - - -#pragma pack(push, 1) -struct MonsterList -{ - inline MonsterList(): //----- (00458429) - uNumMonsters(0), pMonsters(nullptr) - {} - signed __int16 GetMonsterIDByName(const char *pMonsterName); - void ToFile(); - void FromFile(void *data_mm6, void *data_mm7, void *data_mm8); - bool FromFileTxt(const char *Args); - - signed int uNumMonsters; - struct MonsterDesc *pMonsters; -}; -#pragma pack(pop) - - -extern struct MonsterStats *pMonsterStats; -extern struct MonsterList *pMonsterList; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Mouse.cpp --- a/Mouse.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/Mouse.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -4,18 +4,18 @@ #define _CRT_SECURE_NO_WARNINGS -#include "mm7_data.h" +#include "Engine/mm7_data.h" #include "Mouse.h" -#include "Party.h" -#include "LOD.h" -#include "Game.h" +#include "Engine/Party.h" +#include "Engine/LOD.h" +#include "Engine/Game.h" -#include "TurnEngine.h" +#include "Engine/TurnEngine/TurnEngine.h" #include "Engine/Graphics/Viewport.h" #include "GUIWindow.h" #include "Engine/Graphics/Vis.h" -#include "Actor.h" -#include "MM7.h" +#include "Engine/Objects/Actor.h" +#include "Engine/MM7.h" #include "AudioPlayer.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 Mouse.h --- a/Mouse.h Fri Sep 19 00:03:04 2014 +0600 +++ b/Mouse.h Fri Sep 19 02:57:42 2014 +0600 @@ -1,7 +1,7 @@ #pragma once #include "OSWindow.h" -#include "VectorTypes.h" +#include "Engine/VectorTypes.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 NZIArray.h --- a/NZIArray.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -#pragma once -#include -#include - - -template -class NZIArray : std::array<_Ty, _Size> -{ -public: - reference ZerothIndex() - { - return std::array<_Ty, _Size>::operator [](0); - } - - reference operator[](size_type _Pos) - { // subscript nonmutable sequence -#if _ITERATOR_DEBUG_LEVEL == 2 - assert(_Pos != 0 && "not allowed to access zeroth element"); - -#elif _ITERATOR_DEBUG_LEVEL == 1 - _SCL_SECURE_VALIDATE_RANGE(_Pos != 0); -#endif /* _ITERATOR_DEBUG_LEVEL */ - - __analysis_assume(_Pos != 0); - - return std::array<_Ty, _Size>::operator [](_Pos); - } - - const_reference operator[](size_type _Pos) const - { // subscript nonmutable sequence -#if _ITERATOR_DEBUG_LEVEL == 2 - assert(_Pos != 0 && "not allowed to access zeroth element"); - -#elif _ITERATOR_DEBUG_LEVEL == 1 - _SCL_SECURE_VALIDATE_RANGE(_Pos != 0); -#endif /* _ITERATOR_DEBUG_LEVEL */ - - __analysis_assume(_Pos != 0); - - return std::array<_Ty, _Size>::operator [](_Pos); - } -}; diff -r 92eeeb5200f2 -r 68cdef6879a0 NewUI/MainMenu.cpp --- a/NewUI/MainMenu.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/NewUI/MainMenu.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -4,7 +4,7 @@ #define _CRT_SECURE_NO_WARNINGS #include "MainMenu.h" -#include "..\LOD.h" +#include "..\Engine/LOD.h" bool MainMenuWindow::OnMouseLeftClick(int x, int y) { diff -r 92eeeb5200f2 -r 68cdef6879a0 OSAPI.cpp --- a/OSAPI.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/OSAPI.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -5,7 +5,7 @@ #define _CRT_SECURE_NO_WARNINGS #include "OSAPI.h" #include "OSInfo.h" -#include "Log.h" +#include "Engine/Log.h" bool OSInfo::initialized = false; diff -r 92eeeb5200f2 -r 68cdef6879a0 OSWindow.cpp --- a/OSWindow.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/OSWindow.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -5,23 +5,23 @@ #define _CRT_SECURE_NO_WARNINGS #include "OSWindow.h" -#include "mm7_data.h" +#include "Engine/mm7_data.h" #include "Arcomage\Arcomage.h" #include "AudioPlayer.h" #include "Mouse.h" -#include "Timer.h" +#include "Engine/Timer.h" #include "GUIWindow.h" -#include "Party.h" -#include "Game.h" +#include "Engine/Party.h" +#include "Engine/Game.h" #include "Engine/Graphics/IndoorCameraD3D.h" #include "Keyboard.h" #include "Engine/Graphics/Viewport.h" #include "Engine/Graphics/Vis.h" #include "AIL.h" -#include "ErrorHandling.h" -#include "Log.h" -#include "Registry.h" -#include "MMT.h" +#include "Engine/ErrorHandling.h" +#include "Engine/Log.h" +#include "Engine/Registry.h" +#include "Engine/MMT.h" bool wizard_eye = false; //âêëþ÷èòü íà ïîñòîÿííî îêî ÷àðîäåÿ diff -r 92eeeb5200f2 -r 68cdef6879a0 OpenALSoundProvider.h --- a/OpenALSoundProvider.h Fri Sep 19 00:03:04 2014 +0600 +++ b/OpenALSoundProvider.h Fri Sep 19 02:57:42 2014 +0600 @@ -3,8 +3,8 @@ #include "lib/OpenAL/alc.h" #pragma comment(lib, "OpenAL32.lib") -#include "stuff.h" -#include "Log.h" +#include "Engine/stuff.h" +#include "Engine/Log.h" class OpenALSoundProvider { diff -r 92eeeb5200f2 -r 68cdef6879a0 OurMath.cpp --- a/OurMath.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,256 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#include "OurMath.h" -#include "MM7_data.h" - -//----- (00452969) -------------------------------------------------------- -stru193_math::stru193_math() -{ - double v3; // ST18_8@2 - - this->pTanTable[0] = 0; - this->pCosTable[0] = 65536; - this->pInvCosTable[0] = 65536; - for(int i = 1; i < (signed int)this->uIntegerHalfPi; i++) - { - v3 = (double)i * 3.141592653589793 / (double)uIntegerPi; - pTanTable[i] = (signed __int64)(tan(v3) * (double)this->pCosTable[0] + 0.5); - pCosTable[i] = (signed __int64)(cos(v3) * (double)this->pCosTable[0] + 0.5); - pInvCosTable[i] = (signed __int64)(1.0 / cos(v3) * (double)this->pCosTable[0] + 0.5); - } - for(int i = this->uIntegerHalfPi; i < 520; i++) - { - this->pTanTable[i] = 0xEFFFFFFFu; - this->pCosTable[i] = 0; - this->pInvCosTable[i] = 0xEFFFFFFFu; - } -} - - -//----- (00402CAE) -------------------------------------------------------- -int stru193_math::Cos(int angle) -{ - int v2; // eax@1 - - //a2: (angle - uIntegerHalfPi) for sin(angle) - // (angle) for cos(angle) - - v2 = uDoublePiMask & angle; - - if ( v2 > uIntegerPi ) - v2 = uIntegerDoublePi - v2; - if ( v2 >= uIntegerHalfPi ) - return -pCosTable[uIntegerPi - v2]; - else - return pCosTable[v2]; -} - - -//----- (0045281E) -------------------------------------------------------- -// Calculates atan2(y/x) -// return value: angle in integer format (multiplier of Pi/1024) -unsigned int stru193_math::Atan2(int x, int y) -{ - signed int quadrant; - __int64 dividend; - int quotient; - int lowIdx; - int highIdx; - int angle; - - int X = x; - int Y = y; - - if ( abs(X) < 65536 ) - { - if ( (abs(Y) >> 15) >= abs(X) ) - X = 0; - } - - if ( !X ) - { - if ( Y > 0 ) - { - return uIntegerHalfPi; //Pi/2 - } - else - { - return uIntegerHalfPi + uIntegerPi; //3*(Pi/2) - } - } - - if ( Y ) - { - if ( X < 0 ) - { - X = -X; - if ( Y > 0 ) - { - quadrant = 4; - } - else - { - quadrant = 3; - } - } - else - { - if ( Y > 0 ) - { - quadrant = 1; - } - else - { - quadrant = 2; - } - } - - if ( Y < 0 ) - Y = -Y; - - LODWORD(dividend) = Y << 16; - HIDWORD(dividend) = Y >> 16; - quotient = dividend / X; - - //looks like binary search - { - int i; - highIdx = uIntegerHalfPi; - lowIdx = 0; - - for (i = 0; i < 6; ++i) - { - if (quotient <= pTanTable[(lowIdx + highIdx) / 2]) - highIdx = (lowIdx + highIdx) / 2; - else - lowIdx = (lowIdx + highIdx) / 2; - } - } - - angle = lowIdx + 1; - while ( angle < (highIdx - 1) && quotient >= pTanTable[angle] ) - ++angle; - - switch (quadrant) - { - case 1: //X > 0, Y > 0 - return angle; - - case 2: //X > 0, Y < 0 - return uIntegerDoublePi - angle; //2*Pi - angle - - case 3: //X > 0, Y < 0 - return uIntegerPi + angle; //Pi + angle - - case 4: //X < 0, Y > 0 - return uIntegerPi - angle; //Pi - angle - } - - //should newer get here - return 0; - } - - if ( X < 0 ) //Y == 0, X < 0 - return uIntegerPi; - - return 0; -} - -//----- (0042EBDB) -------------------------------------------------------- -int stru193_math::Sin(int angle) -{ - return Cos(angle - this->uIntegerHalfPi); -} - -//----- (0042EBBE) -------------------------------------------------------- -//----- (004453C0) mm6----------------------------------------------------- -//----- (004A1760) mm6_chinese--------------------------------------------- -__int64 fixpoint_mul(int a1, int a2) -{ - return ((__int64)a1 * (__int64)a2) >> 16; -} - -__int64 fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2) -{ - return fixpoint_mul(x1, x2) + - fixpoint_mul(y1, y2) + - fixpoint_mul(z1, z2); -} - -//----- (004A1780) mm6_chinese--------------------------------------------- -__int64 fixpoint_div(int a1, int a2) -{ - return ((__int64)a1 << 16) / a2; -} - -__int64 fixpoint_sub_unknown(int a1, int a2) -{ - return (((__int64)a1 << 16) * a2) >> 16; -} - -//----- (0048B561) -------------------------------------------------------- -int fixpoint_from_float(float val) -{ - // float X.Yf -> int XXXX YYYY - int left = floorf((val - 0.5f) + 0.5f); - int right = floorf((val - left) * 65536.0f); - return (left << 16) | right; -} - -int fixpoint_from_int(int lhv, int rhv) -{ - return (lhv << 16) | rhv; -} - - -//----- (00452A9E) -------------------------------------------------------- -int integer_sqrt(int val) -{ -/////////////////////////////// -//Ïîëó÷åíèå êâàäðàòíîãî êîðíÿ// -/////////////////////////////// - - signed int result; // eax@2 - unsigned int v2; // edx@3 - unsigned int v3; // edi@3 - int v5; // esi@4 - - if (val < 1) - return val; - - v2 = 0; - v3 = val; - result = 0; - for (uint i = 0; i < 16; ++i) - { - result *= 2; - v2 = (v3 >> 30) | 4 * v2; - v5 = 2 * result + 1; - v3 *= 4; - if ( v2 >= v5 ) - { - ++result; - v2 -= v5; - } - } - if ( val - result * result >= (unsigned int)(result - 1) ) - ++result; - return result; -} - -//----- (00452B2E) -------------------------------------------------------- -int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides) -{ - int v3; // esi@1 - - v3 = 0; - if ( uDiceSides ) - { - for ( uint i = 0; i < uNumDice; ++i) - v3 += rand() % uDiceSides + 1; - return v3; - } - return 0; -} diff -r 92eeeb5200f2 -r 68cdef6879a0 OurMath.h --- a/OurMath.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -#pragma once - -#include -#include - -/* 186 */ -#pragma pack(push, 1) -struct stru193_math -{ - stru193_math(); - int Cos(int angle); - unsigned int Atan2(int x, int y); - int Sin(int angle); - - int pTanTable[520]; - int pCosTable[520]; - int pInvCosTable[520]; - static const unsigned int uIntegerPi = 1024; - static const unsigned int uIntegerHalfPi = 512; - static const unsigned int uIntegerDoublePi = 2048; - static const unsigned int uDoublePiMask = 2047; - static const unsigned int uPiMask = 1023; - static const unsigned int uHalfPiMask = 511; -}; -#pragma pack(pop) - -__int64 fixpoint_mul(int, int); -__int64 fixpoint_dot(int x1, int x2, int y1, int y2, int z1, int z2); -__int64 fixpoint_div(int, int); -__int64 fixpoint_sub_unknown(int, int); -int fixpoint_from_float(float value); -int fixpoint_from_int(int lhv, int rhv); -int integer_sqrt(int val); -int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides); // idb -inline int round_to_int(float x) { return (int)floor(x + 0.5f); } - -template -inline int bankersRounding(const FloatType& value) -{ - assert("Method unsupported for this type" && false); - return value; -} - -template<> inline int bankersRounding(const float& inValue) -{ - union Cast - { - double d; - long l; - }; - volatile Cast c; - c.d = inValue + 6755399441055744.0; - return c.l; -} - -#pragma push_macro("max") -#undef max -template<> inline int bankersRounding(const double& inValue) -{ - double maxValue = std::numeric_limits::max(); - assert(maxValue - 6755399441055744.0 >= inValue); - union Cast - { - double d; - long l; - }; - volatile Cast c; - c.d = inValue + 6755399441055744.0; - return c.l; -} -#pragma pop_macro("max") - -extern struct stru193_math *stru_5C6E00; diff -r 92eeeb5200f2 -r 68cdef6879a0 Party.cpp --- a/Party.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1250 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include "ErrorHandling.h" - -#include "Party.h" -#include "Timer.h" -#include "AudioPlayer.h" -#include "IconFrameTable.h" -#include "Mouse.h" -#include "PlayerFrameTable.h" -#include "TurnEngine.h" -#include "Engine/Graphics/Viewport.h" -#include "Actor.h" -#include "GUIWindow.h" -#include "texts.h" - -#include "MM7.h" -#include "Engine/Graphics/Outdoor.h" -#include "LOD.h" -#include "SpriteObject.h" -#include "ObjectList.h" - - -#include "Game.h" - -Party *pParty; // idb - -struct ActionQueue *pPartyActionQueue = new ActionQueue; - - -std::array playerAlreadyPicked; // byte_AE3368_ -char PickedPlayer2_unused; // byte_AE3369_ -char PickedPlayer3_unused; // byte_AE336A_ -char PickedPlayer4_unused; // byte_AE336B_ - - - -//----- (0044A56A) -------------------------------------------------------- -void Party::CountHirelings() -{ - field_70A = 0; - - for (unsigned int i = 0; i < pNPCStats->uNumNewNPCs; ++i) - { - NPCData* npc = &pNPCStats->pNewNPCData[i]; - if (npc->Hired() && - (!pHirelings[0].pName || strcmp(npc->pName, pHirelings[0].pName))) - { - if (!pHirelings[1].pName || strcmp(npc->pName, pHirelings[1].pName)) - ++field_70A; - } - } -} - - -// inlined -//----- (mm6c::004858D0) -------------------------------------------------- -void Party::Zero() -{ - uFlags2 = 0; - uNumGoldInBank = 0; - - uCurrentYear = 0; - uCurrentMonth = 0; - uCurrentMonthWeek = 0; - uDaysPlayed = 0; - uCurrentHour = 0; - uCurrentMinute = 0; - uCurrentTimeSecond = 0; - - field_6FC = 0; - days_played_without_rest = 0; - vPosition.x = 0; - vPosition.y = 0; - vPosition.z = 0; - uFallStartY = 0; - sRotationY = 0; - sRotationX = 0; - uFallSpeed = 0; - field_28 = 0; - uDefaultPartyHeight = 192; - field_14_radius = 37; - y_rotation_granularity = 25; - y_rotation_speed = 90; - - uWalkSpeed = 384; - walk_sound_timer = 0; - - field_24 = 5; - field_6FC = 0; - field_708 = 15; - field_0 = 25; - - uNumDeaths = 0; - uNumPrisonTerms = 0; - uNumBountiesCollected = 0; - monster_for_hunting_killed.fill(0); - monster_id_for_hunting.fill(0); - memset(_quest_bits, 0, sizeof(_quest_bits)); - pArcomageWins.fill(0); - uNumArenaPageWins = 0; - uNumArenaSquireWins = 0; - uNumArenaKnightWins = 0; - uNumArenaLordWins = 0; -} - -//inlined -//----- (mm6c::0045BE90) -------------------------------------------------- -void ActionQueue::Reset() -{ - uNumActions = 0; -} - -//----- (004760C1) -------------------------------------------------------- -void ActionQueue::Add(PartyAction action) -{ - if (uNumActions < 30) - pActions[uNumActions++] = action; -} - -//----- (00497FC5) -------------------------------------------------------- -bool Party::_497FC5_check_party_perception_against_level() -{ - int uMaxPerception; // edi@1 - signed int v5; // eax@3 - bool result; // eax@7 - - uMaxPerception = 0; - for (int i = 0; i < 4; i++) - { - if ( this->pPlayers[i].CanAct() ) - { - v5 = this->pPlayers[i].GetPerception(); - if ( v5 > uMaxPerception ) - uMaxPerception = v5; - } - } - if ( uLevelMapStatsID && (signed int)uLevelMapStatsID < 77 ) - result = uMaxPerception >= 2 * pMapStats->pInfos[uLevelMapStatsID]._per; - else - result = 0; - return result; -} - -//----- (004936E1) -------------------------------------------------------- -void Party::SetHoldingItem(ItemGen *pItem) -{ - sub_421B2C_PlaceInInventory_or_DropPickedItem(); - memcpy(&pPickedItem, pItem, sizeof(pPickedItem)); - pMouse->SetCursorBitmapFromItemID(pPickedItem.uItemID); -} - -//----- (0049370F) -------------------------------------------------------- -int Party::GetNextActiveCharacter() -{ - int v2; // eax@4 - signed int v8; // esi@23 - int v12; // [sp+Ch] [bp-4h]@1 - - v12 = 0; - if ( pParty->bTurnBasedModeOn == 1 ) - { - if ( pTurnEngine->turn_stage != TE_ATTACK || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) != OBJECT_Player) - return 0; - v2 = PID_ID(pTurnEngine->pQueue[0].uPackedID); - return v2 + 1; - } - - if ( playerAlreadyPicked[0] && playerAlreadyPicked[1] && playerAlreadyPicked[2] && playerAlreadyPicked[3] ) - playerAlreadyPicked.fill(false); - for (int i = 0; i < 4; i++) - { - if ( !this->pPlayers[i].CanAct() || this->pPlayers[i].uTimeToRecovery > 0) - playerAlreadyPicked[i] = true; - else if ( !playerAlreadyPicked[i] ) - { - playerAlreadyPicked[i] = true; - if (i > 0) //TODO check if this condition really should be here. it is equal to the original source but still seems kind of weird - return i + 1; - break; - } - } - - for (int i = 0; i < 4; i++) - { - if ( this->pPlayers[i].CanAct() && this->pPlayers[i].uTimeToRecovery == 0 ) - { - if ( v12 == 0 || this->pPlayers[i].uSpeedBonus > v8 ) - { - v8 = this->pPlayers[i].uSpeedBonus; - v12 = i + 1; - } - } - } - return v12; -} - - -//----- (00493244) -------------------------------------------------------- -bool Party::HasItem(unsigned int uItemID) -{ - for (int player = 0; player < 4; player++) - { - for (int itemPos = 0; itemPos < 138; itemPos++) - { - if (pParty->pPlayers[player].pOwnItems[itemPos].uItemID == uItemID) - return true; - } - } - return false; -} - - -//----- (00492AD5) -------------------------------------------------------- -void Party::SetFood(unsigned int uNumFood) -{ - pUIAnim_Food->uAnimTime = 0; - pParty->uNumFoodRations = uNumFood; - pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Food->uIconID].uAnimLength; -} - -//----- (00492B03) -------------------------------------------------------- -void Party::TakeFood(unsigned int uNumFood) -{ - if (pParty->uNumFoodRations <= uNumFood) - pParty->uNumFoodRations = 0; - else - pParty->uNumFoodRations -= uNumFood; - - pUIAnim_Food->uAnimTime = 0; - pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Food->uIconID].uAnimLength; -} - -//----- (00492B42) -------------------------------------------------------- -void Party::GiveFood(unsigned int _this) -{ - pParty->uNumFoodRations += _this; - pUIAnim_Food->uAnimTime = 0; - pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Food->uIconID].uAnimLength; -} - -//----- (00492B70) -------------------------------------------------------- -void Party::SetGold(unsigned int uNumGold) -{ - pParty->uNumGold = uNumGold; - pUIAnim_Gold->uAnimTime = 0; - pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Gold->uIconID].uAnimLength; - pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); -} - -//----- (00492BB6) -------------------------------------------------------- -void Party::TakeGold(unsigned int uNumGold) -{ - if ( uNumGold <= pParty->uNumGold ) - pParty->uNumGold -= uNumGold; - else - pParty->uNumGold = 0; - pUIAnim_Gold->uAnimTime = 0; - pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Gold->uIconID].uAnimLength; - pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); -} - -//----- (0049135E) -------------------------------------------------------- -unsigned int Party::GetPartyFame() -{ - unsigned __int64 total_exp = 0; - for (uint i = 0; i < 4; ++i) - total_exp += pPlayers[i].uExperience; - return (unsigned int)(min(total_exp / 1000, UINT_MAX)); //min wasn't present, but could be incorrect without it -} - -//----- (0049137D) -------------------------------------------------------- -void Party::CreateDefaultParty(char bGiveItems) -{ - Player *pCharacter; // esi@3 - int uSkillIdx; // eax@11 - unsigned int v16; // [sp-4h] [bp-44h]@26 - signed int uNumPlayers; // [sp+18h] [bp-28h]@1 - ItemGen Dst; // [sp+1Ch] [bp-24h]@10 - - pHireling1Name[0] = 0; - pHireling2Name[0] = 0; - this->hirelingScrollPosition = 0; - memset(&pHirelings, 0, sizeof(pHirelings)); - - strcpy(this->pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]); //Zoltan - this->pPlayers[0].uPrevFace = 17; - this->pPlayers[0].uCurrentFace = 17; - this->pPlayers[0].uPrevVoiceID = 17; - this->pPlayers[0].uVoiceID = 17; - this->pPlayers[0].uMight = 30; - this->pPlayers[0].uIntelligence = 5; - this->pPlayers[0].uWillpower = 5; - this->pPlayers[0].uEndurance = 13; - this->pPlayers[0].uAccuracy = 13; - this->pPlayers[0].uSpeed = 14; - this->pPlayers[0].uLuck = 7; - this->pPlayers[0].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather - this->pPlayers[0].pActiveSkills[PLAYER_SKILL_ARMSMASTER] = 1; // armsmaster - this->pPlayers[0].pActiveSkills[PLAYER_SKILL_BOW] = 1; // bow - this->pPlayers[0].pActiveSkills[PLAYER_SKILL_SWORD] = 1; // sword - this->pPlayers[1].uPrevFace = 3; - this->pPlayers[1].uCurrentFace = 3; - this->pPlayers[1].uPrevVoiceID = 3; - this->pPlayers[1].uVoiceID = 3; - strcpy(this->pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); //Roderic - this->pPlayers[1].uMight = 13; - this->pPlayers[1].uIntelligence = 9; - this->pPlayers[1].uWillpower = 9; - this->pPlayers[1].uEndurance = 13; - this->pPlayers[1].uAccuracy = 13; - this->pPlayers[1].uSpeed = 13; - this->pPlayers[1].uLuck = 13; - this->pPlayers[1].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather - this->pPlayers[1].pActiveSkills[PLAYER_SKILL_STEALING] = 1; // stealing - this->pPlayers[1].pActiveSkills[PLAYER_SKILL_DAGGER] = 1; // dagger - this->pPlayers[1].pActiveSkills[PLAYER_SKILL_TRAP_DISARM] = 1; // disarm trap - this->pPlayers[2].uPrevFace = 14; - this->pPlayers[2].uCurrentFace = 14; - this->pPlayers[2].uPrevVoiceID = 14; - this->pPlayers[2].uVoiceID = 14; - strcpy(this->pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); // Serena - this->pPlayers[2].uMight = 12; - this->pPlayers[2].uIntelligence = 9; - this->pPlayers[2].uWillpower = 20; - this->pPlayers[2].uEndurance = 22; - this->pPlayers[2].uAccuracy = 7; - this->pPlayers[2].uSpeed = 13; - this->pPlayers[2].uLuck = 7; - this->pPlayers[2].pActiveSkills[PLAYER_SKILL_ALCHEMY] = 1; // alchemy - this->pPlayers[2].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather - this->pPlayers[2].pActiveSkills[PLAYER_SKILL_BODY] = 1; // body - this->pPlayers[2].pActiveSkills[PLAYER_SKILL_MACE] = 1; // mace - strcpy(this->pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]); // Alexis - this->pPlayers[3].uPrevFace = 10; - this->pPlayers[3].uCurrentFace = 10; - this->pPlayers[3].uEndurance = 13; - this->pPlayers[3].uAccuracy = 13; - this->pPlayers[3].uSpeed = 13; - this->pPlayers[3].uPrevVoiceID = 10; - this->pPlayers[3].uVoiceID = 10; - this->pPlayers[3].uMight = 5; - this->pPlayers[3].uIntelligence = 30; - this->pPlayers[3].uWillpower = 9; - this->pPlayers[3].uLuck = 7; - this->pPlayers[3].pActiveSkills[PLAYER_SKILL_LEATHER] = 1; // leather - this->pPlayers[3].pActiveSkills[PLAYER_SKILL_AIR] = 1; // air - this->pPlayers[3].pActiveSkills[PLAYER_SKILL_FIRE] = 1; // fire - this->pPlayers[3].pActiveSkills[PLAYER_SKILL_STAFF] = 1; // staff - for (uNumPlayers = 0; uNumPlayers < 4; uNumPlayers++) - { - pCharacter = &pParty->pPlayers[uNumPlayers]; - if (pCharacter->classType == PLAYER_CLASS_KNIGHT) - pCharacter->sResMagicBase = 10; //player[i].pResMagicBase - pCharacter->lastOpenedSpellbookPage = 0; - for (int i = 0; i < 9; i++)//for Magic Book - { - if (pPlayers[uNumPlayers].pActiveSkills[12+i]) - { - pCharacter->lastOpenedSpellbookPage = i; - break; - } - } - pCharacter->uExpressionTimePassed = 0; - Dst.Reset(); - if ( bGiveItems ) - { - pItemsTable->GenerateItem(2, 40, &Dst); //ring - pCharacter->AddItem2(-1, &Dst); - for (uSkillIdx = 0; uSkillIdx < 36; uSkillIdx++) - { - if ( pCharacter->pActiveSkills[uSkillIdx] ) - { - switch ( uSkillIdx ) - { - case PLAYER_SKILL_STAFF: - pCharacter->WearItem(ITEM_STAFF_1); - break; - case PLAYER_SKILL_SWORD: - pCharacter->WearItem(ITEM_LONGSWORD_1); - break; - case PLAYER_SKILL_DAGGER: - pCharacter->WearItem(ITEM_DAGGER_1); - break; - case PLAYER_SKILL_AXE: - pCharacter->WearItem(ITEM_AXE_1); - break; - case PLAYER_SKILL_SPEAR: - pCharacter->WearItem(ITEM_SPEAR_1); - break; - case PLAYER_SKILL_BOW: - pCharacter->WearItem(ITEM_CROSSBOW_1); - break; - case PLAYER_SKILL_MACE: - pCharacter->WearItem(ITEM_MACE_1); - break; - case PLAYER_SKILL_SHIELD: - pCharacter->WearItem(ITEM_BUCKLER_1); - break; - case PLAYER_SKILL_LEATHER: - pCharacter->WearItem(ITEM_LEATHER_1); - break; - case PLAYER_SKILL_CHAIN: - pCharacter->WearItem(ITEM_CHAINMAIL_1); - break; - case PLAYER_SKILL_PLATE: - pCharacter->WearItem(ITEM_PLATE_1); - break; - case PLAYER_SKILL_FIRE: - pCharacter->AddItem(-1, ITEM_SPELLBOOK_FIRE_STRIKE); - break; - case PLAYER_SKILL_AIR: - pCharacter->AddItem(-1, ITEM_SPELLBOOK_AIR_FEATHER_FALL); - break; - case PLAYER_SKILL_WATER: - pCharacter->AddItem(-1, ITEM_SPELLBOOK_WATER_POISON_SPRAY); - break; - case PLAYER_SKILL_EARTH: - pCharacter->AddItem(-1, ITEM_SPELLBOOK_EARTH_SLOW); - break; - case PLAYER_SKILL_SPIRIT: - pCharacter->AddItem(-1, ITEM_SPELLBOOK_SPIRIT_BLESS); - break; - case PLAYER_SKILL_MIND: - pCharacter->AddItem(-1, ITEM_SPELLBOOK_MIND_MIND_BLAST); - break; - case PLAYER_SKILL_BODY: - pCharacter->AddItem(-1, ITEM_SPELLBOOK_BODY_FIRST_AID); - break; - case PLAYER_SKILL_ITEM_ID: - case PLAYER_SKILL_REPAIR: - case PLAYER_SKILL_MEDITATION: - case PLAYER_SKILL_PERCEPTION: - case PLAYER_SKILL_DIPLOMACY: - case PLAYER_SKILL_TRAP_DISARM: - case PLAYER_SKILL_LEARNING: - pCharacter->AddItem(-1, ITEM_POTION_BOTTLE); - v16 = 5 * (rand() % 3 + 40); // simple reagent - pCharacter->AddItem(-1, v16); - break; - case PLAYER_SKILL_DODGE: - pCharacter->AddItem(-1, ITEM_BOOTS_1); - break; - case PLAYER_SKILL_UNARMED: - pCharacter->AddItem(-1, ITEM_GAUNTLETS_1); - break; - default: - break; - } - } - } - for (int i = 0; i < 138; i++) - { - if ( pCharacter->pInventoryItemList[i].uItemID != 0) - pCharacter->pInventoryItemList[i].SetIdentified(); - } - } - pCharacter->sHealth = pCharacter->GetMaxHealth(); - pCharacter->sMana = pCharacter->GetMaxMana(); - } -} - -//----- (004917CE) -------------------------------------------------------- -int Party::Reset() -{ - Zero(); - - field_708 = 15; - sEyelevel = 160; - uNumGold = 200; - uNumFoodRations = 7; - - - alignment = PartyAlignment_Neutral; - SetUserInterface(alignment, true); - - uTimePlayed = 0x21C00u; - uLastRegenerationTime = 0x21C00; - - bTurnBasedModeOn = false; - - uActiveCharacter = 1; - ::pPlayers.ZerothIndex() = &pPlayers[0]; - for (uint i = 0; i < 4; ++i) - ::pPlayers[i + 1] = &pPlayers[i]; - - pPlayers[0].Reset(PLAYER_CLASS_KNIGHT); - pPlayers[1].Reset(PLAYER_CLASS_THEIF); - pPlayers[2].Reset(PLAYER_CLASS_CLERIC); - pPlayers[3].Reset(PLAYER_CLASS_SORCERER); - pPlayers[0].uCurrentFace = 17; - pPlayers[0].uPrevVoiceID = 17; - pPlayers[0].uVoiceID = 17; - pPlayers[0].SetInitialStats(); - - pPlayers[0].uSex = pPlayers[0].GetSexByVoice(); - pPlayers[0].RandomizeName(); - strcpy(pPlayers[0].pName, pGlobalTXT_LocalizationStrings[509]); - - - pPlayers[1].uCurrentFace = 3; - pPlayers[1].uPrevVoiceID = 3; - pPlayers[1].uVoiceID = 3; - pPlayers[1].SetInitialStats(); - pPlayers[1].uSex = pPlayers[1].GetSexByVoice(); - pPlayers[1].RandomizeName(); - strcpy(pPlayers[1].pName, pGlobalTXT_LocalizationStrings[506]); - pPlayers[2].uCurrentFace = 14; - pPlayers[2].uPrevVoiceID = 14; - pPlayers[2].uVoiceID = 14; - pPlayers[2].SetInitialStats(); - pPlayers[2].uSex = pPlayers[3].GetSexByVoice(); - pPlayers[2].RandomizeName(); - strcpy(pPlayers[2].pName, pGlobalTXT_LocalizationStrings[508]); - pPlayers[3].uCurrentFace = 10; - pPlayers[3].uPrevVoiceID = 10; - pPlayers[3].uVoiceID = 10; - pPlayers[3].SetInitialStats(); - pPlayers[3].uSex = pPlayers[3].GetSexByVoice(); - pPlayers[3].RandomizeName(); - strcpy(pPlayers[3].pName, pGlobalTXT_LocalizationStrings[507]); - - for (uint i = 0; i < 4; ++i) - { - pPlayers[i].uTimeToRecovery = 0; - for (uint j = 0; j < 20; ++j) - pPlayers[i].pConditions[j] = 0; - - for (uint j = 0; j < 24; ++j) - pPlayers[i].pPlayerBuffs[j].Reset(); - - pPlayers[i].expression = CHARACTER_EXPRESSION_1; - pPlayers[i].uExpressionTimePassed = 0; - pPlayers[i].uExpressionTimeLength = rand() % 256 + 128; - } - - for (uint i = 1; i < 20; ++i) - pPartyBuffs[i].Reset(); - - - pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100; // default character ui - stats - uFlags = 0; - memset(_autonote_bits, 0, sizeof(_autonote_bits)); - memset(_quest_bits, 0, sizeof(_quest_bits)); - pIsArtifactFound.fill(0); - _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_RED_POTION_ACTIVE, 1); - _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_SEASHELL_ACTIVE, 1); - _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_LONGBOW_ACTIVE, 1); - _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_PLATE_ACTIVE, 1); - _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_LUTE_ACTIVE, 1); - _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_HAT_ACTIVE, 1); - - PartyTimes._shop_ban_times.fill(0); - - memcpy(pNPCStats->pNewNPCData, pNPCStats->pNPCData, 0x94BCu); - memcpy(pNPCStats->pGroups_copy, pNPCStats->pGroups, 0x66u); - pNPCStats->pNewNPCData[3].uFlags |= 128;//|= 0x80u; Lady Margaret - _494035_timed_effects__water_walking_damage__etc(); - pEventTimer->Pause(); - return 0; -} - - -//----- (0043AD34) -------------------------------------------------------- -void Party::Yell() -{ - Actor *v0; // esi@5 - int v1; // edi@9 - int v2; // ebx@9 - int v3; // eax@9 - - if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0 ) - pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); - if ( pParty->bTurnBasedModeOn != 1 ) - { - for (unsigned int i = 0; i < uNumActors; i++) - { - v0 = &pActors[i]; - if ( v0->Actor::CanAct() && v0->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long - && v0->pMonsterInfo.uMovementType != MONSTER_MOVEMENT_TYPE_STAIONARY ) - { - v1 = abs(v0->vPosition.x - pParty->vPosition.x); - v2 = abs(v0->vPosition.y - pParty->vPosition.y); - v3 = abs(v0->vPosition.z - pParty->vPosition.z); - if (int_get_vector_length(v1, v2, v3) < 512) - Actor::AI_Flee(i, 4, 0, 0); - } - } - } -} - -//----- (00491BF9) -------------------------------------------------------- -void Party::ResetPosMiscAndSpellBuffs() -{ - this->vPosition.y = 0; - this->vPosition.z = 0; - this->vPosition.x = 0; - this->uFallStartY = 0; - this->sRotationY = 0; - this->sRotationX = 0; - this->uFallSpeed = 0; - this->field_28 = 0; - this->uDefaultPartyHeight = 120; - this->field_14_radius = 37; - this->y_rotation_granularity = 25; - this->uWalkSpeed = 384; - this->y_rotation_speed = 90; - this->field_24 = 5; - this->field_6FC = 0; - this->field_708 = 15; - this->field_0 = 25; - - for (int playerId = 0; playerId < 4; playerId++) - { - for (int buffId = 0; buffId < 24; buffId++) - { - this->pPlayers[playerId].pPlayerBuffs[buffId].Reset(); - } - } - for (int buffId = 0; buffId < 20; buffId++) - { - this->pPartyBuffs[buffId].Reset(); - } -} - -//----- (004909F4) -------------------------------------------------------- -void Party::UpdatePlayersAndHirelingsEmotions() -{ - int v4; // edx@27 - - for (int i = 0; i < 4; ++i) - { - Player* player = &pPlayers[i]; - player->uExpressionTimePassed += (unsigned short)pMiscTimer->uTimeElapsed; - - uint condition = player->GetMajorConditionIdx(); - if (condition == Condition_Good || condition == Condition_Zombie) - { - if (player->uExpressionTimePassed < player->uExpressionTimeLength) - continue; - - player->uExpressionTimePassed = 0; - if (player->expression != 1 || rand() % 5) - { - player->expression = CHARACTER_EXPRESSION_1; - player->uExpressionTimeLength = rand() % 256 + 32; - } - else - { - v4 = rand() % 100; - if (v4 < 25) player->expression = CHARACTER_EXPRESSION_13; - else if (v4 < 31) player->expression = CHARACTER_EXPRESSION_14; - else if (v4 < 37) player->expression = CHARACTER_EXPRESSION_15; - else if (v4 < 43) player->expression = CHARACTER_EXPRESSION_16; - else if (v4 < 46) player->expression = CHARACTER_EXPRESSION_17; - else if (v4 < 52) player->expression = CHARACTER_EXPRESSION_18; - else if (v4 < 58) player->expression = CHARACTER_EXPRESSION_19; - else if (v4 < 64) player->expression = CHARACTER_EXPRESSION_20; - else if (v4 < 70) player->expression = CHARACTER_EXPRESSION_54; - else if (v4 < 76) player->expression = CHARACTER_EXPRESSION_55; - else if (v4 < 82) player->expression = CHARACTER_EXPRESSION_56; - else if (v4 < 88) player->expression = CHARACTER_EXPRESSION_57; - else if (v4 < 94) player->expression = CHARACTER_EXPRESSION_29; - else player->expression = CHARACTER_EXPRESSION_30; - } - - for (unsigned int j = 0; j < pPlayerFrameTable->uNumFrames; ++j) - { - PlayerFrame* frame = &pPlayerFrameTable->pFrames[j]; - if (frame->expression == player->expression) - { - player->uExpressionTimeLength = 8 * frame->uAnimLength; - break; - } - } - } - else if (player->expression != CHARACTER_EXPRESSION_DMGRECVD_MINOR && - player->expression != CHARACTER_EXPRESSION_DMGRECVD_MODERATE && - player->expression != CHARACTER_EXPRESSION_DMGRECVD_MAJOR || - player->uExpressionTimePassed >= player->uExpressionTimeLength) - { - player->uExpressionTimeLength = 0; - player->uExpressionTimePassed = 0; - - switch (condition) - { - case Condition_Dead: player->expression = CHARACTER_EXPRESSION_DEAD; break; - case Condition_Pertified: player->expression = CHARACTER_EXPRESSION_PERTIFIED; break; - case Condition_Eradicated: player->expression = CHARACTER_EXPRESSION_ERADICATED; break; - case Condition_Cursed: player->expression = CHARACTER_EXPRESSION_CURSED; break; - case Condition_Weak: player->expression = CHARACTER_EXPRESSION_WEAK; break; - case Condition_Sleep: player->expression = CHARACTER_EXPRESSION_SLEEP; break; - case Condition_Fear: player->expression = CHARACTER_EXPRESSION_FEAR; break; - case Condition_Drunk: player->expression = CHARACTER_EXPRESSION_DRUNK; break; - case Condition_Insane: player->expression = CHARACTER_EXPRESSION_INSANE; break; - case Condition_Poison_Weak: - case Condition_Poison_Medium: - case Condition_Poison_Severe: player->expression = CHARACTER_EXPRESSION_POISONED; break; - case Condition_Disease_Weak: - case Condition_Disease_Medium: - case Condition_Disease_Severe: player->expression = CHARACTER_EXPRESSION_DISEASED; break; - case Condition_Paralyzed: player->expression = CHARACTER_EXPRESSION_PARALYZED; break; - case Condition_Unconcious: player->expression = CHARACTER_EXPRESSION_UNCONCIOUS; break; - default: - Error("Invalid condition: %u", condition); - } - } - } - - for (int i = 0; i < 2; ++i) - { - NPCData* hireling = &pParty->pHirelings[i]; - if (!hireling->evt_C) - continue; - - hireling->evt_B += pMiscTimer->uTimeElapsed; - if (hireling->evt_B >= hireling->evt_C) - { - hireling->evt_A = 0; - hireling->evt_B = 0; - hireling->evt_C = 0; - - Assert(sizeof(NPCData) == 0x4C); - memset(hireling, 0, sizeof(*hireling)); - - pParty->hirelingScrollPosition = 0; - pParty->CountHirelings(); - viewparams->bRedrawGameUI = true; - } - } -} - -//----- (00490D02) -------------------------------------------------------- -void Party::RestAndHeal() -{ - Player *pPlayer; // esi@4 - bool have_vessels_soul; // [sp+10h] [bp-8h]@10 - - for ( uint i = 0; i < 20; ++i ) - pParty->pPartyBuffs[i].Reset(); - - for ( int pPlayerID = 0; pPlayerID < 4; ++pPlayerID ) - { - pPlayer = &pParty->pPlayers[pPlayerID]; - for ( uint i = 0; i < 20; ++i ) - pPlayer->pPlayerBuffs[i].Reset(); - - pPlayer->Zero(); - if ( pPlayer->pConditions[Condition_Dead] || pPlayer->pConditions[Condition_Pertified] || pPlayer->pConditions[Condition_Eradicated] )//Dead/Petrified/Eradicated - continue; - pPlayer->pConditions[Condition_Unconcious] = 0;//Unconcious - pPlayer->pConditions[Condition_Drunk] = 0;//Drunk - pPlayer->pConditions[Condition_Fear] = 0;//Fear - pPlayer->pConditions[Condition_Sleep] = 0;//Sleep - pPlayer->pConditions[Condition_Weak] = 0;//Weak - pPlayer->uTimeToRecovery = 0; - pPlayer->sHealth = pPlayer->GetMaxHealth(); - pPlayer->sMana = pPlayer->GetMaxMana(); - if ( pPlayer->classType == PLAYER_CLASS_LICH ) - { - have_vessels_soul = false; - for ( uint i = 0; i < 126; i++ ) - { - if ( pPlayer->pInventoryItemList[i].uItemID == ITEM_LICH_JAR_FULL && pPlayer->pInventoryItemList[i].uHolderPlayer == pPlayerID + 1 ) - have_vessels_soul = true; - } - if ( !have_vessels_soul ) - { - pPlayer->sHealth = pPlayer->GetMaxHealth() / 2; - pPlayer->sMana = pPlayer->GetMaxMana() / 2; - } - } - - if (pPlayer->pConditions[Condition_Zombie]) - { - pPlayer->sMana = 0; - pPlayer->sHealth /= 2; - } - else if ( pPlayer->pConditions[Condition_Poison_Severe] || pPlayer->pConditions[Condition_Disease_Severe] ) - { - pPlayer->sHealth /= 4; - pPlayer->sMana /= 4; - } - else if ( pPlayer->pConditions[Condition_Poison_Medium] || pPlayer->pConditions[Condition_Disease_Medium] ) - { - pPlayer->sHealth /= 3; - pPlayer->sMana /= 3; - } - else if ( pPlayer->pConditions[Condition_Poison_Weak] || pPlayer->pConditions[Condition_Disease_Weak] ) - { - pPlayer->sHealth /= 2; - pPlayer->sMana /= 2; - } - if ( pPlayer->pConditions[Condition_Insane] ) - pPlayer->sMana = 0; - UpdatePlayersAndHirelingsEmotions(); - } - pParty->days_played_without_rest = 0; -} - -//----- (004938D1) -------------------------------------------------------- -void __fastcall Rest(unsigned int uHoursToSleep) -{ - signed __int64 v2; // st7@3 - - if ( uHoursToSleep > 240 ) - Actor::InitializeActors(); - v2 = (signed __int64)((7680 * uHoursToSleep) * 0.033333335); - pParty->uTimePlayed += v2; - for (int i = 1; i <= 4; i++) - { - pPlayers[i]->Recover((int)v2); - } - _494035_timed_effects__water_walking_damage__etc(); -} -//----- (004B1BDB) -------------------------------------------------------- -void RestAndHeal(__int64 uNumMinutes) -{ - signed __int64 v1; // ST2C_8@1 - signed __int64 v2; // qax@1 - unsigned __int64 v4; // qax@1 - unsigned int v5; // ebx@1 - - pParty->pHirelings[0].bHasUsedTheAbility = 0; - pParty->pHirelings[1].bHasUsedTheAbility = 0; - pParty->uTimePlayed += (signed __int64)((double)(7680 * uNumMinutes) * 0.033333335); - v1 = (signed __int64)((double)(signed __int64)pParty->uTimePlayed * 0.234375); - v2 = v1 / 60 / 60; - v4 = (unsigned int)v2 / 0x18; - v5 = (unsigned int)(v4 / 7) >> 2; - pParty->uCurrentTimeSecond = v1 % 60; - pParty->uCurrentMinute = v1 / 60 % 60; - pParty->uCurrentHour = v2 % 24; - pParty->uCurrentMonthWeek = v4 / 7 & 3; - pParty->uDaysPlayed = (unsigned int)v4 % 0x1C; - pParty->uCurrentMonth = v5 % 0xC; - pParty->uCurrentYear = v5 / 0xC + game_starting_year; - pParty->RestAndHeal(); - - for (int i = 0; i < 4; i++) - { - pParty->pPlayers[i].uTimeToRecovery = 0; - pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0; - pParty->pPlayers[i].uNumArmageddonCasts = 0; - pParty->pPlayers[i].uNumFireSpikeCasts = 0; - pParty->pPlayers[i].field_1B3B = 0; - } - pParty->UpdatePlayersAndHirelingsEmotions(); -} -//----- (0041F5BE) -------------------------------------------------------- -void Party::Sleep6Hours() -{ - if ( _506F18_num_minutes_to_sleep < 6 ) - { - if ( _506F18_num_minutes_to_sleep ) - { - Rest(_506F18_num_minutes_to_sleep); - _506F18_num_minutes_to_sleep = 0; - OutdoorLocation::LoadActualSkyFrame(); - } - if ( dword_506F14 == 2 ) - { - pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0); - } - } - else - { - Rest(6u); - _506F18_num_minutes_to_sleep -= 6; - OutdoorLocation::LoadActualSkyFrame(); - } - viewparams->bRedrawGameUI = 1; -} - -bool TestPartyQuestBit( PARTY_QUEST_BITS bit ) -{ - return _449B57_test_bit(pParty->_quest_bits, bit); -} - -//----- (0047752B) -------------------------------------------------------- -int Party::GetPartyReputation() -{ - DDM_DLV_Header *v0; // ebx@1 - signed int v1; // esi@3 - - v0 = &pOutdoor->ddm; - if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) - v0 = &pIndoor->dlv; - v1 = 0; - if ( CheckHiredNPCSpeciality(Pirate) ) - v1 += 5; - if ( CheckHiredNPCSpeciality(Burglar) ) - v1 += 5; - if ( CheckHiredNPCSpeciality(Gypsy) ) - v1 += 5; - if ( CheckHiredNPCSpeciality(Duper) ) - v1 += 5; - if ( CheckHiredNPCSpeciality(FallenWizard) ) - v1 += 5; - return v1 + v0->uReputation; -} -//----- (004269A2) -------------------------------------------------------- -void Party::GivePartyExp(unsigned int pEXPNum) -{ - signed int pActivePlayerCount; // ecx@1 - int pLearningPercent; // eax@13 - - if ( pEXPNum > 0) - { - pActivePlayerCount = 0; - for ( uint i = 0; i < 4; ++i ) - { - if ( !pParty->pPlayers[i].pConditions[Condition_Unconcious] && - !pParty->pPlayers[i].pConditions[Condition_Dead] && - !pParty->pPlayers[i].pConditions[Condition_Pertified] && - !pParty->pPlayers[i].pConditions[Condition_Eradicated] ) - pActivePlayerCount ++; - } - if ( pActivePlayerCount ) - { - pEXPNum = pEXPNum / pActivePlayerCount; - for ( uint i = 0; i < 4; ++i ) - { - if ( !pParty->pPlayers[i].pConditions[Condition_Unconcious] && - !pParty->pPlayers[i].pConditions[Condition_Dead] && - !pParty->pPlayers[i].pConditions[Condition_Pertified] && - !pParty->pPlayers[i].pConditions[Condition_Eradicated] ) - { - pLearningPercent = pParty->pPlayers[i].GetLearningPercent(); - pEXPNum = pEXPNum + pEXPNum * pLearningPercent / 100; - pParty->pPlayers[i].uExperience += pEXPNum; - if ( pParty->pPlayers[i].uExperience > 4000000000i64 ) - { - pParty->pPlayers[i].uExperience = 0; - } - } - } - } - } -} -//----- (00420C05) -------------------------------------------------------- -void Party::PartyFindsGold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal) -{ - int hirelingSalaries; // ebp@1 - unsigned int goldToGain; // esi@1 - NPCData *v12; // ecx@21 - unsigned int v13; // ecx@23 - signed int hirelingCount; // [sp+Ch] [bp-4h]@6 - - hirelingSalaries = 0; - goldToGain = uNumGold; - - if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 2 ) - pTmpBuf2[0] = 0; - else if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 1 ) - { - sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], uNumGold);// You found %lu gold! - } - else - { - hirelingCount = 0; - for (int i = 0; i < 2; i++) - { - if (this->pHirelings[i].pName) - { - hirelingCount++; - pTmpBuf[hirelingCount] = i; - } - } - for (uint i = 0; i < pNPCStats->uNumNewNPCs; i++) - { - if ( pNPCStats->pNewNPCData[i].uFlags & 0x80 - && (!this->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, this->pHirelings[0].pName)) - && (!this->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, this->pHirelings[1].pName)) ) - { - hirelingCount++; - pTmpBuf[hirelingCount] = i + 2; - } - } - for (int i = 0; i < hirelingCount; i++) - { - uchar thisBufId = (uchar)pTmpBuf[i]; - if (thisBufId < 2) - v12 = &this->pHirelings[thisBufId]; - else - v12 = &pNPCStats->pNPCData[thisBufId + 499]; - v13 = v12->uProfession; - if ( v13 ) - hirelingSalaries += pNPCStats->pProfessions[v13].uHirePrice;//*(&pNPCStats->field_13A58 + 5 * v13); - } - if ( CheckHiredNPCSpeciality(Factor) ) - goldToGain += (signed int)(10 * goldToGain) / 100; - if ( CheckHiredNPCSpeciality(Banker) ) - goldToGain += (signed int)(20 * goldToGain) / 100; - if ( CheckHiredNPCSpeciality(Pirate) ) - goldToGain += (signed int)(10 * goldToGain) / 100; - if ( hirelingSalaries ) - { - hirelingSalaries = (signed int)(goldToGain * hirelingSalaries / 100) / 100; - if ( hirelingSalaries < 1 ) - hirelingSalaries = 1; - sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[466], goldToGain, hirelingSalaries);// You found %lu gold (followers take %lu)! - } - else - { - sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], goldToGain);// You found %lu gold! - } - } - this->uNumGold += goldToGain - hirelingSalaries; - pUIAnim_Gold->uAnimTime = 0; - pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Gold->uIconID].uAnimLength; - if ( pTmpBuf2[0] ) - ShowStatusBarString(pTmpBuf2.data(), 2u); - pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); -} -//----- (00421B2C) -------------------------------------------------------- -void Party::sub_421B2C_PlaceInInventory_or_DropPickedItem() -{ - unsigned int v0; // eax@2 - Texture *v1; // ebx@2 - int v2; // eax@3 - int v4; // eax@6 - unsigned __int16 v5; // dx@11 - signed int v6; // eax@11 - __int16 v8; // ax@16 - SpriteObject a1; // [sp+4h] [bp-78h]@11 - int v11; // [sp+74h] [bp-8h]@2 - int v12; // [sp+78h] [bp-4h]@5 - - if ( !pParty->pPickedItem.uItemID ) - return; - v0 = pIcons_LOD->LoadTexture( - pParty->pPickedItem.GetIconName(), - TEXTURE_16BIT_PALETTE); - v1 = pIcons_LOD->GetTexture(v0); - v11 = areWeLoadingTexture; - if ( uActiveCharacter - && (v2 = ::pPlayers[uActiveCharacter]->AddItem(-1, pParty->pPickedItem.uItemID)) != 0 ) - { - memcpy(&::pPlayers[uActiveCharacter]->pInventoryItemList[v2-1], &pParty->pPickedItem, 0x24u); - pMouse->RemoveHoldingItem(); - } - else - { - for (v12 = 0; v12 < 4; v12++) - { - v4 = pParty->pPlayers[v12].AddItem(-1, pParty->pPickedItem.uItemID); - if ( v4 ) - { - memcpy(&pParty->pPlayers[v12].pInventoryItemList[v4 - 1], &pParty->pPickedItem, sizeof(ItemGen)); - pMouse->RemoveHoldingItem(); - break; - } - } - if ( v12 == 4 ) - { - v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; - v6 = 0; - a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; - for ( uint i = 0; i < pObjectList->uNumObjects; i++ ) - { - if ( v5 == pObjectList->pObjects[i].uObjectID ) - { - v6 = i; - break; - } - } - a1.spell_caster_pid = OBJECT_Player; - a1.uObjectDescID = v6; - a1.vPosition.y = pParty->vPosition.y; - a1.vPosition.x = pParty->vPosition.x; - a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; - a1.uSoundID = 0; - a1.uFacing = 0; - a1.uAttributes = 8; - v8 = pIndoor->GetSector( - pParty->vPosition.x, - pParty->vPosition.y, - pParty->sEyelevel + pParty->vPosition.z); - a1.uSpriteFrameID = 0; - a1.uSectorID = v8; - memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24)); - a1.Create(pParty->sRotationY, 184, 200, 0); - pMouse->RemoveHoldingItem(); - } - } - if ( !v11 ) - { - v1->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - return; -} - - -//----- (0048C6F6) -------------------------------------------------------- -bool Party::AddItemToParty(ItemGen *pItem) -{ - unsigned int v2; // eax@1 - char *v5; // eax@8 - Texture *v7; // ebx@10 - signed int v8; // esi@10 - Player *v9; // edi@11 - int v10; // eax@11 - int v21; // [sp+24h] [bp-4h]@10 - - v2 = pItem->uItemID; - if ( !pItemsTable->pItems[v2].uItemID_Rep_St ) - pItem->SetIdentified(); - - v5 = pItemsTable->pItems[v2].pIconName; - if ( v5 ) - { - v7 = pIcons_LOD->LoadTexturePtr(v5, TEXTURE_16BIT_PALETTE); - v21 = areWeLoadingTexture; - v8 = 0; - uint current_player = uActiveCharacter; - for (int i = 0; i < 4; i++) - { - current_player = current_player + i; - if ( current_player > 4 ) - current_player = current_player - 4; - v9 = ::pPlayers[current_player]; - v10 = v9->AddItem(-1, pItem->uItemID); - if ( v10 ) - { - memcpy(&v9->pInventoryItemList[v10-1], pItem, 0x24u); - pItem->Reset(); - pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); - v9->PlaySound(SPEECH_60, 0); - if ( !v21 ) - { - v7->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - return true; - } - } - if ( !v21 ) - { - v7->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - return false; - } - else - { - MessageBoxW(nullptr, L"Invalid picture_name detected ::addItem()", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Party.cpp:795", 0); - return false; - } -} -// 506128: using guessed type int areWeLoadingTexture; - -bool Party::IsPartyEvil() -{ - return _449B57_test_bit(_quest_bits, 100); -} - -bool Party::IsPartyGood() -{ - return _449B57_test_bit(_quest_bits, 99); -} - - - -//----- (0046A89E) -------------------------------------------------------- -int Party::_46A89E_immolation_effect(int* affected, int affectedArrSize, int effectRange) -{ - int v5; // ebx@3 - int v17; // [sp+Ch] [bp-10h]@3 - int v18; // [sp+10h] [bp-Ch]@3 - int affectedCount; // [sp+18h] [bp-4h]@1 - - affectedCount = 0; - for ( size_t i = 0; i < uNumActors; ++i ) - { - v5 = abs(pActors[i].vPosition.x - this->vPosition.x); - v17 = abs(pActors[i].vPosition.y - this->vPosition.y); - v18 = abs(pActors[i].vPosition.z - this->vPosition.z); - if ( int_get_vector_length(v5, v17, v18) <= effectRange ) - { - if ( pActors[i].uAIState != Dead && pActors[i].uAIState != Dying && pActors[i].uAIState != Removed - && pActors[i].uAIState != Disabled && pActors[i].uAIState != Summoned ) - { - affected[affectedCount] = i; - affectedCount++; - if ( affectedCount >= affectedArrSize ) - break; - } - } - } - return affectedCount; -} - -//----- (00444D80) -------------------------------------------------------- -int GetTravelTime() -{ - signed int new_travel_time; // esi@1 - - new_travel_time = uDefaultTravelTime_ByFoot; - if ( CheckHiredNPCSpeciality(Guide) ) - --new_travel_time; - if ( CheckHiredNPCSpeciality(Tracker) ) - new_travel_time -= 2; - if ( CheckHiredNPCSpeciality(Pathfinder) ) - new_travel_time -= 3; - if ( CheckHiredNPCSpeciality(Explorer) ) - --new_travel_time; - if ( new_travel_time < 1 ) - new_travel_time = 1; - return new_travel_time; -} -// 6BD07C: using guessed type int uDefaultTravelTime_ByFoot; - -//----- (00449B57) -------------------------------------------------------- -bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2) -{ - return (a1[(a2 - 1) >> 3] & (0x80 >> (a2 - 1) % 8)) != 0; -} - -//----- (00449B7E) -------------------------------------------------------- -void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle) -{ - signed int v3; // esi@1 - unsigned char set_bit; // edx@1 - - v3 = a2 - 1; - set_bit = 0x80 >> v3 % 8; - if (bToggle) - pArray[v3 / 8] |= set_bit; - else - pArray[v3 / 8] &= ~set_bit; -} - -//----- (004760D5) -------------------------------------------------------- -PartyAction ActionQueue::Next() -{ - if (!uNumActions) - return PARTY_INVALID; - - PartyAction result = pActions[0]; - for (unsigned int i = 0; i < uNumActions - 1; ++i) - pActions[i] = pActions[i + 1]; - --uNumActions; - - return result; -} diff -r 92eeeb5200f2 -r 68cdef6879a0 Party.h --- a/Party.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,333 +0,0 @@ -#pragma once -#include "Player.h" -#include "NPC.h" -#include - - - -#define PARTY_AUTONOTES_BIT__EMERALD_FIRE_FOUNTAIN 2 - -enum PARTY_QUEST_BITS: uint16_t -{ - PARTY_QUEST_EMERALD_RED_POTION_ACTIVE = 1, - PARTY_QUEST_EMERALD_SEASHELL_ACTIVE = 2, - PARTY_QUEST_EMERALD_LONGBOW_ACTIVE = 3, - PARTY_QUEST_EMERALD_PLATE_ACTIVE = 4, - PARTY_QUEST_EMERALD_LUTE_ACTIVE = 5, - PARTY_QUEST_EMERALD_HAT_ACTIVE = 6, - - PARTY_QUEST_EMERALD_MARGARETH_OFF = 17, - - 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, - PARTY_QUEST_FOUNTAIN_CELESTIA = 209, - PARTY_QUEST_FOUNTAIN_THE_PIT = 210, - PARTY_QUEST_FOUNTAIN_EVENMORN_ISLE = 211 -}; - -/* 355 */ -enum PARTY_FLAGS_1: __int32 -{ - PARTY_FLAGS_1_0002 = 0x0002, - PARTY_FLAGS_1_WATER_DAMAGE = 0x0004, - PARTY_FLAGS_1_FALLING = 0x0008, - PARTY_FLAGS_1_ALERT_RED = 0x0010, - PARTY_FLAGS_1_ALERT_YELLOW = 0x0020, - PARTY_FLAGS_1_STANDING_ON_WATER = 0x0080, - PARTY_FLAGS_1_LANDING = 0x0100, - PARTY_FLAGS_1_BURNING = 0x200 -}; -enum PARTY_FLAGS_2: __int32 -{ - PARTY_FLAGS_2_RUNNING = 0x2, -}; - -/* 347 */ -enum PARTY_BUFF_INDEX -{ - PARTY_BUFF_RESIST_AIR = 0, - PARTY_BUFF_RESIST_BODY = 1, - PARTY_BUFF_DAY_OF_GODS = 2, - PARTY_BUFF_DETECT_LIFE = 3, - PARTY_BUFF_RESIST_EARTH = 4, - PARTY_BUFF_FEATHER_FALL = 5, - PARTY_BUFF_RESIST_FIRE = 6, - PARTY_BUFF_FLY = 7, - PARTY_BUFF_HASTE = 8, - PARTY_BUFF_HEROISM = 9, - PARTY_BUFF_IMMOLATION = 10, - PARTY_BUFF_INVISIBILITY = 11, - PARTY_BUFF_RESIST_MIND = 12, - PARTY_BUFF_PROTECTION_FROM_MAGIC = 13, - PARTY_BUFF_SHIELD = 14, - PARTY_BUFF_STONE_SKIN = 15, - PARTY_BUFF_TORCHLIGHT = 16, - PARTY_BUFF_RESIST_WATER = 17, - PARTY_BUFF_WATER_WALK = 18, - PARTY_BUFF_WIZARD_EYE = 19, -}; - - - -/* 300 */ -enum PartyAction: unsigned __int32 -{ - PARTY_INVALID = 0, - PARTY_TurnLeft = 0x1, - PARTY_TurnRight = 0x2, - PARTY_StrafeLeft = 0x3, - PARTY_StrafeRight = 0x4, - PARTY_WalkForward = 0x5, - PARTY_WalkBackward = 0x6, - PARTY_LookUp = 0x7, - PARTY_LookDown = 0x8, - PARTY_CenterView = 0x9, - PARTY_unkA = 0xA, - PARTY_unkB = 0xB, - PARTY_Jump = 0xC, - PARTY_FlyUp = 0xD, - PARTY_FlyDown = 0xE, - PARTY_Land = 0xF, - PARTY_RunForward = 0x10, - PARTY_RunBackward = 0x11, - PARTY_FastTurnLeft = 0x12, - PARTY_FastTurnRight = 0x13, - - PARTY_dword = 0xFFFFFFFF -}; - - - -/* 135 */ -#pragma pack(push, 1) -struct ActionQueue -{ - inline ActionQueue(): - uNumActions(0) - {} - - void Add(PartyAction action); - void Reset(); - PartyAction Next(); - - unsigned int uNumActions; - PartyAction pActions[30]; -}; -#pragma pack(pop) - - - - - -enum PartyAlignment: unsigned __int32 -{ - PartyAlignment_Good = 0, - PartyAlignment_Neutral = 1, - PartyAlignment_Evil = 2 -}; - - - - - -/* 208 */ -#pragma pack(push, 1) -struct PartyTimeStruct -{ - std::array<__int64, 10> bountyHunting_next_generation_time; - std::array<__int64, 85> Shops_next_generation_time;//field_50 - std::array<__int64, 53> _shop_ban_times; - std::array CounterEventValues; // (0xACD314h in Silvo's binary) - std::array<__int64, 29> HistoryEventTimes; // (0xACD364h in Silvo's binary) - std::array _s_times; //5d8 440h+8*51 //(0xACD44Ch in Silvo's binary) -}; -#pragma pack(pop) - -/* 207 */ -#pragma pack(push, 1) -struct Party -{ - Party(): - uTimePlayed(0) - { - Zero(); - } - - void Zero(); - void UpdatePlayersAndHirelingsEmotions(); - void RestAndHeal(); - unsigned int GetPartyFame(); - void CreateDefaultParty(char bGiveItems); - int Reset(); - void ResetPosMiscAndSpellBuffs(); - bool HasItem(unsigned int uItemID); - void SetHoldingItem(ItemGen *pItem); - int GetNextActiveCharacter(); - bool _497FC5_check_party_perception_against_level(); - bool AddItemToParty(ItemGen *pItem); - void Yell(); - void CountHirelings(); - - void GivePartyExp(unsigned int pEXPNum); - int GetPartyReputation(); - - - void PartyFindsGold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal); - void sub_421B2C_PlaceInInventory_or_DropPickedItem(); - - static void SetGold(unsigned int uNumGold); - static void TakeGold(unsigned int uNumGold); - static void SetFood(unsigned int uNumFood); - static void TakeFood(unsigned int uNumFood); - static void GiveFood(unsigned int _this); - - static void Sleep6Hours(); - - inline bool WizardEyeActive() {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uExpireTime > 0;} - inline int WizardEyeSkillLevel() {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uSkill;} - inline bool TorchlightActive() {return pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0;} - inline bool FlyActive() {return pPartyBuffs[PARTY_BUFF_FLY].uExpireTime > 0;} - inline bool WaterWalkActive() {return pPartyBuffs[PARTY_BUFF_WATER_WALK].uExpireTime > 0;} - inline bool ImmolationActive() {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uExpireTime > 0;} - inline int ImmolationSkillLevel() {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uSkill;} - inline bool FeatherFallActive() {return pPartyBuffs[PARTY_BUFF_FEATHER_FALL].uExpireTime > 0;} - inline bool Invisible() {return pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0;} - - inline bool GetRedAlert() {return (uFlags & PARTY_FLAGS_1_ALERT_RED) != 0;} - inline void SetRedAlert() {uFlags |= PARTY_FLAGS_1_ALERT_RED;} - inline bool GetYellowAlert() {return (uFlags & PARTY_FLAGS_1_ALERT_YELLOW) != 0;} - inline void SetYellowAlert() {uFlags |= PARTY_FLAGS_1_ALERT_YELLOW;} - - bool IsPartyEvil(); - bool IsPartyGood(); - int _46A89E_immolation_effect(int* affected, int affectedArrSize, int effectRange); - int field_0; - unsigned int uPartyHeight; - unsigned int uDefaultPartyHeight; - int sEyelevel; - unsigned int uDefaultEyelevel; - int field_14_radius; - int y_rotation_granularity; - unsigned int uWalkSpeed; - int y_rotation_speed; // deg/s - int field_24; - int field_28; - unsigned __int64 uTimePlayed; - __int64 uLastRegenerationTime; - PartyTimeStruct PartyTimes; - Vec3_int_ vPosition; - int sRotationY; - int sRotationX; - Vec3_int_ vPrevPosition; - int sPrevRotationY; - int sPrevRotationX; - int sPrevEyelevel; - int field_6E0; - int field_6E4; - int uFallSpeed; - int field_6EC; - int field_6F0; - int floor_face_pid; // face we are standing at - int walk_sound_timer; - int field_6FC; - int uFallStartY; - unsigned int bFlying; - char field_708; - unsigned __int8 hirelingScrollPosition; - char field_70A; - char field_70B; - unsigned int uCurrentYear; - unsigned int uCurrentMonth; - unsigned int uCurrentMonthWeek; - unsigned int uDaysPlayed; - unsigned int uCurrentHour; - unsigned int uCurrentMinute; - unsigned int uCurrentTimeSecond; - unsigned int uNumFoodRations; - int field_72C; - int field_730; - unsigned int uNumGold; - unsigned int uNumGoldInBank; - unsigned int uNumDeaths; - int field_740; - int uNumPrisonTerms; - unsigned int uNumBountiesCollected; - int field_74C; - std::array<__int16, 5> monster_id_for_hunting; - std::array<__int16, 5> monster_for_hunting_killed; - unsigned char days_played_without_rest; - unsigned __int8 _quest_bits[64]; - std::array pArcomageWins; - char field_7B5_in_arena_quest; - char uNumArenaPageWins; - char uNumArenaSquireWins; - char uNumArenaKnightWins; - char uNumArenaLordWins; - std::array pIsArtifactFound; //7ba - std::array field_7d7; - unsigned char _autonote_bits[26]; - std::array field_818; - std::array field_854; - int uNumArcomageWins; - int uNumArcomageLoses; - unsigned int bTurnBasedModeOn; - int field_880; - int uFlags2; - PartyAlignment alignment; - std::array pPartyBuffs; - std::array pPlayers; - std::array pHirelings; - ItemGen pPickedItem; - unsigned int uFlags; - std::array, 53> StandartItemsInShops; - std::array, 53> SpecialItemsInShops; //D0EC - std::array, 32> SpellBooksInGuilds; - std::array field_1605C; - char pHireling1Name[100]; - char pHireling2Name[100]; - int armageddon_timer; - int armageddonDamage; - std::array pTurnBasedPlayerRecoveryTimes; - std::array InTheShopFlags; - int uFine; - float flt_TorchlightColorR; - float flt_TorchlightColorG; - float flt_TorchlightColorB; -}; -#pragma pack(pop) - - - -extern Party *pParty; // idb - - -extern struct ActionQueue *pPartyActionQueue; - -bool TestPartyQuestBit(PARTY_QUEST_BITS bit); -void __fastcall Rest(unsigned int uHoursToSleep); -void RestAndHeal(__int64 uNumMinutes); // idb -int GetTravelTime(); - -bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2); -void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb diff -r 92eeeb5200f2 -r 68cdef6879a0 PlayerFrameTable.cpp --- a/PlayerFrameTable.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,224 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS - -#include "PlayerFrameTable.h" - -#include "ErrorHandling.h" -#include "FrameTableInc.h" -#include "mm7_data.h" - - -//----- (00494AED) -------------------------------------------------------- -unsigned int PlayerFrameTable::GetFrameIdByExpression(CHARACTER_EXPRESSION_ID expression) -{ - for (uint i = 0; i < this->uNumFrames; i++) - { - if (this->pFrames[i].expression == expression) - return i; - } - return 0; -} - -//----- (00494B10) -------------------------------------------------------- -PlayerFrame *PlayerFrameTable::GetFrameBy_x(unsigned int uFramesetID, unsigned int uFrameID) -{ - unsigned int v3; // esi@1 - __int16 v6; // dx@2 - int v7; // edx@3 - char *i; // eax@3 - int v9; // ecx@5 - PlayerFrame *result; // eax@6 - - v3 = uFramesetID; - if (this->pFrames[uFramesetID].uFlags & 1 && (v6 = this->pFrames[uFramesetID].uAnimLength) != 0) - { - v7 = ((signed int)uFrameID >> 3) % (unsigned __int16)v6; - for (i = (char *)&this->pFrames[uFramesetID].uAnimTime;; i += 10) - { - v9 = *(short *)i; - if (v7 <= v9) - break; - v7 -= v9; - ++v3; - } - result = &this->pFrames[v3]; - } - else - result = &this->pFrames[uFramesetID]; - return result; -} - -//----- (00494B5E) -------------------------------------------------------- -PlayerFrame *PlayerFrameTable::GetFrameBy_y(int *pFramesetID, int *pAnimTime, int a4) -{ - int v5; // esi@1 - int v6; // eax@2 - - v5 = a4 + *pAnimTime; - if (v5 < 8 * this->pFrames[*pFramesetID].uAnimTime) - *pAnimTime = v5; - else - { - v6 = rand() % 4 + 21; - *pFramesetID = v6; - *pAnimTime = 8 * v5 % this->pFrames[v6].uAnimTime; - } - return &this->pFrames[*pFramesetID]; -} - -//----- (00494BC3) -------------------------------------------------------- -void PlayerFrameTable::ToFile() -{ - PlayerFrameTable *v1; // esi@1 - FILE *v2; // eax@1 - FILE *v3; // edi@1 - - PlayerFrameTable* Str = this; - - v1 = Str; - v2 = fopen("data\\dpft.bin", "wb"); - v3 = v2; - if (!v2) - Error("Unable to save dpft.bin"); - fwrite(v1, 4, 1, v2); - fwrite(v1->pFrames, 0xAu, v1->uNumFrames, v3); - fclose(v3); -} - -//----- (00494C0F) -------------------------------------------------------- -void PlayerFrameTable::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) -{ - uint num_mm6_frames = data_mm6 ? *(int *)data_mm6 : 0, - num_mm7_frames = data_mm7 ? *(int *)data_mm7 : 0, - num_mm8_frames = data_mm8 ? *(int *)data_mm8 : 0; - uNumFrames = num_mm6_frames + num_mm7_frames + num_mm8_frames; - assert(uNumFrames); - assert(!num_mm8_frames); - - pFrames = (PlayerFrame *)malloc(uNumFrames * sizeof(PlayerFrame)); - memcpy(pFrames, (char *)data_mm7 + 4, num_mm7_frames * sizeof(PlayerFrame)); - memcpy(pFrames + num_mm7_frames, (char *)data_mm6 + 4, num_mm6_frames * sizeof(PlayerFrame)); - memcpy(pFrames + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 4, num_mm8_frames * sizeof(PlayerFrame)); -} - -//----- (00494C5A) -------------------------------------------------------- -int PlayerFrameTable::FromFileTxt(const char *Args) -{ - //PlayerFrameTable *v2; // ebx@1 - FILE *v3; // eax@1 - int v4; // esi@3 - void *v5; // eax@10 - FILE *v6; // ST0C_4@12 - char *i; // eax@12 - // __int16 v8; // ax@15 - // const char *v9; // ST10_4@15 - // unsigned __int16 v10; // ax@15 - // const char *v11; // ST0C_4@15 - int j; // esi@15 - // int v13; // eax@17 - int v14; // edx@22 - int v15; // ecx@23 - int v16; // eax@24 - signed int k; // eax@27 - //PlayerFrame *v18; // edx@28 - int v19; // esi@28 - int l; // ecx@29 - char Buf; // [sp+Ch] [bp-2F8h]@3 - FrameTableTxtLine v23; // [sp+200h] [bp-104h]@4 - FrameTableTxtLine v24; // [sp+27Ch] [bp-88h]@4 - int v25; // [sp+2F8h] [bp-Ch]@3 - int v26; // [sp+2FCh] [bp-8h]@3 - FILE *File; // [sp+300h] [bp-4h]@1 - int Argsa; // [sp+30Ch] [bp+8h]@28 - - __debugbreak();//Ritor1; - //TileTable::dtor((TileTable *)this); - v3 = fopen(Args, "r"); - File = v3; - if (!v3) - Error("PlayerFrameTable::load - Unable to open file: %s.", Args); - v4 = 0; - v25 = 0; - v26 = 1; - if (fgets(&Buf, 490, v3)) - { - do - { - *strchr(&Buf, 10) = 0; - memcpy(&v24, txt_file_frametable_parser(&Buf, &v23), sizeof(v24)); - if (v24.uPropCount && *v24.pProperties[0] != 47) - { - if (v24.uPropCount < 3) - Error("PlayerFrameTable::load, too few arguments, %s line %i.", Args, v26); - ++v25; - } - ++v26; - } while (fgets(&Buf, 490, File)); - v4 = v25; - } - this->uNumFrames = v4; - v5 = malloc(10 * v4); - this->pFrames = (PlayerFrame *)v5; - if (!v5) - Error("PlayerFrameTable::load - Out of Memory!"); - v6 = File; - this->uNumFrames = 0; - fseek(v6, 0, 0); - for (i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File)) - { - *strchr(&Buf, 10) = 0; - memcpy(&v24, txt_file_frametable_parser(&Buf, &v23), sizeof(v24)); - if (v24.uPropCount && *v24.pProperties[0] != 47) - { - //v8 = atoi(v24.pProperties[0]); - //v9 = v24.pProperties[1]; - this->pFrames[this->uNumFrames].expression = (CHARACTER_EXPRESSION_ID)atoi(v24.pProperties[0]); - //v10 = atoi(v9); - //v11 = v24.pProperties[2]; - this->pFrames[this->uNumFrames].uTextureID = atoi(v24.pProperties[1]); - this->pFrames[this->uNumFrames].uAnimTime = atoi(v24.pProperties[2]); - this->pFrames[this->uNumFrames].uAnimLength = 0; - this->pFrames[this->uNumFrames].uFlags = 0; - for (j = 3; j < v24.uPropCount; ++j) - { - if (!_stricmp(v24.pProperties[j], "New")) - this->pFrames[this->uNumFrames].uFlags |= 4; - } - ++this->uNumFrames; - } - } - fclose(File); - - if ((signed int)(this->uNumFrames - 1) > 0) - { - v15 = 0; - for (v14 = 0; v14 < this->uNumFrames - 1; ++v14) - { - v16 = (int)&this->pFrames[v15]; - if (!(*(char *)(v16 + 18) & 4)) - this->pFrames[v14].uFlags |= 1; - ++v15; - } - } - for (k = 0; k < (signed int)this->uNumFrames; *(short *)(Argsa + 6) = v19) - { - //v18 = this->pFrames; - Argsa = (int)&this->pFrames[k]; - v19 = *(short *)(Argsa + 4); - if (this->pFrames[k].uFlags & 1) - { - ++k; - for (l = (int)&this->pFrames[k]; this->pFrames[k].uFlags & 1; l += 10) - { - v19 += *(short *)(l + 4); - ++k; - } - LOWORD(v19) = this->pFrames[k].uAnimTime + v19; - } - ++k; - } - return 1; -} diff -r 92eeeb5200f2 -r 68cdef6879a0 PlayerFrameTable.h --- a/PlayerFrameTable.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -#pragma once - -#include "Player.h" - -/* 46 */ -#pragma pack(push, 1) -struct PlayerFrame -{ - CHARACTER_EXPRESSION_ID expression; - unsigned __int16 uTextureID; - __int16 uAnimTime; - __int16 uAnimLength; - __int16 uFlags; -}; -#pragma pack(pop) - - -/* 47 */ -#pragma pack(push, 1) -struct PlayerFrameTable -{ - inline PlayerFrameTable(): - uNumFrames(0), pFrames(nullptr) - {} - - unsigned int GetFrameIdByExpression(CHARACTER_EXPRESSION_ID expression); - PlayerFrame *GetFrameBy_x(unsigned int uFramesetID, unsigned int uFrameID); - PlayerFrame *GetFrameBy_y(int *a2, int *a3, int a4); - void ToFile(); - void FromFile(void *data_mm6, void *data_mm7, void *data_mm8); - int FromFileTxt(const char *Args); - - unsigned int uNumFrames; - struct PlayerFrame *pFrames; -}; -#pragma pack(pop) - - - -extern struct PlayerFrameTable *pPlayerFrameTable; // idb \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Random.cpp --- a/Random.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include - -#include "Random.h" -#include "OurMath.h" - - - - -struct Random *pRnd=new Random(); // idb - - - - - -//----- (004BE59E) -------------------------------------------------------- -void Random::SetRange(int min, int max) -{ - this->min = min; - this->range = max - min; -} - -//----- (004BE5B1) -------------------------------------------------------- -double Random::GetRandom() -{ - Random *v1; // esi@1 - double v2; // st7@1 - double v3; // st7@1 - - v1 = this; - this->field_0[3] = this->field_0[2]; - this->field_0[2] = this->field_0[1]; - v2 = this->field_0[0]; - this->field_0[1] = v2; - v3 = this->field_0[3] * 1492.0 - + this->field_0[2] * 1776.0 - + this->field_0[3] * 2111111111.0 - + v2 * 5115.0 - + this->field_0[4]; - v1->field_0[0] = v3 - floor(v3); - v1->field_0[4] = floor(v3) * 2.328306436538696e-10; - return v1->field_0[0]; -} - -//----- (004BE623) -------------------------------------------------------- -int Random::GetInRange() -{ -// Random *v1; // esi@1 - float v2; // ST10_4@1 -// double v3; // ST04_8@1 - int floored_random; // ecx@1 - - v2 = GetRandom() * (double)this->range; - floored_random = bankersRounding(v2); - if ( floored_random >= this->range ) - floored_random = this->range; - return floored_random + this->min; -} - -//----- (004BE65D) -------------------------------------------------------- -void Random::Initialize(int seed) -{ - int v2; // eax@1 - Random *this_; // esi@1 - signed int v4; // ecx@3 - unsigned int v5; // eax@4 - signed int v6; // edi@5 - - v2 = seed; - this_ = this; - if ( !seed ) - v2 = -1; - v4 = 0; - do - { - v5 = (((v2 << 13) ^ (unsigned int)v2) >> 17) ^ (v2 << 13) ^ v2; - v2 = 32 * v5 ^ v5; - this_->field_0[v4++] = (double)(unsigned int)v2 * 2.328306436538696e-10; - } - while ( v4 < 5 ); - v6 = 19; - do - { - GetRandom(); - --v6; - } - while ( v6 ); -} - diff -r 92eeeb5200f2 -r 68cdef6879a0 Random.h --- a/Random.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -#pragma once - - -/* 304 */ -#pragma pack(push, 1) -struct Random -{ - //----- (004BE365) -------------------------------------------------------- - inline Random() - { - Initialize(0x5CCE1E47u); - min = 0; - range = 99; - } - - - void SetRange(int min, int max); - double GetRandom(); - int GetInRange(); - void Initialize(int seed); - - double field_0[5]; - int min; - int range; -}; -#pragma pack(pop) - - - - -extern struct Random *pRnd; // idb \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Registry.cpp --- a/Registry.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,189 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include -#include -#include - -#include "Registry.h" -#include "ErrorHandling.h" - -//----- (004649EF) -------------------------------------------------------- -int __fastcall ReadWindowsRegistryInt(const char *pKey, int uDefValue) -{ - DWORD cbData; // [sp+8h] [bp-20h]@1 - LPCSTR lpValueName; // [sp+Ch] [bp-1Ch]@1 - DWORD dwDisposition; // [sp+10h] [bp-18h]@2 - BYTE Data[4]; // [sp+14h] [bp-14h]@5 - HKEY hKey; // [sp+18h] [bp-10h]@1 - HKEY phkResult; // [sp+1Ch] [bp-Ch]@1 - HKEY v10; // [sp+20h] [bp-8h]@1 - HKEY v11; // [sp+24h] [bp-4h]@1 - - lpValueName = pKey; - v11 = 0; - v10 = 0; - hKey = 0; - phkResult = 0; - cbData = 4; - if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) )// for 64 bit - { - if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition) ) - { - if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v10, &dwDisposition) ) - { - if ( !RegCreateKeyExA(v10, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v11, &dwDisposition) ) - { - LSTATUS status; - if ( status = RegQueryValueExA(v11, lpValueName, 0, 0, Data, &cbData) ) - { - status; - GetLastError(); - - *(int *)Data = uDefValue; - RegSetValueExA(v11, lpValueName, 0, 4, Data, 4); - } - RegCloseKey(v11); - } - RegCloseKey(v10); - } - RegCloseKey(phkResult); - } - RegCloseKey(hKey); - } - return *(int *)Data; -} - -//----- (00464B02) -------------------------------------------------------- -void __fastcall WriteWindowsRegistryString(const char *pKey, const char *pString) -{ - size_t v2; // eax@5 - const char *lpValueName; // [sp+4h] [bp-1Ch]@1 - const char *Str; // [sp+8h] [bp-18h]@1 - DWORD dwDisposition; // [sp+Ch] [bp-14h]@2 - HKEY hKey; // [sp+10h] [bp-10h]@1 - HKEY phkResult; // [sp+14h] [bp-Ch]@1 - HKEY v8; // [sp+18h] [bp-8h]@1 - HKEY v9; // [sp+1Ch] [bp-4h]@1 - - Str = pString; - lpValueName = pKey; - v9 = 0; - v8 = 0; - hKey = 0; - phkResult = 0; - if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) ) - { - if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition) ) - { - if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v8, &dwDisposition) ) - { - if ( !RegCreateKeyExA(v8, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v9, &dwDisposition) ) - { - v2 = strlen(Str); - RegSetValueExA(v9, lpValueName, 0, 1, (const BYTE *)Str, v2 + 1); - RegCloseKey(v9); - } - RegCloseKey(v8); - } - RegCloseKey(phkResult); - } - RegCloseKey(hKey); - } -} - -//----- (00464BEF) -------------------------------------------------------- -void __fastcall ReadWindowsRegistryString(const char *pKeyName, char *pOutString, int uBufLen, const char *pDefaultValue) -{ - LSTATUS (__stdcall *v4)(HKEY); // esi@1 - LSTATUS result; // eax@7 - DWORD Type; // [sp+Ch] [bp-24h]@5 - LPCSTR lpValueName; // [sp+10h] [bp-20h]@1 - DWORD cbData; // [sp+14h] [bp-1Ch]@1 - LPBYTE Dest; // [sp+18h] [bp-18h]@1 - DWORD dwDisposition; // [sp+1Ch] [bp-14h]@2 - HKEY phkResult; // [sp+20h] [bp-10h]@1 - HKEY hKey; // [sp+24h] [bp-Ch]@1 - HKEY v13; // [sp+28h] [bp-8h]@1 - HKEY v14; // [sp+2Ch] [bp-4h]@1 - - cbData = uBufLen; - Dest = (LPBYTE)pOutString; - lpValueName = pKeyName; - v14 = 0; - v13 = 0; - hKey = 0; - phkResult = 0; - v4 = RegCloseKey; - if ( RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) - || RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition) - || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v13, &dwDisposition) - || RegCreateKeyExA(v13, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v14, &dwDisposition) ) - { - result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen); - } - else if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) ) - { - RegCloseKey(v14); - v14 = 0; - result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen); - } - else - { - v4 = RegCloseKey; - RegCloseKey(v14); - v14 = 0; - RegCloseKey(v13); - v13 = 0; - RegCloseKey(phkResult); - phkResult = 0; - result = RegCloseKey(hKey); - hKey = 0; - } - if ( v14 ) - result = v4(v14); - if ( v13 ) - result = v4(v13); - if ( hKey ) - result = v4(hKey); - if ( phkResult ) - result = v4(phkResult); -} - -//----- (00464D32) -------------------------------------------------------- -void __fastcall WriteWindowsRegistryInt(const char *pKey, int val) -{ - const char *lpValueName; // [sp+4h] [bp-1Ch]@1 - BYTE Data[4]; // [sp+8h] [bp-18h]@1 - DWORD dwDisposition; // [sp+Ch] [bp-14h]@2 - HKEY hKey; // [sp+10h] [bp-10h]@1 - HKEY phkResult; // [sp+14h] [bp-Ch]@1 - HKEY v7; // [sp+18h] [bp-8h]@1 - HKEY v8; // [sp+1Ch] [bp-4h]@1 - - *(int *)Data = val; - lpValueName = pKey; - v8 = 0; - v7 = 0; - hKey = 0; - phkResult = 0; - if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) ) - { - if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition) ) - { - if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v7, &dwDisposition) ) - { - if ( !RegCreateKeyExA(v7, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v8, &dwDisposition) ) - { - RegSetValueExA(v8, lpValueName, 0, 4, Data, 4); - RegCloseKey(v8); - } - RegCloseKey(v7); - } - RegCloseKey(phkResult); - } - RegCloseKey(hKey); - } -} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Registry.h --- a/Registry.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#pragma once - - - -int __fastcall ReadWindowsRegistryInt(const char *pKey, int uDefValue); // idb -void __fastcall WriteWindowsRegistryString(const char *pKey, const char *pString); -void __fastcall ReadWindowsRegistryString(const char *pKeyName, char *pOutString, int uBufLen, const char *pDefaultValue); -void __fastcall WriteWindowsRegistryInt(const char *pKey, int val); \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 SaveLoad.cpp --- a/SaveLoad.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,633 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include -#include - -#include "ErrorHandling.h" -#include "ZlibWrapper.h" - -#include "SaveLoad.h" -#include "Party.h" -#include "LOD.h" -#include "Engine/Graphics/Outdoor.h" -#include "AudioPlayer.h" -#include "Actor.h" -#include "Chest.h" -#include "Timer.h" -#include "GUIWindow.h" -#include "GUIFont.h" -#include "Engine/Graphics/Overlays.h" -#include "SpriteObject.h" -#include "Engine/Graphics/Viewport.h" -#include "stru123.h" -#include "texts.h" -#include "Log.h" -#include "Engine/Graphics/Level/Decoration.h" - -#include "Game.h" - - - -struct SavegameList *pSavegameList = new SavegameList; -unsigned int uNumSavegameFiles; -std::array pSavegameUsedSlots; -std::array pSavegameThumbnails; -std::array pSavegameHeader; - -//----- (0045EE8A) -------------------------------------------------------- -void __fastcall LoadGame(unsigned int uSlot) -{ - bool v25; // esi@62 - bool v26; // eax@62 - SavegameHeader header; // [sp+Ch] [bp-E4h]@23 - char Str[123]; // [sp+70h] [bp-80h]@25 - - MapsLongTimers_count = 0; - if (!pSavegameUsedSlots[uSlot]) - { - pAudioPlayer->PlaySound(SOUND_error, 0, 0, -1, 0, 0, 0, 0); - Log::Warning(L"LoadGame: slot %u is empty", uSlot); - return; - } - - for (uint i = 1; i < 5; ++i) - for (uint j = 1; j < 6; ++j) - { - sprintf(pTmpBuf.data(), "data\\lloyd%d%d.pcx", i, j); - remove(pTmpBuf.data()); - } - - if (SoundSetAction[24][0]) - for (uint i = 0; i < 4; ++i) - { - for (uint j = 0; j < pSoundList->sNumSounds; ++j) - if (pSoundList->pSL_Sounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998) - { - pSoundList->UnloadSound(j, 1); - break; - } - - for (uint j = 0; j < pSoundList->sNumSounds; ++j) - if (pSoundList->pSL_Sounds[j].uSoundID == 2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999) - { - pSoundList->UnloadSound(j, 1); - break; - } - } - - sprintf(pTmpBuf.data(), "saves\\%s", pSavegameList->pFileList[uSlot].pSaveFileName); - - pNew_LOD->CloseWriteFile(); - if (!CopyFileA(pTmpBuf.data(), "data\\new.lod", 0)) - int e = GetLastError(); - - pNew_LOD->LoadFile("data\\new.lod", 0); - FILE *file = pNew_LOD->FindContainer("header.bin", 1); - if (!file) - { - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 100);//Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d - Log::Warning(L"%S", Str); - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:549", 0); - } - Assert(sizeof(SavegameHeader) == 100); - fread(&header, sizeof(SavegameHeader), 1, file); - - file = pNew_LOD->FindContainer("party.bin", 1); - if (!file) - { - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 101);//Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d - Log::Warning(L"%S", Str); - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:559", 0); - } - if (sizeof(Party) != 0x16238) - Log::Warning(L"class Party: deserialization warning"); - fread(pParty, sizeof(Party), 1, file); - - - file = pNew_LOD->FindContainer("clock.bin", 1); - if (!file) - { - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 102);//Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d - Log::Warning(L"%S", Str); - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:569", 0); - } - if (sizeof(Timer) != 0x28) - Log::Warning(L"class Timer: deserialization warning"); - fread(pEventTimer, sizeof(Timer), 1, file); - - file = pNew_LOD->FindContainer("overlay.bin", 1); - if (!file) - { - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 103);//Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d - Log::Warning(L"%S", Str); - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:579", 0); - } - if (sizeof(OtherOverlayList) != 0x3F0) - Log::Warning(L"class OtherOverlayList: deserialization warning"); - fread(pOtherOverlayList, sizeof(OtherOverlayList), 1, file); - - file = pNew_LOD->FindContainer("npcdata.bin", 0); - if (!file) - { - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 104);//Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d - Log::Warning(L"%S", Str); - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:590", 0); - } - if (sizeof(pNPCStats->pNewNPCData) != 0x94BC) - Log::Warning(L"NPCStats: deserialization warning"); - fread(pNPCStats->pNewNPCData, sizeof(pNPCStats->pNewNPCData), 1, file); - pNPCStats->_476C60(); - - file = pNew_LOD->FindContainer("npcgroup.bin", 0); - if (!file) - { - sprintf(Str, pGlobalTXT_LocalizationStrings[612], 105);//Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d - Log::Warning(L"%S", Str); - MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:600", 0); - } - if (sizeof(pNPCStats->pGroups_copy) != 0x66) - Log::Warning(L"NPCStats: deserialization warning"); - fread(pNPCStats->pGroups_copy, sizeof(pNPCStats->pGroups_copy), 1, file); - - uActiveCharacter = 0; - for (uint i = 0; i < 4; ++i) - if (pParty->pPlayers[i].CanAct()) - { - uActiveCharacter = i + 1; - break; - } - - for (uint i = 0; i < 4; ++i) - { - if ( pParty->pPlayers[i].uQuickSpell ) - AA1058_PartyQuickSpellSound[i].AddPartySpellSound(pParty->pPlayers[i].uQuickSpell, i + 1); - - for (uint j = 0; j < 2; ++j) - { - uint uEquipIdx = pParty->pPlayers[i].pEquipment.pIndices[j]; - if (uEquipIdx) - { - int pItemID = pParty->pPlayers[i].pInventoryItemList[uEquipIdx - 1].uItemID; - if (pItemsTable->pItems[pItemID].uEquipType == EQUIP_WAND && pItemID )//æåçë - { - __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[i].AddPartySpellSound(wand_spell_ids[pItemID - ITEM_WAND_FIRE], i + 9); - } - } - } - } - - pGUIWindow_CurrentMenu->Release(); - pCurrentScreen = SCREEN_GAME; - - viewparams->bRedrawGameUI = true; - - SetUserInterface(pParty->alignment, true); - - pEventTimer->Resume(); - pEventTimer->StopGameTime(); - - v25 = pGames_LOD->DoesContainerExist(header.pLocationName); - sprintf(pTmpBuf.data(), "levels\\%s", header.pLocationName); - v26 = _access(pTmpBuf.data(), 4) != -1; - if ( !v25 && !v26 ) - Error("Unable to find: %s!", header.pLocationName); - - strcpy(pCurrentMapName, header.pLocationName); - dword_6BE364_game_settings_1 |= GAME_SETTINGS_2000 | GAME_SETTINGS_0001; - - for (uint i = 0; i < uNumSavegameFiles; ++i) - pSavegameThumbnails[i].Release(); - - pIcons_LOD->RemoveTexturesPackFromTextureList(); - pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); - pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f); - if (uTurnSpeed) - pParty->sRotationY = uTurnSpeed * pParty->sRotationY / (signed int)uTurnSpeed; - MM7Initialization(); - bFlashQuestBook = false; - viewparams->bRedrawGameUI = true; -} - -//----- (0045F469) -------------------------------------------------------- -void SaveGame( bool IsAutoSAve, bool NotSaveWorld ) -{ - int text_pos; // eax@6 - FILE *pLLoidFile; // edi@24 - char* compressed_buf; // edi@30 - char *data_write_pos; // esi@41 - CHAR Buffer[128]; // [sp+Ch] [bp-264h]@59 - char Dir[255]; // [sp+8Ch] [bp-1E4h]@51 - char Drive[255]; // [sp+ACh] [bp-1C4h]@51 - SavegameHeader save_header; // [sp+CCh] [bp-1A4h]@10 - char Filename[255]; // [sp+130h] [bp-140h]@51 - char Ext[255]; // [sp+150h] [bp-120h]@51 - char Source[32]; // [sp+170h] [bp-100h]@51 - char work_string[120]; // [sp+190h] [bp-E0h]@8 - int pPositionY; // [sp+208h] [bp-68h]@2 - int pPositionX; // [sp+20Ch] [bp-64h]@2 - int sPRotationY; // [sp+210h] [bp-60h]@2 - int sPRotationX; // [sp+214h] [bp-5Ch]@2 - ODMHeader odm_data; // [sp+218h] [bp-58h]@30 - int res; // [sp+224h] [bp-4Ch]@30 - int pPositionZ; // [sp+228h] [bp-48h]@2 - size_t Size; // [sp+250h] [bp-20h]@26 - char *uncompressed_buff; // [sp+258h] [bp-18h]@2 - unsigned int compressed_block_size; // [sp+260h] [bp-10h]@23 - - //v66 = a2; - strcpy(byte_6BE3B0.data(), pCurrentMapName);//byte_6BE3B0 - save_map_name - if (!_stricmp(pCurrentMapName, "d05.blv")) // arena - return; - - uncompressed_buff = (char*)malloc(1000000); - - LOD::Directory pLodDirectory; // [sp+22Ch] [bp-44h]@2 - pPositionX = pParty->vPosition.x; - pPositionY = pParty->vPosition.y; - pPositionZ = pParty->vPosition.z; - sPRotationY = pParty->sRotationY; - sPRotationX = pParty->sRotationX; - pParty->vPosition.x = pParty->vPrevPosition.x; - pParty->vPosition.z = pParty->vPrevPosition.z; - pParty->vPosition.y = pParty->vPrevPosition.y; - - pParty->uFallStartY = pParty->vPrevPosition.z; - - pParty->sRotationY = pParty->sPrevRotationY; - pParty->sRotationX = pParty->sPrevRotationX; - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed; - else - pOutdoor->loc_time.uLastVisitDay = pParty->uTimePlayed; - - pRenderer->PackScreenshot(150, 112, uncompressed_buff, 1000000, &pLodDirectory.uDataSize);//ñîçäàíèå ñêðèíøîòà - strcpy(pLodDirectory.pFilename, "image.pcx"); - - if (pCurrentScreen == SCREEN_SAVEGAME) - { - pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); - pRenderer->DrawTextureIndexed(18, 141, pIcons_LOD->GetTexture(uTextureID_save_up)); - text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[190]); - pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Ñîõðàíåíèå - text_pos = pFontSmallnum->AlignText_Center(186, pSavegameHeader[uLoadGameUI_SelectedSlot].pName); - pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, text_pos + 25, 259, 0, pSavegameHeader[uLoadGameUI_SelectedSlot].pName, 185, 0); - text_pos = pFontSmallnum->AlignText_Center(186, pGlobalTXT_LocalizationStrings[165]); - pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, text_pos + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Ïîæàëóéñòà, ïîäîæäèòå - pRenderer->Present(); - } - - if (pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0)) - { - sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 200); //Ñîõðàíåííàÿ èãðà ïîâðåæäåíà! Code=%d - MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0); - } - - Assert(sizeof(SavegameHeader) == 100); - memset(save_header.pName, 0, 20); - memset(save_header.pLocationName, 0, 20); - memset(save_header.field_30, 0, 52); - strcpy(save_header.pLocationName, pCurrentMapName); - save_header.uWordTime = pParty->uTimePlayed; - strcpy(pLodDirectory.pFilename, "header.bin"); - pLodDirectory.uDataSize = sizeof(SavegameHeader); - if (pNew_LOD->Write(&pLodDirectory, &save_header, 0)) - { - sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 201); - MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0); - } - strcpy(pLodDirectory.pFilename, "party.bin"); - pLodDirectory.uDataSize = sizeof(Party); //90680; - if ( pNew_LOD->Write(&pLodDirectory, pParty, 0) ) - { - sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 202);//Save game corrupted! Code=%d - MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0); - } - strcpy(pLodDirectory.pFilename, "clock.bin"); - pLodDirectory.uDataSize =sizeof(Timer);// 40; - if ( pNew_LOD->Write(&pLodDirectory, pEventTimer, 0) ) - { - sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 203); - MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0); - } - strcpy(pLodDirectory.pFilename, "overlay.bin"); - pLodDirectory.uDataSize =sizeof(OtherOverlayList);// 1008; - if ( pNew_LOD->Write(&pLodDirectory, pOtherOverlayList, 0) ) - { - sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 204); - MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0); - } - strcpy(pLodDirectory.pFilename, "npcdata.bin"); - pLodDirectory.uDataSize = 501 * sizeof(NPCData); - Assert(pLodDirectory.uDataSize == 38076); - if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pNewNPCData, 0) ) - { - sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 205); - MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0); - } - strcpy(pLodDirectory.pFilename, "npcgroup.bin"); - pLodDirectory.uDataSize = 102; - if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pGroups_copy, 0) ) - { - sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 206); - MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0); - } - for (int i = 1; i <= 4; ++i) // 4 - players - { - for (int j = 1; j <= 5; ++j) // 5 - images - { - sprintf(work_string, "data\\lloyd%d%d.pcx", i, j); - pLLoidFile = fopen(work_string, "rb"); - if ( pLLoidFile ) - { - __debugbreak(); - sprintf(work_string, "lloyd%d%d.pcx", i, j); - fseek(pLLoidFile, 0, SEEK_END); - pLodDirectory.uDataSize = ftell(pLLoidFile); - rewind(pLLoidFile); - fread(uncompressed_buff, pLodDirectory.uDataSize, 1, pLLoidFile); - strcpy(pLodDirectory.pFilename, work_string); - fclose(pLLoidFile); - remove(work_string); - if ( pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0) ) - { - sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 207); - MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0); - Size = 5080748; - } - } - } - } - if ( !NotSaveWorld )//autosave for change location - { - //__debugbreak(); - CompactLayingItemsList(); - compressed_buf = (char*)malloc(1000000); - odm_data.uVersion = 91969; - odm_data.pMagic[0] = 'm'; - odm_data.pMagic[1] = 'v'; - odm_data.pMagic[2] = 'i'; - odm_data.pMagic[3] = 'i'; - odm_data.uCompressedSize = 0; - odm_data.uDecompressedSize = 0; - data_write_pos = uncompressed_buff; - memcpy((void *)compressed_buf, &odm_data, 0x10); - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces; - pIndoor->dlv.uNumBModels = 0; - pIndoor->dlv.uNumDecorations = uNumLevelDecorations; - memcpy(data_write_pos, &pIndoor->dlv,sizeof(DDM_DLV_Header) );//0x28 - data_write_pos += sizeof(DDM_DLV_Header); - memcpy(data_write_pos, pIndoor->_visible_outlines, 0x36B); - data_write_pos += 875; - for (int i = 0; i <(signed int)pIndoor->uNumFaces; ++i) - { - memcpy(data_write_pos, &pIndoor->pFaces[i].uAttributes, 4); - data_write_pos += 4; - } - - for (int i = 0; i <(signed int)uNumLevelDecorations; ++i) - { - memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2); - data_write_pos += 2; - } - memcpy(data_write_pos, &uNumActors, 4); - data_write_pos += 4; - memcpy(data_write_pos, &pActors, uNumActors * sizeof(Actor)); - data_write_pos += uNumActors * sizeof(Actor); - memcpy(data_write_pos, &uNumSpriteObjects, 4); - data_write_pos += 4; - memcpy(data_write_pos, pSpriteObjects.data(), 112 * uNumSpriteObjects); - data_write_pos += 112 * uNumSpriteObjects; - memcpy(data_write_pos, &uNumChests, 4); - data_write_pos += 4; - memcpy(data_write_pos, pChests.data(), sizeof(Chest)*uNumChests);//5324 * - data_write_pos += sizeof(Chest)* uNumChests; - memcpy(data_write_pos, pIndoor->pDoors, 0x3E80); - data_write_pos += 16000; - memcpy(data_write_pos, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size); - data_write_pos += pIndoor->blv.uDoors_ddata_Size; - memcpy(data_write_pos, &stru_5E4C90_MapPersistVars, 0xC8); - data_write_pos += 200; - memcpy(data_write_pos, &pIndoor->stru1, 0x38); - data_write_pos += 56; - - } - else//for Outdoor - { - pOutdoor->ddm.uNumFacesInBModels = 0; - for ( int i = 0; i < pOutdoor->uNumBModels; ++i ) - pOutdoor->ddm.uNumFacesInBModels += pOutdoor->pBModels[i].uNumFaces; - pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels; - pOutdoor->ddm.uNumDecorations = uNumLevelDecorations; - memcpy(data_write_pos, &pOutdoor->ddm, sizeof(DDM_DLV_Header));//0x28 - data_write_pos += sizeof(DDM_DLV_Header); - memcpy(data_write_pos, pOutdoor->uFullyRevealedCellOnMap, 0x3C8); - data_write_pos += 968; - memcpy(data_write_pos, pOutdoor->uPartiallyRevealedCellOnMap, 0x3C8); - data_write_pos += 968; - for (int i = 0; i < pOutdoor->uNumBModels ; ++i) - for (int j = 0; j < pOutdoor->pBModels[i].uNumFaces;++j)//*(int *)&pOutdoor->pBModels->pModelName[v24]; ++j) - { - memcpy(data_write_pos, &(pOutdoor->pBModels[i].pFaces[j].uAttributes), 4); - data_write_pos += 4; - } - - for (int i = 0; i < (signed int)uNumLevelDecorations; ++i) - { - memcpy(data_write_pos, &pLevelDecorations[i].uFlags, 2); - data_write_pos += 2; - } - memcpy(data_write_pos, &uNumActors, 4); - data_write_pos += 4; - memcpy(data_write_pos, &pActors, uNumActors * sizeof(Actor)); - data_write_pos += uNumActors * sizeof(Actor); - memcpy(data_write_pos, &uNumSpriteObjects, 4); - data_write_pos += 4; - memcpy(data_write_pos, &pSpriteObjects, uNumSpriteObjects * sizeof(SpriteObject)); - data_write_pos += uNumSpriteObjects * sizeof(SpriteObject); - memcpy(data_write_pos, &uNumChests, 4); - data_write_pos += 4; - memcpy(data_write_pos, pChests.data(), sizeof(Chest)* uNumChests); - data_write_pos += sizeof(Chest) * uNumChests; - memcpy(data_write_pos, &stru_5E4C90_MapPersistVars, 0xC8); - data_write_pos += 200; - memcpy(data_write_pos, &pOutdoor->loc_time, 0x38); - data_write_pos += 56; - } - strcpy(Source, pCurrentMapName); - _splitpath(Source, Drive, Dir, Filename, Ext); - Ext[1] = 'd'; - - Size = (int)data_write_pos - (int)uncompressed_buff; - compressed_block_size = 999984; - res = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size); - if (res || (signed int)compressed_block_size > (signed int)Size ) - { - memcpy((void *)(compressed_buf + 16), uncompressed_buff, Size); - compressed_block_size = Size; - } - compressed_block_size += 16; - memcpy(&((ODMHeader *)compressed_buf)->uCompressedSize, &compressed_block_size, 4); - memcpy(&((ODMHeader *)compressed_buf)->uDecompressedSize, &Size, 4); - sprintf(Source, "%s%s", Filename, Ext); - strcpy(pLodDirectory.pFilename, Source); - pLodDirectory.uDataSize = compressed_block_size; - if ( pNew_LOD->Write(&pLodDirectory, (const void *)compressed_buf, 0) ) - { - sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 208); - MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0); - } - free((void *)compressed_buf); - } - free(uncompressed_buff); - if ( IsAutoSAve ) - { - if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) ) - { - FormatMessageA(0x1000, 0, GetLastError(), 0x400, Buffer, 0x80, 0); - sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 300); - MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0); - } - } - pParty->vPosition.x = pPositionX; - pParty->vPosition.y = pPositionY; - pParty->vPosition.z = pPositionZ; - pParty->uFallStartY = pPositionZ; - pParty->sRotationY = sPRotationY; - pParty->sRotationX = sPRotationX; -} - -//----- (00460078) -------------------------------------------------------- -void __fastcall DoSavegame(unsigned int uSlot) -{ - if ( _stricmp(pCurrentMapName, "d05.blv") )//Not Arena(íå Àðåíà) - { - LOD::Directory pDir; // [sp+Ch] [bp-28h]@2 - SaveGame(0, 0); - strcpy(pSavegameHeader[uSlot].pLocationName, pCurrentMapName);//äàòü íàçâàíèå êàðòû - pSavegameHeader[uSlot].uWordTime = pParty->uTimePlayed;//òåêóùåå âðåìÿ - strcpy(pDir.pFilename, "header.bin"); - pDir.uDataSize = 100; - pNew_LOD->Write(&pDir, &pSavegameHeader[uSlot], 0); - sprintf(pTmpBuf.data(), "saves\\save%03d.mm7", uSlot); - pNew_LOD->CloseWriteFile();//çàêðûòü - CopyFileA("data\\new.lod", pTmpBuf.data(), 0);//ñîõðàíåíèå ôàéëà â äèðåêòîðèþ saves - } - GUI_UpdateWindows(); - pGUIWindow_CurrentMenu->Release(); - pCurrentScreen = SCREEN_GAME; - //v3 = pSavegameThumbnails; - viewparams->bRedrawGameUI = true; - for (uint i = 0; i < 45; i++) - pSavegameThumbnails[i].Release(); - - if ( _stricmp(pCurrentMapName, "d05.blv") ) - pNew_LOD->_4621A7(); - else - ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2);// "No saving in the Arena" - pIcons_LOD->RemoveTexturesFromTextureList(); - pEventTimer->Resume(); - ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2);// "Game Saved!" - viewparams->bRedrawGameUI = true; -} -// 4E28F8: using guessed type int pCurrentScreen; - -//----- (0045E297) -------------------------------------------------------- -void SavegameList::Initialize(unsigned int bHideEmptySlots) -{ - //memset(pSavegameList, 0, sizeof(pSavegameList));//Ritor1: âûçûâàåò çàòèðàíèå - pSavegameList->Reset(); - uNumSavegameFiles = 0; - - _chdir("saves"); - { - if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 ) // AutoSave.MM7 - strcpy(pSavegameList->pFileList[uNumSavegameFiles++].pSaveFileName, pGlobalTXT_LocalizationStrings[613]); - - for (uint i = 0; i < 40; ++i) - { - sprintf(pTmpBuf.data(), "save%03d.mm7", i); - if (_access(pTmpBuf.data(), 0) == -1) - continue; - - uint idx = i; - if (!bHideEmptySlots) - idx = uNumSavegameFiles; - strcpy(pSavegameList->pFileList[idx].pSaveFileName, pTmpBuf.data()); - - ++uNumSavegameFiles; - } - } - _chdir(".."); -} -//----- (0046086A) -------------------------------------------------------- -void SaveNewGame() -{ - FILE *file; // eax@7 - void *pSave; // [sp+170h] [bp-8h]@3 - - if ( pMovie_Track ) - pMediaPlayer->Unload(); - pSave = malloc(1000000); - pNew_LOD->CloseWriteFile(); - remove("data\\new.lod");//óäàëèòü new.lod - - LOD::FileHeader header; // [sp+Ch] [bp-16Ch]@3 çàãîëîâîê - strcpy(header.LodVersion, "MMVII"); - strcpy(header.LodDescription, "newmaps for MMVII"); - header.LODSize = 100; - header.dword_0000A8 = 0; - - LOD::Directory a3; // [sp+14Ch] [bp-2Ch]@3 - a3.dword_000018 = 0; - a3.word_00001E = 0; - strcpy(a3.pFilename, "current"); - pNew_LOD->CreateNewLod(&header, &a3, "data\\new.lod");//ñîçäà¸òñÿ new.lod â äèððåêòîðèè - if (pNew_LOD->LoadFile("data\\new.lod", false))//çàãðóçèòü ôàéë new.lod(isFileOpened = true) - { - pNew_LOD->CreateTempFile();//ñîçäà¸òñÿ âðåìåííûé ôàéë OutputFileHandle - pNew_LOD->uNumSubDirs = 0; - - LOD::Directory pDir; // [sp+10Ch] [bp-6Ch]@4 - for (int i = pGames_LOD->uNumSubDirs / 2; i < pGames_LOD->uNumSubDirs; ++i)//êîïèðîâàíèå ôàéëîâ ñ 76 ïî 151 - { - memcpy(&pDir, &pGames_LOD->pSubIndices[i], sizeof(pDir));//êîïèðîâàíèå òåêóùåãî ôàéëà â pDir - file = pGames_LOD->FindContainer(pGames_LOD->pSubIndices[i].pFilename, 1); - fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, file); - pNew_LOD->AppendDirectory(&pDir, pSave); - } - - LOD::Directory save_game_dir; // [sp+12Ch] [bp-4Ch]@9 - strcpy(pSavegameHeader[0].pLocationName, "out01.odm"); - strcpy(save_game_dir.pFilename, "header.bin"); - save_game_dir.uDataSize = sizeof(SavegameHeader); - pNew_LOD->AppendDirectory(&save_game_dir, &pSavegameHeader[0]); - - pNew_LOD->FixDirectoryOffsets(); - - pParty->vPrevPosition.x = 12552; - pParty->vPrevPosition.y = 1816; - pParty->vPrevPosition.z = 0; - - pParty->vPosition.x = 12552; - pParty->vPosition.y = 1816; - pParty->vPosition.z = 0; - - pParty->uFallStartY = 0; - - pParty->sPrevRotationX = 0; - pParty->sPrevRotationY = 512; - - pParty->sRotationX = 0; - pParty->sRotationY = 512; - - SaveGame(1, 1); - } - free(pSave); -} - diff -r 92eeeb5200f2 -r 68cdef6879a0 SaveLoad.h --- a/SaveLoad.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -#pragma once -#include - -#pragma pack(push, 1) -struct SaveFile_ - { - char field_0[20]; - char pSaveFileName[260]; - }; -#pragma pack(pop) - -/* 243 */ -#pragma pack(push, 1) -struct SavegameList -{ - static void Initialize(unsigned int a1); - SavegameList() {Reset();} - - inline void Reset() - { - for ( int j = 0; j < 45; j++ ) - { - for (int i = 0; i < 20; ++i) - this->pFileList[j].field_0[i] = 0; - for (int i = 0; i < 260; ++i) - this->pFileList[j].pSaveFileName[i] = 0; - } - } - SaveFile_ pFileList[45]; - -}; -#pragma pack(pop) - - -/* 244 */ -#pragma pack(push, 1) -struct SavegameHeader -{ - char pName[20]; - char pLocationName[20]; - unsigned __int64 uWordTime; - char field_30[52]; -}; -#pragma pack(pop) - - -void __fastcall LoadGame(unsigned int uSlot); // idb -void SaveGame(bool IsAutoSAve, bool NotSaveWorld); -void __fastcall DoSavegame(unsigned int uSlot); // idb -bool Initialize_GamesLOD_NewLOD(); -void SaveNewGame(); - -extern unsigned int uNumSavegameFiles; -extern std::array pSavegameUsedSlots; -extern struct SavegameList *pSavegameList; -extern std::array pSavegameHeader; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Spells.cpp --- a/Spells.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,741 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include -#include "ErrorHandling.h" - -#include "Spells.h" -#include "Engine/Graphics/Overlays.h" -#include "LOD.h" -#include "texts.h" - -#include "Party.h" -#include "OurMath.h" -#include "SpriteObject.h" -#include "ObjectList.h" -#include "Engine/Graphics/Indoor.h" -#include "AudioPlayer.h" -#include "Actor.h" -#include "Game.h" -#include "stru6.h" - - -std::array TownPortalList = //4ECBB8 -{{ - {Vec3_int_(-5121, 2107, 1), 1536, 0, 21, 0}, - {Vec3_int_(-15148, -10240, 1473), 0, 0, 4, 0}, - {Vec3_int_(-10519, 5375, 753), 512, 0, 3, 0}, - {Vec3_int_(3114, -11055, 513), 0, 0, 10, 0}, - {Vec3_int_(-158, 7624, 1), 512, 0, 7, 0}, - {Vec3_int_(-1837, -4247, 65), 65, 0, 8, 0} -}} ; - -struct SpellStats *pSpellStats; - - -std::array stru_4E3ACC = -{{ - {10, 0}, - {1000, 0}, {1010, 0}, {1020, 0}, {1030, 0}, {1040, 0}, {1050, 0}, {1060, 0}, {1070, 0}, {1080, 0}, {1090, 0}, {1100, 0}, - {2000, 0}, {2010, 0}, {2020, 0}, {2030, 0}, {2040, 0}, {2050, 0}, {2060, 0}, {2070, 0}, {2080, 0}, {2090, 0}, {2100, 0}, - {3000, 0}, {3010, 0}, {3020, 0}, {3030, 0}, {3040, 0}, {3050, 0}, {3060, 0}, {3070, 0}, {3080, 0}, {3090, 0}, {3100, 0}, - {4000, 0}, {4010, 0}, {4020, 0}, {4030, 0}, {4040, 0}, {4050, 0}, {4060, 0}, {4070, 0}, {4080, 0}, {4090, 0}, {4100, 0}, - {5000, 0}, {5010, 0}, {5020, 0}, {5030, 0}, {5040, 0}, {5050, 0}, {5060, 0}, {5070, 0}, {5080, 0}, {5090, 0}, {5100, 0}, - {6000, 0}, {6010, 0}, {6020, 0}, {6030, 0}, {6040, 0}, {6050, 0}, {6060, 0}, {6070, 0}, {6080, 0}, {6090, 0}, {6100, 0}, - {7000, 0}, {7010, 0}, {7020, 0}, {7030, 0}, {7040, 0}, {7050, 0}, {7060, 0}, {7070, 0}, {7080, 0}, {7090, 0}, {7100, 0}, - {8000, 0}, {8010, 0}, {8020, 0}, {8030, 0}, {8040, 0}, {8050, 0}, {8060, 0}, {8070, 0}, {8080, 0}, {8090, 0}, {8100, 0}, - {9000, 0}, {9010, 0}, {9020, 0}, {9030, 0}, {9040, 0}, {9050, 0}, {9060, 0}, {9070, 0}, {9080, 0}, {9090, 0}, {9100, 0}, - {545, 0}, - {545, 0}, - {555, 0} -}}; - - - -SpellData::SpellData( __int16 innormalMana, __int16 inExpertLevelMana, __int16 inMasterLevelMana, __int16 inMagisterLevelMana, - __int16 inNormalLevelRecovery, __int16 inExpertLevelRecovery, __int16 inMasterLevelRecovery, __int16 inMagisterLevelRecovery, - __int8 inbaseDamage, __int8 inbonusSkillDamage, __int16 instats ): -uNormalLevelMana(innormalMana), -uExpertLevelMana(inExpertLevelMana), -uMasterLevelMana(inMasterLevelMana), -uMagisterLevelMana(inMagisterLevelMana), -uNormalLevelRecovery(inNormalLevelRecovery), -uExpertLevelRecovery(inExpertLevelRecovery), -uMasterLevelRecovery(inMasterLevelRecovery), -uMagisterLevelRecovery(inMagisterLevelRecovery), -baseDamage(inbaseDamage), -bonusSkillDamage(inbonusSkillDamage), -stats(instats) -{ - -} - - //9 spellbook pages 11 spells per page 9*11 =99 +1 zero struct at 0. It counted from 1! -std::array pSpellDatas={{ - SpellData(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), - - SpellData(1, 1, 1, 1, 60, 60, 60, 40, 0, 0, 0),//0 fire - SpellData(2, 2, 2, 2, 110, 110, 100, 90, 3, 3, 0), - SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), - SpellData(4, 4, 4, 4, 120, 120, 120, 120, 0, 0, 0), - SpellData(5, 5, 5, 5, 120, 120, 120, 120, 0, 0, 0), - SpellData(8, 8, 8, 8, 100, 100, 90, 80, 0, 6, 0), - SpellData(10, 10, 10, 10, 150, 150, 150, 150, 0, 6, 0), - SpellData(15, 15, 15, 15, 120, 120, 120, 120, 0, 6, 0), - SpellData(20, 20, 20, 20, 100, 100, 100, 90, 8, 1, 0), - SpellData(25, 25, 25, 25, 100, 100, 100, 90, 12, 1, 0), - SpellData(30, 30, 30, 30, 90, 90, 90, 90, 15, 15, 0), - - SpellData(1, 1, 1, 0, 60, 60, 60, 60, 0, 0, 0), //1 air - SpellData(2, 2, 2, 2, 120, 120, 120, 100, 0, 0, 0), - SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), - SpellData(4, 4, 4, 4, 110, 100, 90, 80, 2, 1, 0), - SpellData(5, 5, 5, 5, 90, 90, 70, 50, 0, 0, 0), - SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0), - SpellData(10, 10, 10, 10, 100, 100, 90, 70, 0, 8, 0), - SpellData(15, 15, 15, 15, 200, 200, 200, 200, 0, 0, 0), - SpellData(20, 20, 20, 20, 100, 100, 100, 90, 10, 10, 0), - SpellData(25, 25, 25, 25, 250, 250, 250, 250, 0, 0, 0), - SpellData(30, 30, 30, 30, 90, 90, 90, 90, 20, 1, 0), - - SpellData(1, 1, 1, 1, 60, 60, 60, 20, 0, 0, 0), //2 water - SpellData(2, 2, 2, 2, 110, 100, 90, 70, 2, 2, 0), - SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), - SpellData(4, 4, 4, 4, 110, 100, 90, 80, 0, 4, 0), - SpellData(5, 5, 5, 5, 150, 150, 150, 150, 0, 0, 0), - SpellData(8, 8, 8, 8, 200, 200, 200, 200, 0, 0, 0), - SpellData(10, 10, 10, 10, 100, 100, 90, 80, 9, 9, 0), - SpellData(15, 15, 15, 15, 140, 140, 140, 140, 0, 0, 0), - SpellData(20, 20, 20, 20, 200, 200, 200, 200, 0, 0, 0), - SpellData(25, 25, 25, 25, 80, 80, 80, 80, 12, 3, 0), - SpellData(30, 30, 30, 30, 250, 250, 250, 250, 0, 0, 0), - - SpellData(1, 1, 1, 1, 80, 80, 80, 80, 0, 0, 0), //3 earth - SpellData(2, 2, 2, 2, 100, 100, 100, 100, 0, 0, 0), - SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), - SpellData(4, 4, 4, 4, 110, 100, 90, 80, 5, 3, 0), - SpellData(5, 5, 5, 5, 120, 120, 120, 120, 0, 0, 0), - SpellData(8, 8, 8, 8, 100, 100, 90, 80, 0, 9, 0), - SpellData(10, 10, 10, 10, 140, 140, 140, 140, 0, 0, 0), - SpellData(15, 15, 15, 15, 90, 90, 90, 80, 0, 8, 0), - SpellData(20, 20, 20, 20, 150, 150, 150, 150, 0, 0, 0), - SpellData(25, 25, 25, 25, 100, 100, 100, 90, 20, 1, 0), - SpellData(30, 30, 30, 30, 90, 90, 90, 90, 25, 0, 0), - - SpellData(1, 1, 1, 1, 100, 100, 100, 100, 0, 0, 0), //4 spirit - SpellData(2, 2, 2, 2, 100, 100, 100, 100, 0, 0, 0), - SpellData(3, 3, 3, 3, 90, 90, 90, 90, 0, 0, 0), - SpellData(4, 4, 4, 4, 120, 120, 120, 120, 0, 0, 0), - SpellData(5, 5, 5, 5, 120, 120, 120, 120, 0, 0, 0), - SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0), - SpellData(10, 10, 10, 10, 120, 120, 120, 120, 0, 0, 0), - SpellData(15, 15, 15, 15, 100, 100, 100, 100, 10, 8, 0), - SpellData(20, 20, 20, 20, 240, 240, 240, 240, 0, 0, 0), - SpellData(25, 25, 25, 25, 150, 150, 150, 150, 0, 0, 0), - SpellData(30, 30, 30, 30, 1000, 1000, 1000, 1000, 0, 0, 0), - - SpellData(1, 1, 1, 1, 120, 120, 120, 120, 0, 0, 0), //5 mind - SpellData(2, 2, 2, 2, 110, 110, 110, 110, 3, 3, 0), - SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), - SpellData(4, 4, 4, 4, 110, 100, 90, 80, 0, 0, 0), - SpellData(5, 5, 5, 5, 100, 100, 100, 100, 0, 0, 0), - SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0), - SpellData(10, 10, 10, 10, 120, 120, 120, 120, 0, 0, 0), - SpellData(15, 15, 15, 15, 80, 80, 80, 80, 0, 0, 0), - SpellData(20, 20, 20, 20, 120, 120, 120, 120, 0, 0, 0), - SpellData(25, 25, 25, 25, 110, 110, 110, 100, 12, 12, 0), - SpellData(30, 30, 30, 30, 120, 120, 120, 120, 0, 0, 0), - - SpellData(1, 1, 1, 1, 120, 120, 120, 120, 0, 0, 0), //6 body - SpellData(2, 2, 2, 2, 100, 100, 100, 100, 0, 0, 0), - SpellData(3, 3, 3, 3, 120, 120, 120, 120, 0, 0, 0), - SpellData(4, 4, 4, 4, 110, 100, 90, 80, 8, 2, 0), - SpellData(5, 5, 5, 5, 110, 110, 110, 110, 0, 0, 0), - SpellData(8, 8, 8, 8, 120, 120, 120, 120, 0, 0, 0), - SpellData(10, 10, 10, 10, 120, 120, 120, 120, 0, 0, 0), - SpellData(15, 15, 15, 15, 120, 120, 120, 120, 0, 0, 0), - SpellData(20, 20, 20, 20, 120, 120, 120, 120, 0, 0, 0), - SpellData(25, 25, 25, 25, 110, 110, 110, 100, 30, 5, 0), - SpellData(30, 30, 30, 30, 100, 100, 100, 100, 0, 0, 0), - - SpellData(5, 5, 5, 5, 110, 100, 90, 80, 0, 4, 0), //7 light - SpellData(10, 10, 10, 10, 120, 110, 100, 90, 16, 16, 0), - SpellData(15, 15, 15, 15, 120, 110, 100, 90, 0, 0, 0), - SpellData(20, 20, 20, 20, 160, 140, 120, 100, 0, 0, 0), - SpellData(25, 25, 25, 25, 140, 140, 140, 140, 0, 0, 0), - SpellData(30, 30, 30, 30, 500, 500, 500, 500, 0, 0, 0), - SpellData(35, 35, 35, 35, 135, 135, 120, 100, 25, 1, 0), - SpellData(40, 40, 40, 40, 500, 500, 500, 500, 0, 0, 0), - SpellData(45, 45, 45, 45, 250, 250, 250, 250, 0, 0, 0), - SpellData(50, 50, 50, 50, 150, 150, 150, 135, 20, 20, 0), - SpellData(55, 55, 55, 55, 300, 300, 300, 300, 0, 0, 0), - - SpellData(10, 10, 10, 10, 140, 140, 140, 140, 0, 0, 0), //8 dark - SpellData(15, 15, 15, 15, 120, 110, 100, 90, 25, 10, 0), - SpellData(20, 20, 20, 20, 120, 100, 90, 120, 0, 0, 0), - SpellData(25, 25, 25, 25, 120, 120, 120, 120, 0, 0, 0), - SpellData(30, 30, 30, 30, 90, 90, 80, 70, 6, 6, 0), - SpellData(35, 35, 35, 35, 120, 120, 100, 80, 0, 0, 0), - SpellData(40, 40, 40, 40, 110, 110, 110, 110, 0, 0, 0), - SpellData(45, 45, 45, 45, 200, 200, 200, 150, 0, 0, 0), - SpellData(50, 50, 50, 50, 120, 120, 120, 100, 0, 25, 0), - SpellData(55, 55, 55, 55, 250, 250, 250, 250, 50, 1, 0), - SpellData(60, 60, 60, 60, 300, 300, 300, 300, 25, 8, 0) - }}; - -std::array wand_spell_ids = -{ -// 135 Wand of Fire 136 Wand of Sparks 137 Wand of Poison 138 Wand of Stunning 139 Wand of Harm - SPELL_FIRE_FIRE_BOLT, SPELL_AIR_SPARKS, SPELL_WATER_POISON_SPRAY, SPELL_EARTH_STUN, SPELL_BODY_HARM, -// 140 Fairy Wand of Light 141 Fairy Wand of Ice 142 Fairy Wand of Lashing 143 Fairy Wand of Mind 144 Fairy Wand of Swarms - SPELL_LIGHT_LIGHT_BOLT, SPELL_WATER_ICE_BOLT, SPELL_SPIRIT_SPIRIT_LASH, SPELL_MIND_MIND_BLAST, SPELL_EARTH_DEADLY_SWARM, -// 145 Alacorn Wand of Fireballs 146 Alacorn Wand of Acid 147 Alacorn Wand of Lightning 148 Alacorn Wand of Blades 149 Alacorn Wand of Charms - SPELL_FIRE_FIREBALL, SPELL_WATER_ACID_BURST, SPELL_AIR_LIGHNING_BOLT, SPELL_EARTH_BLADES, SPELL_MIND_CHARM, -// 150 Arcane Wand of Blasting 151 Arcane Wand of The Fist 152 Arcane Wand of Rocks 153 Arcane Wand of Paralyzing 154 Arcane Wand of Clouds - SPELL_WATER_ICE_BLAST, SPELL_BODY_FLYING_FIST, SPELL_EARTH_ROCK_BLAST, SPELL_LIGHT_PARALYZE, SPELL_DARK_TOXIC_CLOUD, -// 155 Mystic Wand of Implosion 156 Mystic Wand of Distortion 157 Mystic Wand of Sharpmetal 158 Mystic Wand of Shrinking 159 Mystic Wand of Incineration - SPELL_AIR_IMPLOSION, SPELL_EARTH_MASS_DISTORTION, SPELL_DARK_SHARPMETAL, SPELL_DARK_SHRINKING_RAY, SPELL_FIRE_INCINERATE -}; - - -std::array, 9> pSpellbookSpellIndices = // 4E2430 - {{ //0 1 2 3 4 5 6 7 8 9 10 11 - {0, 3, 1, 8, 11, 7, 4, 10, 6, 2, 5, 9}, - {0, 11, 2, 9, 6, 8, 5, 10, 3, 7, 1, 4}, - {0, 4, 8, 9, 1, 10, 3, 11, 7, 6, 2, 5}, - {0, 7, 10, 8, 2, 11, 1, 5, 3, 6, 4, 9}, - {0, 5, 10, 11, 7, 2, 8, 1, 4, 9, 3, 6}, - {0, 5, 9, 8, 3, 7, 6, 4, 1, 11, 2, 10}, - {0, 1, 6, 9, 3, 5, 8, 11, 7, 10, 4, 2}, - {0, 1, 10, 11, 9, 4, 3, 6, 5, 7, 8, 2}, - {0, 9, 3, 7, 1, 5, 2, 10, 11, 8, 6, 4} -}}; - - std::array, 9> pIconPos={{ - - { 0, 0, 17, 13, 115, 2, 217, 15, - 299, 6, 28, 125, 130, 133, 294, 114, - 11, 232, 134, 233, 237, 171, 296, 231}, - - { 0, 0, 19, 9, 117, 3, 206, 13, - 285, 7, 16, 123, 113, 101, 201, 118, - 317, 110, 11, 230, 149, 236, 296, 234}, - - { 0, 0, 17, 9, 140, 0, 210, 34, - 293, 5, 15, 98, 78, 121, 175, 136, - 301, 115, 15, 226, 154, 225, 272, 220}, - - { 0, 0, 7, 9, 156, 2, 277, 9, - 11, 117, 111, 82, 180, 102, 303, 108, - 10, 229, 120, 221, 201, 217, 296, 225}, - - { 0, 0, 18, 8, 89, 15, 192, 14, - 292, 7, 22, 129, 125, 146, 217, 136, - 305, 115, 22, 226, 174, 237, 290, 231}, - - { 0, 0, 18, 12, 148, 9, 292, 7, - 17, 122, 121, 99, 220, 87, 293, 112, - 13, 236, 128, 213, 220, 223, 315, 223}, - - { 0, 0, 23, 14, 127, 8, 204, 0, - 306, 8, 14, 115, 122, 132, 200, 116, - 293, 122, 20, 228, 154, 228, 294, 239}, - - { 0, 0, 19, 14, 124, 10, 283, 12, - 8, 105, 113, 89, 190, 82, 298, 108, - 18, 181, 101, 204, 204, 203, 285, 218}, - - { 0, 0, 18, 17, 110, 16, 201, 15, - 307, 15, 18, 148, 125, 166, 201, 123, - 275, 120, 28, 235, 217, 222, 324, 216}}}; - - -//----- (0042EB31) -------------------------------------------------------- -bool SpellBuff::NotExpired() -{ - return (signed __int64)this->uExpireTime > 0 ? true:false; -} - - -//----- (00458585) -------------------------------------------------------- -void SpellBuff::Reset() -{ - uSkill = 0; - uPower = 0; - uExpireTime = 0i64; - uCaster = 0; - uFlags = 0; - if (uOverlayID) - { - pOtherOverlayList->pOverlays[uOverlayID - 1].Reset(); - pOtherOverlayList->bRedraw = true; - uOverlayID = 0; - } -} - -//----- (004585CA) -------------------------------------------------------- -bool SpellBuff::IsBuffExpiredToTime( __int64 time_end ) - { - if (uExpireTime && (uExpireTime < time_end)) - { - uExpireTime = 0; - uPower = 0; - uSkill = 0; - uOverlayID = 0; - return true; - } - return false; -} - -//----- (004584E0) -------------------------------------------------------- -bool SpellBuff::Apply( signed __int64 uExpireTime, unsigned __int16 uSkillLevel, unsigned __int16 uPower, int uOverlayID, unsigned __int8 caster ) - { - if (this->uExpireTime && (uExpireTime < this->uExpireTime)) - return false; - - this->uSkill = uSkillLevel; - this->uPower = uPower; - this->uExpireTime = uExpireTime; - if (this->uOverlayID && this->uOverlayID != uOverlayID) - { - pOtherOverlayList->pOverlays[this->uOverlayID - 1].Reset(); - pOtherOverlayList->bRedraw = true; - this->uOverlayID = 0; - } - this->uOverlayID = uOverlayID; - this->uCaster = caster; - - return true; -} - -//----- (0045384A) -------------------------------------------------------- -void SpellStats::Initialize() -{ - std::map spellSchoolMaps; - spellSchoolMaps["fire"] = SPELL_SCHOOL_FIRE; - spellSchoolMaps["air"] = SPELL_SCHOOL_AIR; - spellSchoolMaps["water"] = SPELL_SCHOOL_WATER; - spellSchoolMaps["earth"] = SPELL_SCHOOL_EARTH; - spellSchoolMaps["spirit"] = SPELL_SCHOOL_SPIRIT; - spellSchoolMaps["mind"] = SPELL_SCHOOL_MIND; - spellSchoolMaps["body"] = SPELL_SCHOOL_BODY; - spellSchoolMaps["light"] = SPELL_SCHOOL_LIGHT; - spellSchoolMaps["dark"] = SPELL_SCHOOL_DARK; - spellSchoolMaps["magic"] = SPELL_SCHOOL_MAGIC; - - char* test_string; - - free(pSpellsTXT_Raw); - pSpellsTXT_Raw = (char *)pEvents_LOD->LoadRaw("spells.txt", 0); - - strtok(pSpellsTXT_Raw, "\r"); - for(int i=1; i<100; ++i) - { - if (((i % 11) - 1 )==0) - strtok(NULL, "\r"); - test_string=strtok(NULL, "\r")+1; - auto tokens = Tokenize(test_string, '\t'); - pInfos[i].pName=RemoveQuotes(tokens[2]); - auto findResult = spellSchoolMaps.find(tokens[3]); - pInfos[i].uSchool = findResult == spellSchoolMaps.end() ? SPELL_SCHOOL_NONE : findResult->second; - pInfos[i].pShortName=RemoveQuotes(tokens[4]); - pInfos[i].pDescription=RemoveQuotes(tokens[5]); - pInfos[i].pBasicSkillDesc=RemoveQuotes(tokens[6]); - pInfos[i].pExpertSkillDesc=RemoveQuotes(tokens[7]); - pInfos[i].pMasterSkillDesc=RemoveQuotes(tokens[8]); - pInfos[i].pGrandmasterSkillDesc=RemoveQuotes(tokens[9]); - pSpellDatas[i].stats |= strchr(tokens[10], 'm') || strchr(tokens[10], 'M') ? 1 : 0; - pSpellDatas[i].stats |= strchr(tokens[10], 'e') || strchr(tokens[10], 'E') ? 2 : 0; - pSpellDatas[i].stats |= strchr(tokens[10], 'c') || strchr(tokens[10], 'C') ? 4 : 0; - pSpellDatas[i].stats |= strchr(tokens[10], 'x') || strchr(tokens[10], 'X') ? 8 : 0; - } -} -//----- (00448DF8) -------------------------------------------------------- -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 - signed __int64 v10; // st7@4 - signed __int64 v11; // st6@4 - signed __int64 v12; // st5@4 - double v13; // st7@6 - int v14; // ST44_4@7 - uint skillMasteryPlusOne; // ebx@9 - uint v16; // edx@15 - int i; // esi@42 - int j; // esi@60 - unsigned __int64 v36; // qax@99 -// SpellBuff *v37; // ecx@99 - int v38; // esi@103 - signed __int64 v39; // qax@105 - int v42; // esi@111 - int v43; // ebx@111 - int v47; // [sp-4h] [bp-B8h]@35 - int v49; // [sp+0h] [bp-B4h]@35 - int v55; // [sp+28h] [bp-8Ch]@7 - unsigned int yaw; // [sp+30h] [bp-84h]@7 - int pitch; // [sp+34h] [bp-80h]@7 - int v60; // [sp+ACh] [bp-8h]@1 - int a6_4; // [sp+C8h] [bp+14h]@117 - int a7c; // [sp+CCh] [bp+18h]@29 - int a7d; // [sp+CCh] [bp+18h]@55 - signed __int64 xSquared; // [sp+D0h] [bp+1Ch]@6 - int a8b; // [sp+D0h] [bp+1Ch]@37 - int a8c; // [sp+D0h] [bp+1Ch]@55 - signed __int64 ySquared; // [sp+D4h] [bp+20h]@6 - - v9 = 0; - skillMasteryPlusOne = uSkillLevel + 1; - //spellnum_ = uSpellID; - v60 = 0; - if ( tox || toy || toz ) - { - v10 = tox - fromx; - v11 = toy - fromy; - v12 = toz - fromz; - } - else - { - v10 = pParty->vPosition.x - fromx; - v11 = pParty->vPosition.y - fromy; - v12 = (pParty->vPosition.z + pParty->sEyelevel) - fromz; - } - v13 = sqrt(long double(v10 * v10 + v11 * v11 + v12 * v12)); - if ( v13 <= 1.0 ) - { - v55 = 1; - yaw = 0; - pitch = 0; - } - else - { - v55 = (int)v13; - ySquared = v11 * v11; - xSquared = v10 * v10; - v14 = (int)sqrt(long double(xSquared + ySquared)); - yaw = stru_5C6E00->Atan2((int)v10, (int)v11); - pitch = stru_5C6E00->Atan2(v14, (int)v12); - } - Assert(skillMasteryPlusOne > 0 && skillMasteryPlusOne <= 4, "Invalid mastery level"); - - SpriteObject a1; // [sp+38h] [bp-7Ch]@12 - //SpriteObject::SpriteObject(&a1); - - switch ( uSpellID ) - { - case SPELL_FIRE_FIRE_BOLT: - case SPELL_FIRE_FIREBALL: - case SPELL_AIR_LIGHNING_BOLT: - case SPELL_WATER_ICE_BOLT: - case SPELL_WATER_ACID_BURST: - case SPELL_WATER_ICE_BLAST: - case SPELL_EARTH_BLADES: - case SPELL_EARTH_ROCK_BLAST: - case SPELL_WATER_POISON_SPRAY: - case SPELL_AIR_SPARKS: - case SPELL_EARTH_DEATH_BLOSSOM: - a1.uType = stru_4E3ACC[uSpellID].uType; - a1.stru_24.Reset(); - a1.spell_id = uSpellID; - a1.spell_level = uSkill; - a1.spell_skill = skillMasteryPlusOne; - v16 = 0; - while (v16 < pObjectList->uNumObjects) - { - if ( a1.uType == pObjectList->pObjects[v16].uObjectID) - { - break; - } - v16++; - } - a1.uObjectDescID = v16; - a1.vPosition.x = fromx; - a1.vPosition.y = fromy; - a1.vPosition.z = fromz; - a1.uAttributes = 16; - a1.uSectorID = pIndoor->GetSector(fromx, fromy, fromz); - a1.field_60_distance_related_prolly_lod = v55; - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = 8000 | OBJECT_Item; - a1.uSoundID = 0; - break; - } - - switch ( uSpellID ) - { - case SPELL_FIRE_FIRE_BOLT: - case SPELL_FIRE_FIREBALL: - case SPELL_AIR_LIGHNING_BOLT: - case SPELL_WATER_ICE_BOLT: - case SPELL_WATER_ACID_BURST: - case SPELL_WATER_ICE_BLAST: - case SPELL_EARTH_BLADES: - case SPELL_EARTH_ROCK_BLAST: - //v20 = yaw; - a1.spell_target_pid = 0; - a1.uFacing = yaw; - a1.uSoundID = 0; - v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - a1.Create(yaw, pitch, v49, 0); - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); - return; - case SPELL_WATER_POISON_SPRAY: - switch ( skillMasteryPlusOne ) - { - case 1: - v60 = 1; - break; - case 2: - v60 = 3; - break; - case 3: - v60 = 5; - break; - case 4: - v60 = 7; - break; - } - a1.spell_target_pid = 0; - a1.uFacing = yaw; - if ( v60 == 1 ) - { - v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - a1.Create(yaw, pitch, v49, 0); - } - else - { - a7c = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; - a8b = a7c / (v60 - 1); - for ( i = a7c / -2; i <= a7c / 2; i += a8b ) - { - a1.uFacing = i + yaw; - a1.Create((signed __int16)(i + (short)yaw), pitch, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); - } - } - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); - return; - case SPELL_AIR_SPARKS: - switch ( skillMasteryPlusOne ) - { - case 1: - v60 = 3; - break; - case 2: - v60 = 5; - break; - case 3: - v60 = 7; - break; - case 4: - v60 = 9; - break; - } - a7d = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; - a8c = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v60 - 1); - a1.spell_target_pid = 4; - for ( j = a7d / -2; j <= a7d / 2; j += a8c ) - { - a1.uFacing = j + yaw; - a1.Create((signed __int16)(j + (short)yaw), pitch, pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed, 0); - } - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); - return; - case SPELL_EARTH_DEATH_BLOSSOM: - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - return; - a1.spell_target_pid = 4; - v49 = pObjectList->pObjects[(signed __int16)a1.uObjectDescID].uSpeed; - v47 = (signed int)stru_5C6E00->uIntegerHalfPi / 2; - a1.Create(yaw, v47, v49, 0); - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); - return; - - case SPELL_FIRE_HASTE: - if ( skillMasteryPlusOne > 0 ) - { - if ( skillMasteryPlusOne <= 2 ) - v9 = 60 * (uSkill + 60); - else if ( skillMasteryPlusOne == 3 ) - v9 = 180 * (uSkill + 20); - else if ( skillMasteryPlusOne == 4 ) - v9 = 240 * (uSkill + 15); - } - for (uint i = 0; i < 4; ++i) - if (pParty->pPlayers[i].IsWeak()) - return; - pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v9 * 128) * 0.033333335), skillMasteryPlusOne, 0, 0, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0);//çâóê àëòàðÿ - return; - case SPELL_AIR_SHIELD: - case SPELL_EARTH_STONESKIN: - case SPELL_SPIRIT_HEROISM: - switch ( skillMasteryPlusOne ) - { - case 1: - case 2: - v9 = 300 * (uSkill + 12); - break; - case 3: - v9 = 900 * (uSkill + 4); - break; - case 4: - v9 = 3600 * (uSkill + 1); - break; - } - switch ( uSpellID ) - { - case SPELL_AIR_SHIELD: - v60 = 0; - uSkill = 14; - break; - case SPELL_EARTH_STONESKIN: - v60 = uSkill + 5; - uSkill = 15; - break; - case SPELL_SPIRIT_HEROISM: - v60 = uSkill + 5; - uSkill = 9; - break; - } - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); - v36 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(v9 << 7) * 0.033333335); - pParty->pPartyBuffs[uSkill].Apply(v36, skillMasteryPlusOne, v60, 0, 0); - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); - return; - case SPELL_FIRE_IMMOLATION: - if (skillMasteryPlusOne == 4) - v38 = 600 * uSkill; - else - v38 = 60 * uSkill; - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); - v39 = (signed __int64)((double)(v38 << 7) * 0.033333335); - v36 = pParty->uTimePlayed + v39; - pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].Apply(v36, skillMasteryPlusOne, uSkill, 0, 0); - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); - return; - case SPELL_FIRE_PROTECTION_FROM_FIRE: - case SPELL_AIR_PROTECTION_FROM_AIR: - case SPELL_WATER_PROTECTION_FROM_WATER: - case SPELL_EARTH_PROTECTION_FROM_EARTH: - case SPELL_MIND_PROTECTION_FROM_MIND: - case SPELL_BODY_PROTECTION_FROM_BODY: - a6_4 = 3600 * uSkill; - switch (skillMasteryPlusOne) - { - case 1: - v60 = uSkill; - break; - case 2: - v60 = 2 * uSkill; - break; - case 3: - v60 = 3 * uSkill; - break; - case 4: - v60 = 4 * uSkill; - break; - } - switch ( uSpellID ) - { - case SPELL_FIRE_PROTECTION_FROM_FIRE: - uSkill = PARTY_BUFF_RESIST_FIRE; - break; - case SPELL_AIR_PROTECTION_FROM_AIR: - uSkill = PARTY_BUFF_RESIST_AIR; - break; - case SPELL_WATER_PROTECTION_FROM_WATER: - uSkill = PARTY_BUFF_RESIST_WATER; - break; - case SPELL_EARTH_PROTECTION_FROM_EARTH: - uSkill = PARTY_BUFF_RESIST_EARTH; - break; - case SPELL_MIND_PROTECTION_FROM_MIND: - uSkill = PARTY_BUFF_RESIST_MIND; - break; - case SPELL_BODY_PROTECTION_FROM_BODY: - uSkill = PARTY_BUFF_RESIST_BODY; - break; - } - 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), skillMasteryPlusOne, v60, 0, 0); - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); - return; - case SPELL_LIGHT_DAY_OF_THE_GODS : - switch (skillMasteryPlusOne) - { - case 2: - v42 = 10800 * uSkill; - v43 = 3 * uSkill + 10; - break; - case 3: - v42 = 18000 * uSkill; - v43 = 5 * uSkill + 10; - break; - case 4: - v42 = 14400 * uSkill; - v43 = 4 * uSkill + 10; - break; - } - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); - pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); - v39 = (signed __int64)((double)(v42 << 7) * 0.033333335); - v36 = pParty->uTimePlayed + v39; - pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].Apply(v36, skillMasteryPlusOne, v43, 0, 0); - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); - return; - default: - return; - } -} -//----- (00427769) -------------------------------------------------------- -bool sub_427769_isSpellQuickCastableOnShiftClick(unsigned int uSpellID) -{ - return ( pSpellDatas[uSpellID].stats & 0xC ) != 0; -} -//----- (0043AFE3) -------------------------------------------------------- -int _43AFE3_calc_spell_damage(int spellId, int spellLevel, signed int skillMastery, int currentHp) -{ - int result; // eax@1 - unsigned int v5; // [sp-4h] [bp-8h]@9 - - result = 0; - if ( spellId == SPELL_FIRE_FIRE_SPIKE ) - { - switch (skillMastery) - { - case 1: - case 2: - v5 = 6; - case 3: - v5 = 8; - case 4: - v5 = 10; - default: - return 0; - } - result = GetDiceResult(spellLevel, v5); - } - else if ( spellId == SPELL_EARTH_MASS_DISTORTION ) - result = currentHp * (pSpellDatas[SPELL_EARTH_MASS_DISTORTION].baseDamage + 2 * spellLevel) / 100; - else - result = pSpellDatas[spellId].baseDamage - + GetDiceResult(spellLevel, pSpellDatas[spellId].bonusSkillDamage); - - return result; -} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 Spells.h --- a/Spells.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,291 +0,0 @@ -#pragma once - -#include - -#include "VectorTypes.h" - -/* 360 */ -enum SPELL_TYPE -{ - SPELL_FIRE_TORCH_LIGHT = 1, - SPELL_FIRE_FIRE_BOLT = 2, - SPELL_FIRE_PROTECTION_FROM_FIRE = 3, - SPELL_FIRE_FIRE_AURA = 4, - SPELL_FIRE_HASTE = 5, - SPELL_FIRE_FIREBALL = 6, - SPELL_FIRE_FIRE_SPIKE = 7, - SPELL_FIRE_IMMOLATION = 8, - SPELL_FIRE_METEOR_SHOWER = 9, - SPELL_FIRE_INFERNO = 10, - SPELL_FIRE_INCINERATE = 11, - - SPELL_AIR_WIZARD_EYE = 12, - SPELL_AIR_FEATHER_FALL = 13, - SPELL_AIR_PROTECTION_FROM_AIR = 14, - SPELL_AIR_SPARKS = 15, - SPELL_AIR_JUMP = 16, - SPELL_AIR_SHIELD = 17, - SPELL_AIR_LIGHNING_BOLT = 18, - SPELL_AIR_INVISIBILITY = 19, - SPELL_AIR_IMPLOSION = 20, - SPELL_AIR_FLY = 21, - SPELL_AIR_STARBURST = 22, - - SPELL_WATER_AWAKEN = 23, - SPELL_WATER_POISON_SPRAY = 24, - SPELL_WATER_PROTECTION_FROM_WATER = 25, - SPELL_WATER_ICE_BOLT = 26, - SPELL_WATER_WATER_WALK = 27, - SPELL_WATER_RECHARGE_ITEM = 28, - SPELL_WATER_ACID_BURST = 29, - SPELL_WATER_ENCHANT_ITEM = 30, - SPELL_WATER_TOWN_PORTAL = 31, - SPELL_WATER_ICE_BLAST = 32, - SPELL_WATER_LLOYDS_BEACON = 33, - - SPELL_EARTH_STUN = 34, - SPELL_EARTH_SLOW = 35, - SPELL_EARTH_PROTECTION_FROM_EARTH = 36, - SPELL_EARTH_DEADLY_SWARM = 37, - SPELL_EARTH_STONESKIN = 38, - SPELL_EARTH_BLADES = 39, - SPELL_EARTH_STONE_TO_FLESH = 40, - SPELL_EARTH_ROCK_BLAST = 41, - SPELL_EARTH_TELEKINESIS = 42, - SPELL_EARTH_DEATH_BLOSSOM = 43, - SPELL_EARTH_MASS_DISTORTION = 44, - - SPELL_SPIRIT_DETECT_LIFE = 45, - SPELL_SPIRIT_BLESS = 46, - SPELL_SPIRIT_FATE = 47, - SPELL_SPIRIT_TURN_UNDEAD = 48, - SPELL_SPIRIT_REMOVE_CURSE = 49, - SPELL_SPIRIT_PRESERVATION = 50, - SPELL_SPIRIT_HEROISM = 51, - SPELL_SPIRIT_SPIRIT_LASH = 52, - SPELL_SPIRIT_RAISE_DEAD = 53, - SPELL_SPIRIT_SHARED_LIFE = 54, - SPELL_SPIRIT_RESSURECTION = 55, - - SPELL_MIND_REMOVE_FEAR = 56, - SPELL_MIND_MIND_BLAST = 57, - SPELL_MIND_PROTECTION_FROM_MIND = 58, - SPELL_MIND_TELEPATHY = 59, - SPELL_MIND_CHARM = 60, - SPELL_MIND_CURE_PARALYSIS = 61, - SPELL_MIND_BERSERK = 62, - SPELL_MIND_MASS_FEAR = 63, - SPELL_MIND_CURE_INSANITY = 64, - SPELL_MIND_PSYCHIC_SHOCK = 65, - SPELL_MIND_ENSLAVE = 66, - - SPELL_BODY_CURE_WEAKNESS = 67, - SPELL_BODY_FIRST_AID = 68, - SPELL_BODY_PROTECTION_FROM_BODY = 69, - SPELL_BODY_HARM = 70, - SPELL_BODY_REGENERATION = 71, - SPELL_BODY_CURE_POISON = 72, - SPELL_BODY_HAMMERHANDS = 73, - SPELL_BODY_CURE_DISEASE = 74, - SPELL_BODY_PROTECTION_FROM_MAGIC = 75, - SPELL_BODY_FLYING_FIST = 76, - SPELL_BODY_POWER_CURE = 77, - - SPELL_LIGHT_LIGHT_BOLT = 78, - SPELL_LIGHT_DESTROY_UNDEAD = 79, - SPELL_LIGHT_DISPEL_MAGIC = 80, - SPELL_LIGHT_PARALYZE = 81, - SPELL_LIGHT_SUMMON_ELEMENTAL = 82, - SPELL_LIGHT_DAY_OF_THE_GODS = 83, - SPELL_LIGHT_PRISMATIC_LIGHT = 84, - SPELL_LIGHT_DAY_OF_PROTECTION = 85, - SPELL_LIGHT_HOUR_OF_POWER = 86, - SPELL_LIGHT_SUNRAY = 87, - SPELL_LIGHT_DIVINE_INTERVENTION = 88, - - SPELL_DARK_REANIMATE = 89, - SPELL_DARK_TOXIC_CLOUD = 90, - SPELL_DARK_VAMPIRIC_WEAPON = 91, - SPELL_DARK_SHRINKING_RAY = 92, - SPELL_DARK_SHARPMETAL = 93, - SPELL_DARK_CONTROL_UNDEAD = 94, - SPELL_DARK_PAIN_REFLECTION = 95, - SPELL_DARK_SACRIFICE = 96, - SPELL_DARK_DRAGON_BREATH = 97, - SPELL_DARK_ARMAGEDDON = 98, - SPELL_DARK_SOULDRINKER = 99, - - SPELL_BOW_ARROW = 100, - SPELL_101 = 101, - SPELL_LASER_PROJECTILE = 102, - - BECOME_MAGIC_GUILD_MEMBER = 150, - SPELL_QUEST_COMPLETED = 151, - SPELL_152 = 152, - SPELL_DISEASE = 153 -}; - - -enum SPELL_SCHOOL : int -{ - SPELL_SCHOOL_FIRE = 0, - SPELL_SCHOOL_AIR = 1, - SPELL_SCHOOL_WATER = 2, - SPELL_SCHOOL_EARTH = 3, - SPELL_SCHOOL_NONE = 4, - SPELL_SCHOOL_MAGIC = 5, - SPELL_SCHOOL_SPIRIT = 6, - SPELL_SCHOOL_MIND = 7, - SPELL_SCHOOL_BODY = 8, - SPELL_SCHOOL_LIGHT = 9, - SPELL_SCHOOL_DARK = 10 -}; - - - -/* 68 */ -#pragma pack(push, 1) -struct SpellBuff -{ - inline SpellBuff() - { - uExpireTime = 0; - uPower = 0; - uSkill = 0; - uOverlayID = 0; - uCaster = 0; - uFlags = 0; - } - - bool Apply(signed __int64 uExpireTime, unsigned __int16 uSkillLevel, unsigned __int16 uPower, int uOverlayID, unsigned __int8 caster); - void Reset(); - bool IsBuffExpiredToTime(__int64 time_end); - bool NotExpired(); - - signed __int64 uExpireTime; - unsigned __int16 uPower; - unsigned __int16 uSkill; - unsigned __int16 uOverlayID; - unsigned __int8 uCaster; - unsigned __int8 uFlags; -}; -#pragma pack(pop) - - -#pragma pack(push, 1) -struct SpellInfo -{ - char *pName; - char *pShortName; - char *pDescription; - char *pBasicSkillDesc; - char *pExpertSkillDesc; - char *pMasterSkillDesc; - char *pGrandmasterSkillDesc; - SPELL_SCHOOL uSchool; - int field_20; -}; -#pragma pack(pop) - - - -#pragma pack(push, 1) -struct SpellStats -{ - void Initialize(); - - SpellInfo pInfos[100]; -}; -#pragma pack(pop) - - - - - - - - - -/* 364 */ -#pragma pack(push, 1) -struct stru324_spell -{ - __int16 uType; - __int16 field_2; -}; -#pragma pack(pop) - -/* 151 */ -#pragma pack(push, 1) -class SpellData -{ -public: - SpellData(__int16 innormalMana, __int16 inExpertLevelMana, __int16 inMasterLevelMana, __int16 inMagisterLevelMana, - __int16 inNormalLevelRecovery, __int16 inExpertLevelRecovery, __int16 inMasterLevelRecovery, __int16 inMagisterLevelRecovery, - __int8 inbaseDamage, __int8 inbonusSkillDamage, __int16 instats); - union - { - unsigned __int16 mana_per_skill[4]; - struct - { - unsigned __int16 uNormalLevelMana; - unsigned __int16 uExpertLevelMana; - unsigned __int16 uMasterLevelMana; - unsigned __int16 uMagisterLevelMana; - }; - }; - union - { - unsigned __int16 recovery_per_skill[4]; - struct - { - unsigned __int16 uNormalLevelRecovery; - unsigned __int16 uExpertLevelRecovery; - unsigned __int16 uMasterLevelRecovery; - unsigned __int16 uMagisterLevelRecovery; - }; - }; - __int8 baseDamage; - __int8 bonusSkillDamage; - __int16 stats; - // char field_12; - // char field_13; - // __int16 field_14; -}; -#pragma pack(pop) - -#pragma pack(push, 1) -struct SpellBookIconPos -{ - unsigned int Xpos; - unsigned int Ypos; -}; - -#pragma pack(pop) - -/* 154 */ -#pragma pack(push, 1) -struct TownPortalData -{ - Vec3_int_ pos; - __int16 rot_y; - __int16 rot_x; - unsigned __int16 uMapInfoID; - __int16 field_12; -}; -#pragma pack(pop) -extern std::array TownPortalList; //4ECBB8 - - -extern struct SpellStats *pSpellStats; - -extern std::array, 9> pIconPos; - -extern std::array stru_4E3ACC; -extern std::array pSpellDatas; -extern std::array wand_spell_ids; - -int _43AFE3_calc_spell_damage(int spellId, int spellLevel, signed int skillMastery, int currentHp); - -bool sub_427769_isSpellQuickCastableOnShiftClick(unsigned int uSpellID); -void __fastcall EventCastSpell(int uSpellID, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz);//sub_448DF8 diff -r 92eeeb5200f2 -r 68cdef6879a0 StorylineTextTable.cpp --- a/StorylineTextTable.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include -#include - -#include "LOD.h" -#include "texts.h" -#include "StorylineTextTable.h" - -char *pHistoryTXT_Raw; -struct StorylineText *pStorylineText; - -//----- (00453E6D) -------------------------------------------------------- -void StorylineText::Initialize() -{ - char* test_string; - - free(pHistoryTXT_Raw); - pHistoryTXT_Raw = (char *)pEvents_LOD->LoadRaw("history.txt", 0); - strtok(pHistoryTXT_Raw, "\r"); - - StoreLine[0].pText=nullptr; - StoreLine[0].pPageTitle=nullptr; - StoreLine[0].uTime=0; - StoreLine[0].f_9=0; - StoreLine[0].f_A=0; - StoreLine[0].f_B=0; - - for (int i=0;i<28;++i) - { - test_string = strtok(NULL, "\r") + 1; - auto tokens = Tokenize(test_string, '\t'); - - StoreLine[i+1].pText = RemoveQuotes(tokens[1]); - StoreLine[i+1].uTime = atoi(tokens[2]); //strange but in text here string not digit - StoreLine[i+1].pPageTitle = RemoveQuotes(tokens[3]); - } - -} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 StorylineTextTable.h --- a/StorylineTextTable.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -#pragma once - -#pragma pack(push, 1) -struct StorylineRecord -{ - char* pText; //0 - char* pPageTitle; //4 - unsigned __int8 uTime; //8 - char f_9; - char f_A; - char f_B; -}; -#pragma pack(pop) - -/* 173 */ -#pragma pack(push, 1) -struct StorylineText -{ - void Initialize(); - StorylineRecord StoreLine[29]; - int field_15C; - //int field_0; - // int field_4[87]; -}; -#pragma pack(pop) - -extern char *pHistoryTXT_Raw; -extern struct StorylineText *pStorylineText; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 TileFrameTable.h --- a/TileFrameTable.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -#pragma once - - - -/* 327 */ -enum TILE_DESC_FLAGS -{ - TILE_DESC_BURNS = 0x1, - TILE_DESC_WATER = 0x2, - TILE_DESC_BLOCK = 0x4, - TILE_DESC_REPULSE = 0x8, - TILE_DESC_FLAT = 0x10, - TILE_DESC_WAVY = 0x20, - TILE_DESC_DONT_DRAW = 0x40, - TILE_DESC_WATER_2 = 0x100, - TILE_DESC_TRANSITION = 0x200, - TILE_DESC_SCROLL_DOWN = 0x400, - TILE_DESC_SCROLL_UP = 0x800, - TILE_DESC_SCROLL_LEFT = 0x1000, - TILE_DESC_SCROLL_RIGHT = 0x2000, -}; - -#pragma warning( push ) -#pragma warning( disable: 4341 ) -enum Tileset: signed __int16 -{ - Tileset_Grass = 0, - Tileset_Snow = 1, - Tilset_Desert = 2, - Tileset_3 = 3, - Tileset_Dirt = 4, - Tileset_Water = 5, - Tileset_6 = 6, - Tileset_Swamp = 7, - Tileset_8 = 8, - Tileset_9 = 9, - Tileset_RoadGrassCobble = 10, - Tileset_NULL =-1 -}; -#pragma warning( pop ) - -/* 48 */ -#pragma pack(push, 1) -struct TileDesc //26 -{ - char pTileName[16]; - unsigned __int16 uTileID; - unsigned __int16 uBitmapID; - Tileset tileset; - unsigned __int16 uSection; - unsigned __int16 uAttributes; -}; -#pragma pack(pop) - -/* 49 */ -#pragma pack(push, 1) -struct TileTable -{ - //----- (00487E13) -------------------------------------------------------- - TileTable() - { - this->pTiles = nullptr; - this->sNumTiles = 0; - } - ~TileTable(); - - TileDesc *GetTileById(unsigned int uTileID); - void InitializeTileset(Tileset tileset); - int GetTileForTerrainType(signed int a1, bool a2); - unsigned int GetTileId(unsigned int uTerrainType, unsigned int uSection); - void ToFile(); - void FromFile(void *data_mm6, void *data_mm7, void *data_mm8); - int FromFileTxt(const char *pFilename); - - signed int sNumTiles; - struct TileDesc *pTiles; -}; -#pragma pack(pop) diff -r 92eeeb5200f2 -r 68cdef6879a0 TileTable.cpp --- a/TileTable.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,795 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include -#include -#include - -#include "ErrorHandling.h" -#include "TileFrameTable.h" -#include "FrameTableInc.h" -#include "Engine/Graphics/PaletteManager.h" -#include "LOD.h" - -#include "mm7_data.h" - - -//----- (00487E1D) -------------------------------------------------------- -TileTable::~TileTable() -{ - free(pTiles); - pTiles = nullptr; - sNumTiles = 0; -} - -//----- (00487E3B) -------------------------------------------------------- -TileDesc *TileTable::GetTileById(unsigned int uTileID) -{ - Assert(uTileID < sNumTiles); - return &pTiles[uTileID]; -} - -//----- (00487E58) -------------------------------------------------------- -void TileTable::InitializeTileset(Tileset tileset) -{ - for (int i = 0; i < sNumTiles; ++i ) - { - if (pTiles[i].tileset == tileset && pTiles[i].pTileName[0] ) - { - pTiles[i].uBitmapID = pBitmaps_LOD->LoadTexture(pTiles[i].pTileName); - if ( pTiles[i].uBitmapID != -1 ) - pBitmaps_LOD->pTextures[pTiles[i].uBitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[pTiles[i].uBitmapID].palette_id1); - } - } -} - -//----- (00487ED6) -------------------------------------------------------- -int TileTable::GetTileForTerrainType( signed int terrain_type, bool not_random ) - { - int v5; // edx@3 - int v6; // edx@11 - - if ( not_random || terrain_type > 8 ) - { - return GetTileId(terrain_type, 0); - } - v5 = rand() % 50; - if ( v5 < 20) - { - return GetTileId(terrain_type, 0); - } - else if ( v5 < 30 ) - { - return GetTileId(terrain_type, 1); - } - else if ( v5 < 40 ) - { - return GetTileId(terrain_type, 2); - } - else if ( v5 < 48 ) - { - return GetTileId(terrain_type, 3); - } - v6 = rand() % 8; - return GetTileId(terrain_type, v6+4); - return 0; -} - -//----- (00487F84) -------------------------------------------------------- -unsigned int TileTable::GetTileId(unsigned int uTerrainType, unsigned int uSection) -{ - for (int i=0; ipTiles, 0x1Au, v1->sNumTiles, v3); - fclose(v3); -} - -//----- (00488000) -------------------------------------------------------- -void TileTable::FromFile(void *data_mm6, void *data_mm7, void *data_mm8) -{ - uint num_mm6_tiles = data_mm6 ? *(int *)data_mm6 : 0, - num_mm7_tiles = data_mm7 ? *(int *)data_mm7 : 0, - num_mm8_tiles = data_mm8 ? *(int *)data_mm8 : 0; - sNumTiles = num_mm6_tiles + num_mm7_tiles + num_mm8_tiles; - Assert(sNumTiles); - Assert(!num_mm8_tiles); - - pTiles = (TileDesc *)malloc(sNumTiles * sizeof(TileDesc)); - memcpy(pTiles, (char *)data_mm7 + 4, num_mm7_tiles * sizeof(TileDesc)); - memcpy(pTiles + num_mm7_tiles, (char *)data_mm6 + 4, num_mm6_tiles * sizeof(TileDesc)); - memcpy(pTiles + num_mm6_tiles + num_mm7_tiles, (char *)data_mm8 + 4, num_mm8_tiles * sizeof(TileDesc)); -} - -//----- (00488047) -------------------------------------------------------- -int TileTable::FromFileTxt(const char *pFilename) -{ - TileTable *v2; // ebp@1 - FILE *v3; // eax@1 - unsigned int v4; // ebx@3 - void *v5; // eax@9 - unsigned __int16 v6; // ax@14 - const char *v7; // ST14_4@14 - unsigned __int16 v8; // ax@14 - const char *v9; // esi@14 - int v10; // eax@17 - int v11; // eax@20 - int v12; // eax@22 - int v13; // eax@24 - int v14; // eax@26 - int v15; // eax@28 - int v16; // eax@30 - int v17; // eax@32 - int v18; // eax@34 - int v19; // eax@36 - int v20; // eax@38 - int v21; // eax@40 - int v22; // eax@42 - int v23; // eax@44 - int v24; // eax@46 - int v25; // eax@48 - int v26; // eax@50 - int v27; // eax@52 - int v28; // eax@54 - int v29; // eax@56 - int v30; // eax@58 - int v31; // eax@60 - int v32; // eax@62 - int v33; // eax@64 - int v34; // eax@66 - const char *v35; // esi@67 - int v36; // eax@70 - int v37; // eax@73 - int v38; // eax@75 - int v39; // eax@77 - int v40; // eax@79 - int v41; // eax@81 - int v42; // eax@83 - int v43; // eax@85 - int v44; // eax@87 - int v45; // eax@89 - int v46; // eax@91 - int v47; // eax@93 - int v48; // eax@108 - int v49; // eax@110 - int v50; // eax@112 - int v51; // eax@114 - int v52; // eax@116 - int v53; // eax@118 - int v54; // eax@120 - int v55; // eax@122 - int v56; // eax@124 - int v57; // eax@126 - int v58; // eax@128 - int v59; // eax@130 - int v60; // eax@132 - int v61; // eax@134 - int v62; // eax@136 - int v63; // eax@138 - int v64; // eax@140 - int v65; // eax@142 - int v66; // eax@144 - int v67; // eax@146 - int v68; // eax@148 - int v69; // eax@150 - int v70; // eax@151 - int j; // edi@152 - const char *v72; // esi@153 - int v73; // eax@154 - int v74; // eax@156 - int v75; // eax@160 - int v76; // eax@162 - int v77; // eax@164 - int v78; // eax@166 - int v79; // eax@168 - int v80; // eax@170 - FILE *i; // [sp-10h] [bp-304h]@3 - FILE *File; // [sp+4h] [bp-2F0h]@1 - FrameTableTxtLine v84; // [sp+8h] [bp-2ECh]@4 - FrameTableTxtLine v85; // [sp+84h] [bp-270h]@4 - char Buf; // [sp+100h] [bp-1F4h]@4 - - v2 = this; - v3 = fopen(pFilename, "r"); - File = v3; - if ( !v3 ) - Error("TileTable::load - Unable to open file: %s."); - v4 = 0; - for ( i = v3; fgets(&Buf, 490, i); i = File ) - { - *strchr(&Buf, 10) = 0; - memcpy(&v84, txt_file_frametable_parser(&Buf, &v85), sizeof(v84)); - if ( v84.uPropCount && *v84.pProperties[0] != 47 ) - ++v4; - } - v2->sNumTiles = v4; - v5 = malloc(26 * v4); - v2->pTiles = (TileDesc *)v5; - if ( !v5 ) - Error("TileTable::Load - Out of Memory!"); - memset(v5, 0, 26 * v2->sNumTiles); - v2->sNumTiles = 0; - fseek(File, 0, 0); - if ( fgets(&Buf, 490, File) ) - { - while ( 1 ) - { - *strchr(&Buf, 10) = 0; - memcpy(&v84, txt_file_frametable_parser(&Buf, &v85), sizeof(v84)); - if ( v84.uPropCount ) - { - if ( *v84.pProperties[0] != 47 ) - break; - } -LABEL_173: - if ( !fgets(&Buf, 490, File) ) - goto LABEL_174; - } - strcpy(v2->pTiles[v2->sNumTiles].pTileName, v84.pProperties[0]); - v6 = atoi(v84.pProperties[1]); - v7 = v84.pProperties[2]; - v2->pTiles[v2->sNumTiles].uTileID = v6; - v8 = atoi(v7); - v9 = v84.pProperties[3]; - v2->pTiles[v2->sNumTiles].uBitmapID = v8; - v2->pTiles[v2->sNumTiles].tileset = Tileset_Grass; - if ( _stricmp(v9, "TTtype_NULL") ) - { - if ( _stricmp(v9, "TTtype_Start") ) - { - if ( _stricmp(v9, "TTtype_Grass") ) - { - if ( _stricmp(v9, "TTtype_Cracked") ) - { - if ( _stricmp(v9, "TTtype_Snow") ) - { - if ( _stricmp(v9, "TTtype_Sand") ) - { - if ( _stricmp(v9, "TTtype_Volcano") ) - { - if ( _stricmp(v9, "TTtype_Dirt") ) - { - if ( _stricmp(v9, "TTtype_Water") ) - { - if ( _stricmp(v9, "TTtype_Tropical") ) - { - if ( _stricmp(v9, "TTtype_Swamp") ) - { - if ( _stricmp(v9, "TTtype_City") ) - { - if ( _stricmp(v9, "TTtype_RoadGrassCobble") ) - { - if ( _stricmp(v9, "TTtype_RoadGrassDirt") ) - { - if ( _stricmp(v9, "TTtype_RoadCrackedCobble") ) - { - if ( _stricmp(v9, "TTtype_RoadCrackedDirt") ) - { - if ( _stricmp(v9, "TTtype_RoadSandCobble") ) - { - if ( _stricmp(v9, "TTtype_RoadSandDirt") ) - { - if ( _stricmp(v9, "TTtype_RoadVolcanoCobble") ) - { - if ( _stricmp(v9, "TTtype_RoadVolcanoDirt") ) - { - if ( _stricmp(v9, "TTtype_RoadSwampCobble") ) - { - if ( _stricmp(v9, "TTtype_RoadSwampDirt") ) - { - if ( _stricmp(v9, "TTtype_RoadTropicalCobble") ) - { - if ( _stricmp(v9, "TTtype_RoadTropicalDirt") ) - { - if ( _stricmp(v9, "TTtype_RoadSnowCobble") ) - { - if ( _stricmp(v9, "TTtype_RoadSnowDirt") ) - { - if ( !_stricmp(v9, "TTtype_RoadCityStone") ) - { - v34 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v34 |= 0x1Cu; - } - } - else - { - v33 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v33 |= 0xDu; - } - } - else - { - v32 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v32 |= 0xCu; - } - } - else - { - v31 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v31 |= 0x1Bu; - } - } - else - { - v30 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v30 |= 0x1Au; - } - } - else - { - v29 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v29 |= 0x19u; - } - } - else - { - v28 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v28 |= 0x18u; - } - } - else - { - v27 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v27 |= 0x11u; - } - } - else - { - v26 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v26 |= 0x10u; - } - } - else - { - v25 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v25 |= 0xFu; - } - } - else - { - v24 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v24 |= 0xEu; - } - } - else - { - v23 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v23 |= 0x17u; - } - } - else - { - v22 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v22 |= 0x16u; - } - } - else - { - v21 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v21 |= 0xBu; - } - } - else - { - v20 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v20 |= 0xAu; - } - } - else - { - v19 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v19 |= 9u; - } - } - else - { - v18 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v18 |= 7u; - } - } - else - { - v17 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v17 |= 8u; - } - } - else - { - v16 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v16 |= 5u; - } - } - else - { - v15 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v15 |= 4u; - } - } - else - { - v14 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v14 |= 3u; - } - } - else - { - v13 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v13 |= 2u; - } - } - else - { - v12 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v12 |= 1u; - } - } - else - { - v11 = (int)&v2->pTiles[v2->sNumTiles].tileset; - *(char *)v11 |= 6u; - } - } - } - else - { - v10 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v10 |= 0xFEu; - } - } - else - { - LOBYTE(v2->pTiles[v2->sNumTiles].tileset) = -1; - } - v35 = v84.pProperties[4]; - v2->pTiles[v2->sNumTiles].uSection = 0; - v2->pTiles[v2->sNumTiles].uAttributes = 0; - if ( !_stricmp(v35, "TTsect_NULL") ) - { - LOBYTE(v2->pTiles[v2->sNumTiles].uSection) = -1; -LABEL_152: - for ( j = 5; j < v84.uPropCount; ++j ) - { - v72 = v84.pProperties[j]; - if ( _stricmp(v84.pProperties[j], "TTattr_Burn") ) - { - if ( _stricmp(v72, "TTattr_Water") ) - { - if ( _stricmp(v72, "TTattr_Water2") ) - { - if ( _stricmp(v72, "TTattr_Block") ) - { - if ( _stricmp(v72, "TTattr_Repulse") ) - { - if ( _stricmp(v72, "TTattr_Flat") ) - { - if ( _stricmp(v72, "TTattr_Wave") ) - { - if ( _stricmp(v72, "TTattr_NoDraw") ) - { - if ( !_stricmp(v72, "TTattr_Transition") ) - { - v80 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; - *(short *)v80 |= 0x200u; - } - } - else - { - v79 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; - *(char *)v79 |= 0x40u; - } - } - else - { - v78 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; - *(char *)v78 |= 0x20u; - } - } - else - { - v77 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; - *(char *)v77 |= 0x10u; - } - } - else - { - v76 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; - *(char *)v76 |= 8u; - } - } - else - { - v75 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; - *(char *)v75 |= 4; - } - } - else - HIBYTE(v2->pTiles[v2->sNumTiles].uAttributes) |= 1; - } - else - { - v74 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; - *(char *)v74 |= 2; - } - } - else - { - v73 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; - *(char *)v73 |= 1u; - } - } - ++v2->sNumTiles; - goto LABEL_173; - } - if ( !_stricmp(v35, "TTsect_Start") ) - { - v36 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v36 |= 0xFEu; - goto LABEL_152; - } - if ( !_stricmp(v35, "TTsect_Base1") ) - goto LABEL_152; - if ( !_stricmp(v35, "TTsect_Base2") ) - { - v37 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v37 |= 1u; - goto LABEL_152; - } - if ( !_stricmp(v35, "TTsect_Base3") ) - { - v38 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v38 |= 2u; - goto LABEL_152; - } - if ( !_stricmp(v35, "TTsect_Base4") ) - { - v39 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v39 |= 3u; - goto LABEL_152; - } - if ( !_stricmp(v35, "TTsect_Special1") ) - { - v40 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v40 |= 4u; - goto LABEL_152; - } - if ( !_stricmp(v35, "TTsect_Special2") ) - { - v41 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v41 |= 5u; - goto LABEL_152; - } - if ( !_stricmp(v35, "TTsect_Special3") ) - { - v42 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v42 |= 6u; - goto LABEL_152; - } - if ( !_stricmp(v35, "TTsect_Special4") ) - { - v43 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v43 |= 7u; - goto LABEL_152; - } - if ( !_stricmp(v35, "TTsect_Special5") ) - { - v44 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v44 |= 8u; - goto LABEL_152; - } - if ( !_stricmp(v35, "TTsect_Special6") ) - { - v45 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v45 |= 9u; - goto LABEL_152; - } - if ( !_stricmp(v35, "TTsect_Special7") ) - { - v46 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v46 |= 0xAu; - goto LABEL_152; - } - if ( !_stricmp(v35, "TTsect_Special8") ) - { - v47 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v47 |= 0xBu; - goto LABEL_152; - } - if ( !_stricmp(v35, "TTsect_NE1") ) - goto LABEL_130; - if ( !_stricmp(v35, "TTsect_NW1") ) - goto LABEL_134; - if ( !_stricmp(v35, "TTsect_SE1") ) - goto LABEL_130; - if ( !_stricmp(v35, "TTsect_SW1") ) - goto LABEL_134; - if ( !_stricmp(v35, "TTsect_E1") ) - goto LABEL_138; - if ( !_stricmp(v35, "TTsect_W1") ) - goto LABEL_140; - if ( !_stricmp(v35, "TTsect_N1") ) - goto LABEL_142; - if ( !_stricmp(v35, "TTsect_S1") ) - goto LABEL_144; - if ( !_stricmp(v35, "TTsect_XNE1") ) - goto LABEL_146; - if ( _stricmp(v35, "TTsect_XNW1") ) - { - if ( !_stricmp(v35, "TTsect_XSE1") ) - goto LABEL_146; - if ( _stricmp(v35, "TTsect_XSW1") ) - { - if ( !_stricmp(v35, "TTsect_CROS") ) - { -LABEL_151: - v70 = (int)&v2->pTiles[v2->sNumTiles].uAttributes; - *(short *)v70 |= 0x200u; - goto LABEL_152; - } - if ( !_stricmp(v35, "TTsect_NS") ) - { - v48 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v48 |= 1u; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_EW") ) - { - v49 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v49 |= 2u; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_N_E") ) - { - v50 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v50 |= 3u; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_N_W") ) - { - v51 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v51 |= 4u; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_S_E") ) - { - v52 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v52 |= 5u; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_S_W") ) - { - v53 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v53 |= 6u; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_NS_E") ) - { - v54 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v54 |= 7u; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_NS_W") ) - { - v55 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v55 |= 8u; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_EW_N") ) - { - v56 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v56 |= 9u; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_EW_S") ) - { - v57 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v57 |= 0xAu; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_NCAP") ) - { - v58 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v58 |= 0xBu; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_ECAP") ) - { -LABEL_130: - v59 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v59 |= 0xCu; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_SCAP") ) - { - v60 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v60 |= 0xDu; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_WCAP") ) - { -LABEL_134: - v61 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v61 |= 0xEu; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_DN") ) - { - v62 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v62 |= 0xFu; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_DS") ) - { -LABEL_138: - v63 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v63 |= 0x10u; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_DW") ) - { -LABEL_140: - v64 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v64 |= 0x11u; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_DE") ) - { -LABEL_142: - v65 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v65 |= 0x12u; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_DSW") ) - { -LABEL_144: - v66 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v66 |= 0x13u; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_DNE") ) - { -LABEL_146: - v67 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v67 |= 0x14u; - goto LABEL_151; - } - if ( !_stricmp(v35, "TTsect_DSE") ) - { - v68 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v68 |= 0x15u; - goto LABEL_151; - } - if ( _stricmp(v35, "TTsect_DNW") ) - goto LABEL_152; - } - } - v69 = (int)&v2->pTiles[v2->sNumTiles].uSection; - *(char *)v69 |= 0x16u; - goto LABEL_151; - } -LABEL_174: - fclose(File); - return 1; -} - diff -r 92eeeb5200f2 -r 68cdef6879a0 Timer.cpp --- a/Timer.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,108 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS - -#include "Timer.h" -#include "Keyboard.h" - -#include "OSAPI.h" - - - - - -Timer *pMiscTimer = new Timer; -Timer *pEventTimer; - - - - - - -//----- (00426317) -------------------------------------------------------- -unsigned __int64 Timer::Time() -{ - unsigned __int64 v2 = TimeQuant * timeGetTime() / 1000; - if (v2 < uStartTime) - uStartTime = 0; - return v2; -} - - - -//----- (00426349) -------------------------------------------------------- -void Timer::Pause() -{ - if (!bPaused) - { - uStopTime = Time(); - bPaused = true; - } -} - -//----- (00426363) -------------------------------------------------------- -void Timer::Resume() -{ - if (bPaused) - { - pKeyActionMap->ResetKeys();//Unhandled application exception - - bPaused = 0; - uStartTime = Time(); - } -} - -//----- (00426386) -------------------------------------------------------- -void Timer::TrackGameTime() -{ - if (!bTackGameTime) - { - uGameTimeStart = Time(); - bTackGameTime = true; - } -} - - - -//----- (004263A0) -------------------------------------------------------- -void Timer::StopGameTime() -{ - if (bTackGameTime) - { - bTackGameTime = 0; - uStartTime = Time(); - } -} - -//----- (004263B7) -------------------------------------------------------- -void Timer::Update() -{ - //Timer *v1; // esi@1 - //unsigned int v2; // eax@2 - //signed int v3; // eax@3 - //char v4; // zf@5 - - - unsigned __int64 new_time = Time(); - while (new_time <= uStartTime) - new_time = Time(); - - uTimeElapsed = new_time - uStartTime; - uStartTime = new_time; - - if (uTimeElapsed > 32) - uTimeElapsed = 32; - - if (!bPaused && !bTackGameTime) - uTotalGameTimeElapsed += uTimeElapsed; - dt_in_some_format = (uTimeElapsed << 16) / 128; -} - -//----- (00426402) -------------------------------------------------------- -void Timer::Initialize() -{ - uTotalGameTimeElapsed = 0; - bReady = true; -} diff -r 92eeeb5200f2 -r 68cdef6879a0 Timer.h --- a/Timer.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -#pragma once - - - - -/* 61 */ -#pragma pack(push, 1) -struct Timer -{ - static Timer *Create() {return new Timer;} - - Timer(): - bReady(false), bPaused(false) - { - bTackGameTime = 0; - uStartTime = 0; - uStopTime = 0; - uGameTimeStart = 0; - field_18 = 0; - uTimeElapsed = 0; - dt_in_some_format = 0; - uTotalGameTimeElapsed = 0; - } - - void Initialize(); - unsigned __int64 Time(); - void Update(); - void Pause(); - void Resume(); - void TrackGameTime(); - void StopGameTime(); - - unsigned int bReady; - unsigned int bPaused; - int bTackGameTime; - unsigned int uStartTime; - unsigned int uStopTime; - int uGameTimeStart; - int field_18; - unsigned int uTimeElapsed; - int dt_in_some_format; - unsigned int uTotalGameTimeElapsed; - - static const unsigned int TimeQuant = 128; - static const unsigned int Minute = 2 * TimeQuant; - static const unsigned int Hour = 60 * Minute; - static const unsigned int Day = 24 * Hour; - static const unsigned int Week = 7 * Day; - static const unsigned int Month = 4 * Week; - static const unsigned int Year = 12 * Month; -}; - -#pragma pack(pop) - - - -extern Timer *pMiscTimer; -extern Timer *pEventTimer; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 TurnEngine.cpp --- a/TurnEngine.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1103 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS - - -#include "MM7.h" -#include "mm7_data.h" -#include "Actor.h" -#include "Party.h" -#include "AudioPlayer.h" -#include "SpriteObject.h" -#include "Timer.h" -#include "stru298.h" -#include "IconFrameTable.h" -#include "Engine/Graphics/Viewport.h" -#include "FactionTable.h" - -#include "TurnEngine.h" - - -#include "Game.h" -struct stru262_TurnBased *pTurnEngine = new stru262_TurnBased; - - -//----- (00404544) -------------------------------------------------------- -void stru262_TurnBased::SortTurnQueue() -{ - int active_actors; - TurnBased_QueueElem *current_top; // eax@16 - TurnBased_QueueElem *test_element; // ecx@18 - TurnBased_QueueElem temp_elem; - int i,j; - unsigned int p_type; - unsigned int p_id; - - active_actors = this->uActorQueueSize; - //set non active actors in queue initiative that not allow them to paticipate - for( i = 0; i < uActorQueueSize; ++i) - { - p_type = PID_TYPE(pQueue[i].uPackedID); - p_id = PID_ID(pQueue[i].uPackedID); - - if ( p_type == OBJECT_Actor ) - { - pActors[p_id].uAttributes |= ACTOR_STAND_IN_QUEUE;//0x80 - if ( !pActors[p_id].CanAct() ) - { - --active_actors; - pQueue[i].actor_initiative = 1001; - pActors[p_id].ResetQueue(); - } - } - else if ( p_type == OBJECT_Player) - { - if ( !pParty->pPlayers[p_id].CanAct() ) - { - --active_actors; - pQueue[i].actor_initiative = 1001; - } - } - } - //sort - if (uActorQueueSize > 0) - { - for( i = 0; i < uActorQueueSize-1; ++i) - { - current_top=&pQueue[i]; - for ( j = i+1; j < uActorQueueSize; ++j ) - { - test_element=&pQueue[j]; - if ( test_element->actor_initiative < current_top->actor_initiative || // if less initiative -> top - ((test_element->actor_initiative == current_top->actor_initiative) && - (((PID_TYPE(test_element->uPackedID) == OBJECT_Player) && (PID_TYPE(current_top->uPackedID) == OBJECT_Actor)) || //player preferable - ((PID_TYPE(test_element->uPackedID) == PID_TYPE(current_top->uPackedID)) && (PID_ID(test_element->uPackedID) < PID_ID(current_top->uPackedID)))))) //less id preferable - { //swap - memcpy(&temp_elem,current_top,sizeof(TurnBased_QueueElem)); - memcpy(current_top,test_element, sizeof(TurnBased_QueueElem)); - memcpy(test_element, &temp_elem, sizeof(TurnBased_QueueElem)); - } - } - } - } - uActorQueueSize = active_actors; - if ( PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) //we have player at queue top - { - uActiveCharacter = PID_ID(pQueue[0].uPackedID)+1; - field_18 |= TE_PLAYER_TURN; - } - else - { - uActiveCharacter = 0; - field_18 &= ~TE_PLAYER_TURN; - } - for ( i = 0; i < uActorQueueSize; ++i) - { - if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) //set recovery times - pParty->pPlayers[PID_ID(pQueue[i].uPackedID)].uTimeToRecovery = (unsigned __int16)((double)pQueue[i].actor_initiative * 0.46875); - } -} -//----- (0040471C) -------------------------------------------------------- -void stru262_TurnBased::ApplyPlayerAction() -{ - if ( pParty->bTurnBasedModeOn == 1 ) - { - if ( pTurnEngine->turn_stage == TE_ATTACK ) - _406457(0); - } -} - -//----- (004059DB) -------------------------------------------------------- -void stru262_TurnBased::Start() -{ - int v17; // edx@22 - AIDirection v30; // [sp+Ch] [bp-68h]@10 - AIDirection v31; // [sp+28h] [bp-4Ch]@10 - AIDirection a3; // [sp+44h] [bp-30h]@10 - int activ_players[4]; - int players_recovery_time[4]; - int a_players_count; - int i,j; - int temp; - - pTurnEngine->field_18 &= ~TE_HAVE_PENDING_ACTIONS; - pEventTimer->TrackGameTime(); - pAudioPlayer->StopChannels(-1, -1); - pAudioPlayer->PlaySound(SOUND_207, 0, 0, -1, 0, 0, 0, 0); - //pPlayer = pParty->pPlayers.data(); - dword_50C998_turnbased_icon_1A = 8 * pIconsFrameTable->pIcons[uIconID_TurnStart].uAnimLength; - dword_50C994 = 0; - - this->turn_initiative = 100; - this->turns_count = 0; - this->ai_turn_timer = 64; - this->turn_stage = TE_WAIT; - this->uActorQueueSize = 0; - - for ( uint pl_id = 0; pl_id < 4 ; ++pl_id ) - { - if ( pParty->pPlayers[pl_id].CanAct() ) - { - this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Player,pl_id); - this->pQueue[this->uActorQueueSize].AI_action_type = TE_AI_PURSUE; - this->pQueue[this->uActorQueueSize].uActionLength = 0; - pParty->pTurnBasedPlayerRecoveryTimes[this->uActorQueueSize] = 0; - ++this->uActorQueueSize; - } - } - - for ( int i = 0; i < ai_arrays_size ; ++i ) - { - if (ai_near_actors_ids[i] == 10) - continue; - if ( pActors[ai_near_actors_ids[i]].CanAct() ) - { - if ( pActors[ai_near_actors_ids[i]].ActorNearby() ) - { - pActors[ai_near_actors_ids[i]].uAttributes |= ACTOR_STAND_IN_QUEUE;//0x80 - Actor::GetDirectionInfo(PID(OBJECT_Actor,ai_near_actors_ids[i]), ai_near_actors_targets_pid[ai_near_actors_ids[i]], &v31, 0); - memcpy(&v30, &v31, sizeof(AIDirection)); - Actor::AI_StandOrBored(ai_near_actors_ids[i], 4, 32, &v30); - this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Actor,ai_near_actors_ids[i]); - this->pQueue[this->uActorQueueSize].AI_action_type = TE_AI_PURSUE; - this->pQueue[this->uActorQueueSize].uActionLength = 0; - ++this->uActorQueueSize; - } - } - } - - a_players_count = 0; - for ( int k = 0; k < this->uActorQueueSize; ++k ) - { - //set initial initiative for turn actors - if ( PID_TYPE(this->pQueue[k].uPackedID) == OBJECT_Player ) - { - if ( pPlayers[PID_ID(this->pQueue[k].uPackedID) + 1]->uTimeToRecovery != 0 ) - this->pQueue[k].actor_initiative = (signed int)((double)pPlayers[PID_ID(this->pQueue[k].uPackedID) + 1]->uTimeToRecovery * 0.46875); - else - { - activ_players[a_players_count] = k; - ++a_players_count; - } - } - else if ( PID_TYPE(this->pQueue[k].uPackedID) == OBJECT_Actor ) - { - v17 = rand() % 99; - if ( v17 < 33 ) - this->pQueue[k].actor_initiative = 1; - else - this->pQueue[k].actor_initiative= (v17 >= 66)? 5 : 3; - } - else //fot non player and actor - this->pQueue[k].actor_initiative = 666; - this->pQueue[k].actor_initiative += 16; - } - - if ( a_players_count > 0 ) - { - for ( i = 0; i < a_players_count; ++i) - players_recovery_time[i] = pParty->pPlayers[PID_ID(this->pQueue[activ_players[i]].uPackedID)].GetAttackRecoveryTime(0); - //sort players by recovery time - for ( i = 0; i < a_players_count-1; ++i) - { - for ( j = i + 1; j < a_players_count; ++j ) - { - if (players_recovery_time[j] < players_recovery_time[i]) //swap values - { - temp = players_recovery_time[i]; - players_recovery_time[i] = players_recovery_time[j]; - players_recovery_time[j] = temp; - temp = activ_players[i]; - activ_players[i] = activ_players[j]; - activ_players[j] = temp; - } - } - } - for ( i = 0; i < a_players_count; ++i) - this->pQueue[activ_players[i]].actor_initiative = i + 2; - } - this->SortTurnQueue(); -} - -//----- (00405CFF) -------------------------------------------------------- -void stru262_TurnBased::End(bool bPlaySound) -{ - ObjectType objType; // eax@13 - int objID; // esi@13 - int i; - - this->turn_stage = TE_NONE; - for( i = 0; i < uActorQueueSize; ++i) - { - if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor ) - pActors[PID_ID(pQueue[i].uPackedID)].ResetQueue(); - } - - for( uint i = 0; i < uNumSpriteObjects; ++i) - { - if (pSpriteObjects[i].uAttributes & 4) - pSpriteObjects[i].uAttributes &= ~0x04; - } - - for( i = 0; i < uActorQueueSize; ++i) - { - objType = (ObjectType)PID_TYPE(pQueue[i].uPackedID); - objID = PID_ID(pQueue[i].uPackedID); - if ( objType == OBJECT_Player ) - pPlayers[objID + 1]->uTimeToRecovery = (unsigned __int16)((double)pQueue[i].actor_initiative * 2.133333333333333); - else if ( objType == OBJECT_Actor ) - pActors[objID].pMonsterInfo.uRecoveryTime = (unsigned __int16)((double)pQueue[i].actor_initiative * 2.133333333333333); - } - pAudioPlayer->StopChannels(-1, -1); - if ( bPlaySound != 0 ) - pAudioPlayer->PlaySound(SOUND_206, 0, 0, -1, 0, 0, 0, 0); - pTurnEngine->field_18 &= ~TE_HAVE_PENDING_ACTIONS; - pEventTimer->StopGameTime(); - dword_50C994 = 0; - dword_50C998_turnbased_icon_1A = 0; -} -// 50C994: using guessed type int dword_50C994; -// 50C998: using guessed type int dword_50C998_turnbased_icon_1A; - -//----- (00405E14) -------------------------------------------------------- -void stru262_TurnBased::AITurnBasedAction() -{ - AIDirection v6; // esi@21 - AIDirection a3; // [sp+4h] [bp-68h]@21 - AIDirection v14; // [sp+20h] [bp-4Ch]@21 - AIDirection v15; // [sp+3Ch] [bp-30h]@21 - Actor *curr_actor; // [sp+58h] [bp-14h]@2 - int target_pid; // [sp+5Ch] [bp-10h]@6 - int shrinked; - int j; - - for (uint i = 0; i < uNumActors; ++i ) - { - curr_actor=&pActors[i]; - shrinked=pActors[i].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime > 0; - for (j = 0; j < 22; ++j) //check expired spell Buffs - { - if (j != 10) - pActors[i].pActorBuffs[j].IsBuffExpiredToTime(pParty->uTimePlayed); - } - if (shrinked && pActors[i].pActorBuffs[ACTOR_BUFF_SHRINK].uExpireTime <= 0) //buff 3 expired - pActors[i].uActorHeight = pMonsterList->pMonsters[pActors[i].pMonsterInfo.uID - 1].uMonsterHeight; - if (!(curr_actor->uAttributes & 0x80) && (!curr_actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime) && - (!curr_actor->pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime)) - { - curr_actor->uCurrentActionTime += pMiscTimer->uTimeElapsed; - if (curr_actor->uCurrentActionTime>=curr_actor->uCurrentActionLength) - { - target_pid = ai_near_actors_targets_pid[i]; - Actor::GetDirectionInfo(PID(OBJECT_Actor,i), target_pid, &v6, 0); - memcpy(&v15, &v6, sizeof(AIDirection)); - memcpy(&v14, &v15, sizeof(AIDirection)); - if ( curr_actor->uAIState == Dying ) - { - curr_actor->uCurrentActionTime = 0; - curr_actor->uCurrentActionLength = 0; - curr_actor->uAIState = Dead; - curr_actor->UpdateAnimation(); - } - else if ( (curr_actor->uAIState > Removed) && (curr_actor->uAIState < Disabled)) - Actor::AI_StandOrBored(i, target_pid, 32, &v14); - } - } - } - if ( turn_stage == TE_WAIT ) - { - if ( ai_turn_timer == 64 ) - ActorAISetMovementDecision(); - else if ( ai_turn_timer > 0 ) - ActorAIDoAdditionalMove(); - else - { - ActorAIStopMovement(); - turn_initiative = 100; - } - ai_turn_timer -= pEventTimer->uTimeElapsed; - } - else if ( turn_stage == TE_ATTACK ) - { - if ( !(field_18 &TE_FLAG_1)) - { - if ( turn_initiative == 100 ) - { - StartTurn(); - SetAIRecoveryTimes(); - return; - } - if ( turn_initiative > 0 || pQueue[0].actor_initiative <= 0 ) - { - _4065B0(); - SetAIRecoveryTimes(); - return; - } - } - NextTurn(); - } - else if ( turn_stage == TE_MOVEMENT ) - { - if ( (uActionPointsLeft > 0) && (!(field_18 & TE_FLAG_8)) ) - ActorAIChooseNewTargets(); - else - { - field_18 &= ~TE_FLAG_8; - turn_stage = TE_WAIT; - ai_turn_timer = 64; - } - } -} - - -//----- (00406051) -------------------------------------------------------- -void stru262_TurnBased::StartTurn() -{ - int player_num, actor_num, i, j; - - pending_actions = 0; - //add player to queue if he can act - for ( player_num = 0; player_num < 4; ++player_num) - { - for ( j = 0; j < uActorQueueSize; ++j ) - { - if (PID_TYPE(pQueue[j].uPackedID) == OBJECT_Player) - { - if (pPlayers[PID_ID(pQueue[j].uPackedID) + 1]->CanAct() && (player_num != PID_ID(pQueue[j].uPackedID)) ) - break; - } - } - if ( j == uActorQueueSize ) - { - pQueue[uActorQueueSize].uPackedID = PID(OBJECT_Player,player_num); - pQueue[uActorQueueSize].actor_initiative = 100; - pQueue[uActorQueueSize].uActionLength = 0; - pQueue[uActorQueueSize].AI_action_type = TE_AI_STAND; - ++uActorQueueSize; - } - } - //add new arrived actors - for ( actor_num = 0; actor_num < ai_arrays_size; ++actor_num ) - { - for ( j = 0; j < uActorQueueSize; ++j ) - { - if ((PID_TYPE(pQueue[j].uPackedID)== OBJECT_Actor)&& - ai_near_actors_ids[actor_num] == PID_ID(pQueue[j].uPackedID)) - break; - } - if ( j == uActorQueueSize ) - { - pQueue[uActorQueueSize].uPackedID = PID(OBJECT_Actor,ai_near_actors_ids[actor_num]); - pQueue[uActorQueueSize].actor_initiative = 1; - pQueue[uActorQueueSize].uActionLength = 0; - pQueue[uActorQueueSize].AI_action_type = TE_AI_STAND; - ++uActorQueueSize; - } - } - ++turns_count; - turn_initiative = 100; - for ( i = 0; i < uActorQueueSize; ++i ) - { - if (pQueue[i].actor_initiative == 0 ) - pQueue[i].actor_initiative = 100; - } - StepTurnQueue(); - for ( i = 0; i < uActorQueueSize; ++i ) - { - if ((PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) || (pQueue[i].actor_initiative > 0)) - break; - AI_Action_(i); - } -} -// 4F75D8: using guessed type int ai_arrays_size; - - //----- (004061CA) -------------------------------------------------------- - void stru262_TurnBased::NextTurn() -{ - int v13; // [sp+10h] [bp-4h]@7 - int monster_id; // eax@5 - - SortTurnQueue(); - if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) - uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1; - else - uActiveCharacter = 0; - viewparams->bRedrawGameUI = true; - - if ( pending_actions ) - { - pTurnEngine->field_18 |= TE_HAVE_PENDING_ACTIONS; - return; - } - pTurnEngine->field_18 &= ~TE_HAVE_PENDING_ACTIONS; - if ( pQueue[0].actor_initiative <= 0 ) - return; - - v13 = 0; - if (uActorQueueSize > 0 ) - { - for ( int i = 0; i < uActorQueueSize; ++i ) - { - if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) - { - monster_id = PID_ID(pQueue[i].uPackedID); - if ( (pActors[monster_id].uAIState == Dying) || (pActors[monster_id].uAIState == Stunned) - || (pActors[monster_id].uAIState == AttackingMelee) || (pActors[monster_id].uAIState == AttackingRanged1) - || (pActors[monster_id].uAIState == AttackingRanged2) || (pActors[monster_id].uAIState == AttackingRanged3) - || (pActors[monster_id].uAIState == AttackingRanged4) || (pActors[monster_id].uAIState == Summoned)) - { - pActors[monster_id].uCurrentActionTime += pEventTimer->uTimeElapsed; - if ( pActors[monster_id].uCurrentActionTime < pActors[monster_id].uCurrentActionLength ) - v13 = 1; - else if ( pActors[monster_id].uAIState == Dying )// Dying - { - pActors[monster_id].uAIState = Dead; - pActors[monster_id].uCurrentActionTime = 0; - pActors[monster_id].uCurrentActionLength = 0; - pActors[monster_id].UpdateAnimation(); - } - else - { - if ( pActors[monster_id].uAIState == Stunned ) //Stunned - Actor::AI_StandOrBored(monster_id, ai_near_actors_targets_pid[monster_id], 32, 0); - } - } - } - } - if ( v13 != 0 ) - { - field_18 |= TE_FLAG_1; - return; - } - } - - field_18 &= ~TE_FLAG_1; - //set all actors to stay - for ( int i = 0; i < uActorQueueSize; ++i ) - { - if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) - { - monster_id = PID_ID(pQueue[i].uPackedID); - if ((pActors[monster_id].uAIState != Dead) && (pActors[monster_id].uAIState != Dying) && - (pActors[monster_id].uAIState != Removed) && (pActors[monster_id].uAIState != Summoned) && - (pActors[monster_id].uAIState != Disabled)) - { - pQueue[i].uActionLength = 0; - Actor::AI_StandOrBored(monster_id, ai_near_actors_targets_pid[monster_id], 32, nullptr); - } - } - } - // turn tick - turn_stage = TE_MOVEMENT; - pParty->uTimePlayed += 213i64; - _494035_timed_effects__water_walking_damage__etc(); - uActionPointsLeft = 130; -} - -//----- (004063A1) -------------------------------------------------------- -bool stru262_TurnBased::StepTurnQueue() -{ - int v9; // dx@12 - int j; - - SortTurnQueue(); - viewparams->bRedrawGameUI = 1; - if ( pQueue[0].actor_initiative != 0 ) - { - if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) - { - do - { - for (j = 0; j < uActorQueueSize; ++j ) - --pQueue[j].actor_initiative; - --turn_initiative; - if (turn_initiative == 0) - return true; - } - while (pQueue[0].actor_initiative != 0); - } - else - { - if ( pQueue[0].actor_initiative > 0 ) - { - v9 = pActors[PID_ID(pQueue[0].uPackedID)].uAIState; - if (!(v9 == Dying || v9 == Dead || - v9 == Disabled || v9 == Removed)) - { - do - { - for ( j = 0; j < uActorQueueSize; ++j ) - { - --pQueue[j].actor_initiative; - if (pQueue[j].actor_initiative == 0) - pQueue[j].uActionLength = 0; - } - --turn_initiative; - if (turn_initiative == 0) - return true; - } - while (pQueue[0].actor_initiative > 0); - } - } - } - } - return false; -} - -//----- (00406457) -------------------------------------------------------- -void stru262_TurnBased::_406457( int a2 ) -{ - signed int v4; // ecx@2 - signed int v6; // eax@2 - int i; - v6 = 0; - if ( PID_TYPE(pQueue[a2].uPackedID) == OBJECT_Player) - { - v4 = PID_ID(pQueue[a2].uPackedID); - if ( pParty->pTurnBasedPlayerRecoveryTimes[v4] ) - pParty->pTurnBasedPlayerRecoveryTimes[v4] = 0; - else - v6 = pPlayers[v4 + 1]->GetAttackRecoveryTime(0); - if ( v6 < 30 ) - v6 = 30; - } - else - v6 = pMonsterStats->pInfos[pActors[PID_ID(pQueue[a2].uPackedID)].pMonsterInfo.uID].uRecoveryTime; - - pQueue[a2].actor_initiative = v6; - SortTurnQueue(); - if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) - uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1; - else - uActiveCharacter = 0; - viewparams->bRedrawGameUI = 1; - while ( (pQueue[0].actor_initiative > 0) && (turn_initiative > 0) ) - { - for ( i = 0; i < uActorQueueSize; ++i) - { - --pQueue[i].actor_initiative; - if (pQueue[i].actor_initiative == 0) - pQueue[i].uActionLength=0; - } - --turn_initiative; - } -} - -//----- (0040652A) -------------------------------------------------------- -void stru262_TurnBased::SetAIRecoveryTimes() -{ - int i; - int monster_ai_state; - Actor *monster; // eax@5 - - for ( i = 0; i < uActorQueueSize; ++i ) - { - if (pQueue[i].actor_initiative == 0) - { - if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) - break; - monster=&pActors[PID_ID(pQueue[i].uPackedID)]; - monster_ai_state=monster->uAIState; - if (monster_ai_state == Standing || - monster_ai_state == Fleeing || - monster_ai_state == Fidgeting) - { - pQueue[i].actor_initiative = pMonsterStats->pInfos[monster->pMonsterInfo.uID].uRecoveryTime; - if (monster->pActorBuffs[ACTOR_BUFF_SLOWED].uExpireTime > 0) - pQueue[i].actor_initiative*=2; - } - } - } -} - -//----- (004065B0) -------------------------------------------------------- -void stru262_TurnBased::_4065B0() -{ - int i; - - SortTurnQueue(); - if (pQueue[0].actor_initiative <= 0) - { - for ( i = 0; i < uActorQueueSize; ++i ) - { - if ((PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player)|| (pQueue[i].actor_initiative > 0) ) - break; - if ((pQueue[i].uActionLength <= 0) && (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor)) - AI_Action_(i); - } - } - else - { - StepTurnQueue(); - if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) - uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1; - else - uActiveCharacter = 0; - viewparams->bRedrawGameUI = 1; - } - for ( i = 0; i < uActorQueueSize; ++i ) - AIAttacks(i); -} - -//----- (00406648) -------------------------------------------------------- -void stru262_TurnBased::AIAttacks( unsigned int queue_index ) -{ - //TurnBased_QueueElem *v1; // ecx@1 - //int v3; // eax@1 - unsigned int actor_id; // ebx@2 - //Actor *v5; // esi@2 - char v19; // al@24 - AIDirection a3; // [sp+Ch] [bp-3Ch]@2 - AIDirection a4; // [sp+28h] [bp-20h]@2 - //TurnBased_QueueElem *v28; // [sp+44h] [bp-4h]@1 - //unsigned int a2a; // [sp+50h] [bp+8h]@2 - - //v1 = &pQueue[queue_index]; - //v28 = v1; - //v3 = pQueue[queue_index].uPackedID; - if (PID_TYPE(pQueue[queue_index].uPackedID) == OBJECT_Actor) - { - actor_id = PID_ID(pQueue[queue_index].uPackedID); - //a2a = ai_near_actors_targets_pid[v4]; - Actor::GetDirectionInfo(pQueue[queue_index].uPackedID, ai_near_actors_targets_pid[actor_id], &a3, 0); - memcpy(&a4, &a3, sizeof(a4)); - //v5 = &pActors[v4]; - //LOWORD(v3) = v5->uAIState; - if (( pActors[actor_id].uAIState != Dead ) && ( pActors[actor_id].uAIState != Disabled ) - &&( pActors[actor_id].uAIState != Removed )) - { - pActors[actor_id].uCurrentActionTime += pEventTimer->uTimeElapsed; - if ( (signed int)pActors[actor_id].uCurrentActionTime >= pActors[actor_id].uCurrentActionLength ) - { - switch (pActors[actor_id].uAIState) - { - case AttackingMelee: - v19 = pActors[actor_id].special_ability_use_check(actor_id); - AttackerInfo.Add( pQueue[queue_index].uPackedID, 5120, pActors[actor_id].vPosition.x, pActors[actor_id].vPosition.y, - pActors[actor_id].vPosition.z + ((signed int)pActors[actor_id].uActorHeight >> 1), v19, 1); - Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0, &a4); - break; - case AttackingRanged1: - Actor::AI_RangedAttack(actor_id, &a4, pActors[actor_id].pMonsterInfo.uMissleAttack1Type, 0); - Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0,&a4); - break; - case Dying: - pActors[actor_id].uCurrentActionTime = 0; - pActors[actor_id].uCurrentActionLength = 0; - pActors[actor_id].uAIState = Dead; - pActors[actor_id].UpdateAnimation(); - break; - case Stunned: - Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0,&a4); - break; - case AttackingRanged2: - Actor::AI_RangedAttack(actor_id, &a4, pActors[actor_id].pMonsterInfo.uMissleAttack2Type, 1); - Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0,&a4); - break; - case AttackingRanged3: - Actor::AI_SpellAttack(actor_id, &a4, pActors[actor_id].pMonsterInfo.uSpell1ID, 2, pActors[actor_id].pMonsterInfo.uSpellSkillAndMastery1); - Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0, &a4); - break; - case AttackingRanged4: - Actor::AI_SpellAttack(actor_id, &a4, pActors[actor_id].pMonsterInfo.uSpell2ID, 3, pActors[actor_id].pMonsterInfo.uSpellSkillAndMastery2); - Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 0, &a4); - break; - default: - if ( !(rand() % 2) ) - Actor::AI_Bored(actor_id, ai_near_actors_targets_pid[actor_id], &a4); - else - Actor::AI_Stand(actor_id, ai_near_actors_targets_pid[actor_id], 64,&a4); - } - } - } - } -} -// 50FE08: using guessed type stru298 AttackerInfo; - -//----- (0040680F) -------------------------------------------------------- -void stru262_TurnBased::AI_Action_( int queue_index ) -{ - unsigned int actor_id; // edi@2 - AIDirection v7; // esi@10 - int v9; // ecx@10 - signed int v10; // eax@13 - int v14; // eax@29 - AIDirection a3; // [sp+Ch] [bp-44h]@10 - AIDirection v18; // [sp+28h] [bp-28h]@10 - signed int v22; // [sp+58h] [bp+8h]@10 - - pQueue[queue_index].uActionLength = 0; - if (PID_TYPE(pQueue[queue_index].uPackedID) == OBJECT_Actor) - { - actor_id = PID_ID(pQueue[queue_index].uPackedID); - if (!(pActors[actor_id].uAIState == Dying || pActors[actor_id].uAIState == Dead || pActors[actor_id].uAIState == Summoned || - pActors[actor_id].uAIState == Disabled || pActors[actor_id].uAIState == Removed)) - { - Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); - v22 = ai_near_actors_targets_pid[actor_id]; - if ( pActors[actor_id].pMonsterInfo.uHostilityType && !v22) - pActors[actor_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), v22, &v7, 0); - memcpy(&a3, &v7, sizeof(AIDirection)); - memcpy(&v18, &a3, sizeof(AIDirection)); - v9 = a3.uDistance - pActors[actor_id].uActorRadius; - if ( v9 < 0 ) - v9 = 0; - if (PID_TYPE(v22) == OBJECT_Actor) - //v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3); - v10 = pFactionTable->relations[(pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID) / 3 + 1][(pActors[actor_id].pMonsterInfo.uID - 1) / 3 + 1]; - else - v10 = 4; - switch (v10) - { - case 1: - if ( (double)(signed int)v9 < 307.2 ) - pActors[actor_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - break; - case 2: - if ( v9 < 1024 ) - pActors[actor_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - break; - case 3: - if ( v9 < 2560 ) - pActors[actor_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - break; - case 4: - if ( v9 < 5120 ) - pActors[actor_id].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - break; - } - if ( pActors[actor_id].pMonsterInfo.uHostilityType == 4 && v22 && (signed int)v9 < 5120 ) - { - v14 = pActors[actor_id].special_ability_use_check(actor_id); - pQueue[queue_index].AI_action_type = TE_AI_STAND; - switch (v14) - { - case 1: - if ( pActors[actor_id].pMonsterInfo.uMissleAttack2Type ) - { - Actor::AI_MissileAttack2(actor_id, v22, &v18); - pQueue[queue_index].AI_action_type = TE_AI_RANGED_ATTACK; - } - break; - case 2: - if ( pActors[actor_id].pMonsterInfo.uSpell1ID ) - { - Actor::AI_SpellAttack1(actor_id, v22, &v18); - pQueue[queue_index].AI_action_type = TE_AI_RANGED_ATTACK; - } - break; - case 3: - if (pActors[actor_id].pMonsterInfo.uSpell2ID) - { - Actor::AI_SpellAttack2(actor_id, v22, &v18); - pQueue[queue_index].AI_action_type = TE_AI_RANGED_ATTACK; - } - break; - default: - if ( pActors[actor_id].pMonsterInfo.uMissleAttack1Type ) - { - Actor::AI_MissileAttack1(actor_id, v22, &v18); - pQueue[queue_index].AI_action_type = TE_AI_RANGED_ATTACK; - } - } - //if (!pQueue[queue_index].AI_action_type) - if ( (double)v9 < 307.2) - { - Actor::AI_MeleeAttack(actor_id, v22, &v18); - pQueue[queue_index].AI_action_type = TE_AI_MELEE_ATTACK; - pQueue[queue_index].uActionLength = pActors[actor_id].uCurrentActionLength; - return; - } - else - { - Actor::AI_Stand(actor_id, v22, 64, &v18); - pQueue[queue_index].AI_action_type = TE_AI_STAND; - pQueue[queue_index].uActionLength = pActors[actor_id].uCurrentActionLength; - return; - } - } - else - { - Actor::AI_Stand(actor_id, v22, 64, &v18); - pQueue[queue_index].AI_action_type = TE_AI_STAND; - } - pQueue[queue_index].uActionLength = pActors[actor_id].uCurrentActionLength; - } - } -} - -//----- (00406A63) -------------------------------------------------------- -void stru262_TurnBased::ActorAISetMovementDecision() -{ - AIDirection a3; // [sp+8h] [bp-44h]@5 - AIDirection v7; // [sp+24h] [bp-28h]@5 - unsigned int target_pid; // [sp+40h] [bp-Ch]@5 - int i; - - this->ai_turn_timer = 64; - dword_50C994 = 0; - uActiveCharacter = 0; - for ( i = 0; i < uActorQueueSize; ++i ) - { - if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) - { - target_pid = ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)]; - Actor::GetDirectionInfo(pQueue[i].uPackedID, target_pid, &v7, 0); - if ( !ActorMove(i) ) - Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), target_pid, 32, &v7); - } - } -} -// 50C994: using guessed type int dword_50C994; - -//----- (00406AFE) -------------------------------------------------------- -void stru262_TurnBased::ActorAIStopMovement() -{ - AIDirection a3; // [sp+4h] [bp-48h]@5 - AIDirection v7; // [sp+20h] [bp-2Ch]@5 - unsigned int target_pid; - int i; - - for ( i = 0; i < uActorQueueSize; ++i ) - { - if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) - { - target_pid = ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)]; - Actor::GetDirectionInfo(pQueue[i].uPackedID, target_pid, &v7, 0); - Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), target_pid, 32, &v7); - pQueue[i].AI_action_type = TE_AI_STAND; - pQueue[i].uActionLength = 0; - } - } - turn_stage = TE_ATTACK; - ai_turn_timer = 100; -} - -//----- (00406B9F) -------------------------------------------------------- -void stru262_TurnBased::ActorAIDoAdditionalMove() -{ - AIDirection a3; // [sp+0h] [bp-50h]@15 - AIDirection v9; // [sp+1Ch] [bp-34h]@15 - unsigned int v13; // [sp+44h] [bp-Ch]@8 - unsigned int monster_id; - - for ( int i = 0; i < uActorQueueSize; ++i ) - { - if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) - { - monster_id = PID_ID(pQueue[i].uPackedID); - if ( !(pActors[monster_id].pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0|| (pActors[monster_id].pActorBuffs[ACTOR_BUFF_PARALYZED].uExpireTime > 0) || - pActors[monster_id].uAIState == Dead || pActors[monster_id].uAIState == Removed || pActors[monster_id].uAIState == Disabled) ) - { - v13 = ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)]; - Actor::GetDirectionInfo(pQueue[i].uPackedID, v13, &v9, 0); - if ( pActors[monster_id].uAIState == Pursuing || pActors[monster_id].uAIState == Tethered ) - { - if ( (double)(signed int)v9.uDistance < 307.2 ) - Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), v13, 32, &v9); - } - else - { - pActors[monster_id].uCurrentActionTime += pEventTimer->uTimeElapsed; - if ( pActors[monster_id].uCurrentActionTime > pActors[monster_id].uCurrentActionLength ) - { - if ( pActors[monster_id].uAIState == Dying ) - { - pActors[monster_id].uCurrentActionTime = 0; - pActors[monster_id].uCurrentActionLength = 0; - pActors[monster_id].uAIState = Dead; - pActors[monster_id].UpdateAnimation(); - } - if ( !ActorMove(i) ) - Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), v13, 32, &v9); - } - } - } - } - } -} - -//----- (00406D10) -------------------------------------------------------- -bool stru262_TurnBased::ActorMove(signed int queue_position) -{ - AIDirection v9; // esi@10 - int v11; // ecx@10 - unsigned __int8 pHostileType; // al@12 - AIDirection a3; // [sp+Ch] [bp-48h]@10 - AIDirection pDir; // [sp+28h] [bp-2Ch]@10 - unsigned int uActorID; // [sp+50h] [bp-4h]@2 - - if (PID_TYPE(pQueue[queue_position].uPackedID) == OBJECT_Player) - return 0; - uActorID = PID_ID(pQueue[queue_position].uPackedID); - if ( pActors[uActorID].uAIState == Dead || pActors[uActorID].uAIState == Dying || - pActors[uActorID].uAIState == Removed|| pActors[uActorID].uAIState == Disabled || - pActors[uActorID].uAIState == Summoned ) - return 1; - Actor::_SelectTarget(uActorID, &ai_near_actors_targets_pid[uActorID], true); - if ( pActors[uActorID].pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[uActorID] ) - pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - Actor::GetDirectionInfo(pQueue[queue_position].uPackedID, ai_near_actors_targets_pid[uActorID], &v9, 0); - memcpy(&a3, &v9, sizeof(AIDirection)); - memcpy(&pDir, &a3, sizeof(AIDirection)); - v11 = a3.uDistance - pActors[uActorID].uActorRadius; - if ( v11 < 0 ) - v11 = 0; - pHostileType = pActors[uActorID].pMonsterInfo.uHostilityType; - switch (pHostileType) - { - case 1: - if ( (double)v11 < 307.2 ) - pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - break; - case 2: - if ( v11 < 1024 ) - pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - break; - case 3: - if ( v11 < 2560 ) - pActors[uActorID].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - break; - } - if ( pActors[uActorID].pActorBuffs[ACTOR_BUFF_AFRAID].uExpireTime > 0 ) - { - if (v11 < 10240 ) - { - Actor::AI_Flee(uActorID, ai_near_actors_targets_pid[uActorID], 0, &pDir); - pTurnEngine->pQueue[queue_position].AI_action_type = 4; - } - else - { - Actor::AI_RandomMove(uActorID, ai_near_actors_targets_pid[uActorID], 1024, 0); - pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_PURSUE; - } - pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength; - return true; - } - if ( pActors[uActorID].pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long ) - { - if ( !(pActors[uActorID].uAttributes & ACTOR_FLEEING) || pActors[uActorID].pMonsterInfo.uAIType == 1 ) - { - if ( pActors[uActorID].pMonsterInfo.uAIType == 1 ) - { - if ( pActors[uActorID].pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) - Actor::AI_Stand(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0); - else - Actor::AI_Flee(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0); - pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_FLEE; - pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength; - return true; - } - if ( pActors[uActorID].pMonsterInfo.uAIType == 2 ) - { - if (((double)pActors[uActorID].pMonsterInfo.uHP * 0.2) > (double)pActors[uActorID].sCurrentHP && (v11 < 10240 ) ) - { - if ( pActors[uActorID].pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) - Actor::AI_Stand(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0); - else - Actor::AI_Flee(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0); - pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_FLEE; - pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength; - return true; - } - } - if ( pActors[uActorID].pMonsterInfo.uAIType == 3 ) - { - if ( ((double)pActors[uActorID].pMonsterInfo.uHP * 0.1) > (double)pActors[uActorID].sCurrentHP && (v11 < 10240 )) - { - if ( pActors[uActorID].pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) - Actor::AI_Stand(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0); - else - Actor::AI_Flee(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0); - pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_FLEE; - pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength; - return true; - } - } - } - if ( (double)(signed int)v11 < 307.2 ) - return 0; - if ( (signed int)v11 < 5120 ) - { - if ( pActors[uActorID].pMonsterInfo.uMissleAttack1Type && (signed int)v11 < 1024 ) - Actor::AI_Pursue1(uActorID, ai_near_actors_targets_pid[uActorID], uActorID, 32, &pDir); - else - Actor::AI_Pursue2(uActorID, ai_near_actors_targets_pid[uActorID], 32, &pDir, 307); - pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_PURSUE; - pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength; - return true; - } - } - switch(pActors[uActorID].pMonsterInfo.uMovementType) - { - case MONSTER_MOVEMENT_TYPE_SHORT: - Actor::AI_RandomMove(uActorID, ai_near_actors_targets_pid[uActorID], 1024, 32); - break; - case MONSTER_MOVEMENT_TYPE_MEDIUM: - Actor::AI_RandomMove(uActorID, ai_near_actors_targets_pid[uActorID], 2560, 32); - break; - case MONSTER_MOVEMENT_TYPE_LONG: - Actor::AI_RandomMove(uActorID, ai_near_actors_targets_pid[uActorID], 5120, 32); - break; - case MONSTER_MOVEMENT_TYPE_FREE: - Actor::AI_RandomMove(uActorID, ai_near_actors_targets_pid[uActorID], 10240, 32); - break; - case MONSTER_MOVEMENT_TYPE_STAIONARY: - Actor::AI_Stand(uActorID, ai_near_actors_targets_pid[uActorID], 32, 0); - break; - default: - return true; - } - pTurnEngine->pQueue[queue_position].AI_action_type = TE_AI_PURSUE; - pTurnEngine->pQueue[queue_position].uActionLength = pActors[uActorID].uCurrentActionLength; - return true; -} - - //----- (00406FA8) -------------------------------------------------------- -void stru262_TurnBased::ActorAIChooseNewTargets() -{ - Actor *curr_acror; // ebx@4 - AIDirection a3; // [sp+Ch] [bp-6Ch]@8 - AIDirection v9; // [sp+28h] [bp-50h]@8 - AIDirection a4; // [sp+44h] [bp-34h]@8 - unsigned int target_pid; // [sp+60h] [bp-18h]@1 - int uActorID; // [sp+68h] [bp-10h]@4 - int i; - - for ( i = 0; i < uActorQueueSize; ++i ) - { - if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) - { - uActorID=PID_ID(pQueue[i].uPackedID); - curr_acror = &pActors[uActorID]; - if ( !( curr_acror->uAIState == Summoned|| curr_acror->uAIState == Dead || - curr_acror->uAIState == Removed || curr_acror->uAIState == Disabled) ) - { - target_pid = ai_near_actors_targets_pid[uActorID]; - Actor::_SelectTarget(uActorID, &ai_near_actors_targets_pid[uActorID], true); - Actor::GetDirectionInfo(pQueue[i].uPackedID, target_pid, &v9, 0); - memcpy(&a4, &v9, sizeof(AIDirection)); - curr_acror->uCurrentActionTime += pEventTimer->uTimeElapsed; - if ( curr_acror->uCurrentActionTime > curr_acror->uCurrentActionLength ) - { - if ( curr_acror->uAIState == Dying ) - { - curr_acror->uCurrentActionTime = 0; - curr_acror->uCurrentActionLength = 0; - curr_acror->uAIState = Dead; - curr_acror->UpdateAnimation(); - break; - } - if ( rand() % 2 ) - Actor::AI_Stand(uActorID, target_pid, 64, &a4); - else - Actor::AI_Bored(uActorID, target_pid, &a4); - } - } - } - } -} - diff -r 92eeeb5200f2 -r 68cdef6879a0 TurnEngine.h --- a/TurnEngine.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -#pragma once - - -enum TURN_ENGINE_FLAGS -{ - TE_FLAG_1 = 1, - TE_HAVE_PENDING_ACTIONS = 2, - TE_PLAYER_TURN = 4, - TE_FLAG_8 = 8 -}; - -enum TURN_ENGINE_AI_ACTION -{ - TE_AI_STAND = 0, - TE_AI_RANGED_ATTACK = 1, - TE_AI_PURSUE = 2, - TE_AI_MELEE_ATTACK = 3, - TE_AI_FLEE = 4 -}; - -enum TURN_ENGINE_TURN_STAGE -{ - TE_NONE = 0, - TE_WAIT = 1, - TE_ATTACK = 2, - TE_MOVEMENT = 3, -}; - -/* 299 */ -#pragma pack(push, 1) -struct TurnBased_QueueElem -{ - inline TurnBased_QueueElem() - { - uPackedID = 0; - actor_initiative = 0; - uActionLength = 0; - AI_action_type = 0; - } - int uPackedID; - int actor_initiative; //act first who have less - int uActionLength; - int AI_action_type; -}; -#pragma pack(pop) - -/* 254 */ -#pragma pack(push, 1) -struct stru262_TurnBased -{ - inline stru262_TurnBased() - { - turns_count = 0; - turn_stage = 0; - ai_turn_timer = 0; - uActorQueueSize = 0; - turn_initiative = 0; - uActionPointsLeft = 0; - field_18 = 0; - pending_actions = 0; - } - - void SortTurnQueue(); - void ApplyPlayerAction(); - void Start(); - void End(bool bPlaySound); - void AITurnBasedAction(); - void StartTurn(); - void NextTurn(); - bool StepTurnQueue(); - void _406457(int a2); - void SetAIRecoveryTimes(); - void _4065B0(); - void AIAttacks(unsigned int queue_index); - void AI_Action_(int queue_index); - void ActorAISetMovementDecision(); - void ActorAIStopMovement(); - void ActorAIDoAdditionalMove(); - bool ActorMove(signed int a2); - void ActorAIChooseNewTargets(); - - - int turns_count; - int turn_stage; //if = 2 - action - int ai_turn_timer; - int uActorQueueSize; //c - int turn_initiative; - int uActionPointsLeft; //14 - int field_18; - int pending_actions; - TurnBased_QueueElem pQueue[530]; //20 -}; -#pragma pack(pop) - - - -extern struct stru262_TurnBased *pTurnEngine; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/Books/UIMapBook.cpp --- a/UI/Books/UIMapBook.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/Books/UIMapBook.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -1,23 +1,23 @@ #define _CRT_SECURE_NO_WARNINGS #include "UIMapBook.h" -#include "..\..\Events.h" -#include "..\..\MM7.h" +#include "..\..\Engine/Events.h" +#include "..\..\Engine/MM7.h" #include "..\..\Engine/Graphics/Render.h" #include "..\..\Mouse.h" #include "..\UIBooks.h" -#include "..\..\MapInfo.h" +#include "..\..\Engine/MapInfo.h" #include "..\..\GUIWindow.h" #include "..\..\GUIFont.h" -#include "..\..\Party.h" +#include "..\..\Engine/Party.h" #include "..\..\AudioPlayer.h" #include "..\..\Engine/Graphics/Outdoor.h" -#include "..\..\LOD.h" +#include "..\..\Engine/LOD.h" #include "..\..\Engine/Graphics/Viewport.h" -#include "..\..\OurMath.h" -#include "..\..\texts.h" +#include "..\..\Engine/OurMath.h" +#include "..\..\Engine/texts.h" #include "..\..\Engine/Graphics/Level/Decoration.h" // -#include "..\..\mm7_data.h" +#include "..\..\Engine/mm7_data.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/Books/UINotesBooks.cpp --- a/UI/Books/UINotesBooks.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/Books/UINotesBooks.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -1,20 +1,20 @@ #define _CRT_SECURE_NO_WARNINGS -#include "..\..\MM7.h" +#include "..\..\Engine/MM7.h" #include "..\..\Engine/Graphics/Render.h" #include "..\..\Mouse.h" #include "..\UIBooks.h" -#include "..\..\MapInfo.h" +#include "..\..\Engine/MapInfo.h" #include "..\..\GUIWindow.h" #include "..\..\GUIFont.h" -#include "..\..\Party.h" +#include "..\..\Engine/Party.h" #include "..\..\AudioPlayer.h" -#include "..\..\LOD.h" +#include "..\..\Engine/LOD.h" #include "..\..\Engine/Graphics/Viewport.h" -#include "..\..\Awards.h" -#include "..\..\Autonotes.h" -#include "..\..\StorylineTextTable.h" -#include "..\..\texts.h" -#include "..\..\mm7_data.h" +#include "..\..\Engine/Awards.h" +#include "..\..\Engine/Autonotes.h" +#include "..\..\Engine/Tables/StorylineTextTable.h" +#include "..\..\Engine/texts.h" +#include "..\..\Engine/mm7_data.h" //----- (00413D3C) -------------------------------------------------------- static const char *GetDayPart() diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/Books/UISpellBook.cpp --- a/UI/Books/UISpellBook.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/Books/UISpellBook.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -1,16 +1,16 @@ #define _CRT_SECURE_NO_WARNINGS -#include "..\..\MM7.h" +#include "..\..\Engine/MM7.h" #include "..\..\Engine/Graphics/Render.h" #include "..\..\Mouse.h" #include "..\UIBooks.h" #include "..\..\GUIWindow.h" #include "..\..\GUIFont.h" -#include "..\..\Party.h" +#include "..\..\Engine/Party.h" #include "..\..\AudioPlayer.h" -#include "..\..\LOD.h" +#include "..\..\Engine/LOD.h" #include "..\..\Engine/Graphics/Viewport.h" -#include "..\..\texts.h" -#include "..\..\mm7_data.h" +#include "..\..\Engine/texts.h" +#include "..\..\Engine/mm7_data.h" std::array spellbook_texture_filename_suffices = {{"f", "a", "w", "e", "s", "m", "b", "l", "d"}}; // weak diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UIArena.cpp --- a/UI/UIArena.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UIArena.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -4,20 +4,20 @@ #define _CRT_SECURE_NO_WARNINGS -#include "../mm7_data.h" +#include "../Engine/mm7_data.h" #include "../Engine/Graphics/Sprites.h" #include "../GUIWindow.h" #include "../GUIFont.h" -#include "../Party.h" +#include "../Engine/Party.h" #include "../AudioPlayer.h" #include "../Engine/Graphics/Outdoor.h" -#include "../LOD.h" -#include "../Actor.h" -#include "../Events.h" +#include "../Engine/LOD.h" +#include "../Engine/Objects/Actor.h" +#include "../Engine/Events.h" #include "../Engine/Graphics/Viewport.h" -#include "../texts.h" -#include "../MM7.h" +#include "../Engine/texts.h" +#include "../Engine/MM7.h" std::array pMonsterArenaPlacements = {{ diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UIArena.h --- a/UI/UIArena.h Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UIArena.h Fri Sep 19 02:57:42 2014 +0600 @@ -1,5 +1,5 @@ #pragma once -#include "VectorTypes.h" +#include "../Engine/VectorTypes.h" #include diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UIBooks.cpp --- a/UI/UIBooks.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UIBooks.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -3,15 +3,15 @@ #include #define _CRT_SECURE_NO_WARNINGS -#include "..\MM7.h" +#include "..\Engine/MM7.h" #include "UIBooks.h" #include "..\Engine/Graphics/Render.h" #include "..\GUIWindow.h" #include "..\GUIFont.h" #include "..\AudioPlayer.h" -#include "..\LOD.h" +#include "..\Engine/LOD.h" -#include "..\mm7_data.h" +#include "..\Engine/mm7_data.h" //----- (00413CC6) -------------------------------------------------------- void BookUI_Draw(WindowType book) diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UICharacter.cpp --- a/UI/UICharacter.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UICharacter.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -5,24 +5,24 @@ #define _CRT_SECURE_NO_WARNINGS #include #include "UICharacter.h" -#include "..\MM7.h" -#include "..\MapInfo.h" -#include "..\Game.h" +#include "..\Engine/MM7.h" +#include "..\Engine/MapInfo.h" +#include "..\Engine/Game.h" #include "..\GUIWindow.h" #include "..\GUIFont.h" #include "..\GUIProgressBar.h" -#include "..\Party.h" +#include "..\Engine/Party.h" #include "..\AudioPlayer.h" #include "..\Engine/Graphics/Render.h" -#include "..\LOD.h" +#include "..\Engine/LOD.h" #include "..\Engine/Graphics/Viewport.h" -#include "..\Timer.h" -#include "..\Awards.h" -#include "..\CastSpellInfo.h" -#include "..\texts.h" +#include "..\Engine/Timer.h" +#include "..\Engine/Awards.h" +#include "..\Engine/Spells/CastSpellInfo.h" +#include "..\Engine/texts.h" #include "..\Mouse.h" -#include "..\mm7_data.h" +#include "..\Engine/mm7_data.h" int bRingsShownInCharScreen; // 5118E0 diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UIGuilds.cpp --- a/UI/UIGuilds.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UIGuilds.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -3,19 +3,19 @@ #include #define _CRT_SECURE_NO_WARNINGS -#include "..\Items.h" +#include "..\Engine/Objects/Items.h" #include "..\GUIWindow.h" -#include "..\mm7_data.h" -#include "..\texts.h" +#include "..\Engine/mm7_data.h" +#include "..\Engine/texts.h" #include "UIHouses.h" #include "..\GUIFont.h" #include "..\Engine/Graphics/Render.h" -#include "..\Party.h" +#include "..\Engine/Party.h" #include "..\Engine/Graphics/Texture.h" #include "..\Mouse.h" -#include "..\Events2D.h" +#include "..\Engine/Events2D.h" #include "..\AudioPlayer.h" -#include "..\LOD.h" +#include "..\Engine/LOD.h" //----- (004B5D7C) -------------------------------------------------------- void GuildDialog() diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UIHouses.cpp --- a/UI/UIHouses.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UIHouses.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -7,16 +7,16 @@ #include "UIPartyCreation.h" #include "UIShops.h" #include "..\GUIButton.h" -#include "..\SaveLoad.h" +#include "..\Engine/SaveLoad.h" #include "..\Engine/Graphics/Texture.h" -#include "..\mm7_data.h" -#include "..\ErrorHandling.h" +#include "..\Engine/mm7_data.h" +#include "..\Engine/ErrorHandling.h" #include "UIHouses.h" -#include "..\Party.h" -#include "..\texts.h" -#include "..\Events.h" +#include "..\Engine/Party.h" +#include "..\Engine/texts.h" +#include "..\Engine/Events.h" #include "..\Arcomage/Arcomage.h" -#include "..\LOD.h" +#include "..\Engine/LOD.h" #include "..\Mouse.h" #include "..\GUIWindow.h" #include "..\GUIFont.h" @@ -24,17 +24,17 @@ #include "..\Engine/Graphics/Outdoor.h" #include "..\AudioPlayer.h" #include "..\MediaPlayer.h" -#include "..\Monsters.h" +#include "..\Engine/Objects/Monsters.h" #include "..\Engine/Graphics/Viewport.h" #include "..\Keyboard.h" -#include "..\MapInfo.h" -#include "..\Log.h" -#include "..\Game.h" -#include "..\CastSpellInfo.h" +#include "..\Engine/MapInfo.h" +#include "..\Engine/Log.h" +#include "..\Engine/Game.h" +#include "..\Engine/Spells/CastSpellInfo.h" #include "../Engine/Graphics/Level/Decoration.h" -#include "..\stru159.h" +#include "..\Engine/stru159.h" int uHouse_ExitPic; // weak int dword_591080; // weak diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UIHouses.h --- a/UI/UIHouses.h Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UIHouses.h Fri Sep 19 02:57:42 2014 +0600 @@ -1,5 +1,5 @@ #pragma once -#include "..\Events2D.h" +#include "..\Engine/Events2D.h" enum HOUSE_DIALOGUE_MENU: __int32 { diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UIMainMenu.cpp --- a/UI/UIMainMenu.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UIMainMenu.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -5,20 +5,20 @@ #define _CRT_SECURE_NO_WARNINGS #include "..\Mouse.h" #include "..\Keyboard.h" -#include "..\ErrorHandling.h" +#include "..\Engine/ErrorHandling.h" #include "..\GUIWindow.h" #include "..\GUIFont.h" #include "..\AudioPlayer.h" #include "..\Engine/Graphics/Render.h" -#include "..\LOD.h" +#include "..\Engine/LOD.h" #include "..\Engine/Graphics/PaletteManager.h" -#include "..\IconFrameTable.h" -#include "..\texts.h" -#include"MMT.h" +#include "..\Engine/Tables/IconFrameTable.h" +#include "..\Engine/texts.h" +#include "..\Engine/MMT.h" -#include "..\mm7_data.h" -#include "..\Game.h" +#include "..\Engine/mm7_data.h" +#include "..\Engine/Game.h" //----- (0041B578) -------------------------------------------------------- diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UIOptions.cpp --- a/UI/UIOptions.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UIOptions.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -3,21 +3,21 @@ #include #define _CRT_SECURE_NO_WARNINGS -#include "..\MM7.h" +#include "..\Engine/MM7.h" #include "..\Keyboard.h" #include "..\Engine/Graphics/IndoorCameraD3D.h" #include "..\Engine/Graphics/GammaControl.h" #include "..\Engine/Graphics/Render.h" -#include "..\Game.h" +#include "..\Engine/Game.h" #include "..\GUIWindow.h" #include "..\GUIFont.h" #include "..\AudioPlayer.h" -#include "..\LOD.h" -#include "..\texts.h" +#include "..\Engine/LOD.h" +#include "..\Engine/texts.h" -#include "..\mm7_data.h" +#include "..\Engine/mm7_data.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UIPartyCreation.cpp --- a/UI/UIPartyCreation.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UIPartyCreation.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -6,20 +6,20 @@ #include "UIPartyCreation.h" #include "..\Mouse.h" #include "..\Keyboard.h" -#include "..\ErrorHandling.h" +#include "..\Engine/ErrorHandling.h" -#include "..\Game.h" +#include "..\Engine/Game.h" #include "..\GUIWindow.h" #include "..\GUIFont.h" -#include "..\Party.h" +#include "..\Engine/Party.h" #include "..\AudioPlayer.h" #include "..\Engine/Graphics/Render.h" -#include "..\LOD.h" -#include "..\Timer.h" -#include "..\IconFrameTable.h" -#include "..\texts.h" +#include "..\Engine/LOD.h" +#include "..\Engine/Timer.h" +#include "..\Engine/Tables/IconFrameTable.h" +#include "..\Engine/texts.h" -#include "..\mm7_data.h" +#include "..\Engine/mm7_data.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UIPopup.cpp --- a/UI/UIPopup.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UIPopup.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -6,29 +6,29 @@ #include "UIPopup.h" #include "Books\UIMapBook.h" #include "UIShops.h" -#include "..\MM7.h" +#include "..\Engine/MM7.h" #include "..\Mouse.h" #include "..\Engine/Graphics/Sprites.h" #include "..\Engine/Graphics/Vis.h" -#include "..\Game.h" +#include "..\Engine/Game.h" #include "..\GUIWindow.h" #include "..\GUIFont.h" -#include "..\Party.h" +#include "..\Engine/Party.h" #include "..\AudioPlayer.h" -#include "..\LOD.h" -#include "..\Actor.h" +#include "..\Engine/LOD.h" +#include "..\Engine/Objects/Actor.h" #include "..\Engine/Graphics/Viewport.h" -#include "..\SpriteObject.h" -#include "..\ObjectList.h" -#include "..\Chest.h" +#include "..\Engine/Objects/SpriteObject.h" +#include "..\Engine/Objects/ObjectList.h" +#include "..\Engine/Objects/Chest.h" #include "..\Engine/Graphics/PaletteManager.h" -#include "..\Timer.h" -#include "..\texts.h" +#include "..\Engine/Timer.h" +#include "..\Engine/texts.h" -#include "..\mm7_data.h" -#include "..\Events.h" +#include "..\Engine/mm7_data.h" +#include "..\Engine/Events.h" static char static_sub_417BB5_out_string[1200]; // static to a file, not sub actually diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UIRest.cpp --- a/UI/UIRest.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UIRest.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -5,15 +5,15 @@ #define _CRT_SECURE_NO_WARNINGS #include "..\GUIWindow.h" #include "..\GUIFont.h" -#include "..\Party.h" +#include "..\Engine/Party.h" #include "..\AudioPlayer.h" #include "..\Engine/Graphics/Outdoor.h" -#include "..\LOD.h" +#include "..\Engine/LOD.h" #include "..\Engine/Graphics/Viewport.h" -#include "..\Timer.h" -#include "..\texts.h" +#include "..\Engine/Timer.h" +#include "..\Engine/texts.h" -#include "..\mm7_data.h" +#include "..\Engine/mm7_data.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UISaveLoad.cpp --- a/UI/UISaveLoad.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UISaveLoad.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -5,22 +5,22 @@ #define _CRT_SECURE_NO_WARNINGS #include -#include "..\MM7.h" -#include "..\ErrorHandling.h" +#include "..\Engine/MM7.h" +#include "..\Engine/ErrorHandling.h" #include "..\Keyboard.h" -#include "..\MapInfo.h" +#include "..\Engine/MapInfo.h" #include "..\GUIWindow.h" #include "..\GUIFont.h" #include "..\Engine/Graphics/Render.h" -#include "..\LOD.h" -#include "..\SaveLoad.h" -#include "..\texts.h" +#include "..\Engine/LOD.h" +#include "..\Engine/SaveLoad.h" +#include "..\Engine/texts.h" -#include "..\mm7_data.h" +#include "..\Engine/mm7_data.h" -#include "..\Game.h" +#include "..\Engine/Game.h" //----- (004601B7) -------------------------------------------------------- diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UIShops.cpp --- a/UI/UIShops.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UIShops.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -4,19 +4,19 @@ #define _CRT_SECURE_NO_WARNINGS #include "UIShops.h" -#include "..\Items.h" +#include "..\Engine/Objects/Items.h" #include "..\GUIWindow.h" -#include "..\mm7_data.h" -#include "..\texts.h" +#include "..\Engine/mm7_data.h" +#include "..\Engine/texts.h" #include "UIHouses.h" #include "..\GUIFont.h" #include "..\Engine/Graphics/Render.h" -#include "..\Party.h" +#include "..\Engine/Party.h" #include "..\Engine/Graphics/Texture.h" #include "..\Mouse.h" -#include "..\Events2D.h" +#include "..\Engine/Events2D.h" #include "..\AudioPlayer.h" -#include "..\MapInfo.h" +#include "..\Engine/MapInfo.h" #include "..\Engine/Graphics/Viewport.h" #include "..\Engine/Graphics/Outdoor.h" #include "..\Engine/Graphics/Indoor.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UITransition.cpp --- a/UI/UITransition.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UITransition.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -5,21 +5,21 @@ #define _CRT_SECURE_NO_WARNINGS #include -#include "..\ErrorHandling.h" -#include "..\mm7_data.h" +#include "..\Engine/ErrorHandling.h" +#include "..\Engine/mm7_data.h" #include "..\MediaPlayer.h" -#include "..\MapInfo.h" +#include "..\Engine/MapInfo.h" #include "..\GUIWindow.h" #include "..\GUIFont.h" #include "..\GUIProgressBar.h" -#include "..\Party.h" +#include "..\Engine/Party.h" #include "..\AudioPlayer.h" #include "..\Engine/Graphics/Outdoor.h" -#include "..\LOD.h" -#include "..\Timer.h" -#include "..\stru159.h" -#include "..\Events2D.h" -#include "..\texts.h" +#include "..\Engine/LOD.h" +#include "..\Engine/Timer.h" +#include "..\Engine/stru159.h" +#include "..\Engine/Events2D.h" +#include "..\Engine/texts.h" #include "UIHouses.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 UI/UiGame.cpp --- a/UI/UiGame.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/UI/UiGame.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -3,40 +3,40 @@ #include #define _CRT_SECURE_NO_WARNINGS -#include "..\Events.h" +#include "..\Engine/Events.h" #include "..\Engine/Graphics/Texture.h" -#include "..\MM7.h" -#include "..\ErrorHandling.h" +#include "..\Engine/MM7.h" +#include "..\Engine/ErrorHandling.h" #include "..\Mouse.h" #include "..\Keyboard.h" -#include "..\mm7_data.h" +#include "..\Engine/mm7_data.h" #include "..\Engine/Graphics/Vis.h" -#include "..\MapInfo.h" -#include "..\Game.h" +#include "..\Engine/MapInfo.h" +#include "..\Engine/Game.h" #include "..\GUIWindow.h" #include "..\GUIFont.h" -#include "..\Party.h" +#include "..\Engine/Party.h" #include "..\AudioPlayer.h" #include "..\Engine/Graphics/Outdoor.h" -#include "..\LOD.h" -#include "..\Actor.h" +#include "..\Engine/LOD.h" +#include "..\Engine/Objects/Actor.h" #include "..\Engine/Graphics/Viewport.h" -#include "..\SpriteObject.h" -#include "..\ObjectList.h" +#include "..\Engine/Objects/SpriteObject.h" +#include "..\Engine/Objects/ObjectList.h" #include "..\Engine/Graphics/DecorationList.h" -#include "..\PlayerFrameTable.h" -#include "..\stru123.h" -#include "..\Timer.h" -#include "..\IconFrameTable.h" -#include "..\TurnEngine.h" -#include "..\texts.h" +#include "..\Engine/Tables/PlayerFrameTable.h" +#include "..\Engine/stru123.h" +#include "..\Engine/Timer.h" +#include "..\Engine/Tables/IconFrameTable.h" +#include "..\Engine/TurnEngine/TurnEngine.h" +#include "..\Engine/texts.h" #include "UIHouses.h" #include "..\Engine/Graphics/BSPModel.h" -#include "..\OurMath.h" +#include "..\Engine/OurMath.h" #include "..\Engine/Graphics/Level/Decoration.h" -#include "..\Chest.h" +#include "..\Engine/Objects/Chest.h" #include "UIGame.h" #include "..\Engine/Graphics/Overlays.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 VectorTypes.cpp --- a/VectorTypes.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include - -#include "mm7_data.h" -#include "OurMath.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) -{ - extern int integer_sqrt(int val); - *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; - -//----- (004369DB) -------------------------------------------------------- -void Vec3_float_::Normalize() -{ - this->x = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->x; - this->y = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->y; - this->z = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->z; -} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 VectorTypes.h --- a/VectorTypes.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,144 +0,0 @@ -#pragma once - -#include - -uint32_t int_get_vector_length(int32_t x, int32_t y, int32_t z); - -#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) -template -struct Vec3: public Vec2 -{ - 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; - } - - //----- (0049B02E) -------------------------------------------------------- - inline static float NegDot(Vec3_float_ *a1, Vec3_float_ *a2, float *a3) - { - return *a3 = -(a1->z * a2->z + a1->y * a2->y + a1->x * a2->x); - } - - float x; - float y; - float z; -}; -#pragma pack(pop) - -#pragma pack(push, 1) -struct Vec4_int_ -{ - int x; - int y; - int z; - int w; -}; -#pragma pack(pop) - -/* 82 */ -#pragma pack(push, 1) -struct Plane_int_ -{ - Vec3_int_ vNormal; - int dist; -}; -#pragma pack(pop) - -#pragma pack(push, 1) -struct BBox_short_ -{ - __int16 x1; - __int16 x2; - __int16 y1; - __int16 y2; - __int16 z1; - __int16 z2; -}; -#pragma pack(pop) - -#pragma pack(push, 1) -struct BBox_int_ -{ - int x1; - int x2; - int y1; - int y2; - int z1; - int z2; -}; -#pragma pack(pop) - -#pragma pack(push, 1) -struct Plane_float_ -{ - struct Vec3_float_ vNormal; - float dist; -}; -#pragma pack(pop) - -/* 196 */ -#pragma pack(push, 1) -struct Matrix3x3_float_ -{ - union - { - struct - { - float _11; float _12; float _13; - float _21; float _22; float _23; - float _31; float _32; float _33; - }; - float v[3][3]; - }; -}; -#pragma pack(pop) diff -r 92eeeb5200f2 -r 68cdef6879a0 ZlibWrapper.cpp --- a/ZlibWrapper.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ - -namespace zlib -{ -#include "lib\zlib\zlib.h" - int MemUnzip(void *dest, unsigned int *destLen, const void *source, unsigned int sourceLen) - { - //return uncompress((zlib::Bytef *)dest, (zlib::uLongf *)destLen, (zlib::Bytef *)source, sourceLen); - return uncompress((Bytef *)dest, (uLongf *)destLen, (Bytef *)source, sourceLen); - return 0; - } - - int MemZip(void *dest, unsigned int *destLen, void *source, unsigned int sourceLen) - { - //return compress((zlib::Bytef *)dest, (zlib::uLongf *)destLen, (zlib::Bytef *)source, sourceLen); - return compress((Bytef *)dest, (uLongf *)destLen, (Bytef *)source, sourceLen); - return 0; - } -}; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 ZlibWrapper.h --- a/ZlibWrapper.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -#pragma once - -namespace zlib -{ - int MemZip(void *dest, unsigned int *destLen, void *source, unsigned int sourceLen); - int MemUnzip(void *dest, unsigned int *destLen, const void *source, unsigned int sourceLen); -}; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 mm7_7.cpp --- a/mm7_7.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,492 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS - -/* -GUIProgressBar *__cdecl crt_construct_576E30() -{ - RGBTexture::RGBTexture(&pGameLoadingUI_ProgressBar.pLoadingBg); - RGBTexture::RGBTexture(&pGameLoadingUI_ProgressBar.field_40); - RGBTexture::RGBTexture(&pGameLoadingUI_ProgressBar.field_68); - RGBTexture::RGBTexture(&pGameLoadingUI_ProgressBar.field_90); - RGBTexture::RGBTexture(&pGameLoadingUI_ProgressBar.field_B8); - Texture::Texture(&pGameLoadingUI_ProgressBar.field_E0); - Texture::Texture(&pGameLoadingUI_ProgressBar.pBardata); - Texture::Texture(&pGameLoadingUI_ProgressBar.pLoadingProgress); - pGameLoadingUI_ProgressBar.uProgressCurrent = 0; - pGameLoadingUI_ProgressBar.uProgressMax = 0; - pGameLoadingUI_ProgressBar.field_9 = 0; - pGameLoadingUI_ProgressBar.field_8 = 0; - pGameLoadingUI_ProgressBar.uHeight = 0; - pGameLoadingUI_ProgressBar.uWidth = 0; - pGameLoadingUI_ProgressBar.uY = 0; - pGameLoadingUI_ProgressBar.uX = 0; - pGameLoadingUI_ProgressBar.field_17 = 0; - pGameLoadingUI_ProgressBar.field_16 = 0; - pGameLoadingUI_ProgressBar.field_15 = 0; - pGameLoadingUI_ProgressBar.field_14 = 0; - pGameLoadingUI_ProgressBar.field_13 = 0; - pGameLoadingUI_ProgressBar.field_12 = 0; - pGameLoadingUI_ProgressBar.field_11 = 0; - pGameLoadingUI_ProgressBar.field_10 = 0; - return &pGameLoadingUI_ProgressBar; -} -*/ - -/*void constructors() -{ - //no call to these anywhere - uGameUIFontMain_initialize(); - uGameUIFontShadow_initialize(); -}*/ - -/* - -X = called already in our code -byte = constructor byte setter - -.data:004DF004 dd offset sub_4C9A95 -IOStream - -.data:004DF008 dd offset sub_4C9B06 -IOStream - -.data:004DF00C dd offset sub_401022 -achieved by zero initializing dword_4F8580, dword_4F8580[0] = 1; is unused anyway - -.data:004DF010 dd offset sub_408B98 -.data:004DF014 dd offset sub_409BCC -.data:004DF018 dd offset crt_sub_40D6EB -byte - -.data:004DF01C dd offset crt_construct_40D707_ptr_pArcomageGame -X - -.data:004DF020 dd offset crt_sub_40E4A6 -.data:004DF024 dd offset crt_deconstruct_40E503 -.data:004DF028 dd offset crt_sub_40F760 -.data:004DF02C dd offset crt_sub_40F7EA -.data:004DF030 dd offset crt_sub_40F9A9 -.data:004DF034 dd offset crt_sub_410AD9 -byte - -.data:004DF038 dd offset SetMoonPhaseNames -X - -.data:004DF03C dd offset crt_sub_413FD0 -byte - -.data:004DF040 dd offset j_SetMonthNames -.data:004DF044 dd offset j_SetDayNames -.data:004DF048 dd offset j_SetSpellSchoolNames -.data:004DF04C dd offset j_SetAttributeNames -X InitializeGameText - -.data:004DF050 dd offset uGameUIFontMain_initialize -.data:004DF054 dd offset uGameUIFontShadow_initialize -X called in SetUserInterface(Neutral) - -.data:004DF058 dd offset crt_construct_507ABC -.data:004DF05C dd offset crt_construct_507A94 -.data:004DF060 dd offset crt_construct_507A6C -.data:004DF064 dd offset crt_construct_507A44 -.data:004DF068 dd offset crt_construct_507A1C -.data:004DF06C dd offset crt_construct_506F20 -.data:004DF070 dd offset crt_construct_414D90_ptr_506E40 -X (RGBTexture constructor) - -.data:004DF074 dd offset crt_sub_423903 -byte - -.data:004DF078 dd offset IndoorCamera__IndoorCamera -X - -.data:004DF07C dd offset crt_sub_423ACD -byte - -.data:004DF080 dd offset j_reset_some_strus_flt_2Cs -deleted - -.data:004DF084 dd offset j_sub_423B4A -byte - -.data:004DF088 dd offset crt_sub_4262DD -byte - -.data:004DF08C dd offset crt_construct_pEventTimer -.data:004DF090 dd offset crt_construct_pMiscTimer -X - -.data:004DF094 dd offset crt_sub_42640D -.data:004DF098 dd offset crt_sub_4268C7 -.data:004DF09C dd offset crt_sub_42692B -byte - -.data:004DF0A0 dd offset sub_426947 -X initialized - -.data:004DF0A4 dd offset crt_construct_50C0C8 -X CastSpellInfo - -.data:004DF0A8 dd offset crt_sub_42FBB7 -byte - -.data:004DF0AC dd offset crt_construct_50CDB4 -seems unused CastSpellInfo variable - -.data:004DF0B0 dd offset sub_4361D3 -.data:004DF0B4 dd offset sub_4382A0 -.data:004DF0B8 dd offset sub_43850A -.data:004DF0BC dd offset crt_438AEF -.data:004DF0C0 dd offset crt_438B7F -.data:004DF0C4 dd offset ctr_deconstruct_43B4E0 -byte - -.data:004DF0C8 dd offset crt_43B4FC -deleted, constructor for stru_51076C - -.data:004DF0CC dd offset crt_deconstruct_43B51C -.data:004DF0D0 dd offset crt_deconstruct_43B5F0 -.data:004DF0D4 dd offset crt_deconstruct_43B64C -byte - -.data:004DF0D8 dd offset _crt_construct_stru165 -X BloodsplatContainer - -.data:004DF0DC dd offset crt_deconstruct_43B751 -.data:004DF0E0 dd offset crt_deconstruct_43B9E3 -.data:004DF0E4 dd offset crt_deconstruct_43BC8B -.data:004DF0E8 dd offset crt_deconstruct_43F22A -byte - -.data:004DF0EC dd offset crt_construct_51B778 -X BspRenderer - -.data:004DF0F0 dd offset crt_construct_519AB8 -X LightsStack_MobileLight - -.data:004DF0F4 dd offset crt_construct_5187F0 -X LightsStack_StationaryLight - - -.data:004DF0F8 dd offset crt_deconstruct_440B28 -.data:004DF0FC dd offset crt_deconstruct_440F5C -byte - -.data:004DF100 dd offset crt_construct_576E30 -added but have to RECHECK - -.data:004DF104 dd offset crt_deconstruct_4437E5 -byte - -.data:004DF108 dd offset sub_446219 -X InitializeGameText - -.data:004DF10C dd offset crt_construct_5773C4 -unused RGBTexture - -.data:004DF110 dd offset sub_44C346 -.data:004DF114 dd offset crt_deconstruct_44C42C -.data:004DF118 dd offset crt_deconstruct_44D49E -byte - -.data:004DF11C dd offset _inline_SpriteFrameTable__SpriteFrameTable_global -.data:004DF120 dd offset _inline_TextureFrameTable__TextureFrameTable_global -X - -.data:004DF124 dd offset sub_44E49B -.data:004DF128 dd offset sub_44F1F9 -.data:004DF12C dd offset sub_44F560 -.data:004DF130 dd offset sub_450DC2 -.data:004DF134 dd offset crt_deconstruct_45232B -byte - -.data:004DF138 dd offset crt_construct_stru193_math@5C6E00 -X - -.data:004DF13C dd offset crt_452B74 -byte - -.data:004DF140 dd offset j_SetSomeItemsNames -added - -.data:004DF144 dd offset crt_deconstruct_458364 -byte - -.data:004DF148 dd offset _intline_DecorationList__DecorationList_global -X - -.data:004DF14C dd offset j_crt_construct_6836D0 -X LevelDecorations - -.data:004DF150 dd offset _inline_ObjectList__ObjectList_global -X - -.data:004DF154 dd offset j_crt_construct_665230 -X SpriteObjects - -.data:004DF158 dd offset j_crt_construct_5FF158 -X Actors - -.data:004DF15C dd offset _inline_MonsterList__MonsterList_global -X - -.data:004DF160 dd offset _inline_ChestList__ChestList_global -X - -.data:004DF164 dd offset j_crt_construct_5E5150 -X Chests - -.data:004DF168 dd offset _inline_OverlayList__OverlayList_global -X - -.data:004DF16C dd offset crt_construct_5E4D58 -X OverlayList - -.data:004DF170 dd offset sub_459C05 -byte - -.data:004DF174 dd offset sub_459C21 -X KeyboardActionMapping - -.data:004DF178 dd offset crt_deconstruct_45AFBD -.data:004DF17C dd offset crt_deconstruct_45B0EE -.data:004DF180 dd offset sub_45BA89 -byte - -.data:004DF184 dd offset crt_call_global_ctor_45BAA5 -stru_69BD44 = "effpar03" , need RECHECK - -.data:004DF188 dd offset crt_deconstruct_45DEF7 -.data:004DF18C dd offset crt_deconstruct_45DF53 -.data:004DF190 dd offset crt_deconstruct_45DF6F -.data:004DF194 dd offset crt_deconstruct_45DF8B -byte - -.data:004DF198 dd offset crt_construct_ptr_6A0A60 -X LODFile - -.data:004DF19C dd offset crt_construct_ptr_6A0820 -X LODFile - -.data:004DF1A0 dd offset j_crt_construct_ptr_6A0118 -X RGBTexture - -.data:004DF1A4 dd offset sub_461415 -.data:004DF1A8 dd offset crt_deconstruct_4621BE -.data:004DF1AC dd offset crt_deconstruct_46220E -byte - -.data:004DF1B0 dd offset crt_construct_ptr_702B28 -X Allocator - -.data:004DF1B4 dd offset sub_46224A -X unused - -.data:004DF1B8 dd offset crt_construct_ptr_06F0E80 -X LODFile_IconsBitmaps - -.data:004DF1BC dd offset sub_4623CF -X LODFile_Sprites - -.data:004DF1C0 dd offset crt_call_ctors__pIcons_LOD -.data:004DF1C4 dd offset crt_call_ctors__pEvents_LOD -.data:004DF1C8 dd offset _inline_IndoorLocation__IndoorLocation_global -X - -.data:004DF1CC dd offset crt_init_globals_462620 -X initialized - -.data:004DF1D0 dd offset crt_construct_ptr_6BE158 -unused stru289 - -.data:004DF1D4 dd offset j_crt_init_globals_462659 -X initialized - -.data:004DF1D8 dd offset crt_construct_ptr_06BE070 -X ODMRenderParams - -.data:004DF1DC dd offset crt_init_globals_46269B -unused SW variable - -.data:004DF1E0 dd offset crt_construct_ptr_6BE048 -X TileTable - -.data:004DF1E4 dd offset crt_construct_ptr_6A0DF0 -X OutdoorLocation - -.data:004DF1E8 dd offset sub_466CA6 -.data:004DF1EC dd offset crt_deconstruct_467D29 -.data:004DF1F0 dd offset sub_467E32 -.data:004DF1F4 dd offset crt_deconstruct_46AC2C -byte - -.data:004DF1F8 dd offset crt_construct_46AC48_ptr_720990 -X std__string_720990 = "micon1" , need RECHECK - -.data:004DF1FC dd offset crt_deconstruct_46BD83 -byte - -.data:004DF200 dd offset crt_init_globals_46BD9F -added - -.data:004DF204 dd offset nullsub_26 -X - -.data:004DF208 dd offset sub_476102 -byte - -.data:004DF20C dd offset sub_47611E -X Texture - -.data:004DF210 dd offset sub_476128 -dword_7241C8 = 1 RECHECK - -.data:004DF214 dd offset sub_476133 -X InitializeGameText - -.data:004DF218 dd offset sub_477595 -.data:004DF21C dd offset sub_47836D -.data:004DF220 dd offset crt_sub_4783D9 -byte - -.data:004DF224 dd offset j__sub_4783FA_construct_global_73D150 - - -.data:004DF228 dd offset sub_47A368 -.data:004DF22C dd offset sub_47C778 -.data:004DF230 dd offset sub_47CDBE -byte - -.data:004DF234 dd offset sub_47CDDA - - -.data:004DF238 dd offset sub_47F483 -byte - -.data:004DF23C dd offset sub_47F49F - - -.data:004DF240 dd offset sub_47F4B9 - - -.data:004DF244 dd offset sub_482A74 -.data:004DF248 dd offset sub_485F37 -.data:004DF24C dd offset sub_486A0C -.data:004DF250 dd offset crt_deconstruct_487DF7 -.data:004DF254 dd offset sub_488E07 -.data:004DF258 dd offset sub_489572 -.data:004DF25C dd offset crt_deconstruct_489B44 -.data:004DF260 dd offset crt_deconstruct_489BBA -byte - -.data:004DF264 dd offset crt_construct_489BD6_ptr_080D198 -X PaletteManager - -.data:004DF268 dd offset sub_48AAA9 -.data:004DF26C dd offset sub_48C20E -byte - -.data:004DF270 dd offset sub_48C22A -.data:004DF274 dd offset loc_48C234 -.data:004DF278 dd offset loc_48C243 -.data:004DF27C dd offset loc_48C252 -.data:004DF280 dd offset loc_48C3C0 -.data:004DF284 dd offset loc_48C474 -Party constructor - -.data:004DF288 dd offset sub_49801C -.data:004DF28C dd offset sub_498077 -.data:004DF290 dd offset sub_498A25 -.data:004DF294 dd offset sub_49AFE5 -.data:004DF298 dd offset crt_deconstruct_49B36B -byte - -.data:004DF29C dd offset crt_construct_stru187@AE5BA8 -X DecalBuilder - -.data:004DF2A0 dd offset crt_construct_ptr_AE5B94 -std__string_AE5B94 = "hwsplat04", need RECHECK - -.data:004DF2A4 dd offset sub_49C594 -.data:004DF2A8 dd offset sub_49D6C8 -.data:004DF2AC dd offset sub_49D6E4 -.data:004DF2B0 dd offset sub_49E71A -byte - -.data:004DF2B4 dd offset sub_49E736 -X Render - -.data:004DF2B8 dd offset sub_4A198F -byte - -.data:004DF2BC dd offset sub_4A19AB -added - -.data:004DF2C0 dd offset sub_4A51AF -.data:004DF2C4 dd offset sub_4A7047 -.data:004DF2C8 dd offset sub_4A94EB -.data:004DF2CC dd offset sub_4A963E -byte - -.data:004DF2D0 dd offset sub_4A965A -X pSoundList - -.data:004DF2D4 dd offset AudioPlayer__AudioPlayer -X - -.data:004DF2D8 dd offset sub_4AC1AD -.data:004DF2DC dd offset sub_4AC662 -.data:004DF2E0 dd offset sub_4ACC1C -.data:004DF2E4 dd offset sub_4AD369 -.data:004DF2E8 dd offset crt_deconstruct_4AD44B -byte - -.data:004DF2EC dd offset crt_construct_4AD467_ptr_F79D68 -X OSVersion - -.data:004DF2F0 dd offset crt_deconstruct_4AD4DE -byte - -.data:004DF2F4 dd offset crt_construct_ptr_F7CE30 -X Texture - -.data:004DF2F8 dd offset sub_4B142B -.data:004DF2FC dd offset crt_sub_4BE344 -byte - -.data:004DF300 dd offset j_Random__ctor -X - -.data:004DF304 dd offset crt_sub_4BE6B5 -.data:004DF308 dd offset crt_sub_4BE6D4 -byte - -.data:004DF30C dd offset crt_j_VideoPlayer__ctor -RECHECK - -.data:004DF310 dd offset sub_4C021E -byte - -.data:004DF314 dd offset sub_4C023A -added - -.data:004DF318 dd offset sub_4C035A -.data:004DF31C dd offset sub_4C03A3 -byte - -.data:004DF320 dd offset sub_4C03BF -.data:004DF324 dd offset sub_4C03F1 -.data:004DF328 dd offset sub_4C0423 -.data:004DF32C dd offset sub_4C044B -.data:004DF330 dd offset sub_4C047D -X vis filters - -.data:004DF334 dd offset sub_4C2A6E -.data:004DF338 dd offset sub_4C2A8A -.data:004DF33C dd offset sub_4C2F7C -byte - -*/ \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 mm7_data.cpp --- a/mm7_data.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1094 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include "mm7_data.h" - -#include "GUIWindow.h" -#include "Party.h" - - -void ErrHR(HRESULT hr, const char *pAPI, const char *pFunction, const char *pFile, int line) -{ - if (SUCCEEDED(hr)) - return; - - char msg[4096]; - sprintf(msg, "%s error (%08X) in\n\t%s\nin\n\t%s:%u", - pAPI, hr, pFunction, pFile, line); - - char caption[1024]; - sprintf(caption, "%s error", pAPI); - - MessageBoxA(nullptr, msg, caption, MB_ICONEXCLAMATION); -} - - - - -#include "OurMath.h" -struct stru193_math *stru_5C6E00 = new stru193_math; - -#include "MapInfo.h" -struct MapStats *pMapStats; - -#include "Engine/Graphics/Viewport.h" -struct Viewport *pViewport = new Viewport; -struct ViewingParams *viewparams = new ViewingParams; - - - -#include "stru123.h" -stru123 stru_5E4C90_MapPersistVars; - -#include "stru298.h" -stru298 AttackerInfo; // weak - -#include "Autonotes.h" -std::array pAutonoteTxt; // weak - -#include "Awards.h" -std::array pAwards; -std::array achieved_awards; -int num_achieved_awards; -int full_num_items_in_book; - -#include "stru160.h" -std::array array_4EB8B8 = -{{ - stru160( 0.0000000f, 0.0000000f, 1.0000000f), - stru160( 0.0000000f, 0.3826830f, 0.9238799f), - stru160( 0.3826830f, 0.0000000f, 0.9238799f), - stru160( 0.4082480f, 0.4082480f, 0.8164970f), - stru160( 0.0000000f, 0.7071070f, 0.7071070f), - stru160( 0.7071070f, 0.0000000f, 0.7071070f), - stru160( 0.4082480f, 0.8164970f, 0.4082480f), - stru160( 0.8164970f, 0.4082480f, 0.4082480f), - stru160( 0.7071070f, 0.7071070f, 0.0000000f), - stru160( 0.0000000f, 0.9238799f, 0.3826830f), - stru160( 0.3826830f, 0.9238799f, 0.0000000f), - stru160( 0.0000000f, 1.0000000f, 0.0000000f), - stru160( 0.9238799f, 0.3826830f, 0.0000000f), - stru160( 0.9238799f, 0.0000000f, 0.3826830f), - stru160( 1.0000000f, 0.0000000f, 0.0000000f), - stru160( 0.0000000f, -0.3826830f, 0.9238799f), - stru160( 0.4082480f, -0.4082480f, 0.8164970f), - stru160( 0.0000000f, -0.7071070f, 0.7071070f), - stru160( 0.8164970f, -0.4082480f, 0.4082480f), - stru160( 0.4082480f, -0.8164970f, 0.4082480f), - stru160( 0.7071070f, -0.7071070f, 0.0000000f), - stru160( 0.9238799f, -0.3826830f, 0.0000000f), - stru160( 0.3826830f, -0.9238799f, 0.0000000f), - stru160( 0.0000000f, -0.9238799f, 0.3826830f), - stru160( 0.0000000f, -1.0000000f, 0.0000000f), - stru160(-0.3826830f, 0.0000000f, 0.9238799f), - stru160(-0.4082480f, -0.4082480f, 0.8164970f), - stru160(-0.7071070f, 0.0000000f, 0.7071070f), - stru160(-0.4082480f, -0.8164970f, 0.4082480f), - stru160(-0.8164970f, -0.4082480f, 0.4082480f), - stru160(-0.7071070f, -0.7071070f, 0.0000000f), - stru160(-0.3826830f, -0.9238799f, 0.0000000f), - stru160(-0.9238799f, -0.3826830f, 0.0000000f), - stru160(-0.9238799f, 0.0000000f, 0.3826830f), - stru160(-1.0000000f, 0.0000000f, 0.0000000f), - stru160(-0.4082480f, 0.4082480f, 0.8164970f), - stru160(-0.8164970f, 0.4082480f, 0.4082480f), - stru160(-0.4082480f, 0.8164970f, 0.4082480f), - stru160(-0.7071070f, 0.7071070f, 0.0000000f), - stru160(-0.9238799f, 0.3826830f, 0.0000000f), - stru160(-0.3826830f, 0.9238799f, 0.0000000f), - stru160( 0.0000000f, 0.0000000f, -1.0000000f), - stru160( 0.0000000f, 0.3826830f, -0.9238799f), - stru160( 0.3826830f, 0.0000000f, -0.9238799f), - stru160( 0.4082480f, 0.4082480f, -0.8164970f), - stru160( 0.0000000f, 0.7071070f, -0.7071070f), - stru160( 0.7071070f, 0.0000000f, -0.7071070f), - stru160( 0.4082480f, 0.8164970f, -0.4082480f), - stru160( 0.8164970f, 0.4082480f, -0.4082480f), - stru160( 0.0000000f, 0.9238799f, -0.3826830f), - stru160( 0.9238799f, 0.0000000f, -0.3826830f), - stru160( 0.0000000f, -0.3826830f, -0.9238799f), - stru160( 0.4082480f, -0.4082480f, -0.8164970f), - stru160( 0.0000000f, -0.7071070f, -0.7071070f), - stru160( 0.8164970f, -0.4082480f, -0.4082480f), - stru160( 0.4082480f, -0.8164970f, -0.4082480f), - stru160( 0.0000000f, -0.9238799f, -0.3826830f), - stru160(-0.3826830f, 0.0000000f, -0.9238799f), - stru160(-0.4082480f, -0.4082480f, -0.8164970f), - stru160(-0.7071070f, 0.0000000f, -0.7071070f), - stru160(-0.4082480f, -0.8164970f, -0.4082480f), - stru160(-0.8164970f, -0.4082480f, -0.4082480f), - stru160(-0.9238799f, 0.0000000f, -0.3826830f), - stru160(-0.4082480f, 0.4082480f, -0.8164970f), - stru160(-0.8164970f, 0.4082480f, -0.4082480f), - stru160(-0.4082480f, 0.8164970f, -0.4082480f) -}}; -std::array array_4EBBD0; -std::array<__int32, 128*3> array_4EBBD0_x = -{{ - 0x00000000, 0x00000001, 0x00000002, 0x00000001, - 0x00000003, 0x00000002, 0x00000001, 0x00000004, - 0x00000003, 0x00000003, 0x00000005, 0x00000002, - 0x00000004, 0x00000006, 0x00000003, 0x00000006, - 0x00000007, 0x00000003, 0x00000006, 0x00000008, - 0x00000007, 0x00000007, 0x00000005, 0x00000003, - 0x00000004, 0x00000009, 0x00000006, 0x00000009, - 0x0000000A, 0x00000006, 0x00000009, 0x0000000B, - 0x0000000A, 0x0000000A, 0x00000008, 0x00000006, - 0x00000008, 0x0000000C, 0x00000007, 0x0000000C, - 0x0000000D, 0x00000007, 0x0000000C, 0x0000000E, - 0x0000000D, 0x0000000D, 0x00000005, 0x00000007, - 0x00000000, 0x00000002, 0x0000000F, 0x00000002, - 0x00000010, 0x0000000F, 0x00000002, 0x00000005, - 0x00000010, 0x00000010, 0x00000011, 0x0000000F, - 0x00000005, 0x00000012, 0x00000010, 0x00000012, - 0x00000013, 0x00000010, 0x00000012, 0x00000014, - 0x00000013, 0x00000013, 0x00000011, 0x00000010, - 0x00000005, 0x0000000D, 0x00000012, 0x0000000D, - 0x00000015, 0x00000012, 0x0000000D, 0x0000000E, - 0x00000015, 0x00000015, 0x00000014, 0x00000012, - 0x00000014, 0x00000016, 0x00000013, 0x00000016, - 0x00000017, 0x00000013, 0x00000016, 0x00000018, - 0x00000017, 0x00000017, 0x00000011, 0x00000013, - 0x00000000, 0x0000000F, 0x00000019, 0x0000000F, - 0x0000001A, 0x00000019, 0x0000000F, 0x00000011, - 0x0000001A, 0x0000001A, 0x0000001B, 0x00000019, - 0x00000011, 0x0000001C, 0x0000001A, 0x0000001C, - 0x0000001D, 0x0000001A, 0x0000001C, 0x0000001E, - 0x0000001D, 0x0000001D, 0x0000001B, 0x0000001A, - 0x00000011, 0x00000017, 0x0000001C, 0x00000017, - 0x0000001F, 0x0000001C, 0x00000017, 0x00000018, - 0x0000001F, 0x0000001F, 0x0000001E, 0x0000001C, - 0x0000001E, 0x00000020, 0x0000001D, 0x00000020, - 0x00000021, 0x0000001D, 0x00000020, 0x00000022, - 0x00000021, 0x00000021, 0x0000001B, 0x0000001D, - 0x00000000, 0x00000019, 0x00000001, 0x00000019, - 0x00000023, 0x00000001, 0x00000019, 0x0000001B, - 0x00000023, 0x00000023, 0x00000004, 0x00000001, - 0x0000001B, 0x00000024, 0x00000023, 0x00000024, - 0x00000025, 0x00000023, 0x00000024, 0x00000026, - 0x00000025, 0x00000025, 0x00000004, 0x00000023, - 0x0000001B, 0x00000021, 0x00000024, 0x00000021, - 0x00000027, 0x00000024, 0x00000021, 0x00000022, - 0x00000027, 0x00000027, 0x00000026, 0x00000024, - 0x00000026, 0x00000028, 0x00000025, 0x00000028, - 0x00000009, 0x00000025, 0x00000028, 0x0000000B, - 0x00000009, 0x00000009, 0x00000004, 0x00000025, - 0x00000029, 0x0000002A, 0x0000002B, 0x0000002A, - 0x0000002C, 0x0000002B, 0x0000002A, 0x0000002D, - 0x0000002C, 0x0000002C, 0x0000002E, 0x0000002B, - 0x0000002D, 0x0000002F, 0x0000002C, 0x0000002F, - 0x00000030, 0x0000002C, 0x0000002F, 0x00000008, - 0x00000030, 0x00000030, 0x0000002E, 0x0000002C, - 0x0000002D, 0x00000031, 0x0000002F, 0x00000031, - 0x0000000A, 0x0000002F, 0x00000031, 0x0000000B, - 0x0000000A, 0x0000000A, 0x00000008, 0x0000002F, - 0x00000008, 0x0000000C, 0x00000030, 0x0000000C, - 0x00000032, 0x00000030, 0x0000000C, 0x0000000E, - 0x00000032, 0x00000032, 0x0000002E, 0x00000030, - 0x00000029, 0x0000002B, 0x00000033, 0x0000002B, - 0x00000034, 0x00000033, 0x0000002B, 0x0000002E, - 0x00000034, 0x00000034, 0x00000035, 0x00000033, - 0x0000002E, 0x00000036, 0x00000034, 0x00000036, - 0x00000037, 0x00000034, 0x00000036, 0x00000014, - 0x00000037, 0x00000037, 0x00000035, 0x00000034, - 0x0000002E, 0x00000032, 0x00000036, 0x00000032, - 0x00000015, 0x00000036, 0x00000032, 0x0000000E, - 0x00000015, 0x00000015, 0x00000014, 0x00000036, - 0x00000014, 0x00000016, 0x00000037, 0x00000016, - 0x00000038, 0x00000037, 0x00000016, 0x00000018, - 0x00000038, 0x00000038, 0x00000035, 0x00000037, - 0x00000029, 0x00000033, 0x00000039, 0x00000033, - 0x0000003A, 0x00000039, 0x00000033, 0x00000035, - 0x0000003A, 0x0000003A, 0x0000003B, 0x00000039, - 0x00000035, 0x0000003C, 0x0000003A, 0x0000003C, - 0x0000003D, 0x0000003A, 0x0000003C, 0x0000001E, - 0x0000003D, 0x0000003D, 0x0000003B, 0x0000003A, - 0x00000035, 0x00000038, 0x0000003C, 0x00000038, - 0x0000001F, 0x0000003C, 0x00000038, 0x00000018, - 0x0000001F, 0x0000001F, 0x0000001E, 0x0000003C, - 0x0000001E, 0x00000020, 0x0000003D, 0x00000020, - 0x0000003E, 0x0000003D, 0x00000020, 0x00000022, - 0x0000003E, 0x0000003E, 0x0000003B, 0x0000003D, - 0x00000029, 0x00000039, 0x0000002A, 0x00000039, - 0x0000003F, 0x0000002A, 0x00000039, 0x0000003B, - 0x0000003F, 0x0000003F, 0x0000002D, 0x0000002A, - 0x0000003B, 0x00000040, 0x0000003F, 0x00000040, - 0x00000041, 0x0000003F, 0x00000040, 0x00000026, - 0x00000041, 0x00000041, 0x0000002D, 0x0000003F, - 0x0000003B, 0x0000003E, 0x00000040, 0x0000003E, - 0x00000027, 0x00000040, 0x0000003E, 0x00000022, - 0x00000027, 0x00000027, 0x00000026, 0x00000040, - 0x00000026, 0x00000028, 0x00000041, 0x00000028, - 0x00000031, 0x00000041, 0x00000028, 0x0000000B, - 0x00000031, 0x00000031, 0x0000002D, 0x00000041 -}}; - -#include "MapsLongTimer.h" -MapsLongTimer MapsLongTimersList[100]; - -#include "ObjectList.h" -struct ObjectList *pObjectList; - -#include "IconFrameTable.h" -struct IconFrameTable *pIconsFrameTable; - -struct -{ - struct UIAnimation _pUIAnim_Food; - struct UIAnimation _pUIAnim_Gold; - struct UIAnimation _pUIAnum_Torchlight; - struct UIAnimation _pUIAnim_WizardEye; -} _uianim; - -struct UIAnimation *pUIAnim_Food = &_uianim._pUIAnim_Food; -struct UIAnimation *pUIAnim_Gold = &_uianim._pUIAnim_Gold; -struct UIAnimation *pUIAnum_Torchlight = &_uianim._pUIAnum_Torchlight; -struct UIAnimation *pUIAnim_WizardEye = &_uianim._pUIAnim_WizardEye; - -std::array pUIAnims = -{ - &_uianim._pUIAnim_Food, - &_uianim._pUIAnim_Gold, - &_uianim._pUIAnum_Torchlight, - &_uianim._pUIAnim_WizardEye -}; - - - -#include "PlayerFrameTable.h" -struct PlayerFrameTable *pPlayerFrameTable; // idb - -#include "MM7.h" - - -std::array stat_string_coord = //4E2940 -{{ - {0x1A, 0x39, 0xDC, 0x12}, - {0x1A, 0x4A, 0xDC, 0x12}, - {0x1A, 0x5B, 0xDC, 0x12}, - {0x1A, 0x6C, 0xDC, 0x12}, - {0x1A, 0x7D, 0xDC, 0x12}, - {0x1A, 0x8E, 0xDC, 0x12}, - {0x1A, 0x9F, 0xDC, 0x12}, - {0x1A, 0xC6, 0xDC, 0x12}, - {0x1A, 0xD7, 0xDC, 0x12}, - {0x1A, 0xE8, 0xDC, 0x12}, - {0x1A, 0x10C, 0xDC, 0x12}, - {0x1A, 0x11E, 0xDC, 0x12}, - {0x111, 0x36, 0xBA, 0x12}, - {0x111, 0x47, 0xBA, 0x12}, - {0x111, 0x58, 0xBA, 0x12}, - {0x111, 0x7E, 0xBA, 0x12}, - {0x111, 0x8F, 0xBA, 0x12}, - {0x111, 0xA0, 0xBA, 0x12}, - {0x111, 0xB1, 0xBA, 0x12}, - {0x111, 0xCA, 0xBA, 0x12}, - {0x111, 0xDD, 0xBA, 0x12}, - {0x111, 0xF0, 0xBA, 0x12}, - {0x111, 0x103, 0xBA, 0x12}, - {0x111, 0x116, 0xBA, 0x12}, - {0x111, 0x129, 0xBA, 0x12}, - {0x13E, 0x12, 0x89, 0x12}, -} -}; - - - - - -#include "stru314.h" -#include "stru367.h" - - - -//------------------------------------------------------------------------- -// Data declarations - -int game_starting_year = 0; -unsigned int game_viewport_width; -unsigned int game_viewport_height; -int game_viewport_x; -int game_viewport_y; -int game_viewport_z; -int game_viewport_w; - - - -std::array saveload_dlg_xs = {82, 0}; -std::array saveload_dlg_ys = {60, 0}; -std::array saveload_dlg_zs = {460, 640}; -std::array saveload_dlg_ws = {344, 480}; -int pWindowList_at_506F50_minus1_indexing[1]; -int dword_4C9890[10]; // weak -int dword_4C9920[16]; // weak -char byte_4D864C; // weak -float flt_4D86CC = 1.0f; // weak -int dword_4D86D8 = 0x40000000; // weak - - - - - - - -float flt_4D84E8 = 0.0f; - -int pCurrentScreen = SCREEN_VIDEO; // 004E28F8 -unsigned int uGammaPos; -std::array BtnTurnCoord = -{{ - 0xA4, 0x5D, 0x16, 0xB, 0x5, 0xD, 0x7, 0x3B, -}}; // weak -std::array<__int16, 4> RightClickPortraitXmin={{0x14, 0x83, 0xF2, 0x165}}; -std::array<__int16, 4> RightClickPortraitXmax={{0x53, 0xC6, 0x138, 0x1A7}}; - -std::array pHealthBarPos = {{22, 137, 251, 366}}; -std::array pManaBarPos = {{102, 217, 331, 447}}; - -std::array monster_popup_y_offsets = -{{ - -20, 20, 0, -40, 0, 0, 0, 0, 0, 0, -50, - 20, 0, -10, -10, -20, 10, -10, 0, 0, 0, -20, - 10, -10, 0, 0, 0, -20, -10, 0, 0, 0, -40, - -20, 0, 0, 0, -50, -30, -30, -30, -30, -30, -30, - 0, 0, 0, 0, 0, 0, -20, -20, -20, 20, 20, - 20, 10, 10, 10, 10, 10, 10, -90, -60, -40, -20, - -20, -80, -10, 0, 0, -40, 0, 0, 0, -20, 10, - 0, 0, 0, 0, 0, 0, -60, 0, 0, 0, 0 -}}; -unsigned char hourglass_icon_idx = 12; // weak - - -const char *format_4E2D80 = "\f%05d%s\f00000\n"; -//const char *format_4E2DC8 = "\f%05d"; -const char *format_4E2DE8 = "\f%05d%s\f00000 - "; -const char *Stat_string_format_2_column_text = "%s\f%05u\r180%s\n"; -const char *Stat_string_format_2_column_less_100 = "%s\f%05u\t110%d\f00000 / %d\n"; -const char *Stat_string_format_2_column_over_100 = "%s\f%05u\r180%d\f00000 / %d\n"; -int dword_4E455C; // weak -std::array dword_4E4560; -std::array dword_4E4578; -std::array dword_4E4590; -std::array dword_4E45A8; -std::array flt_4E4A80 = -{ - 0.050000001, 0.1, 0.30000001, 0.5, 0.60000002, - 1.0, 6.0, 25.0, 50.0, 100.0 -}; - - -std::array< std::array, 14> pPartySpellbuffsUI_XYs = -{{ - {477, 247}, {497, 247}, {522, 247}, {542, 247}, {564, 247}, {581, 247}, {614, 247}, - {477, 279}, {497, 279}, {522, 279}, {542, 279}, {564, 279}, {589, 279}, {612, 279} -}}; -std::array byte_4E5DD8 = -{{ - PARTY_BUFF_FEATHER_FALL, PARTY_BUFF_RESIST_FIRE, PARTY_BUFF_RESIST_AIR, PARTY_BUFF_RESIST_WATER, PARTY_BUFF_RESIST_MIND, PARTY_BUFF_RESIST_EARTH, PARTY_BUFF_RESIST_BODY, - PARTY_BUFF_HEROISM, PARTY_BUFF_HASTE, PARTY_BUFF_SHIELD, PARTY_BUFF_STONE_SKIN, PARTY_BUFF_PROTECTION_FROM_MAGIC, PARTY_BUFF_IMMOLATION, PARTY_BUFF_DAY_OF_GODS -}}; -std::array pPartySpellbuffsUI_smthns = -{{ - 14, 1, 10, 4, 7, 2, 9, - 3, 6, 15, 8, 3, 12, 0 -}}; - -std::array< std::array, 6> pNPCPortraits_x = // 004E5E50 -{{ - {521, 0, 0, 0, 0, 0}, - {521, 521, 0, 0, 0, 0}, - {521, 521, 521, 0, 0, 0}, - {521, 486, 564, 521, 0, 0}, - {521, 486, 564, 486, 564, 0}, - {486, 564, 486, 564, 486, 564} -}}; -std::array< std::array, 6> pNPCPortraits_y = // 004E5EE0 -{{ - {38, 0, 0, 0, 0, 0}, - {38, 165, 0, 0, 0, 0}, - {38, 133, 228, 0, 0, 0}, - {38, 133, 133, 228, 0, 0}, - {38, 133, 133, 228, 228, 0}, - {38, 38, 133, 133, 228, 228} -}}; -std::array pHouse_ExitPictures= -{ - "", - "ticon01", - "ticon02", - "ticon03", - "ticon04", - "ticon05", - "istairup", - "itrap", - "outside", - "idoor", - "isecdoor" -}; - -std::array<__int16, 11> word_4E8152 = {0, 0, 0, 90, 8, 2, 70, 20, 10, 50, 30}; - -char _4E94D0_light_type = 5; // weak -char _4E94D2_light_type = 6; // weak -char _4E94D3_light_type = 10; // weak -int dword_4E98BC_bApplicationActive; // weak -//char *off_4EB080; // idb -std::array pTransitionStrings = {"", nullptr}; // 004EB080 -std::array pPlayerPortraitsNames = -{{ - "pc01-", "pc02", "pc03", "pc04", "pc05-", - "pc06", "pc07", "pc08", "pc09-", "pc10", - "pc11-", "pc12", "pc13", "pc14", "pc15", - "pc16", "pc17-", "pc18", "pc19", "pc20", - "pc21-", "pc22-", "pc23", "pc24-", "pc25-" -}}; - - - -std::array< std::array, 48> byte_4ECF08 = // 4ECF08 -{{ - {2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1},//1 - {2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},//2 - {2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//3 - {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//4 - {2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//5 - {2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//6 - {2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//7 - {2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1},//8 - {2, 1, 2, 2, 2, 2, 1, 2, 1, 2, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2},//9 - {2, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//10 - {2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},//11 - {1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1, 2, 2},//12 - {2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//13 - {1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 2},//14 - {2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2},//15 - {1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 1},//16 - {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//17 - {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, 2, 1, 2, 1, 1},//18 - {1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//19 - {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//20 - {1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//21 - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//22 - {2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1},//23 - {2, 2, 2, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2},//24 - {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 2, 2, 2, 1, 2, 1, 1},//25 - {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//26 - {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2},//27 - {1, 2, 2, 1, 2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//28 - {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 1, 1},//29 - {1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1},//30 - {1, 1, 2, 1, 2, 1, 2, 2, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 2, 2, 2, 1, 2, 1, 1},//31 - {1, 1, 2, 1, 1, 2, 2, 2, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2},//32 - {1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1},//33 - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1},//34 - {1, 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2},//35 - {1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2},//36 - {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2},//37 - {2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 1, 2, 1, 1},//38 - {1, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1},//39 - {1, 2, 2, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//40 - {2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 1, 2, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1},//41 - {1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 1},//42 - {1, 2, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//43 - {1, 2, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 2},//44 - {2, 1, 1, 1, 2, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2},//45 - {1, 1, 1, 2, 2, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 2, 2, 1, 1, 2, 1, 2, 1, 2, 2},//46 - {1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1},//47 - {1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1},//48 -}}; -std::array, 110> SoundSetAction = // 4ED3D8 -{{ - { 0, 0, 0, 0, 0, 0, 0, 0}, - {38, 0, 0, 37, 38, 45, 0, 0}, - {37, 0, 0, 47, 53, 0, 0, 0}, - { 2, 0, 0, 25, 0, 0, 0, 0}, - { 1, 0, 0, 47, 0, 0, 0, 0}, - { 3, 0, 0, 41, 42, 0, 0, 0}, - { 0, 0, 0, 33, 0, 0, 0, 0}, - { 5, 0, 0, 21, 22, 23, 24, 45}, - { 6, 0, 0, 47, 0, 0, 0, 0}, - { 7, 0, 0, 43, 48, 0, 0, 0}, - { 8, 0, 0, 38, 0, 0, 0, 0}, - { 9, 0, 0, 39, 0, 0, 0, 0}, - {13, 0, 0, 37, 38, 0, 0, 0}, - {23, 0, 0, 25, 0, 0, 0, 0}, - { 0, 0, 0, 37, 38, 45, 0, 0}, - {25, 0, 0, 25, 0, 0, 0, 0}, - {26, 0, 0, 38, 47, 0, 0, 0}, - {27, 0, 0, 41, 42, 0, 0, 0}, - {28, 0, 0, 25, 0, 0, 0, 0}, - { 0, 0, 0, 51, 0, 0, 0, 0}, - {30, 0, 0, 25, 0, 0, 0, 0}, - {29, 0, 0, 27, 0, 0, 0, 0}, - {32, 33, 0, 37, 38, 0, 0, 0}, - {34, 0, 0, 53, 0, 0, 0, 0}, - {15, 0, 0, 34, 35, 36, 0, 0}, - { 0, 0, 0, 3, 0, 0, 0, 0}, - {22, 0, 0, 5, 0, 0, 0, 0}, - {20, 0, 0, 8, 0, 0, 0, 0}, - {20, 0, 0, 9, 0, 0, 0, 0}, - {19, 0, 0, 7, 0, 0, 0, 0}, - {21, 0, 0, 2, 0, 0, 0, 0}, - {18, 0, 0, 6, 0, 0, 0, 0}, - { 0, 0, 0, 11, 0, 0, 0, 0}, - {17, 0, 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 12, 0, 0, 0, 0}, - {17, 0, 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 37, 0, 0, 0, 0}, - { 0, 0, 0, 49, 0, 0, 0, 0}, - {24, 0, 0, 25, 0, 0, 0, 0}, - {31, 0, 0, 25, 0, 0, 0, 0}, - { 0, 0, 0, 41, 42, 0, 0, 0}, - { 0, 0, 0, 39, 48, 0, 0, 0}, - { 0, 0, 0, 46, 0, 0, 0, 0}, - { 0, 0, 0, 39, 48, 0, 0, 0}, - { 0, 0, 0, 41, 42, 0, 0, 0}, - { 0, 0, 0, 39, 48, 0, 0, 0}, - {41, 0, 0, 21, 0, 0, 0, 0}, - {40, 0, 0, 21, 0, 0, 0, 0}, - {16, 0, 0, 46, 0, 0, 0, 0}, - { 0, 0, 0, 40, 0, 0, 0, 0}, - { 0, 0, 0, 39, 0, 0, 0, 0}, - { 0, 0, 0, 37, 38, 0, 0, 0}, - { 0, 0, 0, 48, 49, 50, 0, 0}, - { 0, 0, 0, 44, 0, 0, 0, 0}, - { 0, 0, 0, 48, 0, 0, 0, 0}, - { 0, 0, 0, 37, 38, 45, 0, 0}, - { 0, 0, 0, 41, 42, 0, 0, 0}, - { 0, 0, 0, 47, 0, 0, 0, 0}, - { 0, 0, 0, 39, 48, 0, 0, 0}, - { 0, 0, 0, 39, 48, 0, 0, 0}, - { 0, 0, 0, 37, 38, 0, 0, 0}, - { 0, 0, 0, 37, 38, 0, 0, 0}, - { 0, 0, 0, 37, 38, 0, 0, 0}, - { 0, 0, 0, 31, 0, 0, 0, 0}, - { 0, 0, 0, 32, 0, 0, 0, 0}, - {47, 0, 0, 46, 0, 0, 0, 0}, - {22, 0, 0, 5, 0, 0, 0, 0}, - { 0, 0, 0, 25, 0, 0, 0, 0}, - { 0, 0, 0, 37, 0, 0, 0, 0}, - { 0, 0, 0, 52, 0, 0, 0, 0}, - { 0, 0, 0, 45, 0, 0, 0, 0}, - { 0, 0, 0, 27, 0, 0, 0, 0}, - { 0, 0, 0, 37, 38, 0, 0, 0}, - { 0, 0, 0, 49, 0, 0, 0, 0}, - { 0, 0, 0, 48, 0, 0, 0, 0}, - { 0, 0, 0, 37, 38, 45, 0, 0}, - { 0, 0, 0, 48, 0, 0, 0, 0}, - { 0, 0, 0, 37, 38, 45, 0, 0}, - { 0, 0, 0, 47, 0, 0, 0, 0}, - { 0, 0, 0, 48, 0, 0, 0, 0}, - {44, 0, 0, 39, 48, 0, 0, 0}, - { 0, 0, 0, 48, 49, 0, 0, 0}, - { 0, 0, 0, 38, 0, 0, 0, 0}, - { 0, 0, 0, 31, 0, 0, 0, 0}, - {32, 33, 0, 37, 38, 0, 0, 0}, - { 0, 0, 0, 37, 38, 0, 0, 0}, - { 0, 0, 0, 37, 38, 0, 0, 0}, - { 0, 0, 0, 47, 0, 0, 0, 0}, - { 0, 0, 0, 38, 0, 0, 0, 0}, - { 0, 0, 0, 48, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 38, 0, 0, 0, 0}, - { 0, 0, 0, 47, 0, 0, 0, 0}, - { 0, 0, 0, 38, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 38, 0, 0, 0, 0}, - { 0, 0, 0, 38, 0, 0, 0, 0}, - { 0, 0, 0, 5, 0, 0, 0, 0}, - { 0, 0, 0, 37, 38, 0, 0, 0}, - { 0, 0, 0, 44, 0, 0, 0, 0}, - { 0, 0, 0, 48, 0, 0, 0, 0}, - { 4, 0, 0, 0, 0, 0, 0, 0}, - { 0, 0, 0, 58, 0, 0, 0, 0}, - {10, 0, 0, 45, 0, 0, 0, 0}, - {11, 0, 0, 47, 0, 0, 0, 0}, - {12, 0, 0, 43, 48, 0, 0, 0}, - {39, 0, 0, 48, 0, 0, 0, 0}, - {14, 0, 0, 48, 0, 0, 0, 0}, - {17, 0, 0, 0, 0, 0, 0, 0} -}}; -std::array<__int16, 4> pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing = {34, 149, 264, 379}; -std::array< std::array, 36> byte_4ED970_skill_learn_ability_by_class_table = -{{ - 2, 3, 2, 3, 3, 2, 3, 4, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 3, 0, 2, 1, 0, 1, 2, 2, 0, 3, 0, 0, 1,//Knight - 2, 3, 2, 3, 3, 2, 3, 4, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 3, 0, 2, 1, 0, 1, 2, 2, 0, 3, 0, 0, 1, - 2, 4, 2, 3, 4, 2, 3, 4, 4, 3, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 0, 2, 1, 0, 1, 2, 2, 0, 4, 0, 0, 1, - 2, 4, 2, 3, 4, 2, 3, 4, 4, 3, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 0, 2, 1, 0, 1, 2, 2, 0, 4, 0, 0, 1, - - 0, 3, 3, 0, 0, 2, 2, 4, 1, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 1, 2, 0, 3, 0, 0, 3, 3, 2, 0, 3, 3, 2, 2,//Thief - 0, 3, 3, 0, 0, 2, 2, 4, 1, 3, 2, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 3, 3, 1, 2, 0, 3, 0, 0, 3, 3, 2, 0, 3, 3, 2, 2, - 0, 3, 4, 0, 0, 2, 2, 4, 1, 4, 2, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 3, 3, 1, 2, 0, 3, 0, 0, 4, 3, 2, 0, 3, 4, 2, 2, - 0, 3, 4, 0, 0, 2, 2, 4, 1, 4, 2, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 3, 3, 1, 2, 0, 3, 0, 0, 4, 3, 2, 0, 3, 4, 2, 2, - - 3, 2, 2, 0, 2, 1, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 2, 1, 0, 1, 3, 3, 2, 3, 1, 0, 3,//Monk - 3, 2, 2, 0, 2, 1, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 3, 0, 2, 1, 0, 2, 3, 3, 2, 3, 1, 0, 3, - 4, 2, 2, 0, 2, 1, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 4, 0, 2, 1, 0, 2, 4, 4, 2, 3, 1, 0, 4, - 4, 2, 2, 0, 2, 1, 0, 4, 0, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 4, 0, 2, 1, 0, 3, 4, 4, 2, 3, 2, 0, 4, - - 1, 3, 2, 2, 2, 2, 3, 4, 3, 2, 2, 3, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 2, 3, 3, 2, 1, 3, 0, 0, 1, 1, 0, 2, 0, 0, 1,//Paladin - 1, 3, 2, 2, 2, 2, 3, 4, 3, 2, 2, 3, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 2, 3, 3, 2, 1, 3, 0, 0, 1, 1, 0, 2, 0, 0, 1, - 1, 3, 2, 2, 2, 2, 4, 4, 4, 2, 2, 3, 0, 0, 0, 0, 3, 3, 3, 1, 0, 0, 2, 4, 3, 2, 1, 4, 0, 0, 1, 1, 0, 2, 0, 0, 1, - 1, 3, 2, 2, 2, 2, 4, 4, 4, 2, 2, 3, 0, 0, 0, 0, 3, 3, 3, 0, 1, 0, 2, 4, 3, 2, 1, 4, 0, 0, 1, 1, 0, 2, 0, 0, 1, - - 1, 2, 2, 2, 3, 3, 0, 4, 0, 3, 3, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 0, 0, 1, 2, 1, 0, 2, 0, 0, 3,//Archer - 1, 2, 2, 2, 3, 3, 0, 4, 0, 3, 3, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 0, 0, 1, 2, 1, 0, 2, 0, 0, 3, - 1, 2, 2, 2, 3, 4, 0, 4, 0, 3, 4, 0, 3, 3, 3, 3, 0, 0, 0, 1, 0, 0, 2, 2, 2, 2, 4, 0, 0, 2, 2, 1, 0, 2, 0, 0, 3, - 1, 2, 2, 2, 3, 4, 0, 4, 0, 3, 4, 0, 3, 3, 3, 3, 0, 0, 0, 0, 1, 0, 2, 2, 2, 2, 4, 0, 0, 2, 2, 1, 0, 2, 0, 0, 3, - - 1, 2, 2, 3, 2, 3, 0, 4, 2, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 1, 3, 2, 0, 2, 2, 1, 3, 2, 2, 1, 2,//Ranger - 1, 2, 2, 3, 2, 3, 0, 4, 2, 3, 3, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 2, 1, 3, 2, 0, 2, 2, 1, 3, 2, 2, 1, 2, - 1, 2, 2, 4, 2, 3, 0, 4, 2, 3, 3, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 1, 1, 1, 2, 1, 3, 2, 0, 2, 2, 1, 4, 2, 2, 1, 2, - 1, 2, 2, 4, 2, 3, 0, 4, 2, 3, 3, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 1, 1, 1, 2, 1, 3, 2, 0, 2, 2, 1, 4, 2, 2, 1, 2, - - 1, 0, 0, 0, 0, 2, 3, 4, 3, 2, 2, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 3, 3, 1, 3, 2, 3, 0, 0, 0, 0, 2, 0, 0, 2, 3,//Cleric - 1, 0, 0, 0, 0, 2, 3, 4, 3, 2, 2, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 3, 3, 1, 3, 2, 3, 0, 0, 0, 0, 2, 0, 0, 2, 3, - 1, 0, 0, 0, 0, 2, 3, 4, 3, 2, 2, 0, 0, 0, 0, 0, 4, 4, 4, 4, 0, 0, 4, 3, 1, 3, 2, 3, 0, 0, 0, 0, 2, 0, 0, 2, 3, - 1, 0, 0, 0, 0, 2, 3, 4, 3, 2, 2, 0, 0, 0, 0, 0, 4, 4, 4, 0, 4, 0, 4, 3, 1, 3, 2, 3, 0, 0, 0, 0, 2, 0, 0, 2, 3, - - 1, 0, 3, 0, 0, 1, 2, 4, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 0, 0, 3, 2, 0, 0, 0, 0, 0, 2, 1, 0, 3, 3,//Druid - 1, 0, 3, 0, 0, 1, 2, 4, 2, 2, 0, 0, 3, 3, 3, 3, 3, 3, 3, 0, 0, 2, 2, 0, 0, 3, 2, 0, 0, 0, 0, 0, 2, 1, 0, 3, 3, - 1, 0, 3, 0, 0, 1, 2, 4, 2, 2, 0, 0, 3, 3, 3, 3, 3, 3, 3, 0, 0, 2, 2, 0, 0, 4, 2, 0, 0, 0, 0, 0, 2, 1, 0, 4, 3, - 1, 0, 3, 0, 0, 1, 2, 4, 2, 2, 0, 0, 3, 3, 3, 3, 3, 3, 3, 0, 0, 2, 2, 0, 0, 4, 2, 0, 0, 0, 0, 0, 2, 1, 0, 4, 3, - - 3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 3, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 3, 0, 0, 3, 3,//Sorcerer - 3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 3, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 3, 0, 0, 3, 3, - 3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 4, 4, 4, 4, 0, 0, 0, 4, 0, 4, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 4, 0, 0, 3, 3, - 3, 0, 2, 0, 0, 1, 0, 4, 0, 2, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0, 4, 4, 1, 2, 0, 3, 2, 1, 0, 0, 0, 0, 4, 0, 0, 3, 3, -}}; -std::array pHiredNPCsIconsOffsetsX = {489, 559}; -std::array pHiredNPCsIconsOffsetsY = {152, 152}; -std::array Party_Spec_Motion_status_ids = {7, 18}; //dword_4EE07C -std::array<__int16, 101> word_4EE088_sound_ids = -{{ - 0, 10000, 10010, 10020, 10030, 10040, 10050, 10060, 10070, 10080, - 10090, 10100, 11000, 11010, 11020, 11030, 11040, 11050, 11060, 11070, - 11080, 11090, 11100, 12000, 12010, 12020, 12030, 12040, 12050, 12060, - 12070, 12080, 12090, 12100, 13000, 13010, 13020, 13030, 13040, 13050, - 13060, 13070, 13080, 13090, 13100, 14000, 14010, 14020, 14030, 14040, - 14050, 14060, 14070, 14080, 14090, 14100, 15000, 15010, 15020, 15030, - 15040, 15050, 15060, 15070, 15080, 15090, 15100, 16000, 16010, 16020, - 16030, 16040, 16050, 16060, 16070, 16080, 16090, 16100, 17000, 17010, - 17020, 17030, 17040, 17050, 17060, 17070, 17080, 17090, 17100, 18000, - 18010, 18020, 18030, 18040, 18050, 18060, 18070, 18080, 18090, 18100, - 1 -}}; -std::array word_4EE150 = -{{ - 1, 2, 3, 4, 5, 7, 32, 33, 36, 37, 38, 40, 41, 42, 43, 45, 46, - 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 60 -}}; - -int ScreenshotFileNumber; // dword_4EFA80 -std::array off_4F03B8 = -{{ - "", "WEPNTABL", "ARMORY", "MAGSHELF", - "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", - "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", - "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", - "MAGSHELF", "MAGSHELF", "MAGSHELF" -}}; - -std::array guild_mambership_flags={{ - 54, 54, 54, 54, 52, 52, 52, 52, 55, 55, 55, 55, 53, 53, - 53, 53, 58, 58, 58, 58, 57, 57, 57, 57, 56, 56, - 56, 56, 59, 59, 60, 60}}; -std::array<__int16, 49> word_4F0754; -std::array<__int16, 54> _4F0882_evt_VAR_PlayerItemInHands_vals = -{{ - 0x0D4, 0x270, 0x0D5, 0x21C, 0x0D6, 0x2BE, 0x0D7, 0x2BD, 0x0D8, 0x289, - 0x0D9, 0x258, 0x0DA, 0x2AB, 0x0DB, 0x281, 0x0DC, 0x280, 0x0DD, - 0x284, 0x0DE, 0x285, 0x0DF, 0x283, 0x0E0, 0x282, 0x0E1, 0x27F, - 0x0E2, 0x1E7, 0x0E3, 0x287, 0x0E4, 0x272, 0x0E5, 0x267, 0x0E6, - 0x275, 0x0E7, 0x25A, 0x0E8, 0x2A4, 0x0E9, 0x2A5, 0x0EA, 0x2A3, - 0x0EB, 0x25C, 0x0EC, 0x25D, 0x0ED, 0x259, 0x0F1, 0x21E -}}; -std::array pMaxLevelPerTrainingHallType = {5, 15, 25, 25, 200, 200}; - -std::array price_for_membership={100, 100, 50, 50, 50, 50, 50, 50, 50, 1000, 1000}; // weak - - -std::array<__int16, 32> word_4F0F30 ={{ 4, 7, 10, 11, - 4, 7, 10, 11, - 4, 7, 10, 11, - 4, 7, 10, 11, - 4, 7, 10, 11, - 4, 7, 10, 11, - 4, 7, 10, 11, - 7, 11, - 7, 11}}; -std::array ai_array_4F5E68; -std::array ai_array_4F6638_actor_ids; -std::array ai_near_actors_targets_pid; -int ai_arrays_size; // weak -std::array ai_near_actors_distances; -std::array ai_near_actors_ids; -std::array dword_4F8580 = {}; // weak - -char byte_4FAA24; // weak -//HWND dword_4FAA28; // idb - -std::array pSRZBufferLineOffsets; -int areWeLoadingTexture; // weak -std::array books_num_items_per_page; // weak -int lloyds_beacon_spell_id; // dword_506338 -int lloyds_beacon_sound_id; // dword_50633C -signed int sRecoveryTime; // idb -unsigned int uRequiredMana; // idb -int _506348_current_lloyd_playerid; // weak -__int64 lloyds_beacon_spell_level; // qword_506350 -char byte_506360; // weak -int dword_506364; // weak -unsigned int uExitCancelTextureId; -int books_page_number; // weak -int books_primary_item_per_page; // weak -int Autonotes_Instructors_page_flag; // dword_50652C -int Autonotes_Misc_page_flag; //dword_506530 -int Book_PageBtn6_flag; //dword_506534 -int Book_PageBtn5_flag; //dword_506538 -int Book_PageBtn4_flag; // dword_50653C -int Book_PageBtn3_flag; //dword_506540 -int BtnDown_flag; //BtnDown_flag -int BtnUp_flag; //BtnUp_flag -int quick_spell_at_page; // weak -char byte_506550; // weak -std::array aMoonPhaseNames; -int _506568_autonote_type; // weak -char bRecallingBeacon; // weak -int uLastPointedObjectID; // weak -//unsigned __int8 bMonsterInfoUI_bDollInitialized; -std::array aSpellNames; -int pMainScreenNum; // weak -int dword_506980_uW; // weak -int dword_506984_uZ; // weak -int dword_506988_uY; // weak -int dword_50698C_uX; // weak -int uGameMenuUI_CurentlySelectedKeyIdx; // 506E68 -std::array pPrevVirtualCidesMapping; -int KeyboardPageNum; // weak -int uRestUI_FoodRequiredToRest; -int dword_506F14; // weak -int _506F18_num_minutes_to_sleep; // weak -int dword_506F1C; // weak -std::array pVisibleWindowsIdxs; // weak -int uNumVisibleWindows; -char bFlashHistoryBook; // weak -char bFlashAutonotesBook; // weak -char bFlashQuestBook; // weak -int uTextureID_PlayerBuff_PainReflection; // weak -int uTextureID_PlayerBuff_Hammerhands; // weak -int uTextureID_PlayerBuff_Preservation; // weak -int uTextureID_PlayerBuff_Bless; // weak -int uTextureID_Btn_QuickReference; // weak -int uTextureID_Compas; // dword_5079B4 -int dword_5079C8; // weak -int dword_5079CC; // weak -int dword_5079D0; // weak -int uTextureID_Minimap_Loop; // dword_5079D8 -struct GUIButton *pBtn_ZoomOut; // idb -struct GUIButton *pBtn_ZoomIn; // idb -unsigned int uGameUIFontShadow; -unsigned int uGameUIFontMain; -int dword_507B00_spell_info_to_draw_in_popup; // weak -std::array aMonthNames; -std::array aDayNames; -std::array aSpellSchoolNames; -std::array aAttributeNames; -unsigned int uActiveCharacter; -int dword_507BF0_is_there_popup_onscreen; // weak -int awards_scroll_bar_created; // weak -int dword_507CC0_activ_ch; // weak -__int64 GameUI_RightPanel_BookFlashTimer; // weak -int _507CD4_RestUI_hourglass_anim_controller; // weak -bool OpenedTelekinesis; -std::array dword_50B570; // weak -std::array dword_50B638; // weak -stru367 PortalFace; -std::array dword_50BC10; // weak -std::array dword_50BDA0; // weak -std::array _50BF30_actors_in_viewport_ids; // weak -char town_portal_caster_id; // weak -int some_active_character; // weak -std::array pIconIDs_Turn; -unsigned int uIconID_TurnStop; -unsigned int uIconID_TurnHour; -int uIconID_CharacterFrame; // idb -unsigned int uIconID_TurnStart; -int dword_50C994 = 0; // weak -int dword_50C998_turnbased_icon_1A = 0; // weak -int uSpriteID_Spell11; // idb -bool _50C9A0_IsEnchantingInProgress; // weak -int _50C9A8_item_enchantment_timer = 0; // weak -int _50C9D0_AfterEnchClickEventId; // weak -int _50C9D4_AfterEnchClickEventSecondParam; // weak -int _50C9D8_AfterEnchClickEventTimeout; // weak -int dword_50C9DC; // weak -struct NPCData *ptr_50C9E0; -//int dword_50C9E8; // idb -//int dword_50C9EC[120]; // weak -int dword_50CDC8; -Vec3_int_ layingitem_vel_50FDFC; -char pStartingMapName[32]; // idb -std::array IsPlayerWearingWatersuit; -std::array party_has_equipment; -std::array byte_5111F6_OwnedArtifacts; - -unsigned int uNumBlueFacesInBLVMinimap; -std::array pBlueFacesInBLVMinimapIDs; -std::array pTextureIDs_PartyBuffIcons; -unsigned int uIconIdx_FlySpell; -unsigned int uIconIdx_WaterWalk; -int dword_576E28; // weak -int _576E2C_current_minimap_zoom; // weak -__int64 _5773B8_event_timer; // weak - - -int dword_591084; // weak -struct Actor *pDialogue_SpeakingActor; -unsigned int uDialogueType; -int sDialogue_SpeakingActorNPC_ID; -struct LevelDecoration *_591094_decoration; -std::array sHouseName; // idb -int uCurrentHouse_Animation; // weak -char *dword_591164_teleport_map_name; // idb -int dword_591168_teleport_speedz; // weak -int dword_59116C_teleport_directionx; // weak -int dword_591170_teleport_directiony; // weak -int dword_591174_teleportz; // weak -int dword_591178_teleporty; // weak -int dword_59117C_teleportx; // weak -std::array, 6> byte_591180; // idb -std::array HouseNPCData;//0 zero element holds standart house npc -GUIButton* HouseNPCPortraitsButtonsList[6];//dword_5913F4 -struct Texture *pTexture_591428; -struct Texture *pTexture_outside; // idb -struct Texture *pTexture_Dialogue_Background; -std::array byte_5B0938; -int EvtTargetObj; // 0x5B5920 -int _unused_5B5924_is_travel_ui_drawn = false; // 005B5924 -int _5B65A8_npcdata_uflags_or_other; // weak -int _5B65AC_npcdata_fame_or_other; // weak -int _5B65B0_npcdata_rep_or_other; // weak -int _5B65B4_npcdata_loword_house_or_other; // weak -int _5B65B8_npcdata_hiword_house_or_other; // weak -int dword_5B65BC; // weak -int dword_5B65C0; // weak -int dword_5B65C4_cancelEventProcessing; // weak -int MapsLongTimers_count; // dword_5B65C8 ñ÷¸ò÷èê òàéìåðîâ äëÿ êîëîäöåâ, ôàåðâîëîâ-ëîâóøåê -int npcIdToDismissAfterDialogue; // weak -signed int dword_5B65D0_dialogue_actor_npc_id; // weak -int dword_5C3418; // weak -int dword_5C341C; // weak -//std::array byte_5C3427; // weak -std::array GameUI_Footer_TimedString; -std::array pFooterString; -unsigned int GameUI_Footer_TimeLeft; -int bForceDrawFooter; // weak -int _5C35C0_force_party_death = false; // weak -int bDialogueUI_InitializeActor_NPC_ID; // weak -char *p2DEventsTXT_Raw; - -int dword_5C35D4; // weak -std::array aAMPMNames; -char byte_5C45AF[777]; // weak - -std::array pFinalMessage; // idb -std::array pTmpBuf; -std::array pTmpBuf2; -std::array Journal_limitation_factor; // weak -int ui_current_text_color; // weak -__int64 qword_5C6DF0; // weak -int dword_5C6DF8; // weak -std::array item__getname_buffer; // idb -std::array pClassDescriptions; -std::array pAttributeDescriptions; -std::array pGrandSkillDesc; -std::array pMasterSkillDesc; -std::array pExpertSkillDesc; -std::array pNormalSkillDesc; -std::array pSkillDesc; -char *pHealthPointsAttributeDescription; -char *pSpellPointsAttributeDescription; -char *pArmourClassAttributeDescription; -char *pPlayerConditionAttributeDescription; // idb -char *pFastSpellAttributeDescription; -char *pPlayerAgeAttributeDescription; -char *pPlayerLevelAttributeDescription; -char *pPlayerExperienceAttributeDescription; -char *pAttackBonusAttributeDescription; -char *pAttackDamageAttributeDescription; -char *pMissleBonusAttributeDescription; -char *pMissleDamageAttributeDescription; -char *pFireResistanceAttributeDescription; -char *pAirResistanceAttributeDescription; -char *pWaterResistanceAttributeDescription; -char *pEarthResistanceAttributeDescription; -char *pMindResistanceAttributeDescription; -char *pBodyResistanceAttributeDescription; -char *pSkillPointsAttributeDescription; -char *pClassTXT_Raw; -char *pStatsTXT_Raw; -char *pSkillDescTXT_Raw; - -struct FactionTable *pFactionTable; -//std::array byte_5C8D1A; // weak - -std::array byte_5E4C15; // weak -std::array pSomeItemsNames; - -char *pMonstersTXT_Raw; -char *pMonsterPlacementTXT_Raw; -char *pSpellsTXT_Raw; -char *pMapStatsTXT_Raw; -char *pHostileTXT_Raw; -char *pPotionsTXT_Raw; -char *pPotionNotesTXT_Raw; - -std::array _6807B8_level_decorations_ids; // idb -int _6807E0_num_decorations_with_sounds_6807B8; // weak -std::array event_triggers; // 6807E8 -size_t num_event_triggers; // 6836C8 -std::array dword_69B010; -float flt_69B138_dist; // weak -char byte_69BD41_unused; // weak -unsigned int uTextureID_x_u; -unsigned int uTextureID_LS_saveU; -unsigned int uTextureID_LS_loadU; -unsigned int uTextureID_AR_DN_DN; -unsigned int uTextureID_AR_UP_DN; -unsigned int uTextureID_LS_; -unsigned int uTextureID_x_d; -unsigned int uTextureID_save_up; -unsigned int uTextureID_load_up; -unsigned int uTextureID_loadsave; -int pSaveListPosition; // weak -unsigned int uLoadGameUI_SelectedSlot; -HWND hInsertCDWindow; // idb -int uCPUSpeed; // weak -char cMM7GameCDDriveLetter; // idb -MENU_STATE sCurrentMenuID; -unsigned int uGameState; -int uDefaultTravelTime_ByFoot; // weak -int day_attrib; // weak -int day_fogrange_1; // weak -int day_fogrange_2; // weak -struct TileTable *pTileTable; // idb -int outdoor_grid_band_1; // idb -int outdoor_grid_band_2; // idb -int outdoor_grid_band_3; // idb -std::array pDefaultSkyTexture; // idb -std::array byte_6BE124_cfg_textures_DefaultGroundTexture; // idb -int _6BE134_odm_main_tile_group; // weak -int dword_6BE138; // weak -int dword_6BE13C_uCurrentlyLoadedLocationID; // weak -float fWalkSpeedMultiplier = 1.0f; // weak -float fBackwardWalkSpeedMultiplier = 1.0f; // weak -float fTurnSpeedMultiplier = 1.0f; // weak -float flt_6BE150_look_up_down_dangle = 1.0f; // weak -//HWND hWnd; // idb -bool FORCE_16_BITS = false; -class OSWindow *window = nullptr; -char pCurrentMapName[32]; // idb -unsigned int uLevelMapStatsID; -int dword_6BE364_game_settings_1 = 0; -int dword_6BE368_debug_settings_2 = 0; -unsigned __int8 bCanLoadFromCD = false; -int bShowDamage; // idb -unsigned int bAlwaysRun; -unsigned int bFlipOnExit; -unsigned int uTurnSpeed; -float flt_6BE3A0 = 0.55000001f; // weak -float flt_6BE3A4_debug_recmod1; -float flt_6BE3A8_debug_recmod2; -float flt_6BE3AC_debug_recmod1_x_1_6; -std::array byte_6BE3B0; // idb -char bUnderwater = false; // weak -char bNoNPCHiring = false; // weak -unsigned int bNoVideo = false; -bool bNoIntro = false; -bool bNoLogo = false; -bool bNoCD = false; -bool bNoSound = false; -std::array dword_720020_zvalues; -std::array dword_7201B0_zvalues; -int uTextureID_720980; // weak -std::array<__int16, 104> word_7209A0_intercepts_ys_plus_ys; -std::array<__int16, 104> word_720A70_intercepts_xs_plus_xs; -std::array<__int16, 104> word_720B40_intercepts_zs; -std::array<__int16, 102> word_720C10_intercepts_xs; -std::array<__int16, 777> word_720CE0_ys; // idb -std::array<__int16, 777> word_720DB0_xs; // idb -std::array dword_720E80; -std::array dword_720ED0; -std::array ceiling_height_level; -std::array<__int16, 104> odm_floor_face_vert_coord_Y; // word_720F70 -std::array<__int16, 104> odm_floor_face_vert_coord_X; // word_721040 -std::array current_Face_id; // dword_721110 -std::array current_BModel_id; // dword_721160 -std::array odm_floor_level; // idb -int blv_prev_party_x; // weak -int blv_prev_party_z; // weak -int blv_prev_party_y; // weak -std::array pNPCTopics; -std::array pQuestTable; -char *dword_723718_autonote_related; // idb -std::array pScrolls; -int dword_7241C8; // weak -std::array aNPCProfessionNames; -char *pAwardsTXT_Raw; -char *pScrollsTXT_Raw; -char *pMerchantsTXT_Raw; -std::array pMerchantsBuyPhrases; -std::array pMerchantsSellPhrases; -std::array pMerchantsRepairPhrases; -std::array pMerchantsIdentifyPhrases; -char *pTransitionsTXT_Raw; -char *pAutonoteTXT_Raw; -char *pQuestsTXT_Raw; -unsigned int uNumTerrainNormals; -struct Vec3_float_ *pTerrainNormals; -std::array pTerrainNormalIndices; -std::array pTerrainSomeOtherData; -int dword_A74C88; // weak -unsigned int uPlayerCreationUI_SkySliderPos; -int uPlayerCreationUI_ArrowAnim; -unsigned int uPlayerCreationUI_SelectedCharacter; -int dword_A74CDC; // weak -struct Texture *pTexture_PlayerFaceMask; -struct Texture *pTexture_PlayerFaceEradicated; -struct Texture *pTexture_PlayerFaceDead; -std::array< std::array, 4> pTextures_PlayerFaces; -__int64 _A750D8_player_speech_timer; // qword_A750D8 -enum PlayerSpeech PlayerSpeechID; -int uSpeakingCharacter; // weak -std::array pClassNames; -std::array aCharacterConditionNames; -std::array pSkillNames; -char byte_AE5B91; // weak -std::array dword_F1B430; // weak -//int dword_F8B144; // nexindex [-1] to the following -std::array player_levels = {{1, 1, 1, 1}}; -std::array<__int16, 6> weapons_Ypos; // word_F8B158 -struct Texture *ShopTexture; // idb -std::array ItemsInShopTexture; -__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_MasteryBeingTaught; // weak -int gold_transaction_amount; // F8B1B4 -std::array pShopOptions; -int dword_F8B1D8; // weak -int dword_F8B1E0; // weak -int dword_F8B1E4; // weak -const char *current_npc_text; // idb -char dialogue_show_profession_details = false; // F8B1EC -std::array byte_F8B1EF; // weak -std::array byte_F8B1F0; - -int bGameoverLoop = 0; // weak -std::array<__int16, 104> intersect_face_vertex_coords_list_a; // word_F8BC48 -std::array<__int16, 104> intersect_face_vertex_coords_list_b; // word_F8BD18 \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 mm7_data.h --- a/mm7_data.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,791 +0,0 @@ -#pragma once -#include -#include "VectorTypes.h" -#include "OSAPI.h" -#include -#include -#include "NZIArray.h" - -//typedef char _UNKNOWN; -typedef unsigned int uint; - - -inline void __fastcall memset32(void *ptr, unsigned __int32 value, int count) -{ - unsigned __int32* p = (unsigned __int32 *)ptr; - for (int i = 0; i < count; i++) - *p++ = value; -} - - - - - - - - - - - -#if defined(__GNUC__) - typedef long long ll; - typedef unsigned long long ull; - #define __int64 long long - #define __int32 int - #define __int16 short - #define __int8 char - #define MAKELL(num) num ## LL - #define FMT_64 "ll" -#elif defined(_MSC_VER) - typedef __int64 ll; - typedef unsigned __int64 ull; - #define MAKELL(num) num ## i64 - #define FMT_64 "I64" -#elif defined (__BORLANDC__) - typedef __int64 ll; - typedef unsigned __int64 ull; - #define MAKELL(num) num ## i64 - #define FMT_64 "L" -#else - #error "unknown compiler" -#endif -typedef unsigned int uint; -typedef unsigned char uchar; -typedef unsigned short ushort; -typedef unsigned long ulong; - -typedef char int8; -typedef signed char sint8; -typedef unsigned char uint8; -typedef short int16; -typedef signed short sint16; -typedef unsigned short uint16; -typedef int int32; -typedef signed int sint32; -typedef unsigned int uint32; -typedef ll int64; -typedef ll sint64; -typedef ull uint64; - -// Partially defined types: -#define _BYTE uint8 -#define _WORD uint16 -#define _DWORD uint32 -#define _QWORD uint64 -#if !defined(_MSC_VER) -#define _LONGLONG __int128 -#endif - -#ifndef _WINDOWS_ -typedef int8 BYTE; -typedef int16 WORD; -typedef int32 DWORD; -typedef int32 LONG; -#endif -typedef int64 QWORD; -#ifndef __cplusplus -typedef int bool; // we want to use bool in our C programs -#endif - -// Some convenience macros to make partial accesses nicer -// first unsigned macros: -#ifdef HIBYTE -#undef HIBYTE -#endif // HIBYTE -#ifdef HIWORD -#undef HIWORD -#endif // HIWORD -#ifdef LOBYTE -#undef LOBYTE -#endif // LOBYTE -#ifdef LOWORD -#undef LOWORD -#endif // LOWORD - -#define LOBYTE(x) (*((_BYTE*)&(x))) // low byte -#define LOWORD(x) (*((_WORD*)&(x))) // low word -#define LODWORD(x) (*((_DWORD*)&(x))) // low dword -#define HIBYTE(x) (*((_BYTE*)&(x)+1)) -#define HIWORD(x) (*((_WORD*)&(x)+1)) -#define HIDWORD(x) (*((_DWORD*)&(x)+1)) -#define BYTEn(x, n) (*((_BYTE*)&(x)+n)) -#define WORDn(x, n) (*((_WORD*)&(x)+n)) -#define BYTE1(x) BYTEn(x, 1) // byte 1 (counting from 0) -#define BYTE2(x) BYTEn(x, 2) -#define BYTE3(x) BYTEn(x, 3) -#define BYTE4(x) BYTEn(x, 4) -#define BYTE5(x) BYTEn(x, 5) -#define BYTE6(x) BYTEn(x, 6) -#define BYTE7(x) BYTEn(x, 7) -#define BYTE8(x) BYTEn(x, 8) -#define BYTE9(x) BYTEn(x, 9) -#define BYTE10(x) BYTEn(x, 10) -#define BYTE11(x) BYTEn(x, 11) -#define BYTE12(x) BYTEn(x, 12) -#define BYTE13(x) BYTEn(x, 13) -#define BYTE14(x) BYTEn(x, 14) -#define BYTE15(x) BYTEn(x, 15) -#define WORD1(x) WORDn(x, 1) -#define WORD2(x) WORDn(x, 2) // third word of the object, unsigned -#define WORD3(x) WORDn(x, 3) -#define WORD4(x) WORDn(x, 4) -#define WORD5(x) WORDn(x, 5) -#define WORD6(x) WORDn(x, 6) -#define WORD7(x) WORDn(x, 7) - -// now signed macros (the same but with sign extension) -#define SLOBYTE(x) (*((int8*)&(x))) -#define SLOWORD(x) (*((int16*)&(x))) -#define SLODWORD(x) (*((int32*)&(x))) -#define SHIBYTE(x) (*((int8*)&(x)+1)) -#define SHIWORD(x) (*((int16*)&(x)+1)) -#define SHIDWORD(x) (*((int32*)&(x)+1)) -#define SBYTEn(x, n) (*((int8*)&(x)+n)) -#define SWORDn(x, n) (*((int16*)&(x)+n)) -#define SBYTE1(x) SBYTEn(x, 1) -#define SBYTE2(x) SBYTEn(x, 2) -#define SBYTE3(x) SBYTEn(x, 3) -#define SBYTE4(x) SBYTEn(x, 4) -#define SBYTE5(x) SBYTEn(x, 5) -#define SBYTE6(x) SBYTEn(x, 6) -#define SBYTE7(x) SBYTEn(x, 7) -#define SBYTE8(x) SBYTEn(x, 8) -#define SBYTE9(x) SBYTEn(x, 9) -#define SBYTE10(x) SBYTEn(x, 10) -#define SBYTE11(x) SBYTEn(x, 11) -#define SBYTE12(x) SBYTEn(x, 12) -#define SBYTE13(x) SBYTEn(x, 13) -#define SBYTE14(x) SBYTEn(x, 14) -#define SBYTE15(x) SBYTEn(x, 15) -#define SWORD1(x) SWORDn(x, 1) -#define SWORD2(x) SWORDn(x, 2) -#define SWORD3(x) SWORDn(x, 3) -#define SWORD4(x) SWORDn(x, 4) -#define SWORD5(x) SWORDn(x, 5) -#define SWORD6(x) SWORDn(x, 6) -#define SWORD7(x) SWORDn(x, 7) - - - -// Generate a reference to pair of operands -template int16 __PAIR__( int8 high, T low) { return ((( int16)high) << sizeof(high)*8) | uint8(low); } -template int32 __PAIR__( int16 high, T low) { return ((( int32)high) << sizeof(high)*8) | uint16(low); } -template int64 __PAIR__( int32 high, T low) { return ((( int64)high) << sizeof(high)*8) | uint32(low); } -template uint16 __PAIR__(uint8 high, T low) { return (((uint16)high) << sizeof(high)*8) | uint8(low); } -template uint32 __PAIR__(uint16 high, T low) { return (((uint32)high) << sizeof(high)*8) | uint16(low); } -template uint64 __PAIR__(uint32 high, T low) { return (((uint64)high) << sizeof(high)*8) | uint32(low); } - -// rotate left -template T __ROL__(T value, uint count) -{ - const uint nbits = sizeof(T) * 8; - count %= nbits; - - T high = value >> (nbits - count); - value <<= count; - value |= high; - return value; -} - -// rotate right -template T __ROR__(T value, uint count) -{ - const uint nbits = sizeof(T) * 8; - count %= nbits; - - T low = value << (nbits - count); - value >>= count; - value |= low; - return value; -} - -// carry flag of left shift -template int8 __MKCSHL__(T value, uint count) -{ - const uint nbits = sizeof(T) * 8; - count %= nbits; - - return (value >> (nbits-count)) & 1; -} - -// carry flag of right shift -template int8 __MKCSHR__(T value, uint count) -{ - return (value >> (count-1)) & 1; -} - -// sign flag -template int8 __SETS__(T x) -{ - if ( sizeof(T) == 1 ) - return int8(x) < 0; - if ( sizeof(T) == 2 ) - return int16(x) < 0; - if ( sizeof(T) == 4 ) - return int32(x) < 0; - return int64(x) < 0; -} - -// overflow flag of subtraction (x-y) -template int8 __OFSUB__(T x, U y) -{ - if ( sizeof(T) < sizeof(U) ) - { - U x2 = x; - int8 sx = __SETS__(x2); - return (sx ^ __SETS__(y)) & (sx ^ __SETS__(x2-y)); - } - else - { - T y2 = y; - int8 sx = __SETS__(x); - return (sx ^ __SETS__(y2)) & (sx ^ __SETS__(x-y2)); - } -} - -// overflow flag of addition (x+y) -template int8 __OFADD__(T x, U y) -{ - if ( sizeof(T) < sizeof(U) ) - { - U x2 = x; - int8 sx = __SETS__(x2); - return ((1 ^ sx) ^ __SETS__(y)) & (sx ^ __SETS__(x2+y)); - } - else - { - T y2 = y; - int8 sx = __SETS__(x); - return ((1 ^ sx) ^ __SETS__(y2)) & (sx ^ __SETS__(x+y2)); - } -} - -// carry flag of subtraction (x-y) -template int8 __CFSUB__(T x, U y) -{ - int size = sizeof(T) > sizeof(U) ? sizeof(T) : sizeof(U); - if ( size == 1 ) - return uint8(x) < uint8(y); - if ( size == 2 ) - return uint16(x) < uint16(y); - if ( size == 4 ) - return uint32(x) < uint32(y); - return uint64(x) < uint64(y); -} - -// carry flag of addition (x+y) -template int8 __CFADD__(T x, U y) -{ - int size = sizeof(T) > sizeof(U) ? sizeof(T) : sizeof(U); - if ( size == 1 ) - return uint8(x) > uint8(x+y); - if ( size == 2 ) - return uint16(x) > uint16(x+y); - if ( size == 4 ) - return uint32(x) > uint32(x+y); - return uint64(x) > uint64(x+y); -} - - -//------------------------------------------------------------------------- -// Data declarations - -extern int game_starting_year; -extern unsigned int game_viewport_width; -extern unsigned int game_viewport_height; -extern int game_viewport_x; -extern int game_viewport_y; -extern int game_viewport_z; -extern int game_viewport_w; - -extern int pWindowList_at_506F50_minus1_indexing[1]; -extern int dword_4C9890[10]; // weak -extern int dword_4C9920[16]; // weak -extern char byte_4D864C; // weak -extern float flt_4D86CC; // weak -extern int dword_4D86D8; // weak - - -extern float flt_4D84E8; - -extern int pCurrentScreen; // 004E28F8 -extern unsigned int uGammaPos; -extern std::array BtnTurnCoord; -extern std::array<__int16, 4> RightClickPortraitXmin; -extern std::array<__int16, 4> RightClickPortraitXmax; -//extern int pArmorSkills[5]; -//extern int pWeaponSkills[9]; -//extern int pMiscSkills[12]; -//extern int pMagicSkills[9]; -extern std::array pHealthBarPos; -extern std::array pManaBarPos; -//extern std::array _4E2B21_buff_spell_tooltip_colors; -extern std::array monster_popup_y_offsets; // weak -extern unsigned char hourglass_icon_idx; // weak - - -extern const char *format_4E2D80; -extern char format_4E2D90[8]; -extern const char *format_4E2DE8; // idb -extern const char *Stat_string_format_2_column_text; -extern const char *Stat_string_format_2_column_less_100; // format text of resistance in Stats screen -extern const char *Stat_string_format_2_column_over_100; -extern int dword_4E455C; // weak -extern std::array dword_4E4560; -extern std::array dword_4E4578; -extern std::array dword_4E4590; -extern std::array dword_4E45A8; -extern std::array flt_4E4A80; - -extern std::array< std::array, 14> pPartySpellbuffsUI_XYs; -extern std::array byte_4E5DD8; // weak -extern std::array pPartySpellbuffsUI_smthns; -extern std::array< std::array, 6> pNPCPortraits_x; // 004E5E50 -extern std::array< std::array, 6> pNPCPortraits_y; // 004E5EE0 -extern std::array pHouse_ExitPictures; -extern std::array _4E6BDC_loc_names; -extern std::array<__int16, 11> word_4E8152; -extern std::array< std::array, 7> byte_4E8168; -extern char _4E94D0_light_type; // weak -extern char _4E94D2_light_type; // weak -extern char _4E94D3_light_type; // weak -extern std::array saveload_dlg_xs; -extern std::array saveload_dlg_ys; -extern std::array saveload_dlg_zs; -extern std::array saveload_dlg_ws; -extern int dword_4E98BC_bApplicationActive; // weak -extern std::array pTransitionStrings; // 4EB080 -extern std::array dword_4EC268; // weak -extern std::array dword_4EC28C; // weak -extern std::array pPlayerPortraitsNames; - -extern std::array< std::array, 48> byte_4ECF08; -extern std::array, 110> SoundSetAction; // weak -extern std::array<__int16, 4> pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing; -extern std::array< std::array, 36> byte_4ED970_skill_learn_ability_by_class_table; -extern std::array pHiredNPCsIconsOffsetsX; -extern std::array pHiredNPCsIconsOffsetsY; -extern std::array Party_Spec_Motion_status_ids; //dword_4EE07C -extern std::array<__int16, 101> word_4EE088_sound_ids; // weak -extern std::array word_4EE150; -extern int ScreenshotFileNumber; // dword_4EFA80 -extern std::array off_4F03B8; // idb -extern __int16 word_4F0576[]; // weak - -extern std::array guild_mambership_flags; -extern std::array<__int16, 49> word_4F0754; -extern std::array<__int16, 54> _4F0882_evt_VAR_PlayerItemInHands_vals; -extern std::array pMaxLevelPerTrainingHallType; -extern std::array price_for_membership; // weak -extern std::array<__int16, 32> word_4F0F30; // weak -extern std::array ai_array_4F5E68; -extern std::array ai_array_4F6638_actor_ids; -extern std::array ai_near_actors_targets_pid; -extern int ai_arrays_size; // weak -extern std::array ai_near_actors_distances; -extern std::array ai_near_actors_ids; -extern std::array dword_4F8580; // weak -extern int dword_4FA9B0[]; // weak -extern int dword_4FA9B4[]; // weak - -extern char byte_4FAA24; // weak -//extern HWND dword_4FAA28; // idb - -extern std::array pSRZBufferLineOffsets; -extern int areWeLoadingTexture; // weak -extern std::array books_num_items_per_page; // weak -extern int lloyds_beacon_spell_id; // dword_506338 -extern int lloyds_beacon_sound_id; // dword_50633C -extern signed int sRecoveryTime; // idb -extern unsigned int uRequiredMana; // idb -extern int _506348_current_lloyd_playerid; // weak -extern __int64 lloyds_beacon_spell_level; // qword_506350 -extern char byte_506360; // weak -extern int dword_506364; // weak -//extern Texture *dword_50640C[]; // weak -extern unsigned int uExitCancelTextureId; -extern int books_page_number; // number for page in books(íîìåð ñòðàíèöû â êíèãàõ) -extern int books_primary_item_per_page; // number primary item in book page(íîìåð íà÷àëüíîé çàïèñè íà ñòðàíèöå) -extern int Autonotes_Instructors_page_flag; // dword_50652C -extern int Autonotes_Misc_page_flag; //dword_506530 -extern int Book_PageBtn6_flag; //dword_506534 -extern int Book_PageBtn5_flag; //dword_506538 -extern int Book_PageBtn4_flag; //dword_50653C -extern int Book_PageBtn3_flag; //dword_506540 -extern int BtnDown_flag; //BtnDown_flag -extern int BtnUp_flag; //BtnUp_flag -extern int quick_spell_at_page; // weak -extern char byte_506550; // weak -extern std::array aMoonPhaseNames; -extern int _506568_autonote_type; // 506568 -extern char bRecallingBeacon; // weak -extern int uLastPointedObjectID; // weak -//extern unsigned __int8 bMonsterInfoUI_bDollInitialized; -extern std::array aSpellNames; -extern int pMainScreenNum; // weak -extern int dword_506980_uW; // weak -extern int dword_506984_uZ; // weak -extern int dword_506988_uY; // weak -extern int dword_50698C_uX; // weak -extern int uGameMenuUI_CurentlySelectedKeyIdx; // 506E68 -extern std::array GameMenuUI_InvaligKeyBindingsFlags; // 506E6C -extern std::array pPrevVirtualCidesMapping; -extern int KeyboardPageNum; // weak -extern int uRestUI_FoodRequiredToRest; -extern int dword_506F14; // weak -extern int _506F18_num_minutes_to_sleep; // weak -extern int dword_506F1C; // weak -extern std::array pVisibleWindowsIdxs; // weak -extern int uNumVisibleWindows; -extern char bFlashHistoryBook; // weak -extern char bFlashAutonotesBook; // weak -extern char bFlashQuestBook; // weak -extern int uTextureID_PlayerBuff_PainReflection; // weak -extern int uTextureID_PlayerBuff_Hammerhands; // weak -extern int uTextureID_PlayerBuff_Preservation; // weak -extern int uTextureID_PlayerBuff_Bless; // weak -extern int uTextureID_Btn_QuickReference; // weak -extern int uTextureID_Compas; // dword_5079B4 -extern int dword_5079C8; // weak -extern int dword_5079CC; // weak -extern int dword_5079D0; // weak -extern int uTextureID_Minimap_Loop; // dword_5079D8 -extern struct GUIButton *pBtn_ZoomOut; // idb -extern struct GUIButton *pBtn_ZoomIn; // idb -extern unsigned int uGameUIFontShadow; -extern unsigned int uGameUIFontMain; -extern int dword_507B00_spell_info_to_draw_in_popup; // weak -extern std::array aMonthNames; -extern std::array aDayNames; -extern std::array aSpellSchoolNames; -extern std::array aAttributeNames; -extern unsigned int uActiveCharacter; -extern int dword_507BF0_is_there_popup_onscreen; // weak -extern int awards_scroll_bar_created; // weak -extern int dword_507CC0_activ_ch; // weak -extern __int64 GameUI_RightPanel_BookFlashTimer; // weak -extern int _507CD4_RestUI_hourglass_anim_controller; // weak -extern bool OpenedTelekinesis; // weak -extern std::array dword_50B570; // weak -extern std::array dword_50B638; // weak -extern struct stru367 PortalFace; -extern std::array dword_50BC10; // weak -extern std::array dword_50BDA0; // weak -extern std::array _50BF30_actors_in_viewport_ids; // weak -extern char town_portal_caster_id; // weak -extern int some_active_character; // weak -extern std::array pIconIDs_Turn; -extern unsigned int uIconID_TurnStop; -extern unsigned int uIconID_TurnHour; -extern int uIconID_CharacterFrame; // idb -extern unsigned int uIconID_TurnStart; -extern int dword_50C994; // weak -extern int dword_50C998_turnbased_icon_1A; // weak -extern int uSpriteID_Spell11; // idb -extern bool _50C9A0_IsEnchantingInProgress; // weak -extern int _50C9A8_item_enchantment_timer; // weak -extern int _50C9D0_AfterEnchClickEventId; // weak -extern int _50C9D4_AfterEnchClickEventSecondParam; // weak -extern int _50C9D8_AfterEnchClickEventTimeout; // weak -extern int dword_50C9DC; // weak -extern struct NPCData *ptr_50C9E0; -//extern int dword_50C9E8; // idb -//extern int dword_50C9EC[]; // 50C9EC -extern int dword_50CDC8; -extern Vec3_int_ layingitem_vel_50FDFC; -extern char pStartingMapName[32]; // idb -extern std::array IsPlayerWearingWatersuit; -extern std::array party_has_equipment; -extern std::array byte_5111F6_OwnedArtifacts; -extern std::array papredoll_dbrds; - -extern int bRingsShownInCharScreen; // weak - -extern unsigned int uNumBlueFacesInBLVMinimap; -extern std::array pBlueFacesInBLVMinimapIDs; -extern std::array pTextureIDs_PartyBuffIcons; -extern unsigned int uIconIdx_FlySpell; -extern unsigned int uIconIdx_WaterWalk; -extern int dword_576E28; // weak -extern int _576E2C_current_minimap_zoom; // weak -extern __int64 _5773B8_event_timer; // weak - -extern int dword_591084; // weak -extern struct Actor *pDialogue_SpeakingActor; -extern unsigned int uDialogueType; -extern signed int sDialogue_SpeakingActorNPC_ID; -extern struct LevelDecoration *_591094_decoration; -extern std::array sHouseName; // idb -extern int uCurrentHouse_Animation; // weak -extern char *dword_591164_teleport_map_name; // idb -extern int dword_591168_teleport_speedz; // weak -extern int dword_59116C_teleport_directionx; // weak -extern int dword_591170_teleport_directiony; // weak -extern int dword_591174_teleportz; // weak -extern int dword_591178_teleporty; // weak -extern int dword_59117C_teleportx; // weak -extern std::array, 6> byte_591180; // idb -extern std::array HouseNPCData; //0this array size temporarily increased to 60 from 6 to work aroud house overflow -extern GUIButton* HouseNPCPortraitsButtonsList[6]; -extern struct Texture *pTexture_591428; -extern struct Texture *pTexture_outside; // idb -extern struct Texture *pTexture_Dialogue_Background; -extern std::array byte_5B0938; -extern int EvtTargetObj; // weak -extern int _unused_5B5924_is_travel_ui_drawn; // 005B5924 -extern int _5B65A8_npcdata_uflags_or_other; // weak -extern int _5B65AC_npcdata_fame_or_other; // weak -extern int _5B65B0_npcdata_rep_or_other; // weak -extern int _5B65B4_npcdata_loword_house_or_other; // weak -extern int _5B65B8_npcdata_hiword_house_or_other; // weak -extern int dword_5B65BC; // weak -extern int dword_5B65C0; // weak -extern int dword_5B65C4_cancelEventProcessing; // weak -extern int MapsLongTimers_count; // dword_5B65C8 -extern int npcIdToDismissAfterDialogue; // weak -extern int dword_5B65D0_dialogue_actor_npc_id; // weak -extern int dword_5C3418; // weak -extern int dword_5C341C; // weak -//extern std::array byte_5C3427; // weak -extern std::array GameUI_Footer_TimedString; -extern std::array pFooterString; -extern unsigned int GameUI_Footer_TimeLeft; -extern int bForceDrawFooter; // weak -extern int _5C35C0_force_party_death; // weak -extern int bDialogueUI_InitializeActor_NPC_ID; // weak -extern char *p2DEventsTXT_Raw; - -extern int dword_5C35D4; // weak -extern std::array aAMPMNames; -extern char byte_5C45AF[]; // weak -extern std::array pTmpBuf3; -extern std::array pFinalMessage; // idb -extern std::array pTmpBuf; -extern std::array pTmpBuf2; -extern std::array Journal_limitation_factor; // weak -extern int ui_current_text_color; // weak -extern __int64 qword_5C6DF0; // weak -extern int dword_5C6DF8; // weak -extern std::array item__getname_buffer; // idb -extern std::array pClassDescriptions; -extern std::array pAttributeDescriptions; -extern std::array pGrandSkillDesc; -extern std::array pMasterSkillDesc; -extern std::array pExpertSkillDesc; -extern std::array pNormalSkillDesc; -extern std::array pSkillDesc; -extern char *pHealthPointsAttributeDescription; -extern char *pSpellPointsAttributeDescription; -extern char *pArmourClassAttributeDescription; -extern char *pPlayerConditionAttributeDescription; // idb -extern char *pFastSpellAttributeDescription; -extern char *pPlayerAgeAttributeDescription; -extern char *pPlayerLevelAttributeDescription; -extern char *pPlayerExperienceAttributeDescription; -extern char *pAttackBonusAttributeDescription; -extern char *pAttackDamageAttributeDescription; -extern char *pMissleBonusAttributeDescription; -extern char *pMissleDamageAttributeDescription; -extern char *pFireResistanceAttributeDescription; -extern char *pAirResistanceAttributeDescription; -extern char *pWaterResistanceAttributeDescription; -extern char *pEarthResistanceAttributeDescription; -extern char *pMindResistanceAttributeDescription; -extern char *pBodyResistanceAttributeDescription; -extern char *pSkillPointsAttributeDescription; -extern char *pClassTXT_Raw; -extern char *pStatsTXT_Raw; -extern char *pSkillDescTXT_Raw; -extern struct FactionTable *pFactionTable; -//extern std::array byte_5C8D1A; // weak - -extern std::array byte_5E4C15; // weak -extern std::array pSomeItemsNames; - -extern char *pMonstersTXT_Raw; -extern char *pMonsterPlacementTXT_Raw; -extern char *pSpellsTXT_Raw; -extern char *pMapStatsTXT_Raw; -extern char *pHostileTXT_Raw; -extern char *pPotionsTXT_Raw; -extern char *pPotionNotesTXT_Raw; - -extern std::array _6807B8_level_decorations_ids; // idb -extern int _6807E0_num_decorations_with_sounds_6807B8; // weak -extern std::array event_triggers; // 6807E8 -extern size_t num_event_triggers; // 6836C8 -extern std::array dword_69B010; -extern float flt_69B138_dist; // weak -extern char byte_69BD41_unused; // weak -extern unsigned int uTextureID_x_u; -extern unsigned int uTextureID_LS_saveU; -extern unsigned int uTextureID_LS_loadU; -extern unsigned int uTextureID_AR_DN_DN; -extern unsigned int uTextureID_AR_UP_DN; -extern unsigned int uTextureID_LS_; -extern unsigned int uTextureID_x_d; -extern unsigned int uTextureID_save_up; -extern unsigned int uTextureID_load_up; -extern unsigned int uTextureID_loadsave; -extern int pSaveListPosition; // weak -extern unsigned int uLoadGameUI_SelectedSlot; -extern HWND hInsertCDWindow; // idb -extern int uCPUSpeed; // weak -extern char cMM7GameCDDriveLetter; // idb -extern enum MENU_STATE sCurrentMenuID; -extern unsigned int uGameState; -extern int uDefaultTravelTime_ByFoot; // weak -extern int day_attrib; // weak -extern int day_fogrange_1; // weak -extern int day_fogrange_2; // weak -extern struct TileTable *pTileTable; // idb -extern int outdoor_grid_band_1; // idb -extern int outdoor_grid_band_2; // idb -extern int outdoor_grid_band_3; // idb -extern std::array pDefaultSkyTexture; // idb -extern std::array byte_6BE124_cfg_textures_DefaultGroundTexture; // idb -extern int _6BE134_odm_main_tile_group; // weak -extern int dword_6BE138; // weak -extern int dword_6BE13C_uCurrentlyLoadedLocationID; // weak -extern float fWalkSpeedMultiplier; // weak -extern float fBackwardWalkSpeedMultiplier; // weak -extern float fTurnSpeedMultiplier; // weak -extern float flt_6BE150_look_up_down_dangle; // weak -//extern char pMM7WindowClassName[]; // idb -//extern HINSTANCE hInstance; // idb -//extern char *pCmdLine; -//extern HWND hWnd; // idb -extern char pCurrentMapName[32]; // idb -extern unsigned int uLevelMapStatsID; - -extern bool FORCE_16_BITS; // related to GAME_SETTINGS_INVALID_RESOLUTION -#define GAME_SETTINGS_0001 0x0001 -#define GAME_SETTINGS_INVALID_RESOLUTION 0x0002 -#define GAME_SETTINGS_NO_INTRO 0x0004 -#define GAME_SETTINGS_NO_LOGO 0x0008 -#define GAME_SETTINGS_NO_SOUND 0x0010 -#define GAME_SETTINGS_NO_WALK_SOUND 0x0020 -#define GAME_SETTINGS_NO_HOUSE_ANIM 0x0040 -#define GAME_SETTINGS_0080_SKIP_USER_INPUT_THIS_FRAME 0x0080 -#define GAME_SETTINGS_APP_INACTIVE 0x0100 -#define GAME_SETTINGS_0200_EVENT_TIMER 0x0200 -#define GAME_SETTINGS_0400_MISC_TIMER 0x0400 -#define GAME_SETTINGS_0800 0x0800 -#define GAME_SETTINGS_1000 0x1000 -#define GAME_SETTINGS_2000 0x2000 -#define GAME_SETTINGS_4000 0x4000 -extern int dword_6BE364_game_settings_1; // GAME_SETTINGS_* - -#define DEBUG_SETTINGS_RUN_IN_WIDOW 0x0001 -#define DEBUG_SETTINGS_0002_SHOW_FR 0x0002 -#define DEBUG_SETTINGS_NO_ACTORS 0x0004 -#define DEBUG_SETTINGS_NO_DECORATIONS 0x0008 -#define DEBUG_SETTINGS_NO_DAMAGE 0x0010 -extern int dword_6BE368_debug_settings_2; // DEBUG_SETTINGS_* - -extern unsigned __int8 bCanLoadFromCD; -extern int bShowDamage; // idb -extern unsigned int bAlwaysRun; -extern unsigned int bFlipOnExit; -extern unsigned int uTurnSpeed; -extern float flt_6BE3A0; // weak -extern float flt_6BE3A4_debug_recmod1; -extern float flt_6BE3A8_debug_recmod2; -extern float flt_6BE3AC_debug_recmod1_x_1_6; -extern std::array byte_6BE3B0; // idb -extern char bUnderwater; // weak -extern char bNoNPCHiring; // weak -extern unsigned int bNoVideo; -extern bool bNoIntro; -extern bool bNoLogo; -extern bool bNoCD; -extern bool bNoSound; -extern std::array dword_720020_zvalues; -extern std::array dword_7201B0_zvalues; -extern int uTextureID_720980; // weak -extern std::array<__int16, 104> word_7209A0_intercepts_ys_plus_ys; -extern std::array<__int16, 104> word_720A70_intercepts_xs_plus_xs; -extern std::array<__int16, 104> word_720B40_intercepts_zs; -extern std::array<__int16, 102> word_720C10_intercepts_xs; -extern std::array<__int16, 777> word_720CE0_ys; // idb -extern std::array<__int16, 777> word_720DB0_xs; // idb -extern std::array dword_720E80; -extern std::array dword_720ED0; -extern std::array ceiling_height_level; -extern std::array<__int16, 104> odm_floor_face_vert_coord_Y; // word_720F70 -extern std::array<__int16, 104> odm_floor_face_vert_coord_X; // word_721040 -extern std::array current_Face_id; // dword_721110 -extern std::array current_BModel_id; // dword_721160 -extern std::array odm_floor_level; // idb dword_7211B0 -extern int blv_prev_party_x; // weak -extern int blv_prev_party_z; // weak -extern int blv_prev_party_y; // weak -extern char *dword_722F10; // idb -extern std::array pQuestTable; -extern char *dword_723718_autonote_related; // idb -extern std::array pScrolls; -extern int dword_7241C8; // weak - -extern std::array aNPCProfessionNames; -extern char *pAwardsTXT_Raw; -extern char *pScrollsTXT_Raw; -extern char *pMerchantsTXT_Raw; -extern std::array pMerchantsBuyPhrases; -extern std::array pMerchantsSellPhrases; -extern std::array pMerchantsRepairPhrases; -extern std::array pMerchantsIdentifyPhrases; -extern char *pTransitionsTXT_Raw; -extern char *pAutonoteTXT_Raw; -extern char *pQuestsTXT_Raw; -extern unsigned int uNumTerrainNormals; -extern struct Vec3_float_ *pTerrainNormals; -extern std::array pTerrainNormalIndices; -extern std::array pTerrainSomeOtherData; -extern int dword_A74C88; // weak -extern unsigned int uPlayerCreationUI_SkySliderPos; -extern int uPlayerCreationUI_ArrowAnim; -extern unsigned int uPlayerCreationUI_SelectedCharacter; -extern int dword_A74CDC; // weak -extern struct Texture *pTexture_PlayerFaceMask; -extern struct Texture *pTexture_PlayerFaceEradicated; -extern struct Texture *pTexture_PlayerFaceDead; -extern std::array< std::array, 4> pTextures_PlayerFaces; -extern __int64 _A750D8_player_speech_timer; // qword_A750D8 -extern enum PlayerSpeech PlayerSpeechID; -extern int uSpeakingCharacter; // weak -extern std::array pClassNames; -extern std::array aCharacterConditionNames; -extern std::array pSkillNames; -extern char byte_AE5B91; // weak -extern std::array dword_F1B430; // weak -extern std::array player_levels; -extern std::array<__int16, 6> weapons_Ypos; // word_F8B158 -extern struct Texture *ShopTexture; // idb -extern std::array ItemsInShopTexture; -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_MasteryBeingTaught; // weak -extern int gold_transaction_amount; // F8B1B4 -extern std::array pShopOptions; -extern int dword_F8B1D8; // weak -extern int dword_F8B1E0; // weak -extern int dword_F8B1E4; // weak -extern const char *current_npc_text; // 0xF8B1E8 -extern char dialogue_show_profession_details; // weak -extern std::array byte_F8B1EF; // weak -extern std::array byte_F8B1F0; - -extern int bGameoverLoop; // weak -extern std::array<__int16, 104> intersect_face_vertex_coords_list_a; // word_F8BC48 -extern std::array<__int16, 104> intersect_face_vertex_coords_list_b; // word_F8BD18 -extern bool wizard_eye; -extern bool change_seasons; -extern bool all_magic; -extern bool debug_information; -extern bool show_picked_face; -extern bool draw_portals_loops; -extern bool new_speed; -extern bool bSnow; -extern bool draw_terrain_dist_mist; diff -r 92eeeb5200f2 -r 68cdef6879a0 mm7text_ru.cpp --- a/mm7text_ru.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1439 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include -#include -#include - -#include "Log.h" -#include "ErrorHandling.h" - - -struct GenderTableEntry -{ - const char *name; - int gender; -} gender_table_caps[] = -{ - {"Àâåëü", 0}, - {"Àäàì", 0}, - {"Àäðèàí", 0}, - {"Àäðèàíèñ", 0}, - {"Àäñêàÿ", 1}, - {"Àéð", 0}, - {"Àêèî", 0}, - {"Àêèðà", 0}, - {"Àëàí", 0}, - {"Àëåéí", 0}, - {"Àëåê", 0}, - {"Àëåêñàíäð", 0}, - {"Àëåêñèñ", 1}, - {"Àëåí", 0}, - {"Àëåõàíäðî", 0}, - {"Àëèñà", 1}, - {"Àëüáåðò", 0}, - {"Àëüòîí", 0}, - {"Àëüòðåä", 0}, - {"Àëüôðåä", 0}, - {"Àìàíäà", 1}, - {"Àìáåð", 1}, - {"Àìáðîçèé", 0}, - {"Àìåëèÿ", 1}, - {"Àìîñ", 0}, - {"Àíãåë", 0}, - {"Àíäðåà", 1}, - {"Àíäðåé", 0}, - {"Àíæåëà", 1}, - {"Àíèòà", 1}, - {"Àííà", 1}, - {"Àíòîí", 0}, - {"Àíòîíèé", 0}, - {"Àðáè", 0}, - {"Àðäà", 0}, - {"Àðäåí", 0}, - {"Àðåíà", 1}, - {"Àðèñòåé", 0}, - {"Àðèñòèäèñ", 0}, - {"Àðèõ", 0}, - {"Àðèýëü", 0}, - {"Àðëåí", 0}, - {"Àðëî", 0}, - {"Àðìàíä", 0}, - {"Àðíîëüä", 0}, - {"Àðîí", 0}, - {"Àðòóð", 0}, - {"Àðõàíãåë", 0}, - {"Àðõèìàã", 0}, - {"Àõìåä", 0}, - {"Á¸ðòîí", 0}, - {"Áàä", 0}, - {"Áàéðîí", 0}, - {"Áàíäèò", 0}, - {"Áàð", 0}, - {"Áàðáàðà", 1}, - {"Áàðåòò", 0}, - {"Áàðò", 0}, - {"Áàò÷", 0}, - {"Áåàòðèñ", 1}, - {"Áåâåðëè", 1}, - {"Áåêè", 1}, - {"Áåëèíäà", 1}, - {"Áåí", 0}, - {"Áåíäæàìèí", 0}, - {"Áåíåäèêò", 0}, - {"Áåíèòî", 0}, - {"Áåííåò", 0}, - {"Áåííè", 0}, - {"Áåíóà", 0}, - {"Áåðíàäåòòà", 1}, - {"Áåðíàðä", 0}, - {"Áåðíè", 0}, - {"Áåðíèñ", 1}, - {"Áåðíó÷î", 0}, - {"Áåðò", 0}, - {"Áåðòðàí", 0}, - {"Áåò", 1}, - {"Áåòñè", 1}, - {"Áåòòè", 1}, - {"Áèëëè", 0}, - {"Áèëëèñ", 1}, - {"Áèøîï", 0}, - {"Áëåéê", 0}, - {"Áëåéí", 0}, - {"Áëîíäî", 0}, - {"Áî", 0}, - {"Áîá", 0}, - {"Áîááè", 0}, - {"Áîäî", 0}, - {"Áîëîòíûé", 0}, - {"Áîëüøîé", 0}, - {"Áîííè", 1}, - {"Áîðåãàðä", 0}, - {"Áîðèñ", 0}, - {"Áðàäåí", 0}, - {"Áðàéñ", 0}, - {"Áðàò", 0}, - {"Áðåéí", 0}, - {"Áðåíäà", 1}, - {"Áðåíäîí", 0}, - {"Áðåíò", 0}, - {"Áðåò", 0}, - {"Áðîíâèí", 0}, - {"Áðîíçîâûé", 0}, - {"Áðóê", 0}, - {"Áðóíî", 0}, - {"Áðýä", 0}, - {"Áðýäëè", 0}, - {"Áðýäôîðä", 0}, - {"Áðýíäîí", 0}, - {"Áðþñ", 0}, - {"Áóôîðä", 0}, - {"Âàäèì", 0}, - {"Âàë", 0}, - {"Âàëåðèÿ", 1}, - {"Âàëüòåð", 0}, - {"Âàíäà", 1}, - {"Âàíåññà", 1}, - {"Âàíåòòà", 1}, - {"Âàíñ", 0}, - {"Âåéí", 0}, - {"Âåëèêèé", 0}, - {"Âåíäåëë", 0}, - {"Âåíäè", 1}, - {"Âåðà", 1}, - {"Âåðí", 0}, - {"Âåðíîí", 0}, - {"Âåðîíèêà", 1}, - {"Âåðõîâíàÿ", 1}, - {"Âåñëè", 0}, - {"Âèâåðí", 0}, - {"Âèâüåí", 1}, - {"Âèêè", 1}, - {"Âèêòîð", 0}, - {"Âèêòîðèñ", 0}, - {"Âèêòîðèÿ", 1}, - {"Âèëàì", 0}, - {"Âèëë", 0}, - {"Âèëëàðä", 0}, - {"Âèëüìà", 1}, - {"Âèëüôðåä", 0}, - {"Âèëüÿì", 0}, - {"Âèííûé", 0}, - {"Âèíñòîí", 0}, - {"Âèí÷åíöî", 0}, - {"Âèîëåò", 1}, - {"Âèðãèëèé", 0}, - {"Âèðãèíèÿ", 1}, - {"Âèõðü", 0}, - {"Âëàäèìèð", 0}, - {"Âëàñòåëèí", 0}, - {"Âîäíûé", 0}, - {"Âîåííîå", 2}, - {"Âîçäóøíàÿ", 1}, - {"Âîçäóøíûé", 0}, - {"Âîëõâ", 0}, - {"Âîëüã", 0}, - {"Âîññòàâøèé", 0}, - {"Âðàòà", 1}, - {"Âóäðî", 0}, - {"Âóðäàëàê", 0}, - {"Âûñøàÿ", 1}, - {"Âýéä", 0}, - {"Ãàáðèýëü", 0}, - {"Ãàé", 0}, - {"Ãàíñ", 0}, - {"Ãàðåò", 0}, - {"Ãàðè", 0}, - {"Ãàðïèÿ", 1}, - {"Ãàððè", 0}, - {"Ãâåíäîëèí", 1}, - {"Ãâåíí", 1}, - {"Ãåéá", 0}, - {"Ãåéë", 1}, - {"Ãåêòîð", 0}, - {"Ãåëüìóò", 0}, - {"Ãåíèêêè", 1}, - {"Ãåíðè", 0}, - {"Ãåîðãèíà", 1}, - {"Ãåðá", 0}, - {"Ãåðáåðò", 0}, - {"Ãåðìàí", 0}, - {"Ãåðòðóäà", 1}, - {"Ãåðö", 0}, - {"Ãèãàíòñêàÿ", 1}, - {"Ãèëüäèÿ", 1}, - {"Ãèëüåðìî", 0}, - {"Ãèëüìîð", 0}, - {"Ãèìíàñòè÷åñêèé", 0}, - {"Ãëàçèùå", 2}, - {"Ãëåí", 0}, - {"Ãëåíäà", 1}, - {"Ãëèíÿíûé", 0}, - {"Ãëîðèÿ", 1}, - {"Ãíèþùèé", 0}, - {"Ãíîì", 0}, - {"Ãîáëèí", 0}, - {"Ãîâàðä", 0}, - {"Ãîã", 0}, - {"Ãîìåð", 0}, - {"Ãîíçàëî", 0}, - {"Ãîðàöèé", 0}, - {"Ãîðäîí", 0}, - {"Ãîðíûé", 0}, - {"Ãðàáèòåëü", 0}, - {"Ãðàíò", 0}, - {"Ãðàõýì", 0}, - {"Ãðåã", 0}, - {"Ãðåãîðè", 0}, - {"Ãðåé", 0}, - {"Ãðåòõåí", 1}, - {"Ãðèôîí", 0}, - {"Ãðîçîâîé", 0}, - {"Ãóñ", 0}, - {"Äàâèä", 0}, - {"Äàéàíà", 1}, - {"Äàë", 0}, - {"Äàëëàñ", 0}, - {"Äàìèàí", 0}, - {"Äàíà", 1}, - {"Äàíèýëü", 0}, - {"Äàíòå", 0}, - {"Äàðà", 1}, - {"Äàðëèí", 1}, - {"Äàðîí", 0}, - {"Äàðñè", 1}, - {"Äàñòèí", 0}, - {"Äàôíà", 1}, - {"Äâàéò", 0}, - {"Äâåéí", 0}, - {"Äåàííà", 1}, - {"Äåááè", 1}, - {"Äåáîðà", 1}, - {"Äåâîí", 0}, - {"Äåéâ", 0}, - {"Äåéë", 0}, - {"Äåë", 0}, - {"Äåëîðèñ", 1}, - {"Äåíèñ", 1}, - {"Äåííè", 0}, - {"Äåïîçèòàðèé", 0}, - {"Äåðåâî", 2}, - {"Äåðåê", 0}, - {"Äåñìîíä", 0}, - {"Äæàíèñ", 1}, - {"Äæàñòèí", 0}, - {"Äæåä", 0}, - {"Äæåäàé", 0}, - {"Äæåé", 0}, - {"Äæåéê", 0}, - {"Äæåéìñ", 0}, - {"Äæåéí", 1}, - {"Äæåéñîí", 0}, - {"Äæåê", 0}, - {"Äæåêè", 1}, - {"Äæåìè", 0}, - {"Äæåíèôåð", 1}, - {"Äæåííè", 1}, - {"Äæåðàëüä", 0}, - {"Äæåðàëüäèíà", 1}, - {"Äæåðîì", 0}, - {"Äæåðîìè", 0}, - {"Äæåððè", 0}, - {"Äæåññ", 0}, - {"Äæåññà", 1}, - {"Äæåññèêà", 1}, - {"Äæåòàíî", 0}, - {"Äæèì", 0}, - {"Äæèí", 1}, - {"Äæèíà", 1}, - {"Äæèíæåð", 1}, - {"Äæèííè", 1}, - {"Äæèíî", 0}, - {"Äæî", 2}, - {"Äæîàí", 1}, - {"Äæîàíí", 1}, - {"Äæîàííà", 1}, - {"Äæîçåô", 0}, - {"Äæîé", 0}, - {"Äæîéñ", 1}, - {"Äæîéñèí", 1}, - {"Äæîí", 0}, - {"Äæîíàòàí", 0}, - {"Äæîðäæ", 0}, - {"Äæîó", 0}, - {"Äæîøóà", 0}, - {"Äæîýëü", 0}, - {"Äæóä", 0}, - {"Äæóäè", 1}, - {"Äæóäèñ", 1}, - {"Äæóëè", 1}, - {"Äæóí", 1}, - {"Äèàíà", 1}, - {"Äèëàí", 0}, - {"Äèí", 0}, - {"Äèòåð", 0}, - {"Äîäðèäæ", 0}, - {"Äîê", 0}, - {"Äîëîðåñ", 1}, - {"Äîëüô", 0}, - {"Äîì", 0}, - {"Äîìèíèê", 0}, - {"Äîìèíèêà", 1}, - {"Äîí", 0}, - {"Äîíàéñ", 1}, - {"Äîíàëüä", 0}, - {"Äîííà", 1}, - {"Äîðèí", 1}, - {"Äîðèñ", 1}, - {"Äîðîòè", 1}, - {"Äðàêîíîâàÿ", 1}, - {"Äðåâíåå", 2}, - {"Äðåâíèé", 0}, - {"Äðóèä", 0}, - {"Äðþ", 0}, - {"Äóãëàñ", 0}, - {"Äóíêàí", 0}, - {"Äüÿâîë", 0}, - {"Äýâè", 0}, - {"Äýí", 0}, - {"Äýíèñ", 0}, - {"Äýííè", 0}, - {"Äþê", 0}, - {"Åâà", 1}, - {"Åâãåíèé", 0}, - {"Åëèçàâåòà", 1}, - {"Æàí-Ïîëü", 0}, - {"Æàí-Ïüåð", 0}, - {"Æàíåòà", 1}, - {"Æàíåòò", 1}, - {"Æàíåòòà", 1}, - {"Æàíèí", 1}, - {"Æàíèñ", 1}, - {"Æàííà", 1}, - {"Æàñìèí", 1}, - {"Æåéí", 1}, - {"Æåííà", 1}, - {"Æèëüáåð", 0}, - {"Æîôðåé", 0}, - {"Æóëü", 0}, - {"Çàê", 0}, - {"Çàìîê", 0}, - {"Çàìîðîæåííûå", 2}, - {"Çàõàðèé", 0}, - {"Çåáóëîí", 0}, - {"Çåëåíûé", 0}, - {"Çåìíîé", 0}, - {"Çèããè", 0}, - {"Çèê", 0}, - {"Çëàòûå", 2}, - {"Çîä", 0}, - {"Çîëîòîé", 0}, - {"Çîëòàí", 0}, - {"Çîðåêñ", 0}, - {"Èâ", 0}, - {"Èâàí", 0}, - {"Èâàð", 0}, - {"Èâåðñîí", 0}, - {"Èâîííà", 1}, - {"Èãíàñèî", 0}, - {"Èãîðü", 0}, - {"Èäà", 1}, - {"Èåðåìèÿ", 0}, - {"Èçìàèë", 0}, - {"Èçóìðóäíûé", 0}, - {"Èêå", 0}, - {"Èëåíà", 1}, - {"Èëüÿ", 0}, - {"Èìåíèå", 2}, - {"Èíêóáàòîð", 0}, - {"Èîëàíäà", 1}, - {"Èîí", 0}, - {"Èîíà", 0}, - {"Èîõàíí", 0}, - {"Èðâèí", 0}, - {"Èðâèíã", 0}, - {"Èðåíà", 1}, - {"Èðèíà", 1}, - {"Èðèñ", 1}, - {"Èðìà", 1}, - {"Èñààê", 0}, - {"Èñàî", 0}, - {"Éîðäàí", 0}, - {"Êààî", 0}, - {"Êàé", 0}, - {"Êàëåá", 0}, - {"Êàëüâèí", 0}, - {"Êàìåííàÿ", 1}, - {"Êàìåííûé", 0}, - {"Êàíäåéñ", 1}, - {"Êàïèòàí", 0}, - {"Êàðåí", 1}, - {"Êàðè", 0}, - {"Êàðèí", 0}, - {"Êàðë", 0}, - {"Êàðëè", 1}, - {"Êàðëî", 0}, - {"Êàðëîí", 0}, - {"Êàðëîñ", 0}, - {"Êàðìåí", 1}, - {"Êàðòåð", 0}, - {"Êàñàíäðà", 1}, - {"Êàòåðèíà", 1}, - {"Êàòè", 1}, - {"Êàòëèí", 1}, - {"Êâàí", 0}, - {"Êâåíòèí", 0}, - {"Êâèíí", 0}, - {"Êåâèí", 0}, - {"Êåâèíóñ", 0}, - {"Êåéëèí", 1}, - {"Êåéò", 0}, - {"Êåë", 0}, - {"Êåëëè", 1}, - {"Êåí", 0}, - {"Êåííåò", 0}, - {"Êåðè", 1}, - {"Êåðí", 0}, - {"Êèãàí", 0}, - {"Êèì", 1}, - {"Êèìáåðëè", 1}, - {"Êèðê", 0}, - {"Êèðóñ", 0}, - {"Êëàéä", 0}, - {"Êëàðåíñ", 0}, - {"Êëàðê", 0}, - {"Êëèðèê", 0}, - {"Êëèôôîðä", 0}, - {"Êëýé", 0}, - {"Êëýð", 1}, - {"Êîäè", 0}, - {"Êîëèí", 0}, - {"Êîëîíèÿ", 1}, - {"Êîííè", 1}, - {"Êîííîð", 0}, - {"Êîíðàä", 0}, - {"Êîíñòàíòèí", 0}, - {"Êîíñòàíöèÿ", 1}, - {"Êîïè", 2}, - {"Êîðà", 1}, - {"Êîðáåò", 0}, - {"Êîðä", 0}, - {"Êîðè", 0}, - {"Êîðèñî", 0}, - {"Êîðíåëèÿ", 1}, - {"Êîðíèëèé", 0}, - {"Êîðîëåâà", 1}, - {"Êîðîëåâñêèé", 0}, - {"Êîðîëü", 0}, - {"Êîøêà", 1}, - {"Êðàñíûé", 0}, - {"Êðåéã", 0}, - {"Êðèñ", 0}, - {"Êðèñòà", 1}, - {"Êðèñòåí", 1}, - {"Êðèñòèíà", 1}, - {"Êðèñòèñ", 1}, - {"Êðèñòîôåð", 0}, - {"Êðîâàâûé", 0}, - {"Êñóàí", 0}, - {"Êóëàê", 0}, - {"Êóðãàí", 0}, - {"Êóðèöà", 1}, - {"Êýé", 1}, - {"Êýéñ", 1}, - {"Êýë", 0}, - {"Êýëëî", 0}, - {"Êýìåðîí", 0}, - {"Êýíäè", 1}, - {"Êýðè", 1}, - {"Êýðîë", 1}, - {"Êýðîëàí", 1}, - {"Êýðîëèí", 1}, - {"Êýððè", 1}, - {"Êýñè", 0}, - {"Ëàáèðèíò", 0}, - {"Ëàáîðàòîðèÿ", 1}, - {"Ëàçàðü", 0}, - {"Ëàéîíåë", 0}, - {"Ëàêè", 0}, - {"Ëàíà", 1}, - {"Ëàíñ", 0}, - {"Ëàðà", 1}, - {"Ëàððè", 0}, - {"Ëàðñ", 0}, - {"Ëàóðà", 1}, - {"Ëàóðè", 1}, - {"Ëåà", 1}, - {"Ëåàñà", 1}, - {"Ëåéô", 0}, - {"Ëåî", 0}, - {"Ëåîíàðä", 0}, - {"Ëåîðà", 1}, - {"Ëåðîé", 0}, - {"Ëåñëè", 1}, - {"Ëåñòåð", 0}, - {"Ëåòó÷àÿ", 1}, - {"Ëè", 0}, - {"Ëè", 1}, - {"Ëèàì", 0}, - {"Ëèâèÿ", 1}, - {"Ëèçà", 1}, - {"Ëèëà", 1}, - {"Ëèëàíä", 0}, - {"Ëèëëè", 1}, - {"Ëèìàí", 0}, - {"Ëèíäà", 1}, - {"Ëèíäåí", 0}, - {"Ëèíäñåé", 0}, - {"Ëèíí", 1}, - {"Ëèîí", 0}, - {"Ëè÷", 0}, - {"Ëëîéä", 0}, - {"Ëîâ÷èé", 0}, - {"Ëîãàí", 0}, - {"Ëîãîâî", 2}, - {"Ëîí", 0}, - {"Ëîííè", 0}, - {"Ëîðà", 1}, - {"Ëîðä", 0}, - {"Ëîðåí", 1}, - {"Ëîðåíà", 1}, - {"Ëîó", 0}, - {"Ëîóâåëë", 0}, - {"Ëîÿëüíûé", 0}, - {"Ëóè", 0}, - {"Ëóèäæè", 0}, - {"Ëóèçà", 1}, - {"Ëóèñ", 0}, - {"Ëóèñà", 1}, - {"Ëó÷íèê", 0}, - {"Ëüþèñ", 0}, - {"Ëþäâèã", 0}, - {"Ëþê", 0}, - {"Ëþñèëü", 1}, - {"Ëþòåð", 0}, - {"Ìàäåëåíà", 1}, - {"Ìàéê", 0}, - {"Ìàéëç", 0}, - {"Ìàéëñ", 0}, - {"Ìàê", 0}, - {"Ìàêðî", 0}, - {"Ìàêñ", 0}, - {"Ìàêñâåëë", 0}, - {"Ìàëêîëüì", 0}, - {"Ìàëûé", 0}, - {"Ìàìè", 1}, - {"Ìàííè", 0}, - {"Ìàíòèêîðà", 1}, - {"Ìàíôðåä", 0}, - {"Ìàðâèí", 0}, - {"Ìàðãàðèòà", 1}, - {"Ìàðäæîðè", 1}, - {"Ìàðæ", 1}, - {"Ìàðèàíà", 1}, - {"Ìàðèàííà", 1}, - {"Ìàðèî", 0}, - {"Ìàðèîí", 0}, - {"Ìàðèñ", 1}, - {"Ìàðèñà", 1}, - {"Ìàðèøàëü", 1}, - {"Ìàðèÿ", 1}, - {"Ìàðê", 0}, - {"Ìàðêî", 0}, - {"Ìàðêîíè", 0}, - {"Ìàðêóñ", 0}, - {"Ìàðëåí", 1}, - {"Ìàðëîí", 0}, - {"Ìàðíè", 1}, - {"Ìàðñè", 1}, - {"Ìàðñèÿ", 1}, - {"Ìàðòà", 1}, - {"Ìàðòèë", 1}, - {"Ìàðòèí", 0}, - {"Ìàðõýì", 0}, - {"Ìàð÷åëëî", 0}, - {"Ìàðøà", 1}, - {"Ìàðøàë", 0}, - {"Ìàñòåð", 0}, - {"Ìàòâåé", 0}, - {"Ìàòåðèàëüíûå", 2}, - {"Ìàòò", 0}, - {"Ìåãàäðàêîí", 0}, - {"Ìåäíûé", 0}, - {"Ìåäóçà", 1}, - {"Ìåéì", 1}, - {"Ìåëàíè", 1}, - {"Ìåëâèí", 0}, - {"Ìåëèíäà", 1}, - {"Ìåëèññà", 1}, - {"Ìåëêîâîäüå", 2}, - {"Ìåëîäè", 1}, - {"Ìåðòâåö", 0}, - {"Ìåðòâûé", 0}, - {"Ìåñòíàÿ", 1}, - {"Ìåñòíûé", 0}, - {"Ìèê", 0}, - {"Ìèíäè", 1}, - {"Ìèíåðàëüíûå", 2}, - {"Ìèíèêîðà", 1}, - {"Ìèííè", 1}, - {"Ìèðèàì", 1}, - {"Ìèò÷", 0}, - {"Ìèøåëü", 1}, - {"Ìîãó÷èé", 0}, - {"Ìîéðà", 1}, - {"Ìîíàõ", 0}, - {"Ìîíèêà", 1}, - {"Ìîíòå", 0}, - {"Ìîðåë", 0}, - {"Ìîðèíà", 1}, - {"Ìîððèñ", 0}, - {"Ìîðòîí", 0}, - {"Ìîõàììåä", 0}, - {"Ìðàìîðíàÿ", 1}, - {"Ìóäðûé", 0}, - {"Ìýë", 0}, - {"Ìýíäè", 1}, - {"Ìýðè", 1}, - {"Ìýðè", 1}, - {"Ìýðèëèí", 1}, - {"Ìþðåëü", 1}, - {"Ìþððåé", 0}, - {"Íàäèíà", 1}, - {"Íàë¸ò÷èê", 0}, - {"Íàîìè", 1}, - {"Íàòàëè", 1}, - {"Íàòàí", 0}, - {"Íàòàíèýëü", 0}, - {"Íà÷àëüíàÿ", 1}, - {"Íåáåñà", 1}, - {"Íåä", 0}, - {"Íåêðîìàíò", 0}, - {"Íåëüñîí", 0}, - {"Íåóñòðàøèìûé", 0}, - {"Íèê", 0}, - {"Íèêè", 1}, - {"Íèêîëàé", 0}, - {"Íèêîëàñ", 0}, - {"Íèêîëü", 1}, - {"Íèë", 0}, - {"Íîâîáðàíåö", 0}, - {"Íîé", 0}, - {"Íîðèíà", 1}, - {"Íîðì", 0}, - {"Íîðìà", 1}, - {"Íîðìàí", 0}, - {"Íîððèñ", 0}, - {"Íüþò", 0}, - {"Íýéò", 0}, - {"Íýíñè", 1}, - {"Íýíñèñ", 1}, - {"Îáñèäèàíîâàÿ", 1}, - {"Îãíåííûé", 0}, - {"Îëàô", 0}, - {"Îëèâåð", 0}, - {"Îëèâèÿ", 1}, - {"Îðäåí", 0}, - {"Îñîáíÿê", 0}, - {"Îñòèí", 0}, - {"Îòèñ", 0}, - {"Îóâåí", 0}, - {"Îõîòíèê", 0}, - {"Ïàâåë", 0}, - {"Ïàì", 1}, - {"Ïàìåëà", 1}, - {"Ïàðêåð", 0}, - {"Ïàðòè", 1}, - {"Ïàòðèê", 0}, - {"Ïàòðèñèÿ", 1}, - {"Ïåã", 1}, - {"Ïåããè", 1}, - {"Ïåéäæ", 1}, - {"Ïåííè", 1}, - {"Ïåððè", 0}, - {"Ïåðñè", 0}, - {"Ïåðñèâàëü", 0}, - {"Ïåòåð", 0}, - {"Ïèêñè", 1}, - {"Ïèðñ", 0}, - {"Ïèò", 0}, - {"Ïëàâó÷èé", 0}, - {"Ïîêîè", 2}, - {"Ïîë", 0}, - {"Ïîñâÿù¸ííûé", 0}, - {"Ïîñâÿùåííûé", 0}, - {"Ïîñëåäíèé", 0}, - {"Ïîñëóøíèê", 0}, - {"Ïîñòîÿëûé", 0}, - {"Ïðåäâîäèòåëü", 0}, - {"Ïðåñòîí", 0}, - {"Ïðèâèäåíèå", 2}, - {"Ïðèäîðîæíûé", 0}, - {"Ïðèçðàê", 0}, - {"Ïðèðîäíûå", 2}, - {"Ïüåð", 0}, - {"Ïýò", 0}, - {"Ïýòòè", 1}, - {"Ðàäó", 0}, - {"Ðàçáîéíèê", 0}, - {"Ðàéàí", 0}, - {"Ðàéìîíä", 0}, - {"Ðàëüô", 0}, - {"Ðàìåé", 0}, - {"Ðàìñè", 0}, - {"Ðàíäîëüô", 0}, - {"Ðàññåë", 0}, - {"Ðàñòè", 0}, - {"Ðàòóøà", 1}, - {"Ðàóëü", 0}, - {"Ðàôàýëü", 0}, - {"Ðàøåëü", 1}, - {"Ðåáåêêà", 1}, - {"Ðåâè", 1}, - {"Ðåã", 0}, - {"Ðåãèíà", 1}, - {"Ðåäæèíàëüä", 0}, - {"Ðåêñ", 0}, - {"Ðåíå", 0}, - {"Ðåíè", 1}, - {"Ðåíöî", 0}, - {"Ðåñàíäà", 1}, - {"Ðå÷íîé", 0}, - {"Ðèêè", 0}, - {"Ðèíàëüäî", 0}, - {"Ðèòà", 1}, - {"Ðè÷àðä", 0}, - {"Ðîá", 0}, - {"Ðîááè", 0}, - {"Ðîáåðò", 0}, - {"Ðîáåðòà", 1}, - {"Ðîáèí", 0}, - {"Ðîãàòûé", 0}, - {"Ðîäåðèê", 0}, - {"Ðîäíè", 0}, - {"Ðîçà", 1}, - {"Ðîçàëè", 1}, - {"Ðîçàííà", 1}, - {"Ðîçè", 1}, - {"Ðîçìàðè", 1}, - {"Ðîçìàðèíà", 1}, - {"Ðîé", 0}, - {"Ðîêè", 0}, - {"Ðîëàíä", 0}, - {"Ðîìîíà", 1}, - {"Ðîí", 0}, - {"Ðîíàëüä", 0}, - {"Ðîíäà", 1}, - {"Ðîðè", 0}, - {"Ðîññ", 0}, - {"Ðîóç", 1}, - {"Ðîøåëü", 1}, - {"Ðóáèíà", 1}, - {"Ðóäè", 0}, - {"Ðóïåðò", 0}, - {"Ðóò", 1}, - {"Ðóòè", 1}, - {"Ðýíäàë", 0}, - {"Ðýíäè", 0}, - {"Ñààä", 0}, - {"Ñàáðèíà", 1}, - {"Ñàäè", 1}, - {"Ñàë", 0}, - {"Ñàëëè", 1}, - {"Ñàëüâàòîðå", 0}, - {"Ñàìþýëü", 0}, - {"Ñàíäèï", 0}, - {"Ñàíäðà", 1}, - {"Ñàíòîñ", 0}, - {"Ñàïôèðîâûé", 0}, - {"Ñàðà", 1}, - {"Ñâåí", 0}, - {"Ñâåò", 0}, - {"Ñâåòëàíà", 1}, - {"Ñâåòÿùèéñÿ", 0}, - {"Ñâÿòèëèùå", 2}, - {"Ñâÿùåííàÿ", 1}, - {"Ñâÿùåííèê", 0}, - {"Ñåáàñòüÿí", 0}, - {"Ñåäðèê", 0}, - {"Ñåéìóð", 0}, - {"Ñåêëèÿ", 1}, - {"Ñåëåíà", 1}, - {"Ñåðãèî", 0}, - {"Ñåðåíà", 1}, - {"Ñåðûé", 0}, - {"Ñåñèëü", 0}, - {"Ñåò", 0}, - {"Ñèäíåé", 0}, - {"Ñèëüâåñòð", 0}, - {"Ñèëüôèäà", 1}, - {"Ñèìîí", 0}, - {"Ñèìîíà", 1}, - {"Ñèíäè", 1}, - {"Ñèíäèñ", 1}, - {"Ñèíèé", 0}, - {"Ñèíòèÿ", 1}, - {"Ñêàëèñ", 0}, - {"Ñêåëåò", 0}, - {"Ñêîðïèêîðà", 1}, - {"Ñêîòò", 0}, - {"Ñëàáûé", 0}, - {"Ñëåéä", 0}, - {"Ñîáàêà", 1}, - {"Ñîáîð", 0}, - {"Ñîë", 0}, - {"Ñîëíöå", 2}, - {"Ñîííè", 0}, - {"Ñïåíñåð", 0}, - {"Ñòàðøèé", 0}, - {"Ñòåéñè", 1}, - {"Ñòåëñ", 0}, - {"Ñòåôàí", 0}, - {"Ñòåôàíè", 1}, - {"Ñòèâ", 0}, - {"Ñòèâåí", 0}, - {"Ñòîðîæåâàÿ", 1}, - {"Ñòðàæ", 0}, - {"Ñòðàæíèê", 0}, - {"Ñòðåêîçàâð", 0}, - {"Ñòðåëîê", 0}, - {"Ñòýí", 0}, - {"Ñòýíëè", 0}, - {"Ñòþàðò", 0}, - {"Ñóàííà", 1}, - {"Ñóäüÿ", 0}, - {"Ñóëåéìàí", 0}, - {"Ñóìåðå÷íûé", 0}, - {"Ñüþçàí", 1}, - {"Ñüþçè", 1}, - {"Ñýì", 0}, - {"Ñýíäè", 1}, - {"Ñýíäèí", 1}, - {"Ñýðà", 1}, - {"Ñþçàííà", 1}, - {"Òàäåóñ", 0}, - {"Òàéëåð", 0}, - {"Òàéñîí", 0}, - {"Òàêà", 0}, - {"Òàìàðà", 1}, - {"Òàììè", 1}, - {"Òàíÿ", 1}, - {"Òàðà", 1}, - {"Òåéí", 0}, - {"Òåîäîð", 0}, - {"Òåðåçà", 1}, - {"Òåðåñà", 1}, - {"Òåððàíñ", 0}, - {"Òåððè", 1}, - {"Òèì", 0}, - {"Òèìîòè", 0}, - {"Òèíà", 1}, - {"Òèôôàíè", 1}, - {"Òîáèàñ", 0}, - {"Òîää", 0}, - {"Òîì", 0}, - {"Òîìàñ", 0}, - {"Òîí", 0}, - {"Òîíè", 0}, - {"Òîð", 0}, - {"Òðàí", 0}, - {"Òðàÿí", 0}, - {"Òðåéñè", 1}, - {"Òðåíò", 0}, - {"Òðåíòîí", 0}, - {"Òðèíà", 1}, - {"Òðèï", 0}, - {"Òðèñèÿ", 1}, - {"Òðîãëîäèò", 0}, - {"Òðîííûé", 0}, - {"Òðóâîð", 0}, - {"Òðýâèñ", 0}, - {"Òóìàííûé", 0}, - {"Òýä", 0}, - {"Òýððè", 1}, - {"Òþðüìà", 1}, - {"Óàëüäî", 0}, - {"Óèëáåðò", 0}, - {"Óèëüñîí", 0}, - {"Óíäèíà", 1}, - {"Óîëëåñ", 0}, - {"Óîððåí", 0}, - {"Óïûðü", 0}, - {"Ó÷åáíûé", 0}, - {"Óýáá", 0}, - {"Ôàáèàí", 0}, - {"Ôàìèëüíûé", 0}, - {"Ôàðåëë", 0}, - {"Ôåäðóñ", 0}, - {"Ôåéò", 1}, - {"Ôåëèêñ", 0}, - {"Ôåëèöèÿ", 1}, - {"Ôåðäèíàíä", 0}, - {"Ôèë", 0}, - {"Ôèëèï", 0}, - {"Ôèëëèñ", 1}, - {"Ôèëîìåíà", 1}, - {"Ôëåò÷åð", 0}, - {"Ôëîéä", 0}, - {"Ôëîðåíöèÿ", 1}, - {"Ôëîññè", 1}, - {"Ôîððåñò", 0}, - {"Ôðàíê", 0}, - {"Ôðàíêëèí", 0}, - {"Ôðàíö", 0}, - {"Ôðàíöèñê", 0}, - {"Ôðàí÷åñêà", 1}, - {"Ôðåä", 0}, - {"Ôðåäåðèê", 0}, - {"Õàâüåð", 0}, - {"Õàéäåí", 0}, - {"Õàéäè", 1}, - {"Õàí", 0}, - {"Õàíê", 0}, - {"Õàíí", 0}, - {"Õàîñ", 0}, - {"Õàðâè", 0}, - {"Õàðäè", 0}, - {"Õàðèåòòà", 1}, - {"Õàðëàí", 0}, - {"Õàðëåé", 0}, - {"Õàðîëüä", 0}, - {"Õàððèñîí", 0}, - {"Õåëåí", 1}, - {"Õèëüäà", 1}, - {"Õèò", 0}, - {"Õèòåð", 1}, - {"Õèòåò", 0}, - {"Õèòîìè", 1}, - {"Õîäÿ÷èé", 0}, - {"Õîê", 0}, - {"Õîëäåí", 0}, - {"Õîëëè", 1}, - {"Õðàì", 0}, - {"Õðàíèëèùå", 2}, - {"Õüþ", 0}, - {"Õüþãî", 0}, - {"Õýë", 0}, - {"Õýìïòîí", 0}, - {"Öàðü", 0}, - {"Öåçàðü", 0}, - {"Öèêëîí", 0}, - {"Öèòàäåëü", 1}, - {"×àä", 0}, - {"×àê", 0}, - {"×àí", 0}, - {"×àíäðà", 1}, - {"×àðëè", 0}, - {"×àðëüç", 0}, - {"×àðîäåé", 0}, - {"×àñîâîé", 0}, - {"×åìïèîí", 0}, - {"×åðíàÿ", 1}, - {"×åðíîêíèæíèê", 0}, - {"×åðòîã", 0}, - {"×åñòåð", 0}, - {"×åò", 0}, - {"×èï", 0}, - {"×óäèùå", 2}, - {"Øàòåð", 0}, - {"Øàõòåðñêàÿ", 1}, - {"Øåéëà", 1}, - {"Øåéëàíè", 1}, - {"Øåëäîí", 0}, - {"Øåëë", 0}, - {"Øåëëè", 1}, - {"Øåëëèñ", 1}, - {"Øåðäîí", 0}, - {"Øåðèë", 1}, - {"Øåðìàí", 0}, - {"Øåððè", 1}, - {"Øåððèí", 1}, - {"Øèìîí", 0}, - {"Øêîëà", 1}, - {"Øîí", 0}, - {"Øîóíà", 1}, - {"Øòàá", 0}, - {"Øýíîí", 1}, - {"Øýðè", 1}, - {"Øýðîí", 1}, - {"Ýâàí", 0}, - {"Ýâåëèí", 1}, - {"Ýä", 0}, - {"Ýäãàð", 0}, - {"Ýääè", 0}, - {"Ýäèñîí", 0}, - {"Ýäèò", 1}, - {"Ýäìîíä", 0}, - {"Ýäíà", 1}, - {"Ýéá", 0}, - {"Ýéëèí", 1}, - {"Ýéïðèë", 1}, - {"Ýêñïåðòíàÿ", 1}, - {"Ýë", 0}, - {"Ýëâèí", 0}, - {"Ýëåãàíòíûé", 0}, - {"Ýëåí", 1}, - {"Ýëåîíîðà", 1}, - {"Ýëèîò", 0}, - {"Ýëèñîí", 1}, - {"Ýëèññà", 1}, - {"Ýëèòíûé", 0}, - {"Ýëëà", 1}, - {"Ýëëåí", 1}, - {"Ýëñè", 1}, - {"Ýëòîí", 0}, - {"Ýëüô", 0}, - {"Ýìè", 1}, - {"Ýìèëü", 0}, - {"Ýììà", 1}, - {"Ýììàíóèë", 0}, - {"Ýììåò", 0}, - {"Ýíäæè", 1}, - {"Ýíäè", 0}, - {"Ýíí", 1}, - {"Ýíí", 2}, - {"Ýíîê", 0}, - {"Ýðâèí", 0}, - {"Ýðèê", 0}, - {"Ýðèí", 1}, - {"Ýðë", 0}, - {"Ýðíåñò", 0}, - {"Ýðíè", 0}, - {"Ýðíèí", 0}, - {"Ýðîë", 0}, - {"Ýòàí", 0}, - {"Ýòåëü", 1}, - {"Ýø", 0}, - {"Ýøòîí", 0}, - {"Þäèôü", 1}, - {"Þðèé", 0}, - {"ßäîâèòûé", 0}, - {"ßêîá", 0}, - {"ßí", 0}, - {"ßíñè", 0}, - {"ßðîä", 0}, - {"ßñïåð", 0} -}, - gender_table[] = -{ - {"àä", 0}, {"àêóëà", 1}, {"áàíê", 0}, {"áàøíÿ", 1}, {"áëàñòåð", 0}, {"âàìïèð", 0}, {"âäîâà", 1}, {"âåäüìà", 1}, {"âèòåðñìèò", 0}, {"âëàäûêà", 0}, {"âëàäû÷èöà", 1}, - {"âîèí", 0}, {"âîð", 0}, {"ãèäðà", 1}, {"ãëàç", 0}, {"ãîëåì", 0}, {"ãîðà", 1}, {"ãîðãóëüÿ", 1}, {"ãîðîä", 0}, {"ãðîìîâàÿ", 1}, {"äâîð", 0}, {"äæèíí", 0}, - {"äðàêîí", 0}, {"äóõ", 0}, {"æèòåëü", 0}, {"æèòåëüíèöà", 1}, {"çàë", 0}, {"çàùèòíèê", 0}, {"çåìëÿ", 1}, {"èñêàòåëü", 0}, {"èôðèò", 0}, {"êâàðòèðà", 1}, {"êîëü÷óãà", 1}, - {"êîìàíäèð", 0}, {"êðûñà", 1}, {"ëåéòåíàíò", 0}, {"ëóíà", 1}, {"ëþäîåä", 0}, {"ìàãîã", 0}, {"ìå÷", 0}, {"ìå÷íèê", 0}, {"ìèíîòàâð", 0}, {"ìûøü", 1}, {"íàåìíèê", 0}, - {"îãíåííàÿ", 1}, {"îãîíü", 0}, {"îðê", 0}, {"ïàóê", 0}, {"ïåùåðà", 1}, {"ïåùåðû", 1}, {"ïîâåëèòåëü", 0}, {"ïîãðåá", 0}, {"ïîëèãîí", 0}, {"ïðèþò", 0}, {"ïòèöà", 1}, - {"ïòè÷èé", 0}, {"ðàáîòíèê", 0}, {"ðàé", 0}, {"ðåéíäæåð", 0}, {"ðóõ", 0}, {"ñëèçåíü", 0}, {"ñîëäàò", 0}, {"òèòàí", 0}, {"òðàêòèð", 0}, {"òðîëëü", 0}, {"óáèéöà", 0}, - {"óëàí", 0}, {"ó÷èëèùå", 2}, {"øëÿïà", 1}, {"ýëåìåíòàë", 0} -}; - - - -#include - -int GetGender(char *ansi_name, int name_len) -{ - auto name = (unsigned char *)ansi_name; - - GenderTableEntry *table = nullptr; - unsigned int table_size = 0; - if (name[0] >= (unsigned char)'à' && name[0] <= (unsigned char)'ÿ') - { - table = gender_table; - table_size = sizeof(gender_table) / sizeof(*gender_table); - } - else if (name[0] >= (unsigned char)'À' && name[0] <= (unsigned char)'ß') - { - table = gender_table_caps; - table_size = sizeof(gender_table_caps) / sizeof(*gender_table_caps); - } - else return 0; - - int left = 0, - right = table_size - 1, - match = 0; - while (left < right - 1) - { - match = left + (right - left) / 2; - int rval = _mbsncmp(name, (unsigned char *)table[match].name, name_len); - if (rval < 0) - right = match; - else if (!rval) - return table[match].gender; - else - left = match; - } - - Log::Warning(L"sprintfex: unknown gender: %S", name); - return 0; -} - - -bool IsSpecialName(const char *ansi_name) -{ - auto name = (unsigned char *)ansi_name; - return !_mbsncmp(name, (unsigned char *)"Ìýðè Äæî", 8) || !_mbsncmp(name, (unsigned char *)"Ëè Ýíí", 6) || - !_mbsncmp(name, (unsigned char *)"Âðàòà â Áåçäíó", 14) || !_mbsncmp(name, (unsigned char *)"Ñòåíû òóìàíà", 12); -} -int GetSpecialGender(const char *ansi_name) -{ - auto name = (unsigned char *)ansi_name; - if (!_mbsncmp(name, (unsigned char *)"Ìýðè Äæî", 8)) - return 1; - if (!_mbsncmp(name, (unsigned char *)"Ëè Ýíí", 6)) - return 1; - if (!_mbsncmp(name, (unsigned char *)"Âðàòà â Áåçäíó", 14)) - return 1; - if (!!_mbsncmp(name, (unsigned char *)"Ñòåíû òóìàíà", 12)) - return 0; - return 0; -} -const char *GetSpecialCase(const char *ansi_name, char c) -{ - auto name = (unsigned char *)ansi_name; - - if (!_mbsncmp(name, (unsigned char *)"Ìýðè Äæî", 8)) - return "Ìýðè Äæî"; - if (!_mbsncmp(name, (unsigned char *)"Ëè Ýíí", 6)) - return "Ëè Ýíí"; - - if (!_mbsncmp(name, (unsigned char *)"Âðàòà â Áåçäíó", 14)) - switch (c) - { - case 'I': case 'i': return "Âðàòà â Áåçäíó"; - case 'R': case 'r': return "Âðàò â Áåçäíó"; - case 'D': case 'd': return "Âðàòàì â Áåçäíó"; - case 'V': case 'v': return "Âðàò â Áåçäíó"; - case 'T': case 't': return "Âðàòàìè â Áåçäíó"; - case 'P': case 'p': return "Âðàòàõ â Áåçäíó"; - } - - if (!_mbsncmp(name, (unsigned char *)"Ñòåíû òóìàíà", 12)) - switch (c) - { - case 'I': case 'i': return "Ñòåíû òóìàíà"; - case 'R': case 'r': return "Ñòåí òóìàíà"; - case 'D': case 'd': return "Ñòåíàì òóìàíà"; - case 'V': case 'v': return "Ñòåíû òóìàíà"; - case 'T': case 't': return "Ñòåíàìè òóìàíà"; - case 'P': case 'p': return "Ñòåíàõ òóìàíà"; - } - - return nullptr; -} - -int sprintfex_internal(char *str) -{ - auto p = strstr(str, "^"); - if (!p) - return strlen(str); - - char buf[8192]; - Assert(strlen(str) < sizeof(buf)); - - int next_integer_token = 0; - bool integer_tokens_defined[10] = {false, false, false, false, false, false, false, false, false, false}; - int integer_tokens[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - - bool gender_token_defined = false; - int gender_token = 0; - - auto src = buf, - dst = p; - strcpy(buf, str + (p - str)); - while (true) - { - switch (src[1]) - { - case 'I': - { - if (src[2] != '[') - goto _invalid_token; - src += 3; // ^I[ - - Assert(next_integer_token < 10); - if (sscanf(src, "%d", &integer_tokens[next_integer_token])) - integer_tokens_defined[next_integer_token++] = true; - - auto int_begin = src; - while (*src++ != ']'); - - int int_len = src - int_begin - 1; - strncpy(dst, int_begin, int_len); - dst += int_len; - } - break; - - case 'L': - { - int integer_token_idx = 0; - if (src[2] >= '1' && src[2] <= '9') - { - if (src[3] != '[') - goto _invalid_token; - integer_token_idx = src[2] - '1'; - - src += 1; - } - else if (src[2] != '[') - goto _invalid_token; - - Assert(integer_tokens_defined[integer_token_idx]); - src += 3; // ^L[ - - auto ending1 = src; - while (*src++ != ';'); - auto ending2 = src; - while (*src++ != ';'); - auto ending3 = src; - while (*src++ != ']'); - - char *actual_ending = nullptr; - int actual_ending_len = 0; - - int modulo = abs(integer_tokens[integer_token_idx]) % 10; - if (modulo == 1) - { - actual_ending = ending1; - actual_ending_len = ending2 - ending1 - 1; - } - else if (modulo >= 2 && modulo <= 4) - { - actual_ending = ending2; - actual_ending_len = ending3 - ending2 - 1; - } - else - { - actual_ending = ending3; - actual_ending_len = src - ending3 - 1; - } - - strncpy(dst, actual_ending, actual_ending_len); - dst += actual_ending_len; - } - break; - - case 'R': - { - if (src[2] != '[') - goto _invalid_token; - Assert(gender_token_defined); - - src += 3; // ^R[ - - auto ending1 = src; - while (*src++ != ';'); - auto ending2 = src; - while (*src++ != ';'); - auto ending3 = src; - while (*src++ != ']'); - - char *actual_ending = nullptr; - int actual_ending_len = 0; - - if (gender_token == 0) - { - actual_ending = ending1; - actual_ending_len = ending2 - ending1 - 1; - } - else if (gender_token == 1) - { - actual_ending = ending2; - actual_ending_len = ending3 - ending2 - 1; - } - else if (gender_token == 2) - { - actual_ending = ending3; - actual_ending_len = src - ending3 - 1; - } - else Error("Invalid gender token"); - - strncpy(dst, actual_ending, actual_ending_len); - dst += actual_ending_len; - } - break; - - case 'P': - { - if (src[3] != '[') - goto _invalid_token; - switch (src[2]) - { - case 'I': case 'i': - case 'R': case 'r': - case 'D': case 'd': - case 'V': case 'v': - case 'T': case 't': - case 'P': case 'p': break; - default: - goto _invalid_token; - } - - if (IsSpecialName(src + 4)) - { - auto name = GetSpecialCase(src + 4, src[2]); - int name_len = strlen(name); - - gender_token = GetSpecialGender(src + 4); - gender_token_defined = true; - - strncpy(dst, name, name_len); - dst += name_len; - while (*src++ != ']'); - break; - } - - auto name_begin = src + 4; - int name_len = 0; - for (int i = 0; name_begin[i] != ']'; ++i) - name_len++; - gender_token = GetGender(name_begin, name_len); - gender_token_defined = true; - - switch (src[2]) - { - case 'I': case 'i': - case 'V': case 'v': - case 'R': case 'r': - case 'D': case 'd': - case 'T': case 't': - { - strncpy(dst, name_begin, name_len); - dst += name_len; - } - break; - - case 'P': case 'p': - { - auto token_begin = src; - int token_len = 1; - for (int i = 0; token_begin[i] != ']'; ++i) - token_len++; - strncpy(dst, token_begin, token_len); - dst += token_len; - } - } - while (*src++ != ']'); - } - break; - - default: - { -_invalid_token: - auto token_begin = src; - while (*src++ != ']'); - - int token_len = src - token_begin; - char token[1024]; - strncpy(token, token_begin, token_len); - token[token_len] = 0; - - Error("Invalid format token: %s", token); - } - break; - } - - *dst = 0; - - auto copy_begin = src; - src = strstr(src, "^"); - if (!src) - { - strcpy(dst, copy_begin); // just copy the rest - break; - } - - int copy_len = src - copy_begin; - strncpy(dst, copy_begin, copy_len); - dst += copy_len; - } - - return dst - str; -} - - - - - - -//mm6text.non -> c structure array - /*FILE *f = fopen("_1.txt", "w+t"); - FILE *in = fopen("mm6text.non", "rt"); - fscanf(in, "%*[^\n]\n"); - - int idx = 0; - auto pairs = new NameGender[8000]; - - char line[1024]; - while (fscanf(in, "%[^\n]\n", line) && !feof(in)) - { - char name1[100], name2[100], name3[100]; - int e = sscanf(line, "%s\t%s\t%s", pairs[idx].name, pairs[idx + 1].name, pairs[idx + 2].name); - pairs[idx].gender = 0; - pairs[idx+1].gender = 1; - pairs[idx+2].gender = 2; - idx += e; - } - - for (int i = 0; i < idx; ++i) - for (int j = 0; j < i; ++j) - { - if (_mbsicmp(pairs[i].name, pairs[j].name) < 0) - { - char n[1024]; - strcpy(n, (char *)pairs[j].name); - auto g = pairs[j].gender; - - strcpy((char *)pairs[j].name, (char *)pairs[i].name); - pairs[j].gender = pairs[i].gender; - - strcpy((char *)pairs[i].name, n); - pairs[i].gender = g; - } - } - - for (int i = 0; i < idx; ++i) - { - fprintf(f, " {\"%s\", %u},\n", pairs[i].name, pairs[i].gender); - } - fclose(f);*/ \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 resource.h --- a/resource.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by Might and Magic Trilogy.rc - -// Ñëåäóþùèå ñòàíäàðòíûå çíà÷åíèÿ äëÿ íîâûõ îáúåêòîâ -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff -r 92eeeb5200f2 -r 68cdef6879a0 stru123.h --- a/stru123.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -#pragma once -#include - - -/* 62 */ -#pragma pack(push, 1) -struct stru123 -{ - std::array field_0; - std::array _decor_events; -}; -#pragma pack(pop) -extern stru123 stru_5E4C90_MapPersistVars; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 stru159.h --- a/stru159.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -#pragma once - - - -/* 152 */ -#pragma pack(push, 1) -struct stru159 -{ - char *video_name; - int field_4; - int house_npc_id; - unsigned __int8 uBuildingType; // enum BuildingType - unsigned __int8 uRoomSoundId; - unsigned __int16 padding_e; -}; -#pragma pack(pop) - - -extern std::array pAnimatedRooms; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 stru160.h --- a/stru160.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -#pragma once - - -/* 153 */ -#pragma pack(push, 1) -struct stru160 -{ - inline stru160() {} - inline stru160(float a, float b, float c): field_0(a), field_4(b), field_8(c) {} - - float field_0; - float field_4; - float field_8; -}; -#pragma pack(pop) - -#pragma pack(push, 1) -struct stru16x: public stru160 -{ - float field_C; -}; -#pragma pack(pop) - -extern std::array array_4EB8B8; -extern std::array array_4EBBD0; -extern std::array<__int32, 128*3> array_4EBBD0_x; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 stru298.cpp --- a/stru298.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,21 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#include "stru298.h" - - -//----- (0040261D) -------------------------------------------------------- -void stru298::Add(__int16 uID, __int16 a3, __int16 x, __int16 y, __int16 z, char a7, char a8) -{ - if (count < 100) - { - pIDs[count] = uID; - pXs[count] = x; - pYs[count] = y; - pZs[count] = z; - field_324[count] = a3; - field_3EC[count] = a8; - field_450[count++] = a7; - } -} diff -r 92eeeb5200f2 -r 68cdef6879a0 stru298.h --- a/stru298.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -#pragma once -#include "VectorTypes.h" - -/* 303 */ -#pragma pack(push, 1) -struct stru298 -{ - void Add(__int16 uID, __int16 a3, __int16 x, __int16 y, __int16 z, char a7, char a8); - - int count; - __int16 pIDs[100]; - __int16 pXs[100]; - __int16 pYs[100]; - __int16 pZs[100]; - __int16 field_324[100]; - char field_3EC[100]; - char field_450[100]; - Vec3_int_ vec_4B4[100]; -}; -#pragma pack(pop) - -extern stru298 AttackerInfo; // weak \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 stru314.h --- a/stru314.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -#pragma once - - -/* 179 */ -#pragma pack(push, 1) -struct stru314 -{ - //----- (00489B60) -------------------------------------------------------- - stru314() - { - this->field_4.x = 0.0; - this->field_4.y = 0.0; - this->field_4.z = 0.0; - this->field_10.x = 0.0; - this->field_10.y = 0.0; - this->field_10.z = 0.0; - this->field_1C.x = 0.0; - this->field_1C.y = 0.0; - this->field_1C.z = 0.0; - //this->vdestructor_ptr = &stru314_pvdtor; - } - - //----- (00489B96) -------------------------------------------------------- - inline ~stru314() - {} - - - void (__fastcall ***vdestructor_ptr)(stru314 *, bool); - Vec3_float_ field_4; - Vec3_float_ field_10; - Vec3_float_ field_1C; - float dist; -}; -#pragma pack(pop) diff -r 92eeeb5200f2 -r 68cdef6879a0 stru367.h --- a/stru367.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ -#pragma once - -#include - -/* 152 */ -#pragma pack(push, 1) -struct stru367 -{ - bool direction; - std::array field_4; - std::array _view_transformed_x; - std::array _view_transformed_y; - std::array _view_transformed_z; - std::array _screen_space_y; - std::array _screen_space_x; -}; -#pragma pack(pop) - - -//extern const stru367 stru_367; \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 stru6.cpp --- a/stru6.cpp Fri Sep 19 00:03:04 2014 +0600 +++ b/stru6.cpp Fri Sep 19 02:57:42 2014 +0600 @@ -6,23 +6,23 @@ #include "stru6.h" #include "Engine/Graphics/LightmapBuilder.h" -#include "SpriteObject.h" +#include "Engine/Objects/SpriteObject.h" #include "Engine/Graphics/ParticleEngine.h" -#include "Game.h" -#include "LOD.h" +#include "Engine/Game.h" +#include "Engine/LOD.h" #include "Engine/Graphics/Sprites.h" -#include "ObjectList.h" -#include "Actor.h" -#include "Random.h" -#include "IconFrameTable.h" -#include "Timer.h" +#include "Engine/Objects/ObjectList.h" +#include "Engine/Objects/Actor.h" +#include "Engine/Random.h" +#include "Engine/Tables/IconFrameTable.h" +#include "Engine/Timer.h" #include "Engine/Graphics/Viewport.h" #include "Engine/Graphics/Overlays.h" -#include "stru160.h" -#include "OurMath.h" +#include "Engine/stru160.h" +#include "Engine/OurMath.h" #include "Engine/Graphics/Lights.h" -#include "MM7.h" +#include "Engine/MM7.h" #include "Engine/Graphics/Indoor.h" diff -r 92eeeb5200f2 -r 68cdef6879a0 stuff.h --- a/stuff.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -#pragma once -#include -#include - - - -inline void Assert(bool condition, const char *format, ...) -{ - if (condition) - return; - - va_list va; - va_start(va, format); - char msg[4096]; - vsprintf(msg, format, va); - MessageBoxA(nullptr, msg, "Assert", 0); - va_end(va); - - __debugbreak(); -} - -inline void Error(const char *format, ...) -{ - va_list va; - va_start(va, format); - char msg[4096]; - vsprintf(msg, format, va); - MessageBoxA(nullptr, msg, "Error", 0); - va_end(va); - - __debugbreak(); -} - - - -inline void log(char *format, ...) -{ - va_list va; - va_start(va, format); - char msg[256]; - vsprintf(msg, format, va); - va_end(va); - DWORD w; - - WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), msg, strlen(msg), &w, 0); -} \ No newline at end of file diff -r 92eeeb5200f2 -r 68cdef6879a0 texts.cpp --- a/texts.cpp Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,468 +0,0 @@ -#define _CRTDBG_MAP_ALLOC -#include -#include - -#define _CRT_SECURE_NO_WARNINGS -#include - -#include "LOD.h" -#include "mm7_data.h" -#include "texts.h" - - -std::vector Tokenize( char* input, const char separator ) -{ - std::vector retVect; - retVect.push_back(input); - while (*input) - { - if (*input == separator) - { - *input = '\0'; - retVect.push_back(input + 1); - } - ++input; - } - return retVect; -} - - - -static char *pGlobalTXT_Raw=nullptr; - -std::array pGlobalTXT_LocalizationStrings; - - - -int sprintfex(char *buf, const char *format, ...) -{ - va_list args_ptr; - va_start(args_ptr, format); - { - vsprintf(buf, format, args_ptr); - } - va_end(args_ptr); - - extern int sprintfex_internal(char *buf); - return sprintfex_internal(buf); -} - -//----- (00452B95) -------------------------------------------------------- -void SetSomeItemsNames() -{ - pSomeItemsNames[0] = pGlobalTXT_LocalizationStrings[568]; - pSomeItemsNames[1] = pGlobalTXT_LocalizationStrings[271]; - pSomeItemsNames[2] = pGlobalTXT_LocalizationStrings[272]; - pSomeItemsNames[3] = pGlobalTXT_LocalizationStrings[273]; - pSomeItemsNames[4] = pGlobalTXT_LocalizationStrings[274]; - pSomeItemsNames[5] = pGlobalTXT_LocalizationStrings[275]; - pSomeItemsNames[6] = pGlobalTXT_LocalizationStrings[276]; - pSomeItemsNames[7] = pGlobalTXT_LocalizationStrings[277]; - pSomeItemsNames[8] = pGlobalTXT_LocalizationStrings[278]; - pSomeItemsNames[9] = pGlobalTXT_LocalizationStrings[279]; - pSomeItemsNames[10] = pGlobalTXT_LocalizationStrings[280]; - pSomeItemsNames[11] = pGlobalTXT_LocalizationStrings[281]; - pSomeItemsNames[12] = pGlobalTXT_LocalizationStrings[282]; - pSomeItemsNames[13] = pGlobalTXT_LocalizationStrings[143]; -} - -//----- (00452C30) -------------------------------------------------------- -char *RemoveQuotes(char *pStr) - { - if ( *pStr == '"' ) - { - pStr[strlen(pStr) - 1] = 0; - return pStr + 1; - } - return pStr; - } - -//----- (00452C49) -------------------------------------------------------- -void InitializeGameText() - { - //char *v0; // ebx@1 - /*char *v1; // eax@3 - int v2; // ebp@4 - char v3; // dl@5 - char *v4; // ecx@5 - int v5; // esi@9 - //char **v6; // [sp+10h] [bp-8h]@3 - signed int v7; // [sp+14h] [bp-4h]@4*/ - char *test_string; // eax@3 - char *tmp_pos; // eax@3 - int step; // ebp@4 - unsigned char c; // dl@5 - int temp_str_len; // ecx@5 - bool string_end; // [sp+14h] [bp-4h]@4 - //v0 = 0; - free(pGlobalTXT_Raw); - pGlobalTXT_Raw = (char *)pEvents_LOD->LoadRaw("global.txt", 0); - -/* strtok(pGlobalTXT_Raw, "\r"); - strtok(nullptr, "\r"); - v1 = strtok(nullptr, "\r") + 1; - - for (uint i = 0; i < 677; ++i) - { - char *p = v1; - while (*++p != '\t' && *p); - - pGlobalTXT_LocalizationStrings[i] = RemoveQuotes(p + 1); - - v1 = strtok(nullptr, "\r") + 1; - }*/ - strtok((char *)pGlobalTXT_Raw, "\r"); //Carriage Return 0D 13 - strtok(NULL, "\r"); //Carriage Return 0D 13 - - for (int i = 0; i < MAX_LOC_STRINGS; ++i) - { - test_string = strtok(NULL, "\r") + 1; //Carriage Return 0D 13 - step = 0; - string_end = false; - do - { - c = *(unsigned char*)test_string; - temp_str_len = 0; - if (c!= '\t' ) // Horizontal tab 09 - { - do - { - if ( !c ) - break; - c = *(test_string+temp_str_len+1); - temp_str_len++; - } - while ( c != '\t' ); // Horizontal tab 09 - } - tmp_pos=test_string+temp_str_len; - if (*tmp_pos == 0) - string_end = true; - *tmp_pos = 0; - if ( temp_str_len == 0) - string_end = true; - else - { - if ( step == 1 ) - pGlobalTXT_LocalizationStrings[i] = RemoveQuotes(test_string); - } - ++step; - test_string=tmp_pos+1; - } - while ( step <= 2 && !string_end); - } - - SetSomeItemsNames(); - aMonthNames[0] = pGlobalTXT_LocalizationStrings[415]; aMonthNames[1] = pGlobalTXT_LocalizationStrings[416]; - aMonthNames[2] = pGlobalTXT_LocalizationStrings[417]; aMonthNames[3] = pGlobalTXT_LocalizationStrings[418]; - aMonthNames[4] = pGlobalTXT_LocalizationStrings[419]; aMonthNames[5] = pGlobalTXT_LocalizationStrings[420]; - aMonthNames[6] = pGlobalTXT_LocalizationStrings[421]; aMonthNames[7] = pGlobalTXT_LocalizationStrings[422]; - aMonthNames[8] = pGlobalTXT_LocalizationStrings[423]; aMonthNames[9] = pGlobalTXT_LocalizationStrings[424]; - aMonthNames[10] = pGlobalTXT_LocalizationStrings[425]; aMonthNames[11] = pGlobalTXT_LocalizationStrings[426]; - - aDayNames[0] = pGlobalTXT_LocalizationStrings[145]; aDayNames[1] = pGlobalTXT_LocalizationStrings[230]; - aDayNames[2] = pGlobalTXT_LocalizationStrings[243]; aDayNames[3] = pGlobalTXT_LocalizationStrings[227]; - aDayNames[4] = pGlobalTXT_LocalizationStrings[91]; aDayNames[5] = pGlobalTXT_LocalizationStrings[188]; - aDayNames[6] = pGlobalTXT_LocalizationStrings[222]; - - - pClassNames [0] = pGlobalTXT_LocalizationStrings[LOCSTR_KNIGHT]; - pClassNames [1] = pGlobalTXT_LocalizationStrings[LOCSTR_CAVALIER]; - pClassNames [2] = pGlobalTXT_LocalizationStrings[LOCSTR_CHAMPION]; - pClassNames [3] = pGlobalTXT_LocalizationStrings[LOCSTR_BLK_KNIGHT]; - - pClassNames [4] = pGlobalTXT_LocalizationStrings[LOCSTR_THIEF]; - pClassNames [5] = pGlobalTXT_LocalizationStrings[LOCSTR_ROGUE]; - pClassNames [6] = pGlobalTXT_LocalizationStrings[LOCSTR_SPY]; - pClassNames [7] = pGlobalTXT_LocalizationStrings[LOCSTR_ASSASIN]; - - pClassNames [8] = pGlobalTXT_LocalizationStrings[LOCSTR_MONK]; - pClassNames [9] = pGlobalTXT_LocalizationStrings[26]; - pClassNames [10] = pGlobalTXT_LocalizationStrings[432]; - pClassNames [11] = pGlobalTXT_LocalizationStrings[27]; - - pClassNames [12] = pGlobalTXT_LocalizationStrings[LOCSTR_PALADIN]; - pClassNames [13] = pGlobalTXT_LocalizationStrings[263]; - pClassNames [14] = pGlobalTXT_LocalizationStrings[264]; - pClassNames [15] = pGlobalTXT_LocalizationStrings[28]; - - pClassNames [16] = pGlobalTXT_LocalizationStrings[LOCSTR_ARCHER]; - pClassNames [17] = pGlobalTXT_LocalizationStrings[267]; - pClassNames [18] = pGlobalTXT_LocalizationStrings[119]; - pClassNames [19] = pGlobalTXT_LocalizationStrings[124]; - - pClassNames [20] = pGlobalTXT_LocalizationStrings[LOCSTR_RANGER]; - pClassNames [21] = pGlobalTXT_LocalizationStrings[370]; - pClassNames [22] = pGlobalTXT_LocalizationStrings[33]; - pClassNames [23] = pGlobalTXT_LocalizationStrings[40]; - - pClassNames [24] = pGlobalTXT_LocalizationStrings[LOCSTR_CLERIC]; - pClassNames [25] = pGlobalTXT_LocalizationStrings[257]; - pClassNames [26] = pGlobalTXT_LocalizationStrings[44]; - pClassNames [27] = pGlobalTXT_LocalizationStrings[46]; - - pClassNames [28] = pGlobalTXT_LocalizationStrings[LOCSTR_DRUID]; - pClassNames [29] = pGlobalTXT_LocalizationStrings[269]; - pClassNames [30] = pGlobalTXT_LocalizationStrings[270]; - pClassNames [31] = pGlobalTXT_LocalizationStrings[48]; - - pClassNames [32] = pGlobalTXT_LocalizationStrings[LOCSTR_SORCERER]; - pClassNames [33] = pGlobalTXT_LocalizationStrings[260]; - pClassNames [34] = pGlobalTXT_LocalizationStrings[261]; - pClassNames [35] = pGlobalTXT_LocalizationStrings[49]; - - aCharacterConditionNames[0] = pGlobalTXT_LocalizationStrings[52]; - aCharacterConditionNames[1] = pGlobalTXT_LocalizationStrings[241]; - aCharacterConditionNames[2] = pGlobalTXT_LocalizationStrings[14]; - aCharacterConditionNames[3] = pGlobalTXT_LocalizationStrings[4]; - aCharacterConditionNames[4] = pGlobalTXT_LocalizationStrings[69]; - aCharacterConditionNames[5] = pGlobalTXT_LocalizationStrings[117]; - aCharacterConditionNames[6] = pGlobalTXT_LocalizationStrings[166]; - aCharacterConditionNames[7] = pGlobalTXT_LocalizationStrings[65]; - aCharacterConditionNames[8] = pGlobalTXT_LocalizationStrings[166]; - aCharacterConditionNames[9] = pGlobalTXT_LocalizationStrings[65]; - aCharacterConditionNames[10] = pGlobalTXT_LocalizationStrings[166]; - aCharacterConditionNames[11] = pGlobalTXT_LocalizationStrings[65]; - aCharacterConditionNames[12] = pGlobalTXT_LocalizationStrings[162]; - aCharacterConditionNames[13] = pGlobalTXT_LocalizationStrings[231]; - aCharacterConditionNames[14] = pGlobalTXT_LocalizationStrings[58]; - aCharacterConditionNames[15] = pGlobalTXT_LocalizationStrings[220]; - aCharacterConditionNames[16] = pGlobalTXT_LocalizationStrings[76]; - aCharacterConditionNames[17] = pGlobalTXT_LocalizationStrings[601]; - aCharacterConditionNames[18] = pGlobalTXT_LocalizationStrings[98]; - - pSkillNames[0] = pGlobalTXT_LocalizationStrings[271]; - pSkillNames[1] = pGlobalTXT_LocalizationStrings[272]; - pSkillNames[2] = pGlobalTXT_LocalizationStrings[273]; - pSkillNames[3] = pGlobalTXT_LocalizationStrings[274]; - pSkillNames[4] = pGlobalTXT_LocalizationStrings[275]; - pSkillNames[5] = pGlobalTXT_LocalizationStrings[276]; - pSkillNames[6] = pGlobalTXT_LocalizationStrings[277]; - pSkillNames[7] = pGlobalTXT_LocalizationStrings[278]; - pSkillNames[8] = pGlobalTXT_LocalizationStrings[279]; - pSkillNames[9] = pGlobalTXT_LocalizationStrings[280]; - pSkillNames[10] = pGlobalTXT_LocalizationStrings[281]; - pSkillNames[11] = pGlobalTXT_LocalizationStrings[282]; - pSkillNames[12] = pGlobalTXT_LocalizationStrings[283]; - pSkillNames[13] = pGlobalTXT_LocalizationStrings[284]; - pSkillNames[14] = pGlobalTXT_LocalizationStrings[285]; - pSkillNames[15] = pGlobalTXT_LocalizationStrings[286]; - pSkillNames[16] = pGlobalTXT_LocalizationStrings[289]; - pSkillNames[17] = pGlobalTXT_LocalizationStrings[290]; - pSkillNames[18] = pGlobalTXT_LocalizationStrings[291]; - pSkillNames[19] = pGlobalTXT_LocalizationStrings[287]; - pSkillNames[20] = pGlobalTXT_LocalizationStrings[288]; - pSkillNames[21] = pGlobalTXT_LocalizationStrings[292]; - pSkillNames[22] = pGlobalTXT_LocalizationStrings[293]; - pSkillNames[23] = pGlobalTXT_LocalizationStrings[294]; - pSkillNames[24] = pGlobalTXT_LocalizationStrings[295]; - pSkillNames[25] = pGlobalTXT_LocalizationStrings[296]; - pSkillNames[26] = pGlobalTXT_LocalizationStrings[297]; - pSkillNames[27] = pGlobalTXT_LocalizationStrings[298]; - pSkillNames[28] = pGlobalTXT_LocalizationStrings[299]; - pSkillNames[29] = pGlobalTXT_LocalizationStrings[300]; - pSkillNames[30] = pGlobalTXT_LocalizationStrings[50]; - pSkillNames[31] = pGlobalTXT_LocalizationStrings[77]; - pSkillNames[32] = pGlobalTXT_LocalizationStrings[88]; - pSkillNames[33] = pGlobalTXT_LocalizationStrings[89]; - pSkillNames[34] = pGlobalTXT_LocalizationStrings[90]; - pSkillNames[35] = pGlobalTXT_LocalizationStrings[95]; - pSkillNames[36] = pGlobalTXT_LocalizationStrings[301]; - pSkillNames[37] = pGlobalTXT_LocalizationStrings[153]; - - aSpellSchoolNames[0] = pGlobalTXT_LocalizationStrings[87]; - aSpellSchoolNames[1] = pGlobalTXT_LocalizationStrings[6]; - aSpellSchoolNames[2] = pGlobalTXT_LocalizationStrings[240]; - aSpellSchoolNames[3] = pGlobalTXT_LocalizationStrings[70]; - aSpellSchoolNames[4] = pGlobalTXT_LocalizationStrings[214]; - aSpellSchoolNames[5] = pGlobalTXT_LocalizationStrings[142]; - aSpellSchoolNames[6] = pGlobalTXT_LocalizationStrings[29]; - aSpellSchoolNames[7] = pGlobalTXT_LocalizationStrings[133]; - aSpellSchoolNames[8] = pGlobalTXT_LocalizationStrings[54]; - - aAttributeNames[0] = pGlobalTXT_LocalizationStrings[144]; - aAttributeNames[1] = pGlobalTXT_LocalizationStrings[116]; - aAttributeNames[2] = pGlobalTXT_LocalizationStrings[163]; - aAttributeNames[3] = pGlobalTXT_LocalizationStrings[75]; - aAttributeNames[4] = pGlobalTXT_LocalizationStrings[1]; - aAttributeNames[5] = pGlobalTXT_LocalizationStrings[211]; - aAttributeNames[6] = pGlobalTXT_LocalizationStrings[136]; - - aAMPMNames[0] = pGlobalTXT_LocalizationStrings[472]; - aAMPMNames[1] = pGlobalTXT_LocalizationStrings[473]; - - aNPCProfessionNames[0] = pGlobalTXT_LocalizationStrings[153]; - aNPCProfessionNames[1] = pGlobalTXT_LocalizationStrings[308]; - aNPCProfessionNames[2] = pGlobalTXT_LocalizationStrings[309]; - aNPCProfessionNames[3] = pGlobalTXT_LocalizationStrings[7]; - aNPCProfessionNames[4] = pGlobalTXT_LocalizationStrings[306]; - aNPCProfessionNames[5] = pGlobalTXT_LocalizationStrings[310]; - aNPCProfessionNames[6] = pGlobalTXT_LocalizationStrings[311]; - aNPCProfessionNames[7] = pGlobalTXT_LocalizationStrings[312]; - aNPCProfessionNames[8] = pGlobalTXT_LocalizationStrings[313]; - aNPCProfessionNames[9] = pGlobalTXT_LocalizationStrings[314]; - aNPCProfessionNames[10] = pGlobalTXT_LocalizationStrings[105]; - aNPCProfessionNames[11] = pGlobalTXT_LocalizationStrings[315]; - aNPCProfessionNames[12] = pGlobalTXT_LocalizationStrings[316]; - aNPCProfessionNames[13] = pGlobalTXT_LocalizationStrings[317]; - aNPCProfessionNames[14] = pGlobalTXT_LocalizationStrings[115]; - aNPCProfessionNames[15] = pGlobalTXT_LocalizationStrings[318]; - aNPCProfessionNames[16] = pGlobalTXT_LocalizationStrings[319]; - aNPCProfessionNames[17] = pGlobalTXT_LocalizationStrings[320]; - aNPCProfessionNames[18] = pGlobalTXT_LocalizationStrings[321]; - aNPCProfessionNames[19] = pGlobalTXT_LocalizationStrings[322]; - aNPCProfessionNames[20] = pGlobalTXT_LocalizationStrings[323]; - aNPCProfessionNames[21] = pGlobalTXT_LocalizationStrings[293]; - aNPCProfessionNames[22] = pGlobalTXT_LocalizationStrings[324]; - aNPCProfessionNames[23] = pGlobalTXT_LocalizationStrings[498]; - aNPCProfessionNames[24] = pGlobalTXT_LocalizationStrings[525]; - aNPCProfessionNames[25] = pGlobalTXT_LocalizationStrings[327]; - aNPCProfessionNames[26] = pGlobalTXT_LocalizationStrings[328]; - aNPCProfessionNames[27] = pGlobalTXT_LocalizationStrings[329]; - aNPCProfessionNames[28] = pGlobalTXT_LocalizationStrings[330]; - aNPCProfessionNames[29] = pGlobalTXT_LocalizationStrings[331]; - aNPCProfessionNames[30] = pGlobalTXT_LocalizationStrings[332]; - aNPCProfessionNames[31] = pGlobalTXT_LocalizationStrings[333]; - aNPCProfessionNames[32] = pGlobalTXT_LocalizationStrings[334]; - aNPCProfessionNames[33] = pGlobalTXT_LocalizationStrings[335]; - aNPCProfessionNames[34] = pGlobalTXT_LocalizationStrings[336]; - aNPCProfessionNames[35] = pGlobalTXT_LocalizationStrings[337]; - aNPCProfessionNames[36] = pGlobalTXT_LocalizationStrings[338]; - aNPCProfessionNames[37] = pGlobalTXT_LocalizationStrings[339]; - aNPCProfessionNames[38] = pGlobalTXT_LocalizationStrings[340]; - aNPCProfessionNames[39] = pGlobalTXT_LocalizationStrings[341]; - aNPCProfessionNames[40] = pGlobalTXT_LocalizationStrings[342]; - aNPCProfessionNames[41] = pGlobalTXT_LocalizationStrings[343]; - aNPCProfessionNames[42] = pGlobalTXT_LocalizationStrings[596]; - aNPCProfessionNames[43] = pGlobalTXT_LocalizationStrings[345]; - aNPCProfessionNames[44] = pGlobalTXT_LocalizationStrings[346]; - aNPCProfessionNames[45] = pGlobalTXT_LocalizationStrings[347]; - aNPCProfessionNames[46] = pGlobalTXT_LocalizationStrings[348]; - aNPCProfessionNames[47] = pGlobalTXT_LocalizationStrings[349]; - aNPCProfessionNames[48] = pGlobalTXT_LocalizationStrings[350]; - aNPCProfessionNames[49] = pGlobalTXT_LocalizationStrings[597]; - aNPCProfessionNames[50] = pGlobalTXT_LocalizationStrings[352]; - aNPCProfessionNames[51] = pGlobalTXT_LocalizationStrings[353]; - aNPCProfessionNames[52] = pGlobalTXT_LocalizationStrings[598]; - aNPCProfessionNames[53] = pGlobalTXT_LocalizationStrings[344]; - aNPCProfessionNames[54] = pGlobalTXT_LocalizationStrings[26]; - aNPCProfessionNames[55] = pGlobalTXT_LocalizationStrings[599]; - aNPCProfessionNames[56] = pGlobalTXT_LocalizationStrings[21]; - aNPCProfessionNames[57] = pGlobalTXT_LocalizationStrings[600]; - aNPCProfessionNames[58] = pGlobalTXT_LocalizationStrings[370]; - - aMoonPhaseNames[0] = pGlobalTXT_LocalizationStrings[150]; - aMoonPhaseNames[1] = pGlobalTXT_LocalizationStrings[171]; - aMoonPhaseNames[2] = pGlobalTXT_LocalizationStrings[102]; - aMoonPhaseNames[3] = pGlobalTXT_LocalizationStrings[169]; - aMoonPhaseNames[4] = pGlobalTXT_LocalizationStrings[92]; - - aSpellNames[0] = pGlobalTXT_LocalizationStrings[202]; - aSpellNames[1] = pGlobalTXT_LocalizationStrings[204]; - aSpellNames[2] = pGlobalTXT_LocalizationStrings[219]; - aSpellNames[3] = pGlobalTXT_LocalizationStrings[215]; - aSpellNames[4] = pGlobalTXT_LocalizationStrings[208]; - aSpellNames[5] = pGlobalTXT_LocalizationStrings[454]; - aSpellNames[6] = pGlobalTXT_LocalizationStrings[24]; - aSpellNames[7] = pGlobalTXT_LocalizationStrings[455]; - aSpellNames[8] = pGlobalTXT_LocalizationStrings[441]; - aSpellNames[9] = pGlobalTXT_LocalizationStrings[440]; - aSpellNames[10] = pGlobalTXT_LocalizationStrings[218]; - aSpellNames[11] = pGlobalTXT_LocalizationStrings[217]; - aSpellNames[12] = pGlobalTXT_LocalizationStrings[213]; - aSpellNames[13] = pGlobalTXT_LocalizationStrings[462]; - aSpellNames[14] = pGlobalTXT_LocalizationStrings[279]; - aSpellNames[15] = pGlobalTXT_LocalizationStrings[442]; - aSpellNames[16] = pGlobalTXT_LocalizationStrings[452]; - aSpellNames[17] = pGlobalTXT_LocalizationStrings[194]; - aSpellNames[18] = pGlobalTXT_LocalizationStrings[456]; - aSpellNames[19] = pGlobalTXT_LocalizationStrings[453]; - aSpellNames[20] = pGlobalTXT_LocalizationStrings[202]; - aSpellNames[21] = pGlobalTXT_LocalizationStrings[443]; - aSpellNames[22] = pGlobalTXT_LocalizationStrings[204]; - aSpellNames[23] = pGlobalTXT_LocalizationStrings[208]; - aSpellNames[24] = pGlobalTXT_LocalizationStrings[221]; - aSpellNames[25] = pGlobalTXT_LocalizationStrings[24]; - aSpellNames[26] = pGlobalTXT_LocalizationStrings[228]; - aSpellNames[27] = pGlobalTXT_LocalizationStrings[441]; - aSpellNames[28] = pGlobalTXT_LocalizationStrings[440]; - aSpellNames[29] = pGlobalTXT_LocalizationStrings[213]; - aSpellNames[30] = pGlobalTXT_LocalizationStrings[229]; - aSpellNames[31] = pGlobalTXT_LocalizationStrings[233]; - aSpellNames[32] = pGlobalTXT_LocalizationStrings[234]; - aSpellNames[33] = pGlobalTXT_LocalizationStrings[279]; - aSpellNames[34] = pGlobalTXT_LocalizationStrings[442]; - aSpellNames[35] = pGlobalTXT_LocalizationStrings[235]; - aSpellNames[36] = pGlobalTXT_LocalizationStrings[246]; - aSpellNames[37] = pGlobalTXT_LocalizationStrings[247]; - aSpellNames[38] = pGlobalTXT_LocalizationStrings[248]; - aSpellNames[39] = pGlobalTXT_LocalizationStrings[674]; - aSpellNames[40] = pGlobalTXT_LocalizationStrings[249]; - aSpellNames[41] = pGlobalTXT_LocalizationStrings[258]; - aSpellNames[42] = pGlobalTXT_LocalizationStrings[194]; - aSpellNames[43] = pGlobalTXT_LocalizationStrings[657]; - } -//----- (00413FF1) -------------------------------------------------------- -void SetMonthNames() -{ - aMonthNames[0] = pGlobalTXT_LocalizationStrings[415]; - aMonthNames[1] = pGlobalTXT_LocalizationStrings[416]; - aMonthNames[2] = pGlobalTXT_LocalizationStrings[417]; - aMonthNames[3] = pGlobalTXT_LocalizationStrings[418]; - aMonthNames[4] = pGlobalTXT_LocalizationStrings[419]; - aMonthNames[5] = pGlobalTXT_LocalizationStrings[420]; - aMonthNames[6] = pGlobalTXT_LocalizationStrings[421]; - aMonthNames[7] = pGlobalTXT_LocalizationStrings[422]; - aMonthNames[8] = pGlobalTXT_LocalizationStrings[423]; - aMonthNames[9] = pGlobalTXT_LocalizationStrings[424]; - aMonthNames[10] = pGlobalTXT_LocalizationStrings[425]; - aMonthNames[11] = pGlobalTXT_LocalizationStrings[426]; -} - -//----- (0041406F) -------------------------------------------------------- -void SetDayNames() -{ - aDayNames[0] = pGlobalTXT_LocalizationStrings[145]; - aDayNames[1] = pGlobalTXT_LocalizationStrings[230]; - aDayNames[2] = pGlobalTXT_LocalizationStrings[243]; - aDayNames[3] = pGlobalTXT_LocalizationStrings[227]; - aDayNames[4] = pGlobalTXT_LocalizationStrings[91]; - aDayNames[5] = pGlobalTXT_LocalizationStrings[188]; - aDayNames[6] = pGlobalTXT_LocalizationStrings[222]; -} - -//----- (004140BB) -------------------------------------------------------- -void SetSpellSchoolNames() -{ - aSpellSchoolNames[0] = pGlobalTXT_LocalizationStrings[87]; - aSpellSchoolNames[1] = pGlobalTXT_LocalizationStrings[6]; - aSpellSchoolNames[2] = pGlobalTXT_LocalizationStrings[240]; - aSpellSchoolNames[3] = pGlobalTXT_LocalizationStrings[70]; - aSpellSchoolNames[4] = pGlobalTXT_LocalizationStrings[214]; - aSpellSchoolNames[5] = pGlobalTXT_LocalizationStrings[142]; - aSpellSchoolNames[6] = pGlobalTXT_LocalizationStrings[29]; - aSpellSchoolNames[7] = pGlobalTXT_LocalizationStrings[133]; - aSpellSchoolNames[8] = pGlobalTXT_LocalizationStrings[54]; -} - -//----- (0041411B) -------------------------------------------------------- -void SetAttributeNames() -{ - aAttributeNames[0] = pGlobalTXT_LocalizationStrings[144]; - aAttributeNames[1] = pGlobalTXT_LocalizationStrings[116]; - aAttributeNames[2] = pGlobalTXT_LocalizationStrings[163]; - aAttributeNames[3] = pGlobalTXT_LocalizationStrings[75]; - aAttributeNames[4] = pGlobalTXT_LocalizationStrings[1]; - aAttributeNames[5] = pGlobalTXT_LocalizationStrings[211]; - aAttributeNames[6] = pGlobalTXT_LocalizationStrings[136]; -} -//----- (00410AF5) -------------------------------------------------------- -void SetMoonPhaseNames() -{ - aMoonPhaseNames[0] = pGlobalTXT_LocalizationStrings[150]; - aMoonPhaseNames[1] = pGlobalTXT_LocalizationStrings[171]; - aMoonPhaseNames[2] = pGlobalTXT_LocalizationStrings[102]; - aMoonPhaseNames[3] = pGlobalTXT_LocalizationStrings[169]; - aMoonPhaseNames[4] = pGlobalTXT_LocalizationStrings[92]; -} - - diff -r 92eeeb5200f2 -r 68cdef6879a0 texts.h --- a/texts.h Fri Sep 19 00:03:04 2014 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,863 +0,0 @@ -#pragma once -#include -#include - - -int sprintfex(char *buf, const char *format, ...); - - -void SetSomeItemsNames(); -char *RemoveQuotes(char *Str); -void InitializeGameText(); -void SetMoonPhaseNames(); -void SetAttributeNames(); - -struct ci_less : std::binary_function //case insensitive comparator for dictionaries -{ - // case-independent (ci) compare_less binary function - struct nocase_compare : public std::binary_function - { - bool operator() (const unsigned char& c1, const unsigned char& c2) const { - return tolower (c1) < tolower (c2); - } - }; - bool operator() (const std::string & s1, const std::string & s2) const { - return std::lexicographical_compare - (s1.begin (), s1.end (), // source range - s2.begin (), s2.end (), // dest range - nocase_compare ()); // comparison - } -}; -std::vector Tokenize(char* input, const char separator); - -enum GLOBAL_LOCALIZ_INDEX - { - - LOCSTR_AC = 0, //"AC" - LOCSTR_ACCURACY = 1, //"Accuracy" - LOCSTR_BLK_KNIGHT = 2, //"Black Knight" - LOCSTR_SPY = 3, // "Spy" - - LOCSTR_TOWN_PORTAL = 10, // "Town Portal" - - LOCSTR_ASSASIN = 13, // "Assassin" - - LOCSTR_AUTOSAVE = 16, // "Autosave" - - LOCSTR_ATTACK = 18, // "Attack" - LOCSTR_AVAILABLE = 19, //"Available" - - LOCSTR_MONK = 21, //"Monk" - - LOCSTR_AVARDS_FOR = 23, //"Awards for" - - - LOCSTR_RANGER = 31, //"Ranger" - - LOCSTR_CANCEL = 34, //"Cancel" - - - LOCSTR_SELECT_TGT = 39, ///"Select Target" - - LOCSTR_CLASS = 41, // "Class" - - LOCSTR_CONDITION = 47, //"Condition" - - LOCSTR_CREATE_PARTY = 51, //"C R E A T E P A R T Y" - - LOCSTR_DAWN = 55, //"Dawn" - LOCSTR_DAY = 56, //"Day" - LOCSTR_DAYS = 57, /// "Days" - - LOCSTR_PRESS_ESCAPE = 61, // "Press Escape" - - LOCSTR_TROUBLE_LOAD = 63,//"Might and Magic VII is having trouble loading files. - // Please re-install to fix this problem. Note: Re-installing will not destroy your save games." - LOCSTR_DETAIL_TOGGLE = 64, //"Detail Toggle" - - LOCSTR_DMG = 66, /// "Dmg" - - LOCSTR_EMPTY = 72, // "Empty" - - LOCSTR_EXIT = 79, // "Exit" - LOCSTR_EXIT_BLDNG = 80, // "Exit Building" - - LOCSTR_EXPIRIENCE = 83, //"Experience" - - LOCSTR_GRAND = 96, // "Grand" - - LOCSTR_HP = 107, // "HP" - LOCSTR_HIT_POINTS = 108, // "Hit Points" - LOCSTR_HOUR = 109, //"Hour" - LOCSTR_HOURS = 110, //"Hours" - - LOCSTR_ROGUE = 114, //"Rogue" - - LOCSTR_LEVEL = 131, // "Level" - - LOCSTR_LOADING = 135, //"Loading" - - LOCSTR_MIGHT = 144, //"Might" - - LOCSTR_NAME = 149, // "Name" - - LOCSTR_YOU_TO_TRAIN = 147, // "You are eligible to train to %u." - - LOCSTR_STAY_IN_AREA = 156, //"Stay in this Area" - LOCSTR_3DO_COPYRHT = 157, // ""© 1999 The 3DO Company. - - LOCSTR_PLEASE_WAIT = 165, // "Please Wait" - - LOCSTR_REPUTATION = 180, //"Reputation" - - LOCSTR_REST_HEAL_8 = 183, //"Rest & Heal 8 Hours" - - LOCSTR_TIME_ERATHIA = 186, // "Time in Erathia" - - LOCSTR_SAVING = 190, // "Saving" - - LOCSTR_SKILL_POINTS = 207, /// "Skill Points" - - LOCSTR_KNIGHT = 253, //"Knight" - LOCSTR_CAVALIER = 254, //"Cavalier" - LOCSTR_CHAMPION = 255, //"Champion" - LOCSTR_CLERIC = 256, //"Cleric" - LOCSTR_PRIEST = 257, //"Priest" - - LOCSTR_SORCERER = 259, // "Sorcerer" - - LOCSTR_PALADIN = 262, // "Paladin" - - LOCSTR_ARCHER = 265, /// "Archer" - - LOCSTR_DRUID = 268, // "Druid" - - LOCSTR_THIEF = 307, //"Thief" - - LOCSTR_SET_BEACON = 375, // "Set Beacon" - - LOCSTR_HATED = 379,// "Hated" - - LOCSTR_UNFRENDLY = 392, //"Unfriendly" - - LOCSTR_NEITRAL = 399, // "Neutral" - - LOCSTR_FRENDLY = 402, // "Friendly" - - LOCSTR_D_DAYS_TO_S = 404, //"%d days to %s" - LOCSTR_TRAVEL_COST = 405, //"Travel Cost %d gold" - - LOCSTR_ENTER_S = 411, // "Enter %s" - - LOCSTR_IS_IN_NO_COND = 427, // "%s is in no condition to %s" - - LOCSTR_S_THE_S = 429, //"%s the %s" - - LOCSTR_NORMAL = 431, //"Normal" - LOCSTR_MASTER = 432, //"Master" - LOCSTR_EXPERT = 433, //"Expert" - LOCSTR_LIKED = 434, //"Liked" - - LOCSTR_ACTIVE_SPELL = 450, // "Active Spells: %s" - - LOCSTR_READING = 505, ///"Reading..." - - LOCSTR_NOTHING_HERE = 521, // "Nothing here" - - LOCSTR_SP_COST = 522, //"SP Cost" - LOCSTR_RECALL_BEACON = 523, // "Recall Beacon" - - LOCSTR_TIME = 526, //"Time" - - LOCSTR_NEED_MORE_EXP = 538, //"You need %d more experience to train to level %d" - - LOCSTR_IDENT_ITEM = 541, // "Identify Items" - - LOCSTR_DUSK = 566, //"Dusk" - LOCSTR_NIGHT = 567, // "Night" - - LOCSTR_NO_SAVING = 583, //"No saving in the Arena" - - LOCSTR_AUTOSAVE_MM7 = 613, // "AutoSave.MM7" - - LOCSTR_BONUS = 623, //"Bonus" - - LOCSTR_GAME_SAVED = 656, // "Game Saved!" - - MAX_LOC_STRINGS =677 - - }; - - extern std::array pGlobalTXT_LocalizationStrings; - -/* - -+ [4] 0x04102dab "Afraid" unsigned char * -+ [5] 0x04102db5 "Age" unsigned char * -+ [6] 0x04102dbc "Air" unsigned char * -+ [7] 0x04102dc3 "Alchemist" unsigned char * -+ [8] 0x04102dd0 "Obelisk Notes" unsigned char * -+ [9] 0x04102de1 "Congratulations!" unsigned char * - -+ [11] 0x04102e06 "Armor" unsigned char * -+ [0xc] 0x04102e10 "Armor Class" unsigned char * - -+ [0xe] 0x04102e2d "Asleep" unsigned char * -+ [0xf] 0x04102e38 "Assertion failed at %d in %s" unsigned char * - -+ [17] 0x04102e66 "Exp." unsigned char * - - -+ [20] 0x04102e88 "Available Skills" unsigned char * - -+ [22] 0x04102ea6 "Awards" unsigned char * - -+ [24] 0x04102ec0 "Fire Res" unsigned char * -+ [25] 0x04102ecd "Balance" unsigned char * -+ [26] 0x04102ed9 "Initiate" unsigned char * -+ [27] 0x04102ee6 "Ninja" unsigned char * -+ [28] 0x04102ef0 "Villain" unsigned char * -+ [29] 0x04102efc "Body" unsigned char * -+ [30] 0x04102f05 "Bonus" unsigned char * - -+ [32] 0x04102f1a "Broken Item" unsigned char * -+ [33] 0x04102f2a "Ranger Lord" unsigned char * -+ [34] 0x04102f3a "Cancel" unsigned char * -+ [35] 0x04102f45 "Town Portal to %s" unsigned char * -+ [36] 0x04102f5b "%s can not be used that way" unsigned char * -+ [37] 0x04102f7b "Total Time:" unsigned char * -+ [38] 0x04102f8b "Cast Spell" unsigned char * - -+ [0x28] 0x04102fac "Bounty Hunter" unsigned char * - -+ [0x2a] 0x04102fc8 "Clerk" unsigned char * -+ [0x2b] 0x04102fd2 "Cold" unsigned char * -+ [0x2c] 0x04102fdb "Priest of Light" unsigned char * -+ [45] 0x04102fef "Cond" unsigned char * -+ [46] 0x04102ff8 "Priest of Dark" unsigned char * - -+ [48] 0x04103019 "Warlock" unsigned char * -+ [49] 0x04103025 "Lich" unsigned char * -+ [50] 0x0410302e "Dodging" unsigned char * - -+ [52] 0x04103056 "Cursed" unsigned char * -+ [0x35] 0x04103061 "Damage" unsigned char * -+ [0x36] 0x0410306c "Dark" unsigned char * - - - -+ [58] 0x0410308f "Dead" unsigned char * -+ [59] 0x04103098 "Internal Error" unsigned char * -+ [60] 0x041030ab "Deposit" unsigned char * - -+ [62] 0x041030c8 "Might and Magic VII requires your desktop to be in 16bit (32k or 65k) Color mode in order to operate in a window." unsigned char * - - -+ [65] 0x041031e6 "Diseased" unsigned char * - -+ [0x43] 0x041031fb "%s does not have the skill" unsigned char * -+ [68] 0x0410321a "Donate" unsigned char * -+ [69] 0x04103225 "Drunk" unsigned char * -+ [70] 0x0410322f "Earth" unsigned char * -+ [71] 0x04103239 "Electricity" unsigned char * - -+ [73] 0x04103253 "Enter" unsigned char * -+ [74] 0x0410325d "End Conversation" unsigned char * -+ [75] 0x04103272 "Endurance" unsigned char * -+ [0x4c] 0x04103280 "Eradicated" unsigned char * -+ [0x4d] 0x0410328f "Unarmed" unsigned char * -+ [0x4e] 0x0410329b "Calendar" unsigned char * -+ [0x4f] 0x041032a8 "Exit" unsigned char * - -+ [81] 0x041032c3 "Exit Rest" unsigned char * -+ [82] 0x041032d1 "Are you sure? Click again to quit" unsigned char * - -+ [84] 0x04103307 "Fame" unsigned char * -+ [85] 0x04103310 "Potion Notes" unsigned char * -+ [86] 0x04103321 "Fill Packs to %d days for %d gold" unsigned char * -+ [87] 0x04103347 "Fire" unsigned char * -+ [88] 0x04103350 "Identify Monster" unsigned char * -+ [89] 0x04103365 "Armsmaster" unsigned char * -+ [90] 0x04103374 "Stealing" unsigned char * -+ [91] 0x04103381 "Friday" unsigned char * -+ [92] 0x0410338c "Full" unsigned char * -+ [93] 0x04103395 "Game Options" unsigned char * -+ [94] 0x041033a6 "Your score: %lu" unsigned char * -+ [95] 0x041033ba "Alchemy" unsigned char * - - - -+ [97] 0x041033d0 "Gold" unsigned char * -+ [98] 0x041033d9 "Good" unsigned char * -+ [99] 0x041033e2 "Human" unsigned char * -+ [100] 0x041033ed "Guard" unsigned char * -+ [101] 0x041033f8 "Dwarf" unsigned char * -+ [102] 0x04103403 "Half" unsigned char * -+ [103] 0x0410340d "Elf" unsigned char * -+ [104] 0x04103416 "Heal" unsigned char * -+ [105] 0x04103420 "Healer" unsigned char * -+ [106] 0x0410342c "Goblin" unsigned char * - -+ [108] 0x04103440 "Hit Points" unsigned char * - -+ [111] 0x04103465 "Grand" unsigned char * -+ [112] 0x04103470 "How Much?" unsigned char * -+ [113] 0x0410347f "Identify" unsigned char * - -+ [115] 0x04103498 "Instructor" unsigned char * -+ [116] 0x041034a8 "Intellect" unsigned char * -+ [117] 0x041034b7 "Insane" unsigned char * -+ [118] 0x041034c3 "We hope that you've enjoyed playing Might and Magic VII as much as we did making it. We have saved this screen as MM7_WIN.PCX in your MM7 directory. You can print it out as proof of your accomplishment." unsigned char * -+ [119] 0x04103593 "Master Archer" unsigned char * -+ [120] 0x041035a6 "Inventory" unsigned char * -+ [121] 0x041035b5 "Permanent" unsigned char * -+ [122] 0x041035c4 "Join" unsigned char * -+ [123] 0x041035ce "Miscellaneous Notes" unsigned char * -+ [124] 0x041035e7 "Sniper" unsigned char * -+ [125] 0x041035f3 "+2 Skill Points!" unsigned char * -+ [126] 0x04103609 "Do you wish to leave %s?" unsigned char * -+ [127] 0x04103627 "No Text!" unsigned char * -+ [128] 0x04103635 "It will take %d days to travel to %s." unsigned char * -+ [129] 0x04103660 "%s the Level %u %s" unsigned char * -+ [130] 0x04103678 "Player" unsigned char * - -+ [132] 0x0410368f "Years" unsigned char * -+ [133] 0x0410369a "Light" unsigned char * -+ [134] 0x041036a5 "Buy Standard" unsigned char * - -+ [136] 0x041036c4 "Luck" unsigned char * -+ [137] 0x041036ce "Fountain Notes" unsigned char * -+ [138] 0x041036e2 "Magic" unsigned char * -+ [139] 0x041036ed "Maps" unsigned char * -+ [140] 0x041036f7 "Your packs are already full!" unsigned char * -+ [141] 0x04103719 "Seer Notes" unsigned char * -+ [142] 0x04103729 "Mind" unsigned char * -+ [143] 0x04103733 "Misc" unsigned char * - -+ [145] 0x04103748 "Monday" unsigned char * -+ [146] 0x04103754 "Month" unsigned char * - -+ [148] 0x04103785 "Months" unsigned char * - -+ [150] 0x0410379b "New" unsigned char * -+ [151] 0x041037a4 "Congratulations Adventurer." unsigned char * -+ [152] 0x041037c5 "Buy Special" unsigned char * -+ [153] 0x041037d6 "None" unsigned char * -+ [154] 0x041037e0 "Auto Notes" unsigned char * -+ [155] 0x041037f0 "You don't have enough gold" unsigned char * - -+ [157] 0x04103827 ""© 1999 The 3DO Company. All Rights Reserved. Might and Magic, Blood and Honor, New World Computing, 3DO, and their respective logos, are trademarks and/or service marks of The 3DO Company in the U.S. and other countries. All other trademarks belong to their respective owners. New World Computing is a division of The 3DO Company."" unsigned char * -+ [158] 0x0410397d "Bootleg Bay East" unsigned char * -+ [159] 0x04103993 "Display Inventory" unsigned char * -+ [160] 0x041039aa "Learn Skills" unsigned char * -+ [161] 0x041039bc "Steal" unsigned char * -+ [162] 0x041039c7 "Paralyzed" unsigned char * -+ [163] 0x041039d6 "Personality" unsigned char * -+ [164] 0x041039e7 "%s hits %s for %lu damage" unsigned char * - -+ [166] 0x04103a17 "Poison" unsigned char * -+ [167] 0x04103a23 "- The Might and Magic VII Development Team." unsigned char * -+ [168] 0x04103a54 "Points" unsigned char * -+ [169] 0x04103a60 "Three Quarter" unsigned char * -+ [170] 0x04103a73 "QSpell" unsigned char * -+ [171] 0x04103a7f "Quarter" unsigned char * -+ [172] 0x04103a8c "Quick Spell" unsigned char * -+ [173] 0x04103a9d "Quick Reference" unsigned char * -+ [174] 0x04103ab2 "Current Quests" unsigned char * -+ [175] 0x04103ac6 "%s inflicts %lu points killing %s" unsigned char * -+ [176] 0x04103aed "Might and Magic VII has detected an internal error and will be forced to close. Would you like us to autosave your game before closing?" unsigned char * -+ [177] 0x04103b7b "Standard" unsigned char * -+ [178] 0x04103b89 "Rent Room for %d gold" unsigned char * -+ [179] 0x04103ba4 "Repair" unsigned char * - -+ [181] 0x04103bc0 "Steal %24" unsigned char * -+ [182] 0x04103bcf "Rest" unsigned char * - -+ [184] 0x04103bf2 "Reinstall Necessary" unsigned char * -+ [185] 0x04103c0b "Steal item" unsigned char * - -+ [187] 0x04103c30 "Stolen" unsigned char * -+ [188] 0x04103c3c "Saturday" unsigned char * -+ [189] 0x04103c4a "%s shoots %s for %lu points" unsigned char * - -+ [191] 0x04103c77 "You've been banned from this shop!" unsigned char * -+ [192] 0x04103c9f "Scroll Up" unsigned char * -+ [193] 0x04103cae "Scroll Down" unsigned char * -+ [194] 0x04103cbf "Water Res" unsigned char * -+ [195] 0x04103cce "Select the Item to Buy" unsigned char * -+ [196] 0x04103cea "Select the Special Item to Buy" unsigned char * -+ [197] 0x04103d0e "Select the Item to Identify" unsigned char * -+ [198] 0x04103d2f "Select the Item to Repair" unsigned char * -+ [199] 0x04103d4e "Select the Item to Sell" unsigned char * -+ [200] 0x04103d6b "Sell" unsigned char * -+ [201] 0x04103d75 "Are you sure? Click again to start a New Game" unsigned char * -+ [202] 0x04103da9 "Air Res" unsigned char * -+ [203] 0x04103db6 "Shoot" unsigned char * -+ [204] 0x04103dc1 "Body Res" unsigned char * -+ [205] 0x04103dcf "Skills" unsigned char * -+ [206] 0x04103ddb "Skills for" unsigned char * - -+ [208] 0x04103dfd "Earth Res" unsigned char * -+ [209] 0x04103e0c "SP" unsigned char * -+ [210] 0x04103e14 "Special" unsigned char * -+ [211] 0x04103e21 "Speed" unsigned char * -+ [212] 0x04103e2c "Spell Points" unsigned char * -+ [213] 0x04103e3e "Mind Res" unsigned char * -+ [214] 0x04103e4c "Spirit" unsigned char * -+ [215] 0x04103e58 "Detect Life" unsigned char * -+ [216] 0x04103e69 "Stats" unsigned char * -+ [217] 0x04103e74 "Invisibility" unsigned char * -+ [218] 0x04103e86 "Immolation" unsigned char * -+ [219] 0x04103e96 "Day of the Gods" unsigned char * -+ [220] 0x04103eab "Stoned" unsigned char * -+ [221] 0x04103eb7 "Fate" unsigned char * -+ [222] 0x04103ec1 "Sunday" unsigned char * -+ [223] 0x00000000 unsigned char * -+ [224] 0x00000000 unsigned char * -+ [225] 0x04103ed9 "Grandmaster" unsigned char * -+ [226] 0x04103eea ""Gamma controls the relative ""brightness"" of the game. May vary depending on your monitor."" unsigned char * -+ [227] 0x04103f4e "Thursday" unsigned char * -+ [228] 0x04103f5c "Hammerhands" unsigned char * -+ [229] 0x04103f6d "Pain Reflection" unsigned char * -+ [230] 0x04103f82 "Tuesday" unsigned char * -+ [231] 0x04103f8f "Unconscious" unsigned char * -+ [232] 0x04103fa0 "Not Identified" unsigned char * -+ [233] 0x04103fb4 "Preservation" unsigned char * -+ [234] 0x04103fc6 "Regeneration" unsigned char * -+ [235] 0x04103fd8 "Temp Accuracy" unsigned char * -+ [236] 0x04103feb "Wait without healing" unsigned char * -+ [237] 0x04104005 "Wait until Dawn" unsigned char * -+ [238] 0x0410401a "Wait 5 Minutes" unsigned char * -+ [239] 0x0410402e "Wait 1 Hour" unsigned char * -+ [240] 0x0410403f "Water" unsigned char * -+ [241] 0x0410404a "Weak" unsigned char * -+ [242] 0x04104054 "Weapons" unsigned char * -+ [243] 0x04104061 "Wednesday" unsigned char * -+ [244] 0x04104070 "Withdraw" unsigned char * -+ [245] 0x0410407e "Year" unsigned char * -+ [246] 0x04104088 "Temp Endurance" unsigned char * -+ [247] 0x0410409c "Temp Intelligence" unsigned char * -+ [248] 0x041040b3 "Temp Luck" unsigned char * -+ [249] 0x041040c2 "Temp Personality" unsigned char * -+ [250] 0x041040d8 "You need %s" unsigned char * -+ [251] 0x041040e9 "Zoom In" unsigned char * -+ [252] 0x041040f6 "Zoom Out" unsigned char * - - -+ [258] 0x04104144 "Temp Speed" unsigned char * - -+ [260] 0x04104162 "Wizard" unsigned char * -+ [261] 0x0410416e "Archmage" unsigned char * - -+ [263] 0x04104189 "Crusader" unsigned char * -+ [264] 0x04104197 "Hero" unsigned char * - -+ [266] 0x041041ad "DISCARD A CARD" unsigned char * -+ [267] 0x041041c1 "Warrior Mage" unsigned char * - -+ [269] 0x041041de "Greater Druid" unsigned char * -+ [270] 0x041041f1 "Arch Druid" unsigned char * -+ [271] 0x04104201 "Staff" unsigned char * -+ [272] 0x0410420c "Sword" unsigned char * -+ [273] 0x04104217 "Dagger" unsigned char * -+ [274] 0x04104223 "Axe" unsigned char * -+ [275] 0x0410422c "Spear" unsigned char * -+ [276] 0x04104237 "Bow" unsigned char * -+ [277] 0x04104240 "Mace" unsigned char * -+ [278] 0x0410424a "Blaster" unsigned char * -+ [279] 0x04104257 "Shield" unsigned char * -+ [280] 0x04104263 "Leather" unsigned char * -+ [281] 0x04104270 "Chain" unsigned char * -+ [282] 0x0410427b "Plate" unsigned char * -+ [283] 0x04104286 "Fire Magic" unsigned char * -+ [284] 0x04104296 "Air Magic" unsigned char * -+ [285] 0x041042a5 "Water Magic" unsigned char * -+ [286] 0x041042b6 "Earth Magic" unsigned char * -+ [287] 0x041042c7 "Light Magic" unsigned char * -+ [288] 0x041042d8 "Dark Magic" unsigned char * -+ [289] 0x041042e8 "Spirit Magic" unsigned char * -+ [290] 0x041042fa "Mind Magic" unsigned char * -+ [291] 0x0410430a "Body Magic" unsigned char * -+ [292] 0x0410431a "Identify Item" unsigned char * -+ [293] 0x0410432d "Merchant" unsigned char * -+ [294] 0x0410433b "Repair Item" unsigned char * -+ [295] 0x0410434c "Body Building" unsigned char * -+ [296] 0x0410435f "Meditation" unsigned char * -+ [297] 0x0410436f "Perception" unsigned char * -+ [298] 0x0410437f "Diplomacy" unsigned char * -+ [299] 0x0410438e "Thievery" unsigned char * -+ [300] 0x0410439c "Disarm Trap" unsigned char * -+ [301] 0x041043ad "Learning" unsigned char * -+ [302] 0x041043bb "%s stole %d gold!" unsigned char * -+ [303] 0x041043d2 "Noble" unsigned char * -+ [304] 0x041043dd "Official" unsigned char * -+ [305] 0x041043eb "Peasant" unsigned char * -+ [306] 0x041043f8 "Scholar" unsigned char * - -+ [308] 0x04104410 "Smith" unsigned char * -+ [309] 0x0410441b "Armorer" unsigned char * -+ [310] 0x04104428 "Guide" unsigned char * -+ [311] 0x04104433 "Tracker" unsigned char * -+ [312] 0x04104440 "Pathfinder" unsigned char * -+ [313] 0x04104450 "Sailor" unsigned char * -+ [314] 0x0410445c "Navigator" unsigned char * -+ [315] 0x0410446b "Expert Healer" unsigned char * -+ [316] 0x0410447e "Master Healer" unsigned char * -+ [317] 0x04104491 "Teacher" unsigned char * -+ [318] 0x0410449e "Arms Master" unsigned char * -+ [319] 0x041044af "Weapons Master" unsigned char * -+ [320] 0x041044c3 "Apprentice" unsigned char * -+ [321] 0x041044d3 "Mystic" unsigned char * -+ [322] 0x041044df "Spell Master" unsigned char * -+ [323] 0x041044f1 "Trader" unsigned char * -+ [324] 0x041044fd "Scout" unsigned char * -+ [325] 0x04104508 "Counselor" unsigned char * -+ [326] 0x04104517 "Barrister" unsigned char * -+ [327] 0x04104526 "Tinker" unsigned char * -+ [328] 0x04104532 "Locksmith" unsigned char * -+ [329] 0x04104541 "Fool" unsigned char * -+ [330] 0x0410454b "Chimney Sweep" unsigned char * -+ [331] 0x0410455e "Porter" unsigned char * -+ [332] 0x0410456a "Quarter Master" unsigned char * -+ [333] 0x0410457e "Factor" unsigned char * -+ [334] 0x0410458a "Banker" unsigned char * -+ [335] 0x04104596 "Cook" unsigned char * -+ [336] 0x041045a0 "Chef" unsigned char * -+ [337] 0x041045aa "Horseman" unsigned char * -+ [338] 0x041045b8 "Bard" unsigned char * -+ [339] 0x041045c2 "Enchanter" unsigned char * -+ [340] 0x041045d1 "Cartographer" unsigned char * -+ [341] 0x041045e3 "Wind Master" unsigned char * -+ [342] 0x041045f4 "Water Master" unsigned char * -+ [343] 0x04104606 "Gate Master" unsigned char * -+ [344] 0x04104617 "Acolyte" unsigned char * -+ [345] 0x04104624 "Piper" unsigned char * -+ [346] 0x0410462f "Explorer" unsigned char * -+ [347] 0x0410463d "Pirate" unsigned char * -+ [348] 0x04104649 "Squire" unsigned char * -+ [349] 0x04104655 "Psychic" unsigned char * -+ [350] 0x04104662 "Gypsy" unsigned char * -+ [351] 0x0410466d "Negotiator" unsigned char * -+ [352] 0x0410467d "Duper" unsigned char * -+ [353] 0x04104688 "Burglar" unsigned char * -+ [354] 0x04104695 "Serf" unsigned char * -+ [355] 0x0410469f "Tailor" unsigned char * -+ [356] 0x041046ab "Laborer" unsigned char * -+ [357] 0x041046b8 "Farmer" unsigned char * -+ [358] 0x041046c4 "Cooper" unsigned char * -+ [359] 0x041046d0 "Potter" unsigned char * -+ [360] 0x041046dc "Weaver" unsigned char * -+ [361] 0x041046e8 "Cobbler" unsigned char * -+ [362] 0x041046f5 "Ditch Digger" unsigned char * -+ [363] 0x04104707 "Miller" unsigned char * -+ [364] 0x04104713 "Carpenter" unsigned char * -+ [365] 0x04104722 "Stone Cutter" unsigned char * -+ [366] 0x04104734 "Jester" unsigned char * -+ [367] 0x04104740 "Trapper" unsigned char * -+ [368] 0x0410474d "Beggar" unsigned char * -+ [369] 0x04104759 "Rustler" unsigned char * -+ [370] 0x04104766 "Hunter" unsigned char * -+ [371] 0x04104772 "Scribe" unsigned char * -+ [372] 0x0410477e "Missionary" unsigned char * -+ [373] 0x0410478e "Follower of Baa" unsigned char * -+ [374] 0x041047a3 "Gambler" unsigned char * - -+ [376] 0x041047c0 "%s was caught stealing!" unsigned char * -+ [377] 0x041047dd "%s failed to steal anything!" unsigned char * -+ [378] 0x041047ff ""%s %d, %d"" unsigned char * - -+ [380] 0x0410481b "You already know the %s spell" unsigned char * -+ [381] 0x0410483e "You don't have the skill to learn %s" unsigned char * -+ [382] 0x04104868 "That player is %s" unsigned char * -+ [383] 0x0410487f "his" unsigned char * -+ [384] 0x04104888 "her" unsigned char * -+ [385] 0x04104891 "sir" unsigned char * -+ [386] 0x0410489a "Sir" unsigned char * -+ [387] 0x041048a3 "lady" unsigned char * -+ [388] 0x041048ad "Lord" unsigned char * -+ [389] 0x041048b7 "Lady" unsigned char * -+ [390] 0x041048c1 "brother" unsigned char * -+ [391] 0x041048ce "sister" unsigned char * - -+ [393] 0x041048ea "daughter" unsigned char * -+ [394] 0x041048f8 "Unknown" unsigned char * -+ [395] 0x04104905 "morning" unsigned char * -+ [396] 0x04104912 "day" unsigned char * -+ [397] 0x0410491b "evening" unsigned char * -+ [398] 0x04104928 "Have a Drink" unsigned char * - -+ [400] 0x04104947 "Buy Spells" unsigned char * -+ [401] 0x04104957 "Skill Cost: %lu" unsigned char * - -+ [403] 0x0410497a "You already know the %s skill" unsigned char * - -+ [406] 0x041049c9 "Hire" unsigned char * -+ [407] 0x041049d3 "More Information" unsigned char * -+ [408] 0x041049e9 "Dismiss %s" unsigned char * -+ [409] 0x041049f9 "Do you wish to leave %s?" unsigned char * -+ [410] 0x04104a17 "Leave %s" unsigned char * - -+ [412] 0x04104a33 "Create Party cannot be completed unless you have assigned all characters 2 extra skills and have spent all of your bonus points." unsigned char * -+ [413] 0x04104ab9 "You can't spend more than 50 points." unsigned char * -+ [414] 0x04104ae3 "This place is open from %d%s to %d%s" unsigned char * -+ [415] 0x04104b0d "January" unsigned char * -+ [416] 0x04104b1a "February" unsigned char * -+ [417] 0x04104b28 "March" unsigned char * -+ [418] 0x04104b33 "April" unsigned char * -+ [419] 0x04104b3e "May" unsigned char * -+ [420] 0x04104b47 "June" unsigned char * -+ [421] 0x04104b51 "July" unsigned char * -+ [422] 0x04104b5b "August" unsigned char * -+ [423] 0x04104b67 "September" unsigned char * -+ [424] 0x04104b76 "October" unsigned char * -+ [425] 0x04104b83 "November" unsigned char * -+ [426] 0x04104b91 "December" unsigned char * - -+ [428] 0x04104bc0 "Spell failed" unsigned char * - -+ [430] 0x04104be1 "%s is now Level %lu and has earned %lu Skill Points!" unsigned char * - - -+ [435] 0x04104c4a "Converse with %s" unsigned char * -+ [436] 0x04104c60 "Minutes" unsigned char * -+ [437] 0x04104c6d "Minute" unsigned char * -+ [438] 0x04104c79 "Seconds" unsigned char * -+ [439] 0x04104c86 "Second" unsigned char * -+ [440] 0x04104c92 "Heroism" unsigned char * -+ [441] 0x04104c9f "Haste" unsigned char * -+ [442] 0x04104caa "Stoneskin" unsigned char * -+ [443] 0x04104cb9 "Bless" unsigned char * -+ [444] 0x04104cc4 "Ooops!" unsigned char * -+ [445] 0x04104cd0 "Lucky Day" unsigned char * -+ [446] 0x04104cdf "Identify Failed" unsigned char * -+ [447] 0x04104cf4 "Precision" unsigned char * -+ [448] 0x04104d03 "Repair Failed" unsigned char * -+ [449] 0x04104d16 "Power" unsigned char * -+ [450] 0x04104d21 "Active Spells: %s" unsigned char * -+ [451] 0x04104d38 "Active Party Spells" unsigned char * -+ [452] 0x04104d51 "Torch Light" unsigned char * -+ [453] 0x04104d62 "Wizard Eye" unsigned char * -+ [454] 0x04104d72 "Feather Fall" unsigned char * -+ [455] 0x04104d84 "Fly" unsigned char * -+ [456] 0x04104d8d "Water Walk" unsigned char * -+ [457] 0x04104d9d "Guardian" unsigned char * -+ [458] 0x04104dab "Prot Fire" unsigned char * -+ [459] 0x04104dba "Prot Elec" unsigned char * -+ [460] 0x04104dc9 "Prot Cold" unsigned char * -+ [461] 0x04104dd8 "Prot Poison" unsigned char * -+ [462] 0x04104de9 "Prot Magic" unsigned char * -+ [463] 0x04104df9 "Type: %s" unsigned char * -+ [464] 0x04104e07 "Charges" unsigned char * -+ [465] 0x04104e14 "Value" unsigned char * -+ [466] 0x04104e1f "You found %lu gold (followers take %lu)!" unsigned char * -+ [467] 0x04104e4d "You found %lu gold!" unsigned char * -+ [468] 0x04104e66 "Clicking here will spend %d Skill Points" unsigned char * -+ [469] 0x04104e94 "You need %d more Skill Points to advance here" unsigned char * -+ [470] 0x04104ec7 "Get %s" unsigned char * -+ [471] 0x04104ed3 "You found an item (%s)!" unsigned char * -+ [472] 0x04104ef0 "am" unsigned char * -+ [473] 0x04104ef8 "pm" unsigned char * -+ [474] 0x04104f00 "Recall to %s" unsigned char * -+ [475] 0x04104f12 "Set %s over %s" unsigned char * -+ [476] 0x04104f26 "Set to %s" unsigned char * -+ [477] 0x04104f35 "You are already resting!" unsigned char * -+ [478] 0x04104f53 "You can't rest in turn-based mode!" unsigned char * -+ [479] 0x04104f7b "You can't rest here!" unsigned char * -+ [480] 0x04104f95 "There are hostile enemies near!" unsigned char * -+ [481] 0x04104fba "Encounter!" unsigned char * -+ [482] 0x04104fca "You don't have enough food to rest" unsigned char * -+ [483] 0x04104ff2 "Set %s as the Ready Spell" unsigned char * -+ [484] 0x04105011 "Select a spell then click here to set a QuickSpell" unsigned char * -+ [485] 0x04105049 "Cast %s" unsigned char * -+ [486] 0x04105056 "Select %s" unsigned char * -+ [487] 0x04105065 "You have already mastered this skill!" unsigned char * -+ [488] 0x04105090 "You don't have enough skill points!" unsigned char * -+ [489] 0x041050b9 ""You have %d total gold, %d in the Bank"" unsigned char * -+ [490] 0x041050e7 "You found %d gold and an item (%s)!" unsigned char * -+ [491] 0x04105110 "Can't cast Meteor Shower indoors!" unsigned char * -+ [492] 0x04105137 "Can't cast Inferno outdoors!" unsigned char * -+ [493] 0x04105159 "Can't cast Jump while airborne! " unsigned char * -+ [494] 0x0410517f "Can not cast Fly indoors!" unsigned char * -+ [495] 0x0410519e "Can't cast Starburst indoors!" unsigned char * -+ [496] 0x041051c1 "No valid target exists! " unsigned char * -+ [497] 0x041051df "Can't cast Prismatic Light outdoors!" unsigned char * -+ [498] 0x04105209 "Herbalist" unsigned char * -+ [499] 0x04105218 "Can't cast Armageddon indoors!" unsigned char * -+ [500] 0x0410523c "You have %lu gold" unsigned char * -+ [501] 0x04105253 "You have %lu food" unsigned char * -+ [502] 0x0410526a "You find %lu food" unsigned char * -+ [503] 0x04105281 "You lose %lu gold" unsigned char * -+ [504] 0x04105298 "You lose %lu food" unsigned char * - -+ [506] 0x041052bf "Roderick" unsigned char * -+ [507] 0x041052cd "Alexis" unsigned char * -+ [508] 0x041052d9 "Serena" unsigned char * -+ [509] 0x041052e5 "Zoltan" unsigned char * - -+ [510] 0x041052f1 "Saintly" unsigned char * -+ [511] 0x041052fe "Angelic" unsigned char * -+ [512] 0x0410530b "Glorious" unsigned char * -+ [513] 0x04105319 "Honorable" unsigned char * -+ [514] 0x04105328 "Respectable" unsigned char * -+ [515] 0x04105339 "Average" unsigned char * -+ [516] 0x04105346 "Bad" unsigned char * -+ [517] 0x0410534f "Vile" unsigned char * -+ [518] 0x04105359 "Despicable" unsigned char * -+ [519] 0x04105369 "Monstrous" unsigned char * -+ [520] 0x04105378 "Notorious" unsigned char * - - - -+ [524] 0x041053b9 "Once again you've cheated death! …" unsigned char * -+ [525] 0x041053e1 "Apothecary" unsigned char * - -+ [527] 0x041053fb "Thank You!" unsigned char * -+ [528] 0x0410540b "I can offer you nothing further." unsigned char * -+ [529] 0x04105431 ""Sorry, but we are unable to train you."" unsigned char * -+ [530] 0x0410545f "Moon" unsigned char * -+ [531] 0x04105469 "Location" unsigned char * -+ [532] 0x04105477 "Please try back in " unsigned char * -+ [533] 0x04105490 ""I cannot join you, you're party is full"" unsigned char * -+ [534] 0x041054bf "Become %s in %s for %lu gold" unsigned char * -+ [535] 0x041054e1 "Learn" unsigned char * -+ [536] 0x041054ec ""With your skills, you should be working here as a teacher."" unsigned char * -+ [537] 0x0410552e "Train to level %d for %d gold" unsigned char * - -+ [539] 0x04105587 "Buy Items" unsigned char * -+ [540] 0x04105596 "Sell Items" unsigned char * - -+ [542] 0x041055ba "Repair Items" unsigned char * -+ [543] 0x041055cc "Special Items" unsigned char * -+ [544] 0x041055df "Seek knowledge elsewhere %s the %s" unsigned char * -+ [545] 0x04105607 "Castle Ironfist" unsigned char * -+ [546] 0x0410561c "New Sorpigal" unsigned char * -+ [547] 0x0410562e "Free Haven" unsigned char * -+ [548] 0x0410563e "Arena" unsigned char * -+ [549] 0x04105649 "Blackshire" unsigned char * -+ [550] 0x04105659 "Kriegspire" unsigned char * -+ [551] 0x04105669 "White Cap" unsigned char * -+ [552] 0x04105678 "Silver Cove" unsigned char * -+ [553] 0x04105689 "Darkmoor" unsigned char * -+ [554] 0x04105697 "Mist" unsigned char * -+ [555] 0x041056a1 "Bootleg Bay West" unsigned char * -+ [556] 0x041056b7 "Volcano" unsigned char * -+ [557] 0x041056c4 "Hermit's Isle" unsigned char * -+ [558] 0x041056d7 "Child" unsigned char * -+ [559] 0x041056e2 "Island North" unsigned char * -+ [560] 0x041056f4 "Island South" unsigned char * -+ [561] 0x04105706 ""Sorry, come back another day"" unsigned char * -+ [562] 0x0410572a "do anything" unsigned char * -+ [563] 0x0410573b "Pack is Full!" unsigned char * -+ [564] 0x0410574e "Hic..." unsigned char * -+ [565] 0x0410575a "Have a Drink first..." unsigned char * - -+ [568] 0x0410578a "Club" unsigned char * -+ [569] 0x04105794 "Done!" unsigned char * -+ [570] 0x0410579f "Good as New!" unsigned char * -+ [571] 0x041057b1 "Ready Spell: %s" unsigned char * -+ [572] 0x041057c6 "Scroll Left" unsigned char * -+ [573] 0x041057d7 "Scroll Right" unsigned char * -+ [574] 0x041057e9 ""Welcome to the Arena of Life and Death. Remember, you are only allowed one arena combat per visit. To fight an arena battle, select the option that best describes your abilities and return to me- if you survive…"" unsigned char * -+ [575] 0x041058c6 "Please wait while I summon the monsters. Good luck." unsigned char * -+ [576] 0x04105900 "Congratulations on your win… here's your stuff… %u gold." unsigned char * -+ [577] 0x0410593e "Get back in there you wimps…" unsigned char * -+ [578] 0x04105960 "Page" unsigned char * -+ [579] 0x0410596a "Squire" unsigned char * -+ [580] 0x04105976 "Knight" unsigned char * -+ [581] 0x04105982 "Lord" unsigned char * -+ [582] 0x0410598c "You already won this trip to the Arena…" unsigned char * - -+ [584] 0x041059d5 "Click here to remove your Quick Spell" unsigned char * -+ [585] 0x04105a00 "Item is not of high enough quality" unsigned char * -+ [586] 0x04105a28 "Not enough spell points" unsigned char * -+ [587] 0x04105a45 "Attack Bonus" unsigned char * -+ [588] 0x04105a57 "Attack Damage" unsigned char * -+ [589] 0x04105a6a "Shoot Bonus" unsigned char * -+ [590] 0x04105a7b "Shoot Damage" unsigned char * -+ [591] 0x04105a8d "Charmed" unsigned char * -+ [592] 0x04105a9a "Shrunk" unsigned char * -+ [593] 0x04105aa6 "Slowed" unsigned char * -+ [594] 0x04105ab2 "Feebleminded" unsigned char * -+ [595] 0x04105ac4 "Wand" unsigned char * -+ [596] 0x04105ace "Chaplain" unsigned char * -+ [597] 0x04105adc "Diplomat" unsigned char * -+ [598] 0x04105aea "Fallen Wizard" unsigned char * -+ [599] 0x04105afd "Prelate" unsigned char * -+ [600] 0x04105b0a "Sage" unsigned char * -+ [601] 0x04105b14 "Zombie" unsigned char * -+ [602] 0x04105b20 "History" unsigned char * -+ [603] 0x04105b2d "Pay Fine" unsigned char * -+ [604] 0x04105b3b "Bounty Hunt" unsigned char * -+ [605] 0x04105b4c "Current Fine" unsigned char * -+ [606] 0x04105b5e "Pay" unsigned char * -+ [607] 0x04105b67 "Enslaved" unsigned char * -+ [608] 0x04105b75 "Berserk" unsigned char * -+ [609] 0x04105b82 "Hour of Power" unsigned char * -+ [610] 0x04105b95 "Day of Protection" unsigned char * -+ [611] 0x04105bac "Play ArcoMage" unsigned char * -+ [612] 0x04105bbf "Save game corrupted! Code=%d" unsigned char * - -+ [614] 0x04105bf4 "New Game" unsigned char * -+ [615] 0x04105c02 "Save Game" unsigned char * -+ [616] 0x04105c11 "Load Game" unsigned char * -+ [617] 0x04105c20 ""Sound, Keyboard, Game Options…"" unsigned char * -+ [618] 0x04105c46 "Quit" unsigned char * -+ [619] 0x04105c50 "Return to Game" unsigned char * -+ [620] 0x04105c64 "Rules" unsigned char * -+ [621] 0x04105c6f "Play" unsigned char * -+ [622] 0x04105c79 "Victory Conditions" unsigned char * - -+ [624] 0x04105c9c "Physical" unsigned char * -+ [625] 0x04105caa "Immune" unsigned char * -+ [626] 0x04105cb6 "Resistances" unsigned char * -+ [627] 0x04105cc7 "Resistant" unsigned char * -+ [628] 0x04105cd6 "Spell" unsigned char * -+ [629] 0x04105ce1 "Spells" unsigned char * -+ [630] 0x04105ced "?" unsigned char * -+ [631] 0x04105cf4 "Effects" unsigned char * -+ [632] 0x04105d01 "This skill level can not be learned by the %s class." unsigned char * -+ [633] 0x04105d3b "You have to be promoted to %s to learn this skill level." unsigned char * -+ [634] 0x04105d79 "You have to be promoted to %s or %s to learn this skill level." unsigned char * -+ [635] 0x04105dbd "%s stuns %s" unsigned char * -+ [636] 0x04105dce "%s paralyzes %s" unsigned char * -+ [637] 0x04105de3 "%s evades damage" unsigned char * -+ [638] 0x04105df9 "There are hostile creatures nearby!" unsigned char * -+ [639] 0x04105e22 "A tie!" unsigned char * -+ [640] 0x04105e2e "You won!" unsigned char * -+ [641] 0x04105e3c "You lost!" unsigned char * -+ [642] 0x04105e4b "Error" unsigned char * -+ [643] 0x04105e56 "by a Tower Building Victory!" unsigned char * -+ [644] 0x04105e78 "by Wall Building due to a Tower Building Tie!" unsigned char * -+ [645] 0x04105eab "by a Tower Destruction Victory!" unsigned char * -+ [646] 0x04105ed0 "by a Resource Victory!" unsigned char * -+ [647] 0x04105eec "by a Resource Victory due to a Tower & Wall Building Tie!" unsigned char * -+ [648] 0x04105f2b "This character can't summon any more monsters!" unsigned char * -+ [649] 0x04105f5f "Summoned" unsigned char * -+ [650] 0x04105f6d "Current Hit Points" unsigned char * -+ [651] 0x04105f85 "Hardened" unsigned char * -+ [652] 0x04105f93 "You can not do that while you are underwater!" unsigned char * -+ [653] 0x04105fc6 "Food" unsigned char * -+ [654] 0x04105fd0 "%s's Jar" unsigned char * -+ [655] 0x04105fde "%s' Jar" unsigned char * - -+ [657] 0x04105ffc "Water Breathing" unsigned char * -+ [658] 0x04106011 "Collect Prize" unsigned char * -+ [659] 0x04106024 "x: %d y: %d" unsigned char * -+ [660] 0x04106036 "You are drowning!" unsigned char * -+ [661] 0x0410604d "You are burning!" unsigned char * -+ [662] 0x04106063 "Instructors" unsigned char * -+ [663] 0x04106074 "It will take %d day to cross to %s." unsigned char * -+ [664] 0x0410609d "Click here to accept this party and continue to the game." unsigned char * -+ [665] 0x041060dc "Ok Button" unsigned char * -+ [666] 0x041060eb "Clears all party stats and skills." unsigned char * -+ [667] 0x04106113 "Clear Button" unsigned char * -+ [668] 0x04106125 "Subtract" unsigned char * -+ [669] 0x04106133 ""Subtracts a point from the highlighted skill, returning it to the bonus pool"" unsigned char * -+ [670] 0x04106187 "Add" unsigned char * -+ [671] 0x04106190 ""Adds a point from the highlighted skill, taking it from the bonus pool"" unsigned char * -+ [672] 0x041061de ""For your numerous crimes and evil deeds, you have been sentenced to one year in prison."" unsigned char * -+ [673] 0x0410623d "You have an outstanding fine of %lu gold. Pay your fine now or be sentenced to jail for 1 year?" unsigned char * -+ [674] 0x041062a3 "Temp Might" unsigned char * -+ [675] 0x041062b3 ""Splendid job! With the activation of the Gate, a thousand worlds lie at your feet. Perhaps on one of them you will find the Ancients themselves, and return with the fruits their great civilization has to offer your world and your kingdom."" unsigned char * -+ [676] 0x041063ab ""Brilliant! The completion of the Heavenly Forge has provided enough Ancient weapons to crush all resistance to your plans. Soon the world will bow to your every whim! Still, you can't help but wonder what was beyond the Gate the other side was trying so hard to build."" unsigned char * - */ \ No newline at end of file