
3/4 View, Bullets, and Height. Wee!
Hey all, I'm in the process of creating a prototype shooter game in a 3/4 view. Everything has been going fine and dandy, but killing each other on a flat plane leads to a fairly boring world. I'm stuck on implementing bullets traversing heights, however. I can't think of a solid gameplay way of implementing it. Observe this image from Secret of Mana:
Imagine if you will that every number represents a player. I believe that the player at #1 should be able to hit #2, but wouldn't be able to hit #3. #2 should be able to hit both, and #3 should only be able to hit #2. If #1 was right up against the wall, I feel that #2 should be able to hit #1 but #1 shouldn't be able to hit #2 back. There's really no clean way to implement "leaning over a wall and shooting" which can lead to some unfair advantages to players, especially if they're on something like a pyramid structure where every other tile is another level higher. Anyone have any ideas on a way to make the gunplay fair to everyone without overly complicating it?

Sure there is - check for 'low wall tiles' intersecting the path of the shot.
If the low wall is on a higher elevation than the firer, the shot can travel 1 tile further at that (higher) elevation, or on to a higher elevation.
If the low wall is on the same elevation or lower, the shot can pass the wall.
If the target is adjacent to a low wall on the other side of the firer, assign a cover bonus.
Sorted.
If the low wall is on a higher elevation than the firer, the shot can travel 1 tile further at that (higher) elevation, or on to a higher elevation.
If the low wall is on the same elevation or lower, the shot can pass the wall.
If the target is adjacent to a low wall on the other side of the firer, assign a cover bonus.
Sorted.
Winterdyne Solutions Ltd is recruiting - this thread for details!
The calculations are simple really.
Every position that a character can stand will have a value to it (if it's a tile-based game and the map is 16x16, then there will be 16x16 values). Each value is (let's just say) a byte in size, which represents height (so 0 to 255). This value map can double as a collision detection map (if the value you are moving from is more than some amount away from the value you are moving to, then you can't move there). Another way to save space is, if you are using 32bit graphics, but you aren't using the alpha channel, you have the high byte free for this mapping.
Now that you have the height map, you do somewhat of a 3D line distance trick
Your Character (cX, cY, cZ)
Enemy Character (eX, eY, eZ)
Change in X: dX = eX - cX
Change in Y: dY = eY - cY
Change in Z: dZ = eZ - cZ
distance: d = sqrt(dX*dX + dY*dY + dZ*dZ)
Vector X: vX = dX / d
Vector Y: vY = dY / d
Vector Z: vZ = dZ / d
distance (d) becomes the counter for checking the "shotline" (meaning if d=5, then you are going to do a 5 cycle loop). Start with position (cX,cY,cZ) and add vector (vX,vY,vZ) to it every cycle. On each cycle you will check at 2D position (currentX,currentY) for height and compare to currentZ...if the current height is above the currentZ value (by an amount equal to a persons height...if you see his head, it's still a shot) then the algorithm can stop looping because you can't see the person to shoot them.
You had mentioned if the person in #1 gets up against the wall, then #2 would still be able to shoot them or some crap....but here's the thing, if #1 can shoot #2 then #2 can also shoot #1 no matter where either of them are (it's a matter of perspective).
When you get into overcasting (like a block floating in mid air) it becomes a little more difficult, but you can send me e-mail (sabriath@yahoo.com with subject "height mapping") and I can show you how I would do it.
-Sabriath
Every position that a character can stand will have a value to it (if it's a tile-based game and the map is 16x16, then there will be 16x16 values). Each value is (let's just say) a byte in size, which represents height (so 0 to 255). This value map can double as a collision detection map (if the value you are moving from is more than some amount away from the value you are moving to, then you can't move there). Another way to save space is, if you are using 32bit graphics, but you aren't using the alpha channel, you have the high byte free for this mapping.
Now that you have the height map, you do somewhat of a 3D line distance trick
Your Character (cX, cY, cZ)
Enemy Character (eX, eY, eZ)
Change in X: dX = eX - cX
Change in Y: dY = eY - cY
Change in Z: dZ = eZ - cZ
distance: d = sqrt(dX*dX + dY*dY + dZ*dZ)
Vector X: vX = dX / d
Vector Y: vY = dY / d
Vector Z: vZ = dZ / d
distance (d) becomes the counter for checking the "shotline" (meaning if d=5, then you are going to do a 5 cycle loop). Start with position (cX,cY,cZ) and add vector (vX,vY,vZ) to it every cycle. On each cycle you will check at 2D position (currentX,currentY) for height and compare to currentZ...if the current height is above the currentZ value (by an amount equal to a persons height...if you see his head, it's still a shot) then the algorithm can stop looping because you can't see the person to shoot them.
You had mentioned if the person in #1 gets up against the wall, then #2 would still be able to shoot them or some crap....but here's the thing, if #1 can shoot #2 then #2 can also shoot #1 no matter where either of them are (it's a matter of perspective).
When you get into overcasting (like a block floating in mid air) it becomes a little more difficult, but you can send me e-mail (sabriath@yahoo.com with subject "height mapping") and I can show you how I would do it.
-Sabriath
-Sabriath
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement