Thread: Pet Problems
View Single Post
  #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