tibia-client/src/client/localplayer.h

168 lines
6.2 KiB
C
Raw Normal View History

2011-08-28 15:17:58 +02:00
/*
2017-01-13 11:47:07 +01:00
* Copyright (c) 2010-2017 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 {
2013-03-04 22:56:22 +01:00
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();
void unlockWalk() { m_walkLockExpiration = 0; }
void lockWalk(int millis = 250);
void stopAutoWalk();
bool autoWalk(const Position& destination);
bool canWalk(Otc::Direction direction);
void setStates(int states);
void setSkill(Otc::Skill skill, int level, int levelPercent);
void setBaseSkill(Otc::Skill skill, int baseLevel);
void setHealth(double health, double maxHealth);
void setFreeCapacity(double freeCapacity);
void setTotalCapacity(double totalCapacity);
void setExperience(double experience);
void setLevel(double level, double levelPercent);
void setMana(double mana, double maxMana);
void setMagicLevel(double magicLevel, double magicLevelPercent);
void setBaseMagicLevel(double baseMagicLevel);
void setSoul(double soul);
void setStamina(double stamina);
2012-01-17 06:36:25 +01:00
void setKnown(bool known) { m_known = known; }
void setPendingGame(bool pending) { m_pending = pending; }
2012-07-18 08:04:57 +02:00
void setInventoryItem(Otc::InventorySlot inventory, const ItemPtr& item);
void setVocation(int vocation);
void setPremium(bool premium);
void setRegenerationTime(double regenerationTime);
void setOfflineTrainingTime(double offlineTrainingTime);
2012-08-19 11:46:24 +02:00
void setSpells(const std::vector<int>& spells);
void setBlessings(int blessings);
2012-01-07 23:24:29 +01:00
int getStates() { return m_states; }
int getSkillLevel(Otc::Skill skill) { return m_skillsLevel[skill]; }
int getSkillBaseLevel(Otc::Skill skill) { return m_skillsBaseLevel[skill]; }
int getSkillLevelPercent(Otc::Skill skill) { return m_skillsLevelPercent[skill]; }
int getVocation() { return m_vocation; }
double getHealth() { return m_health; }
double getMaxHealth() { return m_maxHealth; }
double getFreeCapacity() { return m_freeCapacity; }
double getTotalCapacity() { return m_totalCapacity; }
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 getBaseMagicLevel() { return m_baseMagicLevel; }
double getSoul() { return m_soul; }
double getStamina() { return m_stamina; }
double getRegenerationTime() { return m_regenerationTime; }
double getOfflineTrainingTime() { return m_offlineTrainingTime; }
2012-08-19 11:46:24 +02:00
std::vector<int> getSpells() { return m_spells; }
2012-07-18 08:04:57 +02:00
ItemPtr getInventoryItem(Otc::InventorySlot inventory) { return m_inventoryItems[inventory]; }
int getBlessings() { return m_blessings; }
2012-01-07 23:24:29 +01:00
bool hasSight(const Position& pos);
2012-01-17 06:36:25 +01:00
bool isKnown() { return m_known; }
bool isPreWalking() { return m_preWalking; }
bool isAutoWalking() { return m_autoWalkDestination.isValid(); }
bool isServerWalking() { return m_serverWalking; }
bool isPremium() { return m_premium; }
bool isPendingGame() { return m_pending; }
2011-11-03 20:26:53 +01:00
LocalPlayerPtr asLocalPlayer() { return static_self_cast<LocalPlayer>(); }
2012-06-05 17:36:27 +02:00
bool isLocalPlayer() { return true; }
virtual void onAppear();
virtual void onPositionChange(const Position& newPos, const Position& oldPos);
protected:
2012-01-19 05:12:53 +01:00
void walk(const Position& oldPos, const Position& newPos);
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
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
Position m_lastPrewalkDestination;
Position m_autoWalkDestination;
Position m_lastAutoWalkPosition;
ScheduledEventPtr m_serverWalkEndEvent;
2013-01-22 19:04:36 +01:00
ScheduledEventPtr m_autoWalkContinueEvent;
ticks_t m_walkLockExpiration;
stdext::boolean<false> m_preWalking;
stdext::boolean<true> m_lastPrewalkDone;
2013-03-14 00:55:20 +01:00
stdext::boolean<false> m_secondPreWalk;
stdext::boolean<false> m_serverWalking;
2013-01-27 19:58:22 +01:00
stdext::boolean<false> m_knownCompletePath;
stdext::boolean<false> m_premium;
stdext::boolean<false> m_known;
stdext::boolean<false> m_pending;
ItemPtr m_inventoryItems[Otc::LastInventorySlot];
Timer m_idleTimer;
2012-01-19 05:12:53 +01:00
std::array<int, Otc::LastSkill> m_skillsLevel;
std::array<int, Otc::LastSkill> m_skillsBaseLevel;
std::array<int, Otc::LastSkill> m_skillsLevelPercent;
2012-08-19 11:46:24 +02:00
std::vector<int> m_spells;
int m_states;
int m_vocation;
int m_blessings;
double m_health;
double m_maxHealth;
double m_freeCapacity;
double m_totalCapacity;
double m_experience;
double m_level;
double m_levelPercent;
double m_mana;
double m_maxMana;
double m_magicLevel;
double m_magicLevelPercent;
double m_baseMagicLevel;
double m_soul;
double m_stamina;
double m_regenerationTime;
double m_offlineTrainingTime;
2011-08-15 23:02:52 +02:00
};
#endif