/// <summary> /// Song of sleep. /// </summary> /// <param name="ch"></param> /// <param name="spell"></param> /// <param name="level"></param> /// <param name="target"></param> /// <returns></returns> public static bool SongSleep(CharData ch, Spell spell, int level, Target target) { foreach (CharData victim in ch.InRoom.People) { if (victim.IsAffected(Affect.AFFECT_SLEEP) || Magic.SpellSavingThrow(level, victim, AttackType.DamageType.charm) || victim.GetRace() == Race.RACE_VAMPIRE || ch.IsSameGroup(victim)) { continue; } Affect af = new Affect(Affect.AffectType.song, spell.Name, level / 8, Affect.Apply.none, 0, Affect.AFFECT_SLEEP); victim.CombineAffect(af); if (victim.IsAwake()) { victim.SendText("You feel very sleepy... zzzzz.\r\n"); if (ch.Fighting || victim.CurrentPosition == Position.fighting) { Combat.StopFighting(victim, false); } CommandType.Interpret(victim, "sleep"); } } return(true); }
/// <summary> /// Song of nightmares. /// </summary> /// <param name="ch"></param> /// <param name="spell"></param> /// <param name="level"></param> /// <param name="target"></param> /// <returns></returns> public static bool SongNightmares(CharData ch, Spell spell, int level, Target target) { Affect af = new Affect(); foreach (CharData victim in ch.InRoom.People) { if (victim.IsAffected(Affect.AFFECT_FEAR) || Magic.SpellSavingThrow(level, victim, AttackType.DamageType.black_magic)) { ch.SendText("You have failed.\r\n"); ch.SendText("You resist the urge to panic.\r\n"); continue; } af.Type = Affect.AffectType.song; af.Value = spell.Name; af.Duration = 1 + (level / 7); af.SetBitvector(Affect.AFFECT_FEAR); victim.AddAffect(af); SocketConnection.Act("$N&n is scared!", ch, null, victim, SocketConnection.MessageTarget.character); victim.SendText("You are scared!\r\n"); SocketConnection.Act("$N&n is scared!", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim); CommandType.Interpret(victim, "flee"); if (victim.IsNPC()) { Combat.StartFearing(victim, ch); } } return(true); }
/// <summary> /// Compares what the speaker has said to the chatterbot's response database and /// generates a reply if necessary. /// </summary> /// <param name="bot"></param> /// <param name="speaker"></param> /// <param name="argument"></param> /// <returns></returns> public bool CheckConversation(CharData bot, CharData speaker, string argument) { if (ComplainAboutDuplicates && argument == _lastMessageHeard) { if (!string.IsNullOrEmpty(DuplicateResponse)) { CommandType.Interpret(bot, "say" + DuplicateResponse); return(true); } else { CommandType.Interpret(bot, "say Don't repeat yourself. It makes you sound like an idiot."); return(true); } } foreach (ChatterResponse chat in Responses) { if (argument.Contains(chat.Keyphrase)) { CommandType.Interpret(bot, "say" + chat.Response); bot.RageFactor += chat.RageModifier; return(true); } } if (ComplainAboutNotUnderstanding) { if (!string.IsNullOrEmpty(DontUnderstandResponse)) { CommandType.Interpret(bot, "say" + DontUnderstandResponse); return(true); } else { CommandType.Interpret(bot, "say That doesn't mean anything to me."); return(true); } } return(false); }
public static void ReturnToLoad(CharData ch) { if (!ch || !ch.InRoom) { return; } if (ch.InRoom.Area != Room.GetRoom(ch.LoadRoomIndexNumber).Area) { return; } Exit.Direction dir = FindPath(ch.InRoom.IndexNumber, ch.LoadRoomIndexNumber, ch, -40000, true); if (dir == Exit.Direction.invalid) { return; } if (ch.InRoom.ExitData[(int)dir].HasFlag(Exit.ExitFlag.closed) && !ch.IsAffected(Affect.AFFECT_PASS_DOOR) && !ch.HasInnate(Race.RACE_PASSDOOR)) { CommandType.Interpret(ch, "unlock " + dir.ToString()); CommandType.Interpret(ch, "open " + dir.ToString()); return; } ch.Move(dir); if (!ch.InRoom) { string text = "Return_to_load: no ch._inRoom! Mob #" + ch.MobileTemplate.IndexNumber + ", _name: " + ch.Name + ". Placing mob in limbo (mob.AddToRoom())."; Log.Error(text, 0); ch.AddToRoom(Room.GetRoom(StaticRooms.GetRoomNumber("ROOM_NUMBER_LIMBO"))); ImmortalChat.SendImmortalChat(ch, ImmortalChat.IMMTALK_SPAM, 0, text); return; } return; }
/// <summary> /// Tracking code. /// </summary> /// <param name="ch"></param> public static void HuntVictim(CharData ch) { if (!ch || !ch.Hunting || !ch.IsAffected(Affect.AFFECT_TRACK)) { return; } if (ch.CurrentPosition != Position.standing) { if (ch.IsAffected(Affect.AFFECT_TRACK)) { ch.SendText("You abort your tracking effort.\r\n"); ch.RemoveAffect(Affect.AFFECT_TRACK); Combat.StopHunting(ch); } return; } CharData tmp = null; try { /* * Make sure the victim still exists. */ bool found = false; foreach (CharData it in Database.CharList) { ch = it; if (ch.Hunting != null && ch.Hunting.Who == tmp) { found = true; } } if (!found || !CharData.CanSee(ch, ch.Hunting.Who)) { if (!ch.IsAffected(Affect.AFFECT_TRACK)) { CommandType.Interpret(ch, "say Damn! My prey is gone!"); } else { ch.SendText("The trail seems to disappear.\r\n"); ch.RemoveAffect(Affect.AFFECT_TRACK); } Combat.StopHunting(ch); return; } if (ch.InRoom == ch.Hunting.Who.InRoom) { if (ch.Fighting) { return; } FoundPrey(ch, ch.Hunting.Who); return; } ch.WaitState(Skill.SkillList["track"].Delay); Exit.Direction dir = FindPath(ch.InRoom.IndexNumber, ch.Hunting.Who.InRoom.IndexNumber, ch, -40000, true); if (dir == Exit.Direction.invalid) { if (!ch.IsAffected(Affect.AFFECT_TRACK)) { SocketConnection.Act("$n&n says 'Damn! Lost $M!'", ch, null, ch.Hunting.Who, SocketConnection.MessageTarget.room); } else { ch.SendText("You lose the trail.\r\n"); ch.RemoveAffect(Affect.AFFECT_TRACK); Combat.StopHunting(ch); } return; } /* * Give a random direction if the mob misses the die roll. */ if (MUDMath.NumberPercent() > 75) /* @ 25% */ { do { dir = Database.RandomDoor(); }while (!(ch.InRoom.ExitData[(int)dir]) || !(ch.InRoom.ExitData[(int)dir].TargetRoom)); } if (ch.InRoom.ExitData[(int)dir].HasFlag(Exit.ExitFlag.closed)) { CommandType.Interpret(ch, "open " + dir.ToString()); return; } ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_HUNTING, 0, String.Format("{0}&n leaves room {1} to the {2}.", ch.ShortDescription, ch.InRoom.IndexNumber, dir.ToString())); if (ch.IsAffected(Affect.AFFECT_TRACK)) { SocketConnection.Act(String.Format("You sense $N&n's trail {0} from here...", dir.ToString()), ch, null, ch.Hunting.Who, SocketConnection.MessageTarget.character); } ch.Move(dir); if (ch.IsAffected(Affect.AFFECT_TRACK)) { SocketConnection.Act("$n&n peers around looking for tracks.", ch, null, null, SocketConnection.MessageTarget.room); } if (!ch.Hunting) { if (!ch.InRoom) { string text = String.Empty; text = String.Format("Hunt_victim: no ch.in_room! Mob #{0}, _name: {1}. Placing mob in limbo (ch.AddToRoom()).", ch.MobileTemplate.IndexNumber, ch.Name); Log.Error(text, 0); ch.AddToRoom(Room.GetRoom(StaticRooms.GetRoomNumber("ROOM_NUMBER_LIMBO"))); text = String.Format("{0}&n has gone to limbo while hunting {1}.", ch.ShortDescription, ch.Hunting.Name); ImmortalChat.SendImmortalChat(null, ImmortalChat.IMMTALK_HUNTING, 0, text); return; } CommandType.Interpret(ch, "say Damn! Lost my prey!"); return; } if (ch.InRoom == ch.Hunting.Who.InRoom) { FoundPrey(ch, ch.Hunting.Who); } return; } catch (Exception ex) { Log.Error("Exception in HuntVictim: " + ex.ToString()); } }