2011-08-28 15:17:58 +02:00
|
|
|
/*
|
2012-01-02 17:58:37 +01:00
|
|
|
* Copyright (c) 2010-2012 OTClient <https://github.com/edubart/otclient>
|
2011-08-28 15:17:58 +02:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
#ifndef LOCALPLAYER_H
|
|
|
|
#define LOCALPLAYER_H
|
|
|
|
|
|
|
|
#include "player.h"
|
|
|
|
|
|
|
|
class LocalPlayer : public Player
|
|
|
|
{
|
2012-01-19 05:12:53 +01:00
|
|
|
enum {
|
2012-01-19 17:23:24 +01:00
|
|
|
WALK_LOCK_INTERVAL = 250,
|
|
|
|
PREWALK_TIMEOUT = 1000
|
2012-01-19 05:12:53 +01:00
|
|
|
};
|
2011-08-15 23:02:52 +02:00
|
|
|
public:
|
2012-01-19 05:12:53 +01:00
|
|
|
LocalPlayer();
|
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
void setCanReportBugs(uint8 canReportBugs) { m_canReportBugs = (canReportBugs != 0); }
|
2011-08-30 03:34:00 +02:00
|
|
|
void setSkill(Otc::Skill skill, Otc::SkillType skillType, int value) { m_skills[skill][skillType] = value; }
|
2011-11-03 20:26:53 +01:00
|
|
|
void setStatistic(Otc::Statistic statistic, double value) { m_statistics[statistic] = value; }
|
2012-01-07 23:24:29 +01:00
|
|
|
void setAttackingCreature(const CreaturePtr& creature);
|
|
|
|
void setFollowingCreature(const CreaturePtr& creature);
|
2012-01-19 05:12:53 +01:00
|
|
|
void setIcons(int icons) { m_icons = icons; }
|
2012-01-17 06:36:25 +01:00
|
|
|
void setKnown(bool known) { m_known = known; }
|
2012-01-07 23:24:29 +01:00
|
|
|
|
|
|
|
bool getCanReportBugs() { return m_canReportBugs; }
|
|
|
|
int getSkill(Otc::Skill skill, Otc::SkillType skillType) { return m_skills[skill][skillType]; }
|
2011-11-03 23:14:56 +01:00
|
|
|
double getStatistic(Otc::Statistic statistic) { return m_statistics[statistic]; }
|
2012-01-07 23:24:29 +01:00
|
|
|
CreaturePtr getAttackingCreature() { return m_attackingCreature; }
|
|
|
|
CreaturePtr getFollowingCreature() { return m_followingCreature; }
|
2012-01-19 05:12:53 +01:00
|
|
|
int getIcons() { return m_icons; }
|
2012-01-07 23:24:29 +01:00
|
|
|
|
2012-01-17 06:36:25 +01:00
|
|
|
bool isKnown() { return m_known; }
|
2012-01-07 23:24:29 +01:00
|
|
|
bool isAttacking() { return m_attackingCreature != nullptr; }
|
|
|
|
bool isFollowing() { return m_followingCreature != nullptr; }
|
2012-01-25 15:56:17 +01:00
|
|
|
bool isPreWalking() { return m_preWalking; }
|
2011-11-03 20:26:53 +01:00
|
|
|
|
2012-01-19 05:12:53 +01:00
|
|
|
void unlockWalk() { m_walkLocked = false; }
|
|
|
|
void lockWalk();
|
|
|
|
void walk(const Position& oldPos, const Position& newPos);
|
2012-01-15 22:19:52 +01:00
|
|
|
void preWalk(Otc::Direction direction);
|
2011-11-05 21:34:49 +01:00
|
|
|
bool canWalk(Otc::Direction direction);
|
2012-01-19 05:12:53 +01:00
|
|
|
void cancelWalk(Otc::Direction direction = Otc::InvalidDirection);
|
|
|
|
void stopWalk();
|
2011-08-30 16:37:48 +02:00
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
LocalPlayerPtr asLocalPlayer() { return std::static_pointer_cast<LocalPlayer>(shared_from_this()); }
|
|
|
|
|
2012-01-16 10:37:02 +01:00
|
|
|
double getHealth() { return getStatistic(Otc::Health); }
|
|
|
|
double getMaxHealth() { return getStatistic(Otc::MaxHealth); }
|
|
|
|
double getFreeCapacity() { return getStatistic(Otc::FreeCapacity); }
|
|
|
|
double getExperience() { return getStatistic(Otc::Experience); }
|
2012-01-14 02:37:15 +01:00
|
|
|
double getLevel() { return getStatistic(Otc::Level); }
|
2012-01-16 10:37:02 +01:00
|
|
|
double getLevelPercent() { return getStatistic(Otc::LevelPercent); }
|
|
|
|
double getMana() { return getStatistic(Otc::Mana); }
|
|
|
|
double getMaxMana() { return getStatistic(Otc::MaxMana); }
|
|
|
|
double getMagicLevel() { return getStatistic(Otc::MagicLevel); }
|
|
|
|
double getMagicLevelPercent() { return getStatistic(Otc::MagicLevelPercent); }
|
|
|
|
double getSoul() { return getStatistic(Otc::Soul); }
|
|
|
|
double getStamina() { return getStatistic(Otc::Stamina); }
|
2012-01-14 02:37:15 +01:00
|
|
|
|
2012-01-19 05:12:53 +01:00
|
|
|
protected:
|
|
|
|
void updateWalkOffset(int totalPixelsWalked);
|
|
|
|
void updateWalk();
|
|
|
|
void terminateWalk();
|
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
private:
|
2012-01-19 05:12:53 +01:00
|
|
|
// walk related
|
|
|
|
bool m_preWalking;
|
|
|
|
bool m_lastPrewalkDone;
|
|
|
|
bool m_walkLocked;
|
|
|
|
Position m_lastPrewalkDestionation;
|
|
|
|
Timer m_walkLockTimer;
|
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
bool m_canReportBugs;
|
2012-01-17 06:36:25 +01:00
|
|
|
bool m_known;
|
2012-01-19 05:12:53 +01:00
|
|
|
CreaturePtr m_attackingCreature;
|
|
|
|
CreaturePtr m_followingCreature;
|
|
|
|
int m_icons;
|
2011-08-30 03:34:00 +02:00
|
|
|
int m_skills[Otc::LastSkill][Otc::LastSkillType];
|
2011-11-03 20:26:53 +01:00
|
|
|
double m_statistics[Otc::LastStatistic];
|
2011-08-15 23:02:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|