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); }
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 static ReturnTypes ranged_attack(CharacterInstance ch, string argument, ObjectInstance weapon, ObjectInstance projectile, int sn, int range) { var firstArg = argument.FirstWord(); var secondArg = argument.SecondWord(); if (firstArg.IsNullOrEmpty()) { ch.SendTo("Where? At whom?"); return(ReturnTypes.None); } CharacterInstance victim = null; var exit = ch.CurrentRoom.GetExit(firstArg); if (exit == null) { victim = ch.GetCharacterInRoom(firstArg); if (victim == null) { ch.SendTo("Aim in what direction?"); return(ReturnTypes.None); } if (ch.CurrentFighting.Who == victim) { ch.SendTo("They are too close to release that type of attack!"); return(ReturnTypes.None); } } if (victim != null) { if (ch.CurrentRoom.IsPrivate() || ch.CurrentRoom.Flags.IsSet(RoomFlags.Solitary)) { ch.SendTo("You cannot perform a ranged attack from a private room."); return(ReturnTypes.None); } if (ch.CurrentRoom.Tunnel > 0) { if (ch.CurrentRoom.Contents.OfType <CharacterInstance>().Count() >= ch.CurrentRoom.Tunnel) { ch.SendTo("This room is too cramped to perform such an attack."); return(ReturnTypes.None); } } } SkillData skill = null; if (Macros.IS_VALID_SN(sn)) { skill = RepositoryManager.Instance.GetEntity <SkillData>(sn); } if (exit != null && exit.GetDestination() == null) { ch.SendTo("Are you expecting to fire through a wall?!"); return(ReturnTypes.None); } if (exit != null && exit.Flags.IsSet(ExitFlags.Closed)) { if (exit.Flags.IsSet(ExitFlags.Secret) || exit.Flags.IsSet(ExitFlags.Dig)) { ch.SendTo("Are you expecting to fire through a wall?!"); } else { ch.SendTo("Are you expecting to fire through a door?!"); } return(ReturnTypes.None); } CharacterInstance vch = null; if (exit != null && !string.IsNullOrEmpty(secondArg)) { vch = scan_for_victim(ch, exit, secondArg); if (vch == null) { ch.SendTo("You cannot see your target."); return(ReturnTypes.None); } if (vch.CurrentRoom.Flags.IsSet(RoomFlags.NoMissile)) { ch.SendTo("You can't get a clean shot off."); return(ReturnTypes.None); } if (vch.NumberFighting > GameConstants.GetConstant <int>("MaximumCombatants")) { ch.SendTo("There is too much activity there for you to get a clear shot."); return(ReturnTypes.None); } } if (vch != null) { if (!vch.IsNpc() && !ch.IsNpc() && ch.Act.IsSet((int)PlayerFlags.Nice)) { ch.SendTo("You're too nice to do that!"); return(ReturnTypes.None); } if (fight.is_safe(ch, vch, true)) { return(ReturnTypes.None); } } var was_in_room = ch.CurrentRoom; if (projectile != null) { //todo handler.separate_obj(projectile); var action = weapon != null ? "fire" : "throw"; if (exit != null) { comm.act(ATTypes.AT_GREY, $"You {action} $p $T.", ch, projectile, exit.Direction.GetName(), ToTypes.Character); comm.act(ATTypes.AT_GREY, $"$n {action}s $p $T.", ch, projectile, exit.Direction.GetName(), ToTypes.Room); } else { comm.act(ATTypes.AT_GREY, $"You {action} $p at $N.", ch, projectile, victim, ToTypes.Character); comm.act(ATTypes.AT_GREY, $"$n {action}s $p at $N.", ch, projectile, victim, ToTypes.NotVictim); comm.act(ATTypes.AT_GREY, $"$n {action}s $p at you!", ch, projectile, victim, ToTypes.Victim); } } else if (skill != null) { var skillText = GetSkillText(skill); if (skill.Type == SkillTypes.Spell) { var color = ATTypes.AT_MAGIC; if (exit != null) { comm.act(color, "You release $t $T.", ch, skillText.AddArticle(ArticleAppendOptions.TheToFront), exit.Direction.GetName(), ToTypes.Character); comm.act(color, "$n releases $s $t $T.", ch, skillText, exit.Direction.GetName(), ToTypes.Room); } else { comm.act(color, "You release $t at $N.", ch, skillText.AddArticle(ArticleAppendOptions.TheToFront), victim, ToTypes.Character); comm.act(color, "$n releases $s $t at $N.", ch, skillText, victim, ToTypes.NotVictim); comm.act(color, "$n releases $s $t at you!", ch, skillText, victim, ToTypes.Victim); } } } else { //todo record bug, missing projectile and skill return(ReturnTypes.None); } if (victim != null) { fight.check_illegal_pk(ch, victim); ch.CheckAttackForAttackerFlag(victim); return(ranged_got_target(ch, victim, weapon, projectile, 0, sn, "burst of energy", ATTypes.AT_GREY)); } victim = vch; var dtxt = act_move.rev_exit(exit.Direction); var dist = 0; while (dist <= range) { ch.CurrentRoom.RemoveFrom(ch); exit.GetDestination().AddTo(ch); if (exit.Flags.IsSet(ExitFlags.Closed)) { var color = projectile != null ? ATTypes.AT_GREY : ATTypes.AT_MAGIC; var txt = $"You see your {(projectile != null ? projectile.Name : GetSkillText(skill))} {(projectile != null ? "pierce" : "hit")} a door in the distance to the {exit.Direction.GetName()}."; comm.act(color, txt, ch, null, null, ToTypes.Character); if (projectile != null) { } } } ch.CurrentRoom.RemoveFrom(ch); was_in_room.AddTo(ch); return(ReturnTypes.None); }