Attempted translation (someone else can figure out if it even works at all):
NPC Code:
function onCreated() {
showcharacter();
dontblock();
headimg = "frog.png";
setcharani("tyhm_frog_baddy_rustle",NULL);
setTimer(0.1);
}
function onTimeout() {
if (this.counter==1) {
setcharani ("tyhm_frog_baddy",NULL);
}else if (this.counter <3) {
this.vulnerable = 1;
this.attacking = 1;
} else if (this.counter < 4){
this.vulnerable = 0;
this.attacking = 0;
} else if (this.counter < 5){
hide();
} else {
this.counter = 0;
x+=random(-5,+5);
if (x>63) x=63;
else if (x<0) x=0;
y+=random(-5,+5);
if (y>63) y=63;
else if (y<0) y=0;
show();
}
this.counter+=0.05;
if (this.attacking > 0) {
//frankly, this part needs to be customized to each damage system anyway.
}
setTimer(0.05);
}
function onWa****(){
struck();
}
function onWasShot(){
struck();
}
function onExploded(){
struck();
}
function struck(){
if(this.vulnerable>0){
setcharani("baddydead",NULL);
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);
setTimer(0);
this.revive=1;
hide();
}
}
function onPlayerEnters(){
if (this.revive>0){
setTimer(0.05);
this.revive=0;
this.counter=5;
}
}