Initializing the Archer
There are a few differences with an Archer's initialize function that I will point out first.

function Initialize(){
showcharacter;
setcharprop #n,Name;
  setcharprop #3,Head;
hearts=10;
this.speed=.4;
swordpower=1;
this.radius=1.5;
this.keepdist=16;
this.closedist=3;
  timeout=.05;
}

What you will notice I did here is I removed the variable "this.attackdist" and replaced it with two vars: this.keepdist and this.closedist. In general, archers try to keep their distance from their target. So the variable this.keepdist will be used to see if the baddy is a set distance from its target. So if the distance is greater than this value, it will move closer to align its shot, but if the target is too close, then the archer will retreat. I threw in the var this.closedist because I like my archer's to use a sword when someone gets way too close to the baddy. So this works like "this.attackdist" did for the sword wielding baddy. And basically keeps the archer alive a little longer when someone is attacking it with a sword.
This function of course has to be called when you want the baddy to be created. Without it, then the baddy won't have any properties at all, and won't work.

Previous Topic         Home         Next Topic