move g_vampire to the mutator system
authorRudolf Polzer <divverent@alientrap.org>
Wed, 10 Nov 2010 20:57:15 +0000 (21:57 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Wed, 10 Nov 2010 20:57:15 +0000 (21:57 +0100)
qcsrc/server/cl_player.qc
qcsrc/server/defs.qh
qcsrc/server/g_damage.qc
qcsrc/server/g_world.qc
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/base.qh
qcsrc/server/mutators/mutator_vampire.qc [new file with mode: 0644]
qcsrc/server/mutators/mutators.qh
qcsrc/server/progs.src
qcsrc/server/teamplay.qc

index 08a6384..a2943a7 100644 (file)
@@ -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)
index bf0f395..95fce0a 100644 (file)
@@ -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;
index 809df9e..460c608 100644 (file)
@@ -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)
index 2ca6e82..688b5e4 100644 (file)
@@ -710,10 +710,6 @@ void spawnfunc_worldspawn (void)
                        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");
        }
index 2a601ce..1d373c9 100644 (file)
@@ -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");
index cdc28f7..fdfbdfb 100644 (file)
@@ -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 (file)
index 0000000..dbaa654
--- /dev/null
@@ -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;
+}
index 91d2ea5..542014e 100644 (file)
@@ -3,3 +3,4 @@ MUTATOR_DECLARATION(gamemode_keyhunt);
 MUTATOR_DECLARATION(mutator_nix);
 MUTATOR_DECLARATION(mutator_dodging);
 MUTATOR_DECLARATION(mutator_rocketflying);
+MUTATOR_DECLARATION(mutator_vampire);
index 1443317..c2718d4 100644 (file)
@@ -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
index a83b927..13680e6 100644 (file)
@@ -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)