public MapHuman(int serverId, bool hero = false) { IsHero = hero; Template = TemplateLoader.GetHumanById(serverId); if (Template == null) { Debug.LogFormat("Invalid human created (serverId={0})", serverId); } else { InitHuman(); } }
public MapHuman(string name, bool hero = false) { IsHero = hero; Template = TemplateLoader.GetHumanByName(name); if (Template == null) { Debug.LogFormat("Invalid human created (name={0})", name); } else { InitHuman(); } }
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 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")); } }