From: Mario Date: Mon, 15 Feb 2016 05:49:18 +0000 (+1000) Subject: Give picked up nades a set timer, also fix some issues with nade pickups X-Git-Tag: xonotic-v0.8.2~1188 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7c14931b8d769a1c43556272adfd72138a0e70a9;p=xonotic%2Fxonotic-data.pk3dir.git Give picked up nades a set timer, also fix some issues with nade pickups --- diff --git a/mutators.cfg b/mutators.cfg index 6ff74a61b..894caec14 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -183,6 +183,7 @@ set g_nades_throw_offset "0 0 0" "nade throwing offset" set g_nades_spawn 1 "give nades right away when player spawns rather than delaying entire refire" set g_nades_client_select 0 "allow client side selection of nade type" set g_nades_pickup 1 "allow picking up thrown nades (not your own)" +set g_nades_pickup_time 2 "time until picked up nade explodes" set g_nades_nade_lifetime 3.5 set g_nades_nade_minforce 400 set g_nades_nade_maxforce 2000 diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 5520af740..271ccb90f 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -674,7 +674,7 @@ void nade_boom() void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, string pntype); void nade_pickup(entity this, entity thenade) { - spawn_held_nade(this, thenade.realowner, thenade.wait - time, thenade.nade_type, thenade.pokenade_type); + spawn_held_nade(this, thenade.realowner, autocvar_g_nades_pickup_time, thenade.nade_type, thenade.pokenade_type); // set refire so player can't even this.nade_refire = time + autocvar_g_nades_nade_refire; @@ -693,7 +693,8 @@ void nade_touch() return; // no self impacts if(autocvar_g_nades_pickup) - if(!other.nade) + if(time >= self.spawnshieldtime) + if(!other.nade && self.health == self.max_health) // no boosted shot pickups, thank you very much if(IS_REAL_CLIENT(other) && IS_PLAYER(other)) { nade_pickup(other, self); @@ -803,7 +804,7 @@ void nade_damage(entity this, entity inflictor, entity attacker, float damage, i nade_burn_spawn(this); } -void toss_nade(entity e, vector _velocity, float _time) +void toss_nade(entity e, bool set_owner, vector _velocity, float _time) {SELFPARAM(); if(e.nade == world) return; @@ -849,7 +850,11 @@ void toss_nade(entity e, vector _velocity, float _time) else _nade.velocity = W_CalculateProjectileVelocity(e.velocity, _velocity, true); + if(set_owner) + _nade.realowner = e; + _nade.touch = nade_touch; + _nade.spawnshieldtime = time + 0.1; // prevent instantly picking up again _nade.health = autocvar_g_nades_nade_health; _nade.max_health = _nade.health; _nade.takedamage = DAMAGE_AIM; @@ -857,7 +862,6 @@ void toss_nade(entity e, vector _velocity, float _time) _nade.customizeentityforclient = func_null; _nade.exteriormodeltoclient = world; _nade.traileffectnum = 0; - _nade.realowner = e; _nade.teleportable = true; _nade.pushable = true; _nade.gravity = 1; @@ -922,7 +926,7 @@ MUTATOR_HOOKFUNCTION(nades, PutClientInServer) float nade_customize() {SELFPARAM(); //if(IS_SPEC(other)) { return false; } - if(other == self.realowner || (IS_SPEC(other) && other.enemy == self.realowner)) + if(other == self.exteriormodeltoclient || (IS_SPEC(other) && other.enemy == self.exteriormodeltoclient)) { // somewhat hide the model, but keep the glow //self.effects = 0; @@ -1058,7 +1062,7 @@ void nades_CheckThrow() float _force = time - held_nade.nade_time_primed; _force /= autocvar_g_nades_nade_lifetime; _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce)); - toss_nade(self, (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05) * _force, 0); + toss_nade(self, true, (v_forward * 0.75 + v_up * 0.2 + v_right * 0.05) * _force, 0); } } } @@ -1077,7 +1081,7 @@ void nades_Clear(entity player) MUTATOR_HOOKFUNCTION(nades, VehicleEnter) { if(vh_player.nade) - toss_nade(vh_player, '0 0 100', max(vh_player.nade.wait, time + 0.05)); + toss_nade(vh_player, true, '0 0 100', max(vh_player.nade.wait, time + 0.05)); return false; } @@ -1096,7 +1100,7 @@ CLASS(NadeOffhand, OffhandWeapon) held_nade.angles_y = player.angles.y; if (time + 0.1 >= held_nade.wait) - toss_nade(player, '0 0 0', time + 0.05); + toss_nade(player, false, '0 0 0', time + 0.05); } if (!CanThrowNade()) return; @@ -1112,7 +1116,7 @@ CLASS(NadeOffhand, OffhandWeapon) float _force = time - held_nade.nade_time_primed; _force /= autocvar_g_nades_nade_lifetime; _force = autocvar_g_nades_nade_minforce + (_force * (autocvar_g_nades_nade_maxforce - autocvar_g_nades_nade_minforce)); - toss_nade(player, (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1) * _force, 0); + toss_nade(player, false, (v_forward * 0.7 + v_up * 0.2 + v_right * 0.1) * _force, 0); } } } @@ -1251,7 +1255,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST) { if(frag_target.nade) if(!STAT(FROZEN, frag_target) || !autocvar_g_freezetag_revive_nade) - toss_nade(frag_target, '0 0 100', max(frag_target.nade.wait, time + 0.05)); + toss_nade(frag_target, true, '0 0 100', max(frag_target.nade.wait, time + 0.05)); float killcount_bonus = ((frag_attacker.killcount >= 1) ? bound(0, autocvar_g_nades_bonus_score_minor * frag_attacker.killcount, autocvar_g_nades_bonus_score_medium) : autocvar_g_nades_bonus_score_minor); @@ -1314,7 +1318,7 @@ MUTATOR_HOOKFUNCTION(nades, MonsterDies) MUTATOR_HOOKFUNCTION(nades, DropSpecialItems) { if(frag_target.nade) - toss_nade(frag_target, '0 0 0', time + 0.05); + toss_nade(frag_target, true, '0 0 0', time + 0.05); return false; } diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 05d25a0b8..654bd2bc9 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -466,6 +466,7 @@ bool autocvar_g_nades_spawn; int autocvar_g_nades_spawn_count; bool autocvar_g_nades_client_select; bool autocvar_g_nades_pickup = true; +float autocvar_g_nades_pickup_time = 2; float autocvar_g_nades_nade_lifetime; float autocvar_g_nades_nade_minforce; float autocvar_g_nades_nade_maxforce;