Skip to content

Commit

Permalink
Crowd Control can now be used in the single player campaign via new Mods
Browse files Browse the repository at this point in the history
menu options.  Also corrected some compiler warnings.
  • Loading branch information
theastropath committed Jan 1, 2023
1 parent 30f0e6b commit 3973c5c
Show file tree
Hide file tree
Showing 18 changed files with 648 additions and 20 deletions.
12 changes: 6 additions & 6 deletions Classes/Json.uc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static function string Start(string type)
return "{\"type\":\"" $ type $ "\"";
}

static function string Add(out string j, coerce string key, coerce string value)
static function Add(out string j, coerce string key, coerce string value)
{
j = j $ ",\"" $ key $ "\":\"" $ value $ "\"";
}
Expand All @@ -135,7 +135,7 @@ const KeyState = 1;
const ValState = 2;
const ArrayState = 3;
const ArrayDoneState = 4;
const EndState = 5;
const EndingState = 5;

function _parse(string msg) {
ParseJson(msg);
Expand Down Expand Up @@ -242,7 +242,7 @@ function int ParseKey(string msg, out int i, out IntPair p, out int inBraces) {
case "}":
inBraces--;
if(inBraces <= 0)
return EndState;
return EndingState;

case "]":
_buf = _buf $ c;
Expand Down Expand Up @@ -294,7 +294,7 @@ function int ParseVal(string msg, out int i, out IntPair p, out int inBraces) {
j.e[j.count].value[j.e[j.count].valCount] = p;
j.e[j.count].valCount++;
j.count++;
return EndState;
return EndingState;
}
break;

Expand Down Expand Up @@ -388,7 +388,7 @@ function int ParseArrayDone(string msg, out int i, out IntPair p, out int inBrac
case "}":
inBraces--;
if(inBraces <= 0)
return EndState;
return EndingState;

default:
//Build up the buffer
Expand Down Expand Up @@ -460,7 +460,7 @@ function ParseJson(string msg) {
case ArrayDoneState:
parsestate = ParseArrayDone(msg, i, p, inBraces);
break;
case EndState:
case EndingState:
return;
}
}
Expand Down
16 changes: 3 additions & 13 deletions Classes/UT99CCEffects.uc
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ function Swap(Actor a, Actor b)
{
local vector newloc, oldloc;
local rotator newrot;
local bool asuccess, bsuccess;
local Actor abase, bbase;
local bool AbCollideActors, AbBlockActors, AbBlockPlayers;
local EPhysics aphysics, bphysics;
Expand Down Expand Up @@ -893,7 +892,6 @@ function Bot AddBot(string botname)
local bot NewBot;
local NavigationPoint StartSpot;
local DeathMatchPlus game;
local int lowTeam;

game = DeathMatchPlus(Level.Game);

Expand Down Expand Up @@ -952,7 +950,6 @@ function ForcePawnToSpecificWeapon(Pawn p, class<Weapon> weaponClass)
function Weapon FindSpecificWeaponInPawnInventory(Pawn p,class<Weapon> weaponClass)
{
local actor Link;
local Weapon weap;

for( Link = p; Link!=None; Link=Link.Inventory )
{
Expand Down Expand Up @@ -1271,7 +1268,6 @@ function int GiveAmmo(String viewer, String ammoName, int amount)
}

function int doNudge(string viewer) {
local Rotator r;
local vector newAccel;
local Pawn p;

Expand Down Expand Up @@ -1314,10 +1310,7 @@ function int GiveWeapon(String viewer, String weaponName)
{
local class<Weapon> weaponClass;
local Pawn p;
local Inventory inv;
local Weapon weap;
local Actor a;


weaponClass = GetWeaponClassByName(weaponName);

foreach AllActors(class'Pawn',p) { //Probably could just iterate over PlayerPawns, but...
Expand All @@ -1328,6 +1321,8 @@ function int GiveWeapon(String viewer, String weaponName)
}

Broadcast(viewer$" gave everybody a weapon! ("$weaponName$")");

return Success;
}


Expand Down Expand Up @@ -1543,10 +1538,6 @@ function int ForceWeaponUse(String viewer, String weaponName)
{
local class<Weapon> weaponClass;
local Pawn p;
local PlayerPawn pp;
local Inventory inv;
local Weapon weap;
local Actor a;

if (forceWeaponTimer>0) {
return TempFail;
Expand Down Expand Up @@ -1580,7 +1571,6 @@ function int ForceWeaponUse(String viewer, String weaponName)


function int doCrowdControlEvent(string code, string param[5], string viewer, int type) {
local int i;

switch(code) {
case "sudden_death": //Everyone loses all armour and goes down to one health
Expand Down
29 changes: 29 additions & 0 deletions Classes/UT99CCEnemyBrowser.uc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class UT99CCEnemyBrowser extends UTMenu.EnemyBrowser;
function StartMap(string StartMap, int Rung, string GameType)
{
local int Team;
local Class<GameInfo> GameClass;

GameClass = Class<GameInfo>(DynamicLoadObject(GameType, Class'Class'));
GameClass.Static.ResetGame();

if ((GameType == "Botpack.DeathMatchPlus") ||
(GameType == "Botpack.DeathMatchPlusTest"))
Team = 255;
else
Team = 0;

StartMap = StartMap
$"?Game="$GameType
$"?Mutator=UT99CrowdControl.CrowdControl"
$"?Tournament="$Rung
$"?Name="$GetPlayerOwner().PlayerReplicationInfo.PlayerName
$"?Team="$Team;

Root.SetMousePos((Root.WinWidth*Root.GUIScale)/2, (Root.WinHeight*Root.GUIScale)/2);
Root.Console.CloseUWindow();
if ( TournamentGameInfo(GetPlayerOwner().Level.Game) != None )
TournamentGameInfo(GetPlayerOwner().Level.Game).LadderTransition(StartMap);
else
GetPlayerOwner().ClientTravel(StartMap, TRAVEL_Absolute, True);
}
47 changes: 47 additions & 0 deletions Classes/UT99CCLadderAS.uc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
class UT99CCLadderAS extends UTMenu.UTLadderAS;

//This only hits the tutorial... sigh
function StartMap(string StartMap, int Rung, string GameType)
{
local Class<GameInfo> GameClass;

GameClass = Class<GameInfo>(DynamicLoadObject(GameType, Class'Class'));
GameClass.Static.ResetGame();

StartMap = StartMap
$"?Game="$GameType
$"?Mutator=UT99CrowdControl.CrowdControl"
$"?Tournament="$Rung
$"?Name="$GetPlayerOwner().PlayerReplicationInfo.PlayerName
$"?Team=0";

Root.SetMousePos((Root.WinWidth*Root.GUIScale)/2, (Root.WinHeight*Root.GUIScale)/2);
Root.Console.CloseUWindow();
if ( TournamentGameInfo(GetPlayerOwner().Level.Game) != None )
TournamentGameInfo(GetPlayerOwner().Level.Game).LadderTransition(StartMap);
else
GetPlayerOwner().ClientTravel(StartMap, TRAVEL_Absolute, True);
}


function NextPressed()
{
local ObjectiveBrowser OB;

if (PendingPos > ArrowPos)
return;

HideWindow();
OB = UT99CCObjectiveBrowser(Root.CreateWindow(class'UT99CCObjectiveBrowser', 100, 100, 200, 200, Root, True));
OB.LadderWindow = Self;
OB.Ladder = Ladder;
OB.Match = SelectedMatch;
OB.GameType = GameType;
OB.Initialize();
}

function BackPressed()
{
Root.CreateWindow(class'UT99CCManagerWindow', 100, 100, 200, 200, Root, True);
Close();
}
67 changes: 67 additions & 0 deletions Classes/UT99CCLadderCTF.uc
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
class UT99CCLadderCTF extends UTMenu.UTLadderCTF;

//This only hits the tutorial... sigh
function StartMap(string StartMap, int Rung, string GameType)
{
local Class<GameInfo> GameClass;

GameClass = Class<GameInfo>(DynamicLoadObject(GameType, Class'Class'));
GameClass.Static.ResetGame();

StartMap = StartMap
$"?Game="$GameType
$"?Mutator=UT99CrowdControl.CrowdControl"
$"?Tournament="$Rung
$"?Name="$GetPlayerOwner().PlayerReplicationInfo.PlayerName
$"?Team=0";
Root.SetMousePos((Root.WinWidth*Root.GUIScale)/2, (Root.WinHeight*Root.GUIScale)/2);
Root.Console.CloseUWindow();
if ( TournamentGameInfo(GetPlayerOwner().Level.Game) != None )
TournamentGameInfo(GetPlayerOwner().Level.Game).LadderTransition(StartMap);
else
GetPlayerOwner().ClientTravel(StartMap, TRAVEL_Absolute, True);
}
function NextPressed()
{
local TeamBrowser TB;
local string MapName;
if (PendingPos > ArrowPos)
return;
if (SelectedMatch == 0)
{
MapName = LadderObj.CurrentLadder.Default.MapPrefix$Ladder.Static.GetMap(0);
if (class'UTLadderStub'.Static.IsDemo())
{
if (class'UTLadderStub'.Static.DemoHasTuts())
{
CloseUp();
StartMap(MapName, 0, "Botpack.TrainingCTF");
}
} else {
CloseUp();
StartMap(MapName, 0, "Botpack.TrainingCTF");
}
} else {
if (LadderObj.CurrentLadder.Default.DemoDisplay[SelectedMatch] == 1)
return;

HideWindow();
TB = UT99CCTeamBrowser(Root.CreateWindow(class'UT99CCTeamBrowser', 100, 100, 200, 200, Root, True));
TB.LadderWindow = Self;
TB.Ladder = LadderObj.CurrentLadder;
TB.Match = SelectedMatch;
TB.GameType = GameType;
TB.Initialize();
}
}

function BackPressed()
{
Root.CreateWindow(class'UT99CCManagerWindow', 100, 100, 200, 200, Root, True);
Close();
}
50 changes: 50 additions & 0 deletions Classes/UT99CCLadderChal.uc
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
class UT99CCLadderChal extends UTMenu.UTLadderChal;

//This only hits the tutorial... sigh
function StartMap(string StartMap, int Rung, string GameType)
{
local Class<GameInfo> GameClass;

GameClass = Class<GameInfo>(DynamicLoadObject(GameType, Class'Class'));
GameClass.Static.ResetGame();

StartMap = StartMap
$"?Game="$GameType
$"?Mutator=UT99CrowdControl.CrowdControl"
$"?Tournament="$Rung
$"?Name="$GetPlayerOwner().PlayerReplicationInfo.PlayerName
$"?Team=0";
Root.SetMousePos((Root.WinWidth*Root.GUIScale)/2, (Root.WinHeight*Root.GUIScale)/2);
Root.Console.CloseUWindow();
if ( TournamentGameInfo(GetPlayerOwner().Level.Game) != None )
TournamentGameInfo(GetPlayerOwner().Level.Game).LadderTransition(StartMap);
else
GetPlayerOwner().ClientTravel(StartMap, TRAVEL_Absolute, True);
}
function NextPressed()
{
local EnemyBrowser EB;
if (PendingPos > ArrowPos)
return;
HideWindow();
EB = UT99CCEnemyBrowser(Root.CreateWindow(class'UT99CCEnemyBrowser', 100, 100, 200, 200, Root, True));
EB.LadderWindow = Self;
EB.Ladder = Ladder;
EB.Match = SelectedMatch;
if (SelectedMatch == 3)
EB.GameType = "Botpack.ChallengeDMP";
else
EB.GameType = GameType;
EB.Initialize();
}

function BackPressed()
{
Root.CreateWindow(class'UT99CCManagerWindow', 100, 100, 200, 200, Root, True);
Close();
}
62 changes: 62 additions & 0 deletions Classes/UT99CCLadderDM.uc
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
class UT99CCLadderDM extends UTMenu.UTLadderDM;

//This only hits the tutorial... sigh
function StartMap(string StartMap, int Rung, string GameType)
{
local Class<GameInfo> GameClass;

GameClass = Class<GameInfo>(DynamicLoadObject(GameType, Class'Class'));
GameClass.Static.ResetGame();

StartMap = StartMap
$"?Game="$GameType
$"?Mutator=UT99CrowdControl.CrowdControl"
$"?Tournament="$Rung
$"?Name="$GetPlayerOwner().PlayerReplicationInfo.PlayerName
$"?Team=255";
Root.Console.CloseUWindow();
if ( TournamentGameInfo(GetPlayerOwner().Level.Game) != None )
TournamentGameInfo(GetPlayerOwner().Level.Game).LadderTransition(StartMap);
else
GetPlayerOwner().ClientTravel(StartMap, TRAVEL_Absolute, True);
}
function NextPressed()
{
local EnemyBrowser EB;
local string MapName;
if (PendingPos > ArrowPos)
return;
if (SelectedMatch == 0)
{
MapName = LadderObj.CurrentLadder.Default.MapPrefix$Ladder.Static.GetMap(0);
if (class'UTLadderStub'.Static.IsDemo())
{
if (class'UTLadderStub'.Static.DemoHasTuts())
{
CloseUp();
StartMap(MapName, 0, "Botpack.TrainingDM");
}
} else {
CloseUp();
StartMap(MapName, 0, "Botpack.TrainingDM");
}
} else {
HideWindow();
EB = UT99CCEnemyBrowser(Root.CreateWindow(class'UT99CCEnemyBrowser', 100, 100, 200, 200, Root, True));
EB.LadderWindow = Self;
EB.Ladder = LadderObj.CurrentLadder;
EB.Match = SelectedMatch;
EB.GameType = GameType;
EB.Initialize();
}
}

function BackPressed()
{
Root.CreateWindow(class'UT99CCManagerWindow', 100, 100, 200, 200, Root, True);
Close();
}
Loading

0 comments on commit 3973c5c

Please sign in to comment.