10 string species_prefix(float specnum)
14 case SPECIES_HUMAN: return "";
15 case SPECIES_ALIEN: return "alien_";
16 case SPECIES_ROBOT_SHINY: return "robot_";
17 case SPECIES_ROBOT_RUSTY: return "robot_"; // use the same effects, only different gibs
18 case SPECIES_ANIMAL: return "animal_";
19 case SPECIES_RESERVED: return "reserved_";
24 void new_te_bloodshower (float ef, vector org, float explosionspeed, float howmany)
27 pmod = cvar("cl_particles_quality");
28 for (i = 0; i < 250 * pmod; ++i)
29 pointparticles(ef, org, randomvec() * explosionspeed, howmany / 250);
32 void SUB_RemoveOnNoImpact()
34 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
40 // TODO maybe bounce of walls, make more gibs, etc.
42 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
48 sound(self, CHAN_PAIN, strcat("misc/gib_splat0", ftos(floor(prandom() * 4 + 1)), ".wav"), VOL_BASE, ATTN_NORM);
49 pointparticles(particleeffectnum(strcat(species_prefix(self.cnt), "blood")), self.origin + '0 0 1', '0 0 30', 10);
59 Movetype_Physics(FALSE);
63 if(self.touch == Gib_Touch) // don't do this for the "chunk" thingie...
64 trailparticles(self, particleeffectnum(strcat(species_prefix(self.cnt), "TR_SLIGHTBLOOD")), oldorg, self.origin);
66 trailparticles(self, particleeffectnum(strcat(species_prefix(self.cnt), "TR_BLOOD")), oldorg, self.origin);
69 self.alpha = bound(0, self.nextthink - time, 1);
71 if(self.alpha < ALPHA_MIN_VISIBLE)
77 void TossGib (string mdlname, vector org, vector vconst, vector vrand, float specnum, float destroyontouch)
84 // TODO remove some gibs according to cl_nogibs
\r
85 gib = RubbleNew(giblist);
\r
87 if(gibcount >= cvar_or("cl_gibs_maxcount",100))
\r
88 RubbleDrop(giblist,Gib_Delete);
\r
92 gib.classname = "gib";
93 gib.move_movetype = MOVETYPE_BOUNCE;
95 gib.solid = SOLID_CORPSE;
98 setmodel (gib, mdlname); // precision set above
101 setsize (gib, '-8 -8 -8', '8 8 8');
105 gib.move_touch = Gib_Touch;
107 gib.move_touch = SUB_RemoveOnNoImpact;
109 gib.move_origin = gib.origin = org;
110 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");
111 gib.move_avelocity = prandomvec() * vlen(gib.move_velocity);
112 gib.move_time = time;
113 gib.damageforcescale = cvar_or("cl_gibs_damageforcescale", 3.5);
115 gib.nextthink = time + cvar_or("cl_gibs_lifetime", 14) * (1 + prandom() * 0.15);
120 float amount, type, specnum;
124 float c, gibfactor, randomvalue;
126 type = ReadByte(); // gibbage type
127 amount = ReadByte() / 16.0; // gibbage amount
128 org_x = ReadShort() * 4 + 2;
129 org_y = ReadShort() * 4 + 2;
130 org_z = ReadShort() * 4 + 2;
131 vel = decompressShortVector(ReadShort());
133 if(cvar("cl_gentle"))
134 type |= 0x80; // set gentle bit
136 gibfactor = 1 - cvar("cl_nogibs");
145 self.origin = org; // for the sounds
147 specnum = (type & 0x78) / 8; // blood/gibmodel type: using four bits (0..15, bit indexes 3,4,5,6)
148 type = type & 0x87; // remove the species bits: bit 7 = gentle, bit 0,1,2 = kind of gib
149 specstr = species_prefix(specnum);
154 sound (self, CHAN_PAIN, "misc/gib.wav", VOL_BASE, ATTN_NORM);
156 if(prandom() < amount)
157 TossGib ("models/gibs/eye.md3", org, vel, prandomvec() * 150, specnum, 0);
158 new_te_bloodshower(particleeffectnum(strcat(specstr, "bloodshower")), org, 1200, amount);
159 if(prandom() < amount)
160 TossGib ("models/gibs/bloodyskull.md3", org, vel, prandomvec() * 100, specnum, 0);
162 for(c = 0; c < amount; ++c)
164 randomvalue = amount - c;
166 if(prandom() < randomvalue)
167 TossGib ("models/gibs/arm.md3", org, vel, prandomvec() * (prandom() * 120 + 90), specnum,0);
168 if(prandom() < randomvalue)
169 TossGib ("models/gibs/arm.md3", org, vel, prandomvec() * (prandom() * 120 + 90), specnum,0);
170 if(prandom() < randomvalue)
171 TossGib ("models/gibs/chest.md3", org + '0 0 -12', vel, prandomvec() * (prandom() * 120 + 80), specnum,0);
172 if(prandom() < randomvalue)
173 TossGib ("models/gibs/smallchest.md3", org, vel, prandomvec() * (prandom() * 120 + 80), specnum,0);
174 if(prandom() < randomvalue)
175 TossGib ("models/gibs/leg1.md3", org + '0 0 -5', vel, prandomvec() * (prandom() * 120 + 85), specnum,0);
176 if(prandom() < randomvalue)
177 TossGib ("models/gibs/leg2.md3", org + '0 0 -9', vel, prandomvec() * (prandom() * 120 + 85), specnum,0);
179 // these splat on impact
180 if(prandom() < randomvalue)
181 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450, specnum,1);
182 if(prandom() < randomvalue)
183 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450, specnum,1);
184 if(prandom() < randomvalue)
185 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450, specnum,1);
186 if(prandom() < randomvalue)
187 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450, specnum,1);
191 pointparticles(particleeffectnum(strcat(specstr, "blood")), org, vel, amount * 16);
194 if(prandom() < amount)
195 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * (prandom() * 30 + 20), specnum, 1); // TODO maybe adjust to more randomization?
198 pointparticles(particleeffectnum("damage_dissolve"), org, vel, amount);
201 pointparticles(particleeffectnum("damage_hit"), org, vel, amount * 16);
204 // no gibs in gentle mode, sorry
209 void GibSplash_Precache()
211 precache_model("models/gibs/chunk.mdl");
212 precache_model("models/gibs/leg1.md3");
213 precache_model("models/gibs/leg2.md3");
214 precache_model("models/gibs/chest.md3");
215 precache_model("models/gibs/smallchest.md3");
216 precache_model("models/gibs/arm.md3");
217 precache_model("models/gibs/bloodyskull.md3");
218 precache_model("models/gibs/eye.md3");
220 precache_sound ("misc/gib.wav");
221 precache_sound ("misc/gib_splat01.wav");
222 precache_sound ("misc/gib_splat02.wav");
223 precache_sound ("misc/gib_splat03.wav");
224 precache_sound ("misc/gib_splat04.wav");