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 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 setTileCoords (const int x, const int y)
 
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 ()
 
int getHitEffect (const Being *const attacker, const AttackTypeT type, const int attackId, const int level) const
 
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 uint8_t genderToInt (const GenderT sex) A_CONST
 
static GenderT intToGender (const uint8_t sex) A_CONST
 
static BeingcreateBeing (const BeingId id, const ActorTypeT type, const BeingTypeId subtype, Map *const map)
 
- Static Public Member Functions inherited from ActorSprite
static void load ()
 
static void unload ()
 
- Static Public Member Functions inherited from CompoundSprite
static void setEnableDelay (bool b)
 
- Static Public Member Functions inherited from AttributeListener
static void distributeEvent (const AttributesT id, const int64_t oldVal, const int64_t newVal)
 
static void addListener (AttributeListener *const listener)
 
static void removeListener (const AttributeListener *const listener)
 
- Static Public Member Functions inherited from PlayerDeathListener
static void distributeEvent ()
 
static void addListener (PlayerDeathListener *const listener)
 
static void removeListener (const PlayerDeathListener *const listener)
 

Protected Types

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

Protected Member Functions

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

Static Protected Member Functions

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

Protected Attributes

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

Additional Inherited Members

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

Detailed Description

The local player character.

Definition at line 49 of file localplayer.h.

Member Typedef Documentation

◆ MessagePair

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

Definition at line 474 of file localplayer.h.

Constructor & Destructor Documentation

◆ LocalPlayer()

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

Constructor.

Definition at line 113 of file localplayer.cpp.

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

114  :
119  mMoveState(0),
120  mLastTargetX(0),
121  mLastTargetY(0),
122  mHomes(),
123  mTarget(nullptr),
124  mPlayerFollowed(),
125  mPlayerImitated(),
126  mNextDestX(0),
127  mNextDestY(0),
128  mPickUpTarget(nullptr),
129  mLastAction(-1),
131  mMessages(),
132  mMessageTime(0),
134  mAwayDialog(nullptr),
135  mPingSendTick(0),
136  mPingTime(0),
137  mAfkTime(0),
138  mActivityTime(0),
139  mNavigateX(0),
140  mNavigateY(0),
142  mCrossX(0),
143  mCrossY(0),
144  mOldX(0),
145  mOldY(0),
146  mOldTileX(0),
147  mOldTileY(0),
148  mNavigatePath(),
149  mLastHitFrom(),
150  mWaitFor(),
151  mAdvertTime(0),
152  mTestParticle(nullptr),
155  mTestParticleHash(0L),
156  mSyncPlayerMoveDistance(config.getIntValue("syncPlayerMoveDistance")),
157  mUnfreezeTime(0),
158  mWalkingDir(0),
159  mUpdateName(true),
160  mBlockAdvert(false),
161  mTargetDeadPlayers(config.getBoolValue("targetDeadPlayers")),
162  mServerAttack(fromBool(config.getBoolValue("serverAttack"), Keep)),
163  mVisibleNames(static_cast<VisibleName::Type>(
164  config.getIntValue("visiblenames"))),
165  mEnableAdvert(config.getBoolValue("enableAdvert")),
166  mTradebot(config.getBoolValue("tradebot")),
167  mTargetOnlyReachable(config.getBoolValue("targetOnlyReachable")),
168  mIsServerBuggy(serverConfig.getValueBool("enableBuggyServers", true)),
169  mSyncPlayerMove(config.getBoolValue("syncPlayerMove")),
170  mDrawPath(config.getBoolValue("drawPath")),
171  mAttackMoving(config.getBoolValue("attackMoving")),
172  mAttackNext(config.getBoolValue("attackNext")),
173  mShowJobExp(config.getBoolValue("showJobExp")),
174  mShowServerPos(config.getBoolValue("showserverpos")),
175  mNextStep(false),
176  mGoingToTarget(false),
177  mKeepAttacking(false),
178  mPathSetByMouse(false),
179  mWaitPing(false),
180  mShowNavigePath(false),
181  mAllowRename(false),
182  mFreezed(false)
183 {
184  logger->log1("LocalPlayer::LocalPlayer");
185 
186  postInit(subType, nullptr);
187  mAttackRange = 0;
188  mLevel = 1;
189  mAdvanced = true;
191  if (userPalette != nullptr)
193  else
194  mNameColor = nullptr;
195 
197  getWalkSpeed(),
198  Notify_true);
200  0,
201  Notify_true);
202 
203  loadHomes();
204 
205  config.addListener("showownname", this);
206  config.addListener("targetDeadPlayers", this);
207  serverConfig.addListener("enableBuggyServers", this);
208  config.addListener("syncPlayerMove", this);
209  config.addListener("syncPlayerMoveDistance", this);
210  config.addListener("drawPath", this);
211  config.addListener("serverAttack", this);
212  config.addListener("attackMoving", this);
213  config.addListener("attackNext", this);
214  config.addListener("showJobExp", this);
215  config.addListener("enableAdvert", this);
216  config.addListener("tradebot", this);
217  config.addListener("targetOnlyReachable", this);
218  config.addListener("showserverpos", this);
219  config.addListener("visiblenames", this);
220  setShowName(config.getBoolValue("showownname"));
221 }
time_t mActivityTime
Definition: localplayer.h:484
std::string mTestParticleName
Definition: localplayer.h:500
const Color & getColor(UserColorIdT type, const unsigned int alpha)
Definition: userpalette.h:159
void log1(const char *const log_text)
Definition: logger.cpp:233
bool mAttackMoving
Definition: localplayer.h:518
time_t mAfkTime
Definition: localplayer.h:483
void setStatMod(const AttributesT id, const int value, const Notify notify)
Definition: playerinfo.cpp:157
void setShowName(const bool doShowName)
Definition: being.cpp:1165
bool mNextStep
Definition: localplayer.h:522
void setStatBase(const AttributesT id, const int value, const Notify notify)
Definition: playerinfo.cpp:141
std::map< std::string, Vector > mHomes
Definition: localplayer.h:458
int mLastTargetX
Definition: localplayer.h:455
const Color * mNameColor
Definition: being.h:1195
bool mAttackNext
Definition: localplayer.h:519
int mUnfreezeTime
Definition: localplayer.h:504
bool mGoingToTarget
Definition: localplayer.h:524
int mPingSendTick
Definition: localplayer.h:481
void loadHomes()
Configuration config
Particle * mTestParticle
Definition: localplayer.h:499
int mLevel
Definition: being.h:1223
bool mWaitPing
Definition: localplayer.h:529
Being(const BeingId id, const ActorTypeT type)
Definition: being.cpp:161
unsigned long mTestParticleHash
Definition: localplayer.h:502
int getIntValue(const std::string &key) const
const Color * mTextColor
Definition: being.h:1202
Configuration serverConfig
bool mSyncPlayerMove
Definition: localplayer.h:516
Being * mTarget
Definition: localplayer.h:460
bool mBlockAdvert
Definition: localplayer.h:508
void addListener(const std::string &key, ConfigListener *const listener)
bool mIsServerBuggy
Definition: localplayer.h:515
UserPalette * userPalette
Definition: userpalette.cpp:33
bool mTargetOnlyReachable
Definition: localplayer.h:514
std::string mLastHitFrom
Definition: localplayer.h:496
Logger * logger
Definition: logger.cpp:88
bool Keep
Definition: keep.h:29
std::list< MessagePair > mMessages
Definition: localplayer.h:476
std::string mPlayerImitated
Definition: localplayer.h:464
bool getBoolValue(const std::string &key) const
const Color & getColor(const ThemeColorIdT type, const unsigned int alpha)
Definition: theme.h:135
#define fromBool(val, name)
Definition: booldefines.h:48
int mMessageTime
Definition: localplayer.h:477
time_t mPingTime
Definition: localplayer.h:482
bool getValueBool(const std::string &key, const bool deflt) const
Path mNavigatePath
Definition: localplayer.h:494
void postInit(const BeingTypeId subType, Map *const map)
Definition: being.cpp:288
unsigned char mWalkingDir
Definition: localplayer.h:505
int mLastTargetY
Definition: localplayer.h:456
bool mTargetDeadPlayers
Definition: localplayer.h:509
bool mShowNavigePath
Definition: localplayer.h:530
time_t mTestParticleTime
Definition: localplayer.h:501
OkDialog * mAwayDialog
Definition: localplayer.h:479
int mSyncPlayerMoveDistance
Definition: localplayer.h:503
bool mShowJobExp
Definition: localplayer.h:520
Theme * theme
Definition: theme.cpp:61
AwayListener * mAwayListener
Definition: localplayer.h:478
BeingId mNavigateId
Definition: localplayer.h:487
bool mTradebot
Definition: localplayer.h:513
bool mEnableAdvert
Definition: localplayer.h:512
std::string mWaitFor
Definition: localplayer.h:497
std::vector< int32_t > mStatusEffectIcons
Definition: localplayer.h:472
bool mPathSetByMouse
Definition: localplayer.h:528
bool mAllowRename
Definition: localplayer.h:531
int getWalkSpeed() const
Definition: being.h:457
Keep mServerAttack
Definition: localplayer.h:510
const BeingId BeingId_zero
Definition: beingid.h:29
int mAttackRange
Definition: being.h:1225
bool mDrawPath
Definition: localplayer.h:517
time_t mAdvertTime
Definition: localplayer.h:498
FloorItem * mPickUpTarget
Definition: localplayer.h:468
bool mAdvanced
Definition: being.h:1383
std::string mPlayerFollowed
Definition: localplayer.h:463
const bool Notify_true
Definition: notify.h:29
bool mUpdateName
Definition: localplayer.h:507
unsigned int mMoveState
Definition: localplayer.h:453
bool mShowServerPos
Definition: localplayer.h:521
VisibleName::Type mVisibleNames
Definition: localplayer.h:511
bool mKeepAttacking
Definition: localplayer.h:526

◆ ~LocalPlayer()

LocalPlayer::~LocalPlayer ( )

Destructor.

Definition at line 223 of file localplayer.cpp.

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

224 {
225  logger->log1("LocalPlayer::~LocalPlayer");
226 
227  config.removeListeners(this);
228  serverConfig.removeListener("enableBuggyServers", this);
229 
230  navigateClean();
231  mCrossX = 0;
232  mCrossY = 0;
233 
235 
236  if (mAwayDialog != nullptr)
237  {
240  }
242 }
void log1(const char *const log_text)
Definition: logger.cpp:233
SoundManager soundManager
Configuration config
#define delete2(var)
Definition: delete2.h:24
Configuration serverConfig
Logger * logger
Definition: logger.cpp:88
void navigateClean()
void updateNavigateList()
OkDialog * mAwayDialog
Definition: localplayer.h:479
AwayListener * mAwayListener
Definition: localplayer.h:478
void removeListeners(ConfigListener *const listener)
void removeListener(const std::string &key, ConfigListener *const listener)
void volumeRestore() const

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

References mPickUpTarget.

538 {
539  if (mPickUpTarget == &actorSprite)
540  mPickUpTarget = nullptr;
541 }
FloorItem * mPickUpTarget
Definition: localplayer.h:468

◆ addHomunXpMessage()

void LocalPlayer::addHomunXpMessage ( const int  change)

Definition at line 1219 of file localplayer.cpp.

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

Referenced by EAthena::HomunculusRecv::processHomunculusExp(), and setLastHitFrom().

1220 {
1221  if (change != 0 && mMessages.size() < 20)
1222  {
1223  addMessageToQueue(strprintf("%s %d %s",
1224  // TRANSLATORS: get homunculus xp message
1225  _("Homun"),
1226  change,
1227  // TRANSLATORS: get xp message
1228  _("xp")),
1230  }
1231 }
#define _(s)
Definition: gettext.h:34
void addMessageToQueue(const std::string &message, const UserColorIdT color)
std::list< MessagePair > mMessages
Definition: localplayer.h:476
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99

◆ addHpMessage()

void LocalPlayer::addHpMessage ( const int  change)

Definition at line 1233 of file localplayer.cpp.

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

Referenced by EAthena::PlayerRecv::processPlayerHeal(), and setLastHitFrom().

1234 {
1235  if (change != 0 && mMessages.size() < 20)
1236  {
1237  // TRANSLATORS: get hp message
1238  addMessageToQueue(strprintf("%d %s", change, _("hp")),
1240  }
1241 }
#define _(s)
Definition: gettext.h:34
void addMessageToQueue(const std::string &message, const UserColorIdT color)
std::list< MessagePair > mMessages
Definition: localplayer.h:476
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99

◆ addJobMessage()

void LocalPlayer::addJobMessage ( const int64_t  change)

Definition at line 1167 of file localplayer.cpp.

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

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

1168 {
1169  if (change != 0 && mMessages.size() < 20)
1170  {
1171  const std::string xpStr = toString(CAST_U64(change));
1172  if (!mMessages.empty())
1173  {
1174  MessagePair pair = mMessages.back();
1175  // TRANSLATORS: this is normal experience
1176  if (pair.first.find(strprintf(" %s", _("xp"))) ==
1177  // TRANSLATORS: this is normal experience
1178  pair.first.size() - strlen(_("xp")) - 1)
1179  {
1180  mMessages.pop_back();
1181  pair.first.append(strprintf(", %s %s",
1182  xpStr.c_str(),
1183  // TRANSLATORS: this is job experience
1184  _("job")));
1185  mMessages.push_back(pair);
1186  }
1187  else
1188  {
1189  addMessageToQueue(strprintf("%s %s",
1190  xpStr.c_str(),
1191  // TRANSLATORS: this is job experience
1192  _("job")),
1194  }
1195  }
1196  else
1197  {
1198  addMessageToQueue(strprintf("%s %s",
1199  xpStr.c_str(),
1200  // TRANSLATORS: this is job experience
1201  _("job")),
1203  }
1204  }
1205 }
#define _(s)
Definition: gettext.h:34
std::pair< std::string, UserColorIdT > MessagePair
Definition: localplayer.h:474
#define CAST_U64
Definition: cast.h:32
void addMessageToQueue(const std::string &message, const UserColorIdT color)
std::list< MessagePair > mMessages
Definition: localplayer.h:476
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774

◆ addMessageToQueue()

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

Definition at line 1095 of file localplayer.cpp.

References mMessages.

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

1097 {
1098  if (mMessages.size() < 20)
1099  mMessages.push_back(MessagePair(message, color));
1100 }
std::pair< std::string, UserColorIdT > MessagePair
Definition: localplayer.h:474
std::list< MessagePair > mMessages
Definition: localplayer.h:476

◆ addSpMessage()

void LocalPlayer::addSpMessage ( const int  change)

Definition at line 1243 of file localplayer.cpp.

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

Referenced by EAthena::PlayerRecv::processPlayerHeal(), and setLastHitFrom().

1244 {
1245  if (change != 0 && mMessages.size() < 20)
1246  {
1247  // TRANSLATORS: get hp message
1248  addMessageToQueue(strprintf("%d %s", change, _("mana")),
1250  }
1251 }
#define _(s)
Definition: gettext.h:34
void addMessageToQueue(const std::string &message, const UserColorIdT color)
std::list< MessagePair > mMessages
Definition: localplayer.h:476
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99

◆ addXpMessage()

void LocalPlayer::addXpMessage ( const int64_t  change)

Definition at line 1207 of file localplayer.cpp.

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

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

1208 {
1209  if (change != 0 && mMessages.size() < 20)
1210  {
1211  addMessageToQueue(strprintf("%s %s",
1212  toString(CAST_U64(change)).c_str(),
1213  // TRANSLATORS: get xp message
1214  _("xp")),
1216  }
1217 }
#define _(s)
Definition: gettext.h:34
#define CAST_U64
Definition: cast.h:32
void addMessageToQueue(const std::string &message, const UserColorIdT color)
std::list< MessagePair > mMessages
Definition: localplayer.h:476
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774

◆ afkRespond()

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

Definition at line 2045 of file localplayer.cpp.

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, ServerCommandType::str, ServerCommandType::time, and TryRemoveColors_true.

Referenced by ChatWindow::addWhisper(), and getHalfAway().

2046 {
2047  if (settings.awayMode)
2048  {
2049  const time_t time = cur_time;
2050  if (mAfkTime == 0 || time < mAfkTime
2051  || time - mAfkTime > awayLimitTimer)
2052  {
2053  std::string str(serverConfig.getValue("afkMessage",
2054  "I am away from keyboard."));
2055  if (str.find("'NAME'") != std::string::npos)
2056  replaceAll(str, "'NAME'", nick);
2057 
2058  std::string msg("*AFK*: " + str);
2059 
2060  if (config.getIntValue("afkFormat") == 1)
2061  msg = "*" + msg + "*";
2062 
2063  if (tab == nullptr)
2064  {
2065  chatHandler->privateMessage(nick, msg);
2066  if (localChatTab != nullptr)
2067  {
2068  localChatTab->chatLog(std::string(mName).append(
2069  " : ").append(msg),
2073  }
2074  }
2075  else
2076  {
2077  if (tab->getNoAway())
2078  return;
2079  chatHandler->privateMessage(nick, msg);
2080  tab->chatLog(mName, msg);
2081  }
2082  mAfkTime = time;
2083  }
2084  }
2085 }
time_t mAfkTime
Definition: localplayer.h:483
ChatTab * localChatTab
Definition: chattab.cpp:61
static const int16_t awayLimitTimer
Configuration config
std::string & replaceAll(std::string &context, const std::string &from, const std::string &to)
const bool TryRemoveColors_true
void chatLog(std::string line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
Definition: chattab.cpp:110
bool msg(InputEvent &event)
Definition: chat.cpp:38
int getIntValue(const std::string &key) const
Configuration serverConfig
std::string mName
Definition: being.h:1183
Settings settings
Definition: settings.cpp:31
virtual void privateMessage(const std::string &recipient, const std::string &text) const =0
const bool IgnoreRecord_false
Definition: ignorerecord.h:29
volatile time_t cur_time
Definition: timer.cpp:57
std::string getValue(const std::string &key, const std::string &deflt) const
Net::ChatHandler * chatHandler
Definition: net.cpp:83
bool getNoAway() const
Definition: chattab.h:169
bool awayMode
Definition: settings.h:155

◆ allowAction()

bool LocalPlayer::allowAction ( )

Definition at line 2564 of file localplayer.cpp.

References mIsServerBuggy, mLastAction, and tick_time.

Referenced by CrazyMoves::crazyMove9(), and getHalfAway().

2565 {
2566  if (mIsServerBuggy)
2567  {
2568  if (mLastAction != -1)
2569  return false;
2571  }
2572  return true;
2573 }
volatile int tick_time
Definition: timer.cpp:52
bool mIsServerBuggy
Definition: localplayer.h:515

◆ attack()

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

Definition at line 781 of file localplayer.cpp.

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(), Actions::doSit(), Viewport::drawPath(), logic(), and nextTile().

784 {
785  mKeepAttacking = keep;
786 
787  if ((target == nullptr) || target->getType() == ActorType::Npc)
788  return;
789 
790  if (mTarget != target)
791  setTarget(target);
792 
793  // Must be standing or sitting or casting to attack
794  if (mAction != BeingAction::STAND &&
797  {
798  return;
799  }
800 
801 #ifdef TMWA_SUPPORT
802  const int dist_x = target->mX - mX;
803  const int dist_y = target->mY - mY;
804 
806  {
807  if (abs(dist_y) >= abs(dist_x))
808  {
809  if (dist_y > 0)
811  else
813  }
814  else
815  {
816  if (dist_x > 0)
818  else
820  }
821  }
822 #endif // TMWA_SUPPORT
823 
825 
826  if (target->getType() != ActorType::Player
827  || checAttackPermissions(target))
828  {
830 
832  return;
833 
834  if (!dontChangeEquipment)
836 
837  const BeingId targetId = target->getId();
838  playerHandler->attack(targetId, mServerAttack);
840  }
841 
842  if (!keep)
843  stopAttack(false);
844 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:93
volatile int tick_time
Definition: timer.cpp:52
virtual void attack(const BeingId id, const Keep keep) const =0
BeingId getId() const
Definition: actorsprite.h:63
int BeingId
Definition: beingid.h:29
bool limitPackets(const PacketTypeT type)
Being * mTarget
Definition: localplayer.h:460
static bool checAttackPermissions(const Being *const target)
virtual void setDirection(const uint8_t direction)
Definition: being.cpp:1689
int mX
Definition: being.h:1317
void updateAttackAi(const BeingId targetId, const Keep keep)
Definition: playerinfo.cpp:615
void stopAttack(const bool keepAttack)
ActorTypeT getType() const
Definition: being.h:115
int mActionTime
Definition: being.h:1216
ServerTypeT getNetworkType()
Definition: net.cpp:184
int mY
Definition: being.h:1318
void changeEquipmentBeforeAttack(const Being *const target) const
void setTarget(Being *const target)
Keep mServerAttack
Definition: localplayer.h:510
BeingActionT mAction
Definition: being.h:1232
void setAction(const BeingActionT &action, const int attackId)
bool mKeepAttacking
Definition: localplayer.h:526

◆ attack2()

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

Definition at line 2290 of file localplayer.cpp.

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

Referenced by Actions::doSit().

2293 {
2294  if (!dontChangeEquipment && (target != nullptr))
2296 
2297  const bool broken = (Net::getNetworkType() == ServerType::TMWATHENA);
2298 
2299  // probably need cache getPathLength(target)
2300  if ((target == nullptr ||
2301  settings.attackType == 0 ||
2302  settings.attackType == 3) ||
2303  (withinAttackRange(target, broken, broken ? 1 : 0) &&
2304  getPathLength(target) <= getAttackRange2()))
2305  {
2306  attack(target, keep, false);
2307  if (settings.attackType == 2)
2308  {
2309  if (target == nullptr)
2310  {
2311  if (pickUpItems(0))
2312  return;
2313  }
2314  else
2315  {
2316  pickUpItems(3);
2317  }
2318  }
2319  }
2320  else if (mPickUpTarget == nullptr)
2321  {
2322  if (settings.attackType == 2)
2323  {
2324  if (pickUpItems(0))
2325  return;
2326  }
2327  setTarget(target);
2328  if (target->getType() != ActorType::Npc)
2329  {
2330  mKeepAttacking = true;
2331  moveToTarget(-1);
2332  }
2333  }
2334 }
unsigned int attackType
Definition: settings.h:136
void attack(Being *const target, const bool keep, const bool dontChangeEquipment)
int getAttackRange2() const
void moveToTarget(int dist)
bool pickUpItems(int pickUpType)
Settings settings
Definition: settings.cpp:31
ActorTypeT getType() const
Definition: being.h:115
int getPathLength(const Being *const being) const
ServerTypeT getNetworkType()
Definition: net.cpp:184
void changeEquipmentBeforeAttack(const Being *const target) const
void setTarget(Being *const target)
bool withinAttackRange(const Being *const target, const bool fixDistance, const int addRange) const
FloorItem * mPickUpTarget
Definition: localplayer.h:468
bool mKeepAttacking
Definition: localplayer.h:526

◆ attributeChanged()

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

Implements AttributeListener.

Definition at line 1253 of file localplayer.cpp.

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.

Referenced by getLastAttackY().

1256 {
1257  PRAGMA45(GCC diagnostic push)
1258  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
1259  switch (id)
1260  {
1262  {
1264  break;
1265  if (oldVal > newVal)
1266  break;
1267 
1268  const int change = CAST_S32(newVal - oldVal);
1269  addXpMessage(change);
1270  break;
1271  }
1273  mLevel = CAST_S32(newVal);
1274  break;
1275  case Attributes::PLAYER_HP:
1276  if (oldVal != 0 && newVal == 0)
1278  break;
1280  {
1281  if (!mShowJobExp ||
1283  {
1284  return;
1285  }
1286  if (oldVal > newVal ||
1289  {
1290  return;
1291  }
1292  const int32_t change = CAST_S32(newVal - oldVal);
1293  addJobMessage(change);
1294  break;
1295  }
1296  default:
1297  break;
1298  }
1299  PRAGMA45(GCC diagnostic pop)
1300 }
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wunused-result") int TestLauncher
int mLevel
Definition: being.h:1223
void addXpMessage(const int64_t change)
#define CAST_S32
Definition: cast.h:29
void addJobMessage(const int64_t change)
bool mShowJobExp
Definition: localplayer.h:520
ServerTypeT getNetworkType()
Definition: net.cpp:184
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:100

◆ cancelFollow()

void LocalPlayer::cancelFollow ( )

Stop following a player.

Definition at line 2368 of file localplayer.cpp.

References _, debugMsg, mPlayerFollowed, and mPlayerImitated.

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

2369 {
2370  if (!mPlayerFollowed.empty())
2371  {
2372  // TRANSLATORS: cancel follow message
2373  debugMsg(_("Follow canceled"));
2374  }
2375  if (!mPlayerImitated.empty())
2376  {
2377  // TRANSLATORS: cancel follow message
2378  debugMsg(_("Imitation canceled"));
2379  }
2380  mPlayerFollowed.clear();
2381  mPlayerImitated.clear();
2382 }
#define _(s)
Definition: gettext.h:34
std::string mPlayerImitated
Definition: localplayer.h:464
#define debugMsg(str)
Definition: chattab.h:41
std::string mPlayerFollowed
Definition: localplayer.h:463

◆ canMove()

bool LocalPlayer::canMove ( ) const

◆ changeEquipmentBeforeAttack()

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

Definition at line 1425 of file localplayer.cpp.

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

Referenced by attack(), attack2(), and getRename().

1426 {
1427  if (settings.attackWeaponType == 1
1428  || (target == nullptr)
1429  || (PlayerInfo::getInventory() == nullptr))
1430  {
1431  return;
1432  }
1433 
1434  bool allowSword = false;
1435  const int dx = target->mX - mX;
1436  const int dy = target->mY - mY;
1437  const Item *item = nullptr;
1438 
1439  if (dx * dx + dy * dy > 80)
1440  return;
1441 
1442  if (dx * dx + dy * dy < 8)
1443  allowSword = true;
1444 
1445  const Inventory *const inv = PlayerInfo::getInventory();
1446  if (inv == nullptr)
1447  return;
1448 
1449  // if attack distance for sword
1450  if (allowSword)
1451  {
1452  // searching swords
1453  const WeaponsInfos &swords = WeaponsDB::getSwords();
1454  FOR_EACH (WeaponsInfosIter, it, swords)
1455  {
1456  item = inv->findItem(*it, ItemColor_zero);
1457  if (item != nullptr)
1458  break;
1459  }
1460 
1461  // no swords
1462  if (item == nullptr)
1463  return;
1464 
1465  // if sword not equiped
1466  if (item->isEquipped() == Equipped_false)
1468 
1469  // if need equip shield too
1470  if (settings.attackWeaponType == 3)
1471  {
1472  // searching shield
1473  const WeaponsInfos &shields = WeaponsDB::getShields();
1474  FOR_EACH (WeaponsInfosIter, it, shields)
1475  {
1476  item = inv->findItem(*it, ItemColor_zero);
1477  if (item != nullptr)
1478  break;
1479  }
1480  if ((item != nullptr) && item->isEquipped() == Equipped_false)
1482  }
1483  }
1484  // big distance. allowed only bow
1485  else
1486  {
1487  // searching bow
1488  const WeaponsInfos &bows = WeaponsDB::getBows();
1489  FOR_EACH (WeaponsInfosIter, it, bows)
1490  {
1491  item = inv->findItem(*it, ItemColor_zero);
1492  if (item != nullptr)
1493  break;
1494  }
1495 
1496  // no bow
1497  if (item == nullptr)
1498  return;
1499 
1500  if (item->isEquipped() == Equipped_false)
1502  }
1503 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void equipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:236
Item * findItem(const int itemId, const ItemColor color) const
Definition: inventory.cpp:93
Equipped isEquipped() const
Definition: item.h:128
unsigned int attackWeaponType
Definition: settings.h:135
Inventory * getInventory()
Definition: playerinfo.cpp:193
const bool Sfx_true
Definition: sfx.h:29
const ItemColor ItemColor_zero
Definition: itemcolor.h:29
const bool Equipped_false
Definition: equipped.h:29
std::vector< int > WeaponsInfos
Definition: weaponsdb.h:28
Settings settings
Definition: settings.cpp:31
const WeaponsInfos & getBows()
Definition: weaponsdb.cpp:72
int mX
Definition: being.h:1317
Definition: item.h:48
WeaponsInfos::const_iterator WeaponsInfosIter
Definition: weaponsdb.h:29
int mY
Definition: being.h:1318
const WeaponsInfos & getSwords()
Definition: weaponsdb.cpp:77
const WeaponsInfos & getShields()
Definition: weaponsdb.cpp:82

◆ checAttackPermissions()

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

Definition at line 2768 of file localplayer.cpp.

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

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

2769 {
2770  if (target == nullptr)
2771  return false;
2772 
2773  switch (settings.pvpAttackType)
2774  {
2775  case 0:
2776  return true;
2777  case 1:
2778  return !(playerRelations.getRelation(target->mName)
2779  == Relation::FRIEND);
2780  case 2:
2781  return playerRelations.checkBadRelation(target->mName);
2782  default:
2783  case 3:
2784  return false;
2785  }
2786 }
RelationT getRelation(const std::string &name) const
std::string mName
Definition: being.h:1183
Settings settings
Definition: settings.cpp:31
unsigned int pvpAttackType
Definition: settings.h:140
bool checkBadRelation(const std::string &name) const
PlayerRelationsManager playerRelations

◆ checkNewName()

void LocalPlayer::checkNewName ( Being *const  being)

Definition at line 2703 of file localplayer.cpp.

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

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

2704 {
2705  if (being == nullptr)
2706  return;
2707 
2708  const std::string &nick = being->mName;
2709  if (being->getType() == ActorType::Player)
2710  {
2711  const Guild *const guild = getGuild();
2712  if (guild != nullptr)
2713  {
2714  const GuildMember *const gm = guild->getMember(nick);
2715  if (gm != nullptr)
2716  {
2717  const int level = gm->getLevel();
2718  if (level > 1 && being->getLevel() != level)
2719  {
2720  being->setLevel(level);
2721  being->updateName();
2722  }
2723  }
2724  }
2725  if (chatWindow != nullptr)
2726  {
2727  WhisperTab *const tab = chatWindow->getWhisperTab(nick);
2728  if (tab != nullptr)
2729  tab->setWhisperTabColors();
2730  }
2731  }
2732 
2733  if (!mWaitFor.empty() && mWaitFor == nick)
2734  {
2735  // TRANSLATORS: wait player/monster message
2736  debugMsg(strprintf(_("You see %s"), mWaitFor.c_str()));
2738  mWaitFor.clear();
2739  }
2740 }
ChatWindow * chatWindow
Definition: chatwindow.cpp:89
#define _(s)
Definition: gettext.h:34
SoundManager soundManager
Guild * getGuild() const
Definition: being.cpp:1279
int getLevel() const
Definition: avatar.h:113
WhisperTab * getWhisperTab(const std::string &nick) const
GuildMember * getMember(const BeingId id) const
Definition: guild.cpp:139
std::string mName
Definition: being.h:1183
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
void setWhisperTabColors()
Definition: whispertab.cpp:122
ActorTypeT getType() const
Definition: being.h:115
void updateName()
Definition: being.cpp:3425
std::string mWaitFor
Definition: localplayer.h:497
bool gm(InputEvent &event)
Definition: commands.cpp:74
#define debugMsg(str)
Definition: chattab.h:41
virtual int getLevel() const
Definition: being.h:603
static const std::string SOUND_INFO
Definition: sound.h:26
uint32_t guild
Definition: guild.h:68
void setLevel(const int n)
Definition: being.h:600
void playGuiSound(const std::string &name)

◆ emote()

bool LocalPlayer::emote ( const uint8_t  emotion)
static

Definition at line 772 of file localplayer.cpp.

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

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

773 {
775  return false;
776 
777  playerHandler->emote(emotion);
778  return true;
779 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:93
virtual void emote(const uint8_t emoteId) const =0
bool limitPackets(const PacketTypeT type)

◆ failMove()

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

Definition at line 2693 of file localplayer.cpp.

Referenced by getRename(), and EAthena::PlayerRecv::processWalkError().

2695 {
2696 }

◆ fixAttackTarget()

void LocalPlayer::fixAttackTarget ( )

Definition at line 2638 of file localplayer.cpp.

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 getCheckNameSetting(), and Ea::BeingRecv::processPlayerMoveToAttack().

2639 {
2640  if ((mMap == nullptr) || (mTarget == nullptr))
2641  return;
2642 
2643  if (settings.moveToTargetType == 11 || (settings.attackType == 0U)
2644  || !config.getBoolValue("autofixPos"))
2645  {
2646  return;
2647  }
2648 
2649  const Path debugPath = mMap->findPath(
2650  (mPixelX - mapTileSize / 2) / mapTileSize,
2652  mTarget->mX,
2653  mTarget->mY,
2654  getBlockWalkMask(),
2655  0);
2656 
2657  if (!debugPath.empty())
2658  {
2659  const Path::const_iterator i = debugPath.begin();
2660  setDestination((*i).x, (*i).y);
2661  }
2662 }
unsigned int attackType
Definition: settings.h:136
void setDestination(const int x, const int y)
unsigned char getBlockWalkMask() const A_CONST
Configuration config
Being * mTarget
Definition: localplayer.h:460
unsigned int moveToTargetType
Definition: settings.h:133
Settings settings
Definition: settings.cpp:31
bool getBoolValue(const std::string &key) const
int mPixelX
Definition: actor.h:132
int mX
Definition: being.h:1317
int mPixelY
Definition: actor.h:133
int mY
Definition: being.h:1318
Path findPath(const int startX, const int startY, const int destX, const int destY, const unsigned char blockWalkmask, const int maxCost)
Definition: map.cpp:858
std::list< Position > Path
Definition: position.h:48
static const int mapTileSize
Definition: map.h:26
Map * mMap
Definition: actor.h:138

◆ fixPos()

void LocalPlayer::fixPos ( )

Definition at line 2575 of file localplayer.cpp.

References cur_time, mActivityTime, mCrossX, mCrossY, mSyncPlayerMove, mSyncPlayerMoveDistance, Being::mX, Being::mY, Being::setTileCoords(), and ServerCommandType::time.

Referenced by isServerBuggy(), and updateCoords().

2576 {
2577  if ((mCrossX == 0) && (mCrossY == 0))
2578  return;
2579 
2580  const int dx = abs(mX - mCrossX);
2581  const int dy = abs(mY - mCrossY);
2582  const int dist = dx > dy ? dx : dy;
2583  const time_t time = cur_time;
2584  const int maxDist = mSyncPlayerMove ? mSyncPlayerMoveDistance : 7;
2585 
2586  if (dist > maxDist)
2587  {
2588  mActivityTime = time;
2590 // alternative way to fix, move to real position
2591 // setDestination(mCrossX, mCrossY);
2592  }
2593 }
time_t mActivityTime
Definition: localplayer.h:484
void setTileCoords(const int x, const int y)
Definition: being.cpp:5010
bool mSyncPlayerMove
Definition: localplayer.h:516
int mX
Definition: being.h:1317
volatile time_t cur_time
Definition: timer.cpp:57
int mSyncPlayerMoveDistance
Definition: localplayer.h:503
int mY
Definition: being.h:1318

◆ followMoveTo() [1/2]

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

Definition at line 2495 of file localplayer.cpp.

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

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

2497 {
2498  if ((being != nullptr) &&
2499  !mPlayerFollowed.empty() &&
2500  being->mName == mPlayerFollowed)
2501  {
2502  mPickUpTarget = nullptr;
2503  navigateTo(x, y);
2504  }
2505 }
std::string mName
Definition: being.h:1183
bool navigateTo(const int x, const int y)
FloorItem * mPickUpTarget
Definition: localplayer.h:468
std::string mPlayerFollowed
Definition: localplayer.h:463

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

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

2510 {
2511  if (being == nullptr)
2512  return;
2513 
2514  mPickUpTarget = nullptr;
2515  if (!mPlayerFollowed.empty() &&
2516  being->mName == mPlayerFollowed)
2517  {
2518  switch (settings.followMode)
2519  {
2520  case 0:
2521  navigateTo(x1, y1);
2522  setNextDest(x2, y2);
2523  break;
2524  case 1:
2525  if (x1 != x2 || y1 != y2)
2526  {
2527  navigateTo(mX + x2 - x1, mY + y2 - y1);
2528  setNextDest(mX + x2 - x1, mY + y2 - y1);
2529  }
2530  break;
2531  case 2:
2532  if (x1 != x2 || y1 != y2)
2533  {
2534  navigateTo(mX + x1 - x2, mY + y1 - y2);
2535  setNextDest(mX + x1 - x2, mY + y1 - y2);
2536  }
2537  break;
2538  case 3:
2539  if (mTarget == nullptr ||
2541  {
2542  if (actorManager != nullptr)
2543  {
2544  Being *const b = actorManager->findBeingByName(
2546  setTarget(b);
2547  }
2548  }
2549  moveToTarget(-1);
2550  setNextDest(x2, y2);
2551  break;
2552  default:
2553  break;
2554  }
2555  }
2556 }
unsigned int followMode
Definition: settings.h:134
Being * mTarget
Definition: localplayer.h:460
void moveToTarget(int dist)
std::string mName
Definition: being.h:1183
Settings settings
Definition: settings.cpp:31
int mX
Definition: being.h:1317
bool navigateTo(const int x, const int y)
void setNextDest(const int x, const int y)
int mY
Definition: being.h:1318
void setTarget(Being *const target)
Being * findBeingByName(const std::string &name, const ActorTypeT type) const
Definition: being.h:93
FloorItem * mPickUpTarget
Definition: localplayer.h:468
std::string mPlayerFollowed
Definition: localplayer.h:463
ActorManager * actorManager

◆ freezeMoving()

void LocalPlayer::freezeMoving ( const int  timeWaitTicks)

Definition at line 2848 of file localplayer.cpp.

References mFreezed, mUnfreezeTime, and tick_time.

Referenced by getRename(), and EAthena::BeingRecv::processSkillCastingContinue().

2849 {
2850  if (timeWaitTicks <= 0)
2851  return;
2852  const int nextTime = tick_time + timeWaitTicks;
2853  if (mUnfreezeTime < nextTime)
2854  mUnfreezeTime = nextTime;
2855  if (mUnfreezeTime > 0)
2856  mFreezed = true;
2857 }
volatile int tick_time
Definition: timer.cpp:52
int mUnfreezeTime
Definition: localplayer.h:504

◆ getAttackRange()

int LocalPlayer::getAttackRange ( ) const

Gets the attack range.

Definition at line 986 of file localplayer.cpp.

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

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

987 {
988  if (mAttackRange > -1)
989  {
990  return mAttackRange;
991  }
992 
993  const Item *const weapon = PlayerInfo::getEquipment(
995  if (weapon != nullptr)
996  {
997  const ItemInfo &info = weapon->getInfo();
998  return info.getAttackRange();
999  }
1000  return 48; // unarmed range
1001 }
Equipment * getEquipment()
Definition: playerinfo.cpp:218
bool info(InputEvent &event)
Definition: commands.cpp:56
int getAttackRange() const
Definition: iteminfo.h:197
Definition: item.h:48
const ItemInfo & getInfo() const
Definition: item.h:170
int mAttackRange
Definition: being.h:1225

◆ getAttackRange2()

int LocalPlayer::getAttackRange2 ( ) const

Definition at line 2282 of file localplayer.cpp.

References getAttackRange().

Referenced by attack2().

2283 {
2284  int range = getAttackRange();
2285  if (range == 1)
2286  range = 2;
2287  return range;
2288 }
int getAttackRange() const

◆ getAwayListener()

AwayListener* LocalPlayer::getAwayListener ( ) const
inline

Definition at line 415 of file localplayer.h.

References mAwayListener.

Referenced by GameModifiers::changeAwayMode().

416  { return mAwayListener; }
AwayListener * mAwayListener
Definition: localplayer.h:478

◆ getBlockWalkMask()

unsigned char LocalPlayer::getBlockWalkMask ( ) const
virtual

Gets the way the object is blocked by other objects.

Reimplemented from Being.

Definition at line 2742 of file localplayer.cpp.

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

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

2743 {
2744  // for now blocking all types of collisions
2745  return BlockMask::WALL |
2746  BlockMask::AIR |
2749 }

◆ getCheckNameSetting()

bool LocalPlayer::getCheckNameSetting ( ) const
inline

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

Definition at line 352 of file localplayer.h.

References A_WARN_UNUSED, fixAttackTarget(), getPathLength(), mUpdateName, targetMoved(), and updateNavigateList().

353  { return mUpdateName; }
bool mUpdateName
Definition: localplayer.h:507

◆ getFollow()

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

Get the playername followed by the current player.

Definition at line 332 of file localplayer.h.

References mPlayerFollowed.

Referenced by InputManager::updateConditionMask().

333  { return mPlayerFollowed; }
std::string mPlayerFollowed
Definition: localplayer.h:463

◆ getHalfAway()

bool LocalPlayer::getHalfAway ( ) const
inline

◆ getImitate()

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

Get the playername imitated by the current player.

Definition at line 338 of file localplayer.h.

References mPlayerImitated.

Referenced by imitateEmote().

339  { return mPlayerImitated; }
std::string mPlayerImitated
Definition: localplayer.h:464

◆ getLastAttackX()

int LocalPlayer::getLastAttackX ( ) const
inlinevirtual

Reimplemented from Being.

Definition at line 397 of file localplayer.h.

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

398  { return mTarget != nullptr ? mTarget->mX : mLastAttackX; }
Being * mTarget
Definition: localplayer.h:460
int mX
Definition: being.h:1317
int mLastAttackX
Definition: being.h:1226

◆ getLastAttackY()

int LocalPlayer::getLastAttackY ( ) const
inlinevirtual

Reimplemented from Being.

Definition at line 400 of file localplayer.h.

References attributeChanged(), Being::mLastAttackY, mTarget, Being::mY, and updateMusic().

401  { return mTarget != nullptr ? mTarget->mY : mLastAttackY; }
Being * mTarget
Definition: localplayer.h:460
int mLastAttackY
Definition: being.h:1227
int mY
Definition: being.h:1318

◆ getLevel()

int LocalPlayer::getLevel ( ) const
virtual

Reimplemented from Being.

Definition at line 2669 of file localplayer.cpp.

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

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

2670 {
2672 }
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:100

◆ getMoveState()

unsigned int LocalPlayer::getMoveState ( ) const
inline

Definition at line 192 of file localplayer.h.

References mMoveState.

Referenced by specialMove().

193  { return mMoveState; }
unsigned int mMoveState
Definition: localplayer.h:453

◆ getNextDestX()

int LocalPlayer::getNextDestX ( ) const
inline

Definition at line 310 of file localplayer.h.

References mNextDestX.

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

311  { return mNextDestX; }

◆ getNextDestY()

int LocalPlayer::getNextDestY ( ) const
inline

Definition at line 313 of file localplayer.h.

References mNextDestY, and respawn().

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

314  { return mNextDestY; }

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

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

Referenced by attack2(), and getCheckNameSetting().

2248 {
2249  if ((mMap == nullptr) || (being == nullptr))
2250  return 0;
2251 
2252  if (being->mX == mX && being->mY == mY)
2253  return 0;
2254 
2255  if (being->mX - 1 <= mX &&
2256  being->mX + 1 >= mX &&
2257  being->mY - 1 <= mY &&
2258  being->mY + 1 >= mY)
2259  {
2260  return 1;
2261  }
2262 
2264  {
2265  const Path debugPath = mMap->findPath(
2266  (mPixelX - mapTileSize / 2) / mapTileSize,
2268  being->mX,
2269  being->mY,
2270  getBlockWalkMask(),
2271  0);
2272  return CAST_S32(debugPath.size());
2273  }
2274 
2275  const int dx = CAST_S32(abs(being->mX - mX));
2276  const int dy = CAST_S32(abs(being->mY - mY));
2277  if (dx > dy)
2278  return dx;
2279  return dy;
2280 }
unsigned char getBlockWalkMask() const A_CONST
bool mTargetOnlyReachable
Definition: localplayer.h:514
int mPixelX
Definition: actor.h:132
#define CAST_S32
Definition: cast.h:29
int mX
Definition: being.h:1317
int mPixelY
Definition: actor.h:133
int mY
Definition: being.h:1318
Path findPath(const int startX, const int startY, const int destX, const int destY, const unsigned char blockWalkmask, const int maxCost)
Definition: map.cpp:858
std::list< Position > Path
Definition: position.h:48
static const int mapTileSize
Definition: map.h:26
Map * mMap
Definition: actor.h:138

◆ getPickUpTarget()

const FloorItem* LocalPlayer::getPickUpTarget ( ) const
inline

Definition at line 318 of file localplayer.h.

References mPickUpTarget.

Referenced by ActorManager::logic().

319  { return mPickUpTarget; }
FloorItem * mPickUpTarget
Definition: localplayer.h:468

◆ getPingTime()

std::string LocalPlayer::getPingTime ( ) const

Definition at line 1960 of file localplayer.cpp.

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

Referenced by NetDebugTab::logic(), and setMoveState().

1961 {
1962  std::string str;
1963  if (!mWaitPing)
1964  {
1965  if (mPingTime == 0)
1966  str = "?";
1967  else
1968  str = toString(CAST_S32(mPingTime));
1969  }
1970  else
1971  {
1972  time_t time = tick_time;
1973  if (time > mPingSendTick)
1974  time -= mPingSendTick;
1975  else
1976  time += MAX_TICK_VALUE - mPingSendTick;
1977  if (time <= mPingTime)
1978  time = mPingTime;
1979  if (mPingTime != time)
1980  str = strprintf("%d (%d)", CAST_S32(mPingTime), CAST_S32(time));
1981  else
1982  str = toString(CAST_S32(time));
1983  }
1984  return str;
1985 }
volatile int tick_time
Definition: timer.cpp:52
int mPingSendTick
Definition: localplayer.h:481
bool mWaitPing
Definition: localplayer.h:529
#define CAST_S32
Definition: cast.h:29
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
time_t mPingTime
Definition: localplayer.h:482
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
static const int MAX_TICK_VALUE

◆ getRename()

bool LocalPlayer::getRename ( ) const
inline

◆ getTarget()

Being * LocalPlayer::getTarget ( ) const

◆ getWalkingDir()

unsigned char LocalPlayer::getWalkingDir ( ) const
inline

Gets the walking direction

Definition at line 147 of file localplayer.h.

References A_WARN_UNUSED, emote(), getLevel(), Actions::itemInfo(), mWalkingDir, pickedUp(), setGotoTarget(), stopWalking(), toggleSit(), updateSit(), and withinAttackRange().

148  { return mWalkingDir; }
unsigned char mWalkingDir
Definition: localplayer.h:505

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

References CAST_S32, StatusEffect::deliverMessage(), MiniStatusWindow::eraseIcon(), StatusEffect::getIcon(), ActorSprite::handleStatusEffect(), miniStatusWindow, mStatusEffectIcons, StatusEffect::playSFX(), and MiniStatusWindow::setIcon().

Referenced by getRename().

1038 {
1040  effectId,
1041  newStatus,
1042  start);
1043 
1044  if (effect != nullptr)
1045  {
1046  effect->deliverMessage();
1047  effect->playSFX();
1048 
1049  AnimatedSprite *const sprite = effect->getIcon();
1050 
1051  if (sprite == nullptr)
1052  {
1053  // delete sprite, if necessary
1054  for (size_t i = 0; i < mStatusEffectIcons.size(); )
1055  {
1056  if (mStatusEffectIcons[i] == effectId)
1057  {
1058  mStatusEffectIcons.erase(mStatusEffectIcons.begin() + i);
1059  if (miniStatusWindow != nullptr)
1061  }
1062  else
1063  {
1064  i++;
1065  }
1066  }
1067  }
1068  else
1069  {
1070  // replace sprite or append
1071  bool found = false;
1072  const size_t sz = mStatusEffectIcons.size();
1073  for (size_t i = 0; i < sz; i++)
1074  {
1075  if (mStatusEffectIcons[i] == effectId)
1076  {
1077  if (miniStatusWindow != nullptr)
1078  miniStatusWindow->setIcon(CAST_S32(i), sprite);
1079  found = true;
1080  break;
1081  }
1082  }
1083 
1084  if (!found)
1085  { // add new
1086  const int offset = CAST_S32(mStatusEffectIcons.size());
1087  if (miniStatusWindow != nullptr)
1088  miniStatusWindow->setIcon(offset, sprite);
1089  mStatusEffectIcons.push_back(effectId);
1090  }
1091  }
1092  }
1093 }
void deliverMessage() const
AnimatedSprite * getIcon() const
MiniStatusWindow * miniStatusWindow
#define CAST_S32
Definition: cast.h:29
void eraseIcon(const int index)
void playSFX() const
std::vector< int32_t > mStatusEffectIcons
Definition: localplayer.h:472
void setIcon(const int index, AnimatedSprite *const sprite)
virtual void handleStatusEffect(const StatusEffect *const effect, const int32_t effectId, const Enable newStatus, const IsStart start)

◆ imitateAction()

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

Definition at line 2395 of file localplayer.cpp.

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

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

2397 {
2398  if (being == nullptr)
2399  return;
2400 
2401  if (!mPlayerImitated.empty() && being->mName == mPlayerImitated)
2402  {
2403  setAction(action, 0);
2404  playerHandler->changeAction(action);
2405  }
2406 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:93
std::string mName
Definition: being.h:1183
std::string mPlayerImitated
Definition: localplayer.h:464
virtual void changeAction(const BeingActionT &action) const =0
void setAction(const BeingActionT &action, const int attackId)

◆ imitateDirection()

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

Definition at line 2408 of file localplayer.cpp.

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

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

2410 {
2411  if (being == nullptr)
2412  return;
2413 
2414  if (!mPlayerImitated.empty() && being->mName == mPlayerImitated)
2415  {
2417  return;
2418 
2419  if (settings.followMode == 2)
2420  {
2421  uint8_t dir2 = 0;
2422  if ((dir & BeingDirection::LEFT) != 0)
2423  dir2 |= BeingDirection::RIGHT;
2424  else if ((dir & BeingDirection::RIGHT) != 0)
2425  dir2 |= BeingDirection::LEFT;
2426  if ((dir & BeingDirection::UP) != 0)
2427  dir2 |= BeingDirection::DOWN;
2428  else if ((dir & BeingDirection::DOWN) != 0)
2429  dir2 |= BeingDirection::UP;
2430 
2431  setDirection(dir2);
2432  playerHandler->setDirection(dir2);
2433  }
2434  else
2435  {
2436  setDirection(dir);
2438  }
2439  }
2440 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:93
unsigned int followMode
Definition: settings.h:134
bool limitPackets(const PacketTypeT type)
std::string mName
Definition: being.h:1183
virtual void setDirection(const uint8_t direction)
Definition: being.cpp:1689
Settings settings
Definition: settings.cpp:31
std::string mPlayerImitated
Definition: localplayer.h:464
virtual void setDirection(const unsigned char direction) const =0

◆ imitateEmote()

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

Definition at line 2384 of file localplayer.cpp.

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

Referenced by getHalfAway(), and Ea::BeingRecv::processBeingEmotion().

2386 {
2387  if (being == nullptr)
2388  return;
2389 
2390  std::string player_imitated = getImitate();
2391  if (!player_imitated.empty() && being->mName == player_imitated)
2392  emote(action);
2393 }
std::string mName
Definition: being.h:1183
const std::string & getImitate() const
Definition: localplayer.h:338
static bool emote(const uint8_t emotion)

◆ imitateOutfit()

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

Definition at line 2442 of file localplayer.cpp.

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(), ServerCommandType::item, Being::mName, mPlayerImitated, CompoundSprite::mSprites, settings, Sfx_false, and PlayerInfo::unequipItem().

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

2444 {
2445  if (player == nullptr)
2446  return;
2447 
2448  if (settings.imitationMode == 1 &&
2449  !mPlayerImitated.empty() &&
2450  player->mName == mPlayerImitated)
2451  {
2452  if (sprite < 0 || sprite >= player->getNumberOfLayers())
2453  return;
2454 
2455  const AnimatedSprite *const equipmentSprite
2456  = dynamic_cast<const AnimatedSprite *>(
2457  player->mSprites[sprite]);
2458 
2459  if (equipmentSprite != nullptr)
2460  {
2461 // logger->log("have equipmentSprite");
2462  const Inventory *const inv = PlayerInfo::getInventory();
2463  if (inv == nullptr)
2464  return;
2465 
2466  const std::string &path = equipmentSprite->getIdPath();
2467  if (path.empty())
2468  return;
2469 
2470 // logger->log("idPath: " + path);
2471  const Item *const item = inv->findItemBySprite(path,
2472  player->getGender(), player->getSubType());
2473  if ((item != nullptr) && item->isEquipped() == Equipped_false)
2475  }
2476  else
2477  {
2478 // logger->log("have unequip %d", sprite);
2479  const int equipmentSlot = inventoryHandler
2480  ->convertFromServerSlot(sprite);
2481 // logger->log("equipmentSlot: " + toString(equipmentSlot));
2482  if (equipmentSlot == inventoryHandler->getProjectileSlot())
2483  return;
2484 
2485  const Item *const item = PlayerInfo::getEquipment(equipmentSlot);
2486  if (item != nullptr)
2487  {
2488 // logger->log("unequiping");
2490  }
2491  }
2492  }
2493 }
int getNumberOfLayers() const
Definition: being.h:376
void equipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:236
Equipment * getEquipment()
Definition: playerinfo.cpp:218
GenderT getGender() const
Definition: being.h:625
Equipped isEquipped() const
Definition: item.h:128
Inventory * getInventory()
Definition: playerinfo.cpp:193
const bool Sfx_false
Definition: sfx.h:29
const bool Equipped_false
Definition: equipped.h:29
unsigned int imitationMode
Definition: settings.h:141
std::string mName
Definition: being.h:1183
Settings settings
Definition: settings.cpp:31
std::string mPlayerImitated
Definition: localplayer.h:464
virtual int getProjectileSlot() const =0
std::vector< Sprite * > mSprites
std::string getIdPath() const
Definition: item.h:48
const Item * findItemBySprite(std::string spritePath, const GenderT gender, const BeingTypeId race) const
Definition: inventory.cpp:317
Net::InventoryHandler * inventoryHandler
Definition: net.cpp:86
void unequipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:244
virtual int convertFromServerSlot(const int eAthenaSlot) const =0
BeingTypeId getSubType() const
Definition: being.h:399

◆ isPathSetByMouse()

bool LocalPlayer::isPathSetByMouse ( ) const
inline

Tells if the path has been set by mouse.

Definition at line 189 of file localplayer.h.

References mPathSetByMouse.

190  { return mPathSetByMouse; }
bool mPathSetByMouse
Definition: localplayer.h:528

◆ isReachable() [1/2]

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

Definition at line 1505 of file localplayer.cpp.

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(), setMoveState(), SocialNavigationTab::updateList(), and ActorManager::validateBeing().

1507 {
1508  if ((being == nullptr) || (mMap == nullptr))
1509  return false;
1510 
1511  if (being->getReachable() == Reachable::REACH_NO)
1512  return false;
1513 
1514  if (being->mX == mX &&
1515  being->mY == mY)
1516  {
1517  being->setDistance(0);
1519  return true;
1520  }
1521  else if (being->mX - 1 <= mX &&
1522  being->mX + 1 >= mX &&
1523  being->mY - 1 <= mY &&
1524  being->mY + 1 >= mY)
1525  {
1526  being->setDistance(1);
1528  return true;
1529  }
1530 
1531  const Path debugPath = mMap->findPath(
1532  (mPixelX - mapTileSize / 2) / mapTileSize,
1534  being->mX,
1535  being->mY,
1536  getBlockWalkMask(),
1537  maxCost);
1538 
1539  being->setDistance(CAST_S32(debugPath.size()));
1540  if (!debugPath.empty())
1541  {
1543  return true;
1544  }
1546  return false;
1547 }
void setDistance(const int n)
Definition: being.h:554
unsigned char getBlockWalkMask() const A_CONST
ReachableT getReachable() const
Definition: being.h:609
int mPixelX
Definition: actor.h:132
#define CAST_S32
Definition: cast.h:29
int mX
Definition: being.h:1317
void setReachable(const ReachableT n)
Definition: being.h:606
int mPixelY
Definition: actor.h:133
int mY
Definition: being.h:1318
Path findPath(const int startX, const int startY, const int destX, const int destY, const unsigned char blockWalkmask, const int maxCost)
Definition: map.cpp:858
std::list< Position > Path
Definition: position.h:48
static const int mapTileSize
Definition: map.h:26
Map * mMap
Definition: actor.h:138

◆ isReachable() [2/2]

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

Definition at line 1549 of file localplayer.cpp.

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

1551 {
1552  const WalkLayer *const walk = mMap->getWalkLayer();
1553  if (walk == nullptr)
1554  return false;
1555  int num = walk->getDataAt(x, y);
1556  if (allowCollision && num < 0)
1557  num = -num;
1558 
1559  return walk->getDataAt(mX, mY) == num;
1560 }
const WalkLayer * getWalkLayer() const
Definition: map.h:346
int mX
Definition: being.h:1317
int getDataAt(const int x, const int y) const
Definition: walklayer.cpp:39
int mY
Definition: being.h:1318
Map * mMap
Definition: actor.h:138

◆ isServerBuggy()

bool LocalPlayer::isServerBuggy ( ) const
inline

◆ loadHomes()

void LocalPlayer::loadHomes ( )
protected

Definition at line 1778 of file localplayer.cpp.

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

Referenced by getRename(), and LocalPlayer().

1779 {
1780  std::string buf;
1781  std::stringstream ss(serverConfig.getValue("playerHomes", ""));
1782 
1783  while (ss >> buf)
1784  {
1785  Vector pos;
1786  ss >> pos.x;
1787  ss >> pos.y;
1788  mHomes[buf] = pos;
1789  }
1790 }
std::map< std::string, Vector > mHomes
Definition: localplayer.h:458
Definition: vector.h:38
Configuration serverConfig
float x
Definition: vector.h:208
std::string getValue(const std::string &key, const std::string &deflt) const
float y
Definition: vector.h:208

◆ logic()

void LocalPlayer::logic ( )
virtual

Performs being logic.

Reimplemented from Being.

Definition at line 244 of file localplayer.cpp.

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.

Referenced by Being::getNumberOfLayers().

245 {
246  BLOCK_START("LocalPlayer::logic")
247 #ifdef USE_MUMBLE
248  if (mumbleManager)
249  mumbleManager->setPos(mX, mY, mDirection);
250 #endif // USE_MUMBLE
251 
252  // Actions are allowed once per second
253  if (get_elapsed_time(mLastAction) >= 1000)
254  mLastAction = -1;
255 
256  if (mActivityTime == 0 || mLastAction != -1)
258 
259  if (mUnfreezeTime > 0 &&
261  {
262  mUnfreezeTime = 0;
263  mFreezed = false;
264  }
265 
266  if ((mAction != BeingAction::MOVE || mNextStep) && !mNavigatePath.empty())
267  {
268  mNextStep = false;
269  int dist = 5;
270  if (!mSyncPlayerMove)
271  dist = 20;
272 
273  if (((mNavigateX != 0) || (mNavigateY != 0)) &&
274  ((mCrossX + dist >= mX && mCrossX <= mX + dist
275  && mCrossY + dist >= mY && mCrossY <= mY + dist)
276  || ((mCrossX == 0) && (mCrossY == 0))))
277  {
278  const Path::const_iterator i = mNavigatePath.begin();
279  if ((*i).x == mX && (*i).y == mY)
280  mNavigatePath.pop_front();
281  else
282  setDestination((*i).x, (*i).y);
283  }
284  }
285 
286  // Show XP messages
287  if (!mMessages.empty())
288  {
289  if (mMessageTime == 0)
290  {
291  const MessagePair info = mMessages.front();
292 
293  if ((particleEngine != nullptr) && (gui != nullptr))
294  {
296  info.first,
297  mPixelX,
298  mPixelY - 48,
299  &userPalette->getColor(info.second, 255U),
301  true);
302  }
303 
304  mMessages.pop_front();
305  mMessageTime = 30;
306  }
307  mMessageTime--;
308  }
309 
310  if (mTarget != nullptr)
311  {
312  if (mTarget->getType() == ActorType::Npc)
313  {
314  // NPCs are always in range
316  }
317  else
318  {
319  // Find whether target is in range
320  const int rangeX = CAST_S32(
321  abs(mTarget->mX - mX));
322  const int rangeY = CAST_S32(
323  abs(mTarget->mY - mY));
324  const int attackRange = getAttackRange();
325  const TargetCursorTypeT targetType
326  = rangeX > attackRange || rangeY > attackRange
328  mTarget->setTargetType(targetType);
329 
330  if (!mTarget->isAlive() && (!mTargetDeadPlayers
332  {
333  stopAttack(true);
334  }
335 
336  if (mKeepAttacking && (mTarget != nullptr))
337  attack(mTarget, true, false);
338  }
339  }
340 
341  Being::logic();
342  BLOCK_END("LocalPlayer::logic")
343 }
time_t mActivityTime
Definition: localplayer.h:484
const Color & getColor(UserColorIdT type, const unsigned int alpha)
Definition: userpalette.h:159
void setDestination(const int x, const int y)
volatile int tick_time
Definition: timer.cpp:52
Gui * gui
Definition: gui.cpp:110
void attack(Being *const target, const bool keep, const bool dontChangeEquipment)
std::pair< std::string, UserColorIdT > MessagePair
Definition: localplayer.h:474
bool mNextStep
Definition: localplayer.h:522
uint8_t mDirection
Definition: being.h:1234
TargetCursorType ::T TargetCursorTypeT
int mUnfreezeTime
Definition: localplayer.h:504
#define BLOCK_START(name)
Definition: perfomance.h:78
ParticleEngine * particleEngine
Font * getInfoParticleFont() const
Definition: gui.h:184
#define BLOCK_END(name)
Definition: perfomance.h:79
bool mSyncPlayerMove
Definition: localplayer.h:516
Being * mTarget
Definition: localplayer.h:460
Particle * addTextRiseFadeOutEffect(const std::string &text, const int x, const int y, const Color *const color, Font *const font, const bool outline)
UserPalette * userPalette
Definition: userpalette.cpp:33
int get_elapsed_time(const int startTime)
Definition: timer.cpp:93
std::list< MessagePair > mMessages
Definition: localplayer.h:476
int mPixelX
Definition: actor.h:132
#define CAST_S32
Definition: cast.h:29
int mX
Definition: being.h:1317
bool info(InputEvent &event)
Definition: commands.cpp:56
int mMessageTime
Definition: localplayer.h:477
void setTargetType(const TargetCursorTypeT type)
bool isAlive() const
Definition: being.h:487
void stopAttack(const bool keepAttack)
ActorTypeT getType() const
Definition: being.h:115
Path mNavigatePath
Definition: localplayer.h:494
volatile time_t cur_time
Definition: timer.cpp:57
int mPixelY
Definition: actor.h:133
bool mTargetDeadPlayers
Definition: localplayer.h:509
int mY
Definition: being.h:1318
void logic()
Definition: being.cpp:1833
BeingActionT mAction
Definition: being.h:1232
int getAttackRange() const
bool mKeepAttacking
Definition: localplayer.h:526

◆ magicAttack()

void LocalPlayer::magicAttack ( ) const

Definition at line 1720 of file localplayer.cpp.

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

Referenced by Actions::getAmountFromEvent(), and setMoveState().

1721 {
1723  return;
1724  if (chatWindow == nullptr ||
1725  !isAlive() ||
1727  {
1728  return;
1729  }
1730 
1731  switch (settings.magicAttackType)
1732  {
1733  // flar W00
1734  case 0:
1735  tryMagic("#flar", 1, 0, 10);
1736  break;
1737  // chiza W01
1738  case 1:
1739  tryMagic("#chiza", 1, 0, 9);
1740  break;
1741  // ingrav W10
1742  case 2:
1743  tryMagic("#ingrav", 2, 2, 20);
1744  break;
1745  // frillyar W11
1746  case 3:
1747  tryMagic("#frillyar", 2, 2, 25);
1748  break;
1749  // upmarmu W12
1750  case 4:
1751  tryMagic("#upmarmu", 2, 2, 20);
1752  break;
1753  default:
1754  break;
1755  }
1756 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:93
ChatWindow * chatWindow
Definition: chatwindow.cpp:89
virtual bool canUseMagic() const =0
Settings settings
Definition: settings.cpp:31
bool isAlive() const
Definition: being.h:487
ServerTypeT getNetworkType()
Definition: net.cpp:184
unsigned int magicAttackType
Definition: settings.h:139
static void tryMagic(const std::string &spell, const int baseMagic, const int schoolMagic, const int mana)

◆ move()

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

◆ moveByDirection()

void LocalPlayer::moveByDirection ( const unsigned char  dir)

Definition at line 1667 of file localplayer.cpp.

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

Referenced by setMoveState(), and specialMove().

1668 {
1669  int dx = 0;
1670  int dy = 0;
1671  if ((dir & BeingDirection::UP) != 0)
1672  dy--;
1673  if ((dir & BeingDirection::DOWN) != 0)
1674  dy++;
1675  if ((dir & BeingDirection::LEFT) != 0)
1676  dx--;
1677  if ((dir & BeingDirection::RIGHT) != 0)
1678  dx++;
1679  move(dx, dy);
1680 }
void move(const int dX, const int dY)

◆ moveToHome()

void LocalPlayer::moveToHome ( )

Definition at line 1395 of file localplayer.cpp.

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

Referenced by Actions::closeMoveNpcDialog(), and setMoveState().

1396 {
1397  mPickUpTarget = nullptr;
1398  if ((mX != mCrossX || mY != mCrossY) && (mCrossX != 0) && (mCrossY != 0))
1399  {
1401  }
1402  else if (mMap != nullptr)
1403  {
1404  const std::map<std::string, Vector>::const_iterator iter =
1405  mHomes.find(mMap->getProperty("_realfilename", std::string()));
1406 
1407  if (iter != mHomes.end())
1408  {
1409  const Vector pos = mHomes[(*iter).first];
1410  if (mX == pos.x && mY == pos.y)
1411  {
1413  CAST_S32(pos.x),
1414  CAST_S32(pos.y),
1415  CAST_S32(mDirection));
1416  }
1417  else
1418  {
1419  navigateTo(CAST_S32(pos.x), CAST_S32(pos.y));
1420  }
1421  }
1422  }
1423 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:93
void setDestination(const int x, const int y)
std::map< std::string, Vector > mHomes
Definition: localplayer.h:458
uint8_t mDirection
Definition: being.h:1234
Definition: vector.h:38
const std::string getProperty(const std::string &name, const std::string &def) const
Definition: properties.h:58
#define CAST_S32
Definition: cast.h:29
int mX
Definition: being.h:1317
virtual void setDestination(const int x, const int y, const int direction) const =0
bool navigateTo(const int x, const int y)
float x
Definition: vector.h:208
int mY
Definition: being.h:1318
float y
Definition: vector.h:208
FloorItem * mPickUpTarget
Definition: localplayer.h:468
Map * mMap
Definition: actor.h:138

◆ moveToTarget()

void LocalPlayer::moveToTarget ( int  dist)

Definition at line 1308 of file localplayer.cpp.

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(), Actions::closeMoveNpcDialog(), followMoveTo(), and setMoveState().

1309 {
1310  bool gotPos(false);
1311  Path debugPath;
1312 
1313  size_t limit(0);
1314 
1315  if (dist == -1)
1316  {
1317  dist = settings.moveToTargetType;
1318  if (dist != 0)
1319  {
1320  const bool broken = (Net::getNetworkType() ==
1322  switch (dist)
1323  {
1324  case 10:
1325  dist = mAttackRange;
1326  if (dist == 1 && broken)
1327  dist = 2;
1328  break;
1329  case 11:
1330  dist = mAttackRange - 1;
1331  if (dist < 1)
1332  dist = 1;
1333  if (dist == 1 && broken)
1334  dist = 2;
1335  break;
1336  default:
1337  break;
1338  }
1339  }
1340  }
1341 
1342  if (mTarget != nullptr)
1343  {
1344  if (mMap != nullptr)
1345  {
1346  debugPath = mMap->findPath(
1347  (mPixelX - mapTileSize / 2) / mapTileSize,
1349  mTarget->mX,
1350  mTarget->mY,
1351  getBlockWalkMask(),
1352  0);
1353  }
1354 
1355  const size_t sz = debugPath.size();
1356  if (sz < CAST_SIZE(dist))
1357  return;
1358  limit = CAST_S32(sz) - dist;
1359  gotPos = true;
1360  }
1361  else if ((mNavigateX != 0) || (mNavigateY != 0))
1362  {
1363  debugPath = mNavigatePath;
1364  limit = dist;
1365  gotPos = true;
1366  }
1367 
1368  if (gotPos)
1369  {
1370  if (dist == 0)
1371  {
1372  if (mTarget != nullptr)
1374  }
1375  else
1376  {
1377  Position pos(0, 0);
1378  size_t f = 0;
1379 
1380  for (Path::const_iterator i = debugPath.begin(),
1381  i_fend = debugPath.end();
1382  i != i_fend && f < limit; ++i, f++)
1383  {
1384  pos = (*i);
1385  }
1386  navigateTo(pos.x, pos.y);
1387  }
1388  }
1389  else if ((mLastTargetX != 0) || (mLastTargetY != 0))
1390  {
1392  }
1393 }
int mLastTargetX
Definition: localplayer.h:455
unsigned char getBlockWalkMask() const A_CONST
Being * mTarget
Definition: localplayer.h:460
unsigned int moveToTargetType
Definition: settings.h:133
Settings settings
Definition: settings.cpp:31
int mPixelX
Definition: actor.h:132
#define CAST_S32
Definition: cast.h:29
int mX
Definition: being.h:1317
Path mNavigatePath
Definition: localplayer.h:494
bool navigateTo(const int x, const int y)
int mLastTargetY
Definition: localplayer.h:456
int mPixelY
Definition: actor.h:133
ServerTypeT getNetworkType()
Definition: net.cpp:184
int mY
Definition: being.h:1318
Path findPath(const int startX, const int startY, const int destX, const int destY, const unsigned char blockWalkmask, const int maxCost)
Definition: map.cpp:858
std::list< Position > Path
Definition: position.h:48
static const int mapTileSize
Definition: map.h:26
#define CAST_SIZE
Definition: cast.h:33
int mAttackRange
Definition: being.h:1225
Map * mMap
Definition: actor.h:138

◆ navigateClean()

void LocalPlayer::navigateClean ( )

Definition at line 2118 of file localplayer.cpp.

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

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

2119 {
2120  if (mMap == nullptr)
2121  return;
2122 
2123  mShowNavigePath = false;
2124  mOldX = 0;
2125  mOldY = 0;
2126  mOldTileX = 0;
2127  mOldTileY = 0;
2128  mNavigateX = 0;
2129  mNavigateY = 0;
2131 
2132  mNavigatePath.clear();
2133 
2134  SpecialLayer *const tmpLayer = mMap->getTempLayer();
2135  if (tmpLayer == nullptr)
2136  return;
2137 
2138  tmpLayer->clean();
2139 }
Path mNavigatePath
Definition: localplayer.h:494
bool mShowNavigePath
Definition: localplayer.h:530
SpecialLayer * getTempLayer() const
Definition: map.h:237
BeingId mNavigateId
Definition: localplayer.h:487
const BeingId BeingId_zero
Definition: beingid.h:29
Map * mMap
Definition: actor.h:138

◆ navigateTo()

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

Definition at line 2087 of file localplayer.cpp.

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 Actions::changeRelation(), followMoveTo(), getHalfAway(), Viewport::getMouseTile(), AvatarListBox::mousePressed(), Minimap::mouseReleased(), moveToHome(), moveToTarget(), pickUp(), SocialNavigationTab::selectIndex(), and setGotoTarget().

2088 {
2089  if (mMap == nullptr)
2090  return false;
2091 
2092  SpecialLayer *const tmpLayer = mMap->getTempLayer();
2093  if (tmpLayer == nullptr)
2094  return false;
2095 
2096  mShowNavigePath = true;
2097  mOldX = mPixelX;
2098  mOldY = mPixelY;
2099  mOldTileX = mX;
2100  mOldTileY = mY;
2101  mNavigateX = x;
2102  mNavigateY = y;
2104 
2106  (mPixelX - mapTileSize / 2) / mapTileSize,
2108  x,
2109  y,
2110  getBlockWalkMask(),
2111  0);
2112 
2113  if (mDrawPath)
2114  tmpLayer->addRoad(mNavigatePath);
2115  return !mNavigatePath.empty();
2116 }
unsigned char getBlockWalkMask() const A_CONST
int mPixelX
Definition: actor.h:132
int mX
Definition: being.h:1317
Path mNavigatePath
Definition: localplayer.h:494
int mPixelY
Definition: actor.h:133
bool mShowNavigePath
Definition: localplayer.h:530
void addRoad(const Path &road)
SpecialLayer * getTempLayer() const
Definition: map.h:237
BeingId mNavigateId
Definition: localplayer.h:487
int mY
Definition: being.h:1318
Path findPath(const int startX, const int startY, const int destX, const int destY, const unsigned char blockWalkmask, const int maxCost)
Definition: map.cpp:858
static const int mapTileSize
Definition: map.h:26
const BeingId BeingId_zero
Definition: beingid.h:29
bool mDrawPath
Definition: localplayer.h:517
Map * mMap
Definition: actor.h:138

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

References attack(), Party::getMember(), 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().

Referenced by Being::setActionTime().

438 {
439  const Party *const party = Party::getParty(1);
440  if (party != nullptr)
441  {
442  PartyMember *const pm = party->getMember(mName);
443  if (pm != nullptr)
444  {
445  pm->setX(mX);
446  pm->setY(mY);
447  }
448  }
449 
450  if (mPath.empty())
451  {
452  if (mPickUpTarget != nullptr)
454 
455  if (mWalkingDir != 0U)
457  }
458  else if (mPath.size() == 1)
459  {
460  if (mPickUpTarget != nullptr)
462  }
463 
464  if (mGoingToTarget &&
465  mTarget != nullptr &&
466  withinAttackRange(mTarget, false, 0))
467  {
469  attack(mTarget, true, false);
470  mGoingToTarget = false;
471  mPath.clear();
472  return;
473  }
474  else if (mGoingToTarget && (mTarget == nullptr))
475  {
476  mGoingToTarget = false;
477  mPath.clear();
478  }
479 
480  if (mPath.empty())
481  {
482  if (mNavigatePath.empty() || mAction != BeingAction::MOVE)
484  else
485  mNextStep = true;
486  }
487  else
488  {
489  Being::nextTile();
490  }
491 }
Definition: party.h:61
void attack(Being *const target, const bool keep, const bool dontChangeEquipment)
bool mNextStep
Definition: localplayer.h:522
bool mGoingToTarget
Definition: localplayer.h:524
Path mPath
Definition: being.h:1200
virtual void nextTile()
Definition: being.cpp:1781
void setY(const int y)
Definition: avatar.h:134
uint32_t party
Being * mTarget
Definition: localplayer.h:460
std::string mName
Definition: being.h:1183
int mX
Definition: being.h:1317
static Party * getParty(const int16_t id)
Definition: party.cpp:312
PartyMember * getMember(const BeingId id) const
Definition: party.cpp:98
Path mNavigatePath
Definition: localplayer.h:494
unsigned char mWalkingDir
Definition: localplayer.h:505
void startWalking(const unsigned char dir)
int mY
Definition: being.h:1318
bool withinAttackRange(const Being *const target, const bool fixDistance, const int addRange) const
BeingActionT mAction
Definition: being.h:1232
FloorItem * mPickUpTarget
Definition: localplayer.h:468
void setAction(const BeingActionT &action, const int attackId)
void setX(const int x)
Definition: avatar.h:128
bool pickUp(FloorItem *const item)

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

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

Referenced by isServerBuggy(), and Being::setDistance().

1103 {
1104  if (value == "showownname")
1105  {
1106  setShowName(config.getBoolValue("showownname"));
1107  }
1108  else if (value == "targetDeadPlayers")
1109  {
1110  mTargetDeadPlayers = config.getBoolValue("targetDeadPlayers");
1111  }
1112  else if (value == "enableBuggyServers")
1113  {
1114  mIsServerBuggy = serverConfig.getBoolValue("enableBuggyServers");
1115  }
1116  else if (value == "syncPlayerMove")
1117  {
1118  mSyncPlayerMove = config.getBoolValue("syncPlayerMove");
1119  }
1120  else if (value == "syncPlayerMoveDistance")
1121  {
1122  mSyncPlayerMoveDistance = config.getIntValue("syncPlayerMoveDistance");
1123  }
1124  else if (value == "drawPath")
1125  {
1126  mDrawPath = config.getBoolValue("drawPath");
1127  }
1128  else if (value == "serverAttack")
1129  {
1130  mServerAttack = fromBool(config.getBoolValue("serverAttack"), Keep);
1131  }
1132  else if (value == "attackMoving")
1133  {
1134  mAttackMoving = config.getBoolValue("attackMoving");
1135  }
1136  else if (value == "attackNext")
1137  {
1138  mAttackNext = config.getBoolValue("attackNext");
1139  }
1140  else if (value == "showJobExp")
1141  {
1142  mShowJobExp = config.getBoolValue("showJobExp");
1143  }
1144  else if (value == "enableAdvert")
1145  {
1146  mEnableAdvert = config.getBoolValue("enableAdvert");
1147  }
1148  else if (value == "tradebot")
1149  {
1150  mTradebot = config.getBoolValue("tradebot");
1151  }
1152  else if (value == "targetOnlyReachable")
1153  {
1154  mTargetOnlyReachable = config.getBoolValue("targetOnlyReachable");
1155  }
1156  else if (value == "showserverpos")
1157  {
1158  mShowServerPos = config.getBoolValue("showserverpos");
1159  }
1160  else if (value == "visiblenames")
1161  {
1162  mVisibleNames = static_cast<VisibleName::Type>(
1163  config.getIntValue("visiblenames"));
1164  }
1165 }
bool mAttackMoving
Definition: localplayer.h:518
void setShowName(const bool doShowName)
Definition: being.cpp:1165
bool mAttackNext
Definition: localplayer.h:519
Configuration config
int getIntValue(const std::string &key) const
Configuration serverConfig
bool mSyncPlayerMove
Definition: localplayer.h:516
bool mIsServerBuggy
Definition: localplayer.h:515
bool mTargetOnlyReachable
Definition: localplayer.h:514
bool Keep
Definition: keep.h:29
bool getBoolValue(const std::string &key) const
#define fromBool(val, name)
Definition: booldefines.h:48
bool mTargetDeadPlayers
Definition: localplayer.h:509
int mSyncPlayerMoveDistance
Definition: localplayer.h:503
bool mShowJobExp
Definition: localplayer.h:520
bool mTradebot
Definition: localplayer.h:513
bool mEnableAdvert
Definition: localplayer.h:512
Keep mServerAttack
Definition: localplayer.h:510
bool mDrawPath
Definition: localplayer.h:517
bool mShowServerPos
Definition: localplayer.h:521
VisibleName::Type mVisibleNames
Definition: localplayer.h:511

◆ pathSetByMouse()

void LocalPlayer::pathSetByMouse ( )
inline

Tells that the path has been set by mouse.

Definition at line 185 of file localplayer.h.

References mPathSetByMouse.

186  { mPathSetByMouse = true; }
bool mPathSetByMouse
Definition: localplayer.h:528

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

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

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

873 {
874  if (fail != Pickup::OKAY)
875  {
876  if ((actorManager != nullptr) && floorItemId != BeingId_zero)
877  {
878  FloorItem *const item = actorManager->findItem(floorItemId);
879  if (item != nullptr)
880  {
881  if (!item->getShowMsg())
882  return;
883  item->setShowMsg(false);
884  }
885  }
886  const char* msg = nullptr;
887  switch (fail)
888  {
889  case Pickup::BAD_ITEM:
890  // TRANSLATORS: pickup error message
891  msg = N_("Tried to pick up nonexistent item.");
892  break;
893  case Pickup::TOO_HEAVY:
894  // TRANSLATORS: pickup error message
895  msg = N_("Item is too heavy.");
896  break;
897  case Pickup::TOO_FAR:
898  // TRANSLATORS: pickup error message
899  msg = N_("Item is too far away.");
900  break;
901  case Pickup::INV_FULL:
902  // TRANSLATORS: pickup error message
903  msg = N_("Inventory is full.");
904  break;
905  case Pickup::STACK_FULL:
906  // TRANSLATORS: pickup error message
907  msg = N_("Stack is too big.");
908  break;
909  case Pickup::DROP_STEAL:
910  // TRANSLATORS: pickup error message
911  msg = N_("Item belongs to someone else.");
912  break;
913  case Pickup::MAX_AMOUNT:
914  // TRANSLATORS: pickup error message
915  msg = N_("You can't pickup this amount of items.");
916  break;
918  // TRANSLATORS: pickup error message
919  msg = N_("Your item stack has max amount.");
920  break;
921  case Pickup::OKAY:
922  break;
923  default:
924  case Pickup::UNKNOWN:
925  // TRANSLATORS: pickup error message
926  msg = N_("Unknown problem picking up item.");
927  break;
928  }
929  if (localChatTab != nullptr &&
930  config.getBoolValue("showpickupchat"))
931  {
932  localChatTab->chatLog(gettext(msg),
936  }
937 
938  if ((mMap != nullptr) && config.getBoolValue("showpickupparticle"))
939  {
940  // Show pickup notification
942  }
943  }
944  else
945  {
946  std::string str;
947 #ifdef TMWA_SUPPORT
949  {
950  str = itemInfo.getName();
951  }
952  else
953 #endif // TMWA_SUPPORT
954  {
955  str = itemInfo.getName(color);
956  }
957 
958  if (config.getBoolValue("showpickupchat") && (localChatTab != nullptr))
959  {
960  // TRANSLATORS: %d is number,
961  // [@@%d|%[email protected]@] - here player can see link to item
962  localChatTab->chatLog(strprintf(ngettext("You picked up %d "
963  "[@@%d|%[email protected]@].", "You picked up %d [@@%d|%[email protected]@].", amount),
964  amount, itemInfo.getId(), str.c_str()),
968  }
969 
970  if ((mMap != nullptr) && config.getBoolValue("showpickupparticle"))
971  {
972  // Show pickup notification
973  if (amount > 1)
974  {
975  addMessageToQueue(strprintf("%d x %s", amount,
976  str.c_str()), UserColorId::PICKUP_INFO);
977  }
978  else
979  {
981  }
982  }
983  }
984 }
ChatTab * localChatTab
Definition: chattab.cpp:61
FloorItem * findItem(const BeingId id) const
#define N_(s)
Definition: gettext.h:35
int getId() const
Definition: iteminfo.h:67
Configuration config
const bool TryRemoveColors_true
void chatLog(std::string line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
Definition: chattab.cpp:110
bool msg(InputEvent &event)
Definition: chat.cpp:38
const std::string & getName() const
Definition: iteminfo.h:73
void addMessageToQueue(const std::string &message, const UserColorIdT color)
bool getBoolValue(const std::string &key) const
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
bool getShowMsg() const
Definition: flooritem.h:107
const bool IgnoreRecord_false
Definition: ignorerecord.h:29
void setShowMsg(const bool n)
Definition: flooritem.h:110
ServerTypeT getNetworkType()
Definition: net.cpp:184
const BeingId BeingId_zero
Definition: beingid.h:29
ActorManager * actorManager
Map * mMap
Definition: actor.h:138

◆ pickUp()

bool LocalPlayer::pickUp ( FloorItem *const  item)