The Daily Click ::. Forums ::. Klik Coding Help ::. Attack collision theory & combos
 

Post Reply  Post Oekaki 
 

Posted By Message

Lukas Hägg



Registered
  02/01/2004
Points
  642
17th July, 2006 at 22:59:06 -

I'm working on a platformer game in which the way you fight resembles that of a fighting game and there's two things on my mind.

Hit detection and Combos.

Let's start with hit detection. If you want an enemy to take damage of the player avatars attack animation, you make events too check and see which frame is active when the collision occurs. Right? When I was trying this the last time, I used TGF and I haven't tried it in MMF (1-2). But it didn't work very well in TGF, or maybe it was just my code that was all messy and bad (probably that)

So I went with a different approach on the problem. Collision detectors. One to check if the player makes damage, and one to check if the player takes damage. (Took a sprite of May Lee from KoF to 'show' what I mean)

Image
Is this a good way to do this or an incredibly stupid way to do this?


Over to combos. I checked around TDC to see if there were anything on this. And there was, RapidFlash pointed out how you should use an alterable string to make the player inputs input letters in a string. It works, but there's no limit to how long the intervals between player inputs can be. How can this be solved. I got nothing right now.

Thanks.

Image Edited by the Author.

 
Mendokuse...

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
17th July, 2006 at 23:42:58 -

One way would be to come up with some minimum interval, then insert a character representing that into the string.

Example:
ZXCXCXXXZXCXZXZ (the raw string)
ooooZoXoooCXoooCoXoXoXoooZoXoCXooZXoZooo (string with a 'o' inserted every 1/10th of a second or whatever)

The frequency of the minimum interval will have to be tweaked, but basically this way you know that any two keys that are separated by nothing or only one 'o' were hit at most 2/10ths of a second apart, while any two keys separated by two 'o's were hit at least 1/10th of a second apart. That's not ideal but smaller intervals will result in higher precision.

As for the collisions, that's a perfectly okay way to do it. Rather than drawing the hitzones manually the way I'd do it would be to create three versions of the main character object, one which is visible (the sprite) and two invisible others representing the take-damage and deal-damage zones. Then for each frame of animation in the two invisible objects, delete all non-applicable areas of the sprite.
Assuming you're not doing that already, it's just less tedious.

 
n/a

Lukas Hägg



Registered
  02/01/2004
Points
  642
18th July, 2006 at 00:23:59 -

[quote]One way would be to come up with some minimum interval, then insert a character representing that into the string.

That's sounds like it would work. When I tested the combo thing before I put in an event which cleared the string of all characters when a combo where input succesfully. Combined with that, I think this would make a very much solid combo-engine-thing.

[quote]Rather than drawing the hitzones manually the way I'd do it would be to create three versions of the main character object, one which is visible (the sprite) and two invisible others representing the take-damage and deal-damage zones. Then for each frame of animation in the two invisible objects, delete all non-applicable areas of the sprite.

That's pretty much what I was doing. Cool!

EDIT// Ran into a problem with it. I need to tell MMF to ignore the o's when searching for a completed combo-string, like in the current case that would be 'PKP'. I'm pretty sure it can be done with Mid$ or something. But I'm not sure how.

Image Edited by the Author.

 
Mendokuse...

Werbad



Registered
  18/09/2002
Points
  235
18th July, 2006 at 07:03:10 -

Set value A to 10 every time a button is pressed and use that as a counter, when Value A is 0, clear the string... filling the string with o's doesn't soun like a goo solution since the string would get very big after a while

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
18th July, 2006 at 09:19:30 -

No. If the string is treated as a vector, it will never exceed it's (arbitrary) maximum size.

Ironically, your idea WOULD have exactly that problem, as continued input wouldn't allow A to ever reach zero and the string could grow indefinitely (ignoring the fact that MMF can handle its own memory).

Lukas Hägg: There's a string parser extension (don't recall the name, but there can't be too many of those) that can delete all of a particular character from a string. Then you can look for a 'combo' substring, then compare it to the number of o's in that section of the master string (given the length of the particular 'combo' substring matched, for example if a combo is 5 characters long then you know it can't contain more than, say, 5+2 o's) to determine whether the timing was okay.

Edit:
Actually, just some clarification, when you say 'combo' are you referring to multi-hit combos or special moves? Honestly I read it as the latter at first since I couldn't think of why you'd need an input string otherwise. If the former is your concern, then I don't see why you couldn't do it with a contact timer, a flag or two and a table of cooldown-times for each move.

Image Edited by the Author.

 
n/a

Werbad



Registered
  18/09/2002
Points
  235
18th July, 2006 at 16:00:59 -

I did this once and i put a limit of 8 characters in my string, the problem with the o thing is that it fills even if you don't press anything... not that it matters if you limit the string...

example of limiting it would be:
* on pressing up
- set string to right$( string$( "String" ) + "u",

 
n/a

Lukas Hägg



Registered
  02/01/2004
Points
  642
19th July, 2006 at 19:41:28 -

It's for special moves.

Radix: Does that extension let you have that as a condition? Unlike the normal String Parser which only let's you have "Is Url Safe?" as a condition.

And I've found that the 'o' solution may not be perfectly airtight. I set the interval to 0,55 seconds and depending on when you start your input, the difficulty of making a correct input varies. Sometimes you begin the input at say the 0,49th of that interval. That will possibly create the x in the splitsecond you switch to press the next button. But yes, it's still a very minor problem and most players won't notice. But it's still there. >_>

I'm using MMF2 for this, so old extensions that haven't/will not be ported are kind of out the question sadly. =(

Image Edited by the Author.

 
Mendokuse...

Lukas Hägg



Registered
  02/01/2004
Points
  642
19th July, 2006 at 20:11:32 -

*Reads Phizzy's post.*
...
...

*Slaps face.*

I did try with 'Compare two general values', but not with String Parser. Didn't even cross my mind. I haven't worked with String Parser much, so I'm not sure what to do with it.

 
Mendokuse...

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
20th July, 2006 at 00:00:52 -

As I said, you'll have a one-interval margin of error. Like I also said, the smaller the interval the more precision you'll have. If you set it as low as possible (1/50th of a second in MMF), you can simply increase the minimum allowable gap between inputs (say 10 o's are allowed between input but 11 o's are not).

 
n/a

Lukas Hägg



Registered
  02/01/2004
Points
  642
20th July, 2006 at 00:29:37 -

Ah, I didn't fully get what you meant before.

Shen wrote an article about strings and s. parser, and it does explain a deal about it. But not enough so that I can work out how to use it for this. I've got the theory down now though.

 
Mendokuse...
   

Post Reply



 



Advertisement

Worth A Click