Graal Forums  

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

 
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 05-11-2001, 06:56 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Here an example for a class 'followers'.
First an NPC that joins that class:

NPC Code:

if (created) {
showcharacter;
}
if (playerchats) {
if (strequals(#c,follow)) {
setstring this.owner,#a;
followPlayer();
}
if (strequals(#c,stop)) {
setstring this.owner,;
stopingFollow();
}
}
function stopingFollow() {
setcharani idle,;
message STOP;
sleep 3;
message;
}
join followers;



And here the class file:

NPC Code:

function followPlayer() {
cannotwarp;
setarray this.followpos,0;
while (true) {
noowner = true;
with (getplayer(#s(this.owner))) {
noowner = false;
if (!strequals(#F,#L)) {
// Player leaved the level, so follow him
setarray this.followpos,0;
dir = playerdir;
warpto #F,playerx,playery;
} else {
//
// Follow the player
//
px = playerx;
py = playery;

// Add one step to the list if the player has moved
alen = arraylen(this.followpos);
if (alen<2 || this.followpos[alen-2]!=px || this.followpos[alen-1]!=py) {
setarray this.followpos,alen+2;
this.followpos[alen] = px;
this.followpos[alen+1] = py;
}
// Only save 4 steps, so delete one entry at the beginning
// if there are too many
if (arraylen(this.followpos)>4*2) {
for (i=0; i<4; i++) {
this.followpos[i*2] = this.followpos[(i+1)*2];
this.followpos[i*2+1] = this.followpos[(i+1)*2+1];
}
setarray this.followpos,4*2;
}

// Get the new position (oldest saved step)
nx = this.followpos[0];
ny = this.followpos[1];

// Setting direction
if (abs(nx-x)>abs(ny-y)) {
if (nx<x) dir = 1; else dir = 3;
} else if (abs(nx-x)<abs(ny-y)) {
if (ny<y) dir = 0; else dir = 2;
}
if (nx==px && ny==py) dir = playerdir;

// Setting animation
if (onwater(nx+1.5,ny+2))
this.animode = 2;
else if (x==nx && y==ny)
this.animode = 0;
else
this.animode = 1;
setAnimation();

// Applying the new position
x = nx;
y = ny;
}
}
if (noowner==true)
break;
sleep 0.1;
}
stopingFollow();
}
function stopingFollow() {
this.animode = 0;
setAnimation();
}
function setAnimation() {
if (startswith(bomy,#3(-1))) {
if (this.animode==0)
setcharani bomy_idle,;
else if (this.animode==1)
setcharani bomy_walk,;
else if (this.animode==2)
setcharani bomy_kick,;
} else {
if (this.animode==0)
setcharani idle,;
else if (this.animode==1)
setcharani walk,;
else if (this.animode==2)
setcharani swim,;
}
}



The follow script uses the array this.followpos
to remember the walking position of the
player. You can see that the NPC is overwriting
the function stopingFollow() to implement
its own code (saying 'STOP' for 3 seconds).
You can see that using the followers script
is very simple, you only need to set this.owner,
then call followPlayer()

If you have questions or improvements then
let me know
  #2  
Old 05-11-2001, 08:55 AM
KJS KJS is offline
The one, The only -
KJS's Avatar
Join Date: Apr 2001
Location: USA, Minnesota
Posts: 1,012
KJS is on a distinguished road
Send a message via AIM to KJS
Cool what does?

what does the function 'join' do?
you used it like this
join followers;
and I am just wondering if you could give me a small tatoral on how to use it and what it does
__________________
Thanks,
-KJL
  #3  
Old 05-11-2001, 08:27 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Yes classes are saved in text files, but
you need the npccontrol to change the
class script
  #4  
Old 05-11-2001, 08:55 PM
KJS KJS is offline
The one, The only -
KJS's Avatar
Join Date: Apr 2001
Location: USA, Minnesota
Posts: 1,012
KJS is on a distinguished road
Send a message via AIM to KJS
Cool so I am guessing

I am guessing it would be a good idea to put a system weapon inside of a txt file and join it. So then you dont have to have a function in the npc weapon to warp them to a level to get the new update of the system weapon?
am I correct?
__________________
Thanks,
-KJL
  #5  
Old 05-11-2001, 09:54 PM
kyle0654 kyle0654 is offline
-. .`
kyle0654's Avatar
Join Date: Mar 2001
Posts: 1,000
kyle0654 will become famous soon enough
Actually, if you just stored the system script as a server NPC with the name System-NPC I think you could use:

addweapon System-NPC;

And it should update every logon.


Question: Can NPCWs join a server script? Like for a bow, you have the local script with all the shooting stuff, but for a few global functions like possibly how arrows move you want to join a server script instead of having to write it in every single weapon that's a bow-type.
  #6  
Old 05-11-2001, 10:11 PM
KJS KJS is offline
The one, The only -
KJS's Avatar
Join Date: Apr 2001
Location: USA, Minnesota
Posts: 1,012
KJS is on a distinguished road
Send a message via AIM to KJS
Quote:
Originally posted by kyle0654
[B]Actually, if you just stored the system script as a server NPC with the name System-NPC I think you could use:

addweapon System-NPC;

And it should update every logon.
well see the thing is, like that doesn't make the weapon invisable if I name it that. I am naming my weapon
-system
so it is invisable and no one can delete it.
and fyi it is 'toweapons <weapon name>' not addweapon
__________________
Thanks,
-KJL
  #7  
Old 05-12-2001, 02:35 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
weapons are something different,
join is not possible yet for weapons
  #8  
Old 05-12-2001, 06:10 AM
kyle0654 kyle0654 is offline
-. .`
kyle0654's Avatar
Join Date: Mar 2001
Posts: 1,000
kyle0654 will become famous soon enough
You could probably name the server npc -system too...not sure if the '-' would work. I was just giving an example for you to build off of though, I expected you to try at least to change the name. addweapon adds a script that's on the server as a weapon with the name of the NPC on the server.

As for joining with NPCWs, could that PLEASE be added soon?
Something like:
NPC Code:

if (created) {
join BowFunctions;
join ArrowProperties;
toweapons Mega-Bow;
}
// rest of weapon here


Not really a text file...those are kinda outta date...

Last edited by kyle0654; 05-12-2001 at 06:13 AM..
  #9  
Old 05-12-2001, 06:55 AM
Hawk Hawk is offline
??
Hawk's Avatar
Join Date: Mar 2001
Location: Canada B.C
Posts: 1,374
Hawk will become famous soon enough
Send a message via ICQ to Hawk Send a message via AIM to Hawk Send a message via Yahoo to Hawk
yes yes!
__________________
email--hawk at graal.net
AIM--Hawx0rz

waiting upon graal2001 //
  #10  
Old 05-14-2001, 06:04 PM
Immitat0r Immitat0r is offline
Registered User
Immitat0r's Avatar
Join Date: Mar 2001
Posts: 792
Immitat0r will become famous soon enough
(James205)


  #11  
Old 06-26-2001, 03:47 AM
Metal-Slug Metal-Slug is offline
!_!
Metal-Slug's Avatar
Join Date: Jun 2001
Posts: 2,421
Metal-Slug is on a distinguished road
can i use the top script wihtou using the bottom 1?
__________________

Er1c2 loaded the local ban info of Loriel-2002 RC
  #12  
Old 06-26-2001, 11:08 PM
Metal-Slug Metal-Slug is offline
!_!
Metal-Slug's Avatar
Join Date: Jun 2001
Posts: 2,421
Metal-Slug is on a distinguished road
im not makinf a class, im trying to make and image follow a player, one image, not different angles and everything, just bleh
__________________

Er1c2 loaded the local ban info of Loriel-2002 RC
  #13  
Old 06-28-2001, 03:10 AM
ArmadeusWarlock ArmadeusWarlock is offline
Registered User
Join Date: Jun 2001
Posts: 373
ArmadeusWarlock is on a distinguished road
Well

Im not exactly sure what you want that image to do, but since im not the greatest scripter, heres meh script!
if(playertouchsme){
followplayer;
}

I havent quite figured out how to make them follow you into different levels. I could do a really bugged up script that would works but it wont do anything spectacularly special.
  #14  
Old 06-30-2001, 03:51 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Thats a client-side thing that is taken out in the
next Graal version
  #15  
Old 06-30-2001, 04:07 AM
Guest
Posts: n/a
Stefan, I can't get weapons to add to your list. Since you said weapons can't be a class, should I make the NPC on NPC Control, thenm put the weapon script on Edit Script?

Otaku is confused.
 


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 02:00 AM.


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