Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-18-2006, 01:31 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Legend movement preview

A preview of the script I plan to use for the movement. There will be variations for speed, and the distance you travel after you let go of the button (for flying and other vehicles) but this is a general idea of what it will be like. It's pretty smooth, but I'm working on it even better. Also, this is in GS1 just so you can test it off line. What do you think?
PHP Code:
if(created)
{
  
freezeplayer .05;
  
timeout .05;
}
if(
timeout)
{
  if(
this.count==1)
  {
    
this.cx=mousex-.5;
    
this.cy=mousey-.5;
    
this.count=0;
  }
  
this.count++;
  
showimg 1000,dr-crosshairs.png,this.cx,this.cy;
  
freezeplayer .05;
  if(
keydown(0))
  {
    
playerx+=.75*sin(this.ang*(3.14/180));
    
playery-=.75*cos(this.ang*(3.14/180));
  }
  if(
keydown(2))
  {
    
playerx-=.75*sin(this.ang*(3.14/180));
    
playery+=.75*cos(this.ang*(3.14/180));
  }
  if(
keydown(1))
  {
    if(
abs(playery-mousey)>abs(playerx-mousex))
    {
      
playerx-=.75*cos(this.ang*(3.14/180));
    }
    else
    {
      
playerx+=.75*cos(this.ang*(3.14/180));
    }
    if(
abs(playery-mousey)>abs(playerx-mousex))
    {
      
playery+=.75*sin(this.ang*(3.14/180));
    }
    else
    {
      
playery-=.75*sin(this.ang*(3.14/180));
    }
  }
  if(
keydown(3))
  {
    if(
abs(playery-mousey)>abs(playerx-mousex))
    {
      
playerx+=.75*cos(this.ang*(3.14/180));
    }
    else
    {
      
playerx-=.75*cos(this.ang*(3.14/180));
    }
    if(
abs(playery-mousey)>abs(playerx-mousex))
    {
      
playery-=.75*sin(this.ang*(3.14/180));
    }
    else
    {
      
playery+=.75*sin(this.ang*(3.14/180));
    }
  }
  
timeout .05;

Reply With Quote
  #2  
Old 10-18-2006, 02:33 AM
Crono Crono is offline
:pluffy:
Join Date: Feb 2002
Location: Sweden
Posts: 20,000
Crono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond reputeCrono has a reputation beyond repute
hot

wait wtf it's like buggy

if i press left sometimes it goes right and starts bouncing and **** x_X!
__________________
Reply With Quote
  #3  
Old 10-18-2006, 03:12 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Yeah I know, there are some bugs. For left/right, try to keep the mouse in the same spot, and don't get to close. Also, I wouldn't press up or doan and left/right at the same time. I'm still working on this
Reply With Quote
  #4  
Old 10-18-2006, 04:50 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Well, I hope you can pull off a bugless serversided movement system. This current version has plenty of problems.
Reply With Quote
  #5  
Old 10-18-2006, 05:04 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Gambet View Post
Well, I hope you can pull off a bugless serversided movement system. This current version has plenty of problems.
Way to help him out
Reply With Quote
  #6  
Old 10-20-2006, 05:01 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Quote:
Originally Posted by Gambet View Post
Well, I hope you can pull off a bugless serversided movement system. This current version has plenty of problems.
Do you mean custom movement system? Serverside player movement would detract so much from gameplay that I wouldn't even look into it.
Reply With Quote
  #7  
Old 10-20-2006, 05:58 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Quote:
Originally Posted by jake13jake View Post
Do you mean custom movement system? Serverside player movement would detract so much from gameplay that I wouldn't even look into it.
Oh yeah...damn...I should have pointed that out lol.

Anyway, have a much more complex system now, in gs2, with variable speed and 'drift' (the amount of time you comtinue in the same direction after you have pressed the button, this is for use with different vehicles, or terrain, such as ice, space, mud, etc).
Reply With Quote
  #8  
Old 10-24-2006, 04:17 AM
wild8900 wild8900 is offline
Mr. Brightside
wild8900's Avatar
Join Date: Dec 2005
Posts: 418
wild8900 is an unknown quantity at this point
Send a message via MSN to wild8900
Oh, by a glance at the code, I take it that this is the topdown shooter server you told me about? Sounds really fun, when will the server be playable to the public?

Btw,
I was working on a 360 degree car system with fine collision (sliding across walls too) detection. Ill post part of it for people to use. Its GS1 thought because I test it out in the editor (just an excuse to not learn GS2).

If anyone wants me to, I can post an edited one that allows straifing (and moving forward at same time).

NPC Code:

//If used, please give credit to me, wild8900 (or my persona, Irata)
//This is the basic collision and movement script.
//The collision is based around a centered point.
checky = y+sin((360-direction)*(3.14159/180))*speed;
checkx = x+cos((360-direction)*(3.14159/180))*speed;
if (!onwall(x, checky)) {
y = checky;
}
if (!onwall(checkx, y)) {
x = checkx;
}



Last edited by wild8900; 10-24-2006 at 05:28 AM..
Reply With Quote
  #9  
Old 10-18-2006, 05:12 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
I think I'm going to make it edit your direction when you get cose to an edge that might make you shake. The current version is clientside, but it'd be a similar script serverside.
The math+smoothness is what I'm going for here
Reply With Quote
  #10  
Old 10-24-2006, 06:10 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
Yea, I have a lot of good movement functions down in GS2 if you'd want to convert. Definitely makes it a lot easier. movedx (with wallcheck) movedy (with wallcheck) moveobj(tiles,dx,dy,object). tiles being an array of tiletypes to be considered walls. The trick is to add up the amount of distance you'd want to move in terms of x and y as separate variables and then putting it in the function. These functions can be integrated onto any existing movement system as well (won't make you go through walls unless your other movement is fundamentally flawed)
http://graal.net/snippet/detail.php?type=snippet&id=88

A few variables you'd want to define in your weapon NPC containing this script though (people often forget to).

this.offx (offset from natural x value of character/object to the point where you want to block)
this.offy (offset from natural y value of character/object to the point where you want to block)
this.w (width of the area being blocked)
this.h (height of the area being blocked)

you can change these if you want to do multiple movements of an object in the same script.
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:53 PM.


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