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 01-04-2002, 03:02 AM
ShockwaveISTHEBEST ShockwaveISTHEBEST is offline
Registered User
Join Date: Nov 2001
Location: never never land
Posts: 208
ShockwaveISTHEBEST is on a distinguished road
Send a message via AIM to ShockwaveISTHEBEST Send a message via Yahoo to ShockwaveISTHEBEST
Turning this off

Ok I got the npc person so that he wouldnt do anything form the start and so that he would attack if you said "intruder". I was trying to find a way to turn him off and set him back to his old location. How would I do this? I have this much.


Quote:
// Graal2001 NPC by Stefan Knorr
if (created) {
// Initialize the attributes
showcharacter;
setcharprop #3,head16.png;
setcharprop #C0,orange;
setcharprop #C1,gray;
setcharprop #C2,darkblue;
setcharprop #C3,darkblue;
setcharprop #C4,darkblue;
setcharprop #n,Gaurd (Graal Royal Army);
setcharprop #2,no-shield.gif;
shieldpower = 1;
dir = 2;
swordpower = 1;
}
if (playerchats && strequals(#c,intruder) && strequals(#g,Graal Royal Army)) {
// Initialize the this. variables
message;
this.huntspeed = 0.4;
timeout = 0.05;
this.walkmode = 1;
if (wasthrown && this.walkmode>1) this.walkmode = 1;
this.x1 = 30;
this.x2 = 38;
this.y1 = 22;
this.y2 = 38;
this.speed = 0.4;
this.mode = 0;
setcharani idle,;
this.runcounter = int(random(22,38));
}
// Walking stuff
if (timeout && this.mode==0) { // WALKING
setcharani walk,;
newx = x + vecx(dir)*this.speed;
newy = y + vecy(dir)*this.speed;
this.runcounter--;
if (this.walkmode==1) { // RANDOM
if (this.runcounter>0) {
testx = newx + 1.5 + vecx(dir);
testy = newy + 2 + vecy(dir);
if (onwall(testx,testy)) {
dir = (dir+2)%4;
this.runcounter = int(random(0,60));
} else {
x = newx;
y = newy;
}
} else {
this.runcounter = int(random(10,40));
dir = (dir+1+int(random(0,2))*2)%4;
}
} else if (this.walkmode==2) { // LEFTRIGHT
if (dir!=1 && dir!=3) dir = 3;
else {
x = newx;
y = newy;
if ((dir==1 && x<=this.x1) || (dir==3 && x>=this.x2))
dir = (dir+2)%4;
}
} else if (this.walkmode==3) { // UPDOWN
if (dir!=0 && dir!=2) dir = 2;
else {
x = newx;
y = newy;
if ((dir==0 && y<=this.y1) || (dir==2 && y>=this.y2))
dir = (dir+2)%4;
}
} else if (this.walkmode==4) { // RECTANGLE
x = newx;
y = newy;
if ((dir==0 && y<=this.y1) || (dir==1 && x<=this.x1) ||
(dir==2 && y>=this.y2) || (dir==3 && x>=this.x2))
dir = (dir+3)%4;
}
if (this.walkmode>1 && this.runcounter<=0)
this.runcounter = 20;
message;
timeout = 0.05;
}

// Sword attacking stuff
if (timeout && (this.mode==0 || this.mode==2)) {
// Look for players
mindist = 1000;
for (i=0; i<playerscount; i++)
if (players[i].hearts>0 && players[i].id>=0) {
dx = players[i].x - x;
dy = players[i].y - y;
if (abs(dx)>abs(dy)) {
if (dx>0) pdir=3; else pdir=1;
} else {
if (dy>0) pdir=2; else pdir=0;
}
if (pdir==dir) {
dist = (dx*dx+dy*dy)^0.5;
if (dist<mindist) {
cansee = 1;
if (abs(dx)>abs(dy)) k = int(abs(dx));
else k = int(abs(dy));
for (j=0; j<=k-2; j++)
if (onwall(x+1.5+dx*j/k,y+2+dy*j/k)) cansee = 0;
if (cansee!=0) {
mindist = dist;
aimplayer = i;
this.aimx = players[i].x;
this.aimy = players[i].y;
}
}
}
}
if (mindist<=3) {
this.runcounter = -1;
this.mode = 3; // SLAYING
setcharani sword,;
timeout = 0.05;
} else if (mindist<20) {
if (this.mode!=2) message Intruder;
this.runcounter = 100;
this.mode = 2; // HUNTING
} else timeout = 0.05;
}
if (timeout && this.mode==3) { // SLAYING
this.runcounter++;
if (this.runcounter>4) {
this.runcounter = 100;
this.mode = 2; // HUNTING
setcharani idle,;
}
message;
timeout = 0.05;
}
if (timeout && this.mode==2) { // HUNTING
setcharani walk,;
this.runcounter--;
if (this.runcounter>0 && aimplayer<playerscount && players[aimplayer].hearts>0) {
// Get new direction
dx = players[aimplayer].x-x;
dy = players[aimplayer].y-y;
if (abs(dx)>abs(dy)) {
if (dx>0) dir=3; else dir=1;
} else {
if (dy>0) dir=2; else dir=0;
}

// Test if we can do a step
dx = this.aimx-x;
dy = this.aimy-y;
if (abs(dx)<=1 && abs(dy)<=1) {
this.aimx = players[aimplayer].x;;
this.aimy = players[aimplayer].y;
dx = this.aimx-x;
dy = this.aimy-y;
}
if (abs(dx)>abs(dy)) {
if (dx>0) testdir=3; else testdir=1;
} else {
if (dy>0) testdir=2; else testdir=0;
}
len = (dx*dx+dy*dy)^0.5;
addx = (dx/len)*this.huntspeed;
addy = (dy/len)*this.huntspeed;
testx = x + 1.5;
testy = y + 2;
if (!onwall(testx+addx,testy+addy)) {
// Do a step
x += addx;
y += addy;
} else if (!onwall(testx+addx,testy)) x += addx;
else if (!onwall(testx,testy+addy)) y += addy;
} else {
this.mode = 0; // WALKING
this.walkmode = 1; // RANDOM
this.runcounter = int(random(22,38));
setcharani idle,;
dir = (dir+2)%4;
message;
}
timeout = 0.05;
}
__________________
[img]http://rick.*******ers.net/ss/users/jerrytyrrell64/Shockwave%20Sig%2003.jpg[/img]
Reply With Quote
  #2  
Old 01-04-2002, 03:05 AM
ShockwaveISTHEBEST ShockwaveISTHEBEST is offline
Registered User
Join Date: Nov 2001
Location: never never land
Posts: 208
ShockwaveISTHEBEST is on a distinguished road
Send a message via AIM to ShockwaveISTHEBEST Send a message via Yahoo to ShockwaveISTHEBEST
Oh yeah thanks and could you make it so he wont hurt anyone in a specific guild.
__________________
[img]http://rick.*******ers.net/ss/users/jerrytyrrell64/Shockwave%20Sig%2003.jpg[/img]
Reply With Quote
  #3  
Old 01-04-2002, 03:16 AM
GrowlZP2P GrowlZP2P is offline
Registered User
Join Date: Dec 2001
Location: Corpadverticus, which in case you don't know is the recently-formed and Blockbuster Video-sponsored Tenth Circle of Hell
Posts: 57
GrowlZP2P is on a distinguished road
Send a message via AIM to GrowlZP2P Send a message via Yahoo to GrowlZP2P
Replace the original if (created) section with this;

NPC Code:
if (created) { 
// Initialize the attributes
showcharacter;
setcharprop #3,head16.png;
setcharprop #C0,orange;
setcharprop #C1,gray;
setcharprop #C2,darkblue;
setcharprop #C3,darkblue;
setcharprop #C4,darkblue;
setcharprop #n,Guard (Graal Royal Army);
setcharprop #2,no-shield.gif;
shieldpower = 1;
dir = 2;
swordpower = 1;
this.originalx=x;
this.originaly=y;
}
if (playerchats && strequals(#c,reset) && strequals(#g,Graal Royal Army)) {
x=this.originalx;
y=this.originaly;
}



Saying RESET will now make it default back to its original position. I couldn't test this and so I think it'll still attack players even when warped back. It doesn't stop it attacking a certain guild, but tell me what you think. :P
__________________


AIM: GrowlZ1010 | Y! IM: GrowlZ1010 | MSN: [email protected] | Email: [email protected]

- I use obscenely long words to befuddle my adversaries, therefore I am -

Current Favorite Quote: Real programmers don't document. If it was hard to write, it should be hard
to understand.

Last edited by GrowlZP2P; 01-04-2002 at 03:26 AM..
Reply With Quote
  #4  
Old 01-04-2002, 03:27 AM
ShockwaveISTHEBEST ShockwaveISTHEBEST is offline
Registered User
Join Date: Nov 2001
Location: never never land
Posts: 208
ShockwaveISTHEBEST is on a distinguished road
Send a message via AIM to ShockwaveISTHEBEST Send a message via Yahoo to ShockwaveISTHEBEST
Thanks that got me 1 step closet but can anyone tell me how to get it so he stops attacking me if I reset him.
__________________
[img]http://rick.*******ers.net/ss/users/jerrytyrrell64/Shockwave%20Sig%2003.jpg[/img]
Reply With Quote
  #5  
Old 01-04-2002, 03:28 AM
ShockwaveISTHEBEST ShockwaveISTHEBEST is offline
Registered User
Join Date: Nov 2001
Location: never never land
Posts: 208
ShockwaveISTHEBEST is on a distinguished road
Send a message via AIM to ShockwaveISTHEBEST Send a message via Yahoo to ShockwaveISTHEBEST
I mean stop attacking moving and set his gani back to idle all that jazz.
__________________
[img]http://rick.*******ers.net/ss/users/jerrytyrrell64/Shockwave%20Sig%2003.jpg[/img]
Reply With Quote
  #6  
Old 01-04-2002, 03:35 AM
GrowlZP2P GrowlZP2P is offline
Registered User
Join Date: Dec 2001
Location: Corpadverticus, which in case you don't know is the recently-formed and Blockbuster Video-sponsored Tenth Circle of Hell
Posts: 57
GrowlZP2P is on a distinguished road
Send a message via AIM to GrowlZP2P Send a message via Yahoo to GrowlZP2P
if (playerchats && strequals(#c,reset) && strequals(#g,Graal Royal Army)) {
x=this.originalx;
y=this.originaly;
this.walkmode=0;
dir=2;
this.mode=0;
this.runcounter=0;
setcharani idle,;
sprite = 0;
mindist = 0;
aimplayer = 0;
this.aimx = 0;
this.aimy = 0;
}

__________________


AIM: GrowlZ1010 | Y! IM: GrowlZ1010 | MSN: [email protected] | Email: [email protected]

- I use obscenely long words to befuddle my adversaries, therefore I am -

Current Favorite Quote: Real programmers don't document. If it was hard to write, it should be hard
to understand.
Reply With Quote
  #7  
Old 01-04-2002, 03:45 AM
TheFrozenFiend TheFrozenFiend is offline
Registered User
TheFrozenFiend's Avatar
Join Date: Apr 2001
Posts: 582
TheFrozenFiend is on a distinguished road
If stefan added a

NPC Code:

players[index].guild



then it would be easy.
__________________



Also known as TDM
Reply With Quote
  #8  
Old 01-04-2002, 03:52 AM
GrowlZP2P GrowlZP2P is offline
Registered User
Join Date: Dec 2001
Location: Corpadverticus, which in case you don't know is the recently-formed and Blockbuster Video-sponsored Tenth Circle of Hell
Posts: 57
GrowlZP2P is on a distinguished road
Send a message via AIM to GrowlZP2P Send a message via Yahoo to GrowlZP2P
Quote:
Originally posted by TheFrozenFiend
If stefan added a

NPC Code:

players[index].guild



then it would be easy.
If only.. *sigh*
__________________


AIM: GrowlZ1010 | Y! IM: GrowlZ1010 | MSN: [email protected] | Email: [email protected]

- I use obscenely long words to befuddle my adversaries, therefore I am -

Current Favorite Quote: Real programmers don't document. If it was hard to write, it should be hard
to understand.
Reply With Quote
  #9  
Old 01-04-2002, 05:10 AM
ShockwaveISTHEBEST ShockwaveISTHEBEST is offline
Registered User
Join Date: Nov 2001
Location: never never land
Posts: 208
ShockwaveISTHEBEST is on a distinguished road
Send a message via AIM to ShockwaveISTHEBEST Send a message via Yahoo to ShockwaveISTHEBEST
NPC Code:
Originally posted by GrowlZP2P 
if (playerchats && strequals(#c,reset) && strequals(#g,Graal Royal Army)) {
x=this.originalx;
y=this.originaly;
this.walkmode=0;
dir=2;
this.mode=0;
this.runcounter=0;
setcharani idle,;
sprite = 0;
mindist = 0;
aimplayer = 0;
this.aimx = 0;
this.aimy = 0;
}



It didnt work
__________________
[img]http://rick.*******ers.net/ss/users/jerrytyrrell64/Shockwave%20Sig%2003.jpg[/img]
Reply With Quote
  #10  
Old 01-04-2002, 05:48 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
isnt there #g() array? and index is same as player[] index I believe
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #11  
Old 01-04-2002, 05:49 AM
ShockwaveISTHEBEST ShockwaveISTHEBEST is offline
Registered User
Join Date: Nov 2001
Location: never never land
Posts: 208
ShockwaveISTHEBEST is on a distinguished road
Send a message via AIM to ShockwaveISTHEBEST Send a message via Yahoo to ShockwaveISTHEBEST
Please stick to the topic Liquid Ice
__________________
[img]http://rick.*******ers.net/ss/users/jerrytyrrell64/Shockwave%20Sig%2003.jpg[/img]
Reply With Quote
  #12  
Old 01-04-2002, 07:10 AM
BocoC BocoC is offline
Registered User
BocoC's Avatar
Join Date: Jun 2001
Location: Washington State, USA
Posts: 980
BocoC is on a distinguished road
Send a message via AIM to BocoC Send a message via Yahoo to BocoC
timeout=0;

Use that command. It will stop the timeout, thus stopping is movement.
__________________
-Boco

FLKJH$TRFG*$(&%>FMG >REN<>F ;.kjsd
Reply With Quote
  #13  
Old 01-04-2002, 08:54 AM
Faheria_GP2 Faheria_GP2 is offline
Banned
Faheria_GP2's Avatar
Join Date: Oct 2001
Posts: 1,177
Faheria_GP2 is on a distinguished road
Quote:
Originally posted by ShockwaveISTHEBEST
Please stick to the topic Liquid Ice
OMIGOD YOU ARE SO DUMB!

the #g() message code is what you would use to stop him from attacking members of a certain guild *******!

So he was on topic and you need to die! :grrr: :grrr: :grrr: :grrr:
Reply With Quote
  #14  
Old 01-04-2002, 09:11 AM
Falcor Falcor is offline
Darth Cucumber
Falcor's Avatar
Join Date: Mar 2001
Location: At School
Posts: 2,874
Falcor is on a distinguished road
Send a message via ICQ to Falcor Send a message via AIM to Falcor Send a message via MSN to Falcor Send a message via Yahoo to Falcor
OMG, He was confused! I think it is the end of the world! You have a right to be so angry!
__________________

subliminal message: 1+1=3
Reply With Quote
  #15  
Old 01-04-2002, 10:33 PM
nyghtGT nyghtGT is offline
Banned
nyghtGT's Avatar
Join Date: Jun 2001
Posts: 3,993
nyghtGT is on a distinguished road
Send a message via AIM to nyghtGT
DARE TO BE STUPID!
Reply With Quote
  #16  
Old 01-05-2002, 12:49 PM
joseyisleet joseyisleet is offline
Registered User
Join Date: Aug 2001
Posts: 378
joseyisleet is on a distinguished road
if (playerchats&&strequals(#c,stop)){
this.huntspeed=0;
}

I think it's the huntspeed that makes it attack. I'm not sure though.
__________________
Account used by Josey and Howard.
Ali G: 'Is it cause i Black?'
Reply With Quote
  #17  
Old 01-06-2002, 04:53 AM
Saga2001 Saga2001 is offline
Wishing he had 3 feet
Join Date: Aug 2001
Location: Basement
Posts: 1,565
Saga2001 is on a distinguished road
Send a message via ICQ to Saga2001 Send a message via AIM to Saga2001 Send a message via Yahoo to Saga2001
omi its a scam the npc says made by stefan k!!!
__________________

!Wan ( 11:27:55 AM):
can i c ur scripts please?
Zorg (RC): If I hear NPC Server call Ne0, Past Austin or Brent sexy one more time im disconnecting it
Reply With Quote
  #18  
Old 01-07-2002, 09:29 AM
ShockwaveISTHEBEST ShockwaveISTHEBEST is offline
Registered User
Join Date: Nov 2001
Location: never never land
Posts: 208
ShockwaveISTHEBEST is on a distinguished road
Send a message via AIM to ShockwaveISTHEBEST Send a message via Yahoo to ShockwaveISTHEBEST
Huh Im confused. lol
__________________
[img]http://rick.*******ers.net/ss/users/jerrytyrrell64/Shockwave%20Sig%2003.jpg[/img]
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 11:17 PM.


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