case ENT_CLIENT_LGBEAM: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_LGBEAM); break;
case ENT_CLIENT_GAUNTLET: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_GAUNTLET); break;
case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
+ case ENT_CLIENT_WEAPONDAMAGE: Ent_WeaponDamage(); break;
default:
error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
break;
precache_sound ("misc/gib_splat03.wav");
precache_sound ("misc/gib_splat04.wav");
}
+
+void Ent_WeaponDamage()
+{
+ float type, specnum1, specnum2;
+ vector org;
+ string specstr;
+
+ type = ReadByte(); // damage weapon
+ specnum1 = ReadByte(); // player species
+ org_x = ReadCoord();
+ org_y = ReadCoord();
+ org_z = ReadCoord();
+
+ specnum2 = (specnum1 & 0x78) / 8; // blood type: using four bits (0..7, bit indexes 3,4,5)
+ specstr = species_prefix(specnum2);
+}
{
Violence_GibSplash_At(source.origin + source.view_ofs, source.velocity, type, amount, source, attacker);
}
+
+float Violence_WeaponDamage_SendEntity(entity to, float sf)
+{
+ WriteByte(MSG_ENTITY, ENT_CLIENT_WEAPONDAMAGE);
+ WriteByte(MSG_ENTITY, self.cnt); // the damage weapon
+ WriteByte(MSG_ENTITY, self.state); // species
+ WriteCoord(MSG_ENTITY, floor(self.origin_x));
+ WriteCoord(MSG_ENTITY, floor(self.origin_y));
+ WriteCoord(MSG_ENTITY, floor(self.origin_z));
+ return TRUE;
+}
+
+void Violence_WeaponDamage(entity pl, float type)
+{
+ entity e;
+
+ e = spawn();
+ e.classname = "weapondamage";
+ e.cnt = type;
+ e.state |= 8 * pl.species; // gib type, ranges from 0 to 15
+ setorigin(e, pl.origin);
+
+ Net_LinkEntity(e, FALSE, 0.2, Violence_WeaponDamage_SendEntity);
+}
+
+.float lifetime;
+.float weapondamage_counter;
+
+void Violence_WeaponDamage_DoRepeat()
+{
+ if(time > self.lifetime)
+ {
+ self.nextthink = 0;
+ remove(self);
+ return;
+ }
+
+ if(time > self.weapondamage_counter)
+ {
+ Violence_WeaponDamage(self.owner, self.cnt);
+ self.weapondamage_counter = time + 0.5; // TO BE CVARED
+ }
+}
+
+void Violence_WeaponDamage_SetRepeat(entity pl, float type)
+{
+ entity repeater;
+ repeater = spawn();
+ repeater.classname = "weapondamage_repeater";
+ repeater.owner = pl;
+ repeater.origin = pl.origin;
+ repeater.cnt = type;
+ repeater.lifetime = time + 3; // TO BE CVARED
+ repeater.think = Violence_WeaponDamage_DoRepeat;
+ repeater.nextthink = time;
+}