ModernUO/Projects/UOContent/Mobiles/Monsters/Reptile/Magic/SkeletalDragon.cs
Kamron Batman e1e30998ba
fix: Adds ReadType/Write(Type) and improves type referencing (#1172)
## Changes
* Improves type hashing by introducing xxHash3 (64bit)
* Removes individual `tdb` files in favor of a single `SerializedTypes.db` file. This file is only used to identify a type that is being deserialized, which doesn't exist.
* Adds duplicate type alias detection
* Adds `AssemblyHandler.FindTypeByHash`

View changed files whitespaces: https://github.com/modernuo/ModernUO/pull/1172/files?diff=split&w=1

## SerializedTypes.db
The serialized types file is used to get back the original name of a type in case it no longer exists in code. This can easily be necessary if a class is renamed in code and no `TypeAlias` is provided.

### Format
byte[4] - version
byte[4] - count
--array--
byte[8] - xxHash
byte[1] - flag, 0 - null, 1 - not null
byte[n] - Full class name in UTF8

### Example
<img width="472" alt="SerializedTypes_Example" src="https://user-images.githubusercontent.com/3953314/195255429-31d24293-6bd1-419e-811b-07874dd0f78d.png">

## Benchmarks
Serialized 500 Type fields. The 8192bytes comes from the _ConcurrentQueue_ that would later be used for SerializedTypes.
Note that the queue is never cleared, so it's size grew considerably.
```cs
|               Method |     Mean |    Error |   StdDev | Allocated |
|--------------------- |---------:|---------:|---------:|----------:|
|      BenchmarkXXHash | 18.44 us | 0.278 us | 0.260 us |    8192 B |
| BenchmarkTypeStrings | 25.09 us | 0.292 us | 0.259 us |         - |
```

TODO:
* Add support in the Serialization Generator for `ReadType()` and `Write(Type)`
* Remove `SetTypeRef` from Serialization Generator
2022-10-11 22:17:22 -07:00

82 lines
2.6 KiB
C#

namespace Server.Mobiles
{
public class SkeletalDragon : BaseCreature
{
[Constructible]
public SkeletalDragon() : base(AIType.AI_Mage)
{
Body = 104;
BaseSoundID = 0x488;
SetStr(898, 1030);
SetDex(68, 200);
SetInt(488, 620);
SetHits(558, 599);
SetDamage(29, 35);
SetDamageType(ResistanceType.Physical, 75);
SetDamageType(ResistanceType.Fire, 25);
SetResistance(ResistanceType.Physical, 75, 80);
SetResistance(ResistanceType.Fire, 40, 60);
SetResistance(ResistanceType.Cold, 40, 60);
SetResistance(ResistanceType.Poison, 70, 80);
SetResistance(ResistanceType.Energy, 40, 60);
SetSkill(SkillName.EvalInt, 80.1, 100.0);
SetSkill(SkillName.Magery, 80.1, 100.0);
SetSkill(SkillName.MagicResist, 100.3, 130.0);
SetSkill(SkillName.Tactics, 97.6, 100.0);
SetSkill(SkillName.Wrestling, 97.6, 100.0);
SetSkill(SkillName.Necromancy, 120.1, 130.0);
SetSkill(SkillName.SpiritSpeak, 120.1, 130.0);
Fame = 22500;
Karma = -22500;
VirtualArmor = 80;
}
public SkeletalDragon(Serial serial) : base(serial)
{
}
public override string CorpseName => "a skeletal dragon corpse";
public override string DefaultName => "a skeletal dragon";
public override bool ReacquireOnMovement => true;
public override double BonusPetDamageScalar => Core.SE ? 3.0 : 1.0;
// TODO: Undead summoning?
public override bool AutoDispel => true;
public override Poison PoisonImmune => Poison.Lethal;
public override bool BleedImmune => true;
public override int Meat => 19; // where's it hiding these? :)
public override int Hides => 20;
public override HideType HideType => HideType.Barbed;
private static MonsterAbility[] _abilities = { MonsterAbility.ColdBreath };
public override MonsterAbility[] GetMonsterAbilities() => _abilities;
public override void GenerateLoot()
{
AddLoot(LootPack.FilthyRich, 4);
AddLoot(LootPack.Gems, 5);
}
public override void Serialize(IGenericWriter writer)
{
base.Serialize(writer);
writer.Write(0);
}
public override void Deserialize(IGenericReader reader)
{
base.Deserialize(reader);
var version = reader.ReadInt();
}
}
}