6 if (other.solid == SOLID_BSP)
7 if (vlen(self.velocity) >= 50)
8 if (time >= self.attack_finished_single)
13 f = floor(random() * 3) + 1;
15 s = strcat("weapons/casings", ftos(f), ".wav");
16 else if(self.state == 2)
17 s = strcat("weapons/steel", ftos(f), ".wav");
19 s = strcat("weapons/brass", ftos(f), ".wav");
20 sound (self, CHAN_PROJECTILE, s, VOL_BASE, ATTN_NORM);
22 self.attack_finished_single = time + 0.2;
23 //self.touch = SUB_Null; // one tink is enough
24 //self.dest = self.origin - self.groundentity.origin;
30 self.nextthink = time + 0.1;
31 if (self.flags & FL_ONGROUND)
33 // just keep the yaw angle
36 self.flags = self.flags - FL_ONGROUND;
37 self.nextthink = time + 0.5;
39 p = pointcontents(self.origin);
40 if (p == CONTENT_SOLID || p == CONTENT_LAVA || p == CONTENT_SKY)
47 self.nextthink = time;
48 self.alpha = self.alpha - frametime;
49 if (self.alpha < 0.0625)
54 // knock loose the casing when disturbed
55 void casingknockedloosefunc()
57 self.movetype = MOVETYPE_BOUNCE;
58 self.flags = self.flags - (self.flags & FL_ONGROUND);
59 self.avelocity = randomvec() * 300;
60 self.nextthink = time + 0.1;
61 self.touch = casingtouch;
64 void SpawnCasing(vector org, vector vel, float randomvel, vector ang, vector avel, float randomavel, float casingtype)
67 if (cvar("temp1") & 2048)
75 e.movetype = MOVETYPE_BOUNCE;
76 e.solid = SOLID_TRIGGER;
77 e.velocity = vel + randomvec() * randomvel;
79 e.avelocity = avel + randomvec() * randomavel;
81 e.think = casingthink;
82 e.touch = casingtouch;
83 //e.knockedloosefunc = casingknockedloosefunc;
84 e.effects = EF_LOWPRECISION;
88 setmodel (e, "models/casing_shell.mdl"); // precision set above
90 // bias to make these be considered more important than other things
91 e.createdtime = time + 1;
93 else if (casingtype == 2)
95 // FIXME: this is not used and not precached, uncomment if you need it
96 //setmodel (e, "models/casing_steel.mdl"); // precision set above
101 setmodel (e, "models/casing_bronze.mdl"); // precision set above
106 setsize (e, '0 0 -1', '0 0 -1');
111 float Casing_SendEntity(entity to, float sf)
113 WriteByte(MSG_ENTITY, ENT_CLIENT_CASING);
114 WriteByte(MSG_ENTITY, self.state); // actually type
115 WriteCoord(MSG_ENTITY, self.origin_x);
116 WriteCoord(MSG_ENTITY, self.origin_y);
117 WriteCoord(MSG_ENTITY, self.origin_z);
118 WriteShort(MSG_ENTITY, self.oldorigin_x); // acrually compressed velocity
119 WriteByte(MSG_ENTITY, self.angles_x * 256 / 360);
120 WriteByte(MSG_ENTITY, self.angles_y * 256 / 360);
121 WriteByte(MSG_ENTITY, self.angles_z * 256 / 360);
125 void SpawnCasing(vector org, vector vel, float randomvel, vector ang, vector avel, float randomavel, float casingtype)
130 e.state = casingtype;
135 e.oldorigin_x = compressShortVector(e.velocity);
138 e.SendEntity = Casing_SendEntity;
140 e.nextthink = time + 0.2;
141 e.think = SUB_Remove;
142 // 0.2s should be enough time for all clients to receive this ent once, do the gibbage and be done with it