public static bool Execute(MobileInstance ch, IManager dbManager) { if (!ch.IsAwake() || ch.CurrentFighting != null) { return(false); } var maxEvil = 300; var crime = string.Empty; CharacterInstance victim = null; CharacterInstance ech = null; foreach (var vch in ch.CurrentRoom.Persons.Where(vch => vch != ch)) { victim = vch; crime = GetCrime(victim); if (!string.IsNullOrEmpty(crime)) { break; } if (vch.CurrentFighting == null || vch.GetMyTarget() == ch || vch.CurrentAlignment >= maxEvil) { continue; } maxEvil = vch.CurrentAlignment; ech = victim; } if (victim != null && ch.CurrentRoom.Flags.IsSet(RoomFlags.Safe)) { Yell.do_yell(ch, $"{victim.Name} is a {crime}! As well as a COWARD!"); return(true); } if (victim != null) { Shout.do_shout(ch, $"{victim.Name} is a {crime}! PROTECT THE INNOCENT! BANZAI!!!"); fight.multi_hit(ch, victim, Program.TYPE_UNDEFINED); return(true); } if (ech == null) { return(false); } comm.act(ATTypes.AT_YELL, "$n screams 'PROTECT THE INNOCENT!! BANZAI!!", ch, null, null, ToTypes.Room); fight.multi_hit(ch, ech, Program.TYPE_UNDEFINED); return(true); }
public static bool Execute(MobileInstance ch, IManager dbManager) { if (!ch.IsAwake() || ch.CurrentFighting != null) { return(false); } var crime = string.Empty; CharacterInstance victim = null; foreach (var vch in ch.CurrentRoom.Persons.Where(vch => vch != ch)) { victim = vch; crime = GetCrime(victim); if (!string.IsNullOrEmpty(crime)) { break; } } if (victim == null) { return(false); } if (ch.CurrentRoom.Flags.IsSet(RoomFlags.Safe)) { Yell.do_yell(ch, $"{victim.Name} is a {crime}! As well as a COWARD!"); return(true); } Shout.do_shout(ch, $"{victim.Name} is a {crime}! PROTECT THE INNOCENT! MORE BLOOOOD!!!"); fight.multi_hit(ch, victim, Program.TYPE_UNDEFINED); if (ch.CharDied()) { return(true); } var vnum = GameConstants.GetVnum("MobileCityGuard"); var databaseMgr = (IRepositoryManager)(dbManager ?? RepositoryManager.Instance); var cityguard = databaseMgr.GetEntity <MobileTemplate>(vnum); var newGuard = databaseMgr.CHARACTERS.Create(cityguard, null); ch.CurrentRoom.AddTo(newGuard); newGuard = databaseMgr.CHARACTERS.Create(cityguard, null); ch.CurrentRoom.AddTo(newGuard); return(true); }
public static void ProcessUpdate(this MobileInstance ch, IRepositoryManager dbManager) { handler.set_cur_char(ch); if (ch.CurrentRoom == null || ch.IsAffected(AffectedByTypes.Charm) || ch.IsAffected(AffectedByTypes.Paralysis)) { return; } if (ch.MobIndex.ID == VnumConstants.MOB_VNUM_ANIMATED_CORPSE && !ch.IsAffected(AffectedByTypes.Charm)) { if (ch.CurrentRoom.Persons.Any()) { comm.act(ATTypes.AT_MAGIC, "$n returns to the dust from whence $e came.", ch, null, null, ToTypes.Room); } if (ch.IsNpc()) { ch.Extract(true); } return; } if (!ch.Act.IsSet((int)ActFlags.Running) && !ch.Act.IsSet((int)ActFlags.Sentinel) && ch.CurrentFighting == null && ch.CurrentHunting == null) { Macros.WAIT_STATE(ch, 2 * GameConstants.GetSystemValue <int>("PulseViolence")); track.hunt_victim(ch); return; } if (!ch.Act.IsSet((int)ActFlags.Running) && ch.SpecialFunction != null) { if (ch.SpecialFunction.Value.Invoke(ch, dbManager)) { return; } if (ch.CharDied()) { return; } } if (ch.MobIndex.HasProg(MudProgTypes.Script)) { MudProgHandler.ExecuteMobileProg(MudProgTypes.Script, ch); return; } if (ch != handler.CurrentCharacter) { // TODO BUG: ch does not equal CurrentCharacter after spec_fun"); return; } if (ch.CurrentPosition != PositionTypes.Standing) { return; } if (ch.Act.IsSet((int)ActFlags.Mounted)) { if (ch.Act.IsSet((int)ActFlags.Aggressive) || ch.Act.IsSet((int)ActFlags.MetaAggr)) { Emote.do_emote(ch, "snarls and growls."); } return; } if (ch.CurrentRoom.Flags.IsSet(RoomFlags.Safe) && (ch.Act.IsSet((int)ActFlags.Aggressive) || ch.Act.IsSet((int)ActFlags.MetaAggr))) { Emote.do_emote(ch, "glares around and snarls."); } if (ch.CurrentRoom.Area.NumberOfPlayers > 0) { MudProgHandler.ExecuteMobileProg(MudProgTypes.Random, ch); if (ch.CharDied()) { return; } if ((int)ch.CurrentPosition < (int)PositionTypes.Standing) { return; } } MudProgHandler.ExecuteMobileProg(MudProgTypes.Hour, ch); if (ch.CharDied()) { return; } MudProgHandler.ExecuteRoomProg(MudProgTypes.Hour, ch); if (ch.CharDied()) { return; } if ((int)ch.CurrentPosition < (int)PositionTypes.Standing) { return; } if (ch.Act.IsSet((int)ActFlags.Scavenger) && ch.CurrentRoom.Contents.Any() && SmaugRandom.Bits(2) == 0) { Scavenge(ch); } if (!ch.Act.IsSet((int)ActFlags.Running) && !ch.Act.IsSet((int)ActFlags.Sentinel) && !ch.Act.IsSet((int)ActFlags.Prototype) && !ch.Act.IsSet((int)ActFlags.StayArea)) { var door = SmaugRandom.Bits(5); if (door > 9) { return; } var exit = ch.CurrentRoom.GetExit(door); if (exit == null) { return; } if (exit.Flags.IsSet(ExitFlags.Window) || exit.Flags.IsSet(ExitFlags.Closed)) { return; } var room = exit.GetDestination(); if (room == null) { return; } if (room.Flags.IsSet(RoomFlags.NoMob) || room.Flags.IsSet(RoomFlags.Death)) { return; } if (room.Area != ch.CurrentRoom.Area) { return; } var retcode = Move.move_char(ch, exit, 0); if (ch.CharDied()) { return; } if (retcode != ReturnTypes.None || ch.Act.IsSet((int)ActFlags.Sentinel) || (int)ch.CurrentPosition < (int)PositionTypes.Standing) { return; } } if (ch.CurrentHealth < ch.MaximumHealth / 2) { var door = SmaugRandom.Bits(4); if (door > 9) { return; } var exit = ch.CurrentRoom.GetExit(door); if (exit == null) { return; } if (exit.Flags.IsSet(ExitFlags.Window) || exit.Flags.IsSet(ExitFlags.Closed)) { return; } var room = exit.GetDestination(); if (room == null) { return; } if (room.Flags.IsSet(RoomFlags.NoMob) || room.Flags.IsSet(RoomFlags.Death)) { return; } var found = false; foreach (var rch in ch.CurrentRoom.Persons) { if (ch.IsFearing(rch)) { var buf = string.Empty; switch (SmaugRandom.Bits(2)) { case 0: buf = $"Get away from me, {rch.Name}!"; break; case 1: buf = $"Leave me be, {rch.Name}!"; break; case 2: buf = $"{rch.Name} is trying to kill me! Help!"; break; case 3: buf = $"Someone save me from {rch.Name}!"; break; } Yell.do_yell(ch, buf); found = true; break; } } if (found) { Move.move_char(ch, exit, 0); } } }