Topic: laser hit, not well-coded
// TODO: should be more general
CHARACTER *GAMEWORLD::intersect_character(vec2 pos0, vec2 pos1, float radius, vec2& new_pos, ENTITY *notthis)
{
// Find other players
float closest_len = distance(pos0, pos1) * 100.0f;
vec2 line_dir = normalize(pos1-pos0);
CHARACTER *closest = 0;
CHARACTER *p = (CHARACTER *)game.world.find_first(NETOBJTYPE_CHARACTER);
for(; p; p = (CHARACTER *)p->typenext())
{
if(p == notthis)
continue;
vec2 intersect_pos = closest_point_on_line(pos0, pos1, p->pos);
float len = distance(p->pos, intersect_pos);
if(len < CHARACTER::phys_size+radius)
{
if(len < closest_len)
{
new_pos = intersect_pos;
closest_len = len;
closest = p;
}
}
}
return closest;
}
because there may be a Tee with a shorter "closest_len" behind another Tee that stands between him and the laser
see my drawing for explain
i tried in game to jump and shoot to create the same situation and you can see result by screenshoot