Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-11-2003, 05:40 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
Thumbs down I need some help with this...

I'm having some problems with the following script, i don't see what's wrong, please help me...

// NPC made by Cyrin
setimg beer.png
if (playertouchsme) toweapons Dagger;
if (weaponfired) {
if (strequals(#s(client.equipment),fists)){
setstring client.equipment,dagger;
setplayerprop #c,Equipped Dagger;
setstring client.weaponpower,2;}
if (strequals(#s(client.equipment),dagger)){
setstring client.equipment,fists;
setplayerprop #c,Unequipped Dagger;
setstring client.weaponpower,1;}}

The beer stuff isn't in th original script >.>
And you also need to set a flag "client.equipment=fists".
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #2  
Old 04-11-2003, 08:13 PM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
you don't need those "#s()"s around the string, I don't remember if that'll kill the script or not, but don't use them there
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #3  
Old 04-11-2003, 08:56 PM
CheeToS2 CheeToS2 is offline
That Guy
CheeToS2's Avatar
Join Date: Dec 2001
Location: Seattle, WA
Posts: 2,528
CheeToS2 will become famous soon enough
Send a message via AIM to CheeToS2
Re: I need some help with this...

Quote:
Originally posted by GoZelda
setimg beer.png
missing a ;

Quote:
Originally posted by Dach
you don't need those "#s()"s around the string, I don't remember if that'll kill the script or not, but don't use them there
yes you do :x (last time I checked at least)
__________________

Reply With Quote
  #4  
Old 04-11-2003, 09:37 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
That didn't help, it even stopped the script from working :o
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #5  
Old 04-11-2003, 10:04 PM
GrowlZ1010 GrowlZ1010 is offline
defunct
Join Date: May 2002
Posts: 187
GrowlZ1010 is on a distinguished road
Nobody else spotted this?

NPC Code:

if (weaponfired) {
if (strequals(#s(client.equipment),fists)){
setstring client.equipment,dagger;
setplayerprop #c,Equipped Dagger;
setstring client.weaponpower,2;
}
// Hey, look! client.equipment, at this point, equals dagger!
if (strequals(#s(client.equipment),dagger)){
// So let's get rid of the dagger and bring the fists back,
// despite the fact that we've just got rid of the fists!
setstring client.equipment,fists;
setplayerprop #c,Unequipped Dagger;
setstring client.weaponpower,1;
}
}



Use some kind of small modification like this to check whether or not the equipment has already been changed. Oh, and have the default weapon set automatically.
NPC Code:

if (weaponfired) {
this.check=0;
if (strequals(#s(client.equipment),fists)){
this.check=1;
// dagger equip stuff..
}
if (strequals(#s(client.equipment),dagger) && this.check=0){
// fist equip stuff..
}
if (strequals(#s(client.equipment),)){
// default weapon setting stuff..
}
}

Reply With Quote
  #6  
Old 04-12-2003, 09:57 AM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
OMG, other than the two obvious facts:
(1) You didn't even put if (created). That is like a BIG no-no to put just setimg like that x-x
(2) It's a flat out bish to read, you didnt' really use any formatting! x-x

But other than that, I thought it would be obvious. If you tell it if you are using fists, then it switches to a dagger, but then directly underneath it checks it to switch a dagger to a fist. It changes it to a dagger, but then right back. There is a little thing known as return; that is very helpful x-x
---Shifter
__________________
Who has time for life these days?
Reply With Quote
  #7  
Old 04-12-2003, 04:21 PM
Dude6252000 Dude6252000 is offline
More often known as Karsh
Dude6252000's Avatar
Join Date: May 2002
Location: USA.
Posts: 2,603
Dude6252000 is on a distinguished road
Send a message via AIM to Dude6252000
Re: I need some help with this...

Quote:
Originally posted by GoZelda
// NPC made by Cyrin
setimg beer.png
if (playertouchsme) toweapons Dagger;
if (weaponfired) {
if (strequals(#s(client.equipment),fists)){
setstring client.equipment,dagger;
setplayerprop #c,Equipped Dagger;
setstring client.weaponpower,2;}
if (strequals(#s(client.equipment),dagger)){
setstring client.equipment,fists;
setplayerprop #c,Unequipped Dagger;
setstring client.weaponpower,1;}}
if (playertouchsme) { toweapons Dagger; }
__________________
BEING AWAY FROM THE FORUMS RULES

http://www.livejournal.com/users/karsheth/
Reply With Quote
  #8  
Old 04-12-2003, 05:29 PM
Ningnong Ningnong is offline
Registered User
Ningnong's Avatar
Join Date: Nov 2002
Location: < -- way
Posts: 262
Ningnong is on a distinguished road
Re: Re: I need some help with this...

Quote:
Originally posted by Dude6252000

if (playertouchsme) { toweapons Dagger; }
You don't need brackets for a single command.
__________________
Former Global Scripting Team Member


Reply With Quote
  #9  
Old 04-12-2003, 06:19 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
I followed the aid of Growlz and... succeeded!
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #10  
Old 04-13-2003, 01:57 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
Re: Re: I need some help with this...

Quote:
Originally posted by CheeToS2

yes you do :x (last time I checked at least)
HOLY CRAP!!
I just realized I have not once had to check my own strings in any script I have ever made!!! Gyayayaya, and to think I've scripted for almost 3 years now!
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #11  
Old 04-13-2003, 02:12 AM
CheeToS2 CheeToS2 is offline
That Guy
CheeToS2's Avatar
Join Date: Dec 2001
Location: Seattle, WA
Posts: 2,528
CheeToS2 will become famous soon enough
Send a message via AIM to CheeToS2
Re: Re: Re: I need some help with this...

Quote:
Originally posted by Dach


HOLY CRAP!!
I just realized I have not once had to check my own strings in any script I have ever made!!! Gyayayaya, and to think I've scripted for almost 3 years now!
maybe its time you did.. doesn't work without the #s
__________________

Reply With Quote
  #12  
Old 04-13-2003, 02:16 AM
Dude6252000 Dude6252000 is offline
More often known as Karsh
Dude6252000's Avatar
Join Date: May 2002
Location: USA.
Posts: 2,603
Dude6252000 is on a distinguished road
Send a message via AIM to Dude6252000
Re: Re: Re: I need some help with this...

Quote:
Originally posted by Ningnong


You don't need brackets for a single command.
Er, oh. This is what I get for trying to correct people, when I can barely script myself
__________________
BEING AWAY FROM THE FORUMS RULES

http://www.livejournal.com/users/karsheth/
Reply With Quote
  #13  
Old 04-13-2003, 02:18 AM
CheeToS2 CheeToS2 is offline
That Guy
CheeToS2's Avatar
Join Date: Dec 2001
Location: Seattle, WA
Posts: 2,528
CheeToS2 will become famous soon enough
Send a message via AIM to CheeToS2
Re: Re: Re: Re: I need some help with this...

Quote:
Originally posted by Dude6252000

Er, oh. This is what I get for trying to correct people, when I can barely script myself
It doesn't hurt to have them, & putting brackets around stuff (not sure if this holds true in gscript or not) speeds up processing of the script (barely, but still :P)
__________________

Reply With Quote
  #14  
Old 04-13-2003, 02:36 AM
CheeToS2 CheeToS2 is offline
That Guy
CheeToS2's Avatar
Join Date: Dec 2001
Location: Seattle, WA
Posts: 2,528
CheeToS2 will become famous soon enough
Send a message via AIM to CheeToS2
Re: Re: Re: Re: Re: Re: I need some help with this...

Quote:
Originally posted by Kaimetsu
I don't see why it would speed up the compilation?
its easier for it to determine what is being typed is (a command/evaluation/etc).. again, i'm not saying it holds true for gscript, because I wouldn't know :P
__________________

Reply With Quote
  #15  
Old 04-13-2003, 08:30 AM
HoudiniMan HoudiniMan is offline
Playerworld Administrator
HoudiniMan's Avatar
Join Date: Dec 2001
Location: Calfiornia - USA
Posts: 3,512
HoudiniMan will become famous soon enough
if (created) variable=5*5;

evaluation?
__________________
-HoudiniMan (Chief Playerworld Administrator)
Compulsive Support Center Checker - 5 Years and Change
Graal Support Center

Reply With Quote
  #16  
Old 04-13-2003, 10:09 AM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Even if it IS a single command, if you add components as a method of building your scripts then you should put 99.9997% of single commands in brackets { and }. It means when you edit the script and add and test things you don't have to add them in. And actually it SLOWS the compilation process, if you can even call it that. You're talknig perhaps 10 nano's at best :P It's just like a text file (it is basically), where each space and return and } and { and such take up more space to store. But the amount doesn't matter when it's so trivial as that. A friend asked me to look at ascript of his that took up 15% CPU usage. I changed a few things to the way I format, and VOILA< it was 2% (still a lot but 2 > 15 when you're talking lag )
---Shifter
__________________
Who has time for life these days?
Reply With Quote
  #17  
Old 04-17-2003, 04:31 AM
Pokilty Pokilty is offline
Registered User
Join Date: Nov 2002
Posts: 101
Pokilty is on a distinguished road
Kai is right... when the script is compiled it isn't fed into the engine exactly how you write it. It has to go through a process to determine how the script works and adding a { } wouldn't make it any faster. It doesn't take any more work for the compiler to recognize that whatever comes after the if statement is what the user wants to happen versus whatever is in the brackets is what the user wants to happen. To the computer it's all good
__________________
"I have not failed. I've just found 10,000 ways that won't work."
"Logic is in the eye of the logician."
Reply With Quote
  #18  
Old 04-24-2003, 11:22 AM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
Quote:
Originally posted by Kaimetsu

You're either lying or drastically mistaken. A simple change of formatting will never account for such a drastic change, especially since all formatting is removed when the script is converted into bytecode.
Kaimetsu, wasn't something alike in your KSI-thing?
i mean if he typed all the time
if (playertouchsme){
if (strequals(#s(client.lives),true)){
say2 hey you live!;
}
}
if (playertouchsme){
if (strequals(#s(client.lives),false)){
say2 hey you are dead!;
}
}
and so on, instead of
if (playertouchsme){
if (strequals(#s(client.lives),false)){
say2 hey you are dead!l
}
if (strequals(#s(client.lives),true)){
say2 hey you live!;
}
and there could be much more things ya know.
You can easily make stuff easiers, shorter etc. by compiling.
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #19  
Old 04-24-2003, 04:51 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Re: I need some help with this...

Quote:
Originally posted by GoZelda
I'm having some problems with the following script, i don't see what's wrong, please help me...

// NPC made by Cyrin
setimg beer.png

if (playertouchsme){
// wont' work online, but fine for offline
toweapons Dagger;
}

if (weaponfired) {
if (strequals(#s(client.equipment),fists)){
setstring client.equipment,dagger;
setplayerprop #c,Equipped Dagger;
setstring client.weaponpower,2;
}
if (strequals(#s(client.equipment),dagger)){
setstring client.equipment,fists;
setplayerprop #c,Unequipped Dagger;
setstring client.weaponpower,1;
}
}


If the script worked it would always be set client.equipment=fists

becouse you change it to dagger then the next if statement checks if it's dagger and changes it back to fists.

You might try an elseif statement.

To busy arguing to catch that guys?
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #20  
Old 04-24-2003, 04:53 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Quote:
Originally posted by HoudiniMan
if (created) variable=5*5;

evaluation?

"5*5" evaluation if im not mistaken


"something = something else" assignment command.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #21  
Old 04-25-2003, 01:33 AM
HoudiniMan HoudiniMan is offline
Playerworld Administrator
HoudiniMan's Avatar
Join Date: Dec 2001
Location: Calfiornia - USA
Posts: 3,512
HoudiniMan will become famous soon enough
It has to evaluate it before it can execute the command... thats my logic behind it
__________________
-HoudiniMan (Chief Playerworld Administrator)
Compulsive Support Center Checker - 5 Years and Change
Graal Support Center

Reply With Quote
  #22  
Old 04-25-2003, 09:22 AM
HoudiniMan HoudiniMan is offline
Playerworld Administrator
HoudiniMan's Avatar
Join Date: Dec 2001
Location: Calfiornia - USA
Posts: 3,512
HoudiniMan will become famous soon enough
I just think it would still have to evaluate it first...
__________________
-HoudiniMan (Chief Playerworld Administrator)
Compulsive Support Center Checker - 5 Years and Change
Graal Support Center

Reply With Quote
  #23  
Old 04-25-2003, 04:10 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
And now the answer to the guys question is lost in the shuffle.

Now to get the mod to delete irrelevent posts. Like his own.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #24  
Old 04-25-2003, 04:27 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Quote:
Originally posted by Kaimetsu


The thread has been alive for over two weeks. If he hasn't come to get his answer by now then he never will.
Don't be silly he checked back yesterday. You replied to him.

And none of you cought the serious problem I did and posted.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #25  
Old 04-25-2003, 04:29 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Re: Re: I need some help with this...

Quote:
Originally posted by adam



If the script worked it would always be set client.equipment=fists

becouse you change it to dagger then the next if statement checks if it's dagger and changes it back to fists.

You might try an elseif statement.
Bump the truth down to a place where it can be easily read....
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #26  
Old 04-25-2003, 07:00 PM
HoudiniMan HoudiniMan is offline
Playerworld Administrator
HoudiniMan's Avatar
Join Date: Dec 2001
Location: Calfiornia - USA
Posts: 3,512
HoudiniMan will become famous soon enough
Arguing about it is only going to drive the thread further off-topic...
__________________
-HoudiniMan (Chief Playerworld Administrator)
Compulsive Support Center Checker - 5 Years and Change
Graal Support Center

Reply With Quote
  #27  
Old 04-27-2003, 06:00 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
I feel that someone or plural persons have not read this thread carefully, as i posted that if succeeded, thanks to Growlz.
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #28  
Old 04-27-2003, 09:46 PM
HoudiniMan HoudiniMan is offline
Playerworld Administrator
HoudiniMan's Avatar
Join Date: Dec 2001
Location: Calfiornia - USA
Posts: 3,512
HoudiniMan will become famous soon enough
They were just bickering... seemed to be stopped until you posted though ;(

It's all your fault!
__________________
-HoudiniMan (Chief Playerworld Administrator)
Compulsive Support Center Checker - 5 Years and Change
Graal Support Center

Reply With Quote
  #29  
Old 04-30-2003, 08:42 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
Your fault!
Don't know why though ;P
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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:48 PM.


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