public void CreateMoneyTask() { GamePlayer player = CreateMockGamePlayer(); GameMerchant merchant = new GameMerchant(); merchant.Name = "Tester"; merchant.Realm = eRealm.Albion; Console.WriteLine(player.Name); if (MoneyTask.CheckAvailability(player, merchant)) { if (MoneyTask.BuildTask(player, merchant)) { MoneyTask task = (MoneyTask)player.Task; Assert.IsNotNull(task); Console.WriteLine("XP" + task.RewardXP); Console.WriteLine("Item:" + task.ItemName); Console.WriteLine("Item:" + task.Name); Console.WriteLine("Item:" + task.Description); // Check Notify Event handling InventoryItem item = GameInventoryItem.Create(new ItemTemplate()); item.Name = task.ItemName; GameNPC npc = new GameNPC(); npc.Name = task.RecieverName; task.Notify(GamePlayerEvent.GiveItem, player, new GiveItemEventArgs(player, npc, item)); if (player.Task.TaskActive || player.Task == null) Assert.Fail("Task did not finished proper in Notify"); } } }
public AncientTransmuterSpellHandler(GameLiving caster, Spell spell, SpellLine line) : base(caster, spell, line) { if (caster is GamePlayer) { GamePlayer casterPlayer = caster as GamePlayer; merchant = new GameMerchant(); //Fill the object variables merchant.X = casterPlayer.X + Util.Random(20, 40) - Util.Random(20, 40); merchant.Y = casterPlayer.Y + Util.Random(20, 40) - Util.Random(20, 40); merchant.Z = casterPlayer.Z; merchant.CurrentRegion = casterPlayer.CurrentRegion; merchant.Heading = (ushort)((casterPlayer.Heading + 2048) % 4096); merchant.Level = 1; merchant.Realm = casterPlayer.Realm; merchant.Name = "Ancient Transmuter"; merchant.Model = 993; merchant.CurrentSpeed = 0; merchant.MaxSpeedBase = 0; merchant.GuildName = ""; merchant.Size = 50; merchant.Flags |= GameNPC.eFlags.PEACE; merchant.TradeItems = new MerchantTradeItems("ML_transmuteritems"); } }
public NpcTemplate(GameNPC mob) { if (mob == null) { throw new ArgumentNullException("data"); } m_translationId = mob.TranslationId; m_blockChance = mob.BlockChance; m_race = (ushort)mob.Race; m_bodyType = mob.BodyType; m_charisma = mob.Charisma; m_classType = mob.GetType().ToString(); m_constitution = mob.Constitution; m_dexterity = mob.Dexterity; m_empathy = mob.Empathy; m_equipmentTemplateID = mob.EquipmentTemplateID; m_evadeChance = mob.EvadeChance; m_flags = (ushort)mob.Flags; m_guildName = mob.GuildName; m_examineArticle = mob.ExamineArticle; m_messageArticle = mob.MessageArticle; m_intelligence = mob.Intelligence; m_maxdistance = mob.MaxDistance; m_maxSpeed = (short)mob.MaxSpeedBase; m_meleeDamageType = (eDamageType)mob.MeleeDamageType; m_model = mob.Model.ToString(); m_leftHandSwingChance = mob.LeftHandSwingChance; m_level = mob.Level.ToString(); m_name = mob.Name; m_suffix = mob.Suffix; m_parryChance = mob.ParryChance; m_piety = mob.Piety; m_quickness = mob.Quickness; m_strength = mob.Strength; m_size = mob.Size.ToString(); m_templateId = GetNextFreeTemplateId(); m_tetherRange = mob.TetherRange; m_visibleActiveWeaponSlot = mob.VisibleActiveWeaponSlots; if (mob.Abilities != null && mob.Abilities.Count > 0) { try { if (m_abilities == null) { m_abilities = new ArrayList(mob.Abilities.Count); } foreach (Ability mobAbility in mob.Abilities.Values) { m_abilities.Add(mobAbility); } } catch (Exception ex) { log.Error("Trapped Error: ", ex); } } if (mob.Spells != null && mob.Spells.Count > 0) { try { if (m_spells == null) { m_spells = new ArrayList(mob.Spells.Count); } foreach (Spell mobSpell in mob.Spells) { m_spells.Add(mobSpell); } } catch (Exception ex) { log.Error("Trapped Error: ", ex); } } if (mob.Styles != null && mob.Styles.Count > 0) { try { if (m_styles == null) { m_styles = new ArrayList(mob.Styles.Count); } foreach (Style mobStyle in mob.Styles) { m_styles.Add(mobStyle); } } catch (Exception ex) { log.Error("Trapped Error: ", ex); } } AI.Brain.StandardMobBrain brain = mob.Brain as AI.Brain.StandardMobBrain; if (brain != null) { m_aggroLevel = (byte)brain.AggroLevel; m_aggroRange = brain.AggroRange; } if (string.IsNullOrEmpty(ItemsListTemplateID) == false) { GameMerchant merchant = mob as GameMerchant; if (merchant != null) { merchant.TradeItems = new MerchantTradeItems(ItemsListTemplateID); } } }