Graal Forums  

Go Back   Graal Forums > Development Forums > Tech Support
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-31-2002, 03:10 PM
luigi22 luigi22 is offline
Registered User
Join Date: Jun 2002
Location: Florida
Posts: 59
luigi22 is on a distinguished road
Send a message via AIM to luigi22 Send a message via Yahoo to luigi22
Pet Problems

I'm postion this for LiquidIce....

When we are using the same class for pet, the pets do not work when they are ''following''... I think its a problem with the with(getplayer()) command. Even the other pets, when I have 2 following me, only one follows.

NPC Code:

//SCRIPT BY LIQUIDICE

//I changed some of the stuff around
//so that it does not change anything while in with
//just gets the players stuff
//only part it stays a long time in the with
//is when it is checking what the player is saying and such,
//but even then the following part (where the npc moves)
//is done mostly outside of the with

//Variables
this.steps=4; //number of steps to follow
this.maxcoowners=3; //max number of coowners

//Dont edit anything below this

//modes
//0=idle
//1=idle (sleeping)
//2=follow
//3=skipping rope
//4=playing dead
//5=taking off on hat
//6=putting on hat
//7=defending
//8=walk

function dresserver() {
setcharprop #P1,unpet_#s(this.body).gif;
setcharprop #n,#s(this.owner)'s Pet #s(this.petrace);
}

if (created) {
// Initialize the attributes
setshape 1,48,48;
dontblocklocal;
dresserver();
thiso.mode=1;
canwarp;
setarray stepx,this.steps;
setarray stepy,this.steps;
setarray stepdir,this.steps;
setstring this.currentowner,#s(this.owner);
timeout=.1;
}

if (playerchats&&strequals(#s(this.owner),#a)) {
if (startswith(addcoowner,#c)) {
tokenize #s(this.coowner);
if (tokenscount=<this.maxcoowners) {
tokenize #c;
setstring this.coowner,#T(#s(this.coowner) #t(1));
setcharprop #c,Co-Owner #t(1) Added;
this.chatcount=50;
}
else {
setcharprop #c,Too many co owners. Max is #v
(this.maxcoowners) coowners;
this.chatcount=50;
}
}

if (startswith(removecoowner,#c)) {
tokenize #c;
setstring this.temprem,#t(1);
tokenize #s(this.coowner);
setstring this.coowner,;
for (this.i=0;this.i<tokenscount;this.i++) {
if (strequals(#t(this.i),#s(this.temprem))) {
setcharprop #c,Co-Owner #s(this.temprem) Removed;
this.chatcount=50;
}
else {
setstring this.coowner,#T(#s(this.coowner) #t(this.i));
}
}
if (strequals(this.currentowner,#s(this.temprem))) {
setstring this.currentowner,#s(this.owner); }
setstring this.temprem,;
}

if (strequals(#c,disable coowners)) { setcharprop #c,CoOwners
Disabled;this.chatcount=40;this.enablecoowners=1; setstring
this.currentowner,#s(this.owner); }

if (strequals(#c,enable coowners)) { setcharprop #c,CoOwners
Enabled;this.chatcount=40;this.enablecoowners=0; }
}

if (timeout) {
if (this.chatcount>0) { this.chatcount--; } else { setcharprop
#c,; }
if (this.swungcount>0) { this.swungcount--; }
//this is for adding people to ownership list
with (getplayer(#s(this.owner))) {

//warping to main owner
if (strequals(#c,o #s(this.petrace))) {
setstring this.currentowner,#s(this.owner);
if (!strequals(#L,#F) ) {
warpto #F,playerx,playery;
setcharprop #c,Here I am #s(this.currentowner);
}
else { setcharprop #c,Im already here #s
(this.currentowner); }
setplayerprop #c,;
this.chatcount=10;
thiso.mode=2;
createarray();
}
}

//cycle thru co owners to see if any are calling the pet
if (this.enablecoowners=0) {
tokenize #s(this.coowner);
for (this.i=0;this.i<tokenscount;this.i++) {
with (getplayer( #t(this.i) )) {
//warping to player
if (strequals(#c,o #s(this.petrace))) {
setstring this.currentowner,#t(this.i);
if (!strequals(#L,#F) ) {
warpto #F,playerx,playery;
setcharprop #c,Here I am #s(this.currentowner);
}
else { setcharprop #c,Im already here #s
(this.currentowner); }
setplayerprop #c,;
this.chatcount=10;
thiso.mode=2;
createarray();
}
}
}
}

//this is for the current owner
with (getplayer(#s(this.currentowner))) {

if (strequals(#L,#F)) {

if (strequals(#c,what can you do?)) {
setplayerprop #c,;
say2 Commands Are:#bo #s(this.petrace)#bwake
up#bsleep#bfollow#bstop#bface up/left/down/right#bpet say <text>
#bcoowner list#bshow owner#bshow race#bwalk#bdisable/enable
coowners#b|add/remove|coowner <acctname>;
}

if (strequals(#c,follow)&&thiso.mode<>2&&strequals(#L ,#F))
{ thiso.mode=2; createarray(); }

if (strequals(#c,walk)&&thiso.mode<>8) { thiso.mode=8;
randmove(); }

if (strequals(#c,wake up)&&thiso.mode=1) { thiso.mode=0;
setcharani unpet_idle,; }

if (startswith(pet say,#c)) {
setcharprop #c,#e(8,strlen(#c)-8,#c);
setplayerprop #c,.;
this.chatcount=100;
}

if (startswith(face,#c)&&thiso.mode=0) {
tokenize #c;
if (tokenscount=2) {
if (strequals(#t(1),up)) { dir=0; }
if (strequals(#t(1),left)) { dir=1; }
if (strequals(#t(1),down)) { dir=2; }
if (strequals(#t(1),right)) { dir=3; }
}
}

// if (startswith(anim,#c)) {
// thiso.mode=0;
// if (!strequals(#e(5,strlen(#c)-3,#c),sword)&&!strequals
(#e(5,strlen(#c)-3,#c),spin)) {
// setcharani #e(5,strlen(#c)-3,#c),;
// }
// }

if (strequals(#c,stop)) { thiso.mode=0;
if (onwater(x,y)||onwater(x+1.5,y+2)) { setcharani
unpet_swim,; }
else { setcharani unpet_idle,; }
}

if (strequals(#c,sleep)) {
thiso.mode=0;
setcharani unpet_sleep,;
}

//end of say commands
}

if (thiso.mode=8) {
cannotwarp;
noplayeronwall;
if (onwater(x,y)||onwater(x+1.5,y+2)) {
setcharani unpet_swim,;
}
else { setcharani unpet_walk,; }
}
else { if (!canwarp) { canwarp; } }

//following player
if (thiso.mode=2) {
thiso.playery=playery;
thiso.playerdir=playerdir;
thiso.playerx=playerx;
if (!strequals(#L,#F) ) {
warpto #F,playerx,playery;
thiso.createarray=1;
}
}
//player left. lets sleep
if (!strequals(#L,#F)) { thiso.mode=1; setcharani
unpet_sleep,; }
}

if (thiso.createarray=1) { thiso.createarray=0; createarray();
}

if (thiso.mode=2) {
if (stepx[arraylen(stepx)-1]<>thiso.playerx||stepy[arraylen
(stepy)-1]<>thiso.playery) {
movearray();
x=stepx[0];
y=stepy[0];
dir=stepdir[0];
if (onwater(x,y)||onwater(x+1.5,y+2)) { setcharani
unpet_swim,; }
else { setcharani unpet_walk,; }
}
else {
if (onwater(x,y)||onwater(x+1.5,y+2)) { setcharani
unpet_swim,; }
else { setcharani unpet_idle,; }
}
}
timeout=.1;
}

function createarray() {
with (getplayer(#s(this.currentowner))) {
thiso.playerx=playerx;
thiso.playerdir=playerdir;
thiso.playery=playery;
}
for (this.i=0;this.i<arraylen(stepx);this.i++) {
stepx[this.i]=thiso.playerx;
stepy[this.i]=thiso.playery;
stepdir[this.i]=thiso.playerdir;
}
x=stepx[0];
y=stepy[0];
dir=stepdir[0];
}

function movearray() {
for (this.i=0;this.i<arraylen(stepx);this.i++) {
stepx[this.i]=stepx[this.i+1];
stepy[this.i]=stepy[this.i+1];
stepdir[this.i]=stepdir[this.i+1];
}
with (getplayer(#s(this.currentowner))) {
thiso.playerx=playerx;
thiso.playery=playery;
thiso.playerdir=playerdir;
}
stepx[arraylen(stepx)-1]=thiso.playerx;
stepy[arraylen(stepy)-1]=thiso.playery;
stepdir[arraylen(stepdir)-1]=thiso.playerdir;
}

if (playertouchsme&&thiso.mode=7&&!
issparringzone&&this.swungcount=0) {
if (!onwater(x,y)&&!onwater(x+1.5,y+2)&&!strequals(#a ,#s
(this.currentowner))) {
setcharprop #c,Get Away!;
this.chatcount=20;
this.swungcount=10;
if (playerx>=x&&playery=<y) { dir=0; }
if (playerx<x&&playery=<y) { dir=1; }
if (playery>y&&playerx=<y) { dir=2; }
if (playerx>=x&&playery>=y) { dir=3; }
setcharani idle,;
setcharani sword,;
}
}

if (movementfinished&&thiso.mode=8) { randmove(); }

function randmove() {
this.i = int(random(0,4));
this.len = random(2,10);
move vecx(this.i)*this.len, vecy(this.i)*this.len, this.len/6, 4
+8+16;
}

//any player commands
if (playerchats&&strequals(#c,show owner)) {
setcharprop #c,My owner is #s(this.owner);
this.chatcount=30;
}

if (playerchats&&strequals(#c,show race)) {
setcharprop #c,I am a #s(this.petrace);
this.chatcount=30;
}

if (playerchats&&strequals(#c,coowner list)) { setcharprop #c,Co
Owners are:#s(this.coowner); this.chatcount=80; }
//end any player commands

//#CLIENTSIDE
if (playerenters) {
dontblocklocal;
timeout=.1;
}
if (timeout) {
this.rand=int(random(0,20));
if (this.rand>=18 && ( onwater(x,y)||onwater(x+.5,y+2) ) ) {
putleaps 5,x+1.5,y+1; }
timeout=.5;
}

__________________
Reply With Quote
  #2  
Old 08-01-2002, 01:32 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
is this a database npc?
Reply With Quote
  #3  
Old 08-01-2002, 08:19 AM
RavenTelvecho RavenTelvecho is offline
Registered User
RavenTelvecho's Avatar
Join Date: Apr 2002
Location: Toronto, Ontario, Canada
Posts: 0
RavenTelvecho is on a distinguished road
Send a message via ICQ to RavenTelvecho Send a message via AIM to RavenTelvecho Send a message via Yahoo to RavenTelvecho
"
lqd: say yes
lqd: its a
lqd: d/b npc
lqd: both of them
lqd: using that class posted
"
__________________

^tuff newbie ;x
RavenTelvecho
!Booj
we are 'brothers'
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:37 PM.


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