From: TimePath Date: Sat, 15 Aug 2015 08:01:42 +0000 (+1000) Subject: Convert more calls X-Git-Tag: xonotic-v0.8.2~2071^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7d2a5c5901e03528feac551445b1c2c67ca233ce;p=xonotic%2Fxonotic-data.pk3dir.git Convert more calls --- diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 540ad5ac7..07547f4fc 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -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 diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index d05f76c40..b2080b76d 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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; diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index 1411ea339..41b74a0df 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -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); diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 49dbae90a..a20d35220 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -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; diff --git a/qcsrc/server/mutators/base.qh b/qcsrc/server/mutators/base.qh index 8e753140f..478a0b963 100644 --- a/qcsrc/server/mutators/base.qh +++ b/qcsrc/server/mutators/base.qh @@ -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