1 string species_prefix(float specnum)
5 case SPECIES_HUMAN: return "";
6 case SPECIES_ALIEN: return "alien_";
7 case SPECIES_ROBOT_SHINY: return "robot_";
8 case SPECIES_ROBOT_RUSTY: return "robot_"; // use the same effects, only different gibs
9 case SPECIES_ANIMAL: return "animal_";
10 case SPECIES_RESERVED: return "reserved_";
15 void SUB_RemoveOnNoImpact()
17 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
23 // TODO maybe bounce of walls, make more gibs, etc.
25 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
31 sound(self, CHAN_PAIN, strcat("misc/gib_splat0", ftos(floor(prandom() * 4 + 1)), ".wav"), VOL_BASE, ATTN_NORM);
32 pointparticles(particleeffectnum(strcat(species_prefix(self.cnt), "blood")), self.origin + '0 0 1', '0 0 30', 10);
42 Movetype_Physics(FALSE);
46 if(self.touch == Gib_Touch) // don't do this for the "chunk" thingie...
47 trailparticles(self, particleeffectnum(strcat(species_prefix(self.cnt), "TR_SLIGHTBLOOD")), oldorg, self.origin);
49 trailparticles(self, particleeffectnum(strcat(species_prefix(self.cnt), "TR_BLOOD")), oldorg, self.origin);
52 self.alpha = bound(0, self.nextthink - time, 1);
54 if(self.alpha < ALPHA_MIN_VISIBLE)
60 void TossGib (string mdlname, vector org, vector vconst, vector vrand, float specnum, float destroyontouch)
64 // TODO remove some gibs according to cl_nogibs
67 gib.classname = "gib";
68 gib.move_movetype = MOVETYPE_BOUNCE;
70 gib.solid = SOLID_CORPSE;
73 setmodel (gib, mdlname); // precision set above
76 setsize (gib, '-8 -8 -8', '8 8 8');
80 gib.move_touch = Gib_Touch;
82 gib.move_touch = SUB_RemoveOnNoImpact;
84 gib.move_origin = gib.origin = org;
85 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");
86 gib.move_avelocity = prandomvec() * vlen(gib.move_velocity);
88 gib.damageforcescale = cvar_or("cl_gibs_damageforcescale", 3.5);
90 gib.nextthink = time + cvar_or("cl_gibs_lifetime", 14) * (1 + prandom() * 0.15);
95 float amount, type, specnum;
96 vector org, vel, mi, ma;
99 float c, gibfactor, randomvalue;
101 type = ReadByte(); // gibbage type
102 amount = ReadByte() / 16.0; // gibbage amount
103 org_x = ReadShort() * 4 + 2;
104 org_y = ReadShort() * 4 + 2;
105 org_z = ReadShort() * 4 + 2;
106 vel = decompressShortVector(ReadShort());
107 mi = decompressShortVector(ReadShort());
108 ma = decompressShortVector(ReadShort());
110 if(cvar("cl_gentle"))
111 type |= 0x80; // set gentle bit
113 gibfactor = 1 - cvar("cl_nogibs");
122 self.origin = org; // for the sounds
124 specnum = (type & 0x78) / 8; // blood/gibmodel type: using four bits (0..15, bit indexes 3,4,5,6)
125 type = type & 0x87; // remove the species bits: bit 7 = gentle, bit 0,1,2 = kind of gib
126 specstr = species_prefix(specnum);
131 sound (self, CHAN_PAIN, "misc/gib.wav", VOL_BASE, ATTN_NORM);
133 if(prandom() < amount)
134 TossGib ("models/gibs/eye.md3", org, vel, prandomvec() * 150, specnum, 0);
135 te_bloodshower(org + mi, org + ma, 1200, 1000 * amount);
136 if(prandom() < amount)
137 TossGib ("models/gibs/bloodyskull.md3", org, vel, prandomvec() * 100, specnum, 0);
139 for(c = 0; c < amount; ++c)
141 randomvalue = amount - c;
143 if(prandom() < randomvalue)
144 TossGib ("models/gibs/arm.md3", org, vel, prandomvec() * (prandom() * 120 + 90), specnum,0);
145 if(prandom() < randomvalue)
146 TossGib ("models/gibs/arm.md3", org, vel, prandomvec() * (prandom() * 120 + 90), specnum,0);
147 if(prandom() < randomvalue)
148 TossGib ("models/gibs/chest.md3", org + '0 0 -12', vel, prandomvec() * (prandom() * 120 + 80), specnum,0);
149 if(prandom() < randomvalue)
150 TossGib ("models/gibs/smallchest.md3", org, vel, prandomvec() * (prandom() * 120 + 80), specnum,0);
151 if(prandom() < randomvalue)
152 TossGib ("models/gibs/leg1.md3", org + '0 0 -5', vel, prandomvec() * (prandom() * 120 + 85), specnum,0);
153 if(prandom() < randomvalue)
154 TossGib ("models/gibs/leg2.md3", org + '0 0 -9', vel, prandomvec() * (prandom() * 120 + 85), specnum,0);
156 // these splat on impact
157 if(prandom() < randomvalue)
158 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450, specnum,1);
159 if(prandom() < randomvalue)
160 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450, specnum,1);
161 if(prandom() < randomvalue)
162 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450, specnum,1);
163 if(prandom() < randomvalue)
164 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450, specnum,1);
168 pointparticles(particleeffectnum(strcat(specstr, "blood")), org, vel, amount * 16);
171 if(prandom() < amount)
172 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * (prandom() * 30 + 20), specnum, 1); // TODO maybe adjust to more randomization?
175 pointparticles(particleeffectnum("damage_dissolve"), org, vel, amount);
178 pointparticles(particleeffectnum("damage_hit"), org, vel, amount * 16);
181 // no gibs in gentle mode, sorry
186 void GibSplash_Precache()
188 precache_model("models/gibs/chunk.mdl");
189 precache_model("models/gibs/leg1.md3");
190 precache_model("models/gibs/leg2.md3");
191 precache_model("models/gibs/chest.md3");
192 precache_model("models/gibs/smallchest.md3");
193 precache_model("models/gibs/arm.md3");
194 precache_model("models/gibs/bloodyskull.md3");
195 precache_model("models/gibs/eye.md3");
197 precache_sound ("misc/gib.wav");
198 precache_sound ("misc/gib_splat01.wav");
199 precache_sound ("misc/gib_splat02.wav");
200 precache_sound ("misc/gib_splat03.wav");
201 precache_sound ("misc/gib_splat04.wav");