2499
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5 #define _CRT_SECURE_NO_WARNINGS
|
|
6 #pragma once
|
|
7 #include "Conditions.h"
|
|
8 #include "Party.h"
|
|
9 std::array<ConditionProcessor, 18> conditionArray =
|
|
10 {
|
|
11 // hint: condname, protfrommagic, gmprot, enchantment, ...
|
|
12 ConditionProcessor(Condition_Cursed, false, false, 0),
|
|
13 ConditionProcessor(Condition_Weak, true, false, 0),
|
|
14 ConditionProcessor(Condition_Sleep, false, false, 22, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR),
|
|
15 ConditionProcessor(Condition_Fear, false, false, 0),
|
|
16 ConditionProcessor(Condition_Drunk, false, false, 0),
|
|
17 ConditionProcessor(Condition_Insane, false, false, 19, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK),
|
|
18 ConditionProcessor(Condition_Poison_Weak, true, false, 21, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK),
|
|
19 ConditionProcessor(Condition_Disease_Weak, true, false, 18, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK),
|
|
20 ConditionProcessor(Condition_Poison_Medium, true, false, 21, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK),
|
|
21 ConditionProcessor(Condition_Disease_Medium, true, false, 18, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK),
|
|
22 ConditionProcessor(Condition_Poison_Severe, true, false, 21, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK),
|
|
23 ConditionProcessor(Condition_Disease_Severe, true, false, 18, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK),
|
|
24 ConditionProcessor(Condition_Paralyzed, false, false, 20, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK, ITEM_ARTIFACT_GHOULSBANE, EQIUP_ANY),
|
|
25 ConditionProcessor(Condition_Unconcious,false, false, 0),
|
|
26 ConditionProcessor(Condition_Dead, true, true, 0),
|
|
27 ConditionProcessor(Condition_Pertified, true, false, 23, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK, ITEM_RELIC_KELEBRIM, EQIUP_ANY),
|
|
28 ConditionProcessor(Condition_Eradicated, true, true, 0),
|
|
29 ConditionProcessor(Condition_Zombie, false, false, 0)
|
|
30 };
|
|
31
|
|
32 bool ConditionProcessor::IsPlayerAffected( Player* inPlayer, int condToCheck, int blockable)
|
|
33 {
|
|
34 if ( !blockable )
|
|
35 return true;
|
|
36 ConditionProcessor* thisProc = &conditionArray[condToCheck];
|
|
37 if (thisProc->m_IsBlockedByProtFromMagic && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0)
|
|
38 {
|
|
39 if (!(thisProc->m_DoesNeedGmProtFromMagic && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uSkill < 4))
|
|
40 {
|
|
41 --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower;
|
|
42 if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1 )
|
|
43 pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset();
|
|
44 return false;
|
|
45 }
|
|
46 }
|
|
47 if (thisProc->m_WorkingEnchantment != 0)
|
|
48 {
|
|
49 if (inPlayer->HasEnchantedItemEquipped(thisProc->m_WorkingEnchantment))
|
|
50 return false;
|
|
51 }
|
|
52 for (unsigned int i = 0; i < thisProc->m_equipmentPairs.size() / 2; i++)
|
|
53 {
|
|
54 if (thisProc->m_equipmentPairs[i * 2].m_ItemId == (ITEM_TYPE)0)
|
|
55 return true;
|
|
56 ITEM_TYPE itemId = thisProc->m_equipmentPairs[i * 2].m_ItemId;
|
|
57 ITEM_EQUIP_TYPE slot = thisProc->m_equipmentPairs[i * 2 + 1].m_EquipSlot;
|
|
58 if (slot == EQIUP_ANY)
|
|
59 {
|
|
60 if (inPlayer->WearsItemAnyWhere(itemId))
|
|
61 return false;
|
|
62 }
|
|
63 else
|
|
64 {
|
|
65 if (inPlayer->WearsItem(itemId, slot))
|
|
66 return false;
|
|
67 }
|
|
68 }
|
|
69 return true;
|
|
70 }
|