Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Little scripting problem (https://forums.graalonline.com/forums/showthread.php?t=31729)

BLOOD_kane 06-16-2002 11:20 PM

Little scripting problem
 
Ok I have this NPC that asks you a riddle. Before you talk to him if you say the correct answer nothing happens (i got this down) after you speak with him if you answer anything else BUT the right answer he dissapears and a baddy appears. if you kill the baddy he will re-appear like nothing happened and you have to ask him again, if you answer correctly he drops a gold rupee, my problem is while you are still saying the answer if you touch him he drops more rupees, and everytime after that if you say the answer he drops rupees BUT says You already answered (which i made him say if you got the right answer) It involvs alot of flags and im gonna post what i have of the script here (its kinda unorganized and messy and unfinished but its what i have so far)
I need help to where if you answer right, you cannot do the riddle ever again.

if (playerenters) {set riddle1;}
if (riddle1&&playersays(an address)) {say2 ;}
if (playertouchsme) {say 4;set riddle2;}
if (riddle2&&playersays(an address)){lay goldrupee;say2 Haha! Right!;set hasrupee;}
if (playertouchsme&&hasrupee) {say2 You've already answered!;}
if (riddle2&&playerchats&&!hasrupee) {say2 Wrong!;shootball;hide;putnewcomp lizardon,20.5,49,baddylizardon.png,10;}
if (compusdied) {say2 Let's try again;show;set riddle1;}

:confused: cant figure it all out...

BLOOD_kane 06-17-2002 10:47 AM

please help, Tyhm obviously couldnt

nyghtGT 06-17-2002 11:52 AM

Here is some usefull info:

Try using varaibles instead of so many flags...

Use 'strequals(#c,stuff)'...

Try learning how to format your scripts better...

Projectshifter 06-17-2002 08:45 PM

[code]
if (playerenters) {this.riddle=1;}
if (this.riddle==1&&playerchats&&strequals(#c,an address)) {say2 ;}
if (playertouchsme) {say 4; ;this.riddle=2;}
if (this.riddle==2&&playerchats&&strequals(#c,an address)){lay goldrupee;say2 Haha! Right!;this.riddle=3;;}
if (playertouchsme&&this.riddle==3) {say2 You've already answered!;}
if (this.riddle==2&&playerchats&&!strequals(#c,an address)) {say2 Wrong!;shootball;hide;putnewcomp lizardon,20.5,49,baddylizardon.png,10;}
if (compusdied) {say2 Let's try again;show;this.riddle=1;}

=D That should be of some help. But you have some problems. YOu have it if they say an address when it equals 1, then it doesn't really do anything, but then if it equals 2 and they say it they lay a rupee... I hope this helps
---Shifter

BLOOD_kane 06-18-2002 12:26 AM

Wow thanks! It all works except the part where he says "Youv'e already answered" I need to make it to where its a permanent fixture to where if you already answered then you cannot answer it again. Kina like chests with rupees in it you know? You can only get them once unless your account is reset

user13-xo 06-18-2002 01:53 AM

if (playerenters) this.riddle=1;
if (playerchats) {
if (this.riddle==1) {
if (strequals(#c,an address)) {
say2 ;
this.riddle=2;
}
}
if (this.riddle==2) {
if (!gotgold) {
if (strequals(#c,an address)) {
lay goldrupee;
set gotgold;
say2 Haha! Right!;
} else {
say2 Wrong!;
shootball;
hide;
putnewcomp lizardon,20.5,49,baddylizardon.png,10;
}
} else if(gotgold) {
say2 You've already answered!;
}
}
}
if (compusdied) {
say2 Let's try again;
show;
this.riddle=1;
}

This might help as well

Dustey4Ever 06-18-2002 02:28 AM

in npc that you just want something temporary like what anwer your on, use variables, they work better most time, use flags only if you hae to go from one place to another and keep something stored

BLOOD_kane 06-18-2002 06:33 AM

thanks i got it to work now!

adam 06-18-2002 10:53 AM

:( :(

Somebody please teach these savages to format thier code.

and use the code tags.

user13-xo 06-18-2002 12:22 PM

i forgot the code tags what are they again

adam 06-18-2002 12:27 PM

Quote:

Originally posted by user13-xo
i forgot the code tags what are they again
:rolleyes:

"{code}" "{/code}" replace { } with [ ]

Dragona2002 06-18-2002 04:02 PM

srry im at scool now but try to let it see correct i mean (it wont reconize ride1= .......
it has to need a value...)

BLOOD_kane 06-18-2002 10:43 PM

another problem
 
Well Everything works perfect EXCEPT! If you say the answer "an address" even after youve answered the first time, he keeps dropping rupees! You have to keep on saying it but he will not say that ive already answered unless i (playertouchsme)

here is the code:

if (playerenters) {this.riddle=1;}
if (this.riddle==1&&playerchats&&strequals(#c,an address)) {say2 ;}
if (playertouchsme) {say 4;this.riddle=2;}
if (this.riddle==2&&playerchats&&strequals(#c,an address)){lay bluerupee;say2 Haha! Right!;set hasrupee;}
if (playertouchsme&&hasrupee) {say2 You've already answered!;}
if (this.riddle==2&&playerchats&&!strequals(#c,an address)) {say2 Wrong!;putexplosion 2.5,playerx+0.25,playery+1;
hide;putnewcomp lizardon,20.5,39,baddylizardon.png,10;}
if (compusdied) {say2 Let's try again;show;this.riddle=1;}

---------------------------------

if (playertouchsme&&hasrupee) {say2 You've already answered!;}

I need somthing in here to where if you say the right answer he wont drop any rupees anymore. I know it is simple probably but everything i try wont work.

GrowlZ1010 06-18-2002 11:00 PM

PLEASE, format your code! It makes it easier to read, easier to understand, and easier for other people to help out with. >.>

Now I'm not going to just hand you the solution, because that would be baaaaad (and would probably get the post deleted), so I'm going to teach you what the problem is. The problem is you're not checking for the hasrupee flag on the playerchats event. See?
NPC Code:
if (this.riddle==2&&playerchats&&strequals(#c,an address)){


Do you see "&&!hasrupee" in there anywhere? Because I sure don't.

BLOOD_kane 06-18-2002 11:28 PM

Quote:

Originally posted by GrowlZ1010
PLEASE, format your code! It makes it easier to read, easier to understand, and easier for other people to help out with. >.>

Now I'm not going to just hand you the solution, because that would be baaaaad (and would probably get the post deleted), so I'm going to teach you what the problem is. The problem is you're not checking for the hasrupee flag on the playerchats event. See?
NPC Code:
if (this.riddle==2&&playerchats&&strequals(#c,an address)){


Do you see "&&!hasrupee" in there anywhere? Because I sure don't.


well hell im still fairly new to scripting (actually i was fairly good but then i quit graal over a year and didnt do anything like scripting for that period) all I need to know is how to make it to where if you say the answer he wont give you anymore rupees.

BLOOD_kane 06-18-2002 11:47 PM

Grrr now if you get it right then say somthing it says WRONG and puts the explosion only once after you get it right, then it resets to riddle==1 thus they can still get rupees.

Sparker3000 06-19-2002 06:40 AM

dont use playersays anymore
use playerchats&&strequals(#c,text)

BLOOD_kane 06-19-2002 07:41 AM

well now I got it to ALL WORKING but the only prob i still have is once you answered he wont give you anymore rupees BUT if you say anything (even a blank space) he will say WRONG and put the explosion on you...but only once, after that you can say anything and it wont happen and walk up to him and he will say you already answered. heres the script:


NPC Code:
if (playerenters) {this.riddle=1;}
if (this.riddle==1&&playerchats&&strequals(#c,an address)) {say2 ;}
if (playertouchsme) {say 4;this.riddle=2;}
if (this.riddle==2&&playerchats&&strequals(#c,an address)&&!hasrupee;){lay bluerupee;say2 Haha! Right!;set hasrupee;}
if (playertouchsme&&hasrupee) {say2 You've already answered!;}
if (this.riddle==2&&playerchats&&!strequals(#c,an address)) {say2 Wrong!;putexplosion 2.5,playerx+0.25,playery+1;this.riddle=1;}


user13-xo 06-19-2002 01:16 PM

Was there something wrong with my script?
Did you even look at it?

BLOOD_kane 06-19-2002 11:05 PM

he wont even talk on yours

BLOOD_kane 06-19-2002 11:08 PM

Plus after you get the rupee he still lets you answer the quest again thus...infinite rupees.

BLOOD_kane 06-21-2002 10:34 AM

please


All times are GMT +2. The time now is 05:01 PM.

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