X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ftrigger%2Fjumppads.qc;h=5ffdf2d1066085d9bd47fd1dd5d541af179b4671;hp=9e40cfd40178224fc9c48efe76cece7de982253a;hb=b093c2ea2c367cb9bb4ce2c0468346080938270c;hpb=b945d959784e5b249c66aea4f3326d8ae048f1cd diff --git a/qcsrc/common/triggers/trigger/jumppads.qc b/qcsrc/common/triggers/trigger/jumppads.qc index 9e40cfd40..5ffdf2d10 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qc +++ b/qcsrc/common/triggers/trigger/jumppads.qc @@ -1,7 +1,6 @@ #include "jumppads.qh" // TODO: split target_push and put it in the target folder #ifdef SVQC -#include "jumppads.qh" #include void trigger_push_use(entity this, entity actor, entity trigger) @@ -9,7 +8,7 @@ void trigger_push_use(entity this, entity actor, entity trigger) if(teamplay) { this.team = actor.team; - this.SendFlags |= 2; + this.SendFlags |= SF_TRIGGER_UPDATE; } } #endif @@ -254,7 +253,7 @@ void trigger_push_touch(entity this, entity toucher) return; if(this.team) - if(((this.spawnflags & 4) == 0) == (DIFF_TEAM(this, toucher))) + if(((this.spawnflags & INVERT_TEAMS) == 0) == (DIFF_TEAM(this, toucher))) return; EXACTTRIGGER_TOUCH(this, toucher); @@ -309,6 +308,24 @@ bool trigger_push_testorigin(entity tracetest_ent, entity targ, entity jp, vecto tracebox(trace_endpos, tracetest_ent.mins, tracetest_ent.maxs, trace_endpos - eZ * 1500, true, tracetest_ent); return true; } + +bool trigger_push_testorigin_for_item(entity tracetest_ent, entity item, vector org) +{ + setorigin(tracetest_ent, org); + tracetoss(tracetest_ent, tracetest_ent); + + if(trace_startsolid) + return false; + if (trace_ent == item) + return true; + + tracebox(trace_endpos, tracetest_ent.mins, tracetest_ent.maxs, trace_endpos - eZ * 1500, true, tracetest_ent); + + if (trace_ent == item) + return true; + + return false; +} #endif /// if (item != NULL) returns true if the item can be reached by using this jumppad, false otherwise @@ -317,7 +334,7 @@ bool trigger_push_test(entity this, entity item) { // first calculate a typical start point for the jump vector org = (this.absmin + this.absmax) * 0.5; - org.z = this.absmax.z - PL_MIN_CONST.z - 10; + org.z = this.absmax.z - PL_MIN_CONST.z - 7; if (this.target) { @@ -337,26 +354,28 @@ bool trigger_push_test(entity this, entity item) e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP; e.velocity = trigger_push_calculatevelocity(org, t, this.height, e); - if(item) - { - setorigin(e, org); - tracetoss(e, e); - bool r = (trace_ent == item); - delete(e); - return r; - } - vel = e.velocity; vector best_target = '0 0 0'; vector best_org = '0 0 0'; vector best_vel = '0 0 0'; bool valid_best_target = false; - if (trigger_push_testorigin(e, t, this, org)) + if (item) + { + if (!trigger_push_testorigin_for_item(e, item, org)) + { + delete(e); + return false; + } + } + else { - best_target = trace_endpos; - best_org = org; - best_vel = e.velocity; - valid_best_target = true; + if (trigger_push_testorigin(e, t, this, org)) + { + best_target = trace_endpos; + best_org = org; + best_vel = e.velocity; + valid_best_target = true; + } } vector new_org; @@ -369,31 +388,43 @@ bool trigger_push_test(entity this, entity item) vector flatdir = normalize(dist - eZ * dist.z); vector ofs = flatdir * 0.5 * min(fabs(this.absmax.x - this.absmin.x), fabs(this.absmax.y - this.absmin.y)); new_org = org + ofs; + + LABEL(new_test) e.velocity = trigger_push_calculatevelocity(new_org, t, this.height, e); - vel = e.velocity; - if (vdist(vec2(e.velocity), <, autocvar_sv_maxspeed)) - e.velocity = autocvar_sv_maxspeed * flatdir; - if (trigger_push_testorigin(e, t, this, new_org) && (!valid_best_target || trace_endpos.z > best_target.z + 50)) + if (item) { - best_target = trace_endpos; - best_org = new_org; - best_vel = vel; - valid_best_target = true; + if (!trigger_push_testorigin_for_item(e, item, new_org)) + { + delete(e); + return false; + } } - new_org = org - ofs; - e.velocity = trigger_push_calculatevelocity(new_org, t, this.height, e); - vel = e.velocity; - if (vdist(vec2(e.velocity), <, autocvar_sv_maxspeed)) - e.velocity = autocvar_sv_maxspeed * flatdir; - if (trigger_push_testorigin(e, t, this, new_org) && (!valid_best_target || trace_endpos.z > best_target.z + 50)) + else { - best_target = trace_endpos; - best_org = new_org; - best_vel = vel; - valid_best_target = true; + vel = e.velocity; + if (vdist(vec2(e.velocity), <, autocvar_sv_maxspeed)) + e.velocity = autocvar_sv_maxspeed * flatdir; + if (trigger_push_testorigin(e, t, this, new_org) && (!valid_best_target || trace_endpos.z > best_target.z + 50)) + { + best_target = trace_endpos; + best_org = new_org; + best_vel = vel; + valid_best_target = true; + } + } + if (ofs && new_org != org - ofs) + { + new_org = org - ofs; + goto new_test; } } + if (item) + { + delete(e); + return true; + } + if (valid_best_target) { if (!(boxesoverlap(this.absmin, this.absmax + eZ * 50, best_target + PL_MIN_CONST, best_target + PL_MAX_CONST))) @@ -441,7 +472,7 @@ bool trigger_push_test(entity this, entity item) setorigin(e, org); e.velocity = this.movedir; tracetoss(e, e); - if(item) + if (item) { bool r = (trace_ent == item); delete(e); @@ -472,9 +503,7 @@ float trigger_push_send(entity this, entity to, float sf) WriteByte(MSG_ENTITY, this.active); WriteCoord(MSG_ENTITY, this.height); - WriteCoord(MSG_ENTITY, this.movedir_x); - WriteCoord(MSG_ENTITY, this.movedir_y); - WriteCoord(MSG_ENTITY, this.movedir_z); + WriteVector(MSG_ENTITY, this.movedir); trigger_common_write(this, true); @@ -483,7 +512,7 @@ float trigger_push_send(entity this, entity to, float sf) void trigger_push_updatelink(entity this) { - this.SendFlags |= 1; + this.SendFlags |= SF_TRIGGER_INIT; } void trigger_push_link(entity this) @@ -537,9 +566,7 @@ bool target_push_send(entity this, entity to, float sf) WriteByte(MSG_ENTITY, this.cnt); WriteString(MSG_ENTITY, this.targetname); - WriteCoord(MSG_ENTITY, this.origin_x); - WriteCoord(MSG_ENTITY, this.origin_y); - WriteCoord(MSG_ENTITY, this.origin_z); + WriteVector(MSG_ENTITY, this.origin); WriteAngle(MSG_ENTITY, this.angles_x); WriteAngle(MSG_ENTITY, this.angles_y); @@ -581,23 +608,35 @@ void target_push_init2(entity this) target_push_init(this); // normal push target behaviour can be combined with a legacy pusher? } -spawnfunc(target_push) { target_push_init2(this); } -spawnfunc(info_notnull) { target_push_init(this); } -spawnfunc(target_position) { target_push_init(this); } +spawnfunc(target_push) +{ + target_push_init2(this); +} + +spawnfunc(info_notnull) +{ + target_push_init(this); +} +spawnfunc(target_position) +{ + target_push_init(this); +} #elif defined(CSQC) NET_HANDLE(ENT_CLIENT_TRIGGER_PUSH, bool isnew) { this.classname = "jumppad"; - int mytm = ReadByte(); if(mytm) { this.team = mytm - 1; } + int mytm = ReadByte(); + if(mytm) + { + this.team = mytm - 1; + } this.spawnflags = ReadInt24_t(); this.active = ReadByte(); this.height = ReadCoord(); - this.movedir_x = ReadCoord(); - this.movedir_y = ReadCoord(); - this.movedir_z = ReadCoord(); + this.movedir = ReadVector(); trigger_common_read(this, true); @@ -612,13 +651,8 @@ NET_HANDLE(ENT_CLIENT_TRIGGER_PUSH, bool isnew) void target_push_remove(entity this) { - //if(this.classname) - //strunzone(this.classname); - //this.classname = string_null; - - if(this.targetname) - strunzone(this.targetname); - this.targetname = string_null; + // strfree(this.classname); + strfree(this.targetname); } NET_HANDLE(ENT_CLIENT_TARGET_PUSH, bool isnew) @@ -626,9 +660,7 @@ NET_HANDLE(ENT_CLIENT_TARGET_PUSH, bool isnew) this.classname = "push_target"; this.cnt = ReadByte(); this.targetname = strzone(ReadString()); - this.origin_x = ReadCoord(); - this.origin_y = ReadCoord(); - this.origin_z = ReadCoord(); + this.origin = ReadVector(); this.angles_x = ReadAngle(); this.angles_y = ReadAngle();