From a63f5d0afcdd3c85742b92a4dbc99c324e4ddb6f Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Wed, 10 Nov 2010 21:57:15 +0100 Subject: [PATCH] move g_vampire to the mutator system --- qcsrc/server/cl_player.qc | 10 +++++++ qcsrc/server/defs.qh | 2 +- qcsrc/server/g_damage.qc | 7 ----- qcsrc/server/g_world.qc | 5 +--- qcsrc/server/miscfunctions.qc | 3 +- qcsrc/server/mutators/base.qh | 11 +++++++ qcsrc/server/mutators/mutator_vampire.qc | 37 ++++++++++++++++++++++++ qcsrc/server/mutators/mutators.qh | 1 + qcsrc/server/progs.src | 1 + qcsrc/server/teamplay.qc | 2 -- 10 files changed, 64 insertions(+), 15 deletions(-) create mode 100644 qcsrc/server/mutators/mutator_vampire.qc diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index 08a638409..a2943a760 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -449,6 +449,16 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht take = damage; } + frag_inflictor = inflictor; + frag_attacker = attacker; + frag_target = self; + damage_take = take; + damage_save = save; + damage_force = force; + MUTATOR_CALLHOOK(PlayerDamage); + take = bound(0, damage_take, self.health); + save = bound(0, damage_save, self.armorvalue); + if(sound_allowed(MSG_BROADCAST, attacker)) { if (save > 10) diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index bf0f395b8..95fce0ade 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -18,7 +18,7 @@ float require_spawnfunc_prefix; // if this float exists, only functions with spa float ctf_score_value(string parameter); float g_dm, g_domination, g_ctf, g_tdm, g_keyhunt, g_onslaught, g_assault, g_arena, g_ca, g_lms, g_runematch, g_race, g_nexball, g_cts; -float g_cloaked, g_footsteps, g_jump_grunt, g_grappling_hook, g_midair, g_minstagib, g_pinata, g_norecoil, g_vampire, g_minstagib_invis_alpha, g_bloodloss; +float g_cloaked, g_footsteps, g_jump_grunt, g_grappling_hook, g_midair, g_minstagib, g_pinata, g_norecoil, g_minstagib_invis_alpha, g_bloodloss; float g_warmup_limit; float g_warmup_allguns; float g_warmup_allow_timeout; diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 809df9ecb..460c608dc 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -789,13 +789,6 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, float if(targ.classname == "player" && attacker.classname == "player" && attacker != targ && attacker.health > 2) { - // Savage: vampire mode - if (g_vampire) - if (!g_minstagib) - if (time >= self.spawnshieldtime) - { - attacker.health += damage; - } if(g_runematch) { if (attacker.runes & RUNE_VAMPIRE) diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 2ca6e8233..688b5e416 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -709,10 +709,6 @@ void spawnfunc_worldspawn (void) if(cvar_string("g_weaponarena") != "0") s = strcat(s, ":", cvar_string("g_weaponarena"), " arena"); - // TODO to mutator system - if(cvar("g_vampire")) - s = strcat(s, ":vampire"); - // TODO to mutator system if(cvar("g_norecoil")) s = strcat(s, ":norecoil"); @@ -724,6 +720,7 @@ void spawnfunc_worldspawn (void) // TODO to mutator system if(cvar("g_minstagib")) s = strcat(s, ":minstagib"); + GameLogEcho(s); GameLogEcho(":gameinfo:end"); } diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 2a601cefa..1d373c973 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -1186,6 +1186,8 @@ void readlevelcvars(void) MUTATOR_ADD(mutator_dodging); if(cvar("g_rocket_flying")) MUTATOR_ADD(mutator_rocketflying); + if(cvar("g_vampire")) + MUTATOR_ADD(mutator_vampire); serverflags = 0; if(cvar("sv_allow_fullbright")) @@ -1233,7 +1235,6 @@ void readlevelcvars(void) g_midair = cvar("g_midair"); g_minstagib = cvar("g_minstagib"); g_norecoil = cvar("g_norecoil"); - g_vampire = cvar("g_vampire"); g_bloodloss = cvar("g_bloodloss"); sv_maxidle = cvar("sv_maxidle"); sv_maxidle_spectatorsareidle = cvar("sv_maxidle_spectatorsareidle"); diff --git a/qcsrc/server/mutators/base.qh b/qcsrc/server/mutators/base.qh index cdc28f76b..fdfbdfb12 100644 --- a/qcsrc/server/mutators/base.qh +++ b/qcsrc/server/mutators/base.qh @@ -118,3 +118,14 @@ MUTATOR_HOOKABLE(EditProjectile); // INPUT: entity self; entity other; + +MUTATOR_HOOKABLE(PlayerDamage); + // called when a player gets damaged to e.g. remove stuff he was carrying. + // INPUT: + entity frag_inflictor; + entity frag_attacker; + entity frag_target; // same as self + vector damage_force; // NOTE: this force already HAS been applied (create and use a Damage hook to change that one) + // INPUT, OUTPUT: + float damage_take; + float damage_save; diff --git a/qcsrc/server/mutators/mutator_vampire.qc b/qcsrc/server/mutators/mutator_vampire.qc new file mode 100644 index 000000000..dbaa654a9 --- /dev/null +++ b/qcsrc/server/mutators/mutator_vampire.qc @@ -0,0 +1,37 @@ +MUTATOR_HOOKFUNCTION(vampire_PlayerDamage) +{ + if(time < self.spawnshieldtime) + return 0; + if(g_minstagib) + { + // minstagib: each hit means +1 ammo + frag_attacker.ammo_cells += 1; + } + else + { + // otherwise: each hit gets damage back + frag_attacker.health += damage_take; + } + return 0; +} + +MUTATOR_HOOKFUNCTION(vampire_BuildMutatorsString) +{ + ret_string = strcat(ret_string, ":Vampire"); + return 0; +} + +MUTATOR_HOOKFUNCTION(vampire_BuildMutatorsPrettyString) +{ + ret_string = strcat(ret_string, ", Vampire"); + return 0; +} + +MUTATOR_DEFINITION(mutator_vampire) +{ + MUTATOR_HOOK(PlayerDamage, vampire_PlayerDamage, CBC_ORDER_ANY); + MUTATOR_HOOK(BuildMutatorsString, vampire_BuildMutatorsString, CBC_ORDER_ANY); + MUTATOR_HOOK(BuildMutatorsPrettyString, vampire_BuildMutatorsPrettyString, CBC_ORDER_ANY); + + return 0; +} diff --git a/qcsrc/server/mutators/mutators.qh b/qcsrc/server/mutators/mutators.qh index 91d2ea5be..542014e86 100644 --- a/qcsrc/server/mutators/mutators.qh +++ b/qcsrc/server/mutators/mutators.qh @@ -3,3 +3,4 @@ MUTATOR_DECLARATION(gamemode_keyhunt); MUTATOR_DECLARATION(mutator_nix); MUTATOR_DECLARATION(mutator_dodging); MUTATOR_DECLARATION(mutator_rocketflying); +MUTATOR_DECLARATION(mutator_vampire); diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index 144331718..c2718d4e8 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -180,6 +180,7 @@ mutators/gamemode_keyhunt.qc mutators/mutator_nix.qc mutators/mutator_dodging.qc mutators/mutator_rocketflying.qc +mutators/mutator_vampire.qc ../warpzonelib/anglestransform.qc ../warpzonelib/mathlib.qc diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index a83b927c3..13680e68a 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -514,8 +514,6 @@ void PrintWelcomeMessage(entity pl) modifications = strcat(modifications, ", Hook"); if(g_midair) modifications = strcat(modifications, ", Midair"); - if(g_vampire) - modifications = strcat(modifications, ", Vampire"); if(g_pinata) modifications = strcat(modifications, ", Pinata"); if(g_weapon_stay) -- 2.39.2