Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. const HEALTH = 50;
  2. const HURT_ANI = "hurt";
  3. const IDLE_ANI = "idle";
  4. const WALK_ANI = "walk";
  5. const BADDY_LEVEL = "levelname";
  6. const SWORD_ANI = "sword";
  7. const BADDY_NICK = "me";
  8. const DEAD_ANI = "dead";
  9.  
  10. function onCreated() {
  11. setShape(1, 32, 32);
  12. showcharacter();
  13. this.health = HEALTH;
  14. this.head = "head0.png";
  15. this.body = "body.png";
  16. this.baddy_level = BADDY_LEVEL;
  17. this.colors[0] = "orange";
  18. this.colors[1] = "white";
  19. this.colors[2] = "blue";
  20. this.colors[3] = "red";
  21. this.colors[4] = "black";
  22. this.shield = "no-shield.png";
  23. this.dir = 2;
  24. this.nick = "";
  25. this.ap = 0;
  26. this.swordpower = 1;
  27. setcharani(IDLE_ANI, NULL);
  28. sleep(random(.5, 5));
  29. setcharani(IDLE_ANI, NULL);
  30. sleep(1.5);
  31. this.nick = BADDY_NICK;
  32. setTimer(0.05);
  33. }
  34.  
  35. function onPlayerEnters() {
  36. if (this.got_player == false || players.size() <= 1) {
  37. onCreated();
  38. }
  39. }
  40.  
  41. function onTimeout() {
  42. if (players.size() <= 0) {
  43. this.got_player = false;
  44. return;
  45. }
  46. this.got_player = true;
  47. temp.pl = findnearestplayer(this.x, this.y);
  48. this.target = temp.pl.account;
  49. this.dist_x = temp.pl.x - this.x;
  50. this.dist_y = temp.pl.y - this.y;
  51. this.len = ((this.dist_x * this.dist_x) + (this.dist_y * this.dist_y )) ^ .4;
  52. this.move_x = (this.dist_x / this.len);
  53. this.move_y = (this.dist_y / this.len);
  54. if (temp.pl.x in |this.x-4, this.x+4| && temp.pl.y in |this.y-4, this.y+4|) {
  55. setCharAni(SWORD_ANI, "");
  56. sleep(random(.1, .3));
  57. }
  58. setcharani(WALK_ANI, NULL);
  59. move(this.move_x, this.move_y, .5, 4+8+16);
  60. sleep(.8);
  61. setTimer(0.05);
  62. }
  63.  
  64. function onWasHit() {
  65. if (this.health - player.swordpower > 0) {
  66. setCharani(HURT_ANI, "");
  67. this.health -= player.swordpower;
  68. this.chat = "(HP:"SPC this.health @"/"@ HEALTH @")";
  69. sleep(.2);
  70. this.chat = "";
  71. if ( this.health <= 20 ){
  72. this.chat = "";
  73. }
  74. } else {
  75. this.chat = "";
  76. setCharani(DEAD_ANI, "");
  77. sleep(5);
  78. onCreated();
  79. }
  80. setTimer(0.05);
  81. }
  82.  
  83. function onPlayerLeaves() {
  84. if (player.level != this.baddy_level ) {
  85. this.target = false;
  86. onCreated();
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement