Mana
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
LocalPlayer Class Referencefinal

The local player character. More...

#include <localplayer.h>

Inheritance diagram for LocalPlayer:
Being ActorSprite EventListener Actor

Public Member Functions

 LocalPlayer (int id=65535, int subtype=0)
 
 ~LocalPlayer () override
 
void logic () override
 Performs being logic.
 
void setAction (Action action, int attackId=1) override
 Sets the current action.
 
bool checkInviteRights (const std::string &guildName)
 Check the player has permission to invite users to specific guild.
 
void inviteToGuild (Being *being)
 Invite a player to join guild.
 
void pickUp (FloorItem *item)
 
void setAttackRange (int range)
 Sets the attack range.
 
int getAttackRange () const
 Gets the attack range.
 
void attack (Being *target=nullptr, bool keep=false)
 
void setGMLevel (int level)
 
void stopAttack ()
 
BeinggetTarget () const
 Returns the current target of the player.
 
void setTarget (Being *target)
 Sets the target being of the player.
 
virtual void setDestination (int x, int y)
 Sets a new destination for this being to walk to.
 
virtual void setDestination (const Vector &dest)
 
virtual void setDestination (const Position &dest)
 
void setWalkingDir (int dir)
 Sets a new direction to keep walking in, when using the keyboard or the joystick.
 
int getWalkingDir () const
 Gets the walking direction.
 
void setGotoTarget (Being *target)
 Sets going to being to attack.
 
void cancelGoToTarget ()
 Cancel a possible target destination in progress, but not the targeting.
 
bool withinRange (Actor *target, int range) const
 Returns whether the target is in range (in pixels).
 
void toggleSit ()
 
void emote (int emoteId)
 
void pickedUp (const ItemInfo &itemInfo, int amount, unsigned char fail)
 Shows item pickup notifications.
 
void setShowIp (bool show)
 
bool getShowIp () const
 
void pathSetByMouse ()
 Tells that the path has been set by mouse.
 
bool isPathSetByMouse () const
 Tells if the path has been set by mouse.
 
void setAwayMode (bool away)
 
bool getAwayMode () const
 
void afkRespond (ChatTab *tab, const std::string &nick)
 
void addMessageToQueue (const std::string &message, int color=UserPalette::EXP_INFO)
 
void event (Event::Channel channel, const Event &event) override
 
- Public Member Functions inherited from Being
 Being (int id, Type type, int subtype, Map *map)
 Constructor.
 
 ~Being () override
 
Type getType () const final
 Returns the type of the ActorSprite.
 
void setType (Type type, int subtype)
 Can be used to change the type of the being.
 
void clearPath ()
 Removes all path nodes from this being.
 
void setDestination (int ex, int ey)
 Creates a path for the being from current position to ex and ey.
 
const VectorgetDestination () const
 Returns the destination for this being.
 
int getTileX () const override
 Returns the tile x coord.
 
int getTileY () const override
 Returns the tile y coord.
 
void setSpeech (const std::string &text, int time=5000)
 Puts a "speech balloon" above this being for the specified amount of time.
 
void takeDamage (Being *attacker, int damage, AttackType type, int attackId=1)
 Puts a damage bubble above this being.
 
void handleAttack (Being *victim, int damage, int attackId=1)
 Handles an attack of another being by this being.
 
const ItemInfogetEquippedWeapon () const
 
const std::string & getName () const
 Returns the name of the being.
 
void setName (const std::string &name)
 Sets the name for the being.
 
bool getShowName () const
 
void setShowName (bool doShowName)
 
void setPartyName (const std::string &name)
 Sets the name of the party the being is in.
 
const std::string & getPartyName () const
 
void setGuildName (const std::string &name)
 Sets the name of the primary guild the being is in.
 
void setGuildPos (const std::string &pos)
 
void addGuild (Guild *guild)
 Adds a guild to the being.
 
void removeGuild (int id)
 Removers a guild from the being.
 
GuildgetGuild (const std::string &guildName) const
 Returns a pointer to the specified guild that the being is in.
 
GuildgetGuild (int id) const
 Returns a pointer to the specified guild that the being is in.
 
const std::map< int, Guild * > & getGuilds () const
 Returns all guilds the being is in.
 
void clearGuilds ()
 Removes all guilds the being is in.
 
short getNumberOfGuilds () const
 Get number of guilds the being belongs to.
 
bool isInParty () const
 
void setParty (Party *party)
 
PartygetParty () const
 
void setSprite (unsigned slot, int id, const std::string &color=std::string(), bool isWeapon=false)
 Sets visible equipments for this being.
 
void setSpriteID (unsigned slot, int id)
 
void setSpriteColor (unsigned slot, const std::string &color=std::string())
 
unsigned getSpriteCount () const
 
bool drawnWhenBehind () const override
 Determines wether the actor should be drawn translucent when behind another object.
 
void drawSpeech (int offsetX, int offsetY)
 Draws the speech text above the being.
 
uint16_t getSubType () const
 
const BeingInfogetInfo () const
 
bool isTargetSelection () const
 
TargetCursorSize getTargetCursorSize () const override
 Returns the required size of a target cursor for this being.
 
Cursor getHoverCursor () const
 
unsigned char getWalkMask () const
 Gets the way the object is blocked by other objects.
 
Map::BlockType getBlockType () const override
 Gets the way the monster blocks pathfinding for other objects.
 
void setMoveSpeed (const Vector &speed)
 Sets the move speed.
 
void setAttackSpeed (int speed)
 Sets the attack speed.
 
int getAttackSpeed () const
 Gets the attack speed.
 
void setAction (const std::string &action)
 Sets the current action by name.
 
Action getCurrentAction () const
 Get the being's action currently performed.
 
bool isAlive () const
 Returns whether this being is still alive.
 
uint8_t getDirection () const
 Returns the current direction.
 
void setDirection (uint8_t direction)
 Sets the current direction.
 
SpriteDirection getSpriteDirection () const
 Returns the direction the being is facing.
 
void setPosition (const Vector &pos) final
 Sets the pixel position of this actor.
 
void setPosition (float x, float y, float z=0.0f)
 Overloaded method provided for convenience.
 
int getCollisionRadius () const
 Returns the being's pixel radius used to detect collisions.
 
void fireMissile (Being *target, const std::string &particle)
 Shoots a missile particle from this being, to target being.
 
void setStatusEffect (int id, bool active)
 
const PathgetPath () const
 Returns the path this being is following.
 
void flashName (int time)
 
int getDamageTaken () const
 
void updateName ()
 
void setGender (Gender gender)
 Sets the gender of this being.
 
Gender getGender () const
 
bool isGM () const
 Whether or not this player is a GM.
 
void setGM (bool gm)
 Triggers whether or not to show the name as a GM name.
 
void setIp (int ip)
 Sets the IP or an IP hash.
 
int getIp () const
 Returns the player's IP or an IP hash.
 
bool canTalk ()
 
void talkTo ()
 
void death (const gcn::Event &event) override
 
void setMap (Map *map) final
 
void lookAt (const Vector &destVec)
 Make the being look at a given pixel position.
 
void lookAt (const Position &destPos)
 
- Public Member Functions inherited from ActorSprite
 ActorSprite (int id)
 
 ~ActorSprite () override
 
int getId () const
 
void setId (int id)
 
int getDrawOrder () const override
 Returns the pixel Y coordinate that the actor should be drawn at.
 
bool draw (Graphics *graphics, int offsetX, int offsetY) const override
 Draws the Actor to the given graphics context.
 
bool drawSpriteAt (Graphics *graphics, int x, int y) const
 
void controlParticle (Particle *particle)
 Take control of a particle.
 
void setTargetType (TargetCursorType type)
 Sets the target animation for this actor.
 
void untarget ()
 Untargets the actor.
 
void setAlpha (float alpha) override
 Sets the alpha value used to draw the actor.
 
float getAlpha () const override
 Returns the current alpha value used to draw the actor.
 
int getWidth () const
 
int getHeight () const
 
- Public Member Functions inherited from Actor
 Actor ()
 
virtual ~Actor ()
 
const VectorgetPosition () const
 Returns the pixel position of this actor.
 
int getPixelX () const
 Returns the pixels X coordinate of the actor.
 
int getPixelY () const
 Returns the pixel Y coordinate of the actor.
 
MapgetMap () const
 
- Public Member Functions inherited from EventListener
virtual ~EventListener ()
 
void listen (Event::Channel channel)
 
void ignore (Event::Channel channel)
 

Protected Member Functions

void updateStatusEffect (int id, bool newStatus) override
 Notify self that a status effect has flipped.
 
void startWalking (unsigned char dir)
 Make the character starts to walk.
 
void stopWalking (bool sendToServer=true)
 Stops the player dead in his tracks.
 
void nextTile (unsigned char dir)
 set the next path tile when walking and using the keyboard.
 
Position getNextWalkPosition (unsigned char dir) const
 Compute the next pathnode location when walking using keyboard.
 
void pathFinished () override
 Called when the being has reached the end of its path.
 
- Protected Member Functions inherited from Being
void setPath (const Path &path)
 Sets the new path for this being.
 
void updateNamePosition ()
 Updates name's location.
 
void addSpriteParticles (SpriteState &spriteState, const SpriteDisplay &display)
 
void restoreAllSpriteParticles ()
 
void updateColors ()
 
void updatePlayerSprites ()
 Updates the visible sprite IDs of the player, taking into account the item replacements.
 
int getSpeechTextYPosition () const
 Gets the advised Y chat text position.
 
- Protected Member Functions inherited from ActorSprite
void setupSpriteDisplay (const SpriteDisplay &display, bool forceDisplay=true)
 

Protected Attributes

int mAttackRange = -1
 
Timer mLastTargetTimer
 Timer for last targeting action.
 
int mGMLevel = 0
 
BeingmTarget = nullptr
 
FloorItemmPickUpTarget = nullptr
 
bool mGoingToTarget = false
 
bool mKeepAttacking = false
 Whether or not to continue to attack.
 
Timer mLastActionTimer
 Timeout for the last action.
 
int mWalkingDir = 0
 The direction the player is walking in.
 
bool mPathSetByMouse = false
 Tells if the path was set using mouse.
 
std::list< std::pair< std::string, int > > mMessages
 Queued messages.
 
Timer mMessageTimer
 
bool mShowIp = false
 
std::unique_ptr< AwayListenermAwayListener
 
Timer mAfkTimer
 
bool mAwayMode = false
 
- Protected Attributes inherited from Being
const BeingInfomInfo
 
Timer mActionTimer
 Time spent in current action.
 
Timer mSpeechTimer
 Time until the last speech sentence disappears.
 
int mAttackSpeed = 350
 Attack speed.
 
Action mAction = STAND
 Action the being is performing.
 
int mSubType = 0xFFFF
 Subtype (graphical view, basically)
 
uint8_t mDirection = DOWN
 Facing direction.
 
uint8_t mSpriteDirection = DIRECTION_DOWN
 Facing direction.
 
std::string mName
 Name of character.
 
std::string mPartyName
 
FlashTextmDispName = nullptr
 Holds a text object when the being displays its name, 0 otherwise.
 
const gcn::Color * mNameColor
 
bool mShowName = false
 
const ItemInfomEquippedWeapon = nullptr
 Engine-related infos about weapon.
 
Path mPath
 
std::string mSpeech
 
TextmText = nullptr
 
Vector mDest
 destination coordinates.
 
std::vector< SpriteStatemSpriteStates
 
bool mRestoreParticlesOnLogic = false
 
Gender mGender = Gender::Neutral
 
std::map< int, Guild * > mGuilds
 
PartymParty = nullptr
 
bool mIsGM = false
 
- Protected Attributes inherited from ActorSprite
int mId
 
std::vector< ParticleHandlemChildParticleEffects
 
CompoundSprite mSprites
 
- Protected Attributes inherited from Actor
MapmMap = nullptr
 
Vector mPos
 Position in pixels relative to map.
 

Additional Inherited Members

- Public Types inherited from Being
enum  Action {
  STAND , MOVE , ATTACK , SIT ,
  DEAD , HURT
}
 Action the being is currently performing WARNING: Has to be in sync with the same enum in the Being class of the server! More...
 
enum  Speech { NO_SPEECH = 0 , TEXT_OVERHEAD , NO_NAME_IN_BUBBLE , NAME_IN_BUBBLE }
 
enum  AttackType {
  HIT = 0x00 , CRITICAL = 0x0a , MULTI = 0x08 , REFLECT = 0x04 ,
  FLEE = 0x0b
}
 
enum  BeingDirection { DOWN = 1 , LEFT = 2 , UP = 4 , RIGHT = 8 }
 Directions, to be used as bitmask values. More...
 
- Public Types inherited from ActorSprite
enum  Type {
  UNKNOWN , PLAYER , NPC , MONSTER ,
  FLOOR_ITEM , PORTAL
}
 
enum  TargetCursorSize { TC_SMALL = 0 , TC_MEDIUM , TC_LARGE , NUM_TC }
 
enum  TargetCursorType { TCT_NONE = -1 , TCT_NORMAL = 0 , TCT_IN_RANGE , NUM_TCT }
 
- Static Public Member Functions inherited from ActorSprite
static void load ()
 
static void unload ()
 

Detailed Description

The local player character.

Definition at line 74 of file localplayer.h.

Constructor & Destructor Documentation

◆ LocalPlayer()

LocalPlayer::LocalPlayer ( int  id = 65535,
int  subtype = 0 
)

Definition at line 58 of file localplayer.cpp.

◆ ~LocalPlayer()

LocalPlayer::~LocalPlayer ( )
overridedefault

Member Function Documentation

◆ addMessageToQueue()

void LocalPlayer::addMessageToQueue ( const std::string &  message,
int  color = UserPalette::EXP_INFO 
)

Definition at line 948 of file localplayer.cpp.

◆ afkRespond()

void LocalPlayer::afkRespond ( ChatTab tab,
const std::string &  nick 
)

Definition at line 1050 of file localplayer.cpp.

◆ attack()

void LocalPlayer::attack ( Being target = nullptr,
bool  keep = false 
)

Definition at line 801 of file localplayer.cpp.

◆ cancelGoToTarget()

void LocalPlayer::cancelGoToTarget ( )
inline

Cancel a possible target destination in progress, but not the targeting.

Definition at line 154 of file localplayer.h.

◆ checkInviteRights()

bool LocalPlayer::checkInviteRights ( const std::string &  guildName)

Check the player has permission to invite users to specific guild.

Definition at line 559 of file localplayer.cpp.

◆ emote()

void LocalPlayer::emote ( int  emoteId)

Definition at line 792 of file localplayer.cpp.

◆ event()

void LocalPlayer::event ( Event::Channel  channel,
const Event event 
)
overridevirtual

Reimplemented from Being.

Definition at line 953 of file localplayer.cpp.

◆ getAttackRange()

int LocalPlayer::getAttackRange ( ) const
inline

Gets the attack range.

Definition at line 104 of file localplayer.h.

◆ getAwayMode()

bool LocalPlayer::getAwayMode ( ) const
inline

Definition at line 186 of file localplayer.h.

◆ getNextWalkPosition()

Position LocalPlayer::getNextWalkPosition ( unsigned char  dir) const
protected

Compute the next pathnode location when walking using keyboard.

used by nextTile().

Definition at line 178 of file localplayer.cpp.

◆ getShowIp()

bool LocalPlayer::getShowIp ( ) const
inline

Definition at line 174 of file localplayer.h.

◆ getTarget()

Being * LocalPlayer::getTarget ( ) const

Returns the current target of the player.

Returns 0 if no being is currently targeted.

Definition at line 608 of file localplayer.cpp.

◆ getWalkingDir()

int LocalPlayer::getWalkingDir ( ) const
inline

Gets the walking direction.

Definition at line 142 of file localplayer.h.

◆ inviteToGuild()

void LocalPlayer::inviteToGuild ( Being being)

Invite a player to join guild.

Definition at line 567 of file localplayer.cpp.

◆ isPathSetByMouse()

bool LocalPlayer::isPathSetByMouse ( ) const
inline

Tells if the path has been set by mouse.

Definition at line 182 of file localplayer.h.

◆ logic()

void LocalPlayer::logic ( )
overridevirtual

Performs being logic.

Reimplemented from Being.

Definition at line 71 of file localplayer.cpp.

◆ nextTile()

void LocalPlayer::nextTile ( unsigned char  dir = 0)
protected

set the next path tile when walking and using the keyboard.

Definition at line 537 of file localplayer.cpp.

◆ pathFinished()

void LocalPlayer::pathFinished ( )
inlineoverrideprotectedvirtual

Called when the being has reached the end of its path.

Reimplemented from Being.

Definition at line 218 of file localplayer.h.

◆ pathSetByMouse()

void LocalPlayer::pathSetByMouse ( )
inline

Tells that the path has been set by mouse.

Definition at line 178 of file localplayer.h.

◆ pickedUp()

void LocalPlayer::pickedUp ( const ItemInfo itemInfo,
int  amount,
unsigned char  fail 
)

Shows item pickup notifications.

Definition at line 849 of file localplayer.cpp.

◆ pickUp()

void LocalPlayer::pickUp ( FloorItem item)

Definition at line 584 of file localplayer.cpp.

◆ setAction()

void LocalPlayer::setAction ( Action  action,
int  attackId = 1 
)
overridevirtual

Sets the current action.

Reimplemented from Being.

Definition at line 158 of file localplayer.cpp.

◆ setAttackRange()

void LocalPlayer::setAttackRange ( int  range)

Sets the attack range.

Definition at line 901 of file localplayer.cpp.

◆ setAwayMode()

void LocalPlayer::setAwayMode ( bool  away)

Definition at line 1032 of file localplayer.cpp.

◆ setDestination() [1/3]

virtual void LocalPlayer::setDestination ( const Position dest)
inlinevirtual

Definition at line 130 of file localplayer.h.

◆ setDestination() [2/3]

virtual void LocalPlayer::setDestination ( const Vector dest)
inlinevirtual

Definition at line 128 of file localplayer.h.

◆ setDestination() [3/3]

void LocalPlayer::setDestination ( int  x,
int  y 
)
virtual

Sets a new destination for this being to walk to.

Definition at line 649 of file localplayer.cpp.

◆ setGMLevel()

void LocalPlayer::setGMLevel ( int  level)

Definition at line 169 of file localplayer.cpp.

◆ setGotoTarget()

void LocalPlayer::setGotoTarget ( Being target)

Sets going to being to attack.

Definition at line 933 of file localplayer.cpp.

◆ setShowIp()

void LocalPlayer::setShowIp ( bool  show)
inline

Definition at line 171 of file localplayer.h.

◆ setTarget()

void LocalPlayer::setTarget ( Being target)

Sets the target being of the player.

Definition at line 613 of file localplayer.cpp.

◆ setWalkingDir()

void LocalPlayer::setWalkingDir ( int  dir)

Sets a new direction to keep walking in, when using the keyboard or the joystick.

Definition at line 691 of file localplayer.cpp.

◆ startWalking()

void LocalPlayer::startWalking ( unsigned char  dir)
protected

Make the character starts to walk.

Definition at line 740 of file localplayer.cpp.

◆ stopAttack()

void LocalPlayer::stopAttack ( )

Definition at line 837 of file localplayer.cpp.

◆ stopWalking()

void LocalPlayer::stopWalking ( bool  sendToServer = true)
protected

Stops the player dead in his tracks.

Definition at line 756 of file localplayer.cpp.

◆ toggleSit()

void LocalPlayer::toggleSit ( )

Definition at line 775 of file localplayer.cpp.

◆ updateStatusEffect()

void LocalPlayer::updateStatusEffect ( int  index,
bool  newStatus 
)
overrideprotectedvirtual

Notify self that a status effect has flipped.

The new flag is passed.

Reimplemented from Being.

Definition at line 1016 of file localplayer.cpp.

◆ withinRange()

bool LocalPlayer::withinRange ( Actor target,
int  range 
) const

Returns whether the target is in range (in pixels).

Definition at line 921 of file localplayer.cpp.

Member Data Documentation

◆ mAfkTimer

Timer LocalPlayer::mAfkTimer
protected

Definition at line 243 of file localplayer.h.

◆ mAttackRange

int LocalPlayer::mAttackRange = -1
protected

Definition at line 220 of file localplayer.h.

◆ mAwayListener

std::unique_ptr<AwayListener> LocalPlayer::mAwayListener
protected

Definition at line 242 of file localplayer.h.

◆ mAwayMode

bool LocalPlayer::mAwayMode = false
protected

Definition at line 244 of file localplayer.h.

◆ mGMLevel

int LocalPlayer::mGMLevel = 0
protected

Definition at line 224 of file localplayer.h.

◆ mGoingToTarget

bool LocalPlayer::mGoingToTarget = false
protected

Definition at line 230 of file localplayer.h.

◆ mKeepAttacking

bool LocalPlayer::mKeepAttacking = false
protected

Whether or not to continue to attack.

Definition at line 231 of file localplayer.h.

◆ mLastActionTimer

Timer LocalPlayer::mLastActionTimer
protected

Timeout for the last action.

Definition at line 232 of file localplayer.h.

◆ mLastTargetTimer

Timer LocalPlayer::mLastTargetTimer
protected

Timer for last targeting action.

Definition at line 222 of file localplayer.h.

◆ mMessages

std::list<std::pair<std::string, int> > LocalPlayer::mMessages
protected

Queued messages.

Definition at line 237 of file localplayer.h.

◆ mMessageTimer

Timer LocalPlayer::mMessageTimer
protected

Definition at line 238 of file localplayer.h.

◆ mPathSetByMouse

bool LocalPlayer::mPathSetByMouse = false
protected

Tells if the path was set using mouse.

Definition at line 234 of file localplayer.h.

◆ mPickUpTarget

FloorItem* LocalPlayer::mPickUpTarget = nullptr
protected

Definition at line 228 of file localplayer.h.

◆ mShowIp

bool LocalPlayer::mShowIp = false
protected

Definition at line 240 of file localplayer.h.

◆ mTarget

Being* LocalPlayer::mTarget = nullptr
protected

Definition at line 226 of file localplayer.h.

◆ mWalkingDir

int LocalPlayer::mWalkingDir = 0
protected

The direction the player is walking in.

Definition at line 233 of file localplayer.h.


The documentation for this class was generated from the following files: