Hi there, this NPC i have been working for a customizale board
does not quite qork right. Instead of all of the arrows showing up,
i would like it so that one arrow shows up on its own x and y each time it is fired. any tips, knowledge and help would be great. For each time you fire another arrow starts on its own and any y and the other arrows keep going til they hit a wall, that is the goal.
NPC Code:
// NPC made by Prozac
// may not be used on any playerworld wihtout permission
// to ask, email: [email protected]
// customizable bow
if (playerenters) {show;}
if (playertouchsme)
{
toweapons Custom Bow; //or your weapon name
if (isweapon)
{
this.ammo=10; // number of times to shoot at once
this.power=2; // how many half hearts to hit
setarray this.shotx,this.ammo;
setarray this.shoty,this.ammo; //vars for x and y of each arrow;
setarray this.inuse,this.ammo; //1=arrow being shot, 0=not being shot
this.fired=0; // how many times been fired
}
}
if (weaponfired)
{
this.ammo=10; // number of times to shoot at once
this.power=1; // how many half hearts to hit
setarray this.shotx,this.ammo;
setarray this.shoty,this.ammo; //vars for x and y of each arrow;
setarray this.inuse,this.ammo; //1=arrow being shot, 0=not being shot
if (this.fired<this.ammo)
{this.fired++; this.inuse[this.fired]=1;}else{this.fired=0;}
this.dir=playerdir;
this.shotx[this.fired]=playerx+vecx(this.dir)*2;
this.shoty[this.fired]=playery+.5+vecy(this.dir)*2;
freezeplayer .2; playersprite=14;
test();
}
function test()
{
while(this.fired>0)
{
for (this.i=0; this.i<this.ammo; this.i++)
{
if (this.inuse[this.i]==1)
{
if (!onwall(this.shotx[this.fired]+.5,this.shoty[this.fired]+.5))
{
this.shotx[this.fired]+=vecx(this.dir);
this.shoty[this.fired]+=vecy(this.dir);
showimg this.i,arrow.gif,this.shotx[this.fired]+.5,this.shoty[this.fired]+.5;
hitobjects this.power,this.shotx[this.fired]+.5,this.shoty[this.fired]+.5;
sleep .05;
}
else
{
this.inuse[this.i]=0; this.fired--; hideimg this.i;
}
}
}
}
return;
}