Skip to content

Commit

Permalink
Add "Swap all enemies" and "swap all items" crowd control effects
Browse files Browse the repository at this point in the history
  • Loading branch information
theastropath committed Mar 9, 2024
1 parent 4594ff3 commit ff42f40
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
2 changes: 2 additions & 0 deletions DXRando.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public DeusEx(UserRecord player, Func<CrowdControlBlock, bool> responseHandler,
new Effect ("Ask a Question","ask_a_question"){Price = 5,Description = "Make a dialog box appear on screen with a question while the game continues in behind!"}, //New for second Crowd Control batch
new Effect ("Nudge","nudge"){Price = 1,Description = "Just ever so slightly... nudge... the player in a random direction"}, //New for second Crowd Control batch
new Effect ("Swap Player with another human","swap_player_position"){Price = 40,Description = "Finds another human somewhere in the current level and swaps their position with the player!"}, //New for second Crowd Control batch
new Effect ("Swap all enemies positions","swap_enemies"){Price = 20,Description = "Shuffles all the enemies in the level into each others locations!"}, //New for fifth Crowd Control batch
new Effect ("Swap all item positions","swap_items"){Price = 5,Description = "Shuffles all the inventory items in the level into each others locations!"}, //New for fifth Crowd Control batch
new Effect ("Float Away","floaty_physics"){Price = 100,Description = "Suddenly gravity feels very light and everything starts floating up into the sky...",Duration=30}, //New for second Crowd Control batch
new Effect ("Floor is Lava","floor_is_lava"){Price = 75,Description = "Floor is lava! If the player doesn't keep jumping or get up on top of something, they're gonna burn!",Duration=60}, //New for second Crowd Control batch
new Effect ("Invert Mouse Controls","invert_mouse"){Price = 20,Description = "Up is down and down is up!",Duration=60}, //New for second Crowd Control batch
Expand Down
87 changes: 87 additions & 0 deletions DXRando/DeusEx/Classes/DXRandoCrowdControlEffects.uc
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,69 @@ function bool canDropItem() {

}

function bool CanSwapEnemies()
{
local int numEnemies;
local ScriptedPawn a;

numEnemies=0;
foreach AllActors(class'ScriptedPawn', a )
{
if( a.bHidden || a.bStatic ) continue;
if( a.bImportant || a.bIsSecretGoal ) continue;
if( ccLink.ccModule.IsCritter(a) ) continue;
if( !ccLink.ccModule.IsInitialEnemy(a) ) continue;
if( a.Region.Zone.bWaterZone || a.Region.Zone.bPainZone ) continue;
if( #var(prefix)Robot(a) != None && a.Orders == 'Idle' ) continue;
#ifdef gmdx
if( SpiderBot2(a) != None && SpiderBot2(a).bUpsideDown ) continue;
#endif
numEnemies++;
}

//As long as there are two possible enemies...
return numEnemies > 1;
}

function bool SwapAllEnemies(string viewer)
{
local DXREnemiesShuffle enemies;

foreach AllActors(class'DXREnemiesShuffle',enemies){break;}

if (enemies==None) return False; //Failed to find DXREnemiesShuffle

enemies.SwapScriptedPawns(100,true);

PlayerMessage(viewer@"swapped the position of all the enemies in the level!");

return true;
}

function bool CanSwapItems()
{
local int numItems;
local Inventory inv;

numItems=0;
foreach AllActors(class'Inventory',inv){
if (!ccLink.ccModule.SkipActor(inv)){
numItems++;
}
}

return numItems>1;
}

function bool SwapAllItems(string viewer)
{
ccLink.ccModule.SwapAll("Engine.Inventory",100);

PlayerMessage(viewer@"swapped the position of all the inventory items in the level!");

return true;
}

function SplitString(string src, string divider, out string parts[8])
{
local int i, c;
Expand Down Expand Up @@ -1831,6 +1894,30 @@ function int doCrowdControlEvent(string code, string param[5], string viewer, in
}
break;

case "swap_enemies":
if (!InGame()) {
return TempFail;
}
if (!CanSwapEnemies()){
return TempFail;
}
if (SwapAllEnemies(viewer) == false) {
return TempFail;
}
break;

case "swap_items":
if (!InGame()) {
return TempFail;
}
if (!CanSwapItems()){
return TempFail;
}
if (SwapAllItems(viewer) == false) {
return TempFail;
}
break;

case "floaty_physics":
if (isTimerActive('cc_floatyTimer')) {
return TempFail;
Expand Down
4 changes: 3 additions & 1 deletion DXRando/DeusEx/Classes/DXRandoCrowdControlLink.uc
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function int RandomOfflineEffects() {
viewer = "Simulated Crowd Control";
param[0] = "1";

switch(Rand(83)) {
switch(Rand(85)) {
case 0: if(Rand(2)==0){ return 0; } else { return ccEffects.doCrowdControlEvent("poison", param, viewer, 0, 0); }
case 1: return ccEffects.doCrowdControlEvent("glass_legs", param, viewer, 0, 0);
case 2: param[0] = string(Rand(20)); return ccEffects.doCrowdControlEvent("give_health", param, viewer, 0, 0);
Expand Down Expand Up @@ -269,6 +269,8 @@ function int RandomOfflineEffects() {
case 80: return ccEffects.doCrowdControlEvent("spawnenemy_greasel", param, viewer, 0, 0);
case 81: return ccEffects.doCrowdControlEvent("nasty_rat", param, viewer, 0, 0);
case 82: return ccEffects.doCrowdControlEvent("drop_piano", param, viewer, 0, 0);
case 83: return ccEffects.doCrowdControlEvent("swap_enemies", param, viewer, 0, 0);
case 84: return ccEffects.doCrowdControlEvent("swap_items", param, viewer, 0, 0);
}

return 0;
Expand Down

0 comments on commit ff42f40

Please sign in to comment.