Go to the documentation of this file.
101 lightView->
addLightSource(dest + (animationOffset +
Point(16,16)) * scaleFactor, scaleFactor, light);
125 xPattern = direction;
130 dest -= datType->getDisplacement() * scaleFactor;
131 datType->draw(dest, scaleFactor, 0, xPattern, 0, 0, animationPhase, lightView);
147 datType->draw(dest, scaleFactor, 0, xPattern, yPattern, zPattern, animationPhase, yPattern == 0 ? lightView :
nullptr);
154 datType->draw(dest, scaleFactor,
SpriteMaskYellow, xPattern, yPattern, zPattern, animationPhase);
156 datType->draw(dest, scaleFactor,
SpriteMaskRed, xPattern, yPattern, zPattern, animationPhase);
158 datType->draw(dest, scaleFactor,
SpriteMaskGreen, xPattern, yPattern, zPattern, animationPhase);
160 datType->draw(dest, scaleFactor,
SpriteMaskBlue, xPattern, yPattern, zPattern, animationPhase);
169 int animationPhase = 0;
176 animationPhases = std::max<int>(1, animationPhases-2);
180 if(animationPhases > 1) {
182 animationPhase = (
g_clock.
millis() % (animateTicks * animationPhases)) / animateTicks;
184 animationPhase = animationPhases-1;
188 animationPhase = std::min<int>(animationPhase+1, animationPhases);
190 type->
draw(dest - (
getDisplacement() * scaleFactor), scaleFactor, 0, 0, 0, 0, animationPhase, lightView);
207 else if(!(frameSize = exactSize))
212 outfitBuffer->
resize(
Size(frameSize, frameSize));
213 outfitBuffer->
bind();
218 outfitBuffer->
draw(destRect,
Rect(0,0,frameSize,frameSize));
220 float scaleFactor = destRect.
width() / (float)frameSize;
237 Rect backgroundRect =
Rect(point.
x-(13.5), point.
y, 27, 4);
238 backgroundRect.
bind(parentRect);
241 Rect textRect =
Rect(point.
x - nameSize.
width() / 2.0, point.
y-12, nameSize);
242 textRect.
bind(parentRect);
250 if(textRect.
top() == parentRect.
top())
251 backgroundRect.
moveTop(textRect.
top() + offset);
253 textRect.
moveTop(backgroundRect.
top() - offset);
261 fillColor =
Color(0x66, 0xcc, 0xff);
392 double height = a*t*t + b*t;
408 nextT =
stdext::round((-b + std::sqrt(std::max<double>(b*b + 4*a*(roundHeight+diff*i), 0.0)) * diff) / (2*a));
411 if(nextT < halfJumpDuration)
413 else if(nextT > halfJumpDuration)
417 auto self = static_self_cast<Creature>();
466 auto self = static_self_cast<Creature>();
468 self->m_removed =
true;
471 self->callLuaField(
"onDisappear");
474 if(!self->isLocalPlayer())
477 self->m_disappearEvent =
nullptr;
499 if(footAnimPhases == 0)
511 auto self = static_self_cast<Creature>();
513 if(!self->m_walking || self->m_walkTimer.ticksElapsed() >= self->getStepDuration(
true))
514 self->m_walkAnimationPhase = 0;
515 self->m_walkFinishAnimEvent =
nullptr;
516 }, std::min<int>(footDelay, 200));
542 for(
int xi = -1; xi <= 1 && !newWalkingTile; ++xi) {
543 for(
int yi = -1; yi <= 1 && !newWalkingTile; ++yi) {
578 auto self = static_self_cast<Creature>();
580 self->m_walkUpdateEvent =
nullptr;
581 self->nextWalkUpdate();
639 if(healthPercent > 92)
641 else if(healthPercent > 60)
643 else if(healthPercent > 30)
645 else if(healthPercent > 8)
647 else if(healthPercent > 3)
655 if(healthPercent <= 0)
704 auto self = static_self_cast<Creature>();
706 self->updateOutfitColor(color, finalColor, delta, duration);
732 callLuaField(
"onBaseSpeedChange", baseSpeed, oldBaseSpeed);
777 auto self = static_self_cast<Creature>();
779 self->updateShield();
820 auto self = static_self_cast<Creature>();
822 self->removeTimedSquare();
831 auto self = static_self_cast<Creature>();
833 self->updateShield();
882 if(groundSpeed > 0 && speed > 0)
883 interval = 1000 * groundSpeed;
886 int formulatedSpeed = 1;
891 interval = std::floor(interval / (
double)formulatedSpeed);
966 for(layer = 0; layer <
getLayers(); ++layer)
967 exactSize = std::max<int>(exactSize,
Thing::getExactSize(layer, xPattern, yPattern, zPattern, animationPhase));
bool contains(const TPoint< T > &p, bool insideOnly=false) const
ThingType * rawGetThingType(uint16 id, ThingCategory category)
virtual void setAlphaWriting(bool enable)=0
Position translatedToDirection(Otc::Direction direction)
bool isInRange(const Position &pos, int xRange, int yRange) const
virtual void setColor(const Color &color)
stdext::boolean< false > m_footStepDrawn
void turn(Otc::Direction direction)
virtual void terminateWalk()
void setShield(uint8 shield)
Position m_lastStepFromPosition
void drawOutfit(const Rect &destRect, bool resize)
void setEmblemTexture(const std::string &filename)
const FrameBufferPtr & getTemporaryFrameBuffer()
const TilePtr & getTile()
EventPtr m_disappearEvent
virtual void setCompositionMode(CompositionMode compositionMode)=0
virtual Point getDisplacement()
virtual void clear(const Color &color)=0
CompositionMode getCompositionMode()
EventDispatcher g_dispatcher
void setSkullTexture(const std::string &filename)
void setDirection(Otc::Direction direction)
void addLightSource(const Point ¢er, float scaleFactor, const Light &light)
void bind(const TRect< T > &r)
void setIconTexture(const std::string &filename)
virtual void onPositionChange(const Position &newPos, const Position &oldPos)
const Position & getPosition()
Color m_staticSquareColor
void addTimedSquare(uint8 color)
virtual int getDisplacementX()
const TilePtr & getTile(const Position &pos)
void setCategory(ThingCategory category)
ScheduledEventPtr m_outfitColorUpdateEvent
void addWalkingCreature(const CreaturePtr &creature)
virtual int getExactSize(int layer=0, int xPattern=0, int yPattern=0, int zPattern=0, int animationPhase=0)
void setFont(const BitmapFontPtr &font)
virtual void onDisappear()
virtual int getDisplacementY()
void setText(const std::string &text)
void removeWalkingCreature(const CreaturePtr &creature)
void setSkull(uint8 skull)
@ INVISIBLE_TICKS_PER_FRAME
void drawInformation(const Point &point, bool useGray, const Rect &parentRect, int drawFlags)
Color getBodyColor() const
virtual void updateWalk()
virtual int getDisplacementX()
TexturePtr m_emblemTexture
Position m_lastStepToPosition
void setOutfitColor(const Color &color, int duration)
R callLuaField(const std::string &field, const T &... args)
virtual void nextWalkUpdate()
stdext::boolean< false > m_allowAppearWalk
void setTypeTexture(const std::string &filename)
void internalDrawOutfit(Point dest, float scaleFactor, bool animateWalk, bool animateIdle, Otc::Direction direction, LightView *lightView=nullptr)
TexturePtr m_skullTexture
Position translated(int dx, int dy, short dz=0) const
ScheduledEventPtr m_walkUpdateEvent
virtual void walk(const Position &oldPos, const Position &newPos)
void setName(const std::string &name)
virtual bool isLocalPlayer()
void setSpeed(uint16 speed)
void jump(int height, int duration)
std::array< double, Otc::LastSpeedFormula > m_speedFormula
EventPtr addEvent(const std::function< void()> &callback, bool pushFront=false)
void setAlign(Fw::AlignmentFlag align)
void updateOutfitColor(Color color, Color finalColor, Color delta, int duration)
TRect< T > expanded(T add) const
virtual void drawBoundingRect(const Rect &dest, int innerLineWidth=1)=0
TexturePtr m_shieldTexture
virtual void updateWalkOffset(int totalPixelsWalked)
const ThingTypePtr & getThingType(uint16 id, ThingCategory category)
bool getFeature(Otc::GameFeature feature)
stdext::boolean< false > m_showTimedSquare
void setShieldTexture(const std::string &filename, bool blink)
TexturePtr getTexture(const std::string &fileName)
stdext::boolean< true > m_removed
ScheduledEventPtr m_walkFinishAnimEvent
Otc::Direction getDirectionFromPosition(const Position &position) const
Otc::Direction m_direction
const TilePtr & getOrCreateTile(const Position &pos)
void draw(const Rect &rect)
virtual int getDisplacementY()
Color getHeadColor() const
virtual void updateWalkAnimation(int totalPixelsWalked)
void setSpeedFormula(double speedA, double speedB, double speedC)
@ VOLATILE_SQUARE_DURATION
void notificateTileUpdate(const Position &pos)
virtual Point getDisplacement()
virtual void draw(const Point &dest, float scaleFactor, bool animate, LightView *lightView=nullptr)
BitmapFontPtr getFont(const std::string &fontName)
void draw(const Point &dest, float scaleFactor, int layer, int xPattern, int yPattern, int zPattern, int animationPhase, LightView *lightView=nullptr)
virtual int getExactSize(int layer, int xPattern, int yPattern, int zPattern, int animationPhase)
LocalPlayerPtr getLocalPlayer()
Color getFeetColor() const
void resize(const Size &size)
stdext::boolean< false > m_walking
ThingCategory getCategory() const
int getStepDuration(bool ignoreDiagonal=false, Otc::Direction dir=Otc::InvalidDirection)
Otc::Direction m_lastStepDirection
Otc::Direction m_walkTurnDirection
stdext::boolean< false > m_showStaticSquare
@ CompositionMode_Multiply
Color getLegsColor() const
TextureManager g_textures
TPoint< T > bottomRight() const
void setHealthPercent(uint8 healthPercent)
static Color from8bit(int color)
FrameBufferManager g_framebuffers
virtual void drawFilledRect(const Rect &dest)=0
ScheduledEventPtr scheduleEvent(const std::function< void()> &callback, int delay)
void setBaseSpeed(double baseSpeed)
void setOutfit(const Outfit &outfit)
stdext::boolean< false > m_shieldBlink
ThingTypeManager g_things
int getExactSize(int layer=0, int xPattern=0, int yPattern=0, int zPattern=0, int animationPhase=0)
void setEmblem(uint8 emblem)
ThingType * rawGetThingType()
stdext::boolean< true > m_showShieldTexture
const ThingTypePtr & getThingType()
virtual void drawTexturedRect(const Rect &dest, const TexturePtr &texture, const Rect &src)=0
bool isValidDatId(uint16 id, ThingCategory category)