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"
|
|
|
|
|
2012-06-22 05:14:13 +02:00
|
|
|
// @bindclass
|
2011-08-15 23:02:52 +02:00
|
|
|
class LocalPlayer : public Player
|
|
|
|
{
|
2012-01-19 05:12:53 +01:00
|
|
|
enum {
|
2012-01-19 17:23:24 +01:00
|
|
|
PREWALK_TIMEOUT = 1000
|
2012-01-19 05:12:53 +01:00
|
|
|
};
|
2012-02-09 04:45:19 +01:00
|
|
|
|
2011-08-15 23:02:52 +02:00
|
|
|
public:
|
2012-01-19 05:12:53 +01:00
|
|
|
LocalPlayer();
|
|
|
|
|
2012-02-09 04:45:19 +01:00
|
|
|
void unlockWalk() { m_walkLocked = false; }
|
2012-07-30 12:59:08 +02:00
|
|
|
void lockWalk(int millis = 250);
|
2012-02-09 04:45:19 +01:00
|
|
|
bool canWalk(Otc::Direction direction);
|
|
|
|
|
|
|
|
void setStates(int states);
|
|
|
|
void setSkill(Otc::Skill skill, int level, int levelPercent);
|
|
|
|
void setHealth(double health, double maxHealth);
|
|
|
|
void setFreeCapacity(double freeCapacity);
|
|
|
|
void setExperience(double experience);
|
|
|
|
void setLevel(double level, double levelPercent);
|
|
|
|
void setMana(double mana, double maxMana);
|
|
|
|
void setMagicLevel(double magicLevel, double magicLevelPercent);
|
|
|
|
void setSoul(double soul);
|
|
|
|
void setStamina(double stamina);
|
2012-01-17 06:36:25 +01:00
|
|
|
void setKnown(bool known) { m_known = known; }
|
2012-07-18 08:04:57 +02:00
|
|
|
void setInventoryItem(Otc::InventorySlot inventory, const ItemPtr& item);
|
2012-07-23 17:11:53 +02:00
|
|
|
void setVocation(int vocation);
|
|
|
|
void setPremium(bool premium);
|
2012-01-07 23:24:29 +01:00
|
|
|
|
2012-02-09 04:45:19 +01:00
|
|
|
int getStates() { return m_states; }
|
|
|
|
int getSkillLevel(Otc::Skill skill) { return m_skillsLevel[skill]; }
|
|
|
|
int getSkillLevelPercent(Otc::Skill skill) { return m_skillsLevelPercent[skill]; }
|
2012-07-23 17:11:53 +02:00
|
|
|
int getVocation() { return m_vocation; }
|
2012-02-09 04:45:19 +01:00
|
|
|
double getHealth() { return m_health; }
|
|
|
|
double getMaxHealth() { return m_maxHealth; }
|
|
|
|
double getFreeCapacity() { return m_freeCapacity; }
|
|
|
|
double getExperience() { return m_experience; }
|
|
|
|
double getLevel() { return m_level; }
|
|
|
|
double getLevelPercent() { return m_levelPercent; }
|
|
|
|
double getMana() { return m_mana; }
|
|
|
|
double getMaxMana() { return m_maxMana; }
|
|
|
|
double getMagicLevel() { return m_magicLevel; }
|
|
|
|
double getMagicLevelPercent() { return m_magicLevelPercent; }
|
|
|
|
double getSoul() { return m_soul; }
|
|
|
|
double getStamina() { return m_stamina; }
|
2012-07-18 08:04:57 +02:00
|
|
|
ItemPtr getInventoryItem(Otc::InventorySlot inventory) { return m_inventoryItems[inventory]; }
|
2012-01-07 23:24:29 +01:00
|
|
|
|
2012-01-17 06:36:25 +01:00
|
|
|
bool isKnown() { return m_known; }
|
2012-01-25 15:56:17 +01:00
|
|
|
bool isPreWalking() { return m_preWalking; }
|
2012-06-03 21:28:17 +02:00
|
|
|
bool isAutoWalking() { return m_autoWalking; }
|
2012-07-23 17:11:53 +02:00
|
|
|
bool isPremium() { return m_premium; }
|
2011-11-03 20:26:53 +01:00
|
|
|
|
2012-07-29 05:34:40 +02:00
|
|
|
LocalPlayerPtr asLocalPlayer() { return self_cast<LocalPlayer>(); }
|
2012-06-05 17:36:27 +02:00
|
|
|
bool isLocalPlayer() { return true; }
|
2012-02-09 04:45:19 +01:00
|
|
|
|
|
|
|
protected:
|
2012-01-19 05:12:53 +01:00
|
|
|
void walk(const Position& oldPos, const Position& newPos);
|
2012-01-15 22:19:52 +01:00
|
|
|
void preWalk(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
|
|
|
|
2012-02-09 04:45:19 +01:00
|
|
|
friend class Game;
|
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;
|
2012-06-03 21:28:17 +02:00
|
|
|
bool m_autoWalking;
|
2012-07-23 17:11:53 +02:00
|
|
|
bool m_premium;
|
2012-01-19 05:12:53 +01:00
|
|
|
Position m_lastPrewalkDestionation;
|
|
|
|
Timer m_walkLockTimer;
|
2012-07-18 08:04:57 +02:00
|
|
|
ItemPtr m_inventoryItems[Otc::LastInventorySlot];
|
2012-06-03 21:28:17 +02:00
|
|
|
ScheduledEventPtr m_autoWalkEndEvent;
|
2012-01-19 05:12:53 +01:00
|
|
|
|
2012-02-09 04:45:19 +01:00
|
|
|
std::array<int, Otc::LastSkill> m_skillsLevel;
|
|
|
|
std::array<int, Otc::LastSkill> m_skillsLevelPercent;
|
|
|
|
|
2012-01-17 06:36:25 +01:00
|
|
|
bool m_known;
|
2012-02-09 04:45:19 +01:00
|
|
|
int m_states;
|
2012-07-23 17:11:53 +02:00
|
|
|
int m_vocation;
|
2012-07-30 12:59:08 +02:00
|
|
|
int m_walkLockInterval;
|
2012-02-09 04:45:19 +01:00
|
|
|
|
|
|
|
double m_health;
|
|
|
|
double m_maxHealth;
|
|
|
|
double m_freeCapacity;
|
|
|
|
double m_experience;
|
|
|
|
double m_level;
|
|
|
|
double m_levelPercent;
|
|
|
|
double m_mana;
|
|
|
|
double m_maxMana;
|
|
|
|
double m_magicLevel;
|
|
|
|
double m_magicLevelPercent;
|
|
|
|
double m_soul;
|
|
|
|
double m_stamina;
|
2011-08-15 23:02:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|