X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Feffects%2Fqc%2Fcasings.qc;h=c0c7f5ac98d41bc95cb90948d4234f84c007f6dc;hb=af2f0cb624aaf967708b22e1303d113668af5114;hp=304552961c1a4a5ce1af56b8ee11f77de1ad7cf4;hpb=6c2de3fa93af948850424fcb30bfb0a4e878345a;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/effects/qc/casings.qc b/qcsrc/common/effects/qc/casings.qc index 304552961..c0c7f5ac9 100644 --- a/qcsrc/common/effects/qc/casings.qc +++ b/qcsrc/common/effects/qc/casings.qc @@ -1,5 +1,6 @@ #include "casings.qh" +#include #include #ifdef CSQC @@ -9,29 +10,33 @@ REGISTER_NET_TEMP(casings) -#ifdef SVQC - -.bool cvar_cl_casings; REPLICATE(cvar_cl_casings, bool, "cl_casings"); +REPLICATE(cvar_r_drawviewmodel, int, "r_drawviewmodel"); +#ifdef SVQC void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner, .entity weaponentity) { - if (!(CS(casingowner).cvar_cl_casings)) - return; - - entity wep = casingowner.(weaponentity); - vector org = casingowner.origin + casingowner.view_ofs + wep.spawnorigin.x * v_forward - wep.spawnorigin.y * v_right + wep.spawnorigin.z * v_up; - - if (!sound_allowed(MSG_BROADCAST, casingowner)) - casingtype |= 0x80; - - WriteHeader(MSG_ALL, casings); - WriteByte(MSG_ALL, casingtype); - WriteVector(MSG_ALL, org); - WriteShort(MSG_ALL, compressShortVector(vel)); // actually compressed velocity - WriteByte(MSG_ALL, ang.x * 256 / 360); - WriteByte(MSG_ALL, ang.y * 256 / 360); - WriteByte(MSG_ALL, ang.z * 256 / 360); + vector org = casingowner.(weaponentity).spawnorigin; + org = casingowner.origin + casingowner.view_ofs + org.x * v_forward - org.y * v_right + org.z * v_up; + + FOREACH_CLIENT(true, { + if (!(CS_CVAR(it).cvar_cl_casings)) + continue; + if (it == casingowner && !(CS_CVAR(it).cvar_r_drawviewmodel)) + continue; + + msg_entity = it; + if (!sound_allowed(MSG_ONE, it)) + casingtype |= 0x80; // silent + + WriteHeader(MSG_ONE, casings); + WriteByte(MSG_ONE, casingtype); + WriteVector(MSG_ONE, org); + WriteShort(MSG_ONE, compressShortVector(vel)); // actually compressed velocity + WriteByte(MSG_ONE, ang.x * 256 / 360); + WriteByte(MSG_ONE, ang.y * 256 / 360); + WriteByte(MSG_ONE, ang.z * 256 / 360); + }); } #endif @@ -56,10 +61,6 @@ void Casing_Draw(entity this) //UNSET_ONGROUND(this); } - Movetype_Physics_MatchTicrate(this, autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy); - if (wasfreed(this)) - return; // deleted by touch function - this.renderflags = 0; this.alpha = bound(0, this.cnt - time, 1); @@ -67,20 +68,25 @@ void Casing_Draw(entity this) { Casing_Delete(this); this.drawmask = 0; + return; } + + Movetype_Physics_MatchTicrate(this, autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy); + //if (wasfreed(this)) + // return; // deleted by touch function } SOUND(BRASS1, W_Sound("brass1")); SOUND(BRASS2, W_Sound("brass2")); SOUND(BRASS3, W_Sound("brass3")); Sound SND_BRASS_RANDOM() { - return Sounds_from(SND_BRASS1.m_id + floor(prandom() * 3)); + return REGISTRY_GET(Sounds, SND_BRASS1.m_id + floor(prandom() * 3)); } SOUND(CASINGS1, W_Sound("casings1")); SOUND(CASINGS2, W_Sound("casings2")); SOUND(CASINGS3, W_Sound("casings3")); Sound SND_CASINGS_RANDOM() { - return Sounds_from(SND_CASINGS1.m_id + floor(prandom() * 3)); + return REGISTRY_GET(Sounds, SND_CASINGS1.m_id + floor(prandom() * 3)); } void Casing_Touch(entity this, entity toucher) @@ -136,7 +142,7 @@ NET_HANDLE(casings, bool isNew) ang_z = ReadByte() * 360 / 256; return = true; - Casing casing = RubbleNew("casing"); + Casing casing = ListNewChildRubble(CasingsNGibs, new(casing)); casing.silent = (_state & 0x80); casing.state = (_state & 0x7F); casing.origin = org; @@ -150,6 +156,7 @@ NET_HANDLE(casings, bool isNew) casing.velocity = casing.velocity + 2 * prandomvec(); casing.avelocity = '0 250 0' + 100 * prandomvec(); set_movetype(casing, MOVETYPE_BOUNCE); + casing.bouncefactor = 0.25; settouch(casing, Casing_Touch); casing.move_time = time; casing.event_damage = Casing_Damage; @@ -169,7 +176,7 @@ NET_HANDLE(casings, bool isNew) setsize(casing, '0 0 -1', '0 0 -1'); - RubbleLimit("casing", autocvar_cl_casings_maxcount, Casing_Delete); + LimitedChildrenRubble(CasingsNGibs, "casing", autocvar_cl_casings_maxcount, Casing_Delete, NULL); } #endif