Advertisement
Guest User

Untitled

a guest
Apr 29th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. if global.Turn == 0 {
  2. //thinking
  3. if !meFinishedTurn {
  4.  
  5. //Мозги врага
  6. if !meDecided { //Decide what to do
  7. //Направления движения 0 - стоять на месте.
  8. xDir = 0;
  9. yDir = 0;
  10. //Потенциальная точка прибытия - такая же, как и сейчас.
  11. xPot = x;
  12. yPot = y;
  13.  
  14. //Выбираем направления к игроку по x и y
  15. if obj_hero.y<y {yDir=-1;}
  16. if obj_hero.y>y {yDir=1;}
  17. if obj_hero.x<x {xDir=-1;}
  18. if obj_hero.x>x {xDir=1;}
  19.  
  20. //Выбираем только одно направление, если надо идти по диагонали.
  21. if (xDir!=0 && yDir!=0) { if random(1)<0.5 {xDir=0} else {yDir=0} };
  22.  
  23. //Находим потенциальный тайл назначения.
  24. yPot+=yDir*global.MoveStep;
  25. xPot+=xDir*global.MoveStep;
  26. tilePotID = tilemap_get_at_pixel(global.map_id, xPot, yPot);
  27.  
  28. //помечаем тайл назначения для наглядности.
  29. tilemap_set_at_pixel(global.map_id2, 12 ,xPot, yPot);
  30.  
  31. //решение принято.
  32. meDecided=true;
  33. };
  34.  
  35. //can move?
  36. if (tilePotID = 10) || (tilePotID = 2) {
  37. //moving
  38. x+=xDir*2;
  39. y+=yDir*2;
  40. if x==xPot {xDir=0};
  41. if y==yPot {yDir=0};
  42. if (x==xPot) && (y==yPot) {meFinishedTurn=true;}
  43. // meFinishedTurn=true;
  44. };
  45. //fall into pit
  46. if (tilePotID = 11) {
  47. global.EnemiesInRoom--;
  48. instance_destroy();
  49. };
  50.  
  51.  
  52. if meFinishedTurn {global.EnemiesWaitingForTurn--;
  53. meDecided=false;
  54. meFinishedTurn=false;
  55. tilemap_set_at_pixel(global.map_id2, 0 ,xPot, yPot);
  56. oldX=x;
  57. oldY=y;};
  58. };
  59. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement