Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const HEALTH = 50;
- const HURT_ANI = "hurt";
- const IDLE_ANI = "idle";
- const WALK_ANI = "walk";
- const BADDY_LEVEL = "levelname";
- const SWORD_ANI = "sword";
- const BADDY_NICK = "me";
- const DEAD_ANI = "dead";
- function onCreated() {
- setShape(1, 32, 32);
- showcharacter();
- this.health = HEALTH;
- this.head = "head0.png";
- this.body = "body.png";
- this.baddy_level = BADDY_LEVEL;
- this.colors[0] = "orange";
- this.colors[1] = "white";
- this.colors[2] = "blue";
- this.colors[3] = "red";
- this.colors[4] = "black";
- this.shield = "no-shield.png";
- this.dir = 2;
- this.nick = "";
- this.ap = 0;
- this.swordpower = 1;
- setcharani(IDLE_ANI, NULL);
- sleep(random(.5, 5));
- setcharani(IDLE_ANI, NULL);
- sleep(1.5);
- this.nick = BADDY_NICK;
- setTimer(0.05);
- }
- function onPlayerEnters() {
- if (this.got_player == false || players.size() <= 1) {
- onCreated();
- }
- }
- function onTimeout() {
- if (players.size() <= 0) {
- this.got_player = false;
- return;
- }
- this.got_player = true;
- temp.pl = findnearestplayer(this.x, this.y);
- this.target = temp.pl.account;
- this.dist_x = temp.pl.x - this.x;
- this.dist_y = temp.pl.y - this.y;
- this.len = ((this.dist_x * this.dist_x) + (this.dist_y * this.dist_y )) ^ .4;
- this.move_x = (this.dist_x / this.len);
- this.move_y = (this.dist_y / this.len);
- if (temp.pl.x in |this.x-4, this.x+4| && temp.pl.y in |this.y-4, this.y+4|) {
- setCharAni(SWORD_ANI, "");
- sleep(random(.1, .3));
- }
- setcharani(WALK_ANI, NULL);
- move(this.move_x, this.move_y, .5, 4+8+16);
- sleep(.8);
- setTimer(0.05);
- }
- function onWasHit() {
- if (this.health - player.swordpower > 0) {
- setCharani(HURT_ANI, "");
- this.health -= player.swordpower;
- this.chat = "(HP:"SPC this.health @"/"@ HEALTH @")";
- sleep(.2);
- this.chat = "";
- if ( this.health <= 20 ){
- this.chat = "";
- }
- } else {
- this.chat = "";
- setCharani(DEAD_ANI, "");
- sleep(5);
- onCreated();
- }
- setTimer(0.05);
- }
- function onPlayerLeaves() {
- if (player.level != this.baddy_level ) {
- this.target = false;
- onCreated();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement