peonso

Untitled

Oct 12th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. bool Monster::getNextStep(Direction& dir, uint32_t& flags)
  2. {
  3. if(isIdle || getHealth() <= 0){
  4. //we dont have anyone watching might aswell stop walking
  5. eventWalk = 0;
  6. return false;
  7. }
  8.  
  9. bool result = false;
  10. if((!followCreature || !hasFollowPath) && !isSummon()){
  11. if(followCreature){
  12. result = getRandomStep(getPosition(), dir);
  13. }else{
  14. if(getTimeSinceLastMove() > 1000){
  15. //choose a random direction
  16. result = getRandomStep(getPosition(), dir);
  17. }
  18. }
  19. }
  20. else if(isSummon() || followCreature){
  21. result = Creature::getNextStep(dir, flags);
  22. if(result){
  23. flags |= FLAG_PATHFINDING;
  24. }
  25. else{
  26. //target dancing
  27. if(attackedCreature && attackedCreature == followCreature){
  28. if(isFleeing()){
  29. result = getDanceStep(getPosition(), dir, false, false);
  30. }
  31. else if(mType->staticAttackChance < (uint32_t)random_range(1, 100)){
  32. result = getDanceStep(getPosition(), dir);
  33. }
  34. }
  35. }
  36. }
  37.  
  38. if(result && (canPushItems() || canPushCreatures()) ){
  39. const Position& pos = Spells::getCasterPosition(this, dir);
  40. Tile* tile = g_game.getTile(pos.x, pos.y, pos.z);
  41. if(tile){
  42. if(canPushItems()){
  43. pushItems(tile);
  44. }
  45.  
  46. if(canPushCreatures()){
  47. pushCreatures(tile);
  48. }
  49. }
  50. #ifdef __DEBUG__
  51. else{
  52. std::cout << "getNextStep - no tile." << std::endl;
  53. }
  54. #endif
  55. }
  56.  
  57.  
  58. if (result) {
  59. const Position& pos = Spells::getCasterPosition(this, dir);
  60. Tile* tile = g_game.getTile(pos.x, pos.y, pos.z);
  61. if (tile) {
  62. Creature* c = tile->getTopVisibleCreature(this);
  63. if (c) {
  64. selectTarget(c);
  65. }
  66. }
  67. }
  68.  
  69. return result;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment