NPC Code:
if (created) {
showcharacter;
dontblock;
setcharprop #3,baddygray.png;
setcharani tyhm_swamp_baddy_hide,wbow1.png;
hearts=2;
this.counter=3.6;
hide;
}
if (playerenters||timeout) {
if (isleader) {
if (this.counter==1.5) {
// putleaps 0,x,y;
setcharani tyhm_swamp_baddy_shoot,wbow1.png;
}else if (this.counter <3) {
//there's a clever way to do the following in one line.
//I don't particularly care, though.
if (abs(playerx-x)>abs(playery-y)){
if(playerx<x) dir=1;
else dir=3;
}else{
if(playery<y) dir=0;
else dir=2;
}
this.vulnerable = 1;
if (this.counter == 1.8) {
setshootparams wasshot,1;
shoot x,y+0.5,1,(dir+1)*1.57,0,-1,adv_shot,advshot1.png;
//shootarrow dir;
}
} else if (this.counter < 4.4){
this.vulnerable = 0;
hide;
} else {
this.counter = 0;
setcharani tyhm_swamp_baddy_rustle,wbow1.png;
show;
}
this.counter+=0.05;
}
timereverywhere;
timeout=0.05;
}
if((wa****||wasshot||exploded)&&this.vulnerable>0) {
hearts--;
setcharani baddyhurt,;
if (hearts<=0){
setcharani baddydead,;
sleep 1;//I know, I know, bad form but it's temporary.
temp.i=int(random(0,20));
if (temp.i<5) lay greenrupee;
else if (temp.i<6) lay bluerupee;
else if (temp.i<9) lay heart;
destroy;
}
}
I leave the Putleaps problem to people smarter than I - I scripted it into the gani, but it doesn't seem to Go. If I gotta gani the leaves in, I will, I'd just rather not.