private void InitHuman() { InitBaseUnit(); Class = UnitClassLoader.GetUnitClassById(Template.TypeID); if (Class == null) { Debug.LogFormat("Invalid unit created (class not found, serverId={0}, typeId={1})", Template.ServerID, Template.TypeID); Template = null; return; } Width = Math.Max(1, Template.TokenSize); Height = Width; CoreStats.Health = CoreStats.HealthMax = Math.Max(Template.HealthMax, 0); CoreStats.Mana = CoreStats.ManaMax = Math.Max(Template.ManaMax, 0); // they sometimes put -1 as mana counter for fighters // BRMS CoreStats.Body = (short)Template.Body; CoreStats.Reaction = (short)Template.Reaction; CoreStats.Mind = (short)Template.Mind; CoreStats.Spirit = (short)Template.Spirit; // speed and scanrange CoreStats.RotationSpeed = (byte)Template.RotationSpeed; if (CoreStats.RotationSpeed < 1) { CoreStats.RotationSpeed = 1; } CoreStats.Speed = (byte)Template.Speed; if (CoreStats.Speed < 1) { CoreStats.Speed = 1; } CoreStats.ScanRange = Template.ScanRange; // human specific if (Template.Gender == 1) { Gender = GenderFlags.Female; } else { Gender = GenderFlags.Male; } // guess class (mage/fighter) from type if (Class.ID == 24 || Class.ID == 23) // unarmed mage, mage with staff { Gender |= GenderFlags.Mage; } else { Gender |= GenderFlags.Fighter; // otherwise its a fighter. } // initial items for (int i = 0; i < Template.EquipItems.Length; i++) { if (Template.EquipItems[i].Length <= 0) { continue; } Item item = new Item(Template.EquipItems[i]); if (!item.IsValid || item.Class.IsSpecial) { continue; } PutItemToBody((BodySlot)item.Class.Option.Slot, item); } // spellbook for (int i = 0; i < 32; i++) { uint sp = 1u << i; if (Template.ManaMax > 0 && (Template.KnownSpells & sp) != 0) { Spell cspell = new Spell(i, this); SpellBook.Add(cspell); } } CalculateVision(); UpdateItems(); // add item for testing if (!NetworkManager.IsClient) { ItemsPack.PutItem(ItemsPack.Count, new Item("Very Rare Crystal Ring {body=4}")); ItemsPack.PutItem(ItemsPack.Count, new Item("Very Rare Crystal Amulet {body=4}")); ItemsPack.PutItem(ItemsPack.Count, new Item("Potion Body")); ItemsPack.PutItem(ItemsPack.Count, new Item("Very Rare Meteoric Plate Cuirass {body=4}")); ItemsPack.PutItem(ItemsPack.Count, new Item("Very Rare Meteoric Plate Cuirass {body=4}")); ItemsPack.PutItem(ItemsPack.Count, new Item("Wood Shaman Staff {castSpell=Fire_Ball:100}")); /* MapProjectile proj = new MapProjectile(15); * proj.SetPosition(16, 16, 0); * proj.Target = ConsolePlayer.Avatar; * Objects.Add(proj); */ItemsPack.PutItem(ItemsPack.Count, new Item("Very Rare Meteoric Crossbow")); } }
private void InitHuman() { InitBaseUnit(); Class = UnitClassLoader.GetUnitClassById(Template.TypeID); if (Class == null) { Debug.LogFormat("Invalid unit created (class not found, serverId={0}, typeId={1})", Template.ServerID, Template.TypeID); Template = null; return; } Width = Math.Max(1, Template.TokenSize); Height = Width; CoreStats.Health = CoreStats.HealthMax = Math.Max(Template.HealthMax, 0); CoreStats.Mana = CoreStats.ManaMax = Math.Max(Template.ManaMax, 0); // they sometimes put -1 as mana counter for fighters // BRMS CoreStats.Body = (short)Template.Body; CoreStats.Reaction = (short)Template.Reaction; CoreStats.Mind = (short)Template.Mind; CoreStats.Spirit = (short)Template.Spirit; // speed and scanrange CoreStats.RotationSpeed = (byte)Template.RotationSpeed; if (CoreStats.RotationSpeed < 1) { CoreStats.RotationSpeed = 1; } CoreStats.Speed = (byte)Template.Speed; if (CoreStats.Speed < 1) { CoreStats.Speed = 1; } CoreStats.ScanRange = Template.ScanRange; // human specific if (Template.Gender == 1) { Gender = GenderFlags.Female; } else { Gender = GenderFlags.Male; } // guess class (mage/fighter) from type if (Class.ID == 24 || Class.ID == 23) // unarmed mage, mage with staff { Gender |= GenderFlags.Mage; } else { Gender |= GenderFlags.Fighter; // otherwise its a fighter. } // CoreStats.HealthRegeneration = 100; CoreStats.ManaRegeneration = 100; // initial items for (int i = 0; i < Template.EquipItems.Length; i++) { if (Template.EquipItems[i].Length <= 0) { continue; } Item item = new Item(Template.EquipItems[i]); if (!item.IsValid || item.Class.IsSpecial) { continue; } PutItemToBody((BodySlot)item.Class.Option.Slot, item); } // spellbook for (int i = 0; i < 32; i++) { uint sp = 1u << i; if (Template.ManaMax > 0 /* && (Template.KnownSpells & sp) != 0*/) // [ZZ] uncomment for production!!! currently enables all spells on unit { Spell cspell = new Spell(i, this); SpellBook.Add(cspell); } } // set skills by experience // [ZZ] I know that magic and fighting skills are exactly same in the array. // this is written this way in case it changes. will be optimized later if ((Gender & GenderFlags.Fighter) != 0) { SetSkill(ExperienceSkill.Blade, Template.SkillBladeFire); SetSkill(ExperienceSkill.Axe, Template.SkillAxeWater); SetSkill(ExperienceSkill.Bludgeon, Template.SkillBludgeonAir); SetSkill(ExperienceSkill.Pike, Template.SkillPikeEarth); SetSkill(ExperienceSkill.Shooting, Template.SkillShootingAstral); } else if ((Gender & GenderFlags.Mage) != 0) { SetSkill(ExperienceSkill.Fire, Template.SkillBladeFire); SetSkill(ExperienceSkill.Water, Template.SkillAxeWater); SetSkill(ExperienceSkill.Air, Template.SkillBludgeonAir); SetSkill(ExperienceSkill.Earth, Template.SkillPikeEarth); SetSkill(ExperienceSkill.Astral, Template.SkillShootingAstral); } CoreStats.HealthMax = -1; OnUpdateItems(); // fix health and mana Stats.TrySetHealth(Stats.HealthMax); Stats.TrySetMana(Stats.ManaMax); }
private void InitUnit() { InitBaseUnit(); Class = UnitClassLoader.GetUnitClassById(Template.TypeID); if (Class == null) { Debug.LogFormat("Invalid unit created (class not found, serverId={0}, typeId={1})", Template.ServerID, Template.TypeID); Template = null; return; } Width = Template.TokenSize; Height = Width; CoreStats.Health = CoreStats.HealthMax = Math.Max(Template.HealthMax, 0); CoreStats.Mana = CoreStats.ManaMax = Math.Max(Template.ManaMax, 0); // they sometimes put -1 as mana counter for fighters CoreStats.HealthRegeneration = (short)Template.HealthRegeneration; CoreStats.ManaRegeneration = (short)Template.ManaRegeneration; // BRMS CoreStats.Body = (short)Template.Body; CoreStats.Reaction = (short)Template.Reaction; CoreStats.Mind = (short)Template.Mind; CoreStats.Spirit = (short)Template.Spirit; // physical damage and resists int templateMin = Template.PhysicalMin; int templateMax = Template.PhysicalMax - templateMin; if (IsIgnoringArmor && ((templateMin & 0x80) != 0)) { templateMin = (templateMin & 0x7F) * 15; templateMax *= 15; } if (templateMax < 0) { templateMin = Template.PhysicalMax; templateMax = (Template.PhysicalMin - Template.PhysicalMax) * 64; } CoreStats.DamageMin = (short)templateMin; CoreStats.DamageMax = (short)(templateMax + templateMin); CoreStats.ToHit = (short)Template.ToHit; CoreStats.Absorbtion = (short)Template.Absorbtion; CoreStats.Defence = (short)Template.Defense; // magical resists CoreStats.ProtectionFire = (byte)Template.ProtectionFire; CoreStats.ProtectionWater = (byte)Template.ProtectionWater; CoreStats.ProtectionAir = (byte)Template.ProtectionAir; CoreStats.ProtectionEarth = (byte)Template.ProtectionEarth; CoreStats.ProtectionAstral = (byte)Template.ProtectionAstral; // physical resists (custom) CoreStats.ProtectionBlade = (byte)Template.ProtectionBlade; CoreStats.ProtectionAxe = (byte)Template.ProtectionAxe; CoreStats.ProtectionBludgeon = (byte)Template.ProtectionBludgeon; CoreStats.ProtectionPike = (byte)Template.ProtectionPike; CoreStats.ProtectionShooting = (byte)Template.ProtectionShooting; // speed and scanrange CoreStats.RotationSpeed = (byte)Template.RotationSpeed; if (CoreStats.RotationSpeed < 1) { CoreStats.RotationSpeed = 1; } CoreStats.Speed = (byte)Template.Speed; if (CoreStats.Speed < 1) { CoreStats.Speed = 1; } CoreStats.ScanRange = Template.ScanRange; // initial items if (Template.EquipItem1.Length > 0) { Item item1 = new Item(Template.EquipItem1); if (item1.IsValid) { PutItemToBody((BodySlot)item1.Class.Option.Slot, item1); } } if (Template.EquipItem2.Length > 0) { Item item2 = new Item(Template.EquipItem2); if (item2.IsValid) { PutItemToBody((BodySlot)item2.Class.Option.Slot, item2); } } // spellbook for (int i = 0; i < 32; i++) { uint sp = 1u << i; if (Template.ManaMax > 0 && (Template.KnownSpells & sp) != 0) { Spell cspell = new Spell(i, this); SpellBook.Add(cspell); } } CalculateVision(); UpdateItems(); }