servuo/Scripts/Mobiles/Normal/Ronin.cs
pyro17 bebc100d6c
Ranger Equipment fix, Additem delete (#5012)
* Ranger Equipment fix, Additem delete
- add parameter with default value to AddItem
- On Conflict, still log conflict, but delete the conflicting Item by default

- Delete the base boots of Rangers befor adding the new boots

* Updated Mobile Scripts

- went through all scripts to update them to SetWearable
- reverted change to AddItem

* Update to SetWearable

- last item being set will be worn (if no override to OnEquip returns false
- delete the item on the layer that is the same as the new item (if existend)
- used ifs to cap item.Movable, therefor no need to call to Random if <= 0 or >= 1

* Update base InitOutFit

- replaced the Additem for Backpack with SetWearable, Movable is getting set this way too
- altered the other SetWearable calls, to allow the items to be moved / dropped (as they should normally)

* Null reference sanity check.

Co-authored-by: Voxpire <admin@vita-nex.com>
2022-06-16 04:44:54 +01:00

168 lines
5 KiB
C#

using Server.Items;
using System;
namespace Server.Mobiles
{
[CorpseName("a ronin corpse")]
public class Ronin : BaseCreature
{
public override bool ClickTitle => false;
private DateTime m_NextWeaponChange;
[Constructable]
public Ronin() : base(AIType.AI_Samurai, FightMode.Closest, 10, 1, 0.3, 0.6)
{
SpeechHue = Utility.RandomDyedHue();
Hue = Utility.RandomSkinHue();
Name = "a ronin";
Body = ((Female = Utility.RandomBool()) ? Body = 0x191 : Body = 0x190);
Hue = Utility.RandomSkinHue();
SetStr(326, 375);
SetDex(31, 45);
SetInt(101, 110);
SetHits(301, 400);
SetMana(101, 110);
SetDamage(17, 25);
SetDamageType(ResistanceType.Physical, 90);
SetDamageType(ResistanceType.Poison, 10);
SetResistance(ResistanceType.Physical, 55, 75);
SetResistance(ResistanceType.Fire, 40, 60);
SetResistance(ResistanceType.Cold, 35, 55);
SetResistance(ResistanceType.Poison, 50, 70);
SetResistance(ResistanceType.Energy, 55, 75);
SetSkill(SkillName.MagicResist, 42.6, 57.5);
SetSkill(SkillName.Tactics, 115.1, 130.0);
SetSkill(SkillName.Wrestling, 92.6, 107.5);
SetSkill(SkillName.Anatomy, 110.1, 125.0);
SetSkill(SkillName.Fencing, 92.6, 107.5);
SetSkill(SkillName.Macing, 92.6, 107.5);
SetSkill(SkillName.Swords, 92.6, 107.5);
SetSkill(SkillName.Bushido, 95.0, 120.0);
Fame = 8500;
Karma = -8500;
SetWearable(new SamuraiTabi(), dropChance: 1);
SetWearable(new LeatherHiroSode(), dropChance: 1);
SetWearable(new LeatherDo(), dropChance: 1);
switch (Utility.Random(4))
{
case 0: SetWearable(new LightPlateJingasa(), dropChance: 1); break;
case 1: SetWearable(new ChainHatsuburi(), dropChance: 1); break;
case 2: SetWearable(new DecorativePlateKabuto(), dropChance: 1); break;
case 3: SetWearable(new LeatherJingasa(), dropChance: 1); break;
}
switch (Utility.Random(3))
{
case 0: SetWearable(new StuddedHaidate(), dropChance: 1); break;
case 1: SetWearable(new LeatherSuneate(), dropChance: 1); break;
case 2: SetWearable(new PlateSuneate(), dropChance: 1); break;
}
if (Utility.RandomDouble() > .2)
SetWearable(new NoDachi(), dropChance: 1);
else
SetWearable(new Halberd(), dropChance: 1);
PackItem(new Wakizashi());
PackItem(new Longsword());
Utility.AssignRandomHair(this);
SetWeaponAbility(WeaponAbility.RidingSwipe);
}
public override void GenerateLoot()
{
AddLoot(LootPack.FilthyRich);
AddLoot(LootPack.Rich);
AddLoot(LootPack.Gems, 2);
AddLoot(LootPack.LootItem<BookOfBushido>());
}
public override bool AlwaysMurderer => true;
public override bool BardImmune => true;
public override bool CanRummageCorpses => true;
public override double WeaponAbilityChance
{
get
{
if (Combatant is Mobile && ((Mobile)Combatant).Mounted)
return 0.8;
return base.WeaponAbilityChance;
}
}
private void ChangeWeapon()
{
if (Backpack == null)
return;
Item item = FindItemOnLayer(Layer.OneHanded);
if (item == null)
item = FindItemOnLayer(Layer.TwoHanded);
System.Collections.Generic.List<BaseWeapon> weapons = new System.Collections.Generic.List<BaseWeapon>();
foreach (Item i in Backpack.Items)
{
if (i is BaseWeapon && i != item)
weapons.Add((BaseWeapon)i);
}
if (weapons.Count > 0)
{
if (item != null)
Backpack.DropItem(item);
AddItem(weapons[Utility.Random(weapons.Count)]);
m_NextWeaponChange = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(30, 60));
}
}
public override void OnThink()
{
base.OnThink();
if (Combatant != null && m_NextWeaponChange < DateTime.UtcNow)
ChangeWeapon();
}
public Ronin(Serial serial) : base(serial)
{
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
m_NextWeaponChange = DateTime.UtcNow;
}
}
}