Quote:
Originally posted by prozac424242
Ok guys, I made a working version that uses strings!
Save this one in graal/levels/npcs folder as defnpcShootWepaonString.txt
and have fun!
Hint: for action, put: putexplosion 1 this.x,this.y
no semicolon
or
putbomb 1,this.x,this.y
and blank out playerdir
and increase repeats!
fun!
NPC Code:
// NPC made by Prozac
//#COMMENTS NPC that shoots something, String based! -By Prozac-
//#EDIT action shootarrow
//#EDIT direction playerdir
//#EDIT How_much_ammo 1
//#EDIT Repeat 1
//#EDIT Weapon_name MyBow
//#EDIT AmmoStringName ammo1
//#EDIT HowMuchGiveToStart 5
//#EDIT SayIfNoAmmoLeft No_Ammo_Left!
if (created)
{setimg wbowi1.png; show;}
//#CLIENTSIDE
if (playertouchsme)
{toweapons Weapon_name;
setstring AmmoStringName,HowMuchGiveToStart;
}
if (weaponfired && strtofloat(#s(AmmoStringName))>0)
{
this.distance=Repeat; //how far to throw
this.dir=playerdir;
this.x=playerx+.5+vecx(this.dir)*2;
this.y=playery+1+vecy(this.dir)*2;
for(this.i=0; this.i<this.distance; this.i++)
{
freezeplayer .3; playersprite=33;
this.x+=vecx(this.dir);
this.y+=vecy(this.dir);
action direction;
sleep .05;
}
setstring AmmoStringName,#v(strtofloat(#s(AmmoStringName))-How_much_ammo)
}
if (weaponfired && strtofloat(#s(AmmoStringName))<=0)
{setplayerprop #c,SayIfNoAmmoLeft;}
|
You don't mind if this is used on playerworlds, do you? With proper credit, of course.