Skip to content

Commit 7fb416b

Browse files
committed
show endpoint in /trace
add spawnflags 32 for trigger_newpush with 'speed' value acting as angle (0, 90, 180, 270)
1 parent 1734eae commit 7fb416b

File tree

2 files changed

+53
-39
lines changed

2 files changed

+53
-39
lines changed

codemp/game/g_cmds.c

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7615,50 +7615,47 @@ void Cmd_Trace_f(gentity_t* ent) {
76157615
return;
76167616
}
76177617

7618-
/*
7619-
if (trap_Argc() > 1) {
7620-
int entnr;
7621-
char arg[16];
7622-
trap_Argv(1, arg, sizeof(arg));
7623-
entnr = atoi(arg);
7624-
if (entnr == 0 && !(arg[0] == '0' && arg[1] == 0)) {
7625-
trap->SendServerCommand(ent - g_entities, "print \"^3Invalid entity number.\n\"");
7626-
return;
7627-
}
7628-
tEnt = GetEnt(entnr);
7629-
}
7630-
else */{
7631-
vec3_t start;
7632-
if (!ent)
7633-
return;
7618+
{
7619+
trace_t tr;
7620+
vec3_t fPos, maxs, mins, start;
7621+
7622+
AngleVectors(ent->client->ps.viewangles, fPos, 0, 0);
7623+
VectorSet(mins, -8, -8, -8);
7624+
VectorSet(maxs, 8, 8, 8);
76347625

76357626
start[0] = ent->client->ps.origin[0];
76367627
start[1] = ent->client->ps.origin[1];
76377628
start[2] = ent->client->ps.origin[2] + ent->client->ps.viewheight;
76387629

7639-
G_PlayEffectID(G_EffectIndex("env/beam"), start, ent->client->ps.viewangles);
7640-
tEnt = AimAnyTarget(ent, 8192);
7641-
}
7642-
if (!tEnt || !tEnt->inuse) {
7643-
trap->SendServerCommand(ent - g_entities, "print \"^3Entity not found.\n\"");
7644-
return;
7645-
}
7630+
fPos[0] = start[0] + fPos[0] * 8192;
7631+
fPos[1] = start[1] + fPos[1] * 8192;
7632+
fPos[2] = start[2] + fPos[2] * 8192;
76467633

7647-
Q_strncpyz(buf, va("^5Entity ^3%i ^5info:\n", tEnt->s.number), sizeof(buf));
7648-
Q_strcat(buf, sizeof(buf), va(" ^5Classname^3: ^2%s\n", tEnt->classname));
7649-
if (tEnt->targetname && tEnt->targetname[0])
7650-
Q_strcat(buf, sizeof(buf), va(" ^5Targetname^3: ^2%s\n", tEnt->targetname));
7651-
if (tEnt->target && tEnt->target[0]) {
7652-
Q_strcat(buf, sizeof(buf), va(" ^5Target^3: ^2%s\n", tEnt->target));
7653-
}
7654-
Q_strcat(buf, sizeof(buf), va(" ^5Spawnflags^3: ^2%i\n", tEnt->spawnflags));
7655-
Q_strcat(buf, sizeof(buf), va(" ^5Constant origin^3: (^2%.00f %.00f %.00f^3)\n", tEnt->s.origin[0], tEnt->s.origin[1], tEnt->s.origin[2]));
7656-
Q_strcat(buf, sizeof(buf), va(" ^5Constant angles^3: (^2%.00f %.00f %.00f^3)\n", tEnt->s.angles[0], tEnt->s.angles[1], tEnt->s.angles[2]));
7657-
if (tEnt->model) {
7658-
Q_strcat(buf, sizeof(buf), va(" ^5Model^3: ^2%s\n", tEnt->model));
7659-
}
7634+
trap->Trace(&tr, start, mins, maxs, fPos, ent->s.number, ent->clipmask, qfalse, 0, 0);
7635+
tEnt = &g_entities[tr.entityNum];
7636+
7637+
7638+
if (tr.fraction != 1 && tr.entityNum != ENTITYNUM_WORLD && tr.entityNum != ENTITYNUM_NONE && tEnt && tEnt->inuse) {
7639+
Q_strncpyz(buf, va("^5Entity ^3%i ^5info:\n", tEnt->s.number), sizeof(buf));
7640+
Q_strcat(buf, sizeof(buf), va(" ^5Classname^3: ^2%s\n", tEnt->classname));
7641+
if (tEnt->targetname && tEnt->targetname[0])
7642+
Q_strcat(buf, sizeof(buf), va(" ^5Targetname^3: ^2%s\n", tEnt->targetname));
7643+
if (tEnt->target && tEnt->target[0]) {
7644+
Q_strcat(buf, sizeof(buf), va(" ^5Target^3: ^2%s\n", tEnt->target));
7645+
}
7646+
Q_strcat(buf, sizeof(buf), va(" ^5Spawnflags^3: ^2%i\n", tEnt->spawnflags));
7647+
Q_strcat(buf, sizeof(buf), va(" ^5Constant origin^3: (^2%.00f %.00f %.00f^3)\n", tEnt->s.origin[0], tEnt->s.origin[1], tEnt->s.origin[2]));
7648+
Q_strcat(buf, sizeof(buf), va(" ^5Constant angles^3: (^2%.00f %.00f %.00f^3)\n", tEnt->s.angles[0], tEnt->s.angles[1], tEnt->s.angles[2]));
7649+
if (tEnt->model) {
7650+
Q_strcat(buf, sizeof(buf), va(" ^5Model^3: ^2%s\n", tEnt->model));
7651+
}
76607652

7661-
trap->SendServerCommand(ent - g_entities, va("print \"%s\"", buf));
7653+
trap->SendServerCommand(ent - g_entities, va("print \"%s\"", buf));
7654+
}
7655+
else {
7656+
trap->SendServerCommand(ent - g_entities, va("print \"^3Entity not found. Endpoint: (^2%.00f %.00f %.00f^3)\n\"", tr.endpos[0], tr.endpos[1], tr.endpos[2]));
7657+
}
7658+
}
76627659
}
76637660
#endif
76647661

codemp/game/g_trigger.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,8 +1942,6 @@ void NewPush(gentity_t *trigger, gentity_t *player, trace_t *trace) {//JAPRO Tim
19421942
return;
19431943
if (player->client->ps.pm_type != PM_NORMAL && player->client->ps.pm_type != PM_FLOAT && player->client->ps.pm_type != PM_FREEZE)
19441944
return;
1945-
if (player->client->lastBounceTime > level.time - 500)
1946-
return;
19471945

19481946
if (trigger->spawnflags & 8) {//PLAYERONLY
19491947
if (player->s.eType == ET_NPC)
@@ -1954,6 +1952,25 @@ void NewPush(gentity_t *trigger, gentity_t *player, trace_t *trace) {//JAPRO Tim
19541952
return;
19551953
}
19561954

1955+
if (trigger && trigger->spawnflags & 32) { //Spawnflags 4 deadstops them if they are traveling in this direction... sad hack to let people retroactively fix maps without barriers
1956+
if (trigger->speed == 0 && pm->ps->velocity[0] > 0) {
1957+
pm->ps->velocity[0] = pm->ps->velocity[1] = 0;
1958+
}
1959+
else if (trigger->speed == 90 && pm->ps->velocity[1] > 0) {
1960+
pm->ps->velocity[0] = pm->ps->velocity[1] = 0;
1961+
}
1962+
else if (trigger->speed == 180 && pm->ps->velocity[0] < 0) {
1963+
pm->ps->velocity[0] = pm->ps->velocity[1] = 0;
1964+
}
1965+
else if (trigger->speed == 270 && pm->ps->velocity[1] < 0) {
1966+
pm->ps->velocity[0] = pm->ps->velocity[1] = 0;
1967+
}
1968+
return;
1969+
}
1970+
1971+
if (player->client->lastBounceTime > level.time - 500)
1972+
return;
1973+
19571974
(trigger->speed) ? (scale = trigger->speed) : (scale = 2.0f); //Check for bounds? scale can be negative, that means "bounce".
19581975
player->client->lastBounceTime = level.time;
19591976

0 commit comments

Comments
 (0)