2011-08-28 15:17:58 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2010-2011 OTClient <https://github.com/edubart/otclient>
|
|
|
|
*
|
|
|
|
* 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-24 05:58:23 +02:00
|
|
|
#include "creature.h"
|
2011-08-31 17:03:33 +02:00
|
|
|
#include "thingstype.h"
|
2011-08-26 07:07:23 +02:00
|
|
|
#include "localplayer.h"
|
|
|
|
#include "map.h"
|
2011-08-31 22:22:57 +02:00
|
|
|
#include "tile.h"
|
|
|
|
#include "item.h"
|
|
|
|
|
2011-08-15 16:11:24 +02:00
|
|
|
#include <framework/graphics/graphics.h>
|
2011-11-05 22:37:36 +01:00
|
|
|
#include <framework/core/eventdispatcher.h>
|
2011-12-01 23:25:32 +01:00
|
|
|
#include <framework/core/clock.h>
|
2011-08-15 16:11:24 +02:00
|
|
|
|
2011-08-31 22:22:57 +02:00
|
|
|
Creature::Creature() : Thing()
|
2011-08-15 16:11:24 +02:00
|
|
|
{
|
2011-08-15 23:02:52 +02:00
|
|
|
m_healthPercent = 0;
|
2011-11-13 23:23:21 +01:00
|
|
|
m_showSquareColor = false;
|
2011-08-28 18:02:26 +02:00
|
|
|
m_direction = Otc::South;
|
2011-12-01 23:25:32 +01:00
|
|
|
m_walkTimePerPixel = 1000.0/32.0;
|
2011-08-26 07:07:23 +02:00
|
|
|
|
|
|
|
m_walking = false;
|
2011-08-29 02:38:26 +02:00
|
|
|
|
2011-11-01 03:35:50 +01:00
|
|
|
m_informationFont = g_fonts.getFont("verdana-11px-rounded");
|
2011-08-15 16:11:24 +02:00
|
|
|
}
|
|
|
|
|
2011-11-08 02:44:30 +01:00
|
|
|
void Creature::draw(const Point& p)
|
2011-08-15 16:11:24 +02:00
|
|
|
{
|
2011-11-13 23:23:21 +01:00
|
|
|
// TODO: activate on attack, follow, discover how 'attacked' works
|
|
|
|
if(m_showSquareColor) {
|
|
|
|
g_graphics.bindColor(Outfit::getColor(m_squareColor));
|
|
|
|
g_graphics.drawBoundingRect(Rect(p + m_walkOffset - 8, Size(32, 32)), 2);
|
|
|
|
}
|
|
|
|
|
2011-08-29 02:38:26 +02:00
|
|
|
// Render creature
|
2011-12-02 03:29:05 +01:00
|
|
|
for(m_yPattern = 0; m_yPattern < m_type->dimensions[ThingType::PatternY]; m_yPattern++) {
|
2011-08-24 05:58:23 +02:00
|
|
|
|
|
|
|
// continue if we dont have this addon.
|
2011-11-13 09:46:19 +01:00
|
|
|
if(m_yPattern > 0 && !(m_outfit.getAddons() & (1 << (m_yPattern-1))))
|
2011-08-24 05:58:23 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// draw white item
|
2011-11-13 23:23:21 +01:00
|
|
|
g_graphics.bindColor(Fw::white);
|
2011-11-08 02:44:30 +01:00
|
|
|
internalDraw(p + m_walkOffset, 0);
|
2011-08-24 05:58:23 +02:00
|
|
|
|
|
|
|
// draw mask if exists
|
2011-12-02 03:29:05 +01:00
|
|
|
if(m_type->dimensions[ThingType::Layers] > 1) {
|
2011-08-28 20:06:47 +02:00
|
|
|
// switch to blend color mode
|
2011-08-28 18:02:26 +02:00
|
|
|
g_graphics.bindBlendFunc(Fw::BlendColorzing);
|
2011-08-19 14:26:26 +02:00
|
|
|
|
2011-08-28 20:06:47 +02:00
|
|
|
// head
|
2011-11-14 23:47:36 +01:00
|
|
|
g_graphics.bindColor(m_outfit.getHeadColor());
|
2011-11-08 02:44:30 +01:00
|
|
|
internalDraw(p + m_walkOffset, 1, Otc::SpriteYellowMask);
|
2011-08-24 05:58:23 +02:00
|
|
|
|
2011-08-28 20:06:47 +02:00
|
|
|
// body
|
2011-11-14 23:47:36 +01:00
|
|
|
g_graphics.bindColor(m_outfit.getBodyColor());
|
2011-11-08 02:44:30 +01:00
|
|
|
internalDraw(p + m_walkOffset, 1, Otc::SpriteRedMask);
|
2011-08-24 05:58:23 +02:00
|
|
|
|
2011-08-28 20:06:47 +02:00
|
|
|
// legs
|
2011-11-14 23:47:36 +01:00
|
|
|
g_graphics.bindColor(m_outfit.getLegsColor());
|
2011-11-08 02:44:30 +01:00
|
|
|
internalDraw(p + m_walkOffset, 1, Otc::SpriteGreenMask);
|
2011-08-24 05:58:23 +02:00
|
|
|
|
2011-08-28 20:06:47 +02:00
|
|
|
// feet
|
2011-11-14 23:47:36 +01:00
|
|
|
g_graphics.bindColor(m_outfit.getFeetColor());
|
2011-11-08 02:44:30 +01:00
|
|
|
internalDraw(p + m_walkOffset, 1, Otc::SpriteBlueMask);
|
2011-08-28 20:06:47 +02:00
|
|
|
|
|
|
|
// restore default blend func
|
|
|
|
g_graphics.bindBlendFunc(Fw::BlendDefault);
|
2011-08-28 18:02:26 +02:00
|
|
|
g_graphics.bindColor(Fw::white);
|
2011-08-24 05:58:23 +02:00
|
|
|
}
|
2011-08-19 14:26:26 +02:00
|
|
|
}
|
2011-08-21 05:21:35 +02:00
|
|
|
}
|
2011-08-19 15:23:35 +02:00
|
|
|
|
2011-11-04 05:53:00 +01:00
|
|
|
void Creature::drawInformation(int x, int y, bool useGray, const Rect& rect)
|
2011-08-21 05:21:35 +02:00
|
|
|
{
|
2011-08-21 21:09:23 +02:00
|
|
|
Color fillColor = Color(96, 96, 96);
|
|
|
|
|
2011-08-29 05:05:57 +02:00
|
|
|
if(!useGray)
|
|
|
|
fillColor = m_informationColor;
|
2011-08-19 15:23:35 +02:00
|
|
|
|
2011-11-04 05:53:00 +01:00
|
|
|
// calculate main rects
|
|
|
|
Rect backgroundRect = Rect(x-(13.5), y, 27, 4);
|
2011-11-06 05:12:13 +01:00
|
|
|
backgroundRect.bound(rect);
|
2011-11-04 05:53:00 +01:00
|
|
|
|
2011-11-13 09:46:19 +01:00
|
|
|
Rect textRect = Rect(x - m_nameSize.width() / 2.0, y-15, m_nameSize);
|
2011-11-06 05:12:13 +01:00
|
|
|
textRect.bound(rect);
|
2011-11-04 05:53:00 +01:00
|
|
|
|
|
|
|
// distance them
|
|
|
|
if(textRect.top() == rect.top())
|
|
|
|
backgroundRect.moveTop(textRect.top() + 15);
|
|
|
|
if(backgroundRect.bottom() == rect.bottom())
|
|
|
|
textRect.moveTop(backgroundRect.top() - 15);
|
|
|
|
|
|
|
|
// health rect is based on background rect, so no worries
|
2011-08-21 21:09:23 +02:00
|
|
|
Rect healthRect = backgroundRect.expanded(-1);
|
2011-11-04 05:53:00 +01:00
|
|
|
healthRect.setWidth((m_healthPercent / 100.0) * 25);
|
2011-08-20 22:30:41 +02:00
|
|
|
|
2011-11-04 05:53:00 +01:00
|
|
|
// draw
|
2011-08-28 18:02:26 +02:00
|
|
|
g_graphics.bindColor(Fw::black);
|
2011-08-21 21:09:23 +02:00
|
|
|
g_graphics.drawFilledRect(backgroundRect);
|
2011-08-20 22:30:41 +02:00
|
|
|
|
2011-08-21 21:09:23 +02:00
|
|
|
g_graphics.bindColor(fillColor);
|
|
|
|
g_graphics.drawFilledRect(healthRect);
|
2011-08-20 22:30:41 +02:00
|
|
|
|
2011-11-04 05:53:00 +01:00
|
|
|
m_informationFont->renderText(m_name, textRect, Fw::AlignTopCenter, fillColor);
|
2011-08-15 16:11:24 +02:00
|
|
|
}
|
2011-08-15 23:02:52 +02:00
|
|
|
|
2011-11-05 21:34:49 +01:00
|
|
|
void Creature::walk(const Position& position, bool inverse)
|
2011-08-26 07:07:23 +02:00
|
|
|
{
|
2011-08-26 17:44:29 +02:00
|
|
|
// set walking state
|
2011-11-05 22:01:41 +01:00
|
|
|
bool sameWalk = m_walking && !m_inverseWalking && inverse;
|
2011-08-26 07:07:23 +02:00
|
|
|
m_walking = true;
|
2011-11-05 21:34:49 +01:00
|
|
|
m_inverseWalking = inverse;
|
2011-08-29 07:54:28 +02:00
|
|
|
int walkTimeFactor = 1;
|
2011-08-26 17:44:29 +02:00
|
|
|
|
|
|
|
// set new direction
|
2011-08-30 16:37:48 +02:00
|
|
|
if(m_position + Position(0, -1, 0) == position) {
|
2011-11-06 22:45:42 +01:00
|
|
|
setDirection(Otc::North);
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.y = 32;
|
2011-08-26 17:44:29 +02:00
|
|
|
}
|
2011-08-30 16:37:48 +02:00
|
|
|
else if(m_position + Position(1, 0, 0) == position) {
|
2011-11-06 22:45:42 +01:00
|
|
|
setDirection(Otc::East);
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.x = -32;
|
2011-08-26 17:44:29 +02:00
|
|
|
}
|
2011-08-30 16:37:48 +02:00
|
|
|
else if(m_position + Position(0, 1, 0) == position) {
|
2011-11-06 22:45:42 +01:00
|
|
|
setDirection(Otc::South);
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.y = -32;
|
2011-08-26 17:44:29 +02:00
|
|
|
}
|
2011-08-30 16:37:48 +02:00
|
|
|
else if(m_position + Position(-1, 0, 0) == position) {
|
2011-11-06 22:45:42 +01:00
|
|
|
setDirection(Otc::West);
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.x = 32;
|
2011-08-26 17:44:29 +02:00
|
|
|
}
|
2011-08-30 16:37:48 +02:00
|
|
|
else if(m_position + Position(1, -1, 0) == position) {
|
2011-11-06 22:45:42 +01:00
|
|
|
setDirection(Otc::NorthEast);
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.x = -32;
|
|
|
|
m_walkOffset.y = 32;
|
2011-08-29 07:54:28 +02:00
|
|
|
walkTimeFactor = 2;
|
|
|
|
}
|
2011-08-30 16:37:48 +02:00
|
|
|
else if(m_position + Position(1, 1, 0) == position) {
|
2011-11-06 22:45:42 +01:00
|
|
|
setDirection(Otc::SouthEast);
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.x = -32;
|
|
|
|
m_walkOffset.y = -32;
|
2011-08-29 07:54:28 +02:00
|
|
|
walkTimeFactor = 2;
|
|
|
|
}
|
2011-08-30 16:37:48 +02:00
|
|
|
else if(m_position + Position(-1, 1, 0) == position) {
|
2011-11-06 22:45:42 +01:00
|
|
|
setDirection(Otc::SouthWest);
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.x = 32;
|
|
|
|
m_walkOffset.y = -32;
|
2011-08-29 07:54:28 +02:00
|
|
|
walkTimeFactor = 2;
|
|
|
|
}
|
2011-08-30 16:37:48 +02:00
|
|
|
else if(m_position + Position(-1, -1, 0) == position) {
|
2011-11-06 22:45:42 +01:00
|
|
|
setDirection(Otc::NorthWest);
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.x = 32;
|
|
|
|
m_walkOffset.y = 32;
|
2011-08-29 07:54:28 +02:00
|
|
|
walkTimeFactor = 2;
|
|
|
|
}
|
2011-08-26 07:07:23 +02:00
|
|
|
else { // Teleport
|
2011-08-26 17:44:29 +02:00
|
|
|
// we teleported, dont walk or change direction
|
2011-08-26 07:07:23 +02:00
|
|
|
m_walking = false;
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.x = 0;
|
|
|
|
m_walkOffset.y = 0;
|
2011-11-05 22:37:36 +01:00
|
|
|
m_animation = 0;
|
2011-08-26 07:07:23 +02:00
|
|
|
}
|
2011-08-26 17:44:29 +02:00
|
|
|
|
2011-11-05 21:34:49 +01:00
|
|
|
if(!m_inverseWalking) {
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.x = 0;
|
|
|
|
m_walkOffset.y = 0;
|
2011-11-05 21:34:49 +01:00
|
|
|
}
|
2011-08-29 07:54:28 +02:00
|
|
|
|
2011-08-30 16:37:48 +02:00
|
|
|
if(m_walking) {
|
|
|
|
// get walk speed
|
2011-11-05 22:01:41 +01:00
|
|
|
int groundSpeed = 100;
|
2011-08-26 17:44:29 +02:00
|
|
|
|
2011-09-01 00:08:55 +02:00
|
|
|
ItemPtr ground = g_map.getTile(position)->getGround();
|
2011-08-30 16:37:48 +02:00
|
|
|
if(ground)
|
2011-12-02 03:29:05 +01:00
|
|
|
groundSpeed = ground->getType()->parameters[ThingType::GroundSpeed];
|
2011-08-26 17:44:29 +02:00
|
|
|
|
2011-08-30 16:37:48 +02:00
|
|
|
float walkTime = walkTimeFactor * 1000.0 * (float)groundSpeed / m_speed;
|
2011-11-05 22:01:41 +01:00
|
|
|
walkTime = (walkTime == 0) ? 1000 : walkTime;
|
2011-08-29 02:38:26 +02:00
|
|
|
|
2011-08-30 16:37:48 +02:00
|
|
|
m_walkTimePerPixel = walkTime / 32.0;
|
2011-11-05 22:01:41 +01:00
|
|
|
if(!sameWalk)
|
2011-12-01 23:25:32 +01:00
|
|
|
m_walkStartTicks = g_clock.ticks();
|
2011-11-05 22:43:13 +01:00
|
|
|
updateWalk();
|
2011-11-05 22:37:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Creature::updateWalk()
|
|
|
|
{
|
|
|
|
if(m_walking) {
|
2011-12-01 23:25:32 +01:00
|
|
|
int elapsedTicks = g_clock.ticks() - m_walkStartTicks;
|
2011-11-29 00:10:16 +01:00
|
|
|
int totalPixelsWalked = std::min((int)round(elapsedTicks / m_walkTimePerPixel), 32);
|
2011-11-05 22:37:36 +01:00
|
|
|
|
|
|
|
if(m_inverseWalking) {
|
|
|
|
if(m_direction == Otc::North || m_direction == Otc::NorthEast || m_direction == Otc::NorthWest)
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.y = 32 - totalPixelsWalked;
|
2011-11-05 22:37:36 +01:00
|
|
|
else if(m_direction == Otc::South || m_direction == Otc::SouthEast || m_direction == Otc::SouthWest)
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.y = totalPixelsWalked - 32;
|
2011-11-05 22:37:36 +01:00
|
|
|
|
|
|
|
if(m_direction == Otc::East || m_direction == Otc::NorthEast || m_direction == Otc::SouthEast)
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.x = totalPixelsWalked - 32;
|
2011-11-05 22:37:36 +01:00
|
|
|
else if(m_direction == Otc::West || m_direction == Otc::NorthWest || m_direction == Otc::SouthWest)
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.x = 32 - totalPixelsWalked;
|
2011-11-05 22:37:36 +01:00
|
|
|
|
2011-11-08 02:44:30 +01:00
|
|
|
if(m_walkOffset.x == 0 && m_walkOffset.y == 0)
|
2011-11-05 22:37:36 +01:00
|
|
|
cancelWalk(m_direction);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(m_direction == Otc::North || m_direction == Otc::NorthEast || m_direction == Otc::NorthWest)
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.y = -totalPixelsWalked;
|
2011-11-05 22:37:36 +01:00
|
|
|
else if(m_direction == Otc::South || m_direction == Otc::SouthEast || m_direction == Otc::SouthWest)
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.y = totalPixelsWalked;
|
2011-11-05 22:37:36 +01:00
|
|
|
|
|
|
|
if(m_direction == Otc::East || m_direction == Otc::NorthEast || m_direction == Otc::SouthEast)
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.x = totalPixelsWalked;
|
2011-11-05 22:37:36 +01:00
|
|
|
else if(m_direction == Otc::West || m_direction == Otc::NorthWest || m_direction == Otc::SouthWest)
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.x = -totalPixelsWalked;
|
2011-11-05 22:37:36 +01:00
|
|
|
}
|
|
|
|
|
2011-11-06 05:12:13 +01:00
|
|
|
int totalWalkTileTicks = (int)m_walkTimePerPixel*32 * 0.5;
|
2011-12-02 03:29:05 +01:00
|
|
|
if(m_type->dimensions[ThingType::AnimationPhases] > 0)
|
|
|
|
m_animation = (g_clock.ticks() % totalWalkTileTicks) / (totalWalkTileTicks / (m_type->dimensions[ThingType::AnimationPhases] - 1)) + 1;
|
2011-12-01 23:25:32 +01:00
|
|
|
else
|
|
|
|
m_animation = 0;
|
2011-11-05 22:37:36 +01:00
|
|
|
g_dispatcher.scheduleEvent(std::bind(&Creature::updateWalk, asCreature()), m_walkTimePerPixel);
|
|
|
|
|
|
|
|
if(totalPixelsWalked == 32)
|
|
|
|
cancelWalk(m_direction);
|
2011-08-30 16:37:48 +02:00
|
|
|
}
|
|
|
|
}
|
2011-08-29 02:38:26 +02:00
|
|
|
|
2011-08-30 16:37:48 +02:00
|
|
|
void Creature::cancelWalk(Otc::Direction direction)
|
|
|
|
{
|
2011-12-01 23:25:32 +01:00
|
|
|
if(m_walking) {
|
|
|
|
auto self = asCreature();
|
|
|
|
g_dispatcher.scheduleEvent([=]() {
|
|
|
|
if(!self->m_walking)
|
|
|
|
self->m_animation = 0;
|
|
|
|
}, m_walkTimePerPixel * 2);
|
|
|
|
}
|
|
|
|
|
2011-08-30 16:37:48 +02:00
|
|
|
m_walking = false;
|
2011-11-05 22:37:36 +01:00
|
|
|
m_walkStartTicks = 0;
|
2011-11-08 02:44:30 +01:00
|
|
|
m_walkOffset.x = 0;
|
|
|
|
m_walkOffset.y = 0;
|
2011-08-30 16:37:48 +02:00
|
|
|
m_direction = direction;
|
2011-08-26 07:07:23 +02:00
|
|
|
}
|
|
|
|
|
2011-11-13 09:46:19 +01:00
|
|
|
void Creature::setName(const std::string& name)
|
2011-08-15 23:02:52 +02:00
|
|
|
{
|
2011-11-13 09:46:19 +01:00
|
|
|
m_nameSize = m_informationFont->calculateTextRectSize(name);
|
|
|
|
m_name = name;
|
2011-08-15 23:02:52 +02:00
|
|
|
}
|
2011-08-29 05:05:57 +02:00
|
|
|
|
2011-11-13 09:46:19 +01:00
|
|
|
void Creature::setHealthPercent(uint8 healthPercent)
|
2011-08-29 05:05:57 +02:00
|
|
|
{
|
|
|
|
m_informationColor = Fw::black;
|
|
|
|
|
2011-11-13 09:46:19 +01:00
|
|
|
if(healthPercent > 92) {
|
2011-08-29 05:05:57 +02:00
|
|
|
m_informationColor.setGreen(188);
|
|
|
|
}
|
2011-11-13 09:46:19 +01:00
|
|
|
else if(healthPercent > 60) {
|
2011-08-29 05:05:57 +02:00
|
|
|
m_informationColor.setRed(80);
|
|
|
|
m_informationColor.setGreen(161);
|
|
|
|
m_informationColor.setBlue(80);
|
|
|
|
}
|
2011-11-13 09:46:19 +01:00
|
|
|
else if(healthPercent > 30) {
|
2011-08-29 05:05:57 +02:00
|
|
|
m_informationColor.setRed(161);
|
|
|
|
m_informationColor.setGreen(161);
|
|
|
|
}
|
2011-11-13 09:46:19 +01:00
|
|
|
else if(healthPercent > 8) {
|
2011-08-29 05:05:57 +02:00
|
|
|
m_informationColor.setRed(160);
|
|
|
|
m_informationColor.setGreen(39);
|
|
|
|
m_informationColor.setBlue(39);
|
|
|
|
}
|
2011-11-13 09:46:19 +01:00
|
|
|
else if(healthPercent > 3) {
|
2011-08-29 05:05:57 +02:00
|
|
|
m_informationColor.setRed(160);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_informationColor.setRed(79);
|
|
|
|
}
|
2011-11-13 09:46:19 +01:00
|
|
|
|
|
|
|
m_healthPercent = healthPercent;
|
2011-08-29 05:05:57 +02:00
|
|
|
}
|
2011-11-06 22:45:42 +01:00
|
|
|
|
2011-11-13 09:46:19 +01:00
|
|
|
void Creature::setDirection(Otc::Direction direction)
|
2011-11-06 22:45:42 +01:00
|
|
|
{
|
2011-11-13 09:46:19 +01:00
|
|
|
if(direction >= 4) {
|
|
|
|
if(direction == Otc::NorthEast || direction == Otc::SouthEast)
|
2011-11-06 22:45:42 +01:00
|
|
|
m_xPattern = Otc::East;
|
2011-11-13 09:46:19 +01:00
|
|
|
else if(direction == Otc::NorthWest || direction == Otc::SouthWest)
|
2011-11-06 22:45:42 +01:00
|
|
|
m_xPattern = Otc::West;
|
|
|
|
}
|
|
|
|
else {
|
2011-11-13 09:46:19 +01:00
|
|
|
m_xPattern = direction;
|
2011-11-06 22:45:42 +01:00
|
|
|
}
|
2011-11-13 09:46:19 +01:00
|
|
|
|
|
|
|
m_direction = direction;
|
|
|
|
}
|
|
|
|
|
2011-12-02 03:29:05 +01:00
|
|
|
void Creature::setOutfit(const Outfit& outfit)
|
|
|
|
{
|
|
|
|
m_outfit = outfit;
|
|
|
|
m_type = getType();
|
|
|
|
}
|
|
|
|
|
|
|
|
ThingType *Creature::getType()
|
2011-11-13 09:46:19 +01:00
|
|
|
{
|
|
|
|
return g_thingsType.getThingType(m_outfit.getType(), ThingsType::Creature);
|
2011-11-06 22:45:42 +01:00
|
|
|
}
|