11 string species_prefix(float specnum)
15 case SPECIES_HUMAN: return "";
16 case SPECIES_ALIEN: return "alien_";
17 case SPECIES_ROBOT_SHINY: return "robot_";
18 case SPECIES_ROBOT_RUSTY: return "robot_"; // use the same effects, only different gibs
19 case SPECIES_ANIMAL: return "animal_";
20 case SPECIES_RESERVED: return "reserved_";
25 void new_te_bloodshower (float ef, vector org, float explosionspeed, float howmany)
28 pmod = cvar("cl_particles_quality");
29 for (i = 0; i < 250 * pmod; ++i)
30 pointparticles(ef, org, randomvec() * explosionspeed, howmany / 250);
33 void SUB_RemoveOnNoImpact()
35 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
41 // TODO maybe bounce of walls, make more gibs, etc.
43 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
50 sound(self, CHAN_PAIN, strcat("misc/gib_splat0", ftos(floor(prandom() * 4 + 1)), ".wav"), VOL_BASE, ATTN_NORM);
51 pointparticles(particleeffectnum(strcat(species_prefix(self.cnt), "blood")), self.origin + '0 0 1', '0 0 30', 10);
61 Movetype_Physics_NoMatchServer();
65 if(self.touch == Gib_Touch) // don't do this for the "chunk" thingie...
66 trailparticles(self, particleeffectnum(strcat(species_prefix(self.cnt), "TR_SLIGHTBLOOD")), oldorg, self.origin);
68 trailparticles(self, particleeffectnum(strcat(species_prefix(self.cnt), "TR_BLOOD")), oldorg, self.origin);
71 self.alpha = bound(0, self.nextthink - time, 1);
73 if(self.alpha < ALPHA_MIN_VISIBLE)
79 void TossGib (string mdlname, vector org, vector vconst, vector vrand, float specnum, float destroyontouch, float issilent)
86 // TODO remove some gibs according to cl_nogibs
87 gib = RubbleNew(giblist);
89 if(gibcount >= cvar_or("cl_gibs_maxcount",100))
90 RubbleDrop(giblist,Gib_Delete);
94 gib.classname = "gib";
95 gib.move_movetype = MOVETYPE_BOUNCE;
97 gib.solid = SOLID_CORPSE;
99 gib.silent = issilent;
101 setmodel (gib, mdlname); // precision set above
104 setsize (gib, '-8 -8 -8', '8 8 8');
108 gib.move_touch = Gib_Touch;
110 gib.move_touch = SUB_RemoveOnNoImpact;
112 gib.move_origin = gib.origin = org;
113 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");
114 gib.move_avelocity = prandomvec() * vlen(gib.move_velocity);
115 gib.move_time = time;
116 gib.damageforcescale = cvar_or("cl_gibs_damageforcescale", 3.5);
118 gib.nextthink = time + cvar_or("cl_gibs_lifetime", 14) * (1 + prandom() * 0.15);
123 float amount, type, specnum;
128 float c, gibfactor, randomvalue;
130 type = ReadByte(); // gibbage type
131 amount = ReadByte() / 16.0; // gibbage amount
132 org_x = ReadShort() * 4 + 2;
133 org_y = ReadShort() * 4 + 2;
134 org_z = ReadShort() * 4 + 2;
135 vel = decompressShortVector(ReadShort());
137 if(cvar("cl_gentle"))
138 type |= 0x80; // set gentle bit
140 gibfactor = 1 - cvar("cl_nogibs");
149 self.origin = org; // for the sounds
151 specnum = (type & 0x78) / 8; // blood/gibmodel type: using four bits (0..7, bit indexes 3,4,5)
152 issilent = (type & 0x40);
153 type = type & 0x87; // remove the species bits: bit 7 = gentle, bit 0,1,2 = kind of gib
154 specstr = species_prefix(specnum);
160 sound (self, CHAN_PAIN, "misc/gib.wav", VOL_BASE, ATTN_NORM);
162 if(prandom() < amount)
163 TossGib ("models/gibs/eye.md3", org, vel, prandomvec() * 150, specnum, 0, issilent);
164 new_te_bloodshower(particleeffectnum(strcat(specstr, "bloodshower")), org, 1200, amount);
165 if(prandom() < amount)
166 TossGib ("models/gibs/bloodyskull.md3", org, vel, prandomvec() * 100, specnum, 0, issilent);
168 for(c = 0; c < amount; ++c)
170 randomvalue = amount - c;
172 if(prandom() < randomvalue)
173 TossGib ("models/gibs/arm.md3", org, vel, prandomvec() * (prandom() * 120 + 90), specnum,0, issilent);
174 if(prandom() < randomvalue)
175 TossGib ("models/gibs/arm.md3", org, vel, prandomvec() * (prandom() * 120 + 90), specnum,0, issilent);
176 if(prandom() < randomvalue)
177 TossGib ("models/gibs/chest.md3", org + '0 0 -12', vel, prandomvec() * (prandom() * 120 + 80), specnum,0, issilent);
178 if(prandom() < randomvalue)
179 TossGib ("models/gibs/smallchest.md3", org, vel, prandomvec() * (prandom() * 120 + 80), specnum,0, issilent);
180 if(prandom() < randomvalue)
181 TossGib ("models/gibs/leg1.md3", org + '0 0 -5', vel, prandomvec() * (prandom() * 120 + 85), specnum,0, issilent);
182 if(prandom() < randomvalue)
183 TossGib ("models/gibs/leg2.md3", org + '0 0 -9', vel, prandomvec() * (prandom() * 120 + 85), specnum,0, issilent);
185 // these splat on impact
186 if(prandom() < randomvalue)
187 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450, specnum,1, issilent);
188 if(prandom() < randomvalue)
189 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450, specnum,1, issilent);
190 if(prandom() < randomvalue)
191 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450, specnum,1, issilent);
192 if(prandom() < randomvalue)
193 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450, specnum,1, issilent);
197 pointparticles(particleeffectnum(strcat(specstr, "blood")), org, vel, amount * 16);
200 if(prandom() < amount)
201 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * (prandom() * 30 + 20), specnum, 1, issilent); // TODO maybe adjust to more randomization?
204 pointparticles(particleeffectnum("damage_dissolve"), org, vel, amount);
207 pointparticles(particleeffectnum("damage_hit"), org, vel, amount * 16);
210 // no gibs in gentle mode, sorry
215 void GibSplash_Precache()
217 precache_model("models/gibs/chunk.mdl");
218 precache_model("models/gibs/leg1.md3");
219 precache_model("models/gibs/leg2.md3");
220 precache_model("models/gibs/chest.md3");
221 precache_model("models/gibs/smallchest.md3");
222 precache_model("models/gibs/arm.md3");
223 precache_model("models/gibs/bloodyskull.md3");
224 precache_model("models/gibs/eye.md3");
226 precache_sound ("misc/gib.wav");
227 precache_sound ("misc/gib_splat01.wav");
228 precache_sound ("misc/gib_splat02.wav");
229 precache_sound ("misc/gib_splat03.wav");
230 precache_sound ("misc/gib_splat04.wav");