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 02-20-2006, 11:17 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
Movement Sliding

Hi,

well u all know that the classic movement "slides" around edges...

whats the best way to put this into a scripted movement?
Only thing i could think of is testing coordinates at a slightly offset place and if theres no wall move the char towards this place =/

Any better solutions?
Reply With Quote
  #2  
Old 02-21-2006, 03:12 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
I was also wondering how this would be accomplished :x
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #3  
Old 02-21-2006, 04:42 PM
Polo Polo is offline
Classic Systems Admin
Join Date: Sep 2002
Location: Vancouver, Canada
Posts: 735
Polo is on a distinguished road
Send a message via AIM to Polo
To do it, theres a few certain rules to consider.

1) We only need to do the sliding when only one direction is being pressed. If the player is trying to walk on a diagonal, the sliding should not be done. (It's fairly easy to prove this).

2) We only need to do sliding if the player has not moved as a result of ther normal movement.

3) The wall detection doesn't care about walls directly to the side of the player, only those directly in front of, and those on the diagonals to the players base. Basically, you take the area in front of the player, and then shift it left or right (from the characters facing direction) up to 1 tiles worth, each direction relating to each sliding direction. If these tiles are clear, then the player can slide in that direction. The reason we need to look at the shifts 0 to 1 is because we dont know how much the player is clipping the wall, how large the gap they are sliding into is (we don't want to over measure and detect the wall on the other side).

4) It is worthwhile to note that because this is not looking at the tiles to the side of the player, this allows the player to move onto a wall to accomplish the sliding, which may sound odd, but is actually how the original movement behaves.

5) If you use a sliding speed greater than 1/16 (1 pixel) per timeout, then you need to check that the player is not overshooting the free area. For example, if you have a gap which is perfectly the width of the player, its likely that they will need to slide in order to line up with it. If the sliding speed is too fast, they will slide back and forth between the two sides, and never align with the gap.

If you want any clarification on the things I've said, dont hesitate to ask!
__________________
Be good little players, or Master Storm will ban you!



Proof that the staff are crazy..
*Ghost Pirate: I'm a little teacup short and stubbe here is my raygun here is my butt
DragonX: Jumping jack rabbits Batman! Our eggo waffles have been stolen! To the batmobile Robin!
X-Mann (RC): I have a head ache
Reply With Quote
  #4  
Old 02-21-2006, 06:08 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
Quote:
Originally Posted by Polo
4) It is worthwhile to note that because this is not looking at the tiles to the side of the player, this allows the player to move onto a wall to accomplish the sliding, which may sound odd, but is actually how the original movement behaves.
i dont get this one lol

thanks for the others =D
Reply With Quote
  #5  
Old 02-21-2006, 08:04 PM
Polo Polo is offline
Classic Systems Admin
Join Date: Sep 2002
Location: Vancouver, Canada
Posts: 735
Polo is on a distinguished road
Send a message via AIM to Polo
Quote:
Originally Posted by projectigi
i dont get this one [number 4 - Storm] lol

thanks for the others =D
Ok, consider the 2 examples in the attached image. The black are shows the wall, and the blue area shows where we need to check before sliding the player.

The first example is demonstrating where we check to see if they can slide, with the player walking to the right.

In the second example, we are still checking the same area, and as it is clear, we should make the player slide, even though it will move them up over the top wall to do this. Hope that clarifies things a bit.
Attached Thumbnails
Click image for larger version

Name:	wallsliding_example_01.png
Views:	199
Size:	1.3 KB
ID:	35646  
__________________
Be good little players, or Master Storm will ban you!



Proof that the staff are crazy..
*Ghost Pirate: I'm a little teacup short and stubbe here is my raygun here is my butt
DragonX: Jumping jack rabbits Batman! Our eggo waffles have been stolen! To the batmobile Robin!
X-Mann (RC): I have a head ache
Reply With Quote
  #6  
Old 02-21-2006, 08:55 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
Yes, it does.
thanks
Reply With Quote
  #7  
Old 02-21-2006, 09:03 PM
Polo Polo is offline
Classic Systems Admin
Join Date: Sep 2002
Location: Vancouver, Canada
Posts: 735
Polo is on a distinguished road
Send a message via AIM to Polo
Quote:
Originally Posted by Polo
1) We only need to do the sliding when only one direction is being pressed. If the player is trying to walk on a diagonal, the sliding should not be done. (It's fairly easy to prove this).
I actually lied a little bit here. There is one case where sliding when holding a diagonal can occur, but I thought it was a lot less common than it is. When holding the diagonal, you need to check for sliding along both leading edges of the player, but you only have to do half the check for each. They should not slide away from the diagonal which they are holding.

For example, if the player is holding up and right, then we can either face upwards and slide to the right, or face to the right and slide upwards. The other 2 checks, facing right and sliding downwards, and facing up and sliding to the left, would feel unnatural to the user, and should be avoided.
__________________
Be good little players, or Master Storm will ban you!



Proof that the staff are crazy..
*Ghost Pirate: I'm a little teacup short and stubbe here is my raygun here is my butt
DragonX: Jumping jack rabbits Batman! Our eggo waffles have been stolen! To the batmobile Robin!
X-Mann (RC): I have a head ache
Reply With Quote
  #8  
Old 02-21-2006, 09:07 PM
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
using my control movement script (movement functions, uploaded on graal.net), I came up with this specifically. Does it just about perfectly, except my movement scripts go exactly to the wall rather than rounding.

PHP Code:
function side_movement() {
  
this.1;
  
this.1;
  for (
i=0i<4i++) {
    if (
keydown(i)) {
      
temp.case_x player.x+vecx(i)*1.5*vecDir(this.speed_factor) - abs(vecy(i))*0.5;
      
temp.case_y player.y+1.5 vecy(i)*1.5*vecDir(this.speed_factor) - abs(vecx(i))*0.5;
      
temp.case_one tilesSwitch(temp.case_x,temp.case_y,7/8,7/8);
      
temp.case_x player.x+vecx(i)*1.5*vecDir(this.speed_factor) + abs(vecy(i))*(5/8);
      
temp.case_y player.y+1.5 vecy(i)*1.5*vecDir(this.speed_factor) + abs(vecx(i))*(5/8);
      
temp.case_two tilesSwitch(temp.case_x,temp.case_y,7/8,7/8);;    
    
/* In case I screw this up
      temp.case_x = player.x+1 + vecx(i)*1.5 - abs(vecy(i))*0.5;
      temp.case_y = player.y+1.5 + vecy(i)*1.5 - abs(vecx(i))*0.5;
      temp.case_one = tilesSwitch(temp.case_x,temp.case_y,7/8,7/8);
      temp.case_x = player.x+1 + vecx(i)*1.5 + abs(vecy(i))*(5/8);
      temp.case_y = player.y+1.5 + vecy(i)*1.5 + abs(vecx(i))*(5/8);
      temp.case_two = tilesSwitch(temp.case_x,temp.case_y,7/8,7/8);;
    */
      
if (temp.case_one xor temp.case_two) {
        if (
temp.case_one) {
          
this.offx 1.0 vecx(i)*1.5*vecDir(this.speed_factor) + abs(vecy(i))*0.5;
          
this.offy 1.5 vecy(i)*1.5*vecDir(this.speed_factor) + abs(vecx(i))*0.5;
          
movedx(abs(vecy(i))*this.sidemove_speed,player);
          
movedy(abs(vecx(i))*this.sidemove_speed,player);
        } else {
          
this.offx 1.0 vecx(i)*1.5*vecDir(this.speed_factor) - abs(vecy(i))*0.5;
          
this.offy 1.5 vecy(i)*1.5*vecDir(this.speed_factor) - abs(vecx(i))*0.5;
          
movedx(-abs(vecy(i))*this.sidemove_speed,player);
          
movedy(-abs(vecx(i))*this.sidemove_speed,player);
        }
      }
    }
  }

forgot to say, tilesSwitch would be the function you use for wall detection on an area.

Last edited by jake13jake; 02-22-2006 at 12:24 AM..
Reply With Quote
  #9  
Old 02-24-2006, 03:18 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by jake13jake
using my control movement script (movement functions, uploaded on graal.net), I came up with this specifically. Does it just about perfectly, except my movement scripts go exactly to the wall rather than rounding.

forgot to say, tilesSwitch would be the function you use for wall detection on an area.
What's up with the double-semicolon?
>> temp.case_two = tilesSwitch(temp.case_x,temp.case_y,7/8,7/8);;
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #10  
Old 02-24-2006, 06:30 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 ApothiX
What's up with the double-semicolon?
>> temp.case_two = tilesSwitch(temp.case_x,temp.case_y,7/8,7/8);;
Ooops, something I got out of there eventually. (that's a really old version of the script because I couldn't get on RC from where I was posting :P)

Add: the one I'm using now just uses the onTiles function I made because I am finally able to detect NPCs correctly for Stefan adding an npc.var for whether or not the NPC is blocking. Now I just need to wait for Stefan to add read access to players[i].paused, players[i].rating, and players[i].ratingd, and then reimplement the AP system somehow... though reimplementing the AP system is going to be hard. Gotta look for NPCs that don't use the heal() function, gotta make exceptions for spar and event levels, and I gotta add a earnedhp variable so the maxhp variable can override it (which will be a fun challenge).

hp = how many hearts
maxhp = how many hearts you can have currently.
earnedhp = how many hearts you have by default

maxhp can go under earnedhp depending on AP, but I don't want to cap it because perhaps there would be some event in which you want to give a player 20 hearts.

But yea, that's the easiest way to manipulate to include the AP system based on how everything's already built for Classic.

I don't know how I got on this tangent.

Last edited by jake13jake; 02-24-2006 at 09:33 PM..
Reply With Quote
  #11  
Old 03-02-2006, 01:48 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
http://wiki.graal.us/Movement_Tutorial

wikified for accessibility and further modification
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #12  
Old 03-02-2006, 03:27 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 Dach
http://wiki.graal.us/Movement_Tutorial

wikified for accessibility and further modification
I wouldn't exactly call that a relevant tutorial. After all, side moving doesn't obey the same wall detection.
Reply With Quote
  #13  
Old 03-02-2006, 02:35 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by jake13jake
I wouldn't exactly call that a relevant tutorial. After all, side moving doesn't obey the same wall detection.
I think it's a tad more relevant than this:

Quote:
Originally Posted by jake13jake
Now I just need to wait for Stefan to add read access to players[i].paused, players[i].rating, and players[i].ratingd, and then reimplement the AP system somehow... though reimplementing the AP system is going to be hard. Gotta look for NPCs that don't use the heal() function, gotta make exceptions for spar and event levels, and I gotta add a earnedhp variable so the maxhp variable can override it (which will be a fun challenge).

hp = how many hearts
maxhp = how many hearts you can have currently.
earnedhp = how many hearts you have by default

maxhp can go under earnedhp depending on AP, but I don't want to cap it because perhaps there would be some event in which you want to give a player 20 hearts.

But yea, that's the easiest way to manipulate to include the AP system based on how everything's already built for Classic.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
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 06:48 AM.


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