Skip to main content
GameDev.net gamedev.net
🔒 Locked

Solution needed

Started by overeasy Sep 20, 2009 at 1:21 PM 4 replies 1.2k views
Original Post
overeasy
overeasy
When characters move in my 2d game, they occupy 2 cells - the cell they are in the cell they are going into. They block both cells, but the character object is contained in the cell they are moving into. How do I handle them being attacked while moving? I don't want to put the character in both cells, because then the AI would think there were two of them. This is making it impossible to attack from behind while the character is moving away from you.
felisandria
felisandria
Can you change the sequence of attacks and moves in the game, or extend the attack range out to 2 cells if either character in question is also in motion?
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
Katie
Katie
How about storing an "amount into the cell" along with the containing information. Any entry "blocks" the cell, but you can tell which one the figure is notionally in by looking for the cell with than 50% in it.

As it moves, you change the ratios until one of the cells contains zero amount of the figure.

You could scale the attacks so that striking a cell which has 1/4 of the figure in it has 1/4 the chance of causing damage.

Captain P
Captain P
Quote:
Original post by overeasy
How do I handle them being attacked while moving?
I don't want to put the character in both cells, because then the AI would think there were two of them.

How do you, as the game designer, want this to be handled by your game?

Anyway, surely you can let your AI know that it's dealing with one character that's occupying multiple cells. Or perhaps using cells for movement just isn't the right decision for a game like yours.
overeasy
overeasy
Quote:
Original post by Captain P
Quote:
Original post by overeasy
How do I handle them being attacked while moving?
I don't want to put the character in both cells, because then the AI would think there were two of them.

How do you, as the game designer, want this to be handled by your game?

Anyway, surely you can let your AI know that it's dealing with one character that's occupying multiple cells. Or perhaps using cells for movement just isn't the right decision for a game like yours.


more importantly, how do other games handle this so I can copy their already working system
felisandria
felisandria
From my experience, a lot of them use internally turn-based logic.

So, element A would have a turn to move, attack, etc, then element B would have a turn to move, attack, etc. If attacks are not happening when you think they should at that point, or if that's impractical for your setup, generally you extend the attack range.
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.