Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Server (https://forums.graalonline.com/forums/forumdisplay.php?f=14)
-   -   My script vs. npcserver (https://forums.graalonline.com/forums/showthread.php?t=5926)

BocoC 06-27-2001 08:37 AM

My script vs. npcserver
 
And npcserver wins in a knockout! I need help. I can't get one of my scripts to work on npcserver. Ok. Now for a little background.

I was surfing the boards one day when I found some people criticizing Brandon (Bravo Online owner) and saying he should add a bowling alley to Bravo. I thought, "Hey! What a neat idea!" So I told Brandon I would make one. I got the preliminarly stuff down, and it worked ok in offline mode, so I thought I should test it out on the Bravo Npcserver before I finish the script up and add in all the little details. Low and behold! I can't pick up the bowling ball. I tried and I tried, but this is frustrating. So, anyone out their willing to help?

Here is the current code for the bowling ball. Sorry for being pretty messy, but here goes:

NPC Code:

// NPC made by Boco
if (playertouchsme) {
setstring this.owner,#a;
replacegani idle,bravo_bowling_idle;
replacegani walk,bravo_bowling_walk;
timeout=0.05;
}
if (timeout) {
with (getplayer(#s(this.owner))) {
if (keydown(6) && playerx in |5,18| && playery in |0,47| && level.reset_a=false) { //37
disabledefmovement;
setani idle,;
Run();
} else { timeout=0.05; }
}
}
function Run() {
GetPower();
ThrowBall();
GoToPins();
Reset();
}
function GetPower() {
for (i=0;i<1;i+=0.05) {
if (keydown(6) && !this.kd) {
this.dis+=1;
set this.kd;
}
if (!keydown(6)) { unset this.kd; }
sleep 0.05;
}
}
function ThrowBall() {
setani bravo_bowling_throwball,;
for (i=0;i<this.dis;i+=0.5) {
playery-=0.5;
sleep 0.05;
if (keydown(1) && !this.kdl) { this.spin-=0.025; set this.kdl; }
if (keydown(3) && !this.kdr) { this.spin+=0.025; set this.kdr; }
if (!keydown(1)) { unset this.kdl; }
if (!keydown(3)) { unset this.kdr; }
}
replacegani walk,walk;
replacegani idle,idle;
}
function GoToPins() {
x=int(playerx+1);
y=int(playery-1);
for (this.i=playery;this.i>2;this.i--) {
y--;
x+=this.spin;
nx=x;
ny=y;
if (y<10) { triggeraction x+0.5,y+0.5,pinstruck,#v(nx),#v(ny); }
sleep 0.05;
}
Reset();
}
function Reset() {
enabledefmovement;
setstring this.owner,;
show;
x=18;
y=38;
this.dis=0;
this.spin=0;
}
//#CLIENTSIDE
if (created) {
setimgpart bravo_bowlingball0.gif,0,0,16,16;
}



Ok. Now for an explanation of the variables:

level.reset_a Sets when the pins are being reset so the player can't throw the ball
this.dis Distance the player moves when throwing
this.spin Applies a spin affect
this.owner Account of active user. This was added when I tried the 'with' command to make the script work
this.kd Stands for Key Down
this.kdl Stands for Key Down Left
this.kdr Stands for Key Down Right

Please help me. I think the problem associates to the replacegani command, because I checked out the status of the NPC on NPC Control. I saw that this.owner was set correctly, but seemed to crash on replacegani and not call timeout=0.05. Anyone care to help? I tried to be as descriptive as possible. Thanks.

Er1c 06-27-2001 10:31 AM

I believe (but am not sure) that the replacegani command needs to be clientside... that NPC would work much better as a weapon. Maybe make a ball and when you touch it you get the bowling weapon, and when you bowl it destroys, so that you can make a ball-return system.

BocoC 06-27-2001 11:27 AM

Doesn't the 'with' command make the enclosed commands client-side? Like:
NPC Code:

with (getplayer(#a)) {
do stuff;
}


Isn't the do stuff; client-side if it is in a 'with' argument?

Loriel 06-28-2001 11:14 PM

no.

06-30-2001 03:41 AM

It's not very clientside when it is loading the account from the database =\

Admins 06-30-2001 03:48 AM

I guess the bowling thing should be
made client-side. Make it work in offline mode,
use showimg instead of an npc that is moved.

Only the pins might need to be scripted
for server-side, let the ball do a triggeraction
when it hits the pins and when the server gets it
(put an npc that uses setshape there)
then you calculate how many pins are falling
and display it.


All times are GMT +2. The time now is 03:30 AM.

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