From 5d4a5c509120ce7a4bb70b940d648613c9bd460f Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 5 Feb 2018 13:27:09 +1000 Subject: [PATCH] Apply some general fixes and add an icon parameter to REGISTER_WAYPOINT --- defaultClient.cfg | 3 +- qcsrc/common/mutators/mutator/buffs/buffs.qh | 2 +- .../common/mutators/mutator/buffs/sv_buffs.qc | 24 +++-- .../common/mutators/mutator/waypoints/all.inc | 96 +++++++++---------- .../common/mutators/mutator/waypoints/all.qh | 8 +- .../mutator/waypoints/waypointsprites.qc | 6 +- .../mutator/waypoints/waypointsprites.qh | 3 +- 7 files changed, 76 insertions(+), 66 deletions(-) diff --git a/defaultClient.cfg b/defaultClient.cfg index 794ff4287..2d7eb360d 100644 --- a/defaultClient.cfg +++ b/defaultClient.cfg @@ -386,7 +386,8 @@ seta g_waypointsprite_turrets 1 "disable turret waypoints" seta g_waypointsprite_turrets_maxdist 5000 "max distance for turret waypoints" seta g_waypointsprite_uppercase 1 seta g_waypointsprite_text 0 "Always show text instead of icons, setting this to 0 will still use text if the icon is unavailable" -seta g_waypointsprite_iconsize 64 +seta g_waypointsprite_iconsize 32 +seta g_waypointsprite_iconcolor 0 "Show the icon at natural color rather than the waypoint's color" alias "g_waypointsprite_personal" "impulse 30" alias "g_waypointsprite_personal_p" "impulse 31" diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qh b/qcsrc/common/mutators/mutator/buffs/buffs.qh index 81a638ea7..963cf0015 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qh +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qh @@ -4,7 +4,7 @@ #include #ifdef GAMEQC -REGISTER_WAYPOINT(Buff, _("Buff"), '1 0.5 0', 1); +REGISTER_WAYPOINT(Buff, _("Buff"), "", '1 0.5 0', 1); REGISTER_RADARICON(Buff, 1); #endif diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index 6994c8176..d2755f10f 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -405,7 +405,7 @@ void buff_SpawnReplacement(entity ent, entity old) { setorigin(ent, old.origin); ent.angles = old.angles; - ent.noalign = (old.noalign || (old.spawnflags & 1)); + ent.noalign = Item_ShouldKeepPosition(old); buff_Init(ent); } @@ -739,24 +739,28 @@ MUTATOR_HOOKFUNCTION(buffs, CustomizeWaypoint) return true; } -MUTATOR_HOOKFUNCTION(buffs, OnEntityPreSpawn, CBC_ORDER_LAST) +MUTATOR_HOOKFUNCTION(buffs, FilterItem) { if(autocvar_g_buffs < 0) - return; // no auto replacing of entities in this mode + return false; // no auto replacing of entities in this mode - entity ent = M_ARGV(0, entity); + entity item = M_ARGV(0, entity); if(autocvar_g_buffs_replace_powerups) - switch(ent.classname) { - case "item_strength": - case "item_shield": + switch(item.classname) { - entity e = spawn(); - buff_SpawnReplacement(e, ent); - return true; + case "item_strength": + case "item_shield": + { + entity e = spawn(); + buff_SpawnReplacement(e, item); + return true; + } } } + + return false; } MUTATOR_HOOKFUNCTION(buffs, WeaponRateFactor) diff --git a/qcsrc/common/mutators/mutator/waypoints/all.inc b/qcsrc/common/mutators/mutator/waypoints/all.inc index 73f22b836..407b9c35b 100644 --- a/qcsrc/common/mutators/mutator/waypoints/all.inc +++ b/qcsrc/common/mutators/mutator/waypoints/all.inc @@ -1,64 +1,64 @@ /** If you register a new waypoint, make sure to add it to this list */ -REGISTER_WAYPOINT(Waypoint, _("Waypoint"), '0 1 1', 1); -REGISTER_WAYPOINT(Helpme, _("Help me!"), '1 0.5 0', 1); -REGISTER_WAYPOINT(Here, _("Here"), '0 1 0', 1); -REGISTER_WAYPOINT(Danger, _("DANGER"), '1 0.5 0', 1); +REGISTER_WAYPOINT(Waypoint, _("Waypoint"), "", '0 1 1', 1); +REGISTER_WAYPOINT(Helpme, _("Help me!"), "", '1 0.5 0', 1); +REGISTER_WAYPOINT(Here, _("Here"), "", '0 1 0', 1); +REGISTER_WAYPOINT(Danger, _("DANGER"), "", '1 0.5 0', 1); -REGISTER_WAYPOINT(Frozen, _("Frozen!"), '0.25 0.90 1', 1); +REGISTER_WAYPOINT(Frozen, _("Frozen!"), "", '0.25 0.90 1', 1); -REGISTER_WAYPOINT(Item, _("Item"), '1 0 1', 1); +REGISTER_WAYPOINT(Item, _("Item"), "", '1 0 1', 1); -REGISTER_WAYPOINT(RaceCheckpoint, _("Checkpoint"), '1 0.5 0', 1); -REGISTER_WAYPOINT(RaceFinish, _("Finish"), '1 0.5 0', 1); -REGISTER_WAYPOINT(RaceStart, _("Start"), '1 0.5 0', 1); -REGISTER_WAYPOINT(RaceStartFinish, _("Start"), '1 0.5 0', 1); +REGISTER_WAYPOINT(RaceCheckpoint, _("Checkpoint"), "", '1 0.5 0', 1); +REGISTER_WAYPOINT(RaceFinish, _("Finish"), "", '1 0.5 0', 1); +REGISTER_WAYPOINT(RaceStart, _("Start"), "", '1 0.5 0', 1); +REGISTER_WAYPOINT(RaceStartFinish, _("Start"), "", '1 0.5 0', 1); -REGISTER_WAYPOINT(AssaultDefend, _("Defend"), '1 0.5 0', 1); -REGISTER_WAYPOINT(AssaultDestroy, _("Destroy"), '1 0.5 0', 1); -REGISTER_WAYPOINT(AssaultPush, _("Push"), '1 0.5 0', 1); +REGISTER_WAYPOINT(AssaultDefend, _("Defend"), "", '1 0.5 0', 1); +REGISTER_WAYPOINT(AssaultDestroy, _("Destroy"), "", '1 0.5 0', 1); +REGISTER_WAYPOINT(AssaultPush, _("Push"), "", '1 0.5 0', 1); -REGISTER_WAYPOINT(FlagCarrier, _("Flag carrier"), '0.8 0.8 0', 1); -REGISTER_WAYPOINT(FlagCarrierEnemy, _("Enemy carrier"), '1 1 1', 1); -REGISTER_WAYPOINT(FlagDropped, _("Dropped flag"), '1 1 1', 1); -REGISTER_WAYPOINT(FlagBaseNeutral, _("White base"), '0.8 0.8 0', 1); -REGISTER_WAYPOINT(FlagBaseRed, _("Red base"), '0.8 0.8 0', 1); -REGISTER_WAYPOINT(FlagBaseBlue, _("Blue base"), '0.8 0.8 0', 1); -REGISTER_WAYPOINT(FlagBaseYellow, _("Yellow base"), '0.8 0.8 0', 1); -REGISTER_WAYPOINT(FlagBasePink, _("Pink base"), '0.8 0.8 0', 1); -REGISTER_WAYPOINT(FlagReturn, _("Return flag here"), '0 0.8 0.8', 1); +REGISTER_WAYPOINT(FlagCarrier, _("Flag carrier"), "", '0.8 0.8 0', 1); +REGISTER_WAYPOINT(FlagCarrierEnemy, _("Enemy carrier"), "flag_neutral_carrying", '1 1 1', 1); +REGISTER_WAYPOINT(FlagDropped, _("Dropped flag"), "flag_neutral_lost", '1 1 1', 1); +REGISTER_WAYPOINT(FlagBaseNeutral, _("White base"), "flag_neutral_taken", '0.8 0.8 0', 1); +REGISTER_WAYPOINT(FlagBaseRed, _("Red base"), "flag_red_taken", '0.8 0.8 0', 1); +REGISTER_WAYPOINT(FlagBaseBlue, _("Blue base"), "flag_blue_taken", '0.8 0.8 0', 1); +REGISTER_WAYPOINT(FlagBaseYellow, _("Yellow base"), "flag_yellow_taken", '0.8 0.8 0', 1); +REGISTER_WAYPOINT(FlagBasePink, _("Pink base"), "flag_pink_taken", '0.8 0.8 0', 1); +REGISTER_WAYPOINT(FlagReturn, _("Return flag here"), "", '0 0.8 0.8', 1); -REGISTER_WAYPOINT(DomNeut, _("Control point"), '0 1 1', 1); -REGISTER_WAYPOINT(DomRed, _("Control point"), '0 1 1', 1); -REGISTER_WAYPOINT(DomBlue, _("Control point"), '0 1 1', 1); -REGISTER_WAYPOINT(DomYellow, _("Control point"), '0 1 1', 1); -REGISTER_WAYPOINT(DomPink, _("Control point"), '0 1 1', 1); +REGISTER_WAYPOINT(DomNeut, _("Control point"), "", '0 1 1', 1); +REGISTER_WAYPOINT(DomRed, _("Control point"), "", '0 1 1', 1); +REGISTER_WAYPOINT(DomBlue, _("Control point"), "", '0 1 1', 1); +REGISTER_WAYPOINT(DomYellow, _("Control point"), "", '0 1 1', 1); +REGISTER_WAYPOINT(DomPink, _("Control point"), "", '0 1 1', 1); -REGISTER_WAYPOINT(KeyDropped, _("Dropped key"), '0 1 1', 1); -REGISTER_WAYPOINT(KeyCarrierFriend, _("Key carrier"), '0 1 0', 1); -REGISTER_WAYPOINT(KeyCarrierFinish, _("Run here"), '0 1 1', 1); -REGISTER_WAYPOINT(KeyCarrierRed, _("Key carrier"), '0 1 1', 1); -REGISTER_WAYPOINT(KeyCarrierBlue, _("Key carrier"), '0 1 1', 1); -REGISTER_WAYPOINT(KeyCarrierYellow, _("Key carrier"), '0 1 1', 1); -REGISTER_WAYPOINT(KeyCarrierPink, _("Key carrier"), '0 1 1', 1); +REGISTER_WAYPOINT(KeyDropped, _("Dropped key"), "", '0 1 1', 1); +REGISTER_WAYPOINT(KeyCarrierFriend, _("Key carrier"), "", '0 1 0', 1); +REGISTER_WAYPOINT(KeyCarrierFinish, _("Run here"), "", '0 1 1', 1); +REGISTER_WAYPOINT(KeyCarrierRed, _("Key carrier"), "", '0 1 1', 1); +REGISTER_WAYPOINT(KeyCarrierBlue, _("Key carrier"), "", '0 1 1', 1); +REGISTER_WAYPOINT(KeyCarrierYellow, _("Key carrier"), "", '0 1 1', 1); +REGISTER_WAYPOINT(KeyCarrierPink, _("Key carrier"), "", '0 1 1', 1); -REGISTER_WAYPOINT(KaBall, _("Ball"), '0 1 1', 1); -REGISTER_WAYPOINT(KaBallCarrier, _("Ball carrier"), '1 0 0', 1); +REGISTER_WAYPOINT(KaBall, _("Ball"), "", '0 1 1', 1); +REGISTER_WAYPOINT(KaBallCarrier, _("Ball carrier"), "", '1 0 0', 1); -REGISTER_WAYPOINT(NbBall, _("Ball"), '0.91 0.85 0.62', 1); -REGISTER_WAYPOINT(NbGoal, _("Goal"), '1 0.5 0', 1); +REGISTER_WAYPOINT(NbBall, _("Ball"), "", '0.91 0.85 0.62', 1); +REGISTER_WAYPOINT(NbGoal, _("Goal"), "", '1 0.5 0', 1); -REGISTER_WAYPOINT(OnsCP, _("Control point"), '1 0.5 0', 1); -REGISTER_WAYPOINT(OnsCPDefend, _("Control point"), '1 0.5 0', 0.5); -REGISTER_WAYPOINT(OnsCPAttack, _("Control point"), '1 0.5 0', 2); -REGISTER_WAYPOINT(OnsGen, _("Generator"), '1 0.5 0', 1); -REGISTER_WAYPOINT(OnsGenShielded, _("Generator"), '1 0.5 0', 1); +REGISTER_WAYPOINT(OnsCP, _("Control point"), "", '1 0.5 0', 1); +REGISTER_WAYPOINT(OnsCPDefend, _("Control point"), "", '1 0.5 0', 0.5); +REGISTER_WAYPOINT(OnsCPAttack, _("Control point"), "", '1 0.5 0', 2); +REGISTER_WAYPOINT(OnsGen, _("Generator"), "", '1 0.5 0', 1); +REGISTER_WAYPOINT(OnsGenShielded, _("Generator"), "", '1 0.5 0', 1); -REGISTER_WAYPOINT(Weapon, _("Weapon"), '0 0 0', 1); +REGISTER_WAYPOINT(Weapon, _("Weapon"), "", '0 0 0', 1); -REGISTER_WAYPOINT(Monster, _("Monster"), '1 0 0', 1); +REGISTER_WAYPOINT(Monster, _("Monster"), "", '1 0 0', 1); -REGISTER_WAYPOINT(Vehicle, _("Vehicle"), '1 1 1', 1); -REGISTER_WAYPOINT(VehicleIntruder, _("Intruder!"), '1 1 1', 1); +REGISTER_WAYPOINT(Vehicle, _("Vehicle"), "", '1 1 1', 1); +REGISTER_WAYPOINT(VehicleIntruder, _("Intruder!"), "", '1 1 1', 1); -REGISTER_WAYPOINT(Seeker, _("Tagged"), '0.5 1 0', 2); +REGISTER_WAYPOINT(Seeker, _("Tagged"), "", '0.5 1 0', 2); diff --git a/qcsrc/common/mutators/mutator/waypoints/all.qh b/qcsrc/common/mutators/mutator/waypoints/all.qh index 77c431200..132600237 100644 --- a/qcsrc/common/mutators/mutator/waypoints/all.qh +++ b/qcsrc/common/mutators/mutator/waypoints/all.qh @@ -14,18 +14,20 @@ CLASS(Waypoint, Object) ATTRIB(Waypoint, m_id, int, 0); ATTRIB(Waypoint, netname, string); ATTRIB(Waypoint, m_name, string); + ATTRIB(Waypoint, m_icon, string); ATTRIB(Waypoint, m_color, vector, '1 1 1'); ATTRIB(Waypoint, m_blink, int, 1); - CONSTRUCTOR(Waypoint, string _netname, string _name, vector _color, int _blink) { + CONSTRUCTOR(Waypoint, string _netname, string _name, string _icon, vector _color, int _blink) { CONSTRUCT(Waypoint); this.netname = _netname; this.m_name = _name; + this.m_icon = _icon; this.m_color = _color; this.m_blink = _blink; } ENDCLASS(Waypoint) -#define REGISTER_WAYPOINT(id, text, color, blink) REGISTER_WAYPOINT_(id, NEW(Waypoint, #id, text, color, blink)) +#define REGISTER_WAYPOINT(id, text, icon, color, blink) REGISTER_WAYPOINT_(id, NEW(Waypoint, #id, text, icon, color, blink)) REGISTRY(RadarIcons, BITS(7)) #define RadarIcons_from(i) _RadarIcons_from(i, RADARICON_NONE) @@ -35,7 +37,7 @@ REGISTRY_CHECK(RadarIcons) .int m_radaricon; #define REGISTER_RADARICON(id, num) REGISTER(RadarIcons, RADARICON, id, m_id, new_pure(RadarIcon)) { this.m_radaricon = num; this.netname = #id; } -REGISTER_WAYPOINT(Null, "", '0 0 0', 1); +REGISTER_WAYPOINT(Null, "", "", '0 0 0', 1); REGISTER_RADARICON(NONE, 0); REGISTER_RADARICON(FLAG, 1); diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc index f7f64fe16..a5d48249a 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc @@ -271,6 +271,7 @@ string spritelookupicon(entity this, string s) // TODO: needs icons! //if (s == WP_RaceStartFinish.netname) return (race_checkpointtime || race_mycheckpointtime) ? _("Finish") : _("Start"); if (s == WP_Weapon.netname) return Weapons_from(this.wp_extra).model2; if (s == WP_Item.netname) return Items_from(this.wp_extra).m_icon; + if (s == WP_Buff.netname) return strcat("buff_", Buffs_from(this.wp_extra).m_name); //if (s == WP_Monster.netname) return get_monsterinfo(this.wp_extra).m_icon; if (MUTATOR_CALLHOOK(WP_Format, this, s)) { @@ -665,6 +666,7 @@ void Draw_WaypointSprite(entity this) o = drawspritearrow(o, ang, rgb, a, SPRITE_ARROW_SCALE * t); + vector iconcolor = ((autocvar_g_waypointsprite_iconcolor) ? '1 1 1' : rgb); string spr_icon = spritelookupicon(this, spriteimage); string pic = spr_icon; bool icon_found = !(!spr_icon || spr_icon == ""); @@ -725,14 +727,14 @@ void Draw_WaypointSprite(entity this) if(autocvar_g_waypointsprite_text || !icon_found) o = drawspritetext(o, ang, (SPRITE_HEALTHBAR_WIDTH + 2 * SPRITE_HEALTHBAR_BORDER) * t, rgb, a, waypointsprite_fontsize * '1 1 0', txt); else - drawpic(o - vec2(iconsize/2, autocvar_g_waypointsprite_iconsize*t + 2*marg + SPRITE_HEALTHBAR_HEIGHT*t), pic, '1 1 0'*iconsize, rgb, a, DRAWFLAG_NORMAL); + drawpic(o - vec2(autocvar_g_waypointsprite_iconsize/2, autocvar_g_waypointsprite_iconsize*t + 2*marg + SPRITE_HEALTHBAR_HEIGHT*t), pic, '1 1 0'*autocvar_g_waypointsprite_iconsize, iconcolor, a, DRAWFLAG_NORMAL); } else { if (autocvar_g_waypointsprite_text || !icon_found) o = drawspritetext(o, ang, 0, rgb, a, waypointsprite_fontsize * '1 1 0', txt); else - drawpic_aspect(o, pic, vec2(SPRITE_HEALTHBAR_WIDTH * t, SPRITE_HEALTHBAR_HEIGHT * t), rgb, a, DRAWFLAG_NORMAL); + drawpic(o - vec2(autocvar_g_waypointsprite_iconsize/2, autocvar_g_waypointsprite_iconsize*t + 2 + SPRITE_HEALTHBAR_HEIGHT*t), pic, '1 1 0'*autocvar_g_waypointsprite_iconsize, iconcolor, a, DRAWFLAG_NORMAL); } draw_endBoldFont(); } diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh index 2695bedc9..3f79ee272 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qh @@ -54,7 +54,8 @@ bool autocvar_g_waypointsprite_turrets = true; float autocvar_g_waypointsprite_turrets_maxdist = 5000; bool autocvar_g_waypointsprite_uppercase; bool autocvar_g_waypointsprite_text; -float autocvar_g_waypointsprite_iconsize = 64; +float autocvar_g_waypointsprite_iconsize = 32; +bool autocvar_g_waypointsprite_iconcolor; float waypointsprite_fadedistance; float waypointsprite_normdistance; -- 2.39.2