X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Feffects%2Fqc%2Fcasings.qc;h=3573444a6ea004c0bd57cbc79a2be071a38494d7;hp=605d42e671a86dd7cf55b020d720fb1d83ac64ac;hb=72f571cf9621a68a0992dbad748f6b3657a27463;hpb=3220cab5a7b69ced4a641504a6a5f4eccf2d3bfc diff --git a/qcsrc/common/effects/qc/casings.qc b/qcsrc/common/effects/qc/casings.qc index 605d42e671..3573444a6e 100644 --- a/qcsrc/common/effects/qc/casings.qc +++ b/qcsrc/common/effects/qc/casings.qc @@ -1,8 +1,4 @@ -#ifdef SVQC -void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner); -#endif - -#ifdef IMPLEMENTATION +#include "casings.qh" #include @@ -14,9 +10,15 @@ void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float ran REGISTER_NET_TEMP(casings) #ifdef SVQC -void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner) + +.bool cvar_cl_casings; +REPLICATE(cvar_cl_casings, bool, "cl_casings"); + +void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner, .entity weaponentity) { - .entity weaponentity = weaponentities[0]; // TODO: parameter + 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; @@ -25,9 +27,7 @@ void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float ran WriteHeader(MSG_ALL, casings); WriteByte(MSG_ALL, casingtype); - WriteCoord(MSG_ALL, org.x); - WriteCoord(MSG_ALL, org.y); - WriteCoord(MSG_ALL, org.z); + 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); @@ -37,23 +37,23 @@ void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float ran #ifdef CSQC entityclass(Casing); -class(Casing) .float alpha; -class(Casing) .bool silent; -class(Casing) .int state; -class(Casing) .float cnt; +classfield(Casing) .float alpha; +classfield(Casing) .bool silent; +classfield(Casing) .int state; +classfield(Casing) .float cnt; void Casing_Delete(entity this) { - remove(this); + delete(this); } void Casing_Draw(entity this) { - if (this.move_flags & FL_ONGROUND) + if (IS_ONGROUND(this)) { - this.move_angles_x = 0; - this.move_angles_z = 0; - UNSET_ONGROUND(this); + this.angles_x = 0; + this.angles_z = 0; + //UNSET_ONGROUND(this); } Movetype_Physics_MatchTicrate(this, autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy); @@ -83,7 +83,7 @@ Sound SND_CASINGS_RANDOM() { return Sounds_from(SND_CASINGS1.m_id + floor(prandom() * 3)); } -void Casing_Touch(entity this) +void Casing_Touch(entity this, entity toucher) { if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) { @@ -121,17 +121,14 @@ void Casing_Damage(entity this, float thisdmg, int hittype, vector org, vector t { if (thisforce.z < 0) thisforce.z = 0; - this.move_velocity = this.move_velocity + thisforce + '0 0 100'; - this.move_flags &= ~FL_ONGROUND; + this.velocity = this.velocity + thisforce + '0 0 100'; + UNSET_ONGROUND(this); } NET_HANDLE(casings, bool isNew) { int _state = ReadByte(); - vector org; - org_x = ReadCoord(); - org_y = ReadCoord(); - org_z = ReadCoord(); + vector org = ReadVector(); vector vel = decompressShortVector(ReadShort()); vector ang; ang_x = ReadByte() * 360 / 256; @@ -151,11 +148,10 @@ NET_HANDLE(casings, bool isNew) casing.drawmask = MASK_NORMAL; casing.draw = Casing_Draw; - casing.move_origin = casing.origin; - casing.move_velocity = casing.velocity + 2 * prandomvec(); - casing.move_angles = casing.angles; - casing.move_avelocity = '0 250 0' + 100 * prandomvec(); - casing.move_movetype = MOVETYPE_BOUNCE; + if (isNew) IL_PUSH(g_drawables, casing); + casing.velocity = casing.velocity + 2 * prandomvec(); + casing.avelocity = '0 250 0' + 100 * prandomvec(); + set_movetype(casing, MOVETYPE_BOUNCE); settouch(casing, Casing_Touch); casing.move_time = time; casing.event_damage = Casing_Damage; @@ -179,4 +175,3 @@ NET_HANDLE(casings, bool isNew) } #endif -#endif