From 1ed06754bd71b432974e163c080c9dc6d1320d45 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 15 Mar 2017 07:52:24 +1000 Subject: [PATCH] Add a mutator hook to customize a bot's aim target --- qcsrc/server/bot/default/havocbot/havocbot.qc | 10 ++++------ qcsrc/server/mutators/events.qh | 6 ++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 038aea0f6..63a9577fc 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -1190,18 +1190,16 @@ void havocbot_chooseweapon(entity this, .entity weaponentity) void havocbot_aim(entity this) { - vector myvel, enemyvel; -// if(this.flags & FL_INWATER) -// return; if (time < this.nextaim) return; this.nextaim = time + 0.1; - myvel = this.velocity; + vector myvel = this.velocity; if (!this.waterlevel) myvel.z = 0; - if (this.enemy) + if(MUTATOR_CALLHOOK(HavocBot_Aim, this)) { /* do nothing */ } + else if (this.enemy) { - enemyvel = this.enemy.velocity; + vector enemyvel = this.enemy.velocity; if (!this.enemy.waterlevel) enemyvel.z = 0; lag_additem(this, time + this.ping, 0, 0, this.enemy, this.origin, myvel, (this.enemy.absmin + this.enemy.absmax) * 0.5, enemyvel); diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index a347aef39..89fec0178 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -958,3 +958,9 @@ MUTATOR_HOOKABLE(Item_ScheduleRespawn, EV_Item_ScheduleRespawn); /** player */ i(entity, MUTATOR_ARGV_0_entity) \ /**/ MUTATOR_HOOKABLE(PlayerPhysics_UpdateStats, EV_PlayerPhysics_UpdateStats); + +/** return true to use your own aim target (or none at all) */ +#define EV_HavocBot_Aim(i, o) \ + /** bot */ i(entity, MUTATOR_ARGV_0_entity) \ + /**/ +MUTATOR_HOOKABLE(HavocBot_Aim, EV_HavocBot_Aim); -- 2.39.2