}
return false;
}
+
+void HUD_Mod_LMS_Draw(vector myPos, vector mySize)
+{
+ int stat = STAT(REDALIVE); // number of leaders
+ if(!stat)
+ {
+ mod_active = 0;
+ return;
+ }
+
+ string pic = "player_neutral";
+ vector color = '1 1 1';
+
+ drawpic_aspect_skin(myPos, pic, vec2(0.5 * mySize.x, mySize.y), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawstring_aspect(myPos + eX * 0.5 * mySize.x, ftos(stat), vec2(0.5 * mySize.x, mySize.y), color, panel_fg_alpha, DRAWFLAG_NORMAL);
+}
+
+void HUD_Mod_LMS(vector myPos, vector mySize)
+{
+ mod_active = 1;
+
+ HUD_Mod_LMS_Draw(myPos, mySize);
+}
#include <common/mapinfo.qh>
+#ifdef CSQC
+void HUD_Mod_LMS(vector myPos, vector mySize);
+#endif
CLASS(LastManStanding, Gametype)
INIT(LastManStanding)
{
returns(menu, _("Lives:"), 3, 50, 1, "g_lms_lives_override", string_null, string_null);
}
ATTRIB(LastManStanding, m_legacydefaults, string, "9 20 0");
+#ifdef CSQC
+ ATTRIB(LastManStanding, m_modicons, void(vector myPos, vector mySize), HUD_Mod_LMS);
+#endif
ENDCLASS(LastManStanding)
REGISTER_GAMETYPE(LMS, NEW(LastManStanding));
float autocvar_g_lms_dynamic_vampire_factor_max;
int autocvar_g_lms_dynamic_vampire_min_lives_diff;
-.float lms_wp_time;
+.float lms_leader;
// main functions
int LMS_NewPlayerLives()
// runs on waypoints which are attached to leaders, updates once per frame
bool lms_waypointsprite_visible_for_player(entity this, entity player, entity view)
{
- if(view.lms_wp_time)
+ if(view.lms_leader)
if(IS_SPEC(player))
return false; // we don't want spectators of leaders to see the attached waypoint on the top of their screen
float leader_time = autocvar_g_lms_leader_wp_time;
float leader_repeat_time = leader_time + autocvar_g_lms_leader_wp_time_repeat;
- float wp_time = this.owner.lms_wp_time;
- if (wp_time && (time - wp_time) % leader_repeat_time > leader_time)
+ if (time % leader_repeat_time > leader_time)
return false;
return true;
}
-void lms_UpdateWaypoints()
+void lms_UpdateLeaders()
{
int max_lives = 0;
int pl_cnt = 0;
int lives = GameRules_scoring_add(it, LMS_LIVES, 0);
if (lives == max_lives)
{
- if (!it.waypointsprite_attachedforcarrier)
- {
- WaypointSprite_AttachCarrier(WP_LmsLeader, it, RADARICON_FLAGCARRIER);
- it.waypointsprite_attachedforcarrier.waypointsprite_visible_for_player = lms_waypointsprite_visible_for_player;
- WaypointSprite_UpdateRule(it.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
- vector pl_color = colormapPaletteColor(it.clientcolors & 0x0F, false);
- WaypointSprite_UpdateTeamRadar(it.waypointsprite_attachedforcarrier, RADARICON_FLAGCARRIER, pl_color);
- WaypointSprite_Ping(it.waypointsprite_attachedforcarrier);
- }
- if (!it.lms_wp_time)
- it.lms_wp_time = time;
+ if (!it.lms_leader)
+ it.lms_leader = true;
}
else
{
- if (it.waypointsprite_attachedforcarrier)
- WaypointSprite_Kill(it.waypointsprite_attachedforcarrier);
- it.lms_wp_time = 0;
+ it.lms_leader = false;
}
});
else
FOREACH_CLIENT(IS_PLAYER(it) && it.frags != FRAGS_PLAYER_OUT_OF_GAME, {
if (it.waypointsprite_attachedforcarrier)
WaypointSprite_Kill(it.waypointsprite_attachedforcarrier);
- it.lms_wp_time = 0;
+ it.lms_leader = false;
});
}
TRANSMUTE(Player, it);
PutClientInServer(it);
- it.lms_wp_time = 0;
+ it.lms_leader = false;
if (it.waypointsprite_attachedforcarrier)
WaypointSprite_Kill(it.waypointsprite_attachedforcarrier);
});
TRANSMUTE(Observer, player);
}
if (autocvar_g_lms_leader_wp_lives > 0)
- lms_UpdateWaypoints();
+ lms_UpdateLeaders();
}
if (CS(player).killcount != FRAGS_SPECTATOR && player.lms_spectate_warning < 3)
player.frags = FRAGS_SPECTATOR;
}
+int lms_leaders = 0;
MUTATOR_HOOKFUNCTION(lms, PlayerPreThink)
{
entity player = M_ARGV(0, entity);
+ // recycled REDALIVE to avoid adding a dedicated stat
+ STAT(REDALIVE, player) = lms_leaders;
+
if(player.deadflag == DEAD_DYING)
player.deadflag = DEAD_RESPAWNING;
}
+MUTATOR_HOOKFUNCTION(lms, SV_StartFrame)
+{
+ lms_leaders = 0;
+ FOREACH_CLIENT(true, {
+ if (IS_PLAYER(it) && it.frags != FRAGS_PLAYER_OUT_OF_GAME)
+ {
+ if (it.lms_leader)
+ {
+ if (!it.waypointsprite_attachedforcarrier)
+ {
+ WaypointSprite_AttachCarrier(WP_LmsLeader, it, RADARICON_FLAGCARRIER);
+ it.waypointsprite_attachedforcarrier.waypointsprite_visible_for_player = lms_waypointsprite_visible_for_player;
+ WaypointSprite_UpdateRule(it.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
+ vector pl_color = colormapPaletteColor(it.clientcolors & 0x0F, false);
+ WaypointSprite_UpdateTeamRadar(it.waypointsprite_attachedforcarrier, RADARICON_FLAGCARRIER, pl_color);
+ WaypointSprite_Ping(it.waypointsprite_attachedforcarrier);
+ }
+ lms_leaders++;
+ }
+ }
+ else
+ {
+ if (it.waypointsprite_attachedforcarrier)
+ WaypointSprite_Kill(it.waypointsprite_attachedforcarrier);
+ }
+ });
+}
+
MUTATOR_HOOKFUNCTION(lms, PlayerRegen)
{
if(autocvar_g_lms_regenerate)
MUTATOR_HOOKFUNCTION(lms, PlayerDied)
{
if (!warmup_stage && autocvar_g_lms_leader_wp_lives > 0)
- lms_UpdateWaypoints();
+ lms_UpdateLeaders();
}
MUTATOR_HOOKFUNCTION(lms, CalculateRespawnTime)