83
« on: April 13, 2013, 06:14:03 PM »
Since the battle maps and stuff are getting an overhaul, hoping alex can take the time and look at that
as is there's 3 possible layouts of objectives in any battle in the campaign (2 on the middle, 3 diagonal, and 5 in X formation iirc). I'm wondering if it would be possible to make this a bit more random.
as is this can be done for the campaign by something like this (forgive any error in code, just theoretical example for demonstration)
api.addObjective(minX + width * (float) Math.random(), minY + height * (float) Math.random(), "nav_buoy");
the problem with this, of course, is that things can get rather imbalanced (what if all the objectives spawned at your side or the enemies?). To solve that, two things can be done:
a) simply mirror the map, basically setting a set of variables on the generator instead of randomizing it there, then use the reverse to add another objective, this way the objectives will come in pairs, like such:
float thisx = math.random();
float thisy = math.random();
api.addObjective(minX + width *thisx, minY + height * thisy, "nav_buoy");
api.addObjective(minX + width * (1-thisx), minY + height * (1-thisy), "nav_buoy");
b) the more complex way of going about this, I don't have it all figured out yet. Perhaps a value can be assigned to each objective, depending on its type and location. (though with the next patch, maybe all the objectives will have about the same value)
the equation should go something like this:
float value = (objective.y/height)-0.5 / (1+math.abs((objective.x/width)-0.5)) * objectivevalue
meaning, each objective will be graded on its height (negative value if closer to player, positive if close to enemy), it's location on X axis (objectives on the sides are worth less since they're harder to get to), and its original value (as is comm relays are far more valuable than the rest, for example, but this will change with time). Then the map generator can use that data and generate the map so that all the objective values in the game adds up to or close to 0, ensuring relative balance
hope I made sense for the most part, thoughts?
gunny