Advertisement
Guest User

Untitled

a guest
Feb 28th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. int64_t Creature::getStepDuration() const
  2. {
  3. if (isRemoved()) {
  4. return 0;
  5. }
  6.  
  7. uint32_t calculatedStepSpeed;
  8. uint32_t groundSpeed;
  9.  
  10. int32_t stepSpeed = getStepSpeed();
  11. if (stepSpeed > -Creature::speedB) {
  12. calculatedStepSpeed = floor((Creature::speedA * log((stepSpeed / 2) + Creature::speedB) + Creature::speedC) + 0.5);
  13. if (calculatedStepSpeed <= 0) {
  14. calculatedStepSpeed = 1;
  15. }
  16. } else {
  17. calculatedStepSpeed = 1;
  18. }
  19.  
  20. Item* ground = _tile->getGround();
  21. if (ground) {
  22. groundSpeed = Item::items[ground->getID()].speed;
  23. if (groundSpeed == 0) {
  24. groundSpeed = 150;
  25. }
  26. } else {
  27. groundSpeed = 150;
  28. }
  29.  
  30. double duration = std::floor(1000 * groundSpeed / calculatedStepSpeed);
  31. int64_t stepDuration = std::ceil(duration / 50) * 50;
  32.  
  33. const Monster* monster = getMonster();
  34. if (monster && monster->isTargetNearby() && !monster->isFleeing() && !monster->getMaster()) {
  35. stepDuration *= 2;
  36. }
  37.  
  38. return stepDuration;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement