public int Disarm(Player player, Player target, Room room, string obj) { if (string.IsNullOrEmpty(player.Target)) { _writer.WriteLine("You are not fighting anyone.", player.ConnectionId); return(0); } if (player.Equipped.Wielded == null) { _writer.WriteLine("You must wield a weapon to disarm.", player.ConnectionId); return(0); } if (target.Equipped.Wielded == null) { _writer.WriteLine("Your opponent is not wielding a weapon.", player.ConnectionId); return(0); } var playerWeaponSkill = Helpers.GetWeaponSkill(player.Equipped.Wielded, player); var targetWeaponSkill = Helpers.GetWeaponSkill(target.Equipped.Wielded, target); var playerSkillOfTargetsWeapon = Helpers.GetWeaponSkill(target.Equipped.Wielded, player); var chance = playerWeaponSkill; chance += (playerSkillOfTargetsWeapon - targetWeaponSkill) / 2; /* dex vs. strength */ chance += player.Attributes.Attribute[EffectLocation.Dexterity]; chance -= target.Attributes.Attribute[EffectLocation.Strength]; chance += (player.Level - target.Level) * 2; if (player.Affects.Haste) { chance += 10; } if (target.Affects.Haste) { chance -= 25; } var hasGrip = target.Skills.FirstOrDefault(x => x.SkillName.Equals("grip", StringComparison.CurrentCultureIgnoreCase)); var gripChance = _dice.Roll(1, 1, 100); if (hasGrip != null) { if (gripChance <= hasGrip.Proficiency) { chance -= 20; } else { _gain.GainSkillExperience(target, hasGrip.Level * 100, hasGrip, _dice.Roll(1, 1, 5)); } } if (_dice.Roll(1, 1, 100) < chance) { if ((target.Equipped.Wielded.ItemFlag & Item.Item.ItemFlags.Noremove) != 0) { var skillMessageNoRemove = new SkillMessage() { Hit = { ToPlayer = $"{target.Name}'s weapon won't budge!", ToRoom = $"{player.Name} tries to disarm {target.Name}, but fails.", ToTarget = $"{player.Name} tries to disarm you, but your weapon won't budge!" } }; _skillManager.EmoteAction(player, target, room, skillMessageNoRemove); return(0); } var skillMessage = new SkillMessage() { Hit = { ToPlayer = $"You disarm {target.Name}!", ToRoom = $"{player.Name} disarms {target.Name}!", ToTarget = $"{player.Name} DISARMS you and sends your weapon flying!" } }; _skillManager.EmoteAction(player, target, room, skillMessage); room.Items.Add(target.Equipped.Wielded); target.Equipped.Wielded = null; } else { var skillMessage = new SkillMessage() { Hit = { ToPlayer = $"You fail to disarm {target.Name}.", ToRoom = $"{player.Name} tries to disarm {target.Name}, but fails.", ToTarget = $"{player.Name} tries to disarm you, but fails." } }; _skillManager.EmoteAction(player, target, room, skillMessage); } player.Lag += 1; return(0); }
public int Impale(Player player, Player target, Room room, string obj) { if (player.Equipped.Wielded == null) { _writer.WriteLine("Impale with what?", player.ConnectionId); } var weaponDam = player.Equipped.Wielded?.Damage.Maximum ?? 1 * 2; var str = player.Attributes.Attribute[EffectLocation.Strength]; var damage = weaponDam + _dice.Roll(1, 2, 10) + str / 5; /*dexterity check */ var chance = 50; chance += player.Attributes.Attribute[EffectLocation.Dexterity]; chance -= target.Attributes.Attribute[EffectLocation.Dexterity]; if (player.Affects.Haste) { chance += 10; } if (target.Affects.Haste) { chance -= 25; } /* level check */ chance += player.Level - target.Level; if (_dice.Roll(1, 1, 100) < chance) { _skillManager.DamagePlayer("impale", damage, player, target, room); player.Lag += 1; _skillManager.updateCombat(player, target, room); } else { var skillMessageMiss = new SkillMessage() { Hit = { ToPlayer = $"You try to impale {target.Name} and miss.", ToRoom = $"{player.Name} tries to impale {target.Name} but {target.Name} easily avoids it.", ToTarget = $"{player.Name} tries to impale you but misses." } }; _skillManager.EmoteAction(player, target, room, skillMessageMiss); } return(damage); }
public void Armor(Player player, Player target, Room room, bool wearOff) { var skillMessage = new SkillMessage() { NoEffect = new Messages() { ToPlayer = "A protective white light engulfs #target#." }, Hit = new Messages() { ToPlayer = "#target# is engulfed by a protective white light.", ToTarget = "You feel protected.", ToRoom = "A protective white light engulfs #target#." }, Death = new Messages(), Miss = new Messages(), EffectWearOff = new Messages() { ToPlayer = "Your protective white light fades away.", ToRoom = "#target#'s protective white light fades away." } }; var affect = target.Affects.Custom.FirstOrDefault(x => x.Name.Equals("Armour", StringComparison.CurrentCultureIgnoreCase)); if (wearOff) { player.ArmorRating.Armour -= 20; target.Affects.Custom.Remove(affect); _skillManager.EmoteEffectWearOffAction(player, room, skillMessage); _updateClientUi.UpdateAffects(player); _updateClientUi.UpdateScore(player); return; } var skill = new AllSpells().Armour(); target = _skillManager.GetValidTarget(player, target, skill.ValidTargets); //create emote effectWear off message _skillManager.EmoteAction(player, target, room, skillMessage); if (affect == null) { var newAffect = new Affect() { Modifier = new Modifier() { Armour = 20 }, Benefits = "Affects armour by 20", Affects = DefineSpell.SpellAffect.ArmorClass, Duration = player.Level + player.Attributes.Attribute[EffectLocation.Intelligence] / 2, Name = "Armour", }; target.Affects.Custom.Add(newAffect); Helpers.ApplyAffects(newAffect, target); } else { affect.Duration = player.Level + player.Attributes.Attribute[EffectLocation.Intelligence] / 2; } _updateClientUi.UpdateAffects(target); _updateClientUi.UpdateScore(target); _updateClientUi.UpdateScore(player); }