X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fweapons%2Fcommon.qc;h=130609af34dcd7511029e5bed4ddb70587617e00;hb=3cbcea63497633f206816900e4f7e32b833751f0;hp=6d163755067def2224a973db9bc311f1dcb60770;hpb=8f08a117d2eada0c38cb1d07a0798daf192dd666;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/weapons/common.qc b/qcsrc/server/weapons/common.qc index 6d1637550..130609af3 100644 --- a/qcsrc/server/weapons/common.qc +++ b/qcsrc/server/weapons/common.qc @@ -1,35 +1,57 @@ #include "common.qh" -#include #include -#include #include +#include +#include #include +#include +#include #include #include -#include +#include +#include +#include +#include +#include +#include + +bool W_DualWielding(entity player) +{ + int held_weapons = 0; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(player.(weaponentity) && player.(weaponentity).m_switchweapon != WEP_Null) + ++held_weapons; + } + + return held_weapons > 1; +} void W_GiveWeapon(entity e, int wep) { if (!wep) return; - e.weapons |= WepSet_FromWeapon(Weapons_from(wep)); + STAT(WEAPONS, e) |= WepSet_FromWeapon(REGISTRY_GET(Weapons, wep)); if (IS_PLAYER(e)) { Send_Notification(NOTIF_ONE, e, MSG_MULTI, ITEM_WEAPON_GOT, wep); } } -void W_PlayStrengthSound(entity player) // void W_PlayStrengthSound +void W_PlayStrengthSound(entity player) { + entity store = IS_PLAYER(player) ? PS(player) : player; // because non-player entities can fire, but can they have items? TODO + if((player.items & ITEM_Strength.m_itemid) - && ((time > player.prevstrengthsound + autocvar_sv_strengthsound_antispam_time) // prevent insane sound spam - || (time > player.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold))) + && ((time > store.prevstrengthsound + autocvar_sv_strengthsound_antispam_time) // prevent insane sound spam + || (time > store.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold))) { sound(player, CH_TRIGGER, SND_STRENGTH_FIRE, VOL_BASE, ATTEN_NORM); - player.prevstrengthsound = time; + store.prevstrengthsound = time; } - player.prevstrengthsoundattempt = time; + store.prevstrengthsoundattempt = time; } float W_CheckProjectileDamage(entity inflictor, entity projowner, int deathtype, float exception) @@ -79,16 +101,76 @@ void W_PrepareExplosionByDamage(entity this, entity attacker, void(entity this) this.takedamage = DAMAGE_NO; this.event_damage = func_null; + MUTATOR_CALLHOOK(PrepareExplosionByDamage, this, attacker); + if(IS_CLIENT(attacker) && !autocvar_g_projectiles_keep_owner) { this.owner = attacker; this.realowner = attacker; } - MUTATOR_CALLHOOK(PrepareExplosionByDamage, this, attacker); - // do not explode NOW but in the NEXT FRAME! // because recursive calls to RadiusDamage are not allowed this.nextthink = time; setthink(this, explode); } + +void adaptor_think2use_hittype_splash(entity this) // for timed projectile detonation +{ + if(!(IS_ONGROUND(this))) // if onground, we ARE touching something, but HITTYPE_SPLASH is to be networked if the damage causing projectile is not touching ANYTHING + this.projectiledeathtype |= HITTYPE_SPLASH; + adaptor_think2use(this); +} + +bool SUB_NoImpactCheck(entity this, entity toucher) +{ + // zero hitcontents = this is not the real impact, but either the + // mirror-impact of something hitting the projectile instead of the + // projectile hitting the something, or a touchareagrid one. Neither of + // these stop the projectile from moving, so... + if(trace_dphitcontents == 0) + { + LOG_TRACEF("A hit from a projectile happened with no hit contents! DEBUG THIS, this should never happen for projectiles! Projectile will self-destruct. (edict: %i, classname: %s, origin: %v)", this, this.classname, this.origin); + checkclient(this); // TODO: .health is checked in the engine with this, possibly replace with a QC function? + } + if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) + return true; + if (toucher == NULL && this.size != '0 0 0') + { + vector tic; + tic = this.velocity * sys_frametime; + tic = tic + normalize(tic) * vlen(this.maxs - this.mins); + traceline(this.origin - tic, this.origin + tic, MOVE_NORMAL, this); + if (trace_fraction >= 1) + { + LOG_TRACE("Odd... did not hit...?"); + } + else if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) + { + LOG_TRACE("Detected and prevented the sky-grapple bug."); + return true; + } + } + + return false; +} + +bool WarpZone_Projectile_Touch_ImpactFilter_Callback(entity this, entity toucher) +{ + // owner check + if(toucher && toucher == this.owner) + return true; + if(SUB_NoImpactCheck(this, toucher)) + { + if(this.classname == "nade") + return false; // no checks here + else if(this.classname == "grapplinghook") + RemoveHook(this); + else + delete(this); + return true; + } + if(trace_ent && trace_ent.solid > SOLID_TRIGGER) + UpdateCSQCProjectile(this); + return false; +}