Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-25-2003, 02:54 AM
Chris1Polly Chris1Polly is offline
Registered User
Chris1Polly's Avatar
Join Date: Feb 2002
Location: A place without hate
Posts: 44
Chris1Polly is on a distinguished road
Send a message via AIM to Chris1Polly
Exclamation 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. 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;

__________________
Reply With Quote
  #2  
Old 07-25-2003, 03:08 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
Post the NPC in a level? :x
__________________
BEING AWAY FROM THE FORUMS RULES

http://www.livejournal.com/users/karsheth/
Reply With Quote
  #3  
Old 07-25-2003, 03:09 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Ew, chaotic indenting. It makes scripts more trouble to read
__________________
Reply With Quote
  #4  
Old 07-25-2003, 04:32 AM
Chris1Polly Chris1Polly is offline
Registered User
Chris1Polly's Avatar
Join Date: Feb 2002
Location: A place without hate
Posts: 44
Chris1Polly is on a distinguished road
Send a message via AIM to Chris1Polly
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?
__________________
Reply With Quote
  #5  
Old 07-25-2003, 05:14 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Alas, I don't look at scripts unless they conform to KSI-GS.
__________________
Reply With Quote
  #6  
Old 07-25-2003, 05:24 AM
Chris1Polly Chris1Polly is offline
Registered User
Chris1Polly's Avatar
Join Date: Feb 2002
Location: A place without hate
Posts: 44
Chris1Polly is on a distinguished road
Send a message via AIM to Chris1Polly
Question 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.
__________________
Reply With Quote
  #7  
Old 07-25-2003, 05:37 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
The guidelines died after a stupid boy deleted them. I'll write up some new ones.
__________________
Reply With Quote
  #8  
Old 07-25-2003, 05:52 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
so inefficent =|
Reply With Quote
  #9  
Old 07-25-2003, 05:57 AM
Chris1Polly Chris1Polly is offline
Registered User
Chris1Polly's Avatar
Join Date: Feb 2002
Location: A place without hate
Posts: 44
Chris1Polly is on a distinguished road
Send a message via AIM to Chris1Polly
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.
__________________
Reply With Quote
  #10  
Old 07-25-2003, 06:11 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Re: Well...

Quote:
Originally posted by Chris1Polly
I can script most anything
Believe me, you can't. Nobody can.
__________________
Reply With Quote
  #11  
Old 07-25-2003, 06:20 AM
Chris1Polly Chris1Polly is offline
Registered User
Chris1Polly's Avatar
Join Date: Feb 2002
Location: A place without hate
Posts: 44
Chris1Polly is on a distinguished road
Send a message via AIM to Chris1Polly
"most anything" not everything, I dont claim to be able to do that.
__________________
Reply With Quote
  #12  
Old 07-25-2003, 06:38 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
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.
__________________
Reply With Quote
  #13  
Old 07-25-2003, 06:44 AM
TribulationStaff TribulationStaff is offline
Registered User
Join Date: Jul 2003
Location: Pennsylvania
Posts: 368
TribulationStaff is on a distinguished road
Send a message via AIM to TribulationStaff
Huzzah for the laws of probability
__________________


Help me keep scripting
Reply With Quote
  #14  
Old 07-25-2003, 08:22 AM
Tseng Tseng is offline
Sublime
Tseng's Avatar
Join Date: Jan 2003
Location: California
Posts: 0
Tseng is on a distinguished road
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.
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----
Reply With Quote
  #15  
Old 07-25-2003, 08:12 PM
Alexander Alexander is offline
Registered User
Join Date: Apr 2003
Location: California
Posts: 246
Alexander is on a distinguished road
Send a message via AIM to Alexander
I maybe stupid but I thought = was assign, not equal.
Reply With Quote
Reply


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 12:35 AM.


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