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

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

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

1219 {
1220  if (change != 0 && mMessages.size() < 20)
1221  {
1222  addMessageToQueue(strprintf("%s %d %s",
1223  // TRANSLATORS: get homunculus xp message
1224  _("Homun"),
1225  change,
1226  // TRANSLATORS: get xp message
1227  _("xp")),
1229  }
1230 }
#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 1232 of file localplayer.cpp.

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

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

1233 {
1234  if (change != 0 && mMessages.size() < 20)
1235  {
1236  // TRANSLATORS: get hp message
1237  addMessageToQueue(strprintf("%d %s", change, _("hp")),
1239  }
1240 }
#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 1166 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().

1167 {
1168  if (change != 0 && mMessages.size() < 20)
1169  {
1170  const std::string xpStr = toString(CAST_U64(change));
1171  if (!mMessages.empty())
1172  {
1173  MessagePair pair = mMessages.back();
1174  // TRANSLATORS: this is normal experience
1175  if (pair.first.find(strprintf(" %s", _("xp"))) ==
1176  // TRANSLATORS: this is normal experience
1177  pair.first.size() - strlen(_("xp")) - 1)
1178  {
1179  mMessages.pop_back();
1180  pair.first.append(strprintf(", %s %s",
1181  xpStr.c_str(),
1182  // TRANSLATORS: this is job experience
1183  _("job")));
1184  mMessages.push_back(pair);
1185  }
1186  else
1187  {
1188  addMessageToQueue(strprintf("%s %s",
1189  xpStr.c_str(),
1190  // TRANSLATORS: this is job experience
1191  _("job")),
1193  }
1194  }
1195  else
1196  {
1197  addMessageToQueue(strprintf("%s %s",
1198  xpStr.c_str(),
1199  // TRANSLATORS: this is job experience
1200  _("job")),
1202  }
1203  }
1204 }
#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 1094 of file localplayer.cpp.

References mMessages.

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

1096 {
1097  if (mMessages.size() < 20)
1098  mMessages.push_back(MessagePair(message, color));
1099 }
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 1242 of file localplayer.cpp.

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

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

1243 {
1244  if (change != 0 && mMessages.size() < 20)
1245  {
1246  // TRANSLATORS: get hp message
1247  addMessageToQueue(strprintf("%d %s", change, _("mana")),
1249  }
1250 }
#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 1206 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().

1207 {
1208  if (change != 0 && mMessages.size() < 20)
1209  {
1210  addMessageToQueue(strprintf("%s %s",
1211  toString(CAST_U64(change)).c_str(),
1212  // TRANSLATORS: get xp message
1213  _("xp")),
1215  }
1216 }
#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 2040 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().

2041 {
2042  if (settings.awayMode)
2043  {
2044  const time_t time = cur_time;
2045  if (mAfkTime == 0 || time < mAfkTime
2046  || time - mAfkTime > awayLimitTimer)
2047  {
2048  std::string str(serverConfig.getValue("afkMessage",
2049  "I am away from keyboard."));
2050  if (str.find("'NAME'") != std::string::npos)
2051  replaceAll(str, "'NAME'", nick);
2052 
2053  std::string msg("*AFK*: " + str);
2054 
2055  if (config.getIntValue("afkFormat") == 1)
2056  msg = "*" + msg + "*";
2057 
2058  if (tab == nullptr)
2059  {
2060  chatHandler->privateMessage(nick, msg);
2061  if (localChatTab != nullptr)
2062  {
2063  localChatTab->chatLog(std::string(mName).append(
2064  " : ").append(msg),
2068  }
2069  }
2070  else
2071  {
2072  if (tab->getNoAway())
2073  return;
2074  chatHandler->privateMessage(nick, msg);
2075  tab->chatLog(mName, msg);
2076  }
2077  mAfkTime = time;
2078  }
2079  }
2080 }
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:82
bool getNoAway() const
Definition: chattab.h:169
bool awayMode
Definition: settings.h:155

◆ allowAction()

bool LocalPlayer::allowAction ( )

Definition at line 2559 of file localplayer.cpp.

References mIsServerBuggy, mLastAction, and tick_time.

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

2560 {
2561  if (mIsServerBuggy)
2562  {
2563  if (mLastAction != -1)
2564  return false;
2566  }
2567  return true;
2568 }
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 780 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().

783 {
784  mKeepAttacking = keep;
785 
786  if ((target == nullptr) || target->getType() == ActorType::Npc)
787  return;
788 
789  if (mTarget != target)
790  setTarget(target);
791 
792  // Must be standing or sitting or casting to attack
793  if (mAction != BeingAction::STAND &&
796  {
797  return;
798  }
799 
800 #ifdef TMWA_SUPPORT
801  const int dist_x = target->mX - mX;
802  const int dist_y = target->mY - mY;
803 
805  {
806  if (abs(dist_y) >= abs(dist_x))
807  {
808  if (dist_y > 0)
810  else
812  }
813  else
814  {
815  if (dist_x > 0)
817  else
819  }
820  }
821 #endif // TMWA_SUPPORT
822 
824 
825  if (target->getType() != ActorType::Player
826  || checAttackPermissions(target))
827  {
829 
831  return;
832 
833  if (!dontChangeEquipment)
835 
836  const BeingId targetId = target->getId();
837  playerHandler->attack(targetId, mServerAttack);
839  }
840 
841  if (!keep)
842  stopAttack(false);
843 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:92
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:614
void stopAttack(const bool keepAttack)
ActorTypeT getType() const
Definition: being.h:115
int mActionTime
Definition: being.h:1216
ServerTypeT getNetworkType()
Definition: net.cpp:182
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 2285 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().

2288 {
2289  if (!dontChangeEquipment && (target != nullptr))
2291 
2292  const bool broken = (Net::getNetworkType() == ServerType::TMWATHENA);
2293 
2294  // probably need cache getPathLength(target)
2295  if ((target == nullptr ||
2296  settings.attackType == 0 ||
2297  settings.attackType == 3) ||
2298  (withinAttackRange(target, broken, broken ? 1 : 0) &&
2299  getPathLength(target) <= getAttackRange2()))
2300  {
2301  attack(target, keep, false);
2302  if (settings.attackType == 2)
2303  {
2304  if (target == nullptr)
2305  {
2306  if (pickUpItems(0))
2307  return;
2308  }
2309  else
2310  {
2311  pickUpItems(3);
2312  }
2313  }
2314  }
2315  else if (mPickUpTarget == nullptr)
2316  {
2317  if (settings.attackType == 2)
2318  {
2319  if (pickUpItems(0))
2320  return;
2321  }
2322  setTarget(target);
2323  if (target->getType() != ActorType::Npc)
2324  {
2325  mKeepAttacking = true;
2326  moveToTarget(-1);
2327  }
2328  }
2329 }
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:182
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 1252 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().

1255 {
1256  PRAGMA45(GCC diagnostic push)
1257  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
1258  switch (id)
1259  {
1261  {
1263  break;
1264  if (oldVal > newVal)
1265  break;
1266 
1267  const int change = CAST_S32(newVal - oldVal);
1268  addXpMessage(change);
1269  break;
1270  }
1272  mLevel = CAST_S32(newVal);
1273  break;
1274  case Attributes::PLAYER_HP:
1275  if (oldVal != 0 && newVal == 0)
1277  break;
1279  {
1280  if (!mShowJobExp ||
1282  {
1283  return;
1284  }
1285  if (oldVal > newVal ||
1288  {
1289  return;
1290  }
1291  const int32_t change = CAST_S32(newVal - oldVal);
1292  addJobMessage(change);
1293  break;
1294  }
1295  default:
1296  break;
1297  }
1298  PRAGMA45(GCC diagnostic pop)
1299 }
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:182
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:100

◆ cancelFollow()

void LocalPlayer::cancelFollow ( )

Stop following a player.

Definition at line 2363 of file localplayer.cpp.

References _, debugMsg, mPlayerFollowed, and mPlayerImitated.

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

2364 {
2365  if (!mPlayerFollowed.empty())
2366  {
2367  // TRANSLATORS: cancel follow message
2368  debugMsg(_("Follow canceled"));
2369  }
2370  if (!mPlayerImitated.empty())
2371  {
2372  // TRANSLATORS: cancel follow message
2373  debugMsg(_("Imitation canceled"));
2374  }
2375  mPlayerFollowed.clear();
2376  mPlayerImitated.clear();
2377 }
#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 1424 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().

1425 {
1426  if (settings.attackWeaponType == 1
1427  || (target == nullptr)
1428  || (PlayerInfo::getInventory() == nullptr))
1429  {
1430  return;
1431  }
1432 
1433  bool allowSword = false;
1434  const int dx = target->mX - mX;
1435  const int dy = target->mY - mY;
1436  const Item *item = nullptr;
1437 
1438  if (dx * dx + dy * dy > 80)
1439  return;
1440 
1441  if (dx * dx + dy * dy < 8)
1442  allowSword = true;
1443 
1444  const Inventory *const inv = PlayerInfo::getInventory();
1445  if (inv == nullptr)
1446  return;
1447 
1448  // if attack distance for sword
1449  if (allowSword)
1450  {
1451  // searching swords
1452  const WeaponsInfos &swords = WeaponsDB::getSwords();
1453  FOR_EACH (WeaponsInfosIter, it, swords)
1454  {
1455  item = inv->findItem(*it, ItemColor_zero);
1456  if (item != nullptr)
1457  break;
1458  }
1459 
1460  // no swords
1461  if (item == nullptr)
1462  return;
1463 
1464  // if sword not equiped
1465  if (item->isEquipped() == Equipped_false)
1467 
1468  // if need equip shield too
1469  if (settings.attackWeaponType == 3)
1470  {
1471  // searching shield
1472  const WeaponsInfos &shields = WeaponsDB::getShields();
1473  FOR_EACH (WeaponsInfosIter, it, shields)
1474  {
1475  item = inv->findItem(*it, ItemColor_zero);
1476  if (item != nullptr)
1477  break;
1478  }
1479  if ((item != nullptr) && item->isEquipped() == Equipped_false)
1481  }
1482  }
1483  // big distance. allowed only bow
1484  else
1485  {
1486  // searching bow
1487  const WeaponsInfos &bows = WeaponsDB::getBows();
1488  FOR_EACH (WeaponsInfosIter, it, bows)
1489  {
1490  item = inv->findItem(*it, ItemColor_zero);
1491  if (item != nullptr)
1492  break;
1493  }
1494 
1495  // no bow
1496  if (item == nullptr)
1497  return;
1498 
1499  if (item->isEquipped() == Equipped_false)
1501  }
1502 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void equipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:235
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:192
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 2763 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().

2764 {
2765  if (target == nullptr)
2766  return false;
2767 
2768  switch (settings.pvpAttackType)
2769  {
2770  case 0:
2771  return true;
2772  case 1:
2773  return !(playerRelations.getRelation(target->mName)
2774  == Relation::FRIEND);
2775  case 2:
2776  return playerRelations.checkBadRelation(target->mName);
2777  default:
2778  case 3:
2779  return false;
2780  }
2781 }
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 2698 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().

2699 {
2700  if (being == nullptr)
2701  return;
2702 
2703  const std::string &nick = being->mName;
2704  if (being->getType() == ActorType::Player)
2705  {
2706  const Guild *const guild = getGuild();
2707  if (guild != nullptr)
2708  {
2709  const GuildMember *const gm = guild->getMember(nick);
2710  if (gm != nullptr)
2711  {
2712  const int level = gm->getLevel();
2713  if (level > 1 && being->getLevel() != level)
2714  {
2715  being->setLevel(level);
2716  being->updateName();
2717  }
2718  }
2719  }
2720  if (chatWindow != nullptr)
2721  {
2722  WhisperTab *const tab = chatWindow->getWhisperTab(nick);
2723  if (tab != nullptr)
2724  tab->setWhisperTabColors();
2725  }
2726  }
2727 
2728  if (!mWaitFor.empty() && mWaitFor == nick)
2729  {
2730  // TRANSLATORS: wait player/monster message
2731  debugMsg(strprintf(_("You see %s"), mWaitFor.c_str()));
2733  mWaitFor.clear();
2734  }
2735 }
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 771 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().

772 {
774  return false;
775 
776  playerHandler->emote(emotion);
777  return true;
778 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:92
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 2688 of file localplayer.cpp.

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

2690 {
2691 }

◆ fixAttackTarget()

void LocalPlayer::fixAttackTarget ( )

Definition at line 2633 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().

2634 {
2635  if ((mMap == nullptr) || (mTarget == nullptr))
2636  return;
2637 
2638  if (settings.moveToTargetType == 11 || (settings.attackType == 0u)
2639  || !config.getBoolValue("autofixPos"))
2640  {
2641  return;
2642  }
2643 
2644  const Path debugPath = mMap->findPath(
2645  (mPixelX - mapTileSize / 2) / mapTileSize,
2647  mTarget->mX,
2648  mTarget->mY,
2649  getBlockWalkMask(),
2650  0);
2651 
2652  if (!debugPath.empty())
2653  {
2654  const Path::const_iterator i = debugPath.begin();
2655  setDestination((*i).x, (*i).y);
2656  }
2657 }
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 2570 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().

2571 {
2572  if ((mCrossX == 0) && (mCrossY == 0))
2573  return;
2574 
2575  const int dx = abs(mX - mCrossX);
2576  const int dy = abs(mY - mCrossY);
2577  const int dist = dx > dy ? dx : dy;
2578  const time_t time = cur_time;
2579  const int maxDist = mSyncPlayerMove ? mSyncPlayerMoveDistance : 7;
2580 
2581  if (dist > maxDist)
2582  {
2583  mActivityTime = time;
2585 // alternative way to fix, move to real position
2586 // setDestination(mCrossX, mCrossY);
2587  }
2588 }
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 2490 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().

2492 {
2493  if ((being != nullptr) &&
2494  !mPlayerFollowed.empty() &&
2495  being->mName == mPlayerFollowed)
2496  {
2497  mPickUpTarget = nullptr;
2498  navigateTo(x, y);
2499  }
2500 }
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 2502 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.

2505 {
2506  if (being == nullptr)
2507  return;
2508 
2509  mPickUpTarget = nullptr;
2510  if (!mPlayerFollowed.empty() &&
2511  being->mName == mPlayerFollowed)
2512  {
2513  switch (settings.followMode)
2514  {
2515  case 0:
2516  navigateTo(x1, y1);
2517  setNextDest(x2, y2);
2518  break;
2519  case 1:
2520  if (x1 != x2 || y1 != y2)
2521  {
2522  navigateTo(mX + x2 - x1, mY + y2 - y1);
2523  setNextDest(mX + x2 - x1, mY + y2 - y1);
2524  }
2525  break;
2526  case 2:
2527  if (x1 != x2 || y1 != y2)
2528  {
2529  navigateTo(mX + x1 - x2, mY + y1 - y2);
2530  setNextDest(mX + x1 - x2, mY + y1 - y2);
2531  }
2532  break;
2533  case 3:
2534  if (mTarget == nullptr ||
2536  {
2537  if (actorManager != nullptr)
2538  {
2539  Being *const b = actorManager->findBeingByName(
2541  setTarget(b);
2542  }
2543  }
2544  moveToTarget(-1);
2545  setNextDest(x2, y2);
2546  break;
2547  default:
2548  break;
2549  }
2550  }
2551 }
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 2843 of file localplayer.cpp.

References mFreezed, mUnfreezeTime, and tick_time.

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

2844 {
2845  if (timeWaitTicks <= 0)
2846  return;
2847  const int nextTime = tick_time + timeWaitTicks;
2848  if (mUnfreezeTime < nextTime)
2849  mUnfreezeTime = nextTime;
2850  if (mUnfreezeTime > 0)
2851  mFreezed = true;
2852 }
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 985 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().

986 {
987  if (mAttackRange > -1)
988  {
989  return mAttackRange;
990  }
991 
992  const Item *const weapon = PlayerInfo::getEquipment(
994  if (weapon != nullptr)
995  {
996  const ItemInfo &info = weapon->getInfo();
997  return info.getAttackRange();
998  }
999  return 48; // unarmed range
1000 }
Equipment * getEquipment()
Definition: playerinfo.cpp:217
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 2277 of file localplayer.cpp.

References getAttackRange().

Referenced by attack2().

2278 {
2279  int range = getAttackRange();
2280  if (range == 1)
2281  range = 2;
2282  return range;
2283 }
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 2737 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().

2738 {
2739  // for now blocking all types of collisions
2740  return BlockMask::WALL |
2741  BlockMask::AIR |
2744 }

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

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

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

2665 {
2667 }
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 2242 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().

2243 {
2244  if ((mMap == nullptr) || (being == nullptr))
2245  return 0;
2246 
2247  if (being->mX == mX && being->mY == mY)
2248  return 0;
2249 
2250  if (being->mX - 1 <= mX &&
2251  being->mX + 1 >= mX &&
2252  being->mY - 1 <= mY &&
2253  being->mY + 1 >= mY)
2254  {
2255  return 1;
2256  }
2257 
2259  {
2260  const Path debugPath = mMap->findPath(
2261  (mPixelX - mapTileSize / 2) / mapTileSize,
2263  being->mX,
2264  being->mY,
2265  getBlockWalkMask(),
2266  0);
2267  return CAST_S32(debugPath.size());
2268  }
2269 
2270  const int dx = CAST_S32(abs(being->mX - mX));
2271  const int dy = CAST_S32(abs(being->mY - mY));
2272  if (dx > dy)
2273  return dx;
2274  return dy;
2275 }
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 1955 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().

1956 {
1957  std::string str;
1958  if (!mWaitPing)
1959  {
1960  if (mPingTime == 0)
1961  str = "?";
1962  else
1963  str = toString(CAST_S32(mPingTime));
1964  }
1965  else
1966  {
1967  time_t time = tick_time;
1968  if (time > mPingSendTick)
1969  time -= mPingSendTick;
1970  else
1971  time += MAX_TICK_VALUE - mPingSendTick;
1972  if (time <= mPingTime)
1973  time = mPingTime;
1974  if (mPingTime != time)
1975  str = strprintf("%d (%d)", CAST_S32(mPingTime), CAST_S32(time));
1976  else
1977  str = toString(CAST_S32(time));
1978  }
1979  return str;
1980 }
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 1033 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().

1037 {
1039  effectId,
1040  newStatus,
1041  start);
1042 
1043  if (effect != nullptr)
1044  {
1045  effect->deliverMessage();
1046  effect->playSFX();
1047 
1048  AnimatedSprite *const sprite = effect->getIcon();
1049 
1050  if (sprite == nullptr)
1051  {
1052  // delete sprite, if necessary
1053  for (size_t i = 0; i < mStatusEffectIcons.size(); )
1054  {
1055  if (mStatusEffectIcons[i] == effectId)
1056  {
1057  mStatusEffectIcons.erase(mStatusEffectIcons.begin() + i);
1058  if (miniStatusWindow != nullptr)
1060  }
1061  else
1062  {
1063  i++;
1064  }
1065  }
1066  }
1067  else
1068  {
1069  // replace sprite or append
1070  bool found = false;
1071  const size_t sz = mStatusEffectIcons.size();
1072  for (size_t i = 0; i < sz; i++)
1073  {
1074  if (mStatusEffectIcons[i] == effectId)
1075  {
1076  if (miniStatusWindow != nullptr)
1077  miniStatusWindow->setIcon(CAST_S32(i), sprite);
1078  found = true;
1079  break;
1080  }
1081  }
1082 
1083  if (!found)
1084  { // add new
1085  const int offset = CAST_S32(mStatusEffectIcons.size());
1086  if (miniStatusWindow != nullptr)
1087  miniStatusWindow->setIcon(offset, sprite);
1088  mStatusEffectIcons.push_back(effectId);
1089  }
1090  }
1091  }
1092 }
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 2390 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().

2392 {
2393  if (being == nullptr)
2394  return;
2395 
2396  if (!mPlayerImitated.empty() && being->mName == mPlayerImitated)
2397  {
2398  setAction(action, 0);
2399  playerHandler->changeAction(action);
2400  }
2401 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:92
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 2403 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().

2405 {
2406  if (being == nullptr)
2407  return;
2408 
2409  if (!mPlayerImitated.empty() && being->mName == mPlayerImitated)
2410  {
2412  return;
2413 
2414  if (settings.followMode == 2)
2415  {
2416  uint8_t dir2 = 0;
2417  if ((dir & BeingDirection::LEFT) != 0)
2418  dir2 |= BeingDirection::RIGHT;
2419  else if ((dir & BeingDirection::RIGHT) != 0)
2420  dir2 |= BeingDirection::LEFT;
2421  if ((dir & BeingDirection::UP) != 0)
2422  dir2 |= BeingDirection::DOWN;
2423  else if ((dir & BeingDirection::DOWN) != 0)
2424  dir2 |= BeingDirection::UP;
2425 
2426  setDirection(dir2);
2427  playerHandler->setDirection(dir2);
2428  }
2429  else
2430  {
2431  setDirection(dir);
2433  }
2434  }
2435 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:92
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 2379 of file localplayer.cpp.

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

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

2381 {
2382  if (being == nullptr)
2383  return;
2384 
2385  std::string player_imitated = getImitate();
2386  if (!player_imitated.empty() && being->mName == player_imitated)
2387  emote(action);
2388 }
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 2437 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().

2439 {
2440  if (player == nullptr)
2441  return;
2442 
2443  if (settings.imitationMode == 1 &&
2444  !mPlayerImitated.empty() &&
2445  player->mName == mPlayerImitated)
2446  {
2447  if (sprite < 0 || sprite >= player->getNumberOfLayers())
2448  return;
2449 
2450  const AnimatedSprite *const equipmentSprite
2451  = dynamic_cast<const AnimatedSprite *>(
2452  player->mSprites[sprite]);
2453 
2454  if (equipmentSprite != nullptr)
2455  {
2456 // logger->log("have equipmentSprite");
2457  const Inventory *const inv = PlayerInfo::getInventory();
2458  if (inv == nullptr)
2459  return;
2460 
2461  const std::string &path = equipmentSprite->getIdPath();
2462  if (path.empty())
2463  return;
2464 
2465 // logger->log("idPath: " + path);
2466  const Item *const item = inv->findItemBySprite(path,
2467  player->getGender(), player->getSubType());
2468  if ((item != nullptr) && item->isEquipped() == Equipped_false)
2470  }
2471  else
2472  {
2473 // logger->log("have unequip %d", sprite);
2474  const int equipmentSlot = inventoryHandler
2475  ->convertFromServerSlot(sprite);
2476 // logger->log("equipmentSlot: " + toString(equipmentSlot));
2477  if (equipmentSlot == inventoryHandler->getProjectileSlot())
2478  return;
2479 
2480  const Item *const item = PlayerInfo::getEquipment(equipmentSlot);
2481  if (item != nullptr)
2482  {
2483 // logger->log("unequiping");
2485  }
2486  }
2487  }
2488 }
int getNumberOfLayers() const
Definition: being.h:376
void equipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:235
Equipment * getEquipment()
Definition: playerinfo.cpp:217
GenderT getGender() const
Definition: being.h:625
Equipped isEquipped() const
Definition: item.h:128
Inventory * getInventory()
Definition: playerinfo.cpp:192
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:85
void unequipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:243
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 1504 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().

1506 {
1507  if ((being == nullptr) || (mMap == nullptr))
1508  return false;
1509 
1510  if (being->getReachable() == Reachable::REACH_NO)
1511  return false;
1512 
1513  if (being->mX == mX &&
1514  being->mY == mY)
1515  {
1516  being->setDistance(0);
1518  return true;
1519  }
1520  else if (being->mX - 1 <= mX &&
1521  being->mX + 1 >= mX &&
1522  being->mY - 1 <= mY &&
1523  being->mY + 1 >= mY)
1524  {
1525  being->setDistance(1);
1527  return true;
1528  }
1529 
1530  const Path debugPath = mMap->findPath(
1531  (mPixelX - mapTileSize / 2) / mapTileSize,
1533  being->mX,
1534  being->mY,
1535  getBlockWalkMask(),
1536  maxCost);
1537 
1538  being->setDistance(CAST_S32(debugPath.size()));
1539  if (!debugPath.empty())
1540  {
1542  return true;
1543  }
1545  return false;
1546 }
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 1548 of file localplayer.cpp.

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

1550 {
1551  const WalkLayer *const walk = mMap->getWalkLayer();
1552  if (walk == nullptr)
1553  return false;
1554  int num = walk->getDataAt(x, y);
1555  if (allowCollision && num < 0)
1556  num = -num;
1557 
1558  return walk->getDataAt(mX, mY) == num;
1559 }
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 1773 of file localplayer.cpp.

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

Referenced by getRename(), and LocalPlayer().

1774 {
1775  std::string buf;
1776  std::stringstream ss(serverConfig.getValue("playerHomes", ""));
1777 
1778  while (ss >> buf)
1779  {
1780  Vector pos;
1781  ss >> pos.x;
1782  ss >> pos.y;
1783  mHomes[buf] = pos;
1784  }
1785 }
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 1715 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().

1716 {
1718  return;
1719  if (chatWindow == nullptr ||
1720  !isAlive() ||
1722  {
1723  return;
1724  }
1725 
1726  switch (settings.magicAttackType)
1727  {
1728  // flar W00
1729  case 0:
1730  tryMagic("#flar", 1, 0, 10);
1731  break;
1732  // chiza W01
1733  case 1:
1734  tryMagic("#chiza", 1, 0, 9);
1735  break;
1736  // ingrav W10
1737  case 2:
1738  tryMagic("#ingrav", 2, 2, 20);
1739  break;
1740  // frillyar W11
1741  case 3:
1742  tryMagic("#frillyar", 2, 2, 25);
1743  break;
1744  // upmarmu W12
1745  case 4:
1746  tryMagic("#upmarmu", 2, 2, 20);
1747  break;
1748  default:
1749  break;
1750  }
1751 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:92
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:182
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 1663 of file localplayer.cpp.

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

Referenced by setMoveState(), and specialMove().

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

◆ moveToHome()

void LocalPlayer::moveToHome ( )

Definition at line 1394 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().

1395 {
1396  mPickUpTarget = nullptr;
1397  if ((mX != mCrossX || mY != mCrossY) && (mCrossX != 0) && (mCrossY != 0))
1398  {
1400  }
1401  else if (mMap != nullptr)
1402  {
1403  const std::map<std::string, Vector>::const_iterator iter =
1404  mHomes.find(mMap->getProperty("_realfilename", std::string()));
1405 
1406  if (iter != mHomes.end())
1407  {
1408  const Vector pos = mHomes[(*iter).first];
1409  if (mX == pos.x && mY == pos.y)
1410  {
1412  CAST_S32(pos.x),
1413  CAST_S32(pos.y),
1414  CAST_S32(mDirection));
1415  }
1416  else
1417  {
1418  navigateTo(CAST_S32(pos.x), CAST_S32(pos.y));
1419  }
1420  }
1421  }
1422 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:92
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 1307 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().

1308 {
1309  bool gotPos(false);
1310  Path debugPath;
1311 
1312  size_t limit(0);
1313 
1314  if (dist == -1)
1315  {
1316  dist = settings.moveToTargetType;
1317  if (dist != 0)
1318  {
1319  const bool broken = (Net::getNetworkType() ==
1321  switch (dist)
1322  {
1323  case 10:
1324  dist = mAttackRange;
1325  if (dist == 1 && broken)
1326  dist = 2;
1327  break;
1328  case 11:
1329  dist = mAttackRange - 1;
1330  if (dist < 1)
1331  dist = 1;
1332  if (dist == 1 && broken)
1333  dist = 2;
1334  break;
1335  default:
1336  break;
1337  }
1338  }
1339  }
1340 
1341  if (mTarget != nullptr)
1342  {
1343  if (mMap != nullptr)
1344  {
1345  debugPath = mMap->findPath(
1346  (mPixelX - mapTileSize / 2) / mapTileSize,
1348  mTarget->mX,
1349  mTarget->mY,
1350  getBlockWalkMask(),
1351  0);
1352  }
1353 
1354  const size_t sz = debugPath.size();
1355  if (sz < CAST_SIZE(dist))
1356  return;
1357  limit = CAST_S32(sz) - dist;
1358  gotPos = true;
1359  }
1360  else if ((mNavigateX != 0) || (mNavigateY != 0))
1361  {
1362  debugPath = mNavigatePath;
1363  limit = dist;
1364  gotPos = true;
1365  }
1366 
1367  if (gotPos)
1368  {
1369  if (dist == 0)
1370  {
1371  if (mTarget != nullptr)
1373  }
1374  else
1375  {
1376  Position pos(0, 0);
1377  size_t f = 0;
1378 
1379  for (Path::const_iterator i = debugPath.begin(),
1380  i_fend = debugPath.end();
1381  i != i_fend && f < limit; ++i, f++)
1382  {
1383  pos = (*i);
1384  }
1385  navigateTo(pos.x, pos.y);
1386  }
1387  }
1388  else if ((mLastTargetX != 0) || (mLastTargetY != 0))
1389  {
1391  }
1392 }
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:182
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 2113 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().

2114 {
2115  if (mMap == nullptr)
2116  return;
2117 
2118  mShowNavigePath = false;
2119  mOldX = 0;
2120  mOldY = 0;
2121  mOldTileX = 0;
2122  mOldTileY = 0;
2123  mNavigateX = 0;
2124  mNavigateY = 0;
2126 
2127  mNavigatePath.clear();
2128 
2129  SpecialLayer *const tmpLayer = mMap->getTempLayer();
2130  if (tmpLayer == nullptr)
2131  return;
2132 
2133  tmpLayer->clean();
2134 }
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 2082 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().

2083 {
2084  if (mMap == nullptr)
2085  return false;
2086 
2087  SpecialLayer *const tmpLayer = mMap->getTempLayer();
2088  if (tmpLayer == nullptr)
2089  return false;
2090 
2091  mShowNavigePath = true;
2092  mOldX = mPixelX;
2093  mOldY = mPixelY;
2094  mOldTileX = mX;
2095  mOldTileY = mY;
2096  mNavigateX = x;
2097  mNavigateY = y;
2099 
2101  (mPixelX - mapTileSize / 2) / mapTileSize,
2103  x,
2104  y,
2105  getBlockWalkMask(),
2106  0);
2107 
2108  if (mDrawPath)
2109  tmpLayer->addRoad(mNavigatePath);
2110  return !mNavigatePath.empty();
2111 }
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 1101 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().

1102 {
1103  if (value == "showownname")
1104  {
1105  setShowName(config.getBoolValue("showownname"));
1106  }
1107  else if (value == "targetDeadPlayers")
1108  {
1109  mTargetDeadPlayers = config.getBoolValue("targetDeadPlayers");
1110  }
1111  else if (value == "enableBuggyServers")
1112  {
1113  mIsServerBuggy = serverConfig.getBoolValue("enableBuggyServers");
1114  }
1115  else if (value == "syncPlayerMove")
1116  {
1117  mSyncPlayerMove = config.getBoolValue("syncPlayerMove");
1118  }
1119  else if (value == "syncPlayerMoveDistance")
1120  {
1121  mSyncPlayerMoveDistance = config.getIntValue("syncPlayerMoveDistance");
1122  }
1123  else if (value == "drawPath")
1124  {
1125  mDrawPath = config.getBoolValue("drawPath");
1126  }
1127  else if (value == "serverAttack")
1128  {
1129  mServerAttack = fromBool(config.getBoolValue("serverAttack"), Keep);
1130  }
1131  else if (value == "attackMoving")
1132  {
1133  mAttackMoving = config.getBoolValue("attackMoving");
1134  }
1135  else if (value == "attackNext")
1136  {
1137  mAttackNext = config.getBoolValue("attackNext");
1138  }
1139  else if (value == "showJobExp")
1140  {
1141  mShowJobExp = config.getBoolValue("showJobExp");
1142  }
1143  else if (value == "enableAdvert")
1144  {
1145  mEnableAdvert = config.getBoolValue("enableAdvert");
1146  }
1147  else if (value == "tradebot")
1148  {
1149  mTradebot = config.getBoolValue("tradebot");
1150  }
1151  else if (value == "targetOnlyReachable")
1152  {
1153  mTargetOnlyReachable = config.getBoolValue("targetOnlyReachable");
1154  }
1155  else if (value == "showserverpos")
1156  {
1157  mShowServerPos = config.getBoolValue("showserverpos");
1158  }
1159  else if (value == "visiblenames")
1160  {
1161  mVisibleNames = static_cast<VisibleName::Type>(
1162  config.getIntValue("visiblenames"));
1163  }
1164 }
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 867 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().

872 {
873  if (fail != Pickup::OKAY)
874  {
875  if ((actorManager != nullptr) && floorItemId != BeingId_zero)
876  {
877  FloorItem *const item = actorManager->findItem(floorItemId);
878  if (item != nullptr)
879  {
880  if (!item->getShowMsg())
881  return;
882  item->setShowMsg(false);
883  }
884  }
885  const char* msg = nullptr;
886  switch (fail)
887  {
888  case Pickup::BAD_ITEM:
889  // TRANSLATORS: pickup error message
890  msg = N_("Tried to pick up nonexistent item.");
891  break;
892  case Pickup::TOO_HEAVY:
893  // TRANSLATORS: pickup error message
894  msg = N_("Item is too heavy.");
895  break;
896  case Pickup::TOO_FAR:
897  // TRANSLATORS: pickup error message
898  msg = N_("Item is too far away.");
899  break;
900  case Pickup::INV_FULL:
901  // TRANSLATORS: pickup error message
902  msg = N_("Inventory is full.");
903  break;
904  case Pickup::STACK_FULL:
905  // TRANSLATORS: pickup error message
906  msg = N_("Stack is too big.");
907  break;
908  case Pickup::DROP_STEAL:
909  // TRANSLATORS: pickup error message
910  msg = N_("Item belongs to someone else.");
911  break;
912  case Pickup::MAX_AMOUNT:
913  // TRANSLATORS: pickup error message
914  msg = N_("You can't pickup this amount of items.");
915  break;
917  // TRANSLATORS: pickup error message
918  msg = N_("Your item stack has max amount.");
919  break;
920  case Pickup::OKAY:
921  break;
922  default:
923  case Pickup::UNKNOWN:
924  // TRANSLATORS: pickup error message
925  msg = N_("Unknown problem picking up item.");
926  break;
927  }
928  if (localChatTab != nullptr &&
929  config.getBoolValue("showpickupchat"))
930  {
931  localChatTab->chatLog(gettext(msg),
935  }
936 
937  if ((mMap != nullptr) && config.getBoolValue("showpickupparticle"))
938  {
939  // Show pickup notification
941  }
942  }
943  else
944  {
945  std::string str;
946 #ifdef TMWA_SUPPORT
948  {
949  str = itemInfo.getName();
950  }
951  else
952 #endif // TMWA_SUPPORT
953  {
954  str = itemInfo.getName(color);
955  }
956 
957  if (config.getBoolValue("showpickupchat") && (localChatTab != nullptr))
958  {
959  // TRANSLATORS: %d is number,
960  // [@@%d|%[email protected]@] - here player can see link to item
961  localChatTab->chatLog(strprintf(ngettext("You picked up %d "
962  "[@@%d|%[email protected]@].", "You picked up %d [@@%d|%[email protected]@].", amount),
963  amount, itemInfo.getId(), str.c_str()),
967  }
968 
969  if ((mMap != nullptr) && config.getBoolValue("showpickupparticle"))
970  {
971  // Show pickup notification
972  if (amount > 1)
973  {
974  addMessageToQueue(strprintf("%d x %s", amount,
975  str.c_str()), UserColorId::PICKUP_INFO);
976  }
977  else
978  {
980  }
981  }
982  }
983 }
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:182
const BeingId BeingId_zero
Definition: beingid.h:29
ActorManager * actorManager
Map * mMap
Definition: actor.h:138

◆ pickUp()

bool LocalPlayer::pickUp ( FloorItem *const  item)