ManaPlus
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes
LocalPlayer Class Reference

#include <localplayer.h>

Inheritance diagram for LocalPlayer:
Being ActorSpriteListener AttributeListener PlayerDeathListener ActorSprite ConfigListener CompoundSprite Actor Sprite

Public Member Functions

 LocalPlayer (const BeingId id, const BeingTypeId subType)
 
 ~LocalPlayer ()
 
void logic ()
 
void slowLogic ()
 
void setAction (const BeingActionT &action, const int attackId)
 
Position getNextWalkPosition (const unsigned char dir) const
 
void nextTile ()
 
bool pickUp (FloorItem *const item)
 
void actorSpriteDestroyed (const ActorSprite &actorSprite)
 
int getAttackRange () const
 
int getAttackRange2 () const
 
void attack (Being *const target, const bool keep, const bool dontChangeEquipment)
 
void attack2 (Being *const target, const bool keep, const bool dontChangeEquipment)
 
void setGroupId (const int id)
 
void stopAttack (const bool keepAttack)
 
void untarget ()
 
BeinggetTarget () const
 
void setTarget (Being *const target)
 
BeingsetNewTarget (const ActorTypeT type, const AllowSort allowSort)
 
void setDestination (const int x, const int y)
 
void setWalkingDir (const unsigned char dir)
 
unsigned char getWalkingDir () const
 
void setGotoTarget (Being *const target)
 
bool withinAttackRange (const Being *const target, const bool fixDistance, const int addRange) const
 
void stopWalking (const bool sendToServer)
 
bool toggleSit () const
 
bool updateSit () const
 
void pickedUp (const ItemInfo &itemInfo, const int amount, const ItemColor color, const BeingId floorItemId, const PickupT fail)
 
int getLevel () const
 
void pathSetByMouse ()
 
bool isPathSetByMouse () const
 
unsigned int getMoveState () const
 
void setMoveState (const unsigned int n)
 
std::string getPingTime () const
 
void tryPingRequest ()
 
void magicAttack () const
 
void specialMove (const unsigned char direction)
 
void moveByDirection (const unsigned char dir)
 
bool pickUpItems (int pickUpType)
 
void move (const int dX, const int dY)
 
void moveToTarget (int dist)
 
void moveToHome ()
 
bool isReachable (Being *const being, const int maxCost)
 
bool isReachable (const int x, const int y, const bool allowCollision) const
 
void setHome ()
 
void pingRequest ()
 
void pingResponse ()
 
void setAway (const std::string &message) const
 
void setHalfAway (const bool n)
 
bool getHalfAway () const
 
void afkRespond (ChatTab *const tab, const std::string &nick)
 
bool navigateTo (const int x, const int y)
 
void navigateClean ()
 
void imitateEmote (const Being *const being, const unsigned char action) const
 
void imitateAction (const Being *const being, const BeingActionT &action)
 
void imitateDirection (const Being *const being, const unsigned char dir)
 
void imitateOutfit (const Being *const player, const int sprite) const
 
void followMoveTo (const Being *const being, const int x, const int y)
 
void followMoveTo (const Being *const being, const int x1, const int y1, const int x2, const int y2)
 
bool allowAction ()
 
void setRealPos (const int x, const int y)
 
bool isServerBuggy () const
 
void fixPos ()
 
void setTileCoords (const int x, const int y)
 
void setMap (Map *const map)
 
void addMessageToQueue (const std::string &message, const UserColorIdT color)
 
void optionChanged (const std::string &value)
 
void playerDeath ()
 
void setFollow (const std::string &player)
 
void setImitate (const std::string &player)
 
void setNextDest (const int x, const int y)
 
int getNextDestX () const
 
int getNextDestY () const
 
void respawn ()
 
const FloorItemgetPickUpTarget () const
 
void unSetPickUpTarget ()
 
void cancelFollow ()
 
const std::string & getFollow () const
 
const std::string & getImitate () const
 
void setCheckNameSetting (const bool checked)
 
bool getCheckNameSetting () const
 
void fixAttackTarget ()
 
void updateNavigateList ()
 
int getPathLength (const Being *const being) const
 
void targetMoved () const
 
void setLastHitFrom (const std::string &n)
 
void waitFor (const std::string &nick)
 
void checkNewName (Being *const being)
 
unsigned char getBlockWalkMask () const A_CONST
 
void saveHomes ()
 
void removeHome ()
 
void stopAdvert ()
 
void addXpMessage (const int64_t change)
 
void addHomunXpMessage (const int change)
 
void addJobMessage (const int64_t change)
 
void addHpMessage (const int change)
 
void addSpMessage (const int change)
 
void updateStatus () const
 
void setTestParticle (const std::string &fileName, const bool updateHash)
 
int getLastAttackX () const
 
int getLastAttackY () const
 
void attributeChanged (const AttributesT id, const int64_t oldVal, const int64_t newVal)
 
void updateMusic () const
 
void setAfkTime (const int v)
 
void setAwayDialog (OkDialog *const dialog)
 
AwayListenergetAwayListener () const
 
void setRename (const bool r)
 
bool getRename () const
 
bool canMove () const
 
void freezeMoving (const int timeWaitTicks)
 
void failMove (const int x, const int y)
 
- Public Member Functions inherited from Being
 Being (const BeingId id, const ActorTypeT type)
 
 ~Being ()
 
ActorTypeT getType () const
 
void clearPath ()
 
int getActionTime () const
 
void setActionTime (const int actionTime)
 
void setDestination (const int dstX, const int dstY)
 
void setCachedDestination (const int dstX, const int dstY)
 
int getCachedX () const
 
int getCachedY () const
 
const VectorgetDestination () const
 
int getTileX () const
 
int getTileY () const
 
void setSpeech (const std::string &text)
 
void takeDamage (Being *const attacker, const int amount, const AttackTypeT type, const int attackId, const int level)
 
void handleAttack (Being *const victim, const int damage, const int attackId)
 
void handleSkillCasting (Being *const victim, const int skillId, const int skillLevel)
 
void handleSkill (Being *const victim, const int damage, const int skillId, const int skillLevel)
 
const ItemInfogetEquippedWeapon () const
 
const std::string & getName () const
 
const std::string & getExtName () const
 
void setName (const std::string &name)
 
bool getShowName () const
 
void setShowName (const bool doShowName)
 
void setPartyName (const std::string &name)
 
const std::string & getPartyName () const
 
const std::string & getGuildName () const
 
const std::string & getClanName () const
 
void setGuildName (const std::string &name)
 
void setGuildPos (const std::string &pos)
 
void setClanName (const std::string &name)
 
void addGuild (Guild *const guild)
 
void removeGuild (const int id)
 
const GuildgetGuild (const std::string &guildName) const
 
const GuildgetGuild (const int id) const
 
GuildgetGuild () const
 
const std::map< int, Guild * > & getGuilds () const
 
void clearGuilds ()
 
int16_t getNumberOfGuilds () const
 
bool isInParty () const
 
void setParty (Party *const party)
 
void setGuild (Guild *const guild)
 
void updateGuild ()
 
PartygetParty () const
 
void setSprite (const unsigned int slot, const int id, std::string color, ItemColor colorId)
 
void setSpriteColor (const unsigned int slot, const int id, const std::string &color)
 
void setSpriteColorId (const unsigned int slot, const int id, ItemColor colorId)
 
void setSpriteCards (const unsigned int slot, const int id, const CardsList &cards)
 
void setSpriteId (const unsigned int slot, const int id)
 
void unSetSprite (const unsigned int slot)
 
void setWeaponId (const int id)
 
void setTempSprite (const unsigned int slot, const int id)
 
void setHairTempSprite (const unsigned int slot, const int id)
 
void updateSprite (const unsigned int slot, const int id, const std::string &color)
 
void setHairColorSpriteID (const unsigned int slot, const int id)
 
void setSpriteColor (const unsigned int slot, const std::string &color)
 
int getNumberOfLayers () const
 
void botLogic ()
 
void drawSpeech (const int offsetX, const int offsetY)
 
void drawEmotion (Graphics *const graphics, const int offsetX, const int offsetY) const
 
BeingTypeId getSubType () const
 
void setSubtype (const BeingTypeId subtype, const uint16_t look)
 
const BeingInfogetInfo () const
 
TargetCursorSizeT getTargetCursorSize () const
 
int getTargetOffsetX () const
 
int getTargetOffsetY () const
 
BlockTypeT getBlockType () const
 
void setWalkSpeed (const int speed)
 
int getWalkSpeed () const
 
void setAttackSpeed (const int speed)
 
int getAttackSpeed () const
 
BeingActionT getCurrentAction () const
 
bool isAlive () const
 
uint8_t getDirection () const
 
virtual void setDirection (const uint8_t direction)
 
void setDirectionDelayed (const uint8_t direction)
 
uint8_t getDirectionDelayed () const
 
SpriteDirection::Type getSpriteDirection () const
 
void setPixelPositionF (const Vector &pos)
 
void setPixelPositionF (const float x, const float y, const float z) A_INLINE
 
int getWidth () const
 
int getHeight () const
 
void fireMissile (Being *const victim, const MissileInfo &missile) const
 
const PathgetPath () const
 
int getDistance () const
 
void setDistance (const int n)
 
void setEmote (const uint8_t emotion, const int emote_time)
 
void setState (const uint8_t state)
 
void drawPlayerSprites (Graphics *const graphics, const int posX, const int posY) const
 
void drawSpritesSDL (Graphics *const graphics, const int posX, const int posY) const
 
void drawHpBar (Graphics *const graphics, const int maxHP, const int hp, const int damage, const UserColorIdT color1, const UserColorIdT color2, const int x, const int y, const int width, const int height) const
 
void flashName (const int time)
 
int getDamageTaken () const
 
void setDamageTaken (const int damage)
 
void updateName ()
 
void setLevel (const int n)
 
void setReachable (const ReachableT n)
 
ReachableT getReachable () const
 
void addToCache () const
 
bool updateFromCache ()
 
virtual void setGender (const GenderT gender)
 
GenderT getGender () const
 
std::string getSitAction () const
 
std::string getCastAction () const
 
std::string getCastAction (const SkillInfo *const skill) const
 
std::string getMoveAction () const
 
std::string getDeadAction () const
 
std::string getStandAction () const
 
std::string getSpawnAction () const
 
std::string getWeaponAttackAction (const ItemInfo *const weapon) const
 
std::string getAttackAction () const
 
std::string getAttackAction (const Attack *const attack1) const
 
bool isGM () const
 
void setGM (const bool gm)
 
bool canTalk () const
 
void talkTo () const
 
void draw (Graphics *const graphics, const int offsetX, const int offsetY) const
 
void drawPlayer (Graphics *const graphics, const int offsetX, const int offsetY) const
 
void drawOther (Graphics *const graphics, const int offsetX, const int offsetY) const
 
void drawNpc (Graphics *const graphics, const int offsetX, const int offsetY) const
 
void drawMonster (Graphics *const graphics, const int offsetX, const int offsetY) const
 
void drawPortal (Graphics *const graphics, const int offsetX, const int offsetY) const
 
void drawBasic (Graphics *const graphics, const int x, const int y) const
 
void setMoveTime ()
 
void setAttackTime ()
 
void setTalkTime ()
 
void setTestTime ()
 
void setOtherTime ()
 
time_t getMoveTime () const
 
time_t getAttackTime () const
 
time_t getTalkTime () const
 
time_t getTestTime () const
 
time_t getOtherTime () const
 
void resetCounters ()
 
void updateColors ()
 
void setEnemy (const bool n)
 
const std::string & getIp () const
 
void setIp (const std::string &ip)
 
unsigned int getPvpRank () const
 
void setPvpRank (const unsigned int rank)
 
void setHP (const int hp)
 
void setMaxHP (const int hp)
 
int getHP () const
 
int getMaxHP () const
 
uint8_t calcDirection (const int dstX, const int dstY) const
 
uint8_t calcDirection () const
 
void setAttackDelay (const int n)
 
int getAttackDelay () const
 
int getMinHit () const
 
void setMinHit (const int n)
 
int getMaxHit () const
 
void setMaxHit (const int n)
 
int getCriticalHit () const
 
void setCriticalHit (const int n)
 
void updateHit (const int amount)
 
EquipmentgetEquipment ()
 
void undressItemById (const int id)
 
int getGoodStatus () const
 
void setGoodStatus (const int n)
 
std::string getGenderSign () const
 
std::string getGenderSignWithSpace () const
 
void updateComment ()
 
const std::string getComment () const
 
void setComment (const std::string &n)
 
bool isAdvanced () const
 
void setAdvanced (const bool n)
 
bool isBuyShopEnabled () const
 
bool isSellShopEnabled () const
 
void enableShop (const bool b)
 
void setAttackRange (const int range)
 
void updatePercentHP ()
 
void setRaceName (const std::string &name)
 
std::string getRaceName () const
 
int getSpriteID (const int slot) const
 
const BeingSlotgetSpriteSlot (const int slot) const
 
ItemColor getSpriteColor (const int slot) const
 
void setHairStyle (const unsigned int slot, const int id)
 
void setHairColor (const unsigned int slot, const ItemColor color)
 
void setHairColor (const ItemColor color)
 
void setSpriteSlot (const unsigned int slot, const BeingSlot &beingSlot)
 
ItemColor getHairColor () const
 
void recalcSpritesOrder ()
 
CursorT getHoverCursor () const
 
void addAfkEffect ()
 
void removeAfkEffect ()
 
void updateAwayEffect ()
 
void addSpecialEffect (const int effect)
 
void removeSpecialEffect ()
 
void addEffect (const std::string &name)
 
void setOwner (Being *const owner)
 
BeinggetOwner () const
 
void playSfx (const SoundInfo &sound, Being *const being, const bool main, const int x, const int y) const
 
uint16_t getLook () const
 
void setLook (const uint16_t look)
 
void setPath (const Path &path)
 
int getSortPixelY () const
 
void recreateItemParticles ()
 
void incUsage ()
 
int decUsage ()
 
void drawHomunculus (Graphics *const graphics, const int offsetX, const int offsetY) const
 
void drawMercenary (Graphics *const graphics, const int offsetX, const int offsetY) const
 
void drawElemental (Graphics *const graphics, const int offsetX, const int offsetY) const
 
void setTrickDead (const bool b)
 
void setChat (ChatObject *const obj)
 
ChatObjectgetChat () const
 
void setRiding (const bool b)
 
void setHorse (const int horseId)
 
void removeHorse ()
 
void setSellBoard (const std::string &text)
 
std::string getSellBoard () const
 
void setBuyBoard (const std::string &text)
 
std::string getBuyBoard () const
 
void setSpiritBalls (const unsigned int balls)
 
unsigned int getSpiritBalls () const
 
void stopCast (const bool b)
 
void setCreatorId (const BeingId id)
 
BeingId getCreatorId () const
 
void setKarma (const int karma)
 
int getKarma () const
 
void setManner (const int manner)
 
int getManner () const
 
void disableBotAi ()
 
void enableBotAi ()
 
int getAreaSize () const
 
void setAreaSize (const int areaSize)
 
void setTeamId (const uint16_t teamId)
 
void showTeamBadge (const bool show)
 
void showGuildBadge (const bool show)
 
void showClanBadge (const bool show)
 
void showGmBadge (const bool show)
 
void showPartyBadge (const bool show)
 
void showNameBadge (const bool show)
 
void showShopBadge (const bool show)
 
void showInactiveBadge (const bool show)
 
void showAwayBadge (const bool show)
 
void showBadges (const bool show)
 
void setLanguageId (const int lang)
 
int getLanguageId ()
 
uint16_t getTeamId () const
 
int getGroupId () const
 
void serverRemove ()
 
void addCast (const int dstX, const int dstY, const int skillId, const int skillLevel, const int range, const int waitTimeTicks)
 
void fixDirectionOffsets (int &offsetX, int &offsetY) const
 
bool getAllowNpcEquipment () const
 
- Public Member Functions inherited from ActorSprite
 ActorSprite (const BeingId id)
 
 ~ActorSprite ()
 
BeingId getId () const
 
void setId (const BeingId id)
 
void controlAutoParticle (Particle *const particle)
 
void controlCustomParticle (Particle *const particle)
 
void setTargetType (const TargetCursorTypeT type)
 
void untarget ()
 
void setStatusEffect (const int32_t index, const Enable active, const IsStart start)
 
void setStatusEffectOpitons (const uint32_t option, const uint32_t opt1, const uint32_t opt2, const uint32_t opt3)
 
void setStatusEffectOpitons (const uint32_t option, const uint32_t opt1, const uint32_t opt2)
 
void setStatusEffectOpiton0 (const uint32_t option)
 
void setAlpha (const float alpha)
 
float getAlpha () const
 
void addActorSpriteListener (ActorSpriteListener *const listener)
 
void removeActorSpriteListener (ActorSpriteListener *const listener)
 
int getActorX () const
 
int getActorY () const
 
void setPoison (const bool b)
 
bool getPoison () const
 
void setHaveCart (const bool b)
 
bool getHaveCart () const
 
bool isTrickDead () const
 
const std::set< int32_t > & getStatusEffects () const
 
std::string getStatusEffectsString () const
 
size_t getParticlesCount () const
 
void controlParticleDeleted (const Particle *const particle)
 
- Public Member Functions inherited from CompoundSprite
 CompoundSprite ()
 
 ~CompoundSprite ()
 
bool reset ()
 
bool play (const std::string &action)
 
bool update (const int time)
 
void drawSimple (Graphics *const graphics, const int posX, const int posY) const
 
int getWidth () const
 
int getHeight () const
 
const ImagegetImage () const
 
bool setSpriteDirection (const SpriteDirection::Type direction)
 
int getNumberOfLayers () const
 
unsigned int getCurrentFrame () const
 
unsigned int getFrameCount () const
 
void addSprite (Sprite *const sprite)
 
void setSprite (const size_t layer, Sprite *const sprite)
 
void removeSprite (const int layer)
 
void clear ()
 
void ensureSize (const size_t layerCount)
 
void drawSprites (Graphics *const graphics, const int posX, const int posY) const
 
void setAlpha (float alpha)
 
bool updateNumber (const unsigned num)
 
int getLastTime () const
 
int getStartTime () const
 
- Public Member Functions inherited from Sprite
virtual ~Sprite ()
 
virtual const void * getHash () const
 
virtual const void * getHash2 () const
 
- Public Member Functions inherited from Actor
virtual ~Actor ()
 
const VectorgetPixelPositionF () const
 
int getPixelX () const
 
virtual int getPixelY () const
 
const MapgetMap () const
 
- Public Member Functions inherited from ConfigListener
 ConfigListener ()
 
virtual ~ConfigListener ()
 
- Public Member Functions inherited from ActorSpriteListener
 ActorSpriteListener ()
 
virtual ~ActorSpriteListener ()
 
- Public Member Functions inherited from AttributeListener
 AttributeListener ()
 
virtual ~ AttributeListener ()
 
- Public Member Functions inherited from PlayerDeathListener
 PlayerDeathListener ()
 
virtual ~ PlayerDeathListener ()
 

Static Public Member Functions

static bool emote (const uint8_t emotion)
 
static void setPseudoAway (const std::string &message)
 
static void setAfkMessage (std::string message)
 
static bool checAttackPermissions (const Being *const target)
 
- Static Public Member Functions inherited from Being
static void reReadConfig ()
 
static BeingCacheEntrygetCacheEntry (const BeingId id)
 
static void clearCache ()
 
static std::string loadComment (const std::string &name, const ActorTypeT &type)
 
static void saveComment (const std::string &name, const std::string &comment, const ActorTypeT &type)
 
static int getHitEffect (const Being *const attacker, const AttackTypeT type, const int attackId, const int level)
 
static uint8_t genderToInt (const GenderT sex) A_CONST
 
static GenderT intToGender (const uint8_t sex) A_CONST
 
static BeingcreateBeing (const BeingId id, const ActorTypeT type, const BeingTypeId subtype, Map *const map)
 
- Static Public Member Functions inherited from ActorSprite
static void load ()
 
static void unload ()
 
- Static Public Member Functions inherited from CompoundSprite
static void setEnableDelay (bool b)
 
- Static Public Member Functions inherited from AttributeListener
static void distributeEvent (const AttributesT id, const int64_t oldVal, const int64_t newVal)
 
static void addListener (AttributeListener *const listener)
 
static void removeListener (const AttributeListener *const listener)
 
- Static Public Member Functions inherited from PlayerDeathListener
static void distributeEvent ()
 
static void addListener (PlayerDeathListener *const listener)
 
static void removeListener (const PlayerDeathListener *const listener)
 

Protected Types

typedef std::pair< std::string, UserColorIdTMessagePair
 
- Protected Types inherited from Being
typedef std::map< int, ParticleInfo * > SpriteParticleInfo
 
typedef SpriteParticleInfo::iterator SpriteParticleInfoIter
 
- Protected Types inherited from ActorSprite
typedef std::list< ActorSpriteListener * > ActorSpriteListeners
 
typedef ActorSpriteListeners::iterator ActorSpriteListenerIterator
 
- Protected Types inherited from CompoundSprite
typedef std::list< CompoundItem * > ImagesCache
 

Protected Member Functions

void updateCoords ()
 
void handleStatusEffect (const StatusEffect *const effect, const int32_t effectId, const Enable newStatus, const IsStart start)
 
void startWalking (const unsigned char dir)
 
void changeEquipmentBeforeAttack (const Being *const target) const
 
void loadHomes ()
 
- Protected Member Functions inherited from Being
void drawPlayerSpriteAt (Graphics *const graphics, const int x, const int y) const
 
void drawOtherSpriteAt (Graphics *const graphics, const int x, const int y) const
 
void drawNpcSpriteAt (Graphics *const graphics, const int x, const int y) const
 
void drawPortalSpriteAt (Graphics *const graphics, const int x, const int y) const
 
void drawMonsterSpriteAt (Graphics *const graphics, const int x, const int y) const
 
void drawHomunculusSpriteAt (Graphics *const graphics, const int x, const int y) const
 
void drawMercenarySpriteAt (Graphics *const graphics, const int x, const int y) const
 
void drawElementalSpriteAt (Graphics *const graphics, const int x, const int y) const
 
void drawCompound (Graphics *const graphics, const int posX, const int posY) const
 
void showName ()
 
void addItemParticles (const int id, const SpriteDisplay &display)
 
void addItemParticlesCards (const int id, const SpriteDisplay &display, const CardsList &cards)
 
void removeAllItemsParticles ()
 
void removeItemParticles (const int id)
 
void createSpeechBubble ()
 
void setDefaultNameColor (const UserColorIdT defaultColor)
 
void updateBadgesCount ()
 
void postInit (const BeingTypeId subType, Map *const map)
 
void updateBadgesPosition ()
 
template<signed char pos, signed char neg>
int getOffset () const
 
int searchSlotValue (const std::vector< int > &slotRemap, const int val) const
 
void addSpiritBalls (const unsigned int balls, const int effectId)
 
void removeSpiritBalls (const unsigned int balls)
 
void dumpSprites () const
 
void drawBeingCursor (Graphics *const graphics, const int offsetX, const int offsetY) const
 
void drawCasting (Graphics *const graphics, const int offsetX, const int offsetY) const
 
void updateBotFollow (int dstX, int dstY, const int divX, const int divY)
 
void moveBotTo (int dstX, int dstY)
 
void updateBotDirection (const int dstX, const int dstY)
 
void botFixOffset (int &dstX, int &dstY) const
 
- Protected Member Functions inherited from ActorSprite
virtual void updateStatusEffect (const int32_t index, const Enable newStatus, const IsStart start)
 
void setupSpriteDisplay (const SpriteDisplay &display, const ForceDisplay forceDisplay, const DisplayTypeT displayType, const std::string &color)
 
- Protected Member Functions inherited from CompoundSprite
void redraw () const
 
void updateImages () const
 
bool updateFromCache () const
 
void initCurrentCacheItem () const
 
- Protected Member Functions inherited from Sprite
 Sprite ()
 
- Protected Member Functions inherited from Actor
 Actor ()
 

Static Protected Member Functions

static void tryMagic (const std::string &spell, const int baseMagic, const int schoolMagic, const int mana)
 
- Static Protected Member Functions inherited from Being
static int getDefaultEffectId (const AttackTypeT &type)
 
static void searchSlotValueItr (std::vector< int >::iterator &it, int &idx, std::vector< int > &slotRemap, const int val)
 
- Static Protected Member Functions inherited from ActorSprite
static void initTargetCursor ()
 
static void cleanupTargetCursors ()
 

Protected Attributes

unsigned int mMoveState
 
int mLastTargetX
 
int mLastTargetY
 
std::map< std::string, VectormHomes
 
BeingmTarget
 
std::string mPlayerFollowed
 
std::string mPlayerImitated
 
int mNextDestX
 
int mNextDestY
 
FloorItemmPickUpTarget
 
int mLastAction
 
std::vector< int32_t > mStatusEffectIcons
 
std::list< MessagePairmMessages
 
int mMessageTime
 
AwayListenermAwayListener
 
OkDialogmAwayDialog
 
int mPingSendTick
 
time_t mPingTime
 
time_t mAfkTime
 
time_t mActivityTime
 
int mNavigateX
 
int mNavigateY
 
BeingId mNavigateId
 
int mCrossX
 
int mCrossY
 
int mOldX
 
int mOldY
 
int mOldTileX
 
int mOldTileY
 
Path mNavigatePath
 
std::string mLastHitFrom
 
std::string mWaitFor
 
time_t mAdvertTime
 
ParticlemTestParticle
 
std::string mTestParticleName
 
time_t mTestParticleTime
 
unsigned long mTestParticleHash
 
int mSyncPlayerMoveDistance
 
int mUnfreezeTime
 
unsigned char mWalkingDir
 
bool mUpdateName
 
bool mBlockAdvert
 
bool mTargetDeadPlayers
 
Keep mServerAttack
 
VisibleName::Type mVisibleNames
 
bool mEnableAdvert
 
bool mTradebot
 
bool mTargetOnlyReachable
 
bool mIsServerBuggy
 
bool mSyncPlayerMove
 
bool mDrawPath
 
bool mAttackMoving
 
bool mAttackNext
 
bool mShowJobExp
 
bool mShowServerPos
 
bool mNextStep
 
bool mGoingToTarget
 
bool mKeepAttacking
 
bool mPathSetByMouse
 
bool mWaitPing
 
bool mShowNavigePath
 
bool mAllowRename
 
bool mFreezed
 
- Protected Attributes inherited from Being
BeingInfomInfo
 
AnimatedSpritemEmotionSprite
 
AnimatedSpritemAnimationEffect
 
CastingEffectmCastingEffect
 
AnimatedSpritemBadges [BadgeIndex::BadgeIndexSize]
 
std::string mSpriteAction
 
std::string mName
 
std::string mExtName
 
std::string mRaceName
 
std::string mPartyName
 
std::string mGuildName
 
std::string mClanName
 
std::string mSpeech
 
FlashTextmDispName
 
const ColormNameColor
 
const ItemInfomEquippedWeapon
 
Path mPath
 
TextmText
 
const ColormTextColor
 
Vector mDest
 
std::vector< BeingSlotmSlots
 
SpriteParticleInfo mSpriteParticles
 
std::map< int, Guild * > mGuilds
 
PartymParty
 
int mActionTime
 
int mEmotionTime
 
int mSpeechTime
 
int mAttackSpeed
 
int mLevel
 
int mGroupId
 
int mAttackRange
 
int mLastAttackX
 
int mLastAttackY
 
int mPreStandTime
 
GenderT mGender
 
BeingActionT mAction
 
BeingTypeId mSubType
 
uint8_t mDirection
 
uint8_t mDirectionDelayed
 
SpriteDirection::Type mSpriteDirection
 
bool mShowName
 
bool mIsGM
 
const ActorTypeT mType
 
SpeechBubblemSpeechBubble
 
int mWalkSpeed
 
int mSpeed
 
std::string mIp
 
int * mSpriteRemap
 
int * mSpriteHide
 
int * mSpriteDraw
 
std::string mComment
 
std::string mBuyBoard
 
std::string mSellBoard
 
BeingmOwner
 
ParticlemSpecialParticle
 
ChatObjectmChat
 
HorseInfomHorseInfo
 
std::vector< AnimatedSprite * > mDownHorseSprites
 
std::vector< AnimatedSprite * > mUpHorseSprites
 
std::vector< Particle * > mSpiritParticles
 
int mX
 
int mY
 
int mCachedX
 
int mCachedY
 
int mSortOffsetY
 
int mPixelOffsetY
 
int mFixedOffsetY
 
uint8_t mOldHeight
 
int mDamageTaken
 
int mHP
 
int mMaxHP
 
int mDistance
 
ReachableT mReachable
 
int mGoodStatus
 
time_t mMoveTime
 
time_t mAttackTime
 
time_t mTalkTime
 
time_t mOtherTime
 
time_t mTestTime
 
int mAttackDelay
 
int mMinHit
 
int mMaxHit
 
int mCriticalHit
 
unsigned int mPvpRank
 
unsigned int mNumber
 
unsigned int mSpiritBalls
 
int mUsageCounter
 
int mKarma
 
int mManner
 
int mAreaSize
 
int mCastEndTime
 
int mLanguageId
 
int mBadgesX
 
int mBadgesY
 
BeingId mCreatorId
 
uint16_t mTeamId
 
uint16_t mLook
 
uint16_t mBadgesCount
 
ItemColor mHairColor
 
bool mErased
 
bool mEnemy
 
bool mGotComment
 
bool mAdvanced
 
bool mShop
 
bool mAway
 
bool mInactive
 
bool mNeedPosUpdate
 
bool mBotAi
 
bool mAllowNpcEquipment
 
- Protected Attributes inherited from ActorSprite
std::set< int32_t > mStatusEffects
 
ParticleVector mStatusParticleEffects
 
ParticleList mChildParticleEffects
 
int mHorseId
 
BeingId mId
 
AnimatedSpritemUsedTargetCursor
 
ActorSpriteListeners mActorSpriteListeners
 
int mCursorPaddingX
 
int mCursorPaddingY
 
bool mMustResetParticles
 
bool mPoison
 
bool mHaveCart
 
bool mTrickDead
 
- Protected Attributes inherited from CompoundSprite
ImagesCache imagesCache
 
CompoundItemmCacheItem
 
ImagemImage
 
ImagemAlphaImage
 
int mOffsetX
 
int mOffsetY
 
int mStartTime
 
int mLastTime
 
int mNextRedrawTime
 
bool mNeedsRedraw
 
bool mEnableAlphaFix
 
bool mDisableAdvBeingCaching
 
bool mDisableBeingCaching
 
- Protected Attributes inherited from Sprite
float mAlpha
 
- Protected Attributes inherited from Actor
MapmMap
 
Vector mPos
 
int mYDiff
 

Additional Inherited Members

- Public Types inherited from CompoundSprite
typedef std::vector< Sprite * >::iterator SpriteIterator
 
typedef std::vector< Sprite * >::const_iterator SpriteConstIterator
 
- Data Fields inherited from Being
NextSoundInfo mNextSound
 
- Data Fields inherited from CompoundSprite
std::vector< Sprite * > mSprites
 
- Data Fields inherited from Actor
int mPixelX
 
int mPixelY
 
- Static Protected Attributes inherited from Being
static time_t mUpdateConfigTime = 0
 
static unsigned int mConfLineLim = 0
 
static int mSpeechType = 0
 
static bool mHighlightMapPortals = false
 
static bool mHighlightMonsterAttackRange = false
 
static bool mLowTraffic = true
 
static bool mDrawHotKeys = true
 
static bool mShowBattleEvents = false
 
static bool mShowMobHP = false
 
static bool mShowOwnHP = false
 
static bool mShowGender = false
 
static bool mShowLevel = false
 
static bool mShowPlayersStatus = false
 
static bool mEnableReorderSprites = true
 
static bool mHideErased = false
 
static Move mMoveNames = Move_false
 
static bool mUseDiagonal = true
 
static BadgeDrawType::Type mShowBadges = BadgeDrawType::Top
 
static int mAwayEffect = -1
 
static VisibleNamePos::Type mVisibleNamePos = VisibleNamePos::Bottom
 
- Static Protected Attributes inherited from ActorSprite
static AnimatedSpritetargetCursor [static_cast< size_t >(TargetCursorType::NUM_TCT)][static_cast< size_t >(TargetCursorSize::NUM_TC)]
 
static bool loaded = false
 
- Static Protected Attributes inherited from CompoundSprite
static bool mEnableDelay = true
 

Detailed Description

The local player character.

Definition at line 49 of file localplayer.h.

Member Typedef Documentation

◆ MessagePair

typedef std::pair<std::string, UserColorIdT> LocalPlayer::MessagePair
protected

Definition at line 477 of file localplayer.h.

Constructor & Destructor Documentation

◆ LocalPlayer()

LocalPlayer::LocalPlayer ( const BeingId  id,
const BeingTypeId  subType 
)

Constructor.

Definition at line 113 of file localplayer.cpp.

114  :
119  mMoveState(0),
120  mLastTargetX(0),
121  mLastTargetY(0),
122  mHomes(),
123  mTarget(nullptr),
124  mPlayerFollowed(),
125  mPlayerImitated(),
126  mNextDestX(0),
127  mNextDestY(0),
128  mPickUpTarget(nullptr),
129  mLastAction(-1),
131  mMessages(),
132  mMessageTime(0),
134  mAwayDialog(nullptr),
135  mPingSendTick(0),
136  mPingTime(0),
137  mAfkTime(0),
138  mActivityTime(0),
139  mNavigateX(0),
140  mNavigateY(0),
142  mCrossX(0),
143  mCrossY(0),
144  mOldX(0),
145  mOldY(0),
146  mOldTileX(0),
147  mOldTileY(0),
148  mNavigatePath(),
149  mLastHitFrom(),
150  mWaitFor(),
151  mAdvertTime(0),
152  mTestParticle(nullptr),
155  mTestParticleHash(0L),
156  mSyncPlayerMoveDistance(config.getIntValue("syncPlayerMoveDistance")),
157  mUnfreezeTime(0),
158  mWalkingDir(0),
159  mUpdateName(true),
160  mBlockAdvert(false),
161  mTargetDeadPlayers(config.getBoolValue("targetDeadPlayers")),
162  mServerAttack(fromBool(config.getBoolValue("serverAttack"), Keep)),
163  mVisibleNames(static_cast<VisibleName::Type>(
164  config.getIntValue("visiblenames"))),
165  mEnableAdvert(config.getBoolValue("enableAdvert")),
166  mTradebot(config.getBoolValue("tradebot")),
167  mTargetOnlyReachable(config.getBoolValue("targetOnlyReachable")),
168  mIsServerBuggy(serverConfig.getValueBool("enableBuggyServers", true)),
169  mSyncPlayerMove(config.getBoolValue("syncPlayerMove")),
170  mDrawPath(config.getBoolValue("drawPath")),
171  mAttackMoving(config.getBoolValue("attackMoving")),
172  mAttackNext(config.getBoolValue("attackNext")),
173  mShowJobExp(config.getBoolValue("showJobExp")),
174  mShowServerPos(config.getBoolValue("showserverpos")),
175  mNextStep(false),
176  mGoingToTarget(false),
177  mKeepAttacking(false),
178  mPathSetByMouse(false),
179  mWaitPing(false),
180  mShowNavigePath(false),
181  mAllowRename(false),
182  mFreezed(false)
183 {
184  logger->log1("LocalPlayer::LocalPlayer");
185 
186 #ifdef TMWA_SUPPORT
188  {
190  config.getIntValue("syncPlayerMoveDistanceLegacy");
191  }
192 #endif
193 
194  postInit(subType, nullptr);
195  mAttackRange = 0;
196  mLevel = 1;
197  mAdvanced = true;
198  mTextColor = &theme->getColor(ThemeColorId::PLAYER, 255);
199  if (userPalette != nullptr)
201  else
202  mNameColor = nullptr;
203 
205  getWalkSpeed(),
206  Notify_true);
208  0,
209  Notify_true);
210 
211  loadHomes();
212 
213  config.addListener("showownname", this);
214  config.addListener("targetDeadPlayers", this);
215  serverConfig.addListener("enableBuggyServers", this);
216  config.addListener("syncPlayerMove", this);
217  config.addListener("syncPlayerMoveDistance", this);
218 #ifdef TMWA_SUPPORT
219  config.addListener("syncPlayerMoveDistanceLegacy", this);
220 #endif
221  config.addListener("drawPath", this);
222  config.addListener("serverAttack", this);
223  config.addListener("attackMoving", this);
224  config.addListener("attackNext", this);
225  config.addListener("showJobExp", this);
226  config.addListener("enableAdvert", this);
227  config.addListener("tradebot", this);
228  config.addListener("targetOnlyReachable", this);
229  config.addListener("showserverpos", this);
230  config.addListener("visiblenames", this);
231  setShowName(config.getBoolValue("showownname"));
232 }

References Configuration::addListener(), config, Configuration::getBoolValue(), Theme::getColor(), UserPalette::getColor(), Configuration::getIntValue(), Net::getNetworkType(), Being::getWalkSpeed(), loadHomes(), Logger::log1(), logger, Being::mAdvanced, Being::mAttackRange, Being::mLevel, Being::mNameColor, mSyncPlayerMoveDistance, Being::mTextColor, Notify_true, Attributes::PLAYER_WALK_SPEED, Being::postInit(), UserColorId::SELF, serverConfig, Being::setShowName(), PlayerInfo::setStatBase(), PlayerInfo::setStatMod(), theme, ServerType::TMWATHENA, and userPalette.

◆ ~LocalPlayer()

LocalPlayer::~LocalPlayer ( )

Destructor.

Definition at line 234 of file localplayer.cpp.

235 {
236  logger->log1("LocalPlayer::~LocalPlayer");
237 
238  config.removeListeners(this);
239  serverConfig.removeListener("enableBuggyServers", this);
240 
241  navigateClean();
242  mCrossX = 0;
243  mCrossY = 0;
244 
246 
247  if (mAwayDialog != nullptr)
248  {
251  }
253 }

References config, delete2, Logger::log1(), logger, mAwayDialog, mAwayListener, mCrossX, mCrossY, navigateClean(), Configuration::removeListener(), Configuration::removeListeners(), serverConfig, soundManager, updateNavigateList(), and SoundManager::volumeRestore().

Member Function Documentation

◆ actorSpriteDestroyed()

void LocalPlayer::actorSpriteDestroyed ( const ActorSprite actorSprite)
virtual

Called when an ActorSprite has been destroyed.

Parameters
actorSpritethe ActorSprite being destroyed.

Implements ActorSpriteListener.

Definition at line 555 of file localplayer.cpp.

556 {
557  if (mPickUpTarget == &actorSprite)
558  mPickUpTarget = nullptr;
559 }

References mPickUpTarget.

◆ addHomunXpMessage()

void LocalPlayer::addHomunXpMessage ( const int  change)

Definition at line 1255 of file localplayer.cpp.

1256 {
1257  if (change != 0 && mMessages.size() < 20)
1258  {
1259  addMessageToQueue(strprintf("%s %d %s",
1260  // TRANSLATORS: get homunculus xp message
1261  _("Homun"),
1262  change,
1263  // TRANSLATORS: get xp message
1264  _("xp")),
1266  }
1267 }

References _, addMessageToQueue(), UserColorId::EXP_INFO, mMessages, and strprintf().

Referenced by EAthena::HomunculusRecv::processHomunculusExp().

◆ addHpMessage()

void LocalPlayer::addHpMessage ( const int  change)

Definition at line 1269 of file localplayer.cpp.

1270 {
1271  if (change != 0 && mMessages.size() < 20)
1272  {
1273  // TRANSLATORS: get hp message
1274  addMessageToQueue(strprintf("%d %s", change, _("hp")),
1276  }
1277 }

References _, addMessageToQueue(), UserColorId::EXP_INFO, mMessages, and strprintf().

Referenced by EAthena::PlayerRecv::processPlayerHeal().

◆ addJobMessage()

void LocalPlayer::addJobMessage ( const int64_t  change)

Definition at line 1203 of file localplayer.cpp.

1204 {
1205  if (change != 0 && mMessages.size() < 20)
1206  {
1207  const std::string xpStr = toString(CAST_U64(change));
1208  if (!mMessages.empty())
1209  {
1210  MessagePair pair = mMessages.back();
1211  // TRANSLATORS: this is normal experience
1212  if (pair.first.find(strprintf(" %s", _("xp"))) ==
1213  // TRANSLATORS: this is normal experience
1214  pair.first.size() - strlen(_("xp")) - 1)
1215  {
1216  mMessages.pop_back();
1217  pair.first.append(strprintf(", %s %s",
1218  xpStr.c_str(),
1219  // TRANSLATORS: this is job experience
1220  _("job")));
1221  mMessages.push_back(pair);
1222  }
1223  else
1224  {
1225  addMessageToQueue(strprintf("%s %s",
1226  xpStr.c_str(),
1227  // TRANSLATORS: this is job experience
1228  _("job")),
1230  }
1231  }
1232  else
1233  {
1234  addMessageToQueue(strprintf("%s %s",
1235  xpStr.c_str(),
1236  // TRANSLATORS: this is job experience
1237  _("job")),
1239  }
1240  }
1241 }

References _, addMessageToQueue(), CAST_U64, UserColorId::EXP_INFO, mMessages, strprintf(), and Catch::toString().

Referenced by attributeChanged(), EAthena::PlayerRecv::processPlayerGetExp(), and EAthena::PlayerRecv::processPlayerGetExp2().

◆ addMessageToQueue()

void LocalPlayer::addMessageToQueue ( const std::string &  message,
const UserColorIdT  color 
)

Definition at line 1115 of file localplayer.cpp.

1117 {
1118  if (mMessages.size() < 20)
1119  mMessages.push_back(MessagePair(message, color));
1120 }

References mMessages.

Referenced by addHomunXpMessage(), addHpMessage(), addJobMessage(), addSpMessage(), addXpMessage(), and pickedUp().

◆ addSpMessage()

void LocalPlayer::addSpMessage ( const int  change)

Definition at line 1279 of file localplayer.cpp.

1280 {
1281  if (change != 0 && mMessages.size() < 20)
1282  {
1283  // TRANSLATORS: get hp message
1284  addMessageToQueue(strprintf("%d %s", change, _("mana")),
1286  }
1287 }

References _, addMessageToQueue(), UserColorId::EXP_INFO, mMessages, and strprintf().

Referenced by EAthena::PlayerRecv::processPlayerHeal().

◆ addXpMessage()

void LocalPlayer::addXpMessage ( const int64_t  change)

Definition at line 1243 of file localplayer.cpp.

1244 {
1245  if (change != 0 && mMessages.size() < 20)
1246  {
1247  addMessageToQueue(strprintf("%s %s",
1248  toString(CAST_U64(change)).c_str(),
1249  // TRANSLATORS: get xp message
1250  _("xp")),
1252  }
1253 }

References _, addMessageToQueue(), CAST_U64, UserColorId::EXP_INFO, mMessages, strprintf(), and Catch::toString().

Referenced by attributeChanged(), EAthena::PlayerRecv::processPlayerGetExp(), and EAthena::PlayerRecv::processPlayerGetExp2().

◆ afkRespond()

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

Definition at line 2081 of file localplayer.cpp.

2082 {
2083  if (settings.awayMode)
2084  {
2085  const time_t time = cur_time;
2086  if (mAfkTime == 0 || time < mAfkTime
2087  || time - mAfkTime > awayLimitTimer)
2088  {
2089  std::string str(serverConfig.getValue("afkMessage",
2090  "I am away from keyboard."));
2091  if (str.find("'NAME'") != std::string::npos)
2092  replaceAll(str, "'NAME'", nick);
2093 
2094  std::string msg("*AFK*: " + str);
2095 
2096  if (config.getIntValue("afkFormat") == 1)
2097  msg = "*" + msg + "*";
2098 
2099  if (tab == nullptr)
2100  {
2101  chatHandler->privateMessage(nick, msg);
2102  if (localChatTab != nullptr)
2103  {
2104  localChatTab->chatLog(std::string(mName).append(
2105  " : ").append(msg),
2109  }
2110  }
2111  else
2112  {
2113  if (tab->getNoAway())
2114  return;
2115  chatHandler->privateMessage(nick, msg);
2116  tab->chatLog(mName, msg);
2117  }
2118  mAfkTime = time;
2119  }
2120  }
2121 }

References ChatMsgType::ACT_WHISPER, awayLimitTimer, Settings::awayMode, chatHandler, ChatTab::chatLog(), config, cur_time, Configuration::getIntValue(), ChatTab::getNoAway(), ConfigurationObject::getValue(), IgnoreRecord_false, localChatTab, mAfkTime, Being::mName, Actions::msg(), Net::ChatHandler::privateMessage(), replaceAll(), serverConfig, settings, and TryRemoveColors_true.

Referenced by ChatWindow::addWhisper().

◆ allowAction()

bool LocalPlayer::allowAction ( )

Definition at line 2600 of file localplayer.cpp.

2601 {
2602  if (mIsServerBuggy)
2603  {
2604  if (mLastAction != -1)
2605  return false;
2607  }
2608  return true;
2609 }

References mIsServerBuggy, mLastAction, and tick_time.

Referenced by CrazyMoves::crazyMove9().

◆ attack()

void LocalPlayer::attack ( Being *const  target,
const bool  keep,
const bool  dontChangeEquipment 
)

Definition at line 799 of file localplayer.cpp.

802 {
803  mKeepAttacking = keep;
804 
805  if ((target == nullptr) || target->getType() == ActorType::Npc)
806  return;
807 
808  if (mTarget != target)
809  setTarget(target);
810 
811  // Must be standing or sitting or casting to attack
812  if (mAction != BeingAction::STAND &&
815  {
816  return;
817  }
818 
819 #ifdef TMWA_SUPPORT
820  const int dist_x = target->mX - mX;
821  const int dist_y = target->mY - mY;
822 
824  {
825  if (abs(dist_y) >= abs(dist_x))
826  {
827  if (dist_y > 0)
829  else
831  }
832  else
833  {
834  if (dist_x > 0)
836  else
838  }
839  }
840 #endif // TMWA_SUPPORT
841 
843 
844  if (target->getType() != ActorType::Player
845  || checAttackPermissions(target))
846  {
848 
850  return;
851 
852  if (!dontChangeEquipment)
854 
855  const BeingId targetId = target->getId();
856  playerHandler->attack(targetId, mServerAttack);
858  }
859 
860  if (!keep)
861  stopAttack(false);
862 }

References BeingAction::ATTACK, Net::PlayerHandler::attack(), BeingAction::CAST, changeEquipmentBeforeAttack(), checAttackPermissions(), BeingDirection::DOWN, ActorSprite::getId(), Net::getNetworkType(), Being::getType(), BeingDirection::LEFT, PacketLimiter::limitPackets(), Being::mAction, Being::mActionTime, mKeepAttacking, mServerAttack, mTarget, Being::mX, Being::mY, ActorType::Npc, PacketType::PACKET_ATTACK, ActorType::Player, playerHandler, BeingDirection::RIGHT, setAction(), Being::setDirection(), setTarget(), BeingAction::SIT, BeingAction::STAND, stopAttack(), tick_time, ServerType::TMWATHENA, BeingDirection::UP, and PlayerInfo::updateAttackAi().

Referenced by attack2(), logic(), and nextTile().

◆ attack2()

void LocalPlayer::attack2 ( Being *const  target,
const bool  keep,
const bool  dontChangeEquipment 
)

Definition at line 2326 of file localplayer.cpp.

2329 {
2330  if (!dontChangeEquipment && (target != nullptr))
2332 
2333  const bool broken = (Net::getNetworkType() == ServerType::TMWATHENA);
2334 
2335  // probably need cache getPathLength(target)
2336  if ((target == nullptr ||
2337  settings.attackType == 0 ||
2338  settings.attackType == 3) ||
2339  (withinAttackRange(target, broken, broken ? 1 : 0) &&
2340  getPathLength(target) <= getAttackRange2()))
2341  {
2342  attack(target, keep, false);
2343  if (settings.attackType == 2)
2344  {
2345  if (target == nullptr)
2346  {
2347  if (pickUpItems(0))
2348  return;
2349  }
2350  else
2351  {
2352  pickUpItems(3);
2353  }
2354  }
2355  }
2356  else if (mPickUpTarget == nullptr)
2357  {
2358  if (settings.attackType == 2)
2359  {
2360  if (pickUpItems(0))
2361  return;
2362  }
2363  setTarget(target);
2364  if (target->getType() != ActorType::Npc)
2365  {
2366  mKeepAttacking = true;
2367  moveToTarget(-1);
2368  }
2369  }
2370 }

References attack(), Settings::attackType, changeEquipmentBeforeAttack(), getAttackRange2(), Net::getNetworkType(), getPathLength(), Being::getType(), mKeepAttacking, moveToTarget(), mPickUpTarget, ActorType::Npc, pickUpItems(), setTarget(), settings, ServerType::TMWATHENA, and withinAttackRange().

◆ attributeChanged()

void LocalPlayer::attributeChanged ( const AttributesT  id,
const int64_t  oldVal,
const int64_t  newVal 
)
virtual

Implements AttributeListener.

Definition at line 1289 of file localplayer.cpp.

1292 {
1293  PRAGMA45(GCC diagnostic push)
1294  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
1295  switch (id)
1296  {
1298  {
1300  break;
1301  if (oldVal > newVal)
1302  break;
1303 
1304  const int change = CAST_S32(newVal - oldVal);
1305  addXpMessage(change);
1306  break;
1307  }
1309  mLevel = CAST_S32(newVal);
1310  break;
1311  case Attributes::PLAYER_HP:
1312  if (oldVal != 0 && newVal == 0)
1314  break;
1316  {
1317  if (!mShowJobExp ||
1319  {
1320  return;
1321  }
1322  if (oldVal > newVal ||
1325  {
1326  return;
1327  }
1328  const int32_t change = CAST_S32(newVal - oldVal);
1329  addJobMessage(change);
1330  break;
1331  }
1332  default:
1333  break;
1334  }
1335  PRAGMA45(GCC diagnostic pop)
1336 }

References addJobMessage(), addXpMessage(), CAST_S32, PlayerDeathListener::distributeEvent(), PlayerInfo::getAttribute(), Net::getNetworkType(), Being::mLevel, mShowJobExp, Attributes::PLAYER_BASE_LEVEL, Attributes::PLAYER_EXP, Attributes::PLAYER_HP, Attributes::PLAYER_JOB_EXP, Attributes::PLAYER_JOB_EXP_NEEDED, PRAGMA45(), and ServerType::TMWATHENA.

◆ cancelFollow()

void LocalPlayer::cancelFollow ( )

Stop following a player.

Definition at line 2404 of file localplayer.cpp.

2405 {
2406  if (!mPlayerFollowed.empty())
2407  {
2408  // TRANSLATORS: cancel follow message
2409  debugMsg(_("Follow canceled"))
2410  }
2411  if (!mPlayerImitated.empty())
2412  {
2413  // TRANSLATORS: cancel follow message
2414  debugMsg(_("Imitation canceled"))
2415  }
2416  mPlayerFollowed.clear();
2417  mPlayerImitated.clear();
2418 }

References _, debugMsg, mPlayerFollowed, and mPlayerImitated.

Referenced by GameModifiers::changeAwayMode(), and Game::handleMove().

◆ canMove()

bool LocalPlayer::canMove ( ) const

Definition at line 2918 of file localplayer.cpp.

2919 {
2920  return !mFreezed &&
2924 }

References BeingAction::DEAD, Net::ServerFeatures::haveMoveWhileSit(), Being::mAction, mFreezed, serverFeatures, and BeingAction::SIT.

Referenced by Game::handleMove().

◆ changeEquipmentBeforeAttack()

void LocalPlayer::changeEquipmentBeforeAttack ( const Being *const  target) const
protected

Definition at line 1461 of file localplayer.cpp.

1462 {
1463  if (settings.attackWeaponType == 1
1464  || (target == nullptr)
1465  || (PlayerInfo::getInventory() == nullptr))
1466  {
1467  return;
1468  }
1469 
1470  bool allowSword = false;
1471  const int dx = target->mX - mX;
1472  const int dy = target->mY - mY;
1473  const Item *item = nullptr;
1474 
1475  if (dx * dx + dy * dy > 80)
1476  return;
1477 
1478  if (dx * dx + dy * dy < 8)
1479  allowSword = true;
1480 
1481  const Inventory *const inv = PlayerInfo::getInventory();
1482  if (inv == nullptr)
1483  return;
1484 
1485  // if attack distance for sword
1486  if (allowSword)
1487  {
1488  // searching swords
1489  const WeaponsInfos &swords = WeaponsDB::getSwords();
1490  FOR_EACH (WeaponsInfosIter, it, swords)
1491  {
1492  item = inv->findItem(*it, ItemColor_zero);
1493  if (item != nullptr)
1494  break;
1495  }
1496 
1497  // no swords
1498  if (item == nullptr)
1499  return;
1500 
1501  // if sword not equiped
1502  if (item->isEquipped() == Equipped_false)
1504 
1505  // if need equip shield too
1506  if (settings.attackWeaponType == 3)
1507  {
1508  // searching shield
1509  const WeaponsInfos &shields = WeaponsDB::getShields();
1510  FOR_EACH (WeaponsInfosIter, it, shields)
1511  {
1512  item = inv->findItem(*it, ItemColor_zero);
1513  if (item != nullptr)
1514  break;
1515  }
1516  if ((item != nullptr) && item->isEquipped() == Equipped_false)
1518  }
1519  }
1520  // big distance. allowed only bow
1521  else
1522  {
1523  // searching bow
1524  const WeaponsInfos &bows = WeaponsDB::getBows();
1525  FOR_EACH (WeaponsInfosIter, it, bows)
1526  {
1527  item = inv->findItem(*it, ItemColor_zero);
1528  if (item != nullptr)
1529  break;
1530  }
1531 
1532  // no bow
1533  if (item == nullptr)
1534  return;
1535 
1536  if (item->isEquipped() == Equipped_false)
1538  }
1539 }

References Settings::attackWeaponType, PlayerInfo::equipItem(), Equipped_false, Inventory::findItem(), FOR_EACH, WeaponsDB::getBows(), PlayerInfo::getInventory(), WeaponsDB::getShields(), WeaponsDB::getSwords(), Item::isEquipped(), ItemColor_zero, Being::mX, Being::mY, settings, and Sfx_true.

Referenced by attack(), and attack2().

◆ checAttackPermissions()

bool LocalPlayer::checAttackPermissions ( const Being *const  target)
static

Definition at line 2846 of file localplayer.cpp.

2847 {
2848  if (target == nullptr)
2849  return false;
2850 
2851  switch (settings.pvpAttackType)
2852  {
2853  case 0:
2854  return true;
2855  case 1:
2856  return !(playerRelations.getRelation(target->mName)
2857  == Relation::FRIEND);
2858  case 2:
2859  return playerRelations.checkBadRelation(target->mName);
2860  default:
2861  case 3:
2862  return false;
2863  }
2864 }

References PlayerRelationsManager::checkBadRelation(), Relation::FRIEND, PlayerRelationsManager::getRelation(), Being::mName, playerRelations, Settings::pvpAttackType, and settings.

Referenced by attack(), and ActorManager::findNearestPvpPlayer().

◆ checkNewName()

void LocalPlayer::checkNewName ( Being *const  being)

Definition at line 2781 of file localplayer.cpp.

2782 {
2783  if (being == nullptr)
2784  return;
2785 
2786  const std::string &nick = being->mName;
2787  if (being->getType() == ActorType::Player)
2788  {
2789  const Guild *const guild = getGuild();
2790  if (guild != nullptr)
2791  {
2792  const GuildMember *const gm = guild->getMember(nick);
2793  if (gm != nullptr)
2794  {
2795  const int level = gm->getLevel();
2796  if (level > 1 && being->getLevel() != level)
2797  {
2798  being->setLevel(level);
2799  being->updateName();
2800  }
2801  }
2802  }
2803  if (chatWindow != nullptr)
2804  {
2805  WhisperTab *const tab = chatWindow->getWhisperTab(nick);
2806  if (tab != nullptr)
2807  tab->setWhisperTabColors();
2808  }
2809  }
2810 
2811  if (!mWaitFor.empty() && mWaitFor == nick)
2812  {
2813  // TRANSLATORS: wait player/monster message
2814  debugMsg(strprintf(_("You see %s"), mWaitFor.c_str()))
2815  soundManager.playGuiSound(SOUND_INFO);
2816  mWaitFor.clear();
2817  }
2818 }

References _, chatWindow, debugMsg, Being::getGuild(), Being::getLevel(), Being::getType(), ChatWindow::getWhisperTab(), Actions::gm(), guild, Being::mName, mWaitFor, ActorType::Player, SoundManager::playGuiSound(), Being::setLevel(), WhisperTab::setWhisperTabColors(), SOUND_INFO, soundManager, strprintf(), and Being::updateName().

Referenced by ActorManager::createBeing(), TmwAthena::BeingRecv::processBeingMove(), EAthena::BeingRecv::processBeingMove(), EAthena::BeingRecv::processBeingSpawn(), TmwAthena::BeingRecv::processBeingVisible(), EAthena::BeingRecv::processBeingVisible(), Ea::BeingRecv::processNameResponse(), EAthena::BeingRecv::processNameResponse2(), and EAthena::BeingRecv::processNameResponseTitle().

◆ emote()

bool LocalPlayer::emote ( const uint8_t  emotion)
static

◆ failMove()

void LocalPlayer::failMove ( const int  x,
const int  y 
)

Definition at line 2770 of file localplayer.cpp.

2772 {
2773  fixPos();
2774 }

References fixPos().

Referenced by EAthena::PlayerRecv::processWalkError().

◆ fixAttackTarget()

void LocalPlayer::fixAttackTarget ( )

Definition at line 2715 of file localplayer.cpp.

2716 {
2717  if ((mMap == nullptr) || (mTarget == nullptr))
2718  return;
2719 
2720  if (settings.moveToTargetType == 11 || (settings.attackType == 0U)
2721  || !config.getBoolValue("autofixPos"))
2722  {
2723  return;
2724  }
2725 
2726  const Path debugPath = mMap->findPath(
2727  (mPixelX - mapTileSize / 2) / mapTileSize,
2729  mTarget->mX,
2730  mTarget->mY,
2731  getBlockWalkMask(),
2732  0);
2733 
2734  if (!debugPath.empty())
2735  {
2736  const Path::const_iterator i = debugPath.begin();
2737  setDestination((*i).x, (*i).y);
2738  }
2739 }

References Settings::attackType, config, Map::findPath(), getBlockWalkMask(), Configuration::getBoolValue(), mapTileSize, Actor::mMap, Settings::moveToTargetType, Actor::mPixelX, Actor::mPixelY, mTarget, Being::mX, Being::mY, setDestination(), and settings.

Referenced by Ea::BeingRecv::processPlayerMoveToAttack().

◆ fixPos()

void LocalPlayer::fixPos ( )

Definition at line 2611 of file localplayer.cpp.

2612 {
2613  if ((mCrossX == 0) && (mCrossY == 0))
2614  return;
2615 
2616  const int dx = (mX >= mCrossX) ? mX - mCrossX : mCrossX - mX;
2617  const int dy = (mY >= mCrossY) ? mY - mCrossY : mCrossY - mY;
2618  const int dist = dx > dy ? dx : dy;
2619  const time_t time = cur_time;
2620 
2621 #ifdef TMWA_SUPPORT
2622  int maxDist;
2623  if (mSyncPlayerMove)
2624  {
2625  maxDist = mSyncPlayerMoveDistance;
2626  }
2627  else
2628  {
2630  maxDist = 30;
2631  else
2632  maxDist = 10;
2633  }
2634 #else
2635  const int maxDist = mSyncPlayerMove ? mSyncPlayerMoveDistance : 10;
2636 #endif
2637 
2638  if (dist > maxDist)
2639  {
2640  mActivityTime = time;
2641 #ifdef ENABLEDEBUGLOG
2642  logger->dlog(strprintf("Fix position from (%d,%d) to (%d,%d)",
2643  mX, mY,
2644  mCrossX, mCrossY));
2645 #endif
2647 /*
2648  if (mNavigateX != 0 || mNavigateY != 0)
2649  {
2650 #ifdef ENABLEDEBUGLOG
2651  logger->dlog(strprintf("Renavigate to (%d,%d)",
2652  mNavigateX, mNavigateY));
2653 #endif
2654  navigateTo(mNavigateX, mNavigateY);
2655  }
2656 */
2657 // alternative way to fix, move to real position
2658 // setDestination(mCrossX, mCrossY);
2659  }
2660 }

References cur_time, Logger::dlog(), Net::getNetworkType(), logger, mActivityTime, mCrossX, mCrossY, mSyncPlayerMove, mSyncPlayerMoveDistance, Being::mX, Being::mY, setTileCoords(), strprintf(), and ServerType::TMWATHENA.

Referenced by failMove(), nextTile(), setRealPos(), and updateCoords().

◆ followMoveTo() [1/2]

void LocalPlayer::followMoveTo ( const Being *const  being,
const int  x,
const int  y 
)

Definition at line 2531 of file localplayer.cpp.

2533 {
2534  if ((being != nullptr) &&
2535  !mPlayerFollowed.empty() &&
2536  being->mName == mPlayerFollowed)
2537  {
2538  mPickUpTarget = nullptr;
2539  navigateTo(x, y);
2540  }
2541 }

References Being::mName, mPickUpTarget, mPlayerFollowed, navigateTo(), x, and y.

Referenced by EAthena::BeingRecv::processBeingMove(), EAthena::BeingRecv::processBeingMove2(), Ea::BeingRecv::processBeingRemove(), and TmwAthena::BeingRecv::processPlayerMove().

◆ followMoveTo() [2/2]

void LocalPlayer::followMoveTo ( const Being *const  being,
const int  x1,
const int  y1,
const int  x2,
const int  y2 
)

Definition at line 2543 of file localplayer.cpp.

2546 {
2547  if (being == nullptr)
2548  return;
2549 
2550  mPickUpTarget = nullptr;
2551  if (!mPlayerFollowed.empty() &&
2552  being->mName == mPlayerFollowed)
2553  {
2554  switch (settings.followMode)
2555  {
2556  case 0:
2557  navigateTo(x1, y1);
2558  setNextDest(x2, y2);
2559  break;
2560  case 1:
2561  if (x1 != x2 || y1 != y2)
2562  {
2563  navigateTo(mX + x2 - x1, mY + y2 - y1);
2564  setNextDest(mX + x2 - x1, mY + y2 - y1);
2565  }
2566  break;
2567  case 2:
2568  if (x1 != x2 || y1 != y2)
2569  {
2570  navigateTo(mX + x1 - x2, mY + y1 - y2);
2571  setNextDest(mX + x1 - x2, mY + y1 - y2);
2572  }
2573  break;
2574  case 3:
2575  if (mTarget == nullptr ||
2577  {
2578  if (actorManager != nullptr)
2579  {
2580  Being *const b = actorManager->findBeingByName(
2582  setTarget(b);
2583  }
2584  }
2585  moveToTarget(-1);
2586  setNextDest(x2, y2);
2587  break;
2588  default:
2589  break;
2590  }
2591  }
2592 }

References actorManager, ActorManager::findBeingByName(), Settings::followMode, Being::mName, moveToTarget(), mPickUpTarget, mPlayerFollowed, mTarget, Being::mX, Being::mY, navigateTo(), ActorType::Player, setNextDest(), setTarget(), and settings.

◆ freezeMoving()

void LocalPlayer::freezeMoving ( const int  timeWaitTicks)

Definition at line 2926 of file localplayer.cpp.

2927 {
2928  if (timeWaitTicks <= 0)
2929  return;
2930  const int nextTime = tick_time + timeWaitTicks;
2931  if (mUnfreezeTime < nextTime)
2932  mUnfreezeTime = nextTime;
2933  if (mUnfreezeTime > 0)
2934  mFreezed = true;
2935 }

References mFreezed, mUnfreezeTime, and tick_time.

Referenced by EAthena::BeingRecv::processSkillCastingContinue().

◆ getAttackRange()

int LocalPlayer::getAttackRange ( ) const

Gets the attack range.

Definition at line 1004 of file localplayer.cpp.

1005 {
1006  if (mAttackRange > -1)
1007  {
1008  return mAttackRange;
1009  }
1010 
1011  const Item *const weapon = PlayerInfo::getEquipment(
1013  if (weapon != nullptr)
1014  {
1015  const ItemInfo &info = weapon->getInfo();
1016  return info.getAttackRange();
1017  }
1018  return 48; // unarmed range
1019 }

References EquipSlot::FIGHT1_SLOT, PlayerInfo::getEquipment(), Item::getInfo(), Actions::info(), and Being::mAttackRange.

Referenced by MapLayer::drawFringe(), ActorManager::findNearestLivingBeing(), getAttackRange2(), logic(), and withinAttackRange().

◆ getAttackRange2()

int LocalPlayer::getAttackRange2 ( ) const

Definition at line 2318 of file localplayer.cpp.

2319 {
2320  int range = getAttackRange();
2321  if (range == 1)
2322  range = 2;
2323  return range;
2324 }

References getAttackRange().

Referenced by attack2().

◆ getAwayListener()

AwayListener* LocalPlayer::getAwayListener ( ) const
inline

Definition at line 418 of file localplayer.h.

419  { return mAwayListener; }

References mAwayListener.

Referenced by GameModifiers::changeAwayMode().

◆ getBlockWalkMask()

unsigned char LocalPlayer::getBlockWalkMask ( ) const
virtual

Gets the way the object is blocked by other objects.

Reimplemented from Being.

Definition at line 2820 of file localplayer.cpp.

2821 {
2822  // for now blocking all types of collisions
2823  return BlockMask::WALL |
2824  BlockMask::AIR |
2827 }

References BlockMask::AIR, BlockMask::PLAYERWALL, BlockMask::WALL, and BlockMask::WATER.

Referenced by CrazyMoves::crazyMove8(), fixAttackTarget(), getPathLength(), isReachable(), moveToTarget(), navigateTo(), pickUp(), and startWalking().

◆ getCheckNameSetting()

bool LocalPlayer::getCheckNameSetting ( ) const
inline

Gets if the engine has to check if the Player Name is to be displayed.

Definition at line 355 of file localplayer.h.

356  { return mUpdateName; }

References mUpdateName.

◆ getFollow()

const std::string& LocalPlayer::getFollow ( ) const
inline

Get the playername followed by the current player.

Definition at line 335 of file localplayer.h.

336  { return mPlayerFollowed; }

References mPlayerFollowed.

Referenced by InputManager::updateConditionMask().

◆ getHalfAway()

bool LocalPlayer::getHalfAway ( ) const
inline

Definition at line 238 of file localplayer.h.

239  { return mInactive; }

References Being::mInactive.

Referenced by Game::adjustPerfomance().

◆ getImitate()

const std::string& LocalPlayer::getImitate ( ) const
inline

Get the playername imitated by the current player.

Definition at line 341 of file localplayer.h.

342  { return mPlayerImitated; }

References mPlayerImitated.

Referenced by imitateEmote().

◆ getLastAttackX()

int LocalPlayer::getLastAttackX ( ) const
inlinevirtual

Reimplemented from Being.

Definition at line 400 of file localplayer.h.

401  { return mTarget != nullptr ? mTarget->mX : mLastAttackX; }

References Being::mLastAttackX, mTarget, and Being::mX.

◆ getLastAttackY()

int LocalPlayer::getLastAttackY ( ) const
inlinevirtual

Reimplemented from Being.

Definition at line 403 of file localplayer.h.

404  { return mTarget != nullptr ? mTarget->mY : mLastAttackY; }

References Being::mLastAttackY, mTarget, and Being::mY.

◆ getLevel()

int LocalPlayer::getLevel ( ) const
virtual

Reimplemented from Being.

Definition at line 2746 of file localplayer.cpp.

References PlayerInfo::getAttribute(), and Attributes::PLAYER_BASE_LEVEL.

Referenced by KillStats::gainXp(), and KillStats::KillStats().

◆ getMoveState()

unsigned int LocalPlayer::getMoveState ( ) const
inline

Definition at line 192 of file localplayer.h.

193  { return mMoveState; }

References mMoveState.

Referenced by specialMove().

◆ getNextDestX()

int LocalPlayer::getNextDestX ( ) const
inline

Definition at line 313 of file localplayer.h.

314  { return mNextDestX; }

References mNextDestX.

Referenced by Ea::BeingRecv::processBeingRemove().

◆ getNextDestY()

int LocalPlayer::getNextDestY ( ) const
inline

Definition at line 316 of file localplayer.h.

317  { return mNextDestY; }

References mNextDestY.

Referenced by Ea::BeingRecv::processBeingRemove().

◆ getNextWalkPosition()

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

Compute the next pathnode location when walking using keyboard. used by nextTile().

◆ getPathLength()

int LocalPlayer::getPathLength ( const Being *const  being) const

Definition at line 2283 of file localplayer.cpp.

2284 {
2285  if ((mMap == nullptr) || (being == nullptr))
2286  return 0;
2287 
2288  if (being->mX == mX && being->mY == mY)
2289  return 0;
2290 
2291  if (being->mX - 1 <= mX &&
2292  being->mX + 1 >= mX &&
2293  being->mY - 1 <= mY &&
2294  being->mY + 1 >= mY)
2295  {
2296  return 1;
2297  }
2298 
2300  {
2301  const Path debugPath = mMap->findPath(
2302  (mPixelX - mapTileSize / 2) / mapTileSize,
2304  being->mX,
2305  being->mY,
2306  getBlockWalkMask(),
2307  0);
2308  return CAST_S32(debugPath.size());
2309  }
2310 
2311  const int dx = CAST_S32(abs(being->mX - mX));
2312  const int dy = CAST_S32(abs(being->mY - mY));
2313  if (dx > dy)
2314  return dx;
2315  return dy;
2316 }

References CAST_S32, Map::findPath(), getBlockWalkMask(), mapTileSize, Actor::mMap, Actor::mPixelX, Actor::mPixelY, mTargetOnlyReachable, Being::mX, and Being::mY.

Referenced by attack2().

◆ getPickUpTarget()

const FloorItem* LocalPlayer::getPickUpTarget ( ) const
inline

Definition at line 321 of file localplayer.h.

322  { return mPickUpTarget; }

References mPickUpTarget.

Referenced by ActorManager::logic().

◆ getPingTime()

std::string LocalPlayer::getPingTime ( ) const

Definition at line 1996 of file localplayer.cpp.

1997 {
1998  std::string str;
1999  if (!mWaitPing)
2000  {
2001  if (mPingTime == 0)
2002  str = "?";
2003  else
2004  str = toString(CAST_S32(mPingTime));
2005  }
2006  else
2007  {
2008  time_t time = tick_time;
2009  if (time > mPingSendTick)
2010  time -= mPingSendTick;
2011  else
2012  time += MAX_TICK_VALUE - mPingSendTick;
2013  if (time <= mPingTime)
2014  time = mPingTime;
2015  if (mPingTime != time)
2016  str = strprintf("%d (%d)", CAST_S32(mPingTime), CAST_S32(time));
2017  else
2018  str = toString(CAST_S32(time));
2019  }
2020  return str;
2021 }

References CAST_S32, MAX_TICK_VALUE, mPingSendTick, mPingTime, mWaitPing, strprintf(), tick_time, and Catch::toString().

Referenced by NetDebugTab::logic().

◆ getRename()

bool LocalPlayer::getRename ( ) const
inline

Definition at line 424 of file localplayer.h.

425  { return mAllowRename; }

References mAllowRename.

Referenced by CharSelectDialog::updateState().

◆ getTarget()

Being * LocalPlayer::getTarget ( ) const

◆ getWalkingDir()

unsigned char LocalPlayer::getWalkingDir ( ) const
inline

Gets the walking direction

Definition at line 147 of file localplayer.h.

148  { return mWalkingDir; }

References mWalkingDir.

◆ handleStatusEffect()

void LocalPlayer::handleStatusEffect ( const StatusEffect *const  effect,
const int32_t  effectId,
const Enable  newStatus,
const IsStart  start 
)
protectedvirtual

Handle an update to a status or stun effect

Parameters
TheStatusEffect to effect
effectId-1 for stun, otherwise the effect index

Reimplemented from ActorSprite.

Definition at line 1052 of file localplayer.cpp.

1056 {
1058  effectId,
1059  newStatus,
1060  start);
1061 
1062  if (effect != nullptr)
1063  {
1064  effect->deliverMessage();
1065  effect->playSFX();
1066 
1067  AnimatedSprite *const sprite = effect->getIcon();
1068 
1069  if (sprite == nullptr)
1070  {
1071  // delete sprite, if necessary
1072  for (size_t i = 0; i < mStatusEffectIcons.size(); )
1073  {
1074  if (mStatusEffectIcons[i] == effectId)
1075  {
1076  mStatusEffectIcons.erase(mStatusEffectIcons.begin() + i);
1077  if (miniStatusWindow != nullptr)
1079  }
1080  else
1081  {
1082  i++;
1083  }
1084  }
1085  }
1086  else
1087  {
1088  // replace sprite or append
1089  bool found = false;
1090  const size_t sz = mStatusEffectIcons.size();
1091  for (size_t i = 0; i < sz; i++)
1092  {
1093  if (mStatusEffectIcons[i] == effectId)
1094  {
1095  if (miniStatusWindow != nullptr)
1096  miniStatusWindow->setIcon(CAST_S32(i), sprite);
1097  found = true;
1098  break;
1099  }
1100  }
1101 
1102  if (!found)
1103  { // add new
1104  if (miniStatusWindow != nullptr)
1105  {
1106  const int offset = CAST_S32(mStatusEffectIcons.size());
1107  miniStatusWindow->setIcon(offset, sprite);
1108  }
1109  mStatusEffectIcons.push_back(effectId);
1110  }
1111  }
1112  }
1113 }

References CAST_S32, StatusEffect::deliverMessage(), MiniStatusWindow::eraseIcon(), StatusEffect::getIcon(), ActorSprite::handleStatusEffect(), miniStatusWindow, mStatusEffectIcons, StatusEffect::playSFX(), MiniStatusWindow::setIcon(), and anonymous_namespace{stringutils.cpp}::start.

◆ imitateAction()

void LocalPlayer::imitateAction ( const Being *const  being,
const BeingActionT action 
)

◆ imitateDirection()

void LocalPlayer::imitateDirection ( const Being *const  being,
const unsigned char  dir 
)

Definition at line 2444 of file localplayer.cpp.

2446 {
2447  if (being == nullptr)
2448  return;
2449 
2450  if (!mPlayerImitated.empty() && being->mName == mPlayerImitated)
2451  {
2453  return;
2454 
2455  if (settings.followMode == 2)
2456  {
2457  uint8_t dir2 = 0;
2458  if ((dir & BeingDirection::LEFT) != 0)
2459  dir2 |= BeingDirection::RIGHT;
2460  else if ((dir & BeingDirection::RIGHT) != 0)
2461  dir2 |= BeingDirection::LEFT;
2462  if ((dir & BeingDirection::UP) != 0)
2463  dir2 |= BeingDirection::DOWN;
2464  else if ((dir & BeingDirection::DOWN) != 0)
2465  dir2 |= BeingDirection::UP;
2466 
2467  setDirection(dir2);
2468  playerHandler->setDirection(dir2);
2469  }
2470  else
2471  {
2472  setDirection(dir);
2474  }
2475  }
2476 }

References BeingDirection::DOWN, Settings::followMode, BeingDirection::LEFT, PacketLimiter::limitPackets(), Being::mName, mPlayerImitated, PacketType::PACKET_DIRECTION, playerHandler, BeingDirection::RIGHT, Net::PlayerHandler::setDirection(), Being::setDirection(), settings, and BeingDirection::UP.

Referenced by TmwAthena::BeingRecv::processBeingChangeDirection(), EAthena::BeingRecv::processBeingChangeDirection(), TmwAthena::BeingRecv::processPlayerMove(), TmwAthena::BeingRecv::processPlayerUpdate1(), and TmwAthena::BeingRecv::processPlayerUpdate2().

◆ imitateEmote()

void LocalPlayer::imitateEmote ( const Being *const  being,
const unsigned char  action 
) const

Definition at line 2420 of file localplayer.cpp.

2422 {
2423  if (being == nullptr)
2424  return;
2425 
2426  std::string player_imitated = getImitate();
2427  if (!player_imitated.empty() && being->mName == player_imitated)
2428  emote(action);
2429 }

References emote(), getImitate(), and Being::mName.

Referenced by Ea::BeingRecv::processBeingEmotion().

◆ imitateOutfit()

void LocalPlayer::imitateOutfit ( const Being *const  player,
const int  sprite 
) const

Definition at line 2478 of file localplayer.cpp.

2480 {
2481  if (player == nullptr)
2482  return;
2483 
2484  if (settings.imitationMode == 1 &&
2485  !mPlayerImitated.empty() &&
2486  player->mName == mPlayerImitated)
2487  {
2488  if (sprite < 0 || sprite >= player->getNumberOfLayers())
2489  return;
2490 
2491  const AnimatedSprite *const equipmentSprite
2492  = dynamic_cast<const AnimatedSprite *>(
2493  player->mSprites[sprite]);
2494 
2495  if (equipmentSprite != nullptr)
2496  {
2497 // logger->log("have equipmentSprite");
2498  const Inventory *const inv = PlayerInfo::getInventory();
2499  if (inv == nullptr)
2500  return;
2501 
2502  const std::string &path = equipmentSprite->getIdPath();
2503  if (path.empty())
2504  return;
2505 
2506 // logger->log("idPath: " + path);
2507  const Item *const item = inv->findItemBySprite(path,
2508  player->getGender(), player->getSubType());
2509  if ((item != nullptr) && item->isEquipped() == Equipped_false)
2511  }
2512  else
2513  {
2514 // logger->log("have unequip %d", sprite);
2515  const int equipmentSlot = inventoryHandler
2516  ->convertFromServerSlot(sprite);
2517 // logger->log("equipmentSlot: " + toString(equipmentSlot));
2518  if (equipmentSlot == inventoryHandler->getProjectileSlot())
2519  return;
2520 
2521  const Item *const item = PlayerInfo::getEquipment(equipmentSlot);
2522  if (item != nullptr)
2523  {
2524 // logger->log("unequiping");
2526  }
2527  }
2528  }
2529 }

References Net::InventoryHandler::convertFromServerSlot(), PlayerInfo::equipItem(), Equipped_false, Inventory::findItemBySprite(), PlayerInfo::getEquipment(), Being::getGender(), AnimatedSprite::getIdPath(), PlayerInfo::getInventory(), Being::getNumberOfLayers(), Net::InventoryHandler::getProjectileSlot(), Being::getSubType(), Settings::imitationMode, inventoryHandler, Item::isEquipped(), Being::mName, mPlayerImitated, CompoundSprite::mSprites, settings, Sfx_false, and PlayerInfo::unequipItem().

Referenced by TmwAthena::BeingRecv::processBeingChangeLookContinue(), EAthena::BeingRecv::processBeingChangeLookContinue(), TmwAthena::BeingRecv::processPlayerMove(), TmwAthena::BeingRecv::processPlayerUpdate1(), and TmwAthena::BeingRecv::processPlayerUpdate2().

◆ isPathSetByMouse()

bool LocalPlayer::isPathSetByMouse ( ) const
inline

Tells if the path has been set by mouse.

Definition at line 189 of file localplayer.h.

190  { return mPathSetByMouse; }

References mPathSetByMouse.

◆ isReachable() [1/2]

bool LocalPlayer::isReachable ( Being *const  being,
const int  maxCost 
)

Definition at line 1541 of file localplayer.cpp.

1543 {
1544  if ((being == nullptr) || (mMap == nullptr))
1545  return false;
1546 
1547  if (being->getReachable() == Reachable::REACH_NO)
1548  return false;
1549 
1550  if (being->mX == mX &&
1551  being->mY == mY)
1552  {
1553  being->setDistance(0);
1555  return true;
1556  }
1557  else if (being->mX - 1 <= mX &&
1558  being->mX + 1 >= mX &&
1559  being->mY - 1 <= mY &&
1560  being->mY + 1 >= mY)
1561  {
1562  being->setDistance(1);
1564  return true;
1565  }
1566 
1567  const Path debugPath = mMap->findPath(
1568  (mPixelX - mapTileSize / 2) / mapTileSize,
1570  being->mX,
1571  being->mY,
1572  getBlockWalkMask(),
1573  maxCost);
1574 
1575  being->setDistance(CAST_S32(debugPath.size()));
1576  if (!debugPath.empty())
1577  {
1579  return true;
1580  }
1582  return false;
1583 }

References CAST_S32, Map::findPath(), getBlockWalkMask(), Being::getReachable(), mapTileSize, Actor::mMap, Actor::mPixelX, Actor::mPixelY, Being::mX, Being::mY, Reachable::REACH_NO, Reachable::REACH_YES, Being::setDistance(), and Being::setReachable().

Referenced by SocialNavigationTab::addPortal(), ActorManager::pickUpNearest(), SocialNavigationTab::updateList(), and ActorManager::validateBeing().

◆ isReachable() [2/2]

bool LocalPlayer::isReachable ( const int  x,
const int  y,
const bool  allowCollision 
) const

Definition at line 1585 of file localplayer.cpp.

1587 {
1588  const WalkLayer *const walk = mMap->getWalkLayer();
1589  if (walk == nullptr)
1590  return false;
1591  int num = walk->getDataAt(x, y);
1592  if (allowCollision && num < 0)
1593  num = -num;
1594 
1595  return walk->getDataAt(mX, mY) == num;
1596 }

References WalkLayer::getDataAt(), Map::getWalkLayer(), Actor::mMap, Being::mX, Being::mY, x, and y.

◆ isServerBuggy()

bool LocalPlayer::isServerBuggy ( ) const
inline

Definition at line 275 of file localplayer.h.

276  { return mIsServerBuggy; }

References mIsServerBuggy.

Referenced by DropShortcut::dropFirst(), and DropShortcut::dropItems().

◆ loadHomes()

void LocalPlayer::loadHomes ( )
protected

Definition at line 1814 of file localplayer.cpp.

1815 {
1816  std::string buf;
1817  std::stringstream ss(serverConfig.getValue("playerHomes", ""));
1818 
1819  while (ss >> buf)
1820  {
1821  Vector pos;
1822  ss >> pos.x;
1823  ss >> pos.y;
1824  mHomes[buf] = pos;
1825  }
1826 }

References ConfigurationObject::getValue(), mHomes, serverConfig, Vector::x, and Vector::y.

Referenced by LocalPlayer().

◆ logic()

void LocalPlayer::logic ( )
virtual

Performs being logic.

Reimplemented from Being.

Definition at line 255 of file localplayer.cpp.

256 {
257  BLOCK_START("LocalPlayer::logic")
258 #ifdef USE_MUMBLE
259  if (mumbleManager)
260  mumbleManager->setPos(mX, mY, mDirection);
261 #endif // USE_MUMBLE
262 
263  // Actions are allowed once per second
264  if (get_elapsed_time(mLastAction) >= 1000)
265  mLastAction = -1;
266 
267  if (mActivityTime == 0 || mLastAction != -1)
269 
270  if (mUnfreezeTime > 0 &&
272  {
273  mUnfreezeTime = 0;
274  mFreezed = false;
275  }
276 
277  if ((mAction != BeingAction::MOVE || mNextStep) && !mNavigatePath.empty())
278  {
279  mNextStep = false;
280  int dist = 5;
281  if (!mSyncPlayerMove)
282  dist = 20;
283 
284  if (((mNavigateX != 0) || (mNavigateY != 0)) &&
285  ((mCrossX + dist >= mX && mCrossX <= mX + dist
286  && mCrossY + dist >= mY && mCrossY <= mY + dist)
287  || ((mCrossX == 0) && (mCrossY == 0))))
288  {
289  const Path::const_iterator i = mNavigatePath.begin();
290  if ((*i).x == mX && (*i).y == mY)
291  mNavigatePath.pop_front();
292  else
293  setDestination((*i).x, (*i).y);
294  }
295  }
296 
297  // Show XP messages
298  if (!mMessages.empty())
299  {
300  if (mMessageTime == 0)
301  {
302  const MessagePair info = mMessages.front();
303 
304  if ((particleEngine != nullptr) && (gui != nullptr))
305  {
307  info.first,
308  mPixelX,
309  mPixelY - 48,
310  &userPalette->getColor(info.second, 255U),
312  true);
313  }
314 
315  mMessages.pop_front();
316  mMessageTime = 30;
317  }
318  mMessageTime--;
319  }
320 
321  if (mTarget != nullptr)
322  {
323  if (mTarget->getType() == ActorType::Npc)
324  {
325  // NPCs are always in range
327  }
328  else
329  {
330  // Find whether target is in range
331  const int rangeX = CAST_S32(
332  abs(mTarget->mX - mX));
333  const int rangeY = CAST_S32(
334  abs(mTarget->mY - mY));
335  const int attackRange = getAttackRange();
336  const TargetCursorTypeT targetType
337  = rangeX > attackRange || rangeY > attackRange
339  mTarget->setTargetType(targetType);
340 
341  if (!mTarget->isAlive() && (!mTargetDeadPlayers
343  {
344  stopAttack(true);
345  }
346 
347  if (mKeepAttacking && (mTarget != nullptr))
348  attack(mTarget, true, false);
349  }
350  }
351 
352  Being::logic();
353  BLOCK_END("LocalPlayer::logic")
354 }

References ParticleEngine::addTextRiseFadeOutEffect(), attack(), BLOCK_END, BLOCK_START, CAST_S32, cur_time, get_elapsed_time(), getAttackRange(), UserPalette::getColor(), Gui::getInfoParticleFont(), Being::getType(), gui, TargetCursorType::IN_RANGE, Actions::info(), Being::isAlive(), Being::logic(), Being::mAction, mActivityTime, mCrossX, mCrossY, Being::mDirection, mFreezed, mKeepAttacking, mLastAction, mMessages, mMessageTime, mNavigatePath, mNavigateX, mNavigateY, mNextStep, BeingAction::MOVE, Actor::mPixelX, Actor::mPixelY, mSyncPlayerMove, mTarget, mTargetDeadPlayers, mUnfreezeTime, Being::mX, Being::mY, TargetCursorType::NORMAL, ActorType::Npc, particleEngine, ActorType::Player, setDestination(), ActorSprite::setTargetType(), stopAttack(), tick_time, and userPalette.

◆ magicAttack()

void LocalPlayer::magicAttack ( ) const

Definition at line 1756 of file localplayer.cpp.

1757 {
1759  return;
1760  if (chatWindow == nullptr ||
1761  !isAlive() ||
1763  {
1764  return;
1765  }
1766 
1767  switch (settings.magicAttackType)
1768  {
1769  // flar W00
1770  case 0:
1771  tryMagic("#flar", 1, 0, 10);
1772  break;
1773  // chiza W01
1774  case 1:
1775  tryMagic("#chiza", 1, 0, 9);
1776  break;
1777  // ingrav W10
1778  case 2:
1779  tryMagic("#ingrav", 2, 2, 20);
1780  break;
1781  // frillyar W11
1782  case 3:
1783  tryMagic("#frillyar", 2, 2, 25);
1784  break;
1785  // upmarmu W12
1786  case 4:
1787  tryMagic("#upmarmu", 2, 2, 20);
1788  break;
1789  default:
1790  break;
1791  }
1792 }

References Net::PlayerHandler::canUseMagic(), chatWindow, Net::getNetworkType(), Being::isAlive(), Settings::magicAttackType, playerHandler, settings, ServerType::TMWATHENA, and tryMagic().

◆ move()

void LocalPlayer::move ( const int  dX,
const int  dY 
)

◆ moveByDirection()

void LocalPlayer::moveByDirection ( const unsigned char  dir)

Definition at line 1703 of file localplayer.cpp.

1704 {
1705  int dx = 0;
1706  int dy = 0;
1707  if ((dir & BeingDirection::UP) != 0)
1708  dy--;
1709  if ((dir & BeingDirection::DOWN) != 0)
1710  dy++;
1711  if ((dir & BeingDirection::LEFT) != 0)
1712  dx--;
1713  if ((dir & BeingDirection::RIGHT) != 0)
1714  dx++;
1715  move(dx, dy);
1716 }

References BeingDirection::DOWN, BeingDirection::LEFT, move(), BeingDirection::RIGHT, and BeingDirection::UP.

Referenced by specialMove().

◆ moveToHome()

void LocalPlayer::moveToHome ( )

Definition at line 1431 of file localplayer.cpp.

1432 {
1433  mPickUpTarget = nullptr;
1434  if ((mX != mCrossX || mY != mCrossY) && (mCrossX != 0) && (mCrossY != 0))
1435  {
1437  }
1438  else if (mMap != nullptr)
1439  {
1440  const std::map<std::string, Vector>::const_iterator iter =
1441  mHomes.find(mMap->getProperty("_realfilename", std::string()));
1442 
1443  if (iter != mHomes.end())
1444  {
1445  const Vector pos = mHomes[(*iter).first];
1446  if (mX == pos.x && mY == pos.y)
1447  {
1449  CAST_S32(pos.x),
1450  CAST_S32(pos.y),
1451  CAST_S32(mDirection));
1452  }
1453  else
1454  {
1455  navigateTo(CAST_S32(pos.x), CAST_S32(pos.y));
1456  }
1457  }
1458  }
1459 }

References CAST_S32, Properties::getProperty(), mCrossX, mCrossY, Being::mDirection, mHomes, Actor::mMap, mPickUpTarget, Being::mX, Being::mY, navigateTo(), playerHandler, Net::PlayerHandler::setDestination(), setDestination(), Vector::x, and Vector::y.

◆ moveToTarget()

void LocalPlayer::moveToTarget ( int  dist)

Definition at line 1344 of file localplayer.cpp.

1345 {
1346  bool gotPos(false);
1347  Path debugPath;
1348 
1349  size_t limit(0);
1350 
1351  if (dist == -1)
1352  {
1353  dist = settings.moveToTargetType;
1354  if (dist != 0)
1355  {
1356  const bool broken = (Net::getNetworkType() ==
1358  switch (dist)
1359  {
1360  case 10:
1361  dist = mAttackRange;
1362  if (dist == 1 && broken)
1363  dist = 2;
1364  break;
1365  case 11:
1366  dist = mAttackRange - 1;
1367  if (dist < 1)
1368  dist = 1;
1369  if (dist == 1 && broken)
1370  dist = 2;
1371  break;
1372  default:
1373  break;
1374  }
1375  }
1376  }
1377 
1378  if (mTarget != nullptr)
1379  {
1380  if (mMap != nullptr)
1381  {
1382  debugPath = mMap->findPath(
1383  (mPixelX - mapTileSize / 2) / mapTileSize,
1385  mTarget->mX,
1386  mTarget->mY,
1387  getBlockWalkMask(),
1388  0);
1389  }
1390 
1391  const size_t sz = debugPath.size();
1392  if (sz < CAST_SIZE(dist))
1393  return;
1394  limit = CAST_S32(sz) - dist;
1395  gotPos = true;
1396  }
1397  else if ((mNavigateX != 0) || (mNavigateY != 0))
1398  {
1399  debugPath = mNavigatePath;
1400  limit = dist;
1401  gotPos = true;
1402  }
1403 
1404  if (gotPos)
1405  {
1406  if (dist == 0)
1407  {
1408  if (mTarget != nullptr)
1410  }
1411  else
1412  {
1413  Position pos(0, 0);
1414  size_t f = 0;
1415 
1416  for (Path::const_iterator i = debugPath.begin(),
1417  i_fend = debugPath.end();
1418  i != i_fend && f < limit; ++i, f++)
1419  {
1420  pos = (*i);
1421  }
1422  navigateTo(pos.x, pos.y);
1423  }
1424  }
1425  else if ((mLastTargetX != 0) || (mLastTargetY != 0))
1426  {
1428  }
1429 }

References CAST_S32, CAST_SIZE, Map::findPath(), getBlockWalkMask(), Net::getNetworkType(), mapTileSize, Being::mAttackRange, mLastTargetX, mLastTargetY, Actor::mMap, mNavigatePath, mNavigateX, mNavigateY, Settings::moveToTargetType, Actor::mPixelX, Actor::mPixelY, mTarget, Being::mX, Being::mY, navigateTo(), settings, ServerType::TMWATHENA, Position::x, and Position::y.

Referenced by attack2(), and followMoveTo().

◆ navigateClean()

void LocalPlayer::navigateClean ( )

Definition at line 2154 of file localplayer.cpp.

2155 {
2156  if (mMap == nullptr)
2157  return;
2158 
2159  mShowNavigePath = false;
2160  mOldX = 0;
2161  mOldY = 0;
2162  mOldTileX = 0;
2163  mOldTileY = 0;
2164  mNavigateX = 0;
2165  mNavigateY = 0;
2167 
2168  mNavigatePath.clear();
2169 
2170  SpecialLayer *const tmpLayer = mMap->getTempLayer();
2171  if (tmpLayer == nullptr)
2172  return;
2173 
2174  tmpLayer->clean();
2175 }

References BeingId_zero, SpecialLayer::clean(), Map::getTempLayer(), Actor::mMap, mNavigateId, mNavigatePath, mNavigateX, mNavigateY, mOldTileX, mOldTileY, mOldX, mOldY, and mShowNavigePath.

Referenced by GameModifiers::changeAwayMode(), EAthena::BeingRecv::processBeingSlide(), Ea::PlayerRecv::processPlayerWarp(), respawn(), setMap(), specialMove(), stopWalking(), updateCoords(), and ~LocalPlayer().

◆ navigateTo()

bool LocalPlayer::navigateTo ( const int  x,
const int  y 
)

Definition at line 2123 of file localplayer.cpp.

2124 {
2125  if (mMap == nullptr)
2126  return false;
2127 
2128  SpecialLayer *const tmpLayer = mMap->getTempLayer();
2129  if (tmpLayer == nullptr)
2130  return false;
2131 
2132  mShowNavigePath = true;
2133  mOldX = mPixelX;
2134  mOldY = mPixelY;
2135  mOldTileX = mX;
2136  mOldTileY = mY;
2137  mNavigateX = x;
2138  mNavigateY = y;
2140 
2142  (mPixelX - mapTileSize / 2) / mapTileSize,
2144  x,
2145  y,
2146  getBlockWalkMask(),
2147  0);
2148 
2149  if (mDrawPath)
2150  tmpLayer->addRoad(mNavigatePath);
2151  return !mNavigatePath.empty();
2152 }

References SpecialLayer::addRoad(), BeingId_zero, Map::findPath(), getBlockWalkMask(), Map::getTempLayer(), mapTileSize, mDrawPath, Actor::mMap, mNavigateId, mNavigatePath, mNavigateX, mNavigateY, mOldTileX, mOldTileY, mOldX, mOldY, Actor::mPixelX, Actor::mPixelY, mShowNavigePath, Being::mX, Being::mY, x, and y.

Referenced by followMoveTo(), AvatarListBox::mousePressed(), Minimap::mouseReleased(), moveToHome(), moveToTarget(), pickUp(), SocialNavigationTab::selectIndex(), and setGotoTarget().

◆ nextTile()

void LocalPlayer::nextTile ( )
virtual

Adds a new tile to the path when walking.

Note
Eathena Also, when specified, it picks up an item at the end of a path or attack target.

Reimplemented from Being.

Definition at line 448 of file localplayer.cpp.

449 {
450  const Party *const party = Party::getParty(1);
451  if (party != nullptr)
452  {
453  PartyMember *const pm = party->getMember(mName);
454  if (pm != nullptr)
455  {
456  pm->setX(mX);
457  pm->setY(mY);
458  }
459  }
460 
461  if (mPath.empty())
462  {
463  if (mPickUpTarget != nullptr)
465 
466  if (mWalkingDir != 0U)
468  }
469  else if (mPath.size() == 1)
470  {
471  if (mPickUpTarget != nullptr)
473  }
474 
475  if (mGoingToTarget &&
476  mTarget != nullptr &&
477  withinAttackRange(mTarget, false, 0))
478  {
480  attack(mTarget, true, false);
481  mGoingToTarget = false;
482  mPath.clear();
483  return;
484  }
485  else if (mGoingToTarget && (mTarget == nullptr))
486  {
487  mGoingToTarget = false;
488  mPath.clear();
489  }
490 
491  if (mPath.empty())
492  {
493  if (mNavigatePath.empty() || mAction != BeingAction::MOVE)
494  {
496  // +++ probably sync position here always?
497  }
498  else
499  {
500  mNextStep = true;
501  }
502  }
503  else
504  {
505  Being::nextTile();
506  }
507 
508  fixPos();
509 }

References attack(), fixPos(), Party::getParty(), Being::mAction, mGoingToTarget, Being::mName, mNavigatePath, mNextStep, BeingAction::MOVE, Being::mPath, mPickUpTarget, mTarget, mWalkingDir, Being::mX, Being::mY, Being::nextTile(), party, pickUp(), setAction(), Avatar::setX(), Avatar::setY(), BeingAction::STAND, startWalking(), and withinAttackRange().

◆ optionChanged()

void LocalPlayer::optionChanged ( const std::string &  value)
virtual

Called when a option (set with config.addListener()) is changed

Reimplemented from Being.

Definition at line 1122 of file localplayer.cpp.

1123 {
1124  if (value == "showownname")
1125  {
1126  setShowName(config.getBoolValue("showownname"));
1127  }
1128  else if (value == "targetDeadPlayers")
1129  {
1130  mTargetDeadPlayers = config.getBoolValue("targetDeadPlayers");
1131  }
1132  else if (value == "enableBuggyServers")
1133  {
1134  mIsServerBuggy = serverConfig.getBoolValue("enableBuggyServers");
1135  }
1136  else if (value == "syncPlayerMove")
1137  {
1138  mSyncPlayerMove = config.getBoolValue("syncPlayerMove");
1139  }
1140  else if (value == "syncPlayerMoveDistance")
1141  {
1142 #ifdef TMWA_SUPPORT
1144 #endif
1145  {
1147  config.getIntValue("syncPlayerMoveDistance");
1148  }
1149  }
1150 #ifdef TMWA_SUPPORT
1151  else if (value == "syncPlayerMoveDistanceLegacy")
1152  {
1154  {
1156  config.getIntValue("syncPlayerMoveDistanceLegacy");
1157  }
1158  }
1159 #endif
1160  else if (value == "drawPath")
1161  {
1162  mDrawPath = config.getBoolValue("drawPath");
1163  }
1164  else if (value == "serverAttack")
1165  {
1166  mServerAttack = fromBool(config.getBoolValue("serverAttack"), Keep);
1167  }
1168  else if (value == "attackMoving")
1169  {
1170  mAttackMoving = config.getBoolValue("attackMoving");
1171  }
1172  else if (value == "attackNext")
1173  {
1174  mAttackNext = config.getBoolValue("attackNext");
1175  }
1176  else if (value == "showJobExp")
1177  {
1178  mShowJobExp = config.getBoolValue("showJobExp");
1179  }
1180  else if (value == "enableAdvert")
1181  {
1182  mEnableAdvert = config.getBoolValue("enableAdvert");
1183  }
1184  else if (value == "tradebot")
1185  {
1186  mTradebot = config.getBoolValue("tradebot");
1187  }
1188  else if (value == "targetOnlyReachable")
1189  {
1190  mTargetOnlyReachable = config.getBoolValue("targetOnlyReachable");
1191  }
1192  else if (value == "showserverpos")
1193  {
1194  mShowServerPos = config.getBoolValue("showserverpos");
1195  }
1196  else if (value == "visiblenames")
1197  {
1198  mVisibleNames = static_cast<VisibleName::Type>(
1199  config.getIntValue("visiblenames"));
1200  }
1201 }

References config, fromBool, Configuration::getBoolValue(), Configuration::getIntValue(), Net::getNetworkType(), mAttackMoving, mAttackNext, mDrawPath, mEnableAdvert, mIsServerBuggy, mServerAttack, mShowJobExp, mShowServerPos, mSyncPlayerMove, mSyncPlayerMoveDistance, mTargetDeadPlayers, mTargetOnlyReachable, mTradebot, mVisibleNames, serverConfig, Being::setShowName(), and ServerType::TMWATHENA.

◆ pathSetByMouse()

void LocalPlayer::pathSetByMouse ( )
inline

Tells that the path has been set by mouse.

Definition at line 185 of file localplayer.h.

186  { mPathSetByMouse = true; }

References mPathSetByMouse.

◆ pickedUp()

void LocalPlayer::pickedUp ( const ItemInfo itemInfo,
const int  amount,
const ItemColor  color,
const BeingId  floorItemId,
const PickupT  fail 
)

Shows item pickup notifications.

Definition at line 886 of file localplayer.cpp.

891 {
892  if (fail != Pickup::OKAY)
893  {
894  if ((actorManager != nullptr) && floorItemId != BeingId_zero)
895  {
896  FloorItem *const item = actorManager->findItem(floorItemId);
897  if (item != nullptr)
898  {
899  if (!item->getShowMsg())
900  return;
901  item->setShowMsg(false);
902  }
903  }
904  const char* msg = nullptr;
905  switch (fail)
906  {
907  case Pickup::BAD_ITEM:
908  // TRANSLATORS: pickup error message
909  msg = N_("Tried to pick up nonexistent item.");
910  break;
911  case Pickup::TOO_HEAVY:
912  // TRANSLATORS: pickup error message
913  msg = N_("Item is too heavy.");
914  break;
915  case Pickup::TOO_FAR:
916  // TRANSLATORS: pickup error message
917  msg = N_("Item is too far away.");
918  break;
919  case Pickup::INV_FULL:
920  // TRANSLATORS: pickup error message
921  msg = N_("Inventory is full.");
922  break;
923  case Pickup::STACK_FULL:
924  // TRANSLATORS: pickup error message
925  msg = N_("Stack is too big.");
926  break;
927  case Pickup::DROP_STEAL:
928  // TRANSLATORS: pickup error message
929  msg = N_("Item belongs to someone else.");
930  break;
931  case Pickup::MAX_AMOUNT:
932  // TRANSLATORS: pickup error message
933  msg = N_("You can't pickup this amount of items.");
934  break;
936  // TRANSLATORS: pickup error message
937  msg = N_("Your item stack has max amount.");
938  break;
939  case Pickup::OKAY:
940  break;
941  default:
942  case Pickup::UNKNOWN:
943  // TRANSLATORS: pickup error message
944  msg = N_("Unknown problem picking up item.");
945  break;
946  }
947  if (localChatTab != nullptr &&
948  config.getBoolValue("showpickupchat"))
949  {
950  localChatTab->chatLog(gettext(msg),
954  }
955 
956  if ((mMap != nullptr) && config.getBoolValue("showpickupparticle"))
957  {
958  // Show pickup notification
960  }
961  }
962  else
963  {
964  std::string str;
965 #ifdef TMWA_SUPPORT
967  {
968  str = itemInfo.getName();
969  }
970  else
971 #endif // TMWA_SUPPORT
972  {
973  str = itemInfo.getName(color);
974  }
975 
976  if (config.getBoolValue("showpickupchat") && (localChatTab != nullptr))
977  {
978  // TRANSLATORS: %d is number,
979  // [@@%d|%[email protected]@] - here player can see link to item
980  localChatTab->chatLog(strprintf(ngettext("You picked up %d "
981  "[@@%d|%[email protected]@].", "You picked up %d [@@%d|%[email protected]@].", amount),
982  amount, itemInfo.getId(), str.c_str()),
986  }
987 
988  if ((mMap != nullptr) && config.getBoolValue("showpickupparticle"))
989  {
990  // Show pickup notification
991  if (amount > 1)
992  {
993  addMessageToQueue(strprintf("%d x %s", amount,
994  str.c_str()), UserColorId::PICKUP_INFO);
995  }
996  else
997  {
999  }
1000  }
1001  }
1002 }

References actorManager, addMessageToQueue(), Pickup::BAD_ITEM, BeingId_zero, ChatMsgType::BY_SERVER, ChatTab::chatLog(), config, Pickup::DROP_STEAL, ActorManager::findItem(), Configuration::getBoolValue(), Net::getNetworkType(), FloorItem::getShowMsg(), IgnoreRecord_false, Pickup::INV_FULL, Actions::itemInfo(), localChatTab, Pickup::MAX_AMOUNT, Actor::mMap, Actions::msg(), N_, Pickup::OKAY, UserColorId::PICKUP_INFO, FloorItem::setShowMsg(), Pickup::STACK_AMOUNT, Pickup::STACK_FULL, strprintf(), ServerType::TMWATHENA, Pickup::TOO_FAR, Pickup::TOO_HEAVY, TryRemoveColors_true, and Pickup::UNKNOWN.

Referenced by TmwAthena::InventoryRecv::processPlayerInventoryAdd(), and EAthena::InventoryRecv::processPlayerInventoryAdd().

◆ pickUp()

bool LocalPlayer::pickUp ( FloorItem *const  item)

Definition at line 511 of file localplayer.cpp.

512 {
513  if (item == nullptr)
514  return false;
515 
517  return false;
518 
519  const int dx = item->getTileX() - mX;
520  const int dy = item->getTileY() - mY;
521  int dist = 6;
522 
523  const unsigned int pickUpType = settings.pickUpType;
524  if (pickUpType >= 4 && pickUpType <= 6)
525  dist = 4;
526 
527  if (dx * dx + dy * dy < dist)
528  {
529  if ((actorManager != nullptr) && actorManager->checkForPickup(item))
530  {
532  mPickUpTarget = nullptr;
533  }
534  }
535  else if (pickUpType >= 4 && pickUpType <= 6)
536  {
537  const Path debugPath = mMap->findPath(
538  (mPixelX - mapTileSize / 2) / mapTileSize,
540  item->getTileX(),
541  item->getTileY(),
543  0);
544  if (!debugPath.empty())
545  navigateTo(item->getTileX(), item->getTileY());
546  else
547  setDestination(item->getTileX(), item->getTileY());
548 
549  mPickUpTarget = item;
551  }
552  return true;
553 }

References actorManager, ActorSprite::addActorSpriteListener(), ActorManager::checkForPickup(), Map::findPath(), getBlockWalkMask(), FloorItem::getTileX(), FloorItem::getTileY(), PacketLimiter::limitPackets(), mapTileSize, Actor::mMap, mPickUpTarget, Actor::mPixelX, Actor::mPixelY, Being::mX, Being::mY, navigateTo(), PacketType::PACKET_PICKUP, PlayerInfo::pickUpItem(), Settings::pickUpType, setDestination(), settings, and Sfx_true.

Referenced by nextTile(), ActorManager::pickUpAll(), pickUpItems(), and ActorManager::pickUpNearest().

◆ pickUpItems()

bool LocalPlayer::pickUpItems ( int  pickUpType)

Definition at line 1598 of file localplayer.cpp.

1599 {
1600  if (actorManager == nullptr)
1601  return false;
1602 
1603  bool status = false;
1604  int x = mX;
1605  int y = mY;
1606 
1607  // first pick up item on player position
1608  FloorItem *item =
1609  actorManager->findItem(x, y);
1610  if (item != nullptr)
1611  status = pickUp(item);
1612 
1613  if (pickUpType == 0)
1614  pickUpType = settings.pickUpType;
1615 
1616  if (pickUpType == 0)
1617  return status;
1618 
1619  int x1;
1620  int y1;
1621  int x2;
1622  int y2;
1623  switch (pickUpType)
1624  {
1625  case 1:
1626  switch (mDirection)
1627  {
1628  case BeingDirection::UP : --y; break;
1629  case BeingDirection::DOWN : ++y; break;
1630  case BeingDirection::LEFT : --x; break;
1631  case BeingDirection::RIGHT: ++x; break;
1632  default: break;
1633  }
1634  item = actorManager->findItem(x, y);
1635  if (item != nullptr)
1636  status = pickUp(item);
1637  break;
1638  case 2:
1639  switch (mDirection)
1640  {
1641  case BeingDirection::UP:
1642  x1 = x - 1; y1 = y - 1; x2 = x + 1; y2 = y; break;
1643  case BeingDirection::DOWN:
1644  x1 = x - 1; y1 = y; x2 = x + 1; y2 = y + 1; break;
1645  case BeingDirection::LEFT:
1646  x1 = x - 1; y1 = y - 1; x2 = x; y2 = y + 1; break;
1647  case BeingDirection::RIGHT:
1648  x1 = x; y1 = y - 1; x2 = x + 1; y2 = y + 1; break;
1649  default:
1650  x1 = x; x2 = x; y1 = y; y2 = y; break;
1651  }
1652  if (actorManager->pickUpAll(x1, y1, x2, y2, false))
1653  status = true;
1654  break;
1655  case 3:
1656  if (actorManager->pickUpAll(x - 1, y - 1, x + 1, y + 1, false))
1657  status = true;
1658  break;
1659 
1660  case 4:
1661  if (!actorManager->pickUpAll(x - 1, y - 1, x + 1, y + 1, false))
1662  {
1663  if (actorManager->pickUpNearest(x, y, 4))
1664  status = true;
1665  }
1666  else
1667  {
1668  status = true;
1669  }
1670  break;
1671 
1672  case 5:
1673  if (!actorManager->pickUpAll(x - 1, y - 1, x + 1, y + 1, false))
1674  {
1675  if (actorManager->pickUpNearest(x, y, 8))
1676  status = true;
1677  }
1678  else
1679  {
1680  status = true;
1681  }
1682  break;
1683 
1684  case 6:
1685  if (!actorManager->pickUpAll(x - 1, y - 1, x + 1, y + 1, false))
1686  {
1687  if (actorManager->pickUpNearest(x, y, 90))
1688  status = true;
1689  }
1690  else
1691  {
1692  status = true;
1693  }
1694  break;
1695 
1696  default:
1697  break;
1698  }
1699  return status;
1700 }

References actorManager, BeingDirection::DOWN, ActorManager::findItem(), BeingDirection::LEFT, Being::mDirection, Being::mX, Being::mY, pickUp(), ActorManager::pickUpAll(), ActorManager::pickUpNearest(), Settings::pickUpType, BeingDirection::RIGHT, settings, BeingDirection::UP, x, and y.

Referenced by attack2(), and CrazyMoves::crazyMoveA().

◆ pingRequest()

void LocalPlayer::pingRequest ( )

Definition at line 1982 of file localplayer.cpp.

1983 {
1984  const int time = tick_time;
1985  if (mWaitPing == true && mPingSendTick != 0)
1986  {
1987  if (time >= mPingSendTick && (time - mPingSendTick) > 1000)
1988  return;
1989  }
1990 
1991  mPingSendTick = time;
1992  mWaitPing = true;
1994 }

References beingHandler, ActorSprite::getId(), mPingSendTick, mWaitPing, Net::BeingHandler::requestNameById(), and tick_time.

Referenced by tryPingRequest().

◆ pingResponse()

void LocalPlayer::pingResponse ( )

Definition at line 2023 of file localplayer.cpp.

2024 {
2025  if (mWaitPing == true && mPingSendTick > 0)
2026  {
2027  mWaitPing = false;
2028  const int time = tick_time;
2029  if (time < mPingSendTick)
2030  {
2031  mPingSendTick = 0;
2032  mPingTime = 0;
2033  }
2034  else
2035  {
2036  mPingTime = (time - mPingSendTick) * 10;
2037  }
2038  }
2039 }

References mPingSendTick, mPingTime, mWaitPing, and tick_time.

Referenced by Ea::BeingRecv::processNameResponse(), EAthena::BeingRecv::processNameResponse2(), EAthena::BeingRecv::processNameResponseTitle(), EAthena::BeingRecv::processPlayerGuilPartyInfo(), and EAthena::BeingRecv::processPlayerGuilPartyInfo2().

◆ playerDeath()

void LocalPlayer::playerDeath ( )
virtual

Implements PlayerDeathListener.

Definition at line 2909 of file localplayer.cpp.

2910 {
2911  if (mAction != BeingAction::DEAD)
2912  {
2915  }
2916 }

References BeingAction::DEAD, Being::mAction, Being::recalcSpritesOrder(), and setAction().

◆ removeHome()

void LocalPlayer::removeHome ( )

Definition at line 2829 of file localplayer.cpp.

2830 {
2831  if (mMap == nullptr)
2832  return;
2833 
2834  const std::string key = mMap->getProperty("_realfilename", std::string());
2835  const std::map<std::string, Vector>::iterator iter = mHomes.find(key);
2836 
2837  if (iter != mHomes.end())
2838  mHomes.erase(key);
2839 }

References Properties::getProperty(), mHomes, and Actor::mMap.

Referenced by PopupMenu::handleLink().

◆ respawn()

void LocalPlayer::respawn ( )

Definition at line 2741 of file localplayer.cpp.

2742 {
2743  navigateClean();
2744 }

References navigateClean().

Referenced by PlayerPostDeathListener::action().

◆ saveHomes()

void LocalPlayer::saveHomes ( )

Definition at line 1963 of file localplayer.cpp.

1964 {
1965  std::stringstream ss;
1966 
1967  for (std::map<std::string, Vector>::const_iterator iter = mHomes.begin(),
1968  iter_fend = mHomes.end();
1969  iter != iter_fend;
1970  ++iter)
1971  {
1972  const Vector &pos = (*iter).second;
1973 
1974  if (iter != mHomes.begin())
1975  ss << " ";
1976  ss << (*iter).first << " " << pos.x << " " << pos.y;
1977  }
1978 
1979  serverConfig.setValue("playerHomes", ss.str());
1980 }

References mHomes, serverConfig, Configuration::setValue(), Vector::x, and Vector::y.

Referenced by PopupMenu::handleLink(), and setHome().

◆ setAction()

void LocalPlayer::setAction ( const BeingActionT action,
const int  attackId 
)
virtual

Sets the current action.

Reimplemented from Being.

Definition at line 408 of file localplayer.cpp.

410 {
411  if (action == BeingAction::DEAD)
412  {
413  if (!mLastHitFrom.empty() &&
415  {
416  // TRANSLATORS: chat message after death
417  debugMsg(strprintf(_("You were killed by %s."),
418  mLastHitFrom.c_str()))
420  }
421  setTarget(nullptr);
422  }
423 
424  Being::setAction(action,
425  attackId);
426 #ifdef USE_MUMBLE
427  if (mumbleManager)
428  mumbleManager->setAction(CAST_S32(action));
429 #endif // USE_MUMBLE
430 }

References _, CAST_S32, BeingAction::DEAD, debugMsg, Net::ServerFeatures::haveKillerId(), mLastHitFrom, serverFeatures, Being::setAction(), setTarget(), and strprintf().

Referenced by attack(), imitateAction(), nextTile(), playerDeath(), Ea::PlayerRecv::processPlayerWarp(), stopWalking(), and untarget().

◆ setAfkMessage()

void LocalPlayer::setAfkMessage ( std::string  message)
static

Definition at line 2058 of file localplayer.cpp.

2059 {
2060  if (!message.empty())
2061  {
2062  if (message.size() > 4 && message.substr(0, 4) == "/me ")
2063  {
2064  message = message.substr(4);
2065  config.setValue("afkFormat", 1);
2066  }
2067  else
2068  {
2069  config.setValue("afkFormat", 0);
2070  }
2071  serverConfig.setValue("afkMessage", message);
2072  }
2073 }

References config, serverConfig, and Configuration::setValue().

Referenced by setAway(), and setPseudoAway().

◆ setAfkTime()

void LocalPlayer::setAfkTime ( const int  v)
inline

Definition at line 412 of file localplayer.h.

413  { mAfkTime = v; }

References mAfkTime.

Referenced by GameModifiers::changeAwayMode().

◆ setAway()

void LocalPlayer::setAway ( const std::string &  message) const

Definition at line 2051 of file localplayer.cpp.

2052 {
2053  setAfkMessage(message);
2055  updateStatus();
2056 }

References GameModifiers::changeAwayMode(), setAfkMessage(), and updateStatus().

◆ setAwayDialog()

void LocalPlayer::setAwayDialog ( OkDialog *const  dialog)
inline

Definition at line 415 of file localplayer.h.

416  { mAwayDialog = dialog; }

References mAwayDialog.

Referenced by GameModifiers::changeAwayMode().

◆ setCheckNameSetting()

void LocalPlayer::setCheckNameSetting ( const bool  checked)
inline

Tells the engine whether to check if the Player Name is to be displayed.

Definition at line 348 of file localplayer.h.

349  { mUpdateName = checked; }

References mUpdateName.

Referenced by Setup_Relations::apply().

◆ setDestination()

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

Sets a new destination for this being to walk to.

Definition at line 622 of file localplayer.cpp.

623 {
625 
626  if (settings.attackType == 0 || !mAttackMoving)
627  mKeepAttacking = false;
628 
629  // Only send a new message to the server when destination changes
630  if (x != mDest.x || y != mDest.y)
631  {
632  if (settings.moveType != 1)
633  {
636  }
637  else
638  {
639  uint8_t newDir = 0;
640  if ((mDirection & BeingDirection::UP) != 0)
641  newDir |= BeingDirection::DOWN;
642  if ((mDirection & BeingDirection::LEFT) != 0)
643  newDir |= BeingDirection::RIGHT;
644  if ((mDirection & BeingDirection::DOWN) != 0)
645  newDir |= BeingDirection::UP;
646  if ((mDirection & BeingDirection::RIGHT) != 0)
647  newDir |= BeingDirection::LEFT;
648 
649  playerHandler->setDestination(x, y, newDir);
650 
651 // if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
652  {
653  setDirection(newDir);
654  playerHandler->setDirection(newDir);
655  }
656 
659  }
660  }
661 }

References Settings::attackType, cur_time, BeingDirection::DOWN, BeingDirection::LEFT, mActivityTime, mAttackMoving, Being::mDest, Being::mDirection, mKeepAttacking, Settings::moveType, playerHandler, BeingDirection::RIGHT, Net::PlayerHandler::setDestination(), Being::setDestination(), Net::PlayerHandler::setDirection(), Being::setDirection(), settings, BeingDirection::UP, x, Vector::x, y, and Vector::y.

Referenced by fixAttackTarget(), logic(), move(), moveToHome(), pickUp(), startWalking(), and stopWalking().

◆ setFollow()

void LocalPlayer::setFollow ( const std::string &  player)

set a following player.

Definition at line 2372 of file localplayer.cpp.

2373 {
2374  mPlayerFollowed = player;
2375  if (!mPlayerFollowed.empty())
2376  {
2377  // TRANSLATORS: follow command message
2378  std::string msg = strprintf(_("Follow: %s"), player.c_str());
2379  debugMsg(msg)
2380  }
2381  else
2382  {
2383  // TRANSLATORS: follow command message
2384  debugMsg(_("Follow canceled"))
2385  }
2386 }

References _, debugMsg, mPlayerFollowed, Actions::msg(), and strprintf().

◆ setGotoTarget()

void LocalPlayer::setGotoTarget ( Being *const  target)

Sets going to being to attack

Definition at line 1040 of file localplayer.cpp.

1041 {
1042  if (target == nullptr)
1043  return;
1044 
1045  mPickUpTarget = nullptr;
1046  setTarget(target);
1047  mGoingToTarget = true;
1048  navigateTo(target->mX,
1049  target->mY);
1050 }

References mGoingToTarget, mPickUpTarget, Being::mX, Being::mY, navigateTo(), and setTarget().

◆ setGroupId()

void LocalPlayer::setGroupId ( const int  id)
virtual

Reimplemented from Being.

Definition at line 432 of file localplayer.cpp.

433 {
434  Being::setGroupId(id);
435 
436  if (mIsGM != 0)
437  {
438  if (chatWindow != nullptr)
439  {
442  }
443  }
444  if (statusWindow != nullptr)
446 }

References chatWindow, ChatWindow::loadGMCommands(), Being::mIsGM, Being::setGroupId(), ChatWindow::showGMTab(), statusWindow, and StatusWindow::updateLevelLabel().

Referenced by EAthena::PlayerRecv::processPlayerAttrs(), and TmwAthena::PlayerHandler::setStat().

◆ setHalfAway()

void LocalPlayer::setHalfAway ( const bool  n)
inline

Definition at line 235 of file localplayer.h.

236  { mInactive = n; }

References Being::mInactive.

Referenced by GameModifiers::changeAwayMode(), and EventsManager::handleActive().

◆ setHome()

void LocalPlayer::setHome ( )

Definition at line 1845 of file localplayer.cpp.

1846 {
1847  if ((mMap == nullptr) || (socialWindow == nullptr))
1848  return;
1849 
1850  SpecialLayer *const specialLayer = mMap->getSpecialLayer();
1851 
1852  if (specialLayer == nullptr)
1853  return;
1854 
1855  const std::string key = mMap->getProperty("_realfilename", std::string());
1856  Vector pos = mHomes[key];
1857 
1858  if (mAction == BeingAction::SIT)
1859  {
1860  const std::map<std::string, Vector>::const_iterator
1861  iter = mHomes.find(key);
1862 
1863  if (iter != mHomes.end())
1864  {
1866  CAST_S32(pos.y));
1867  }
1868 
1869  if (iter != mHomes.end() && mX == CAST_S32(pos.x)
1870  && mY == CAST_S32(pos.y))
1871  {
1872  mMap->updatePortalTile("",
1874  CAST_S32(pos.x),
1875  CAST_S32(pos.y),
1876  true);
1877 
1878  mHomes.erase(key);
1880  CAST_S32(pos.y));
1881  }
1882  else
1883  {
1884  if (iter != mHomes.end())
1885  {
1886  specialLayer->setTile(CAST_S32(pos.x),
1887  CAST_S32(pos.y), MapItemType::EMPTY);
1888  specialLayer->updateCache();
1889  }
1890 
1891  pos.x = static_cast<float>(mX);
1892  pos.y = static_cast<float>(mY);
1893  mHomes[key] = pos;
1894  mMap->updatePortalTile("home",
1896  mX,
1897  mY,
1898  true);
1900  }
1901  MapItem *const mapItem = specialLayer->getTile(mX, mY);
1902  if (mapItem != nullptr)
1903  {
1904  const int idx = socialWindow->getPortalIndex(mX, mY);
1906  OutfitWindow::keyName(idx)));
1907  }
1908  saveHomes();
1909  }
1910  else
1911  {
1912  MapItem *mapItem = specialLayer->getTile(mX, mY);
1913  int type = 0;
1914 
1915  const std::map<std::string, Vector>::iterator iter = mHomes.find(key);
1916  if (iter != mHomes.end() && mX == pos.x && mY == pos.y)
1917  {
1918  mHomes.erase(key);
1919  saveHomes();
1920  }
1921 
1922  if ((mapItem == nullptr) || mapItem->getType() == MapItemType::EMPTY)
1923  {
1924  if ((mDirection & BeingDirection::UP) != 0)
1925  type = MapItemType::ARROW_UP;
1926  else if ((mDirection & BeingDirection::LEFT) != 0)
1927  type = MapItemType::ARROW_LEFT;
1928  else if ((mDirection & BeingDirection::DOWN) != 0)
1929  type = MapItemType::ARROW_DOWN;
1930  else if ((mDirection & BeingDirection::RIGHT) != 0)
1931  type = MapItemType::ARROW_RIGHT;
1932  }
1933  else
1934  {
1935  type = MapItemType::EMPTY;
1936  }
1937  mMap->updatePortalTile("",
1938  type,
1939  mX,
1940  mY,
1941  true);
1942 
1943  if (type != MapItemType::EMPTY)
1944  {
1946  mapItem = specialLayer->getTile(mX, mY);
1947  if (mapItem != nullptr)
1948  {
1949  const int idx = socialWindow->getPortalIndex(mX, mY);
1951  OutfitWindow::keyName(idx)));
1952  }
1953  }
1954  else
1955  {
1956  specialLayer->setTile(mX, mY, MapItemType::EMPTY);
1957  specialLayer->updateCache();
1959  }
1960  }
1961 }

References SocialWindow::addPortal(), MapItemType::ARROW_DOWN, MapItemType::ARROW_LEFT, MapItemType::ARROW_RIGHT, MapItemType::ARROW_UP, CAST_S32, BeingDirection::DOWN, MapItemType::EMPTY, KeyboardConfig::getKeyShortString(), SocialWindow::getPortalIndex(), Properties::getProperty(), Map::getSpecialLayer(), SpecialLayer::getTile(), MapItem::getType(), MapItemType::HOME, OutfitWindow::keyName(), BeingDirection::LEFT, Being::mAction, Being::mDirection, mHomes, Actor::mMap, Being::mX, Being::mY, SocialWindow::removePortal(), BeingDirection::RIGHT, saveHomes(), MapItem::setName(), SpecialLayer::setTile(), BeingAction::SIT, socialWindow, BeingDirection::UP, SpecialLayer::updateCache(), Map::updatePortalTile(), Vector::x, and Vector::y.

◆ setImitate()

void LocalPlayer::setImitate ( const std::string &  player)

set an imitation player.

Definition at line 2388 of file localplayer.cpp.

2389 {
2390  mPlayerImitated = player;
2391  if (!mPlayerImitated.empty())
2392  {
2393  // TRANSLATORS: imitate command message
2394  std::string msg = strprintf(_("Imitation: %s"), player.c_str());
2395  debugMsg(msg)
2396  }
2397  else
2398  {
2399  // TRANSLATORS: imitate command message
2400  debugMsg(_("Imitation canceled"))
2401  }
2402 }

References _, debugMsg, mPlayerImitated, Actions::msg(), and strprintf().

◆ setLastHitFrom()

void LocalPlayer::setLastHitFrom ( const std::string &  n)
inline

Definition at line 366 of file localplayer.h.

367  { mLastHitFrom = n; }

References mLastHitFrom.

Referenced by Being::takeDamage().

◆ setMap()

void LocalPlayer::setMap ( Map *const  map)
virtual

Sets the map the being is on

Reimplemented from Being.

Definition at line 1828 of file localplayer.cpp.

1829 {
1830  BLOCK_START("LocalPlayer::setMap")
1831  if (map != nullptr)
1832  {
1833  if (socialWindow != nullptr)
1835  }
1836  navigateClean();
1837  mCrossX = 0;
1838  mCrossY = 0;
1839 
1840  Being::setMap(map);
1842  BLOCK_END("LocalPlayer::setMap")
1843 }

References BLOCK_END, BLOCK_START, mCrossX, mCrossY, navigateClean(), Being::setMap(), socialWindow, SocialWindow::updateActiveList(), and updateNavigateList().

Referenced by Game::changeMap(), TmwAthena::CharServerRecv::processChangeMapServer(), EAthena::CharServerRecv::processChangeMapServer(), and ActorManager::setMap().

◆ setMoveState()

void LocalPlayer::setMoveState ( const unsigned int  n)
inline

Definition at line 195 of file localplayer.h.

196  { mMoveState = n; }

References mMoveState.

Referenced by GameModifiers::changeMoveType().

◆ setNewTarget()

Being * LocalPlayer::setNewTarget ( const ActorTypeT  type,
const AllowSort  allowSort 
)

Definition at line 606 of file localplayer.cpp.

608 {
609  if (actorManager != nullptr)
610  {
611  Being *const target = actorManager->findNearestLivingBeing(
612  localPlayer, 20, type, allowSort);
613 
614  if ((target != nullptr) && target != mTarget)
615  setTarget(target);
616 
617  return target;
618  }
619  return nullptr;
620 }

References actorManager, ActorManager::findNearestLivingBeing(), localPlayer, mTarget, and setTarget().

Referenced by Actions::setTarget(), SkillDialog::useSkillDefault(), and SkillDialog::useSkillTarget().

◆ setNextDest()

void LocalPlayer::setNextDest ( const int  x,
const int  y 
)

setting the next destination of the following, in case of warp

Definition at line 2594 of file localplayer.cpp.

2595 {
2596  mNextDestX = x;
2597  mNextDestY = y;
2598 }

References mNextDestX, mNextDestY, x, and y.

Referenced by followMoveTo().

◆ setPseudoAway()

void LocalPlayer::setPseudoAway ( const std::string &  message)
static

Definition at line 2075 of file localplayer.cpp.

2076 {
2077  setAfkMessage(message);
2079 }

References Settings::pseudoAwayMode, setAfkMessage(), and settings.

◆ setRealPos()

void LocalPlayer::setRealPos ( const int  x,
const int  y 
)

Definition at line 2669 of file localplayer.cpp.

2670 {
2671  if (mMap == nullptr)
2672  return;
2673 
2674  SpecialLayer *const layer = mMap->getTempLayer();
2675  if (layer != nullptr)
2676  {
2677  bool cacheUpdated(false);
2678  if (((mCrossX != 0) || (mCrossY != 0)) &&
2679  (layer->getTile(mCrossX, mCrossY) != nullptr) &&
2681  {
2683  layer->updateCache();
2684  cacheUpdated = true;
2685  }
2686 
2687  if (mShowServerPos)
2688  {
2689  const MapItem *const mapItem = layer->getTile(x, y);
2690 
2691  if (mapItem == nullptr ||
2692  mapItem->getType() == MapItemType::EMPTY)
2693  {
2694  if (mX != x && mY != y)
2695  {
2696  layer->setTile(x, y, MapItemType::CROSS);
2697  if (cacheUpdated == false)
2698  layer->updateCache();
2699  }
2700  }
2701  }
2702 
2703  if (mCrossX != x || mCrossY != y)
2704  {
2705  mCrossX = x;
2706  mCrossY = y;
2707  // +++ possible configuration option
2708  fixPos();
2709  }
2710  }
2711  if (mMap->isCustom())
2712  mMap->setWalk(x, y);
2713 }

References MapItemType::CROSS, MapItemType::EMPTY, fixPos(), Map::getTempLayer(), SpecialLayer::getTile(), MapItem::getType(), Map::isCustom(), mCrossX, mCrossY, Actor::mMap, mShowServerPos, Being::mX, Being::mY, SpecialLayer::setTile(), Map::setWalk(), SpecialLayer::updateCache(), x, and y.

Referenced by TmwAthena::PlayerRecv::processWalkResponse(), and EAthena::PlayerRecv::processWalkResponse().

◆ setRename()

void LocalPlayer::setRename ( const bool  r)
inline

Definition at line 421 of file localplayer.h.

422  { mAllowRename = r; }

References mAllowRename.

Referenced by EAthena::CharServerRecv::readPlayerData().

◆ setTarget()

void LocalPlayer::setTarget ( Being *const  target)

Sets the target being of the player.

Definition at line 566 of file localplayer.cpp.

567 {
568  if (target == this && (target != nullptr))
569  return;
570 
571  if (target == mTarget)
572  return;
573 
574  Being *oldTarget = nullptr;
575  if (mTarget != nullptr)
576  {
577  mTarget->untarget();
578  oldTarget = mTarget;
579  }
580 
581  if (mTarget != nullptr)
582  {
584  mTarget->setShowName(false);
585  }
586 
587  mTarget = target;
588 
589  if (oldTarget != nullptr)
590  oldTarget->updateName();
591 
592  if (target != nullptr)
593  {
594  mLastTargetX = target->mX;
595  mLastTargetY = target->mY;
596  target->updateName();
598  target->setShowName(true);
599  }
600  if (oldTarget != nullptr && mVisibleNames == VisibleName::ShowOnSelection)
601  oldTarget->setShowName(false);
602  if (target != nullptr && target->getType() == ActorType::Monster)
603  target->setShowName(true);
604 }

References Being::getType(), mLastTargetX, mLastTargetY, ActorType::Monster, mTarget, mVisibleNames, Being::mX, Being::mY, Being::setShowName(), VisibleName::ShowOnSelection, ActorSprite::untarget(), and Being::updateName().

Referenced by attack(), attack2(), ActorManager::clear(), followMoveTo(), ActorManager::logic(), setAction(), setGotoTarget(), setNewTarget(), untarget(), and ActorSprite::~ActorSprite().

◆ setTestParticle()

void LocalPlayer::setTestParticle ( const std::string &  fileName,
const bool  updateHash 
)

◆ setTileCoords()

void LocalPlayer::setTileCoords ( const int  x,
const int  y 
)
virtual

◆ setWalkingDir()

void LocalPlayer::setWalkingDir ( const unsigned char  dir)

Sets a new direction to keep walking in.

Definition at line 663 of file localplayer.cpp.

664 {
665  // This function is called by Game::handleInput()
666  mWalkingDir = dir;
667 
668  // If we're not already walking, start walking.
669  if (mAction != BeingAction::MOVE && (dir != 0U))
670  startWalking(dir);
671 }

References Being::mAction, BeingAction::MOVE, mWalkingDir, and startWalking().

Referenced by CrazyMoves::crazyMove1(), CrazyMoves::crazyMove2(), and specialMove().

◆ slowLogic()

void LocalPlayer::slowLogic ( )

Definition at line 356 of file localplayer.cpp.

357 {
358  BLOCK_START("LocalPlayer::slowLogic")
359  const time_t time = cur_time;
360  if ((weightNotice != nullptr) && weightNoticeTime < time)
361  {
363  weightNotice = nullptr;
364  weightNoticeTime = 0;
365  }
366 
367  if ((serverFeatures != nullptr) &&
369  mEnableAdvert &&
370  !mBlockAdvert &&
372  {
373  uint8_t smile = BeingFlag::SPECIAL;
374  if (mTradebot &&
375  shopWindow != nullptr &&
377  {
378  smile |= BeingFlag::SHOP;
379  }
380 
382  smile |= BeingFlag::AWAY;
383 
384  if (mInactive)
385  smile |= BeingFlag::INACTIVE;
386 
387  if (emote(smile))
388  mAdvertTime = time + 60;
389  else
390  mAdvertTime = time + 30;
391  }
392 
393  if (mTestParticleTime != time && !mTestParticleName.empty())
394  {
395  const unsigned long hash = UpdaterWindow::getFileHash(
397  if (hash != mTestParticleHash)
398  {
400  mTestParticleHash = hash;
401  }
402  mTestParticleTime = time;
403  }
404 
405  BLOCK_END("LocalPlayer::slowLogic")
406 }

References BeingFlag::AWAY, Settings::awayMode, BLOCK_END, BLOCK_START, cur_time, emote(), UpdaterWindow::getFileHash(), Net::ServerFeatures::havePlayerStatusUpdate(), BeingFlag::INACTIVE, ShopWindow::isShopEmpty(), mAdvertTime, mBlockAdvert, mEnableAdvert, Being::mInactive, mTestParticleHash, mTestParticleName, mTestParticleTime, mTradebot, Settings::pseudoAwayMode, Window::scheduleDelete(), serverFeatures, setTestParticle(), settings, BeingFlag::SHOP, shopWindow, BeingFlag::SPECIAL, weightNotice, and weightNoticeTime.

Referenced by Game::slowLogic().

◆ specialMove()

void LocalPlayer::specialMove ( const unsigned char  direction)

Definition at line 1718 of file localplayer.cpp.

1719 {
1720  if ((direction != 0U) && ((mNavigateX != 0) || (mNavigateY != 0)))
1721  navigateClean();
1722 
1723  if ((direction != 0U) && (settings.moveType >= 2
1724  && settings.moveType <= 4))
1725  {
1726  if (mAction == BeingAction::MOVE)
1727  return;
1728 
1729  unsigned int max;
1730 
1731  if (settings.moveType == 2)
1732  max = 5;
1733  else if (settings.moveType == 4)
1734  max = 1;
1735  else
1736  max = 3;
1737 
1738  if (getMoveState() < max)
1739  {
1740  moveByDirection(direction);
1741  mMoveState ++;
1742  }
1743  else
1744  {
1745  mMoveState = 0;
1746  crazyMoves->crazyMove();
1747  }
1748  }
1749  else
1750  {
1751  setWalkingDir(direction);
1752  }
1753 }

References CrazyMoves::crazyMove(), crazyMoves, getMoveState(), Being::mAction, mMoveState, mNavigateX, mNavigateY, BeingAction::MOVE, moveByDirection(), Settings::moveType, navigateClean(), settings, and setWalkingDir().

Referenced by Game::moveInDirection().

◆ startWalking()

void LocalPlayer::startWalking ( const unsigned char  dir)
protected

Definition at line 673 of file localplayer.cpp.

674 {
675  // This function is called by setWalkingDir(),
676  // but also by nextTile() for TMW-Athena...
677  if ((mMap == nullptr) || (dir == 0U))
678  return;
679 
680  mPickUpTarget = nullptr;
681  if (mAction == BeingAction::MOVE && !mPath.empty())
682  {
683  // Just finish the current action, otherwise we get out of sync
685  return;
686  }
687 
688  int dx = 0;
689  int dy = 0;
690  if ((dir & BeingDirection::UP) != 0)
691  dy--;
692  if ((dir & BeingDirection::DOWN) != 0)
693  dy++;
694  if ((dir & BeingDirection::LEFT) != 0)
695  dx--;
696  if ((dir & BeingDirection::RIGHT) != 0)
697  dx++;
698 
699  const unsigned char blockWalkMask = getBlockWalkMask();
700  // Prevent skipping corners over colliding tiles
701  if ((dx != 0) && !mMap->getWalk(mX + dx, mY, blockWalkMask))
702  dx = 0;
703  if ((dy != 0) && !mMap->getWalk(mX, mY + dy, blockWalkMask))
704  dy = 0;
705 
706  // Choose a straight direction when diagonal target is blocked
707  if (dx != 0 && dy != 0 && !mMap->getWalk(mX + dx, mY + dy, blockWalkMask))
708  dx = 0;
709 
710  // Walk to where the player can actually go
711  if ((dx != 0 || dy != 0) && mMap->getWalk(mX + dx, mY + dy, blockWalkMask))
712  {
713  setDestination(mX + dx, mY + dy);
714  }
715  else if (dir != mDirection)
716  {
717  // If the being can't move, just change direction
718 
719 // if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
720  {
722  setDirection(dir);
723  }
724  }
725 }

References blockWalkMask, BeingDirection::DOWN, getBlockWalkMask(), Map::getWalk(), BeingDirection::LEFT, Being::mAction, Being::mDirection, Actor::mMap, BeingAction::MOVE, Being::mPath, mPickUpTarget, Being::mX, Being::mY, playerHandler, BeingDirection::RIGHT, setDestination(), Being::setDestination(), Net::PlayerHandler::setDirection(), Being::setDirection(), and BeingDirection::UP.

Referenced by nextTile(), and setWalkingDir().

◆ stopAdvert()

void LocalPlayer::stopAdvert ( )

Definition at line 2841 of file localplayer.cpp.

2842 {
2843  mBlockAdvert = true;
2844 }

References mBlockAdvert.

Referenced by EAthena::SkillRecv::processSkillFailed(), and TmwAthena::SkillRecv::processSkillFailed().

◆ stopAttack()

void LocalPlayer::stopAttack ( const bool  keepAttack)

◆ stopWalking()

void LocalPlayer::stopWalking ( const bool  sendToServer)

Stops the player dead in his tracks

Definition at line 727 of file localplayer.cpp.

728 {
729  if (mAction == BeingAction::MOVE && (mWalkingDir != 0U))
730  {
731  mWalkingDir = 0;
732  mPickUpTarget = nullptr;
734  mPixelY);
735  if (sendToServer)
736  {
738  mPixelX,
739  mPixelY,
740  -1);
741  }
743  }
744 
745  // No path set anymore, so we reset the path by mouse flag
746  mPathSetByMouse = false;
747 
748  clearPath();
749  navigateClean();
750 }

References Being::clearPath(), Being::mAction, BeingAction::MOVE, mPathSetByMouse, mPickUpTarget, Actor::mPixelX, Actor::mPixelY, mWalkingDir, navigateClean(), playerHandler, setAction(), Net::PlayerHandler::setDestination(), setDestination(), and BeingAction::STAND.

Referenced by TmwAthena::NpcHandler::getNpc(), and EAthena::NpcHandler::getNpc().

◆ targetMoved()

void LocalPlayer::targetMoved ( ) const

Definition at line 2266 of file localplayer.cpp.

2267 {
2268 /*
2269  if (mKeepAttacking)
2270  {
2271  if (mTarget && mServerAttack == Keep_true)
2272  {
2273  logger->log("LocalPlayer::targetMoved0");
2274  if (!PacketLimiter::limitPackets(PacketType::PACKET_ATTACK))
2275  return;
2276  logger->log("LocalPlayer::targetMoved");
2277  playerHandler->attack(mTarget->getId(), mServerAttack);
2278  }
2279  }
2280 */
2281 }

◆ toggleSit()

bool LocalPlayer::toggleSit ( ) const

Definition at line 752 of file localplayer.cpp.

753 {
755  return false;
756 
757  BeingActionT newAction;
758  switch (mAction)
759  {
760  case BeingAction::STAND:
762  case BeingAction::SPAWN:
763  newAction = BeingAction::SIT;
764  break;
765  case BeingAction::SIT:
766  newAction = BeingAction::STAND;
767  break;
768  case BeingAction::MOVE:
769  case BeingAction::ATTACK:
770  case BeingAction::DEAD:
771  case BeingAction::HURT:
772  case BeingAction::CAST:
773  default:
774  return true;
775  }
776 
777  playerHandler->changeAction(newAction);
778  return true;
779 }

References BeingAction::ATTACK, BeingAction::CAST, Net::PlayerHandler::changeAction(), BeingAction::DEAD, BeingAction::HURT, PacketLimiter::limitPackets(), Being::mAction, BeingAction::MOVE, PacketType::PACKET_SIT, playerHandler, BeingAction::PRESTAND, BeingAction::SIT, BeingAction::SPAWN, and BeingAction::STAND.

Referenced by CrazyMoves::crazyMoveAs(), and Actions::doSit().

◆ tryMagic()

void LocalPlayer::tryMagic ( const std::string &  spell,
const int  baseMagic,
const int  schoolMagic,
const int  mana 
)
staticprotected

Definition at line 1794 of file localplayer.cpp.

1796 {
1797  if (chatWindow == nullptr)
1798  return;
1799 
1800  if (PlayerInfo::getSkillLevel(340) >= baseMagic
1801  && PlayerInfo::getSkillLevel(342) >= schoolMagic)
1802  {
1804  {
1806  return;
1807 
1808  chatWindow->localChatInput(spell);
1809  }
1810  }
1811 }

References chatWindow, PlayerInfo::getAttribute(), PlayerInfo::getSkillLevel(), PacketLimiter::limitPackets(), ChatWindow::localChatInput(), PacketType::PACKET_CHAT, and Attributes::PLAYER_MP.

Referenced by magicAttack().

◆ tryPingRequest()

void LocalPlayer::tryPingRequest ( )

Definition at line 2041 of file localplayer.cpp.

2042 {
2043  if (mPingSendTick == 0 || tick_time < mPingSendTick
2044  || (tick_time - mPingSendTick) > 200)
2045  {
2046  pingRequest();
2047  }
2048 }

References mPingSendTick, pingRequest(), and tick_time.

Referenced by DebugWindow::slowLogic().

◆ unSetPickUpTarget()

void LocalPlayer::unSetPickUpTarget ( )
inline

Definition at line 324 of file localplayer.h.

325  { mPickUpTarget = nullptr; }

References mPickUpTarget.

Referenced by ActorManager::clear(), and ActorManager::logic().

◆ untarget()

void LocalPlayer::untarget ( )

Definition at line 877 of file localplayer.cpp.

878 {
881 
882  if (mTarget != nullptr)
883  setTarget(nullptr);
884 }

References BeingAction::ATTACK, Being::mAction, mTarget, setAction(), setTarget(), and BeingAction::STAND.

Referenced by stopAttack().

◆ updateCoords()

void LocalPlayer::updateCoords ( )
protectedvirtual

Updates name's location.

Reimplemented from Being.

Definition at line 2194 of file localplayer.cpp.

2195 {
2197 
2198  // probably map not loaded.
2199  if ((mPixelX == 0) || (mPixelY == 0))
2200  return;
2201 
2202  if (mX != mOldTileX || mY != mOldTileY)
2203  {
2204  if (socialWindow != nullptr)
2207  updateMusic();
2208  }
2209 
2210  if ((mMap != nullptr) && (mX != mOldTileX || mY != mOldTileY))
2211  {
2212  SpecialLayer *const tmpLayer = mMap->getTempLayer();
2213  if (tmpLayer == nullptr)
2214  return;
2215 
2216  const int x = (mPixelX - mapTileSize / 2) / mapTileSize;
2217  const int y = (mPixelY - mapTileSize) / mapTileSize;
2218  if (mNavigateId != BeingId_zero)
2219  {
2220  if (actorManager == nullptr)
2221  {
2222  navigateClean();
2223  return;
2224  }
2225 
2226  const Being *const being = actorManager
2228  if (being == nullptr)
2229  {
2230  navigateClean();
2231  return;
2232  }
2233  mNavigateX = being->mX;
2234  mNavigateY = being->mY;
2235  }
2236 
2237  if (mNavigateX == x && mNavigateY == y)
2238  {
2239  navigateClean();
2240  return;
2241  }
2242  for (Path::const_iterator i = mNavigatePath.begin(),
2243  i_fend = mNavigatePath.end();
2244  i != i_fend;
2245  ++i)
2246  {
2247  if ((*i).x == mX && (*i).y == mY)
2248  {
2249  mNavigatePath.pop_front();
2250  fixPos();
2251  break;
2252  }
2253  }
2254  if (mDrawPath && mShowNavigePath)
2255  {
2256  tmpLayer->clean();
2257  tmpLayer->addRoad(mNavigatePath);
2258  }
2259  }
2260  mOldX = mPixelX;
2261  mOldY = mPixelY;
2262  mOldTileX = mX;
2263  mOldTileY = mY;
2264 }

References actorManager, SpecialLayer::addRoad(), BeingId_zero, SpecialLayer::clean(), ActorManager::findBeing(), fixPos(), Map::getTempLayer(), PopupManager::hideBeingPopup(), mapTileSize, mDrawPath, Actor::mMap, mNavigateId, mNavigatePath, mNavigateX, mNavigateY, mOldTileX, mOldTileY, mOldX, mOldY, Actor::mPixelX, Actor::mPixelY, mShowNavigePath, Being::mX, Being::mY, navigateClean(), socialWindow, Being::updateCoords(), updateMusic(), SocialWindow::updatePortals(), x, and y.

◆