Add infos into target window
[ryzomcore.git] / ryzom / client / src / user_entity.h
blob3d16b2e3da2ae19b5c177777282bc8769d970442
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2020 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 //
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef CL_USER_ENTITY_H
24 #define CL_USER_ENTITY_H
27 /////////////
28 // INCLUDE //
29 /////////////
30 // Misc.
31 #include "nel/misc/types_nl.h"
32 #include "nel/misc/vector.h"
33 // 3D Interface.
34 #include "nel/3d/u_visual_collision_entity.h"
35 // Client DB
36 #include "nel/misc/cdb.h"
37 // Client
38 #include "player_cl.h"
39 #include "client_cfg.h"
40 // Std.
41 #include <list>
42 // sp_types
43 #include "game_share/sp_type.h"
44 // r2 types
45 #include "game_share/r2_types.h"
48 ///////////
49 // USING //
50 ///////////
51 using NLMISC::CVector;
52 using NL3D::UVisualCollisionEntity;
53 //using std::list;
56 class CItemImage;
58 ///////////
59 // CLASS //
60 ///////////
61 /**
62 * Class to manage an user entity.
63 * \author Guillaume PUZIN
64 * \author Nevrax France
65 * \date 2001
67 class CUserEntity : public CPlayerCL
69 public:
70 enum TView
72 FirstPV = 0, // First Person View
73 ThirdPV // Third Person View
75 // Move To Actions
76 enum TMoveToAction
78 None = 0,
79 Attack,
80 Quarter,
81 Loot,
82 PickUp,
83 ExtractRM,
84 TradeItem,
85 TradePhrase,
86 TradePact,
87 Mission,
88 DynamicMission,
89 StaticMission,
90 CreateGuild,
91 News,
92 TradeTeleport,
93 TradeFaction,
94 TradeCosmetic,
95 Talk,
96 CombatPhrase,
97 Mount,
98 WebPage,
99 Outpost,
100 BuildTotem,
101 MissionRing,
102 OpenArkUrl,
105 public:
106 NLMISC_DECLARE_CLASS(CUserEntity);
108 /// Constructor
109 CUserEntity();
110 /// Destructor
111 virtual ~CUserEntity();
113 /// Build the entity from a sheet.
114 virtual bool build(const CEntitySheet *sheet);
117 * Apply the motion to the entity.
119 void applyMotion(CEntityCL *target);
122 * Apply ForceLook (computed at prec applyMotion).
124 void applyForceLook();
127 * Update precollision
129 virtual void updatePreCollision(const NLMISC::TTime &time, CEntityCL *target);
132 * Update the position of the entity after the motion.
133 * \param target : pointer on the current target.
135 virtual void updatePosCombatFloatChanged(CEntityCL *target);
137 * Update the position of the entity after the motion.
138 * \param time : Time for the position of the entity after the motion.
139 * \param target : pointer on the current target.
141 virtual void updatePos(const NLMISC::TTime &time, CEntityCL *target);
143 /** Update the PACS position after the evalCollision. The entity position is set too. This is fast.
144 * If the entity position is too far from its PACS position, setGlobalPosition is called.
145 * After this call, the position.z is valid.
147 virtual void pacsFinalizeMove();
150 * Update the sound management to play user steps
152 void updateSound(const NLMISC::TTime &time);
154 virtual void snapToGround();
157 * 'true' if the user is dead too much and have to be disconnected.
159 bool permanentDeath() const {return _PermanentDeath;}
162 /// Method called to change the mode (Combat/Mount/etc.).
163 virtual bool mode(MBEHAV::EMode m);
164 /// Set the mode for the entity
165 virtual MBEHAV::EMode mode() const {return _Mode;}
167 /// Return the mount entity if the user is riding, otherwise NULL
168 CEntityCL* getMountEntity();
170 /// Return the DB entry for the specified user's animal (NULL if not found)
171 NLMISC::CCDBNodeBranch *getBeastDBEntry( CLFECOMMON::TClientDataSetIndex uid );
173 /** To Inform about an entity removed (to remove from selection for example).
174 * This will remove the entity from the target.
175 * \param slot : Slot of the entity that will be removed.
177 virtual void slotRemoved(const CLFECOMMON::TCLEntityId &slot);
179 /** Change the entity selected.
180 * \param slot : slot now selected (CLFECOMMON::INVALID_SLOT for an empty selection).
181 * \warning Can be different from the entity targeted (in combat mode for example).
183 virtual void selection(const CLFECOMMON::TCLEntityId &slot);
184 /** Return the entity selected.
185 * \return CLFECOMMON::TCLEntityId : slot currently selected (CLFECOMMON::INVALID_SLOT for an empty selection).
186 * \warning Can be different from the entity targeted (in combat mode for example).
188 virtual const CLFECOMMON::TCLEntityId &selection() const {return _Selection;}
190 /** Set the trader (see also trader() and interlocutor())
191 * \param slot : trader slot (CLFECOMMON::INVALID_SLOT if no trader).
193 virtual void trader(const CLFECOMMON::TCLEntityId &slot);
194 /** Return the trader entity that will be turned towards the user entity (client-side)
195 * and other stuff such as distance checking (see also interlocutor())
196 * \return CLFECOMMON::TCLEntityId : slot of the trader (CLFECOMMON::INVALID_SLOT if no trader).
198 virtual const CLFECOMMON::TCLEntityId &trader() const {return _Trader;}
200 /** Set the current interlocutor entity that will be turned towards the user entity (client-side).
201 * This one is for dyn-chat, while trader() is for bot-chat.
202 * \param slot : interlocutor slot (CLFECOMMON::INVALID_SLOT if no interlocutor).
204 void interlocutor( const CLFECOMMON::TCLEntityId &slot);
205 /** Return the current interlocutor entity that will be turned towards the user entity (client-side).
206 * This one is for dyn-chat, while trader() is for bot-chat.
207 * \return CLFECOMMON::TCLEntityId : slot of the interlocutor (CLFECOMMON::INVALID_SLOT if no interlocutor).
209 const CLFECOMMON::TCLEntityId &interlocutor() const {return _Interlocutor;}
211 /// Method to place the user to attack the target and attack.
212 void moveToAttack();
213 /// Method to attack the target.
214 void attack();
215 /// Method to disengage the target.
216 void disengage();
217 /// Method to attack the target, with a special phrase
218 void attackWithPhrase();
219 /// your current target become the target of your current one.
220 void assist();
221 /// the entity target in the slot become the target of your current one.
222 void assist(uint slot);
224 /// Ask fot the client to sit/stand ('true' to sit).
225 bool sit(bool s);
226 /// Return true if the user can sit.
227 bool canSit() const;
229 /// Set the user away from keyboard (or not), txt can be customized
230 void setAFK(bool b, std::string afkTxt="");
232 /// Roll a dice and tell the result around
233 void rollDice(sint16 min, sint16 max, bool local);
235 /// return true if user can engage melee combat, else return false and display system msg
236 bool canEngageCombat();
239 /** \name VELOCITY
240 * Method to manage the user velocity.
242 //@{
244 * Set the velocity when the user walks.
245 * \param velocity : new velocity for the user when he walks.
247 inline void walkVelocity(float velocity)
249 _WalkVelocity = velocity;
250 if(!_Run)
251 _CurrentVelocity = _WalkVelocity;
254 * Get the velocity when the user walks.
255 * \return float : User velocity when he walks.
257 inline float walkVelocity() const {return _WalkVelocity;}
259 * Set the velocity when the user runs.
260 * \param velocity : new velocity for the user when he runs.
262 inline void runVelocity(float velocity)
264 _RunVelocity = velocity;
265 if(_Run)
266 _CurrentVelocity = _RunVelocity;
269 * Get the velocity when the user runs.
270 * \return float : User velocity when he runs.
272 inline float runVelocity() const {return _RunVelocity;}
275 * Get the current velocity of the user.
276 * \return float : Current User velocity.
278 inline float currentVelocity() const {return _CurrentVelocity;}
281 * Switch velocity between Run and Walk.
282 * \param userRequest : true if user asked it
284 void switchVelocity(bool userRequest = true);
287 * Test if user is running
289 bool running() const { return _Run; }
290 //@}
292 /// Get the front velocity.
293 inline float frontVelocity() const {return _FrontVelocity;}
294 /// Set the front velocity.
295 inline void frontVelocity(float velocity) {_FrontVelocity = velocity;}
297 /// Get the lateral velocity.
298 inline float lateralVelocity() const {return _LateralVelocity;}
299 /// Set the lateral velocity.
300 inline void lateralVelocity(float velocity) {_LateralVelocity = velocity;}
302 // get the velocity vector of the entity
303 NLMISC::CVector getVelocity() const;
305 inline void setSpeedServerAdjust(float speed) {_SpeedFactor.addFactorValue(speed);}
307 /// Check if the mount is able to run, and force walking mode if not
308 void checkMountAbleToRun();
310 /// Get Eyes Height.
311 float eyesHeight();
312 /// Set Eyes Height.
313 inline void eyesHeight(float h) {_EyesHeight = h;}
315 /// Head Pitch methods
316 void setHeadPitch(double hp);
317 double getHeadPitch() const {return _HeadPitch;}
318 void rotHeadVertically(float ang);
320 /// Get the playersheet
321 inline const CPlayerSheet *sheet() const {return _Sheet;}
324 /// rotate the body on the left or right (front changes).
325 void rotate(float ang);
328 /// TODO: Ben tests for landscape pacs bug
329 const NLPACS::UMovePrimitive *getMovePrimitive() const { return _Primitive; }
331 /// Remove the primitive
332 virtual void removePrimitive();
333 /// Create a primitive for the entity.
334 virtual void computePrimitive();
336 /// Remove the check primitive
337 void removeCheckPrimitive();
339 /// Is the user selectable (first or third person view for example).
340 bool selectable() const {return _Selectable;}
341 /// Set is the user is selectable or not.
342 void selectable(bool s) {_Selectable = s;}
344 /// Return if the user is already busy (combat/bo chat/loot/ etc.).
345 bool isBusy() const;
347 /// Return 'true' if the user is on a mount.
348 bool isOnMount() const {return _OnMount;}
350 /** \name DEBUG
351 * Methods only here for the debug.
353 //@{
354 /// Display Debug Information.
355 virtual void displayDebug(float x, float &y, float lineStep);
356 //@}
358 void updateVisualDisplay();
360 /// Return 'true' is an attack animation is currently playing.
361 bool isAttacking() const {return _AnimAttackOn;}
363 /// Show the user light.
364 void lightOn();
366 /// Show/Hide the user light.
367 void light();
369 /// Display dmg/heal numbers above the head.
370 virtual void displayModifiers();
372 /** \name VIEW
373 * Methods about the view (First/Third Person View).
375 //@{
376 /// Change the View (First/Third Person View).
377 void viewMode(TView viewMode, bool changeView=true);
378 /// Return the current View Mode.
379 TView viewMode() const {return _ViewMode;}
380 /// Toggle Camera (First/Third Person)
381 void toggleCamera();
382 /// Force Camera First Person View
383 void forceCameraFirstPerson();
384 //@}
386 /// Return the entity scale. (return 1.0 if there is any problem).
387 virtual float getScale() const;
388 /// Return 'true' is the entity is displayed.
389 virtual bool isVisible() const;
391 /// Return true if the user is indoor and the CFG want to force the FPV Indoor.
392 bool forceIndoorFPV();
393 bool moveTo() const {return (_MoveToSlot != CLFECOMMON::INVALID_SLOT);}
394 /// Return true if the User is following an entity.
395 bool follow() const {return _FollowMode;}
396 /// set true to resetCameraRot if you want that camera rotation follow
397 void enableFollow(bool resetCameraRot);
398 void disableFollow();
399 // when the user request to move the head pitch, stop the "follow mode" to force it
400 void stopForceHeadPitchInFollow();
401 /// Method to move to someone else. NB: resetAnyMoveTo() is called first
402 void moveTo(CLFECOMMON::TCLEntityId slot, double dist, TMoveToAction action);
403 /// Method to move to someone else for a mission. NB: resetAnyMoveTo() is called first
404 void moveToMission(CLFECOMMON::TCLEntityId slot, double dist, uint32 id);
405 /// Method to move to someone else for a ring mission. NB: resetAnyMoveTo() is called first
406 void moveToMissionRing(CLFECOMMON::TCLEntityId slot, double dist, uint32 id);
407 /** Method to move to someone else, for foraging extraction
408 * The caller MUST call after CSPhraseManager::clientExecute(), to increment action counter
409 * NB: resetAnyMoveTo() is called first
411 void moveToExtractionPhrase(CLFECOMMON::TCLEntityId slot, double dist, uint phraseMemoryLine, uint phraseMemorySlot, bool cyclic);
412 /** Method to begin a spire construction
413 * The caller MUST call after CSPhraseManager::clientExecute(), to increment action counter
414 * NB: resetAnyMoveTo() is called first
416 void moveToTotemBuildingPhrase(CLFECOMMON::TCLEntityId slot, double dist, uint phraseMemoryLine, uint phraseMemorySlot, bool cyclic);
417 /// Reset any MoveTo. NB: if the current moveTo is a moveToCombatPhrase() or a moveToExtractionPhrase(), decrement action counter
418 void resetAnyMoveTo();
419 /** Launch the Action Once the Move is done.
420 * \param CEntityCL * : pointer on the destination entity.
421 * \warning entity pointer must be valid(allocated).
423 void moveToAction(CEntityCL *ent);
424 /// Send the position and orientation to the server.
425 bool sendToServer(NLMISC::CBitMemStream &out);
426 /// Fill the msg to know if the user is well placed to fight.
427 bool msgForCombatPos(NLMISC::CBitMemStream &out);
428 /// Check the User Position according to the server code.
429 void checkPos();
430 /// Check a position according to the server code.
431 bool testPacsPos(NLMISC::CVectorD& pos);
432 /// Teleport the player (remove selection, re-init checkPos, etc.).
433 void tp(const NLMISC::CVectorD &dest);
434 /// Teleport the player to correct his position.
435 void correctPos(const NLMISC::CVectorD &dest);
437 /// Skill Up
438 void skillUp();
439 /// get the level of the player (max of all skills)
440 sint getLevel() const;
442 /// After a few time, if the user is still in collision with someone else, remove collisions with other entitites.
443 void startColTimer();
444 /// Called when the user is no more in collision with another entity.
445 void stopColTimer();
447 /// Make the character transparent if the mouse is under it (params is if we must make it transparent or opaque)
448 virtual void makeTransparent(bool t);
449 virtual void setDiffuse(bool onOff, NLMISC::CRGBA diffuse);
451 /// false if in first person mode
452 virtual bool canCastShadowMap() const;
454 /// Return the Entity Current Speed.
455 virtual double speed() const;
457 /// assert(target). NB: this engage (moveToCombatPhrase) if in melee and to far, or directly launch the action
458 void executeCombatWithPhrase(CEntityCL *target, uint32 memoryLine, uint32 memoryIndex, bool cyclic);
460 /// equip with the last weapon used of with the best weapon that can be found in inventory
461 void autoEquipWithLastUsedWeapons();
463 /// save the last weapon(s) used in fight or weapons in hand before tool auto-equip
464 void rememberWeaponsInHand();
466 /// overriden beginCast method
467 virtual void beginCast(const MBEHAV::CBehaviour &behaviour);
469 /// Return the walk speed applicable when riding
470 float getMountWalkVelocity() const { return _MountSpeeds.getWalkSpeed(); }
472 /// Return the run speed applicable when riding
473 float getMountRunVelocity() const { return _MountSpeeds.getRunSpeed(); }
475 /// \name R2 specific
476 // @{
477 // R2 char mode (player, dm, anim, edit) NB: automatically affect the camera max distance and player run/walk speed
478 void setR2CharMode(R2::TCharMode mode);
479 R2::TCharMode getR2CharMode() const {return _R2CharMode;}
480 // re-update view camera dist max, and walk/run speed according to current R2 char mode
481 void flushR2CharMode() {setR2CharMode(_R2CharMode);}
482 // @}
483 // When a player control a npc (in a ring shard) then he must adapt his speed on the Npc speed.
484 void updateNpcContolSpeed();
485 bool isInNpcControl() const;
487 /// cancel current action
488 void cancelAllPhrases();
490 /// true if current behaviour allows to change front
491 bool canChangeFront();
493 string getLoginName()
495 if (_LoginName.empty())
496 _LoginName = getDisplayName();
498 return _LoginName;
501 CVector getCameraMoves()
503 return _CameraMoves;
506 void setCameraMoves(CVector moves)
508 _CameraMoves = moves;
511 protected:
512 class CSpeedFactor : public NLMISC::ICDBNode::IPropertyObserver
514 public:
515 /// Initialize
516 void init();
517 /// Release
518 void release();
519 /// Return the speed factor.
520 float getValue() const { return _Value * _ServerFactor; }
521 void setFactorValue(float value) {_ServerFactor = value;}
522 void addFactorValue(float value) {
523 _ServerFactor += value;
524 if (_ServerFactor > 1.0)
525 _ServerFactor = 1.0;
526 if (_ServerFactor < 0.1)
527 _ServerFactor = 0.1;
530 virtual void serial(NLMISC::IStream &f) {f.serial(_Value);}
531 protected:
532 /// Method called when the ping message is back.
533 virtual void update(NLMISC::ICDBNode* leaf);
534 private:
535 float _Value;
536 float _ServerFactor;
539 class CMountHunger
541 public:
542 /// Initialize
543 void init();
544 /// Release
545 void release();
546 /// Return true if the mount can run. Precondition: UserEntity->isRiding().
547 bool canRun() const;
548 virtual void serial(NLMISC::IStream &/* f */) {}
551 class CMountSpeeds : public NLMISC::ICDBNode::IPropertyObserver
553 public:
554 /// Initialize
555 void init();
556 /// Release
557 void release();
558 /// Return the walk speed when riding
559 float getWalkSpeed() const { return _WalkSpeed; }
560 /// Return the run speed when riding
561 float getRunSpeed() const { return _RunSpeed; }
562 protected:
563 /// Method called when the value is changed
564 virtual void update(NLMISC::ICDBNode* leaf);
565 private:
566 float _WalkSpeed;
567 float _RunSpeed;
570 /// Speed Factor to use for the user sent by the server to respect magical spells
571 CSpeedFactor _SpeedFactor;
572 /// The current maximum speed of the mount (if any)
573 CMountHunger _MountHunger;
574 /// An observer of the current mount speeds
575 CMountSpeeds _MountSpeeds;
576 /// Velocity : Front and Lateral
577 float _FrontVelocity;
578 float _LateralVelocity;
579 /// Speed adjustement from gpms
580 float _SpeedServerAdjust;
581 /// Head Pitch
582 double _HeadPitch;
583 /// Height of the eyes (camera).
584 float _EyesHeight;
585 /// 'True' if the user is running else is walking.
586 bool _Run;
587 /// 'True' if the user & mount should run but are walking because of the mount unability to run
588 bool _RunWhenAble;
589 /// Speed when the user walks.
590 float _WalkVelocity;
591 /// Speed when the user runs.
592 float _RunVelocity;
593 /// Current User Velocity.
594 float _CurrentVelocity;
595 /// Slot Currently Selected (can be different from _TargetSlot).
596 CLFECOMMON::TCLEntityId _Selection;
597 /// Trader Slot (bot chat)
598 CLFECOMMON::TCLEntityId _Trader;
599 /// Interlocutor Slot (dyn chat)
600 CLFECOMMON::TCLEntityId _Interlocutor;
601 bool _Selectable;
602 bool _PermanentDeath;
603 bool _FollowMode;
604 /// Last position validated by the Check system
605 NLMISC::CVectorD _LastPositionValidated;
606 /// Last Validated Global Position.
607 NLPACS::UGlobalPosition _LastGPosValidated;
608 /// Last Global Position sent to the server (in fact it's a normal position sent).
609 NLPACS::UGlobalPosition _LastGPosSent;
610 /// Primitive used to check if the server will accept the current move.
611 NLPACS::UMovePrimitive *_CheckPrimitive;
613 CLFECOMMON::TCLEntityId _MoveToSlot;
614 double _MoveToDist;
615 TMoveToAction _MoveToAction;
616 uint _MoveToPhraseMemoryLine; // used for extraction as well
617 uint _MoveToPhraseMemorySlot; // used for extraction phrase as well
618 bool _MoveToPhraseCyclic;
619 uint32 _MoveToMissionId; // Used for both mission option and mission ring
620 /// Time in MS when the User started beiing in collision with anything that avoid him to do an Action (and still is).
621 sint64 _MoveToColStartTime;
623 CVector _CameraMoves;
626 /// CSkill points observer
627 class CSkillPointsObserver : public NLMISC::ICDBNode::IPropertyObserver
629 public :
630 uint SpType;
632 /// From ICDBNode::IPropertyObserver
633 virtual void update(NLMISC::ICDBNode* node );
635 CSkillPointsObserver _SkillPointObs[EGSPD::CSPType::EndSPType];
637 class CInvisibleObserver : public NLMISC::ICDBNode::IPropertyObserver
639 public :
640 virtual void update(NLMISC::ICDBNode* node);
642 CInvisibleObserver _InvisibleObs;
644 /// Fame observer
645 class CFameObserver : public NLMISC::ICDBNode::IPropertyObserver
647 public :
648 uint32 FactionIndex;
650 /// From ICDBNode::IPropertyObserver
651 virtual void update(NLMISC::ICDBNode* node );
653 std::vector<CFameObserver *> _FamesObs;
655 protected:
656 /// Initialize properties of the entity (according to the class).
657 virtual void initProperties();
659 /// Update Entity Position.
660 virtual void updateVisualPropertyPos (const NLMISC::TGameCycle &gameCycle, const sint64 &prop, const NLMISC::TGameCycle &pI);
661 /// Update Entity Orientation.
662 virtual void updateVisualPropertyOrient (const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
663 /// Update Entity Behaviour.
664 virtual void updateVisualPropertyBehaviour (const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
665 /// Update Entity Name.
666 virtual void updateVisualPropertyName (const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
667 /// Update Entity Target.
668 virtual void updateVisualPropertyTarget (const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
669 /// Update Entity Mode.
670 virtual void updateVisualPropertyMode (const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
671 /// Update Entity Visual Property A
672 virtual void updateVisualPropertyVpa (const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
673 /// Update Entity Visual Property B
674 virtual void updateVisualPropertyVpb (const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
675 /// Update Entity Visual Property C
676 virtual void updateVisualPropertyVpc (const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
677 /// Update Entity Mount
678 virtual void updateVisualPropertyEntityMounted (const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
679 /// Update Entity Rider
680 virtual void updateVisualPropertyRiderEntity (const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
681 /// Target lists
682 virtual void updateVisualPropertyTargetList (const NLMISC::TGameCycle &gameCycle, const sint64 &prop, uint listIndex);
683 /// visual fx
684 virtual void updateVisualPropertyVisualFX (const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
685 /// PVP Mode
686 virtual void updateVisualPropertyPvpMode (const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
687 /// Pvp Outpost
688 virtual void updateVisualPropertyOutpostInfos (const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
689 /// Pvp Clan
690 virtual void updateVisualPropertyPvpClan (const NLMISC::TGameCycle &gameCycle, const sint64 &prop);
693 /// Apply the behaviour for the user.
694 virtual void applyBehaviour(const CBehaviourContext &behaviour);
695 /// Method to Flag the character as dead and do everything needed.
696 virtual void setDead();
698 /// Mount the mount in _Mount
699 void setOnMount();
701 /** Return the current max speed for the entity in meter per sec
702 * The method return a max according to the speed factor (given by the server)
703 * It's also return a value according to the landscape (water)
704 * Also managed mounts
706 virtual double getMaxSpeed() const;
708 /// Read/Write Variables from/to the stream.
709 virtual void readWrite(NLMISC::IStream &f);
710 /// To call after a read from a stream to re-initialize the entity.
711 virtual void load();
714 /// Extract RM from a select forage source
715 void extractRM();
718 /// Build a Totem
719 void buildTotem();
721 private:
722 /// TO know if the user is on a mount at the moment.
723 bool _OnMount;
724 /// Keep track of last hidden mount when switching to FPV mode
725 CLFECOMMON::TCLEntityId _HiddenMount;
726 /// Is the attack animation is currently playing.
727 bool _AnimAttackOn;
728 /// Current View Mode (First/Third Person View).
729 TView _ViewMode;
730 /// 'true' if the collisions between the user and other entities are removed.
731 bool _ColRemoved;
732 /// 'true' if the User is in collision with someone else.
733 bool _ColOn;
734 /// Time in MS when the User started beiing in collision with another entity (and still is).
735 sint64 _ColStartTime;
737 /// Force Look also modify the head pitch in First person
738 bool _FollowForceHeadPitch;
739 /// The Head Offset to follow is kept here.
740 float _FollowHeadOffset;
742 /// Check if the user is not already well placed.
743 void moveToCheckStartDist(CLFECOMMON::TCLEntityId slot, double dist, TMoveToAction action);
745 /// forceLook an entity (follow or moveTo)
746 CLFECOMMON::TCLEntityId _ForceLookSlot;
747 void forceLookEntity(const NLMISC::CVectorD &dir2targ, bool updateHeadPitch, bool start = false);
748 void startForceLookEntity(CLFECOMMON::TCLEntityId slot);
750 /** Method to move to someone else, for special melee combat
751 * The caller MUST call after CSPhraseManager::clientExecute(), to increment action counter
752 * NB: resetAnyMoveTo() is called first
754 void moveToCombatPhrase(CLFECOMMON::TCLEntityId slot, double dist, uint phraseMemoryLine, uint phraseMemorySlot, bool phraseCyclic);
756 /// For executeCombatWithPhrase
757 CLFECOMMON::TCLEntityId _LastExecuteCombatSlot;
759 /// R2: to know in which mode is the current entity (affect camera view and run speed)
760 R2::TCharMode _R2CharMode;
762 /// snapshot of a CItemImage
763 struct CItemSnapshot
765 uint32 Sheet;
766 uint16 Quality;
767 uint16 Quantity;
768 uint8 UserColor;
769 uint32 Price;
770 uint32 Weight;
771 uint32 NameId;
772 uint8 InfoVersion;
774 CItemSnapshot()
776 Sheet = 0;
777 Quality = 0;
778 Quantity = 0;
779 UserColor = 0;
780 Price = 0;
781 Weight = 0;
782 NameId = 0;
783 InfoVersion = 0;
786 CItemSnapshot( const CItemImage& i );
788 /// previous items in hand before they have been changed by an auto-equip due to an action (ex: forage)
789 CItemSnapshot _PreviousRightHandItem;
790 CItemSnapshot _PreviousLeftHandItem;
792 std::string _LoginName;
795 /// Out game received position
796 extern NLMISC::CVectorD UserEntityInitPos;
797 extern NLMISC::CVector UserEntityInitFront;
798 extern CUserEntity *UserEntity;
800 /// char and account time properties
801 extern uint32 CharFirstConnectedTime;
802 extern uint32 CharPlayedTime;
804 /// Max distance between player and extracted forage source
805 extern const double MaxExtractionDistance;
807 #endif // CL_USER_ENTITY_H
809 /* End of user_entity.h */