static Doppelganger() { DBNpcTemplate chthonian = GameServer.Database.SelectObject <DBNpcTemplate>("Name=@Name", new QueryParameter("@Name", "chthonian crawler")); if (chthonian != null) { m_petTemplate = new NpcTemplate(chthonian); } }
static Doppelganger() { DBNpcTemplate chthonian = DOLDB <DBNpcTemplate> .SelectObject(DB.Column("Name").IsEqualTo("chthonian crawler")); if (chthonian != null) { m_petTemplate = new NpcTemplate(chthonian); } }
public void Save(DBNpcTemplate template) { if (string.IsNullOrWhiteSpace(template.ObjectId)) { DatabaseManager.Database.AddObject(template); return; } DatabaseManager.Database.SaveObject(template); }
public string Save(DBNpcTemplate template) { if (!template.IsPersisted) { template.ObjectId = IDGenerator.GenerateID(); DatabaseManager.Database.AddObject(template); return(template.ObjectId); } DatabaseManager.Database.SaveObject(template); return(template.ObjectId); }
private void button2_Click(object sender, System.EventArgs e) { var dialogResult = MessageBox.Show(@"You are about to create a new NPC Template record.\nAre you sure this is what you want to do?", @"Insert new NPC Template", MessageBoxButtons.YesNo); if (dialogResult != DialogResult.Yes) { return; } _template = new DBNpcTemplate(); BindingService.SyncData(_template, this); SyncFlags(); SyncWeaponSlots(); _template.ObjectId = null; _npcTemplateService.Save(_template); BindingService.ClearData(this); }
private void LoadItem(string id) { if (string.IsNullOrWhiteSpace(id)) { return; } _template = _npcTemplateService.Get(id); if (_template == null) { MessageBox.Show($@"Object with ObjectId: {id} not found", @"Object not found"); return; } BindingService.BindData(_template, this); BindFlags(); BindWeaponSlots(); }
private void button3_Click(object sender, System.EventArgs e) { Clear(); _template = null; }
public void Delete(DBNpcTemplate template) { DatabaseManager.Database.DeleteObject(template); }
/// <summary> /// Constructs a new NpcTemplate /// </summary> /// <param name="data">The source npc template data</param> public NpcTemplate(DBNpcTemplate data) { if (data == null) { throw new ArgumentNullException("data"); } m_templateId = data.TemplateId; m_translationId = data.TranslationId; m_name = data.Name; m_suffix = data.Suffix; m_classType = data.ClassType; m_guildName = data.GuildName; m_examineArticle = data.ExamineArticle; m_messageArticle = data.MessageArticle; m_model = data.Model; m_gender = data.Gender; m_size = data.Size; if (m_size == null) { m_size = "50"; } m_level = data.Level; if (m_level == null) { m_level = "0"; } m_equipmentTemplateID = data.EquipmentTemplateID; m_itemsListTemplateID = data.ItemsListTemplateID; m_maxSpeed = data.MaxSpeed; m_parryChance = data.ParryChance; m_evadeChance = data.EvadeChance; m_blockChance = data.BlockChance; m_leftHandSwingChance = data.LeftHandSwingChance; m_strength = data.Strength; m_constitution = data.Constitution; m_dexterity = data.Dexterity; m_quickness = data.Quickness; m_intelligence = data.Intelligence; m_piety = data.Piety; m_charisma = data.Charisma; m_empathy = data.Empathy; // Time to add Spells/Styles and Abilties to the templates m_abilities = new ArrayList(); m_spelllines = new ArrayList(); m_spells = new ArrayList(); // Adding the spells to an Arraylist here if (data.Spells != null && data.Spells.Length > 0) { string[] spells = data.Spells.Split(';'); for (int k = 0; k < spells.Length; k++) { int id = int.Parse(spells[k]); Spell sp = SkillBase.GetSpellByID(id); if (sp != null) { m_spells.Add(sp); } else { log.Error("Tried to load a null spell into NPC template " + m_templateId + " spell ID: " + id); } } } // Adding Style list to Template NPC m_styles = new ArrayList(); if (data.Styles != null && data.Styles.Length > 0) { string[] styles = data.Styles.Split(';'); for (int i = 0; i < styles.Length; i++) { if (styles[i].Trim().Length == 0) { continue; } string[] styleAndClass = styles[i].Split('|'); if (styleAndClass.Length != 2) { continue; } string stylePart = styleAndClass[0].Trim(); string classPart = styleAndClass[1].Trim(); if (stylePart.Length == 0 || classPart.Length == 0) { continue; } int styleID = int.Parse(stylePart); int classID = int.Parse(classPart); Style style = SkillBase.GetStyleByID(styleID, classID); m_styles.Add(style); } } // Adding Abilities to Template NPC. // Certain Abilities have levels will need to fix that down the road. -Batlas if (data.Abilities != null && data.Abilities.Length > 0) { foreach (string splitab in data.Abilities.SplitCSV()) { string[] ab = splitab.Split('|'); if (splitab.Trim().Length == 0) { continue; } int id = 1; if (ab.Length > 1) { id = int.Parse(ab[1]); } Ability abil = SkillBase.GetAbility(ab[0], id); if (abil != null) { m_abilities.Add(abil); } } } m_flags = data.Flags; m_meleeDamageType = (eDamageType)data.MeleeDamageType; if (data.MeleeDamageType == 0) { m_meleeDamageType = eDamageType.Slash; } m_inventory = data.EquipmentTemplateID; m_aggroLevel = data.AggroLevel; m_aggroRange = data.AggroRange; m_race = (ushort)data.Race; m_bodyType = (ushort)data.BodyType; m_maxdistance = data.MaxDistance; m_tetherRange = data.TetherRange; m_visibleActiveWeaponSlot = data.VisibleWeaponSlots; m_replaceMobValues = data.ReplaceMobValues; }
public virtual void SaveIntoDatabase() { DBNpcTemplate tmp = GameServer.Database.FindObjectByKey <DBNpcTemplate>(TemplateId); bool add = false; if (tmp == null) { tmp = new DBNpcTemplate(); add = true; } if (TemplateId == 0) { tmp.TemplateId = GetNextFreeTemplateId(); } else { tmp.TemplateId = TemplateId; } tmp.TranslationId = TranslationId; tmp.AggroLevel = AggroLevel; tmp.AggroRange = AggroRange; tmp.BlockChance = BlockChance; tmp.BodyType = BodyType; tmp.Charisma = Charisma; tmp.ClassType = ClassType; tmp.Constitution = Constitution; tmp.Dexterity = Dexterity; tmp.Empathy = Empathy; tmp.EquipmentTemplateID = EquipmentTemplateID; tmp.ItemsListTemplateID = ItemsListTemplateID; tmp.EvadeChance = EvadeChance; tmp.Flags = Flags; tmp.GuildName = GuildName; tmp.ExamineArticle = ExamineArticle; tmp.MessageArticle = MessageArticle; tmp.Intelligence = Intelligence; tmp.LeftHandSwingChance = LeftHandSwingChance; tmp.Level = Level; tmp.MaxDistance = MaxDistance; tmp.MaxSpeed = MaxSpeed; tmp.MeleeDamageType = (byte)MeleeDamageType; tmp.Model = Model; tmp.Name = Name; tmp.Suffix = Suffix; tmp.ParryChance = ParryChance; tmp.Piety = Piety; tmp.Quickness = Quickness; tmp.Size = Size; tmp.Strength = Strength; tmp.TetherRange = TetherRange; if (m_abilities != null && m_abilities.Count > 0) { string serializedAbilities = string.Empty; foreach (Ability npcAbility in m_abilities) { if (npcAbility != null) { if (serializedAbilities.Length > 0) { serializedAbilities += ";"; } } serializedAbilities += npcAbility.Name + "|" + npcAbility.Level; } tmp.Abilities = serializedAbilities; } if (m_spells != null && m_spells.Count > 0) { string serializedSpells = string.Empty; foreach (Spell npcSpell in m_spells) { if (npcSpell != null) { if (serializedSpells.Length > 0) { serializedSpells += ";"; } } serializedSpells += npcSpell.ID; } tmp.Spells = serializedSpells; } if (m_styles != null && m_styles.Count > 0) { string serializedStyles = string.Empty; foreach (Style npcStyle in m_styles) { if (npcStyle != null) { if (serializedStyles.Length > 0) { serializedStyles += ";"; } } serializedStyles += npcStyle.ID + "|" + npcStyle.ClassID; } tmp.Styles = serializedStyles; } if (add) { GameServer.Database.AddObject(tmp); } else { GameServer.Database.SaveObject(tmp); } }