From a1e75a32dbbbcdcc08c5e90a3a19ec5b76377937 Mon Sep 17 00:00:00 2001 From: TimePath Date: Thu, 5 Nov 2015 09:57:37 +1100 Subject: [PATCH] Mutators: add hooks for overkill --- qcsrc/client/progs.inc | 1 + .../common/{mutators/mutator => }/casings.qc | 11 ++--- qcsrc/common/mutators/all.inc | 11 +++-- qcsrc/common/mutators/events.qh | 3 +- .../mutator/{ => damagetext}/damagetext.qc | 14 +++---- .../mutators/mutator/damagetext/module.inc | 1 + .../mutators/mutator/instagib/instagib.qc | 4 ++ .../mutators/mutator/instagib/module.inc | 1 + .../mutator/overkill}/hmg.qc | 8 ++++ .../mutators/mutator/overkill/module.inc | 6 +++ .../mutators/mutator/overkill/overkill.qc} | 24 +++++++++++ .../mutator/overkill}/rpc.qc | 0 .../mutators/mutator/waypoints/module.inc | 1 + qcsrc/common/weapons/all.inc | 2 - qcsrc/server/autocvars.qh | 10 ----- qcsrc/server/mutators/all.inc | 1 - qcsrc/server/mutators/events.qh | 28 ++++++++++--- .../server/mutators/mutator/mutator_nades.qc | 41 ++++++++++++------- qcsrc/server/progs.inc | 9 ++-- qcsrc/server/weapons/weaponsystem.qc | 13 +----- 20 files changed, 120 insertions(+), 69 deletions(-) rename qcsrc/common/{mutators/mutator => }/casings.qc (96%) rename qcsrc/common/mutators/mutator/{ => damagetext}/damagetext.qc (95%) create mode 100644 qcsrc/common/mutators/mutator/damagetext/module.inc create mode 100644 qcsrc/common/mutators/mutator/instagib/module.inc rename qcsrc/common/{weapons/weapon => mutators/mutator/overkill}/hmg.qc (96%) create mode 100644 qcsrc/common/mutators/mutator/overkill/module.inc rename qcsrc/{server/mutators/mutator/mutator_overkill.qc => common/mutators/mutator/overkill/overkill.qc} (94%) rename qcsrc/common/{weapons/weapon => mutators/mutator/overkill}/rpc.qc (100%) create mode 100644 qcsrc/common/mutators/mutator/waypoints/module.inc diff --git a/qcsrc/client/progs.inc b/qcsrc/client/progs.inc index 5c110e2b8..e3e8c00c0 100644 --- a/qcsrc/client/progs.inc +++ b/qcsrc/client/progs.inc @@ -33,6 +33,7 @@ #include "weapons/projectile.qc" // TODO #include "../common/animdecide.qc" +#include "../common/casings.qc" #include "../common/effects/effectinfo.qc" #include "../common/mapinfo.qc" #include "../common/movetypes/include.qc" diff --git a/qcsrc/common/mutators/mutator/casings.qc b/qcsrc/common/casings.qc similarity index 96% rename from qcsrc/common/mutators/mutator/casings.qc rename to qcsrc/common/casings.qc index 2ad32cf32..22046dd20 100644 --- a/qcsrc/common/mutators/mutator/casings.qc +++ b/qcsrc/common/casings.qc @@ -1,14 +1,10 @@ -#ifdef IMPLEMENTATION - -#include "../../util.qh" +#include "util.qh" #ifdef CSQC -#include "../../movetypes/movetypes.qh" -#include "../../../client/rubble.qh" +#include "movetypes/movetypes.qh" +#include "../client/rubble.qh" #endif -REGISTER_MUTATOR(casings, true); - REGISTER_NET_TEMP(casings) #ifdef SVQC @@ -177,4 +173,3 @@ NET_HANDLE(casings, bool isNew) } #endif -#endif diff --git a/qcsrc/common/mutators/all.inc b/qcsrc/common/mutators/all.inc index 6b19a0bc6..d3e63de45 100644 --- a/qcsrc/common/mutators/all.inc +++ b/qcsrc/common/mutators/all.inc @@ -1,5 +1,8 @@ -#include "mutator/casings.qc" -#include "mutator/damagetext.qc" -#include "mutator/instagib/instagib.qc" +#include "mutator/instagib/module.inc" #include "mutator/itemstime.qc" -#include "mutator/waypoints/waypointsprites.qc" +#include "mutator/waypoints/module.inc" + +// completely self contained + +#include "mutator/damagetext/module.inc" +#include "mutator/overkill/module.inc" diff --git a/qcsrc/common/mutators/events.qh b/qcsrc/common/mutators/events.qh index 7ba24fa7a..bb845b801 100644 --- a/qcsrc/common/mutators/events.qh +++ b/qcsrc/common/mutators/events.qh @@ -15,7 +15,8 @@ string ret_string; _(x, string) \ /**/ -#define MUTATOR_NEWGLOBAL(x, type) type mutator_argv_##type##_##x; +#define MUTATOR_ARGV(x, type) MUTATOR_ARGV_##x##_##type +#define MUTATOR_NEWGLOBAL(x, type) type MUTATOR_ARGV(x, type); MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 0) MUTATOR_TYPES(MUTATOR_NEWGLOBAL, 1) diff --git a/qcsrc/common/mutators/mutator/damagetext.qc b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc similarity index 95% rename from qcsrc/common/mutators/mutator/damagetext.qc rename to qcsrc/common/mutators/mutator/damagetext/damagetext.qc index ac451ca54..923ca3bcc 100644 --- a/qcsrc/common/mutators/mutator/damagetext.qc +++ b/qcsrc/common/mutators/mutator/damagetext/damagetext.qc @@ -2,7 +2,7 @@ #define MUTATOR_DAMAGETEXT_H #ifdef MENUQC -#include "../../../menu/xonotic/tab.qc" +#include "../../../../menu/xonotic/tab.qc" #endif #endif @@ -82,11 +82,11 @@ AUTOCVAR(sv_damagetext, int, 2, _("<= 0: disabled, >= 1: spectators, >= 2: playe #define SV_DAMAGETEXT_ALL() (autocvar_sv_damagetext >= 3 /* all players */) MUTATOR_HOOKFUNCTION(damagetext, PlayerDamaged) { if (SV_DAMAGETEXT_DISABLED()) return; - const entity attacker = mutator_argv_entity_0; - const entity hit = mutator_argv_entity_1; if (hit == attacker) return; - const int health = mutator_argv_int_0; - const int armor = mutator_argv_int_1; - const int deathtype = mutator_argv_int_2; + const entity attacker = MUTATOR_ARGV(0, entity); + const entity hit = MUTATOR_ARGV(1, entity); if (hit == attacker) return; + const int health = MUTATOR_ARGV(0, int); + const int armor = MUTATOR_ARGV(1, int); + const int deathtype = MUTATOR_ARGV(2, int); const vector location = hit.origin; entity e; FOR_EACH_REALCLIENT(e) if ( @@ -133,7 +133,7 @@ NET_HANDLE(damagetext, bool isNew) #ifdef MENUQC CLASS(XonoticDamageTextSettings, XonoticTab) - #include "../../../menu/gamesettings.qh" + #include "../../../../menu/gamesettings.qh" REGISTER_SETTINGS(damagetext, NEW(XonoticDamageTextSettings)); ATTRIB(XonoticDamageTextSettings, title, string, _("Damage text")) ATTRIB(XonoticDamageTextSettings, intendedWidth, float, 0.9) diff --git a/qcsrc/common/mutators/mutator/damagetext/module.inc b/qcsrc/common/mutators/mutator/damagetext/module.inc new file mode 100644 index 000000000..8e70be7c6 --- /dev/null +++ b/qcsrc/common/mutators/mutator/damagetext/module.inc @@ -0,0 +1 @@ +#include "damagetext.qc" diff --git a/qcsrc/common/mutators/mutator/instagib/instagib.qc b/qcsrc/common/mutators/mutator/instagib/instagib.qc index 391302be0..16b5b86d1 100644 --- a/qcsrc/common/mutators/mutator/instagib/instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/instagib.qc @@ -8,6 +8,10 @@ #ifdef IMPLEMENTATION #ifdef SVQC +int autocvar_g_instagib_ammo_drop; +int autocvar_g_instagib_extralives; +float autocvar_g_instagib_speed_highspeed; + #include "../../../../server/cl_client.qh" #include "../../../buffs/all.qh" diff --git a/qcsrc/common/mutators/mutator/instagib/module.inc b/qcsrc/common/mutators/mutator/instagib/module.inc new file mode 100644 index 000000000..7270067d3 --- /dev/null +++ b/qcsrc/common/mutators/mutator/instagib/module.inc @@ -0,0 +1 @@ +#include "instagib.qc" diff --git a/qcsrc/common/weapons/weapon/hmg.qc b/qcsrc/common/mutators/mutator/overkill/hmg.qc similarity index 96% rename from qcsrc/common/weapons/weapon/hmg.qc rename to qcsrc/common/mutators/mutator/overkill/hmg.qc index d701870ec..7f2341fb0 100644 --- a/qcsrc/common/weapons/weapon/hmg.qc +++ b/qcsrc/common/mutators/mutator/overkill/hmg.qc @@ -43,6 +43,14 @@ HMG_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP) #ifdef IMPLEMENTATION #ifdef SVQC +REGISTER_MUTATOR(hmg_nadesupport, true); +MUTATOR_HOOKFUNCTION(hmg_nadesupport, Nade_Damage) +{ + if (MUTATOR_ARGV(0, entity) != WEP_HMG) return; + return = true; + MUTATOR_ARGV(0, float) /* damage */ = self.max_health * 0.1; +} + spawnfunc(weapon_hmg) { weapon_defaultspawnfunc(this, WEP_HMG); } void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int fire) diff --git a/qcsrc/common/mutators/mutator/overkill/module.inc b/qcsrc/common/mutators/mutator/overkill/module.inc new file mode 100644 index 000000000..a8bde27b5 --- /dev/null +++ b/qcsrc/common/mutators/mutator/overkill/module.inc @@ -0,0 +1,6 @@ +#include "hmg.qc" +#include "rpc.qc" + +#ifdef SVQC + #include "overkill.qc" +#endif diff --git a/qcsrc/server/mutators/mutator/mutator_overkill.qc b/qcsrc/common/mutators/mutator/overkill/overkill.qc similarity index 94% rename from qcsrc/server/mutators/mutator/mutator_overkill.qc rename to qcsrc/common/mutators/mutator/overkill/overkill.qc index a65efd53b..c146f1c1a 100644 --- a/qcsrc/server/mutators/mutator/mutator_overkill.qc +++ b/qcsrc/common/mutators/mutator/overkill/overkill.qc @@ -1,4 +1,12 @@ #ifdef IMPLEMENTATION +bool autocvar_g_overkill_powerups_replace; +float autocvar_g_overkill_superguns_respawn_time; +bool autocvar_g_overkill_100h_anyway; +bool autocvar_g_overkill_100a_anyway; +bool autocvar_g_overkill_ammo_charge; +float autocvar_g_overkill_ammo_charge_notice; +float autocvar_g_overkill_ammo_charge_limit; + .vector ok_deathloc; .float ok_spawnsys_timer; .float ok_lastwep; @@ -31,6 +39,22 @@ REGISTER_MUTATOR(ok, cvar("g_overkill") && !cvar("g_instagib") && !g_nexball && return false; } +MUTATOR_HOOKFUNCTION(ok, W_DecreaseAmmo) +{ + entity actor = MUTATOR_ARGV(0, entity); + if (actor.ok_use_ammocharge) + { + ok_DecreaseCharge(actor, actor.weapon); + return true; + } +} + +MUTATOR_HOOKFUNCTION(ok, W_Reload) +{ + entity actor = MUTATOR_ARGV(0, entity); + return actor.ok_use_ammocharge; +} + void W_Blaster_Attack(entity, float, float, float, float, float, float, float, float, float, float); spawnfunc(weapon_hmg); spawnfunc(weapon_rpc); diff --git a/qcsrc/common/weapons/weapon/rpc.qc b/qcsrc/common/mutators/mutator/overkill/rpc.qc similarity index 100% rename from qcsrc/common/weapons/weapon/rpc.qc rename to qcsrc/common/mutators/mutator/overkill/rpc.qc diff --git a/qcsrc/common/mutators/mutator/waypoints/module.inc b/qcsrc/common/mutators/mutator/waypoints/module.inc new file mode 100644 index 000000000..50bb5b4d6 --- /dev/null +++ b/qcsrc/common/mutators/mutator/waypoints/module.inc @@ -0,0 +1 @@ +#include "waypointsprites.qc" diff --git a/qcsrc/common/weapons/all.inc b/qcsrc/common/weapons/all.inc index fc89a0cd2..99c7225ac 100644 --- a/qcsrc/common/weapons/all.inc +++ b/qcsrc/common/weapons/all.inc @@ -25,5 +25,3 @@ #include "weapon/seeker.qc" #include "weapon/shockwave.qc" #include "weapon/arc.qc" -#include "weapon/hmg.qc" -#include "weapon/rpc.qc" diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 16f9898ad..d72617fac 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -236,9 +236,6 @@ float autocvar_g_maxpushtime; float autocvar_g_maxspeed; float autocvar_g_midair_shieldtime; #define autocvar_g_instagib cvar("g_instagib") -int autocvar_g_instagib_ammo_drop; -int autocvar_g_instagib_extralives; -float autocvar_g_instagib_speed_highspeed; float autocvar_g_instagib_invis_alpha; bool autocvar_g_instagib_damagedbycontents = true; bool autocvar_g_instagib_blaster_keepdamage = false; @@ -600,13 +597,6 @@ float autocvar_g_campcheck_damage; float autocvar_g_campcheck_distance; float autocvar_g_campcheck_interval; bool autocvar_g_jump_grunt; -bool autocvar_g_overkill_powerups_replace; -float autocvar_g_overkill_superguns_respawn_time; -bool autocvar_g_overkill_100h_anyway; -bool autocvar_g_overkill_100a_anyway; -bool autocvar_g_overkill_ammo_charge; -float autocvar_g_overkill_ammo_charge_notice; -float autocvar_g_overkill_ammo_charge_limit; float autocvar_g_spawn_near_teammate_distance; int autocvar_g_spawn_near_teammate_ignore_spawnpoint; float autocvar_g_spawn_near_teammate_ignore_spawnpoint_delay; diff --git a/qcsrc/server/mutators/all.inc b/qcsrc/server/mutators/all.inc index d1cd583b1..e12e9c58b 100644 --- a/qcsrc/server/mutators/all.inc +++ b/qcsrc/server/mutators/all.inc @@ -26,7 +26,6 @@ #include "mutator/mutator_nades.qc" #include "mutator/mutator_new_toys.qc" #include "mutator/mutator_nix.qc" -#include "mutator/mutator_overkill.qc" #include "mutator/mutator_physical_items.qc" #include "mutator/mutator_pinata.qc" #include "mutator/mutator_random_gravity.qc" diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 7bc65791c..9cd9045d5 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -337,15 +337,31 @@ MUTATOR_HOOKABLE(PlayerDamage_Calculate, EV_PlayerDamage_Calculate); * Called when a player is damaged */ #define EV_PlayerDamaged(i, o) \ - /** attacker */ i(entity, mutator_argv_entity_0) \ - /** target */ i(entity, mutator_argv_entity_1) \ - /** health */ i(int, mutator_argv_int_0) \ - /** armor */ i(int, mutator_argv_int_1) \ - /** location */ i(vector, mutator_argv_vector_0) \ - /** deathtype */ i(int, mutator_argv_int_2) \ + /** attacker */ i(entity, MUTATOR_ARGV_0_entity) \ + /** target */ i(entity, MUTATOR_ARGV_1_entity) \ + /** health */ i(int, MUTATOR_ARGV_0_int) \ + /** armor */ i(int, MUTATOR_ARGV_1_int) \ + /** location */ i(vector, MUTATOR_ARGV_0_vector) \ + /** deathtype */ i(int, MUTATOR_ARGV_2_int) \ /**/ MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged); +/** + * Called by W_DecreaseAmmo + */ +#define EV_W_DecreaseAmmo(i, o) \ + /** actor */ i(entity, MUTATOR_ARGV_0_entity) \ + /**/ +MUTATOR_HOOKABLE(W_DecreaseAmmo, EV_W_DecreaseAmmo); + +/** + * Called by W_Reload + */ +#define EV_W_Reload(i, o) \ + /** actor */ i(entity, MUTATOR_ARGV_0_entity) \ + /**/ +MUTATOR_HOOKABLE(W_Reload, EV_W_Reload); + /** called at the end of player_powerups() in cl_client.qc, used for manipulating the values which are set by powerup items. */ #define EV_PlayerPowerups(i, o) \ /**/ i(entity, __self) \ diff --git a/qcsrc/server/mutators/mutator/mutator_nades.qc b/qcsrc/server/mutators/mutator/mutator_nades.qc index cdca4c485..9cfc2ec41 100644 --- a/qcsrc/server/mutators/mutator/mutator_nades.qc +++ b/qcsrc/server/mutators/mutator/mutator_nades.qc @@ -26,6 +26,18 @@ void(entity player, float score) nades_GiveBonus; // Remove all bonus nades from a player void(entity player) nades_RemoveBonus; +/** + * called to adjust nade damage and force on hit + */ +#define EV_Nade_Damage(i, o) \ + /** weapon */ i(entity, MUTATOR_ARGV_0_entity) \ + /** force */ i(vector, MUTATOR_ARGV_0_vector) \ + /**/ o(vector, MUTATOR_ARGV_0_vector) \ + /** damage */ i(float, MUTATOR_ARGV_0_float) \ + /**/ o(float, MUTATOR_ARGV_0_float) \ + /**/ +MUTATOR_HOOKABLE(Nade_Damage, EV_Nade_Damage); + #endif #ifdef IMPLEMENTATION @@ -630,35 +642,34 @@ void nade_damage(entity inflictor, entity attacker, float damage, int deathtype, if(self.nade_type == NADE_TYPE_TRANSLOCATE.m_id || self.nade_type == NADE_TYPE_SPAWN.m_id) return; - if(DEATH_ISWEAPON(deathtype, WEP_BLASTER)) + if (MUTATOR_CALLHOOK(Nade_Damage, DEATH_WEAPONOF(deathtype), force, damage)) {} + else if(DEATH_ISWEAPON(deathtype, WEP_BLASTER)) { force *= 1.5; damage = 0; } - - if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY)) + else if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER) && (deathtype & HITTYPE_SECONDARY)) { force *= 0.5; // too much - frag_damage = 0; + damage = 0; } - - if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER)) + else if(DEATH_ISWEAPON(deathtype, WEP_VORTEX) || DEATH_ISWEAPON(deathtype, WEP_VAPORIZER)) { force *= 6; damage = self.max_health * 0.55; } - - if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN) || DEATH_ISWEAPON(deathtype, WEP_HMG)) + else if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN)) damage = self.max_health * 0.1; - - if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO - if(deathtype & HITTYPE_SECONDARY) + else if(DEATH_ISWEAPON(deathtype, WEP_SHOCKWAVE) || DEATH_ISWEAPON(deathtype, WEP_SHOTGUN)) // WEAPONTODO { - damage = self.max_health * 0.1; - force *= 10; + if(deathtype & HITTYPE_SECONDARY) + { + damage = self.max_health * 0.1; + force *= 10; + } + else + damage = self.max_health * 1.15; } - else - damage = self.max_health * 1.15; self.velocity += force; UpdateCSQCProjectile(self); diff --git a/qcsrc/server/progs.inc b/qcsrc/server/progs.inc index ab94c42bd..b51ae73a6 100644 --- a/qcsrc/server/progs.inc +++ b/qcsrc/server/progs.inc @@ -61,20 +61,21 @@ #include "../common/animdecide.qc" #include "../common/campaign_file.qc" #include "../common/campaign_setup.qc" +#include "../common/casings.qc" #include "../common/effects/effectinfo.qc" #include "../common/mapinfo.qc" -#include "../common/monsters/spawn.qc" -#include "../common/monsters/sv_monsters.qc" #include "../common/minigames/minigames.qc" #include "../common/minigames/sv_minigames.qc" +#include "../common/monsters/spawn.qc" +#include "../common/monsters/sv_monsters.qc" #include "../common/movetypes/include.qc" #include "../common/net_notice.qc" #include "../common/notifications.qc" #include "../common/physics.qc" #include "../common/playerstats.qc" -#include "../common/viewloc.qc" #include "../common/triggers/include.qc" #include "../common/util.qc" +#include "../common/viewloc.qc" #include "../common/deathtypes/all.qc" #include "../common/buffs/all.qc" @@ -82,11 +83,11 @@ #include "../common/gamemodes/all.qc" #include "../common/items/all.qc" #include "../common/monsters/all.qc" -#include "../common/mutators/all.qc" #include "../common/nades/all.qc" #include "../common/turrets/all.qc" #include "../common/vehicles/all.qc" #include "../common/weapons/all.qc" +#include "../common/mutators/all.qc" #include "../common/turrets/sv_turrets.qc" #include "../common/turrets/config.qc" diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 132740eaa..3ea45ad46 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -905,14 +905,7 @@ void W_AttachToShotorg(entity actor, entity flash, vector offset) void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use) { - if (cvar("g_overkill")) - { - if (actor.ok_use_ammocharge) - { - ok_DecreaseCharge(actor, actor.weapon); - return; // TODO - } - } + if (MUTATOR_CALLHOOK(W_DecreaseAmmo, actor)) return; if ((actor.items & IT_UNLIMITED_WEAPON_AMMO) && !wep.reloading_ammo) return; @@ -982,9 +975,7 @@ void W_Reload(entity actor, float sent_ammo_min, string sent_sound) // set global values to work with entity e = Weapons_from(actor.weapon); - if (cvar("g_overkill")) - if (actor.ok_use_ammocharge) return; - // TODO + if (MUTATOR_CALLHOOK(W_Reload, actor)) return; actor.reload_ammo_min = sent_ammo_min; actor.reload_ammo_amount = e.reloading_ammo; -- 2.39.2