Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
safalin1 committed Aug 25, 2020
2 parents 8cd5993 + 7d64f55 commit 2b1ae10
Show file tree
Hide file tree
Showing 12 changed files with 244 additions and 43 deletions.
2 changes: 2 additions & 0 deletions src/scripting/AS-MicroTF2-SDK.sp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public Action Cmd_ProcessSounds(int client, int args)

PrintToServer("Processing minigame music");
ProcessMinigameMusic();

return Plugin_Handled;
}

public void ProcessSystemMusic()
Expand Down
22 changes: 17 additions & 5 deletions src/scripting/AS-MicroTF2.sp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/
//#define DEBUG
//#define LOGGING_STARTUP
#define PLUGIN_VERSION "4.0.0"
#define PLUGIN_VERSION "4.1.0"
#define PLUGIN_PREFIX "\x0700FFFF[ \x07FFFF00WarioWare \x0700FFFF] {default}"
#define PLUGIN_MAPPREFIX "warioware_redux_"
//#define PLUGIN_DOPRECACHE
Expand All @@ -51,6 +51,7 @@
#include "Sounds.sp"
#include "System.sp"
#include "Commands.sp"
#include "TimelimitManager.sp"
#include "PluginInterop.sp"
#include "Speed.sp"
#include "Hud.sp"
Expand Down Expand Up @@ -159,6 +160,7 @@ public Action Timer_GameLogic_EngineInitialisation(Handle timer)
IsOnlyBlockingDamageByPlayers = false;

CreateTimer(0.25, Timer_GameLogic_PrepareForMinigame);
return Plugin_Handled;
}

public Action Timer_GameLogic_PrepareForMinigame(Handle timer)
Expand Down Expand Up @@ -1140,11 +1142,13 @@ public Action Timer_GameLogic_GameOverEnd(Handle timer)
SetSpeed();
SetConVarInt(ConVar_TFFastBuild, 0);

if (MaxRounds == 0 || RoundsPlayed < MaxRounds)
bool hasTimelimit = TimelimitManager_HasTimeLimit();

if ((!hasTimelimit && (MaxRounds == 0 || RoundsPlayed < MaxRounds)) || (hasTimelimit && !TimelimitManager_HasExceededTimeLimit()))
{
bool isWaitingForVoteToFinish = false;

if (PluginForward_HasMapIntegrationLoaded() && GetConVarBool(ConVar_MTF2IntermissionEnabled) && MaxRounds != 0 && RoundsPlayed == (MaxRounds / 2))
if (PluginForward_HasMapIntegrationLoaded() && !hasTimelimit && GetConVarBool(ConVar_MTF2IntermissionEnabled) && MaxRounds != 0 && RoundsPlayed == (MaxRounds / 2))
{
PluginForward_StartMapVote();
isWaitingForVoteToFinish = true;
Expand All @@ -1164,6 +1168,8 @@ public Action Timer_GameLogic_GameOverEnd(Handle timer)
PluginForward_SendGamemodeChanged(GamemodeID);
HideHudGamemodeText = true;

float waitTime;

if (isWaitingForVoteToFinish)
{
for (int i = 1; i <= MaxClients; i++)
Expand All @@ -1185,9 +1191,15 @@ public Action Timer_GameLogic_GameOverEnd(Handle timer)
EmitSoundToClient(i, SYSBGM_WAITING);
}
}

waitTime = 3.0;
}
else
{
waitTime = 0.0;
}

CreateTimer(2.0, Timer_GameLogic_WaitForVoteToFinishIfAny, _, TIMER_FLAG_NO_MAPCHANGE);
CreateTimer(waitTime, Timer_GameLogic_WaitForVoteToFinishIfAny, _, TIMER_FLAG_NO_MAPCHANGE);
}
else
{
Expand All @@ -1199,7 +1211,7 @@ public Action Timer_GameLogic_GameOverEnd(Handle timer)

public Action Timer_GameLogic_WaitForVoteToFinishIfAny(Handle timer)
{
if (PluginForward_HasMapIntegrationLoaded())
if (GetConVarBool(ConVar_MTF2IntermissionEnabled) && !TimelimitManager_HasTimeLimit() && PluginForward_HasMapIntegrationLoaded())
{
bool voteHasEnded = PluginForward_HasMapVoteEnded();

Expand Down
87 changes: 82 additions & 5 deletions src/scripting/Bossgames/Bossgame7.sp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#define BOSSGAME7_SAYTEXTANSWERS_CAPACITY 512

int Bossgame7_LastBgmIdx = -1;
char Bossgame7_BgmFiles[][] =
{
"gemidyne/warioware/bosses/bgm/danganronpa_hga.mp3",
Expand All @@ -27,6 +28,7 @@ char Bossgame7_BgmFiles[][] =
#define BOSSGAME7_SFX_SPIRAL "gemidyne/warioware/bosses/sfx/drpa_spiralinward.mp3"
#define BOSSGAME7_SFX_TYPING_START "gemidyne/warioware/bosses/sfx/drpa_typingstart.mp3"
#define BOSSGAME7_SFX_LEVEL_UP "gemidyne/warioware/bosses/sfx/drpa_levelup.mp3"
#define BOSSGAME7_VO_LEVEL_UP "vo/announcer_warning.mp3"

char Bossgame7_Sfx_WordFail[][] =
{
Expand All @@ -44,6 +46,14 @@ char Bossgame7_Sfx_WordSuccessPinch[][] =
"gemidyne/warioware/bosses/sfx/drpa_wordsuccess_pinch4.mp3",
};

#define BOSSGAME7_VO_10SEC "vo/announcer_ends_10sec.mp3"
#define BOSSGAME7_VO_5SEC "vo/announcer_ends_5sec.mp3"
#define BOSSGAME7_VO_4SEC "vo/announcer_ends_4sec.mp3"
#define BOSSGAME7_VO_3SEC "vo/announcer_ends_3sec.mp3"
#define BOSSGAME7_VO_2SEC "vo/announcer_ends_2sec.mp3"
#define BOSSGAME7_VO_1SEC "vo/announcer_ends_1sec.mp3"
#define BOSSGAME7_VO_BEGIN "vo/announcer_am_roundstart03.mp3"

#define BOSSGAME7_SAYTEXTINDICE_EASY 0
#define BOSSGAME7_SAYTEXTINDICE_MEDIUM 1
#define BOSSGAME7_SAYTEXTINDICE_HARD 2
Expand Down Expand Up @@ -111,6 +121,14 @@ public void Bossgame7_OnMapStart()
PrecacheSound(BOSSGAME7_SFX_TYPING_START, true);
PrecacheSound(BOSSGAME7_SFX_WORDSUCCESS_RELAX, true);
PrecacheSound(BOSSGAME7_SFX_LEVEL_UP, true);
PrecacheSound(BOSSGAME7_VO_LEVEL_UP, true);
PrecacheSound(BOSSGAME7_VO_10SEC, true);
PrecacheSound(BOSSGAME7_VO_5SEC, true);
PrecacheSound(BOSSGAME7_VO_4SEC, true);
PrecacheSound(BOSSGAME7_VO_3SEC, true);
PrecacheSound(BOSSGAME7_VO_2SEC, true);
PrecacheSound(BOSSGAME7_VO_1SEC, true);
PrecacheSound(BOSSGAME7_VO_BEGIN, true);
}

public bool Bossgame7_LoadDictionary(int indice, const char[] path)
Expand Down Expand Up @@ -357,10 +375,17 @@ public Action Bossgame7_DoDescentSequence(Handle timer)
}

int camera = GetCameraEntity("DRBoss_DescentCamera_Point");
int randomBgmIdx;

Bossgame7_ActiveCameraEntityId = camera;

int randomBgmIdx = GetRandomInt(0, sizeof(Bossgame7_BgmFiles)-1);
do
{
randomBgmIdx = GetRandomInt(0, sizeof(Bossgame7_BgmFiles)-1);
}
while (randomBgmIdx == Bossgame7_LastBgmIdx);

Bossgame7_LastBgmIdx = randomBgmIdx;

for (int i = 1; i <= MaxClients; i++)
{
Expand Down Expand Up @@ -453,6 +478,7 @@ public Action Bossgame7_DoCloseupSequence(Handle timer)
player.DisplayOverlay(OVERLAY_BLANK);

EmitSoundToClient(i, BOSSGAME7_SFX_TYPING_START, Bossgame7_ActiveCameraEntityId);
EmitSoundToClient(i, BOSSGAME7_VO_BEGIN, Bossgame7_ActiveCameraEntityId);
}
}

Expand Down Expand Up @@ -521,6 +547,27 @@ public Action Bossgame7_DoTypingTick(Handle timer)
if (player.IsValid && player.IsParticipating)
{
PrintAnswerDisplay(player);

switch (Bossgame7_RemainingTime)
{
case 10:
EmitSoundToClient(player.ClientId, BOSSGAME7_VO_10SEC, Bossgame7_ActiveCameraEntityId);

case 5:
EmitSoundToClient(player.ClientId, BOSSGAME7_VO_5SEC, Bossgame7_ActiveCameraEntityId);

case 4:
EmitSoundToClient(player.ClientId, BOSSGAME7_VO_4SEC, Bossgame7_ActiveCameraEntityId);

case 3:
EmitSoundToClient(player.ClientId, BOSSGAME7_VO_3SEC, Bossgame7_ActiveCameraEntityId);

case 2:
EmitSoundToClient(player.ClientId, BOSSGAME7_VO_2SEC, Bossgame7_ActiveCameraEntityId);

case 1:
EmitSoundToClient(player.ClientId, BOSSGAME7_VO_1SEC, Bossgame7_ActiveCameraEntityId);
}
}
}

Expand Down Expand Up @@ -675,6 +722,8 @@ public Action Bossgame7_DoReviewSequencePost(Handle timer, any data)
int activePlayers = 0;
int lastWinnerId = 0;

float additionalDelay = 0.1;

for (int i = 1; i <= MaxClients; i++)
{
Player player = new Player(i);
Expand All @@ -684,8 +733,10 @@ public Action Bossgame7_DoReviewSequencePost(Handle timer, any data)
if (Bossgame7_PlayerActiveAnswerCount[i] <= data)
{
player.Status = PlayerStatus_Failed;
ForcePlayerSuicide(i);
EmitSoundToClient(i, BOSSGAME7_SFX_OVERVIEW_DEFEAT, Bossgame7_ActiveCameraEntityId);
CreateTimer(additionalDelay, Bossgame7_DeferredDeath, player.ClientId);

additionalDelay += 0.1;
}
else
{
Expand All @@ -697,19 +748,43 @@ public Action Bossgame7_DoReviewSequencePost(Handle timer, any data)
}
}

float nextTimerDelay = 2.0 + additionalDelay;

if (activePlayers <= 1)
{
CreateTimer(2.0, Bossgame7_DoFinalReview, lastWinnerId);
CreateTimer(nextTimerDelay, Bossgame7_DoFinalReview, lastWinnerId);
return Plugin_Handled;
}

if (Bossgame7_ActiveRound == 1 || Bossgame7_ActiveRound == 3)
{
CreateTimer(2.0, Bossgame7_DoLevelChange);
CreateTimer(nextTimerDelay, Bossgame7_DoLevelChange);
}
else
{
CreateTimer(2.0, Bossgame7_DoDescentSequence);
CreateTimer(nextTimerDelay, Bossgame7_DoDescentSequence);
}

return Plugin_Handled;
}

public Action Bossgame7_DeferredDeath(Handle timer, any clientId)
{
if (BossgameID != 7)
{
return Plugin_Handled;
}

if (!IsMinigameActive)
{
return Plugin_Handled;
}

Player player = new Player(clientId);

if (player.IsValid)
{
player.Kill();
}

return Plugin_Handled;
Expand Down Expand Up @@ -737,6 +812,8 @@ public Action Bossgame7_DoLevelChange(Handle timer)
Format(text, sizeof(text), "%T", "Bossgame7_Caption_LevelUpAnnouncement", player.ClientId);

EmitSoundToClient(i, BOSSGAME7_SFX_LEVEL_UP, Bossgame7_ActiveCameraEntityId);
EmitSoundToClient(i, BOSSGAME7_VO_LEVEL_UP, Bossgame7_ActiveCameraEntityId);

player.SetCaption(text);
}
}
Expand Down
48 changes: 34 additions & 14 deletions src/scripting/Commands.sp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Handle ConVar_MTF2AllowCosmetics = INVALID_HANDLE;
Handle ConVar_MTF2ForceMinigame = INVALID_HANDLE;
Handle ConVar_MTF2ForceBossgame = INVALID_HANDLE;
Handle ConVar_MTF2ForceBossgameThreshold = INVALID_HANDLE;
Handle ConVar_MTF2UseServerMapTimelimit = INVALID_HANDLE;

stock void InitializeCommands()
{
Expand All @@ -41,14 +42,14 @@ stock void InitializeCommands()
ConVar_TFWeaponSpreads = FindConVar("tf_use_fixed_weaponspreads");
ConVar_FriendlyFire = FindConVar("mp_friendlyfire");

RegAdminCmd("sm_changegamemode", CmdSetGamemode, ADMFLAG_VOTE, "Changes the current gamemode.");

RegAdminCmd("sm_triggerboss", CmdTriggerBoss, ADMFLAG_VOTE, "Triggers a bossgame to be played next.");
RegAdminCmd("sm_changegamemode", Command_SetGamemode, ADMFLAG_VOTE, "Changes the current gamemode.");
RegAdminCmd("sm_triggerboss", Command_TriggerBoss, ADMFLAG_VOTE, "Triggers a bossgame to be played next.");

ConVar_MTF2MaxRounds = CreateConVar("mtf2_maxrounds", "4", "Sets the maximum rounds to be played. 0 = no limit (not recommended).", 0, true, 0.0);
ConVar_MTF2IntermissionEnabled = CreateConVar("mtf2_intermission_enabled", "1", "Controls whether or not intermission is to be held half way through the maximum round count. Having Intermission enabled assumes you have a intermission integration enabled - for example the SourceMod Mapchooser integration.", 0, true, 0.0, true, 1.0);
ConVar_MTF2BonusPoints = CreateConVar("mtf2_bonuspoints", "0", "Controls whether or not minigames should have a bonus point.", 0, true, 0.0, true, 1.0);
ConVar_MTF2AllowCosmetics = CreateConVar("mtf2_cosmetics_enabled", "0", "Allows cosmetics to be worn by players. NOTE: This mode is explicitly not supported and may cause visual bugs and possible server lag spikes.", 0, true, 0.0, true, 1.0);
ConVar_MTF2UseServerMapTimelimit = CreateConVar("mtf2_use_server_map_timelimit", "0", "Sets whether or not the gamemode should instead run an infinite number of rounds and let mp_timelimit dictate when the map ends. If set to 1, the gamemode will also not run intermission, and your mapchooser plugin will need to handle this instead.", 0, true, 0.0, true, 1.0);

if (ConVar_MTF2MaxRounds != INVALID_HANDLE)
{
Expand Down Expand Up @@ -92,9 +93,13 @@ stock void ResetConVars()
ResetConVar(FindConVar("mp_waitingforplayers_time"));
ResetConVar(FindConVar("mp_disable_respawn_times"));
ResetConVar(FindConVar("mp_respawnwavetime"));
ResetConVar(FindConVar("mp_timelimit"));
ResetConVar(FindConVar("mp_forcecamera"));
ResetConVar(FindConVar("mp_idlemaxtime"));

if (!GetConVarBool(ConVar_MTF2UseServerMapTimelimit))
{
ResetConVar(FindConVar("mp_timelimit"));
}

// TeamFortress ConVars
ResetConVar(FindConVar("tf_avoidteammates_pushaway"));
Expand Down Expand Up @@ -126,10 +131,15 @@ stock void PrepareConVars()
SetConVarInt(FindConVar("mp_waitingforplayers_time"), 90);
SetConVarInt(FindConVar("mp_disable_respawn_times"), 0);
SetConVarInt(FindConVar("mp_respawnwavetime"), 9999);
SetConVarInt(FindConVar("mp_timelimit"), 0);
SetConVarInt(FindConVar("mp_forcecamera"), 0);
SetConVarInt(FindConVar("mp_idlemaxtime"), 8);

if (!GetConVarBool(ConVar_MTF2UseServerMapTimelimit))
{
// If not using mp_timelimit mode, set to 0.
SetConVarInt(FindConVar("mp_timelimit"), 0);
}

// TeamFortress ConVars
SetConVarInt(FindConVar("tf_avoidteammates_pushaway"), 0);
SetConVarFloat(FindConVar("tf_max_health_boost"), 1.0);
Expand Down Expand Up @@ -186,8 +196,14 @@ public Action CmdOnPlayerKill(int client, const char[] command, int args)
}


public Action CmdSetGamemode(int client, int args)
public Action Command_SetGamemode(int client, int args)
{
if (args != 1)
{
ReplyToCommand(client, "[WWR] Usage: sm_changegamemode <gamemodeid>");
return Plugin_Handled;
}

char text[10];
GetCmdArg(1, text, sizeof(text));

Expand All @@ -198,21 +214,25 @@ public Action CmdSetGamemode(int client, int args)
GamemodeID = id;
SpecialRoundID = 0;

ReplyToCommand(client, "[ WarioWare ] Gamemode set to %s.", SystemNames[GamemodeID]);
ReplyToCommand(client, "[WWR] Gamemode changed to \"%s\".", SystemNames[GamemodeID]);

PluginForward_SendGamemodeChanged(id);

return Plugin_Handled;
}
else
{
ReplyToCommand(client, "[ WarioWare ] Unable to set gamemode, invalid value specified.");
}

ReplyToCommand(client, "[WWR] Error: specified gamemode ID is invalid.");

return Plugin_Handled;
}

public Action CmdTriggerBoss(int client, int args)
public Action Command_TriggerBoss(int client, int args)
{
MinigamesPlayed = BossGameThreshold-1;
MinigamesPlayed = BossGameThreshold - 1;

ReplyToCommand(client, "[WWR] Bossgame will be played shortly.");

ReplyToCommand(client, "[ WarioWare ] Triggering boss...");
return Plugin_Handled;
}

public void OnMaxRoundsChanged(Handle cvar, const char[] oldVal, const char[] newVal)
Expand Down
6 changes: 3 additions & 3 deletions src/scripting/Hud.sp
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ public void DisplayRoundHud(Player player, char buffer[128])
{
char roundDisplay[32];

if (MaxRounds > 0)
if (TimelimitManager_HasTimeLimit() || MaxRounds <= 0)
{
Format(roundDisplay, sizeof(roundDisplay), "%T", "Hud_RoundDisplay", player.ClientId, RoundsPlayed + 1, MaxRounds);
Format(roundDisplay, sizeof(roundDisplay), "%T", "Hud_RoundDisplayUnlimited", player.ClientId, RoundsPlayed + 1);
}
else
{
Format(roundDisplay, sizeof(roundDisplay), "%T", "Hud_RoundDisplayUnlimited", player.ClientId, RoundsPlayed + 1);
Format(roundDisplay, sizeof(roundDisplay), "%T", "Hud_RoundDisplay", player.ClientId, RoundsPlayed + 1, MaxRounds);
}

if (SpecialRoundID == 19)
Expand Down
1 change: 1 addition & 0 deletions src/scripting/Minigames/Minigame11.sp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public void Minigame11_OnMinigameSelectedPre()
public Action Timer_Minigame11_AllowConditions(Handle timer)
{
Minigame11_CanCheckConditions = true;
return Plugin_Handled;
}

public void Minigame11_OnMinigameSelected(int client)
Expand Down
Loading

0 comments on commit 2b1ae10

Please sign in to comment.