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 50 of file localplayer.h.

Member Typedef Documentation

◆ MessagePair

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

Definition at line 478 of file localplayer.h.

Constructor & Destructor Documentation

◆ LocalPlayer()

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

Constructor.

Definition at line 114 of file localplayer.cpp.

115  :
120  mMoveState(0),
121  mLastTargetX(0),
122  mLastTargetY(0),
123  mHomes(),
124  mTarget(nullptr),
125  mPlayerFollowed(),
126  mPlayerImitated(),
127  mNextDestX(0),
128  mNextDestY(0),
129  mPickUpTarget(nullptr),
130  mLastAction(-1),
132  mMessages(),
133  mMessageTime(0),
135  mAwayDialog(nullptr),
136  mPingSendTick(0),
137  mPingTime(0),
138  mAfkTime(0),
139  mActivityTime(0),
140  mNavigateX(0),
141  mNavigateY(0),
143  mCrossX(0),
144  mCrossY(0),
145  mOldX(0),
146  mOldY(0),
147  mOldTileX(0),
148  mOldTileY(0),
149  mNavigatePath(),
150  mLastHitFrom(),
151  mWaitFor(),
152  mAdvertTime(0),
153  mTestParticle(nullptr),
156  mTestParticleHash(0L),
157  mSyncPlayerMoveDistance(config.getIntValue("syncPlayerMoveDistance")),
158  mUnfreezeTime(0),
159  mWalkingDir(0),
160  mUpdateName(true),
161  mBlockAdvert(false),
162  mTargetDeadPlayers(config.getBoolValue("targetDeadPlayers")),
163  mServerAttack(fromBool(config.getBoolValue("serverAttack"), Keep)),
164  mVisibleNames(static_cast<VisibleName::Type>(
165  config.getIntValue("visiblenames"))),
166  mEnableAdvert(config.getBoolValue("enableAdvert")),
167  mTradebot(config.getBoolValue("tradebot")),
168  mTargetOnlyReachable(config.getBoolValue("targetOnlyReachable")),
169  mIsServerBuggy(serverConfig.getValueBool("enableBuggyServers", true)),
170  mSyncPlayerMove(config.getBoolValue("syncPlayerMove")),
171  mDrawPath(config.getBoolValue("drawPath")),
172  mAttackMoving(config.getBoolValue("attackMoving")),
173  mAttackNext(config.getBoolValue("attackNext")),
174  mShowJobExp(config.getBoolValue("showJobExp")),
175  mShowServerPos(config.getBoolValue("showserverpos")),
176  mNextStep(false),
177  mGoingToTarget(false),
178  mKeepAttacking(false),
179  mPathSetByMouse(false),
180  mWaitPing(false),
181  mShowNavigePath(false),
182  mAllowRename(false),
183  mFreezed(false)
184 {
185  logger->log1("LocalPlayer::LocalPlayer");
186 
187 #ifdef TMWA_SUPPORT
189  {
191  config.getIntValue("syncPlayerMoveDistanceLegacy");
192  }
193 #endif
194 
195  postInit(subType, nullptr);
196  mAttackRange = 0;
197  mLevel = 1;
198  mAdvanced = true;
199  mTextColor = &theme->getColor(ThemeColorId::PLAYER, 255);
200  if (userPalette != nullptr)
202  else
203  mNameColor = nullptr;
204 
206  getWalkSpeed(),
207  Notify_true);
209  0,
210  Notify_true);
211 
212  loadHomes();
213 
214  config.addListener("showownname", this);
215  config.addListener("targetDeadPlayers", this);
216  serverConfig.addListener("enableBuggyServers", this);
217  config.addListener("syncPlayerMove", this);
218  config.addListener("syncPlayerMoveDistance", this);
219 #ifdef TMWA_SUPPORT
220  config.addListener("syncPlayerMoveDistanceLegacy", this);
221 #endif
222  config.addListener("drawPath", this);
223  config.addListener("serverAttack", this);
224  config.addListener("attackMoving", this);
225  config.addListener("attackNext", this);
226  config.addListener("showJobExp", this);
227  config.addListener("enableAdvert", this);
228  config.addListener("tradebot", this);
229  config.addListener("targetOnlyReachable", this);
230  config.addListener("showserverpos", this);
231  config.addListener("visiblenames", this);
232  setShowName(config.getBoolValue("showownname"));
233 }
const BeingId BeingId_zero
Definition: beingid.h:30
#define fromBool(val, name)
Definition: booldefines.h:49
Being(const BeingId id, const ActorTypeT type)
Definition: being.cpp:162
int getWalkSpeed() const
Definition: being.h:458
const Color * mNameColor
Definition: being.h:1192
const Color * mTextColor
Definition: being.h:1199
int mAttackRange
Definition: being.h:1222
void postInit(const BeingTypeId subType, Map *const map)
Definition: being.cpp:289
void setShowName(const bool doShowName)
Definition: being.cpp:1166
bool mAdvanced
Definition: being.h:1380
int mLevel
Definition: being.h:1220
bool getValueBool(const std::string &key, const bool deflt) const
bool getBoolValue(const std::string &key) const
void addListener(const std::string &key, ConfigListener *const listener)
int getIntValue(const std::string &key) const
AwayListener * mAwayListener
Definition: localplayer.h:482
bool mTargetDeadPlayers
Definition: localplayer.h:513
bool mShowJobExp
Definition: localplayer.h:524
std::string mTestParticleName
Definition: localplayer.h:504
bool mUpdateName
Definition: localplayer.h:511
int mUnfreezeTime
Definition: localplayer.h:508
std::vector< int32_t > mStatusEffectIcons
Definition: localplayer.h:476
bool mWaitPing
Definition: localplayer.h:533
bool mAllowRename
Definition: localplayer.h:535
bool mAttackMoving
Definition: localplayer.h:522
int mMessageTime
Definition: localplayer.h:481
Path mNavigatePath
Definition: localplayer.h:498
FloorItem * mPickUpTarget
Definition: localplayer.h:472
int mLastTargetY
Definition: localplayer.h:460
time_t mAdvertTime
Definition: localplayer.h:502
unsigned char mWalkingDir
Definition: localplayer.h:509
bool mKeepAttacking
Definition: localplayer.h:530
bool mIsServerBuggy
Definition: localplayer.h:519
time_t mAfkTime
Definition: localplayer.h:487
std::list< MessagePair > mMessages
Definition: localplayer.h:480
OkDialog * mAwayDialog
Definition: localplayer.h:483
bool mGoingToTarget
Definition: localplayer.h:528
bool mEnableAdvert
Definition: localplayer.h:516
bool mShowNavigePath
Definition: localplayer.h:534
bool mTradebot
Definition: localplayer.h:517
bool mAttackNext
Definition: localplayer.h:523
bool mBlockAdvert
Definition: localplayer.h:512
time_t mTestParticleTime
Definition: localplayer.h:505
unsigned int mMoveState
Definition: localplayer.h:457
unsigned long mTestParticleHash
Definition: localplayer.h:506
std::string mPlayerImitated
Definition: localplayer.h:468
bool mTargetOnlyReachable
Definition: localplayer.h:518
Being * mTarget
Definition: localplayer.h:464
int mPingSendTick
Definition: localplayer.h:485
VisibleName::Type mVisibleNames
Definition: localplayer.h:515
Particle * mTestParticle
Definition: localplayer.h:503
std::string mPlayerFollowed
Definition: localplayer.h:467
BeingId mNavigateId
Definition: localplayer.h:491
bool mPathSetByMouse
Definition: localplayer.h:532
std::string mLastHitFrom
Definition: localplayer.h:500
time_t mActivityTime
Definition: localplayer.h:488
std::string mWaitFor
Definition: localplayer.h:501
bool mDrawPath
Definition: localplayer.h:521
void loadHomes()
time_t mPingTime
Definition: localplayer.h:486
bool mShowServerPos
Definition: localplayer.h:525
bool mNextStep
Definition: localplayer.h:526
int mLastTargetX
Definition: localplayer.h:459
bool mSyncPlayerMove
Definition: localplayer.h:520
int mSyncPlayerMoveDistance
Definition: localplayer.h:507
Keep mServerAttack
Definition: localplayer.h:514
std::map< std::string, Vector > mHomes
Definition: localplayer.h:462
void log1(const char *const log_text)
Definition: logger.cpp:238
const Color & getColor(const ThemeColorIdT type, const unsigned int alpha)
Definition: theme.h:136
const Color & getColor(UserColorIdT type, const unsigned int alpha)
Definition: userpalette.h:160
Configuration config
Configuration serverConfig
bool Keep
Definition: keep.h:30
Logger * logger
Definition: logger.cpp:89
@ PLAYER_WALK_SPEED
Definition: attributes.h:53
ServerTypeT getNetworkType()
Definition: net.cpp:189
void setStatMod(const AttributesT id, const int value, const Notify notify)
Definition: playerinfo.cpp:159
void setStatBase(const AttributesT id, const int value, const Notify notify)
Definition: playerinfo.cpp:143
const bool Notify_true
Definition: notify.h:30
Theme * theme
Definition: theme.cpp:62
UserPalette * userPalette
Definition: userpalette.cpp:34

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 235 of file localplayer.cpp.

236 {
237  logger->log1("LocalPlayer::~LocalPlayer");
238 
239  config.removeListeners(this);
240  serverConfig.removeListener("enableBuggyServers", this);
241 
242  navigateClean();
243  mCrossX = 0;
244  mCrossY = 0;
245 
247 
248  if (mAwayDialog != nullptr)
249  {
252  }
254 }
void removeListener(const std::string &key, ConfigListener *const listener)
void removeListeners(ConfigListener *const listener)
void updateNavigateList()
void navigateClean()
void volumeRestore() const
#define delete2(var)
Definition: delete2.h:25
SoundManager soundManager

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 556 of file localplayer.cpp.

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

References mPickUpTarget.

◆ addHomunXpMessage()

void LocalPlayer::addHomunXpMessage ( const int  change)

Definition at line 1256 of file localplayer.cpp.

1257 {
1258  if (change != 0 && mMessages.size() < 20)
1259  {
1260  addMessageToQueue(strprintf("%s %d %s",
1261  // TRANSLATORS: get homunculus xp message
1262  _("Homun"),
1263  change,
1264  // TRANSLATORS: get xp message
1265  _("xp")),
1267  }
1268 }
void addMessageToQueue(const std::string &message, const UserColorIdT color)
#define _(s)
Definition: gettext.h:35
std::string strprintf(const char *const format,...)

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

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

◆ addHpMessage()

void LocalPlayer::addHpMessage ( const int  change)

Definition at line 1270 of file localplayer.cpp.

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

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

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

◆ addJobMessage()

void LocalPlayer::addJobMessage ( const int64_t  change)

Definition at line 1204 of file localplayer.cpp.

1205 {
1206  if (change != 0 && mMessages.size() < 20)
1207  {
1208  const std::string xpStr = toString(CAST_U64(change));
1209  if (!mMessages.empty())
1210  {
1211  MessagePair pair = mMessages.back();
1212  // TRANSLATORS: this is normal experience
1213  if (pair.first.find(strprintf(" %s", _("xp"))) ==
1214  // TRANSLATORS: this is normal experience
1215  pair.first.size() - strlen(_("xp")) - 1)
1216  {
1217  mMessages.pop_back();
1218  pair.first.append(strprintf(", %s %s",
1219  xpStr.c_str(),
1220  // TRANSLATORS: this is job experience
1221  _("job")));
1222  mMessages.push_back(pair);
1223  }
1224  else
1225  {
1226  addMessageToQueue(strprintf("%s %s",
1227  xpStr.c_str(),
1228  // TRANSLATORS: this is job experience
1229  _("job")),
1231  }
1232  }
1233  else
1234  {
1235  addMessageToQueue(strprintf("%s %s",
1236  xpStr.c_str(),
1237  // TRANSLATORS: this is job experience
1238  _("job")),
1240  }
1241  }
1242 }
#define CAST_U64
Definition: cast.h:33
std::pair< std::string, UserColorIdT > MessagePair
Definition: localplayer.h:478
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774

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 1116 of file localplayer.cpp.

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

References mMessages.

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

◆ addSpMessage()

void LocalPlayer::addSpMessage ( const int  change)

Definition at line 1280 of file localplayer.cpp.

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

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

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

◆ addXpMessage()

void LocalPlayer::addXpMessage ( const int64_t  change)

Definition at line 1244 of file localplayer.cpp.

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

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 2082 of file localplayer.cpp.

2083 {
2084  if (settings.awayMode)
2085  {
2086  const time_t time = cur_time;
2087  if (mAfkTime == 0 || time < mAfkTime
2088  || time - mAfkTime > awayLimitTimer)
2089  {
2090  std::string str(serverConfig.getValue("afkMessage",
2091  "I am away from keyboard."));
2092  if (str.find("'NAME'") != std::string::npos)
2093  replaceAll(str, "'NAME'", nick);
2094 
2095  std::string msg("*AFK*: " + str);
2096 
2097  if (config.getIntValue("afkFormat") == 1)
2098  msg = "*" + msg + "*";
2099 
2100  if (tab == nullptr)
2101  {
2102  chatHandler->privateMessage(nick, msg);
2103  if (localChatTab != nullptr)
2104  {
2105  localChatTab->chatLog(std::string(mName).append(
2106  " : ").append(msg),
2110  }
2111  }
2112  else
2113  {
2114  if (tab->getNoAway())
2115  return;
2116  chatHandler->privateMessage(nick, msg);
2117  tab->chatLog(mName, msg);
2118  }
2119  mAfkTime = time;
2120  }
2121  }
2122 }
volatile time_t cur_time
Definition: timer.cpp:58
Net::ChatHandler * chatHandler
Definition: net.cpp:86
ChatTab * localChatTab
Definition: chattab.cpp:62
std::string mName
Definition: being.h:1180
bool getNoAway() const
Definition: chattab.h:170
void chatLog(std::string line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
Definition: chattab.cpp:111
std::string getValue(const std::string &key, const std::string &deflt) const
virtual void privateMessage(const std::string &recipient, const std::string &text) const =0
bool awayMode
Definition: settings.h:158
const bool IgnoreRecord_false
Definition: ignorerecord.h:30
static const int16_t awayLimitTimer
bool msg(InputEvent &event)
Definition: chat.cpp:39
Settings settings
Definition: settings.cpp:32
std::string & replaceAll(std::string &context, const std::string &from, const std::string &to)
const bool TryRemoveColors_true

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 2601 of file localplayer.cpp.

2602 {
2603  if (mIsServerBuggy)
2604  {
2605  if (mLastAction != -1)
2606  return false;
2608  }
2609  return true;
2610 }
volatile int tick_time
Definition: timer.cpp:53

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 800 of file localplayer.cpp.

803 {
804  mKeepAttacking = keep;
805 
806  if ((target == nullptr) || target->getType() == ActorType::Npc)
807  return;
808 
809  if (mTarget != target)
810  setTarget(target);
811 
812  // Must be standing or sitting or casting to attack
813  if (mAction != BeingAction::STAND &&
816  {
817  return;
818  }
819 
820 #ifdef TMWA_SUPPORT
821  const int dist_x = target->mX - mX;
822  const int dist_y = target->mY - mY;
823 
825  {
826  if (abs(dist_y) >= abs(dist_x))
827  {
828  if (dist_y > 0)
830  else
832  }
833  else
834  {
835  if (dist_x > 0)
837  else
839  }
840  }
841 #endif // TMWA_SUPPORT
842 
844 
845  if (target->getType() != ActorType::Player
846  || checAttackPermissions(target))
847  {
849 
851  return;
852 
853  if (!dontChangeEquipment)
855 
856  const BeingId targetId = target->getId();
857  playerHandler->attack(targetId, mServerAttack);
859  }
860 
861  if (!keep)
862  stopAttack(false);
863 }
int BeingId
Definition: beingid.h:30
BeingId getId() const
Definition: actorsprite.h:64
virtual void setDirection(const uint8_t direction)
Definition: being.cpp:1690
int mX
Definition: being.h:1314
int mY
Definition: being.h:1315
int mActionTime
Definition: being.h:1213
BeingActionT mAction
Definition: being.h:1229
ActorTypeT getType() const
Definition: being.h:116
static bool checAttackPermissions(const Being *const target)
void setTarget(Being *const target)
void setAction(const BeingActionT &action, const int attackId)
void stopAttack(const bool keepAttack)
void changeEquipmentBeforeAttack(const Being *const target) const
virtual void attack(const BeingId id, const Keep keep) const =0
bool limitPackets(const PacketTypeT type)
@ PACKET_ATTACK
Definition: packettype.h:38
void updateAttackAi(const BeingId targetId, const Keep keep)
Definition: playerinfo.cpp:618
Net::PlayerHandler * playerHandler
Definition: net.cpp:96

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 2327 of file localplayer.cpp.

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

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 1290 of file localplayer.cpp.

1293 {
1294  PRAGMA45(GCC diagnostic push)
1295  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
1296  switch (id)
1297  {
1299  {
1301  break;
1302  if (oldVal > newVal)
1303  break;
1304 
1305  const int change = CAST_S32(newVal - oldVal);
1306  addXpMessage(change);
1307  break;
1308  }
1310  mLevel = CAST_S32(newVal);
1311  break;
1312  case Attributes::PLAYER_HP:
1313  if (oldVal != 0 && newVal == 0)
1315  break;
1317  {
1318  if (!mShowJobExp ||
1320  {
1321  return;
1322  }
1323  if (oldVal > newVal ||
1326  {
1327  return;
1328  }
1329  const int32_t change = CAST_S32(newVal - oldVal);
1330  addJobMessage(change);
1331  break;
1332  }
1333  default:
1334  break;
1335  }
1336  PRAGMA45(GCC diagnostic pop)
1337 }
#define CAST_S32
Definition: cast.h:30
void addJobMessage(const int64_t change)
void addXpMessage(const int64_t change)
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wredundant-decls") PRAGMA45(GCC diagnostic pop) class TestMain
@ PLAYER_BASE_LEVEL
Definition: attributes.h:31
@ PLAYER_JOB_EXP
Definition: attributes.h:66
@ PLAYER_JOB_EXP_NEEDED
Definition: attributes.h:67
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:102

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 2405 of file localplayer.cpp.

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

References _, debugMsg, mPlayerFollowed, and mPlayerImitated.

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

◆ canMove()

bool LocalPlayer::canMove ( ) const

Definition at line 2919 of file localplayer.cpp.

2920 {
2921  return !mFreezed &&
2925 }
virtual bool haveMoveWhileSit() const =0
Net::ServerFeatures * serverFeatures
Definition: net.cpp:101

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 1462 of file localplayer.cpp.

1463 {
1464  if (settings.attackWeaponType == 1
1465  || (target == nullptr)
1466  || (PlayerInfo::getInventory() == nullptr))
1467  {
1468  return;
1469  }
1470 
1471  bool allowSword = false;
1472  const int dx = target->mX - mX;
1473  const int dy = target->mY - mY;
1474  const Item *item = nullptr;
1475 
1476  if (dx * dx + dy * dy > 80)
1477  return;
1478 
1479  if (dx * dx + dy * dy < 8)
1480  allowSword = true;
1481 
1482  const Inventory *const inv = PlayerInfo::getInventory();
1483  if (inv == nullptr)
1484  return;
1485 
1486  // if attack distance for sword
1487  if (allowSword)
1488  {
1489  // searching swords
1490  const WeaponsInfos &swords = WeaponsDB::getSwords();
1491  FOR_EACH (WeaponsInfosIter, it, swords)
1492  {
1493  item = inv->findItem(*it, ItemColor_zero);
1494  if (item != nullptr)
1495  break;
1496  }
1497 
1498  // no swords
1499  if (item == nullptr)
1500  return;
1501 
1502  // if sword not equiped
1503  if (item->isEquipped() == Equipped_false)
1505 
1506  // if need equip shield too
1507  if (settings.attackWeaponType == 3)
1508  {
1509  // searching shield
1510  const WeaponsInfos &shields = WeaponsDB::getShields();
1511  FOR_EACH (WeaponsInfosIter, it, shields)
1512  {
1513  item = inv->findItem(*it, ItemColor_zero);
1514  if (item != nullptr)
1515  break;
1516  }
1517  if ((item != nullptr) && item->isEquipped() == Equipped_false)
1519  }
1520  }
1521  // big distance. allowed only bow
1522  else
1523  {
1524  // searching bow
1525  const WeaponsInfos &bows = WeaponsDB::getBows();
1526  FOR_EACH (WeaponsInfosIter, it, bows)
1527  {
1528  item = inv->findItem(*it, ItemColor_zero);
1529  if (item != nullptr)
1530  break;
1531  }
1532 
1533  // no bow
1534  if (item == nullptr)
1535  return;
1536 
1537  if (item->isEquipped() == Equipped_false)
1539  }
1540 }
Item * findItem(const int itemId, const ItemColor color) const
Definition: inventory.cpp:94
Definition: item.h:50
Equipped isEquipped() const
Definition: item.h:129
unsigned int attackWeaponType
Definition: settings.h:137
const bool Equipped_false
Definition: equipped.h:30
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
const ItemColor ItemColor_zero
Definition: itemcolor.h:30
Inventory * getInventory()
Definition: playerinfo.cpp:195
void equipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:238
const WeaponsInfos & getShields()
Definition: weaponsdb.cpp:83
const WeaponsInfos & getSwords()
Definition: weaponsdb.cpp:78
const WeaponsInfos & getBows()
Definition: weaponsdb.cpp:73
const bool Sfx_true
Definition: sfx.h:30
std::vector< int > WeaponsInfos
Definition: weaponsdb.h:29
WeaponsInfos::const_iterator WeaponsInfosIter
Definition: weaponsdb.h:30

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 2847 of file localplayer.cpp.

2848 {
2849  if (target == nullptr)
2850  return false;
2851 
2852  switch (settings.pvpAttackType)
2853  {
2854  case 0:
2855  return true;
2856  case 1:
2857  return !(playerRelations.getRelation(target->mName)
2858  == Relation::FRIEND);
2859  case 2:
2860  return playerRelations.checkBadRelation(target->mName);
2861  default:
2862  case 3:
2863  return false;
2864  }
2865 }
RelationT getRelation(const std::string &name) const
bool checkBadRelation(const std::string &name) const
unsigned int pvpAttackType
Definition: settings.h:142
@ FRIEND
Definition: relation.h:32
PlayerRelationsManager playerRelations

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 2782 of file localplayer.cpp.

2783 {
2784  if (being == nullptr)
2785  return;
2786 
2787  const std::string &nick = being->mName;
2788  if (being->getType() == ActorType::Player)
2789  {
2790  const Guild *const guild = getGuild();
2791  if (guild != nullptr)
2792  {
2793  const GuildMember *const gm = guild->getMember(nick);
2794  if (gm != nullptr)
2795  {
2796  const int level = gm->getLevel();
2797  if (level > 1 && being->getLevel() != level)
2798  {
2799  being->setLevel(level);
2800  being->updateName();
2801  }
2802  }
2803  }
2804  if (chatWindow != nullptr)
2805  {
2806  WhisperTab *const tab = chatWindow->getWhisperTab(nick);
2807  if (tab != nullptr)
2808  tab->setWhisperTabColors();
2809  }
2810  }
2811 
2812  if (!mWaitFor.empty() && mWaitFor == nick)
2813  {
2814  // TRANSLATORS: wait player/monster message
2815  debugMsg(strprintf(_("You see %s"), mWaitFor.c_str()))
2816  soundManager.playGuiSound(SOUND_INFO);
2817  mWaitFor.clear();
2818  }
2819 }
ChatWindow * chatWindow
Definition: chatwindow.cpp:94
virtual int getLevel() const
Definition: being.h:604
void updateName()
Definition: being.cpp:3425
void setLevel(const int n)
Definition: being.h:601
Guild * getGuild() const
Definition: being.cpp:1280
WhisperTab * getWhisperTab(const std::string &nick) const
Definition: guild.h:70
void setWhisperTabColors()
Definition: whispertab.cpp:123
uint32_t guild
bool gm(InputEvent &event)
Definition: commands.cpp:75
static const std::string SOUND_INFO
Definition: sound.h:27

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(), EAthena::BeingRecv::processBeingMove(), TmwAthena::BeingRecv::processBeingMove(), EAthena::BeingRecv::processBeingSpawn(), EAthena::BeingRecv::processBeingVisible(), TmwAthena::BeingRecv::processBeingVisible(), Ea::BeingRecv::processNameResponse(), EAthena::BeingRecv::processNameResponse2(), and EAthena::BeingRecv::processNameResponseTitle().

◆ emote()

bool LocalPlayer::emote ( const uint8_t  emotion)
static

Definition at line 791 of file localplayer.cpp.

792 {
794  return false;
795 
796  playerHandler->emote(emotion);
797  return true;
798 }
virtual void emote(const uint8_t emoteId) const =0
@ PACKET_EMOTE
Definition: packettype.h:35

References Net::PlayerHandler::emote(), PacketLimiter::limitPackets(), PacketType::PACKET_EMOTE, and playerHandler.

Referenced by CrazyMoves::crazyMoveAe(), imitateEmote(), slowLogic(), EmoteShortcut::useEmote(), and EmoteShortcut::useEmotePlayer().

◆ failMove()

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

Definition at line 2771 of file localplayer.cpp.

2773 {
2774  fixPos();
2775 }

References fixPos().

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

◆ fixAttackTarget()

void LocalPlayer::fixAttackTarget ( )

Definition at line 2716 of file localplayer.cpp.

2717 {
2718  if ((mMap == nullptr) || (mTarget == nullptr))
2719  return;
2720 
2721  if (settings.moveToTargetType == 11 || (settings.attackType == 0U)
2722  || !config.getBoolValue("autofixPos"))
2723  {
2724  return;
2725  }
2726 
2727  const Path debugPath = mMap->findPath(
2728  (mPixelX - mapTileSize / 2) / mapTileSize,
2730  mTarget->mX,
2731  mTarget->mY,
2732  getBlockWalkMask(),
2733  0);
2734 
2735  if (!debugPath.empty())
2736  {
2737  const Path::const_iterator i = debugPath.begin();
2738  setDestination((*i).x, (*i).y);
2739  }
2740 }
int mPixelX
Definition: actor.h:133
Map * mMap
Definition: actor.h:139
int mPixelY
Definition: actor.h:134
void setDestination(const int x, const int y)
unsigned char getBlockWalkMask() const A_CONST
Path findPath(const int startX, const int startY, const int destX, const int destY, const unsigned char blockWalkmask, const int maxCost)
Definition: map.cpp:863
unsigned int moveToTargetType
Definition: settings.h:135
static const int mapTileSize
Definition: map.h:27
std::list< Position > Path
Definition: position.h:49

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 2612 of file localplayer.cpp.

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

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 2532 of file localplayer.cpp.

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

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 2544 of file localplayer.cpp.

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

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 2927 of file localplayer.cpp.

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

References mFreezed, mUnfreezeTime, and tick_time.

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

◆ getAttackRange()

int LocalPlayer::getAttackRange ( ) const

Gets the attack range.

Definition at line 1005 of file localplayer.cpp.

1006 {
1007  if (mAttackRange > -1)
1008  {
1009  return mAttackRange;
1010  }
1011 
1012  const Item *const weapon = PlayerInfo::getEquipment(
1014  if (weapon != nullptr)
1015  {
1016  const ItemInfo &info = weapon->getInfo();
1017  return info.getAttackRange();
1018  }
1019  return 48; // unarmed range
1020 }
const ItemInfo & getInfo() const
Definition: item.h:171
bool info(InputEvent &event)
Definition: commands.cpp:57
@ FIGHT1_SLOT
Definition: equipslot.h:41
Equipment * getEquipment()
Definition: playerinfo.cpp:220

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 2319 of file localplayer.cpp.

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

References getAttackRange().

Referenced by attack2().

◆ getAwayListener()

AwayListener* LocalPlayer::getAwayListener ( ) const
inline

Definition at line 419 of file localplayer.h.

420  { 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 2821 of file localplayer.cpp.

2822 {
2823  // for now blocking all types of collisions
2824  return BlockMask::WALL |
2825  BlockMask::AIR |
2828 }
@ PLAYERWALL
Definition: blockmask.h:36

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 356 of file localplayer.h.

357  { return mUpdateName; }

References mUpdateName.

◆ getFollow()

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

Get the playername followed by the current player.

Definition at line 336 of file localplayer.h.

337  { return mPlayerFollowed; }

References mPlayerFollowed.

Referenced by InputManager::updateConditionMask().

◆ getHalfAway()

bool LocalPlayer::getHalfAway ( ) const
inline

Definition at line 239 of file localplayer.h.

240  { return mInactive; }
bool mInactive
Definition: being.h:1383

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 342 of file localplayer.h.

343  { return mPlayerImitated; }

References mPlayerImitated.

Referenced by imitateEmote().

◆ getLastAttackX()

int LocalPlayer::getLastAttackX ( ) const
inlinevirtual

Reimplemented from Being.

Definition at line 401 of file localplayer.h.

402  { return mTarget != nullptr ? mTarget->mX : mLastAttackX; }
int mLastAttackX
Definition: being.h:1223

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

◆ getLastAttackY()

int LocalPlayer::getLastAttackY ( ) const
inlinevirtual

Reimplemented from Being.

Definition at line 404 of file localplayer.h.

405  { return mTarget != nullptr ? mTarget->mY : mLastAttackY; }
int mLastAttackY
Definition: being.h:1224

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

◆ getLevel()

int LocalPlayer::getLevel ( ) const
virtual

Reimplemented from Being.

Definition at line 2747 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 193 of file localplayer.h.

194  { return mMoveState; }

References mMoveState.

Referenced by specialMove().

◆ getNextDestX()

int LocalPlayer::getNextDestX ( ) const
inline

Definition at line 314 of file localplayer.h.

315  { return mNextDestX; }

References mNextDestX.

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

◆ getNextDestY()

int LocalPlayer::getNextDestY ( ) const
inline

Definition at line 317 of file localplayer.h.

318  { 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 2284 of file localplayer.cpp.

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

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 322 of file localplayer.h.

323  { return mPickUpTarget; }

References mPickUpTarget.

Referenced by ActorManager::logic().

◆ getPingTime()

std::string LocalPlayer::getPingTime ( ) const

Definition at line 1997 of file localplayer.cpp.

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

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 425 of file localplayer.h.

426  { 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 148 of file localplayer.h.

149  { 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 1053 of file localplayer.cpp.

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

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 
)

Definition at line 2432 of file localplayer.cpp.

2434 {
2435  if (being == nullptr)
2436  return;
2437 
2438  if (!mPlayerImitated.empty() && being->mName == mPlayerImitated)
2439  {
2440  setAction(action, 0);
2441  playerHandler->changeAction(action);
2442  }
2443 }
virtual void changeAction(const BeingActionT &action) const =0

References Net::PlayerHandler::changeAction(), Being::mName, mPlayerImitated, playerHandler, and setAction().

Referenced by EAthena::BeingRecv::applyPlayerAction(), TmwAthena::BeingRecv::applyPlayerAction(), Ea::BeingRecv::processBeingAction(), EAthena::BeingRecv::processBeingAction2(), and TmwAthena::BeingRecv::processPlayerMove().

◆ imitateDirection()

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

Definition at line 2445 of file localplayer.cpp.

2447 {
2448  if (being == nullptr)
2449  return;
2450 
2451  if (!mPlayerImitated.empty() && being->mName == mPlayerImitated)
2452  {
2454  return;
2455 
2456  if (settings.followMode == 2)
2457  {
2458  uint8_t dir2 = 0;
2459  if ((dir & BeingDirection::LEFT) != 0)
2460  dir2 |= BeingDirection::RIGHT;
2461  else if ((dir & BeingDirection::RIGHT) != 0)
2462  dir2 |= BeingDirection::LEFT;
2463  if ((dir & BeingDirection::UP) != 0)
2464  dir2 |= BeingDirection::DOWN;
2465  else if ((dir & BeingDirection::DOWN) != 0)
2466  dir2 |= BeingDirection::UP;
2467 
2468  setDirection(dir2);
2469  playerHandler->setDirection(dir2);
2470  }
2471  else
2472  {
2473  setDirection(dir);
2475  }
2476  }
2477 }
virtual void setDirection(const unsigned char direction) const =0
@ PACKET_DIRECTION
Definition: packettype.h:37

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

Referenced by EAthena::BeingRecv::processBeingChangeDirection(), TmwAthena::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 2421 of file localplayer.cpp.

2423 {
2424  if (being == nullptr)
2425  return;
2426 
2427  std::string player_imitated = getImitate();
2428  if (!player_imitated.empty() && being->mName == player_imitated)
2429  emote(action);
2430 }
const std::string & getImitate() const
Definition: localplayer.h:342
static bool emote(const uint8_t emotion)

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 2479 of file localplayer.cpp.

2481 {
2482  if (player == nullptr)
2483  return;
2484 
2485  if (settings.imitationMode == 1 &&
2486  !mPlayerImitated.empty() &&
2487  player->mName == mPlayerImitated)
2488  {
2489  if (sprite < 0 || sprite >= player->getNumberOfLayers())
2490  return;
2491 
2492  const AnimatedSprite *const equipmentSprite
2493  = dynamic_cast<const AnimatedSprite *>(
2494  player->mSprites[sprite]);
2495 
2496  if (equipmentSprite != nullptr)
2497  {
2498 // logger->log("have equipmentSprite");
2499  const Inventory *const inv = PlayerInfo::getInventory();
2500  if (inv == nullptr)
2501  return;
2502 
2503  const std::string &path = equipmentSprite->getIdPath();
2504  if (path.empty())
2505  return;
2506 
2507 // logger->log("idPath: " + path);
2508  const Item *const item = inv->findItemBySprite(path,
2509  player->getGender(), player->getSubType());
2510  if ((item != nullptr) && item->isEquipped() == Equipped_false)
2512  }
2513  else
2514  {
2515 // logger->log("have unequip %d", sprite);
2516  const int equipmentSlot = inventoryHandler
2517  ->convertFromServerSlot(sprite);
2518 // logger->log("equipmentSlot: " + toString(equipmentSlot));
2519  if (equipmentSlot == inventoryHandler->getProjectileSlot())
2520  return;
2521 
2522  const Item *const item = PlayerInfo::getEquipment(equipmentSlot);
2523  if (item != nullptr)
2524  {
2525 // logger->log("unequiping");
2527  }
2528  }
2529  }
2530 }
std::string getIdPath() const
int getNumberOfLayers() const
Definition: being.h:377
BeingTypeId getSubType() const
Definition: being.h:400
GenderT getGender() const
Definition: being.h:626
std::vector< Sprite * > mSprites
const Item * findItemBySprite(std::string spritePath, const GenderT gender, const BeingTypeId race) const
Definition: inventory.cpp:318
virtual int convertFromServerSlot(const int eAthenaSlot) const =0
virtual int getProjectileSlot() const =0
unsigned int imitationMode
Definition: settings.h:143
Net::InventoryHandler * inventoryHandler
Definition: net.cpp:89
void unequipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:246
const bool Sfx_false
Definition: sfx.h:30

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 190 of file localplayer.h.

191  { return mPathSetByMouse; }

References mPathSetByMouse.

◆ isReachable() [1/2]

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

Definition at line 1542 of file localplayer.cpp.

1544 {
1545  if ((being == nullptr) || (mMap == nullptr))
1546  return false;
1547 
1548  if (being->getReachable() == Reachable::REACH_NO)
1549  return false;
1550 
1551  if (being->mX == mX &&
1552  being->mY == mY)
1553  {
1554  being->setDistance(0);
1556  return true;
1557  }
1558  else if (being->mX - 1 <= mX &&
1559  being->mX + 1 >= mX &&
1560  being->mY - 1 <= mY &&
1561  being->mY + 1 >= mY)
1562  {
1563  being->setDistance(1);
1565  return true;
1566  }
1567 
1568  const Path debugPath = mMap->findPath(
1569  (mPixelX - mapTileSize / 2) / mapTileSize,
1571  being->mX,
1572  being->mY,
1573  getBlockWalkMask(),
1574  maxCost);
1575 
1576  being->setDistance(CAST_S32(debugPath.size()));
1577  if (!debugPath.empty())
1578  {
1580  return true;
1581  }
1583  return false;
1584 }
ReachableT getReachable() const
Definition: being.h:610
void setDistance(const int n)
Definition: being.h:555
void setReachable(const ReachableT n)
Definition: being.h:607
@ REACH_YES
Definition: reachable.h:32
@ REACH_NO
Definition: reachable.h:33

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 1586 of file localplayer.cpp.

1588 {
1589  const WalkLayer *const walk = mMap->getWalkLayer();
1590  if (walk == nullptr)
1591  return false;
1592  int num = walk->getDataAt(x, y);
1593  if (allowCollision && num < 0)
1594  num = -num;
1595 
1596  return walk->getDataAt(mX, mY) == num;
1597 }
const WalkLayer * getWalkLayer() const
Definition: map.h:347
int getDataAt(const int x, const int y) const
Definition: walklayer.cpp:40

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

◆ isServerBuggy()

bool LocalPlayer::isServerBuggy ( ) const
inline

Definition at line 276 of file localplayer.h.

277  { return mIsServerBuggy; }

References mIsServerBuggy.

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

◆ loadHomes()

void LocalPlayer::loadHomes ( )
protected

Definition at line 1815 of file localplayer.cpp.

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

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 256 of file localplayer.cpp.

257 {
258  BLOCK_START("LocalPlayer::logic")
259 #ifdef USE_MUMBLE
260  if (mumbleManager)
261  mumbleManager->setPos(mX, mY, mDirection);
262 #endif // USE_MUMBLE
263 
264  // Actions are allowed once per second
265  if (get_elapsed_time(mLastAction) >= 1000)
266  mLastAction = -1;
267 
268  if (mActivityTime == 0 || mLastAction != -1)
270 
271  if (mUnfreezeTime > 0 &&
273  {
274  mUnfreezeTime = 0;
275  mFreezed = false;
276  }
277 
278  if ((mAction != BeingAction::MOVE || mNextStep) && !mNavigatePath.empty())
279  {
280  mNextStep = false;
281  int dist = 5;
282  if (!mSyncPlayerMove)
283  dist = 20;
284 
285  if (((mNavigateX != 0) || (mNavigateY != 0)) &&
286  ((mCrossX + dist >= mX && mCrossX <= mX + dist
287  && mCrossY + dist >= mY && mCrossY <= mY + dist)
288  || ((mCrossX == 0) && (mCrossY == 0))))
289  {
290  const Path::const_iterator i = mNavigatePath.begin();
291  if ((*i).x == mX && (*i).y == mY)
292  mNavigatePath.pop_front();
293  else
294  setDestination((*i).x, (*i).y);
295  }
296  }
297 
298  // Show XP messages
299  if (!mMessages.empty())
300  {
301  if (mMessageTime == 0)
302  {
303  const MessagePair info = mMessages.front();
304 
305  if ((particleEngine != nullptr) && (gui != nullptr))
306  {
308  info.first,
309  mPixelX,
310  mPixelY - 48,
311  &userPalette->getColor(info.second, 255U),
313  true);
314  }
315 
316  mMessages.pop_front();
317  mMessageTime = 30;
318  }
319  mMessageTime--;
320  }
321 
322  if (mTarget != nullptr)
323  {
324  if (mTarget->getType() == ActorType::Npc)
325  {
326  // NPCs are always in range
328  }
329  else
330  {
331  // Find whether target is in range
332  const int rangeX = CAST_S32(
333  abs(mTarget->mX - mX));
334  const int rangeY = CAST_S32(
335  abs(mTarget->mY - mY));
336  const int attackRange = getAttackRange();
337  const TargetCursorTypeT targetType
338  = rangeX > attackRange || rangeY > attackRange
340  mTarget->setTargetType(targetType);
341 
342  if (!mTarget->isAlive() && (!mTargetDeadPlayers
344  {
345  stopAttack(true);
346  }
347 
348  if (mKeepAttacking && (mTarget != nullptr))
349  attack(mTarget, true, false);
350  }
351  }
352 
353  Being::logic();
354  BLOCK_END("LocalPlayer::logic")
355 }
void setTargetType(const TargetCursorTypeT type)
void logic()
Definition: being.cpp:1834
bool isAlive() const
Definition: being.h:488
uint8_t mDirection
Definition: being.h:1231
Font * getInfoParticleFont() const
Definition: gui.h:185
Particle * addTextRiseFadeOutEffect(const std::string &text, const int x, const int y, const Color *const color, Font *const font, const bool outline)
Gui * gui
Definition: gui.cpp:111
ParticleEngine * particleEngine
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79
TargetCursorType ::T TargetCursorTypeT
int get_elapsed_time(const int startTime)
Definition: timer.cpp:94

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 1757 of file localplayer.cpp.

1758 {
1760  return;
1761  if (chatWindow == nullptr ||
1762  !isAlive() ||
1764  {
1765  return;
1766  }
1767 
1768  switch (settings.magicAttackType)
1769  {
1770  // flar W00
1771  case 0:
1772  tryMagic("#flar", 1, 0, 10);
1773  break;
1774  // chiza W01
1775  case 1:
1776  tryMagic("#chiza", 1, 0, 9);
1777  break;
1778  // ingrav W10
1779  case 2:
1780  tryMagic("#ingrav", 2, 2, 20);
1781  break;
1782  // frillyar W11
1783  case 3:
1784  tryMagic("#frillyar", 2, 2, 25);
1785  break;
1786  // upmarmu W12
1787  case 4:
1788  tryMagic("#upmarmu", 2, 2, 20);
1789  break;
1790  default:
1791  break;
1792  }
1793 }
static void tryMagic(const std::string &spell, const int baseMagic, const int schoolMagic, const int mana)
virtual bool canUseMagic() const =0
unsigned int magicAttackType
Definition: settings.h:141

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 1704 of file localplayer.cpp.

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

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

Referenced by specialMove().

◆ moveToHome()

void LocalPlayer::moveToHome ( )

Definition at line 1432 of file localplayer.cpp.

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

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

◆ moveToTarget()

void LocalPlayer::moveToTarget ( int  dist)

Definition at line 1345 of file localplayer.cpp.

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

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 2155 of file localplayer.cpp.

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

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 2124 of file localplayer.cpp.

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

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 449 of file localplayer.cpp.

450 {
451  const Party *const party = Party::getParty(1);
452  if (party != nullptr)
453  {
454  PartyMember *const pm = party->getMember(mName);
455  if (pm != nullptr)
456  {
457  pm->setX(mX);
458  pm->setY(mY);
459  }
460  }
461 
462  if (mPath.empty())
463  {
464  if (mPickUpTarget != nullptr)
466 
467  if (mWalkingDir != 0U)
469  }
470  else if (mPath.size() == 1)
471  {
472  if (mPickUpTarget != nullptr)
474  }
475 
476  if (mGoingToTarget &&
477  mTarget != nullptr &&
478  withinAttackRange(mTarget, false, 0))
479  {
481  attack(mTarget, true, false);
482  mGoingToTarget = false;
483  mPath.clear();
484  return;
485  }
486  else if (mGoingToTarget && (mTarget == nullptr))
487  {
488  mGoingToTarget = false;
489  mPath.clear();
490  }
491 
492  if (mPath.empty())
493  {
494  if (mNavigatePath.empty() || mAction != BeingAction::MOVE)
495  {
497  // +++ probably sync position here always?
498  }
499  else
500  {
501  mNextStep = true;
502  }
503  }
504  else
505  {
506  Being::nextTile();
507  }
508 
509  fixPos();
510 }
void setY(const int y)
Definition: avatar.h:135
void setX(const int x)
Definition: avatar.h:129
virtual void nextTile()
Definition: being.cpp:1782
Path mPath
Definition: being.h:1197
void startWalking(const unsigned char dir)
bool pickUp(FloorItem *const item)
Definition: party.h:63
static Party * getParty(const int16_t id)
Definition: party.cpp:313
uint32_t party

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 1123 of file localplayer.cpp.

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

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 186 of file localplayer.h.

187  { 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 887 of file localplayer.cpp.

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

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 EAthena::InventoryRecv::processPlayerInventoryAdd(), and TmwAthena::InventoryRecv::processPlayerInventoryAdd().

◆ pickUp()

bool LocalPlayer::pickUp ( FloorItem *const  item)

Definition at line 512 of file localplayer.cpp.

513 {
514  if (item == nullptr)
515  return false;
516 
518  return false;
519 
520  const int dx = item->getTileX() - mX;
521  const int dy = item->getTileY() - mY;
522  int dist = 6;
523 
524  const unsigned int pickUpType = settings.pickUpType;
525  if (pickUpType >= 4 && pickUpType <= 6)
526  dist = 4;
527 
528  if (dx * dx + dy * dy < dist)
529  {
530  if ((actorManager != nullptr) && actorManager->checkForPickup(item))
531  {
533  mPickUpTarget = nullptr;
534  }
535  }
536  else if (pickUpType >= 4 && pickUpType <= 6)
537  {
538  const Path debugPath = mMap->findPath(
539  (mPixelX - mapTileSize / 2) / mapTileSize,
541  item->getTileX(),
542  item->getTileY(),
544  0);
545  if (!debugPath.empty())
546  navigateTo(item->getTileX(), item->getTileY());
547  else
548  setDestination(item->getTileX(), item->getTileY());
549 
550  mPickUpTarget = item;
552  }
553  return true;
554 }
bool checkForPickup(const FloorItem *const item) const
void addActorSpriteListener(ActorSpriteListener *const listener)
int getTileY() const
Definition: flooritem.h:96
int getTileX() const
Definition: flooritem.h:93
unsigned int pickUpType
Definition: settings.h:140
@ PACKET_PICKUP
Definition: packettype.h:30
void pickUpItem(const FloorItem *const item, const Sfx sfx)
Definition: playerinfo.cpp:366

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 1599 of file localplayer.cpp.

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

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 1983 of file localplayer.cpp.

1984 {
1985  const int time = tick_time;
1986  if (mWaitPing == true && mPingSendTick != 0)
1987  {
1988  if (time >= mPingSendTick && (time - mPingSendTick) > 1000)
1989  return;
1990  }
1991 
1992  mPingSendTick = time;
1993  mWaitPing = true;
1995 }
Net::BeingHandler * beingHandler
Definition: net.cpp:99
virtual void requestNameById(const BeingId id) const =0

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

Referenced by tryPingRequest().

◆ pingResponse()

void LocalPlayer::pingResponse ( )

Definition at line 2024 of file localplayer.cpp.

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

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 2910 of file localplayer.cpp.

2911 {
2912  if (mAction != BeingAction::DEAD)
2913  {
2916  }
2917 }
void recalcSpritesOrder()
Definition: being.cpp:4359

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

◆ removeHome()

void LocalPlayer::removeHome ( )

Definition at line 2830 of file localplayer.cpp.

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

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

Referenced by PopupMenu::handleLink().

◆ respawn()

void LocalPlayer::respawn ( )

Definition at line 2742 of file localplayer.cpp.

2743 {
2744  navigateClean();
2745 }

References navigateClean().

Referenced by PlayerPostDeathListener::action().

◆ saveHomes()

void LocalPlayer::saveHomes ( )

Definition at line 1964 of file localplayer.cpp.

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

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 409 of file localplayer.cpp.

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

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 2059 of file localplayer.cpp.

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

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

Referenced by setAway(), and setPseudoAway().

◆ setAfkTime()

void LocalPlayer::setAfkTime ( const int  v)
inline

Definition at line 413 of file localplayer.h.

414  { mAfkTime = v; }

References mAfkTime.

Referenced by GameModifiers::changeAwayMode().

◆ setAway()

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

Definition at line 2052 of file localplayer.cpp.

2053 {
2054  setAfkMessage(message);
2056  updateStatus();
2057 }
static void changeAwayMode(const bool forward)
static void setAfkMessage(std::string message)
void updateStatus() const

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

◆ setAwayDialog()

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

Definition at line 416 of file localplayer.h.

417  { 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 349 of file localplayer.h.

350  { 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 623 of file localplayer.cpp.

624 {
626 
627  if (settings.attackType == 0 || !mAttackMoving)
628  mKeepAttacking = false;
629 
630  // Only send a new message to the server when destination changes
631  if (x != mDest.x || y != mDest.y)
632  {
633  if (settings.moveType != 1)
634  {
637  }
638  else
639  {
640  uint8_t newDir = 0;
641  if ((mDirection & BeingDirection::UP) != 0)
642  newDir |= BeingDirection::DOWN;
643  if ((mDirection & BeingDirection::LEFT) != 0)
644  newDir |= BeingDirection::RIGHT;
645  if ((mDirection & BeingDirection::DOWN) != 0)
646  newDir |= BeingDirection::UP;
647  if ((mDirection & BeingDirection::RIGHT) != 0)
648  newDir |= BeingDirection::LEFT;
649 
650  playerHandler->setDestination(x, y, newDir);
651 
652 // if (PacketLimiter::limitPackets(PacketType::PACKET_DIRECTION))
653  {
654  setDirection(newDir);
655  playerHandler->setDirection(newDir);
656  }
657 
660  }
661  }
662 }
Vector mDest
Definition: being.h:1201
void setDestination(const int dstX, const int dstY)
Definition: being.cpp:540
unsigned int moveType
Definition: settings.h:133

References Settings::attackType, cur_time, BeingDirection::DOWN, BeingDirection::LEFT, mActivityTime, mAttackMoving, Being::mDest, Being::mDirection, mKeepAttacking, Settings::moveType, playerHandler, BeingDirection::RIGHT, Being::setDestination(), Net::PlayerHandler::setDestination(), Being::setDirection(), Net::PlayerHandler::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 2373 of file localplayer.cpp.

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

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

◆ setGotoTarget()

void LocalPlayer::setGotoTarget ( Being *const  target)

Sets going to being to attack

Definition at line 1041 of file localplayer.cpp.

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

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

◆ setGroupId()

void LocalPlayer::setGroupId ( const int  id)
virtual

Reimplemented from Being.

Definition at line 433 of file localplayer.cpp.

434 {
435  Being::setGroupId(id);
436 
437  if (mIsGM != 0)
438  {
439  if (chatWindow != nullptr)
440  {
443  }
444  }
445  if (statusWindow != nullptr)
447 }
bool mIsGM
Definition: being.h:1235
virtual void setGroupId(const int id)
Definition: being.cpp:5587
void showGMTab()
void loadGMCommands()
Definition: chatwindow.cpp:264
void updateLevelLabel()
StatusWindow * statusWindow

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 236 of file localplayer.h.

237  { mInactive = n; }

References Being::mInactive.

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

◆ setHome()

void LocalPlayer::setHome ( )

Definition at line 1846 of file localplayer.cpp.

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

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(),