+#include "gamemode_lms.qh"
#ifndef GAMEMODE_LMS_H
#define GAMEMODE_LMS_H
error("This is a game type and it cannot be added at runtime.");
lms_Initialize();
- SetLimits(((!autocvar_g_lms_lives_override) ? -1 : autocvar_g_lms_lives_override), 0, -1, -1);
+ SetLimits(((!autocvar_g_lms_lives_override) ? -1 : autocvar_g_lms_lives_override), 0, autocvar_timelimit_override, -1);
}
MUTATOR_ONROLLBACK_OR_REMOVE
#ifdef IMPLEMENTATION
-#include "../../campaign.qh"
-#include "../../command/cmd.qh"
+#include <common/mutators/mutator/instagib/items.qc>
+#include <server/campaign.qh>
+#include <server/command/cmd.qh>
int autocvar_g_lms_extra_lives;
bool autocvar_g_lms_join_anytime;
return bound(1, lms_lowest_lives, fl);
}
+void ClearWinners();
+
// LMS winning condition: game terminates if and only if there's at most one
// one player who's living lives. Top two scores being equal cancels the time
// limit.
-float WinningCondition_LMS()
+int WinningCondition_LMS()
{
entity head, head2;
- float have_player;
- float have_players;
- float l;
+ bool have_player = false;
+ bool have_players = false;
- have_player = false;
- have_players = false;
- l = LMS_NewPlayerLives();
+ int l = LMS_NewPlayerLives();
- head = find(world, classname, "player");
+ head = find(world, classname, STR_PLAYER);
if(head)
have_player = true;
- head2 = find(head, classname, "player");
+ head2 = find(head, classname, STR_PLAYER);
if(head2)
have_players = true;
}
MUTATOR_HOOKFUNCTION(lms, reset_map_players)
-{SELFPARAM();
- entity e;
+{
if(restart_mapalreadyrestarted || (time < game_starttime))
- FOR_EACH_CLIENT(e)
- if(IS_PLAYER(e))
- {
- WITH(entity, self, e, PlayerScore_Add(e, SP_LMS_LIVES, LMS_NewPlayerLives()));
- }
-
+ FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(PlayerScore_Add(it, SP_LMS_LIVES, LMS_NewPlayerLives())));
return false;
}
MUTATOR_HOOKFUNCTION(lms, PutClientInServer)
-{SELFPARAM();
+{
+ entity player = M_ARGV(0, entity);
+
// player is dead and becomes observer
// FIXME fix LMS scoring for new system
- if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0)
+ if(PlayerScore_Add(player, SP_LMS_RANK, 0) > 0)
{
- self.classname = STR_OBSERVER;
- Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_LMS_NOLIVES);
+ TRANSMUTE(Observer, player);
+ Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_LMS_NOLIVES);
}
-
- return false;
}
MUTATOR_HOOKFUNCTION(lms, PlayerDies)
-{SELFPARAM();
- self.respawn_flags |= RESPAWN_FORCE;
-
+{
+ entity frag_target = M_ARGV(2, entity);
+
+ frag_target.respawn_flags |= RESPAWN_FORCE;
return false;
}
}
MUTATOR_HOOKFUNCTION(lms, MakePlayerObserver)
-{SELFPARAM();
- lms_RemovePlayer(self);
- return false;
+{
+ SELFPARAM();
+ lms_RemovePlayer(this);
+ return true; // prevent team reset
}
MUTATOR_HOOKFUNCTION(lms, ClientConnect)
{SELFPARAM();
- self.classname = STR_PLAYER;
- campaign_bots_may_start = 1;
+ TRANSMUTE(Player, self);
+ campaign_bots_may_start = true;
if(PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives()) <= 0)
{
MUTATOR_HOOKFUNCTION(lms, PlayerPreThink)
{SELFPARAM();
- if(self.deadflag == DEAD_DYING)
- self.deadflag = DEAD_RESPAWNING;
+ if(this.deadflag == DEAD_DYING)
+ this.deadflag = DEAD_RESPAWNING;
return false;
}
MUTATOR_HOOKFUNCTION(lms, GiveFragsForKill)
{
+ entity frag_target = M_ARGV(1, entity);
+
// remove a life
float tl;
tl = PlayerScore_Add(frag_target, SP_LMS_LIVES, -1);
PlayerScore_Add(frag_target, SP_LMS_RANK, lms_next_place); // won't ever spawn again
--lms_next_place;
}
- frag_score = 0;
+ M_ARGV(2, float) = 0;
return true;
}
MUTATOR_HOOKFUNCTION(lms, FilterItem)
{SELFPARAM();
if(autocvar_g_lms_extra_lives)
- if(self.itemdef == ITEM_HealthMega)
- {
- self.max_health = 1;
+ if(self.itemdef == ITEM_ExtraLife)
return false;
- }
+
+ return true;
+}
+
+void lms_extralife(entity this)
+{
+ StartItem(this, ITEM_ExtraLife);
+}
+
+MUTATOR_HOOKFUNCTION(lms, OnEntityPreSpawn)
+{SELFPARAM();
+ if (!autocvar_g_powerups) return false;
+ if (!autocvar_g_lms_extra_lives) return false;
+
+ // Can't use .itemdef here
+ if (self.classname != "item_health_mega") return false;
+
+ entity e = spawn();
+ setthink(e, lms_extralife);
+
+ e.nextthink = time + 0.1;
+ e.spawnflags = self.spawnflags;
+ e.noalign = self.noalign;
+ setorigin(e, self.origin);
return true;
}
MUTATOR_HOOKFUNCTION(lms, ItemTouch)
{SELFPARAM();
- // give extra lives for mega health
- if (self.items & ITEM_HealthMega.m_itemid)
+ if(self.itemdef == ITEM_ExtraLife)
{
Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_EXTRALIVES);
PlayerScore_Add(other, SP_LMS_LIVES, autocvar_g_lms_extra_lives);
+ return MUT_ITEMTOUCH_PICKUP;
}
return MUT_ITEMTOUCH_CONTINUE;
MUTATOR_HOOKFUNCTION(lms, Bot_FixCount, CBC_ORDER_EXCLUSIVE)
{
- entity head;
- FOR_EACH_REALCLIENT(head)
- {
+ FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
++bot_activerealplayers;
++bot_realplayers;
- }
+ ));
return true;
}
MUTATOR_HOOKFUNCTION(lms, ClientCommand_Spectate)
{
+ SELFPARAM();
if(self.lms_spectate_warning)
{
// for the forfeit message...