Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-22-2002, 09:55 AM
prozac424242 prozac424242 is offline
Registered User
prozac424242's Avatar
Join Date: May 2001
Location: Gone crazy: back soon
Posts: 356
prozac424242 is on a distinguished road
Send a message via ICQ to prozac424242 Send a message via AIM to prozac424242
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 !!!
__________________

Useful links:
Graal Stats
Client Script Functions-GS1 to GS2
Serverside Script Functions-Gscript page
Particle Engine-Player Attributes
Server Options-Admin rights-Gmaps
Quote:
Originally Posted by Admins
Thanks for developing and improving playerworlds and such
Reply With Quote
  #2  
Old 04-22-2002, 04:40 PM
Spanko Spanko is offline
Squeaker of Soles
Spanko's Avatar
Join Date: Nov 2001
Location: The Netherworl...lands
Posts: 1,366
Spanko is on a distinguished road
Send a message via ICQ to Spanko Send a message via AIM to Spanko Send a message via Yahoo to Spanko
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.
__________________

ICQ: 125283920
MSN: [email protected]
AIM: Squeax0r
Squeaker seems unable to access the forum using this account.. tis a sad day.
Now with occasional Asuka flavour! Ooops a bit too much...
Asuka should be king of Dustari!

"Y'know, some days even my lucky rocketship underpants don't even help."
Reply With Quote
  #3  
Old 04-22-2002, 10:34 PM
jeff335 jeff335 is offline
Registered User
Join Date: Oct 2001
Posts: 605
jeff335 is on a distinguished road
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.
__________________

Quote:
Some people like standing around talking to idiots in the real world, and some don't. Neither choice is inherently better than the other.

-Kaimetsu
Reply With Quote
  #4  
Old 04-23-2002, 09:59 AM
prozac424242 prozac424242 is offline
Registered User
prozac424242's Avatar
Join Date: May 2001
Location: Gone crazy: back soon
Posts: 356
prozac424242 is on a distinguished road
Send a message via ICQ to prozac424242 Send a message via AIM to prozac424242
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;}


__________________

Useful links:
Graal Stats
Client Script Functions-GS1 to GS2
Serverside Script Functions-Gscript page
Particle Engine-Player Attributes
Server Options-Admin rights-Gmaps
Quote:
Originally Posted by Admins
Thanks for developing and improving playerworlds and such
Reply With Quote
  #5  
Old 04-25-2002, 03:38 AM
LilNiglet LilNiglet is offline
Registered User
Join Date: Jun 2001
Posts: 3,178
LilNiglet is on a distinguished road
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.
Reply With Quote
  #6  
Old 04-25-2002, 08:55 PM
emortylone emortylone is offline
Registered User
Join Date: Apr 2002
Location: Control-NPC
Posts: 834
emortylone is on a distinguished road
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
__________________
Quote:
*Stefan: it seems sometimes they hire newbie scripters everywhere x-x
*Stefan: scripters are sometimes like people that draw paintings
*Stefan: all that counts is that it looks nice
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:49 AM.


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