84 #include "resources/map/map.h"
94 #include "utils/timer.h"
131 mStatusEffectIcons(),
155 mTestParticleTime(0),
156 mTestParticleHash(0L),
157 mSyncPlayerMoveDistance(
config.getIntValue(
"syncPlayerMoveDistance")),
162 mTargetDeadPlayers(
config.getBoolValue(
"targetDeadPlayers")),
165 config.getIntValue(
"visiblenames"))),
166 mEnableAdvert(
config.getBoolValue(
"enableAdvert")),
167 mTradebot(
config.getBoolValue(
"tradebot")),
168 mTargetOnlyReachable(
config.getBoolValue(
"targetOnlyReachable")),
169 mIsServerBuggy(
serverConfig.getValueBool(
"enableBuggyServers", true)),
170 mSyncPlayerMove(
config.getBoolValue(
"syncPlayerMove")),
171 mDrawPath(
config.getBoolValue(
"drawPath")),
172 mAttackMoving(
config.getBoolValue(
"attackMoving")),
173 mAttackNext(
config.getBoolValue(
"attackNext")),
174 mShowJobExp(
config.getBoolValue(
"showJobExp")),
175 mShowServerPos(
config.getBoolValue(
"showserverpos")),
177 mGoingToTarget(false),
178 mKeepAttacking(false),
179 mPathSetByMouse(false),
181 mShowNavigePath(false),
291 if ((*i).x ==
mX && (*i).y ==
mY)
338 = rangeX > attackRange || rangeY > attackRange
429 mumbleManager->setAction(
CAST_S32(action));
452 if (
party !=
nullptr)
470 else if (
mPath.size() == 1)
525 if (pickUpType >= 4 && pickUpType <= 6)
528 if (dx * dx + dy * dy < dist)
536 else if (pickUpType >= 4 && pickUpType <= 6)
545 if (!debugPath.empty())
569 if (target ==
this && (target !=
nullptr))
575 Being *oldTarget =
nullptr;
590 if (oldTarget !=
nullptr)
593 if (target !=
nullptr)
615 if ((target !=
nullptr) && target !=
mTarget)
678 if ((
mMap ==
nullptr) || (dir == 0U))
802 const bool dontChangeEquipment)
821 const int dist_x = target->
mX -
mX;
822 const int dist_y = target->
mY -
mY;
826 if (abs(dist_y) >= abs(dist_x))
853 if (!dontChangeEquipment)
905 const char*
msg =
nullptr;
910 msg =
N_(
"Tried to pick up nonexistent item.");
914 msg =
N_(
"Item is too heavy.");
918 msg =
N_(
"Item is too far away.");
922 msg =
N_(
"Inventory is full.");
926 msg =
N_(
"Stack is too big.");
930 msg =
N_(
"Item belongs to someone else.");
934 msg =
N_(
"You can't pickup this amount of items.");
938 msg =
N_(
"Your item stack has max amount.");
945 msg =
N_(
"Unknown problem picking up item.");
982 "[@@%d|%s@@].",
"You picked up %d [@@%d|%s@@].", amount),
983 amount,
itemInfo.getId(), str.c_str()),
1014 if (weapon !=
nullptr)
1017 return info.getAttackRange();
1023 const bool fixDistance,
1024 const int addRange)
const
1026 if (target ==
nullptr)
1033 if (fixDistance && range == 1)
1038 return !(dx > range || dy > range);
1043 if (target ==
nullptr)
1054 const int32_t effectId,
1063 if (effect !=
nullptr)
1070 if (sprite ==
nullptr)
1092 for (
size_t i = 0; i < sz; i++)
1125 if (value ==
"showownname")
1129 else if (value ==
"targetDeadPlayers")
1133 else if (value ==
"enableBuggyServers")
1137 else if (value ==
"syncPlayerMove")
1141 else if (value ==
"syncPlayerMoveDistance")
1152 else if (value ==
"syncPlayerMoveDistanceLegacy")
1161 else if (value ==
"drawPath")
1165 else if (value ==
"serverAttack")
1169 else if (value ==
"attackMoving")
1173 else if (value ==
"attackNext")
1177 else if (value ==
"showJobExp")
1181 else if (value ==
"enableAdvert")
1185 else if (value ==
"tradebot")
1189 else if (value ==
"targetOnlyReachable")
1193 else if (value ==
"showserverpos")
1197 else if (value ==
"visiblenames")
1206 if (change != 0 &&
mMessages.size() < 20)
1213 if (pair.first.find(
strprintf(
" %s",
_(
"xp"))) ==
1215 pair.first.size() - strlen(
_(
"xp")) - 1)
1246 if (change != 0 &&
mMessages.size() < 20)
1258 if (change != 0 &&
mMessages.size() < 20)
1272 if (change != 0 &&
mMessages.size() < 20)
1282 if (change != 0 &&
mMessages.size() < 20)
1291 const int64_t oldVal,
1292 const int64_t newVal)
1295 PRAGMA45(GCC diagnostic ignored
"-Wswitch-enum")
1302 if (oldVal > newVal)
1305 const int change =
CAST_S32(newVal - oldVal);
1313 if (oldVal != 0 && newVal == 0)
1323 if (oldVal > newVal ||
1329 const int32_t change =
CAST_S32(newVal - oldVal);
1363 if (dist == 1 && broken)
1370 if (dist == 1 && broken)
1381 if (
mMap !=
nullptr)
1392 const size_t sz = debugPath.size();
1417 for (Path::const_iterator i = debugPath.begin(),
1418 i_fend = debugPath.end();
1419 i != i_fend && f < limit; ++i, f++)
1439 else if (
mMap !=
nullptr)
1441 const std::map<std::string, Vector>::const_iterator iter =
1444 if (iter !=
mHomes.end())
1447 if (
mX == pos.
x &&
mY == pos.
y)
1465 || (target ==
nullptr)
1471 bool allowSword =
false;
1472 const int dx = target->
mX -
mX;
1473 const int dy = target->
mY -
mY;
1474 const Item *item =
nullptr;
1476 if (dx * dx + dy * dy > 80)
1479 if (dx * dx + dy * dy < 8)
1494 if (item !=
nullptr)
1499 if (item ==
nullptr)
1514 if (item !=
nullptr)
1529 if (item !=
nullptr)
1534 if (item ==
nullptr)
1545 if ((being ==
nullptr) || (
mMap ==
nullptr))
1551 if (being->
mX ==
mX &&
1558 else if (being->
mX - 1 <=
mX &&
1559 being->
mX + 1 >=
mX &&
1560 being->
mY - 1 <=
mY &&
1561 being->
mY + 1 >=
mY)
1577 if (!debugPath.empty())
1587 const bool allowCollision)
const
1590 if (walk ==
nullptr)
1593 if (allowCollision && num < 0)
1604 bool status =
false;
1611 if (item !=
nullptr)
1614 if (pickUpType == 0)
1617 if (pickUpType == 0)
1636 if (item !=
nullptr)
1643 x1 =
x - 1; y1 =
y - 1; x2 =
x + 1; y2 =
y;
break;
1645 x1 =
x - 1; y1 =
y; x2 =
x + 1; y2 =
y + 1;
break;
1647 x1 =
x - 1; y1 =
y - 1; x2 =
x; y2 =
y + 1;
break;
1649 x1 =
x; y1 =
y - 1; x2 =
x + 1; y2 =
y + 1;
break;
1651 x1 =
x; x2 =
x; y1 =
y; y2 =
y;
break;
1796 const int schoolMagic,
const int mana)
1853 if (specialLayer ==
nullptr)
1856 const std::string key =
mMap->
getProperty(
"_realfilename", std::string());
1861 const std::map<std::string, Vector>::const_iterator
1864 if (iter !=
mHomes.end())
1885 if (iter !=
mHomes.end())
1892 pos.
x =
static_cast<float>(
mX);
1893 pos.
y =
static_cast<float>(
mY);
1903 if (mapItem !=
nullptr)
1916 const std::map<std::string, Vector>::iterator iter =
mHomes.find(key);
1917 if (iter !=
mHomes.end() &&
mX == pos.
x &&
mY == pos.
y)
1948 if (mapItem !=
nullptr)
1966 std::stringstream ss;
1968 for (std::map<std::string, Vector>::const_iterator iter =
mHomes.begin(),
1969 iter_fend =
mHomes.end();
1973 const Vector &pos = (*iter).second;
1975 if (iter !=
mHomes.begin())
1977 ss << (*iter).first <<
" " << pos.
x <<
" " << pos.
y;
2061 if (!message.empty())
2063 if (message.size() > 4 && message.substr(0, 4) ==
"/me ")
2065 message = message.substr(4);
2091 "I am away from keyboard."));
2092 if (str.find(
"'NAME'") != std::string::npos)
2095 std::string
msg(
"*AFK*: " + str);
2126 if (
mMap ==
nullptr)
2130 if (tmpLayer ==
nullptr)
2157 if (
mMap ==
nullptr)
2172 if (tmpLayer ==
nullptr)
2180 if (
mMap !=
nullptr)
2214 if (tmpLayer ==
nullptr)
2229 if (being ==
nullptr)
2248 if ((*i).x ==
mX && (*i).y ==
mY)
2286 if ((
mMap ==
nullptr) || (being ==
nullptr))
2289 if (being->
mX ==
mX && being->
mY ==
mY)
2292 if (being->
mX - 1 <=
mX &&
2293 being->
mX + 1 >=
mX &&
2294 being->
mY - 1 <=
mY &&
2295 being->
mY + 1 >=
mY)
2329 const bool dontChangeEquipment)
2331 if (!dontChangeEquipment && (target !=
nullptr))
2337 if ((target ==
nullptr ||
2343 attack(target, keep,
false);
2346 if (target ==
nullptr)
2379 std::string
msg =
strprintf(
_(
"Follow: %s"), player.c_str());
2395 std::string
msg =
strprintf(
_(
"Imitation: %s"), player.c_str());
2422 const unsigned char action)
const
2424 if (being ==
nullptr)
2428 if (!player_imitated.empty() && being->
mName == player_imitated)
2435 if (being ==
nullptr)
2446 const unsigned char dir)
2448 if (being ==
nullptr)
2480 const int sprite)
const
2482 if (player ==
nullptr)
2496 if (equipmentSprite !=
nullptr)
2503 const std::string &path = equipmentSprite->
getIdPath();
2523 if (item !=
nullptr)
2533 const int x,
const int y)
2535 if ((being !=
nullptr) &&
2545 const int x1,
const int y1,
2546 const int x2,
const int y2)
2548 if (being ==
nullptr)
2562 if (x1 != x2 || y1 != y2)
2569 if (x1 != x2 || y1 != y2)
2619 const int dist = dx > dy ? dx : dy;
2642 #ifdef ENABLEDEBUGLOG
2672 if (
mMap ==
nullptr)
2676 if (layer !=
nullptr)
2678 bool cacheUpdated(
false);
2685 cacheUpdated =
true;
2692 if (mapItem ==
nullptr ||
2698 if (cacheUpdated ==
false)
2735 if (!debugPath.empty())
2737 const Path::const_iterator i = debugPath.begin();
2754 if (
mMap !=
nullptr)
2756 const std::map<std::string, Vector>::const_iterator iter =
2759 if (iter !=
mHomes.end())
2762 if ((pos.
x != 0.0F) && (pos.
y != 0.0F))
2784 if (being ==
nullptr)
2787 const std::string &nick = being->
mName;
2791 if (
guild !=
nullptr)
2796 const int level =
gm->getLevel();
2797 if (level > 1 && being->
getLevel() != level)
2832 if (
mMap ==
nullptr)
2835 const std::string key =
mMap->
getProperty(
"_realfilename", std::string());
2836 const std::map<std::string, Vector>::iterator iter =
mHomes.find(key);
2838 if (iter !=
mHomes.end())
2849 if (target ==
nullptr)
2892 const bool updateHash)
2929 if (timeWaitTicks <= 0)
2931 const int nextTime =
tick_time + timeWaitTicks;
ActorManager * actorManager
Attributes ::T AttributesT
BeingAction ::T BeingActionT
Net::BeingHandler * beingHandler
const BeingId BeingId_zero
#define fromBool(val, name)
Net::ChatHandler * chatHandler
bool pickUpAll(const int x1, const int y1, const int x2, const int y2, const bool serverBuggy) const
Being * findNearestLivingBeing(const int x, const int y, int maxTileDist, const ActorTypeT type, const Being *const excluded) const
Being * findBeing(const BeingId id) const
Being * findBeingByName(const std::string &name, const ActorTypeT type) const
FloorItem * findItem(const BeingId id) const
bool checkForPickup(const FloorItem *const item) const
bool pickUpNearest(const int x, const int y, int maxdist) const
ParticleList mChildParticleEffects
void setTargetType(const TargetCursorTypeT type)
void controlCustomParticle(Particle *const particle)
void addActorSpriteListener(ActorSpriteListener *const listener)
virtual void handleStatusEffect(const StatusEffect *const effect, const int32_t effectId, const Enable newStatus, const IsStart start)
std::string getIdPath() const
virtual void setDirection(const uint8_t direction)
virtual void setAction(const BeingActionT &action, const int attackId)
ReachableT getReachable() const
virtual int getLevel() const
virtual void setTileCoords(const int x, const int y)
int getNumberOfLayers() const
BeingTypeId getSubType() const
void setLevel(const int n)
virtual void updateCoords()
void postInit(const BeingTypeId subType, Map *const map)
void recalcSpritesOrder()
void setShowName(const bool doShowName)
void setDistance(const int n)
void setMap(Map *const map)
virtual void setGroupId(const int id)
GenderT getGender() const
void setReachable(const ReachableT n)
ActorTypeT getType() const
void setDestination(const int dstX, const int dstY)
void chatLog(std::string line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
WhisperTab * getWhisperTab(const std::string &nick) const
void localChatInput(const std::string &msg) const
std::vector< Sprite * > mSprites
std::string getValue(const std::string &key, const std::string &deflt) const
bool getBoolValue(const std::string &key) const
void addListener(const std::string &key, ConfigListener *const listener)
void setValue(const std::string &key, const std::string &value)
void removeListener(const std::string &key, ConfigListener *const listener)
void removeListeners(ConfigListener *const listener)
int getIntValue(const std::string &key) const
void setShowMsg(const bool n)
static void changeAwayMode(const bool forward)
Font * getInfoParticleFont() const
const Item * findItemBySprite(std::string spritePath, const GenderT gender, const BeingTypeId race) const
Item * findItem(const int itemId, const ItemColor color) const
Equipped isEquipped() const
const ItemInfo & getInfo() const
static std::string getKeyShortString(const std::string &key)
void setNextDest(const int x, const int y)
void updateNavigateList()
AwayListener * mAwayListener
static bool checAttackPermissions(const Being *const target)
void attack2(Being *const target, const bool keep, const bool dontChangeEquipment)
void moveToTarget(int dist)
std::string mTestParticleName
void freezeMoving(const int timeWaitTicks)
void setTileCoords(const int x, const int y)
void setWalkingDir(const unsigned char dir)
bool pickUpItems(int pickUpType)
void followMoveTo(const Being *const being, const int x, const int y)
void addHpMessage(const int change)
void setMap(Map *const map)
void failMove(const int x, const int y)
void startWalking(const unsigned char dir)
std::string getPingTime() const
void attributeChanged(const AttributesT id, const int64_t oldVal, const int64_t newVal)
void setTarget(Being *const target)
std::vector< int32_t > mStatusEffectIcons
Being * getTarget() const
int getAttackRange() const
void imitateDirection(const Being *const being, const unsigned char dir)
void addHomunXpMessage(const int change)
void waitFor(const std::string &nick)
void setFollow(const std::string &player)
FloorItem * mPickUpTarget
void attack(Being *const target, const bool keep, const bool dontChangeEquipment)
unsigned char mWalkingDir
void setGroupId(const int id)
void setAction(const BeingActionT &action, const int attackId)
void imitateEmote(const Being *const being, const unsigned char action) const
static void tryMagic(const std::string &spell, const int baseMagic, const int schoolMagic, const int mana)
bool navigateTo(const int x, const int y)
void setRealPos(const int x, const int y)
int getAttackRange2() const
void stopAttack(const bool keepAttack)
void stopWalking(const bool sendToServer)
std::list< MessagePair > mMessages
void setImitate(const std::string &player)
void optionChanged(const std::string &value)
void setDestination(const int x, const int y)
void setTestParticle(const std::string &fileName, const bool updateHash)
void actorSpriteDestroyed(const ActorSprite &actorSprite)
void move(const int dX, const int dY)
void handleStatusEffect(const StatusEffect *const effect, const int32_t effectId, const Enable newStatus, const IsStart start)
void moveByDirection(const unsigned char dir)
bool withinAttackRange(const Being *const target, const bool fixDistance, const int addRange) const
void setAway(const std::string &message) const
unsigned long mTestParticleHash
void addJobMessage(const int64_t change)
const std::string & getImitate() const
std::string mPlayerImitated
bool mTargetOnlyReachable
unsigned int getMoveState() const
VisibleName::Type mVisibleNames
void imitateOutfit(const Being *const player, const int sprite) const
void afkRespond(ChatTab *const tab, const std::string &nick)
std::pair< std::string, UserColorIdT > MessagePair
void checkNewName(Being *const being)
std::string mPlayerFollowed
void setGotoTarget(Being *const target)
static bool emote(const uint8_t emotion)
int getPathLength(const Being *const being) const
void addXpMessage(const int64_t change)
void addSpMessage(const int change)
void changeEquipmentBeforeAttack(const Being *const target) const
void specialMove(const unsigned char direction)
Being * setNewTarget(const ActorTypeT type, const AllowSort allowSort)
static void setPseudoAway(const std::string &message)
bool isReachable(Being *const being, const int maxCost)
static void setAfkMessage(std::string message)
void addMessageToQueue(const std::string &message, const UserColorIdT color)
unsigned char getBlockWalkMask() const A_CONST
bool pickUp(FloorItem *const item)
void updateStatus() const
void pickedUp(const ItemInfo &itemInfo, const int amount, const ItemColor color, const BeingId floorItemId, const PickupT fail)
void imitateAction(const Being *const being, const BeingActionT &action)
int mSyncPlayerMoveDistance
std::map< std::string, Vector > mHomes
void log1(const char *const log_text)
void dlog(const std::string &str)
void setName(const std::string &name)
void addPortalTile(const std::string &name, const int type, const int x, const int y)
void updatePortalTile(const std::string &name, const int type, const int x, const int y, const bool addNew)
std::string getObjectData(const unsigned x, const unsigned y, const int type) const
bool getWalk(const int x, const int y, const unsigned char blockWalkMask) const
Path findPath(const int startX, const int startY, const int destX, const int destY, const unsigned char blockWalkmask, const int maxCost)
SpecialLayer * getSpecialLayer() const
const WalkLayer * getWalkLayer() const
SpecialLayer * getTempLayer() const
const std::string getMusicFile() const
void setWalk(const int x, const int y)
void setIcon(const int index, AnimatedSprite *const sprite)
void eraseIcon(const int index)
virtual void requestNameById(const BeingId id) const =0
virtual void privateMessage(const std::string &recipient, const std::string &text) const =0
virtual int convertFromServerSlot(const int eAthenaSlot) const =0
virtual int getProjectileSlot() const =0
virtual void setDirection(const unsigned char direction) const =0
virtual void stopAttack() const =0
virtual void changeAction(const BeingActionT &action) const =0
virtual void setDestination(const int x, const int y, const int direction) const =0
virtual bool canUseMagic() const =0
virtual void attack(const BeingId id, const Keep keep) const =0
virtual void updateStatus(const uint8_t status) const =0
virtual void emote(const uint8_t emoteId) const =0
virtual bool haveMoveWhileSit() const =0
virtual bool havePlayerStatusUpdate() const =0
virtual bool haveKillerId() const =0
static std::string keyName(const int number)
Particle * addEffect(const std::string &particleEffectFile, const int pixelX, const int pixelY, const int rotation)
Particle * addTextRiseFadeOutEffect(const std::string &text, const int x, const int y, const Color *const color, Font *const font, const bool outline)
void removeLocally(const Particle *const particle)
static Party * getParty(const int16_t id)
static void distributeEvent()
RelationT getRelation(const std::string &name) const
bool checkBadRelation(const std::string &name) const
const std::string getProperty(const std::string &name, const std::string &def) const
unsigned int imitationMode
unsigned int magicAttackType
unsigned int attackWeaponType
unsigned int pvpAttackType
unsigned int moveToTargetType
void removePortal(const int x, const int y)
int getPortalIndex(const int x, const int y)
void addPortal(const int x, const int y)
std::string getCurrentMusicFile() const
void fadeOutAndPlayMusic(const std::string &fileName, const int ms)
void playGuiSound(const std::string &name)
void volumeRestore() const
void fadeOutMusic(const int ms)
MapItem * getTile(const int x, const int y) const
void setTile(const int x, const int y, MapItem *const item)
void addRoad(const Path &road)
AnimatedSprite * getIcon() const
void deliverMessage() const
const Color & getColor(const ThemeColorIdT type, const unsigned int alpha)
static unsigned long getFileHash(const std::string &filePath)
const Color & getColor(UserColorIdT type, const unsigned int alpha)
int getDataAt(const int x, const int y) const
void setWhisperTabColors()
virtual void scheduleDelete()
Configuration serverConfig
static const int mapTileSize
const bool Equipped_false
#define FOR_EACH(type, iter, array)
PRAGMA45(GCC diagnostic push) PRAGMA45(GCC diagnostic ignored "-Wredundant-decls") PRAGMA45(GCC diagnostic pop) class TestMain
const bool IgnoreRecord_false
Net::InventoryHandler * inventoryHandler
const ItemColor ItemColor_zero
static const int16_t awayLimitTimer
static const int MAX_TICK_VALUE
std::map< int, Guild * >::const_iterator GuildMapCIter
LocalPlayer * localPlayer
MiniStatusWindow * miniStatusWindow
bool msg(InputEvent &event)
bool itemInfo(InputEvent &event)
bool gm(InputEvent &event)
bool info(InputEvent &event)
std::string toString(T const &value)
converts any type to a string
ServerTypeT getNetworkType()
bool limitPackets(const PacketTypeT type)
Inventory * getInventory()
void setStatMod(const AttributesT id, const int value, const Notify notify)
void equipItem(const Item *const item, const Sfx sfx)
Equipment * getEquipment()
void pickUpItem(const FloorItem *const item, const Sfx sfx)
int32_t getAttribute(const AttributesT id)
int getSkillLevel(const int id)
void unequipItem(const Item *const item, const Sfx sfx)
void updateAttackAi(const BeingId targetId, const Keep keep)
void setStatBase(const AttributesT id, const int value, const Notify notify)
const WeaponsInfos & getShields()
const WeaponsInfos & getSwords()
const WeaponsInfos & getBows()
std::vector< std::string > mMessages
static const int blockWalkMask
Net::ServerFeatures * serverFeatures
Net::PlayerHandler * playerHandler
ParticleEngine * particleEngine
#define BLOCK_START(name)
PlayerRelationsManager playerRelations
std::list< Position > Path
SocialWindow * socialWindow
static const std::string SOUND_INFO
SoundManager soundManager
StatusWindow * statusWindow
std::string & replaceAll(std::string &context, const std::string &from, const std::string &to)
std::string strprintf(const char *const format,...)
TargetCursorType ::T TargetCursorTypeT
int get_elapsed_time(const int startTime)
const bool TryRemoveColors_true
UserColorId ::T UserColorIdT
UserPalette * userPalette
std::vector< int > WeaponsInfos
WeaponsInfos::const_iterator WeaponsInfosIter