public override void OnDeath(Container c) { if (Government != null && !Government.Deleted) { ReportInfo newReport = new ReportInfo(this.Name + " died in the line of duty, stationed at X: " + (Spawner as MilitarySpawner).X + ", Y: " + (Spawner as MilitarySpawner).Y + "."); newReport.TimeOfReport = Formatting.GetTimeFormat(this, Format.Time); Government.Reports.Add(newReport); if (Government.Employees.Contains(this)) Government.Employees.Remove(this); } base.OnDeath(c); }
public static void RecognizeCrime(Mobile m, Soldier s) { if (m.Deleted || m == null || !m.Alive) return; if (s.Deleted || s == null || !s.Alive) return; if (s.Government == null || s.Government.Deleted) return; if (m is PlayerMobile && CustomGuildStone.IsGuildOfficer(m as PlayerMobile, s.Government)) return; if (m is Soldier && (m as Soldier).Government != null && !(m as Soldier).Government.Deleted && (m as Soldier).Government == s.Government) return; if (m is PlayerMobile && GroupInfo.IsGroupLeader(s, m as PlayerMobile)) return; XmlAttachment attachment = null; attachment = XmlAttach.FindAttachmentOnMobile(m, typeof(XmlCriminal), s.Nation.ToString()); if (attachment == null) { XmlAttach.AttachTo(m, new XmlCriminal(s)); m.SendMessage(CriminalAlertMessage(s.Nation)); if (m is PlayerMobile) { if (((PlayerMobile)m).CriminalActivity) { ((PlayerMobile)m).CriminalActivity = false; ReportInfo newReport = new ReportInfo(m, true, false); newReport.ReporterName = s.Name; s.ReportTimer = new ReportTimer(newReport, s); } else { ReportInfo newReport = new ReportInfo(m, false, true); newReport.ReporterName = s.Name; s.ReportTimer = new ReportTimer(newReport, s); } s.ReportTimer.Start(); } m.RevealingAction(); s.OnThink(); } }
public ReportTimer(ReportInfo r, Soldier s) : base(TimeSpan.FromSeconds(1), TimeSpan.FromMinutes(30)) { Priority = TimerPriority.OneMinute; m_Report = r; m_Soldier = s; m_Report.Name = m_Soldier.Name.ToString(); m_TimerStarted = DateTime.Now; }
public static void Serialize(GenericWriter writer, ReportInfo info) { writer.Write((bool)info.IsPlayer); writer.Write((bool)info.IsSoldier); writer.Write((string)info.Name); writer.Write((bool)info.IsFemale); writer.Write((int)info.Height); writer.Write((int)info.Weight); writer.Write((string)info.Age); writer.Write((int)info.Nation); writer.Write((string)info.Description); writer.Write((string)info.Guild); writer.Write((Point3D)info.Location); writer.Write((bool)info.Thievery); writer.Write((bool)info.Assault); writer.Write((bool)info.IsOptional); writer.Write((string)info.ReporterName); writer.Write((string)info.Information); writer.Write((string)info.TimeOfReport); }
public static string WriteReport(ReportInfo info) { string reportString = ""; if (info.IsPlayer) { if (info.IsFemale) reportString += "A female "; else reportString += "A male "; reportString += info.Nation + ", " + info.Age + ", weight: " + info.Weight + " petrae, height: " + info.Height + " petrae. "; if (info.Guild != null) reportString += "<br> The subject bore the insignia of " + info.Guild + ". "; if (Utility.RandomMinMax(1, 100) > 75) reportString += "<br> The following description was provided: " + info.Description; } else { if (info.IsSoldier) reportString += "soldier under the command of " + info.Guild + ". "; else reportString = info.Name + "."; } if (info.Thievery) reportString = "Spotted engaging in suspicious and illegal activity at " + info.Location + ": " + reportString; else if (info.Assault) reportString = "Spotted engaging in violent activity at " + info.Location + ": " + reportString; return reportString; }
public static void Deserialize(GenericReader reader, ReportInfo info) { info.IsPlayer = reader.ReadBool(); info.IsSoldier = reader.ReadBool(); info.Name = reader.ReadString(); info.IsFemale = reader.ReadBool(); info.Height = reader.ReadInt(); info.Weight = reader.ReadInt(); info.Age = reader.ReadString(); info.Nation = (Nation)reader.ReadInt(); info.Description = reader.ReadString(); info.Guild = reader.ReadString(); info.Location = reader.ReadPoint3D(); info.Thievery = reader.ReadBool(); info.Assault = reader.ReadBool(); info.IsOptional = reader.ReadBool(); info.ReporterName = reader.ReadString(); info.Information = reader.ReadString(); info.TimeOfReport = reader.ReadString(); }
public virtual bool AcquireFocusMob(int iRange, FightMode acqType, bool bPlayerOnly, bool bFacFriend, bool bFacFoe) { m_Mobile.DebugSay("Entered AcquireFocusMob"); if (m_Mobile.Deleted) return false; XmlAwe awe = XmlAttach.FindAttachment(m_Mobile, typeof(XmlAwe)) as XmlAwe; if (awe != null) return false; if (m_Mobile is Soldier && m_Mobile.ControlOrder == OrderType.Stop) return false; if ((m_Mobile.Controlled) || (m_Mobile is Soldier && m_Mobile.ControlOrder == OrderType.Attack)) { if (m_Mobile.Combatant != null && !m_Mobile.Combatant.Deleted) { m_Mobile.ControlTarget = m_Mobile.Combatant; } if (m_Mobile.ControlTarget == null || m_Mobile.ControlTarget.Deleted || !m_Mobile.ControlTarget.Alive || m_Mobile.ControlTarget.IsDeadBondedPet || !m_Mobile.InRange(m_Mobile.ControlTarget, m_Mobile.RangePerception * 2)) { m_Mobile.FocusMob = null; return false; } else { m_Mobile.FocusMob = m_Mobile.ControlTarget; return (m_Mobile.FocusMob != null); } } if (m_Mobile.ConstantFocus != null) { m_Mobile.FocusMob = m_Mobile.ConstantFocus; return true; } if (m_Mobile.MarkedForTermination) { m_Mobile.FocusMob = null; return false; } if (m_Mobile.Aggressors.Count == 0 && m_Mobile.Aggressed.Count == 0 && m_Mobile.FactionAllegiance == null && m_Mobile.EthicAllegiance == null) { if (acqType == FightMode.Aggressor) { if (!m_Mobile.IsPredator && !(m_Mobile is IMagicalForestCreature) && !(m_Mobile is IRacialGuard) && !(m_Mobile is Soldier)) { m_Mobile.FocusMob = null; return false; } } if (m_Mobile is IPeacefulPredator && m_Mobile.Hunger > 9) { m_Mobile.FocusMob = null; return false; } } if (m_Mobile.NextReacquireTime > DateTime.Now) { m_Mobile.FocusMob = null; return false; } if (acqType == FightMode.None) { m_Mobile.FocusMob = null; return false; } m_Mobile.NextReacquireTime = DateTime.Now + m_Mobile.ReacquireDelay; m_Mobile.DebugSay("Acquiring..."); Map map = m_Mobile.Map; if (map != null) { Mobile newFocusMob = null; double val = double.MinValue; double theirVal; bool originalbPlayerOnly = bPlayerOnly; bool originalbFacFoe = bFacFoe; IPooledEnumerable eable = map.GetMobilesInRange(m_Mobile.Location, iRange); foreach (Mobile m in eable) { if (m.Deleted || m.Blessed) continue; // Let's not target ourselves... if (m == m_Mobile) continue; // Dead targets are invalid. if (!m.Alive || m.IsDeadBondedPet) continue; if (m_Mobile.Summoned && m_Mobile.SummonMaster != null) { // If this is a summon, it can't target its controller. if (m == m_Mobile.SummonMaster) continue; // It also must abide by harmful spell rules. if (!Server.Spells.SpellHelper.ValidIndirectTarget(m_Mobile.SummonMaster, m)) continue; // Animated creatures cannot attack players directly. if (m is PlayerMobile && m_Mobile.IsAnimatedDead) continue; } bool bValid = false; // We will attack aggressors, or people we've aggressed priorly, regardless of our ethics. for (int a = 0; !bValid && a < m_Mobile.Aggressors.Count; ++a) bValid = (m_Mobile.Aggressors[a].Attacker == m); for (int a = 0; !bValid && a < m_Mobile.Aggressed.Count; ++a) bValid = (m_Mobile.Aggressed[a].Defender == m); if (bValid) { // we were aggressed, or fighting something -- we'll show them, player or not. bPlayerOnly = false; bFacFoe = false; } else // this guy didn't do anything wrong to us, let's see if we want to ignore him { if (!m_Mobile.CanSee(m)) continue; if (m_Mobile is BaseCreature && m is BaseCreature && ((BaseCreature)m_Mobile).Team != ((BaseCreature)m).Team) { bValid = true; bPlayerOnly = false; bFacFoe = false; } else if (AreAllies(m_Mobile, m)) continue; // Prevent controlled mounts from being targeted if (m is BaseMount && ((BaseMount)m).Controlled && ((BaseMount)m).ControlMaster != null) continue; if (m_Mobile is ICelestial && m is BaseCreature && !(m is IAbyssal)) continue; if (m_Mobile is IMinotaur && m is IMinotaur) continue; if (acqType == FightMode.FindThreat) // look for things that might harm us { if (m.Body.Type == BodyType.Human) // flee from humans { bValid = true; bPlayerOnly = false; bFacFoe = false; } else if (m_Mobile is BaseCreature && ((BaseCreature)m_Mobile).IsPrey && m is BaseCreature && (((BaseCreature)m).IsPredator || m is PlayerMobile)) { if (IsLargerThanPrey(((BaseCreature)m), ((BaseCreature)m_Mobile)) || m is PlayerMobile) { // run away from predators if they're bigger than us, we're prey bValid = true; bPlayerOnly = false; bFacFoe = false; } } } if (m_Mobile is BaseCreature && ((BaseCreature)m_Mobile).IsPredator && m is PlayerMobile) { BaseCreature bc = m_Mobile as BaseCreature; PlayerMobile pm = m as PlayerMobile; if (bc is IJungleCreature && pm.Backgrounds.BackgroundDictionary[BackgroundList.AnimalEmpathy].Level > 0) continue; if (bc is IForestCreature && pm.Backgrounds.BackgroundDictionary[BackgroundList.AnimalEmpathy].Level > 0) continue; if (bc is IDesertCreature && pm.Backgrounds.BackgroundDictionary[BackgroundList.AnimalEmpathy].Level > 0) continue; if (bc is IPlainsCreature && pm.Backgrounds.BackgroundDictionary[BackgroundList.AnimalEmpathy].Level > 0) continue; if (bc is ICaveCreature && pm.Backgrounds.BackgroundDictionary[BackgroundList.AnimalEmpathy].Level > 0) continue; if (bc is ITundraCreature && pm.Backgrounds.BackgroundDictionary[BackgroundList.AnimalEmpathy].Level > 0) continue; } if (m_Mobile is IUndead) { if (m is IUndead && !bValid) continue; if ((m_Mobile is ClericScorpion || m_Mobile is LesserClericScorpion || m_Mobile is GreaterClericScorpion) && ( (m is PlayerMobile && (m as PlayerMobile).Nation == Nation.Khemetar) || (m is BaseCreature && (m as BaseCreature).Nation == Nation.Khemetar) ) ) continue; bValid = true; bPlayerOnly = false; bFacFoe = false; } if (m_Mobile is BaseCreature && ((BaseCreature)m_Mobile).IsPredator && m is BaseCreature && ((BaseCreature)m).IsPrey) { if ((m_Mobile.Hunger < 10 || m_Mobile is IAlwaysHungry) && IsLargerThanPrey(((BaseCreature)m_Mobile), ((BaseCreature)m))) { bValid = true; bPlayerOnly = false; bFacFoe = false; } } if ((m_Mobile is IRacialGuard) || (m_Mobile is Soldier)) { bPlayerOnly = false; bFacFoe = false; } } if (!bValid) { /* #region Ethics & Faction checks if ( !bValid ) bValid = ( m_Mobile.GetFactionAllegiance( m ) == BaseCreature.Allegiance.Enemy || m_Mobile.GetEthicAllegiance( m ) == BaseCreature.Allegiance.Enemy ); #endregion */ if (!bValid && acqType == FightMode.Evil) { if (m is BaseCreature && ((BaseCreature)m).Controlled && ((BaseCreature)m).ControlMaster != null) bValid = (((BaseCreature)m).ControlMaster.Karma < 0); else bValid = (m.Karma < 0); } if (!bValid && m_Mobile is IMagicalForestCreature && m is PlayerMobile && !bValid) { PlayerMobile pm = m as PlayerMobile; if (pm.EnemyOfNature) bValid = true; } if (!bValid && m_Mobile is Soldier && (m_Mobile as Soldier).Government != null && !(m_Mobile as Soldier).Government.Deleted && Soldier.VisionCheck(m, m_Mobile, 16)) { Soldier soldier = m_Mobile as Soldier; soldier.WillArrest = false; soldier.DebugSay("I am a soldier!"); XmlAttachment attachment = null; attachment = XmlAttach.FindAttachment(m, typeof(XmlCriminal), soldier.Nation.ToString()); if (!bValid && m is BaseCreature && IsDangerous(m as BaseCreature, soldier)) bValid = true; else if (!bValid && soldier.Government.MilitaryPolicies.AttackOnSight(m)) { bValid = true; if (soldier.Government.MilitaryPolicies.KillIndividualOnSight.Contains(m.Name) || soldier.Government.MilitaryPolicies.JailIndividualOnSight.Contains(m.Name)) { ReportInfo newReport = new ReportInfo(m.Name + " sighted at " + soldier.Location + "."); newReport.ReporterName = soldier.Name; soldier.ReportTimer = new ReportTimer(newReport, soldier); soldier.ReportTimer.Start(); } else if ( m is PlayerMobile && (soldier.Government.MilitaryPolicies.KillNationOnSight.Contains((m as PlayerMobile).Nation) || soldier.Government.MilitaryPolicies.JailNationOnSight.Contains((m as PlayerMobile).Nation)) ) { ReportInfo newReport = new ReportInfo( (m as PlayerMobile).Nation.ToString() + " sighted at " + soldier.Location + "."); newReport.ReporterName = soldier.Name; soldier.ReportTimer = new ReportTimer(newReport, soldier); soldier.ReportTimer.Start(); } else if (m is BaseCreature && (soldier.Government.MilitaryPolicies.KillNationOnSight.Contains((m as BaseCreature).Nation) || soldier.Government.MilitaryPolicies.JailNationOnSight.Contains((m as BaseCreature).Nation)) ) { ReportInfo newReport = new ReportInfo((m as BaseCreature).Nation.ToString() + " sighted at " + soldier.Location + "."); newReport.ReporterName = soldier.Name; soldier.ReportTimer = new ReportTimer(newReport, soldier); soldier.ReportTimer.Start(); } } else if (!bValid && (attachment == null) && (m.AccessLevel < AccessLevel.Counselor)) { if (m is PlayerMobile && Soldier.ThiefCheck((PlayerMobile)m, soldier)) { Soldier.RecognizeCrime(m, soldier); bValid = true; } else if (Soldier.AssaultCheck(m, soldier)) { Soldier.RecognizeCrime(m, soldier); bValid = true; } } else if (!bValid && attachment != null && soldier.Combatant == null && m.AccessLevel < AccessLevel.Counselor) { bValid = true; } if (bValid) { string speech = Soldier.RandomAttackSpeech(soldier); if (speech != null) soldier.Say(speech); m.RevealingAction(); } } if (!bValid && m_Mobile is BaseCreature && ((BaseCreature)m_Mobile).IsPredator) { if (m_Mobile.Hunger < 10 || m_Mobile is IAlwaysHungry) { if (m is PlayerMobile && (m_Mobile is ILargePredator || m_Mobile is IMediumPredator || m_Mobile is ISerpent)) bValid = true; } } if (!bValid) { if (acqType != FightMode.Aggressor && acqType != FightMode.Evil && acqType != FightMode.FindThreat) { bValid = true; // other modes will attack anyway bPlayerOnly = false; bFacFoe = false; } else continue; } } // Does it have to be a player? if (bPlayerOnly && !m.Player) continue; // If we only want faction friends, make sure it's one. if (bFacFriend && !m_Mobile.IsFriend(m)) continue; // Same goes for faction enemies. if (bFacFoe && !m_Mobile.IsEnemy(m)) continue; bPlayerOnly = originalbPlayerOnly; // If it's an enemy factioned mobile, make sure we can be harmful to it. if (bFacFoe && !bFacFriend && !m_Mobile.CanBeHarmful(m, false)) continue; theirVal = m_Mobile.GetValueFrom(m, acqType, bPlayerOnly); if (theirVal > val && m_Mobile.InLOS(m)) { newFocusMob = m; val = theirVal; } bFacFoe = originalbFacFoe; } eable.Free(); m_Mobile.FocusMob = newFocusMob; } return (m_Mobile.FocusMob != null); }
public override void Deserialize(GenericReader reader) { base.Deserialize( reader ); int version = reader.ReadInt(); switch (version) { case 7: { #region Version 7 m_TradeInformation = new TradeInfo(); TradeInfo.Deserialize(reader, m_TradeInformation); #endregion goto case 6; } case 6: { #region Version 6 m_Employees = new List<Mobile>(); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { Mobile e = reader.ReadMobile(); if(!m_Employees.Contains(e)) m_Employees.Add(e); } #endregion goto case 5; } case 5: { #region Version 5 TradeAdvisor = (TradeAdvisor)reader.ReadMobile(); int count = 0; m_MilitarySpawners = new List<MilitarySpawner>(); count = reader.ReadInt(); for (int i = 0; i < count; i++) { object o = reader.ReadItem(); if (o != null) m_MilitarySpawners.Add((MilitarySpawner)o); } m_WayPoints = new List<MilitaryWayPoint>(); count = reader.ReadInt(); for (int i = 0; i < count; i++) { object o = reader.ReadItem(); if (o != null) m_WayPoints.Add((MilitaryWayPoint)o); } m_Nation = (Nation)reader.ReadInt(); m_CityGovernment = reader.ReadBool(); m_Resources = new Dictionary<ResourceType, int>(); count = reader.ReadInt(); for (int i = 0; i < count; i++) { ResourceType r = (ResourceType)reader.ReadInt(); int a = reader.ReadInt(); m_Resources.Add(r, a); } m_Reports = new List<ReportInfo>(); count = reader.ReadInt(); for (int i = 0; i < count; i++) { ReportInfo r = new ReportInfo(null, false, false); ReportInfo.Deserialize(reader, r); m_Reports.Add(r); } m_MilitaryAdvisor = (MilitaryAdvisor)reader.ReadMobile(); m_MilitaryPolicies = new MilitaryInfo(this); MilitaryInfo.Deserialize(reader, m_MilitaryPolicies); Governments.Add(this); #endregion Version 5 break; } } }
public void Lose() { if (Government != null && !Government.Deleted) { ReportInfo newReport = new ReportInfo( "Lost contact with " + this.Resource.ToString() + " at X: " + this.X.ToString() + " and Y: " + this.Y.ToString() + "."); newReport.TimeOfReport = Formatting.GetTimeFormat(this, Format.Time); Government.Reports.Add(newReport); } Owned = false; Government = null; Name = BaseName; if (m_Timer != null && m_Timer.Running) m_Timer.Stop(); }
public void Capture() { if (m_ClaimantGovernment == null || m_ClaimantGovernment.Deleted) return; if (Government != null && !Government.Deleted && Government != m_ClaimantGovernment) { ReportInfo newReport = new ReportInfo("Lost contact with " + this.Resource.ToString() + " at X: " + this.X.ToString() + " and Y: " + this.Y.ToString() + "."); newReport.TimeOfReport = Formatting.GetTimeFormat(this, Format.Time); Government.Reports.Add(newReport); List<MilitarySpawner> nearbySpawners = new List<MilitarySpawner>(); IPooledEnumerable nearbyItems = this.Map.GetItemsInRange(this.Location, 15); foreach (Item item in nearbyItems) { if (item is MilitarySpawner && (item as MilitarySpawner).Government != null && !(item as MilitarySpawner).Government.Deleted) { MilitarySpawner spawner = item as MilitarySpawner; if (spawner.Government == Government) nearbySpawners.Add(spawner); else if (Government.AlliedGuilds.Contains(spawner.Government)) nearbySpawners.Add(spawner); else if (m_ClaimantGovernment.EnemyGuilds.Contains(spawner.Government)) nearbySpawners.Add(spawner); } } nearbyItems.Free(); for (int i = (nearbySpawners.Count - 1); i > -1; i--) nearbySpawners[i].Delete(); nearbySpawners.Clear(); } IPooledEnumerable eable = Map.GetItemsInRange(this.Location, 15); List<MilitarySpawner> removeSpawner = new List<MilitarySpawner>(); foreach (Item i in eable) { if (i is MilitarySpawner) { MilitarySpawner spawner = i as MilitarySpawner; if (spawner.Government != null && !spawner.Government.Deleted) if (m_ClaimantGovernment.EnemyGuilds.Contains(spawner.Government)) removeSpawner.Add(spawner); } } eable.Free(); for (int i = (removeSpawner.Count - 1); i > -1; i--) removeSpawner[i].Delete(); removeSpawner.Clear(); Government = m_ClaimantGovernment; Owned = true; ProductionDate = DateTime.Now.AddDays(1); Name = BaseName + " [" + Government.Name.ToString() + "]"; if(m_LastCapture + TimeSpan.FromDays(7.0) <= DateTime.Now) { eable = this.Map.GetMobilesInRange(this.Location, 15); foreach (Mobile m in eable) { if (m is PlayerMobile && Government != null && !Government.Deleted && Government.Members.Contains(m)) { m.SendMessage("You have successfully claimed the " + this.Resource.ToString() + "!"); int reward = ProductionRate * Utility.RandomMinMax( Utility.Random(Government.Members.Count) + 1, Government.Members.Count + 2 ); LevelSystem.AwardExp(m as PlayerMobile, Utility.RandomMinMax(ProductionRate, reward)); LevelSystem.AwardCP(m as PlayerMobile, Utility.RandomMinMax(ProductionRate, reward)); } if (m is BaseCreature && Government != null && !Government.Deleted && ((m as BaseCreature).Government != null && (m as BaseCreature).Government == Government || Government.Members.Contains((m as BaseCreature).ControlMaster))) { LevelSystem.AwardExp(m as BaseCreature, Utility.RandomMinMax(ProductionRate + 1, (ProductionRate * (Utility.Random(25) + 1)))); } } eable.Free(); } m_LastCapture = DateTime.Now; m_Claimant = null; m_ClaimantGovernment = null; m_ClaimTimer.Stop(); m_Timer = new ResourceTimer(this); m_Timer.Start(); }