Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Strafe [could be used as a shield block] (https://forums.graalonline.com/forums/showthread.php?t=74273)

xAndrewx 05-29-2007 06:48 PM

Strafe [could be used as a shield block]
 
Well, here's a stafe thing.
HTML Code:

//#CLIENTSIDE
function onCreated()
{
  movement = this;
}

public function onStaticDirection(newDirection)
{
  if (playerDirection != temp.newDirection)
  {
    playerDirection = temp.newDirection;
  }
  if (keydown2(160, true) && playerShield)
  {
    setani("c_shieldblock", "");
    player.dir = playerDirection;
    scheduleevent(0.05, "StaticDirection", playerDirection);
  }
  else
  {
    playerShield = false;
  }
}

How it's called

HTML Code:

//#CLIENTSIDE
function onKeyPressed(letterCode)

  switch(temp.letterCode)
  {
    case 160:
      playerShield = true;
      movement.onStaticDirection(player.dir);
    return true;
  }
}

Advise, make all the keyPressed actions all in one weapon, and then just send it through there

cbk1994 05-31-2007 01:38 AM

Make sure you add a a break in that case 160:

Few things that could work only on your server though.

Otherwise nice, I never realised you could do movement = this; on clientside, and then call it from other weapons!

xXziroXx 05-31-2007 01:39 AM

Uhm..

PHP Code:

movement this

That looks retarded. Why not just name the wNPC to "movement" and do movement.SomeFunctionHere() ?

cbk1994 05-31-2007 01:41 AM

Quote:

Originally Posted by xXziroXx (Post 1313560)
Uhm..

PHP Code:

movement this

That looks retarded. Why not just name the wNPC to "movement" and do movement.SomeFunctionHere() ?

How so?

Notice this is in the code gallery, so people using it might not have custom Q Menus.

In that case, it could be deleted! That would be bad :(
There's nothing wrong with what xAndrewx did... I like it.

Better than doing

( @ "-System/Movement" ).doSomething();

xXziroXx 05-31-2007 01:44 AM

Quote:

Originally Posted by cbkbud (Post 1313563)
I like it.

Good for you! I don't though.

cbk1994 05-31-2007 01:49 AM

Quote:

Originally Posted by xXziroXx (Post 1313566)
Good for you! I don't though.

Why not? It seems perfectly logical to me.

xAndrewx 05-31-2007 10:44 AM

I don't use break, as it would carry on with the script. Calling return just stops the function at hand.

cbk1994 05-31-2007 12:33 PM

Quote:

Originally Posted by xAndrewx (Post 1313721)
I don't use break, as it would carry on with the script. Calling return just stops the function at hand.

It's probably a better practice to always break; at the end of the switch, then use return. Personal preference I suppose though.


All times are GMT +2. The time now is 03:44 PM.

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