ModernUO/Projects/Scripts/Mobiles/Monsters/ML/Special/Ilhenir.cs
Kamron Batman 179cb50557 Updates Packets & Randomizer (#43)
* Fixes a bug with the main loop. Removes unnecessary optimizations for RDRand.

* WIP - Rewriting packets.

* Cleanup and updates README

* Converts more packets

* Fixes header

* Converts Effects packets.

* Forgot the send command

* Adds the start of containers packets.

* Adds message packets with caching

* Extends the send methods

* Starts to add Acquire methods

* Converted the packets

* Cleanup

* Cleanup

* Adds more packets

* Adds more packets

* Fixes clearing arrays from pool. Adds Mobile Incoming

* Converts more packets.

* Moves more packets

* Moves more packets

* Test compression

* Merges

* Migrating to an idiomatic syntax that also supports compression, and proxying.

* Optimize the stack alloc. Changes attributes

* Converted container packets

* Visual Studio doesn't auto save files. I am still getting used to subpar IDEs.

* Adds static packet caching. Will profile later. Converts more packets

* Fixes packets and changes how compression is configured

* WIP - Adds basics for Gumps. Not finished though.

* Fix file

* Fixes formatting

* Changed SpanWriter to be more idiomatic.

* Fixes Span vs RawSpan and missing stackallocs

* Converts over some more gumps

* WIP - Deletes 32bit support.

* Drops RDRand32 support.

* Fixes gump compilation

* Converting gump components

* Removes old huffman compression function

* Revert signature for backwards compatibility

* WIP - Converting more gump components

* Creates ArraySet for the strings. Updates AppendTo to reference that.

* Converts the maining gump components

* Cleans up gump components

* Cleans up directives

* Cleans up ArraySet and moves it. Adds null-coalescing-assignment

* Cleanup, Target Packets, and C# 8 changes.

* Removed OPL Packet

* World packets

* Fixing packet uses

* Cleans up code. Fixes packet uses in various places.

* More cleanup for packets

* Code cleanup

* Converts more packet uses and cleans up more code

* More code cleanup

* Finishes fixing the packets in Item

* Updates secure trade packets

* Updates core and gets it to compile.

* Moved packets to scripts. Fixed account handler use of packets

* Code cleanup

* Updates chat packets

* Code cleanuo

* Adds party packets, but need to implement them.

* Party packets WIP

* Finishes party packets

* Rearrange movement namespaces and classes

* Finishes plant packets

* Code Formatting

* Fixes moving effects

* Code cleanup, eliminates equipinfo

* Adds more packets. Fixes bugs with various packets.

* Finishes mahjon packets

* Fixes mahjong packet

* Code cleanup

* Finishes mahjong packets

* Adds Map packets

* Add multifacet maps and charts

* Cleans up some packets with UTF8

* Optimizes packets

* Cleans up more packets. Moves the MessageHelper

* Removes assistant support. Removes extended protocol. Incorporates MapUO packets as normal packets.

* Updates protocol extensions packet receiver

* Fixes a few bugs. Fixes a few more packets.

* Code cleanup and fixing more packets

* Fixes packet effects

* Cleaned up more code

* Buff Icon cleanup

* Removed unused constructors

* Code Cleanup. Adds BoatHS Packets

* Moves house files. Updates house foundation packets.

* Deployment cleanup

* Fixes:

* Code cleanup

* More code cleanup

* More code cleanup

* Cleaned up BaseHouse

* Enforces styling

* Converts foreach to linq where possible.

* Dont need that

* Goals/Readme updates

* Removes 32bit support at the highest level. Turns on HRT by default.

* Code cleanup. Fixes extended features packet.

* Fixes various bugs

* Code cleanup

* Code cleanup

* Code cleanup. Fixes gump X/Y assignment.

* Code cleanup using |= operator

* More code cleanup

* Cleanup

* Fixes spacing issues. Thanks Visual Studio. You suck.

* Compiler error

* Fixes NPE from RunUO 2.7

* Renames ScriptCompiler to AssemblyHandler. Fixes packets. Updates README

* Fixes more packets. Stupid trailing nulls.

* Fixes various bugs.

* Fixes for gumps

* Fixes more gump stuff. Going to split it out later since it is getting insane

* Recoded the gump writing

* WIP

* *Added output path of scripts project to dev branch
*Activated debugging in code
2019-11-11 12:40:16 +01:00

394 lines
9.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Server.Engines.CannedEvil;
using Server.Items;
using Server.Network;
namespace Server.Mobiles
{
public class Ilhenir : BaseChampion
{
private static HashSet<Mobile> m_Table = new HashSet<Mobile>();
[Constructible]
public Ilhenir()
: base(AIType.AI_Mage)
{
Title = "the Stained";
Body = 0x103;
BaseSoundID = 589;
SetStr(1105, 1350);
SetDex(82, 160);
SetInt(505, 750);
SetHits(9000);
SetDamage(21, 28);
SetDamageType(ResistanceType.Physical, 60);
SetDamageType(ResistanceType.Fire, 20);
SetDamageType(ResistanceType.Poison, 20);
SetResistance(ResistanceType.Physical, 55, 65);
SetResistance(ResistanceType.Fire, 50, 60);
SetResistance(ResistanceType.Cold, 55, 65);
SetResistance(ResistanceType.Poison, 70, 90);
SetResistance(ResistanceType.Energy, 65, 75);
SetSkill(SkillName.EvalInt, 100);
SetSkill(SkillName.Magery, 100);
SetSkill(SkillName.Meditation, 0);
SetSkill(SkillName.Poisoning, 5.4);
SetSkill(SkillName.Anatomy, 117.5);
SetSkill(SkillName.MagicResist, 120.0);
SetSkill(SkillName.Tactics, 119.9);
SetSkill(SkillName.Wrestling, 119.9);
Fame = 50000;
Karma = -50000;
VirtualArmor = 44;
if (Core.ML)
{
PackResources(8);
PackTalismans(5);
}
}
public Ilhenir(Serial serial)
: base(serial)
{
}
public override string CorpseName => "a corpse of Ilhenir";
public override ChampionSkullType SkullType => ChampionSkullType.Pain;
public override Type[] UniqueList => new Type[] { };
public override Type[] SharedList => new[]
{
typeof(ANecromancerShroud),
typeof(LieutenantOfTheBritannianRoyalGuard),
typeof(OblivionsNeedle),
typeof(TheRobeOfBritanniaAri)
};
public override Type[] DecorativeList => new[] { typeof(MonsterStatuette) };
public override MonsterStatuetteType[] StatueTypes => new[]
{
MonsterStatuetteType.PlagueBeast,
MonsterStatuetteType.RedDeath
};
public override string DefaultName => "Ilhenir";
public override bool Unprovokable => true;
public override bool Uncalmable => true;
public override Poison PoisonImmune => Poison.Lethal;
//public override bool GivesMLMinorArtifact => true; // TODO: Needs verification
public override int TreasureMapLevel => 5;
public virtual void PackResources(int amount)
{
for (int i = 0; i < amount; i++)
switch (Utility.Random(6))
{
case 0:
PackItem(new Blight());
break;
case 1:
PackItem(new Scourge());
break;
case 2:
PackItem(new Taint());
break;
case 3:
PackItem(new Putrefication());
break;
case 4:
PackItem(new Corruption());
break;
case 5:
PackItem(new Muculent());
break;
}
}
public virtual void PackItems(Item item, int amount)
{
for (int i = 0; i < amount; i++)
PackItem(item);
}
public virtual void PackTalismans(int amount)
{
int count = Utility.Random(amount);
for (int i = 0; i < count; i++)
PackItem(new RandomTalisman());
}
public override void GenerateLoot()
{
AddLoot(LootPack.FilthyRich, 8);
}
public override void OnDeath(Container c)
{
base.OnDeath(c);
if (Core.ML)
{
c.DropItem(new GrizzledBones());
// TODO: Parrots
/*if ( Utility.RandomDouble() < 0.6 )
c.DropItem( new ParrotItem() ); */
if (Utility.RandomDouble() < 0.05)
c.DropItem(new GrizzledMareStatuette());
if (Utility.RandomDouble() < 0.025)
c.DropItem(new CrimsonCincture());
// TODO: Armor sets
/*if ( Utility.RandomDouble() < 0.05 )
{
switch ( Utility.Random(5) )
{
case 0: c.DropItem( new GrizzleGauntlets() ); break;
case 1: c.DropItem( new GrizzleGreaves() ); break;
case 2: c.DropItem( new GrizzleHelm() ); break;
case 3: c.DropItem( new GrizzleTunic() ); break;
case 4: c.DropItem( new GrizzleVambraces() ); break;
}
}*/
}
}
public override void OnGaveMeleeAttack(Mobile defender)
{
base.OnGaveMeleeAttack(defender);
if (Utility.RandomDouble() < 0.25)
CacophonicAttack(defender);
}
public override void OnDamage(int amount, Mobile from, bool willKill)
{
if (Utility.RandomDouble() < 0.1)
DropOoze();
base.OnDamage(amount, from, willKill);
}
public override int GetAngerSound() => 0x581;
public override int GetIdleSound() => 0x582;
public override int GetAttackSound() => 0x580;
public override int GetHurtSound() => 0x583;
public override int GetDeathSound() => 0x584;
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();
}
public virtual void CacophonicAttack(Mobile to)
{
if (to.Alive && to.Player && !UnderCacophonicAttack(to))
{
Packets.SendSpeedControlWalk(to.NetState);
to.SendLocalizedMessage(1072069); // A cacophonic sound lambastes you, suppressing your ability to move.
to.PlaySound(0x584);
m_Table.Add(to);
Timer.DelayCall(TimeSpan.FromSeconds(30), CacophonicEnd, to);
}
}
public virtual void CacophonicEnd(Mobile from)
{
m_Table.Remove(from);
Packets.SendSpeedControlDisabled(from.NetState);
}
public static bool UnderCacophonicAttack(Mobile from) => m_Table.Contains(from);
public virtual void DropOoze()
{
int amount = Utility.RandomMinMax(1, 3);
bool corrosive = Utility.RandomBool();
for (int i = 0; i < amount; i++)
{
Item ooze = new StainedOoze(corrosive);
Point3D p = new Point3D(Location);
for (int j = 0; j < 5; j++)
{
p = GetSpawnPosition(2);
if (!Map.GetItemsInRange(p, 0).OfType<StainedOoze>().Any())
break;
}
ooze.MoveToWorld(p, Map);
}
if (Combatant != null)
{
if (corrosive)
Combatant.SendLocalizedMessage(1072071); // A corrosive gas seeps out of your enemy's skin!
else
Combatant.SendLocalizedMessage(1072072); // A poisonous gas seeps out of your enemy's skin!
}
}
private int RandomPoint(int mid) => mid + Utility.RandomMinMax(-2, 2);
public virtual Point3D GetSpawnPosition(int range) => GetSpawnPosition(Location, Map, range);
public virtual Point3D GetSpawnPosition(Point3D from, Map map, int range)
{
if (map == null)
return from;
Point3D loc = new Point3D(RandomPoint(X), RandomPoint(Y), Z);
loc.Z = Map.GetAverageZ(loc.X, loc.Y);
return loc;
}
}
public class StainedOoze : Item
{
private int m_Ticks;
private Timer m_Timer;
[Constructible]
public StainedOoze(bool corrosive = false) : base(0x122A)
{
Movable = false;
Hue = 0x95;
Corrosive = corrosive;
m_Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1), OnTick);
m_Ticks = 0;
}
public StainedOoze(Serial serial)
: base(serial)
{
}
[CommandProperty(AccessLevel.GameMaster)]
public bool Corrosive{ get; set; }
public override void OnAfterDelete()
{
if (m_Timer != null)
{
m_Timer.Stop();
m_Timer = null;
}
}
private void OnTick()
{
List<Mobile> toDamage = new List<Mobile>();
foreach (Mobile m in GetMobilesInRange(0))
{
if (m is BaseCreature bc)
{
if (!bc.Controlled && !bc.Summoned)
continue;
}
else if (!m.Player)
{
continue;
}
if (m.Alive && !m.IsDeadBondedPet && m.CanBeDamaged())
toDamage.Add(m);
}
for (int i = 0; i < toDamage.Count; ++i)
Damage(toDamage[i]);
++m_Ticks;
if (m_Ticks >= 35)
Delete();
else if (m_Ticks == 30)
ItemID = 0x122B;
}
public void Damage(Mobile m)
{
if (Corrosive)
{
List<Item> items = m.Items;
bool damaged = false;
for (int i = 0; i < items.Count; ++i)
if (items[i] is IDurability wearable && wearable.HitPoints >= 10 && Utility.RandomDouble() < 0.25)
{
wearable.HitPoints -= wearable.HitPoints == 10 ? Utility.Random(1, 5) : 10;
damaged = true;
}
if (damaged)
{
m.LocalOverheadMessage(MessageType.Regular, 0x21,
1072070); // The infernal ooze scorches you, setting you and your equipment ablaze!
return;
}
}
AOS.Damage(m, 40, 0, 0, 0, 100, 0);
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write(0); // version
writer.Write(Corrosive);
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
Corrosive = reader.ReadBool();
m_Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1), OnTick);
m_Ticks = ItemID == 0x122A ? 0 : 30;
}
}
}