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=BeingTypeId_zero)
 
 ~LocalPlayer ()
 
void logic ()
 
void slowLogic ()
 
void setAction (const BeingActionT &action, const int attackId)
 
Position getNextWalkPosition (const unsigned char dir) const
 
void nextTile ()
 
void nextTile (unsigned char dir)
 
bool pickUp (FloorItem *const item)
 
void actorSpriteDestroyed (const ActorSprite &actorSprite)
 
int getAttackRange () const
 
int getAttackRange2 () const
 
void attack (Being *const target=0, const bool keep=false, const bool dontChangeEquipment=false)
 
void attack2 (Being *const target=0, const bool keep=false, const bool dontChangeEquipment=false)
 
void setGroupId (const int id)
 
void stopAttack (const bool keepAttack=false)
 
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=false, const int addRange=0) const
 
void stopWalking (const bool sendToServer=true)
 
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=0)
 
void move (const int dX, const int dY)
 
void moveToTarget (int dist=-1)
 
void moveToHome ()
 
bool isReachable (Being *const being, const int maxCost=0)
 
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=-1) 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=UserColorId::EXP_INFO)
 
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 A_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=true)
 
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)
 
virtual ~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, const std::string &channel="", int time=0)
 
void takeDamage (Being *const attacker, const int amount, const AttackTypeT type, const int attackId=1, const int level=1)
 
void handleAttack (Being *const victim, const int damage, const int attackId=1)
 
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
 
void setGuildName (const std::string &name)
 
void setGuildPos (const std::string &pos) A_CONST
 
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=0.0F) 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 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)
 
virtual ~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 ()
 
virtual ~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
void setStatusEffectBlock (const int offset, const uint16_t newEffects)
 
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 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 470 of file localplayer.h.

Constructor & Destructor Documentation

◆ LocalPlayer()

LocalPlayer::LocalPlayer ( const BeingId  id,
const BeingTypeId  subType = BeingTypeId_zero 
)
explicit

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, 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());
199 
200  loadHomes();
201 
202  config.addListener("showownname", this);
203  config.addListener("targetDeadPlayers", this);
204  serverConfig.addListener("enableBuggyServers", this);
205  config.addListener("syncPlayerMove", this);
206  config.addListener("syncPlayerMoveDistance", this);
207  config.addListener("drawPath", this);
208  config.addListener("serverAttack", this);
209  config.addListener("attackMoving", this);
210  config.addListener("attackNext", this);
211  config.addListener("showJobExp", this);
212  config.addListener("enableAdvert", this);
213  config.addListener("tradebot", this);
214  config.addListener("targetOnlyReachable", this);
215  config.addListener("showserverpos", this);
216  config.addListener("visiblenames", this);
217  setShowName(config.getBoolValue("showownname"));
218 }
time_t mActivityTime
Definition: localplayer.h:480
std::string mTestParticleName
Definition: localplayer.h:496
const Color & getColor(UserColorIdT type, const unsigned int alpha=255U)
Definition: userpalette.h:159
void log1(const char *const log_text)
Definition: logger.cpp:222
bool mAttackMoving
Definition: localplayer.h:514
time_t mAfkTime
Definition: localplayer.h:479
void setStatMod(const AttributesT id, const int value, const Notify notify)
Definition: playerinfo.cpp:157
void setShowName(const bool doShowName)
Definition: being.cpp:1155
bool mNextStep
Definition: localplayer.h:518
void setStatBase(const AttributesT id, const int value, const Notify notify)
Definition: playerinfo.cpp:141
std::map< std::string, Vector > mHomes
Definition: localplayer.h:454
int mLastTargetX
Definition: localplayer.h:451
const Color * mNameColor
Definition: being.h:1189
bool mAttackNext
Definition: localplayer.h:515
int mUnfreezeTime
Definition: localplayer.h:500
bool mGoingToTarget
Definition: localplayer.h:520
int mPingSendTick
Definition: localplayer.h:477
void loadHomes()
Configuration config
Particle * mTestParticle
Definition: localplayer.h:495
int mLevel
Definition: being.h:1217
bool mWaitPing
Definition: localplayer.h:525
Being(const BeingId id, const ActorTypeT type)
Definition: being.cpp:163
unsigned long mTestParticleHash
Definition: localplayer.h:498
int getIntValue(const std::string &key) const
const Color * mTextColor
Definition: being.h:1196
Configuration serverConfig
bool mSyncPlayerMove
Definition: localplayer.h:512
Being * mTarget
Definition: localplayer.h:456
bool mBlockAdvert
Definition: localplayer.h:504
void addListener(const std::string &key, ConfigListener *const listener)
bool mIsServerBuggy
Definition: localplayer.h:511
UserPalette * userPalette
Definition: userpalette.cpp:33
bool mTargetOnlyReachable
Definition: localplayer.h:510
std::string mLastHitFrom
Definition: localplayer.h:492
Logger * logger
Definition: logger.cpp:95
bool Keep
Definition: keep.h:29
std::list< MessagePair > mMessages
Definition: localplayer.h:472
std::string mPlayerImitated
Definition: localplayer.h:460
bool getBoolValue(const std::string &key) const
#define fromBool(val, name)
Definition: booldefines.h:48
int mMessageTime
Definition: localplayer.h:473
time_t mPingTime
Definition: localplayer.h:478
const Color & getColor(ThemeColorIdT type, const unsigned int alpha=255U)
Definition: theme.h:136
bool getValueBool(const std::string &key, const bool deflt) const
Path mNavigatePath
Definition: localplayer.h:490
void postInit(const BeingTypeId subType, Map *const map)
Definition: being.cpp:289
unsigned char mWalkingDir
Definition: localplayer.h:501
int mLastTargetY
Definition: localplayer.h:452
bool mTargetDeadPlayers
Definition: localplayer.h:505
bool mShowNavigePath
Definition: localplayer.h:526
time_t mTestParticleTime
Definition: localplayer.h:497
OkDialog * mAwayDialog
Definition: localplayer.h:475
int mSyncPlayerMoveDistance
Definition: localplayer.h:499
bool mShowJobExp
Definition: localplayer.h:516
Theme * theme
Definition: theme.cpp:61
AwayListener * mAwayListener
Definition: localplayer.h:474
BeingId mNavigateId
Definition: localplayer.h:483
bool mTradebot
Definition: localplayer.h:509
bool mEnableAdvert
Definition: localplayer.h:508
std::string mWaitFor
Definition: localplayer.h:493
std::vector< int32_t > mStatusEffectIcons
Definition: localplayer.h:468
bool mPathSetByMouse
Definition: localplayer.h:524
bool mAllowRename
Definition: localplayer.h:527
int getWalkSpeed() const
Definition: being.h:453
Keep mServerAttack
Definition: localplayer.h:506
const BeingId BeingId_zero
Definition: beingid.h:29
int mAttackRange
Definition: being.h:1219
bool mDrawPath
Definition: localplayer.h:513
time_t mAdvertTime
Definition: localplayer.h:494
FloorItem * mPickUpTarget
Definition: localplayer.h:464
bool mAdvanced
Definition: being.h:1377
std::string mPlayerFollowed
Definition: localplayer.h:459
bool mUpdateName
Definition: localplayer.h:503
unsigned int mMoveState
Definition: localplayer.h:449
bool mShowServerPos
Definition: localplayer.h:517
VisibleName::Type mVisibleNames
Definition: localplayer.h:507
bool mKeepAttacking
Definition: localplayer.h:522

◆ ~LocalPlayer()

LocalPlayer::~LocalPlayer ( )

Destructor.

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

221 {
222  logger->log1("LocalPlayer::~LocalPlayer");
223 
224  config.removeListeners(this);
225  serverConfig.removeListener("enableBuggyServers", this);
226 
227  navigateClean();
228  mCrossX = 0;
229  mCrossY = 0;
230 
232 
233  if (mAwayDialog != nullptr)
234  {
237  }
239 }
void log1(const char *const log_text)
Definition: logger.cpp:222
SoundManager soundManager
Configuration config
#define delete2(var)
Definition: delete2.h:24
Configuration serverConfig
Logger * logger
Definition: logger.cpp:95
void navigateClean()
void updateNavigateList()
OkDialog * mAwayDialog
Definition: localplayer.h:475
AwayListener * mAwayListener
Definition: localplayer.h:474
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.

Referenced by nextTile().

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

◆ addHomunXpMessage()

void LocalPlayer::addHomunXpMessage ( const int  change)

Definition at line 1206 of file localplayer.cpp.

References _, addMessageToQueue(), mMessages, and strprintf().

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

1207 {
1208  if (change != 0 && mMessages.size() < 20)
1209  {
1210  addMessageToQueue(strprintf("%s %d %s",
1211  // TRANSLATORS: get homunculus xp message
1212  _("Homun"),
1213  change,
1214  // TRANSLATORS: get xp message
1215  _("xp")));
1216  }
1217 }
#define _(s)
Definition: gettext.h:34
std::list< MessagePair > mMessages
Definition: localplayer.h:472
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
void addMessageToQueue(const std::string &message, const UserColorIdT color=UserColorId::EXP_INFO)

◆ addHpMessage()

void LocalPlayer::addHpMessage ( const int  change)

Definition at line 1219 of file localplayer.cpp.

References _, addMessageToQueue(), mMessages, and strprintf().

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

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

◆ addJobMessage()

void LocalPlayer::addJobMessage ( const int64_t  change)

Definition at line 1157 of file localplayer.cpp.

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

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

1158 {
1159  if (change != 0 && mMessages.size() < 20)
1160  {
1161  const std::string xpStr = toString(CAST_U64(change));
1162  if (!mMessages.empty())
1163  {
1164  MessagePair pair = mMessages.back();
1165  // TRANSLATORS: this is normal experience
1166  if (pair.first.find(strprintf(" %s", _("xp"))) ==
1167  // TRANSLATORS: this is normal experience
1168  pair.first.size() - strlen(_("xp")) - 1)
1169  {
1170  mMessages.pop_back();
1171  pair.first.append(strprintf(", %s %s",
1172  xpStr.c_str(),
1173  // TRANSLATORS: this is job experience
1174  _("job")));
1175  mMessages.push_back(pair);
1176  }
1177  else
1178  {
1179  addMessageToQueue(strprintf("%s %s",
1180  xpStr.c_str(),
1181  // TRANSLATORS: this is job experience
1182  _("job")));
1183  }
1184  }
1185  else
1186  {
1187  addMessageToQueue(strprintf("%s %s",
1188  xpStr.c_str(),
1189  // TRANSLATORS: this is job experience
1190  _("job")));
1191  }
1192  }
1193 }
#define _(s)
Definition: gettext.h:34
std::pair< std::string, UserColorIdT > MessagePair
Definition: localplayer.h:470
#define CAST_U64
Definition: cast.h:32
std::list< MessagePair > mMessages
Definition: localplayer.h:472
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
void addMessageToQueue(const std::string &message, const UserColorIdT color=UserColorId::EXP_INFO)

◆ addMessageToQueue()

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

Definition at line 1085 of file localplayer.cpp.

References mMessages.

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

1087 {
1088  if (mMessages.size() < 20)
1089  mMessages.push_back(MessagePair(message, color));
1090 }
std::pair< std::string, UserColorIdT > MessagePair
Definition: localplayer.h:470
std::list< MessagePair > mMessages
Definition: localplayer.h:472

◆ addSpMessage()

void LocalPlayer::addSpMessage ( const int  change)

Definition at line 1228 of file localplayer.cpp.

References _, addMessageToQueue(), mMessages, and strprintf().

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

1229 {
1230  if (change != 0 && mMessages.size() < 20)
1231  {
1232  // TRANSLATORS: get hp message
1233  addMessageToQueue(strprintf("%d %s", change, _("mana")));
1234  }
1235 }
#define _(s)
Definition: gettext.h:34
std::list< MessagePair > mMessages
Definition: localplayer.h:472
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
void addMessageToQueue(const std::string &message, const UserColorIdT color=UserColorId::EXP_INFO)

◆ addXpMessage()

void LocalPlayer::addXpMessage ( const int64_t  change)

Definition at line 1195 of file localplayer.cpp.

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

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

1196 {
1197  if (change != 0 && mMessages.size() < 20)
1198  {
1199  addMessageToQueue(strprintf("%s %s",
1200  toString(CAST_U64(change)).c_str(),
1201  // TRANSLATORS: get xp message
1202  _("xp")));
1203  }
1204 }
#define _(s)
Definition: gettext.h:34
#define CAST_U64
Definition: cast.h:32
std::list< MessagePair > mMessages
Definition: localplayer.h:472
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
void addMessageToQueue(const std::string &message, const UserColorIdT color=UserColorId::EXP_INFO)

◆ afkRespond()

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

Definition at line 2015 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, and ServerCommandType::time.

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

2016 {
2017  if (settings.awayMode)
2018  {
2019  const time_t time = cur_time;
2020  if (mAfkTime == 0 || time < mAfkTime
2021  || time - mAfkTime > awayLimitTimer)
2022  {
2023  std::string str(serverConfig.getValue("afkMessage",
2024  "I am away from keyboard."));
2025  if (str.find("'NAME'") != std::string::npos)
2026  replaceAll(str, "'NAME'", nick);
2027 
2028  std::string msg("*AFK*: " + str);
2029 
2030  if (config.getIntValue("afkFormat") == 1)
2031  msg = "*" + msg + "*";
2032 
2033  if (tab == nullptr)
2034  {
2035  chatHandler->privateMessage(nick, msg);
2036  if (localChatTab != nullptr)
2037  {
2038  localChatTab->chatLog(std::string(mName).append(
2039  " : ").append(msg),
2042  }
2043  }
2044  else
2045  {
2046  if (tab->getNoAway())
2047  return;
2048  chatHandler->privateMessage(nick, msg);
2049  tab->chatLog(mName, msg);
2050  }
2051  mAfkTime = time;
2052  }
2053  }
2054 }
time_t mAfkTime
Definition: localplayer.h:479
ChatTab * localChatTab
Definition: chattab.cpp:61
void chatLog(std::string line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord=IgnoreRecord_false, const TryRemoveColors tryRemoveColors=TryRemoveColors_true)
Definition: chattab.cpp:109
static const int16_t awayLimitTimer
Configuration config
std::string & replaceAll(std::string &context, const std::string &from, const std::string &to)
bool msg(InputEvent &event)
Definition: chat.cpp:38
int getIntValue(const std::string &key) const
Configuration serverConfig
std::string mName
Definition: being.h:1178
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:80
bool getNoAway() const
Definition: chattab.h:165
bool awayMode
Definition: settings.h:155

◆ allowAction()

bool LocalPlayer::allowAction ( )

Definition at line 2532 of file localplayer.cpp.

References mIsServerBuggy, mLastAction, and tick_time.

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

2533 {
2534  if (mIsServerBuggy)
2535  {
2536  if (mLastAction != -1)
2537  return false;
2539  }
2540  return true;
2541 }
volatile int tick_time
Definition: timer.cpp:52
bool mIsServerBuggy
Definition: localplayer.h:511

◆ attack()

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

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

782 {
783  mKeepAttacking = keep;
784 
785  if ((target == nullptr) || target->getType() == ActorType::Npc)
786  return;
787 
788  if (mTarget != target)
789  setTarget(target);
790 
791  // Must be standing or sitting or casting to attack
792  if (mAction != BeingAction::STAND &&
795  {
796  return;
797  }
798 
799 #ifdef TMWA_SUPPORT
800  const int dist_x = target->mX - mX;
801  const int dist_y = target->mY - mY;
802 
804  {
805  if (abs(dist_y) >= abs(dist_x))
806  {
807  if (dist_y > 0)
809  else
811  }
812  else
813  {
814  if (dist_x > 0)
816  else
818  }
819  }
820 #endif // TMWA_SUPPORT
821 
823 
824  if (target->getType() != ActorType::Player
825  || checAttackPermissions(target))
826  {
828 
830  return;
831 
832  if (!dontChangeEquipment)
834 
835  const BeingId targetId = target->getId();
836  playerHandler->attack(targetId, mServerAttack);
838  }
839 
840  if (!keep)
841  stopAttack();
842 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:89
volatile int tick_time
Definition: timer.cpp:52
void stopAttack(const bool keepAttack=false)
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:456
static bool checAttackPermissions(const Being *const target)
virtual void setDirection(const uint8_t direction)
Definition: being.cpp:1649
int mX
Definition: being.h:1311
void updateAttackAi(const BeingId targetId, const Keep keep)
Definition: playerinfo.cpp:629
ActorTypeT getType() const
Definition: being.h:115
int mActionTime
Definition: being.h:1210
ServerTypeT getNetworkType()
Definition: net.cpp:178
int mY
Definition: being.h:1312
void changeEquipmentBeforeAttack(const Being *const target) const
void setTarget(Being *const target)
Keep mServerAttack
Definition: localplayer.h:506
BeingActionT mAction
Definition: being.h:1226
void setAction(const BeingActionT &action, const int attackId)
bool mKeepAttacking
Definition: localplayer.h:522

◆ attack2()

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

Definition at line 2259 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(), and nextTile().

2261 {
2262  if (!dontChangeEquipment && (target != nullptr))
2264 
2265  const bool broken = (Net::getNetworkType() == ServerType::TMWATHENA);
2266 
2267  // probably need cache getPathLength(target)
2268  if ((target == nullptr ||
2269  settings.attackType == 0 ||
2270  settings.attackType == 3) ||
2271  (withinAttackRange(target, broken, broken ? 1 : 0) &&
2272  getPathLength(target) <= getAttackRange2()))
2273  {
2274  attack(target, keep);
2275  if (settings.attackType == 2)
2276  {
2277  if (target == nullptr)
2278  {
2279  if (pickUpItems())
2280  return;
2281  }
2282  else
2283  {
2284  pickUpItems(3);
2285  }
2286  }
2287  }
2288  else if (mPickUpTarget == nullptr)
2289  {
2290  if (settings.attackType == 2)
2291  {
2292  if (pickUpItems())
2293  return;
2294  }
2295  setTarget(target);
2296  if (target->getType() != ActorType::Npc)
2297  {
2298  mKeepAttacking = true;
2299  moveToTarget();
2300  }
2301  }
2302 }
bool withinAttackRange(const Being *const target, const bool fixDistance=false, const int addRange=0) const
unsigned int attackType
Definition: settings.h:136
int getAttackRange2() const
bool pickUpItems(int pickUpType=0)
void attack(Being *const target=0, const bool keep=false, const bool dontChangeEquipment=false)
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:178
void changeEquipmentBeforeAttack(const Being *const target) const
void setTarget(Being *const target)
void moveToTarget(int dist=-1)
FloorItem * mPickUpTarget
Definition: localplayer.h:464
bool mKeepAttacking
Definition: localplayer.h:522

◆ attributeChanged()

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

Implements AttributeListener.

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

1240 {
1241  PRAGMA45(GCC diagnostic push)
1242  PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
1243  switch (id)
1244  {
1246  {
1248  break;
1249  if (oldVal > newVal)
1250  break;
1251 
1252  const int change = CAST_S32(newVal - oldVal);
1253  addXpMessage(change);
1254  break;
1255  }
1257  mLevel = CAST_S32(newVal);
1258  break;
1259  case Attributes::PLAYER_HP:
1260  if (oldVal != 0 && newVal == 0)
1262  break;
1264  {
1265  if (!mShowJobExp ||
1267  {
1268  return;
1269  }
1270  if (oldVal > newVal ||
1273  {
1274  return;
1275  }
1276  const int32_t change = CAST_S32(newVal - oldVal);
1277  addJobMessage(change);
1278  break;
1279  }
1280  default:
1281  break;
1282  }
1283  PRAGMA45(GCC diagnostic pop)
1284 }
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wunused-result") int TestLauncher
int mLevel
Definition: being.h:1217
void addXpMessage(const int64_t change)
#define CAST_S32
Definition: cast.h:29
void addJobMessage(const int64_t change)
bool mShowJobExp
Definition: localplayer.h:516
ServerTypeT getNetworkType()
Definition: net.cpp:178
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:100

◆ cancelFollow()

void LocalPlayer::cancelFollow ( )

Stop following a player.

Definition at line 2336 of file localplayer.cpp.

References _, debugMsg, mPlayerFollowed, and mPlayerImitated.

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

2337 {
2338  if (!mPlayerFollowed.empty())
2339  {
2340  // TRANSLATORS: cancel follow message
2341  debugMsg(_("Follow canceled"));
2342  }
2343  if (!mPlayerImitated.empty())
2344  {
2345  // TRANSLATORS: cancel follow message
2346  debugMsg(_("Imitation canceled"));
2347  }
2348  mPlayerFollowed.clear();
2349  mPlayerImitated.clear();
2350 }
#define _(s)
Definition: gettext.h:34
std::string mPlayerImitated
Definition: localplayer.h:460
#define debugMsg(str)
Definition: chattab.h:41
std::string mPlayerFollowed
Definition: localplayer.h:459

◆ canMove()

bool LocalPlayer::canMove ( ) const

◆ changeEquipmentBeforeAttack()

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

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

1410 {
1411  if (settings.attackWeaponType == 1
1412  || (target == nullptr)
1413  || (PlayerInfo::getInventory() == nullptr))
1414  {
1415  return;
1416  }
1417 
1418  bool allowSword = false;
1419  const int dx = target->mX - mX;
1420  const int dy = target->mY - mY;
1421  const Item *item = nullptr;
1422 
1423  if (dx * dx + dy * dy > 80)
1424  return;
1425 
1426  if (dx * dx + dy * dy < 8)
1427  allowSword = true;
1428 
1429  const Inventory *const inv = PlayerInfo::getInventory();
1430  if (inv == nullptr)
1431  return;
1432 
1433  // if attack distance for sword
1434  if (allowSword)
1435  {
1436  // searching swords
1437  const WeaponsInfos &swords = WeaponsDB::getSwords();
1438  FOR_EACH (WeaponsInfosIter, it, swords)
1439  {
1440  item = inv->findItem(*it, ItemColor_zero);
1441  if (item != nullptr)
1442  break;
1443  }
1444 
1445  // no swords
1446  if (item == nullptr)
1447  return;
1448 
1449  // if sword not equiped
1450  if (item->isEquipped() == Equipped_false)
1452 
1453  // if need equip shield too
1454  if (settings.attackWeaponType == 3)
1455  {
1456  // searching shield
1457  const WeaponsInfos &shields = WeaponsDB::getShields();
1458  FOR_EACH (WeaponsInfosIter, it, shields)
1459  {
1460  item = inv->findItem(*it, ItemColor_zero);
1461  if (item != nullptr)
1462  break;
1463  }
1464  if ((item != nullptr) && item->isEquipped() == Equipped_false)
1466  }
1467  }
1468  // big distance. allowed only bow
1469  else
1470  {
1471  // searching bow
1472  const WeaponsInfos &bows = WeaponsDB::getBows();
1473  FOR_EACH (WeaponsInfosIter, it, bows)
1474  {
1475  item = inv->findItem(*it, ItemColor_zero);
1476  if (item != nullptr)
1477  break;
1478  }
1479 
1480  // no bow
1481  if (item == nullptr)
1482  return;
1483 
1484  if (item->isEquipped() == Equipped_false)
1486  }
1487 }
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
void equipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:250
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:207
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:1311
Definition: item.h:48
WeaponsInfos::const_iterator WeaponsInfosIter
Definition: weaponsdb.h:29
int mY
Definition: being.h:1312
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 2736 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().

2737 {
2738  if (target == nullptr)
2739  return false;
2740 
2741  switch (settings.pvpAttackType)
2742  {
2743  case 0:
2744  return true;
2745  case 1:
2746  return !(playerRelations.getRelation(target->mName)
2747  == Relation::FRIEND);
2748  case 2:
2749  return playerRelations.checkBadRelation(target->mName);
2750  default:
2751  case 3:
2752  return false;
2753  }
2754 }
RelationT getRelation(const std::string &name) const
std::string mName
Definition: being.h:1178
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 2671 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().

2672 {
2673  if (being == nullptr)
2674  return;
2675 
2676  const std::string &nick = being->mName;
2677  if (being->getType() == ActorType::Player)
2678  {
2679  const Guild *const guild = getGuild();
2680  if (guild != nullptr)
2681  {
2682  const GuildMember *const gm = guild->getMember(nick);
2683  if (gm != nullptr)
2684  {
2685  const int level = gm->getLevel();
2686  if (level > 1 && being->getLevel() != level)
2687  {
2688  being->setLevel(level);
2689  being->updateName();
2690  }
2691  }
2692  }
2693  if (chatWindow != nullptr)
2694  {
2695  WhisperTab *const tab = chatWindow->getWhisperTab(nick);
2696  if (tab != nullptr)
2697  tab->setWhisperTabColors();
2698  }
2699  }
2700 
2701  if (!mWaitFor.empty() && mWaitFor == nick)
2702  {
2703  // TRANSLATORS: wait player/monster message
2704  debugMsg(strprintf(_("You see %s"), mWaitFor.c_str()));
2706  mWaitFor.clear();
2707  }
2708 }
ChatWindow * chatWindow
Definition: chatwindow.cpp:88
#define _(s)
Definition: gettext.h:34
SoundManager soundManager
Guild * getGuild() const
Definition: being.cpp:1241
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:1178
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:3358
std::string mWaitFor
Definition: localplayer.h:493
bool gm(InputEvent &event)
Definition: commands.cpp:74
#define debugMsg(str)
Definition: chattab.h:41
virtual int getLevel() const
Definition: being.h:599
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:596
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:89
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 2661 of file localplayer.cpp.

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

2663 {
2664 }

◆ fixAttackTarget()

void LocalPlayer::fixAttackTarget ( )

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

2607 {
2608  if ((mMap == nullptr) || (mTarget == nullptr))
2609  return;
2610 
2611  if (settings.moveToTargetType == 11 || (settings.attackType == 0u)
2612  || !config.getBoolValue("autofixPos"))
2613  {
2614  return;
2615  }
2616 
2617  const Path debugPath = mMap->findPath(
2618  (mPixelX - mapTileSize / 2) / mapTileSize,
2620  mTarget->mX,
2621  mTarget->mY,
2622  getBlockWalkMask(),
2623  0);
2624 
2625  if (!debugPath.empty())
2626  {
2627  const Path::const_iterator i = debugPath.begin();
2628  setDestination((*i).x, (*i).y);
2629  }
2630 }
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:456
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:1311
int mPixelY
Definition: actor.h:133
int mY
Definition: being.h:1312
std::list< Position > Path
Definition: position.h:48
static const int mapTileSize
Definition: map.h:26
Path findPath(const int startX, const int startY, const int destX, const int destY, const unsigned char blockWalkmask, const int maxCost=20)
Definition: map.cpp:851
Map * mMap
Definition: actor.h:138

◆ fixPos()

void LocalPlayer::fixPos ( )

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

2544 {
2545  if ((mCrossX == 0) && (mCrossY == 0))
2546  return;
2547 
2548  const int dx = abs(mX - mCrossX);
2549  const int dy = abs(mY - mCrossY);
2550  const int dist = dx > dy ? dx : dy;
2551  const time_t time = cur_time;
2552  const int maxDist = mSyncPlayerMove ? mSyncPlayerMoveDistance : 7;
2553 
2554  if (dist > maxDist)
2555  {
2556  mActivityTime = time;
2558 // alternative way to fix, move to real position
2559 // setDestination(mCrossX, mCrossY);
2560  }
2561 }
time_t mActivityTime
Definition: localplayer.h:480
void setTileCoords(const int x, const int y)
Definition: being.cpp:4934
bool mSyncPlayerMove
Definition: localplayer.h:512
int mX
Definition: being.h:1311
volatile time_t cur_time
Definition: timer.cpp:57
int mSyncPlayerMoveDistance
Definition: localplayer.h:499
int mY
Definition: being.h:1312

◆ followMoveTo() [1/2]

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

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

2465 {
2466  if ((being != nullptr) &&
2467  !mPlayerFollowed.empty() &&
2468  being->mName == mPlayerFollowed)
2469  {
2470  mPickUpTarget = nullptr;
2471  navigateTo(x, y);
2472  }
2473 }
std::string mName
Definition: being.h:1178
bool navigateTo(const int x, const int y)
FloorItem * mPickUpTarget
Definition: localplayer.h:464
std::string mPlayerFollowed
Definition: localplayer.h:459

◆ 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 2475 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.

2478 {
2479  if (being == nullptr)
2480  return;
2481 
2482  mPickUpTarget = nullptr;
2483  if (!mPlayerFollowed.empty() &&
2484  being->mName == mPlayerFollowed)
2485  {
2486  switch (settings.followMode)
2487  {
2488  case 0:
2489  navigateTo(x1, y1);
2490  setNextDest(x2, y2);
2491  break;
2492  case 1:
2493  if (x1 != x2 || y1 != y2)
2494  {
2495  navigateTo(mX + x2 - x1, mY + y2 - y1);
2496  setNextDest(mX + x2 - x1, mY + y2 - y1);
2497  }
2498  break;
2499  case 2:
2500  if (x1 != x2 || y1 != y2)
2501  {
2502  navigateTo(mX + x1 - x2, mY + y1 - y2);
2503  setNextDest(mX + x1 - x2, mY + y1 - y2);
2504  }
2505  break;
2506  case 3:
2507  if (mTarget == nullptr ||
2509  {
2510  if (actorManager != nullptr)
2511  {
2512  Being *const b = actorManager->findBeingByName(
2514  setTarget(b);
2515  }
2516  }
2517  moveToTarget();
2518  setNextDest(x2, y2);
2519  break;
2520  default:
2521  break;
2522  }
2523  }
2524 }
Being * findBeingByName(const std::string &name, const ActorTypeT type=ActorType::Unknown) const
unsigned int followMode
Definition: settings.h:134
Being * mTarget
Definition: localplayer.h:456
std::string mName
Definition: being.h:1178
Settings settings
Definition: settings.cpp:31
int mX
Definition: being.h:1311
bool navigateTo(const int x, const int y)
void setNextDest(const int x, const int y)
int mY
Definition: being.h:1312
void setTarget(Being *const target)
void moveToTarget(int dist=-1)
Definition: being.h:93
FloorItem * mPickUpTarget
Definition: localplayer.h:464
std::string mPlayerFollowed
Definition: localplayer.h:459
ActorManager * actorManager

◆ freezeMoving()

void LocalPlayer::freezeMoving ( const int  timeWaitTicks)

Definition at line 2816 of file localplayer.cpp.

References mFreezed, mUnfreezeTime, and tick_time.

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

2817 {
2818  if (timeWaitTicks <= 0)
2819  return;
2820  const int nextTime = tick_time + timeWaitTicks;
2821  if (mUnfreezeTime < nextTime)
2822  mUnfreezeTime = nextTime;
2823  if (mUnfreezeTime > 0)
2824  mFreezed = true;
2825 }
volatile int tick_time
Definition: timer.cpp:52
int mUnfreezeTime
Definition: localplayer.h:500

◆ getAttackRange()

int LocalPlayer::getAttackRange ( ) const

Gets the attack range.

Definition at line 976 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(), nextTile(), and withinAttackRange().

977 {
978  if (mAttackRange > -1)
979  {
980  return mAttackRange;
981  }
982 
983  const Item *const weapon = PlayerInfo::getEquipment(
985  if (weapon != nullptr)
986  {
987  const ItemInfo &info = weapon->getInfo();
988  return info.getAttackRange();
989  }
990  return 48; // unarmed range
991 }
Equipment * getEquipment()
Definition: playerinfo.cpp:232
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:1219

◆ getAttackRange2()

int LocalPlayer::getAttackRange2 ( ) const

Definition at line 2251 of file localplayer.cpp.

References getAttackRange().

Referenced by attack2(), and nextTile().

2252 {
2253  int range = getAttackRange();
2254  if (range == 1)
2255  range = 2;
2256  return range;
2257 }
int getAttackRange() const

◆ getAwayListener()

AwayListener* LocalPlayer::getAwayListener ( ) const
inline

Definition at line 411 of file localplayer.h.

References mAwayListener.

Referenced by GameModifiers::changeAwayMode().

412  { return mAwayListener; }
AwayListener * mAwayListener
Definition: localplayer.h:474

◆ getBlockWalkMask()

unsigned char LocalPlayer::getBlockWalkMask ( ) const
virtual

Gets the way the object is blocked by other objects.

Reimplemented from Being.

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

2711 {
2712  // for now blocking all types of collisions
2713  return BlockMask::WALL |
2714  BlockMask::AIR |
2717 }

◆ getCheckNameSetting()

bool LocalPlayer::getCheckNameSetting ( ) const
inline

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

Definition at line 348 of file localplayer.h.

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

349  { return mUpdateName; }
bool mUpdateName
Definition: localplayer.h:503

◆ getFollow()

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

Get the playername followed by the current player.

Definition at line 328 of file localplayer.h.

References mPlayerFollowed.

Referenced by InputManager::updateConditionMask().

329  { return mPlayerFollowed; }
std::string mPlayerFollowed
Definition: localplayer.h:459

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

References mPlayerImitated.

Referenced by imitateEmote().

335  { return mPlayerImitated; }
std::string mPlayerImitated
Definition: localplayer.h:460

◆ getLastAttackX()

int LocalPlayer::getLastAttackX ( ) const
inlinevirtual

Reimplemented from Being.

Definition at line 393 of file localplayer.h.

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

394  { return mTarget != nullptr ? mTarget->mX : mLastAttackX; }
Being * mTarget
Definition: localplayer.h:456
int mX
Definition: being.h:1311
int mLastAttackX
Definition: being.h:1220

◆ getLastAttackY()

int LocalPlayer::getLastAttackY ( ) const
inlinevirtual

Reimplemented from Being.

Definition at line 396 of file localplayer.h.

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

397  { return mTarget != nullptr ? mTarget->mY : mLastAttackY; }
Being * mTarget
Definition: localplayer.h:456
int mLastAttackY
Definition: being.h:1221
int mY
Definition: being.h:1312

◆ getLevel()

int LocalPlayer::getLevel ( ) const
virtual

Reimplemented from Being.

Definition at line 2637 of file localplayer.cpp.

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

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

2638 {
2640 }
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:100

◆ getMoveState()

unsigned int LocalPlayer::getMoveState ( ) const
inline

Definition at line 193 of file localplayer.h.

References mMoveState.

Referenced by specialMove().

194  { return mMoveState; }
unsigned int mMoveState
Definition: localplayer.h:449

◆ getNextDestX()

int LocalPlayer::getNextDestX ( ) const
inline

Definition at line 306 of file localplayer.h.

References mNextDestX.

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

307  { return mNextDestX; }

◆ getNextDestY()

int LocalPlayer::getNextDestY ( ) const
inline

Definition at line 309 of file localplayer.h.

References mNextDestY, and respawn().

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

310  { 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 2216 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().

2217 {
2218  if ((mMap == nullptr) || (being == nullptr))
2219  return 0;
2220 
2221  if (being->mX == mX && being->mY == mY)
2222  return 0;
2223 
2224  if (being->mX - 1 <= mX &&
2225  being->mX + 1 >= mX &&
2226  being->mY - 1 <= mY &&
2227  being->mY + 1 >= mY)
2228  {
2229  return 1;
2230  }
2231 
2233  {
2234  const Path debugPath = mMap->findPath(
2235  (mPixelX - mapTileSize / 2) / mapTileSize,
2237  being->mX,
2238  being->mY,
2239  getBlockWalkMask(),
2240  0);
2241  return CAST_S32(debugPath.size());
2242  }
2243 
2244  const int dx = CAST_S32(abs(being->mX - mX));
2245  const int dy = CAST_S32(abs(being->mY - mY));
2246  if (dx > dy)
2247  return dx;
2248  return dy;
2249 }
unsigned char getBlockWalkMask() const A_CONST
bool mTargetOnlyReachable
Definition: localplayer.h:510
int mPixelX
Definition: actor.h:132
#define CAST_S32
Definition: cast.h:29
int mX
Definition: being.h:1311
int mPixelY
Definition: actor.h:133
int mY
Definition: being.h:1312
std::list< Position > Path
Definition: position.h:48
static const int mapTileSize
Definition: map.h:26
Path findPath(const int startX, const int startY, const int destX, const int destY, const unsigned char blockWalkmask, const int maxCost=20)
Definition: map.cpp:851
Map * mMap
Definition: actor.h:138

◆ getPickUpTarget()

const FloorItem* LocalPlayer::getPickUpTarget ( ) const
inline

Definition at line 314 of file localplayer.h.

References mPickUpTarget.

Referenced by ActorManager::logic().

315  { return mPickUpTarget; }
FloorItem * mPickUpTarget
Definition: localplayer.h:464

◆ getPingTime()

std::string LocalPlayer::getPingTime ( ) const

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

1931 {
1932  std::string str;
1933  if (!mWaitPing)
1934  {
1935  if (mPingTime == 0)
1936  str = "?";
1937  else
1938  str = toString(CAST_S32(mPingTime));
1939  }
1940  else
1941  {
1942  time_t time = tick_time;
1943  if (time > mPingSendTick)
1944  time -= mPingSendTick;
1945  else
1946  time += MAX_TICK_VALUE - mPingSendTick;
1947  if (time <= mPingTime)
1948  time = mPingTime;
1949  if (mPingTime != time)
1950  str = strprintf("%d (%d)", CAST_S32(mPingTime), CAST_S32(time));
1951  else
1952  str = toString(CAST_S32(time));
1953  }
1954  return str;
1955 }
volatile int tick_time
Definition: timer.cpp:52
int mPingSendTick
Definition: localplayer.h:477
bool mWaitPing
Definition: localplayer.h:525
#define CAST_S32
Definition: cast.h:29
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
time_t mPingTime
Definition: localplayer.h:478
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 148 of file localplayer.h.

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

149  { return mWalkingDir; }
unsigned char mWalkingDir
Definition: localplayer.h:501

◆ 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 1024 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().

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

2365 {
2366  if (being == nullptr)
2367  return;
2368 
2369  if (!mPlayerImitated.empty() && being->mName == mPlayerImitated)
2370  {
2371  setAction(action, 0);
2372  playerHandler->changeAction(action);
2373  }
2374 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:89
std::string mName
Definition: being.h:1178
std::string mPlayerImitated
Definition: localplayer.h:460
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 2376 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().

2378 {
2379  if (being == nullptr)
2380  return;
2381 
2382  if (!mPlayerImitated.empty() && being->mName == mPlayerImitated)
2383  {
2385  return;
2386 
2387  if (settings.followMode == 2)
2388  {
2389  uint8_t dir2 = 0;
2390  if ((dir & BeingDirection::LEFT) != 0)
2391  dir2 |= BeingDirection::RIGHT;
2392  else if ((dir & BeingDirection::RIGHT) != 0)
2393  dir2 |= BeingDirection::LEFT;
2394  if ((dir & BeingDirection::UP) != 0)
2395  dir2 |= BeingDirection::DOWN;
2396  else if ((dir & BeingDirection::DOWN) != 0)
2397  dir2 |= BeingDirection::UP;
2398 
2399  setDirection(dir2);
2400  playerHandler->setDirection(dir2);
2401  }
2402  else
2403  {
2404  setDirection(dir);
2406  }
2407  }
2408 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:89
unsigned int followMode
Definition: settings.h:134
bool limitPackets(const PacketTypeT type)
std::string mName
Definition: being.h:1178
virtual void setDirection(const uint8_t direction)
Definition: being.cpp:1649
Settings settings
Definition: settings.cpp:31
std::string mPlayerImitated
Definition: localplayer.h:460
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 2352 of file localplayer.cpp.

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

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

2354 {
2355  if (being == nullptr)
2356  return;
2357 
2358  std::string player_imitated = getImitate();
2359  if (!player_imitated.empty() && being->mName == player_imitated)
2360  emote(action);
2361 }
std::string mName
Definition: being.h:1178
const std::string & getImitate() const
Definition: localplayer.h:334
static bool emote(const uint8_t emotion)

◆ imitateOutfit()

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

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

2412 {
2413  if (player == nullptr)
2414  return;
2415 
2416  if (settings.imitationMode == 1 &&
2417  !mPlayerImitated.empty() &&
2418  player->mName == mPlayerImitated)
2419  {
2420  if (sprite < 0 || sprite >= player->getNumberOfLayers())
2421  return;
2422 
2423  const AnimatedSprite *const equipmentSprite
2424  = dynamic_cast<const AnimatedSprite *>(
2425  player->mSprites[sprite]);
2426 
2427  if (equipmentSprite != nullptr)
2428  {
2429 // logger->log("have equipmentSprite");
2430  const Inventory *const inv = PlayerInfo::getInventory();
2431  if (inv == nullptr)
2432  return;
2433 
2434  const std::string &path = equipmentSprite->getIdPath();
2435  if (path.empty())
2436  return;
2437 
2438 // logger->log("idPath: " + path);
2439  const Item *const item = inv->findItemBySprite(path,
2440  player->getGender(), player->getSubType());
2441  if ((item != nullptr) && item->isEquipped() == Equipped_false)
2443  }
2444  else
2445  {
2446 // logger->log("have unequip %d", sprite);
2447  const int equipmentSlot = inventoryHandler
2448  ->convertFromServerSlot(sprite);
2449 // logger->log("equipmentSlot: " + toString(equipmentSlot));
2450  if (equipmentSlot == inventoryHandler->getProjectileSlot())
2451  return;
2452 
2453  const Item *const item = PlayerInfo::getEquipment(equipmentSlot);
2454  if (item != nullptr)
2455  {
2456 // logger->log("unequiping");
2458  }
2459  }
2460  }
2461 }
int getNumberOfLayers() const
Definition: being.h:372
void equipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:250
Equipment * getEquipment()
Definition: playerinfo.cpp:232
GenderT getGender() const
Definition: being.h:621
Equipped isEquipped() const
Definition: item.h:128
Inventory * getInventory()
Definition: playerinfo.cpp:207
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:1178
Settings settings
Definition: settings.cpp:31
std::string mPlayerImitated
Definition: localplayer.h:460
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:82
void unequipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:258
virtual int convertFromServerSlot(const int eAthenaSlot) const =0
BeingTypeId getSubType() const
Definition: being.h:395

◆ isPathSetByMouse()

bool LocalPlayer::isPathSetByMouse ( ) const
inline

Tells if the path has been set by mouse.

Definition at line 190 of file localplayer.h.

References mPathSetByMouse.

191  { return mPathSetByMouse; }
bool mPathSetByMouse
Definition: localplayer.h:524

◆ isReachable() [1/2]

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

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

1491 {
1492  if ((being == nullptr) || (mMap == nullptr))
1493  return false;
1494 
1495  if (being->getReachable() == Reachable::REACH_NO)
1496  return false;
1497 
1498  if (being->mX == mX &&
1499  being->mY == mY)
1500  {
1501  being->setDistance(0);
1503  return true;
1504  }
1505  else if (being->mX - 1 <= mX &&
1506  being->mX + 1 >= mX &&
1507  being->mY - 1 <= mY &&
1508  being->mY + 1 >= mY)
1509  {
1510  being->setDistance(1);
1512  return true;
1513  }
1514 
1515  const Path debugPath = mMap->findPath(
1516  (mPixelX - mapTileSize / 2) / mapTileSize,
1518  being->mX,
1519  being->mY,
1520  getBlockWalkMask(),
1521  maxCost);
1522 
1523  being->setDistance(CAST_S32(debugPath.size()));
1524  if (!debugPath.empty())
1525  {
1527  return true;
1528  }
1530  return false;
1531 }
void setDistance(const int n)
Definition: being.h:550
unsigned char getBlockWalkMask() const A_CONST
ReachableT getReachable() const
Definition: being.h:605
int mPixelX
Definition: actor.h:132
#define CAST_S32
Definition: cast.h:29
int mX
Definition: being.h:1311
void setReachable(const ReachableT n)
Definition: being.h:602
int mPixelY
Definition: actor.h:133
int mY
Definition: being.h:1312
std::list< Position > Path
Definition: position.h:48
static const int mapTileSize
Definition: map.h:26
Path findPath(const int startX, const int startY, const int destX, const int destY, const unsigned char blockWalkmask, const int maxCost=20)
Definition: map.cpp:851
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 1533 of file localplayer.cpp.

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

1535 {
1536  const WalkLayer *const walk = mMap->getWalkLayer();
1537  if (walk == nullptr)
1538  return false;
1539  int num = walk->getDataAt(x, y);
1540  if (allowCollision && num < 0)
1541  num = -num;
1542 
1543  return walk->getDataAt(mX, mY) == num;
1544 }
const WalkLayer * getWalkLayer() const
Definition: map.h:336
int mX
Definition: being.h:1311
int getDataAt(const int x, const int y) const
Definition: walklayer.cpp:39
int mY
Definition: being.h:1312
Map * mMap
Definition: actor.h:138

◆ isServerBuggy()

bool LocalPlayer::isServerBuggy ( ) const
inline

◆ loadHomes()

void LocalPlayer::loadHomes ( )
protected

Definition at line 1758 of file localplayer.cpp.

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

Referenced by getRename(), and LocalPlayer().

1759 {
1760  std::string buf;
1761  std::stringstream ss(serverConfig.getValue("playerHomes", ""));
1762 
1763  while (ss >> buf)
1764  {
1765  Vector pos;
1766  ss >> pos.x;
1767  ss >> pos.y;
1768  mHomes[buf] = pos;
1769  }
1770 }
std::map< std::string, Vector > mHomes
Definition: localplayer.h:454
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 241 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().

242 {
243  BLOCK_START("LocalPlayer::logic")
244 #ifdef USE_MUMBLE
245  if (mumbleManager)
246  mumbleManager->setPos(mX, mY, mDirection);
247 #endif // USE_MUMBLE
248 
249  // Actions are allowed once per second
250  if (get_elapsed_time(mLastAction) >= 1000)
251  mLastAction = -1;
252 
253  if (mActivityTime == 0 || mLastAction != -1)
255 
256  if (mUnfreezeTime > 0 &&
258  {
259  mUnfreezeTime = 0;
260  mFreezed = false;
261  }
262 
263  if ((mAction != BeingAction::MOVE || mNextStep) && !mNavigatePath.empty())
264  {
265  mNextStep = false;
266  int dist = 5;
267  if (!mSyncPlayerMove)
268  dist = 20;
269 
270  if (((mNavigateX != 0) || (mNavigateY != 0)) &&
271  ((mCrossX + dist >= mX && mCrossX <= mX + dist
272  && mCrossY + dist >= mY && mCrossY <= mY + dist)
273  || ((mCrossX == 0) && (mCrossY == 0))))
274  {
275  const Path::const_iterator i = mNavigatePath.begin();
276  if ((*i).x == mX && (*i).y == mY)
277  mNavigatePath.pop_front();
278  else
279  setDestination((*i).x, (*i).y);
280  }
281  }
282 
283  // Show XP messages
284  if (!mMessages.empty())
285  {
286  if (mMessageTime == 0)
287  {
288  const MessagePair info = mMessages.front();
289 
290  if ((particleEngine != nullptr) && (gui != nullptr))
291  {
293  info.first,
294  mPixelX,
295  mPixelY - 48,
296  &userPalette->getColor(info.second),
298  true);
299  }
300 
301  mMessages.pop_front();
302  mMessageTime = 30;
303  }
304  mMessageTime--;
305  }
306 
307  if (mTarget != nullptr)
308  {
309  if (mTarget->getType() == ActorType::Npc)
310  {
311  // NPCs are always in range
313  }
314  else
315  {
316  // Find whether target is in range
317  const int rangeX = CAST_S32(
318  abs(mTarget->mX - mX));
319  const int rangeY = CAST_S32(
320  abs(mTarget->mY - mY));
321  const int attackRange = getAttackRange();
322  const TargetCursorTypeT targetType
323  = rangeX > attackRange || rangeY > attackRange
325  mTarget->setTargetType(targetType);
326 
327  if (!mTarget->isAlive() && (!mTargetDeadPlayers
329  {
330  stopAttack(true);
331  }
332 
333  if (mKeepAttacking && (mTarget != nullptr))
334  attack(mTarget, true);
335  }
336  }
337 
338  Being::logic();
339  BLOCK_END("LocalPlayer::logic")
340 }
time_t mActivityTime
Definition: localplayer.h:480
const Color & getColor(UserColorIdT type, const unsigned int alpha=255U)
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 stopAttack(const bool keepAttack=false)
std::pair< std::string, UserColorIdT > MessagePair
Definition: localplayer.h:470
bool mNextStep
Definition: localplayer.h:518
uint8_t mDirection
Definition: being.h:1228
TargetCursorType ::T TargetCursorTypeT
int mUnfreezeTime
Definition: localplayer.h:500
#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:512
void attack(Being *const target=0, const bool keep=false, const bool dontChangeEquipment=false)
Being * mTarget
Definition: localplayer.h:456
UserPalette * userPalette
Definition: userpalette.cpp:33
int get_elapsed_time(const int startTime)
Definition: timer.cpp:93
std::list< MessagePair > mMessages
Definition: localplayer.h:472
int mPixelX
Definition: actor.h:132
#define CAST_S32
Definition: cast.h:29
Particle * addTextRiseFadeOutEffect(const std::string &text, const int x, const int y, const Color *const color, Font *const font, const bool outline=false)
int mX
Definition: being.h:1311
bool info(InputEvent &event)
Definition: commands.cpp:56
int mMessageTime
Definition: localplayer.h:473
void setTargetType(const TargetCursorTypeT type)
bool isAlive() const
Definition: being.h:483
ActorTypeT getType() const
Definition: being.h:115
Path mNavigatePath
Definition: localplayer.h:490
volatile time_t cur_time
Definition: timer.cpp:57
int mPixelY
Definition: actor.h:133
bool mTargetDeadPlayers
Definition: localplayer.h:505
int mY
Definition: being.h:1312
void logic()
Definition: being.cpp:1793
BeingActionT mAction
Definition: being.h:1226
int getAttackRange() const
bool mKeepAttacking
Definition: localplayer.h:522

◆ magicAttack()

void LocalPlayer::magicAttack ( ) const

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

1701 {
1703  return;
1704  if (chatWindow == nullptr ||
1705  !isAlive() ||
1707  {
1708  return;
1709  }
1710 
1711  switch (settings.magicAttackType)
1712  {
1713  // flar W00
1714  case 0:
1715  tryMagic("#flar", 1, 0, 10);
1716  break;
1717  // chiza W01
1718  case 1:
1719  tryMagic("#chiza", 1, 0, 9);
1720  break;
1721  // ingrav W10
1722  case 2:
1723  tryMagic("#ingrav", 2, 2, 20);
1724  break;
1725  // frillyar W11
1726  case 3:
1727  tryMagic("#frillyar", 2, 2, 25);
1728  break;
1729  // upmarmu W12
1730  case 4:
1731  tryMagic("#upmarmu", 2, 2, 20);
1732  break;
1733  default:
1734  break;
1735  }
1736 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:89
ChatWindow * chatWindow
Definition: chatwindow.cpp:88
virtual bool canUseMagic() const =0
Settings settings
Definition: settings.cpp:31
bool isAlive() const
Definition: being.h:483
ServerTypeT getNetworkType()
Definition: net.cpp:178
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 1648 of file localplayer.cpp.

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

Referenced by setMoveState(), and specialMove().

1649 {
1650  int dx = 0, dy = 0;
1651  if ((dir & BeingDirection::UP) != 0)
1652  dy--;
1653  if ((dir & BeingDirection::DOWN) != 0)
1654  dy++;
1655  if ((dir & BeingDirection::LEFT) != 0)
1656  dx--;
1657  if ((dir & BeingDirection::RIGHT) != 0)
1658  dx++;
1659  move(dx, dy);
1660 }
void move(const int dX, const int dY)

◆ moveToHome()

void LocalPlayer::moveToHome ( )

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

1380 {
1381  mPickUpTarget = nullptr;
1382  if ((mX != mCrossX || mY != mCrossY) && (mCrossX != 0) && (mCrossY != 0))
1383  {
1385  }
1386  else if (mMap != nullptr)
1387  {
1388  const std::map<std::string, Vector>::const_iterator iter =
1389  mHomes.find(mMap->getProperty("_realfilename"));
1390 
1391  if (iter != mHomes.end())
1392  {
1393  const Vector pos = mHomes[(*iter).first];
1394  if (mX == pos.x && mY == pos.y)
1395  {
1397  CAST_S32(pos.x),
1398  CAST_S32(pos.y),
1399  CAST_S32(mDirection));
1400  }
1401  else
1402  {
1403  navigateTo(CAST_S32(pos.x), CAST_S32(pos.y));
1404  }
1405  }
1406  }
1407 }
Net::PlayerHandler * playerHandler
Definition: net.cpp:89
void setDestination(const int x, const int y)
std::map< std::string, Vector > mHomes
Definition: localplayer.h:454
uint8_t mDirection
Definition: being.h:1228
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:1311
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:1312
float y
Definition: vector.h:208
FloorItem * mPickUpTarget
Definition: localplayer.h:464
Map * mMap
Definition: actor.h:138

◆ moveToTarget()

void LocalPlayer::moveToTarget ( int  dist = -1)

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

1293 {
1294  bool gotPos(false);
1295  Path debugPath;
1296 
1297  size_t limit(0);
1298 
1299  if (dist == -1)
1300  {
1301  dist = settings.moveToTargetType;
1302  if (dist != 0)
1303  {
1304  const bool broken = (Net::getNetworkType() ==
1306  switch (dist)
1307  {
1308  case 10:
1309  dist = mAttackRange;
1310  if (dist == 1 && broken)
1311  dist = 2;
1312  break;
1313  case 11:
1314  dist = mAttackRange - 1;
1315  if (dist < 1)
1316  dist = 1;
1317  if (dist == 1 && broken)
1318  dist = 2;
1319  break;
1320  default:
1321  break;
1322  }
1323  }
1324  }
1325 
1326  if (mTarget != nullptr)
1327  {
1328  if (mMap != nullptr)
1329  {
1330  debugPath = mMap->findPath(
1331  (mPixelX - mapTileSize / 2) / mapTileSize,
1333  mTarget->mX,
1334  mTarget->mY,
1335  getBlockWalkMask(),
1336  0);
1337  }
1338 
1339  const size_t sz = debugPath.size();
1340  if (sz < CAST_SIZE(dist))
1341  return;
1342  limit = CAST_S32(sz) - dist;
1343  gotPos = true;
1344  }
1345  else if ((mNavigateX != 0) || (mNavigateY != 0))
1346  {
1347  debugPath = mNavigatePath;
1348  limit = dist;
1349  gotPos = true;
1350  }
1351 
1352  if (gotPos)
1353  {
1354  if (dist == 0)
1355  {
1356  if (mTarget != nullptr)
1358  }
1359  else
1360  {
1361  Position pos(0, 0);
1362  size_t f = 0;
1363 
1364  for (Path::const_iterator i = debugPath.begin(),
1365  i_fend = debugPath.end();
1366  i != i_fend && f < limit; ++i, f++)
1367  {
1368  pos = (*i);
1369  }
1370  navigateTo(pos.x, pos.y);
1371  }
1372  }
1373  else if ((mLastTargetX != 0) || (mLastTargetY != 0))
1374  {
1376  }
1377 }
int mLastTargetX
Definition: localplayer.h:451
unsigned char getBlockWalkMask() const A_CONST
Being * mTarget
Definition: localplayer.h:456
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:1311
Path mNavigatePath
Definition: localplayer.h:490
bool navigateTo(const int x, const int y)
int mLastTargetY
Definition: localplayer.h:452
int mPixelY
Definition: actor.h:133
ServerTypeT getNetworkType()
Definition: net.cpp:178
int mY
Definition: being.h:1312
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:1219
Path findPath(const int startX, const int startY, const int destX, const int destY, const unsigned char blockWalkmask, const int maxCost=20)
Definition: map.cpp:851
Map * mMap
Definition: actor.h:138

◆ navigateClean()

void LocalPlayer::navigateClean ( )

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

2088 {
2089  if (mMap == nullptr)
2090  return;
2091 
2092  mShowNavigePath = false;
2093  mOldX = 0;
2094  mOldY = 0;
2095  mOldTileX = 0;
2096  mOldTileY = 0;
2097  mNavigateX = 0;
2098  mNavigateY = 0;
2100 
2101  mNavigatePath.clear();
2102 
2103  SpecialLayer *const tmpLayer = mMap->getTempLayer();
2104  if (tmpLayer == nullptr)
2105  return;
2106 
2107  tmpLayer->clean();
2108 }
Path mNavigatePath
Definition: localplayer.h:490
bool mShowNavigePath
Definition: localplayer.h:526
SpecialLayer * getTempLayer() const
Definition: map.h:234
BeingId mNavigateId
Definition: localplayer.h:483
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 2056 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().

2057 {
2058  if (mMap == nullptr)
2059  return false;
2060 
2061  SpecialLayer *const tmpLayer = mMap->getTempLayer();
2062  if (tmpLayer == nullptr)
2063  return false;
2064 
2065  mShowNavigePath = true;
2066  mOldX = mPixelX;
2067  mOldY = mPixelY;
2068  mOldTileX = mX;
2069  mOldTileY = mY;
2070  mNavigateX = x;
2071  mNavigateY = y;
2073 
2075  (mPixelX - mapTileSize / 2) / mapTileSize,
2077  x,
2078  y,
2079  getBlockWalkMask(),
2080  0);
2081 
2082  if (mDrawPath)
2083  tmpLayer->addRoad(mNavigatePath);
2084  return !mNavigatePath.empty();
2085 }
unsigned char getBlockWalkMask() const A_CONST
int mPixelX
Definition: actor.h:132
int mX
Definition: being.h:1311
Path mNavigatePath
Definition: localplayer.h:490
int mPixelY
Definition: actor.h:133
bool mShowNavigePath
Definition: localplayer.h:526
void addRoad(const Path &road)
SpecialLayer * getTempLayer() const
Definition: map.h:234
BeingId mNavigateId
Definition: localplayer.h:483
int mY
Definition: being.h:1312
static const int mapTileSize
Definition: map.h:26
const BeingId BeingId_zero
Definition: beingid.h:29
bool mDrawPath
Definition: localplayer.h:513
Path findPath(const int startX, const int startY, const int destX, const int destY, const unsigned char blockWalkmask, const int maxCost=20)
Definition: map.cpp:851
Map * mMap
Definition: actor.h:138

◆ nextTile() [1/2]

void LocalPlayer::nextTile ( )
inlinevirtual

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

References A_WARN_UNUSED, actorSpriteDestroyed(), attack(), attack2(), getAttackRange(), getAttackRange2(), getTarget(), ServerCommandType::item, pickUp(), setDestination(), setGroupId(), setNewTarget(), setTarget(), setWalkingDir(), stopAttack(), untarget(), x, and y.

Referenced by Being::setActionTime().

89  { nextTile(0); }
void nextTile()
Definition: localplayer.h:88

◆ nextTile() [2/2]

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

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

440 {
441  const Party *const party = Party::getParty(1);
442  if (party != nullptr)
443  {
444  PartyMember *const pm = party->getMember(mName);
445  if (pm != nullptr)
446  {
447  pm->setX(mX);
448  pm->setY(mY);
449  }
450  }
451 
452  if (mPath.empty())
453  {
454  if (mPickUpTarget != nullptr)
456 
457  if (mWalkingDir != 0u)
459  }
460  else if (mPath.size() == 1)
461  {
462  if (mPickUpTarget != nullptr)
464  }
465 
466  if (mGoingToTarget && (mTarget != nullptr) && withinAttackRange(mTarget))
467  {
469  attack(mTarget, true);
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 }
bool withinAttackRange(const Being *const target, const bool fixDistance=false, const int addRange=0) const
Definition: party.h:61
bool mNextStep
Definition: localplayer.h:518
bool mGoingToTarget
Definition: localplayer.h:520
Path mPath
Definition: being.h:1194
virtual void nextTile()
Definition: being.cpp:1741
void attack(Being *const target=0, const bool keep=false, const bool dontChangeEquipment=false)
void setY(const int y)
Definition: avatar.h:134
uint32_t party
Being * mTarget
Definition: localplayer.h:456
std::string mName
Definition: being.h:1178
int mX
Definition: being.h:1311
static Party * getParty(const int16_t id)
Definition: party.cpp:313
PartyMember * getMember(const BeingId id) const
Definition: party.cpp:99
Path mNavigatePath
Definition: localplayer.h:490
unsigned char mWalkingDir
Definition: localplayer.h:501
void startWalking(const unsigned char dir)
int mY
Definition: being.h:1312
BeingActionT mAction
Definition: being.h:1226
FloorItem * mPickUpTarget
Definition: localplayer.h:464
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 1092 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().

1093 {
1094  if (value == "showownname")
1095  {
1096  setShowName(config.getBoolValue("showownname"));
1097  }
1098  else if (value == "targetDeadPlayers")
1099  {
1100  mTargetDeadPlayers = config.getBoolValue("targetDeadPlayers");
1101  }
1102  else if (value == "enableBuggyServers")
1103  {
1104  mIsServerBuggy = serverConfig.getBoolValue("enableBuggyServers");
1105  }
1106  else if (value == "syncPlayerMove")
1107  {
1108  mSyncPlayerMove = config.getBoolValue("syncPlayerMove");
1109  }
1110  else if (value == "syncPlayerMoveDistance")
1111  {
1112  mSyncPlayerMoveDistance = config.getIntValue("syncPlayerMoveDistance");
1113  }
1114  else if (value == "drawPath")
1115  {
1116  mDrawPath = config.getBoolValue("drawPath");
1117  }
1118  else if (value == "serverAttack")
1119  {
1120  mServerAttack = fromBool(config.getBoolValue("serverAttack"), Keep);
1121  }
1122  else if (value == "attackMoving")
1123  {
1124  mAttackMoving = config.getBoolValue("attackMoving");
1125  }
1126  else if (value == "attackNext")
1127  {
1128  mAttackNext = config.getBoolValue("attackNext");
1129  }
1130  else if (value == "showJobExp")
1131  {
1132  mShowJobExp = config.getBoolValue("showJobExp");
1133  }
1134  else if (value == "enableAdvert")
1135  {
1136  mEnableAdvert = config.getBoolValue("enableAdvert");
1137  }
1138  else if (value == "tradebot")
1139  {
1140  mTradebot = config.getBoolValue("tradebot");
1141  }
1142  else if (value == "targetOnlyReachable")
1143  {
1144  mTargetOnlyReachable = config.getBoolValue("targetOnlyReachable");
1145  }
1146  else if (value == "showserverpos")
1147  {
1148  mShowServerPos = config.getBoolValue("showserverpos");
1149  }
1150  else if (value == "visiblenames")
1151  {
1152  mVisibleNames = static_cast<VisibleName::Type>(
1153  config.getIntValue("visiblenames"));
1154  }
1155 }
bool mAttackMoving
Definition: localplayer.h:514
void setShowName(const bool doShowName)
Definition: being.cpp:1155
bool mAttackNext
Definition: localplayer.h:515
Configuration config
int getIntValue(const std::string &key) const
Configuration serverConfig
bool mSyncPlayerMove
Definition: localplayer.h:512
bool mIsServerBuggy
Definition: localplayer.h:511
bool mTargetOnlyReachable
Definition: localplayer.h:510
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:505
int mSyncPlayerMoveDistance
Definition: localplayer.h:499
bool mShowJobExp
Definition: localplayer.h:516
bool mTradebot
Definition: localplayer.h:509
bool mEnableAdvert
Definition: localplayer.h:508
Keep mServerAttack
Definition: localplayer.h:506
bool mDrawPath
Definition: localplayer.h:513
bool mShowServerPos
Definition: localplayer.h:517
VisibleName::Type mVisibleNames
Definition: localplayer.h:507

◆ pathSetByMouse()

void LocalPlayer::pathSetByMouse ( )
inline

Tells that the path has been set by mouse.

Definition at line 186 of file localplayer.h.

References mPathSetByMouse.

187  { mPathSetByMouse = true; }
bool mPathSetByMouse
Definition: localplayer.h:524

◆ 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 866 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(), 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, and Pickup::UNKNOWN.

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

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

◆ pickUp()

bool LocalPlayer::pickUp ( FloorItem *const  item)

Definition at line 493 of file localplayer.cpp.

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

Referenced by Viewport::drawPath(), Actions::getAmountFromEvent(), nextTile(), ActorManager::pickUpAll(), pickUpItems(), and ActorManager::pickUpNearest().

494 {
495  if (item == nullptr)
496  return false;
497 
499  return false;
500 
501  const int dx = item->getTileX() - mX;
502  const int dy = item->getTileY() - mY;
503  int dist = 6;
504 
505  const unsigned int pickUpType = settings.pickUpType;
506  if (pickUpType >= 4 && pickUpType <= 6)
507  dist = 4;
508 
509  if (dx * dx + dy * dy < dist)
510  {
511  if ((actorManager != nullptr) && actorManager->checkForPickup(item))
512  {
514  mPickUpTarget = nullptr;
515  }
516  }
517  else if (pickUpType >= 4 && pickUpType <= 6)
518  {
519  const Path debugPath = mMap->findPath(
520  (mPixelX - mapTileSize / 2) / mapTileSize,
521  (