Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
safalin1 committed Jul 8, 2019
2 parents 3731260 + 9d644e3 commit f2b133c
Show file tree
Hide file tree
Showing 8 changed files with 380 additions and 20 deletions.
28 changes: 28 additions & 0 deletions src/scripting/AS-MicroTF2-MapChooser.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma semicolon 1
#define REQUIRE_PLUGIN

#include <sourcemod>
#include <sdktools>
#include <warioware>
#include <mapchooser>

#pragma newdecls required

public Plugin myinfo =
{
name = "WarioWare REDUX: SourceMod Mapchooser Integration",
author = "Gemidyne Softworks / Team WarioWare",
description = "SourceMod Mapchooser Plugin integration",
version = "1.0",
url = "https://www.gemidyne.com/"
}

public void WarioWare_Intermission_StartMapVote()
{
InitiateMapChooserVote(MapChange_MapEnd);
}

public bool WarioWare_Intermission_HasMapVoteEnded()
{
return !IsVoteInProgress();
}
58 changes: 41 additions & 17 deletions src/scripting/AS-MicroTF2.sp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <tf2>
#include <tf2_stocks>
#include <morecolors>
#include <warioware>

#undef REQUIRE_PLUGIN

Expand Down Expand Up @@ -39,11 +40,12 @@
*/
//#define DEBUG
//#define LOGGING_STARTUP
#define PLUGIN_VERSION "2019.2"
#define PLUGIN_VERSION "2019.2.1.0"
#define PLUGIN_PREFIX "\x0700FFFF[ \x07FFFF00WarioWare \x0700FFFF] {default}"

#include "Header.sp"
#include "Forwards.sp"
#include "PluginInterop.sp"
#include "MethodMaps/Player.inc"
#include "Weapons.sp"
#include "Voices.sp"
Expand All @@ -64,7 +66,7 @@

public Plugin myinfo =
{
name = "WarioWare",
name = "WarioWare REDUX",
author = "Gemidyne Softworks / Team WarioWare",
description = "Yet another WarioWare gamemode for Team Fortress 2",
version = PLUGIN_VERSION,
Expand All @@ -76,6 +78,14 @@ public void OnPluginStart()
InitializeSystem();
}

public APLRes AskPluginLoad2(Handle plugin, bool late, char[] error, int err_max)
{
RegPluginLibrary("warioware");
InitializePluginNatives();

return APLRes_Success;
}

public void OnPluginEnd()
{
if (IsPluginEnabled)
Expand Down Expand Up @@ -550,6 +560,15 @@ public Action Timer_GameLogic_EndMinigame(Handle timer)
PrintToChatAll("[DEBUG] %N: Participant, NotWon/Failed", i);
#endif

if (returnedFromBoss)
{
PluginForward_SendPlayerFailedBossgame(player.ClientId, PreviousBossgameID);
}
else
{
PluginForward_SendPlayerFailedMinigame(player.ClientId, PreviousMinigameID);
}

player.SetHealth(1);
player.SetGlow(true);

Expand Down Expand Up @@ -587,6 +606,15 @@ public Action Timer_GameLogic_EndMinigame(Handle timer)
PrintToChatAll("[DEBUG] %N: Participant, Winner", i);
#endif

if (returnedFromBoss)
{
PluginForward_SendPlayerWinBossgame(player.ClientId, PreviousBossgameID);
}
else
{
PluginForward_SendPlayerWinMinigame(player.ClientId, PreviousMinigameID);
}

PlaySoundToPlayer(i, SystemMusic[GamemodeID][SYSMUSIC_WINNER]);
PlayPositiveVoice(i);

Expand Down Expand Up @@ -709,6 +737,7 @@ public Action Timer_GameLogic_SpeedChange(Handle timer)
}

SetSpeed();
PluginForward_SendSpeedChange(SpeedLevel);

if (SpecialRoundID == 20)
{
Expand Down Expand Up @@ -850,6 +879,8 @@ public Action Timer_GameLogic_GameOverStart(Handle timer)
{
winnerCount++;

PluginForward_SendPlayerWinRound(i, player.Score);

player.SetRandomClass();
player.Regenerate();
player.SetViewModelVisible(true);
Expand All @@ -867,6 +898,8 @@ public Action Timer_GameLogic_GameOverStart(Handle timer)
}
else
{
PluginForward_SendPlayerLoseRound(i, player.Score);

player.SetThirdPersonMode(true);

TF2_StunPlayer(i, 8.0, 0.0, TF_STUNFLAGS_LOSERSTATE, 0);
Expand Down Expand Up @@ -1021,18 +1054,10 @@ public Action Timer_GameLogic_GameOverEnd(Handle timer)

if (GetConVarBool(ConVar_MTF2IntermissionEnabled) && MaxRounds != 0 && RoundsPlayed == (MaxRounds / 2))
{
#if defined UMC_MAPCHOOSER
// This should be using UMC_StartVote native, but that requires too many parameters... TODO: update this later on
ServerCommand("sm_umc_mapvote 2");
#else
InitiateMapChooserVote(MapChange_MapEnd);
#endif

PluginForward_StartMapVote();
isWaitingForVoteToFinish = true;
}

HideHudGamemodeText = true;

if (GetRandomInt(0, 2) == 1 || ForceNextSpecialRound)
{
// Special Round
Expand All @@ -1044,6 +1069,9 @@ public Action Timer_GameLogic_GameOverEnd(Handle timer)
GamemodeID = GetRandomInt(0, MaxGamemodesSelectable - 1);
}

PluginForward_SendGamemodeChanged(GamemodeID);
HideHudGamemodeText = true;

if (isWaitingForVoteToFinish)
{
for (int i = 1; i <= MaxClients; i++)
Expand Down Expand Up @@ -1079,13 +1107,9 @@ public Action Timer_GameLogic_GameOverEnd(Handle timer)

public Action Timer_GameLogic_WaitForVoteToFinishIfAny(Handle timer)
{
#if defined UMC_MAPCHOOSER
bool voteIsInProgress = UMC_IsVoteInProgress("core");
#else
bool voteIsInProgress = IsVoteInProgress();
#endif
bool voteHasEnded = PluginForward_HasMapVoteEnded();

if (voteIsInProgress)
if (!voteHasEnded)
{
CreateTimer(1.0, Timer_GameLogic_WaitForVoteToFinishIfAny, _, TIMER_FLAG_NO_MAPCHANGE);
return Plugin_Handled;
Expand Down
8 changes: 5 additions & 3 deletions src/scripting/Commands.sp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ stock void InitializeCommands()
RegAdminCmd("sm_triggerboss", CmdTriggerBoss, ADMFLAG_VOTE, "Triggers the boss round.");

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.", 0, true, 0.0, true, 1.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);

// Debug cvars/cmds
ConVar_MTF2ForceMinigame = CreateConVar("mtf2_debug_forceminigame", "0", "Forces a minigame to always be played. If 0, no minigame will be forced. This cvar is used only when debugging.", 0, true, 0.0);
Expand Down Expand Up @@ -173,12 +173,12 @@ public Action CmdSetNextSpecialRound(int client, int args)

int id = StringToInt(text);

if (id >= SPR_MIN && id <= SPR_MAX)
if (id >= SPR_MIN && id < SpecialRoundsLoaded)
{
ForceNextSpecialRound = true;
ForceSpecialRound = id;

ReplyToCommand(client, "%sThe next special round has been set as #%i.", PLUGIN_PREFIX, id);
ReplyToCommand(client, "%sThe next special round has been set to #%s.", PLUGIN_PREFIX, SpecialRounds[id]);
}
else
{
Expand Down Expand Up @@ -216,6 +216,8 @@ public Action CmdSetGamemode(int client, int args)
GamemodeID = id;

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

PluginForward_SendGamemodeChanged(id);
}
else
{
Expand Down
4 changes: 4 additions & 0 deletions src/scripting/MinigameSystem.sp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ public void DoSelectMinigame()
PrintToChatAll("[MINIGAMESYS] Chose minigame %i, minigame pool count: %i", MinigameID, PlayedMinigamePool.Length);
#endif
}

PluginForward_SendMinigameSelected(MinigameID);
}

public void DoSelectBossgame()
Expand Down Expand Up @@ -466,6 +468,8 @@ public void DoSelectBossgame()
#if defined DEBUG
PrintToChatAll("[MINIGAMESYS] Chose bossgame %i, bossgame pool count: %i", BossgameID, PlayedBossgamePool.Length);
#endif

PluginForward_SendBossgameSelected(BossgameID);
}

public bool TrySpeedChangeEvent()
Expand Down
162 changes: 162 additions & 0 deletions src/scripting/PluginInterop.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/**
* MicroTF2 - PluginInterop.sp
*
* Implements functionality for other SourceMod plugins to interact
* with the gamemode.
*/

Handle PluginForward_IntermissionStartMapVote;
Handle PluginForward_IntermissionHasMapVoteEnded;
Handle PluginForward_EventOnMinigameSelected;
Handle PluginForward_EventOnBossgameSelected;
Handle PluginForward_EventOnPlayerWinMinigame;
Handle PluginForward_EventOnPlayerFailedMinigame;
Handle PluginForward_EventOnPlayerWinBossgame;
Handle PluginForward_EventOnPlayerFailedBossgame;
Handle PluginForward_EventOnPlayerWinRound;
Handle PluginForward_EventOnPlayerLoseRound;
Handle PluginForward_EventOnGamemodeChanged;
Handle PluginForward_EventOnSpeedChange;
Handle PluginForward_EventOnSpecialRoundSelected;

stock void InitializePluginForwards()
{
PluginForward_IntermissionStartMapVote = CreateGlobalForward("WarioWare_Intermission_StartMapVote", ET_Ignore);
PluginForward_IntermissionHasMapVoteEnded = CreateGlobalForward("WarioWare_Intermission_HasMapVoteEnded", ET_Single);
PluginForward_EventOnMinigameSelected = CreateGlobalForward("WarioWare_Event_OnMinigameSelected", ET_Ignore, Param_Any);
PluginForward_EventOnBossgameSelected = CreateGlobalForward("WarioWare_Event_OnBossgameSelected", ET_Ignore, Param_Any);
PluginForward_EventOnPlayerWinMinigame = CreateGlobalForward("WarioWare_Event_OnPlayerWinMinigame", ET_Ignore, Param_Any, Param_Any);
PluginForward_EventOnPlayerFailedMinigame = CreateGlobalForward("WarioWare_Event_OnPlayerFailedMinigame", ET_Ignore, Param_Any, Param_Any);
PluginForward_EventOnPlayerWinBossgame = CreateGlobalForward("WarioWare_Event_OnPlayerWinBossgame", ET_Ignore, Param_Any, Param_Any);
PluginForward_EventOnPlayerFailedBossgame = CreateGlobalForward("WarioWare_Event_OnPlayerFailedBossgame", ET_Ignore, Param_Any, Param_Any);
PluginForward_EventOnPlayerWinRound = CreateGlobalForward("WarioWare_Event_OnPlayerWinRound", ET_Ignore, Param_Any, Param_Any);
PluginForward_EventOnPlayerLoseRound = CreateGlobalForward("WarioWare_Event_OnPlayerLoseRound", ET_Ignore, Param_Any, Param_Any);
PluginForward_EventOnGamemodeChanged = CreateGlobalForward("WarioWare_Event_OnGamemodeChanged", ET_Ignore, Param_Any);
PluginForward_EventOnSpeedChange = CreateGlobalForward("WarioWare_Event_OnSpeedChange", ET_Ignore, Param_Float);
PluginForward_EventOnSpecialRoundSelected = CreateGlobalForward("WarioWare_Event_OnSpecialRoundSelected", ET_Ignore, Param_Any);
}

stock void InitializePluginNatives()
{
CreateNative("WarioWare_GetMaxRounds", Native_WarioWare_GetMaxRounds);
CreateNative("WarioWare_SetMaxRounds", Native_WarioWare_SetMaxRounds);
}

stock void RemovePluginForwardsFromMemory()
{
SafelyRemoveAllFromForward(PluginForward_IntermissionStartMapVote);
SafelyRemoveAllFromForward(PluginForward_IntermissionHasMapVoteEnded);
}

public void PluginForward_StartMapVote()
{
Call_StartForward(PluginForward_IntermissionStartMapVote);
Call_Finish();
}

public bool PluginForward_HasMapVoteEnded()
{
bool voteIsInProgress = false;

Call_StartForward(PluginForward_IntermissionHasMapVoteEnded);
Call_Finish(voteIsInProgress);

return voteIsInProgress;
}

public void PluginForward_SendMinigameSelected(int minigameId)
{
Call_StartForward(PluginForward_EventOnMinigameSelected);
Call_PushCell(minigameId);
Call_Finish();
}

public void PluginForward_SendBossgameSelected(int bossgameId)
{
Call_StartForward(PluginForward_EventOnBossgameSelected);
Call_PushCell(bossgameId);
Call_Finish();
}

public void PluginForward_SendPlayerWinMinigame(int client, int minigameId)
{
Call_StartForward(PluginForward_EventOnPlayerWinMinigame);
Call_PushCell(client);
Call_PushCell(minigameId);
Call_Finish();
}

public void PluginForward_SendPlayerFailedMinigame(int client, int minigameId)
{
Call_StartForward(PluginForward_EventOnPlayerFailedMinigame);
Call_PushCell(client);
Call_PushCell(minigameId);
Call_Finish();
}

public void PluginForward_SendPlayerWinBossgame(int client, int bossgameId)
{
Call_StartForward(PluginForward_EventOnPlayerWinBossgame);
Call_PushCell(client);
Call_PushCell(bossgameId);
Call_Finish();
}

public void PluginForward_SendPlayerFailedBossgame(int client, int bossgameId)
{
Call_StartForward(PluginForward_EventOnPlayerFailedBossgame);
Call_PushCell(client);
Call_PushCell(bossgameId);
Call_Finish();
}

public void PluginForward_SendPlayerWinRound(int client, int score)
{
Call_StartForward(PluginForward_EventOnPlayerWinRound);
Call_PushCell(client);
Call_PushCell(score);
Call_Finish();
}

public void PluginForward_SendPlayerLoseRound(int client, int score)
{
Call_StartForward(PluginForward_EventOnPlayerLoseRound);
Call_PushCell(client);
Call_PushCell(score);
Call_Finish();
}

public void PluginForward_SendGamemodeChanged(int gamemodeId)
{
Call_StartForward(PluginForward_EventOnGamemodeChanged);
Call_PushCell(gamemodeId);
Call_Finish();
}

public void PluginForward_SendSpeedChange(float speed)
{
Call_StartForward(PluginForward_EventOnSpeedChange);
Call_PushFloat(speed);
Call_Finish();
}

public void PluginForward_SendSpecialRoundSelected(int id)
{
Call_StartForward(PluginForward_EventOnSpecialRoundSelected);
Call_PushCell(id);
Call_Finish();
}

public int Native_WarioWare_GetMaxRounds(Handle plugin, int numParams)
{
return MaxRounds;
}

public int Native_WarioWare_SetMaxRounds(Handle plugin, int numParams)
{
int value = GetNativeCell(1);

SetConVarInt(ConVar_MTF2MaxRounds, value);

return 0;
}
Loading

0 comments on commit f2b133c

Please sign in to comment.