PHP Code:
//#CLIENTSIDE //This sets the character look
function onCreated() {
this.showCharacter();
this.head = "head3.png";
this.body = "body2.png";
this.attr[1] = "hat49.png";
this.dir = 2;
this.firing = false;
}
/*
This function is for when the player touches the NPC,
it'll show a message, and face the character.
In scheduleevent, after 5 seconds, it'll call the function to shoot
arrows at whatever direction it was pointing.
this.firing makes sure that you can't repeatedly touch the NPC to keep
it firing.
*/
function onPlayerTouchsMe() {
if (this.firing) return;
this.firing = true;
say2("message here");
switch (player.dir) {
case 0:
this.dir = 2;
break;
case 1:
this.dir = 3;
break;
case 2:
this.dir = 0;
break;
case 3:
this.dir = 1;
break;
}
scheduleevent(5, "timeToRek");
}
/*With the for loop, the NPC will fire 6 arrows over a time
of 3 seconds.
*/
function onTimeToRek() {
for (i = 0; i <= 5; i++) {
shootarrow(this.dir);
sleep(.5);
}
this.firing = false;
}