X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Ft_jumppads.qc;h=5a5042b3d48a63dc1a273feff50b33e767a7de8f;hb=7170086b517c814aa5ea60985993900492c8770a;hp=18dbef1711424dd28e5864c58fc0adc0d30d2112;hpb=68eb8d499b3e9b32c46ea77cd2f284af61a690c1;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/t_jumppads.qc b/qcsrc/server/t_jumppads.qc index 18dbef171..5a5042b3d 100644 --- a/qcsrc/server/t_jumppads.qc +++ b/qcsrc/server/t_jumppads.qc @@ -2,6 +2,7 @@ float PUSH_ONCE = 1; float PUSH_SILENT = 2; .float pushltime; +.float istypefrag; .float height; void() SUB_UseTargets; @@ -30,8 +31,8 @@ void trigger_push_use() vector trigger_push_calculatevelocity(vector org, entity tgt, float ht) { - local float grav, sdist, zdist, vs, vz, jumpheight; - local vector sdir, torg; + float grav, sdist, zdist, vs, vz, jumpheight; + vector sdir, torg; torg = tgt.origin + (tgt.mins + tgt.maxs) * 0.5; @@ -139,13 +140,30 @@ void trigger_push_touch() EXACTTRIGGER_TOUCH; - if(self.target) - self.movedir = trigger_push_calculatevelocity(other.origin, self.enemy, self.height); + if(self.enemy) + { + other.velocity = trigger_push_calculatevelocity(other.origin, self.enemy, self.height); + } + else if(self.target) + { + entity e; + RandomSelection_Init(); + for(e = world; (e = find(e, targetname, self.target)); ) + { + if(e.cnt) + RandomSelection_Add(e, 0, string_null, e.cnt, 1); + else + RandomSelection_Add(e, 0, string_null, 1, 1); + } + other.velocity = trigger_push_calculatevelocity(other.origin, RandomSelection_chosen_ent, self.height); + } + else + { + other.velocity = self.movedir; + } other.flags &~= FL_ONGROUND; - other.velocity = self.movedir; - if (other.classname == "player") { // reset tracking of oldvelocity for impact damage (sudden velocity changes) @@ -158,12 +176,12 @@ void trigger_push_touch() sound (other, CH_TRIGGER, self.noise, VOL_BASE, ATTN_NORM); self.pushltime = time + 0.2; } - local float ct; + float ct; ct = clienttype(other); if( ct == CLIENTTYPE_REAL || ct == CLIENTTYPE_BOT) { - local float i; - local float found; + float i; + float found; found = FALSE; for(i = 0; i < other.jumppadcount && i < NUM_JUMPPADSUSED; ++i) if(other.(jumppadsused[i]) == self) @@ -181,12 +199,16 @@ void trigger_push_touch() } else other.lastteleporttime = time; + + if (other.deadflag == DEAD_NO) + animdecide_setaction(other, ANIMACTION_JUMP, TRUE); } else other.jumppadcount = TRUE; // reset tracking of who pushed you into a hazard (for kill credit) other.pushltime = 0; + other.istypefrag = 0; } if(self.enemy.target) @@ -218,18 +240,17 @@ void trigger_push_touch() if (self.spawnflags & PUSH_ONCE) { - self.touch = SUB_Null; + self.touch = func_null; self.think = SUB_Remove; self.nextthink = time; } -}; +} .vector dest; void trigger_push_findtarget() { - local entity e; - local vector org; - local float flighttime; + entity e, t; + vector org; // first calculate a typical start point for the jump org = (self.absmin + self.absmax) * 0.5; @@ -237,32 +258,49 @@ void trigger_push_findtarget() if (self.target) { - // find the target - self.enemy = find(world, targetname, self.target); - if (!self.enemy) + float n; + n = 0; + for(t = world; (t = find(t, targetname, self.target)); ) { - objerror("trigger_push: target not found\n"); - remove(self); - return; + ++n; + e = spawn(); + setorigin(e, org); + setsize(e, PL_MIN, PL_MAX); + e.velocity = trigger_push_calculatevelocity(org, t, self.height); + tracetoss(e, e); + if(e.movetype == MOVETYPE_NONE) + waypoint_spawnforteleporter(self, trace_endpos, vlen(trace_endpos - org) / vlen(e.velocity)); + remove(e); } - self.movedir = trigger_push_calculatevelocity(org, self.enemy, self.height); - flighttime = trigger_push_calculatevelocity_flighttime; + if(n == 0) + { + // no dest! + objerror ("Jumppad with nonexistant target"); + return; + } + else if(n == 1) + { + // exactly one dest - bots love that + self.enemy = find(world, targetname, self.target); + } + else + { + // have to use random selection every single time + self.enemy = world; + } } else - flighttime = 0; - - // calculate the destination and spawn a teleporter spawnfunc_waypoint - e = spawn(); - setorigin(e, org); - setsize(e, PL_MIN, PL_MAX); - e.velocity = self.movedir; - tracetoss(e, e); - self.dest = trace_endpos; - remove(e); - - waypoint_spawnforteleporter(self, self.dest, flighttime); -}; + { + e = spawn(); + setorigin(e, org); + setsize(e, PL_MIN, PL_MAX); + e.velocity = self.movedir; + tracetoss(e, e); + waypoint_spawnforteleporter(self, trace_endpos, vlen(trace_endpos - org) / vlen(e.velocity)); + remove(e); + } +} /* * ENTITY PARAMETERS: @@ -297,8 +335,8 @@ void spawnfunc_trigger_push() // this must be called to spawn the teleport waypoints for bots InitializeEntity(self, trigger_push_findtarget, INITPRIO_FINDTARGET); -}; +} -void spawnfunc_target_push() {}; -void spawnfunc_info_notnull() {}; -void spawnfunc_target_position() {}; +void spawnfunc_target_push() {} +void spawnfunc_info_notnull() {} +void spawnfunc_target_position() {}