Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Player transitional movement (https://forums.graalonline.com/forums/showthread.php?t=76210)

DustyPorViva 08-11-2007 05:47 AM

Player transitional movement
 
Just thought I'd share this very small bit of code, mainly because while small, it can make a big difference in how well made a server can look.
What it does, is 'slide' the player to a new position. Anyways, here's the script. I'll post it so you can put it in a weapon, but if you know what you're doing I'm sure you can crop out the unneeded stuff and fix it into your own systems.

Anyways, what you do is...
core.goto(newx,newy);

And it will 'slide' the player to the new coordinates given. So you could do something like this in a shovel script...
PHP Code:

//#CLIENTSIDE
function onWeaponfired() {
  
core.goto(int(player.x+.5),int(player.y+.5));
  
//This will move the player to the nearest integer tile coordinate before
  //digging your hole, lining up the player with the hole

  //shovel stuff goes here...


So here's the script.
PHP Code:

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

public function goto(
newx,newy) {
  
dist=((newx-player.x)^2+(newy-player.y)^2)^.5;
  while(
dist>.1) {
    
player.x+=(newx-player.x)/5;
    
player.y+=(newy-player.y)/5;
    
dist=((newx-player.x)^2+(newy-player.y)^2)^.5;
    
sleep(0.05);
  }


As for what it's useful for? Just making the game look a little more professional. I get tired of seeing players just 'jump' to a near area, or seeing a hole dug up offset from the shovel. You could incorporate it into many different things like opening doors. You could slide the player in front of the door and set their animation to a door opening gani.

Well, maybe I'm glorifying something too simple to be worth it, but I'd like to see more servers doing something along the lines of this!

Horrified 08-11-2007 07:28 AM

:O!

Very cool. Might use it in one of my projects on my server! :D

Thanks.

Chompy 08-11-2007 06:04 PM

Pretty nice and interesting :)

Kamaeru 07-24-2017 07:34 AM

Dude this is really useful. I've used it for a few things.


All times are GMT +2. The time now is 09:35 PM.

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