Keen: Modding Forum Index Keen: Modding
All the modding info you'll ever need
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The IMPROVED Gravity Patch

 
Post new topic   Reply to topic    Keen: Modding Forum Index -> Patches: Marooned on Mars
View previous topic :: View next topic  
Author Message
lemm



Joined: 05 Jul 2009
Posts: 532

PostPosted: Sat Aug 29, 2009 10:17 am    Post subject: The IMPROVED Gravity Patch Reply with quote

EDIT: Sep. 2, 2009. Now it modifies the actual gravity.

Code:

%ext ck1
%version 1.31

%patch $2C37 $03     #acceleration

%patch $2C3C $C8 $00   #max gravity
%patch $2C44 $C8 $00


%end


Last edited by lemm on Wed Sep 02, 2009 2:57 pm; edited 1 time in total
Back to top
View user's profile Send private message
levellass



Joined: 11 Oct 2006
Posts: 2053
Location: Ngaruawahia New Zealand

PostPosted: Sun Aug 30, 2009 1:35 pm    Post subject: Reply with quote

Very juicy! I didn't think the level had a y-variable! Now all we need is to be able to change gravity on certain levels.

EDIT: You should also indicate if your patches are incompatible with others you have made. (For example the custom palette patch is incompatible with the status box patch, if I recall.)
Back to top
View user's profile Send private message
lemm



Joined: 05 Jul 2009
Posts: 532

PostPosted: Sun Aug 30, 2009 5:29 pm    Post subject: Reply with quote

You get a buggy zero-gravity if you replace the relevant line with:

Code:

%patch $55F1 $B8 $F780W      # mov ax, $0000W


However, every time a sprite hits the ground, it jumps, and sprites get stuck on the ceiling, similar to how they get stuck on the wall if the "breeze" is too strong, even if their maximum speed is faster than the breeze.[/code]
Back to top
View user's profile Send private message
levellass



Joined: 11 Oct 2006
Posts: 2053
Location: Ngaruawahia New Zealand

PostPosted: Mon Aug 31, 2009 6:23 am    Post subject: Reply with quote

That's interesting; I wonder why? I do know some sprites have a zero speed if they hit tiles (This results in the Vorticons sometimes getting 'stuck' in a wall.
Back to top
View user's profile Send private message
CommanderSpleen



Joined: 31 Aug 2003
Posts: 965
Location: The Land of Sparkly Things

PostPosted: Mon Aug 31, 2009 7:01 am    Post subject: Reply with quote

Hmm, maybe there's a loop that detects the ground by checking where Keen would theoretically fall next using the current velocity, and then subtracts from that value until it's not inside a tile? I don't know anything about how the game handles gravity, but this is a possible scenario.

At any rate there's evidently something else that needs to be patched besides a gravitational constant.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
levellass



Joined: 11 Oct 2006
Posts: 2053
Location: Ngaruawahia New Zealand

PostPosted: Tue Sep 01, 2009 12:20 am    Post subject: Reply with quote

Well, I do know that the gravity/falling is separate from checking for floors/ceilings, since I've turned off the gravity for various sprites. (Or at least a small subroutine that when unpatched,, makes them fall.) so who knows? This is getting interesting.
Back to top
View user's profile Send private message
lemm



Joined: 05 Jul 2009
Posts: 532

PostPosted: Wed Sep 02, 2009 3:08 pm    Post subject: The IMPROVED, ERROR FREE gravity patch Reply with quote

UPDATE: look at the original post. This was actually an incredibly easy patch :p


What I was doing before was altering the map-positions of all sprites AFTER the collision detection etc had been calculated, so that's why the game was screwing up. This patch just modifies the acceleration and the maximum speed. In fact the gravitational constant WAS the only thing that needed patching ;-).


Levellass, you are right, there are two subroutines. This patch modifies the relatively straightforward do_fall() subroutine (0x2C2A). The other subroutine is check_keen_ground() (3f8b), which does the tile collisions by calling another subroutine and is horribly complicated and probably not a good idea to mess with.

There is also a check_ceiling() (0x3365), but I think this just deals with checking the invisible map ceiling as I don't see any references to the tile data.

Finally, if you are wondering about the game loop, I am starting another thread right now in K:V discussion.
Back to top
View user's profile Send private message
CommanderSpleen



Joined: 31 Aug 2003
Posts: 965
Location: The Land of Sparkly Things

PostPosted: Wed Sep 02, 2009 3:17 pm    Post subject: Reply with quote

Sveet. Applause to thee!
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
CommanderSpleen



Joined: 31 Aug 2003
Posts: 965
Location: The Land of Sparkly Things

PostPosted: Fri Sep 04, 2009 2:45 am    Post subject: Reply with quote

Hmm, any idea on how to do this for specific sprites? I managed it with the gargs recently, with similar issues that you described with the previous version of this patch. But I don't quite recall how.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
lemm



Joined: 05 Jul 2009
Posts: 532

PostPosted: Fri Sep 04, 2009 8:06 am    Post subject: Reply with quote

At the end of each think function for that sprite, right before the call to do_fall(), add a value to ds:8240, which is the y_velocity for the current sprite being modified.
Back to top
View user's profile Send private message
levellass



Joined: 11 Oct 2006
Posts: 2053
Location: Ngaruawahia New Zealand

PostPosted: Fri Sep 04, 2009 9:24 am    Post subject: Reply with quote

Lem, Check_Ceiling does indeed push Keen down if he tries to exit non-map levels through the top. If you remove the push-down-ness of it, Keen dies by falling off the top of the level. Lol.

I have kept the breeze patch, but also added this new gravity patch; oddly enough it's been stumbled on before, by me, LL and Andy while trying to do other things. (I KNEW I recognized that line!) But this is the first time something functioning has been made.

Spleen: If you get precise patches, post them here!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Keen: Modding Forum Index -> Patches: Marooned on Mars All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group