Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-14-2009, 02:59 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Custom Movement: Help Needed!

Okay so what I have here lets me move fine altho it does not let me move flush against the wall.. and if walking between 2 wall tiles.. example: wall, non, non, wall u have to be perfectly in between the walls to move. Also only lets me move at speeds close to (16/16) i think.

Anyone have any suggestions on making movements twards a wall flush? And is there any way to output the collision points of a onwall2?

PHP Code:
//#CLIENTSIDE
function onCreated()
{
  
this.enabled true;
  
setTimer(0.05);
  if ( 
this.enabled == true )
  {
    
disabledefmovement;
  } else {
      
enabledefmovement;
      }
}

function 
onTimeOut()
{
  
this.speed = (8/16);

  for ( 
i=04i++ )
  {
    if ( 
keydown(i) )
    {

  
temp.tw = ( abs(vecx)) == 16 32 ) / 16;
  
temp.th = ( abs(vecy)) == 16 32 ) / 16;
  
temp.aa = ( abs(vecy)) == .5 );
  
temp.tx player.vecx) * temp.aa;
  
temp.ty player.vecy) * temp.aa;
    
      if ( 
player.ani != "walk" && player.ani != "swim") {
        
setAni("walk"null);
      }

      if ( 
this.enabled == true )
      {
        
player.dir i;
        
temp.nx player.vecx(i)*this.speed;
        
temp.ny player.vecy(i)*this.speed;
        if ( !
onwall2temp.txtemp.tytemp.twtemp.th ) ) {
          
player.temp.nx;
          
player.temp.ny;
        }
      }
    } else {
        if ( !
keydown(0) && !keydown(1) && !keydown(2) && !keydown(3) ) {
          if ( !
onwaterplayer.xplayer.) ) {
            
setAni("idle"null);
          }
        }
      }
  }

  if ( 
onwaterplayer.xplayer.) ) {
    if ( 
player.ani != "swim" ) {
      
setAni("swim"null);
    }
  }

  
  
setTimer0.05 );
  
  
// debug only
  
showpoly(200,{temp.tx,temp.ty,temp.tx+temp.tw,temp.ty,temp.tx+temp.tw,temp.ty+temp.th,temp.tx,temp.ty+temp.th});
  
changeimgcolors(200,1,0,0,.25); 
  

Any help or suggestions appreciated.

PS: This is a rough draft. I know its sloppy but its readable non-the-less.
Reply With Quote
  #2  
Old 07-14-2009, 03:13 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
A common technique to 'close the gap' is usually running a loop like such :
for (temp.i=0;i<playerspeed;i+=1/16)
Then checking for an onwall from the player plus the vecx/y of the player's direction * i. If there is a wall, break the loop and add playerx += vecx(playerdir)*i and so on.
Reply With Quote
  #3  
Old 07-14-2009, 03:29 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
There are 2 positions my script checks so would I be using 2 onwall checks then instead of my onwall2? I didn't realise onwall2 used more CPU then onwall. So that will be something I need to change.
Reply With Quote
  #4  
Old 07-14-2009, 04:19 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
Meh, I used onwall2... I find it much more convenient to do two 16x16 onwall2 checks than 4 onwall checks, especially since you only need those two checks for sliding around corners.
Reply With Quote
  #5  
Old 07-14-2009, 04:42 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
Speeds close to 16/16? As in one?

If you mean something along the lines of speeds like x/16, that's fine, as 1/16 is one pixel in Graal coordinates.
Reply With Quote
  #6  
Old 07-14-2009, 04:44 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
I adjust my onwall2 to compensate for whatever speed the player is moving.
Reply With Quote
  #7  
Old 07-14-2009, 07:04 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
Doesn't that make the player stop further away from the wall..?
Reply With Quote
  #8  
Old 07-14-2009, 05:45 PM
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
Not if you close the gap like I explained
Reply With Quote
  #9  
Old 07-15-2009, 01:22 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
Well I don't see the point of doing onwall2, as you can't have sliding collision then.
Reply With Quote
  #10  
Old 07-15-2009, 01:41 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
How so? I have sliding collision...
Reply With Quote
Reply


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:54 PM.


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