25 result[0] = point[0] +
forward[0] * distance[0] +
right[0] * distance[1];
26 result[1] = point[1] +
forward[1] * distance[0] +
right[1] * distance[1];
27 result[2] = point[2] +
forward[2] * distance[0] +
right[2] * distance[1] + distance[2];
43 edict_t *
G_Find(edict_t *from,
int fieldofs,
char *match)
55 s = *(
char **)((
byte *)from + fieldofs);
58 if (!Q_stricmp(s, match))
75 edict_t *
findradius(edict_t *from, vec3_t org,
float rad)
87 if (from->solid == SOLID_NOT)
89 for (j = 0 ; j < 3 ; j++)
90 eorg[j] = org[j] - (from->s.origin[j] + (from->mins[j] + from->maxs[j]) * 0.5);
91 if (VectorLength(eorg) > rad)
121 gi.dprintf(
"G_PickTarget called with NULL targetname\n");
126 ent =
G_Find(ent,
FOFS(targetname), targetname);
129 choice[num_choices++] = ent;
135 gi.dprintf(
"G_PickTarget: target %s not found\n", targetname);
139 return choice[rand() % num_choices];
176 t->classname =
"DelayedUse";
179 t->activator = activator;
181 gi.dprintf(
"Think_Delay with no activator\n");
182 t->message = ent->message;
183 t->target = ent->target;
184 t->killtarget = ent->killtarget;
192 if ((ent->message) && !(activator->svflags & SVF_MONSTER)) {
193 gi.centerprintf(activator,
"%s", ent->message);
194 if (ent->noise_index)
195 gi.sound(activator, CHAN_AUTO, ent->noise_index, 1, ATTN_NORM, 0);
197 gi.sound(activator, CHAN_AUTO,
gi.soundindex(
"misc/talk1.wav"), 1, ATTN_NORM, 0);
203 if (ent->killtarget) {
205 while ((t =
G_Find(t,
FOFS(targetname), ent->killtarget))) {
208 gi.dprintf(
"entity was removed while using killtargets\n");
219 while ((t =
G_Find(t,
FOFS(targetname), ent->target))) {
221 if (!Q_stricmp(t->classname,
"func_areaportal") &&
222 (!Q_stricmp(ent->classname,
"func_door") || !Q_stricmp(ent->classname,
"func_door_rotating")))
226 gi.dprintf(
"WARNING: Entity used itself.\n");
229 t->use(t, ent, activator);
232 gi.dprintf(
"entity was removed while using targets\n");
248 float *
tv(
float x,
float y,
float z)
251 static vec3_t vecs[8];
257 index = (index + 1) & 7;
278 static char str[8][32];
283 index = (index + 1) & 7;
285 Q_snprintf(s, 32,
"(%i %i %i)", (
int)v[0], (
int)v[1], (
int)v[2]);
298 if (VectorCompare(angles,
VEC_UP)) {
300 }
else if (VectorCompare(angles,
VEC_DOWN)) {
314 if ( vec[PITCH] == 0) {
318 else if (vec[YAW] < 0)
321 yaw = (
int)(atan2(vec[YAW], vec[PITCH]) * 180 / M_PI);
335 if (value1[1] == 0 && value1[0] == 0) {
343 yaw = (
int)(atan2(value1[1], value1[0]) * 180 / M_PI);
344 else if (value1[1] > 0)
351 forward = sqrt(value1[0] * value1[0] + value1[1] * value1[1]);
352 pitch = (
int)(atan2(value1[2],
forward) * 180 / M_PI);
357 angles[PITCH] = -pitch;
375 e->classname =
"noclass";
400 if (!e->inuse && (e->freetime < 2 ||
level.
time - e->freetime > 0.5)) {
407 gi.error(
"ED_Alloc: no free edicts");
430 memset(ed, 0,
sizeof(*ed));
431 ed->classname =
"freed";
446 edict_t *touch[MAX_EDICTS], *hit;
449 if ((ent->client || (ent->svflags & SVF_MONSTER)) && (ent->health <= 0))
452 num =
gi.BoxEdicts(ent->absmin, ent->absmax, touch
453 , MAX_EDICTS, AREA_TRIGGERS);
457 for (i = 0 ; i < num ; i++) {
463 hit->touch(hit, ent, NULL, NULL);
478 edict_t *touch[MAX_EDICTS], *hit;
480 num =
gi.BoxEdicts(ent->absmin, ent->absmax, touch
481 , MAX_EDICTS, AREA_SOLID);
485 for (i = 0 ; i < num ; i++) {
490 ent->touch(hit, ent, NULL, NULL);
520 tr =
gi.trace(ent->s.origin, ent->mins, ent->maxs, ent->s.origin, NULL, MASK_PLAYERSOLID);