World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Conditions.cpp
См. документацию.
1 #include "Engine/Conditions.h"
2 
3 #include <cstdlib>
4 
5 #include "Party.h"
6 
7 std::array<ConditionProcessor, 18> conditionArray = {{
8  // hint: condname, protfrommagic, gmprot, enchantment, ...
9  ConditionProcessor(Condition_Cursed, false, false, 0),
10  ConditionProcessor(Condition_Weak, true, false, 0),
12  EQUIP_ARMOUR),
13  ConditionProcessor(Condition_Fear, false, false, 0),
14  ConditionProcessor(Condition_Drunk, false, false, 0),
17  EQUIP_CLOAK),
36  ConditionProcessor(Condition_Paralyzed, false, false, 20,
40  ConditionProcessor(Condition_Unconcious, false, false, 0),
41  ConditionProcessor(Condition_Dead, true, true, 0),
42  ConditionProcessor(Condition_Pertified, true, false, 23,
47  ConditionProcessor(Condition_Zombie, false, false, 0)
48 }};
49 
50 bool ConditionProcessor::IsPlayerAffected(Player* inPlayer, int condToCheck,
51  int blockable) {
52  if (!blockable) return true;
53  ConditionProcessor* thisProc = &conditionArray[condToCheck];
54  if (thisProc->m_IsBlockedByProtFromMagic &&
56  if (!(thisProc->m_DoesNeedGmProtFromMagic &&
58  4)) {
61  1)
63  return false;
64  }
65  }
66  if (thisProc->m_WorkingEnchantment != 0) {
67  if (inPlayer->HasEnchantedItemEquipped(thisProc->m_WorkingEnchantment))
68  return false;
69  }
70  for (unsigned int i = 0; i < thisProc->m_equipmentPairs.size() / 2; i++) {
71  if (thisProc->m_equipmentPairs[i * 2].m_ItemId == (ITEM_TYPE)0)
72  return true;
73  ITEM_TYPE itemId = thisProc->m_equipmentPairs[i * 2].m_ItemId;
74  ITEM_EQUIP_TYPE slot =
75  thisProc->m_equipmentPairs[i * 2 + 1].m_EquipSlot;
76  if (slot == EQIUP_ANY) {
77  if (inPlayer->WearsItemAnyWhere(itemId)) return false;
78  } else {
79  if (inPlayer->WearsItem(itemId, slot)) return false;
80  }
81  }
82  return true;
83 }
ConditionProcessor::m_IsBlockedByProtFromMagic
bool m_IsBlockedByProtFromMagic
Definition: Conditions.h:47
Player
Definition: Player.h:401
Condition_Poison_Medium
@ Condition_Poison_Medium
Definition: Conditions.h:16
ConditionProcessor::m_equipmentPairs
std::array< EquipemntPair, 3 > m_equipmentPairs
Definition: Conditions.h:50
EQUIP_CLOAK
@ EQUIP_CLOAK
Definition: Items.h:234
ITEM_TYPE
ITEM_TYPE
Definition: Items.h:73
PARTY_BUFF_PROTECTION_FROM_MAGIC
@ PARTY_BUFF_PROTECTION_FROM_MAGIC
Definition: Party.h:84
ITEM_ARTIFACT_YORUBA
@ ITEM_ARTIFACT_YORUBA
Definition: Items.h:158
EQIUP_ANY
@ EQIUP_ANY
Definition: Items.h:244
conditionArray
std::array< ConditionProcessor, 18 > conditionArray
Definition: Conditions.cpp:7
ITEM_EQUIP_TYPE
ITEM_EQUIP_TYPE
Definition: Items.h:226
Condition_Paralyzed
@ Condition_Paralyzed
Definition: Conditions.h:20
ConditionProcessor::IsPlayerAffected
static bool IsPlayerAffected(Player *, int, int)
Definition: Conditions.cpp:50
ConditionProcessor::m_DoesNeedGmProtFromMagic
bool m_DoesNeedGmProtFromMagic
Definition: Conditions.h:48
Condition_Insane
@ Condition_Insane
Definition: Conditions.h:13
ITEM_ARTIFACT_GHOULSBANE
@ ITEM_ARTIFACT_GHOULSBANE
Definition: Items.h:160
Party::pPartyBuffs
std::array< SpellBuff, 20 > pPartyBuffs
Definition: Party.h:309
Player::WearsItemAnyWhere
bool WearsItemAnyWhere(int item_id)
Definition: Player.cpp:1609
Condition_Fear
@ Condition_Fear
Definition: Conditions.h:11
pParty
Party * pParty
Definition: Party.cpp:30
EQUIP_ARMOUR
@ EQUIP_ARMOUR
Definition: Items.h:230
Condition_Dead
@ Condition_Dead
Definition: Conditions.h:22
Condition_Disease_Weak
@ Condition_Disease_Weak
Definition: Conditions.h:15
Player::WearsItem
bool WearsItem(int item_id, ITEM_EQUIP_TYPE equip_type)
Definition: Player.cpp:1603
Condition_Zombie
@ Condition_Zombie
Definition: Conditions.h:25
Party.h
ConditionProcessor::m_WorkingEnchantment
int m_WorkingEnchantment
Definition: Conditions.h:49
Conditions.h
ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP
@ ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP
Definition: Items.h:183
ITEM_RELIC_KELEBRIM
@ ITEM_RELIC_KELEBRIM
Definition: Items.h:173
Condition_Poison_Severe
@ Condition_Poison_Severe
Definition: Conditions.h:18
Condition_Cursed
@ Condition_Cursed
Definition: Conditions.h:8
ConditionProcessor
Definition: Conditions.h:45
Condition_Weak
@ Condition_Weak
Definition: Conditions.h:9
Player::HasEnchantedItemEquipped
bool HasEnchantedItemEquipped(int uEnchantment)
Definition: Player.cpp:1592
Condition_Poison_Weak
@ Condition_Poison_Weak
Definition: Conditions.h:14
Condition_Unconcious
@ Condition_Unconcious
Definition: Conditions.h:21
Condition_Disease_Severe
@ Condition_Disease_Severe
Definition: Conditions.h:19
Condition_Eradicated
@ Condition_Eradicated
Definition: Conditions.h:24
Condition_Pertified
@ Condition_Pertified
Definition: Conditions.h:23
Condition_Drunk
@ Condition_Drunk
Definition: Conditions.h:12
Condition_Disease_Medium
@ Condition_Disease_Medium
Definition: Conditions.h:17
Condition_Sleep
@ Condition_Sleep
Definition: Conditions.h:10