4 #include "movetypes.qh"
8 #include "../common/util.qh"
15 class(Casing) .bool silent;
24 if(self.move_flags & FL_ONGROUND)
26 self.move_angles_x = 0;
27 self.move_angles_z = 0;
28 self.flags &= ~FL_ONGROUND;
31 Movetype_Physics_MatchTicrate(autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy);
33 return; // deleted by touch function
36 self.alpha = bound(0, self.cnt - time, 1);
38 if(self.alpha < ALPHA_MIN_VISIBLE)
47 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
54 if(!trace_ent || trace_ent.solid == SOLID_BSP)
56 if(vlen(self.velocity) > 50)
58 if(time >= self.nextthink)
61 int f = floor(prandom() * 3) + 1;
66 s = strcat("weapons/casings", itos(f), ".wav");
69 s = strcat("weapons/brass", itos(f), ".wav");
73 sound (self, CH_SHOTS, s, VOL_BASE, ATTEN_LARGE);
78 self.nextthink = time + 0.2;
81 void Casing_Damage(float thisdmg, int hittype, vector org, vector thisforce)
85 self.move_velocity = self.move_velocity + thisforce + '0 0 100';
86 self.move_flags &= ~FL_ONGROUND;
89 void Ent_Casing(float isNew)
93 casing = RubbleNew("casing");
94 casing.state = ReadByte();
95 casing.silent = (casing.state & 0x80);
96 casing.state = (casing.state & 0x7F);
97 casing.origin_x = ReadCoord();
98 casing.origin_y = ReadCoord();
99 casing.origin_z = ReadCoord();
100 setorigin(casing, casing.origin);
101 casing.velocity = decompressShortVector(ReadShort());
102 casing.angles_x = ReadByte() * 360 / 256;
103 casing.angles_y = ReadByte() * 360 / 256;
104 casing.angles_z = ReadByte() * 360 / 256;
105 casing.drawmask = MASK_NORMAL;
107 if(autocvar_cl_casings && isNew) {
108 casing.draw = Casing_Draw;
109 casing.move_origin = casing.origin;
110 casing.move_velocity = casing.velocity + 2 * prandomvec();
111 casing.move_angles = casing.angles;
112 casing.move_avelocity = '0 250 0' + 100 * prandomvec();
113 casing.move_movetype = MOVETYPE_BOUNCE;
114 casing.move_touch = Casing_Touch;
115 casing.move_time = time;
116 casing.event_damage = Casing_Damage;
117 casing.solid = SOLID_TRIGGER;
122 setmodel(casing, "models/casing_shell.mdl");
123 casing.cnt = time + autocvar_cl_casings_shell_time;
126 setmodel(casing, "models/casing_bronze.iqm");
127 casing.cnt = time + autocvar_cl_casings_bronze_time;
131 setsize(casing, '0 0 -1', '0 0 -1');
133 RubbleLimit("casing", autocvar_cl_casings_maxcount, Casing_Delete);
137 entity oldself = self;
139 Casing_Delete(); // yes, this IS stupid, but I don't need to duplicate all the read* stuff then
144 void Casings_Precache()
146 precache_model("models/casing_shell.mdl");
147 precache_model("models/casing_bronze.iqm");
148 precache_sound("weapons/brass1.wav");
149 precache_sound("weapons/brass2.wav");
150 precache_sound("weapons/brass3.wav");
151 precache_sound("weapons/casings1.wav");
152 precache_sound("weapons/casings2.wav");
153 precache_sound("weapons/casings3.wav");