private static void CCChangeTeam(ConCommandArgs args) { if (args.Count == 0) { Log.Message(MagicVars.TEAM_ARGS); return; } CharacterMaster master = args.sender.master; if (args.Count > 1) { NetworkUser player = GetNetUserFromString(args[1]); if (player != null) { master = player.master; } } if (Enum.TryParse(Alias.GetEnumFromPartial <TeamIndex>(args[0]).ToString(), true, out TeamIndex teamIndex)) { if ((int)teamIndex >= (int)TeamIndex.None && (int)teamIndex < (int)TeamIndex.Count) { if (master.GetBody()) { master.GetBody().teamComponent.teamIndex = teamIndex; master.teamIndex = teamIndex; Log.Message("Changed to team " + teamIndex); return; } } } //Note the `return` on succesful evaluation. Log.Message("Invalid team. Please use 0,'neutral',1,'player',2, or 'monster'"); }
private static void CCKillAll(ConCommandArgs args) { TeamIndex team; if (args.Count == 0) { team = TeamIndex.Monster; } else { team = Alias.GetEnumFromPartial <TeamIndex>(args[0]); } int count = 0; foreach (CharacterMaster cm in FindObjectsOfType <CharacterMaster>()) { if (cm.teamIndex == team) { CharacterBody cb = cm.GetBody(); if (cb) { if (cb.healthComponent) { cb.healthComponent.Suicide(null); count++; } } } } Log.Message("Killed " + count + " of team " + team + "."); }
private static void CCNextBoss(ConCommandArgs args) { Log.Message(Lang.PARTIALIMPLEMENTATION_WARNING, args, LogLevel.MessageClientOnly); if (args.Count == 0) { Log.Message(Lang.NEXTBOSS_ARGS, args); } StringBuilder s = new StringBuilder(); if (args.Count >= 1) { try { nextBoss = Alias.Instance.GetDirectorCardFromPartial(args[0]); s.AppendLine($"Next boss is: {nextBoss.spawnCard.name}. "); if (args.Count >= 2) { if (!int.TryParse(args[1], out nextBossCount)) { Log.Message(Lang.COUNTISNUMERIC, args, LogLevel.MessageClientOnly); nextBossCount = 1; } else { if (nextBossCount > 6) { nextBossCount = 6; } else if (nextBossCount <= 0) { nextBossCount = 1; } s.Append($"Count: {nextBossCount}. "); if (args.Count >= 3) { nextBossElite = Alias.GetEnumFromPartial <EliteIndex>(args[2]); s.Append("Elite: " + nextBossElite.ToString()); } } } On.RoR2.CombatDirector.SetNextSpawnAsBoss += Hooks.CombatDirector_SetNextSpawnAsBoss; Log.Message(s.ToString(), args); } catch (Exception ex) { Log.Message(Lang.OBJECT_NOTFOUND + args[0], args, LogLevel.ErrorClientOnly); Log.Message(ex.ToString(), args, LogLevel.ErrorClientOnly); } } }
private static void CCNextBoss(ConCommandArgs args) { Log.Message(MagicVars.PARTIAL_IMPLEMENTATION); if (args.Count == 0) { Log.Message(MagicVars.NEXTBOSS_ARGS); } if (args.Count >= 1) { try { RoR2Cheats.nextBoss = Alias.Instance.GetDirectorCardFromPartial(args[0]); Log.Message($"Next boss is: {RoR2Cheats.nextBoss.spawnCard.name}"); if (args.Count >= 2) { if (!int.TryParse(args[1], out nextBossCount)) { Log.Message(MagicVars.COUNTISNUMERIC); return; } else { if (nextBossCount > 6) { nextBossCount = 6; } else if (nextBossCount <= 0) { nextBossCount = 1; } Log.Message("Count: " + nextBossCount); if (args.Count >= 3) { nextBossElite = Alias.GetEnumFromPartial <EliteIndex>(args[2]); Log.Message("Elite: " + nextBossElite.ToString()); } } } nextBossSet = true; } catch (Exception ex) { Log.Message(MagicVars.OBJECT_NOTFOUND + args[0]); Log.Message(ex); } } }
private static void CCSpawnAI(ConCommandArgs args) { if (args.Count == 0) { Log.Message(MagicVars.SPAWNAI_ARGS); return; } string character = Alias.Instance.GetMasterName(args[0]); if (character == null) { Log.Message(MagicVars.SPAWN_ERROR + character); return; } var masterprefab = MasterCatalog.FindMasterPrefab(character); var body = masterprefab.GetComponent <CharacterMaster>().bodyPrefab; var bodyGameObject = Instantiate <GameObject>(masterprefab, args.sender.master.GetBody().transform.position, Quaternion.identity); CharacterMaster master = bodyGameObject.GetComponent <CharacterMaster>(); NetworkServer.Spawn(bodyGameObject); master.SpawnBody(body, args.sender.master.GetBody().transform.position, Quaternion.identity); if (args.Count > 1) { var eliteIndex = Alias.GetEnumFromPartial <EliteIndex>(args[1]); master.inventory.SetEquipmentIndex(EliteCatalog.GetEliteDef(eliteIndex).eliteEquipmentIndex); master.inventory.GiveItem(ItemIndex.BoostHp, Mathf.RoundToInt((GetTierDef(eliteIndex).healthBoostCoefficient - 1) * 10)); master.inventory.GiveItem(ItemIndex.BoostDamage, Mathf.RoundToInt((GetTierDef(eliteIndex).damageBoostCoefficient - 1) * 10)); } if (args.Count > 2 && Enum.TryParse <TeamIndex>(Alias.GetEnumFromPartial <TeamIndex>(args[2]).ToString(), true, out TeamIndex teamIndex)) { if ((int)teamIndex >= (int)TeamIndex.None && (int)teamIndex < (int)TeamIndex.Count) { master.teamIndex = teamIndex; } } if (args.Count > 3 && bool.TryParse(args[3], out bool braindead) && braindead) { Destroy(master.GetComponent <BaseAI>()); } Log.Message(MagicVars.SPAWN_ATTEMPT + character); }
private static void CCGetTeamIndexPartial(ConCommandArgs args) { //Alias.Instance.GetMasterName(args[0]); Log.Message(Alias.GetEnumFromPartial <TeamIndex>(args[0]).ToString()); }