Go to the documentation of this file.
95 light.intensity = std::max<uint8>(light.intensity, 1);
96 if(light.color == 0 || light.color > 215) {
101 if(light.intensity > 0) {
113 int animationPhase = 0;
122 xPattern = direction;
130 dest -= datType->getDisplacement() * scaleFactor;
131 datType->draw(dest, scaleFactor, 0, xPattern, 0, 0, animationPhase);
150 datType->draw(dest, scaleFactor, 0, xPattern, yPattern, zPattern, animationPhase);
157 datType->draw(dest, scaleFactor,
SpriteMaskYellow, xPattern, yPattern, zPattern, animationPhase);
159 datType->draw(dest, scaleFactor,
SpriteMaskRed, xPattern, yPattern, zPattern, animationPhase);
161 datType->draw(dest, scaleFactor,
SpriteMaskGreen, xPattern, yPattern, zPattern, animationPhase);
163 datType->draw(dest, scaleFactor,
SpriteMaskBlue, xPattern, yPattern, zPattern, animationPhase);
172 int animationPhase = 0;
179 animationPhases = std::max<int>(1, animationPhases - 2);
183 if(animationPhases > 1) {
184 animationPhase = (
g_clock.
millis() % (animateTicks * animationPhases)) / animateTicks;
188 animationPhase = std::min<int>(animationPhase + 1, animationPhases);
190 type->
draw(dest - (
getDisplacement() * scaleFactor), scaleFactor, 0, 0, 0, 0, animationPhase);
207 else if((frameSize = exactSize) == 0)
212 outfitBuffer->
resize(
Size(frameSize, frameSize));
213 outfitBuffer->
bind();
218 outfitBuffer->
draw(destRect,
Rect(0, 0, frameSize, frameSize));
220 const float scaleFactor = destRect.
width() /
static_cast<float>(frameSize);
237 Rect backgroundRect =
Rect(point.
x - (13.5), point.
y, 27, 4);
240 Rect textRect =
Rect(point.
x - nameSize.
width() / 2.0, point.
y - 12, nameSize);
248 if(textRect.
top() == parentRect.
top())
249 backgroundRect.
moveTop(textRect.
top() + offset);
251 textRect.
moveTop(backgroundRect.
top() - offset);
259 fillColor =
Color(0x66, 0xcc, 0xff);
395 const double height = a * t * t + b * t;
411 nextT =
stdext::round((-b + std::sqrt(std::max<double>(b * b + 4 * a * (roundHeight + diff * i), 0.0)) * diff) / (2 * a));
414 if(nextT < halfJumpDuration)
416 else if(nextT > halfJumpDuration)
421 const auto self = static_self_cast<Creature>();
473 auto self = static_self_cast<Creature>();
475 self->m_removed =
true;
478 self->callLuaField(
"onDisappear");
481 if(!self->isLocalPlayer())
485 self->m_disappearEvent =
nullptr;
534 for(
int xi = -1; xi <= 1 && !newWalkingTile; ++xi) {
535 for(
int yi = -1; yi <= 1 && !newWalkingTile; ++yi) {
554 if(newWalkingTile->
isEmpty()) {
575 auto self = static_self_cast<Creature>();
577 self->m_walkUpdateEvent =
nullptr;
578 self->nextWalkUpdate();
585 stepDuration += (12 - stepDuration * .01);
630 const auto self = static_self_cast<Creature>();
632 self->m_walkAnimationPhase = 0;
633 self->m_walkFinishAnimEvent =
nullptr;
635 self->requestDrawing();
648 if(healthPercent > 92)
650 else if(healthPercent > 60)
652 else if(healthPercent > 30)
654 else if(healthPercent > 8)
656 else if(healthPercent > 3)
663 callLuaField(
"onHealthPercentChange", healthPercent, oldHealthPercent);
665 if(healthPercent <= 0)
727 const auto self = static_self_cast<Creature>();
729 self->updateOutfitColor(color, finalColor, delta, duration);
761 callLuaField(
"onBaseSpeedChange", baseSpeed, oldBaseSpeed);
810 auto self = static_self_cast<Creature>();
812 self->updateShield();
840 const auto self = static_self_cast<Creature>();
842 self->removeTimedSquare();
851 auto self = static_self_cast<Creature>();
853 self->updateShield();
898 }
else groundSpeed = 150;
900 if(
m_speed != m_stepCache.speed || groundSpeed != m_stepCache.groundSpeed) {
902 m_stepCache.groundSpeed = groundSpeed;
904 double stepDuration = 1000. * groundSpeed;
907 }
else stepDuration /=
m_speed;
911 stepDuration = std::ceil(stepDuration / serverBeat) * serverBeat;
914 m_stepCache.duration = stepDuration;
918 return ignoreDiagonal ? m_stepCache.duration : m_stepCache.getDuration(
m_lastStepDirection);
982 const auto idleAnimator = thingType->getIdleAnimator();
988 if(thingType->isAnimateAlways()) {
989 const int ticksPerFrame =
std::round(1000 / thingType->getAnimationPhases());
990 return (
g_clock.
millis() % (ticksPerFrame * thingType->getAnimationPhases())) / ticksPerFrame;
1007 for(yPattern = 0; yPattern < numPatternY; ++yPattern) {
1011 for(layer = 0; layer < layers; ++layer)
1012 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)
void turn(Otc::Direction direction)
virtual void terminateWalk()
void requestDrawing(const Position &pos, const Otc::RequestDrawFlags reDrawFlags, const bool force=false, const bool isLocalPlayer=false)
void setShield(uint8 shield)
void startListenerPainter(const float duration)
Position m_lastStepFromPosition
@ ReDrawStaticCreatureInformation
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
AnimatorPtr getIdleAnimator()
virtual void clear(const Color &color)=0
CompositionMode getCompositionMode()
EventDispatcher g_dispatcher
void setSkullTexture(const std::string &filename)
void setDirection(Otc::Direction direction)
void notificateTileUpdate(const Position &pos, const ThingPtr &thing=nullptr, const Otc::Operation operation=Otc::OPERATION_NEUTRAL)
void addLightSource(const Point ¢er, float scaleFactor, const Light &light)
void internalDrawOutfit(Point dest, float scaleFactor, bool animateWalk, Otc::Direction direction)
stdext::boolean< false > m_updateDynamicInformation
int getExactSize(int layer=0, int xPattern=0, int yPattern=0, int zPattern=0, int animationPhase=0) override
void setIconTexture(const std::string &filename)
const Position & getPosition()
void onPositionChange(const Position &newPos, const Position &oldPos) override
Color m_staticSquareColor
virtual void updateWalkAnimation()
void addTimedSquare(uint8 color)
const TilePtr & getTile(const Position &pos)
void setCategory(ThingCategory category)
ScheduledEventPtr m_outfitColorUpdateEvent
void addWalkingCreature(const CreaturePtr &creature)
void setFont(const BitmapFontPtr &font)
void setText(const std::string &text)
void requestDrawing(const bool force=false)
void removeWalkingCreature(const CreaturePtr &creature)
void setSkull(uint8 skull)
@ INVISIBLE_TICKS_PER_FRAME
@ ReDrawDynamicInformation
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)
int getCurrentAnimationPhase(bool mount=false)
R callLuaField(const std::string &field, const T &... args)
virtual void nextWalkUpdate()
stdext::boolean< false > m_allowAppearWalk
void setTypeTexture(const std::string &filename)
TexturePtr m_skullTexture
Position translated(int dx, int dy, short dz=0) const
ScheduledEventPtr m_walkUpdateEvent
int m_calculatedStepSpeed
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
Light getLight() override
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)
const ThingTypePtr & getThingType() override
stdext::boolean< true > m_removed
int getTotalAnimationPhase()
int getDisplacementX() override
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
@ VOLATILE_SQUARE_DURATION
virtual Point getDisplacement()
BitmapFontPtr getFont(const std::string &fontName)
ThingType * rawGetThingType() override
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
Point getDisplacement() override
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
void onDisappear() override
ThingType * rawGetMountThingType()
TPoint< T > bottomRight() const
void draw(const Point &dest, float scaleFactor, int layer, int xPattern, int yPattern, int zPattern, int animationPhase, int reDrawFlags=Otc::ReDrawThing, LightView *lightView=nullptr)
void setHealthPercent(uint8 healthPercent)
static Color from8bit(int color)
FrameBufferManager g_framebuffers
virtual void draw(const Point &dest, float scaleFactor, int reDrawFlags, LightView *lightView=nullptr)
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)
int getDisplacementY() override
stdext::boolean< true > m_showShieldTexture
virtual void drawTexturedRect(const Rect &dest, const TexturePtr &texture, const Rect &src)=0
bool isValidDatId(uint16 id, ThingCategory category)