tibia-client/src/otclient/core/creature.h

129 lines
4.4 KiB
C
Raw Normal View History

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 16:11:24 +02:00
#ifndef CREATURE_H
#define CREATURE_H
#include "thing.h"
2011-11-13 09:46:19 +01:00
#include "outfit.h"
2011-08-29 05:05:57 +02:00
#include <framework/graphics/fontmanager.h>
2011-08-15 16:11:24 +02:00
class Creature : public Thing
{
public:
2012-01-05 15:24:38 +01:00
enum {
2012-01-11 23:31:23 +01:00
SHIELD_BLINK_TICKS = 500,
2012-01-10 01:36:18 +01:00
INVISIBLE_TICKS = 500,
2012-01-05 15:24:38 +01:00
VOLATILE_SQUARE_DURATION = 1000
};
2011-08-15 16:11:24 +02:00
Creature();
2011-08-15 23:02:52 +02:00
virtual ~Creature() { }
2011-08-15 16:11:24 +02:00
2012-01-05 19:34:37 +01:00
virtual void draw(const Point& p, const Rect&);
void drawInformation(int x, int y, bool useGray, const Rect& visibleRect);
2011-08-15 16:11:24 +02:00
2011-11-13 09:46:19 +01:00
void setName(const std::string& name);
2011-08-29 05:05:57 +02:00
void setHealthPercent(uint8 healthPercent);
2011-11-06 22:45:42 +01:00
void setDirection(Otc::Direction direction);
2011-12-02 03:29:05 +01:00
void setOutfit(const Outfit& outfit);
void setLight(const Light& light) { m_light = light; }
void setSpeed(uint16 speed) { m_speed = speed; }
void setSkull(uint8 skull);
void setShield(uint8 shield);
void setEmblem(uint8 emblem);
void setSkullTexture(const std::string& filename);
2012-01-11 23:31:23 +01:00
void setShieldTexture(const std::string& filename, bool blink);
void setEmblemTexture(const std::string& filename);
2011-12-30 15:15:23 +01:00
void setPassable(bool passable) { m_passable = passable; }
2012-01-05 15:24:38 +01:00
void addVolatileSquare(uint8 color);
void removeVolatileSquare() { m_showVolatileSquare = false; }
2012-01-06 18:29:18 +01:00
void showStaticSquare(const Color& color) { m_showStaticSquare = true; m_staticSquareColor = color; }
void hideStaticSquare() { m_showStaticSquare = false; }
2011-08-15 16:11:24 +02:00
2011-08-15 23:02:52 +02:00
std::string getName() { return m_name; }
uint8 getHealthPercent() { return m_healthPercent; }
Otc::Direction getDirection() { return m_direction; }
Outfit getOutfit() { return m_outfit; }
Light getLight() { return m_light; }
uint16 getSpeed() { return m_speed; }
uint8 getSkull() { return m_skull; }
uint8 getShield() { return m_shield; }
uint8 getEmblem() { return m_emblem; }
2011-12-30 15:15:23 +01:00
bool getPassable() { return m_passable; }
2012-01-10 01:36:18 +01:00
void updateAnimation();
2012-01-11 23:31:23 +01:00
void updateShield();
2012-01-10 01:36:18 +01:00
2011-12-02 03:29:05 +01:00
ThingType *getType();
2011-08-29 05:05:57 +02:00
2012-01-09 06:23:39 +01:00
//virtual void walk(const Position& oldPos, const Position& newPos, bool inverse = true);
2011-11-05 21:34:49 +01:00
virtual void walk(const Position& position, bool inverse = true);
2011-12-28 12:00:09 +01:00
void turn(Otc::Direction direction);
2011-12-29 08:08:02 +01:00
virtual void cancelWalk(Otc::Direction direction, bool force = false);
2011-11-08 02:44:30 +01:00
Point getWalkOffset() { return m_walkOffset; }
2011-09-01 16:49:51 +02:00
bool isWalking() { return m_walking; }
2011-08-15 23:02:52 +02:00
CreaturePtr asCreature() { return std::static_pointer_cast<Creature>(shared_from_this()); }
2011-08-15 16:11:24 +02:00
2011-11-05 21:34:49 +01:00
protected:
void updateWalk();
2011-08-15 16:11:24 +02:00
std::string m_name;
2011-11-13 09:46:19 +01:00
Size m_nameSize;
2011-08-15 16:11:24 +02:00
uint8 m_healthPercent;
Otc::Direction m_direction;
2011-08-15 16:11:24 +02:00
Outfit m_outfit;
Light m_light;
uint16 m_speed;
uint8 m_skull, m_shield, m_emblem;
TexturePtr m_skullTexture, m_shieldTexture, m_emblemTexture;
2012-01-11 23:31:23 +01:00
bool m_showShieldTexture, m_shieldBlink;
2011-12-30 15:15:23 +01:00
bool m_passable;
2012-01-05 15:24:38 +01:00
Color m_volatileSquareColor, m_staticSquareColor;
bool m_showVolatileSquare, m_showStaticSquare;
2011-08-29 05:05:57 +02:00
FontPtr m_informationFont;
Color m_informationColor;
2011-12-28 12:00:09 +01:00
ticks_t m_walkStart, m_walkEnd;
2011-11-05 21:34:49 +01:00
bool m_walking, m_inverseWalking;
2011-08-29 02:38:26 +02:00
float m_walkTimePerPixel;
2011-11-08 02:44:30 +01:00
Point m_walkOffset;
2011-12-28 12:00:09 +01:00
Otc::Direction m_turnDirection;
2011-08-15 16:11:24 +02:00
};
2012-01-09 06:23:39 +01:00
class Npc : public Creature {
public:
NpcPtr asNpc() { return std::static_pointer_cast<Npc>(shared_from_this()); }
};
class Monster : public Creature {
public:
MonsterPtr asMonster() { return std::static_pointer_cast<Monster>(shared_from_this()); }
};
2011-08-15 23:02:52 +02:00
#endif