puzzlepaint / freeage

An open-source reimplementation of the game engine of Age of Empires 2: Definitive Edition.
59 stars 4 forks source link

Elevation attack multiplier #4

Open puzzlepaint opened 4 years ago

puzzlepaint commented 4 years ago

Units should get an attack bonus if they attack something that is below them, and get an attack reduction if they attack something that is above them. For details, see: https://ageofempires.fandom.com/wiki/Attack

Attacking is implemented in Game::SimulateMeleeAttack() in src/FreeAge/server/game.cpp.

It might be useful to add a function to ServerMap to interpolate the elevation at an exact location where a unit stands on, using bilinear interpolation. It might also be useful to define a threshold for a minimum elevation difference for the attack bonus/malus to kick in, otherwise the results for units at a similar height might appear somewhat random.