From: Mario Date: Mon, 13 Mar 2017 20:53:07 +0000 (+1000) Subject: Add an option to always show item re-spawn waypoints in overkill X-Git-Tag: xonotic-v0.8.2~60 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2aec8af0d6bca64877f1c135912099020723e3cb;p=xonotic%2Fxonotic-data.pk3dir.git Add an option to always show item re-spawn waypoints in overkill --- diff --git a/mutators.cfg b/mutators.cfg index f61930852..229fd3a6d 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -51,6 +51,7 @@ set g_instagib_friendlypush 1 "allow pushing teammates with the vaporizer primar set g_overkill 0 "enable overkill" set g_overkill_powerups_replace 1 +set g_overkill_itemwaypoints 1 set g_overkill_filter_healthmega 0 set g_overkill_filter_armormedium 0 set g_overkill_filter_armorbig 0 diff --git a/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc b/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc index 5d938f3fd..82df487c5 100644 --- a/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc +++ b/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc @@ -5,6 +5,8 @@ bool autocvar_g_overkill_powerups_replace; +bool autocvar_g_overkill_itemwaypoints = true; + bool autocvar_g_overkill_filter_healthmega; bool autocvar_g_overkill_filter_armormedium; bool autocvar_g_overkill_filter_armorbig; @@ -223,6 +225,34 @@ MUTATOR_HOOKFUNCTION(ok, OnEntityPreSpawn) } } +bool ok_HandleItemWaypoints(entity e) +{ + if(!autocvar_g_overkill_itemwaypoints) + return false; // don't handle it + + switch(e.itemdef) + { + case ITEM_HealthMega: return true; + case ITEM_ArmorMedium: return true; + case ITEM_ArmorBig: return true; + case ITEM_ArmorMega: return true; + } + + return false; +} + +MUTATOR_HOOKFUNCTION(ok, Item_RespawnCountdown) +{ + entity item = M_ARGV(0, entity); + return ok_HandleItemWaypoints(item); +} + +MUTATOR_HOOKFUNCTION(ok, Item_ScheduleRespawn) +{ + entity item = M_ARGV(0, entity); + return ok_HandleItemWaypoints(item); +} + MUTATOR_HOOKFUNCTION(ok, FilterItem) { entity item = M_ARGV(0, entity); diff --git a/qcsrc/common/t_items.qc b/qcsrc/common/t_items.qc index 19e404a1a..5490478ba 100644 --- a/qcsrc/common/t_items.qc +++ b/qcsrc/common/t_items.qc @@ -537,7 +537,6 @@ void Item_RespawnCountdown (entity this) this.count += 1; if(this.count == 1) { - MUTATOR_CALLHOOK(Item_RespawnCountdown, string_null, '0 0 0'); do { { entity wi = Weapons_from(this.weapon); @@ -556,10 +555,11 @@ void Item_RespawnCountdown (entity this) } } } while (0); + bool mutator_returnvalue = MUTATOR_CALLHOOK(Item_RespawnCountdown, this); if(this.waypointsprite_attached) { GameItem def = this.itemdef; - if (Item_ItemsTime_SpectatorOnly(def)) + if (Item_ItemsTime_SpectatorOnly(def) && !mutator_returnvalue) WaypointSprite_UpdateRule(this.waypointsprite_attached, 0, SPRITERULE_SPECTATOR); WaypointSprite_UpdateBuildFinished(this.waypointsprite_attached, time + ITEM_RESPAWN_TICKS); } @@ -594,15 +594,18 @@ void Item_RespawnThink(entity this) void Item_ScheduleRespawnIn(entity e, float t) { // if the respawn time is longer than 10 seconds, show a waypoint, otherwise, just respawn normally - if ((Item_ItemsTime_Allow(e.itemdef) || (e.weapons & WEPSET_SUPERWEAPONS)) && (t - ITEM_RESPAWN_TICKS) > 0) + if ((Item_ItemsTime_Allow(e.itemdef) || (e.weapons & WEPSET_SUPERWEAPONS) || MUTATOR_CALLHOOK(Item_ScheduleRespawn, e, t)) && (t - ITEM_RESPAWN_TICKS) > 0) { setthink(e, Item_RespawnCountdown); e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS); e.scheduledrespawntime = e.nextthink + ITEM_RESPAWN_TICKS; e.count = 0; - t = Item_ItemsTime_UpdateTime(e, e.scheduledrespawntime); - Item_ItemsTime_SetTime(e, t); - Item_ItemsTime_SetTimesForAllPlayers(); + if(Item_ItemsTime_Allow(e.itemdef) || (e.weapons & WEPSET_SUPERWEAPONS)) + { + t = Item_ItemsTime_UpdateTime(e, e.scheduledrespawntime); + Item_ItemsTime_SetTime(e, t); + Item_ItemsTime_SetTimesForAllPlayers(); + } } else { diff --git a/qcsrc/common/t_items.qh b/qcsrc/common/t_items.qh index 198bd0f41..1b2293bcf 100644 --- a/qcsrc/common/t_items.qh +++ b/qcsrc/common/t_items.qh @@ -63,9 +63,9 @@ bool have_pickup_item(entity this); const float ITEM_RESPAWN_TICKS = 10; -#define ITEM_RESPAWNTIME(i) ((i).respawntime + (crandom() * (i).respawntimejitter)) +#define ITEM_RESPAWNTIME(i) ((i).respawntime + crandom() * (i).respawntimejitter) // range: respawntime - respawntimejitter .. respawntime + respawntimejitter -#define ITEM_RESPAWNTIME_INITIAL(i) (ITEM_RESPAWN_TICKS + (random() * ((i).respawntime + (i).respawntimejitter - ITEM_RESPAWN_TICKS))) +#define ITEM_RESPAWNTIME_INITIAL(i) (ITEM_RESPAWN_TICKS + random() * ((i).respawntime + (i).respawntimejitter - ITEM_RESPAWN_TICKS)) // range: 10 .. respawntime + respawntimejitter .float max_armorvalue; diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 7523b3aac..b6d31c11a 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -532,10 +532,7 @@ MUTATOR_HOOKABLE(SetWeaponreplace, EV_SetWeaponreplace); /** called when an item is about to respawn */ #define EV_Item_RespawnCountdown(i, o) \ - /** item name */ i(string, MUTATOR_ARGV_0_string) \ - /**/ o(string, MUTATOR_ARGV_0_string) \ - /** item colour */ i(vector, MUTATOR_ARGV_1_vector) \ - /**/ o(vector, MUTATOR_ARGV_1_vector) \ + /** item */ i(entity, MUTATOR_ARGV_0_entity) \ /**/ MUTATOR_HOOKABLE(Item_RespawnCountdown, EV_Item_RespawnCountdown); @@ -948,3 +945,10 @@ enum { /** player */ i(entity, MUTATOR_ARGV_0_entity) \ /**/ MUTATOR_HOOKABLE(HideTeamNagger, EV_HideTeamNagger); + +/** return true to show a waypoint while the item is spawning */ +#define EV_Item_ScheduleRespawn(i, o) \ + /** item */ i(entity, MUTATOR_ARGV_0_entity) \ + /** respawn time */ i(float, MUTATOR_ARGV_1_float) \ + /**/ +MUTATOR_HOOKABLE(Item_ScheduleRespawn, EV_Item_ScheduleRespawn);