Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-03-2007, 06:45 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
For Switch and whoever: Staff Boots

As requested in this thread:
http://forums.graalonline.com/forums...ad.php?t=72559

PHP Code:
//Custom staff boots system
//By: Gambet
//Controls:
//  + and = key (left of backspace on American keyboard) - plus speed
//  - and _ key (left of + and = key on American keyboard) - minus speed
//  z key = toggle on/off
//  Max Speed: 10

//#CLIENTSIDE
function onKeyPressed(code,key)
{
 if (
key == "z")
  {
   if (
this.staff_boots == "on")
    {
      
this.staff_boots this.speed "";
      
player.chat "Staff Boots -Off-";
      
setTimer(0);
    } else
     {
       
this.staff_boots "on";
       
player.chat "Staff Boots -On-";
       
setTimer(0.05);
     }
  }
 if (
code == 187)
  {
   if (
this.speed+<= 10)
    {
     
this.speed+=1;
     
player.chat "Speed: " this.speed;
    }
  } else if (
code == 189)
   {
    if (
this.speed->= 0)
     {
      
this.speed-=1;
      
player.chat "Speed: " this.speed;
     }
   }
}

function 
onTimeOut()
{
 if (
this.staff_boots == "on")
  {
   for (
a=0a<4a++)
    {
     if (
keydown(a))
      {
       switch(
a)
        {
          case 
"0":
           
player.y-=this.speed;
           break;
          case 
"1":
           
player.x-=this.speed;
           break;
          case 
"2":
           
player.y+=this.speed;
           break;
          case 
"3":
           
player.x+=this.speed;
           break;
        }
      }
    }
  }
 
setTimer(0.05);



Made it in like 5 minutes so yeah, do with it as you please. Everyone is open to use it, though there are plenty of boot scripts out there for those of you that don't know how to script -- just add this one to the list!


Though you shouldn't get into the habit of just taking peoples scripts without at least bothering to learn the basics of GScript. It sort of defeats the purpose.


Regardless, enjoy!


Reply With Quote
  #2  
Old 03-03-2007, 06:53 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
THANKS SO MUCH GAMBET! NOW you must read my PM ;P
Also, I put it in my server and found an error. We don't want it at speed 0, so here's a revision:
PHP Code:
//Custom staff boots system
//By: Gambet
//Controls:
//  + and = key (left of backspace on American keyboard) - plus speed
//  - and _ key (left of + and = key on American keyboard) - minus speed
//  z key = toggle on/off
//  Max Speed: 10

//#CLIENTSIDE
function onKeyPressed(code,key)
{
 if (
key == "z")
  {
   if (
this.staff_boots == "on")
    {
      
this.staff_boots this.speed "";
      
player.chat "Staff Boots -Off-";
      
setTimer(0);
    } else
     {
       
this.staff_boots "on";
       
player.chat "Staff Boots -On-";
       
setTimer(0.05);
     }
  }
 if (
code == 187)
  {
   if (
this.speed+<= 10)
    {
     
this.speed+=1;
     
player.chat "Speed: " this.speed;
    }
  } else if (
code == 189)
   {
    if (
this.speed->= 1)
     {
      
this.speed-=1;
      
player.chat "Speed: " this.speed;
     }
   }
}

function 
onTimeOut()
{
 if (
this.staff_boots == "on")
  {
   for (
a=0a<4a++)
    {
     if (
keydown(a))
      {
       switch(
a)
        {
          case 
"0":
           
player.y-=this.speed;
           break;
          case 
"1":
           
player.x-=this.speed;
           break;
          case 
"2":
           
player.y+=this.speed;
           break;
          case 
"3":
           
player.x+=this.speed;
           break;
        }
      }
    }
  }
 
setTimer(0.05);

But the error with THAT is that it STARTS at speed 0, then you ahve to press + (or = ) before it actualy is USABLE to move around on walls and stuff.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.

Last edited by Switch; 03-03-2007 at 07:26 PM..
Reply With Quote
  #3  
Old 03-03-2007, 07:36 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Switch View Post
But the error with THAT is that it STARTS at speed 0, then you ahve to press + (or = ) before it actualy is USABLE to move around on walls and stuff.
Where you see: player.chat = "Staff Boots -On-";

Just add after: this.speed = 1;
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #4  
Old 03-03-2007, 07:49 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by napo_p2p View Post
Where you see: player.chat = "Staff Boots -On-";

Just add after: this.speed = 1;


^


That should fix your problem.
Reply With Quote
  #5  
Old 03-03-2007, 08:19 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Eheh ok thanks ^.^
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #6  
Old 03-03-2007, 08:22 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
I'm just curious, is there a way to make it add and minus speed using the mouse wheel?
__________________
Deep into the Darkness peering...
Reply With Quote
  #7  
Old 03-03-2007, 08:45 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Angel_Light View Post
I'm just curious, is there a way to make it add and minus speed using the mouse wheel?


Yes, using the mousewheeldelta and/or mousewheel commands.
Reply With Quote
  #8  
Old 03-03-2007, 08:54 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
I got bored so I compacted Gambet's script

PHP Code:
//Custom staff boots system
//By: Gambet
//Compacted By: Hell Raven (bordem?)
//Controls:
//  + and = key (left of backspace on American keyboard) - plus speed
//  - and _ key (left of + and = key on American keyboard) - minus speed
//  z key = toggle on/off
//  Max Speed: 10

//#CLIENTSIDE
function onCreated() {
  
this.speed 1// reserve speed setting = better feature?
}

function 
onKeyPressed(code,key) {
  if (
key == "z") {
    
temp.statword = {"Off","On"};
    
this.status abs(temp.status 1);
    
player.chat "Staff Boots -"@temp.statword[this.status]@"-";
    
setTimer(.05 this.status);
  }
  if (
code in {187,189}) {
    
temp.speed this.speed 188 code;
    if(
temp.speed in |1,10|)
      
this.speed temp.speed;
  }
}

function 
onTimeOut() {
  for (
a=0a<4a++)
    if (
keydown(a))
      
player.(char(120 + (a+1) % 2)) += (-int(a/2)*2) * this.speed;
      
  
setTimer(.05);

__________________
Reply With Quote
  #9  
Old 03-04-2007, 11:36 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Kristi View Post
I got bored so I compacted Gambet's script
You beat me to it
Reply With Quote
  #10  
Old 03-04-2007, 03:25 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Angel_Light View Post
I'm just curious, is there a way to make it add and minus speed using the mouse wheel?
In a timeout something like this
PHP Code:
function onTimeOut()

 if ( 
mousewheeldelta && this.speed )
 {
  
this.speed -= 1;
 }
 if ( 
mousewheeldelta && this.speed 10 )
 {
  
this.speed += 1;
 }
 
setTimer0.05 );

Sorry about horrible formatting ... the mousewheeldeltas might need to be altered (I forget which way is which).
[EDIT]
Tested this, and fixed the mousewheeldeltas.
Also, this.status = abs(temp.status - 1);?
Should be:
this.status = 1 - this.status;
or:
this.status = abs(this.status - 1);
__________________

Last edited by cbk1994; 03-04-2007 at 03:36 PM..
Reply With Quote
  #11  
Old 03-04-2007, 09:08 PM
Riot Riot is offline
Delteria Management
Join Date: Nov 2003
Location: Seminole County, Florida
Posts: 280
Riot is on a distinguished road
Quote:
Originally Posted by cbkbud View Post
Also, this.status = abs(temp.status - 1);?
Should be:
this.status = 1 - this.status;
or:
this.status = abs(this.status - 1);
or even this.status = !this.status;
Reply With Quote
  #12  
Old 03-04-2007, 09:10 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Riot View Post
or even this.status = !this.status;
Yup, that's my favorite .
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #13  
Old 03-04-2007, 09:22 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
That just doesn't make much sense to me ... 1 - this.status seems so much cleaner
__________________
Reply With Quote
  #14  
Old 03-05-2007, 05:41 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Riot View Post
or even this.status = !this.status;
I prefer this. Just switches the boolean
Reply With Quote
  #15  
Old 03-05-2007, 05:50 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by cbkbud View Post
That just doesn't make much sense to me ... 1 - this.status seems so much cleaner
I like to think of this.status = !this.status as "toggling".
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #16  
Old 03-05-2007, 04:58 PM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
Quote:
Originally Posted by Angel_Light
I'm just curious, is there a way to make it add and minus speed using the mouse wheel?
Try this:

PHP Code:
function onMouseWheel()
{
     if (!(
this.speed+>= 10) && !(this.speed-<= 1))
     {
          
this.speed +=- mousewheeldelta;
     }

__________________
What signature? I see no signature?
Reply With Quote
  #17  
Old 03-05-2007, 05:59 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by godofwarares View Post
Try this:

PHP Code:
function onMouseWheel()
{
     if (!(
this.speed+>= 10) && !(this.speed-<= 1))
     {
          
this.speed +=- mousewheeldelta;
     }

+=-?
__________________
Skyld
Reply With Quote
  #18  
Old 03-05-2007, 06:52 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by Riot View Post
or even this.status = !this.status;
That is my preference too, however, I felt like having fun with math, as you can see from the overall code
__________________
Reply With Quote
  #19  
Old 03-05-2007, 07:11 PM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
Quote:
Originally Posted by Skyld
+=-?
Adds if the integer is positive, subtracts if negative . . . Some stupid unneeded operator ._.
__________________
What signature? I see no signature?
Reply With Quote
  #20  
Old 03-05-2007, 07:17 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by godofwarares View Post
Adds if the integer is positive, subtracts if negative . . . Some stupid unneeded operator ._.
It's not an operator; it's doing what it says:
PHP Code:
temp.foo += -temp.bar
i.e.
PHP Code:
temp.foo 0;
temp.foo +=- 3
... equals -3.
PHP Code:
temp.foo 0;
temp.foo +=- -3
... equals 3.
PHP Code:
temp.foo 0;
temp.foo -=+ 3
... equals -3.
PHP Code:
temp.foo 0;
temp.foo -=+ -3
... equals 3.
__________________
Skyld
Reply With Quote
  #21  
Old 03-05-2007, 07:39 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by godofwarares View Post
Adds if the integer is positive, subtracts if negative . . . Some stupid unneeded operator ._.
Gramatically speaking, what you just said would be adding the absolute value, because subtracting a number when it is negative is like adding its positive, and actually, that is NOT what it is doing, its simply adding the negative of a variable.

In this case, this.speed +=- mousewheeldelta is better written as
this.speed -= mousewheeldelta
__________________
Reply With Quote
  #22  
Old 03-06-2007, 01:43 PM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
Ugh i'm getting my operators screwed up -_-
__________________
What signature? I see no signature?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:42 PM.


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