From 0a7be57387707934a449fd7e787a565cbff3be02 Mon Sep 17 00:00:00 2001 From: TimePath Date: Fri, 6 Nov 2015 08:32:58 +1100 Subject: [PATCH] Damageeffects: move to qc effects --- qcsrc/client/damage.qh | 6 -- qcsrc/client/main.qc | 1 - qcsrc/client/progs.inc | 1 - qcsrc/common/constants.qh | 1 - qcsrc/common/effects/qc/all.inc | 1 + .../effects/qc/damageeffects.qc} | 72 +++++++++++++++++-- .../vehicles/vehicle/bumblebee_weapons.qc | 5 +- qcsrc/server/g_damage.qc | 40 ----------- 8 files changed, 71 insertions(+), 56 deletions(-) delete mode 100644 qcsrc/client/damage.qh rename qcsrc/{client/damage.qc => common/effects/qc/damageeffects.qc} (87%) diff --git a/qcsrc/client/damage.qh b/qcsrc/client/damage.qh deleted file mode 100644 index 8cbdf81e2..000000000 --- a/qcsrc/client/damage.qh +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef CLIENT_DAMAGE_H -#define CLIENT_DAMAGE_H - -.float total_damages; // number of effects which currently are attached to a player - -#endif diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index d205284c7..16b6d9570 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -1,6 +1,5 @@ #include "main.qh" -#include "damage.qh" #include "../common/effects/qc/all.qh" #include "hook.qh" #include "hud/all.qh" diff --git a/qcsrc/client/progs.inc b/qcsrc/client/progs.inc index 84e596c94..83f387b6d 100644 --- a/qcsrc/client/progs.inc +++ b/qcsrc/client/progs.inc @@ -6,7 +6,6 @@ #include "announcer.qc" #include "bgmscript.qc" #include "csqcmodel_hooks.qc" -#include "damage.qc" #include "hook.qc" #include "hud/all.qc" #include "main.qc" diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 703b271aa..58f41bcdd 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -67,7 +67,6 @@ REGISTER_NET_LINKED(ENT_CLIENT_LASER) REGISTER_NET_LINKED(ENT_CLIENT_NAGGER) // flags [votecalledvote] REGISTER_NET_LINKED(ENT_CLIENT_RADARLINK) // flags [startorigin] [endorigin] [startcolor+16*endcolor] REGISTER_NET_LINKED(ENT_CLIENT_PROJECTILE) -REGISTER_NET_LINKED(ENT_CLIENT_DAMAGEINFO) REGISTER_NET_LINKED(ENT_CLIENT_INIT) REGISTER_NET_LINKED(ENT_CLIENT_MAPVOTE) REGISTER_NET_LINKED(ENT_CLIENT_CLIENTDATA) diff --git a/qcsrc/common/effects/qc/all.inc b/qcsrc/common/effects/qc/all.inc index 33aa1ccb8..16fc20169 100644 --- a/qcsrc/common/effects/qc/all.inc +++ b/qcsrc/common/effects/qc/all.inc @@ -1,3 +1,4 @@ #include "casings.qc" +#include "damageeffects.qc" #include "gibs.qc" #include "lightningarc.qc" diff --git a/qcsrc/client/damage.qc b/qcsrc/common/effects/qc/damageeffects.qc similarity index 87% rename from qcsrc/client/damage.qc rename to qcsrc/common/effects/qc/damageeffects.qc index fe99d507b..6cf7c1992 100644 --- a/qcsrc/client/damage.qc +++ b/qcsrc/common/effects/qc/damageeffects.qc @@ -1,9 +1,67 @@ -#include "damage.qh" +#ifndef DAMAGEEFFECTS_H +#define DAMAGEEFFECTS_H -#include "../common/deathtypes/all.qh" -#include "../common/movetypes/movetypes.qh" -#include "../common/vehicles/all.qh" -#include "../common/weapons/all.qh" +#ifdef CSQC +#include "../../deathtypes/all.qh" +#include "../../movetypes/movetypes.qh" +#include "../../vehicles/all.qh" +#include "../../weapons/all.qh" +#endif + +#endif + +#ifdef IMPLEMENTATION + +REGISTER_NET_LINKED(ENT_CLIENT_DAMAGEINFO) + +#ifdef SVQC + +bool Damage_DamageInfo_SendEntity(entity this, entity to, int sf) +{ + WriteHeader(MSG_ENTITY, ENT_CLIENT_DAMAGEINFO); + WriteShort(MSG_ENTITY, self.projectiledeathtype); + WriteCoord(MSG_ENTITY, floor(self.origin.x)); + WriteCoord(MSG_ENTITY, floor(self.origin.y)); + WriteCoord(MSG_ENTITY, floor(self.origin.z)); + WriteByte(MSG_ENTITY, bound(1, self.dmg, 255)); + WriteByte(MSG_ENTITY, bound(0, self.dmg_radius, 255)); + WriteByte(MSG_ENTITY, bound(1, self.dmg_edge, 255)); + WriteShort(MSG_ENTITY, self.oldorigin.x); + WriteByte(MSG_ENTITY, self.species); + return true; +} + +void Damage_DamageInfo(vector org, float coredamage, float edgedamage, float rad, vector force, int deathtype, float bloodtype, entity dmgowner) +{ + // TODO maybe call this from non-edgedamage too? + // TODO maybe make the client do the particle effects for the weapons and the impact sounds using this info? + + entity e; + + if(!sound_allowed(MSG_BROADCAST, dmgowner)) + deathtype |= 0x8000; + + e = new(damageinfo); + make_pure(e); + setorigin(e, org); + e.projectiledeathtype = deathtype; + e.dmg = coredamage; + e.dmg_edge = edgedamage; + e.dmg_radius = rad; + e.dmg_force = vlen(force); + e.velocity = force; + e.oldorigin_x = compressShortVector(e.velocity); + e.species = bloodtype; + + Net_LinkEntity(e, false, 0.2, Damage_DamageInfo_SendEntity); +} + +#endif + +#ifdef CSQC + +/** number of effects which currently are attached to a player */ +.int total_damages; .entity tag_entity; @@ -370,3 +428,7 @@ NET_HANDLE(ENT_CLIENT_DAMAGEINFO, bool isNew) } } } + +#endif + +#endif diff --git a/qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc b/qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc index 5be36a48a..a5bb23e63 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc +++ b/qcsrc/common/vehicles/vehicle/bumblebee_weapons.qc @@ -102,6 +102,7 @@ NET_HANDLE(ENT_CLIENT_BUMBLE_RAYGUN, bool isnew) return true; } +.float bumble_raygun_nextdraw; void bumble_raygun_draw(entity this) { float _len; @@ -111,11 +112,11 @@ void bumble_raygun_draw(entity this) _len = vlen(self.origin - self.move_origin); _dir = normalize(self.move_origin - self.origin); - if(self.total_damages < time) + if(self.bumble_raygun_nextdraw < time) { boxparticles(particleeffectnum(Effects_from(self.traileffect)), self, self.origin, self.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA); boxparticles(self.lip, self, self.move_origin, self.move_origin + _dir * -64, _dir * -200 , _dir * -200, 1, PARTICLES_USEALPHA); - self.total_damages = time + 0.1; + self.bumble_raygun_nextdraw = time + 0.1; } float i, df, sz, al; diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 343be952c..5d9436f68 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -24,46 +24,6 @@ #include "../lib/csqcmodel/sv_model.qh" #include "../lib/warpzone/common.qh" -bool Damage_DamageInfo_SendEntity(entity this, entity to, int sf) -{ - WriteHeader(MSG_ENTITY, ENT_CLIENT_DAMAGEINFO); - WriteShort(MSG_ENTITY, self.projectiledeathtype); - WriteCoord(MSG_ENTITY, floor(self.origin.x)); - WriteCoord(MSG_ENTITY, floor(self.origin.y)); - WriteCoord(MSG_ENTITY, floor(self.origin.z)); - WriteByte(MSG_ENTITY, bound(1, self.dmg, 255)); - WriteByte(MSG_ENTITY, bound(0, self.dmg_radius, 255)); - WriteByte(MSG_ENTITY, bound(1, self.dmg_edge, 255)); - WriteShort(MSG_ENTITY, self.oldorigin.x); - WriteByte(MSG_ENTITY, self.species); - return true; -} - -void Damage_DamageInfo(vector org, float coredamage, float edgedamage, float rad, vector force, int deathtype, float bloodtype, entity dmgowner) -{ - // TODO maybe call this from non-edgedamage too? - // TODO maybe make the client do the particle effects for the weapons and the impact sounds using this info? - - entity e; - - if(!sound_allowed(MSG_BROADCAST, dmgowner)) - deathtype |= 0x8000; - - e = new(damageinfo); - make_pure(e); - setorigin(e, org); - e.projectiledeathtype = deathtype; - e.dmg = coredamage; - e.dmg_edge = edgedamage; - e.dmg_radius = rad; - e.dmg_force = vlen(force); - e.velocity = force; - e.oldorigin_x = compressShortVector(e.velocity); - e.species = bloodtype; - - Net_LinkEntity(e, false, 0.2, Damage_DamageInfo_SendEntity); -} - void UpdateFrags(entity player, float f) { PlayerTeamScore_AddScore(player, f); -- 2.39.2