Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-11-2007, 05:47 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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!
Reply With Quote
 


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 09:13 PM.


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