MCPcopy Create free account
hub / github.com/demoth/jake2 / infront

Method infront

game/src/main/java/jake2/game/GameUtil.java:227–240  ·  view source on GitHub ↗

Returns true if the entity is in front (in sight) of self

(SubgameEntity self, edict_t other)

Source from the content-addressed store, hash-verified

225 * Returns true if the entity is in front (in sight) of self
226 */
227 public static boolean infront(SubgameEntity self, edict_t other) {
228 float[] vec = { 0, 0, 0 };
229 float dot;
230 float[] forward = { 0, 0, 0 };
231
232 Math3D.AngleVectors(self.s.angles, forward, null, null);
233 Math3D.VectorSubtract(other.s.origin, self.s.origin, vec);
234 Math3D.VectorNormalize(vec);
235 dot = Math3D.DotProduct(vec, forward);
236
237 if (dot > 0.3)
238 return true;
239 return false;
240 }
241
242 /**
243 * Returns 1 if the entity is visible to self, even if not infront().

Callers 4

ai_checkattackMethod · 0.95
FindTargetMethod · 0.95
check_dodgeMethod · 0.95
thinkMethod · 0.95

Calls 4

AngleVectorsMethod · 0.95
VectorSubtractMethod · 0.95
VectorNormalizeMethod · 0.95
DotProductMethod · 0.95

Tested by

no test coverage detected