Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Movement on gmap (https://forums.graalonline.com/forums/showthread.php?t=134257313)

thatdwarf 12-15-2009 05:55 AM

Movement on gmap
 
Hey everybody,

I have an NPC who's sole purpose is to move a player on a GMAP from y-coordinate 300 to y-coordinate 50. Straight line, nothing fancy

The problem is when I get to y-coordinate 191 and around 64, the player stops moving

Why is this? And any suggestions on fixing this?

The NPC is a DB NPC, here is the main excerpt:

PHP Code:

//#CLIENTSIDE
function onPlayerTouchsMe() {
  
setani("skilift","");
  
disabledefmovement();
  
onTimeout();
}

function 
onTimeout() {
  
player.dir 0;
  
player.y--;
  
setTimer(0.05);


Obviously there is a check in the actual uploaded script for when the script gets to the destination, I am just posting the main part of the movement. I just need help with the


Thanks in advance

cbk1994 12-15-2009 05:58 AM

The script will stop being active when the player is 3 (?) levels away. Your best bet is to put it in a weapon and have your level NPCs trigger that weapon clientside.

thatdwarf 12-15-2009 06:04 AM

Wouldnt that method be extremely messy?

Maybe I'm not seeing the correct method for going about doing that, but that sounds very messy

DustyPorViva 12-15-2009 06:07 AM

Quote:

Originally Posted by cbk1994 (Post 1544443)
The script will stop being active when the player is 3 (?) levels away. Your best bet is to put it in a weapon and have your level NPCs trigger that weapon clientside.

You got it right. When you're on a gmap it loads your current level and all adjacent.

So something like this:

[ ][ ][ ]
[ ][p][ ]
[ ][ ][ ]


So if you're on a gmap, all the boxes marked with x are 'out of range', and thus scripts and player data are no longer sent:

[x][ ][ ][ ][x]
[x][ ][p][ ][x]
[x][ ][ ][ ][x]
[x][x][x][x][x]
[x][x][x][x][x]

cbk1994 12-15-2009 06:08 AM

Quote:

Originally Posted by thatdwarf (Post 1544445)
Wouldnt that method be extremely messy?

Maybe I'm not seeing the correct method for going about doing that, but that sounds very messy

It's actually cleaner since it keeps all your code in one place and lets you trigger it, if you do it right.

PHP Code:

//#CLIENTSIDE
function onPlayerTouchsMe() {
  (@ 
"-SkiLift").trigger("startLift");


PHP Code:

//#CLIENTSIDE
function onStartLift() {
  
setTimer(1); // etc



DustyPorViva 12-15-2009 06:12 AM

You could probably make a general function and put it in a system NPC, or a class. Most servers will have a WNPC or class dedicated specifically for general functions, like math functions, that can be used between a multitude of NPCs. Add this in a global WNPC or a class that's joined to the player:

PHP Code:

//#CLIENTSIDE
public function moveplayer(dx,dy) {
  
// do movement stuff here


Then if it's a WNPC, you can simply call WeaponName.moveplayer(0,-100); or if it's a player class, player.moveplayer(0,-100);

thatdwarf 12-15-2009 06:50 AM

hmm

On that subject, is the move function usable on the player object? I attempted Dusty's method for the moving, but I tried using player.move() and it wouldnt work. Is this a possible movement technique?

DustyPorViva 12-15-2009 06:57 AM

Nope, sorry, move doesn't work with players(though I wouldn't object to it!). However, you should always avoid using names of available functions, whether they're intended for use with the object or not.

thatdwarf 12-15-2009 06:59 AM

Alright. Thanks Dusty :] Rep for you <3


All times are GMT +2. The time now is 07:45 AM.

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