annotate Engine/Conditions.cpp @ 2575:a76d408c5132 tip

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