63 struct WeightListener :
public gcn::ActionListener
65 void action(
const gcn::ActionEvent &event)
override
74 struct DeathListener :
public gcn::ActionListener
76 void action(
const gcn::ActionEvent &event)
override
93static const char *randomDeathMessage()
95 static char const *
const deadMsg[] =
98 N_(
"We regret to inform you that your character was killed in "
100 N_(
"You are not that alive anymore."),
101 N_(
"The cold hands of the grim reaper are grabbing for your soul."),
103 N_(
"Insert coin to continue."),
104 N_(
"No, kids. Your character did not really die. It... "
105 "err... went to a better place."),
106 N_(
"Your plan of breaking your enemies weapon by "
107 "bashing it with your throat failed."),
108 N_(
"I guess this did not run too well."),
110 N_(
"Do you want your possessions identified?"),
112 N_(
"Sadly, no trace of you was ever found..."),
116 N_(
"Looks like you got your head handed to you."),
118 N_(
"You screwed up again, dump your body down the tubes "
119 "and get you another one."),
121 N_(
"You're not dead yet. You're just resting."),
122 N_(
"You are no more."),
123 N_(
"You have ceased to be."),
124 N_(
"You've expired and gone to meet your maker."),
125 N_(
"You're a stiff."),
126 N_(
"Bereft of life, you rest in peace."),
127 N_(
"If you weren't so animated, you'd be pushing up the daisies."),
128 N_(
"Your metabolic processes are now history."),
129 N_(
"You're off the twig."),
130 N_(
"You've kicked the bucket."),
131 N_(
"You've shuffled off your mortal coil, run down the "
132 "curtain and joined the bleedin' choir invisible."),
133 N_(
"You are an ex-player."),
134 N_(
"You're pining for the fjords.")
137 const int random = rand() % (
sizeof(deadMsg) /
sizeof(deadMsg[0]));
138 return gettext(deadMsg[random]);
147 static const Uint16 _messages[] = {
189 Log::info(
"Warping to %s (%d, %d)", mapPath.c_str(), x, y);
200 bool sameMap = (currentMapName == mapPath);
203 mapPath = mapPath.substr(0, mapPath.rfind(
"."));
206 float scrollOffsetX = 0.0f;
207 float scrollOffsetY = 0.0f;
227 Log::info(
"Adjust scrolling by %d:%d", (
int) scrollOffsetX,
228 (
int) scrollOffsetY);
261 _(
"You are carrying more than "
262 "half your weight. You are "
263 "unable to regain health."));
301 randomDeathMessage(),
329 if (newMoney > oldMoney)
509 Log::info(
"0x013b: Unhandled message %i", type);
520 if (
Map *map = game->getCurrentMap())
556 unsigned int count = (msg.
getLength() - 4) / 6;
557 for (
unsigned int i = 0; i < count; ++i)
609 static Timer lastPickupTimer;
613 if (!floorItem || !lastPickupTimer.
passed())
619 lastPickupTimer.
set(100);
690 return Vector(15.0f, 15.0f, 0.0f);
700 if (!map || speed.
x == 0 || speed.
y == 0)
702 Log::info(
"TmwAthena::PlayerHandler: Speed set to default: "
703 "Map not yet initialized or invalid speed.");
709 constexpr float ticksPerSecond = 1000.0 / MILLISECONDS_IN_A_TICK;
711 pixelsPerSecond.
x = map->
getTileWidth() / speed.
x * ticksPerSecond;
714 return pixelsPerSecond;
742 const auto ¤tMapName = game->getCurrentMapName();
750 auto *npc =
static_cast<Being *
>(actor);
753 const auto newEffect = updatedQuestEffects.get(npcId);
755 if (oldEffect != newEffect)
758 npc->setStatusEffect(oldEffect,
false);
760 npc->setStatusEffect(newEffect,
true);
ActorSpriteManager * actorSpriteManager
const ActorSprites & getAll() const
Returns the whole list of beings.
void setPosition(const Vector &pos) final
Sets the pixel position of this actor.
void setStatusEffect(int id, bool active)
void setMoveSpeed(const Vector &speed)
Sets the move speed.
int getTileX() const override
Returns the tile x coord.
void setAttackSpeed(int speed)
Sets the attack speed.
Action
Action the being is currently performing WARNING: Has to be in sync with the same enum in the Being c...
int getTileY() const override
Returns the tile y coord.
uint16_t getSubType() const
static void closeAll()
Closes all instances.
static void closeAll()
Closes all instances.
int getIntValue(const std::string &key) const
returns a value corresponding to the given key.
bool trigger(int id, Being *being, int rotation=0)
Triggers a effect with the id, at the specified being, and with the given rotation in degree: 0° = Do...
void listen(Event::Channel channel)
void trigger(Channel channel) const
Sends this event to all classes listening to the given channel.
An item lying on the floor.
The main class responsible for running the game.
const std::string & getCurrentMapName()
Map * getCurrentMap()
Returns the currently active map.
static Game * instance()
Provides access to the game instance.
void changeMap(const std::string &mapName)
Changes the currently active map.
void setGMLevel(int level)
void addMessageToQueue(const std::string &message, int color=UserPalette::EXP_INFO)
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.
void set(Key key, Value value)
int getTileHeight() const
Returns the tile height used by this map.
int getTileWidth() const
Returns the tile width of this map.
Vector getTileCenter(int x, int y) const
Returns the tile center position in pixel coordinates.
const uint16_t * handledMessages
static void closeAll()
Closes all instances.
void setPointsNeeded(int id, int needed)
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 set(uint32_t ms=0)
Sets the timer with an optional duration in milliseconds.
Used for parsing an incoming message from eAthena.
std::string readString(int length=-1)
Reads a string.
uint16_t readInt16()
Reads an unsigned 16-bit integer from the message.
uint8_t readInt8()
Reads an unsigned 8-bit integer from the message.
uint16_t getId() const
Returns the message ID.
uint32_t readInt32()
Reads an unsigned 32-bit integer from the message.
unsigned int getLength() const
Returns the message length.
Used for building an outgoing message to eAthena.
void writeInt32(uint32_t value)
Writes an unsigned 32-bit integer to the message.
void writeInt8(uint8_t value)
Writes an unsigned 8-bit integer to the message.
void writeInt16(uint16_t value)
Writes an unsigned 16-bit integer to the message.
void writeCoordinates(uint16_t x, uint16_t y, uint8_t direction)
Encodes coordinates and direction in 3 bytes.
bool canUseMagic() override
void updateQuestStatusEffects()
void ignorePlayer(const std::string &player, bool ignore) override
bool canCorrectAttributes() override
void emote(int emoteId) override
Vector getDefaultMoveSpeed() const override
Get the original default movement speed.
void setDirection(char direction) override
void applyQuestStatusEffects(Being *npc)
void changeAction(Being::Action action) override
void ignoreAll(bool ignore) override
QuestEffectMap mActiveQuestEffects
void setDestination(int x, int y, int direction=-1) override
int getJobLocation() override
void increaseAttribute(int attr) override
void attack(int id) override
void increaseSkill(int skillId) override
void event(Event::Channel channel, const Event &event) override
void pickUp(FloorItem *floorItem) override
Vector getPixelsPerSecondMoveSpeed(const Vector &speed, Map *map=nullptr) override
Convert the original server-dependant speed for internal use.
void decreaseAttribute(int attr) override
void handleMessage(MessageIn &msg) override
static std::string formatCurrency(int value)
Formats the given number in the correct currency format.
void closePopupMenu()
Closes the popup menu.
void scrollBy(float x, float y)
Changes viewpoint by relative pixel coordinates.
void shakeScreen(int intensity)
Makes the screen shake in a random direction.
Config config
Global settings (config.xml)
Configuration paths
XML default paths information reader.
EffectManager * effectManager
void serverNotice(const std::string &message)
Viewport * viewport
Viewport on the map.
StatusWindow * statusWindow
LocalPlayer * local_player
const int MAP_TELEPORT_SCROLL_DISTANCE
Max.
Net::PlayerHandler * playerHandler
void info(const char *log_text,...) LOG_PRINTF_ATTR
PlayerHandler * getPlayerHandler()
int getStatEffective(int id)
Returns the current effective value of the given stat.
void setStatExperience(int id, int have, int need, bool notify)
Changes the experience of the given stat.
void setStatBase(int id, int value, bool notify)
Changes the base value of the given stat.
void setAttribute(int id, int value, bool notify)
Changes the value of the given attribute.
int getAttribute(int id)
Returns the value of the given attribute.
std::pair< int, int > getStatExperience(int id)
Returns the experience of the given stat.
void setStatMod(int id, int value, bool notify)
Changes the modifier for the given stat.
QuestChange questChange(int varId, int oldValue, int newValue)
QuestEffectMap getActiveEffects(const QuestVars &questVars, const std::string &mapName)
Warning: buffers and other variables are shared, so there can be only one connection active at a time...
@ SMSG_PLAYER_STAT_UPDATE_1
@ SMSG_PLAYER_STAT_UPDATE_4
@ SMSG_PLAYER_ARROW_MESSAGE
@ SMSG_PLAYER_STAT_UPDATE_5
@ CMSG_STAT_UPDATE_REQUEST
@ CMSG_SKILL_LEVELUP_REQUEST
@ SMSG_PLAYER_STAT_UPDATE_6
@ CMSG_PLAYER_CHANGE_DEST
@ SMSG_PLAYER_STAT_UPDATE_2
@ SMSG_PLAYER_STAT_UPDATE_3
std::string strprintf(char const *format,...)
A safe version of sprintf that returns a std::string of the result.