Graal Forums

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

LiquidIce00 11-12-2001 08:01 AM

weapon list..
 
I was b0red.. nothing much . u can learn off of it .. ^^ (i still rather use the one that comes with Graal)
I would make it go around like instead of just showing 1 it shows a circle of them. . but its not like im going to use this ^_^
NPC Code:

// NPC made by LiquidIce - PM MY RC plz
timeout=.05;
if (playerenters&&!isweapon) {
toweapons -Backpack;
}
if (isweapon) { disableselectweapons; }
if (timeout&&isweapon) {
this.timer=(this.timer+1)%3;
if (keydown(9)&&this.timer=2) {
if (this.inmenu=1) {
hideimg();
this.inmenu=0;
}
else { this.inmenu=1; }
}
if (this.inmenu=1) { disabledefmovement;
if (this.timer=2) {
checkkey();
}
draw();
}
}

function draw() {
//gain weapons count w/o hidden weapons
this.count=0;
for (this.i=0;this.i<weaponscount;this.i++) {
if (!startswith(-,#w(this.i))) { this.count++; }
}
//player has no weapons. shut down
if (this.count=0) { setplayerprop #c,You have no weapons; this.inmenu=0;hideimg(); return;}
//check if the current weapon is the first non hidden
this.notfirst=0;
for (this.i=0;this.i<selectedweapon;this.i++) {
if (!startswith(-,#w(this.i))) { this.notfirst=1 }
}
if (selectedweapon>0&&this.notfirst=1) { showimg 100,@<,screenwidth/2-20,screenheight/2; }
else { hideimg 100; }
showimg 101,#W,screenwidth/2,screenheight/2;
showimg 102,@#w,screenwidth/2-strtofloat(#v(strlen(#w)))*2,screenheight/2-30;

if (selectedweapon<this.count) {
showimg 103,@>,screenwidth/2+40,screenheight/2;
}
else { hideimg 103; }
for (this.i=0;this.i<4;this.i++) { changeimgvis this.i+100,4; }
}

function hideimg() {
for (this.i=0;this.i<4;this.i++) { hideimg this.i+100; }
enabledefmovement;
}

if (playerhurt&&this.inmenu=1) {
this.inmenu=0;
hideimg();
}
function checkkey() {
if (keydown(1)) {
//find index of before non hidden weapon
for (this.i=selectedweapon-1;this.i>-1;this.i--) {
if (!startswith(-,#w(this.i))) { selectedweapon=this.i; return;}
}
play nextpage.wav;
}
if (keydown(3)) { selectedweapon+=1; play nextpage.wav; }
}


jonny12 11-13-2001 09:06 PM

what does it do?
dose not work for me

TDK_Admin1 11-13-2001 09:28 PM

Dude that is awesome! Could you help me learn that type of stuff like:
for (this.i=0;this.i<weaponscount;this.i++) {
please?

LiquidIce00 11-14-2001 12:22 AM

Quote:

Originally posted by jonny12
what does it do?
dose not work for me

should work fine..

LiquidIce00 11-14-2001 12:28 AM

Quote:

Originally posted by TDK_Admin1
Dude that is awesome! Could you help me learn that type of stuff like:
for (this.i=0;this.i<weaponscount;this.i++) {
please?

that just browses thru all the persons weapons..
since even hidden weapons that start with - are considered weapons,when you make your own weapon list you want to keep those away.

If you do selectedweapon+=1; (to go to the next weapon) it will work fine. but if you subtract one it wont. why? because of the hidden npc's.. If a hidden npc is before the one it will just add 1 to it until it finds a non hidden one..
So i use
NPC Code:

//find index of before non hidden weapon
for (this.i=selectedweapon-1;this.i>-1;this.i--) {
if (!startswith(-,#w(this.i))) { selectedweapon=this.i; return;}
}


which will go from your current weapon down to 0 (the first weapon) and find the closest one to it which is not a hidden weapon.
For example lets say you have
bow, bomb, -system, fireblast
When It is on fireblast and I want to go back, I dont want the -system to become the weapon, because if I set it to -system, Graal will say "thats a hidden weapon" and will go back to the fireblast. Now using the loop It will go from -system to bow looking for the first one that is not hidden, which in the case would be bomb^_^
(confusing i hope it helps hehe)

TDK_Admin1 11-14-2001 08:44 PM

Yea I guess it helps a bit. is this.i a built in graal var or is it just the one people most commonly use?

LiquidIce00 11-15-2001 03:26 AM

Quote:

Originally posted by TDK_Admin1
Yea I guess it helps a bit. is this.i a built in graal var or is it just the one people most commonly use?
most common..
i, z, a, b ,x , y
those are like the most common I believe

TDK_Admin1 11-15-2001 08:36 AM

Hmm...very interesting.

entravial 11-15-2001 10:19 AM

~AlphaFlame~

this.i is a this. variable, which means it's basically a variable that only the NPC its located in can use. This. variables can be named anything you want... ex: this.thisisathisvariablelookitisntitlikethecoolest thing... just a really stupid example though :-P

Most people use this.i... probably because i stands for index in most peoples minds... *shrug*.

Faheria_LAT1 11-15-2001 10:41 AM

Nice scripting, but you could at least be more original on how the weapons scroll and appear on the screen ;)

LiquidIce00 11-15-2001 10:45 AM

Quote:

Originally posted by Faheria_LAT1
Nice scripting, but you could at least be more original on how the weapons scroll and appear on the screen ;)
I kno I was just learning ;)
It would be neat if it was like listed alphabetically or something like that .. or listed FF7 style (like a screen then opens up a screen in a screen..and so on) .. or have like the Hat item where its a circle of the weapons (would be trouble with too many weapons though)

entravial 11-15-2001 10:57 AM

~AlphaFlame~

Quote:

I kno I was just learning
It would be neat if it was like listed alphabetically or something like that .. or listed FF7 style (like a screen then opens up a screen in a screen..and so on) .. or have like the Hat item where its a circle of the weapons (would be trouble with too many weapons though)
Alphabetical:
... for loop... strequals...

FF7 style:
... showimg... for loops... and hidden weapons to determine what goes where...

Circle:
... limit the amount of weapons shown at one time... showimg... yet again, for loop...

LiquidIce00 11-16-2001 06:17 AM

Quote:

Originally posted by entravial
~AlphaFlame~



Alphabetical:
... for loop... strequals...

FF7 style:
... showimg... for loops... and hidden weapons to determine what goes where...

Circle:
... limit the amount of weapons shown at one time... showimg... yet again, for loop...

uhhhh..
alphabetically u would have to create an array with all the letters in order..
and FF7 style is just like a menu then it would be grouped..

for circle u would just use cosine/sine (or that new getangle thing) and add radius depending on weaponscount

Falcor 11-16-2001 07:07 AM

Simple but neat. Useless though, unless it servers somesort of purpose like showing other things besides wepons. ect ect.

Slaktmaster 11-16-2001 02:24 PM

Cool, I wish my computer worked so I could finish my weapon list script :(

Its going to be "special", mainly because I'm not a good scripter. ;)

ninjaterd 11-16-2001 05:13 PM

hes right
 
Quote:

Originally posted by jonny12
what does it do?
dose not work for me

hes right u know this script just doesnt work.......sorry.....i entered the level and got no weapon or nuffin

nyghtGT 11-16-2001 05:41 PM

that would look twice as awesome with some background gifs for it too ...

nyghtGT 11-16-2001 05:42 PM

Re: hes right
 
Quote:

Originally posted by ninjaterd

hes right u know this script just doesnt work.......sorry.....i entered the level and got no weapon or nuffin

your so dumb ... it works for people who actually somewhat know what it does ....

LiquidIce00 11-17-2001 03:28 AM

yes it works ;)
it could be useful if you were developing your own type of weapon system .. like Boco was ..
also if you wanted to make a FF style battlesystem you could use this to change weapons or something .. or just use the disableselectweapons command to just disable the weapon list ;)


All times are GMT +2. The time now is 06:38 AM.

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