Monsters seeing thru liquids and/or glass
Posted: Mon Feb 09, 2015 11:09 pm
What would be the best approach to the subject ? Assuming I'm targeting modern engines like Darkplaces and FTE.
I've been thinking about and the best idea that occurred me would be multiple calls to traceline:
Any better idea or suggestions ? I think this is kinda hacky and too prone to fail. :?
I've been thinking about and the best idea that occurred me would be multiple calls to traceline:
Code: Select all
// pseudocode
float (entity monster, entity player) canSee =
local entity etmp;
traceline (monster.origin, player.origin, FALSE, monster);
if (trace_fraction < 1.0) {
if (trace_inwater) { // player probably is inside water
traceline (trace_endpos, player.origin, FALSE, world);
if (trace_fraction == 1) { return TRUE; }
}
else if (trace_ent != player) {
if ((trace_ent.solid == SOLID_BSP) && (trace_ent.alpha < 1.0)) { // assume some sort of glass
etmp = trace_ent;
traceline (player.origin, monster.origin, FALSE, player);
if (trace_ent == etmp) { return TRUE; }
}
}
}
return FALSE;
}