Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Moving Class (https://forums.graalonline.com/forums/showthread.php?t=43515)

tlf288 03-17-2003 12:24 AM

Moving Class
 
I want to help out the Graal community so I will be posting things for playerworld to use.

This class can be used for NPCs to move around:
NPC Code:

/*****************************
* name: people *
* type: class *
* by: Trevor (Scripter) *
*****************************/
canwarp;
if(timeout){

if(this.step>=arraylen(this.moveVecX)){
this.step=0;
dir=this.moveDirC[0];
this.distWent=0;
x=this.baseX;
y=this.baseY;
}

if(dir==1||dir==3){
if(this.distWent>=abs(this.moveVecX[this.step])){
this.distWent=0;
this.step++;
dir=this.moveDirC[this.step];
}
}else if(dir==0||dir==2){
if(this.distWent>=abs(this.moveVecY[this.step])){
this.distWent=0;
this.step++;
dir=this.moveDirC[this.step];
}
}

this.nX=x+vecx(dir)*(this.speed/2);
this.nY=y+vecy(dir)*(this.speed/2);

this.testP=testplayer(this.nX+1.5+vecx(dir),this.n Y+2+vecy(dir));
if(this.testP>=0){
setcharani idle,;
this.messageOn=true;
this.message=1;
doMessage();
if(this.hold==false){
this.hold=true;
}
}else{this.hold=false; message;}

if(this.hold==false){
setcharani walk,;
move this.nX-x,this.nY-y,.1,2+16;
this.distWent+=(this.speed/2);
}
timeout=.1;
}

function doMessage()
{
if(this.messageOn==true){
if(this.message==1){
message #R(#s(this.message));
this.message=-1;
}
sleep4;
this.messageOn=false;
}
}



Here is an example DBNPC for the class:
NPC Code:

join people;
if (initialized) {
showcharacter;
setcharprop #C0,orange;
setcharprop #C1,darkblue;
setcharprop #C2,blue;
setcharprop #C3,black;
setcharprop #C4,black;
setcharprop #n,*Debbie (Police);
setcharprop #2,shield3.gif;
setcharprop #3,head21.png;
setcharprop #8,body4.png;
setcharprop #P1,hat92.png;
setcharprop #1,zeroriotstick-sword.png;
shieldpower=1;
this.speed=1;
ap=100;
this.moveVecX={ 4, 0, -4, 0}
this.moveVecY={ 0, 4, 0, -4}
this.moveDirC={ 3, 2, 1, 0}
dir=this.moveDirC[0];
this.step=0;
this.baseX=x; // You may want to change this var to the start x
this.baseY=y; // ""-x + y
timeout=.1;
setstring this.message,Welcome to Graal2001!,Enjoy your stay :),Hope you have fun here at Graal2001;
}



You can use both of these freely as long as you keep the credits in the script.

ShadowDarkstar 03-17-2003 04:46 AM

err...
what is '#R'?
=X

Torankusu 03-17-2003 06:03 AM

Quote:

Originally posted by ShadowDarkstar
err...
what is '#R'?
=X

I think it's required for the DBNPC to read it. I'm not sure, I've never seen it before either.

tlf288 03-17-2003 06:44 AM

Quote:

Originally posted by Kaimetsu
'#R(string)' is equivalent to '#I(string,int(random(0,sarraylen(string)))'
Ding ding ding! It is one of those things unless you talk to people on debug (Jagen in particularly) you would never know about it. Becasue, Stefan documents nothing.

PastAustin 03-17-2003 08:43 AM

Quote:

Originally posted by tlf288


Ding ding ding! It is one of those things unless you talk to people on debug (Jagen in particularly) you would never know about it. Becasue, Stefan documents nothing.

I am sure Stefan resents that.
*cough* Though it is true. *cough*

adam 03-17-2003 06:30 PM

Quote:

Originally posted by PastAustin


I am sure Stefan resents that.
*cough* Though it is true. *cough*


Possibly, although it's still at least partially true.

tlf288 03-17-2003 06:33 PM

Quote:

Originally posted by adam



Possibly, although it's still at least partially true.

Partially? He doesn't document ANYTHING now'a'days.

HoudiniMan 03-20-2003 08:32 AM

He should keep a log somewhere, maybe like a journal... people would know what he did with his time or he could at least say "-added #R today"

PastAustin 03-20-2003 10:18 AM

Quote:

Originally posted by HoudiniMan
He should keep a log somewhere, maybe like a journal... people would know what he did with his time or he could at least say "-added #R today"
lol that sounds almost comical, I can see it now, "Stefan's Adventure Log: The Lost Tales of Nice but Unknown Scripting Commands". Sure that would work out well. I think that he should get a documentor who would document for him.

tlf288 03-20-2003 11:15 AM

Quote:

Originally posted by PastAustin

I think that he should get a documentor who would document for him.

Documentor (secretary) requires money. Of which Stefan has no extra.

PastAustin 03-20-2003 11:23 AM

Quote:

Originally posted by tlf288


Documentor (secretary) requires money. Of which Stefan has no extra.

He doesn't pay anyone else, like PWAs / Global Admins, why would he pay this person?

tlf288 03-20-2003 06:17 PM

Quote:

Originally posted by PastAustin


He doesn't pay anyone else, like PWAs / Global Admins, why would he pay this person?

For this person to document stuff they would have to be in his office. This would be a real life job.

PastAustin 03-20-2003 06:27 PM

Quote:

Originally posted by tlf288


For this person to document stuff they would have to be in his office. This would be a real life job.

Not true. Jagen is on debug and he knows a lot of this stuff. I'd love to do something like that, just go though scripts and try to find new things...

CheeToS2 03-20-2003 09:59 PM

Quote:

Originally posted by Kaimetsu
'#R(string)' is equivalent to '#I(string,int(random(0,sarraylen(string)))'
XD! I suggested that a long time ago, never even knew it was added

HoudiniMan 03-21-2003 04:46 AM

Quote:

Originally posted by PastAustin


lol that sounds almost comical, I can see it now, "Stefan's Adventure Log: The Lost Tales of Nice but Unknown Scripting Commands". Sure that would work out well. I think that he should get a documentor who would document for him.

If he couldn't keep a log, why would he tell somebody on graal that he hired? :\

PastAustin 03-21-2003 08:33 AM

Quote:

Originally posted by HoudiniMan


If he couldn't keep a log, why would he tell somebody on graal that he hired? :\

Me wouldn't as the person learned about the commands, they would post them on the forums or write them into commands.rtf.

HoudiniMan 03-21-2003 09:30 AM

So why can't anybody from debug do that? o.o

PastAustin 03-21-2003 07:13 PM

Quote:

Originally posted by HoudiniMan
So why can't anybody from debug do that? o.o
My thoughts exactly.

Soul-Blade 03-24-2003 02:27 PM

Quote:

Originally posted by tlf288


Ding ding ding! It is one of those things unless you talk to people on debug (Jagen in particularly) you would never know about it. Becasue, Stefan documents nothing.

Jagen never told me of this, and I am always on debug :(

Jagen, your days are numbered, beware.

Python523 03-24-2003 05:12 PM

Quote:

Originally posted by PastAustin


Not true. Jagen is on debug and he knows a lot of this stuff. I'd love to do something like that, just go though scripts and try to find new things...

except most of the new things don't work anywhere else because 2k2 is the only place that uses mudlibs ^_^;;

have fun with this, use it on a DB-NPC only (I think)

if(playertouchsme) makescreenshot <screenshot>.png;

saves a screenshot to the client's
graalfolder/screenshots/<imagename>;

HoudiniMan 03-25-2003 02:23 AM

Quote:

Originally posted by Python523

except most of the new things don't work anywhere else because 2k2 is the only place that uses mudlibs ^_^;;

have fun with this, use it on a DB-NPC only (I think)

if(playertouchsme) makescreenshot <screenshot>.png;

saves a screenshot to the client's
graalfolder/screenshots/<imagename>;

Thats not really a big secret, and it couldn't be used for much since it just makes a screen shot on the client side :\

tlf288 03-25-2003 02:25 AM

Quote:

Originally posted by Soul-Blade


Jagen never told me of this, and I am always on debug :(

I always bug him, so stuff slips out :p .


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

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