public static void do_consider(CharacterInstance ch, string argument) { var arg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, arg, "Consider killing whom?")) { return; } var victim = ch.GetCharacterInRoom(arg); if (CheckFunctions.CheckIfNullObject(ch, victim, "They're not here.")) { return; } if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "You decide you're pretty sure you could take yourself in a fight.")) { return; } var levelDiff = victim.Level - ch.Level; var msg = GetLevelConsiderMessage(levelDiff); comm.act(ATTypes.AT_CONSIDER, msg, ch, null, victim, ToTypes.Character); levelDiff = (victim.MaximumHealth - ch.MaximumHealth) / 6; msg = GetHealthConsiderMessage(levelDiff); comm.act(ATTypes.AT_CONSIDER, msg, ch, null, victim, ToTypes.Character); }
private static void DrinkFromPotion(CharacterInstance ch, ObjectInstance obj) { if (CheckFunctions.CheckIfEquivalent(ch, ch, obj.CarriedBy, "You're not carrying that.")) { return; } interp.interpret(ch, $"quaff {obj.Name}"); }
public static void do_kill(CharacterInstance ch, string argument) { if (CheckFunctions.CheckIfEmptyString(ch, argument, "Kill whom?")) { return; } var firstArg = argument.FirstWord(); var victim = ch.GetCharacterInRoom(firstArg); if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here.")) { return; } if (CheckFunctions.CheckIfTrue(ch, victim.IsNpc() && victim.CurrentMorph != null, "This creature appears strange to you. Look upon it more closely before attempting to kill it.")) { return; } if (CheckFunctions.CheckIfTrue(ch, !victim.IsNpc() && !victim.Act.IsSet((int)PlayerFlags.Killer) && !victim.Act.IsSet((int)PlayerFlags.Thief), "You must MURDER a player.")) { return; } if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "You hit yourself. Ouch!")) { fight.multi_hit(ch, ch, Program.TYPE_UNDEFINED); return; } if (fight.is_safe(ch, victim, true)) { return; } if (ch.IsAffected(AffectedByTypes.Charm) && ch.Master == victim) { comm.act(ATTypes.AT_PLAIN, "$N is your beloved master.", ch, null, victim, ToTypes.Character); return; } if (CheckFunctions.CheckIfTrue(ch, ch.IsInCombatPosition(), "You do the best you can!")) { return; } Macros.WAIT_STATE(ch, 1 * GameConstants.GetSystemValue <int>("PulseViolence")); ch.CheckAttackForAttackerFlag(victim); fight.multi_hit(ch, victim, Program.TYPE_UNDEFINED); }
private static bool IsKeeperFighting(CharacterInstance keeper, CharacterInstance ch) { var whof = keeper.GetMyTarget(); if (whof == null) { return(false); } if (!CheckFunctions.CheckIfEquivalent(ch, whof, ch, "I don't think that's a good idea...")) { Say.do_say(keeper, "I'm too busy for that!"); } return(true); }
private static void EmptyIntoObject(CharacterInstance ch, ObjectInstance obj, string arg) { var destObj = ch.GetObjectOnMeOrInRoom(arg); if (CheckFunctions.CheckIfNullObject(ch, destObj, "You can't find it.")) { return; } if (CheckFunctions.CheckIfEquivalent(ch, destObj, obj, "You can't empty something into itself!")) { return; } if (CheckFunctions.CheckIfTrue(ch, destObj.ItemType != ItemTypes.Container && destObj.ItemType != ItemTypes.KeyRing && destObj.ItemType != ItemTypes.Quiver, "That's not a container!")) { return; } if (((int)destObj.Values.Flags).IsSet(ContainerFlags.Closed)) { comm.act(ATTypes.AT_PLAIN, "The $d is closed.", ch, null, destObj.Name, ToTypes.Character); return; } destObj.Split(); if (obj.Empty(destObj)) { comm.act(ATTypes.AT_ACTION, "You empty $p into $P.", ch, obj, destObj, ToTypes.Character); comm.act(ATTypes.AT_ACTION, "$n empties $p into $P.", ch, obj, destObj, ToTypes.Room); if (destObj.CarriedBy == null && GetSaveFlags().IsSet(AutoSaveFlags.Empty)) { save.save_char_obj(ch); } } else { comm.act(ATTypes.AT_ACTION, "$P is too full.", ch, obj, destObj, ToTypes.Character); } }
public static void do_slay(CharacterInstance ch, string argument) { var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Slay whom?")) { return; } var victim = ch.GetCharacterInRoom(firstArg); if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here.")) { return; } if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "Suicide is a mortal sin.")) { return; } if (CheckFunctions.CheckIfTrue(ch, !victim.IsNpc() && victim.Trust >= ch.Trust, "You failed.")) { return; } var secondArg = argument.SecondWord(); if (SlayTable.ContainsKey(secondArg.ToLower())) { SlayTable[secondArg.ToLower()].Invoke(ch, victim); } else { Default(ch, victim); } handler.set_cur_char(victim); ch.RawKill(victim); }
public static void do_shove(CharacterInstance ch, string argument) { if (CheckFunctions.CheckIfTrue(ch, ch.IsNpc() || !((PlayerInstance)ch).PlayerData.Flags.IsSet(PCFlags.Deadly), "Only deadly characters can shove.")) { return; } if (CheckFunctions.CheckIfTrue(ch, ch.HasTimer(TimerTypes.PKilled), "You can't shove a player right now.")) { return; } var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Shove whom?")) { return; } var victim = ch.GetCharacterInRoom(firstArg); if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here.")) { return; } if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "You shove yourself around, to no avail.")) { return; } if (CheckFunctions.CheckIfTrue(ch, victim.IsNpc() || !((PlayerInstance)victim).PlayerData.Flags.IsSet(PCFlags.Deadly), "You can only shove deadly characters.")) { return; } if (CheckFunctions.CheckIfTrue(ch, ch.Level.GetAbsoluteDifference(victim.Level) > 5, "There is too great an experience difference for you to even bother.")) { return; } if (CheckFunctions.CheckIfNullObject(ch, victim.HasTimer(TimerTypes.PKilled), "You can't shove that player right now.")) { return; } if (victim.CurrentPosition != PositionTypes.Standing) { comm.act(ATTypes.AT_PLAIN, "$N isn't standing up.", ch, null, victim, ToTypes.Character); return; } var secondArg = argument.SecondWord(); if (CheckFunctions.CheckIfEmptyString(ch, secondArg, "Shove them in which direction?")) { return; } if (CheckFunctions.CheckIfTrue(ch, victim.CurrentRoom.Flags.IsSet(RoomFlags.Safe) && !ch.HasTimer(TimerTypes.ShoveDrag), "That character cannot be shoved right now.")) { return; } victim.CurrentPosition = PositionTypes.Shove; var exitDir = EnumerationExtensions.GetEnumByName <DirectionTypes>(secondArg); var exit = ch.CurrentRoom.GetExit(exitDir); if (CheckFunctions.CheckIfNullObject(ch, exit, "There's no exit in that direction.")) { victim.CurrentPosition = PositionTypes.Standing; return; } if (CheckFunctions.CheckIfTrue(ch, exit.Flags.IsSet(ExitFlags.Closed) && (!victim.IsAffected(AffectedByTypes.PassDoor) || exit.Flags.IsSet(ExitFlags.NoPassDoor)), "There's no exit in that direction.")) { victim.CurrentPosition = PositionTypes.Standing; return; } var toRoom = exit.GetDestination(); if (CheckFunctions.CheckIfSet(ch, toRoom.Flags, RoomFlags.Death, "You cannot shove someone into a death trap.")) { victim.CurrentPosition = PositionTypes.Standing; return; } if (CheckFunctions.CheckIfTrue(ch, ch.CurrentRoom.Area != toRoom.Area && !toRoom.Area.IsInHardRange(victim), "That character cannot enter that area.")) { victim.CurrentPosition = PositionTypes.Standing; return; } var chance = GetChanceByCharacterClass(ch); chance += (ch.GetCurrentStrength() - 15) * 3; chance += ch.Level - victim.Level; chance += GetBonusByCharacterRace(ch); if (CheckFunctions.CheckIfTrue(ch, chance < SmaugRandom.D100(), "You failed.")) { victim.CurrentPosition = PositionTypes.Standing; return; } comm.act(ATTypes.AT_ACTION, "You shove $M.", ch, null, victim, ToTypes.Character); comm.act(ATTypes.AT_ACTION, "$n shoves you.", ch, null, victim, ToTypes.Victim); Move.move_char(victim, exit, 0); if (!victim.CharDied()) { victim.CurrentPosition = PositionTypes.Standing; } Macros.WAIT_STATE(ch, 12); if (ch.CurrentRoom.Flags.IsSet(RoomFlags.Safe) && !ch.HasTimer(TimerTypes.ShoveDrag)) { ch.AddTimer(TimerTypes.ShoveDrag, 10); } }
public static bool CheckAbility(CharacterInstance ch, string command, string argument, IRepositoryManager databaseManager = null) { var sn = ch.GetIDOfSkillCharacterKnows(command); if (sn == -1) { return(false); } var skill = (databaseManager ?? RepositoryManager.Instance).GetEntity <SkillData>(sn); if (skill.SkillFunction == null || skill.SpellFunction == null || ch.CanUseSkill(0, sn)) { return(false); } if (!interp.check_pos(ch, skill.MinimumPosition)) { return(true); } if (CheckFunctions.CheckIf(ch, HelperFunctions.IsCharmedOrPossessed, "For some reason, you seem unable to perform that...", new List <object> { ch })) { comm.act(ATTypes.AT_GREY, "$n wanders around aimlessly.", ch, null, null, ToTypes.Room); return(true); } //// Check if mana is required int mana = 0, blood = 0; if (skill.MinimumMana > 0) { mana = ch.IsNpc() ? 0 : skill.MinimumMana .GetHighestOfTwoNumbers(100 / (2 + ch.Level - skill.RaceLevel.ToList()[(int)ch.CurrentRace])); if (CheckFunctions.CheckIf(ch, HelperFunctions.HasSufficientBloodPower, "You don't have enough blood power.", new List <object> { ch, blood })) { return(true); } if (CheckFunctions.CheckIf(ch, HelperFunctions.HasSufficientMana, "You don't have enough mana.", new List <object> { ch, mana })) { return(true); } } DateTime start, end; //// Is this a real d-fun or just a spell? if (skill.SkillFunction == null) { CharacterInstance victim = null; ObjectInstance obj = null; var targetName = string.Empty; object vo; switch (skill.Target) { default: LogManager.Instance.Bug("Bad target to Skill {0}", sn); ch.SendTo("Something went wrong..."); return(true); case TargetTypes.Ignore: vo = null; victim = ch.GetMyTarget(); targetName = argument.IsNullOrEmpty() && victim != null ? victim.Name : argument; break; case TargetTypes.OffensiveCharacter: victim = ch.GetMyTarget(); if (argument.IsNullOrEmpty() && victim == null) { ch.Printf("Confusion overcomes you as your '%s' has no target.\r\n", skill.Name); return(true); } victim = ch.GetCharacterInRoom(argument); if (CheckFunctions.CheckIfTrue(ch, !argument.IsNullOrEmpty() && victim == null, "They aren't here.")) { return(true); } if (fight.is_safe(ch, victim, true)) { return(true); } if (CheckFunctions.CheckIfTrue(ch, ch == victim && skill.Flags.IsSet(SkillFlags.NoSelf), "You can't target yourself!")) { return(true); } if (!ch.IsNpc()) { if (!victim.IsNpc()) { if (CheckFunctions.CheckIfNotNullObject(ch, ch.GetTimer(TimerTypes.PKilled), "You have been killed in the last five minutes.")) { return(true); } if (CheckFunctions.CheckIfNotNullObject(ch, victim.GetTimer(TimerTypes.PKilled), "This player has been killed in the last five minutes.")) { return(true); } if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "You really shouldn't do this to another player...")) { return(true); } } if (CheckFunctions.CheckIfTrue(ch, ch.IsAffected(AffectedByTypes.Charm) && ch.Master == victim, "You can't do that on your own follower.")) { return(true); } } if (CheckFunctions.CheckIfTrue(ch, fight.check_illegal_pk(ch, victim), "You can't do that to another player!")) { return(true); } vo = victim; break; case TargetTypes.DefensiveCharacter: victim = ch.GetCharacterInRoom(argument); if (CheckFunctions.CheckIfTrue(ch, !argument.IsNullOrEmpty() && victim == null, "They aren't here.")) { return(true); } if (CheckFunctions.CheckIfTrue(ch, ch == victim && skill.Flags.IsSet(SkillFlags.NoSelf), "You can't target yourself!")) { return(true); } vo = victim; break; case TargetTypes.Self: victim = ch; vo = ch; break; case TargetTypes.InventoryObject: obj = ch.GetCarriedObject(argument); if (CheckFunctions.CheckIfNullObject(ch, obj, "You can't find that.")) { return(true); } vo = obj; break; } Macros.WAIT_STATE(ch, skill.Rounds); //// Check for failure if (SmaugRandom.D100() + skill.difficulty * 5 > (ch.IsNpc() ? 75 : Macros.LEARNED(ch, (int)skill.ID))) { ch.FailedCast(skill, victim, obj); skill.LearnFromFailure((PlayerInstance)ch); if (mana > 0) { if (ch.IsVampire()) { ((PlayerInstance)ch).GainCondition(ConditionTypes.Bloodthirsty, -blood / 2); } else { ch.CurrentMana -= mana / 2; } } return(true); } if (mana > 0) { if (ch.IsVampire()) { ((PlayerInstance)ch).GainCondition(ConditionTypes.Bloodthirsty, -blood); } else { ch.CurrentMana -= mana; } } start = DateTime.Now; var retcode = skill.SpellFunction.Value.Invoke((int)skill.ID, ch.Level, ch, vo); end = DateTime.Now; skill.UseHistory.Use(ch, end.Subtract(start)); if (retcode == ReturnTypes.CharacterDied || retcode == ReturnTypes.Error || ch.CharDied()) { return(true); } if (retcode == ReturnTypes.SpellFailed) { skill.LearnFromFailure((PlayerInstance)ch); retcode = ReturnTypes.None; } else { skill.AbilityLearnFromSuccess((PlayerInstance)ch); } if (skill.Target == TargetTypes.OffensiveCharacter && victim != ch && !victim.CharDied()) { if (ch.CurrentRoom.Persons.Any(vch => victim == vch && victim.CurrentFighting == null && victim.Master != ch)) { retcode = fight.multi_hit(victim, ch, Program.TYPE_UNDEFINED); } } return(true); } if (mana > 0) { if (ch.IsVampire()) { ((PlayerInstance)ch).GainCondition(ConditionTypes.Bloodthirsty, -blood); } else { ch.CurrentMana -= mana; } } ch.LastCommand = skill.SkillFunction; start = DateTime.Now; skill.SkillFunction.Value.Invoke(ch, argument); end = DateTime.Now; skill.UseHistory.Use(ch, end.Subtract(start)); // TODO: Tail chain? return(true); }
public static ReturnTypes spell_animate_dead(int sn, int level, CharacterInstance ch, object vo) { var corpse = ch.CurrentRoom.Contents.FirstOrDefault(x => x.ItemType == ItemTypes.NpcCorpse && x.Cost != -5); if (CheckFunctions.CheckIfNullObject(ch, corpse, "You cannot find a suitable corpse here")) { return(ReturnTypes.SpellFailed); } var skill = RepositoryManager.Instance.GetEntity <SkillData>(sn); var template = RepositoryManager.Instance.MOBILETEMPLATES.Get(VnumConstants.MOB_VNUM_ANIMATED_CORPSE); if (template == null) { throw new ObjectNotFoundException("Animated Corpse VNUM template was not found."); } // TODO Get the template using the corpse cost? huh? if (CheckFunctions.CheckIfEquivalent(ch, template, RepositoryManager.Instance.MOBILETEMPLATES.Get(VnumConstants.MOB_VNUM_DEITY), "You can't animate the corpse of a deity's Avatar.")) { return(ReturnTypes.SpellFailed); } if (!ch.IsNpc()) { if (ch.IsVampire()) { if (CheckFunctions.CheckIfTrue(ch, !ch.IsImmortal() && ((PlayerInstance)ch).PlayerData.GetConditionValue(ConditionTypes.Bloodthirsty) - template.Level / 3 < 0, "You don't have the power to reanimate this corpse.")) { return(ReturnTypes.SpellFailed); } ((PlayerInstance)ch).GainCondition(ConditionTypes.Bloodthirsty, template.Level / 3); } else if (ch.CurrentMana - template.Level / 4 < 0) { ch.SendTo("You do not have enough mana to reanimate this corpse."); return(ReturnTypes.SpellFailed); } else { ch.CurrentMana -= template.Level * 4; } } if (ch.IsImmortal() || (ch.Chance(75) && template.Level - ch.Level < 10)) { return(AnimateCorpse(level, ch, template, corpse)); } ch.FailedCast(skill); return(ReturnTypes.SpellFailed); }
public static void do_murder(CharacterInstance ch, string argument) { if (CheckFunctions.CheckIfEmptyString(ch, argument, "Murder whom?")) { return; } var firstArg = argument.FirstWord(); var victim = ch.GetCharacterInRoom(firstArg); if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here.")) { return; } if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "Suicide is a mortal sin.")) { return; } if (fight.is_safe(ch, victim, true)) { return; } if (ch.IsAffected(AffectedByTypes.Charm)) { if (ch.Master == victim) { comm.act(ATTypes.AT_PLAIN, "$N is your beloeved master.", ch, null, victim, ToTypes.Character); return; } ch.Master?.Act.SetBit((int)PlayerFlags.Attacker); } if (CheckFunctions.CheckIfTrue(ch, ch.IsInCombatPosition(), "You do the best you can!")) { return; } if (CheckFunctions.CheckIfTrue(ch, !victim.IsNpc() && ch.Act.IsSet((int)PlayerFlags.Nice), "You feel too nice to do that!")) { return; } // TODO Log the murder Macros.WAIT_STATE(ch, 1 & GameConstants.GetSystemValue <int>("PulseViolence")); var buf = $"Help! I am being attacked by {(ch.IsNpc() ? ch.ShortDescription : ch.Name)}!"; if (victim.IsPKill()) { Wartalk.do_wartalk(victim, buf); } else { Yell.do_yell(victim, buf); } fight.check_illegal_pk(ch, victim); ch.CheckAttackForAttackerFlag(victim); fight.multi_hit(ch, victim, Program.TYPE_UNDEFINED); }
public void CheckIfEquivalent() { var actor = new CharacterInstance(1, "TestNpc"); Assert.That(CheckFunctions.CheckIfEquivalent(actor, actor, actor, string.Empty), Is.True); }
public static void do_order(CharacterInstance ch, string argument) { var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, firstArg, "Order whom to do what?")) { return; } if (CheckFunctions.CheckIfTrue(ch, ch.IsAffected(AffectedByTypes.Charm), "You feel like taking, not giving, orders.")) { return; } if (CheckFunctions.CheckIfTrue(ch, firstArg.EqualsIgnoreCase("mp"), "No... I don't think so.")) { return; } var all = false; CharacterInstance victim = null; var secondArg = argument.SecondWord(); if (secondArg.EqualsIgnoreCase("all")) { all = true; } else { victim = ch.GetCharacterInRoom(secondArg); if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here.")) { return; } if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "Aye aye, right away!")) { return; } if (CheckFunctions.CheckIfTrue(ch, !victim.IsAffected(AffectedByTypes.Charm) || victim.Master != ch, "Do it yourself!")) { return; } } var found = false; foreach (var och in ch.CurrentRoom.Persons .Where(och => och.IsAffected(AffectedByTypes.Charm) && och.Master == ch && (all || och == victim))) { found = true; comm.act(ATTypes.AT_ACTION, "$n orders you to '$t'", ch, firstArg, och, ToTypes.Victim); interp.interpret(och, firstArg); } if (CheckFunctions.CheckIfTrue(ch, !found, "You have no followers here.")) { return; } LogManager.Instance.Info("{0}: order {1}.", ch.Name, string.Format(argument, (int)LogTypes.Info, ch.Level)); ch.SendTo("Ok."); Macros.WAIT_STATE(ch, 12); }
private static void PlaceBid(CharacterInstance ch, string argument, IAuctionManager auctionManager) { if (CheckFunctions.CheckIfNullObject(ch, (auctionManager ?? AuctionManager.Instance).Auction, "There isn't anything being auctioned right now.")) { return; } var auction = (auctionManager ?? AuctionManager.Instance).Auction; if (CheckFunctions.CheckIfTrue(ch, ch.Level < auction.ItemForSale.Level, "This object's level is too high for your use.")) { return; } if (CheckFunctions.CheckIfEquivalent(ch, ch, auction.Seller, "You can't bid on your own item!")) { return; } var secondArg = argument.SecondWord(); if (CheckFunctions.CheckIfEmptyString(ch, secondArg, "Bid how much?")) { return; } var bid = Program.parsebet(auction.BidAmount, secondArg); if (CheckFunctions.CheckIfTrue(ch, bid < auction.StartingBid, "You must place a bid that is higher than the starting bet.")) { return; } if (CheckFunctions.CheckIfTrue(ch, bid < auction.BidAmount + 10000, "You must bid at least 10,000 coins over the current bid.")) { return; } if (CheckFunctions.CheckIfTrue(ch, bid < ch.CurrentCoin, "You don't have that much money!")) { return; } if (CheckFunctions.CheckIfTrue(ch, bid > GameConstants.GetSystemValue <int>("MaximumAuctionBid"), $"You can't bid over {GameConstants.GetSystemValue<int>("MaximumAuctionBid")} coins.")) { return; } var thirdArg = argument.ThirdWord(); if (CheckFunctions.CheckIfTrue(ch, thirdArg.IsNullOrEmpty() || auction.ItemForSale.Name.IsAnyEqual(thirdArg), "That item is not being auctioned right now.")) { return; } if (auction.Buyer != null && auction.Buyer != auction.Seller) { auction.Buyer.CurrentCoin += auction.BidAmount; } ch.CurrentCoin -= bid; if (GameManager.Instance.SystemData.SaveFlags.IsSet(AutoSaveFlags.Auction)) { save.save_char_obj(ch); } (auctionManager ?? AuctionManager.Instance).PlaceBid(ch, bid); ChatManager.talk_auction($"A bid of {bid} coin has been received on {auction.ItemForSale.ShortDescription}."); }
public static ReturnTypes spell_charm_person(int sn, int level, CharacterInstance ch, object vo) { var victim = (CharacterInstance)vo; var skill = RepositoryManager.Instance.GetEntity <SkillData>(sn); if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "You like yourself even better!")) { return(ReturnTypes.SpellFailed); } if (CheckFunctions.CheckIfTrueCasting(victim.IsImmune(ResistanceTypes.Magic) || victim.IsImmune(ResistanceTypes.Charm), skill, ch, CastingFunctionType.Immune, victim)) { return(ReturnTypes.SpellFailed); } if (!victim.IsNpc() && !ch.IsNpc()) { ch.SendTo("I don't think so..."); victim.SendTo("You feel charmed..."); return(ReturnTypes.SpellFailed); } var schance = victim.ModifySavingThrowWithResistance(level, ResistanceTypes.Charm); if (victim.IsAffected(AffectedByTypes.Charm) || schance == 1000 || ch.IsAffected(AffectedByTypes.Charm) || level < victim.Level || victim.IsCircleFollowing(ch) || !ch.CanCharm() || victim.SavingThrows.CheckSaveVsSpellStaff(schance, victim)) { ch.FailedCast(skill, victim); return(ReturnTypes.SpellFailed); } if (victim.Master != null) { victim.StopFollower(); } victim.AddFollower(ch); var af = new AffectData { SkillNumber = sn, Duration = GetDuration(level) }; victim.AddAffect(af); ch.SuccessfulCast(skill, victim); if (!ch.IsNpc()) { ((PlayerInstance)ch).PlayerData.NumberOfCharmies++; } if (!victim.IsNpc()) { return(ReturnTypes.None); } var mob = (MobileInstance)victim; mob.StartHating(ch); mob.StartHunting(ch); return(ReturnTypes.None); }
public static void do_aid(CharacterInstance ch, string argument) { if (CheckFunctions.CheckIfTrue(ch, ch.IsNpc() && ch.IsAffected(AffectedByTypes.Charm), Resources.CANNOT_CONCENTRATE)) { return; } var arg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(ch, arg, Resources.AID_WHO)) { return; } var victim = ch.GetCharacterInRoom(arg); if (CheckFunctions.CheckIfNullObject(ch, victim, "They aren't here.")) { return; } if (CheckFunctions.CheckIfNpc(ch, victim, "Not on mobs.")) { return; } if (CheckFunctions.CheckIfNotNullObject(ch, ch.CurrentMount, "You can't do that while mounted.")) { return; } if (CheckFunctions.CheckIfEquivalent(ch, ch, victim, "Aid yourself?")) { return; } if ((int)victim.CurrentPosition >= (int)PositionTypes.Stunned) { comm.act(ATTypes.AT_PLAIN, "$N doesn't need your help.", ch, null, victim, ToTypes.Character); return; } if (victim.CurrentHealth <= -6) { comm.act(ATTypes.AT_PLAIN, "$N's condition is beyond your aiding ability.", ch, null, victim, ToTypes.Character); return; } var percent = SmaugRandom.D100() - ch.GetCurrentLuck() - 13; var skill = RepositoryManager.Instance.GetEntity <SkillData>("aid"); if (skill == null) { throw new ObjectNotFoundException("Skill 'aid' was not found."); } Macros.WAIT_STATE(ch, skill.Rounds); if (!ch.CanUseSkill(percent, skill)) { ch.SendTo("You fail."); skill.LearnFromFailure((PlayerInstance)ch); return; } comm.act(ATTypes.AT_SKILL, "You aid $N!", ch, null, victim, ToTypes.Character); comm.act(ATTypes.AT_SKILL, "$n aids $N!", ch, null, victim, ToTypes.Room); skill.LearnFromSuccess((PlayerInstance)ch); ((PlayerInstance)ch).AdjustFavor(DeityFieldTypes.Aid, 1); if (victim.CurrentHealth < 1) { victim.CurrentHealth = 1; } victim.UpdatePositionByCurrentHealth(); comm.act(ATTypes.AT_SKILL, "$n aids you!", ch, null, victim, ToTypes.Victim); }
public static void do_drag(CharacterInstance ch, string argument) { if (CheckFunctions.CheckIfNpc(ch, ch, "Only characters can drag.")) { return; } if (CheckFunctions.CheckIfTrue(ch, ch.HasTimer(TimerTypes.PKilled), "You can't drag a player right now.")) { return; } var pch = (PlayerInstance)ch; var firstArg = argument.FirstWord(); if (CheckFunctions.CheckIfEmptyString(pch, firstArg, "Drag whom?")) { return; } var victim = pch.GetCharacterInRoom(firstArg); if (CheckFunctions.CheckIfNullObject(pch, victim, "They aren't here.")) { return; } if (CheckFunctions.CheckIfEquivalent(pch, pch, victim, "You take yourself by the scruff of your neck, but go nowhere.")) { return; } if (CheckFunctions.CheckIfNpc(ch, victim, "You can only drag characters.")) { return; } if (CheckFunctions.CheckIfTrue(ch, !victim.Act.IsSet((int)PlayerFlags.ShoveDrag) || (!victim.IsNpc() && !victim.IsDeadly()), "That character doesn't seem to appreciate your attentions.")) { return; } if (CheckFunctions.CheckIfTrue(ch, victim.HasTimer(TimerTypes.PKilled), "You can't drag that player right now.")) { return; } if (CheckFunctions.CheckIf(ch, HelperFunctions.IsFighting, "You try, but can't get close enough.", new List <object> { ch })) { return; } if (CheckFunctions.CheckIfTrue(ch, !ch.IsNpc() && !victim.IsDeadly() && ch.IsDeadly(), "You can't drag a deadly character.")) { return; } if (CheckFunctions.CheckIfTrue(ch, !ch.IsNpc() && !ch.IsDeadly() && (int)ch.CurrentPosition > 3, "They don't seem to need your assistance.")) { return; } var secondArg = argument.SecondWord(); if (CheckFunctions.CheckIfEmptyString(ch, secondArg, "Drag them in which direction?")) { return; } if (CheckFunctions.CheckIfTrue(ch, Math.Abs(ch.Level - victim.Level) > 5, "There is too great an experience difference for you to even bother.")) { return; } if (CheckFunctions.CheckIfTrue(ch, victim.CurrentRoom.Flags.IsSet(RoomFlags.Safe) && victim.GetTimer(TimerTypes.ShoveDrag) == null, "That character cannot be dragged right now.")) { return; } var exitDir = EnumerationExtensions.GetEnumByName <DirectionTypes>(secondArg); var exit = ch.CurrentRoom.GetExit(exitDir); if (CheckFunctions.CheckIfNullObject(ch, exit, "There's no exit in that direction.")) { return; } if (CheckFunctions.CheckIfTrue(ch, !IsPassable(exit, victim), "There's no exit in that direction.")) { return; } var toRoom = exit.GetDestination(); if (CheckFunctions.CheckIfSet(ch, toRoom.Flags, RoomFlags.Death, "You cannot drag someone into a death trap.")) { return; } if (CheckFunctions.CheckIfTrue(ch, ch.CurrentRoom.Area != toRoom.Area && !toRoom.Area.IsInHardRange(victim), "That character cannot enter that area.")) { victim.CurrentPosition = PositionTypes.Standing; return; } var chance = CalculateChanceToDrag(ch, victim); if (CheckFunctions.CheckIfTrue(ch, chance < SmaugRandom.D100(), "You failed.")) { victim.CurrentPosition = PositionTypes.Standing; return; } if ((int)victim.CurrentPosition < (int)PositionTypes.Standing) { DragIntoNextRoom(ch, victim, exit); return; } ch.SendTo("You cannot do that to someone who is standing."); }