Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 08-11-2007, 07:28 AM
Horrified Horrified is offline
Rediculously inactive
Join Date: Jul 2007
Posts: 961
Horrified is on a distinguished road
Send a message via ICQ to Horrified Send a message via AIM to Horrified Send a message via MSN to Horrified Send a message via Yahoo to Horrified
:O!

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

Thanks.
Reply With Quote
  #3  
Old 08-11-2007, 06:04 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Pretty nice and interesting
__________________
Reply With Quote
  #4  
Old 07-24-2017, 07:34 AM
Kamaeru Kamaeru is offline
G2k1
Kamaeru's Avatar
Join Date: Dec 2001
Posts: 1,040
Kamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud of
Dude this is really useful. I've used it for a few things.
__________________
3DS friendcode: 1118-0226-7975
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 03:47 PM.


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