Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Help on a weapon (https://forums.graalonline.com/forums/showthread.php?t=19478)

Link188 12-23-2001 01:03 PM

Help on a weapon
 
Can someone help me on this script?


// NPC made by Jeice Lighthawk
if (playerenters) {
toweapons *Giru Shoot;
replaceani shoot,giru_shoot;
setstring girushot,#v(strtofloat(#s(girushot))+50);
timeout=0.05;
}
while (isweapon) {
timeout=0.05;
}
if (isweapon) {
this.pos = {screenwidth-125,65};
this.girushot = ((strtofloat(#s(girushot))/50)*10);
showimg 1,girubeam.gif,this.pos[0],this.pos[1];
changeimgvis 1, 4;
showimg 2,girubeam2.gif,this.pos[0],this.pos[1];
changeimgpart 2,0,0,40,this.girushot;
changeimgvis 2, 4;
timeout=0.05;
}
if (weaponfired&&timeout) {
setstring girushot,#v(strtofloat(#s(girushot))-10);
timeout=0.05;
}
if (timeout&&strtofloat(#s(girushot))<50) {
setstring girushot,#v(strtofloat(#s(girushot))+1);
sleep 1;
timeout=0.05;
}
if (weaponfired&&playerdir=0&&strtofloat(#s(levelup)) >0&&timeout) {
shootnuke;
shootfireblast;
timeout=0.05;
}
if (weaponfired&&playerdir=3&&strtofloat(#s(levelup)) >0&&timeout) {
shootnuke right;
shootfireblast right;
timeout=0.05;
}
if (weaponfired&&playerdir=2&&strtofloat(#s(levelup)) >0&&timeout) {
shootnuke down;
shootfireblast down;
timeout=0.05;
}
if (weaponfired&&playerdir=1&&strtofloat(#s(levelup)) >0&&timeout) {
shootnuke left;
shootfireblast left;
timeout=0.05;
}
timeout=0.05;

Faheria_GP2 12-23-2001 01:10 PM

please wrap it in [.code] tags so we can actually read it :o

Faheria_GP2 12-23-2001 01:11 PM

it gets stuck in this loop
while (isweapon) {
timeout=0.05;
}

this loop is a major scripting nono, it has no "break" command, and no "sleep" command

mikepg 12-24-2001 01:26 AM

hmm
 
okay, obviously, youre really new to scripting, but atleast your trying :)

Okay, i have some tips for you!

Instead of doing
if (weaponfired&&timeout&&playerdir=0) {
blah}
ect, you should simplify it!

make it so there is only 1 timeout and weaponfired clause, in other words, make a nested if statement.
NPC Code:

if (timeout) {
if (other clause here) {
}
if (weaponfired) {
}
}


and for the weaponfired section, instead of having all the if playerdirs, use shootfireball playerdir;
that means it shoots the fireball the direction that the player is facing, because 0=up 1=left 2=down 3=right in graal.

And one thing that probably makes your script not run, in the playerdir=up section, you didnt specify a direction for it to shoot the fireball and nuke.

As for the while (isweapon) loop, that is insane.
just put
if (playerenters) {
blah;
timeout = .1;
toweapons MegaCheating Weapon;
}
if (timeout) {
blah;
blah blah;
blah blah blah;
if (isweapon) {timeout = .1;
}
}

that would only loop the timeout if the player has the weapon!


All times are GMT +2. The time now is 09:47 AM.

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