1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
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 Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef RY_COMBAT_DEFENDER_H
20 #define RY_COMBAT_DEFENDER_H
23 #include "nel/misc/types_nl.h"
25 #include "game_share/skills.h"
26 #include "game_share/damage_types.h"
27 #include "game_share/armor_types.h"
28 #include "game_share/game_item_manager/game_item.h"
31 #include "entity_base.h"
32 #include "character.h"
33 #include "player_manager.h"
34 #include "entity_manager.h"
36 extern CPlayerManager PlayerManager
;
43 MaxBluntProtection
= 0;
44 MaxPiercingProtection
= 0;
45 MaxSlashingProtection
= 0;
46 BluntProtectionFactor
= 0.0f
;
47 PiercingProtectionFactor
= 0.0f
;
48 SlashingProtectionFactor
= 0.0f
;
51 RotProtectionFactor
= 0.0f
;
52 MaxAcidProtection
= 0;
53 AcidProtectionFactor
= 0.0f
;
54 MaxColdProtection
= 0;
55 ColdProtectionFactor
= 0.0f
;
56 MaxFireProtection
= 0;
57 FireProtectionFactor
= 0.0f
;
58 MaxPoisonProtection
= 0;
59 PoisonProtectionFactor
= 0.0f
;
60 MaxElectricityProtection
= 0;
61 ElectricityProtectionFactor
= 0.0f
;
62 MaxShockProtection
= 0;
63 ShockProtectionFactor
= 0.0f
;
65 Skill
= SKILLS::unknown
;
67 ArmorType
= ARMORTYPE::UNKNOWN
;
70 CCombatArmor( const CStaticItem
*item
, uint16 quality
);
72 std::string
toString() const
74 const std::string temp
= NLMISC::toString("Quality= %u, SkillValue= %u, MaxB =%u,FactorB =%f, MaxP=%u,FactorP=%f, MaxS=%u, FactorS=%f", Quality
, SkillValue
, MaxBluntProtection
, BluntProtectionFactor
, MaxPiercingProtection
, PiercingProtectionFactor
, MaxSlashingProtection
, SlashingProtectionFactor
);
79 uint16 MaxBluntProtection
;
80 uint16 MaxPiercingProtection
;
81 uint16 MaxSlashingProtection
;
82 float BluntProtectionFactor
;
83 float PiercingProtectionFactor
;
84 float SlashingProtectionFactor
;
86 uint16 MaxRotProtection
;
87 float RotProtectionFactor
;
88 uint16 MaxAcidProtection
;
89 float AcidProtectionFactor
;
90 uint16 MaxColdProtection
;
91 float ColdProtectionFactor
;
92 uint16 MaxFireProtection
;
93 float FireProtectionFactor
;
94 uint16 MaxPoisonProtection
;
95 float PoisonProtectionFactor
;
96 uint16 MaxElectricityProtection
;
97 float ElectricityProtectionFactor
;
98 uint16 MaxShockProtection
;
99 float ShockProtectionFactor
;
101 SKILLS::ESkills Skill
;
103 ARMORTYPE::EArmorType ArmorType
;
106 struct CCombatShield
: public CCombatArmor
108 CCombatShield() : CCombatArmor()
110 ShieldType
= SHIELDTYPE::NONE
;
113 SHIELDTYPE::EShieldType ShieldType
;
118 * Base class for combat defenders
119 * \author David Fleury
120 * \author Nevrax France
123 class CCombatDefender
128 CCombatDefender(const TDataSetRow
&rowId
) : _RowId(rowId
)
132 virtual ~CCombatDefender()
135 virtual sint32
getSkillValue( SKILLS::ESkills skill
) const = 0;
137 inline CEntityBase
*getEntity() { return CEntityBaseManager::getEntityBasePtr(_RowId
); }
138 inline const TDataSetRow
&getEntityRowId() const { return _RowId
; }
140 virtual bool getArmor( SLOT_EQUIPMENT::TSlotEquipment slot
, CCombatArmor
&armor
) const = 0;
141 virtual bool getShield(CCombatShield
&shield
) const = 0;
143 virtual void damageOnShield(uint32 dmg
) = 0;
144 virtual void damageOnArmor(SLOT_EQUIPMENT::TSlotEquipment slot
, uint32 dmg
) = 0;
146 virtual sint32
getDefenseValue() = 0;
155 * Base class for combat player defenders
156 * \author David Fleury
157 * \author Nevrax France
160 class CCombatDefenderPlayer
: public CCombatDefender
163 CCombatDefenderPlayer()
166 CCombatDefenderPlayer(const TDataSetRow
&rowId
) : CCombatDefender(rowId
)
169 virtual ~CCombatDefenderPlayer()
172 inline sint32
getSkillValue( SKILLS::ESkills skill
) const
174 CCharacter
*character
= PlayerManager
.getChar(_RowId
);
175 if (!character
|| skill
>= SKILLS::NUM_SKILLS
) return 0;
176 return character
->getSkills()._Skills
[ skill
].Current
;
179 virtual bool getArmor( SLOT_EQUIPMENT::TSlotEquipment slot
, CCombatArmor
&armor
) const ;
181 virtual bool getShield(CCombatShield
&shield
) const;
183 virtual sint32
getDefenseValue()
185 CCharacter
*character
= PlayerManager
.getChar(_RowId
);
191 if (character
->dodgeAsDefense())
193 return character
->getSkills()._Skills
[ SKILLS::SDD
].Current
;
197 // get right weapon skill
198 CGameItemPtr item
= character
->getRightHandItem();
199 if (item
!= NULL
&& item
->getStaticForm() != NULL
&& item
->getStaticForm()->Family
== ITEMFAMILY::MELEE_WEAPON
&& item
->getStaticForm()->Skill
< SKILLS::NUM_SKILLS
)
200 return character
->getSkills()._Skills
[ item
->getStaticForm()->Skill
].Current
;
202 // return character->getSkills()._Skills[ SKILLS::BareHandCombat ].Current; TODO; skill missing
207 virtual void damageOnShield(uint32 dmg
)
209 CCharacter
*character
= PlayerManager
.getChar(_RowId
);
215 CGameItemPtr shieldPtr
= character
->getLeftHandItem();
216 if (shieldPtr
== NULL
|| shieldPtr
->getStaticForm() == NULL
|| shieldPtr
->getStaticForm()->Family
!= ITEMFAMILY::SHIELD
)
219 shieldPtr
->removeHp(dmg
);
222 virtual void damageOnArmor(SLOT_EQUIPMENT::TSlotEquipment slot
, uint32 dmg
)
224 CCharacter
*character
= PlayerManager
.getChar(_RowId
);
230 CGameItemPtr armorPtr
= character
->getItem(INVENTORIES::equipment
, slot
);
231 if (armorPtr
== NULL
|| armorPtr
->getStaticForm() == NULL
|| armorPtr
->getStaticForm()->Family
!= ITEMFAMILY::ARMOR
)
234 armorPtr
->removeHp(dmg
);
240 * Base class for combat AI defenders
241 * \author David Fleury
242 * \author Nevrax France
245 class CCombatDefenderAI
: public CCombatDefender
248 CCombatDefenderAI() : CreatureForm(0)
251 CCombatDefenderAI(const TDataSetRow
&rowId
);
253 virtual ~CCombatDefenderAI()
256 inline sint32
getSkillValue( SKILLS::ESkills skill
) const { return _DefenseValue
; }
257 inline sint32
getDefenseValue() { return _DefenseValue
; }
259 virtual bool getArmor( SLOT_EQUIPMENT::TSlotEquipment slot
, CCombatArmor
&armor
) const;
261 virtual bool getShield(CCombatShield
&shield
) const;
263 inline void damageOnShield(uint32 dmg
) {}
264 inline void damageOnArmor(SLOT_EQUIPMENT::TSlotEquipment slot
, uint32 dmg
) {}
266 std::pair
<const CStaticItem
*, uint16
> getArmorOnSlot( SLOT_EQUIPMENT::TSlotEquipment slot
);
270 const CStaticCreatures
*CreatureForm
;
272 /// defense value (parry or dodge)
273 sint32 _DefenseValue
;
276 CCombatShield _GlobalArmor
;
280 CCombatShield _Shield;
283 CCombatArmor _HeadArmor;
285 CCombatArmor _LegsArmor;
287 CCombatArmor _ArmsArmor;
289 CCombatArmor _ChestArmor;
291 CCombatArmor _FeetArmor;
293 CCombatArmor _HandsArmor;
297 #endif // RY_COMBAT_DEFENDER_H
299 /* End of combat_defender.h */