Skip to content

Commit 3f4b08e

Browse files
committed
Add an ally team option to spawn_ai
Useful for directly adding drones to yourself without having to spawn broken interactables and buying them.
1 parent d5c17c4 commit 3f4b08e

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

Code/DT-Commands/Spawners.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,23 @@ private static void CCSpawnAI(ConCommandArgs args)
218218
return;
219219
}
220220

221+
bool isAlly = false;
221222
TeamIndex teamIndex = TeamIndex.Monster;
222223
if (args.Count > 4 && args[4] != Lang.DEFAULT_VALUE)
223224
{
224-
teamIndex = StringFinder.Instance.GetTeamFromPartial(args[4]);
225-
if (teamIndex == StringFinder.TeamIndex_NotFound)
225+
if (args[4].ToUpperInvariant() == Lang.ALLY)
226226
{
227-
Log.MessageNetworked(Lang.TEAM_NOTFOUND, args, LogLevel.MessageClientOnly);
228-
return;
227+
isAlly = true;
228+
teamIndex = args.senderBody.teamComponent.teamIndex;
229+
}
230+
else
231+
{
232+
teamIndex = StringFinder.Instance.GetTeamFromPartial(args[4]);
233+
if (teamIndex == StringFinder.TeamIndex_NotFound)
234+
{
235+
Log.MessageNetworked(Lang.TEAM_NOTFOUND, args, LogLevel.MessageClientOnly);
236+
return;
237+
}
229238
}
230239
}
231240

@@ -253,6 +262,7 @@ private static void CCSpawnAI(ConCommandArgs args)
253262
},
254263
RoR2Application.rng
255264
);
265+
spawnRequest.summonerBodyObject = isAlly ? args.senderBody.gameObject : null;
256266
spawnRequest.teamIndexOverride = teamIndex;
257267
spawnRequest.ignoreTeamMemberLimit = true;
258268

Code/Lang.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public const string
5353
RUNSETWAVESCLEARED_ARGS = "Requires 1 argument {wave}",
5454
SEED_ARGS = "Requires 0 or 1 argument: [new_seed]",
5555
SETARTIFACT_ARGS = "Requires 1 (2 if using 'all') argument: {artifact (artifact|'all')} [enable (0|1)]",
56-
SPAWNAI_ARGS = "Requires 1 argument: {ai} [count:1] [elite:None] [braindead (0|1):0/false] [team:Monster]",
56+
SPAWNAI_ARGS = "Requires 1 argument: {ai} [count:1] [elite:None] [braindead (0|1):0/false] [team (team|'ally'):Monster]",
5757
SPAWNAS_ARGS = "Requires 1 (2 if from server) argument: {body} [player:<self>]",
5858
SPAWNBODY_ARGS = "Requires 1 argument: {body}",
5959
SPAWNINTERACTABLE_ARGS = "Requires 1 argument: {interactable}",
@@ -203,6 +203,7 @@ public const string
203203
// Keywords
204204
public const string
205205
ALL = "ALL",
206+
ALLY = "ALLY",
206207
BOTH = "BOTH",
207208
COIN_LUNAR = "LUNARCOIN",
208209
COIN_VOID = "VOIDCOIN",

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Spawn Commands:
126126

127127
* **spawn_interactable/spawn_interactible** - Spawns an interactible in front of the player. `(spawn_interactable|spawn_interactible) {interactable}`
128128
* **spawn_portal** - Spawns a portal in front of the player. `spawn_portal {portal ('artifact'|'blue'|'celestial'|'deepvoid'|'gold'|'green'|'null'|'void')}`.
129-
* **spawn_ai** - Spawn an AI. `spawn_ai {ai} [count:1] [elite:None] [braindead (0|1):0/false] [team:Monster]`.
129+
* **spawn_ai** - Spawn an AI. `spawn_ai {ai} [count:1] [elite:None] [braindead (0|1):0/false] [team (team|'ally'):Monster]`.
130130
* **spawn_as** - Spawn as a new character. `spawn_as {body} *[player:<self>]`
131131
* **spawn_body** - Spawns a CharacterBody with no AI, inventory, or team alliance: `spawn_body {body}`
132132
* **change_team** - Change a player's team. `change_team {team} *[player:<self>]`.

0 commit comments

Comments
 (0)