public void PlayerChallenge(string playerName) { if (!Config.Instance.EnableConflict || Core.NexusDetected) { Context.Respond("Conflict is not enabled"); return; } if (string.IsNullOrEmpty(playerName)) { Context.Respond("Command requires the name of the player you wish to challenge"); } var id = Context.Player.IdentityId; if (id == 0) { Context.Respond("This command can only be used ingame"); return; } var subjectId = Utilities.IdentityUtility.GetPlayerId(playerName); if (subjectId == 0) { Context.Respond("Challenge failed. Player with name " + playerName + " not found or not online"); return; } ConflictPairModule.IssueChallenge(id, subjectId, ConflictPairModule.ConflictType.Player, Context.Player.SteamUserId); }
private static bool DamageFaction(MyFactionCollection __instance, long playerIdentityId, long attackedIdentityId, MyReputationDamageType repDamageType) { if (MySession.Static.Players.IdentityIsNpc(playerIdentityId) || MySession.Static.Players.IdentityIsNpc(attackedIdentityId)) { return(true); } return((Config.Instance.EnableConflict && ConflictPairModule.InConflict(playerIdentityId, attackedIdentityId, out var foundPair) && foundPair.CurrentConflictState == ConflictPairModule.ConflictState.Active) || MySession.Static.Factions.GetNpcFactions().Any(x => x.Members.ContainsKey(playerIdentityId) || x.Members.ContainsKey(attackedIdentityId))); }
public void AcceptChallenge() { if (!Config.Instance.EnableConflict || Core.NexusDetected) { Context.Respond("Conflict is not enabled"); return; } if (Context.Player == null) { Context.Respond("This command can only be used ingame"); return; } var playerId = Context.Player.IdentityId; if (Context.Args?.Count == 0) { if (ConflictPairModule.AcceptChallenge(playerId, Context.Player.SteamUserId) == 0) { Context.Respond("No pending conflict found"); return; } } if (Context.Args != null) { var factionId = Utilities.IdentityUtility.GetFactionId(Context.Args[0]); var challengingPlayerId = Utilities.IdentityUtility.GetPlayerId(Context.Args[0]); if (factionId > 0) { var playerFaction = MySession.Static.Factions.TryGetPlayerFaction(playerId); if (playerFaction == null || (!playerFaction.IsFounder(playerId) && !playerFaction.IsLeader(playerId))) { Context.Respond("You either do not belong to a faction or do not have permission to accept challenge"); return; } ConflictPairModule.AcceptChallenge(playerFaction.FactionId, factionId, ConflictPairModule.ConflictType.Faction, Context.Player.SteamUserId); return; } if (challengingPlayerId > 0) { ConflictPairModule.AcceptChallenge(playerId, challengingPlayerId, ConflictPairModule.ConflictType.Player, Context.Player.SteamUserId); return; } Context.Respond($"{Context.Args[0]} not found"); } }
public void RecheckReputations() { var playerFactions = new HashSet <MyFaction>(MySession.Static.Factions.Select(x => x.Value).Where(x => !x.IsEveryoneNpc())); if (playerFactions.Count == 0) { return; } var players = new HashSet <MyIdentity>(MySession.Static.Players.GetAllIdentities().Where(x => !MySession.Static.Players.IdentityIsNpc(x.IdentityId))); int count = 0; foreach (var player in players) { var playerFaction = MySession.Static.Factions.GetPlayerFaction(player.IdentityId); foreach (var faction in playerFactions) { var relation = MySession.Static.Factions.GetRelationBetweenPlayerAndFaction(player.IdentityId, faction.FactionId); if (relation == null || !MySession.Static.Factions.HasRelationWithPlayer(player.IdentityId, faction.FactionId)) { continue; } count++; if (MySession.Static.Factions.GetRelationBetweenPlayerAndFaction(player.IdentityId, faction.FactionId) == null) { if (!Config.Instance.EnableConflict || !ConflictPairModule.InConflict(playerFaction.FactionId, faction.FactionId, out var foundPair) || foundPair.CurrentConflictState == ConflictPairModule.ConflictState.PendingConflict) { MySession.Static.Factions.SetReputationBetweenPlayerAndFaction(player.IdentityId, faction.FactionId, 0); continue; } } MySession.Static.Factions.SetReputationBetweenPlayerAndFaction(player.IdentityId, faction.FactionId, -500); } } Log.Warn($"{count} reputation changes made"); }
private static bool ChangeRequest(MyFactionStateChange action, long fromFactionId, long toFactionId, long playerId) { if (MySession.Static.Factions.IsNpcFaction(fromFactionId) || MySession.Static.Factions.IsNpcFaction(toFactionId) || MySession.Static.Players.IdentityIsNpc(playerId)) { return(true); } if (action != MyFactionStateChange.DeclareWar) { return(true); } if (Config.Instance.EnableConflict && ConflictPairModule.InConflict(fromFactionId, toFactionId, out var foundPair) && foundPair.CurrentConflictState == ConflictPairModule.ConflictState.Active) { return(true); } ConflictPairModule.IssueChallenge(fromFactionId, toFactionId, ConflictPairModule.ConflictType.Faction, MyEventContext.Current.Sender.Value); Core.RequestFactionChange(MyFactionStateChange.AcceptPeace, fromFactionId, toFactionId, playerId); return(false); }
public void FactionChallenge(string factionNameOrTag) { if (!Config.Instance.EnableConflict || Core.NexusDetected) { Context.Respond("Conflict is not enabled"); return; } if (string.IsNullOrEmpty(factionNameOrTag)) { Context.Respond("Command requires the faction name or tag you wish to challenge"); } var playerId = Context.Player.IdentityId; if (playerId == 0) { Context.Respond("This command can only be used ingame"); return; } var playerFaction = MySession.Static.Factions.GetPlayerFaction(Context.Player.IdentityId); var subjectId = Utilities.IdentityUtility.GetFactionId(factionNameOrTag); if (subjectId == 0 || playerFaction == null || (!playerFaction.IsLeader(playerId) && !playerFaction.IsFounder(playerId))) { Context.Respond("Faction error. This command requires you to be the founder or leader of your faction and a valid faction name or tag to issue challenge"); return; } if (MySession.Static.Factions.IsNpcFaction(subjectId)) { Context.Respond("Command cannot be used with NPC faction"); return; } ConflictPairModule.IssueChallenge(playerFaction.FactionId, subjectId, ConflictPairModule.ConflictType.Faction, Context.Player.SteamUserId); }
public void PlayerSubmit(string playerName) { if (!Config.Instance.EnableConflict || Core.NexusDetected) { Context.Respond("Conflict is not enabled"); return; } if (string.IsNullOrEmpty(playerName)) { Context.Respond("Command requires the player name or tag you wish to challenge"); } var playerId = Utilities.IdentityUtility.GetPlayerId(playerName); if (playerId == 0) { Context.Respond("This command can only be used ingame"); return; } ConflictPairModule.RequestSubmit(playerId, Context.Player.SteamUserId); }
private static void ProcessDamage(object target, ref MyDamageInformation info) { if (!Config.Instance.EnablePlugin) { return; } long id; var attackerId = info.AttackerId; switch (target) { case MySlimBlock block: id = block.CubeGrid.BigOwners.Count > 0 ? block.CubeGrid.BigOwners[0]:0; if (Config.Instance.PvpZones?.Count > 0) { foreach (var zone in Config.Instance.PvpZones) { if (!zone.IsWithinZoneRadius(block.CubeGrid)) { continue; } return; } } break; case MyCharacter _: return; case MyCubeGrid grid: id = grid.BigOwners.Count > 0 ? grid.BigOwners[0]:0; if (Config.Instance.PvpZones?.Count > 0) { foreach (var zone in Config.Instance.PvpZones) { if (!zone.IsWithinZoneRadius(grid)) { continue; } return; } } break; default: id = 0; break; } if (MyEntities.TryGetEntityById(attackerId, out var attacker, true)) { if (attacker is MyVoxelBase) { return; } if (attacker is MyCubeBlock block) { attackerId = block.CubeGrid.BigOwners.Count > 0 ? block.CubeGrid.BigOwners[0] : 0; } if (attacker is MyHandToolBase handTool) { attackerId = handTool.OwnerIdentityId; } if (attacker is MyAngleGrinder grinder) { attackerId = grinder.OwnerIdentityId; } if (attacker is MyUserControllableGun controllableGun) { attackerId = controllableGun.CubeGrid.BigOwners.Count > 0 ? controllableGun.CubeGrid.BigOwners[0] : 0; } if (attacker is MyAutomaticRifleGun gun) { attackerId = gun.OwnerIdentityId; } if (attacker is MyShipToolBase tool) { attackerId = tool.CubeGrid.BigOwners.Count > 0 ?tool.CubeGrid.BigOwners[0]:0; } if (attacker is MyAutomaticRifleGun characterWeapon) { attackerId = characterWeapon.OwnerIdentityId; } if (attacker is MyCubeGrid grid) { attackerId = grid.BigOwners.Count > 0 ? grid.BigOwners[0]:0; } if (attacker is MyLargeTurretBase turret) { attackerId = turret.CubeGrid.BigOwners.Count > 0 ? turret.CubeGrid.BigOwners[0] : 0; } } if (id == 0 || MySession.Static.Players.IdentityIsNpc(id) || MySession.Static.Players.IdentityIsNpc(attackerId) || id == attackerId) { return; } if (attackerId == 0 && Config.Instance.EnableNoOwner) { return; } var attackerSteamId = MySession.Static.Players.TryGetSteamId(attackerId); var targetSteamId = MySession.Static.Players.TryGetSteamId(id); if (ConflictPairModule.InConflict(attackerId, id, out var foundPair) && (foundPair == null || foundPair.CurrentConflictState == ConflictPairModule.ConflictState.Active)) { return; } if (Config.Instance.EnableFactionDamage) { var fac1 = MySession.Static.Factions.TryGetPlayerFaction(attackerId); var fac2 = MySession.Static.Factions.TryGetPlayerFaction(id); if (fac2 != null && fac1 != null && fac2 == fac1) { return; } } if (attackerSteamId == targetSteamId) { return; } info.Amount = 0; }
private static bool AttachCheck(ref bool __result, MyLandingGear __instance, MyEntity entity, Vector3D worldPos) { if (!Config.Instance.EnablePlugin || Config.Instance.AllowLandingGear) { return(true); } var lgGrid = __instance.CubeGrid; if (lgGrid == entity || entity.MarkedForClose) { return(true); } var firstOwner = lgGrid != null && lgGrid.BigOwners.Count > 0 ? lgGrid.BigOwners[0] : __instance.OwnerId; if (firstOwner == 0) { __result = false; return(false); } long secondOwner; switch (entity) { case MyCubeGrid grid: secondOwner = grid.BigOwners[0]; if (Config.Instance.PvpZones?.Count > 0) { foreach (var zone in Config.Instance.PvpZones) { if (!zone.IsWithinZoneRadius(grid)) { continue; } return(true); } } break; case MyCubeBlock block: secondOwner = block.CubeGrid.BigOwners[0]; if (Config.Instance.PvpZones?.Count > 0) { foreach (var zone in Config.Instance.PvpZones) { if (!zone.IsWithinZoneRadius(block.CubeGrid)) { continue; } return(true); } } break; default: return(true); } if (secondOwner == firstOwner || secondOwner == 0) { return(true); } var attackerSteamId = MySession.Static.Players.TryGetSteamId(firstOwner); var targetSteamId = MySession.Static.Players.TryGetSteamId(secondOwner); if (attackerSteamId == targetSteamId) { return(true); } if (Config.Instance.EnableFactionDamage) { var firstOwnerFaction = MySession.Static.Factions.GetPlayerFaction(firstOwner); var secondOwnerFaction = MySession.Static.Factions.GetPlayerFaction(secondOwner); if (firstOwnerFaction != null && secondOwnerFaction != null && firstOwnerFaction == secondOwnerFaction) { return(true); } } if (ConflictPairModule.InConflict(firstOwner, secondOwner, out var foundPair) && (foundPair == null || foundPair.CurrentConflictState == ConflictPairModule.ConflictState.Active)) { return(true); } __result = false; return(false); }