Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   simple movement (https://forums.graalonline.com/forums/showthread.php?t=134265774)

alissalee 02-18-2012 03:01 AM

simple movement
 
im trying to set a simple movement within a level area but it keeps heading up to the top of the gmap instead of staying in the level and doing the random movements.
PHP Code:

function onCreated(){
  
showcharacter();
  
setcharani ("ghostani",NULL);
  
dontblock();
  
this.speed 8;
  
this.options 8+16;
  
startmove();
}
function 
startmove() {
  
this.newx=random(1,63);
  
this.newy=random(1,63);
  
dx=(this.newx-x);
  
dy=(this.newy-y);
  
this.distance = ((this.newy-y)^2+(this.newx-x)^2)^.5;
  
this.time = (this.distance/this.speed);
  
move(dx,dy,this.time,this.options);
}
function 
onMvementFinished) {
  
startmove();



ffcmike 02-18-2012 03:06 AM

Quote:

Originally Posted by alissalee (Post 1684872)
im trying to set a simple movement within a level area but it keeps heading up to the top of the gmap instead of staying in the level and doing the random movements.
PHP Code:

function onCreated(){
  
showcharacter();
  
setcharani ("ghostani",NULL);
  
dontblock();
  
this.speed 8;
  
this.options 8+16;
  
startmove();
}
function 
startmove() {
  
this.newx=random(1,63);
  
this.newy=random(1,63);
  
dx=(this.newx-x);
  
dy=(this.newy-y);
  
this.distance = ((this.newy-y)^2+(this.newx-x)^2)^.5;
  
this.time = (this.distance/this.speed);
  
move(dx,dy,this.time,this.options);
}
function 
onMvementFinished) {
  
startmove();



On GMAPs you have to take into consideration the entire width/height of the map, where 1 - 63 would always be the top left corner level.

You could try something like:

PHP Code:

function onCreated(){
  
temp.offx 32 - (this.64);
  
temp.offy 32 - (this.64);
  
this.centerx this.temp.offx;
  
this.centery this.temp.offy;
}

function 
startmove() {
  
this.newx random(this.centerx 32this.centerx 32);
  
this.newy random(this.centery 32this.centery 32);


There's probably a better way but this would give you a rough idea.

callimuc 02-18-2012 03:17 AM

Quote:

Originally Posted by alissalee (Post 1684872)
function onMvementFinished) {
startmove();
} [/PHP]

Its onMovementFinished() so you actually got 2 typos. Or it just happened when you pasted that here.

alissalee 02-18-2012 03:29 AM

but it defeats the purpose of a certain area were it dose the random movements sorry ive been going thro re-scripting gs1 to gs2 for the last 7 hours and this just is ticking me off to easy

alissalee 02-18-2012 03:30 AM

that was a typo rusing to get it posted

alissalee 02-21-2012 05:50 AM

thanks for the help lol sorry for the late post.


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

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