X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmapobjects%2Ftrigger%2Fjumppads.qc;h=3b9276d6e74683cb3e4a165a2d338928656c6fcc;hp=5ffdf2d1066085d9bd47fd1dd5d541af179b4671;hb=5ea8bccb50ca76ead04bde011b2f64bb6afa7286;hpb=60b0e81cdaed847a7aac9d234f219937ab9462b2 diff --git a/qcsrc/common/mapobjects/trigger/jumppads.qc b/qcsrc/common/mapobjects/trigger/jumppads.qc index 5ffdf2d10..3b9276d6e 100644 --- a/qcsrc/common/mapobjects/trigger/jumppads.qc +++ b/qcsrc/common/mapobjects/trigger/jumppads.qc @@ -2,6 +2,7 @@ // TODO: split target_push and put it in the target folder #ifdef SVQC #include +#include void trigger_push_use(entity this, entity actor, entity trigger) { @@ -36,8 +37,8 @@ vector trigger_push_calculatevelocity(vector org, entity tgt, float ht, entity p torg = tgt.origin + (tgt.mins + tgt.maxs) * 0.5; grav = PHYS_GRAVITY(NULL); - if(pushed_entity && PHYS_ENTGRAVITY(pushed_entity)) - grav *= PHYS_ENTGRAVITY(pushed_entity); + if(pushed_entity && pushed_entity.gravity) + grav *= pushed_entity.gravity; zdist = torg.z - org.z; sdist = vlen(torg - org - zdist * '0 0 1'); @@ -133,9 +134,17 @@ bool jumppad_push(entity this, entity targ) if (!isPushable(targ)) return false; + vector org = targ.origin; + + if(STAT(Q3COMPAT)) + { + org.z += targ.mins_z; + org.z += 1; // off by 1! + } + if(this.enemy) { - targ.velocity = trigger_push_calculatevelocity(targ.origin, this.enemy, this.height, targ); + targ.velocity = trigger_push_calculatevelocity(org, this.enemy, this.height, targ); } else if(this.target && this.target != "") { @@ -148,7 +157,7 @@ bool jumppad_push(entity this, entity targ) else RandomSelection_AddEnt(e, 1, 1); } - targ.velocity = trigger_push_calculatevelocity(targ.origin, RandomSelection_chosen_ent, this.height, targ); + targ.velocity = trigger_push_calculatevelocity(org, RandomSelection_chosen_ent, this.height, targ); } else { @@ -328,13 +337,57 @@ bool trigger_push_testorigin_for_item(entity tracetest_ent, entity item, vector } #endif +#ifdef SVQC +vector trigger_push_get_start_point(entity this) +{ + // 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 - 7; + return org; +} + +float trigger_push_get_push_time(entity this, vector endpos) +{ + vector org = trigger_push_get_start_point(this); + + float grav = PHYS_GRAVITY(NULL); + + entity t = this.enemy; + if (t) + { + entity e = spawn(); + setsize(e, PL_MIN_CONST, PL_MAX_CONST); + e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP; + vector v = trigger_push_calculatevelocity(org, t, this.height, e); + vector v2 = trigger_push_calculatevelocity(endpos, t, this.height, e); + delete(e); + return (v.z + v2.z) / grav; + } + else if (!(this.target && this.target != "")) + { + if (!this.team) + { + vector v = this.movedir; + + float t = v.z / grav; + float jump_height = 1/2 * grav * (t ** 2); + float remaining_height = org.z + jump_height - endpos.z; + float v2_z = sqrt(2 * grav * remaining_height); + + return (v.z + v2_z) / grav; + } + } + return 0; +} +#endif + /// if (item != NULL) returns true if the item can be reached by using this jumppad, false otherwise /// if (item == NULL) tests jumppad's trajectory and eventually spawns waypoints for it (return value doesn't matter) 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 - 7; +#ifdef SVQC + vector org = trigger_push_get_start_point(this); +#endif if (this.target) { @@ -349,6 +402,10 @@ bool trigger_push_test(entity this, entity item) if(t.move_movetype != MOVETYPE_NONE) continue; + // bots can't tell teamed jumppads from normal ones + if (this.team) + continue; + entity e = spawn(); setsize(e, PL_MIN_CONST, PL_MAX_CONST); e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP; @@ -455,32 +512,41 @@ bool trigger_push_test(entity this, entity item) else if(n == 1) { // exactly one dest - bots love that - this.enemy = find(NULL, targetname, this.target); + if (!this.team) + this.enemy = find(NULL, targetname, this.target); + else // bots can't tell teamed jumppads from normal ones + this.enemy = NULL; } else { // have to use random selection every single time this.enemy = NULL; } + } #ifdef SVQC else { - entity e = spawn(); - setsize(e, PL_MIN_CONST, PL_MAX_CONST); - e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP; - setorigin(e, org); - e.velocity = this.movedir; - tracetoss(e, e); - if (item) + if (!this.team) { - bool r = (trace_ent == item); + entity e = spawn(); + setsize(e, PL_MIN_CONST, PL_MAX_CONST); + e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP; + setorigin(e, org); + e.velocity = this.movedir; + tracetoss(e, e); + if (item) + { + bool r = (trace_ent == item); + delete(e); + return r; + } + if (!(boxesoverlap(this.absmin, this.absmax + eZ * 50, trace_endpos + PL_MIN_CONST, trace_endpos + PL_MAX_CONST))) + waypoint_spawnforteleporter(this, trace_endpos, vlen(trace_endpos - org) / vlen(e.velocity), e); delete(e); - return r; } - if (!(boxesoverlap(this.absmin, this.absmax + eZ * 50, trace_endpos + PL_MIN_CONST, trace_endpos + PL_MAX_CONST))) - waypoint_spawnforteleporter(this, trace_endpos, vlen(trace_endpos - org) / vlen(e.velocity), e); - delete(e); + else if (item) + return false; } defer(this, 0.1, trigger_push_updatelink); @@ -503,8 +569,6 @@ float trigger_push_send(entity this, entity to, float sf) WriteByte(MSG_ENTITY, this.active); WriteCoord(MSG_ENTITY, this.height); - WriteVector(MSG_ENTITY, this.movedir); - trigger_common_write(this, true); return true; @@ -568,9 +632,7 @@ bool target_push_send(entity this, entity to, float sf) WriteString(MSG_ENTITY, this.targetname); WriteVector(MSG_ENTITY, this.origin); - WriteAngle(MSG_ENTITY, this.angles_x); - WriteAngle(MSG_ENTITY, this.angles_y); - WriteAngle(MSG_ENTITY, this.angles_z); + WriteAngleVector(MSG_ENTITY, this.angles); return true; } @@ -636,8 +698,6 @@ NET_HANDLE(ENT_CLIENT_TRIGGER_PUSH, bool isnew) this.active = ReadByte(); this.height = ReadCoord(); - this.movedir = ReadVector(); - trigger_common_read(this, true); this.entremove = trigger_remove_generic; @@ -662,9 +722,7 @@ NET_HANDLE(ENT_CLIENT_TARGET_PUSH, bool isnew) this.targetname = strzone(ReadString()); this.origin = ReadVector(); - this.angles_x = ReadAngle(); - this.angles_y = ReadAngle(); - this.angles_z = ReadAngle(); + this.angles = ReadAngleVector(); return = true;