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)