1 void SUB_RemoveOnNoImpact()
3 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
9 // TODO maybe bounce of walls, make more gibs, etc.
11 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
17 sound(self, CHAN_PAIN, strcat("misc/gib_splat0", ftos(floor(prandom() * 4 + 1)), ".wav"), VOL_BASE, ATTN_NORM);
18 pointparticles(particleeffectnum("blood"), self.origin + '0 0 1', '0 0 30', 10);
28 Movetype_Physics(FALSE);
30 if(self.touch == Gib_Touch) // don't do this for the "chunk" thingie...
31 trailparticles(self, particleeffectnum("TR_SLIGHTBLOOD"), oldorg, self.origin);
33 trailparticles(self, particleeffectnum("TR_BLOOD"), oldorg, self.origin);
36 self.alpha = bound(0, self.nextthink - time, 1);
44 void TossGib (string mdlname, vector org, vector vconst, vector vrand, float destroyontouch)
48 // TODO remove some gibs according to cl_nogibs
51 gib.classname = "gib";
52 gib.move_movetype = MOVETYPE_BOUNCE;
54 gib.solid = SOLID_CORPSE;
56 setmodel (gib, mdlname); // precision set above
58 setsize (gib, '-8 -8 -8', '8 8 8');
62 gib.move_touch = Gib_Touch;
64 gib.move_touch = SUB_RemoveOnNoImpact;
66 gib.move_origin = gib.origin = org;
67 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");
68 gib.move_avelocity = prandomvec() * vlen(gib.move_velocity);
70 gib.damageforcescale = cvar_or("cl_gibs_damageforcescale", 3.5);
72 gib.nextthink = time + cvar_or("cl_gibs_lifetime", 14) * (1 + prandom() * 0.15);
78 vector org, vel, mi, ma;
80 float c, gibfactor, randomvalue;
82 type = ReadByte(); // gibbage type
83 amount = ReadByte() / 16.0; // gibbage amount
84 org_x = ReadShort() * 4 + 2;
85 org_y = ReadShort() * 4 + 2;
86 org_z = ReadShort() * 4 + 2;
87 vel = decompressShortVector(ReadShort());
88 mi = decompressShortVector(ReadShort());
89 ma = decompressShortVector(ReadShort());
92 type |= 0x80; // set gentle bit
94 gibfactor = 1 - cvar("cl_nogibs");
103 self.origin = org; // for the sounds
108 sound (self, CHAN_PAIN, "misc/gib.wav", VOL_BASE, ATTN_NORM);
110 if(prandom() < amount)
111 TossGib("models/gibs/eye.md3", org, vel, prandomvec() * 150, 0);
112 te_bloodshower(org + mi, org + ma, 1200, 1000 * amount);
113 if(prandom() < amount)
114 TossGib("models/gibs/bloodyskull.md3", org, vel, prandomvec() * 100, 0);
116 for(c = 0; c < amount; ++c)
118 randomvalue = amount - c;
120 if(prandom() < randomvalue)
121 TossGib ("models/gibs/arm.md3", org, vel, prandomvec() * (prandom() * 120 + 90),0);
122 if(prandom() < randomvalue)
123 TossGib ("models/gibs/arm.md3", org, vel, prandomvec() * (prandom() * 120 + 90),0);
124 if(prandom() < randomvalue)
125 TossGib ("models/gibs/chest.md3", org + '0 0 -12', vel, prandomvec() * (prandom() * 120 + 80),0);
126 if(prandom() < randomvalue)
127 TossGib ("models/gibs/smallchest.md3", org, vel, prandomvec() * (prandom() * 120 + 80),0);
128 if(prandom() < randomvalue)
129 TossGib ("models/gibs/leg1.md3", org + '0 0 -5', vel, prandomvec() * (prandom() * 120 + 85),0);
130 if(prandom() < randomvalue)
131 TossGib ("models/gibs/leg2.md3", org + '0 0 -9', vel, prandomvec() * (prandom() * 120 + 85),0);
133 // these splat on impact
134 if(prandom() < randomvalue)
135 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450,1);
136 if(prandom() < randomvalue)
137 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450,1);
138 if(prandom() < randomvalue)
139 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450,1);
140 if(prandom() < randomvalue)
141 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * 450,1);
145 pointparticles(particleeffectnum("blood"), org, vel, amount * 16);
148 if(prandom() < amount)
149 TossGib ("models/gibs/chunk.mdl", org, vel, prandomvec() * (prandom() * 30 + 20), 1); // TODO maybe adjust to more randomization?
152 pointparticles(particleeffectnum("damage_dissolve"), org, vel, amount);
155 pointparticles(particleeffectnum("damage_hit"), org, vel, amount * 16);
158 // no gibs in gentle mode, sorry
163 void GibSplash_Precache()
165 precache_model("models/gibs/chunk.mdl");
166 precache_model("models/gibs/leg1.md3");
167 precache_model("models/gibs/leg2.md3");
168 precache_model("models/gibs/chest.md3");
169 precache_model("models/gibs/smallchest.md3");
170 precache_model("models/gibs/arm.md3");
171 precache_model("models/gibs/bloodyskull.md3");
172 precache_model("models/gibs/eye.md3");
174 precache_sound ("misc/gib.wav");
175 precache_sound ("misc/gib_splat01.wav");
176 precache_sound ("misc/gib_splat02.wav");
177 precache_sound ("misc/gib_splat03.wav");
178 precache_sound ("misc/gib_splat04.wav");