public static bool Execute(MobileInstance ch, IManager dbManager) { var handler = Program.Kernel.Get <ISpecFunHandler>(); ch.SummonIfHating(); if (!ch.IsInCombatPosition()) { return(false); } var victim = ch.CurrentRoom.Persons.Where(v => v != ch) .FirstOrDefault(vch => SmaugRandom.Bits(2) == 0 && vch.GetMyTarget() == ch); if (victim == null || victim == ch) { return(false); } var skill = handler.PickSpell(SpellLevelLookupTable, ch.Level); if (skill?.SpellFunction == null) { return(false); } skill.SpellFunction.Value.DynamicInvoke(skill.ID, ch.Level, ch, victim); return(true); }
public static bool Execute(MobileInstance ch, string spellName, IManager dbManager) { if (!ch.IsInCombatPosition()) { return(false); } var victim = ch.CurrentRoom.Persons.Where(v => v != ch) .FirstOrDefault(vch => SmaugRandom.Bits(2) == 0 && vch.GetMyTarget() == ch); if (victim == null) { return(false); } var databaseMgr = (IRepositoryManager)(dbManager ?? RepositoryManager.Instance); var skill = databaseMgr.GetEntity <SkillData>(spellName); if (skill?.SpellFunction == null) { return(false); } skill.SpellFunction.Value.Invoke((int)skill.ID, ch.Level, ch, victim); return(true); }
public static bool Execute(MobileInstance ch, IManager dbManager) { if (!_move) { if (GameManager.Instance.GameTime.Hour == 6 || GameManager.Instance.GameTime.Hour == 20) { _move = true; _index = 0; } _path = GameManager.Instance.GameTime.Hour == 6 ? OpenPath : (GameManager.Instance.GameTime.Hour == 20 ? ClosePath : string.Empty); } if (ch.CurrentFighting != null) { return(CastCleric.Execute(ch, dbManager)); } if (!_move || (int)ch.CurrentPosition < (int)PositionTypes.Sleeping) { return(false); } if (ActionLookupTable.ContainsKey(_path[_index])) { ActionLookupTable[_path[_index]].Invoke(ch); } _index++; return(true); }
private static bool CastSpell(MobileInstance ch, CharacterInstance victim, int bitFlag, string spellName, IManager dbManager) { var databaseMgr = (IRepositoryManager)(dbManager ?? RepositoryManager.Instance); var skill = databaseMgr.GetEntity <SkillData>(spellName); switch (bitFlag) { case 0: case 1: case 3: case 5: case 6: Smaug.spell_smaug((int)skill.ID, ch.Level, ch, victim); return(true); case 2: CureBlindness.spell_cure_blindness((int)skill.ID, ch.Level, ch, victim); return(true); case 4: CurePoison.spell_cure_poison((int)skill.ID, ch.Level, ch, victim); return(true); case 7: RemoveCurse.spell_remove_curse((int)skill.ID, ch.Level, ch, victim); return(true); } return(false); }
public static int GetAdjustedRepairCost(MobileInstance keeper, ObjectInstance obj) { if (obj == null || keeper.MobIndex.Shop == null) { return(0); } var shop = keeper.MobIndex.RepairShop; var cost = shop.ItemTypes.ToList().Any(x => x == obj.ItemType) ? obj.Cost * shop.ProfitFix / 1000 : 0; if (cost <= 0) { cost = 1; } switch (obj.ItemType) { case ItemTypes.Armor: cost = obj.GetArmorRepairCost(cost); break; case ItemTypes.Weapon: cost = obj.GetWeaponRepairCost(cost, GameConstants.GetConstant <int>("InitWeaponCondition")); break; case ItemTypes.Wand: case ItemTypes.Staff: cost = obj.GetImplementRepairCost(cost); break; } return(cost); }
public void IsDevoted_IsNpc_Test() { MobileInstance mob = new MobileInstance(1, "TestChar"); mob.Act.SetBit((int)ActFlags.IsNpc); Assert.That(mob.IsDevoted(), Is.False); }
public void TimesKilled_MobIsPlayer_Test() { PlayerInstance pch = new PlayerInstance(1, "TestChar"); MobileInstance mob = new MobileInstance(2, "TesterMob"); Assert.That(pch.TimesKilled(mob), Is.EqualTo(0)); }
private static int GetCostIfBuying(CharacterInstance ch, MobileInstance keeper, ObjectInstance obj) { var richCustomer = ch.CurrentCoin > ch.Level * ch.Level * 100000; var profitMod = 13 - ch.GetCurrentCharisma() + (richCustomer ? 15 : 0) + (ch.Level.GetNumberThatIsBetween(5, LevelConstants.AvatarLevel) - 20) / 2; var shop = keeper.MobIndex.Shop.CastAs <ItemShopData>(); var cost = obj.Cost * (shop.ProfitSell + 1).GetHighestOfTwoNumbers(shop.ProfitBuy + profitMod) / 100; return(cost); }
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 void TimesKilled_NoMatch_Test() { PlayerInstance pch = new PlayerInstance(1, "TestChar"); MobileInstance mob = new MobileInstance(2, "TesterMob"); mob.Act.SetBit((int)ActFlags.IsNpc); mob.Parent = new MobileTemplate(2, "Template"); pch.PlayerData = new PlayerData(1, 1); Assert.That(pch.TimesKilled(mob), Is.EqualTo(0)); }
public static bool Execute(MobileInstance ch, IManager dbManager) { if (!ch.IsInCombatPosition()) { return(false); } var bits = SmaugRandom.Bits(3); return(bits == 2 ? Dragon.Execute(ch, "lightning breath", dbManager) : Dragon.Execute(ch, BreathTable.ContainsKey(bits) ? BreathTable[bits] : "frost breath", dbManager)); }
public static void StartHating(this MobileInstance ch, CharacterInstance victim) { if (ch.CurrentHating != null) { ch.StopHating(); } ch.CurrentHating = new HuntHateFearData { Name = victim.Name, Who = victim }; }
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 int GetAdjustedCost(CharacterInstance ch, MobileInstance keeper, ObjectInstance obj, bool buy) { if (obj == null || keeper.MobIndex.Shop == null) { return(0); } var cost = buy ? GetCostIfBuying(ch, keeper, obj) : GetCostIfSelling(ch, keeper, obj); if (obj.ItemType == ItemTypes.Staff || obj.ItemType == ItemTypes.Wand) { cost *= (obj.Values.Charges / obj.Values.MaxCharges); } return(cost); }
private static bool IsShopClosed(MobileInstance keeper, CharacterInstance ch, int gameHour) { var shop = keeper.MobIndex.Shop; if (gameHour < shop.OpenHour) { Say.do_say(keeper, "Sorry, come back later."); return(true); } if (gameHour <= shop.CloseHour) { return(false); } Say.do_say(keeper, "Sorry, come back tomorrow."); return(true); }
public static void CheckIfExecuteText(MobileInstance mob, MudProgData mudProg, string txt) { if (mudProg.ArgList.StartsWith("p ")) { if (txt.ContainsIgnoreCase(mudProg.ArgList)) { CheckIfExecute(mob, mudProg.Type); } return; } var words = mudProg.ArgList.Split(' '); foreach (var word in words.Where(txt.ContainsIgnoreCase)) { CheckIfExecute(mob, mudProg.Type); } }
public static bool Execute(MobileInstance ch, IManager dbManager) { if (ch.CurrentPosition != PositionTypes.Standing) { return(false); } if (SmaugRandom.Bits(2) != 0) { return(false); } foreach (var victim in ch.CurrentRoom.Persons.Where(victim => victim != ch) .Where(victim => !victim.IsNpc()) .Where(victim => victim.Level < LevelConstants.ImmortalLevel) .Where(ch.CanSee)) { if (victim.IsAwake() && SmaugRandom.Between(0, ch.Level) == 0) { comm.act(ATTypes.AT_ACTION, "You discover $n's hands in your sack of gold!", ch, null, victim, ToTypes.Victim); comm.act(ATTypes.AT_ACTION, "$N discovers $n's hands in $S sack of gold!", ch, null, victim, ToTypes.NotVictim); return(true); } var maxgold = ch.Level * ch.Level * 1000; var gold = victim.CurrentCoin * SmaugRandom.Between(1, 2.GetNumberThatIsBetween(ch.Level / 4, 10)) / 100; ch.CurrentCoin += 9 * gold / 10; victim.CurrentCoin -= gold; if (ch.CurrentCoin <= maxgold) { return(true); } ch.CurrentRoom.Area.BoostEconomy(ch.CurrentCoin - maxgold / 2); ch.CurrentCoin = maxgold / 2; return(true); } return(false); }
private static int GetCostIfSelling(CharacterInstance ch, MobileInstance keeper, ObjectInstance obj) { var richCustomer = ch.CurrentCoin > ch.Level * ch.Level * 100000; var profitMod = 13 - ch.GetCurrentCharisma() + (richCustomer ? 15 : 0); var shop = keeper.MobIndex.Shop.CastAs <ItemShopData>(); var cost = 0; if (shop.ItemTypes.ToList().Contains(obj.ItemType)) { cost = obj.Cost * (shop.ProfitBuy - 1).GetLowestOfTwoNumbers(shop.ProfitSell + profitMod) / 100; } if (keeper.Carrying.Any(carriedObj => obj.ObjectIndex == carriedObj.ObjectIndex)) { cost = 0; } return(cost); }
public static void appraise_all(CharacterInstance ch, MobileInstance keeper, string fixstr) { int total = 0, cost = 0; string buffer; foreach (var obj in ch.Carrying.Where(obj => obj.WearLocation == WearLocations.None && ch.CanSee(obj) && (obj.ItemType.GetAttribute <ValuedAttribute>() != null))) { if (!ch.CanDrop(obj)) { ch.Printf("You can't let go of %s.", obj.Name); continue; } if ((cost = Appraise.GetAdjustedRepairCost(keeper, obj)) > 0) { comm.act(ATTypes.AT_TELL, cost != -2 ? "$n tells you, 'Sorry, I can't do anything with $p.'" : "$n tells you, '$p looks fine to me!'", keeper, obj, ch, ToTypes.Victim); continue; } buffer = $"$N tells you, 'It will cost {cost} piece{(cost == 1 ? "" : "s")} of gold to {fixstr} {obj.Name}.'"; comm.act(ATTypes.AT_TELL, buffer, ch, null, keeper, ToTypes.Character); total += cost; } if (total <= 0) { return; } ch.SendTo("\r\n"); buffer = $"$N tells you, 'It will cost {total} piece{(cost == 1 ? "" : "s")} of gold in total.'"; comm.act(ATTypes.AT_TELL, buffer, ch, null, keeper, ToTypes.Character); comm.act(ATTypes.AT_TELL, "$N tells you, 'Remember there is a 10% surcharge for repairing all your items.", ch, null, keeper, ToTypes.Character); }
public static void SummonIfHating(this MobileInstance ch, IRepositoryManager dbManager = null) { if ((int)ch.CurrentPosition <= (int)PositionTypes.Sleeping || ch.CurrentFighting != null || ch.CurrentFearing != null || ch.CurrentHating == null || ch.CurrentRoom.Flags.IsSet(RoomFlags.Safe) || ch.CurrentHunting != null) { return; } var victim = (dbManager ?? RepositoryManager.Instance).GetEntity <CharacterInstance>(ch.CurrentHating.Name); if (victim == null || ch.CurrentRoom == victim.CurrentRoom) { return; } Cast.do_cast(ch, $"summon {(victim.IsNpc() ? string.Empty : "0.")}{ch.CurrentHating.Name}"); }
public static void CheckIfExecute(MobileInstance mob, MudProgTypes type) { foreach (var mprog in mob.MobIndex.MudProgs) { int chance; if (!int.TryParse(mprog.ArgList, out chance)) { throw new InvalidDataException(); } if (mprog.Type != type || SmaugRandom.D100() > chance) { continue; } mprog.Execute(mob); if (type != MudProgTypes.Greet && type != MudProgTypes.GreetAll) { break; } } }
public static bool Execute(MobileInstance ch, IManager dbManager) { if (!ch.IsAwake()) { return(false); } foreach (var corpse in ch.CurrentRoom.Contents.Where(obj => obj.ItemType == ItemTypes.NpcCorpse)) { comm.act(ATTypes.AT_ACTION, "$n savagely devours a corpse.", ch, null, null, ToTypes.Room); foreach (var obj in corpse.Contents) { corpse.RemoveFrom(obj); ch.CurrentRoom.AddTo(obj); } corpse.Extract(); return(true); } return(false); }
public static bool Execute(MobileInstance ch, IManager dbManager) { if (!ch.IsInCombatPosition()) { return(false); } var victim = ch.GetMyTarget(); if (victim == null || (SmaugRandom.D100() > 2 * ch.Level)) { return(false); } comm.act(ATTypes.AT_HIT, "You bite $N!", ch, null, victim, ToTypes.Character); comm.act(ATTypes.AT_ACTION, "$n bites $N!", ch, null, victim, ToTypes.NotVictim); comm.act(ATTypes.AT_POISON, "$n bites you!", ch, null, victim, ToTypes.Victim); var databaseMgr = (IRepositoryManager)(dbManager ?? RepositoryManager.Instance); Spells.Poison.spell_poison((int)databaseMgr.GetEntity <SkillData>("poison").ID, ch.Level, ch, victim); return(true); }
private static int ReduceXPForKillingSameMobRepeatedly(CharacterInstance ch, MobileInstance victim, int xp) { var modXp = xp; var times = ((PlayerInstance)ch).TimesKilled(victim); if (times > 0 && times < 20) { modXp = modXp * (20 - times) / 20; if (times > 15) { modXp /= 3; } else if (times > 10) { modXp >>= 1; } } else { modXp = 0; } return(modXp); }
public static bool Execute(MobileInstance ch, IManager dbManager) { if (!ch.IsAwake() || ch.CurrentFighting != null) { return(false); } var victim = ch.CurrentRoom.Persons.Where(vch => vch != ch) .Where(ch.CanSee) .FirstOrDefault(vch => SmaugRandom.Bits(1) != 0); if (victim == null) { return(false); } var bits = SmaugRandom.Bits(3); var actLookupValue = ActLookupTable[bits]; comm.act(ATTypes.AT_MAGIC, $"$n utters the word '{actLookupValue.Item1}'.", ch, null, null, ToTypes.Room); return(CastSpell(ch, victim, bits, actLookupValue.Item2, dbManager)); }
private static void CheckNpc(MobileInstance ch, IRepositoryManager dbManager) { if ((_charCounter & 1) > 0) { return; } if (ch.Act.IsSet((int)ActFlags.Running)) { if (!ch.Act.IsSet((int)ActFlags.Sentinel) && ch.CurrentPosition == PositionTypes.Standing && !ch.Act.IsSet((int)ActFlags.Mounted) && ch.CurrentFighting == null && ch.CurrentHunting != null) { Macros.WAIT_STATE(ch, 2 * GameConstants.GetSystemValue <int>("PulseViolence")); track.hunt_victim(ch); return; } if (ch.SpecialFunction != null) { if (ch.SpecialFunction.Value.Invoke(ch, dbManager)) { return; } if (ch.CharDied()) { return; } } if (!ch.Act.IsSet((int)ActFlags.Sentinel) && ch.CurrentPosition == PositionTypes.Standing && !ch.Act.IsSet((int)ActFlags.Mounted) && !ch.Act.IsSet((int)ActFlags.Prototype)) { var door = SmaugRandom.Bits(4); if (door >= 9) { return; } var exit = ch.CurrentRoom.GetExit(door); if (exit == null) { return; } if (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 (ch.Act.IsSet((int)ActFlags.StayArea) && ch.CurrentRoom.Area != room.Area) { return; } Move.move_char(ch, exit, 0); } } }
public static void StopFearing(this MobileInstance ch) { ch.CurrentFearing = null; }
public static void StopHunting(this MobileInstance ch) { ch.CurrentHunting = null; }
public static bool IsFearing(this MobileInstance ch, CharacterInstance victim) { return(ch.CurrentFearing != null && ch.CurrentFearing.Who == victim); }
public static void Execute(MobileInstance mob) { }