Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   on-off defnpc for the ****s (https://forums.graalonline.com/forums/showthread.php?t=39028)

prozac424242 10-08-2002 07:39 AM

on-off defnpc for the ****s
 
Heres one for you newbie scripters who want to make
an npc that you can press D once for "on" mode, and fire again
to set in "off" mode.

IMPORTANT
close graal
Save as: graal/levels/npcs/defnpcOnOffWeapon.txt
then open graal and go to Predefined npcs.

Try putting for npc-action, shootarrow playerdir

NPC Code:

// NPC made by Prozac
//#COMMENTS Weapon with on and off mode
//#EDIT weapon_name item
//#EDIT to-get-this playertouchsme
//#EDIT npc-action

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

//#CLIENTSIDE
if (to-get-this)
{toweapons weapon_name; this.on=0;}

//on and off part when pressing D
if (weaponfired && this.on==0)
{this.on=1; sleep .2; timeout=.05;}
if (weaponfired && this.on==1)
{this.on=0; sleep .2;}

if (timeout && this.on==1)
{
//put your npc actions here

npc-action

timeout=.05;
}




and its OK that this is on this forum becasue
the script provided there does not do anything practical
as it its .. its a form, a mold, for your imagination to pour into!

R0bin 10-08-2002 08:19 AM

its ok proz, you can post whole scripts if people didnt ask for it.

Graal2001_NAT 10-08-2002 08:32 AM

inefficent, just do
if(weaponfired){
this.on=abs(this.on-1);
if(this.on == 1){
stuff;
}else stuff;
}

Torankusu 10-08-2002 09:03 AM

thx!!!!!!

KuJi2002 10-09-2002 05:48 AM

I'd just do simple flags
if (weaponfired&&!on) {
set on;
}else unset on;
if (on) {
whatever;
}

Torankusu 10-09-2002 05:59 AM

Quote:

Originally posted by KuJi2002
I'd just do simple flags
if (weaponfired&&!on) {
set on;
}else unset on;
if (on) {
whatever;
}

The problem with this is that if another NPC set "on," then it would also trigger this NPC to turn on. Prozac's is for the specific NPC.

KuJi2002 10-09-2002 06:03 AM

Is that script even needed?
i made a good one b4 :D
here
NPC Code:

// NPC made by KuJi
//#COMMENTS Clothes Hanger
//#EDIT img cloats2.png
//#EDIT body body.png
//#EDIT sword sword1.png
//#EDIT shield shield1.png
//#EDIT head head1.png
//#EDIT skin black
//#EDIT coat black
//#EDIT sleeves black
//#EDIT shoes black
//#EDIT belt black
if (created) {setimg img;
}
//#CLIENTSIDE
if (playertouchsme) {
setplayerprop#8,body;
setplayerprop#1,sword;
setplayerprop#2,shield;
setplayerprop#3,head;
setplayerprop#C0,skin;
setplayerprop#C1,coat;
setplayerprop#C2,sleeves;
setplayerprop#C3,shoes;
setplayerprop#C3,belt;
}


Put this in your graal folder
levels/npcs
name it as defnpcClothes.txt

emortylone 10-09-2002 06:39 AM

I usually do a this.var, or if I'm in the mood, I'll use like a specific flag, not on and !on, but like qmenu and other related items.
---Shifter

Falcor 10-09-2002 10:06 AM

would be nice if we could do bitwise operators like this.on = ~this.on or something. we could just toggle it on and off. But then we'd probably need special binary variables or something. *shrugs*

screen_name 10-09-2002 04:35 PM

Quote:

Originally posted by Kaimetsu


this.on=1-this.on;

Oh my, now I feel kind of silly. I too use this.var = abs(this.var-1);

Loriel 10-09-2002 06:42 PM

this.on = vecx(this.on+1)*(-1);

screen_name 10-09-2002 07:14 PM

Quote:

Originally posted by Loriel
this.on = vecx(this.on+1)*(-1);
lol


this.on = abs(this.on-.5-.3-.2);

KuJi2002 10-10-2002 05:13 AM

i do the following for a clothes changing npc or something
this.clotheson=1;
this.on=1;
set clotheson;
unset clotheson;
etc...

Graal2001_NAT 10-10-2002 05:29 AM

why do people use flags =/ I can honestly say I havent use a flag in at least a year, I find them 'outdated' and inefficent, strings are so much better


All times are GMT +2. The time now is 03:53 PM.

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