]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Convert more calls
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 15 Aug 2015 08:01:42 +0000 (18:01 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 15 Aug 2015 08:01:42 +0000 (18:01 +1000)
qcsrc/common/monsters/sv_monsters.qc
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc
qcsrc/server/g_damage.qc
qcsrc/server/mutators/base.qh

index 540ad5ac75509c682edaee7f9c3b28a3c3fb1133..07547f4fc28bb38ccbca29cb49aa9ecfe19583f0 100644 (file)
@@ -40,8 +40,7 @@ void monster_dropitem()
 
        e.monster_loot = self.monster_loot;
 
-       other = e;
-       MUTATOR_CALLHOOK(MonsterDropItem);
+       MUTATOR_CALLHOOK(MonsterDropItem, e);
        e = other;
 
        if(e && e.monster_loot)
@@ -370,7 +369,7 @@ float Monster_CanRespawn(entity ent)
 {
        other = ent;
        if(ent.deadflag == DEAD_DEAD) // don't call when monster isn't dead
-       if(MUTATOR_CALLHOOK(MonsterRespawn))
+       if(MUTATOR_CALLHOOK(MonsterRespawn, ent))
                return true; // enabled by a mutator
 
        if(ent.spawnflags & MONSTERFLAG_NORESPAWN)
@@ -716,11 +715,13 @@ void monster_move(float runspeed, float walkspeed, float stopspeed, float manim_
 
        targ = self.goalentity;
 
-       monster_target = targ;
-       monster_speed_run = runspeed;
-       monster_speed_walk = walkspeed;
-
-       if(MUTATOR_CALLHOOK(MonsterMove) || gameover || self.draggedby != world || (round_handler_IsActive() && !round_handler_IsRoundStarted()) || time < game_starttime || (autocvar_g_campaign && !campaign_bots_may_start) || time < self.spawn_time)
+       if (MUTATOR_CALLHOOK(MonsterMove, runspeed, walkspeed, targ)
+               || gameover
+               || self.draggedby != world
+               || (round_handler_IsActive() && !round_handler_IsRoundStarted())
+               || time < game_starttime
+               || (autocvar_g_campaign && !campaign_bots_may_start)
+               || time < self.spawn_time)
        {
                runspeed = walkspeed = 0;
                if(time >= self.spawn_time)
@@ -729,7 +730,6 @@ void monster_move(float runspeed, float walkspeed, float stopspeed, float manim_
                return;
        }
 
-       targ = monster_target;
        runspeed = bound(0, monster_speed_run * Monster_SkillModifier(), runspeed * 2); // limit maxspeed to prevent craziness
        walkspeed = bound(0, monster_speed_walk * Monster_SkillModifier(), walkspeed * 2); // limit maxspeed to prevent craziness
 
index d05f76c401e1f18393a65fdeb609acb5a44f803f..b2080b76d2b72cf57c873379bc2f937548507b01 100644 (file)
@@ -1462,7 +1462,7 @@ void play_countdown(float finished, string samp)
 void player_powerups (void)
 {
        // add a way to see what the items were BEFORE all of these checks for the mutator hook
-       olditems = self.items;
+       int items_prev = self.items;
 
        if((self.items & IT_USING_JETPACK) && !self.deadflag && !gameover)
                self.modelflags |= MF_ROCKET;
@@ -1574,7 +1574,7 @@ void player_powerups (void)
        if (time < self.spawnshieldtime)
                self.effects = self.effects | (EF_ADDITIVE | EF_FULLBRIGHT);
 
-       MUTATOR_CALLHOOK(PlayerPowerups);
+       MUTATOR_CALLHOOK(PlayerPowerups, self, items_prev);
 }
 
 float CalcRegen(float current, float stable, float regenfactor, float regenframetime)
@@ -1626,11 +1626,7 @@ void player_regen (void)
 {
        float max_mod, regen_mod, rot_mod, limit_mod;
        max_mod = regen_mod = rot_mod = limit_mod = 1;
-       regen_mod_max = max_mod;
-       regen_mod_regen = regen_mod;
-       regen_mod_rot = rot_mod;
-       regen_mod_limit = limit_mod;
-       if(!MUTATOR_CALLHOOK(PlayerRegen))
+       if(!MUTATOR_CALLHOOK(PlayerRegen, max_mod, regen_mod, rot_mod, limit_mod))
        if(!self.frozen)
        {
                float minh, mina, maxh, maxa, limith, limita;
index 1411ea3393226090d8fe44a1136f49507e79ce2a..41b74a0df4e89721ef6a51b9e38710ab86b5ec32 100644 (file)
@@ -385,14 +385,8 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, int deathtyp
                self.istypefrag = 0;
        }
 
-       frag_inflictor = inflictor;
-       frag_attacker = attacker;
-       frag_target = self;
        frag_damage = damage;
-       damage_take = take;
-       damage_save = save;
-       damage_force = force;
-       MUTATOR_CALLHOOK(PlayerDamage_SplitHealthArmor);
+       MUTATOR_CALLHOOK(PlayerDamage_SplitHealthArmor, inflictor, attacker, self, force, take, save);
        take = bound(0, damage_take, self.health);
        save = bound(0, damage_save, self.armorvalue);
        excess = max(0, damage - take - save);
index 49dbae90a8adc7c3fcf8e63b859f82cbdac9c77e..a20d35220ae08c703c8afa7f317ee0b058d9f921 100644 (file)
@@ -746,13 +746,7 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
                }
 
                // should this be changed at all? If so, in what way?
-               frag_attacker = attacker;
-               frag_target = targ;
-               frag_damage = damage;
-               frag_force = force;
-               frag_deathtype = deathtype;
-               frag_mirrordamage = mirrordamage;
-               MUTATOR_CALLHOOK(PlayerDamage_Calculate);
+               MUTATOR_CALLHOOK(PlayerDamage_Calculate, attacker, targ, deathtype, damage, mirrordamage, force);
                damage = frag_damage;
                mirrordamage = frag_mirrordamage;
                force = frag_force;
index 8e753140fc508a6f7614f2c6e15c5d721d395a4c..478a0b9636f8fe3a261f9ea9b3c6665532daf47d 100644 (file)
@@ -264,72 +264,111 @@ MUTATOR_HOOKABLE(MonsterSpawn, EV_NO_ARGS);
     /**/
 MUTATOR_HOOKABLE(MonsterDies, EV_MonsterDies);
 
-MUTATOR_HOOKABLE(MonsterRespawn, EV_NO_ARGS);
-       // called when a monster wants to respawn
-       // INPUT:
-//             entity other;
-
-MUTATOR_HOOKABLE(MonsterDropItem, EV_NO_ARGS);
-       // called when a monster is dropping loot
-       // INPUT, OUTPUT:
-               .void() monster_loot;
-//             entity other;
-
-MUTATOR_HOOKABLE(MonsterMove, EV_NO_ARGS);
-       // called when a monster moves
-       // returning true makes the monster stop
-       // INPUT:
-               float monster_speed_run;
-               float monster_speed_walk;
-               entity monster_target;
+/** called when a monster wants to respawn */
+#define EV_MonsterRespawn(i, o) \
+    /**/ i(entity, other) \
+    /**/
+MUTATOR_HOOKABLE(MonsterRespawn, EV_MonsterRespawn);
+
+/** called when a monster is dropping loot */
+#define EV_MonsterDropItem(i, o) \
+    /**/ i(entity, other) \
+    /**/ o(entity, other) \
+    /**/
+.void() monster_loot;
+MUTATOR_HOOKABLE(MonsterDropItem, EV_MonsterDropItem);
+
+/**
+ * called when a monster moves
+ * returning true makes the monster stop
+ */
+#define EV_MonsterMove(i, o) \
+    /**/ i(float, monster_speed_run) \
+    /**/ o(float, monster_speed_run) \
+    /**/ i(float, monster_speed_walk) \
+    /**/ o(float, monster_speed_walk) \
+    /**/ i(entity, monster_target) \
+    /**/
+float monster_speed_run;
+float monster_speed_walk;
+entity monster_target;
+MUTATOR_HOOKABLE(MonsterMove, EV_MonsterMove);
 
+/** called when a monster looks for another target */
 MUTATOR_HOOKABLE(MonsterFindTarget, EV_NO_ARGS);
-       // called when a monster looks for another target
 
+/** called to change a random monster to a miniboss */
 MUTATOR_HOOKABLE(MonsterCheckBossFlag, EV_NO_ARGS);
-    // called to change a random monster to a miniboss
 
+/**
+ * called when a player tries to spawn a monster
+ * return 1 to prevent spawning
+ */
 MUTATOR_HOOKABLE(AllowMobSpawning, EV_NO_ARGS);
-       // called when a player tries to spawn a monster
-       // return 1 to prevent spawning
-
-MUTATOR_HOOKABLE(PlayerDamage_SplitHealthArmor, EV_NO_ARGS);
-       // 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
-       // INPUT, OUTPUT:
-               float damage_take;
-               float damage_save;
-
-MUTATOR_HOOKABLE(PlayerDamage_Calculate, EV_NO_ARGS);
-       // called to adjust damage and force values which are applied to the player, used for e.g. strength damage/force multiplier
-       // i'm not sure if I should change this around slightly (Naming of the entities, and also how they're done in g_damage).
-       // INPUT:
-//             entity frag_attacker;
-//             entity frag_target;
-//             float frag_deathtype;
-       // INPUT, OUTPUT:
-               float frag_damage;
-               float frag_mirrordamage;
-               vector frag_force;
-
-MUTATOR_HOOKABLE(PlayerPowerups, EV_NO_ARGS);
-       // called at the end of player_powerups() in cl_client.qc, used for manipulating the values which are set by powerup items.
-       // INPUT
-//     entity self;
-       int olditems; // also technically output, but since it is at the end of the function it's useless for that :P
-
-MUTATOR_HOOKABLE(PlayerRegen, EV_NO_ARGS);
-       // called every player think frame
-       // return 1 to disable regen
-       // INPUT, OUTPUT:
-               float regen_mod_max;
-               float regen_mod_regen;
-               float regen_mod_rot;
-               float regen_mod_limit;
+
+/** called when a player gets damaged to e.g. remove stuff he was carrying. */
+#define EV_PlayerDamage_SplitHealthArmor(i, o) \
+    /**/ i(entity, frag_inflictor) \
+    /**/ i(entity, frag_attacker) \
+    /** same as self */ i(entity, frag_target) \
+    /** NOTE: this force already HAS been applied */ i(vector, damage_force) \
+    /**/ i(float, damage_take) \
+    /**/ o(float, damage_take) \
+       /**/ i(float, damage_save) \
+    /**/ o(float, damage_save) \
+    /**/
+vector damage_force;
+float damage_take;
+float damage_save;
+MUTATOR_HOOKABLE(PlayerDamage_SplitHealthArmor, EV_PlayerDamage_SplitHealthArmor);
+
+/**
+ * called to adjust damage and force values which are applied to the player, used for e.g. strength damage/force multiplier
+ * i'm not sure if I should change this around slightly (Naming of the entities, and also how they're done in g_damage).
+ */
+#define EV_PlayerDamage_Calculate(i, o) \
+    /**/ i(entity, frag_attacker) \
+    /**/ i(entity, frag_target) \
+    /**/ i(float, frag_deathtype) \
+       /**/ i(float, frag_damage) \
+    /**/ o(float, frag_damage) \
+       /**/ i(float, frag_mirrordamage) \
+    /**/ o(float, frag_mirrordamage) \
+    /**/ i(vector, frag_force) \
+    /**/ o(vector, frag_force) \
+    /**/
+float frag_damage;
+float frag_mirrordamage;
+vector frag_force;
+MUTATOR_HOOKABLE(PlayerDamage_Calculate, EV_PlayerDamage_Calculate);
+
+/** 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) \
+    /**/ i(int, olditems) \
+    /**/
+int olditems;
+MUTATOR_HOOKABLE(PlayerPowerups, EV_PlayerPowerups);
+
+/**
+ * called every player think frame
+ * return 1 to disable regen
+ */
+#define EV_PlayerRegen(i, o) \
+    /**/ i(float, regen_mod_max) \
+    /**/ o(float, regen_mod_max) \
+    /**/ i(float, regen_mod_regen) \
+    /**/ o(float, regen_mod_regen) \
+    /**/ i(float, regen_mod_rot) \
+    /**/ o(float, regen_mod_rot) \
+    /**/ i(float, regen_mod_limit) \
+    /**/ o(float, regen_mod_limit) \
+    /**/
+float regen_mod_max;
+float regen_mod_regen;
+float regen_mod_rot;
+float regen_mod_limit;
+MUTATOR_HOOKABLE(PlayerRegen, EV_PlayerRegen);
 
 MUTATOR_HOOKABLE(PlayerUseKey, EV_NO_ARGS);
        // called when the use key is pressed