59 :
Being(id, PLAYER, subtype, nullptr)
78 const auto &[message, color] =
mMessages.front();
119 if (!withinAttackRange &&
getPath().empty())
123 else if (withinAttackRange)
202 const int tileX = (int)pos.
x / tileW;
203 const int tileY = (int)pos.
y / tileH;
204 int offsetX = (int)pos.
x % tileW;
205 int offsetY = (int)pos.
y % tileH;
209 bool wTopLeft =
mMap->
getWalk(tileX - 1, tileY - 1, walkMask);
210 bool wTop =
mMap->
getWalk(tileX, tileY - 1, walkMask);
211 bool wTopRight =
mMap->
getWalk(tileX + 1, tileY - 1, walkMask);
212 bool wLeft =
mMap->
getWalk(tileX - 1, tileY, walkMask);
213 bool wRight =
mMap->
getWalk(tileX + 1, tileY, walkMask);
214 bool wBottomLeft =
mMap->
getWalk(tileX - 1, tileY + 1, walkMask);
215 bool wBottom =
mMap->
getWalk(tileX, tileY + 1, walkMask);
216 bool wBottomRight =
mMap->
getWalk(tileX + 1, tileY + 1, walkMask);
229 wBottomRight =
false;
243 if (dx > 0 && dy < 0)
248 else if (wTop && !wRight)
250 else if (!wTop && !wRight)
251 return Position(tileX * tileW + tileW
253 tileY * tileH + collisionRadius);
259 (offsetX / tileH - (offsetX / tileW * tileH)))
269 (
int)pos.
y - tileH));
274 if (dx < 0 && dy < 0)
279 else if (wTop && !wLeft)
281 else if (!wTop && !wLeft)
282 return Position(tileX * tileW + collisionRadius,
283 tileY * tileH + collisionRadius);
297 (
int)pos.
y - tileH));
301 if (dx < 0 && dy > 0)
304 if (!wBottom && wLeft)
306 else if (wBottom && !wLeft)
308 else if (!wBottom && !wLeft)
309 return Position(tileX * tileW + collisionRadius,
310 tileY * tileH + tileH - collisionRadius);
311 else if (!wBottomLeft)
326 (
int)pos.
y + tileH));
330 if (dx > 0 && dy > 0)
333 if (!wBottom && wRight)
335 else if (wBottom && !wRight)
337 else if (!wBottom && !wRight)
338 return Position(tileX * tileW + tileW - collisionRadius,
339 tileY * tileH + tileH - collisionRadius);
340 else if (!wBottomRight)
354 (
int)pos.
y + tileH));
366 return Position(tileX * tileW + tileW - collisionRadius,
373 if (offsetY - collisionRadius < 0)
378 + tileW - collisionRadius,
379 tileY * tileH + collisionRadius);
387 if (offsetY + collisionRadius > tileH)
392 + tileW - collisionRadius,
394 + tileH - collisionRadius);
411 return Position(tileX * tileW + collisionRadius, (
int)pos.
y);
417 if (offsetY - collisionRadius < 0)
421 return Position(tileX * tileW + collisionRadius,
422 tileY * tileH + collisionRadius);
430 if (offsetY + collisionRadius > tileH)
434 return Position(tileX * tileW + collisionRadius,
436 + tileH - collisionRadius);
453 return Position((
int)pos.
x, tileY * tileH + collisionRadius);
459 if (offsetX - collisionRadius < 0)
463 return Position(tileX * tileW + collisionRadius,
464 tileY * tileH + collisionRadius);
472 if (offsetX + collisionRadius > tileW)
477 + tileW - collisionRadius,
478 tileY * tileH + collisionRadius);
485 (
int)pos.
y - tileH));
495 return Position((
int)pos.
x, tileY * tileH
496 + tileH - collisionRadius);
502 if (offsetX - collisionRadius < 0)
506 return Position(tileX * tileW + collisionRadius,
508 + tileH - collisionRadius);
515 if (offsetX + collisionRadius > tileW)
520 + tileW - collisionRadius,
522 + tileH - collisionRadius);
529 (
int)pos.
y + tileH));
545 if ((
int)pos.
x != destination.
x
546 || (
int)pos.
y != destination.
y)
562 return guild->getInviteRights();
628 Being *oldTarget =
nullptr;
663 srcX = srcX / tileWidth;
664 srcY = srcY / tileHeight;
665 dstX = dstX / tileWidth;
666 dstY = dstY / tileHeight;
670 if (srcX != dstX || srcY != dstY)
680 dstX = dstX / tileWidth;
681 dstY = dstY / tileHeight;
686 if (srcX == dstX && srcY == dstY)
702 if (pos.
x != dest.
x || pos.
y != dest.
y)
814 static Timer lastAttackTimer;
815 if (!lastAttackTimer.
passed())
858 msg =
N_(
"Tried to pick up nonexistent item.");
break;
864 msg =
N_(
"Item belongs to someone else.");
break;
865 default: msg =
N_(
"Unknown problem picking up item.");
break;
884 "You picked up %d [@@%d|%s@@].",
886 amount, itemInfo.
id, itemInfo.
name.c_str()));
895 msg += itemInfo.
name;
915 if (info.attackRange > -1)
923 if (!target || range < 0)
928 const int dx = abs(targetPos.
x - pos.
x);
929 const int dy = abs(targetPos.
y - pos.
y);
930 return dx <= range && dy <= range;
975 int oldXp =
event.getInt(
"oldValue");
976 int newXp =
event.getInt(
"newValue");
990 change = newXp - oldXp;
1019 event.setInt(
"index",
id);
1020 event.setBool(
"newStatus", newStatus);
1026static std::string afkMessage()
1055 auto msg =
strprintf(
_(
"*AFK*: %s"), afkMessage().c_str());
1099 if (event.getId() ==
"ok")
An action consists of several animations, one for each direction.
void setTargetType(TargetCursorType type)
Sets the target animation for this actor.
void untarget()
Untargets the actor.
int getPixelX() const
Returns the pixels X coordinate of the actor.
int getPixelY() const
Returns the pixel Y coordinate of the actor.
const Vector & getPosition() const
Returns the pixel position of this actor.
void action(const gcn::ActionEvent &event) override
void showDialog(const std::string &message)
void death(const gcn::Event &event) override
void event(Event::Channel channel, const Event &event) override
void setDestination(int ex, int ey)
Creates a path for the being from current position to ex and ey.
void setShowName(bool doShowName)
void setDirection(uint8_t direction)
Sets the current direction.
Action mAction
Action the being is performing.
unsigned char getWalkMask() const
Gets the way the object is blocked by other objects.
Type getType() const final
Returns the type of the ActorSprite.
virtual void updateStatusEffect(int index, bool newStatus)
Notify self that a status effect has flipped.
std::map< int, Guild * > mGuilds
void lookAt(const Vector &destVec)
Make the being look at a given pixel position.
int getCollisionRadius() const
Returns the being's pixel radius used to detect collisions.
Vector mDest
destination coordinates.
Action
Action the being is currently performing WARNING: Has to be in sync with the same enum in the Being c...
bool isAlive() const
Returns whether this being is still alive.
void setGM(bool gm)
Triggers whether or not to show the name as a GM name.
virtual void setAction(Action action, int attackId=1)
Sets the current action.
const std::string & getName() const
Returns the name of the being.
void logic() override
Performs being logic.
Guild * getGuild(const std::string &guildName) const
Returns a pointer to the specified guild that the being is in.
uint8_t mDirection
Facing direction.
void clearPath()
Removes all path nodes from this being.
const Vector & getDestination() const
Returns the destination for this being.
const Path & getPath() const
Returns the path this being is following.
int mAttackSpeed
Attack speed.
A tab for the chat window.
void chatLog(std::string line, Own own=BY_SERVER, bool ignoreRecord=false)
Adds a line of text to our message list.
void listen(Event::Channel channel)
An item lying on the floor.
gcn::Font * getInfoParticleFont() const
Return the Font used for "Info Particles", i.e.
Defines a class for storing generic item infos.
Represents one or more instances of a certain item type.
const ItemInfo & getInfo() const
Returns information about this item type.
The local player character.
void setTarget(Being *target)
Sets the target being of the player.
std::list< std::pair< std::string, int > > mMessages
Queued messages.
void setAttackRange(int range)
Sets the attack range.
void afkRespond(ChatTab *tab, const std::string &nick)
void pickedUp(const ItemInfo &itemInfo, int amount, unsigned char fail)
Shows item pickup notifications.
void setGMLevel(int level)
void inviteToGuild(Being *being)
Invite a player to join guild.
void addMessageToQueue(const std::string &message, int color=UserPalette::EXP_INFO)
Being * getTarget() const
Returns the current target of the player.
int getAttackRange() const
Gets the attack range.
void updateStatusEffect(int id, bool newStatus) override
Notify self that a status effect has flipped.
void setAction(Action action, int attackId=1) override
Sets the current action.
virtual void setDestination(int x, int y)
Sets a new destination for this being to walk to.
FloorItem * mPickUpTarget
std::unique_ptr< AwayListener > mAwayListener
Position getNextWalkPosition(unsigned char dir) const
Compute the next pathnode location when walking using keyboard.
bool mKeepAttacking
Whether or not to continue to attack.
void setWalkingDir(int dir)
Sets a new direction to keep walking in, when using the keyboard or the joystick.
bool isPathSetByMouse() const
Tells if the path has been set by mouse.
void event(Event::Channel channel, const Event &event) override
void setGotoTarget(Being *target)
Sets going to being to attack.
bool withinRange(Actor *target, int range) const
Returns whether the target is in range (in pixels).
void setAwayMode(bool away)
void pickUp(FloorItem *item)
Timer mLastTargetTimer
Timer for last targeting action.
void cancelGoToTarget()
Cancel a possible target destination in progress, but not the targeting.
LocalPlayer(int id=65535, int subtype=0)
void attack(Being *target=nullptr, bool keep=false)
bool mPathSetByMouse
Tells if the path was set using mouse.
void stopWalking(bool sendToServer=true)
Stops the player dead in his tracks.
int mWalkingDir
The direction the player is walking in.
Timer mLastActionTimer
Timeout for the last action.
bool checkInviteRights(const std::string &guildName)
Check the player has permission to invite users to specific guild.
void logic() override
Performs being logic.
void pathSetByMouse()
Tells that the path has been set by mouse.
void nextTile(unsigned char dir)
set the next path tile when walking and using the keyboard.
void startWalking(unsigned char dir)
Make the character starts to walk.
int getTileHeight() const
Returns the tile height used by this map.
int getTileWidth() const
Returns the tile width of this map.
Position checkNodeOffsets(int radius, unsigned char walkMask, const Position &position) const
Check the current position against surrounding blocking tiles, and correct the position offset within...
bool getWalk(int x, int y, unsigned char walkmask=BLOCKMASK_WALL) const
Gets walkability for a tile with a blocking bitmask.
virtual void privateMessage(const std::string &recipient, const std::string &text)=0
virtual void invite(int guildId, const std::string &name)=0
virtual void setDestination(int x, int y, int direction=-1)=0
virtual void attack(int id)=0
virtual void emote(int emoteId)=0
virtual void setDirection(char direction)=0
virtual void changeAction(Being::Action action)=0
virtual void pickUp(FloorItem *floorItem)=0
const gcn::Color & getColor(int type) const
Gets the color associated with the type.
Particle * addTextRiseFadeOutEffect(const std::string &text, int x, int y, const gcn::Color *color, gcn::Font *font, bool outline=false)
Creates a standalone text particle.
Simple timer that can be used to check if a certain amount of time has passed.
bool passed() const
Returns whether the timer has passed.
void reset()
Reset the timer.
void set(uint32_t ms=0)
Sets the timer with an optional duration in milliseconds.
void scheduleDelete()
Schedule this window for deletion.
Config config
Global settings (config.xml)
UserPalette * userPalette
void serverNotice(const std::string &message)
Particle * particleEngine
constexpr unsigned ACTION_TIMEOUT
constexpr unsigned AWAY_MESSAGE_TIMEOUT
LocalPlayer * local_player
LocalPlayer * local_player
ServerType getNetworkType()
GameHandler * getGameHandler()
ChatHandler * getChatHandler()
PlayerHandler * getPlayerHandler()
GuildHandler * getGuildHandler()
Equipment * getEquipment()
Returns the player's equipment.
void logic()
Does necessary updates every tick.
bool isTalking()
Returns true if the player is involved in a NPC interaction, false otherwise.
int getAttribute(int id)
Returns the value of the given attribute.
std::string strprintf(char const *format,...)
A safe version of sprintf that returns a std::string of the result.
std::string toString(const T &arg)
Converts the given value to a string using std::stringstream.
A position along a being's path.