8 string species_prefix(float specnum)
\r
12 case SPECIES_HUMAN: return "";
\r
13 case SPECIES_ALIEN: return "alien_";
\r
14 case SPECIES_ROBOT_SHINY: return "robot_";
\r
15 case SPECIES_ROBOT_RUSTY: return "robot_"; // use the same effects, only different gibs
\r
16 case SPECIES_ROBOT_SOLID: return "robot_"; // use the same effects, only different gibs
\r
17 case SPECIES_ANIMAL: return "animal_";
\r
18 case SPECIES_RESERVED: return "reserved_";
\r
23 void Gib_setmodel(entity gib, string mdlname, float specnum)
\r
27 case SPECIES_ROBOT_RUSTY:
\r
28 case SPECIES_ROBOT_SHINY:
\r
29 case SPECIES_ROBOT_SOLID:
\r
30 if(specnum != SPECIES_ROBOT_SOLID || mdlname == "models/gibs/chunk.mdl")
\r
32 if(mdlname == "models/gibs/bloodyskull.md3")
\r
33 setmodel(gib, "models/gibs/robo.md3");
\r
35 setmodel(gib, strcat("models/gibs/robo", ftos(floor(random() * 8) + 1), ".md3"));
\r
36 if(specnum == SPECIES_ROBOT_SHINY)
\r
39 gib.colormod = '2 2 2';
\r
45 setmodel(gib, mdlname);
\r
51 void new_te_bloodshower (float ef, vector org, float explosionspeed, float howmany)
\r
54 pmod = cvar("cl_particles_quality");
\r
55 for (i = 0; i < 250 * pmod; ++i)
\r
56 pointparticles(ef, org, randomvec() * explosionspeed, howmany / 250);
\r
59 void SUB_RemoveOnNoImpact()
\r
61 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
\r
67 // TODO maybe bounce of walls, make more gibs, etc.
\r
69 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
\r
76 sound(self, CHAN_PAIN, strcat("misc/gib_splat0", ftos(floor(prandom() * 4 + 1)), ".wav"), VOL_BASE, ATTN_NORM);
\r
77 pointparticles(particleeffectnum(strcat(species_prefix(self.cnt), "blood")), self.origin + '0 0 1', '0 0 30', 10);
\r
85 oldorg = self.origin;
\r
87 Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
\r
91 if(self.touch == Gib_Touch) // don't do this for the "chunk" thingie...
\r
92 trailparticles(self, particleeffectnum(strcat(species_prefix(self.cnt), "TR_SLIGHTBLOOD")), oldorg, self.origin);
\r
94 trailparticles(self, particleeffectnum(strcat(species_prefix(self.cnt), "TR_BLOOD")), oldorg, self.origin);
\r
96 self.renderflags = 0;
\r
97 self.alpha = bound(0, self.nextthink - time, 1);
\r
99 if(self.alpha < ALPHA_MIN_VISIBLE)
\r
105 void TossGib (string mdlname, vector org, vector vconst, vector vrand, float specnum, float destroyontouch, float issilent)
\r
109 // TODO remove some gibs according to cl_nogibs
\r
110 gib = RubbleNew("gib");
\r
111 gib.move_movetype = MOVETYPE_BOUNCE;
\r
113 gib.solid = SOLID_CORPSE;
\r
115 gib.silent = issilent;
\r
116 Gib_setmodel(gib, mdlname, specnum);
\r
118 setsize (gib, '-8 -8 -8', '8 8 8');
\r
120 gib.draw = Gib_Draw;
\r
122 gib.move_touch = Gib_Touch;
\r
124 gib.move_touch = SUB_RemoveOnNoImpact;
\r
126 gib.move_origin = gib.origin = org;
\r
127 gib.move_velocity = vconst * cvar_or("cl_gibs_velocity_scale", 1) + vrand * cvar_or("cl_gibs_velocity_random", 1) + '0 0 1' * cvar("cl_gibs_velocity_up");
\r
128 gib.move_avelocity = prandomvec() * vlen(gib.move_velocity);
\r
129 gib.move_time = time;
\r
130 gib.damageforcescale = cvar_or("cl_gibs_damageforcescale", 3.5);
\r
132 gib.nextthink = time + cvar_or("cl_gibs_lifetime", 14) * (1 + prandom() * 0.15);
\r
134 RubbleLimit("gib", cvar_or("cl_gibs_maxcount",100), Gib_Delete);
\r
137 void Ent_GibSplash(float isNew)
\r
139 float amount, type, specnum;
\r
143 string gentle_prefix;
\r
145 float c, randomvalue;
\r
147 type = ReadByte(); // gibbage type
\r
148 amount = ReadByte() / 16.0; // gibbage amount
\r
149 org_x = ReadShort() * 4 + 2;
\r
150 org_y = ReadShort() * 4 + 2;
\r
151 org_z = ReadShort() * 4 + 2;
\r
152 vel = decompressShortVector(ReadShort());
\r
154 if(cvar("cl_gentle"))
\r
155 type |= 0x80; // set gentle bit
\r
159 if(cvar("cl_gentle") > 1)
\r
160 gentle_prefix = "";
\r
162 gentle_prefix = "morphed_";
\r
164 else if(cvar("cl_particlegibs"))
\r
167 gentle_prefix = "particlegibs_";
\r
170 if not(cvar("cl_gentle"))
\r
171 amount *= 1 - cvar("cl_nogibs");
\r
176 if(amount <= 0 || !isNew)
\r
179 self.origin = org; // for the sounds
\r
181 specnum = (type & 0x78) / 8; // blood/gibmodel type: using four bits (0..7, bit indexes 3,4,5)
\r
182 issilent = (type & 0x40);
\r
183 type = type & 0x87; // remove the species bits: bit 7 = gentle, bit 0,1,2 = kind of gib
\r
184 specstr = species_prefix(specnum);
\r
190 sound (self, CHAN_PAIN, "misc/gib.wav", VOL_BASE, ATTN_NORM);
\r
192 if(prandom() < amount)
\r
193 TossGib ("models/gibs/eye.md3", org, vel, prandomvec() * 150, specnum, 0, issilent);
\r
194 new_te_bloodshower(particleeffectnum(strcat(specstr, "bloodshower")), org, 1200, amount);
\r
195 if(prandom() < amount)
\r
196 TossGib ("models/gibs/bloodyskull.md3", org + 16 * prandomvec(), vel, prandomvec() * 100, specnum, 0, issilent);
\r
198 for(c = 0; c < amount; ++c)
\r
200 randomvalue = amount - c;
\r
202 if(prandom() < randomvalue)
\r
203 TossGib ("models/gibs/arm.md3", org + 16 * prandomvec() + '0 0 8', vel, prandomvec() * (prandom() * 120 + 90), specnum,0, issilent);
\r
204 if(prandom() < randomvalue)
\r
205 TossGib ("models/gibs/arm.md3", org + 16 * prandomvec() + '0 0 8', vel, prandomvec() * (prandom() * 120 + 90), specnum,0, issilent);
\r
206 if(prandom() < randomvalue)
\r
207 TossGib ("models/gibs/chest.md3", org + 16 * prandomvec(), vel, prandomvec() * (prandom() * 120 + 80), specnum,0, issilent);
\r
208 if(prandom() < randomvalue)
\r
209 TossGib ("models/gibs/smallchest.md3", org + 16 * prandomvec(), vel, prandomvec() * (prandom() * 120 + 80), specnum,0, issilent);
\r
210 if(prandom() < randomvalue)
\r
211 TossGib ("models/gibs/leg1.md3", org + 16 * prandomvec() + '0 0 -5', vel, prandomvec() * (prandom() * 120 + 85), specnum,0, issilent);
\r
212 if(prandom() < randomvalue)
\r
213 TossGib ("models/gibs/leg2.md3", org + 16 * prandomvec() + '0 0 -5', vel, prandomvec() * (prandom() * 120 + 85), specnum,0, issilent);
\r
215 // these splat on impact
\r
216 if(prandom() < randomvalue)
\r
217 TossGib ("models/gibs/chunk.mdl", org + 16 * prandomvec(), vel, prandomvec() * 450, specnum,1, issilent);
\r
218 if(prandom() < randomvalue)
\r
219 TossGib ("models/gibs/chunk.mdl", org + 16 * prandomvec(), vel, prandomvec() * 450, specnum,1, issilent);
\r
220 if(prandom() < randomvalue)
\r
221 TossGib ("models/gibs/chunk.mdl", org + 16 * prandomvec(), vel, prandomvec() * 450, specnum,1, issilent);
\r
222 if(prandom() < randomvalue)
\r
223 TossGib ("models/gibs/chunk.mdl", org + 16 * prandomvec(), vel, prandomvec() * 450, specnum,1, issilent);
\r
227 pointparticles(particleeffectnum(strcat(specstr, "blood")), org, vel, amount * 16);
\r
230 if(prandom() < amount)
\r
231 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * (prandom() * 30 + 20), specnum, 1, issilent); // TODO maybe adjust to more randomization?
\r
234 pointparticles(particleeffectnum(strcat(gentle_prefix, "damage_dissolve")), org, vel, amount);
\r
237 pointparticles(particleeffectnum(strcat(gentle_prefix, "damage_hit")), org, vel, amount * 16);
\r
240 // no gibs in gentle mode, sorry
\r
245 void GibSplash_Precache()
\r
247 precache_model("models/gibs/chunk.mdl");
\r
248 precache_model("models/gibs/leg1.md3");
\r
249 precache_model("models/gibs/leg2.md3");
\r
250 precache_model("models/gibs/chest.md3");
\r
251 precache_model("models/gibs/smallchest.md3");
\r
252 precache_model("models/gibs/arm.md3");
\r
253 precache_model("models/gibs/bloodyskull.md3");
\r
254 precache_model("models/gibs/eye.md3");
\r
256 precache_model("models/gibs/robo.md3");
\r
257 precache_model("models/gibs/robo1.md3");
\r
258 precache_model("models/gibs/robo2.md3");
\r
259 precache_model("models/gibs/robo3.md3");
\r
260 precache_model("models/gibs/robo4.md3");
\r
261 precache_model("models/gibs/robo5.md3");
\r
262 precache_model("models/gibs/robo6.md3");
\r
263 precache_model("models/gibs/robo7.md3");
\r
264 precache_model("models/gibs/robo8.md3");
\r
266 precache_sound ("misc/gib.wav");
\r
267 precache_sound ("misc/gib_splat01.wav");
\r
268 precache_sound ("misc/gib_splat02.wav");
\r
269 precache_sound ("misc/gib_splat03.wav");
\r
270 precache_sound ("misc/gib_splat04.wav");
\r