Otclient 1.0  14/8/2020
creature.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #include "creature.h"
24 #include "effect.h"
25 #include "game.h"
26 #include "item.h"
27 #include "lightview.h"
28 #include "localplayer.h"
29 #include "luavaluecasts.h"
30 #include "map.h"
31 #include "thingtypemanager.h"
32 #include "tile.h"
33 
34 #include <framework/core/clock.h>
37 
42 #include "spritemanager.h"
43 
44 double Creature::speedA = 0;
45 double Creature::speedB = 0;
46 double Creature::speedC = 0;
47 
49 {
50  m_id = 0;
51  m_healthPercent = 100;
52  m_speed = 200;
55  m_walkedPixels = 0;
63  m_nameCache.setFont(g_fonts.getFont("verdana-11px-rounded"));
65  m_footStep = 0;
66  m_speedFormula.fill(-1);
68 }
69 
70 void Creature::draw(const Point& dest, float scaleFactor, int reDrawFlags, LightView* lightView)
71 {
72  if(!canBeSeen())
73  return;
74 
75  if(reDrawFlags & Otc::ReDrawThing) {
76  if(m_showTimedSquare) {
78  g_painter->drawBoundingRect(Rect(dest + (m_walkOffset - getDisplacement() + 2) * scaleFactor, Size(28, 28) * scaleFactor), std::max<int>(static_cast<int>(2 * scaleFactor), 1));
80  }
81 
82  if(m_showStaticSquare) {
84  g_painter->drawBoundingRect(Rect(dest + (m_walkOffset - getDisplacement()) * scaleFactor, Size(Otc::TILE_PIXELS, Otc::TILE_PIXELS) * scaleFactor), std::max<int>(static_cast<int>(2 * scaleFactor), 1));
86  }
87 
88  internalDrawOutfit(dest + m_walkOffset * scaleFactor, scaleFactor, true, m_direction);
89  }
90 
91  if(lightView && reDrawFlags & Otc::ReDrawLight) {
92  auto light = getLight();
93 
95  light.intensity = std::max<uint8>(light.intensity, 1);
96  if(light.color == 0 || light.color > 215) {
97  light.color = 215;
98  }
99  }
100 
101  if(light.intensity > 0) {
102  lightView->addLightSource(dest + (m_walkOffset + Point(16, 16)) * scaleFactor, scaleFactor, light);
103  }
104  }
105 }
106 
107 void Creature::internalDrawOutfit(Point dest, float scaleFactor, bool animateWalk, Otc::Direction direction)
108 {
110 
111  // outfit is a real creature
113  int animationPhase = 0;
114 
115  // xPattern => creature direction
116  int xPattern;
117  if(direction == Otc::NorthEast || direction == Otc::SouthEast)
118  xPattern = Otc::East;
119  else if(direction == Otc::NorthWest || direction == Otc::SouthWest)
120  xPattern = Otc::West;
121  else
122  xPattern = direction;
123 
124  int zPattern = 0;
125  if(m_outfit.hasMount()) {
126  if(animateWalk) animationPhase = getCurrentAnimationPhase(true);
127 
128  const auto& datType = rawGetMountThingType();
129 
130  dest -= datType->getDisplacement() * scaleFactor;
131  datType->draw(dest, scaleFactor, 0, xPattern, 0, 0, animationPhase);
132  dest += getDisplacement() * scaleFactor;
133 
134  zPattern = std::min<int>(1, getNumPatternZ() - 1);
135  }
136 
137  if(animateWalk) animationPhase = getCurrentAnimationPhase();
138 
139  const PointF jumpOffset = m_jumpOffset * scaleFactor;
140  dest -= Point(stdext::round(jumpOffset.x), stdext::round(jumpOffset.y));
141 
142  // yPattern => creature addon
143  for(int yPattern = 0; yPattern < getNumPatternY(); ++yPattern) {
144 
145  // continue if we dont have this addon
146  if(yPattern > 0 && !(m_outfit.getAddons() & (1 << (yPattern - 1))))
147  continue;
148 
149  auto* datType = rawGetThingType();
150  datType->draw(dest, scaleFactor, 0, xPattern, yPattern, zPattern, animationPhase);
151 
152  if(getLayers() > 1) {
153  Color oldColor = g_painter->getColor();
154  const Painter::CompositionMode oldComposition = g_painter->getCompositionMode();
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);
164  g_painter->setColor(oldColor);
165  g_painter->setCompositionMode(oldComposition);
166  }
167  }
168  // outfit is a creature imitating an item or the invisible effect
169  } else {
171 
172  int animationPhase = 0;
173  int animationPhases = type->getAnimationPhases();
174  int animateTicks = Otc::ITEM_TICKS_PER_FRAME;
175 
176  // when creature is an effect we cant render the first and last animation phase,
177  // instead we should loop in the phases between
179  animationPhases = std::max<int>(1, animationPhases - 2);
180  animateTicks = Otc::INVISIBLE_TICKS_PER_FRAME;
181  }
182 
183  if(animationPhases > 1) {
184  animationPhase = (g_clock.millis() % (animateTicks * animationPhases)) / animateTicks;
185  }
186 
188  animationPhase = std::min<int>(animationPhase + 1, animationPhases);
189 
190  type->draw(dest - (getDisplacement() * scaleFactor), scaleFactor, 0, 0, 0, 0, animationPhase);
191  }
192 
194 }
195 
196 void Creature::drawOutfit(const Rect& destRect, bool resize)
197 {
198  int exactSize;
200  exactSize = getExactSize();
201  else
203 
204  int frameSize;
205  if(!resize)
206  frameSize = std::max<int>(exactSize * 0.75f, 2 * Otc::TILE_PIXELS * 0.75f);
207  else if((frameSize = exactSize) == 0)
208  return;
209 
210  if(g_graphics.canUseFBO()) {
211  const FrameBufferPtr& outfitBuffer = g_framebuffers.getTemporaryFrameBuffer();
212  outfitBuffer->resize(Size(frameSize, frameSize));
213  outfitBuffer->bind();
214  g_painter->setAlphaWriting(true);
216  internalDrawOutfit(Point(frameSize - Otc::TILE_PIXELS, frameSize - Otc::TILE_PIXELS) + getDisplacement(), 1, true, Otc::South);
217  outfitBuffer->release();
218  outfitBuffer->draw(destRect, Rect(0, 0, frameSize, frameSize));
219  } else {
220  const float scaleFactor = destRect.width() / static_cast<float>(frameSize);
221  const Point dest = destRect.bottomRight() - (Point(Otc::TILE_PIXELS, Otc::TILE_PIXELS) - getDisplacement()) * scaleFactor;
222  internalDrawOutfit(dest, scaleFactor, true, Otc::South);
223  }
224 }
225 
226 void Creature::drawInformation(const Point& point, bool useGray, const Rect& parentRect, int drawFlags)
227 {
228  if(m_healthPercent < 1) // creature is dead
229  return;
230 
231  Color fillColor = Color(96, 96, 96);
232 
233  if(!useGray)
234  fillColor = m_informationColor;
235 
236  // calculate main rects
237  Rect backgroundRect = Rect(point.x - (13.5), point.y, 27, 4);
238 
239  const Size nameSize = m_nameCache.getTextSize();
240  Rect textRect = Rect(point.x - nameSize.width() / 2.0, point.y - 12, nameSize);
241 
242  // distance them
243  uint32 offset = 12;
244  if(isLocalPlayer()) {
245  offset *= 2;
246  }
247 
248  if(textRect.top() == parentRect.top())
249  backgroundRect.moveTop(textRect.top() + offset);
250  if(backgroundRect.bottom() == parentRect.bottom())
251  textRect.moveTop(backgroundRect.top() - offset);
252 
253  // health rect is based on background rect, so no worries
254  Rect healthRect = backgroundRect.expanded(-1);
255  healthRect.setWidth((m_healthPercent / 100.0) * 25);
256 
257  // draw
258  if(g_game.getFeature(Otc::GameBlueNpcNameColor) && isNpc() && m_healthPercent == 100 && !useGray)
259  fillColor = Color(0x66, 0xcc, 0xff);
260 
261  if(drawFlags & Otc::DrawBars && (!isNpc() || !g_game.getFeature(Otc::GameHideNpcNames))) {
263  g_painter->drawFilledRect(backgroundRect);
264 
265  g_painter->setColor(fillColor);
266  g_painter->drawFilledRect(healthRect);
267 
268  if(drawFlags & Otc::DrawManaBar && isLocalPlayer()) {
270  if(player) {
271  backgroundRect.moveTop(backgroundRect.bottom());
272 
274  g_painter->drawFilledRect(backgroundRect);
275 
276  Rect manaRect = backgroundRect.expanded(-1);
277  const double maxMana = player->getMaxMana();
278  if(maxMana == 0) {
279  manaRect.setWidth(25);
280  } else {
281  manaRect.setWidth(player->getMana() / (maxMana * 1.0) * 25);
282  }
283 
285  g_painter->drawFilledRect(manaRect);
286  }
287  }
288  }
289 
290  if(drawFlags & Otc::DrawNames) {
291  if(g_painter->getColor() != fillColor)
292  g_painter->setColor(fillColor);
293  m_nameCache.draw(textRect);
294  }
295 
298  const Rect skullRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_skullTexture->getSize());
300  }
303  const Rect shieldRect = Rect(backgroundRect.x() + 13.5, backgroundRect.y() + 5, m_shieldTexture->getSize());
305  }
308  const Rect emblemRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 16, m_emblemTexture->getSize());
310  }
313  const Rect typeRect = Rect(backgroundRect.x() + 13.5 + 12 + 12, backgroundRect.y() + 16, m_typeTexture->getSize());
315  }
318  const Rect iconRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_iconTexture->getSize());
320  }
321 }
322 
324 {
325  // if is not walking change the direction right away
326  if(!m_walking)
327  setDirection(direction);
328  // schedules to set the new direction when walk ends
329  else
330  m_walkTurnDirection = direction;
331 }
332 
333 void Creature::walk(const Position& oldPos, const Position& newPos)
334 {
335  if(oldPos == newPos)
336  return;
337 
338  // get walk direction
340  m_lastStepFromPosition = oldPos;
341  m_lastStepToPosition = newPos;
342 
343  // set current walking direction
345 
346  // starts counting walk
347  m_walking = true;
349  m_walkedPixels = 0;
350 
351  // no direction need to be changed when the walk ends
353 
356  m_walkFinishAnimEvent = nullptr;
357  }
358 
359  // starts updating walk
360  nextWalkUpdate();
361 }
362 
364 {
365  if(!m_walking)
366  return;
367 
368  // stops the walk right away
369  terminateWalk();
370 }
371 
372 void Creature::jump(int height, int duration)
373 {
374  if(!m_jumpOffset.isNull())
375  return;
376 
378  m_jumpHeight = height;
379  m_jumpDuration = duration;
380 
381  updateJump();
382 }
383 
385 {
387  m_jumpOffset = PointF(0, 0);
388  return;
389  }
390 
391  const int t = m_jumpTimer.ticksElapsed();
392  const double a = -4 * m_jumpHeight / (m_jumpDuration * m_jumpDuration);
393  const double b = +4 * m_jumpHeight / m_jumpDuration;
394 
395  const double height = a * t * t + b * t;
396  const int roundHeight = stdext::round(height);
397  const int halfJumpDuration = m_jumpDuration / 2;
398 
399  m_jumpOffset = PointF(height, height);
400 
401  requestDrawing();
402 
403  int diff = 0;
404  if(m_jumpTimer.ticksElapsed() < halfJumpDuration)
405  diff = 1;
406  else if(m_jumpTimer.ticksElapsed() > halfJumpDuration)
407  diff = -1;
408 
409  int nextT, i = 1;
410  do {
411  nextT = stdext::round((-b + std::sqrt(std::max<double>(b * b + 4 * a * (roundHeight + diff * i), 0.0)) * diff) / (2 * a));
412  ++i;
413 
414  if(nextT < halfJumpDuration)
415  diff = 1;
416  else if(nextT > halfJumpDuration)
417  diff = -1;
418  } while(nextT - m_jumpTimer.ticksElapsed() == 0 && i < 3);
419 
420  // schedules next update
421  const auto self = static_self_cast<Creature>();
422  g_dispatcher.scheduleEvent([self] {
423  self->updateJump();
424  }, nextT - m_jumpTimer.ticksElapsed());
425 }
426 
427 void Creature::onPositionChange(const Position& newPos, const Position& oldPos)
428 {
429  callLuaField("onPositionChange", newPos, oldPos);
430 }
431 
433 {
434  // cancel any disappear event
435  if(m_disappearEvent) {
437  m_disappearEvent = nullptr;
438  }
439 
440  const auto idleAnimator = getIdleAnimator();
441  if(idleAnimator) startListenerPainter(idleAnimator->getAverageDuration());
443 
444  // creature appeared the first time or wasn't seen for a long time
445  if(m_removed) {
446  stopWalk();
447  m_removed = false;
448  callLuaField("onAppear");
449 
450  } // walk
452  m_allowAppearWalk = false;
455 
456  } // teleport
457  else if(m_oldPosition != m_position) {
458  stopWalk();
459  callLuaField("onDisappear");
460  callLuaField("onAppear");
461  } // else turn
462 }
463 
465 {
466  if(m_disappearEvent)
468 
470 
471  // a pair onDisappear and onAppear events are fired even when creatures walks or turns,
472  // so we must filter
473  auto self = static_self_cast<Creature>();
475  self->m_removed = true;
476  self->stopWalk();
477 
478  self->callLuaField("onDisappear");
479 
480  // invalidate this creature position
481  if(!self->isLocalPlayer())
482  self->setPosition(Position());
483 
484  self->m_oldPosition = Position();
485  self->m_disappearEvent = nullptr;
486  });
487 }
488 
490 {
491  callLuaField("onDeath");
492 }
493 
495 {
497  return;
498 
499  const int footAnimPhases = getTotalAnimationPhase();
500 
501  const int footDelay = m_stepCache.getDuration(m_lastStepDirection) / footAnimPhases;
502 
503  if(m_footTimer.ticksElapsed() >= footDelay) {
504  if(m_walkAnimationPhase == footAnimPhases) m_walkAnimationPhase = 1;
505  else ++m_walkAnimationPhase;
506 
508  }
509 }
510 
511 void Creature::updateWalkOffset(int totalPixelsWalked)
512 {
513  m_walkOffset = Point(0, 0);
515  m_walkOffset.y = Otc::TILE_PIXELS - totalPixelsWalked;
517  m_walkOffset.y = totalPixelsWalked - Otc::TILE_PIXELS;
518 
520  m_walkOffset.x = totalPixelsWalked - Otc::TILE_PIXELS;
522  m_walkOffset.x = Otc::TILE_PIXELS - totalPixelsWalked;
523 }
524 
526 {
527  // determine new walking tile
528  TilePtr newWalkingTile;
529 
530  const Rect virtualCreatureRect(Otc::TILE_PIXELS + (m_walkOffset.x - getDisplacementX()),
533 
534  for(int xi = -1; xi <= 1 && !newWalkingTile; ++xi) {
535  for(int yi = -1; yi <= 1 && !newWalkingTile; ++yi) {
536  Rect virtualTileRect((xi + 1) * Otc::TILE_PIXELS, (yi + 1) * Otc::TILE_PIXELS, Otc::TILE_PIXELS, Otc::TILE_PIXELS);
537 
538  // only render creatures where bottom right is inside tile rect
539  if(virtualTileRect.contains(virtualCreatureRect.bottomRight())) {
540  newWalkingTile = g_map.getOrCreateTile(m_position.translated(xi, yi, 0));
541  }
542  }
543  }
544 
545  if(newWalkingTile == m_walkingTile) return;
546 
547  if(m_walkingTile)
548  m_walkingTile->removeWalkingCreature(static_self_cast<Creature>());
549 
550  if(newWalkingTile) {
551  newWalkingTile->addWalkingCreature(static_self_cast<Creature>());
552 
553  // recache visible tiles in map views
554  if(newWalkingTile->isEmpty()) {
555  g_map.notificateTileUpdate(newWalkingTile->getPosition());
556  }
557  }
558 
559  m_walkingTile = newWalkingTile;
560 }
561 
563 {
564  // remove any previous scheduled walk updates
567 
568  // do the update
569  updateWalk();
570  requestDrawing();
571 
572  if(!m_walking) return;
573 
574  // schedules next update
575  auto self = static_self_cast<Creature>();
577  self->m_walkUpdateEvent = nullptr;
578  self->nextWalkUpdate();
579  }, std::max<int>(m_stepCache.duration / Otc::TILE_PIXELS, 16));
580 }
581 
583 {
584  int stepDuration = getStepDuration(true);
585  stepDuration += (12 - stepDuration * .01);
586 
587  const float walkTicksPerPixel = stepDuration / Otc::TILE_PIXELS;
588  const int totalPixelsWalked = std::min<int>(m_walkTimer.ticksElapsed() / walkTicksPerPixel, Otc::TILE_PIXELS);
589 
590  // update walk animation
592 
593  // needed for paralyze effect
594  m_walkedPixels = std::max<int>(m_walkedPixels, totalPixelsWalked);
595 
596  // update offsets
598 
600 
601  // terminate walk only when client and server side walk are completed
602  if(m_walking && m_walkTimer.ticksElapsed() >= stepDuration) {
603  terminateWalk();
604  }
605 }
606 
608 {
609  // remove any scheduled walk update
610  if(m_walkUpdateEvent) {
612  m_walkUpdateEvent = nullptr;
613  }
614 
615  // now the walk has ended, do any scheduled turn
619  }
620 
621  if(m_walkingTile) {
622  m_walkingTile->removeWalkingCreature(static_self_cast<Creature>());
623  m_walkingTile = nullptr;
624  }
625 
626  m_walkedPixels = 0;
627  m_walkOffset = Point(0, 0);
628  m_walking = false;
629 
630  const auto self = static_self_cast<Creature>();
632  self->m_walkAnimationPhase = 0;
633  self->m_walkFinishAnimEvent = nullptr;
634 
635  self->requestDrawing();
636  }, g_game.getServerBeat());
637 
638 }
639 
640 void Creature::setName(const std::string& name)
641 {
642  m_nameCache.setText(name);
643  m_name = name;
644 }
645 
647 {
648  if(healthPercent > 92)
649  m_informationColor = Color(0x00, 0xBC, 0x00);
650  else if(healthPercent > 60)
651  m_informationColor = Color(0x50, 0xA1, 0x50);
652  else if(healthPercent > 30)
653  m_informationColor = Color(0xA1, 0xA1, 0x00);
654  else if(healthPercent > 8)
655  m_informationColor = Color(0xBF, 0x0A, 0x0A);
656  else if(healthPercent > 3)
657  m_informationColor = Color(0x91, 0x0F, 0x0F);
658  else
659  m_informationColor = Color(0x85, 0x0C, 0x0C);
660 
661  const uint8 oldHealthPercent = m_healthPercent;
662  m_healthPercent = healthPercent;
663  callLuaField("onHealthPercentChange", healthPercent, oldHealthPercent);
664 
665  if(healthPercent <= 0)
666  onDeath();
667 
670 }
671 
673 {
674  assert(direction != Otc::InvalidDirection);
675  m_direction = direction;
676 }
677 
678 void Creature::setOutfit(const Outfit& outfit)
679 {
680  const Outfit oldOutfit = m_outfit;
681  if(outfit.getCategory() != ThingCategoryCreature) {
682  if(!g_things.isValidDatId(outfit.getAuxId(), outfit.getCategory()))
683  return;
684 
685  m_outfit.setAuxId(outfit.getAuxId());
686  m_outfit.setCategory(outfit.getCategory());
687  } else {
688  if(outfit.getId() > 0 && !g_things.isValidDatId(outfit.getId(), ThingCategoryCreature))
689  return;
690 
691  m_outfit = outfit;
692  }
693 
694  m_walkAnimationPhase = 0; // might happen when player is walking and outfit is changed.
695 
696  callLuaField("onOutfitChange", m_outfit, oldOutfit);
697 
699 }
700 
701 void Creature::setOutfitColor(const Color& color, int duration)
702 {
705  m_outfitColorUpdateEvent = nullptr;
706  }
707 
708  if(duration <= 0) {
709  m_outfitColor = color;
710  return;
711  }
712 
713  const Color delta = (color - m_outfitColor) / static_cast<float>(duration);
715  updateOutfitColor(m_outfitColor, color, delta, duration);
716 }
717 
718 void Creature::updateOutfitColor(Color color, Color finalColor, Color delta, int duration)
719 {
720  if(m_outfitColorTimer.ticksElapsed() >= duration) {
721  m_outfitColor = finalColor;
722  return;
723  }
724 
725  m_outfitColor = color + delta * m_outfitColorTimer.ticksElapsed();
726 
727  const auto self = static_self_cast<Creature>();
729  self->updateOutfitColor(color, finalColor, delta, duration);
730  }, 100);
731 }
732 
734 {
735  const uint16 oldSpeed = m_speed;
736  m_speed = speed;
737 
738  // Cache for stepSpeed Law
740  speed *= 2;
741 
742  if(speed > -speedB) {
743  m_calculatedStepSpeed = floor((Creature::speedA * log((speed / 2) + Creature::speedB) + Creature::speedC) + 0.5);
745  } else m_calculatedStepSpeed = 1;
746  }
747 
748  // speed can change while walking (utani hur, paralyze, etc..)
749  if(m_walking)
750  nextWalkUpdate();
751 
752  callLuaField("onSpeedChange", m_speed, oldSpeed);
753 }
754 
755 void Creature::setBaseSpeed(double baseSpeed)
756 {
757  if(m_baseSpeed != baseSpeed) {
758  const double oldBaseSpeed = m_baseSpeed;
759  m_baseSpeed = baseSpeed;
760 
761  callLuaField("onBaseSpeedChange", baseSpeed, oldBaseSpeed);
762  }
763 }
764 
766 {
767  m_skull = skull;
768  callLuaField("onSkullChange", m_skull);
769 
771 }
772 
774 {
775  m_shield = shield;
776  callLuaField("onShieldChange", m_shield);
777 
779 }
780 
782 {
783  m_emblem = emblem;
784  callLuaField("onEmblemChange", m_emblem);
785 }
786 
788 {
789  m_type = type;
790  callLuaField("onTypeChange", m_type);
791 }
792 
794 {
795  m_icon = icon;
796  callLuaField("onIconChange", m_icon);
797 }
798 
799 void Creature::setSkullTexture(const std::string& filename)
800 {
802 }
803 
804 void Creature::setShieldTexture(const std::string& filename, bool blink)
805 {
807  m_showShieldTexture = true;
808 
809  if(blink && !m_shieldBlink) {
810  auto self = static_self_cast<Creature>();
811  g_dispatcher.scheduleEvent([self]() {
812  self->updateShield();
813  }, SHIELD_BLINK_TICKS);
814  }
815 
816  m_shieldBlink = blink;
817 }
818 
819 void Creature::setEmblemTexture(const std::string& filename)
820 {
822 }
823 
824 void Creature::setTypeTexture(const std::string& filename)
825 {
826  m_typeTexture = g_textures.getTexture(filename);
827 }
828 
829 void Creature::setIconTexture(const std::string& filename)
830 {
831  m_iconTexture = g_textures.getTexture(filename);
832 }
833 
835 {
836  m_showTimedSquare = true;
838 
839  // schedule removal
840  const auto self = static_self_cast<Creature>();
841  g_dispatcher.scheduleEvent([self]() {
842  self->removeTimedSquare();
844 }
845 
847 {
849 
851  auto self = static_self_cast<Creature>();
852  g_dispatcher.scheduleEvent([self]() {
853  self->updateShield();
854  }, SHIELD_BLINK_TICKS);
855  } else if(!m_shieldBlink)
856  m_showShieldTexture = true;
857 
859 }
860 
862 {
863  Point drawOffset;
864  if(m_walking) {
865  if(m_walkingTile)
866  drawOffset -= Point(1, 1) * m_walkingTile->getDrawElevation();
867  drawOffset += m_walkOffset;
868  } else {
869  const TilePtr& tile = getTile();
870  if(tile)
871  drawOffset -= Point(1, 1) * tile->getDrawElevation();
872  }
873 
874  return drawOffset;
875 }
876 
877 int Creature::getStepDuration(bool ignoreDiagonal, Otc::Direction dir)
878 {
879  if(isParalyzed())
880  return 0;
881 
882  Position tilePos;
883  int groundSpeed;
884 
885  if(dir == Otc::InvalidDirection)
886  tilePos = m_lastStepToPosition;
887  else
888  tilePos = m_position.translatedToDirection(dir);
889 
890  if(!tilePos.isValid())
891  tilePos = m_position;
892 
893  const TilePtr& tile = g_map.getTile(tilePos);
894  if(tile) {
895  groundSpeed = tile->getGroundSpeed();
896  if(groundSpeed == 0)
897  groundSpeed = 150;
898  } else groundSpeed = 150;
899 
900  if(m_speed != m_stepCache.speed || groundSpeed != m_stepCache.groundSpeed) {
901  m_stepCache.speed = m_speed;
902  m_stepCache.groundSpeed = groundSpeed;
903 
904  double stepDuration = 1000. * groundSpeed;
906  stepDuration = std::floor(stepDuration / m_calculatedStepSpeed);
907  } else stepDuration /= m_speed;
908 
909  if(g_game.getClientVersion() >= 900) {
910  const auto serverBeat = g_game.getServerBeat();
911  stepDuration = std::ceil(stepDuration / serverBeat) * serverBeat;
912  }
913 
914  m_stepCache.duration = stepDuration;
915  m_stepCache.diagonalDuration = stepDuration * (g_game.getClientVersion() <= 810 ? 2 : 3);
916  }
917 
918  return ignoreDiagonal ? m_stepCache.duration : m_stepCache.getDuration(m_lastStepDirection);
919 }
920 
922 {
924  return Point(8, 8);
925 
927  return Point(0, 0);
928 
929  return Thing::getDisplacement();
930 }
931 
933 {
935  return 8;
936 
938  return 0;
939 
940  if(m_outfit.hasMount())
942 
943  return Thing::getDisplacementX();
944 }
945 
947 {
949  return 8;
950 
952  return 0;
953 
954  if(m_outfit.hasMount()) {
956  }
957 
958  return Thing::getDisplacementY();
959 }
960 
962 {
963  Light light = Thing::getLight();
964 
965  if(m_light.color > 0 && m_light.intensity >= light.intensity)
966  light = m_light;
967 
968  return light;
969 }
970 
972 {
973  if(!m_outfit.hasMount()) return getAnimationPhases();
974 
976 }
977 
979 {
980  const auto& thingType = mount ? rawGetMountThingType() : rawGetThingType();
981 
982  const auto idleAnimator = thingType->getIdleAnimator();
983  if(idleAnimator) {
984  if(m_walkAnimationPhase == 0) return idleAnimator->getPhase();
985  return m_walkAnimationPhase + idleAnimator->getAnimationPhases() - 1;
986  }
987 
988  if(thingType->isAnimateAlways()) {
989  const int ticksPerFrame = std::round(1000 / thingType->getAnimationPhases());
990  return (g_clock.millis() % (ticksPerFrame * thingType->getAnimationPhases())) / ticksPerFrame;
991  }
992 
993  return m_walkAnimationPhase;
994 }
995 
996 int Creature::getExactSize(int layer, int xPattern, int yPattern, int zPattern, int animationPhase)
997 {
998  const int numPatternY = getNumPatternY(),
999  layers = getLayers();
1000 
1001  animationPhase = 0;
1002 
1003  if(m_outfit.hasMount())
1004  zPattern = m_outfit.hasMount() ? 1 : 0;
1005 
1006  int exactSize = 0;
1007  for(yPattern = 0; yPattern < numPatternY; ++yPattern) {
1008  if(yPattern > 0 && !(m_outfit.getAddons() & (1 << (yPattern - 1))))
1009  continue;
1010 
1011  for(layer = 0; layer < layers; ++layer)
1012  exactSize = std::max<int>(exactSize, Thing::getExactSize(layer, xPattern, yPattern, zPattern, animationPhase));
1013  }
1014 
1015  return exactSize;
1016 }
1017 
1019 {
1021 }
1022 
1024 {
1026 }
1027 
1029 {
1031 }
TRect::contains
bool contains(const TPoint< T > &p, bool insideOnly=false) const
Definition: rect.h:141
ThingTypeManager::rawGetThingType
ThingType * rawGetThingType(uint16 id, ThingCategory category)
Definition: thingtypemanager.h:57
Creature::m_outfit
Outfit m_outfit
Definition: creature.h:159
Painter::setAlphaWriting
virtual void setAlphaWriting(bool enable)=0
Otc::InvalidDirection
@ InvalidDirection
Definition: const.h:192
Position::translatedToDirection
Position translatedToDirection(Otc::Direction direction)
Definition: position.h:41
Position::isInRange
bool isInRange(const Position &pos, int xRange, int yRange) const
Definition: position.h:214
Painter::setColor
virtual void setColor(const Color &color)
Definition: painter.h:77
CachedText::getTextSize
Size getTextSize()
Definition: cachedtext.h:41
Outfit::getMount
int getMount() const
Definition: outfit.h:60
thingtypemanager.h
SpriteMaskGreen
@ SpriteMaskGreen
Definition: thingtype.h:106
Creature::turn
void turn(Otc::Direction direction)
Definition: creature.cpp:323
Otc::TILE_PIXELS
@ TILE_PIXELS
Definition: const.h:33
Creature::terminateWalk
virtual void terminateWalk()
Definition: creature.cpp:607
Map::requestDrawing
void requestDrawing(const Position &pos, const Otc::RequestDrawFlags reDrawFlags, const bool force=false, const bool isLocalPlayer=false)
Definition: map.cpp:84
Creature::setShield
void setShield(uint8 shield)
Definition: creature.cpp:773
lightview.h
Thing::startListenerPainter
void startListenerPainter(const float duration)
Definition: thing.h:133
Painter::getColor
Color getColor()
Definition: painter.h:95
Creature::m_jumpHeight
float m_jumpHeight
Definition: creature.h:214
Otc::GameBlueNpcNameColor
@ GameBlueNpcNameColor
Definition: const.h:398
eventdispatcher.h
Creature::m_lastStepFromPosition
Position m_lastStepFromPosition
Definition: creature.h:209
Creature::getDrawOffset
Point getDrawOffset()
Definition: creature.cpp:861
Otc::ReDrawStaticCreatureInformation
@ ReDrawStaticCreatureInformation
Definition: const.h:59
graphics.h
Creature::drawOutfit
void drawOutfit(const Rect &destRect, bool resize)
Definition: creature.cpp:196
g_map
Map g_map
Definition: map.cpp:36
Game::mount
void mount(bool mount)
Definition: game.cpp:1357
Creature::setEmblemTexture
void setEmblemTexture(const std::string &filename)
Definition: creature.cpp:819
Color
Definition: color.h:32
FrameBufferManager::getTemporaryFrameBuffer
const FrameBufferPtr & getTemporaryFrameBuffer()
Definition: framebuffermanager.h:37
Otc::GameNewSpeedLaw
@ GameNewSpeedLaw
Definition: const.h:401
Creature::speedB
static double speedB
Definition: creature.h:45
Creature::m_shield
uint8 m_shield
Definition: creature.h:168
PointF
TPoint< float > PointF
Definition: point.h:87
Tile::getGroundSpeed
int getGroundSpeed()
Definition: tile.cpp:376
Thing::getTile
const TilePtr & getTile()
Definition: thing.cpp:84
Creature::m_jumpOffset
PointF m_jumpOffset
Definition: creature.h:216
TPoint::y
T y
Definition: point.h:83
Otc::DrawNames
@ DrawNames
Definition: const.h:83
Timer::ticksElapsed
ticks_t ticksElapsed()
Definition: timer.cpp:33
Outfit::getId
int getId() const
Definition: outfit.h:53
Creature::m_disappearEvent
EventPtr m_disappearEvent
Definition: creature.h:205
Otc::North
@ North
Definition: const.h:184
paintershaderprogram.h
Painter::setCompositionMode
virtual void setCompositionMode(CompositionMode compositionMode)=0
TRect< int >
TRect::x
T x() const
Definition: rect.h:58
Creature::m_timedSquareColor
Color m_timedSquareColor
Definition: creature.h:183
Thing::getIdleAnimator
AnimatorPtr getIdleAnimator()
Definition: thing.h:81
Texture::getSize
const Size & getSize()
Definition: texture.h:50
Thing::getLight
virtual Light getLight()
Definition: thing.h:84
Painter::clear
virtual void clear(const Color &color)=0
Painter::getCompositionMode
CompositionMode getCompositionMode()
Definition: painter.h:98
g_dispatcher
EventDispatcher g_dispatcher
Definition: eventdispatcher.cpp:28
Position::isValid
bool isValid() const
Definition: position.h:196
Otc::DrawBars
@ DrawBars
Definition: const.h:82
Creature::speedC
static double speedC
Definition: creature.h:45
SpriteMaskRed
@ SpriteMaskRed
Definition: thingtype.h:105
uint32
uint32_t uint32
Definition: types.h:35
Creature::setSkullTexture
void setSkullTexture(const std::string &filename)
Definition: creature.cpp:799
Otc::DrawManaBar
@ DrawManaBar
Definition: const.h:85
Creature::setDirection
void setDirection(Otc::Direction direction)
Definition: creature.cpp:672
luavaluecasts.h
Map::notificateTileUpdate
void notificateTileUpdate(const Position &pos, const ThingPtr &thing=nullptr, const Otc::Operation operation=Otc::OPERATION_NEUTRAL)
Definition: map.cpp:72
Creature::onDeath
virtual void onDeath()
Definition: creature.cpp:489
LightView::addLightSource
void addLightSource(const Point &center, float scaleFactor, const Light &light)
Definition: lightview.cpp:80
Tile::getDrawElevation
int getDrawElevation()
Definition: tile.h:90
Creature::internalDrawOutfit
void internalDrawOutfit(Point dest, float scaleFactor, bool animateWalk, Otc::Direction direction)
Definition: creature.cpp:107
g_fonts
FontManager g_fonts
Definition: fontmanager.cpp:29
Creature::m_updateDynamicInformation
stdext::boolean< false > m_updateDynamicInformation
Definition: creature.h:202
Creature::getExactSize
int getExactSize(int layer=0, int xPattern=0, int yPattern=0, int zPattern=0, int animationPhase=0) override
Definition: creature.cpp:996
Creature::setIconTexture
void setIconTexture(const std::string &filename)
Definition: creature.cpp:829
Tile::getPosition
const Position & getPosition()
Definition: tile.h:89
Thing::getAnimationPhases
int getAnimationPhases()
Definition: thing.h:78
Creature::onPositionChange
void onPositionChange(const Position &newPos, const Position &oldPos) override
Definition: creature.cpp:427
Game::getClientVersion
int getClientVersion()
Definition: game.h:318
Creature::updateWalkingTile
void updateWalkingTile()
Definition: creature.cpp:525
texturemanager.h
Creature::m_staticSquareColor
Color m_staticSquareColor
Definition: creature.h:184
Creature::canBeSeen
bool canBeSeen()
Definition: creature.h:129
Creature::updateWalkAnimation
virtual void updateWalkAnimation()
Definition: creature.cpp:494
Creature::m_emblem
uint8 m_emblem
Definition: creature.h:169
Creature::addTimedSquare
void addTimedSquare(uint8 color)
Definition: creature.cpp:834
Map::getTile
const TilePtr & getTile(const Position &pos)
Definition: map.cpp:358
LocalPlayer::getMana
double getMana()
Definition: localplayer.h:79
Outfit::setCategory
void setCategory(ThingCategory category)
Definition: outfit.h:49
Otc::EmblemNone
@ EmblemNone
Definition: const.h:271
Creature::m_outfitColorUpdateEvent
ScheduledEventPtr m_outfitColorUpdateEvent
Definition: creature.h:188
Otc::ReDrawThing
@ ReDrawThing
Definition: const.h:56
Tile::addWalkingCreature
void addWalkingCreature(const CreaturePtr &creature)
Definition: tile.cpp:139
TRect::bottom
T bottom() const
Definition: rect.h:55
Otc::SEA_FLOOR
@ SEA_FLOOR
Definition: const.h:36
g_game
Game g_game
Definition: game.cpp:37
Point
TPoint< int > Point
Definition: point.h:86
Creature::m_type
uint8 m_type
Definition: creature.h:170
Otc::ReDrawLight
@ ReDrawLight
Definition: const.h:57
Creature::m_footStep
uint m_footStep
Definition: creature.h:196
CachedText::setFont
void setFont(const BitmapFontPtr &font)
Definition: cachedtext.h:37
Outfit::getAddons
int getAddons() const
Definition: outfit.h:59
ThingCategoryEffect
@ ThingCategoryEffect
Definition: thingtype.h:48
stdext::round
double round(double r)
Definition: math.cpp:64
Creature::m_baseSpeed
double m_baseSpeed
Definition: creature.h:165
ThingType::getAnimationPhases
int getAnimationPhases()
Definition: thingtype.cpp:637
CachedText::setText
void setText(const std::string &text)
Definition: cachedtext.h:38
TSize::width
int width() const
Definition: size.h:43
Creature::setType
void setType(uint8 type)
Definition: creature.cpp:787
Thing
Definition: thing.h:33
Creature::m_skull
uint8 m_skull
Definition: creature.h:167
Thing::requestDrawing
void requestDrawing(const bool force=false)
Definition: thing.cpp:35
Tile::removeWalkingCreature
void removeWalkingCreature(const CreaturePtr &creature)
Definition: tile.cpp:144
Creature::m_informationColor
Color m_informationColor
Definition: creature.h:185
Creature::m_nameCache
CachedText m_nameCache
Definition: creature.h:187
LightView
Definition: lightview.h:37
creature.h
Outfit::setAuxId
void setAuxId(int id)
Definition: outfit.h:42
Creature::setSkull
void setSkull(uint8 skull)
Definition: creature.cpp:765
Otc::INVISIBLE_TICKS_PER_FRAME
@ INVISIBLE_TICKS_PER_FRAME
Definition: const.h:41
Otc::ReDrawDynamicInformation
@ ReDrawDynamicInformation
Definition: const.h:60
clock.h
Thing::m_position
Position m_position
Definition: thing.h:141
framebuffermanager.h
Otc::NorthEast
@ NorthEast
Definition: const.h:188
Position::z
short z
Definition: position.h:267
Creature::drawInformation
void drawInformation(const Point &point, bool useGray, const Rect &parentRect, int drawFlags)
Definition: creature.cpp:226
Outfit::getBodyColor
Color getBodyColor() const
Definition: outfit.h:67
uint16
uint16_t uint16
Definition: types.h:36
Creature::updateWalk
virtual void updateWalk()
Definition: creature.cpp:582
Otc::ITEM_TICKS_PER_FRAME
@ ITEM_TICKS_PER_FRAME
Definition: const.h:42
Thing::getDisplacementX
virtual int getDisplacementX()
Definition: thing.h:71
Creature::SHIELD_BLINK_TICKS
@ SHIELD_BLINK_TICKS
Definition: creature.h:41
Fw::AlignTopCenter
@ AlignTopCenter
Definition: const.h:206
Creature::m_emblemTexture
TexturePtr m_emblemTexture
Definition: creature.h:174
Painter::CompositionMode
CompositionMode
Definition: painter.h:38
SpriteMaskBlue
@ SpriteMaskBlue
Definition: thingtype.h:107
Light::intensity
uint8 intensity
Definition: thingtype.h:122
Creature::speedA
static double speedA
Definition: creature.h:45
Creature::m_walkAnimationPhase
int m_walkAnimationPhase
Definition: creature.h:194
Otc::Direction
Direction
Definition: const.h:183
Creature::m_oldPosition
Position m_oldPosition
Definition: creature.h:211
Creature::m_lastStepToPosition
Position m_lastStepToPosition
Definition: creature.h:210
FrameBuffer::draw
void draw()
Definition: framebuffer.cpp:97
Game::getServerBeat
int getServerBeat()
Definition: game.h:340
localplayer.h
Outfit
Definition: outfit.h:29
Creature::setOutfitColor
void setOutfitColor(const Color &color, int duration)
Definition: creature.cpp:701
Creature::getCurrentAnimationPhase
int getCurrentAnimationPhase(bool mount=false)
Definition: creature.cpp:978
LuaObject::callLuaField
R callLuaField(const std::string &field, const T &... args)
Definition: luaobject.h:172
FrameBuffer::release
void release()
Definition: framebuffer.cpp:91
Creature::nextWalkUpdate
virtual void nextWalkUpdate()
Definition: creature.cpp:562
ThingCategoryCreature
@ ThingCategoryCreature
Definition: thingtype.h:47
Creature::updateJump
void updateJump()
Definition: creature.cpp:384
Creature::m_jumpDuration
float m_jumpDuration
Definition: creature.h:215
Creature::m_allowAppearWalk
stdext::boolean< false > m_allowAppearWalk
Definition: creature.h:201
Creature::setTypeTexture
void setTypeTexture(const std::string &filename)
Definition: creature.cpp:824
spritemanager.h
Creature::setIcon
void setIcon(uint8 icon)
Definition: creature.cpp:793
Creature::m_skullTexture
TexturePtr m_skullTexture
Definition: creature.h:172
painterogl2_shadersources.h
Position::translated
Position translated(int dx, int dy, short dz=0) const
Definition: position.h:201
Otc::West
@ West
Definition: const.h:187
Graphics::canUseFBO
bool canUseFBO()
Definition: graphics.cpp:293
Creature::m_light
Light m_light
Definition: creature.h:160
Creature::m_walkUpdateEvent
ScheduledEventPtr m_walkUpdateEvent
Definition: creature.h:203
Creature::m_calculatedStepSpeed
int m_calculatedStepSpeed
Definition: creature.h:163
Creature::walk
virtual void walk(const Position &oldPos, const Position &newPos)
Definition: creature.cpp:333
Position
Definition: position.h:33
Creature::setName
void setName(const std::string &name)
Definition: creature.cpp:640
Thing::isLocalPlayer
virtual bool isLocalPlayer()
Definition: thing.h:59
Color::white
static const Color white
Definition: color.h:101
Creature::m_walkOffset
Point m_walkOffset
Definition: creature.h:206
Creature::setSpeed
void setSpeed(uint16 speed)
Definition: creature.cpp:733
Creature::jump
void jump(int height, int duration)
Definition: creature.cpp:372
Thing::getNumPatternY
int getNumPatternY()
Definition: thing.h:76
Creature::m_speedFormula
std::array< double, Otc::LastSpeedFormula > m_speedFormula
Definition: creature.h:191
EventDispatcher::addEvent
EventPtr addEvent(const std::function< void()> &callback, bool pushFront=false)
Definition: eventdispatcher.cpp:104
TRect::y
T y() const
Definition: rect.h:59
CachedText::setAlign
void setAlign(Fw::AlignmentFlag align)
Definition: cachedtext.h:39
ThingCategoryItem
@ ThingCategoryItem
Definition: thingtype.h:46
Creature::updateOutfitColor
void updateOutfitColor(Color color, Color finalColor, Color delta, int duration)
Definition: creature.cpp:718
TRect::expanded
TRect< T > expanded(T add) const
Definition: rect.h:120
Creature::m_iconTexture
TexturePtr m_iconTexture
Definition: creature.h:176
Painter::drawBoundingRect
virtual void drawBoundingRect(const Rect &dest, int innerLineWidth=1)=0
Map::getLight
Light getLight()
Definition: map.h:241
Creature::m_shieldTexture
TexturePtr m_shieldTexture
Definition: creature.h:173
Creature::getLight
Light getLight() override
Definition: creature.cpp:961
Size
TSize< int > Size
Definition: size.h:107
map.h
Creature::m_icon
uint8 m_icon
Definition: creature.h:171
Timer::restart
void restart()
Definition: timer.cpp:27
Creature::updateWalkOffset
virtual void updateWalkOffset(int totalPixelsWalked)
Definition: creature.cpp:511
TPoint::x
T x
Definition: point.h:83
ThingTypeManager::getThingType
const ThingTypePtr & getThingType(uint16 id, ThingCategory category)
Definition: thingtypemanager.cpp:376
Game::getFeature
bool getFeature(Otc::GameFeature feature)
Definition: game.h:312
g_graphics
Graphics g_graphics
Definition: graphics.cpp:44
Creature::m_showTimedSquare
stdext::boolean< false > m_showTimedSquare
Definition: creature.h:180
Creature::m_outfitColorTimer
Timer m_outfitColorTimer
Definition: creature.h:189
Creature::setShieldTexture
void setShieldTexture(const std::string &filename, bool blink)
Definition: creature.cpp:804
Creature::m_footTimer
Timer m_footTimer
Definition: creature.h:198
TextureManager::getTexture
TexturePtr getTexture(const std::string &fileName)
Definition: texturemanager.cpp:90
Outfit::hasMount
bool hasMount() const
Definition: outfit.h:62
Creature::m_walkTimer
Timer m_walkTimer
Definition: creature.h:197
Creature::getThingType
const ThingTypePtr & getThingType() override
Definition: creature.cpp:1018
ThingType
Definition: thingtype.h:126
Creature::m_removed
stdext::boolean< true > m_removed
Definition: creature.h:182
Creature::isParalyzed
bool isParalyzed() const
Definition: creature.h:131
Color::blue
static const Color blue
Definition: color.h:107
Otc::SouthEast
@ SouthEast
Definition: const.h:189
Creature::getTotalAnimationPhase
int getTotalAnimationPhase()
Definition: creature.cpp:971
Creature::getDisplacementX
int getDisplacementX() override
Definition: creature.cpp:932
TPoint::isNull
bool isNull() const
Definition: point.h:41
Color::black
static const Color black
Definition: color.h:102
Creature::m_walkFinishAnimEvent
ScheduledEventPtr m_walkFinishAnimEvent
Definition: creature.h:204
Position::getDirectionFromPosition
Otc::Direction getDirectionFromPosition(const Position &position) const
Definition: position.h:190
Creature::m_direction
Otc::Direction m_direction
Definition: creature.h:158
Map::getOrCreateTile
const TilePtr & getOrCreateTile(const Position &pos)
Definition: map.cpp:337
Rect
TRect< int > Rect
Definition: rect.h:319
Otc::ShieldNone
@ ShieldNone
Definition: const.h:256
FrameBuffer::bind
void bind()
Definition: framebuffer.cpp:84
Otc::GameHideNpcNames
@ GameHideNpcNames
Definition: const.h:420
CachedText::draw
void draw(const Rect &rect)
Definition: cachedtext.cpp:34
Thing::isAnimateAlways
bool isAnimateAlways()
Definition: thing.h:118
Otc::South
@ South
Definition: const.h:186
Thing::getDisplacementY
virtual int getDisplacementY()
Definition: thing.h:72
Outfit::getHeadColor
Color getHeadColor() const
Definition: outfit.h:66
Color::alpha
static const Color alpha
Definition: color.h:100
LocalPlayer::getMaxMana
double getMaxMana()
Definition: localplayer.h:80
Otc::NpcIconNone
@ NpcIconNone
Definition: const.h:280
Creature::m_healthPercent
uint8 m_healthPercent
Definition: creature.h:166
Painter::resetColor
void resetColor()
Definition: painter.h:108
Creature::VOLATILE_SQUARE_DURATION
@ VOLATILE_SQUARE_DURATION
Definition: creature.h:42
Creature::m_walkedPixels
int m_walkedPixels
Definition: creature.h:195
Thing::getDisplacement
virtual Point getDisplacement()
Definition: thing.h:70
Otc::NorthWest
@ NorthWest
Definition: const.h:191
effect.h
Thing::getNumPatternZ
int getNumPatternZ()
Definition: thing.h:77
Outfit::getAuxId
int getAuxId() const
Definition: outfit.h:54
Proto::CreatureTypeUnknown
@ CreatureTypeUnknown
Definition: protocolcodes.h:282
stdext::shared_object_ptr< FrameBuffer >
FontManager::getFont
BitmapFontPtr getFont(const std::string &fontName)
Definition: fontmanager.cpp:90
Creature::rawGetThingType
ThingType * rawGetThingType() override
Definition: creature.cpp:1023
Thing::getExactSize
virtual int getExactSize(int layer, int xPattern, int yPattern, int zPattern, int animationPhase)
Definition: thing.h:73
Otc::East
@ East
Definition: const.h:185
Game::getLocalPlayer
LocalPlayerPtr getLocalPlayer()
Definition: game.h:345
g_painter
Painter * g_painter
Definition: painter.cpp:28
Light::color
uint8 color
Definition: thingtype.h:123
SpriteMaskYellow
@ SpriteMaskYellow
Definition: thingtype.h:108
Outfit::getFeetColor
Color getFeetColor() const
Definition: outfit.h:69
FrameBuffer::resize
void resize(const Size &size)
Definition: framebuffer.cpp:57
Creature::m_walking
stdext::boolean< false > m_walking
Definition: creature.h:200
Creature::stopWalk
virtual void stopWalk()
Definition: creature.cpp:363
Creature::getDisplacement
Point getDisplacement() override
Definition: creature.cpp:921
Outfit::getCategory
ThingCategory getCategory() const
Definition: outfit.h:64
TRect::moveTop
void moveTop(T pos)
Definition: rect.h:105
Light
Definition: thingtype.h:120
Thing::getLayers
int getLayers()
Definition: thing.h:74
Creature::getStepDuration
int getStepDuration(bool ignoreDiagonal=false, Otc::Direction dir=Otc::InvalidDirection)
Definition: creature.cpp:877
Creature::m_lastStepDirection
Otc::Direction m_lastStepDirection
Definition: creature.h:208
Thing::isNpc
virtual bool isNpc()
Definition: thing.h:56
Creature::updateShield
void updateShield()
Definition: creature.cpp:846
Creature::m_name
std::string m_name
Definition: creature.h:157
TRect::top
T top() const
Definition: rect.h:53
Creature::m_walkTurnDirection
Otc::Direction m_walkTurnDirection
Definition: creature.h:207
game.h
Clock::millis
ticks_t millis()
Definition: clock.h:37
Creature::m_walkingTile
TilePtr m_walkingTile
Definition: creature.h:199
Creature::m_outfitColor
Color m_outfitColor
Definition: creature.h:186
Creature::m_showStaticSquare
stdext::boolean< false > m_showStaticSquare
Definition: creature.h:181
Creature::m_typeTexture
TexturePtr m_typeTexture
Definition: creature.h:175
Creature::m_jumpTimer
Timer m_jumpTimer
Definition: creature.h:217
Painter::CompositionMode_Multiply
@ CompositionMode_Multiply
Definition: painter.h:40
Outfit::getLegsColor
Color getLegsColor() const
Definition: outfit.h:68
g_textures
TextureManager g_textures
Definition: texturemanager.cpp:33
Creature::onDisappear
void onDisappear() override
Definition: creature.cpp:464
Creature::onAppear
void onAppear() override
Definition: creature.cpp:432
Creature::rawGetMountThingType
ThingType * rawGetMountThingType()
Definition: creature.cpp:1028
TRect::bottomRight
TPoint< T > bottomRight() const
Definition: rect.h:61
TPoint< int >
ThingType::draw
void draw(const Point &dest, float scaleFactor, int layer, int xPattern, int yPattern, int zPattern, int animationPhase, int reDrawFlags=Otc::ReDrawThing, LightView *lightView=nullptr)
Definition: thingtype.cpp:428
Creature::setHealthPercent
void setHealthPercent(uint8 healthPercent)
Definition: creature.cpp:646
Color::from8bit
static Color from8bit(int color)
Definition: color.h:90
g_framebuffers
FrameBufferManager g_framebuffers
Definition: framebuffermanager.cpp:26
Creature::draw
virtual void draw(const Point &dest, float scaleFactor, int reDrawFlags, LightView *lightView=nullptr)
Definition: creature.cpp:70
TRect::setWidth
void setWidth(T width)
Definition: rect.h:85
ThingType::getDisplacementX
int getDisplacementX()
Definition: thingtype.h:158
Painter::drawFilledRect
virtual void drawFilledRect(const Rect &dest)=0
EventDispatcher::scheduleEvent
ScheduledEventPtr scheduleEvent(const std::function< void()> &callback, int delay)
Definition: eventdispatcher.cpp:82
tile.h
TRect::width
T width() const
Definition: rect.h:69
Creature::setBaseSpeed
void setBaseSpeed(double baseSpeed)
Definition: creature.cpp:755
Event::cancel
void cancel()
Definition: event.cpp:49
Creature::setOutfit
void setOutfit(const Outfit &outfit)
Definition: creature.cpp:678
Tile::isEmpty
bool isEmpty()
Definition: tile.cpp:574
Creature::m_shieldBlink
stdext::boolean< false > m_shieldBlink
Definition: creature.h:178
TSize< int >
ThingType::getDisplacementY
int getDisplacementY()
Definition: thingtype.h:159
g_clock
Clock g_clock
Definition: clock.cpp:25
Creature::Creature
Creature()
Definition: creature.cpp:48
g_things
ThingTypeManager g_things
Definition: thingtypemanager.cpp:38
ThingType::getExactSize
int getExactSize(int layer=0, int xPattern=0, int yPattern=0, int zPattern=0, int animationPhase=0)
Definition: thingtype.cpp:618
Creature::setEmblem
void setEmblem(uint8 emblem)
Definition: creature.cpp:781
Creature::getDisplacementY
int getDisplacementY() override
Definition: creature.cpp:946
Creature::m_speed
int m_speed
Definition: creature.h:162
Otc::SouthWest
@ SouthWest
Definition: const.h:190
Creature::m_showShieldTexture
stdext::boolean< true > m_showShieldTexture
Definition: creature.h:177
uint8
uint8_t uint8
Definition: types.h:37
Painter::drawTexturedRect
virtual void drawTexturedRect(const Rect &dest, const TexturePtr &texture, const Rect &src)=0
Creature::m_id
uint32 m_id
Definition: creature.h:156
ThingTypeManager::isValidDatId
bool isValidDatId(uint16 id, ThingCategory category)
Definition: thingtypemanager.h:75
Otc::SkullNone
@ SkullNone
Definition: const.h:246
item.h