Otclient  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 "thingtypemanager.h"
25 #include "localplayer.h"
26 #include "map.h"
27 #include "tile.h"
28 #include "item.h"
29 #include "game.h"
30 #include "effect.h"
31 #include "luavaluecasts.h"
32 #include "lightview.h"
33 
36 #include <framework/core/clock.h>
37 
42 #include "spritemanager.h"
43 
45 {
46  m_id = 0;
47  m_healthPercent = 100;
48  m_speed = 200;
51  m_walkedPixels = 0;
59  m_nameCache.setFont(g_fonts.getFont("verdana-11px-rounded"));
61  m_footStep = 0;
62  m_speedFormula.fill(-1);
64 }
65 
66 void Creature::draw(const Point& dest, float scaleFactor, bool animate, LightView *lightView)
67 {
68  if(!canBeSeen())
69  return;
70 
71  Point animationOffset = animate ? m_walkOffset : Point(0,0);
72 
73  if(m_showTimedSquare && animate) {
75  g_painter->drawBoundingRect(Rect(dest + (animationOffset - getDisplacement() + 2)*scaleFactor, Size(28, 28)*scaleFactor), std::max<int>((int)(2*scaleFactor), 1));
77  }
78 
79  if(m_showStaticSquare && animate) {
81  g_painter->drawBoundingRect(Rect(dest + (animationOffset - getDisplacement())*scaleFactor, Size(Otc::TILE_PIXELS, Otc::TILE_PIXELS)*scaleFactor), std::max<int>((int)(2*scaleFactor), 1));
83  }
84 
85  internalDrawOutfit(dest + animationOffset * scaleFactor, scaleFactor, animate, animate, m_direction);
86  m_footStepDrawn = true;
87 
88  if(lightView) {
89  Light light = rawGetThingType()->getLight();
90  if(m_light.intensity != light.intensity || m_light.color != light.color)
91  light = m_light;
92 
93  // local player always have a minimum light in complete darkness
95  light.intensity = std::max<uint8>(light.intensity, 3);
96  if(light.color == 0 || light.color > 215)
97  light.color = 215;
98  }
99 
100  if(light.intensity > 0)
101  lightView->addLightSource(dest + (animationOffset + Point(16,16)) * scaleFactor, scaleFactor, light);
102  }
103 }
104 
105 void Creature::internalDrawOutfit(Point dest, float scaleFactor, bool animateWalk, bool animateIdle, Otc::Direction direction, LightView *lightView)
106 {
108 
109  // outfit is a real creature
111  int animationPhase = animateWalk ? m_walkAnimationPhase : 0;
112 
113  if(isAnimateAlways() && animateIdle) {
114  int ticksPerFrame = 1000 / getAnimationPhases();
115  animationPhase = (g_clock.millis() % (ticksPerFrame * getAnimationPhases())) / ticksPerFrame;
116  }
117 
118  // xPattern => creature direction
119  int xPattern;
120  if(direction == Otc::NorthEast || direction == Otc::SouthEast)
121  xPattern = Otc::East;
122  else if(direction == Otc::NorthWest || direction == Otc::SouthWest)
123  xPattern = Otc::West;
124  else
125  xPattern = direction;
126 
127  int zPattern = 0;
128  if(m_outfit.getMount() != 0) {
130  dest -= datType->getDisplacement() * scaleFactor;
131  datType->draw(dest, scaleFactor, 0, xPattern, 0, 0, animationPhase, lightView);
132  dest += getDisplacement() * scaleFactor;
133  zPattern = std::min<int>(1, getNumPatternZ() - 1);
134  }
135 
136  PointF jumpOffset = m_jumpOffset * scaleFactor;
137  dest -= Point(stdext::round(jumpOffset.x), stdext::round(jumpOffset.y));
138 
139  // yPattern => creature addon
140  for(int yPattern = 0; yPattern < getNumPatternY(); yPattern++) {
141 
142  // continue if we dont have this addon
143  if(yPattern > 0 && !(m_outfit.getAddons() & (1 << (yPattern-1))))
144  continue;
145 
146  auto datType = rawGetThingType();
147  datType->draw(dest, scaleFactor, 0, xPattern, yPattern, zPattern, animationPhase, yPattern == 0 ? lightView : nullptr);
148 
149  if(getLayers() > 1) {
150  Color oldColor = g_painter->getColor();
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);
161  g_painter->setColor(oldColor);
162  g_painter->setCompositionMode(oldComposition);
163  }
164  }
165  // outfit is a creature imitating an item or the invisible effect
166  } else {
168 
169  int animationPhase = 0;
170  int animationPhases = type->getAnimationPhases();
171  int animateTicks = Otc::ITEM_TICKS_PER_FRAME;
172 
173  // when creature is an effect we cant render the first and last animation phase,
174  // instead we should loop in the phases between
176  animationPhases = std::max<int>(1, animationPhases-2);
177  animateTicks = Otc::INVISIBLE_TICKS_PER_FRAME;
178  }
179 
180  if(animationPhases > 1) {
181  if(animateIdle)
182  animationPhase = (g_clock.millis() % (animateTicks * animationPhases)) / animateTicks;
183  else
184  animationPhase = animationPhases-1;
185  }
186 
188  animationPhase = std::min<int>(animationPhase+1, animationPhases);
189 
190  type->draw(dest - (getDisplacement() * scaleFactor), scaleFactor, 0, 0, 0, 0, animationPhase, lightView);
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))
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, false, true, Otc::South);
217  outfitBuffer->release();
218  outfitBuffer->draw(destRect, Rect(0,0,frameSize,frameSize));
219  } else {
220  float scaleFactor = destRect.width() / (float)frameSize;
221  Point dest = destRect.bottomRight() - (Point(Otc::TILE_PIXELS,Otc::TILE_PIXELS) - getDisplacement()) * scaleFactor;
222  internalDrawOutfit(dest, scaleFactor, false, 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  backgroundRect.bind(parentRect);
239 
240  Size nameSize = m_nameCache.getTextSize();
241  Rect textRect = Rect(point.x - nameSize.width() / 2.0, point.y-12, nameSize);
242  textRect.bind(parentRect);
243 
244  // distance them
245  uint32 offset = 12;
246  if(isLocalPlayer()) {
247  offset *= 2;
248  }
249 
250  if(textRect.top() == parentRect.top())
251  backgroundRect.moveTop(textRect.top() + offset);
252  if(backgroundRect.bottom() == parentRect.bottom())
253  textRect.moveTop(backgroundRect.top() - offset);
254 
255  // health rect is based on background rect, so no worries
256  Rect healthRect = backgroundRect.expanded(-1);
257  healthRect.setWidth((m_healthPercent / 100.0) * 25);
258 
259  // draw
260  if(g_game.getFeature(Otc::GameBlueNpcNameColor) && isNpc() && m_healthPercent == 100 && !useGray)
261  fillColor = Color(0x66, 0xcc, 0xff);
262 
263  if(drawFlags & Otc::DrawBars && (!isNpc() || !g_game.getFeature(Otc::GameHideNpcNames))) {
265  g_painter->drawFilledRect(backgroundRect);
266 
267  g_painter->setColor(fillColor);
268  g_painter->drawFilledRect(healthRect);
269 
270  if(drawFlags & Otc::DrawManaBar && isLocalPlayer()) {
272  if(player) {
273  backgroundRect.moveTop(backgroundRect.bottom());
274 
276  g_painter->drawFilledRect(backgroundRect);
277 
278  Rect manaRect = backgroundRect.expanded(-1);
279  double maxMana = player->getMaxMana();
280  if(maxMana == 0) {
281  manaRect.setWidth(25);
282  } else {
283  manaRect.setWidth(player->getMana() / (maxMana * 1.0) * 25);
284  }
285 
287  g_painter->drawFilledRect(manaRect);
288  }
289  }
290  }
291 
292  if(drawFlags & Otc::DrawNames) {
293  if(g_painter->getColor() != fillColor)
294  g_painter->setColor(fillColor);
295  m_nameCache.draw(textRect);
296  }
297 
300  Rect skullRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_skullTexture->getSize());
302  }
305  Rect shieldRect = Rect(backgroundRect.x() + 13.5, backgroundRect.y() + 5, m_shieldTexture->getSize());
307  }
310  Rect emblemRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 16, m_emblemTexture->getSize());
312  }
315  Rect typeRect = Rect(backgroundRect.x() + 13.5 + 12 + 12, backgroundRect.y() + 16, m_typeTexture->getSize());
317  }
320  Rect iconRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_iconTexture->getSize());
322  }
323 }
324 
326 {
327  // if is not walking change the direction right away
328  if(!m_walking)
329  setDirection(direction);
330  // schedules to set the new direction when walk ends
331  else
332  m_walkTurnDirection = direction;
333 }
334 
335 void Creature::walk(const Position& oldPos, const Position& newPos)
336 {
337  if(oldPos == newPos)
338  return;
339 
340  // get walk direction
342  m_lastStepFromPosition = oldPos;
343  m_lastStepToPosition = newPos;
344 
345  // set current walking direction
347 
348  // starts counting walk
349  m_walking = true;
351  m_walkedPixels = 0;
352 
355  m_walkFinishAnimEvent = nullptr;
356  }
357 
358  // no direction need to be changed when the walk ends
360 
361  // starts updating walk
362  nextWalkUpdate();
363 }
364 
366 {
367  if(!m_walking)
368  return;
369 
370  // stops the walk right away
371  terminateWalk();
372 }
373 
374 void Creature::jump(int height, int duration)
375 {
376  if(!m_jumpOffset.isNull())
377  return;
378 
380  m_jumpHeight = height;
381  m_jumpDuration = duration;
382 
383  updateJump();
384 }
385 
387 {
388  int t = m_jumpTimer.ticksElapsed();
389  double a = -4 * m_jumpHeight / (m_jumpDuration * m_jumpDuration);
390  double b = +4 * m_jumpHeight / (m_jumpDuration);
391 
392  double height = a*t*t + b*t;
393  int roundHeight = stdext::round(height);
394  int halfJumpDuration = m_jumpDuration / 2;
395 
396  // schedules next update
398  m_jumpOffset = PointF(height, height);
399 
400  int diff = 0;
401  if(m_jumpTimer.ticksElapsed() < halfJumpDuration)
402  diff = 1;
403  else if(m_jumpTimer.ticksElapsed() > halfJumpDuration)
404  diff = -1;
405 
406  int nextT, i = 1;
407  do {
408  nextT = stdext::round((-b + std::sqrt(std::max<double>(b*b + 4*a*(roundHeight+diff*i), 0.0)) * diff) / (2*a));
409  ++i;
410 
411  if(nextT < halfJumpDuration)
412  diff = 1;
413  else if(nextT > halfJumpDuration)
414  diff = -1;
415  } while(nextT - m_jumpTimer.ticksElapsed() == 0 && i < 3);
416 
417  auto self = static_self_cast<Creature>();
418  g_dispatcher.scheduleEvent([self] {
419  self->updateJump();
420  }, nextT - m_jumpTimer.ticksElapsed());
421  }
422  else
423  m_jumpOffset = PointF(0, 0);
424 }
425 
426 void Creature::onPositionChange(const Position& newPos, const Position& oldPos)
427 {
428  callLuaField("onPositionChange", newPos, oldPos);
429 }
430 
432 {
433  // cancel any disappear event
434  if(m_disappearEvent) {
436  m_disappearEvent = nullptr;
437  }
438 
439  // creature appeared the first time or wasn't seen for a long time
440  if(m_removed) {
441  stopWalk();
442  m_removed = false;
443  callLuaField("onAppear");
444  // walk
446  m_allowAppearWalk = false;
449  // teleport
450  } else if(m_oldPosition != m_position) {
451  stopWalk();
452  callLuaField("onDisappear");
453  callLuaField("onAppear");
454  } // else turn
455 }
456 
458 {
459  if(m_disappearEvent)
461 
463 
464  // a pair onDisappear and onAppear events are fired even when creatures walks or turns,
465  // so we must filter
466  auto self = static_self_cast<Creature>();
468  self->m_removed = true;
469  self->stopWalk();
470 
471  self->callLuaField("onDisappear");
472 
473  // invalidate this creature position
474  if(!self->isLocalPlayer())
475  self->setPosition(Position());
476  self->m_oldPosition = Position();
477  self->m_disappearEvent = nullptr;
478  });
479 }
480 
482 {
483  callLuaField("onDeath");
484 }
485 
486 void Creature::updateWalkAnimation(int totalPixelsWalked)
487 {
488  // update outfit animation
490  return;
491 
492  int footAnimPhases = getAnimationPhases() - 1;
493  int footDelay = getStepDuration(true) / 3;
494  // Since mount is a different outfit we need to get the mount animation phases
495  if(m_outfit.getMount() != 0) {
497  footAnimPhases = type->getAnimationPhases() - 1;
498  }
499  if(footAnimPhases == 0)
501  else if(m_footStepDrawn && m_footTimer.ticksElapsed() >= footDelay && totalPixelsWalked < 32) {
502  m_footStep++;
503  m_walkAnimationPhase = 1 + (m_footStep % footAnimPhases);
504  m_footStepDrawn = false;
506  } else if(m_walkAnimationPhase == 0 && totalPixelsWalked < 32) {
507  m_walkAnimationPhase = 1 + (m_footStep % footAnimPhases);
508  }
509 
510  if(totalPixelsWalked == 32 && !m_walkFinishAnimEvent) {
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));
517  }
518 
519 }
520 
521 void Creature::updateWalkOffset(int totalPixelsWalked)
522 {
523  m_walkOffset = Point(0,0);
525  m_walkOffset.y = 32 - totalPixelsWalked;
527  m_walkOffset.y = totalPixelsWalked - 32;
528 
530  m_walkOffset.x = totalPixelsWalked - 32;
532  m_walkOffset.x = 32 - totalPixelsWalked;
533 }
534 
536 {
537  // determine new walking tile
538  TilePtr newWalkingTile;
539  Rect virtualCreatureRect(Otc::TILE_PIXELS + (m_walkOffset.x - getDisplacementX()),
542  for(int xi = -1; xi <= 1 && !newWalkingTile; ++xi) {
543  for(int yi = -1; yi <= 1 && !newWalkingTile; ++yi) {
544  Rect virtualTileRect((xi+1)*Otc::TILE_PIXELS, (yi+1)*Otc::TILE_PIXELS, Otc::TILE_PIXELS, Otc::TILE_PIXELS);
545 
546  // only render creatures where bottom right is inside tile rect
547  if(virtualTileRect.contains(virtualCreatureRect.bottomRight())) {
548  newWalkingTile = g_map.getOrCreateTile(m_position.translated(xi, yi, 0));
549  }
550  }
551  }
552 
553  if(newWalkingTile != m_walkingTile) {
554  if(m_walkingTile)
555  m_walkingTile->removeWalkingCreature(static_self_cast<Creature>());
556  if(newWalkingTile) {
557  newWalkingTile->addWalkingCreature(static_self_cast<Creature>());
558 
559  // recache visible tiles in map views
560  if(newWalkingTile->isEmpty())
561  g_map.notificateTileUpdate(newWalkingTile->getPosition());
562  }
563  m_walkingTile = newWalkingTile;
564  }
565 }
566 
568 {
569  // remove any previous scheduled walk updates
572 
573  // do the update
574  updateWalk();
575 
576  // schedules next update
577  if(m_walking) {
578  auto self = static_self_cast<Creature>();
580  self->m_walkUpdateEvent = nullptr;
581  self->nextWalkUpdate();
582  }, getStepDuration() / 32);
583  }
584 }
585 
587 {
588  float walkTicksPerPixel = getStepDuration(true) / 32;
589  int totalPixelsWalked = std::min<int>(m_walkTimer.ticksElapsed() / walkTicksPerPixel, 32.0f);
590 
591  // needed for paralyze effect
592  m_walkedPixels = std::max<int>(m_walkedPixels, totalPixelsWalked);
593 
594  // update walk animation and offsets
595  updateWalkAnimation(totalPixelsWalked);
598 
599  // terminate walk
601  terminateWalk();
602 }
603 
605 {
606  // remove any scheduled walk update
607  if(m_walkUpdateEvent) {
609  m_walkUpdateEvent = nullptr;
610  }
611 
612  // now the walk has ended, do any scheduled turn
616  }
617 
618  if(m_walkingTile) {
619  m_walkingTile->removeWalkingCreature(static_self_cast<Creature>());
620  m_walkingTile = nullptr;
621  }
622 
623  m_walking = false;
624  m_walkedPixels = 0;
625 
626  // reset walk animation states
627  m_walkOffset = Point(0,0);
629 }
630 
631 void Creature::setName(const std::string& name)
632 {
633  m_nameCache.setText(name);
634  m_name = name;
635 }
636 
638 {
639  if(healthPercent > 92)
640  m_informationColor = Color(0x00, 0xBC, 0x00);
641  else if(healthPercent > 60)
642  m_informationColor = Color(0x50, 0xA1, 0x50);
643  else if(healthPercent > 30)
644  m_informationColor = Color(0xA1, 0xA1, 0x00);
645  else if(healthPercent > 8)
646  m_informationColor = Color(0xBF, 0x0A, 0x0A);
647  else if(healthPercent > 3)
648  m_informationColor = Color(0x91, 0x0F, 0x0F);
649  else
650  m_informationColor = Color(0x85, 0x0C, 0x0C);
651 
652  m_healthPercent = healthPercent;
653  callLuaField("onHealthPercentChange", healthPercent);
654 
655  if(healthPercent <= 0)
656  onDeath();
657 }
658 
660 {
661  assert(direction != Otc::InvalidDirection);
662  m_direction = direction;
663 }
664 
665 void Creature::setOutfit(const Outfit& outfit)
666 {
667  Outfit oldOutfit = m_outfit;
668  if(outfit.getCategory() != ThingCategoryCreature) {
669  if(!g_things.isValidDatId(outfit.getAuxId(), outfit.getCategory()))
670  return;
671  m_outfit.setAuxId(outfit.getAuxId());
672  m_outfit.setCategory(outfit.getCategory());
673  } else {
674  if(outfit.getId() > 0 && !g_things.isValidDatId(outfit.getId(), ThingCategoryCreature))
675  return;
676  m_outfit = outfit;
677  }
678  m_walkAnimationPhase = 0; // might happen when player is walking and outfit is changed.
679 
680  callLuaField("onOutfitChange", m_outfit, oldOutfit);
681 }
682 
683 void Creature::setOutfitColor(const Color& color, int duration)
684 {
687  m_outfitColorUpdateEvent = nullptr;
688  }
689 
690  if(duration > 0) {
691  Color delta = (color - m_outfitColor) / (float)duration;
693  updateOutfitColor(m_outfitColor, color, delta, duration);
694  }
695  else
696  m_outfitColor = color;
697 }
698 
699 void Creature::updateOutfitColor(Color color, Color finalColor, Color delta, int duration)
700 {
701  if(m_outfitColorTimer.ticksElapsed() < duration) {
702  m_outfitColor = color + delta * m_outfitColorTimer.ticksElapsed();
703 
704  auto self = static_self_cast<Creature>();
706  self->updateOutfitColor(color, finalColor, delta, duration);
707  }, 100);
708  }
709  else {
710  m_outfitColor = finalColor;
711  }
712 }
713 
715 {
716  uint16 oldSpeed = m_speed;
717  m_speed = speed;
718 
719  // speed can change while walking (utani hur, paralyze, etc..)
720  if(m_walking)
721  nextWalkUpdate();
722 
723  callLuaField("onSpeedChange", m_speed, oldSpeed);
724 }
725 
726 void Creature::setBaseSpeed(double baseSpeed)
727 {
728  if(m_baseSpeed != baseSpeed) {
729  double oldBaseSpeed = m_baseSpeed;
730  m_baseSpeed = baseSpeed;
731 
732  callLuaField("onBaseSpeedChange", baseSpeed, oldBaseSpeed);
733  }
734 }
735 
737 {
738  m_skull = skull;
739  callLuaField("onSkullChange", m_skull);
740 }
741 
743 {
744  m_shield = shield;
745  callLuaField("onShieldChange", m_shield);
746 }
747 
749 {
750  m_emblem = emblem;
751  callLuaField("onEmblemChange", m_emblem);
752 }
753 
755 {
756  m_type = type;
757  callLuaField("onTypeChange", m_type);
758 }
759 
761 {
762  m_icon = icon;
763  callLuaField("onIconChange", m_icon);
764 }
765 
766 void Creature::setSkullTexture(const std::string& filename)
767 {
769 }
770 
771 void Creature::setShieldTexture(const std::string& filename, bool blink)
772 {
774  m_showShieldTexture = true;
775 
776  if(blink && !m_shieldBlink) {
777  auto self = static_self_cast<Creature>();
778  g_dispatcher.scheduleEvent([self]() {
779  self->updateShield();
780  }, SHIELD_BLINK_TICKS);
781  }
782 
783  m_shieldBlink = blink;
784 }
785 
786 void Creature::setEmblemTexture(const std::string& filename)
787 {
789 }
790 
791 void Creature::setTypeTexture(const std::string& filename)
792 {
793  m_typeTexture = g_textures.getTexture(filename);
794 }
795 
796 void Creature::setIconTexture(const std::string& filename)
797 {
798  m_iconTexture = g_textures.getTexture(filename);
799 }
800 
801 void Creature::setSpeedFormula(double speedA, double speedB, double speedC)
802 {
806 }
807 
809 {
812 }
813 
815 {
816  m_showTimedSquare = true;
818 
819  // schedule removal
820  auto self = static_self_cast<Creature>();
821  g_dispatcher.scheduleEvent([self]() {
822  self->removeTimedSquare();
824 }
825 
827 {
829 
831  auto self = static_self_cast<Creature>();
832  g_dispatcher.scheduleEvent([self]() {
833  self->updateShield();
834  }, SHIELD_BLINK_TICKS);
835  }
836  else if(!m_shieldBlink)
837  m_showShieldTexture = true;
838 }
839 
841 {
842  Point drawOffset;
843  if(m_walking) {
844  if(m_walkingTile)
845  drawOffset -= Point(1,1) * m_walkingTile->getDrawElevation();
846  drawOffset += m_walkOffset;
847  } else {
848  const TilePtr& tile = getTile();
849  if(tile)
850  drawOffset -= Point(1,1) * tile->getDrawElevation();
851  }
852  return drawOffset;
853 }
854 
855 int Creature::getStepDuration(bool ignoreDiagonal, Otc::Direction dir)
856 {
857  int speed = m_speed;
858  if(speed < 1)
859  return 0;
860 
862  speed *= 2;
863 
864  int groundSpeed = 0;
865  Position tilePos;
866 
867  if(dir == Otc::InvalidDirection)
868  tilePos = m_lastStepToPosition;
869  else
870  tilePos = m_position.translatedToDirection(dir);
871 
872  if(!tilePos.isValid())
873  tilePos = m_position;
874  const TilePtr& tile = g_map.getTile(tilePos);
875  if(tile) {
876  groundSpeed = tile->getGroundSpeed();
877  if(groundSpeed == 0)
878  groundSpeed = 150;
879  }
880 
881  int interval = 1000;
882  if(groundSpeed > 0 && speed > 0)
883  interval = 1000 * groundSpeed;
884 
886  int formulatedSpeed = 1;
887  if(speed > -m_speedFormula[Otc::SpeedFormulaB]) {
888  formulatedSpeed = std::max<int>(1, (int)floor((m_speedFormula[Otc::SpeedFormulaA] * log((speed / 2)
890  }
891  interval = std::floor(interval / (double)formulatedSpeed);
892  }
893  else
894  interval /= speed;
895 
896  if(g_game.getClientVersion() >= 900)
897  interval = (interval / g_game.getServerBeat()) * g_game.getServerBeat();
898 
899  float factor = 3;
900  if(g_game.getClientVersion() <= 810)
901  factor = 2;
902 
903  interval = std::max<int>(interval, g_game.getServerBeat());
904 
905  if(!ignoreDiagonal && (m_lastStepDirection == Otc::NorthWest || m_lastStepDirection == Otc::NorthEast ||
907  interval *= factor;
908 
909  return interval;
910 }
911 
913 {
915  return Point(8, 8);
917  return Point(0, 0);
918  return Thing::getDisplacement();
919 }
920 
922 {
924  return 8;
926  return 0;
927 
928  if(m_outfit.getMount() != 0) {
930  return datType->getDisplacementX();
931  }
932 
933  return Thing::getDisplacementX();
934 }
935 
937 {
939  return 8;
941  return 0;
942 
943  if(m_outfit.getMount() != 0) {
945  return datType->getDisplacementY();
946  }
947 
948  return Thing::getDisplacementY();
949 }
950 
951 int Creature::getExactSize(int layer, int xPattern, int yPattern, int zPattern, int animationPhase)
952 {
953  int exactSize = 0;
954 
955  animationPhase = 0;
956  xPattern = Otc::South;
957 
958  zPattern = 0;
959  if(m_outfit.getMount() != 0)
960  zPattern = 1;
961 
962  for(yPattern = 0; yPattern < getNumPatternY(); yPattern++) {
963  if(yPattern > 0 && !(m_outfit.getAddons() & (1 << (yPattern-1))))
964  continue;
965 
966  for(layer = 0; layer < getLayers(); ++layer)
967  exactSize = std::max<int>(exactSize, Thing::getExactSize(layer, xPattern, yPattern, zPattern, animationPhase));
968  }
969 
970  return exactSize;
971 }
972 
974 {
976 }
977 
979 {
981 }
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:152
Painter::setAlphaWriting
virtual void setAlphaWriting(bool enable)=0
Otc::InvalidDirection
@ InvalidDirection
Definition: const.h:170
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:200
Painter::setColor
virtual void setColor(const Color &color)
Definition: painter.h:77
CachedText::getTextSize
Size getTextSize()
Definition: cachedtext.h:41
Creature::m_footStepDrawn
stdext::boolean< false > m_footStepDrawn
Definition: creature.h:191
Outfit::getMount
int getMount() const
Definition: outfit.h:60
thingtypemanager.h
SpriteMaskGreen
@ SpriteMaskGreen
Definition: thingtype.h:103
Creature::turn
void turn(Otc::Direction direction)
Definition: creature.cpp:325
Otc::TILE_PIXELS
@ TILE_PIXELS
Definition: const.h:29
Creature::terminateWalk
virtual void terminateWalk()
Definition: creature.cpp:604
Creature::setShield
void setShield(uint8 shield)
Definition: creature.cpp:742
lightview.h
Painter::getColor
Color getColor()
Definition: painter.h:95
Creature::m_jumpHeight
float m_jumpHeight
Definition: creature.h:203
Otc::GameBlueNpcNameColor
@ GameBlueNpcNameColor
Definition: const.h:376
eventdispatcher.h
Creature::m_lastStepFromPosition
Position m_lastStepFromPosition
Definition: creature.h:198
Creature::getDrawOffset
Point getDrawOffset()
Definition: creature.cpp:840
graphics.h
Creature::drawOutfit
void drawOutfit(const Rect &destRect, bool resize)
Definition: creature.cpp:196
g_map
Map g_map
Definition: map.cpp:36
Creature::setEmblemTexture
void setEmblemTexture(const std::string &filename)
Definition: creature.cpp:786
Color
Definition: color.h:32
FrameBufferManager::getTemporaryFrameBuffer
const FrameBufferPtr & getTemporaryFrameBuffer()
Definition: framebuffermanager.h:37
Otc::GameNewSpeedLaw
@ GameNewSpeedLaw
Definition: const.h:379
Creature::m_shield
uint8 m_shield
Definition: creature.h:157
PointF
TPoint< float > PointF
Definition: point.h:87
Tile::getGroundSpeed
int getGroundSpeed()
Definition: tile.cpp:334
Thing::getTile
const TilePtr & getTile()
Definition: thing.cpp:62
Creature::m_jumpOffset
PointF m_jumpOffset
Definition: creature.h:205
TPoint::y
T y
Definition: point.h:83
Otc::DrawNames
@ DrawNames
Definition: const.h:61
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:194
Otc::North
@ North
Definition: const.h:162
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:169
Texture::getSize
const Size & getSize()
Definition: texture.h:50
Creature::onAppear
virtual void onAppear()
Definition: creature.cpp:431
Creature::getDisplacement
virtual Point getDisplacement()
Definition: creature.cpp:912
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:182
Otc::DrawBars
@ DrawBars
Definition: const.h:60
SpriteMaskRed
@ SpriteMaskRed
Definition: thingtype.h:102
uint32
uint32_t uint32
Definition: types.h:35
Creature::setSkullTexture
void setSkullTexture(const std::string &filename)
Definition: creature.cpp:766
Otc::DrawManaBar
@ DrawManaBar
Definition: const.h:63
Creature::setDirection
void setDirection(Otc::Direction direction)
Definition: creature.cpp:659
luavaluecasts.h
Creature::onDeath
virtual void onDeath()
Definition: creature.cpp:481
LightView::addLightSource
void addLightSource(const Point &center, float scaleFactor, const Light &light)
Definition: lightview.cpp:79
Tile::getDrawElevation
int getDrawElevation()
Definition: tile.h:88
g_fonts
FontManager g_fonts
Definition: fontmanager.cpp:29
TRect::bind
void bind(const TRect< T > &r)
Definition: rect.h:273
Creature::setIconTexture
void setIconTexture(const std::string &filename)
Definition: creature.cpp:796
Creature::hasSpeedFormula
bool hasSpeedFormula()
Definition: creature.cpp:808
Creature::onPositionChange
virtual void onPositionChange(const Position &newPos, const Position &oldPos)
Definition: creature.cpp:426
Tile::getPosition
const Position & getPosition()
Definition: tile.h:87
Thing::getAnimationPhases
int getAnimationPhases()
Definition: thing.h:76
Game::getClientVersion
int getClientVersion()
Definition: game.h:316
Creature::updateWalkingTile
void updateWalkingTile()
Definition: creature.cpp:535
texturemanager.h
Creature::m_staticSquareColor
Color m_staticSquareColor
Definition: creature.h:170
Creature::canBeSeen
bool canBeSeen()
Definition: creature.h:125
Creature::m_emblem
uint8 m_emblem
Definition: creature.h:158
Creature::addTimedSquare
void addTimedSquare(uint8 color)
Definition: creature.cpp:814
Creature::getDisplacementX
virtual int getDisplacementX()
Definition: creature.cpp:921
Map::getTile
const TilePtr & getTile(const Position &pos)
Definition: map.cpp:310
LocalPlayer::getMana
double getMana()
Definition: localplayer.h:79
Outfit::setCategory
void setCategory(ThingCategory category)
Definition: outfit.h:49
Otc::EmblemNone
@ EmblemNone
Definition: const.h:249
Creature::m_outfitColorUpdateEvent
ScheduledEventPtr m_outfitColorUpdateEvent
Definition: creature.h:177
Tile::addWalkingCreature
void addWalkingCreature(const CreaturePtr &creature)
Definition: tile.cpp:154
TRect::bottom
T bottom() const
Definition: rect.h:55
Otc::SEA_FLOOR
@ SEA_FLOOR
Definition: const.h:32
ThingType::getLight
Light getLight()
Definition: thingtype.h:159
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:159
Creature::getExactSize
virtual int getExactSize(int layer=0, int xPattern=0, int yPattern=0, int zPattern=0, int animationPhase=0)
Definition: creature.cpp:951
Creature::m_footStep
uint m_footStep
Definition: creature.h:185
CachedText::setFont
void setFont(const BitmapFontPtr &font)
Definition: cachedtext.h:37
Creature::onDisappear
virtual void onDisappear()
Definition: creature.cpp:457
Outfit::getAddons
int getAddons() const
Definition: outfit.h:59
ThingCategoryEffect
@ ThingCategoryEffect
Definition: thingtype.h:45
stdext::round
double round(double r)
Definition: math.cpp:64
Creature::m_baseSpeed
double m_baseSpeed
Definition: creature.h:155
Creature::getDisplacementY
virtual int getDisplacementY()
Definition: creature.cpp:936
ThingType::getAnimationPhases
int getAnimationPhases()
Definition: thingtype.h:150
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:754
Thing
Definition: thing.h:33
Creature::m_skull
uint8 m_skull
Definition: creature.h:156
Tile::removeWalkingCreature
void removeWalkingCreature(const CreaturePtr &creature)
Definition: tile.cpp:159
Creature::m_informationColor
Color m_informationColor
Definition: creature.h:175
Creature::m_nameCache
CachedText m_nameCache
Definition: creature.h:174
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:736
Otc::SpeedFormulaC
@ SpeedFormulaC
Definition: const.h:471
Otc::INVISIBLE_TICKS_PER_FRAME
@ INVISIBLE_TICKS_PER_FRAME
Definition: const.h:37
clock.h
Thing::m_position
Position m_position
Definition: thing.h:131
framebuffermanager.h
Otc::NorthEast
@ NorthEast
Definition: const.h:166
Position::z
short z
Definition: position.h:245
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:64
uint16
uint16_t uint16
Definition: types.h:36
Creature::updateWalk
virtual void updateWalk()
Definition: creature.cpp:586
Otc::ITEM_TICKS_PER_FRAME
@ ITEM_TICKS_PER_FRAME
Definition: const.h:38
Thing::getDisplacementX
virtual int getDisplacementX()
Definition: thing.h:69
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:163
Painter::CompositionMode
CompositionMode
Definition: painter.h:38
SpriteMaskBlue
@ SpriteMaskBlue
Definition: thingtype.h:104
Light::intensity
uint8 intensity
Definition: thingtype.h:119
Creature::m_walkAnimationPhase
int m_walkAnimationPhase
Definition: creature.h:183
Otc::Direction
Direction
Definition: const.h:161
Creature::m_oldPosition
Position m_oldPosition
Definition: creature.h:200
Creature::m_lastStepToPosition
Position m_lastStepToPosition
Definition: creature.h:199
FrameBuffer::draw
void draw()
Definition: framebuffer.cpp:97
Game::getServerBeat
int getServerBeat()
Definition: game.h:338
Otc::SpeedFormulaA
@ SpeedFormulaA
Definition: const.h:469
localplayer.h
Outfit
Definition: outfit.h:29
Creature::setOutfitColor
void setOutfitColor(const Color &color, int duration)
Definition: creature.cpp:683
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:567
ThingCategoryCreature
@ ThingCategoryCreature
Definition: thingtype.h:44
Creature::updateJump
void updateJump()
Definition: creature.cpp:386
Creature::m_jumpDuration
float m_jumpDuration
Definition: creature.h:204
Creature::m_allowAppearWalk
stdext::boolean< false > m_allowAppearWalk
Definition: creature.h:190
Creature::setTypeTexture
void setTypeTexture(const std::string &filename)
Definition: creature.cpp:791
Creature::internalDrawOutfit
void internalDrawOutfit(Point dest, float scaleFactor, bool animateWalk, bool animateIdle, Otc::Direction direction, LightView *lightView=nullptr)
Definition: creature.cpp:105
spritemanager.h
Creature::setIcon
void setIcon(uint8 icon)
Definition: creature.cpp:760
Creature::m_skullTexture
TexturePtr m_skullTexture
Definition: creature.h:161
painterogl2_shadersources.h
Position::translated
Position translated(int dx, int dy, short dz=0) const
Definition: position.h:187
Otc::West
@ West
Definition: const.h:165
Graphics::canUseFBO
bool canUseFBO()
Definition: graphics.cpp:293
Creature::m_light
Light m_light
Definition: creature.h:153
Creature::m_walkUpdateEvent
ScheduledEventPtr m_walkUpdateEvent
Definition: creature.h:192
Creature::walk
virtual void walk(const Position &oldPos, const Position &newPos)
Definition: creature.cpp:335
Position
Definition: position.h:33
Creature::setName
void setName(const std::string &name)
Definition: creature.cpp:631
Thing::isLocalPlayer
virtual bool isLocalPlayer()
Definition: thing.h:58
Color::white
static const Color white
Definition: color.h:101
Creature::m_walkOffset
Point m_walkOffset
Definition: creature.h:195
Creature::setSpeed
void setSpeed(uint16 speed)
Definition: creature.cpp:714
Creature::jump
void jump(int height, int duration)
Definition: creature.cpp:374
Thing::getNumPatternY
int getNumPatternY()
Definition: thing.h:74
Creature::m_speedFormula
std::array< double, Otc::LastSpeedFormula > m_speedFormula
Definition: creature.h:180
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:43
Creature::updateOutfitColor
void updateOutfitColor(Color color, Color finalColor, Color delta, int duration)
Definition: creature.cpp:699
TRect::expanded
TRect< T > expanded(T add) const
Definition: rect.h:120
Creature::m_iconTexture
TexturePtr m_iconTexture
Definition: creature.h:165
Painter::drawBoundingRect
virtual void drawBoundingRect(const Rect &dest, int innerLineWidth=1)=0
Map::getLight
Light getLight()
Definition: map.h:235
Creature::m_shieldTexture
TexturePtr m_shieldTexture
Definition: creature.h:162
Size
TSize< int > Size
Definition: size.h:107
map.h
Otc::SpeedFormulaB
@ SpeedFormulaB
Definition: const.h:470
Creature::m_icon
uint8 m_icon
Definition: creature.h:160
Timer::restart
void restart()
Definition: timer.cpp:27
Creature::updateWalkOffset
virtual void updateWalkOffset(int totalPixelsWalked)
Definition: creature.cpp:521
TPoint::x
T x
Definition: point.h:83
ThingTypeManager::getThingType
const ThingTypePtr & getThingType(uint16 id, ThingCategory category)
Definition: thingtypemanager.cpp:377
Game::getFeature
bool getFeature(Otc::GameFeature feature)
Definition: game.h:310
g_graphics
Graphics g_graphics
Definition: graphics.cpp:44
Creature::m_showTimedSquare
stdext::boolean< false > m_showTimedSquare
Definition: creature.h:171
Creature::m_outfitColorTimer
Timer m_outfitColorTimer
Definition: creature.h:178
Creature::setShieldTexture
void setShieldTexture(const std::string &filename, bool blink)
Definition: creature.cpp:771
Creature::m_footTimer
Timer m_footTimer
Definition: creature.h:187
TextureManager::getTexture
TexturePtr getTexture(const std::string &fileName)
Definition: texturemanager.cpp:90
Creature::m_walkTimer
Timer m_walkTimer
Definition: creature.h:186
ThingType
Definition: thingtype.h:123
Creature::m_removed
stdext::boolean< true > m_removed
Definition: creature.h:173
Color::blue
static const Color blue
Definition: color.h:107
Otc::SouthEast
@ SouthEast
Definition: const.h:167
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:193
Position::getDirectionFromPosition
Otc::Direction getDirectionFromPosition(const Position &position) const
Definition: position.h:177
Creature::m_direction
Otc::Direction m_direction
Definition: creature.h:151
Map::getOrCreateTile
const TilePtr & getOrCreateTile(const Position &pos)
Definition: map.cpp:294
Rect
TRect< int > Rect
Definition: rect.h:319
Otc::ShieldNone
@ ShieldNone
Definition: const.h:234
FrameBuffer::bind
void bind()
Definition: framebuffer.cpp:84
Otc::GameHideNpcNames
@ GameHideNpcNames
Definition: const.h:398
CachedText::draw
void draw(const Rect &rect)
Definition: cachedtext.cpp:34
Thing::isAnimateAlways
bool isAnimateAlways()
Definition: thing.h:113
Otc::South
@ South
Definition: const.h:164
Thing::getDisplacementY
virtual int getDisplacementY()
Definition: thing.h:70
Outfit::getHeadColor
Color getHeadColor() const
Definition: outfit.h:63
Creature::updateWalkAnimation
virtual void updateWalkAnimation(int totalPixelsWalked)
Definition: creature.cpp:486
Color::alpha
static const Color alpha
Definition: color.h:100
LocalPlayer::getMaxMana
double getMaxMana()
Definition: localplayer.h:80
Otc::NpcIconNone
@ NpcIconNone
Definition: const.h:258
Creature::setSpeedFormula
void setSpeedFormula(double speedA, double speedB, double speedC)
Definition: creature.cpp:801
Creature::m_healthPercent
uint8 m_healthPercent
Definition: creature.h:150
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:184
Map::notificateTileUpdate
void notificateTileUpdate(const Position &pos)
Definition: map.cpp:62
Thing::getDisplacement
virtual Point getDisplacement()
Definition: thing.h:68
Creature::draw
virtual void draw(const Point &dest, float scaleFactor, bool animate, LightView *lightView=nullptr)
Definition: creature.cpp:66
Otc::NorthWest
@ NorthWest
Definition: const.h:169
effect.h
Thing::getNumPatternZ
int getNumPatternZ()
Definition: thing.h:75
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
ThingType::draw
void draw(const Point &dest, float scaleFactor, int layer, int xPattern, int yPattern, int zPattern, int animationPhase, LightView *lightView=nullptr)
Definition: thingtype.cpp:374
Thing::getExactSize
virtual int getExactSize(int layer, int xPattern, int yPattern, int zPattern, int animationPhase)
Definition: thing.h:71
Otc::East
@ East
Definition: const.h:163
Game::getLocalPlayer
LocalPlayerPtr getLocalPlayer()
Definition: game.h:343
g_painter
Painter * g_painter
Definition: painter.cpp:28
Light::color
uint8 color
Definition: thingtype.h:120
SpriteMaskYellow
@ SpriteMaskYellow
Definition: thingtype.h:105
Outfit::getFeetColor
Color getFeetColor() const
Definition: outfit.h:66
FrameBuffer::resize
void resize(const Size &size)
Definition: framebuffer.cpp:57
Creature::m_walking
stdext::boolean< false > m_walking
Definition: creature.h:189
Creature::stopWalk
virtual void stopWalk()
Definition: creature.cpp:365
Outfit::getCategory
ThingCategory getCategory() const
Definition: outfit.h:61
TRect::moveTop
void moveTop(T pos)
Definition: rect.h:105
Light
Definition: thingtype.h:117
Thing::getLayers
int getLayers()
Definition: thing.h:72
Creature::getStepDuration
int getStepDuration(bool ignoreDiagonal=false, Otc::Direction dir=Otc::InvalidDirection)
Definition: creature.cpp:855
Creature::m_lastStepDirection
Otc::Direction m_lastStepDirection
Definition: creature.h:197
Thing::isNpc
virtual bool isNpc()
Definition: thing.h:55
Creature::updateShield
void updateShield()
Definition: creature.cpp:826
Creature::m_name
std::string m_name
Definition: creature.h:149
TRect::top
T top() const
Definition: rect.h:53
Creature::m_walkTurnDirection
Otc::Direction m_walkTurnDirection
Definition: creature.h:196
game.h
Clock::millis
ticks_t millis()
Definition: clock.h:37
Creature::m_walkingTile
TilePtr m_walkingTile
Definition: creature.h:188
Creature::m_outfitColor
Color m_outfitColor
Definition: creature.h:176
Creature::m_showStaticSquare
stdext::boolean< false > m_showStaticSquare
Definition: creature.h:172
Creature::m_typeTexture
TexturePtr m_typeTexture
Definition: creature.h:164
Creature::m_jumpTimer
Timer m_jumpTimer
Definition: creature.h:206
Painter::CompositionMode_Multiply
@ CompositionMode_Multiply
Definition: painter.h:40
Outfit::getLegsColor
Color getLegsColor() const
Definition: outfit.h:65
g_textures
TextureManager g_textures
Definition: texturemanager.cpp:33
TRect::bottomRight
TPoint< T > bottomRight() const
Definition: rect.h:61
TPoint< int >
Creature::setHealthPercent
void setHealthPercent(uint8 healthPercent)
Definition: creature.cpp:637
Color::from8bit
static Color from8bit(int color)
Definition: color.h:90
g_framebuffers
FrameBufferManager g_framebuffers
Definition: framebuffermanager.cpp:26
TRect::setWidth
void setWidth(T width)
Definition: rect.h:85
ThingType::getDisplacementX
int getDisplacementX()
Definition: thingtype.h:153
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:726
Event::cancel
void cancel()
Definition: event.cpp:49
Creature::setOutfit
void setOutfit(const Outfit &outfit)
Definition: creature.cpp:665
Tile::isEmpty
bool isEmpty()
Definition: tile.cpp:551
Creature::m_shieldBlink
stdext::boolean< false > m_shieldBlink
Definition: creature.h:167
TSize< int >
ThingType::getDisplacementY
int getDisplacementY()
Definition: thingtype.h:154
g_clock
Clock g_clock
Definition: clock.cpp:25
Creature::Creature
Creature()
Definition: creature.cpp:44
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:557
Creature::setEmblem
void setEmblem(uint8 emblem)
Definition: creature.cpp:748
Creature::rawGetThingType
ThingType * rawGetThingType()
Definition: creature.cpp:978
Creature::m_speed
int m_speed
Definition: creature.h:154
Otc::SouthWest
@ SouthWest
Definition: const.h:168
Creature::m_showShieldTexture
stdext::boolean< true > m_showShieldTexture
Definition: creature.h:166
uint8
uint8_t uint8
Definition: types.h:37
Creature::getThingType
const ThingTypePtr & getThingType()
Definition: creature.cpp:973
Painter::drawTexturedRect
virtual void drawTexturedRect(const Rect &dest, const TexturePtr &texture, const Rect &src)=0
Creature::m_id
uint32 m_id
Definition: creature.h:148
ThingTypeManager::isValidDatId
bool isValidDatId(uint16 id, ThingCategory category)
Definition: thingtypemanager.h:75
Otc::SkullNone
@ SkullNone
Definition: const.h:224
item.h