public static void echo_to_all(ATTypes atColor, string argument, int tar) { if (string.IsNullOrWhiteSpace(argument)) { return; } foreach (var d in db.DESCRIPTORS .Where(x => x.ConnectionStatus == ConnectionTypes.Playing || x.ConnectionStatus == ConnectionTypes.Editing)) { if (tar == (int)EchoTypes.All && d.Character.IsNpc()) { continue; } if (tar == (int)EchoTypes.Immortal && !d.Character.IsImmortal()) { continue; } d.Character.SetColor(atColor); d.Character.SendTo(argument); d.Character.SendTo("\r\n"); } }
public static void echo_to_room(ATTypes atcolor, RoomTemplate room, string argument) { foreach (var ch in room.Persons) { ch.SetColor(atcolor); ch.SendTo(argument); ch.SendTo("\r\n"); } }
public static string color_str(ATTypes attype, CharacterInstance ch) { if (ch.IsNpc() || ch.Act.IsSet((int)PlayerFlags.Ansi)) { return(string.Empty); } var code = EnumerationExtensions.GetEnum <AnsiCodes>((int)attype); return(code.GetName()); }
private static bool SendToChar(CharacterInstance actor, string message, ATTypes atType = ATTypes.AT_PLAIN) { if (atType != ATTypes.AT_PLAIN) { actor.SetColor(atType); } if (!string.IsNullOrEmpty(message)) { actor.SendTo(message); } return(true); }
public static void paint(ATTypes attype, CharacterInstance ch, string fmt, params object[] args) { ch.SetColor(attype); ch.SendTo(string.Format(fmt, args)); ch.SetColor(attype); }
public static void act(ATTypes attype, string format, CharacterInstance ch, object arg1, object arg2, ToTypes type) { if (string.IsNullOrEmpty(format) || ch == null) { return; } var flags1 = (int)ActFFlags.None; var flags2 = (int)ActFFlags.None; var obj1 = arg1.CastAs <ObjectInstance>(); var obj2 = arg2.CastAs <ObjectInstance>(); var vch = arg2.CastAs <CharacterInstance>(); CharacterInstance to; #region Nasty type checking // Do some proper type checking here.. Sort of. We base it on the $* params. // This is kinda lame really, but I suppose in some weird sense it beats having // to pass like 8 different NULL parameters every time we need to call act().. if (format.Contains("$t")) { flags1 |= (int)ActFFlags.Text; obj1 = null; } if (format.Contains("$T") || format.Contains("$d")) { flags2 |= (int)ActFFlags.Text; vch = null; obj2 = null; } if (format.Contains("$N") || format.Contains("$E") || format.Contains("$M") || format.Contains("$S") || format.Contains("$Q")) { flags2 |= (int)ActFFlags.CH; obj2 = null; } if (format.Contains("$p")) { flags1 |= (int)ActFFlags.OBJ; } if (format.Contains("$P")) { flags2 |= (int)ActFFlags.OBJ; vch = null; } if (flags1 != (int)ActFFlags.None && flags1 != (int)ActFFlags.Text && flags1 != (int)ActFFlags.CH && flags1 != (int)ActFFlags.OBJ) { LogManager.Instance.Bug("More than one type {0} defined. Setting all null.", flags1); obj1 = null; } if (flags2 != (int)ActFFlags.None && flags2 != (int)ActFFlags.Text && flags2 != (int)ActFFlags.CH && flags2 != (int)ActFFlags.OBJ) { LogManager.Instance.Bug("More than one type {0} defined. Setting all null.", flags2); vch = null; obj2 = null; } if (ch.CurrentRoom == null) { to = null; } else if (type == ToTypes.Character) { to = ch; } else { to = ch.CurrentRoom.Persons.First(); } #endregion if (ch.IsNpc() && ch.Act.IsSet((int)ActFlags.Secretive) && type != ToTypes.Character) { return; } if (type == ToTypes.Victim) { if (vch?.CurrentRoom == null) { return; } to = vch; } var txt = string.Empty; if (to != null && type != ToTypes.Character && type != ToTypes.Victim) { txt = act_string(format, null, ch, arg1, arg2, Program.STRING_IMM); if (to.CurrentRoom.HasProg(MudProgTypes.Act)) { MudProgHandler.ExecuteRoomProg(MudProgTypes.Act, txt, to.CurrentRoom, ch, (ObjectInstance)arg1, arg2); } foreach (var toObj in to.CurrentRoom.Contents .Where(toObj => to.CurrentRoom.HasProg(MudProgTypes.Act))) { MudProgHandler.ExecuteObjectProg(MudProgTypes.Act, txt, toObj, ch, (ObjectInstance)arg1, arg2); } } if (type == ToTypes.Character || type == ToTypes.Victim) { return; } foreach (var rch in ch.CurrentRoom.Persons) { var playerInstance = to as PlayerInstance; if (playerInstance != null && playerInstance.Descriptor == null) { continue; } var instance = to as MobileInstance; if (instance != null && !instance.MobIndex.HasProg(MudProgTypes.Act)) { continue; } if (!to.IsAwake()) { continue; } if (type == ToTypes.Character && to != ch) { continue; } if (type == ToTypes.Victim && (to != vch || to == ch)) { continue; } if (type == ToTypes.Room && to == ch) { continue; } if (type == ToTypes.NotVictim && (to == ch || to == vch)) { continue; } if (type == ToTypes.CanSee && (to == ch || (!to.IsImmortal() && !ch.IsNpc() && ch.Act.IsSet((int)PlayerFlags.WizardInvisibility) && to.Trust < (playerInstance != null ? (playerInstance.PlayerData?.WizardInvisible ?? 0) : 0)))) { continue; } txt = act_string(format, to, ch, arg1, arg2, to.IsImmortal() ? Program.STRING_IMM : Program.STRING_NONE); if (playerInstance != null) { to.SetColor(attype); to.SendTo(txt); } MudProgHandler.ExecuteMobileProg(MudProgTypes.Act, txt, to, ch, arg1, arg2); } }
public static bool CheckIf(CharacterInstance actor, Func <object[], bool> funcToCheck, string message = "", IEnumerable <object> args = null, ATTypes atType = ATTypes.AT_PLAIN) { return(funcToCheck.Invoke(args?.ToArray()) && SendToChar(actor, message, atType)); }
public static ReturnTypes ranged_got_target(CharacterInstance ch, CharacterInstance victim, ObjectInstance weapon, ObjectInstance projectile, int dist, int dt, string stxt, ATTypes color) { if (ch.CurrentRoom.Flags.IsSet(RoomFlags.Safe)) { if (projectile != null) { ch.PrintfColor("Your %s is blasted from existence by a godly presence.", projectile); comm.act(color, "A godly presence smites $p!", ch, projectile, null, ToTypes.Room); projectile.Extract(); } else { ch.Printf("Your %s is blasted from existence by a godly presence.", stxt); comm.act(color, "A godly presence smites $t!", ch, stxt.AddArticle(ArticleAppendOptions.TheToFront), null, ToTypes.Room); } return(ReturnTypes.None); } var skill = RepositoryManager.Instance.GetEntity <SkillData>("MissileWeapons"); if (victim.IsNpc() && victim.Act.IsSet((int)ActFlags.Sentinel) && ch.CurrentRoom != victim.CurrentRoom) { if (projectile == null) { return(ch.CauseDamageTo(victim, 0, dt)); } skill.LearnFromFailure(ch); if (SmaugRandom.D100() < 50) { projectile.Extract(); } else { if (projectile.InObject != null) { projectile.RemoveFrom(projectile.InObject); } if (projectile.CarriedBy != null) { projectile.RemoveFrom(); } victim.CurrentRoom.AddTo(projectile); } return(ch.CauseDamageTo(victim, 0, dt)); } if (SmaugRandom.D100() > 50 || (projectile != null && weapon != null && ch.CanUseSkill(SmaugRandom.D100(), skill))) { return(projectile != null?fight.projectile_hit(ch, victim, weapon, projectile, dist) : Attack.spell_attack(dt, ch.Level, ch, victim)); } skill.LearnFromFailure(ch); var returnCode = ch.CauseDamageTo(victim, 0, dt); if (projectile == null) { return(returnCode); } if (SmaugRandom.D100() < 50) { projectile.Extract(); } else { if (projectile.InObject != null) { projectile.RemoveFrom(projectile.InObject); } if (projectile.CarriedBy != null) { projectile.RemoveFrom(); } victim.CurrentRoom.AddTo(projectile); } return(returnCode); }