10 #include "../Autonotes.h"
11 #include "../Awards.h"
12 #include "../Events.h"
13 #include "../Events2D.h"
14 #include "../Graphics/Outdoor.h"
15 #include "../Graphics/Viewport.h"
18 #include "../Tables/PlayerFrameTable.h"
19 #include "../Tables/StorylineTextTable.h"
20 #include "../TurnEngine/TurnEngine.h"
23 #include "../Graphics/DecalBuilder.h"
24 #include "../OurMath.h"
25 #include "../Spells/CastSpellInfo.h"
26 #include "../stru123.h"
27 #include "../stru298.h"
112 {0, 2, 0, 1, 1, 1, 1, 0, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0,
113 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0},
114 {0, 1, 2, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
115 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 2, 1, 0},
116 {1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
117 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 2, 2, 1, 1, 0, 0, 0},
118 {0, 1, 1, 1, 0, 0, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0,
119 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0},
120 {0, 1, 0, 1, 1, 2, 0, 0, 0, 1, 0, 0, 1, 2, 1, 0, 0, 0, 0,
121 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1},
122 {0, 1, 1, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
123 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0},
124 {0, 0, 0, 0, 0, 0, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 2,
125 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1},
126 {0, 0, 2, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 2, 1, 0, 1,
127 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1},
128 {2, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 1, 1, 1, 0, 0, 0,
129 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0}
161 25, 20, 20, 0, 0, 0};
162 unsigned char pBaseManaByClass[12] = {0, 0, 0, 5, 5, 0, 10, 10, 15, 0, 0, 0};
164 5, 7, 9, 9, 4, 6, 8, 8, 5, 6, 8, 8, 4, 5, 6, 6, 3, 4,
165 6, 6, 4, 5, 6, 6, 2, 3, 4, 4, 2, 3, 4, 4, 2, 3, 3, 3};
167 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 2, 3, 3, 1, 2,
168 3, 3, 0, 2, 3, 3, 3, 4, 5, 5, 3, 4, 5, 5, 3, 4, 6, 6};
171 {100, 100, 100, 120, 50, 200, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100,
173 {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100,
175 {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100,
177 {100, 100, 100, 100, 50, 150, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100,
179 {100, 100, 100, 50, 10, 100, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100,
181 {100, 100, 100, 120, 20, 120, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100,
183 {100, 100, 100, 100, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
184 100, 100, 100, 100}};
193 {100, 100, 100, 100}};
198 {16, 15, 14, 17, 13, 2, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 1, 0}};
201 500, 400, 350, 300, 275, 250, 225, 200, 175, 150, 125, 100, 75, 50, 40,
202 35, 30, 25, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 0};
204 30, 25, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8,
205 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6};
224 int CurrentStatValue = 50;
225 int RemainingStatPoints = 50;
231 for (
int playerNum = 0; playerNum < 4; playerNum++) {
234 for (
int statNum = 0; statNum <= 6; statNum++) {
262 if (CurrentStatValue >=
271 RemainingStatPoints +=
272 PenaltyMult * (StatBaseValue - CurrentStatValue) / BonusMult;
276 return RemainingStatPoints;
281 if (
engine->config->debug_all_magic)
return true;
308 for (
int i = 0; i < 16; ++i) {
312 item_id =
pOwnItems[item_idx - 1].uItemID;
334 GameTime diff = playtime - condtime;
342 int conditionTimeMultiplier = 1;
343 int baseConditionMultiplier =
348 if (conditionIdx >= 14 &&
349 conditionIdx <= 16) {
350 if (conditionIdx <= 15)
351 baseConditionMultiplier = 5;
353 baseConditionMultiplier = 10;
356 }
else if (conditionIdx < 14) {
357 for (
int i = 0; i <= 13; i++) {
361 conditionTimeMultiplier)
362 conditionTimeMultiplier = high_mult;
366 result = (int)((
double)conditionTimeMultiplier *
367 (double)baseConditionMultiplier *
383 (
signed int)(((
double)uRealValue / (price_multiplier + 2.0)) +
398 (
uint)(((100 -
GetMerchant()) * (uRealValue * price_multiplier)) / 100);
400 if (price < uRealValue)
408 signed int basecost = (price_multiplier * 50.0);
409 int actcost = basecost * (100 -
GetMerchant()) / 100;
411 if (actcost < basecost / 3)
412 actcost = basecost / 3;
422 signed int basecost = (uRealValue / (6.0 - price_multiplier));
423 int actcost = basecost * (100 -
GetMerchant()) / 100;
425 if (actcost < basecost / 3)
426 actcost = basecost / 3;
436 signed int basecost = (uRealValue / (price_multiplier + 2.0));
446 signed int basecost = uRealValue * price_multiplier;
456 signed int basecost = price_multiplier * 50.0;
466 signed int basecost = (uRealValue / (6.0 - price_multiplier));
496 if (!inventory_index) {
505 int cell_idx = inout_item_cell;
506 if (cell_idx > 125 || cell_idx < 0)
return 0;
509 if (inventory_index < 0) {
513 return inventory_index;
518 int avalible_items = 0;
520 __int16 item_index_tabl[138];
521 memset(item_index_tabl, 0,
sizeof(item_index_tabl));
523 for (
int i = 0; i < 138; ++i) {
525 item_index_tabl[avalible_items++] = i;
528 if (avalible_items) {
530 for (
int i = 0; i < enchant_count; ++i) {
532 item_index_tabl[rand() % avalible_items];
540 for (
int i = 0; i < avalible_items; ++i) {
621 switch (uConditionIdx) {
699 int players_before = 0;
700 for (
int i = 1; i < 5;
708 int remainig_player = 0;
709 int players_after = 0;
710 for (
int i = 1; i < 5; ++i) {
717 if ((players_before == 2) &&
720 pPlayers[remainig_player]->PlaySound(
733 Assert(slotHeight > 0 && slotWidth > 0,
734 "Items should have nonzero dimensions");
737 for (
unsigned int x = 0;
x < slotWidth;
x++) {
738 for (
unsigned int y = 0;
y < slotHeight;
y++) {
751 for (
int i = 0; i < 126; i++) {
764 if (freeSlot == -1) {
793 if (item_indx != -1) {
856 if (freeSlot == -1) {
869 int uItemID,
int itemListPos,
877 if (slot_width > 0) {
879 for (
unsigned int i = 0; i < slot_height; i++) {
899 item_in_slot->
Reset();
902 if (inventory_index < 0) {
903 index = (-1 - inventory_index);
906 if (slot_width > 0) {
908 for (
unsigned int i = 0; i < slot_height; i++) {
921 return multiplier * skill;
930 return multiplier * skill;
945 bool result = (multiplier * skill) >=
964 if (skillmaster == 4)
968 bool result = (multiplier * skill) >=
981 if (skillmaster == 4)
985 int bonus = multiplier * skill;
990 return bonus - rep + 7;
1000 if (skillmaster == 4)
1003 return multiplier * skill;
1013 if (skillmaster == 4)
1019 return multiplier * skill;
1028 return multiplier * skill + 9;
1118 signed int npc_luck_bonus = 0;
1133 unsigned short Player::*attrValue,
1134 unsigned short Player::*attrBonus) {
1136 uint uAgeingMultiplier = 100;
1138 for (
uint i = 0; i < 4; ++i) {
1151 return uConditionMult * uAgeingMultiplier * this->*attrValue / 100 / 100 +
1152 magicBonus + itemBonus + this->*attrBonus;
1164 return parbonus + atkskillbonus + weapbonus +
1203 unsigned int uTargetActorID) {
1205 int offHndWpnDmg = 0;
1208 mainWpnDmg = rand() % 3 + 1;
1213 int itemId = mainHandItemGen->
uItemID;
1214 bool addOneDice =
false;
1221 mainHandItemGen, uTargetActorID, addOneDice);
1224 if (!ignoreOffhand) {
1234 offHandItemGen, uTargetActorID,
false);
1240 int dmgSum = mainWpnDmg + offHndWpnDmg;
1242 if (!ignoreSkillBonus) {
1244 int mightAndSkillbonus =
1251 if (dmgSum < 1) dmgSum = 1;
1257 unsigned int uTargetActorID,
1262 if (addOneDice) diceCount++;
1267 for (
int i = 0; i < diceCount; i++) {
1268 diceResult += rand() % diceSides + 1;
1274 if (uTargetActorID > 0) {
1318 if (mainHandItem !=
nullptr &&
1374 int damagefromroll = 0;
1379 damagefromroll += ((rand() % dmgperroll) + 1);
1385 if (uMonsterInfoID) {
1386 if (itemenchant == 64 &&
1391 }
else if (itemenchant == 39 &&
1396 }
else if (itemenchant == 40 &&
1401 }
else if (itemenchant == 63 &&
1422 }
else if (mainHandItem !=
nullptr &&
1433 if (min_damage == max_damage) {
1436 return StringPrintf(
"%d - %d", min_damage, max_damage);
1447 if (mainHandItem !=
nullptr && (mainHandItem->
uItemID >= 135) &&
1448 (mainHandItem->
uItemID <= 159)) {
1450 }
else if (mainHandItem !=
nullptr &&
1461 if (max_damage > 0) {
1462 if (min_damage == max_damage) {
1475 int lvl = this->
uLevel + 1;
1476 int neededExp = ((lvl * (lvl - 1)) / 2 * 1000);
1498 int resist_value = 0;
1529 signed int res_rand_divider =
1533 for (
int i = 0; i < 4; i++) {
1534 if (rand() % res_rand_divider >= 30)
1543 (equippedArmor !=
nullptr)) {
1593 for (
uint i = 0; i < 16; ++i) {
1610 for (
int i = 0; i < 16; i++) {
1621 ItemGen* itemToSteal,
int extraStealDifficulty,
int reputation,
1623 int* fineIfFailed) {
1628 if (!itemToSteal || !
CanAct()) {
1631 unsigned int stealskill =
1633 unsigned int stealmaster =
1635 unsigned int itemvalue = itemToSteal->
GetValue();
1644 *fineIfFailed = 100 * (reputation + extraStealDifficulty) + itemvalue;
1646 if (extraStealFine) {
1647 *fineIfFailed += 500;
1650 if (rand() % 100 >= 5) {
1651 if (*fineIfFailed > currMaxItemValue) {
1652 if (*fineIfFailed - currMaxItemValue < 500) {
1668 unsigned int uActorID,
int _steal_perm,
1672 actroPtr = &
pActors[uActorID];
1674 if (!actroPtr || !
CanAct()) {
1682 unsigned int stealingMastery =
1689 if (rand() % 100 < 5 || fineIfFailed > currMaxItemValue ||
1696 int random = rand();
1698 if (random % 100 >= 70) {
1706 unsigned int enchBonusSum = 0;
1707 for (
int i = 0; i < stealskill; i++)
1717 if ((
int)enchBonusSum >= *enchTypePtr) {
1718 enchBonusSum = *enchTypePtr;
1722 *enchTypePtr -= enchBonusSum;
1728 302, this->pName, enchBonusSum));
1735 }
else if (random % 100 >= 40) {
1739 int randslot = rand() % 4;
1740 unsigned int carriedItemId =
1745 if (carriedItemId != 0 ||
1749 if (carriedItemId != 0) {
1751 tempItem.
uItemID = carriedItemId;
1763 memcpy(&tempItem, itemToSteal,
sizeof(tempItem));
1764 itemToSteal->
Reset();
1765 carriedItemId = tempItem.
uItemID;
1768 if (carriedItemId !=
1820 if (!
engine->config->NoDamage()) {
1836 if (equippedArmor !=
nullptr) {
1847 return recieved_dmg;
1853 struct Actor* pActor) {
1860 signed int itemstobreakcounter = 0;
1861 char itemstobreaklist[140];
1862 ItemGen* itemtocheck =
nullptr;
1863 ItemGen* itemtobreak =
nullptr;
1864 unsigned int itemtostealinvindex = 0;
1866 switch (attTypeCast) {
1912 for (
int i = 0; i < 138; i++) {
1917 itemstobreaklist[itemstobreakcounter++] = i;
1920 if (!itemstobreakcounter)
return 0;
1923 [itemstobreaklist[rand() % itemstobreakcounter]];
1930 for (
int i = 0; i < 16; i++) {
1933 itemstobreaklist[itemstobreakcounter++] =
1939 itemstobreaklist[itemstobreakcounter++] =
1944 if (!itemstobreakcounter)
return 0;
1947 [itemstobreaklist[rand() % itemstobreakcounter]];
1954 for (
int i = 0; i < 16; i++) {
1957 itemstobreaklist[itemstobreakcounter++] =
1965 itemstobreaklist[itemstobreakcounter++] =
1970 if (!itemstobreakcounter)
return 0;
1973 [itemstobreaklist[rand() % itemstobreakcounter]];
1980 for (
int i = 0; i < 126; i++) {
1983 if (ItemPosInList > 0) {
1986 if (itemtocheck->
uItemID > 0 &&
1987 itemtocheck->
uItemID <= 134) {
1988 itemstobreaklist[itemstobreakcounter++] = i;
1993 if (!itemstobreakcounter)
return 0;
1995 itemtostealinvindex =
1996 itemstobreaklist[rand() % itemstobreakcounter];
2007 signed int whichplayer;
2009 if (rand() % savecheck >= 30) {
2012 for (whichplayer = 0; whichplayer < 4; whichplayer++) {
2013 if (
this ==
pPlayers[whichplayer + 1])
break;
2019 switch (attTypeCast) {
2206 if (bRangedAttack) {
2232 ->GetPlayerSkillType()] >
2241 uint armour_recovery = 0;
2244 uint base_armour_recovery =
2250 armour_skill_type, 1.0
f, 0, 0, 0);
2253 armour_skill_type, 1.0
f, 0.5
f, 0, 0);
2256 armour_skill_type, 1.0
f, 0.5
f, 0.5
f, 0);
2261 armour_skill_type, 1.0
f, 1.0
f, 1.0
f, 1.0
f);
2264 armour_recovery = (
uint)(base_armour_recovery * multiplier);
2267 uint shield_recovery = 0;
2272 uint shield_base_recovery =
2276 shield_recovery = (
uint)(shield_base_recovery * multiplier);
2280 sword_axe_bow_recovery_reduction = 0;
2281 bool shooting_laser =
false;
2282 if (weapon !=
nullptr) {
2290 sword_axe_bow_recovery_reduction =
2294 shooting_laser =
true;
2297 uint armsmaster_recovery_reduction = 0;
2298 if (!bRangedAttack && !shooting_laser) {
2299 if (
uint armsmaster_level =
2301 armsmaster_recovery_reduction = armsmaster_level & 0x3F;
2303 armsmaster_recovery_reduction *= 2;
2307 uint hasteRecoveryReduction = 0;
2311 uint weapon_enchantment_recovery_reduction = 0;
2316 weapon_enchantment_recovery_reduction = 20;
2319 int recovery = weapon_recovery + armour_recovery + shield_recovery -
2320 armsmaster_recovery_reduction -
2321 weapon_enchantment_recovery_reduction -
2322 hasteRecoveryReduction - sword_axe_bow_recovery_reduction -
2323 player_speed_recovery_reduction;
2325 if (recovery < 0) recovery = 0;
2331 unsigned char armour_skill_type,
float mult1,
float mult2,
float mult3,
2335 switch (skill_mastery) {
2349 Error(
"Unexpected input value: %d", armour_skill_type);
2481 int racialBonus = 0;
2512 Error(
"Unknown attribute");
2539 v10 += leatherArmorSkillLevel;
2562 Error(
"Unexpected attribute");
2615 for (
uint i = 0; i < 18; ++i) {
2656 bool getOnlyMainHandDmg ) {
2780 if (v22 >= 0 && v22 <= 2) {
2792 if (getOnlyMainHandDmg ||
2802 return v5 + v15 + v14;
2814 if (v17 >= 0 && v17 <= 2) {
2818 if (getOnlyMainHandDmg ||
2835 if (v9 >= 0 && v9 <= 2) {
2846 if (getOnlyMainHandDmg ||
2855 return v5 + v15 + v14;
2900 for (
int i = 0; i < 16; i++) {
2905 if (v32 >= 3 && v32 <= 11) {
2921 v5 < currEquippedItem
2922 ->m_enchantmentStrength)
2930 this, attr, &v5, &v61);
2934 return v5 + v62 + v61;
3025 switch (uSkillType) {
3168 result = bonus_value + skill_value;
3200 int armsMasterBonus;
3202 armsMasterBonus = 0;
3204 if (armmaster_skill > 0) {
3213 armsMasterBonus = multiplier * (armmaster_skill);
3222 return multiplier * (bowSkillLevel & 0x3F);
3229 return base_value * attrib_modif;
3234 return base_value * attrib_modif;
3237 bool wearingArmor =
false;
3238 bool wearingLeather =
false;
3239 unsigned int ACSum = 0;
3241 for (
int j = 0; j < 16; ++j) {
3243 if (currItem !=
nullptr && (!currItem->
IsBroken())) {
3246 int currArmorSkillLevel = 0;
3248 switch (itemSkillType) {
3250 currArmorSkillLevel =
3253 itemSkillType, 0, 1, 1, 1);
3257 currArmorSkillLevel =
3260 itemSkillType, 0, 0, 0, 1);
3263 currArmorSkillLevel =
3265 wearingArmor =
true;
3267 itemSkillType, 1, 1, 2, 2);
3270 currArmorSkillLevel =
3272 wearingLeather =
true;
3274 itemSkillType, 1, 1, 2, 2);
3277 currArmorSkillLevel =
3279 wearingArmor =
true;
3281 itemSkillType, 1, 1, 1, 1);
3284 currArmorSkillLevel =
3286 wearingArmor =
true;
3288 itemSkillType, 1, 1, 1, 1);
3291 ACSum += multiplier * (currArmorSkillLevel & 0x3F);
3299 if (!wearingArmor && (!wearingLeather || dodgeMastery == 4)) {
3300 ACSum += multiplier * (dodgeSkillLevel & 0x3F);
3308 if (!unarmedSkill) {
3313 return armsMasterBonus + multiplier * (unarmedSkill & 0x3F);
3315 for (
int i = 0; i < 16; ++i) {
3321 int currentItemSkillLevel =
3325 currItemSkillType, 1, 2, 3, 5);
3326 return multiplier * (currentItemSkillLevel & 0x3F);
3330 int unarmedSkillLevel =
3334 return multiplier * (unarmedSkillLevel & 0x3F) +
3336 (currentItemSkillLevel & 0x3F);
3338 return armsMasterBonus +
3339 (currentItemSkillLevel & 0x3F);
3348 for (
int i = 0; i < 16; i++) {
3357 int currentItemSkillLevel =
3362 return multiplier * (currentItemSkillLevel & 0x3F);
3363 }
else if (currentItemSkillType ==
3367 return multiplier * (currentItemSkillLevel & 0x3F);
3377 int unarmedSkillLevel =
3379 if (!unarmedSkillLevel) {
3384 return multiplier * (unarmedSkillLevel & 0x3F);
3386 for (
int i = 0; i < 16; i++) {
3395 int currItemSkillLevel =
3399 switch (currItemSkillType) {
3405 int unarmedSkillLevel =
3411 (unarmedSkillLevel & 0x3F);
3413 return armsMasterBonus;
3421 multiplier * (currItemSkillLevel & 0x3F);
3422 return armsMasterBonus + baseSkillBonus;
3428 multiplier * (currItemSkillLevel & 0x3F);
3429 return armsMasterBonus + baseSkillBonus;
3434 currItemSkillType, 0, 1, 1, 1);
3436 multiplier * (currItemSkillLevel & 0x3F);
3437 return armsMasterBonus + baseSkillBonus;
3443 multiplier * (currItemSkillLevel & 0x3F);
3444 return armsMasterBonus + baseSkillBonus;
3461 switch (masteryLvl) {
3471 Error(
"(%u)", masteryLvl);
3620 for (
uint i = 0; i < 37; ++i) {
3638 unsigned char requiredValue;
3642 canBeInactive =
false;
3645 }
else if (
order <= 3) {
3646 canBeInactive =
false;
3649 }
else if (
order <= 12) {
3650 canBeInactive =
true;
3657 for (
int i = 0; i < 37; i++) {
3679 uMinValue = pBaseValue - 2;
3681 unsigned short* AttrToChange =
nullptr;
3682 switch (eAttribute) {
3684 AttrToChange = &this->
uMight;
3699 AttrToChange = &this->
uSpeed;
3702 AttrToChange = &this->
uLuck;
3705 if (*AttrToChange <= pBaseValue) pStep = pDroppedStep;
3706 if (*AttrToChange - pStep >= uMinValue) *AttrToChange -= pStep;
3714 signed int baseStep;
3718 signed int droppedStep;
3719 unsigned short* statToChange;
3727 switch (eAttribute) {
3729 statToChange = &this->
uMight;
3744 statToChange = &this->
uSpeed;
3747 statToChange = &this->
uLuck;
3750 Error(
"(%u)", eAttribute);
3753 if (*statToChange < baseValue) {
3755 baseStep = droppedStep;
3759 if (
result >= droppedStep) {
3760 if (baseStep + *statToChange <= maxValue) *statToChange += baseStep;
3801 int attribute_value;
3806 attribute_value =
uMight;
3821 attribute_value =
uSpeed;
3824 attribute_value =
uLuck;
3827 Error(
"Unexpected attribute");
3830 if (attribute_value == base_attribute_value)
3832 else if (attribute_value > base_attribute_value)
3857 unsigned __int16 v17;
3867 unsigned __int16 v50;
3886 new_mana_val = playerAffected->
sMana;
3888 if (new_mana_val > playerAffected->
GetMaxMana())
3892 playerAffected->
Heal(2);
3927 playerAffected->
Heal(v25);
3933 new_mana_val = playerAffected->
sMana;
3934 new_mana_val += v26;
3935 if (new_mana_val > playerAffected->
GetMaxMana())
3938 playerAffected->
sMana = new_mana_val;
3973 GameTime(0, TIME_SECONDS_PER_QUANT *
3984 GameTime(0, TIME_SECONDS_PER_QUANT *
3995 GameTime(0, TIME_SECONDS_PER_QUANT *
4007 GameTime(0, TIME_SECONDS_PER_QUANT *
4019 GameTime(0, TIME_SECONDS_PER_QUANT *
4030 GameTime(0, TIME_SECONDS_PER_QUANT *
4041 GameTime(0, TIME_SECONDS_PER_QUANT *
4065 GameTime(0, TIME_SECONDS_PER_QUANT *
4076 GameTime(0, TIME_SECONDS_PER_QUANT *
4088 GameTime(0, TIME_SECONDS_PER_QUANT *
4100 GameTime(0, TIME_SECONDS_PER_QUANT *
4112 GameTime(0, TIME_SECONDS_PER_QUANT *
4124 GameTime(0, TIME_SECONDS_PER_QUANT *
4151 playerAffected->
Heal(v25);
4156 new_mana_val = playerAffected->
sMana;
4157 new_mana_val += v26;
4158 if (new_mana_val > playerAffected->
GetMaxMana())
4165 GameTime(0, TIME_SECONDS_PER_QUANT *
4177 GameTime(0, TIME_SECONDS_PER_QUANT *
4189 GameTime(0, TIME_SECONDS_PER_QUANT *
4201 GameTime(0, TIME_SECONDS_PER_QUANT *
4213 GameTime(0, TIME_SECONDS_PER_QUANT *
4225 GameTime(0, TIME_SECONDS_PER_QUANT *
4237 GameTime(0, TIME_SECONDS_PER_QUANT *
4253 playerAffected->
uLuck += 50;
4260 playerAffected->
uSpeed += 50;
4295 playerAffected->
uMight += 50;
4337 if (!playerAffected->
CanAct()) {
4346 if (
engine->IsUnderwater()) {
4353 if (scroll_id == 30 || scroll_id == 4 || scroll_id == 91 ||
4385 if (!playerAffected->
CanAct()) {
4415 if (v16 > v67 || !v17) {
4456 if (playerAffected->
CanAct()) {
4481 playerAffected->
uMight += thisa;
4483 "+%u %s %s", thisa, v74,
4489 "+%u %s %s", thisa, v74,
4495 "+%u %s %s", thisa, v74,
4501 "+%u %s %s", thisa, v74,
4507 "+%u %s %s", thisa, v74,
4511 playerAffected->
uSpeed += thisa;
4513 "+%u %s %s", thisa, v74,
4517 playerAffected->
uLuck += thisa;
4519 "+%u %s %s", thisa, v74,
4537 "+%u %s", 2 * thisa,
4543 "+%u %s", 2500 * thisa,
4549 auto spell_school_name =
4572 (
"Unexpected attribute");
4576 "+%u %s %s", thisa, spell_school_name,
4637 if (valToCompare <= 63)
4638 v4 = skillValue & 0x3F;
4640 v4 = skillValue & skillValue;
4641 return v4 >= valToCompare;
4649 Assert(pValue >= 0,
"Compare variable shouldn't have negative arguments");
4652 unsigned __int8 test_bit_value;
4653 unsigned __int8 byteWithRequestedBit;
4673 return (pValue == this->
uSex);
4679 return this->
sHealth >= pValue;
4683 return this->
sMana >= pValue;
4691 return this->
uLevel >= pValue;
4705 for (
int i = 0; i < 126; i++) {
4740 return this->
uMight >= pValue;
4748 return this->
uSpeed >= pValue;
4752 return this->
uLuck >= pValue;
4786 Error(
"Physical resistance isn't used in events");
4867 Error(
"Thievery isn't used in events");
4922 return v4 >= pValue;
4927 test_bit_value = 0x80u >> (pValue - 2) % 8;
4929 return (test_bit_value & byteWithRequestedBit) != 0;
4933 return (actStat >= baseStat);
4937 return (actStat >= baseStat);
4941 return (actStat >= baseStat);
4945 return (actStat >= baseStat);
4949 return (actStat >= baseStat);
4953 return (actStat >= baseStat);
4957 return (actStat >= baseStat);
4959 test_bit_value = 0x80u >> ((
signed __int16)pValue - 1) % 8;
4960 byteWithRequestedBit =
4962 return (test_bit_value & byteWithRequestedBit) != 0;
4974 for (
int playerNum = 0; playerNum < 4; playerNum++) {
4975 for (
int invPos = 0; invPos < 138; invPos++) {
4977 .pInventoryItemList[invPos]
4992 return v4 >= pValue;
5048 for (
int i = 0; i < 16; i++) {
5113 for (
int i = 0; i < 138; i++) {
5148 this->
sMana = var_value;
5159 this->
uLevel = (
unsigned __int8)var_value;
5204 v6 = rand() % var_value + 1;
5215 v7 = rand() % var_value + 1;
5223 this->
uMight = (
unsigned __int8)var_value;
5231 this->
uWillpower = (
unsigned __int8)var_value;
5235 this->
uEndurance = (
unsigned __int8)var_value;
5239 this->
uSpeed = (
unsigned __int8)var_value;
5243 this->
uAccuracy = (
unsigned __int8)var_value;
5247 this->
uLuck = (
unsigned __int8)var_value;
5282 this->
uLuckBonus = (
unsigned __int8)var_value;
5362 Error(
"Physical res. bonus not used");
5593 Error(
"Thieving unsupported");
5625 int v25 = 8 * playerIndex + 400;
5626 HEXRAYS_LOBYTE(v25) = PID(
OBJECT_Player, playerIndex - 112);
5645 unsigned __int16 skillValue) {
5646 unsigned __int16 currSkillValue = this->*skillToSet;
5647 if (skillValue > 63) {
5648 this->*skillToSet = skillValue | currSkillValue & 63;
5650 this->*skillToSet = skillValue | currSkillValue & 0xC0;
5728 v7 = rand() %
val + 1;
5836 this->
uLuck = std::min(this->
uLuck + val, 255);
6171 Error(
"Thieving unsupported");
6217 unsigned __int16 addSkillValue) {
6218 if (addSkillValue > 63) {
6220 (
unsigned __int8)addSkillValue | this->*skillToSet & 63;
6222 this->*skillToSet = std::min(this->*skillToSet + addSkillValue, 60) |
6223 this->*skillToSet & 0xC0;
6257 this->
sMana = std::max(this->
sMana - pValue, 0);
6265 this->
uLevel -= (
unsigned __int8)pValue;
6277 (
signed __int16)pValue, 0);
6288 for (
uint i = 0; i < 16; ++i) {
6298 for (
int i = 0; i < 126; i++) {
6320 randGold = rand() % (
signed int)pValue + 1;
6332 randFood = rand() % (
signed int)pValue + 1;
6372 this->
uLuckBonus -= (
unsigned __int16)pValue;
6376 this->
uMight -= (
unsigned __int16)pValue;
6384 this->
uWillpower -= (
unsigned __int16)pValue;
6388 this->
uEndurance -= (
unsigned __int16)pValue;
6392 this->
uSpeed -= (
unsigned __int16)pValue;
6396 this->
uAccuracy -= (
unsigned __int16)pValue;
6400 this->
uLuck -= (
unsigned __int16)pValue;
6496 this->
skillAxe -= (
unsigned __int8)pValue;
6504 this->
skillBow -= (
unsigned __int8)pValue;
6508 this->
skillMace -= (
unsigned __int8)pValue;
6532 this->
skillFire -= (
unsigned __int8)pValue;
6536 this->
skillAir -= (
unsigned __int8)pValue;
6552 this->
skillMind -= (
unsigned __int8)pValue;
6556 this->
skillBody -= (
unsigned __int8)pValue;
6564 this->
skillDark -= (
unsigned __int8)pValue;
6596 Error(
"Thieving unsupported");
6704 if (npcIndex == pValue) {
6729 this->uSkillPoints -= pValue;
6731 this->uSkillPoints = 0;
6743 if ((
unsigned int)pValue <= pParty->uNumGoldInBank) {
6789 int itemInvLocation;
6793 tempPickedItem.
Reset();
6797 if (itemInvLocation) {
6800 ->pInventoryItemList[itemInvLocation - 1]
6808 &tempPickedItem,
sizeof(
ItemGen));
6813 if (freeSlot >= 0) {
6826 const int PARTYSIZE = 4;
6827 int valToAdd = backwards ? (PARTYSIZE - 2) : 0;
6828 int mult = backwards ? -1 : 1;
6830 for (
int i = 0; i < (PARTYSIZE - 1); i++) {
6833 if (
pPlayers[currCharId]->uTimeToRecovery == 0) {
6857 for (
uint i = 0; i < 126; ++i) {
6859 if ((
unsigned int)
this
6861 .uItemID == uItemID)
6865 for (
uint i = 0; i < 16; ++i) {
6867 if ((
unsigned int)
this
6883 for (
int i = 1; i <= 4; i++) {
6885 sex =
pPlayers[i]->GetSexByVoice();
6916 for (
uint i = 0; i < 4; ++i) {
6929 Vec3_int_* pPos,
signed int a4) {
6933 signed int recvdMagicDmg;
6935 int healthBeforeRecvdDamage;
6936 unsigned int uActorID;
6938 uActorID = PID_ID(uObjID);
6939 int pidtype = PID_TYPE(uObjID);
6947 actorPtr = &
pActors[uActorID];
6948 healthBeforeRecvdDamage = playerPtr->
sHealth;
6949 if (PID_TYPE(uObjID) != 3 || !actorPtr->
ActorHitOrMiss(playerPtr))
6962 if (!equippedArmor || equippedArmor->
IsBroken() ||
6965 int randVal = rand() % 4;
6980 Error(
"Unexpected sound value");
6983 int randVal = rand() % 4;
6998 Error(
"Unexpected sound value");
7006 dmgToReceive /= spellPower;
7010 switch (dmgSource) {
7038 int actorState = actorPtr->
uAIState;
7039 if (actorState !=
Dying && actorState !=
Dead) {
7043 if (reflectedDamage >= 0) {
7053 !
engine->config->NoBloodsplats()) {
7061 (
float)splatRadius, 0, 0);
7072 if (rand() % 100 < 20)
7080 if (!
engine->config->NoDamage() &&
7096 if (yellThreshold < playerPtr->sHealth &&
7097 yellThreshold >= healthBeforeRecvdDamage &&
7107 if (uActorType == 2) {
7112 int activePlayerCounter = 0;
7113 for (
int i = 1; i <= 4; i++) {
7115 v72[activePlayerCounter] = i;
7116 activePlayerCounter++;
7119 if (activePlayerCounter) {
7122 ->
pPlayers[v72[rand() % activePlayerCounter] -
7146 }
else if (uActorType == 3) {
7151 unsigned __int16 spriteType = v37->
uType;
7153 if (v37->
uType == 545) {
7163 }
else if (spriteType == 555 || spriteType == 510 ||
7164 spriteType == 500 || spriteType == 515 ||
7165 spriteType == 505 || spriteType == 530 ||
7166 spriteType == 525 || spriteType == 520 ||
7167 spriteType == 535 || spriteType == 540) {
7199 if (spellPower > 0) dmgToReceive /= spellPower;
7202 switch (dmgSource) {
7230 unsigned __int16 actorState = actorPtr->
uAIState;
7231 if (actorState !=
Dying && actorState !=
Dead) {
7235 if (recvdMagicDmg >= 0) {
7242 !
engine->config->NoBloodsplats()) {
7250 (
float)splatRadius, 0, 0);
7261 if (rand() % 100 < 20)
7273 !
engine->config->NoDamage() &&
7295 unsigned int pickedItemId;
7296 unsigned int invItemIndex;
7297 unsigned int itemPos;
7307 int inventoryYCoord = (pY - 17) / 32;
7308 int inventoryXCoord = (pX - 14) / 32;
7314 unsigned int enchantedItemPos =
7317 if (enchantedItemPos) {
7328 pSpellInfo->
uFlags &= 0x7F;
7331 pSpellInfo->
field_6 = (-1 - enchantedItemPos);
7352 if (!pickedItemId) {
7353 if (!invItemIndex) {
7357 &this->pInventoryItemList[invItemIndex - 1],
7369 memcpy(&tmpItem, invItemPtr,
sizeof(tmpItem));
7380 memcpy(invItemPtr, &tmpItem,
sizeof(
ItemGen));
7389 itemPos = this->
AddItem(invMatrixIndex, pickedItemId);
7594 Error(
"Unexpected player pointer");
7616 int effectiveActorArmor = armorBuff + naturalArmor;
7624 int attPositiveMod =
7625 skillmod + rand() % (effectiveActorArmor + 2 * attBonus +
7630 if (distancemod == 2) {
7632 ((effectiveActorArmor + 15) / 2) + effectiveActorArmor + 15;
7633 }
else if (distancemod == 3) {
7634 attNegativeMod = 2 * effectiveActorArmor + 30;
7636 attNegativeMod = effectiveActorArmor + 15;
7639 return (attPositiveMod > attNegativeMod);
7652 if (!player->
CanAct())
return;
7665 int wand_item_id = 0;
7668 int laser_weapon_item_id = 0;
7671 if (main_hand_idx) {
7685 laser_weapon_item_id = item->
uItemID;
7696 int target_type = PID_TYPE(target_pid), target_id = PID_ID(target_pid);
7699 target_type = PID_TYPE(target_pid);
7700 target_id = PID_ID(target_pid);
7704 if (target_id < 500) {
7708 int actor_distance = 0;
7714 integer_sqrt(distance_x * distance_x + distance_y * distance_y +
7715 distance_z * distance_z) -
7717 if (actor_distance < 0) actor_distance = 0;
7720 bool shooting_bow =
false, shotting_laser =
false, shooting_wand =
false,
7721 melee_attack =
false;
7722 if (laser_weapon_item_id) {
7723 shotting_laser =
true;
7727 }
else if (wand_item_id) {
7728 shooting_wand =
true;
7739 }
else if (target_type ==
OBJECT_Actor && actor_distance <= 407.2) {
7740 melee_attack =
true;
7746 Vec3_int_::Normalize(&a3.x, &a3.y, &a3.z);
7756 }
else if (bow_idx) {
7757 shooting_bow =
true;
7761 melee_attack =
true;
7770 if (recovery < 30) recovery = 30;
7776 if (shooting_wand) {
7778 }
else if (shooting_bow) {
7781 }
else if (shotting_laser) {
7821 __int16 a5,
signed int actchar) {
7842 if (actchar >= 1 || actchar <= 4)
7847 int id = a1a.
Create(0, 0, 0, 0);
7858 switch (skill_value & 0x1C0) {
7876 int speechCount = 0;
7877 int expressionCount = 0;
7881 int speechVariantArray[5];
7882 int expressionVariantArray[5];
7883 unsigned int expressionDuration = 0;
7885 unsigned int pickedSoundID = 0;
7886 if (
engine->config->voice_level > 0) {
7887 for (
int i = 0; i < 2; i++) {
7894 pickedVariant = speechVariantArray[rand() % speechCount];
7896 if (numberOfSubvariants > 0) {
7897 pickedSoundID = rand() % numberOfSubvariants +
7898 2 * (pickedVariant + 50 *
uVoiceID) + 4998;
7906 for (
int i = 0; i < 5; i++) {
7908 expressionVariantArray[expressionCount] =
7913 if (expressionCount) {
7915 expressionVariantArray[rand() % expressionCount];
7917 pSoundID = pickedSoundID;
7918 if (pSoundID >= 0) {
7941 if (currexpr >= 2 && currexpr <= 11 && currexpr != 8 &&
7977 (
unsigned __int8*)this->_achieved_awards_bits, 67));
7980 (
unsigned __int8*)this->_achieved_awards_bits, 77));
7983 (
unsigned __int8*)this->_achieved_awards_bits, 79));
7986 Error(
"Should not be able to get here (%u)", uClass);
7995 ItemGen* pItem,
int building_type,
int BuildID_2Events,
7998 unsigned int idemId;
7999 signed int equipType;
8010 switch (building_type) {
8017 if (equipType < EQUIP_ARMOUR || equipType >
EQUIP_BOOTS)
return 4;
8034 Error(
"(%u)", building_type);
8040 switch (ShopMenuType) {
8058 Error(
"(%u)", ShopMenuType);
8061 if (merchantLevel) {
8062 if (price == itemValue) {
8079 for (
uint i = 0; i < 24; ++i) {
8178 struct delete_beacon :
public std::unary_function<const LloydBeacon&, bool> {
8179 bool operator()(
const LloydBeacon &beacon)
const {
8188 if (file_index < 0) {