Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Shooting weapon defnpc!!! (https://forums.graalonline.com/forums/showthread.php?t=27852)

prozac424242 04-22-2002 09:55 AM

Shooting weapon defnpc!!!
 
Here is a little NPC that I made to save in your
graall/levels/npcs folder as a text file, defnpcShootWeaopn.txt
TONS of shooting/spell stuff can be done with this.
Anything that starts at the players position and moves out in a line away form the player.
NPC Code:

// NPC made by Prozac
//#COMMENTS NPC that shoots something
//#EDIT action shootarrow
//#EDIT direction playerdir
//#EDIT How_much_ammo 1
//#EDIT Ammo_type playerdarts
//#EDIT Repeat 1
//#EDIT Weapon_name MyBow

if (created)
{setimg wbowi1.png; show;}

//#CLIENTSIDE
if (playertouchsme){toweapons Weapon_name;}

if (weaponfired && Ammo_type>0)
{
this.distance=Repeat; //how far to throw
this.dir=playerdir;
this.x=playerx+vecx(this.dir)*2;
this.y=playery+.5+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;
}
Ammo_type=Ammo_type-How_much_ammo;
}



Once it saved, go to Predefined NPCs in Graal.
Select the Shootweapon.
action: can be anythign from shootarow, putbomb, lay rupee ....
direction: playerdir if shooting an arrow type, leave blank if not an arrow.
How_much_ammo: what it costs the player to use this item
Repeat: how many times to shoot the arrow/how many bombs to lay/explosions to put, etc. If not an arrow, each succesive repetition will be a bit further out form the player.
Weapon_name: what the weapon is called when player presses Q and selects it.

Have fun! let me know of any errors/comments etc.

-Prozac-
2 and a half years of Graal and still going !!!

Spanko 04-22-2002 04:40 PM

Quote:

Originally posted by Kaimetsu
It's just a shame that people will try to use strings as the Ammo_type.
Shouldn't that be that people should be using strings for it?
Though of course if you mean that they should be using playerbombs/playerdarts/etc instead, then you're correct.

jeff335 04-22-2002 10:34 PM

Since there are silly people who will use this instead of coding their own NPC (or modifying this one to their specifications), Kai is right. You should clearly state that Ammotype must be a variable and possibly make another version for stuff like client.zalcores.

prozac424242 04-23-2002 09:59 AM

not to worry
 
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;}



LilNiglet 04-25-2002 03:38 AM

Re: not to worry
 
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.

emortylone 04-25-2002 08:55 PM

So basically it is alittle machine gun kind of thing? Or just makes a path? I'll save it when i get home, thanx Prozac.
---Shifter


All times are GMT +2. The time now is 09:42 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.