# HG changeset patch
# User a.parshin
# Date 1432165859 -7200
# Node ID d569340b05ff9b66ec72cf58006023cefc9ca08b
# Parent 30eb6dcac7682d32f162b78fe3f8085e9a11f1d4
Few constants changed into enum values
diff -r 30eb6dcac768 -r d569340b05ff Build/Visual Studio 2013/World of Might and Magic.vcxproj
--- a/Build/Visual Studio 2013/World of Might and Magic.vcxproj Wed May 20 21:05:07 2015 +0200
+++ b/Build/Visual Studio 2013/World of Might and Magic.vcxproj Thu May 21 01:50:59 2015 +0200
@@ -141,6 +141,7 @@
+
@@ -257,7 +258,6 @@
-
@@ -324,6 +324,7 @@
+
@@ -522,7 +523,6 @@
-
diff -r 30eb6dcac768 -r d569340b05ff Build/Visual Studio 2013/World of Might and Magic.vcxproj.filters
--- a/Build/Visual Studio 2013/World of Might and Magic.vcxproj.filters Wed May 20 21:05:07 2015 +0200
+++ b/Build/Visual Studio 2013/World of Might and Magic.vcxproj.filters Thu May 21 01:50:59 2015 +0200
@@ -483,7 +483,6 @@
Engine
-
GUI\NewUI\Core
@@ -616,6 +615,9 @@
Engine\Serialization
+
+ Engine
+
@@ -1260,7 +1262,6 @@
Engine
-
GUI\NewUI\Core
@@ -1396,6 +1397,9 @@
Engine\Serialization
+
+ Engine
+
diff -r 30eb6dcac768 -r d569340b05ff Engine/Engine.cpp
--- a/Engine/Engine.cpp Wed May 20 21:05:07 2015 +0200
+++ b/Engine/Engine.cpp Thu May 21 01:50:59 2015 +0200
@@ -2954,7 +2954,7 @@
}
else
{
- v25 = pParty->pPlayers[v49].pInventoryItemList[_idx - 1].uSpecEnchantmentType;
+ v25 = pParty->pPlayers[v49].pInventoryItemList[_idx - 1].special_enchantment;
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") &&
diff -r 30eb6dcac768 -r d569340b05ff Engine/Graphics/Indoor.cpp
--- a/Engine/Graphics/Indoor.cpp Wed May 20 21:05:07 2015 +0200
+++ b/Engine/Graphics/Indoor.cpp Thu May 21 01:50:59 2015 +0200
@@ -34,7 +34,7 @@
#include "Lights.h"
#include "Sprites.h"
-#include "stru6.h"
+#include "Engine/stru6.h"
#include "ParticleEngine.h"
#include "../texts.h"
#include "GUI/GUIWindow.h"
@@ -4445,75 +4445,36 @@
{
int v17; // edi@36
- v17 = PID_ID(a1);
- switch ( PID_TYPE(a1) )
- {
- case OBJECT_Item: // take the item
- if ( pObjectList->pObjects[pSpriteObjects[v17].uObjectDescID].uFlags & 0x10 || v17 >= 1000 || !pSpriteObjects[v17].uObjectDescID )
- return 1;
- if (pItemsTable->pItems[pSpriteObjects[v17].containing_item.uItemID].uEquipType == EQUIP_GOLD)
- {
- pParty->PartyFindsGold(pSpriteObjects[v17].containing_item.uSpecEnchantmentType, 0);
- viewparams->bRedrawGameUI = 1;
- }
- else
- {
- if ( pParty->pPickedItem.uItemID )
- return 1;
- sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[pSpriteObjects[v17].containing_item.uItemID].pUnidentifiedName);//You found an item (%s)!
- ShowStatusBarString(pTmpBuf2.data(), 2);
- if (pSpriteObjects[v17].containing_item.uItemID == 506)//artefact
- _449B7E_toggle_bit(pParty->_quest_bits, 184, 1);
- if (pSpriteObjects[v17].containing_item.uItemID == 455)
- _449B7E_toggle_bit(pParty->_quest_bits, 185, 1);
- if (!pParty->AddItemToParty(&pSpriteObjects[v17].containing_item))
- pParty->SetHoldingItem(&pSpriteObjects[v17].containing_item);
- }
- SpriteObject::OnInteraction(v17);
- break;
+ v17 = PID_ID(a1);
+ switch ( PID_TYPE(a1) )
+ {
+ case OBJECT_Item: // take the item
+ {
+ if (pObjectList->pObjects[pSpriteObjects[v17].uObjectDescID].uFlags & 0x10
+ || v17 >= 1000
+ || !pSpriteObjects[v17].uObjectDescID)
+ return 1;
+
+ extern void ItemInteraction(unsigned int item_id);
+ ItemInteraction(v17);
+ break;
+ }
case OBJECT_Actor:
if ( pActors[v17].uAIState == Dying || pActors[v17].uAIState == Summoned )
return 1;
- if ( pActors[v17].uAIState == Dead )
- pActors[v17].LootActor();
+ if (pActors[v17].uAIState == Dead)
+ pActors[v17].LootActor();
else
{
- if ( !pActors[v17].GetActorsRelation(0) && pActors[v17].ActorFriend() && pActors[v17].CanAct() )
- {
- Actor::AI_FaceObject(v17, 4, 0, 0);
- if ( pActors[v17].sNPC_ID )
- pMessageQueue_50CBD0->AddGUIMessage(UIMSG_StartNPCDialogue, v17, 0);
- else
- {
- if ( pNPCStats->pGroups_copy[pActors[v17].uGroup] )
- {
- if ( pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[v17].uGroup]] )
- {
- pParty->uFlags |= 2;
- strcpy(byte_5B0938.data(), pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[v17].uGroup]]);
- sub_4451A8_press_any_key(0, 0, 0);
- }
- }
- }
- }
+ extern bool ActorInteraction(unsigned int id);
+ ActorInteraction(v17);
}
break;
case OBJECT_Decoration:
- if ( pLevelDecorations[v17].uEventID )
- {
- EventProcessor(pLevelDecorations[v17].uEventID, a1, 1);
- pLevelDecorations[v17].uFlags |= LEVEL_DECORATION_VISIBLE_ON_MAP;
- }
- else
- {
- if ( !pLevelDecorations[v17].IsInteractive() )
- return 1;
- activeLevelDecoration = &pLevelDecorations[v17];
- EventProcessor(stru_5E4C90_MapPersistVars._decor_events[pLevelDecorations[v17]._idx_in_stru123 - 75] + 380, 0, 1);
- activeLevelDecoration = nullptr;
- }
+ extern void DecorationInteraction(unsigned int id, unsigned int pid);
+ DecorationInteraction(v17, a1);
break;
default:
diff -r 30eb6dcac768 -r d569340b05ff Engine/Graphics/Outdoor.cpp
--- a/Engine/Graphics/Outdoor.cpp Wed May 20 21:05:07 2015 +0200
+++ b/Engine/Graphics/Outdoor.cpp Thu May 21 01:50:59 2015 +0200
@@ -17,8 +17,8 @@
#include "Engine/Events.h"
#include "Engine/ZlibWrapper.h"
#include "Engine/MMT.h"
-
-#include "stru6.h"
+#include "Engine/stru6.h"
+
#include "Weather.h"
#include "Sprites.h"
#include "LightmapBuilder.h"
diff -r 30eb6dcac768 -r d569340b05ff Engine/Graphics/Render.cpp
--- a/Engine/Graphics/Render.cpp Wed May 20 21:05:07 2015 +0200
+++ b/Engine/Graphics/Render.cpp Thu May 21 01:50:59 2015 +0200
@@ -12,7 +12,7 @@
#include "Sprites.h"
#include "IO/Mouse.h"
#include "GammaControl.h"
-#include "stru6.h"
+#include "Engine/stru6.h"
#include "GUI/GUIWindow.h"
#include "DecalBuilder.h"
#include "ParticleEngine.h"
diff -r 30eb6dcac768 -r d569340b05ff Engine/Graphics/Viewport.cpp
--- a/Engine/Graphics/Viewport.cpp Wed May 20 21:05:07 2015 +0200
+++ b/Engine/Graphics/Viewport.cpp Thu May 21 01:50:59 2015 +0200
@@ -256,6 +256,128 @@
}
uMapBookMapZoom = 384;
}
+
+
+
+
+
+
+void ItemInteraction(unsigned int item_id)
+{
+ if (pItemsTable->pItems[pSpriteObjects[item_id].containing_item.uItemID].uEquipType == EQUIP_GOLD)
+ {
+ pParty->PartyFindsGold(pSpriteObjects[item_id].containing_item.special_enchantment, 0);
+ viewparams->bRedrawGameUI = 1;
+ }
+ else
+ {
+ if (pParty->pPickedItem.uItemID)
+ return;
+
+ sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[pSpriteObjects[item_id].containing_item.uItemID].pUnidentifiedName);//You found an item (%s)!
+ ShowStatusBarString(pTmpBuf2.data(), 2);
+ if (pSpriteObjects[item_id].containing_item.uItemID == ITEM_ARTIFACT_SPLITTER)
+ _449B7E_toggle_bit(pParty->_quest_bits, 184, 1);
+ if (pSpriteObjects[item_id].containing_item.uItemID == ITEM_SPELLBOOK_MIND_REMOVE_FEAR)
+ _449B7E_toggle_bit(pParty->_quest_bits, 185, 1);
+ if (!pParty->AddItemToParty(&pSpriteObjects[item_id].containing_item))
+ pParty->SetHoldingItem(&pSpriteObjects[item_id].containing_item);
+ }
+ SpriteObject::OnInteraction(item_id);
+}
+
+bool ActorInteraction(unsigned int id)
+{
+ if (!pActors[id].GetActorsRelation(0) && pActors[id].ActorFriend() && pActors[id].CanAct())
+ {
+ Actor::AI_FaceObject(id, 4, 0, 0);
+ if (pActors[id].sNPC_ID)
+ pMessageQueue_50CBD0->AddGUIMessage(UIMSG_StartNPCDialogue, id, 0);
+ else
+ {
+ if (pNPCStats->pGroups_copy[pActors[id].uGroup])
+ {
+ if (pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[id].uGroup]])
+ {
+ pParty->uFlags |= 2;
+ strcpy(byte_5B0938.data(), pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[id].uGroup]]);
+ sub_4451A8_press_any_key(0, 0, 0);
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
+void DecorationInteraction(unsigned int id, unsigned int pid)
+{
+ if (pLevelDecorations[id].uEventID)
+ {
+ EventProcessor(pLevelDecorations[id].uEventID, pid, 1);
+ pLevelDecorations[id].uFlags |= LEVEL_DECORATION_VISIBLE_ON_MAP;
+ }
+ else
+ {
+ if (pLevelDecorations[id].IsInteractive())
+ {
+ activeLevelDecoration = &pLevelDecorations[id];
+ EventProcessor(stru_5E4C90_MapPersistVars._decor_events[pLevelDecorations[id]._idx_in_stru123 - 75] + 380, 0, 1);
+ activeLevelDecoration = nullptr;
+ }
+ }
+}
+
+
+void DropHeldItem()
+{
+ if (!pParty->pPickedItem.uItemID)
+ return;
+
+ SpriteObject a1; // [sp+Ch] [bp-80h]@1
+ POINT *v1; // esi@3
+ __debugbreak();//no checker
+ int v6 = 0;
+ a1.uType = (SPRITE_OBJECT_TYPE)pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
+ if ((signed int)pObjectList->uNumObjects <= 0)
+ LOWORD(v6) = 0;
+ else
+ {
+ auto v7 = (char *)&pObjectList->pObjects->uObjectID;
+ while (pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7)
+ {
+ ++v6;
+ v7 += 56;
+ if (v6 >= (signed int)pObjectList->uNumObjects)
+ {
+ LOWORD(v6) = 0;
+ break;
+ }
+ }
+ }
+ a1.uObjectDescID = v6;
+ a1.vPosition.y = pParty->vPosition.y;
+ a1.spell_caster_pid = OBJECT_Player;
+ a1.vPosition.x = pParty->vPosition.x;
+ a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
+ a1.uSoundID = 0;
+ a1.uFacing = 0;
+ a1.uAttributes = 8;
+ a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z);
+ a1.uSpriteFrameID = 0;
+ memcpy(&a1.containing_item, &pParty->pPickedItem, 0x24u);
+
+ extern int UnprojectX(int);
+ //v9 = UnprojectX(v1->x);
+ a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0);
+ auto pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
+ if (pTextureID != -1)
+ pIcons_LOD->pTextures[pTextureID].Release();
+ pMouse->RemoveHoldingItem();
+ pIcons_LOD->SyncLoadedFilesCount();
+}
+
+
//----- (0042213C) --------------------------------------------------------
void OnGameViewportClick()
{
@@ -274,6 +396,8 @@
POINT a2; // [sp+84h] [bp-8h]@3
int clickable_distance = 512;
+ int distance = HIWORD(v0);
+ bool in_range = distance < clickable_distance;
v1 = pMouse->GetCursorPos(&a2);
//if ( pRenderer->pRenderD3D )
@@ -285,429 +409,98 @@
{
int item_id = PID_ID(v0);
//v21 = (signed int)(unsigned __int16)v0 >> 3;
- if ( !(pObjectList->pObjects[pSpriteObjects[item_id].uObjectDescID].uFlags & 0x10) && item_id < 1000 && pSpriteObjects[item_id].uObjectDescID
- && (unsigned int)v0 < 0x2000000 )
- {
- if (pSpriteObjects[item_id].containing_item.GetItemEquipType() == 18)
- {
- pParty->PartyFindsGold(pSpriteObjects[item_id].containing_item.uSpecEnchantmentType, 0);
- viewparams->bRedrawGameUI = 1;
- }
- else
- {
- sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[pSpriteObjects[item_id].containing_item.uItemID].pUnidentifiedName);//You found an item (%s)!
- ShowStatusBarString(pTmpBuf2.data(), 2);
- if (pSpriteObjects[item_id].containing_item.uItemID == ITEM_ARTIFACT_SPLITTER)
- _449B7E_toggle_bit(pParty->_quest_bits, 184, 1);
- if (pSpriteObjects[item_id].containing_item.uItemID == 455)
- _449B7E_toggle_bit(pParty->_quest_bits, 185, 1);
- if (!pParty->AddItemToParty(&pSpriteObjects[item_id].containing_item))
- pParty->SetHoldingItem(&pSpriteObjects[item_id].containing_item);
- }
- SpriteObject::OnInteraction(item_id);
- return;
- }
- if ( !pParty->pPickedItem.uItemID )
- return;
- __debugbreak();//no checker
- v6 = 0;
- a1.uType = (SPRITE_OBJECT_TYPE)pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
- if ( (signed int)pObjectList->uNumObjects <= 0 )
- LOWORD(v6) = 0;
- else
+ if (pObjectList->pObjects[pSpriteObjects[item_id].uObjectDescID].uFlags & 0x10 || item_id >= 1000 || !pSpriteObjects[item_id].uObjectDescID
+ || !in_range)
{
- v7 = (char *)&pObjectList->pObjects->uObjectID;
- while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 )
- {
- ++v6;
- v7 += 56;
- if ( v6 >= (signed int)pObjectList->uNumObjects )
- {
- LOWORD(v6) = 0;
- break;
- }
- }
+ if (pParty->pPickedItem.uItemID)
+ DropHeldItem();
}
- a1.uObjectDescID = v6;
- a1.vPosition.y = pParty->vPosition.y;
- a1.spell_caster_pid = OBJECT_Player;
- a1.vPosition.x = pParty->vPosition.x;
- a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
- a1.uSoundID = 0;
- a1.uFacing = 0;
- a1.uAttributes = 8;
- a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z);
- a1.uSpriteFrameID = 0;
- memcpy(&a1.containing_item, &pParty->pPickedItem, 0x24u);
-
- extern int UnprojectX(int);
- //v9 = UnprojectX(v1->x);
- a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0);
- pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
- if (pTextureID != -1)
- pIcons_LOD->pTextures[pTextureID].Release();
- pMouse->RemoveHoldingItem();
- pIcons_LOD->SyncLoadedFilesCount();
- return;
+ else
+ ItemInteraction(item_id);
}
- if ( PID_TYPE(v0) == OBJECT_Actor)
+ else if ( PID_TYPE(v0) == OBJECT_Actor)
{
int mon_id = PID_ID(v0);
//a2.y = v16;
if ( pActors[mon_id].uAIState == Dead )
{
- if ( (unsigned int)v0 < 0x2000000 )//distance limit for loot monster
+ if (in_range)
+ pActors[mon_id].LootActor();
+ else if (pParty->pPickedItem.uItemID)
+ DropHeldItem();
+ }
+ else if ( GetAsyncKeyState(VK_SHIFT) >= 0 )
+ {
+ if (!in_range)
+ {
+ if (pParty->pPickedItem.uItemID)
+ DropHeldItem();
+ }
+ else if (!ActorInteraction(mon_id))
+ {
+ if (pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == TE_MOVEMENT)
+ pTurnEngine->field_18 |= TE_FLAG_8;
+ else
+ pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Attack, 0, 0);
+ }
+ }
+ else if ( pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == TE_MOVEMENT )
+ pParty->uFlags |= PARTY_FLAGS_1_FALLING;
+ else if ( uActiveCharacter && sub_427769_isSpellQuickCastableOnShiftClick(pPlayers[uActiveCharacter]->uQuickSpell))
+ pMessageQueue_50CBD0->AddGUIMessage(UIMSG_CastQuickSpell, 0, 0);
+ }
+ else if ( PID_TYPE(v0) == OBJECT_Decoration)
+ {
+ int id = PID_ID(v0);
+ if (distance - pDecorationList->pDecorations[pLevelDecorations[id].uDecorationDescID].uRadius >= clickable_distance)
{
- pActors[mon_id].LootActor();
- return;
- }
- if ( !pParty->pPickedItem.uItemID )
- return;
- __debugbreak();//no checker
- v6 = 0;
- a1.uType = (SPRITE_OBJECT_TYPE)pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
- if ( (signed int)pObjectList->uNumObjects <= 0 )
- LOWORD(v6) = 0;
- else
- {
- v7 = (char *)&pObjectList->pObjects->uObjectID;
- while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 )
- {
- ++v6;
- v7 += 56;
- if ( v6 >= (signed int)pObjectList->uNumObjects )
- {
- LOWORD(v6) = 0;
- break;
- }
- }
+ if (pParty->pPickedItem.uItemID)
+ DropHeldItem();
}
- a1.uObjectDescID = v6;
- a1.vPosition.y = pParty->vPosition.y;
- a1.spell_caster_pid = OBJECT_Player;
- a1.vPosition.x = pParty->vPosition.x;
- a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
- a1.uSoundID = 0;
- a1.uFacing = 0;
- a1.uAttributes = 8;
- a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z);
- a1.uSpriteFrameID = 0;
- memcpy(&a1.containing_item, &pParty->pPickedItem, 0x24u);
-
- extern int UnprojectX(int);
- //v9 = UnprojectX(v1->x);
- a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0);
- pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
- if (pTextureID != -1)
- pIcons_LOD->pTextures[pTextureID].Release();
- pMouse->RemoveHoldingItem();
- pIcons_LOD->SyncLoadedFilesCount();
- return;
- }
- if ( GetAsyncKeyState(VK_SHIFT) >= 0 )
- {
- if ( !pActors[mon_id].GetActorsRelation(0) && pActors[mon_id].ActorFriend() )
+ else
+ DecorationInteraction(id, v0);
+ }
+ else if (PID_TYPE(v0) == OBJECT_BModel && in_range)
+ {
+ if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
{
- if ( HIWORD(v0) >= clickable_distance)
- {
- if ( !pParty->pPickedItem.uItemID )
- return;
- __debugbreak();//no checker
- v6 = 0;
- a1.uType = (SPRITE_OBJECT_TYPE)pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
- if ( (signed int)pObjectList->uNumObjects <= 0 )
- LOWORD(v6) = 0;
+ if (!pIndoor->pFaces[PID_ID(v0)].Clickable())
+ {
+ if (!pParty->pPickedItem.uItemID)
+ {
+ ShowNothingHereStatus();
+ if (!pParty->pPickedItem.uItemID)
+ return;
+ }
+ else
+ DropHeldItem();
+ }
else
{
- v7 = (char *)&pObjectList->pObjects->uObjectID;
- while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 )
- {
- ++v6;
- v7 += 56;
- if ( v6 >= (signed int)pObjectList->uNumObjects )
- {
- LOWORD(v6) = 0;
- break;
- }
- }
+ pEventID = pIndoor->pFaceExtras[pIndoor->pFaces[PID_ID(v0)].uFaceExtraID].uEventID;
+ EventProcessor(pEventID, (unsigned __int16)v0, 1);
}
- a1.uObjectDescID = v6;
- a1.vPosition.y = pParty->vPosition.y;
- a1.spell_caster_pid = OBJECT_Player;
- a1.vPosition.x = pParty->vPosition.x;
- a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
- a1.uSoundID = 0;
- a1.uFacing = 0;
- a1.uAttributes = 8;
- a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z);
- a1.uSpriteFrameID = 0;
- memcpy(&a1.containing_item, &pParty->pPickedItem, 0x24u);
-
- extern int UnprojectX(int);
- //v9 = UnprojectX(v1->x);
- a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0);
- pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
- if (pTextureID != -1)
- pIcons_LOD->pTextures[pTextureID].Release();
- pMouse->RemoveHoldingItem();
- pIcons_LOD->SyncLoadedFilesCount();
- return;
- }
- if ( !pActors[mon_id].CanAct() )
- return;
- //v18 = mon_id;
- Actor::AI_FaceObject(mon_id, 4, 0, 0);
- if ( !pActors[mon_id].sNPC_ID )
- {
- if ( pNPCStats->pGroups_copy[pActors[mon_id].uGroup] )
- {
- if ( pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[mon_id].uGroup]] )
- {
- pParty->uFlags |= 2;
- strcpy(byte_5B0938.data(), pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[mon_id].uGroup]]);
- sub_4451A8_press_any_key(0, 0, 0);
- }
- }
- return;
- }
- pMessageQueue_50CBD0->AddGUIMessage(UIMSG_StartNPCDialogue, mon_id, 0);
- return;
- }
- if ( pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == TE_MOVEMENT )
- {
- pTurnEngine->field_18 |= TE_FLAG_8;
- return;
- }
- pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Attack, 0, 0);
- }
- else
- {
- if ( pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == TE_MOVEMENT )
- {
- pParty->uFlags |= PARTY_FLAGS_1_FALLING;
- return;
}
- if ( uActiveCharacter && sub_427769_isSpellQuickCastableOnShiftClick(pPlayers[uActiveCharacter]->uQuickSpell))
- pMessageQueue_50CBD0->AddGUIMessage(UIMSG_CastQuickSpell, 0, 0);
- }
- return;
- }
- if ( PID_TYPE(v0) == OBJECT_Decoration)
- {
- if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].uDecorationDescID].uRadius) >= clickable_distance )
- {
- if ( !pParty->pPickedItem.uItemID )
- return;
- __debugbreak();//no checker
- v6 = 0;
- a1.uType = (SPRITE_OBJECT_TYPE)pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
- if ( (signed int)pObjectList->uNumObjects <= 0 )
- LOWORD(v6) = 0;
- else
- {
- v7 = (char *)&pObjectList->pObjects->uObjectID;
- while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 )
- {
- ++v6;
- v7 += 56;
- if ( v6 >= (signed int)pObjectList->uNumObjects )
- {
- LOWORD(v6) = 0;
- break;
- }
- }
- }
- a1.uObjectDescID = v6;
- a1.vPosition.y = pParty->vPosition.y;
- a1.spell_caster_pid = OBJECT_Player;
- a1.vPosition.x = pParty->vPosition.x;
- a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
- a1.uSoundID = 0;
- a1.uFacing = 0;
- a1.uAttributes = 8;
- a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z);
- a1.uSpriteFrameID = 0;
- memcpy(&a1.containing_item, &pParty->pPickedItem, 0x24u);
-
- extern int UnprojectX(int);
- //v9 = UnprojectX(v1->x);
- a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0);
- pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
- if (pTextureID != -1)
- pIcons_LOD->pTextures[pTextureID].Release();
- pMouse->RemoveHoldingItem();
- pIcons_LOD->SyncLoadedFilesCount();
- return;
- }
- if ( !pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].uEventID )
- {
- if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() )
- {
- v15 = stru_5E4C90_MapPersistVars._decor_events[pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]._idx_in_stru123 - 75] + 380;
- activeLevelDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3];
- EventProcessor(v15, 0, 1);
- activeLevelDecoration = nullptr;
- }
- return;
- }
- pEventID = pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].uEventID;
- EventProcessor(pEventID, (unsigned __int16)v0, 1);
- return;
- }
- if ( PID_TYPE(v0) == OBJECT_BModel && HIWORD(v0) < clickable_distance)
- {
- if ( uCurrentlyLoadedLevelType == LEVEL_Indoor)
- {
- if ( !pIndoor->pFaces[PID_ID(v0)].Clickable() )
+ else if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
{
- if ( !pParty->pPickedItem.uItemID )
- {
- ShowNothingHereStatus();
- if ( !pParty->pPickedItem.uItemID )
- return;
- }
- __debugbreak();//no checker
- v6 = 0;
- a1.uType = (SPRITE_OBJECT_TYPE)pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
- if ( (signed int)pObjectList->uNumObjects <= 0 )
- LOWORD(v6) = 0;
- else
- {
- v7 = (char *)&pObjectList->pObjects->uObjectID;
- while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 )
- {
- ++v6;
- v7 += 56;
- if ( v6 >= (signed int)pObjectList->uNumObjects )
- {
- LOWORD(v6) = 0;
- break;
- }
- }
- }
- a1.uObjectDescID = v6;
- a1.vPosition.y = pParty->vPosition.y;
- a1.spell_caster_pid = OBJECT_Player;
- a1.vPosition.x = pParty->vPosition.x;
- a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
- a1.uSoundID = 0;
- a1.uFacing = 0;
- a1.uAttributes = 8;
- a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z);
- a1.uSpriteFrameID = 0;
- memcpy(&a1.containing_item, &pParty->pPickedItem, 0x24u);
-
- extern int UnprojectX(int);
- v9 = UnprojectX(v1->x);
- a1.Create(pParty->sRotationY + v9, 184, 200, 0);
- pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
- if (pTextureID != -1)
- pIcons_LOD->pTextures[pTextureID].Release();
- pMouse->RemoveHoldingItem();
- pIcons_LOD->SyncLoadedFilesCount();
- return;
- }
- pEventID = pIndoor->pFaceExtras[pIndoor->pFaces[PID_ID(v0)].uFaceExtraID].uEventID;
- }
- if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
- {
- if ( !pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[PID_ID(v0) & 0x3F].Clickable())
- {
- if ( !pParty->pPickedItem.uItemID )
- {
- ShowNothingHereStatus();
- if ( !pParty->pPickedItem.uItemID )
- return;
- }
- __debugbreak();//no checker
- v6 = 0;
- a1.uType = (SPRITE_OBJECT_TYPE)pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
- if ( (signed int)pObjectList->uNumObjects <= 0 )
- LOWORD(v6) = 0;
- else
- {
- v7 = (char *)&pObjectList->pObjects->uObjectID;
- while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 )
+ if (!pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[PID_ID(v0) & 0x3F].Clickable())
{
- ++v6;
- v7 += 56;
- if ( v6 >= (signed int)pObjectList->uNumObjects )
- {
- LOWORD(v6) = 0;
- break;
- }
+ if (!pParty->pPickedItem.uItemID)
+ {
+ ShowNothingHereStatus();
+ if (!pParty->pPickedItem.uItemID)
+ return;
+ }
+ else
+ DropHeldItem();
}
- }
- a1.uObjectDescID = v6;
- a1.vPosition.y = pParty->vPosition.y;
- a1.spell_caster_pid = OBJECT_Player;
- a1.vPosition.x = pParty->vPosition.x;
- a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
- a1.uSoundID = 0;
- a1.uFacing = 0;
- a1.uAttributes = 8;
- a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z);
- a1.uSpriteFrameID = 0;
- memcpy(&a1.containing_item, &pParty->pPickedItem, 0x24u);
-
- extern int UnprojectX(int);
- v9 = UnprojectX(v1->x);
- a1.Create(pParty->sRotationY + v9, 184, 200, 0);
- pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
- if (pTextureID != -1)
- pIcons_LOD->pTextures[pTextureID].Release();
- pMouse->RemoveHoldingItem();
- pIcons_LOD->SyncLoadedFilesCount();
- return;
- }
- pEventID = pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[PID_ID(v0) & 0x3F].sCogTriggeredID;
+ else
+ {
+ pEventID = pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[PID_ID(v0) & 0x3F].sCogTriggeredID;
+ EventProcessor(pEventID, (unsigned __int16)v0, 1);
+ }
}
- EventProcessor(pEventID, (unsigned __int16)v0, 1);
- return;
}
- if ( PID_TYPE(v0) != OBJECT_BModel || HIWORD(v0) >= clickable_distance )
- {
- if ( !pParty->pPickedItem.uItemID )
- return;
- //__debugbreak();//no checker
- v6 = 0;
- a1.uType = (SPRITE_OBJECT_TYPE)pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID;
- if ( (signed int)pObjectList->uNumObjects <= 0 )
- LOWORD(v6) = 0;
- else
- {
- v7 = (char *)&pObjectList->pObjects->uObjectID;
- while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 )
- {
- ++v6;
- v7 += 56;
- if ( v6 >= (signed int)pObjectList->uNumObjects )
- {
- LOWORD(v6) = 0;
- break;
- }
- }
- }
- a1.uObjectDescID = v6;
- a1.vPosition.y = pParty->vPosition.y;
- a1.spell_caster_pid = OBJECT_Player;
- a1.vPosition.x = pParty->vPosition.x;
- a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z;
- a1.uSoundID = 0;
- a1.uFacing = 0;
- a1.uAttributes = 8;
- a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z);
- a1.uSpriteFrameID = 0;
- memcpy(&a1.containing_item, &pParty->pPickedItem, 0x24u);
-
- extern int UnprojectX(int);
- //v9 = UnprojectX(v1->x);
- a1.Create(pParty->sRotationY + UnprojectX(v1->x), 184, 200, 0);
- pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
- if (pTextureID != -1)
- pIcons_LOD->pTextures[pTextureID].Release();
- pMouse->RemoveHoldingItem();
- pIcons_LOD->SyncLoadedFilesCount();
- return;
- }
+ else if (pParty->pPickedItem.uItemID)
+ DropHeldItem();
}
diff -r 30eb6dcac768 -r d569340b05ff Engine/MapInfo.cpp
--- a/Engine/MapInfo.cpp Wed May 20 21:05:07 2015 +0200
+++ b/Engine/MapInfo.cpp Thu May 21 01:50:59 2015 +0200
@@ -386,7 +386,6 @@
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
@@ -438,39 +437,33 @@
}
if ( a2->uIndex == 1 )
{
- v14 = rand() % 51 + 50;
- a1a.containing_item.uItemID = 197;
- v34 = v14;
+ a1a.containing_item.uItemID = ITEM_GOLD_SMALL;
+ v34 = rand() % 51 + 50;
}
else if ( a2->uIndex == 2 )
{
- v14 = rand() % 101 + 100;
- a1a.containing_item.uItemID = 197;
- v34 = v14;
+ a1a.containing_item.uItemID = ITEM_GOLD_SMALL;
+ v34 = rand() % 101 + 100;
}
else if ( a2->uIndex == 3 )
{
- v14 = rand() % 301 + 200;
- a1a.containing_item.uItemID = 198;
- v34 = v14;
+ a1a.containing_item.uItemID = ITEM_GOLD_MEDIUM;
+ v34 = rand() % 301 + 200;
}
else if ( a2->uIndex == 4 )
{
- v14 = rand() % 501 + 500;
- a1a.containing_item.uItemID = 198;
- v34 = v14;
+ a1a.containing_item.uItemID = ITEM_GOLD_MEDIUM;
+ v34 = rand() % 501 + 500;
}
else if ( a2->uIndex == 5 )
{
- v14 = rand() % 1001 + 1000;
- a1a.containing_item.uItemID = 199;
- v34 = v14;
+ a1a.containing_item.uItemID = ITEM_GOLD_LARGE;
+ v34 = rand() % 1001 + 1000;
}
else if ( a2->uIndex == 6 )
{
- v14 = rand() % 3001 + 2000;
- a1a.containing_item.uItemID = 199;
- v34 = v14;
+ a1a.containing_item.uItemID = ITEM_GOLD_LARGE;
+ v34 = rand() % 3001 + 2000;
}
v15 = 0;
v16 = pItemsTable->pItems[a1a.containing_item.uItemID].uSpriteID;
@@ -486,7 +479,7 @@
}
a1a.containing_item.SetIdentified();
a1a.uObjectDescID = v18;
- a1a.containing_item.uSpecEnchantmentType = v34;
+ a1a.containing_item.special_enchantment = (ITEM_ENCHANTMENT)v34;
}
else
{
diff -r 30eb6dcac768 -r d569340b05ff Engine/Objects/Actor.cpp
--- a/Engine/Objects/Actor.cpp Wed May 20 21:05:07 2015 +0200
+++ b/Engine/Objects/Actor.cpp Thu May 21 01:50:59 2015 +0200
@@ -9,7 +9,7 @@
#include "../Graphics/PaletteManager.h"
#include "../Graphics/DecalBuilder.h"
#include "../Graphics/Sprites.h"
-#include "../../stru6.h"
+#include "Engine/stru6.h"
#include "Actor.h"
#include "../OurMath.h"
#include "../Graphics/Outdoor.h"
@@ -144,17 +144,17 @@
{
if ( bGive )
{
- if ( pActors[uActorID].uCarriedItemID == 0)
+ if (pActors[uActorID].uCarriedItemID == ITEM_NULL)
pActors[uActorID].uCarriedItemID = uItemID;
- else if ( pActors[uActorID].ActorHasItems[0].uItemID == 0)
+ else if (pActors[uActorID].ActorHasItems[0].uItemID == ITEM_NULL)
pActors[uActorID].ActorHasItems[0].uItemID = uItemID;
- else if ( pActors[uActorID].ActorHasItems[1].uItemID == 0)
+ else if (pActors[uActorID].ActorHasItems[1].uItemID == ITEM_NULL)
pActors[uActorID].ActorHasItems[1].uItemID = uItemID;
}
else
{
if ( pActors[uActorID].uCarriedItemID == uItemID )
- pActors[uActorID].uCarriedItemID = 0;
+ pActors[uActorID].uCarriedItemID = ITEM_NULL;
else if ( pActors[uActorID].ActorHasItems[0].uItemID == uItemID )
pActors[uActorID].ActorHasItems[0].Reset();
else if ( pActors[uActorID].ActorHasItems[1].uItemID == uItemID )
@@ -187,28 +187,28 @@
//----- (004086E9) --------------------------------------------------------
void Actor::SetRandomGoldIfTheresNoItem()
{
- int v2; // edi@1
-
- v2 = 0;
- if ( !this->ActorHasItems[3].uItemID )
- {
- if ( this->pMonsterInfo.uTreasureDiceRolls )
+ int v2; // edi@1
+
+ v2 = 0;
+ if (!this->ActorHasItems[3].uItemID)
{
- 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 (this->pMonsterInfo.uTreasureDiceRolls)
+ {
+ for (int i = 0; i < this->pMonsterInfo.uTreasureDiceRolls; i++)
+ v2 += rand() % this->pMonsterInfo.uTreasureDiceSides + 1;
+ if (v2)
+ {
+ this->ActorHasItems[3].uItemID = ITEM_GOLD_SMALL;
+ this->ActorHasItems[3].special_enchantment = (ITEM_ENCHANTMENT)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;
+ 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) --------------------------------------------------------
@@ -1968,7 +1968,7 @@
break;
case MONSTER_OOZE_1: case MONSTER_OOZE_2: case MONSTER_OOZE_3:
- drop.uItemID = ITEM_OOZE_ECTOPLASM_BOTTLE;
+ drop.uItemID = ITEM_OOZE_ENDOPLASM_VIAL;
break;
case MONSTER_TROLL_1: case MONSTER_TROLL_2: case MONSTER_TROLL_3:
@@ -3610,7 +3610,7 @@
if ( pMonster->pActorBuffs[ACTOR_BUFF_SHIELD].uExpireTime > 0 )
uDamageAmount /= 2;
IsAdditionalDamagePossible = true;
- if (projectileSprite->containing_item.uItemID != 0 && projectileSprite->containing_item.uSpecEnchantmentType == 3) //of carnage
+ if (projectileSprite->containing_item.uItemID != 0 && projectileSprite->containing_item.special_enchantment == 3) //of carnage
{
attackElement = DMGT_FIRE;
}
@@ -3643,7 +3643,7 @@
{
if ( projectileSprite )
{
- a4 = projectileSprite->containing_item._439DF3_get_additional_damage((int*)&attackElement, &isLifeStealing);
+ a4 = projectileSprite->containing_item._439DF3_get_additional_damage(&attackElement, &isLifeStealing);
if ( isLifeStealing && pMonster->sCurrentHP > 0 )
{
player->sHealth += v61 / 5;
@@ -3663,7 +3663,7 @@
item = player->GetOffHandItem();
else
item = player->GetMainHandItem();
- a4 = item->_439DF3_get_additional_damage((int*)&attackElement, &isLifeStealing);
+ a4 = item->_439DF3_get_additional_damage(&attackElement, &isLifeStealing);
if ( isLifeStealing && pMonster->sCurrentHP > 0 )
{
player->sHealth += v61 / 5;
@@ -3725,7 +3725,7 @@
&& 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) )
+ if ((player->GetSpecialItemBonus(ITEM_ENCHANTMENT_OF_FORCE) || hit_will_stun) && pMonster->DoesDmgTypeDoDamage(DMGT_EARTH))
{
extraRecoveryTime = 20;
knockbackValue = 10;
@@ -3765,6 +3765,9 @@
}
Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster, 1, v61);
}
+
+
+
//----- (004BBF61) --------------------------------------------------------
void Actor::Arena_summon_actor( int monster_id, __int16 x, int y, int z )
{
@@ -4151,7 +4154,7 @@
{
if ( this->ActorHasItems[3].uItemID != 0 && this->ActorHasItems[3].GetItemEquipType() == EQUIP_GOLD )
{
- v14 = this->ActorHasItems[3].uSpecEnchantmentType;
+ v14 = this->ActorHasItems[3].special_enchantment;
this->ActorHasItems[3].Reset();
if ( v14 )
{
diff -r 30eb6dcac768 -r d569340b05ff Engine/Objects/Chest.cpp
--- a/Engine/Objects/Chest.cpp Wed May 20 21:05:07 2015 +0200
+++ b/Engine/Objects/Chest.cpp Thu May 21 01:50:59 2015 +0200
@@ -729,7 +729,7 @@
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);
+ pParty->PartyFindsGold(pChests[(int)pGUIWindow_CurrentMenu->par1C].igChestItems[v4].special_enchantment, 0);
viewparams->bRedrawGameUI = 1;
}
else
diff -r 30eb6dcac768 -r d569340b05ff Engine/Objects/Items.cpp
--- a/Engine/Objects/Items.cpp Wed May 20 21:05:07 2015 +0200
+++ b/Engine/Objects/Items.cpp Thu May 21 01:50:59 2015 +0200
@@ -159,101 +159,101 @@
//----- (00439DF3) --------------------------------------------------------
-int ItemGen::_439DF3_get_additional_damage(int *damage_type, bool *draintargetHP)
- {
+int ItemGen::_439DF3_get_additional_damage(DAMAGE_TYPE *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;
- }
+ *damage_type = DMGT_FIRE;
+ if (uItemID == ITEM_NULL)
+ return 0;
+
+ UpdateTempBonus(pParty->uTimePlayed);
+ if (uItemID == ITEM_ARTIFACT_IRON_FEATHER)
+ {
+ *damage_type = DMGT_ELECTR;
+ return rand() % 10 + 6;
+ }
+ if (uItemID == ITEM_ARTIFACT_GHOULSBANE)
+ {
+ *damage_type = DMGT_FIRE;
+ return rand() % 16 + 3;
+ }
+ if (uItemID == ITEM_ARTEFACT_ULLYSES)
+ {
+ *damage_type = DMGT_COLD;
+ return rand() % 4 + 9;
+ }
+ if (uItemID == ITEM_RELIC_OLD_NICK)
+ {
+ *damage_type = DMGT_BODY;
+ 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;
+ switch (special_enchantment)
+ {
+ case ITEM_ENCHANTMENT_OF_COLD:
+ *damage_type = DMGT_COLD;
+ return rand() % 2 + 3;
+ break;
+ case ITEM_ENCHANTMENT_OF_FROST:
+ *damage_type = DMGT_COLD;
+ return rand() % 3 + 6;
+ break;
+ case ITEM_ENCHANTMENT_OF_ICE:
+ *damage_type = DMGT_COLD;
+ return rand() % 4 + 9;
+ break;
+ case ITEM_ENCHANTMENT_OF_SPARKS:
+ *damage_type = DMGT_ELECTR;
+ return rand() % 4 + 2;
+ break;
+ case ITEM_ENCHANTMENT_OF_LIGHTNING:
+ *damage_type = DMGT_ELECTR;
+ return rand() % 7 + 4;
+ break;
+ case ITEM_ENCHANTMENT_OF_THUNDERBOLTS:
+ *damage_type = DMGT_ELECTR;
+ return rand() % 10 + 6;
+ break;
+ case ITEM_ENCHANTMENT_OF_FIRE:
+ *damage_type = DMGT_FIRE;
+ return GetDiceResult(1, 6);
+ break;
+ case ITEM_ENCHANTMENT_OF_FLAME:
+ *damage_type = DMGT_FIRE;
+ return GetDiceResult(2, 6);
+ break;
+ case ITEM_ENCHANTMENT_OF_INFERNOS:
+ *damage_type = DMGT_FIRE;
+ return GetDiceResult(3, 6);
+ break;
+ case ITEM_ENCHANTMENT_OF_POISON:
+ *damage_type = DMGT_BODY;
+ return 5;
+ break;
+ case ITEM_ENCHANTMENT_OF_VENOM:
+ *damage_type = DMGT_BODY;
+ return 8;
+ break;
+ case ITEM_ENCHANTMENT_OF_ACID:
+ *damage_type = DMGT_BODY;
+ return 12;
+ break;
+ case ITEM_ENCHANTMENT_VAMPIRIC:
+ case ITEM_ENCHANTMENT_OF_DARKNESS:
+ *damage_type = DMGT_DARK;
+ *draintargetHP = true;
+ return 0;
+ break;
- }
-
- }
+ case ITEM_ENCHANTMENT_OF_DRAGON:
+ *damage_type = DMGT_FIRE;
+ return rand() % 11 + 10;
+ break;
+ default:
+ *damage_type = DMGT_FIRE;
+ return 0;
+ }
+}
//----- (00402F07) --------------------------------------------------------
@@ -262,10 +262,10 @@
this->uHolderPlayer = 0;
this->uAttributes = 0;
this->uNumCharges = 0;
- this->uSpecEnchantmentType = 0;
+ this->special_enchantment = ITEM_ENCHANTMENT_NULL;
this->m_enchantmentStrength = 0;
this->uEnchantmentType = 0;
- this->uItemID = 0;
+ this->uItemID = ITEM_NULL;
this->uBodyAnchor = 0;
this->uExpireTime = 0i64;
}
@@ -278,7 +278,7 @@
if ( uTimePlayed > (signed __int64)this->uExpireTime )
{
this->uEnchantmentType = 0;
- this->uSpecEnchantmentType = 0;
+ this->special_enchantment = ITEM_ENCHANTMENT_NULL;
this->uAttributes = this->uAttributes&(~ITEM_TEMP_BONUS);
}
}
@@ -315,414 +315,414 @@
//----- (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 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;
+ 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;
- char* test_string;
- int item_counter;
+ std::map materialMap;
+ materialMap["artifact"] = MATERIAL_ARTEFACT;
+ materialMap["relic"] = MATERIAL_RELIC;
+ materialMap["special"] = MATERIAL_SPECIAL;
- pMapStats = new MapStats;
- pMapStats->Initialize();
+ char* test_string;
+ int item_counter;
+
+ pMapStats = new MapStats;
+ pMapStats->Initialize();
- pMonsterStats = new MonsterStats;
- pMonsterStats->Initialize();
- pMonsterStats->InitializePlacements();
+ pMonsterStats = new MonsterStats;
+ pMonsterStats->Initialize();
+ pMonsterStats->InitializePlacements();
- pSpellStats = new SpellStats;
- pSpellStats->Initialize();
+ pSpellStats = new SpellStats;
+ pSpellStats->Initialize();
- LoadPotions();
- LoadPotionNotes();
+ LoadPotions();
+ LoadPotionNotes();
- pFactionTable = new FactionTable;
- pFactionTable->Initialize();
+ pFactionTable = new FactionTable;
+ pFactionTable->Initialize();
- pStorylineText = new StorylineText;
- pStorylineText->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++)
+ 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)
{
- pEnchantments[i].to_item[j]=atoi(tokens[j+2]);
+ 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];
- }
+ 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]);
- }
+ //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++)
+ 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)
{
- pSpecialEnchantments[i].to_item_apply[j]=atoi(tokens[j+2]);
+ 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;
}
- int res;
- res=atoi(tokens[14]);
- if(!res)
+
+ pSpecialEnchantments_count = 71;
+ memset(&pSpecialEnchantmentsSumm, 0, 96);
+ for (int i = 0; i < 12; ++i)
{
- ++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;
- }
+ for (unsigned int j = 0; j <= pSpecialEnchantments_count; ++j)
+ pSpecialEnchantmentsSumm[i] += pSpecialEnchantments[j].to_item_apply[i];
+ }
- 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();
+ 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
+ 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)
{
- pItems[item_counter].uDamageDice=0;
- pItems[item_counter].uDamageRoll=0;
+ 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++;
}
- 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)
+ 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++)
{
- 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;
- }
- }
- }
+ 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 < item_counter; ++j)
+ uChanceByTreasureLvlSumm[i] += pItems[j].uChanceByTreasureLvl[i];
}
- if ((pItems[item_counter].uMaterial==MATERIAL_SPECIAL)&&(pItems[item_counter]._bonus_type))
+ strtok(NULL, "\r");
+ strtok(NULL, "\r");
+ strtok(NULL, "\r");
+ strtok(NULL, "\r");
+ strtok(NULL, "\r");
+ for (int i = 0; i < 3; ++i)
{
- char b_s=atoi(tokens[13]);
- if (b_s)
- pItems[item_counter]._bonus_strength=b_s;
- else
- pItems[item_counter]._bonus_strength=1;
+ test_string = strtok(NULL, "\r") + 1;
+ auto tokens = Tokenize(test_string, '\t');
+ Assert(tokens.size() > 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;
+ }
}
- 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]);
- }
+ free(pRndItemsTXT_Raw);
+ pRndItemsTXT_Raw = nullptr;
- //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]);
+ }
- 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)
+ pStatsTXT_Raw = (char *)pEvents_LOD->LoadRaw("stats.txt", 0);
+ strtok(pStatsTXT_Raw, "\r");
+ for (int i = 0; i < 26; ++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;
+ 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]);
- }
+
+ 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();
-
- }
+ ItemGen::PopulateSpecialBonusMap();
+ ItemGen::PopulateArtifactBonusMap();
+ ItemGen::PopulateRegularBonusMap();
+
+
+}
//----- (00456D17) --------------------------------------------------------
void ItemsTable::SetSpecialBonus(ItemGen *pItem)
@@ -730,7 +730,7 @@
if ( pItems[pItem->uItemID].uMaterial == MATERIAL_SPECIAL )
{
pItem->uEnchantmentType = pItems[pItem->uItemID]._bonus_type;
- pItem->uSpecEnchantmentType = pItems[pItem->uItemID]._additional_value;
+ pItem->special_enchantment = (ITEM_ENCHANTMENT)pItems[pItem->uItemID]._additional_value;
pItem->m_enchantmentStrength = pItems[pItem->uItemID]._bonus_strength;
}
}
@@ -878,9 +878,9 @@
return uBaseValue;
if (uEnchantmentType )
return uBaseValue + 100 * m_enchantmentStrength;;
- if (uSpecEnchantmentType )
+ if (special_enchantment )
{
- bonus = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType].iTreasureLevel;
+ bonus = pItemsTable->pSpecialEnchantments[special_enchantment].iTreasureLevel;
if ( bonus > 10 )
return uBaseValue + bonus;
else
@@ -935,30 +935,30 @@
}
else
{
- if ( !uSpecEnchantmentType )
+ if ( !special_enchantment )
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.
+ if ( special_enchantment == 16 //Drain Hit Points from target.
+ || special_enchantment == 39 //Double damage vs Demons.
+ || special_enchantment == 40 //Double damage vs Dragons
+ || special_enchantment == 45 //+5 Speed and Accuracy
+ || special_enchantment == 56 //+5 Might and Endurance.
+ || special_enchantment == 57 //+5 Intellect and Personality.
+ || special_enchantment == 58 //Increased Value.
+ || special_enchantment == 60 //+3 Unarmed and Dodging skills
+ || special_enchantment == 61 //+3 Stealing and Disarm skills.
+ || special_enchantment == 59 //Increased Weapon speed.
+ || special_enchantment == 63 //Double Damage vs. Elves.
+ || special_enchantment == 64 //Double Damage vs. Undead.
+ || special_enchantment == 67 //Adds 5 points of Body damage and +2 Disarm skill.
+ || special_enchantment == 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->pSpecialEnchantments[special_enchantment-1].pNameAdd,
pItemsTable->pItems[uItemID].pName);
return item__getname_buffer.data();
}
strcat(item__getname_buffer.data(), " ");
- nameModificator = pItemsTable->pSpecialEnchantments[uSpecEnchantmentType-1].pNameAdd;
+ nameModificator = pItemsTable->pSpecialEnchantments[special_enchantment-1].pNameAdd;
}
strcat(item__getname_buffer.data(), nameModificator);
}
@@ -968,7 +968,7 @@
//----- (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
@@ -979,7 +979,7 @@
unsigned int v27; // eax@89
int v32; // ecx@91
int v33; // eax@91
-// unsigned int v34; // eax@97
+ // unsigned int v34; // eax@97
int v45; // eax@120
int v46; // edx@120
int j; // eax@121
@@ -994,12 +994,12 @@
treasureLevelMinus1 = treasure_level - 1;
- if ( uTreasureType ) //generate known treasure type
+ 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;
@@ -1031,147 +1031,147 @@
__debugbreak(); // check this condition
requested_equip = (ITEM_EQUIP_TYPE)(uTreasureType - 1);
break;
- }
+ }
memset(val_list, 0, sizeof(val_list));
total_chance = 0;
- j=0;
+ j = 0;
//a2a = 1;
if (requested_skill == PLAYER_SKILL_INVALID) // no skill for this item needed
+ {
+ for (uint i = 1; i < 500; ++i)
{
- for (uint i = 1; i < 500; ++i)
+ if (pItems[i].uEquipType == requested_equip)
{
- 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 )
+ 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;
- }
+ 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;
+ out_item->uItemID = ITEM_LONGSWORD_1;
}
}
else
{
- //artifact
- if ( treasureLevelMinus1 == 5 )
+ //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;
- }
+ 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 + ITEM_ARTIFACT_PUCK;
+ 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];
+ ++out_item->uItemID;
+ v57 += pItems[out_item->uItemID].uChanceByTreasureLvl[treasureLevelMinus1];
}
}
- if (out_item->GetItemEquipType() == EQUIP_POTION && out_item->uItemID != ITEM_POTION_BOTTLE )
+ 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;
+ 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) )
+ 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 )
+ 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;
+ if (out_item->GetItemEquipType() != EQUIP_POTION)
+ {
+ out_item->special_enchantment = ITEM_ENCHANTMENT_NULL;
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] )
+ case EQUIP_TWO_HANDED:
+ case EQUIP_BOW:
+ if (!uBonusChanceWpSpecial[treasureLevelMinus1])
return;
- if ((uint)(rand() % 100)>=uBonusChanceWpSpecial[treasureLevelMinus1])
+ 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] )
+ 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])
+ if (special_chance < uBonusChanceStandart[treasureLevelMinus1])
+ {
+ v26 = rand() % pEnchantmentsSumm[out_item->GetItemEquipType() - 3] + 1;
+ v27 = 0;
+ while (v27 < v26)
{
- 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];
- }
+ 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 )
+ 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;
+
+ }
+ else if (special_chance >= uBonusChanceStandart[treasureLevelMinus1] + uBonusChanceSpecial[treasureLevelMinus1])
+ return;
break;
case EQUIP_WAND:
out_item->uNumCharges = rand() % 6 + out_item->GetDamageMod() + 1;
@@ -1179,38 +1179,38 @@
return;
default:
return;
- }
+ }
- j=0;
- int spc_sum=0;
+ j = 0;
+ int spc_sum = 0;
int spc;
memset(&val_list, 0, 3200);
- for (unsigned int i=0; iGetItemEquipType()];
- spc_sum+=spc;
- if(spc)
+ int tr_lv = pSpecialEnchantments[i].iTreasureLevel;
+ if ((treasure_level - 1 == 2) && (tr_lv == 1 || tr_lv == 0) ||
+ (treasure_level - 1 == 3) && (tr_lv == 2 || tr_lv == 1 || tr_lv == 0) ||
+ (treasure_level - 1 == 4) && (tr_lv == 3 || tr_lv == 2 || tr_lv == 1) ||
+ (treasure_level - 1 == 5) && (tr_lv == 3)
+ )
{
- val_list[j++]=i;
+ spc = pSpecialEnchantments[i].to_item_apply[out_item->GetItemEquipType()];
+ spc_sum += spc;
+ if (spc)
+ {
+ val_list[j++] = i;
+ }
}
- }
}
- v46 = rand()%spc_sum+1;//случайные значения от 1 до spc_sum
- j=0;
+ 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()];
+ ++j;
+ out_item->special_enchantment = (ITEM_ENCHANTMENT)val_list[j];
+ v45 += pSpecialEnchantments[val_list[j]].to_item_apply[out_item->GetItemEquipType()];
}
}
@@ -1658,7 +1658,7 @@
void ItemGen::GetItemBonusSpecialEnchantment( Player* owner, CHARACTER_ATTRIBUTE_TYPE attrToGet, int* additiveBonus, int* halfSkillBonus )
{
- auto bonusList = ItemGen::specialBonusMap.find(this->uSpecEnchantmentType);
+ auto bonusList = ItemGen::specialBonusMap.find(this->special_enchantment);
if (bonusList == ItemGen::specialBonusMap.end())
{
return;
@@ -1787,7 +1787,7 @@
if (item_count < 6)
{
pParty->StandartItemsInShops[shop_index][item_count].Reset();
- pParty->StandartItemsInShops[shop_index][item_count].uItemID = 220; //potion bottle
+ pParty->StandartItemsInShops[shop_index][item_count].uItemID = ITEM_POTION_BOTTLE; //potion bottle
continue;
}
else
@@ -1840,7 +1840,7 @@
if (item_count < 6)
{
pParty->SpecialItemsInShops[shop_index][item_count].Reset();
- pParty->SpecialItemsInShops[shop_index][item_count].uItemID = rand() % 32 + 740; //mscrool
+ pParty->SpecialItemsInShops[shop_index][item_count].uItemID = rand() % 32 + ITEM_RECIPE_REJUVENATION; //mscrool
continue;
}
else
@@ -1859,7 +1859,7 @@
//----- (00450218) --------------------------------------------------------
void GenerateItemsInChest()
- {
+{
unsigned int mapType; // eax@1
MapInfo *currMapInfo; // esi@1
ItemGen *currItem; // ebx@2
@@ -1875,82 +1875,82 @@
mapType = pMapStats->GetMapInfo(pCurrentMapName);
currMapInfo = &pMapStats->pInfos[mapType];
- for(int i=1; i<20;++i)
+ for (int i = 1; i < 20; ++i)
{
- for(int j=0; j<140;++j)
+ for (int j = 0; j < 140; ++j)
{
currItem = &pChests[i].igChestItems[j];
- if ( currItem->uItemID < 0 )
+ 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];
+ 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)
+ if (resultTreasureLevel < 7)
{
- v11 = 0;
- do
- {
- whatToGenerateProb = rand() % 100;
- if (whatToGenerateProb<20)
- {
- currItem->Reset();
- }
- else if (whatToGenerateProb<60) //generate gold
+ v11 = 0;
+ do
{
- 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
+ whatToGenerateProb = rand() % 100;
+ if (whatToGenerateProb < 20)
+ {
+ currItem->Reset();
+ }
+ else if (whatToGenerateProb < 60) //generate gold
+ {
+ goldAmount = 0;
+ currItem->Reset();
+ switch (resultTreasureLevel)
+ {
+ case 1:
+ goldAmount = rand() % 51 + 50;
+ currItem->uItemID = ITEM_GOLD_SMALL;
+ break;
+ case 2:
+ goldAmount = rand() % 101 + 100;
+ currItem->uItemID = ITEM_GOLD_SMALL;
+ break;
+ case 3:
+ goldAmount = rand() % 301 + 200;
+ currItem->uItemID = ITEM_GOLD_MEDIUM;
+ break;
+ case 4:
+ goldAmount = rand() % 501 + 500;
+ currItem->uItemID = ITEM_GOLD_MEDIUM;
+ break;
+ case 5:
+ goldAmount = rand() % 1001 + 1000;
+ currItem->uItemID = ITEM_GOLD_LARGE;
+ break;
+ case 6:
+ goldAmount = rand() % 3001 + 2000;
+ currItem->uItemID = ITEM_GOLD_LARGE;
+ break;
+ }
+ currItem->SetIdentified();
+ currItem->special_enchantment = (ITEM_ENCHANTMENT)goldAmount;
+ }
+ else
+ {
+ pItemsTable->GenerateItem(resultTreasureLevel, 0, currItem);
+ }
+ v12 = 0;
+ while (!(pChests[i].igChestItems[v12].uItemID == ITEM_NULL) && (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();
}
- }
+ }
}
}
diff -r 30eb6dcac768 -r d569340b05ff Engine/Objects/Items.h
--- a/Engine/Objects/Items.h Wed May 20 21:05:07 2015 +0200
+++ b/Engine/Objects/Items.h Thu May 21 01:50:59 2015 +0200
@@ -3,20 +3,20 @@
#include