]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
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 08a6384099e3373aae021dc78c8cf21b701229b6..a2943a76053e61e6e873e951594bfa7bd1898feb 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 bf0f395b84b1978441095f80d943485178a8bb36..95fce0ade3b7a284ad646a88e56001f55ab4a6b4 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 809df9ecbd892b5d6037f4cb5b07670818a3ba27..460c608dcf357d944829978620b3e21247f61724 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 2ca6e82330c1341eb41e5021a6b6dcddaa3dc5b2..688b5e416f881b55b7507d7d62a892bd1adda9a7 100644 (file)
@@ -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");
        }
index 2a601cefa23319a860b83f379778ae75da87471e..1d373c97327d2271ede7e7b6e184fb881758e5d2 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 cdc28f76bf426a44a4acace7da91b2a6396a807c..fdfbdfb1223d2c3bfc9111b584c85ce2decc368d 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 91d2ea5be78c915997474f7fc24c851310bac36c..542014e8691275dfe11870f8d97118036f5f846e 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 1443317181bce327261646dc82f259619ae091f1..c2718d4e8642d69e006bc84400a4ff442d235b39 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 a83b927c353a4e22a3e7dd650d75f21053a2f90c..13680e68a8a2719c32ad396fbdef8ef692899e68 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)