Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-18-2012, 03:01 AM
alissalee alissalee is offline
Mr. Ciprioni Atrius Admin
alissalee's Avatar
Join Date: Dec 2004
Location: Lawrence, Ma
Posts: 190
alissalee is an unknown quantity at this point
Send a message via AIM to alissalee Send a message via MSN to alissalee
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();

__________________
account was being used by jigga.... sorry for what he has said in the past
Reply With Quote
  #2  
Old 02-18-2012, 03:06 AM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by alissalee View Post
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.

Last edited by ffcmike; 02-18-2012 at 03:25 AM..
Reply With Quote
  #3  
Old 02-18-2012, 03:17 AM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by alissalee View Post
function onMvementFinished) {
startmove();
} [/PHP]
Its onMovementFinished() so you actually got 2 typos. Or it just happened when you pasted that here.
__________________
MEEP!
Reply With Quote
  #4  
Old 02-18-2012, 03:29 AM
alissalee alissalee is offline
Mr. Ciprioni Atrius Admin
alissalee's Avatar
Join Date: Dec 2004
Location: Lawrence, Ma
Posts: 190
alissalee is an unknown quantity at this point
Send a message via AIM to alissalee Send a message via MSN to alissalee
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
__________________
account was being used by jigga.... sorry for what he has said in the past
Reply With Quote
  #5  
Old 02-18-2012, 03:30 AM
alissalee alissalee is offline
Mr. Ciprioni Atrius Admin
alissalee's Avatar
Join Date: Dec 2004
Location: Lawrence, Ma
Posts: 190
alissalee is an unknown quantity at this point
Send a message via AIM to alissalee Send a message via MSN to alissalee
that was a typo rusing to get it posted
__________________
account was being used by jigga.... sorry for what he has said in the past
Reply With Quote
  #6  
Old 02-21-2012, 05:50 AM
alissalee alissalee is offline
Mr. Ciprioni Atrius Admin
alissalee's Avatar
Join Date: Dec 2004
Location: Lawrence, Ma
Posts: 190
alissalee is an unknown quantity at this point
Send a message via AIM to alissalee Send a message via MSN to alissalee
thanks for the help lol sorry for the late post.
__________________
account was being used by jigga.... sorry for what he has said in the past
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 02:23 AM.


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