-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
class Randomizer extends Mutator; | ||
|
||
function InitRando() | ||
{ | ||
ShuffleItems(); | ||
} | ||
|
||
function ShuffleItems() | ||
{ | ||
local Inventory item, items[512], weapons[128]; | ||
local int num_items, num_weapons, i, slot; | ||
|
||
foreach AllActors(class'Inventory', item) { | ||
if(item.Owner != None) continue; | ||
if(Weapon(item) != None) | ||
weapons[num_weapons++] = item; | ||
else | ||
items[num_items++] = item; | ||
} | ||
|
||
for(i=0; i<num_items; i++) { | ||
slot = Rand(num_items); | ||
if(slot != i) | ||
SwapActors(items[i], items[slot]); | ||
} | ||
|
||
for(i=0; i<num_weapons; i++) { | ||
slot = Rand(num_weapons); | ||
if(slot != i) | ||
SwapActors(weapons[i], weapons[slot]); | ||
} | ||
} | ||
|
||
function SwapActors(Actor a, Actor b) | ||
{ | ||
local vector locA; | ||
local Rotator rotA; | ||
|
||
locA = a.Location; | ||
rotA = a.Rotation; | ||
a.SetLocation(b.Location); | ||
a.SetRotation(b.Rotation); | ||
b.SetLocation(locA); | ||
b.SetRotation(rotA); | ||
} | ||
|
||
simulated function PreBeginPlay() | ||
{ | ||
InitRando(); | ||
CheckServerPackages(); | ||
} | ||
|
||
function CheckServerPackages() | ||
{ | ||
local string packages; | ||
|
||
if (Level.NetMode!=NM_DedicatedServer && Level.NetMode!=NM_ListenServer){ | ||
//Not hosting a server, don't worry about it | ||
return; | ||
} | ||
|
||
packages=ConsoleCommand("get Engine.GameEngine ServerPackages"); | ||
if (InStr(packages,"UT99CrowdControl")!=-1){ | ||
log("UT99CrowdControl is set in ServerPackages! Nice!"); | ||
} else { | ||
log("UT99CrowdControl is not set in ServerPackages! Bummer!"); | ||
packages = Left(packages,Len(packages)-1)$",\"UT99CrowdControl\")"; | ||
log("Added UT99CrowdControl to ServerPackages!"); | ||
ConsoleCommand("set Engine.GameEngine ServerPackages "$packages); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
//Reload the level so that the serverpackages gets updated for real | ||
log("Restarting game so that ServerPackages are reloaded"); | ||
Level.ServerTravel( "?Restart", false ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[Public] | ||
|
||
Object=(Name=UT99CrowdControl.CrowdControl,Class=Class,MetaClass=Engine.Mutator,Description="Crowd Control support for UT99") | ||
Object=(Name=UT99CrowdControl.Randomizer,Class=Class,MetaClass=Engine.Mutator,Description="Randomizer for UT99") | ||
Object=(Name=UT99CrowdControl.UT99CCStartTournyMenuItem,Class=Class,MetaClass=UMenu.UMenuModMenuItem,Description="Start Crowd Control Tournament,Crowd Control Tournament") | ||
Object=(Name=UT99CrowdControl.UT99CCLoadTournyMenuItem,Class=Class,MetaClass=UMenu.UMenuModMenuItem,Description="Resume Crowd Control Tournament,Crowd Control Tournament") |
I'm wondering if there should be a called to SaveConfig() here