1 /* GemRB - Infinity Engine Emulator
2  * Copyright (C) 2012 The GemRB Project
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  *
19  */
20 
21 // convenience classes for storing the complex armor class, to-hit and other combat state
22 
23 #ifndef COMBATINFO_H
24 #define COMBATINFO_H
25 
26 #include "exports.h"
27 
28 namespace GemRB {
29 
30 class Actor;
31 
32 class GEM_EXPORT ArmorClass {
33 public:
34 	ArmorClass();
35 
36 	int GetTotal() const;
GetNatural()37 	int GetNatural() const { return natural; };
GetDeflectionBonus()38 	int GetDeflectionBonus() const { return deflectionBonus; };
GetArmorBonus()39 	int GetArmorBonus() const { return armorBonus; };
GetShieldBonus()40 	int GetShieldBonus() const { return shieldBonus; };
GetDexterityBonus()41 	int GetDexterityBonus() const { return dexterityBonus; };
GetWisdomBonus()42 	int GetWisdomBonus() const { return wisdomBonus; };
GetGenericBonus()43 	int GetGenericBonus() const { return genericBonus; };
44 
45 	void ResetAll();
46 	void SetOwner(Actor *owner);
47 	// no total, it is always kept up to date with RefreshTotal
48 	void SetNatural(int AC, int mod=1);
49 	void SetDeflectionBonus(int bonus, int mod=1);
50 	void SetArmorBonus(int bonus, int mod=1);
51 	void SetShieldBonus(int bonus, int mod=1);
52 	void SetDexterityBonus(int bonus, int mod=1);
53 	void SetWisdomBonus(int bonus, int mod=1);
54 	void SetGenericBonus(int bonus, int mod=1);
55 
56 	void HandleFxBonus(int mod, bool permanent);
57 	void dump() const;
58 
59 private:
60 	Actor *Owner;
61 	int total; // modified stat
62 	int natural; // base stat
63 
64 	int deflectionBonus;
65 	int armorBonus;
66 	int shieldBonus;
67 	int dexterityBonus;
68 	int wisdomBonus;
69 	int genericBonus; // the iwd2 dodge bonus was also just applied here and is not a separate value
70 	// NOTE: some are currently left out, like BonusAgainstCreature and all the real separate AC-mod stats
71 	//   (in case of change) recheck all the introduced GetTotal()s with this in mind - before they were Modified[IE_ARMORCLASS] only
72 
73 	void SetBonus(int &current, int bonus, int mod);
74 	void RefreshTotal();
75 };
76 
77 
78 class GEM_EXPORT ToHitStats {
79 public:
80 	ToHitStats();
81 
82 	int GetTotal() const;
GetBase()83 	int GetBase() const { return base; };
GetWeaponBonus()84 	int GetWeaponBonus() const { return weaponBonus; };
GetArmorBonus()85 	int GetArmorBonus() const { return armorBonus; };
GetShieldBonus()86 	int GetShieldBonus() const { return shieldBonus; };
GetAbilityBonus()87 	int GetAbilityBonus() const { return abilityBonus; };
GetProficiencyBonus()88 	int GetProficiencyBonus() const { return proficiencyBonus; };
GetGenericBonus()89 	int GetGenericBonus() const { return genericBonus; };
GetFxBonus()90 	int GetFxBonus() const { return fxBonus; };
91 
92 	// returns the value of the cascade for the specified attack
93 	// eg. one of +11/+6/+1 for 1,2,3
94 	int GetTotalForAttackNum(unsigned int number) const;
95 
96 	void ResetAll();
97 	void SetOwner(Actor *owner);
98 	// no total, it is always kept up to date with RefreshTotal
99 	void SetBase(int tohit, int mod=1);
100 	void SetProficiencyBonus(int bonus, int mod=1);
101 	void SetArmorBonus(int bonus, int mod=1);
102 	void SetShieldBonus(int bonus, int mod=1);
103 	void SetAbilityBonus(int bonus, int mod=1);
104 	void SetWeaponBonus(int bonus, int mod=1);
105 	void SetGenericBonus(int bonus, int mod=1);
106 	void SetFxBonus(int bonus, int mod=1);
107 
108 	void SetBABDecrement(int decrement);
109 	void HandleFxBonus(int mod, bool permanent);
110 	void dump() const;
111 
112 private:
113 	Actor *Owner;
114 	int total; // modified stat, now really containing all the boni
115 	int base; // base stat
116 	int babDecrement; // 3ed, used for calculating the tohit value of succeeding attacks
117 
118 	// to-hit boni
119 	int weaponBonus;
120 	int armorBonus; // this is a malus
121 	int shieldBonus; // this is a malus
122 	int abilityBonus;
123 	int proficiencyBonus;
124 	int genericBonus; // "other"
125 	int fxBonus; // split off from the generic bonus for hacky reasons
126 
127 	void SetBonus(int &current, int bonus, int mod);
128 	void RefreshTotal();
129 };
130 
131 
132 }
133 
134 #endif
135