X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmutators%2Fmutator%2Fnades%2Fnades.qc;h=413dd99f59c1ee0fde9706d9a4900c3954a5496f;hb=d492869ab1f18e05121529b7bcffcb637d13994c;hp=0d804a91427374c74219435695f929a56e84a25f;hpb=9f5143f10e9edfe86851589a1c4b8db0cdd4bdb4;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 0d804a914..413dd99f5 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -153,12 +153,14 @@ void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expan REGISTER_MUTATOR(nades, cvar("g_nades")); .float nade_time_primed; +.float nade_lifetime; .entity nade_spawnloc; + void nade_timer_think(entity this) { - this.skin = 8 - (this.owner.wait - time) / (autocvar_g_nades_nade_lifetime / 10); + this.skin = 8 - (this.owner.wait - time) / (this.owner.nade_lifetime / 10); this.nextthink = time; if(!this.owner || wasfreed(this.owner)) delete(this); @@ -736,7 +738,7 @@ void nade_boom(entity this) IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this, { - RemoveGrapplingHook(it.realowner); + RemoveHook(it); }); delete(this); @@ -767,7 +769,6 @@ void nade_touch(entity this, entity toucher) if(autocvar_g_nades_pickup) if(time >= this.spawnshieldtime) if(!toucher.nade && this.health == this.max_health) // no boosted shot pickups, thank you very much - if(!STAT(FROZEN, toucher)) if(CanThrowNade(toucher)) // prevent some obvious things, like dead players if(IS_REAL_CLIENT(toucher)) // above checks for IS_PLAYER, don't need to do it here { @@ -785,7 +786,7 @@ void nade_touch(entity this, entity toucher) { IL_EACH(g_projectiles, it.classname == "grapplinghook" && it.aiment == this, { - RemoveGrapplingHook(it.realowner); + RemoveHook(it); }); delete(this); return; @@ -862,7 +863,7 @@ void nade_damage(entity this, entity inflictor, entity attacker, float damage, i if(this.health == this.max_health) { sound(this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, 0.5 *(ATTEN_LARGE + ATTEN_MAX)); - this.nextthink = max(time + autocvar_g_nades_nade_lifetime, time); + this.nextthink = max(time + this.nade_lifetime, time); setthink(this, nade_beep); } @@ -891,7 +892,7 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time) makevectors(e.v_angle); // NOTE: always throw from first weapon entity? - W_SetupShot(e, weaponentities[0], false, false, SND_Null, CH_WEAPON_A, 0); + W_SetupShot(e, _nade.weaponentity_fld, false, false, SND_Null, CH_WEAPON_A, 0); Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES); @@ -1034,6 +1035,8 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin if(Nades_from(n.nade_type) == NADE_TYPE_Null) n.nade_type = NADE_TYPE_NORMAL.m_id; + .entity weaponentity = weaponentities[0]; // TODO: unhardcode + setmodel(n, MDL_PROJECTILE_NADE); //setattachment(n, player, "bip01 l hand"); n.exteriormodeltoclient = player; @@ -1048,9 +1051,10 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin setthink(n, nade_beep); n.nextthink = max(n.wait - 3, time); n.projectiledeathtype = DEATH_NADE.m_id; + n.weaponentity_fld = weaponentity; + n.nade_lifetime = ntime; setmodel(fn, MDL_NADE_VIEW); - .entity weaponentity = weaponentities[0]; // TODO: unhardcode setattachment(fn, player.(weaponentity), ""); fn.realowner = fn.owner = player; fn.colormod = Nades_from(n.nade_type).m_color; @@ -1058,6 +1062,7 @@ void spawn_held_nade(entity player, entity nowner, float ntime, int ntype, strin fn.glowmod = player.glowmod; setthink(fn, SUB_Remove); fn.nextthink = n.wait; + fn.weaponentity_fld = weaponentity; player.nade = n; player.fake_nade = fn; @@ -1100,9 +1105,6 @@ bool CanThrowNade(entity this) if(this.vehicle) return false; - if(gameover) - return false; - if(IS_DEAD(this)) return false; @@ -1174,18 +1176,6 @@ CLASS(NadeOffhand, OffhandWeapon) METHOD(NadeOffhand, offhand_think, void(NadeOffhand this, entity player, bool key_pressed)) { entity held_nade = player.nade; - if (held_nade) - { - player.nade_timer = bound(0, (time - held_nade.nade_time_primed) / autocvar_g_nades_nade_lifetime, 1); - // LOG_TRACEF("%d %d", player.nade_timer, time - held_nade.nade_time_primed); - makevectors(player.angles); - held_nade.velocity = player.velocity; - setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0); - held_nade.angles_y = player.angles.y; - - if (time + 0.1 >= held_nade.wait) - toss_nade(player, false, '0 0 0', time + 0.05); - } if (!CanThrowNade(player)) return; if (!(time > player.nade_refire)) return; @@ -1227,6 +1217,20 @@ MUTATOR_HOOKFUNCTION(nades, PlayerPreThink) if (player.nade && (player.offhand != OFFHAND_NADE || (player.weapons & WEPSET(HOOK)))) OFFHAND_NADE.offhand_think(OFFHAND_NADE, player, player.nade_altbutton); + entity held_nade = player.nade; + if (held_nade) + { + player.nade_timer = bound(0, (time - held_nade.nade_time_primed) / held_nade.nade_lifetime, 1); + // LOG_TRACEF("%d %d", player.nade_timer, time - held_nade.nade_time_primed); + makevectors(player.angles); + held_nade.velocity = player.velocity; + setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0); + held_nade.angles_y = player.angles.y; + + if (time + 0.1 >= held_nade.wait) + toss_nade(player, false, '0 0 0', time + 0.05); + } + if(IS_PLAYER(player)) { if ( autocvar_g_nades_bonus && autocvar_g_nades ) @@ -1395,7 +1399,7 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST) nades_RemoveBonus(frag_target); } -MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate) +MUTATOR_HOOKFUNCTION(nades, Damage_Calculate) { entity frag_inflictor = M_ARGV(0, entity); entity frag_attacker = M_ARGV(1, entity);