public void RemoveGuild(Guild g) { if (m_PendingMembers.Contains(g)) { m_PendingMembers.Remove(g); } if (m_Members.Contains(g)) // Sanity, just incase someone with a custom script adds a character to BOTH arrays { m_Members.Remove(g); g.InvalidateMemberProperties(); g.GuildMessage(1070763, Name); // Your Guild has been removed from the ~1_ALLIANCENAME~ Alliance. AllianceMessage(1070764, g.Name); // A Guild has left your Alliance: ~1_GUILDNAME~ } // g.Alliance = null; //NO G.Alliance call here. Set the Guild's Alliance to null, if you JUST use RemoveGuild, it removes it from the alliance, but doesn't remove the link from the guild to the alliance. setting g.Alliance will call this method. // to check on OSI: have 3 guilds, make 2 of them a member, one pending. remove one of the memebers. alliance still exist? // ANSWER: NO if (g == m_Leader) { CalculateAllianceLeader(); } if (m_Members.Count < 2) { Disband(); } }
public void InvalidateMemberProperties(bool onlyOPL) { for (int i = 0; i < m_Members.Count; i++) { Guild g = m_Members[i]; g.InvalidateMemberProperties(onlyOPL); } }
public void RemoveGuild( Guild g ) { if( m_PendingMembers.Contains( g ) ) { m_PendingMembers.Remove( g ); } if( m_Members.Contains( g ) ) //Sanity, just incase someone with a custom script adds a character to BOTH arrays { m_Members.Remove( g ); g.InvalidateMemberProperties(); g.GuildMessage( 1070763, this.Name ); // Your Guild has been removed from the ~1_ALLIANCENAME~ Alliance. AllianceMessage( 1070764, g.Name ); // A Guild has left your Alliance: ~1_GUILDNAME~ } //g.Alliance = null; //NO G.Alliance call here. Set the Guild's Alliance to null, if you JUST use RemoveGuild, it removes it from the alliance, but doesn't remove the link from the guild to the alliance. setting g.Alliance will call this method. //to check on OSI: have 3 guilds, make 2 of them a member, one pending. remove one of the memebers. alliance still exist? //ANSWER: NO if( g == m_Leader ) { CalculateAllianceLeader(); /* if( m_Leader == null ) //only when m_members.count < 2 Disband(); else AllianceMessage( 1070765, m_Leader.Name ); // Your Alliance is now led by ~1_GUILDNAME~ */ } if( m_Members.Count < 2 ) Disband(); }
public override void OnResponse(NetState sender, RelayInfo info) { PlayerMobile pm = sender.Mobile as PlayerMobile; if (!IsMember(pm, guild)) { return; } RankDefinition playerRank = pm.GuildRank; Guild guildLeader = Guild.GetAllianceLeader(guild); Guild otherGuild = Guild.GetAllianceLeader(m_Other); WarDeclaration war = guildLeader.FindPendingWar(otherGuild); WarDeclaration activeWar = guildLeader.FindActiveWar(otherGuild); WarDeclaration otherWar = otherGuild.FindPendingWar(guildLeader); AllianceInfo alliance = guild.Alliance; AllianceInfo otherAlliance = otherGuild.Alliance; switch (info.ButtonID) { #region War case 5: //Accept the war { if (war != null && !war.WarRequester && activeWar == null) { if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) { pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars. } else if (alliance != null && alliance.Leader != guild) { pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance. pm.SendLocalizedMessage(1070707, alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. } else { //Accept the war guild.PendingWars.Remove(war); war.WarBeginning = DateTime.UtcNow; guild.AcceptedWars.Add(war); if (alliance != null && alliance.IsMember(guild)) { alliance.AllianceMessage(1070769, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name)); // Guild Message: Your guild is now at war with ~1_GUILDNAME~ alliance.InvalidateMemberProperties(); } else { guild.GuildMessage(1070769, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name)); // Guild Message: Your guild is now at war with ~1_GUILDNAME~ guild.InvalidateMemberProperties(); } //Technically SHOULD say Your guild is now at war w/out any info, intentional diff. otherGuild.PendingWars.Remove(otherWar); otherWar.WarBeginning = DateTime.UtcNow; otherGuild.AcceptedWars.Add(otherWar); if (otherAlliance != null && m_Other.Alliance.IsMember(m_Other)) { otherAlliance.AllianceMessage(1070769, ((alliance != null) ? alliance.Name : guild.Name)); // Guild Message: Your guild is now at war with ~1_GUILDNAME~ otherAlliance.InvalidateMemberProperties(); } else { otherGuild.GuildMessage(1070769, ((alliance != null) ? alliance.Name : guild.Name)); // Guild Message: Your guild is now at war with ~1_GUILDNAME~ otherGuild.InvalidateMemberProperties(); } } } break; } case 6: //Modify war terms { if (war != null && !war.WarRequester && activeWar == null) { if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) { pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars. } else if (alliance != null && alliance.Leader != guild) { pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance. pm.SendLocalizedMessage(1070707, alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. } else { pm.SendGump(new WarDeclarationGump(pm, guild, otherGuild)); } } break; } case 7: //Dismiss war { if (war != null) { if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) { pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars. } else if (alliance != null && alliance.Leader != guild) { pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance. pm.SendLocalizedMessage(1070707, alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. } else { //Dismiss the war guild.PendingWars.Remove(war); otherGuild.PendingWars.Remove(otherWar); pm.SendLocalizedMessage(1070752); // The proposal has been updated. //Messages to opposing guild? (Testing on OSI says no) } } break; } case 8: //Surrender { if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) { pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars. } else if (alliance != null && alliance.Leader != guild) { pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance. pm.SendLocalizedMessage(1070707, alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. } else { if (activeWar != null) { if (alliance != null && alliance.IsMember(guild)) { alliance.AllianceMessage(1070740, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name)); // You have lost the war with ~1_val~. alliance.InvalidateMemberProperties(); } else { guild.GuildMessage(1070740, ((otherAlliance != null) ? otherAlliance.Name : otherGuild.Name)); // You have lost the war with ~1_val~. guild.InvalidateMemberProperties(); } guild.AcceptedWars.Remove(activeWar); if (otherAlliance != null && otherAlliance.IsMember(otherGuild)) { otherAlliance.AllianceMessage(1070739, ((guild.Alliance != null) ? guild.Alliance.Name : guild.Name)); // You have won the war against ~1_val~! otherAlliance.InvalidateMemberProperties(); } else { otherGuild.GuildMessage(1070739, ((guild.Alliance != null) ? guild.Alliance.Name : guild.Name)); // You have won the war against ~1_val~! otherGuild.InvalidateMemberProperties(); } otherGuild.AcceptedWars.Remove(otherGuild.FindActiveWar(guild)); } } break; } case 1: //Declare War { if (war == null && activeWar == null) { if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) { pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars. } else if (alliance != null && alliance.Leader != guild) { pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance. pm.SendLocalizedMessage(1070707, alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. } else if (otherAlliance != null && otherAlliance.Leader != m_Other) { pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", m_Other.Name, otherAlliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance. pm.SendLocalizedMessage(1070707, otherAlliance.Leader.Name); // You need to negotiate via ~1_val~ instead. } else { pm.SendGump(new WarDeclarationGump(pm, guild, m_Other)); } } break; } #endregion case 2: //Request Alliance { #region New alliance if (alliance == null) { if (!playerRank.GetFlag(RankFlags.AllianceControl)) { pm.SendLocalizedMessage(1070747); // You don't have permission to create an alliance. } else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader)) { pm.SendLocalizedMessage(1070758); // You cannot propose an alliance to a guild with a different faction allegiance. } else if (otherAlliance != null) { if (otherAlliance.IsPendingMember(m_Other)) { pm.SendLocalizedMessage(1063416, m_Other.Name); // ~1_val~ is currently considering another alliance proposal. } else { pm.SendLocalizedMessage(1063426, m_Other.Name); // ~1_val~ already belongs to an alliance. } } else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0) { pm.SendLocalizedMessage(1063427, m_Other.Name); // ~1_val~ is currently involved in a guild war. } else if (guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0) { pm.SendLocalizedMessage(1063427, guild.Name); // ~1_val~ is currently involved in a guild war. } else { pm.SendLocalizedMessage(1063439); // Enter a name for the new alliance: pm.BeginPrompt(new PromptCallback(CreateAlliance_Callback)); } } #endregion #region Existing Alliance else { if (!playerRank.GetFlag(RankFlags.AllianceControl)) { pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. } else if (alliance.Leader != guild) { pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance. } else if (otherAlliance != null) { if (otherAlliance.IsPendingMember(m_Other)) { pm.SendLocalizedMessage(1063416, m_Other.Name); // ~1_val~ is currently considering another alliance proposal. } else { pm.SendLocalizedMessage(1063426, m_Other.Name); // ~1_val~ already belongs to an alliance. } } else if (alliance.IsPendingMember(guild)) { pm.SendLocalizedMessage(1063416, guild.Name); // ~1_val~ is currently considering another alliance proposal. } else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0) { pm.SendLocalizedMessage(1063427, m_Other.Name); // ~1_val~ is currently involved in a guild war. } else if (guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0) { pm.SendLocalizedMessage(1063427, guild.Name); // ~1_val~ is currently involved in a guild war. } else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader)) { pm.SendLocalizedMessage(1070758); // You cannot propose an alliance to a guild with a different faction allegiance. } else { pm.SendLocalizedMessage(1070750, m_Other.Name); // An invitation to join your alliance has been sent to ~1_val~. m_Other.GuildMessage(1070780, guild.Name); // ~1_val~ has proposed an alliance. m_Other.Alliance = alliance; //Calls addPendingGuild //alliance.AddPendingGuild( m_Other ); } } #endregion break; } case 10: //Show Alliance Roster { if (alliance != null && alliance == otherAlliance) { pm.SendGump(new AllianceInfo.AllianceRosterGump(pm, guild, alliance)); } break; } case 11: //Leave Alliance { if (!playerRank.GetFlag(RankFlags.AllianceControl)) { pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. } else if (alliance != null && alliance.IsMember(guild)) { guild.Alliance = null; //Calls alliance.Removeguild // alliance.RemoveGuild( guild ); m_Other.InvalidateWarNotoriety(); guild.InvalidateMemberNotoriety(); } break; } case 12: //Remove Guild from alliance { if (!playerRank.GetFlag(RankFlags.AllianceControl)) { pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. } else if (alliance != null && alliance.Leader != guild) { pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance. } else if (alliance != null && alliance.IsMember(guild) && alliance.IsMember(m_Other)) { m_Other.Alliance = null; m_Other.InvalidateMemberNotoriety(); guild.InvalidateWarNotoriety(); } break; } case 13: //Promote to Alliance leader { if (!playerRank.GetFlag(RankFlags.AllianceControl)) { pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. } else if (alliance != null && alliance.Leader != guild) { pm.SendLocalizedMessage(1063239, String.Format("{0}\t{1}", guild.Name, alliance.Name)); // ~1_val~ is not the leader of the ~2_val~ alliance. } else if (alliance != null && alliance.IsMember(guild) && alliance.IsMember(m_Other)) { pm.SendLocalizedMessage(1063434, String.Format("{0}\t{1}", m_Other.Name, alliance.Name)); // ~1_val~ is now the leader of ~2_val~. alliance.Leader = m_Other; } break; } case 14: //Withdraw Request { if (!playerRank.GetFlag(RankFlags.AllianceControl)) { pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. } else if (alliance != null && alliance.Leader == guild && alliance.IsPendingMember(m_Other)) { m_Other.Alliance = null; pm.SendLocalizedMessage(1070752); // The proposal has been updated. } break; } case 15: //Deny Alliance Request { if (!playerRank.GetFlag(RankFlags.AllianceControl)) { pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. } else if (alliance != null && otherAlliance != null && alliance.Leader == m_Other && otherAlliance.IsPendingMember(guild)) { pm.SendLocalizedMessage(1070752); // The proposal has been updated. //m_Other.GuildMessage( 1070782 ); // ~1_val~ has responded to your proposal. //Per OSI commented out. guild.Alliance = null; } break; } case 16: //Accept Alliance Request { if (!playerRank.GetFlag(RankFlags.AllianceControl)) { pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. } else if (otherAlliance != null && otherAlliance.Leader == m_Other && otherAlliance.IsPendingMember(guild)) { pm.SendLocalizedMessage(1070752); // The proposal has been updated. otherAlliance.TurnToMember(m_Other); //No need to verify it's in the guild or already a member, the function does this otherAlliance.TurnToMember(guild); } break; } } }
public void CheckExpiredWars() { for (int i = 0; i < AcceptedWars.Count; i++) { WarDeclaration w = AcceptedWars[i]; Guild g = w.Opponent; WarStatus status = w.Status; if (status != WarStatus.InProgress) { AllianceInfo myAlliance = Alliance; bool inAlliance = (myAlliance != null && myAlliance.IsMember(this)); AllianceInfo otherAlliance = ((g != null) ? g.Alliance : null); bool otherInAlliance = (otherAlliance != null && otherAlliance.IsMember(this)); if (inAlliance) { myAlliance.AllianceMessage( 1070739 + (int)status, (g == null) ? "a deleted opponent" : (otherInAlliance ? otherAlliance.Name : g.Name)); myAlliance.InvalidateMemberProperties(); } else { GuildMessage( 1070739 + (int)status, (g == null) ? "a deleted opponent" : (otherInAlliance ? otherAlliance.Name : g.Name)); InvalidateMemberProperties(); } AcceptedWars.Remove(w); if (g != null) { if (status != WarStatus.Draw) { status = (WarStatus)((int)status + 1 % 2); } if (otherInAlliance) { otherAlliance.AllianceMessage(1070739 + (int)status, (inAlliance ? Alliance.Name : Name)); otherAlliance.InvalidateMemberProperties(); } else { g.GuildMessage(1070739 + (int)status, (inAlliance ? Alliance.Name : Name)); g.InvalidateMemberProperties(); } g.AcceptedWars.Remove(g.FindActiveWar(this)); } } } for (int i = 0; i < PendingWars.Count; i++) { WarDeclaration w = PendingWars[i]; Guild g = w.Opponent; if (w.Status != WarStatus.Pending) { //All sanity in here PendingWars.Remove(w); if (g != null) { g.PendingWars.Remove(g.FindPendingWar(this)); } } } }
public void TurnToMember( Guild g ) { if( g.Alliance != this || !m_PendingMembers.Contains( g ) || m_Members.Contains( g ) ) return; g.GuildMessage( 1070760, this.Name ); // Your Guild has joined the ~1_ALLIANCENAME~ Alliance. AllianceMessage( 1070761, g.Name ); // A new Guild has joined your Alliance: ~1_GUILDNAME~ m_PendingMembers.Remove( g ); m_Members.Add( g ); g.InvalidateMemberProperties(); }