Add infos into target window
[ryzomcore.git] / ryzom / server / src / sabrina / sabrina_actor_creature.cpp
blobe06fef70db1c38ca71bb35af174a342df42e2301
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
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.
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 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 //#include "stdpch.h"
20 // nel
21 #include "nel/misc/debug.h"
22 // sabrina
23 #include "sabrina_actor_creature.h"
25 using namespace std;
26 using namespace NLMISC;
29 //------------------------------------------------------------------------------------------------------
30 // Constructor & destructor
32 //------------------------------------------------------------------------------------------------------
33 // CSabrinaActorCreature - ctor
34 //------------------------------------------------------------------------------------------------------
35 CSabrinaActorCreature::CSabrinaActorCreature(CEntityBase *parent):
36 ISabrinaActor(parent)
38 #ifdef NL_DEBUG
39 nlassert(parent!=NULL);
40 #endif
42 _CreatureForm = CSheets::getCreaturesForm(parent->getSheetId());
43 if ( _CreatureForm==NULL )
45 nlwarning( "CSabrinaActorCreature::CSabrinaActorCreature(): invalid creature form %s in entity %s",
46 parent->getSheetId().toString().c_str(), parent->getId().toString().c_str() );
47 #ifdef NL_DEBUG
48 nlstop
49 #endif
50 return;
53 _GlobalArmorStats.setQuality( _CreatureForm->Level );
55 for (int i=0;i<DMGTYPE::NBTYPES;++i)
57 _GlobalArmorStats.setProtectionFactor(i,_CreatureForm->Protections[i].Factor);
58 _GlobalArmorStats.setProtectionLimit(i,_CreatureForm->Protections[i].Max);
61 _GlobalArmorStats.setSkill( SKILLS::unknown );
62 _GlobalArmorStats.setArmorType( ARMORTYPE::UNKNOWN ); // TODO: FIXME
64 _DefenseSkillValue= _CreatureForm->Level * 10; // TODO: FIXME
65 _AttackSkillValue= _CreatureForm->Level * 10; // TODO: FIXME
67 _RightHandWeaponStats.setQuality( _CreatureForm->Level ); // TODO: FIXME
68 _RightHandWeaponStats.setDamage( _CreatureForm->CreatureDamagePerHit * 260/(10+10*_CreatureForm->Level) ); // TODO: FIXME
70 _RightHandWeaponStats.setDmgType( DMGTYPE::SLASHING ); // TODO: FIXME
71 _RightHandWeaponStats.setSpeedInTicks( 30 ); // TODO: FIXME
72 _RightHandWeaponStats.setFamily( ITEMFAMILY::MELEE_WEAPON );
73 _RightHandWeaponStats.setSkill( SKILLS::SFM1H ); // TODO: FIXME: WHY SFM1H????
75 // INFOLOG("AttackerAi :_RightHandWeaponStats.Quality = %u, _RightHandWeaponStats.Damage = %u",
76 // _RightHandWeaponStats.getQuality(), _RightHandWeaponStats.getDamage() );
79 CSabrinaActorCreature::CSabrinaActorCreature(const CSabrinaActorCreature& other):
80 ISabrinaActor(_Parent)
82 _CreatureForm = other._CreatureForm;
83 _AttackSkillValue = other._AttackSkillValue;
84 _DefenseSkillValue = other._DefenseSkillValue;
85 _DodgeSkillValue = other._DodgeSkillValue;
86 _GlobalArmorStats = other._GlobalArmorStats;
87 _RightHandWeaponStats = other._RightHandWeaponStats;
88 _LeftHandWeaponStats = other._LeftHandWeaponStats;
91 //------------------------------------------------------------------------------------------------------
92 // ~CSabrinaActorCreature - dtor
93 //------------------------------------------------------------------------------------------------------
94 CSabrinaActorCreature::~CSabrinaActorCreature()
98 //------------------------------------------------------------------------------------------------------
99 // Management of the actor's own actions
101 //------------------------------------------------------------------------------------------------------
102 // cancelSabrinaAction - dtor
103 //------------------------------------------------------------------------------------------------------
104 void CSabrinaActorCreature::beginSabrinaAction(const ISabrinaPhraseModel* phrase)
106 // TODO
107 // _CurrentActionPhrase->beginPhrase(phrase);
110 //------------------------------------------------------------------------------------------------------
111 // cancelSabrinaAction - dtor
112 //------------------------------------------------------------------------------------------------------
113 void CSabrinaActorCreature::cancelSabrinaAction(SABRINA::TEventCode reason)
115 // TODO
116 // _CurrentActionPhrase->abortPhrase(reason);
120 //------------------------------------------------------------------------------------------------------
121 // Virtual application of results of a Sabrina Action to a target
123 //------------------------------------------------------------------------------------------------------
124 // cbSabrinaActionApplyBegin
125 //------------------------------------------------------------------------------------------------------
126 void CSabrinaActorCreature::cbSabrinaActionApplyBegin()
128 // callback at start of application of a set of effects from a sabrina action
129 // eg: setup an event report record here
132 //------------------------------------------------------------------------------------------------------
133 // applyHeal
134 //------------------------------------------------------------------------------------------------------
135 void CSabrinaActorCreature::applyHeal(SABRINA::THealType healType,uint32 value)
137 // apply damage (to hp, sap or sta)
140 //------------------------------------------------------------------------------------------------------
141 // applyDamage
142 //------------------------------------------------------------------------------------------------------
143 void CSabrinaActorCreature::applyDamage(SABRINA::TDmgType damageType, uint32 value)
145 // apply damage (to hp, sap or sta)
148 //------------------------------------------------------------------------------------------------------
149 // applyBeginSecondaryEffect
150 //------------------------------------------------------------------------------------------------------
151 void CSabrinaActorCreature::applyBeginSecondaryEffect(SABRINA::TEffectType effectType, uint32 strength)
153 // apply secondary effects (eg Stun, debuff, etc)
156 //------------------------------------------------------------------------------------------------------
157 // applyEndSecondaryEffect
158 //------------------------------------------------------------------------------------------------------
159 void CSabrinaActorCreature::applyEndSecondaryEffect(SABRINA::TEffectType effectType)
161 // apply secondary effects (eg Stun, etc)
164 //------------------------------------------------------------------------------------------------------
165 // cbSabrinaActionApplyEnd
166 //------------------------------------------------------------------------------------------------------
167 void CSabrinaActorCreature::cbSabrinaActionApplyEnd()
169 // callback at end of application of a set of effects from a sabrina action
170 // eg: dispatch the en=vent report record now that complete set of event elements have been dealt with
174 //------------------------------------------------------------------------------------------------------
175 // Virtual Read Accessor Interface
177 //------------------------------------------------------------------------------------------------------
178 // getSkillValue
179 //------------------------------------------------------------------------------------------------------
180 sint32 CSabrinaActorCreature::getSkillValue(SKILLS::ESkills skill) const
182 // lookup the value of a given skill
183 nlwarning("Attempt to access specific skill '%s' for a creature - returning attack skill",SKILLS::toString(skill).c_str());
184 return _AttackSkillValue;
187 //------------------------------------------------------------------------------------------------------
188 // getAttackSkillValue
189 //------------------------------------------------------------------------------------------------------
190 sint32 CSabrinaActorCreature::getAttackSkillValue() const
192 // get a value for the attack skill
193 return _AttackSkillValue;
196 //------------------------------------------------------------------------------------------------------
197 // getDefenseSkillValue
198 //------------------------------------------------------------------------------------------------------
199 sint32 CSabrinaActorCreature::getDefenseSkillValue() const
201 // get a value for the defense skill
202 return _DefenseSkillValue;
205 //------------------------------------------------------------------------------------------------------
206 // getDodgeSkillValue
207 //------------------------------------------------------------------------------------------------------
208 sint32 CSabrinaActorCreature::getDodgeSkillValue() const
210 // get a value for the didge skill
211 return _DodgeSkillValue;
214 //------------------------------------------------------------------------------------------------------
215 // getRightHandWeaponStats
216 //------------------------------------------------------------------------------------------------------
217 bool CSabrinaActorCreature::getRightHandWeaponStats(CWeaponStats& stats) const
219 // get the combat stats for the item in right hand
220 // note that in the case of bear hand combat a set of bear hand stats are filled in here
221 // returns false if an item that is not usable for combat is present in right hand
222 stats=_RightHandWeaponStats;
223 return true;
226 //------------------------------------------------------------------------------------------------------
227 // getLeftHandWeaponStats
228 //------------------------------------------------------------------------------------------------------
229 bool CSabrinaActorCreature::getLeftHandWeaponStats(CWeaponStats& stats) const
231 // get the combat stats for the item in left hand
232 // returns false if the left hand is empty or the item in left hand is not a weapon or the player
233 // doesn't have a skill permitting use of the given weapon in the left hand
234 stats=_LeftHandWeaponStats;
235 return true;
238 //------------------------------------------------------------------------------------------------------
239 // getAmmoStats
240 //------------------------------------------------------------------------------------------------------
241 bool CSabrinaActorCreature::getAmmoStats(CWeaponStats& stats) const
243 // get stats for ammo in left hand
244 // returns false if no ammo available or ammo is incompatible with weapon
245 stats=_LeftHandWeaponStats;
246 return true;
249 //------------------------------------------------------------------------------------------------------
250 // getArmorProtectionStats
251 //------------------------------------------------------------------------------------------------------
252 bool CSabrinaActorCreature::getArmorProtectionStats(SLOT_EQUIPMENT::TSlotEquipment slot,CArmorStats& protection) const
254 // get stats for a given piece of armor
255 // in the case where no armor is found the stats are initialised accordingly
256 // returns false if no armor is present on given location
257 protection=_GlobalArmorStats;
258 return true;
261 //------------------------------------------------------------------------------------------------------
262 // getLeftHandProtectionStats
263 //------------------------------------------------------------------------------------------------------
264 bool CSabrinaActorCreature::getLeftHandProtectionStats(CShieldStats& protection) const
266 // get stats for the shield (or likewise)
267 // in the case where no shield is found the stats are initalised accordingly
268 // returns false if the left hand is empty or the left hand item offers no protection
269 protection=CShieldStats();
270 return false;
273 //------------------------------------------------------------------------------------------------------
274 // getTarget
275 //------------------------------------------------------------------------------------------------------
276 ISabrinaActor* CSabrinaActorCreature::getTarget() const
278 // get a pointer to the entity refferenced by this entity
279 return NULL;
283 //------------------------------------------------------------------------------------------------------
284 // Logical test routines
286 //------------------------------------------------------------------------------------------------------
287 // isValidOffensiveTarget
288 //------------------------------------------------------------------------------------------------------
289 bool CSabrinaActorCreature::isValidOffensiveTarget(ISabrinaActor* target) const
291 // make sure that I'm allowed to perform offensive actions against the given target
292 // take into account whether target is in PvP action with me, etc, etc
293 return true;
296 //------------------------------------------------------------------------------------------------------
297 // isValidCurativeTarget
298 //------------------------------------------------------------------------------------------------------
299 bool CSabrinaActorCreature::isValidCurativeTarget(ISabrinaActor* target) const
301 // make sure I'm allowed to perform curative actions on target
302 // take into account PvP rules with neutrals not allowed to assist, etc...
303 return true;
307 //------------------------------------------------------------------------------------------------------
308 // Virtual callbacks for message sending on activation/ cancelation of Sabrina actions
310 //------------------------------------------------------------------------------------------------------
311 // cbSabrinaActionBegin
312 //------------------------------------------------------------------------------------------------------
313 void CSabrinaActorCreature::cbSabrinaActionBegin(const CSabrinaPhraseInstance* completedPhrase)
315 // this routine must lock the items that are used in the phrase...
318 //------------------------------------------------------------------------------------------------------
319 // cbSabrinaActionSuccess
320 //------------------------------------------------------------------------------------------------------
321 void CSabrinaActorCreature::cbSabrinaActionSuccess(const CSabrinaPhraseInstance* completedPhrase, SABRINA::TEventCode code)
323 // this routine is responsible for beginning a new sabrina action if a new action is lined up
324 // this routine should deal with ammo & raw material consumption if need be...
327 //------------------------------------------------------------------------------------------------------
328 // cbSabrinaActionFailure
329 //------------------------------------------------------------------------------------------------------
330 void CSabrinaActorCreature::cbSabrinaActionFailure(const CSabrinaPhraseInstance* completedPhrase, SABRINA::TEventCode code)
332 // this routine is called either by 'cbSabrinaActionBegin()' or when the result of the action is to be applied
333 // this routine is also responsible for beginning a new sabrina action if a new action is lined up
336 //------------------------------------------------------------------------------------------------------
337 // cbSabrinaActionCancel
338 //------------------------------------------------------------------------------------------------------
339 void CSabrinaActorCreature::cbSabrinaActionCancel(const CSabrinaPhraseInstance* completedPhrase, SABRINA::TEventCode code)
341 // this routine is called by cancelSabrinaAction()
342 // this routine is also responsible for beginning a new sabrina action if a new action is lined up
345 //------------------------------------------------------------------------------------------------------
346 // cbSabrinaActionCancel
347 //------------------------------------------------------------------------------------------------------
348 void CSabrinaActorCreature::cbSabrinaActionEnd(const CSabrinaPhraseInstance* completedPhrase)
350 // this callback is called after the postActionTime has elapsed and the action is completely finished