Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Artificial Intellegence! (https://forums.graalonline.com/forums/showthread.php?t=46471)

Chris1Polly 07-25-2003 02:54 AM

Artificial Intellegence!
 
Well now that Ive finished my systems and debugged them Ive moved onto npcs that will actually do some thinking instead of randomly running around and killing things. Well Ive got a simple guard who has a 10 tile field of vision, all of it works except when he resets after going after someone who has a low alignment rating (its a string on the player created by my system not the regular graal AP) After he gets done chasing someone he should go back to his idle mode, which he does. Problem is once thats done he wont return to attack mode if he needs to attack someone again. Heres the script, tiny bit messy I have yet to refine it. Lets see if any of you can understand why he doesnt reset. :confused: Thanks -

NOTE: He doesnt have any customized appearance yet, this shouldnt cause a problem. (being scripted to be made into a class summoned by putnpc2)!

NPC Code:

// NPC made by Aeglos
if (created){
setstring this.hp,100;
setstring this.damHP,10;
setstring this.damBP,5;
setstring this.damEP,5;
setstring this.speed,0.3;
setstring this.walk,walk;
setstring this.attack,sword;
setstring this.idle,idle;
//
setstring this.mode,0;
showcharacter;
}
function reset(){
setstring this.mode,0;
}
//Checking Target Alignment
if (actioncheck){
setstring this.target,#p(0);
check();
}
if (actionalign){
setstring this.align,#p(0);
check2();
}
function check(){
with(getplayer(#s(this.target))){
triggeraction x+1,y+1,align,#s(client.align);
}
}
function check2(){
if (strtofloat(#s(this.align))=>50){message Goodday fine citizen!;}
else if (strtofloat(#s(this.align))<50){setstring this.target2,#s(this.target);message HALT!;setstring this.mode,1;}
}
//Guard Mode
if (strequals(#s(this.mode),0)){
setcharani #s(this.idle),;
if (this.b=<50){this.b++}
else if (this.b>50){changecomment();}
if (this.a=<100){this.a++}
else if (this.a>100){changedir();}
}
//Following
else if (strequals(#s(this.mode),1)){
if (this.d=<200){this.d++}
else if (this.d>200){reset();}
with(getplayer(#s(this.target2))){
this.newx=playerx;
this.newy=playery;
if (playerhearts=0){reset();}
}
if (this.newy<y){y-=strtofloat(#s(this.speed));setcharani #s(this.walk),;getdir()}
if (this.newx<x){x-=strtofloat(#s(this.speed));setcharani #s(this.walk),;getdir()}
if (this.newy>y){y+=strtofloat(#s(this.speed));setcha rani #s(this.walk),;getdir()}
if (this.newx>x){x+=strtofloat(#s(this.speed));setcha rani #s(this.walk),;getdir()}
if (x in |this.newx-1,this.newx+4| && y in |this.newy-1,this.newy+4|){
setcharani #s(this.attack),;
}
}
function getdir(){
if (this.newy<y){dir=2;}
else if (this.newx<x){dir=1;}
else if (this.newy>y){dir=2;}
else if (this.newx>x){dir=3;}
}
function changecomment(){
this.b=0;
this.c=int(random(0,12));
if (this.c=1){message ::grumbles::;}
if (this.c=2){message ::whistles::;}
if (this.c=3){message ::dozes off:: HALT! oh..;}
if (this.c=4){message Bleh... this job is boring;}
if (this.c=5){message ::sighs::;}
if (this.c=6){message ::yawns::;}
if (this.c=7){message ::taps foot lightly::;}
if (this.c=8){message Im tired...;}
if (this.c=9){message If any criminals come my way Ill take care of them! ::laughs::;}
if (this.c=10){message ;}
if (this.c=11){message ::farts::;}
}
function changedir(){
this.a=0;
if (dir=0){dir=1}
else if (dir=1){dir=2}
else if (dir=2){dir=3}
else if (dir=3){dir=0}
}
timeout=0.1;
//#CLIENTSIDE
//Vision Lines
if (dir=0){
if (playerx in |x,x+2| && playery in |y-10,y|){
triggeraction x+1,y+1,check,#a;
}
}
if (dir=1){
if (playerx in |x-10,x| && playery in |y,y+2|){
triggeraction x+1,y+1,check,#a;

}
}
if (dir=2){
if (playerx in |x,x+2| && playery in |y,y+10|){
triggeraction x+1,y+1,check,#a;

}
}
if (dir=3){
if (playerx in |x,x+10| && playery in |y,y+2|){
triggeraction x+1,y+1,check,#a;
}
}
timeout=0.05;


Dude6252000 07-25-2003 03:08 AM

Post the NPC in a level? :x

Kaimetsu 07-25-2003 03:09 AM

Ew, chaotic indenting. It makes scripts more trouble to read :(

Chris1Polly 07-25-2003 04:32 AM

Chaotic Indent c.c
 
Quote:

Ew, chaotic indenting. It makes scripts more trouble to read
Well I have a habit of hitting the style button... lol for me its just as easy to read a block of script
"if (created){setimg door.png;setshape 1,32,32;}"
as it is to read the indented.. maybe its just me x.x;
but did you notice any reason why he doesnt react to players onces hes changed modes once?

Kaimetsu 07-25-2003 05:14 AM

Alas, I don't look at scripts unless they conform to KSI-GS.

Chris1Polly 07-25-2003 05:24 AM

KSI-GS
 
Kaimetsu Standards Institute - Graal Script?
Ill convert it if need be, but Ill need the guidelines.... I just really need to find out whats going wrong with this script, its bugging me to death. :\

Kaimetsu 07-25-2003 05:37 AM

The guidelines died after a stupid boy deleted them. I'll write up some new ones.

Python523 07-25-2003 05:52 AM

so inefficent =|

Chris1Polly 07-25-2003 05:57 AM

Well...
 
Well Im sorry it doesnt meet up to your standards, I can script most anything even if I do take the longer route, Im still new to npc server scripting, and I never took time to learn new commands... since well. o_O mostly the new commands Ive learned by hearing people talk about them. Ive not studied a command for at least 5 versions of graal. Most likely more :\ Instead of commenting on the way it was scripted perhaps you can help? o_O I know your good enough to.

Kaimetsu 07-25-2003 06:11 AM

Re: Well...
 
Quote:

Originally posted by Chris1Polly
I can script most anything
Believe me, you can't. Nobody can.

Chris1Polly 07-25-2003 06:20 AM

"most anything" not everything, I dont claim to be able to do that.

Kaimetsu 07-25-2003 06:38 AM

Quote:

Originally posted by Chris1Polly
"most anything" not everything, I dont claim to be able to do that.
You can create only a tiny proportion of the total imaginable scripts, just like any other human.

TribulationStaff 07-25-2003 06:44 AM

Huzzah for the laws of probability ;)

Tseng 07-25-2003 08:22 AM

Pick a form (preferably the standard one) of indenting and stick with it.

Don't put code outside of event blocks.

Don't treat flags as events.

Alexander 07-25-2003 08:12 PM

I maybe stupid but I thought = was assign, not equal.

Tseng 07-25-2003 08:15 PM

Quote:

Originally posted by Alexander
I maybe stupid but I thought = was assign, not equal.
I believe the scripting engine allows you to use = as a comparison, but it is poor form to do so.

Something I stress a lot: there is a big difference between a script "working" and that script "being scripted correctly."

Chris1Polly 07-25-2003 09:44 PM

>_>
 
:( well, I kinda taught myself scripting by jumping in over my heard, long time ago, and "swimming" my way back up. (never was able to walk, just got up off the floor and ran around the room as a baby ;) ) but, I can get alot of things working >_> I know Im not that great, what do you suggest to use rather than "=" to compare, I figure if it does the same thing and its more complicated theres no real need to do it. Oh and so everyone knows, that script was crap ^_^ I deleted it, I started over but I want to do this right, any suggestions/advise would be greatly appreciated. One last thing for this post, sorry Kai, yesterday I couldnt word things right and I came off sounding like an arrogant *****. :megaeek: Thanks for your time. Ill be checking the forum every hour or so...


PS - yes I like the smiles :D :rolleyes: :p

draygin 07-26-2003 02:35 AM

Re: Artificial Intellegence!
 
Quote:

Originally posted by Chris1Polly
Well now that Ive finished my systems and debugged them Ive moved onto npcs that will actually do some thinking instead of randomly running around and killing things. Well Ive got a simple guard who has a 10 tile field of vision, all of it works except when he resets after going after someone who has a low alignment rating (its a string on the player created by my system not the regular graal AP) After he gets done chasing someone he should go back to his idle mode, which he does. Problem is once thats done he wont return to attack mode if he needs to attack someone again. Heres the script, tiny bit messy I have yet to refine it. Lets see if any of you can understand why he doesnt reset. :confused: Thanks
Heh, man that sounds almost exactly like a rip off of eq because thats exactly how they do it. :p Faction and guards that have what we call an aggro range that will attack you if you get to close and they dont like you. It doesnt seem like a very original thing to be scripting. I hope you're planning on making it unique and not a straight rip from another game. Because that would be bad.

(edit the initials of the game if its bad Kai I know its frowned on but I wasnt advertising I was pointing out how everything he posted is exactly how it is from something else.)

Chris1Polly 07-26-2003 02:49 AM

Re: Re: Artificial Intellegence!
 
Quote:

Originally posted by draygin

Heh, man that sounds almost exactly like a rip off of eq because thats exactly how they do it. :p Faction and guards that have what we call an aggro range that will attack you if you get to close and they dont like you. It doesnt seem like a very original thing to be scripting. I hope you're planning on making it unique and not a straight rip from another game. Because that would be bad.

Its called realism, and Evercrack wasnt the first to have it. Its a common thing.
Quote:

Originally posted by draygin

(edit the initials of the game if its bad Kai I know its frowned on but I wasnt advertising I was pointing out how everything he posted is exactly how it is from something else.)

-_- Again its just realism, but if you want to get really technical about it almost everything has been used before in one thing or another, so no matter what someone did it could be called "ripping".

Tseng 07-26-2003 07:29 AM

Re: >_>
 
Quote:

Originally posted by Chris1Polly
:( well, I kinda taught myself scripting by jumping in over my heard, long time ago, and "swimming" my way back up. (never was able to walk, just got up off the floor and ran around the room as a baby ;) ) but, I can get alot of things working >_> I know Im not that great, what do you suggest to use rather than "=" to compare, I figure if it does the same thing and its more complicated theres no real need to do it.
Use == for comparisons.
Use = for assignments.

Again: there's a big difference between "working" and "scripted properly/to a decent standard."

Androk 07-27-2003 04:25 PM

Heh belive me, you can't script "most anything" either :P Simply because there is endless possobility of ideas that can be assigned. Anyway sorry to go off topic.

Kaimetsu 07-27-2003 06:01 PM

Quote:

Originally posted by Androk
Heh belive me, you can't script "most anything" either :P Simply because there is endless possobility of ideas that can be assigned. Anyway sorry to go off topic.
To whom are you talking?

Alexander 07-27-2003 06:34 PM

Quote:

Originally posted by Kaimetsu


To whom are you talking?

Quote:

Originally posted by Chris1Polly
Well Im sorry it doesnt meet up to your standards, I can script most anything even if I do take the longer route, Im still new to npc server scripting, and I never took time to learn new commands... since well. o_O mostly the new commands Ive learned by hearing people talk about them. Ive not studied a command for at least 5 versions of graal. Most likely more :\ Instead of commenting on the way it was scripted perhaps you can help? o_O I know your good enough to.
He's talking to Chris1Polly, I think.

ApeHex 07-28-2003 02:25 PM

;o
it would be nice to be able to script almost anything

draygin 07-31-2003 10:10 PM

Re: Re: Re: Artificial Intellegence!
 
Quote:

Originally posted by Chris1Polly

Its called realism, and Evercrack wasnt the first to have it. Its a common thing.

-_- Again its just realism, but if you want to get really technical about it almost everything has been used before in one thing or another, so no matter what someone did it could be called "ripping".

They weren't? Please tell me who did?

There is a big difference between using concepts from other games and copying how another game does something so that it is essentially the same exact thing.

So no depending on what a person does it isnt called "ripping"

Jaguar__5 08-02-2003 03:50 PM

Heyo Elrond! Look I'm back in forums w000
Finally got a VIP!

Crono 08-03-2003 06:25 PM

Elrond, (I know call him Aeglos alot xD) has been on graal for a long time. And rather than helping Aeglos (has his problem even been solved? I read all of this and people were getting off topic everywhere) everyone is just spamming about "OMG U KANT SCREEPT EVERYTING!111"

Just help him and get over it. No need to spam a thread with pointless..ok i'll just stop there >.>;;

adam 08-03-2003 07:31 PM

Well, I'd say, If the only requirment for getting help from a group of talented guys is formatting your code a little different. Just do it?

konidias 08-03-2003 08:04 PM

Re: Re: Re: Re: Artificial Intellegence!
 
Quote:

Originally posted by draygin


They weren't? Please tell me who did?

There is a big difference between using concepts from other games and copying how another game does something so that it is essentially the same exact thing.

So no depending on what a person does it isnt called "ripping"

Uh, how is making an npc that has a field of vision, copying EQ? Do you realise how many games have NPCs with a field of vision? Duh, even Graal's default baddies have a field of vision. I don't see how the following, could be copying anything, when it's just basic ideas:

- NPCs have a field of vision
- When a player gets in the field of vision, the NPC attacks
- If the NPC is done attacking, it waits for another person to come into it's field of vision

Now please explain to me how this is such a crazily new and unique concept, created by the people at EQ. :rolleyes:

Kaimetsu 08-04-2003 04:45 AM

Quote:

Originally posted by Gerami
Elrond, (I know call him Aeglos alot xD) has been on graal for a long time. And rather than helping Aeglos (has his problem even been solved? I read all of this and people were getting off topic everywhere) everyone is just spamming about "OMG U KANT SCREEPT EVERYTING!111"
It's hardly spamming, I'm just correcting an erroneous claim. Nobody here has an obligation to help anybody, it's purely a personal choice.

Quote:

Just help him
Make me. I don't have any inclination to read through his huge script just because he doesn't want to do his own debugging, especially when it doesn't conform to standards.

draygin 08-05-2003 12:30 AM

Re: Re: Re: Re: Re: Artificial Intellegence!
 
Quote:

Originally posted by konidias


Uh, how is making an npc that has a field of vision, copying EQ? Do you realise how many games have NPCs with a field of vision? Duh, even Graal's default baddies have a field of vision. I don't see how the following, could be copying anything, when it's just basic ideas:

- NPCs have a field of vision
- When a player gets in the field of vision, the NPC attacks
- If the NPC is done attacking, it waits for another person to come into it's field of vision

Now please explain to me how this is such a crazily new and unique concept, created by the people at EQ. :rolleyes:

It's quite obvious that you dont know what you're talking about. Nor have any clue what one has and how it is an exact reproduction of something else. So until that time you do please dont jump in because you're only making an ass of yourself.

Where did I state that the field of vision was what he was copying? If that was all I wouldnt have stated anything because that would be a concept not a rip of the entire damn thing. Come on Koni think you seem to be doing less and less of it lately. :rolleyes:

Kaimetsu 08-05-2003 12:59 AM

Then what part is he copying? The idea that guards attack people they don't like?

wonderboysp2p 08-07-2003 04:06 AM

god... some people tink that if an idea isnt 100% out of one person's imagination then it's copied... you can put more than one person's ideas together to create your own dammit X_X


All times are GMT +2. The time now is 11:42 AM.

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