// [StartupInvoke("Item SkinModule", StartupInvokePriority.Modules)] public static void SynchronizeItems() { BigEndianReader reader = new BigEndianReader(File.ReadAllBytes(ItemsPath)); List <MA3Item> items = new List <MA3Item>(); while (reader.BytesAvailable > 0) { MA3Item item = new MA3Item(); item.Deserialize(reader); items.Add(item); } foreach (var item in items) { ItemRecord record = ItemRecord.GetItem((ushort)item.Id); if (record != null && record.AppearanceId != item.Skin && item.Skin != 0) { if (record.Weapon) { var weaponRecord = WeaponRecord.GetWeapon((ushort)item.Id); weaponRecord.Template.AppearanceId = (ushort)item.Skin; weaponRecord.UpdateInstantElement(); } else { record.AppearanceId = (ushort)item.Skin; record.UpdateInstantElement(); } logger.Gray("Fixed: " + record.Name); } } }
/// <summary> /// A trouver = TextInformationMessage (Vous avez dus lacher votre arme a deux mains pour pouvoir équiper) /// </summary> /// <param name="position"></param> /// <param name="item"></param> public void CheckTwoHandeds(CharacterInventoryPositionEnum position, CharacterItemRecord item) { if (position == CharacterInventoryPositionEnum.ACCESSORY_POSITION_WEAPON) { if (WeaponRecord.GetWeapon(item.GId).TwoHanded) { CharacterItemRecord shield = GetEquipedItem(CharacterInventoryPositionEnum.ACCESSORY_POSITION_SHIELD); if (shield != null) { UnequipItem(shield, shield.Quantity); OnObjectMoved(shield, CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED); Character.TextInformation(TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 79); } } } else if (position == CharacterInventoryPositionEnum.ACCESSORY_POSITION_SHIELD) { CharacterItemRecord weapon = GetEquipedItem(CharacterInventoryPositionEnum.ACCESSORY_POSITION_WEAPON); if (weapon != null && WeaponRecord.GetWeapon(weapon.GId).TwoHanded) { UnequipItem(weapon, weapon.Quantity); OnObjectMoved(weapon, CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED); Character.TextInformation(TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 78); } } }
public override bool UseWeapon(short cellid) { var target = Fight.GetFighter(cellid); CharacterItemRecord weapon = Client.Character.Inventory.GetEquipedWeapon(); if (weapon == null) { UsePunch(cellid); return(true); } WeaponRecord template = WeaponRecord.GetWeapon(weapon.GID); FightSpellCastCriticalEnum critical = RollCriticalDice(template); Fight.TryStartSequence(this.ContextualId, 2); int targetId = target != null ? target.ContextualId : 0; Fight.Send(new GameActionFightCloseCombatMessage(0, this.ContextualId, targetId, cellid, (sbyte)critical, false, weapon.GID)); var effects = template.GetWeaponEffects(critical); this.HandleWeaponEffect(cellid, effects, critical); this.FighterStats.Stats.ActionPoints -= template.ApCost; this.GameActionFightPointsVariation(ActionsEnum.ACTION_CHARACTER_ACTION_POINTS_USE, (short)(-template.ApCost)); Fight.TryEndSequence(2, 0); return(true); }
public override void Ready(bool ready, ushort step) { List<CharacterItemRecord> results = new List<CharacterItemRecord>(); Dictionary<uint, uint> removed = new Dictionary<uint, uint>(); if (ready) { var recipe = GetRecipe(); if (recipe != null && recipe.ResultLevel <= CharacterJob.Level) { for (int i = 0; i < Count; i++) { if (Character.IsInExchange(ExchangeTypeEnum.CRAFT)) { results.Add(recipe.Result.GetCharacterItem(Character.Id, 1, true)); // True = jet parfait foreach (var ingredient in CraftedItems.GetItems()) { if (!removed.ContainsKey(ingredient.UId)) removed.Add(ingredient.UId, ingredient.Quantity); else removed[ingredient.UId] += ingredient.Quantity; } } else return; } CraftedItems.Clear(false); Character.Inventory.RemoveItems(removed); Character.Inventory.AddItems(results); OnCraftResulted(CraftResultEnum.CRAFT_SUCCESS, results.Last()); Character.SendMap(new ExchangeCraftInformationObjectMessage((sbyte)CraftResultEnum.CRAFT_SUCCESS, recipe.ResultId, (ulong)Character.Id)); int craftXpRatio = recipe.Result.Weapon ? WeaponRecord.GetWeapon(recipe.ResultId).CraftXpRatio : -1; int exp = FormulasProvider.Instance.GetCraftXpByJobLevel(recipe.ResultLevel, CharacterJob.Level, craftXpRatio); Character.AddJobExp(JobType, (ulong)(exp * Count)); SetCount(1); } else { OnCraftResulted(CraftResultEnum.CRAFT_FAILED); } } else { OnCraftResulted(CraftResultEnum.CRAFT_FAILED); } }
public override void Initialize() { this.Id = (int)Character.Id; this.Look = Character.Look.Clone(); this.Stats = new FighterStats(Character); if (Character.Inventory.HasWeaponEquiped) { this.WeaponTemplate = WeaponRecord.GetWeapon(Character.Inventory.GetWeapon().GId); this.WeaponLevel = WeaponManager.Instance.GetWeaponSpellLevel(WeaponTemplate); } base.Initialize(); }
public void EquipItem(CharacterItemRecord item, ItemRecord template, byte newposition, uint quantity) { if (!ConditionProvider.ParseAndEvaluate(Character.Client, template.Criteria)) { Character.Reply("Vous n'avez pas les critères nessessaire pour équiper cet objet"); return; } if (CheckRingStacks(item, newposition)) { Character.Reply("Vous avez déja équipé cet anneau!"); return; } if (CheckDofusStacks(item, newposition)) { Character.Reply("Vous avez déja équipé ce dofus"); return; } if (DOFUS_POSITIONS.Contains((CharacterInventoryPositionEnum)item.Position) && DOFUS_POSITIONS.Contains((CharacterInventoryPositionEnum)newposition)) { return; } if ((CharacterInventoryPositionEnum)newposition == CharacterInventoryPositionEnum.ACCESSORY_POSITION_SHIELD) { var weapon = GetEquipedWeapon(); if (weapon != null) { if (WeaponRecord.GetWeapon(weapon.GID).TwoHanded) { Character.Reply("Vous devez deséquiper votre arme pour équiper le bouclier."); return; } } } if ((CharacterInventoryPositionEnum)newposition == CharacterInventoryPositionEnum.ACCESSORY_POSITION_WEAPON) { var shield = GetItemByPosition(CharacterInventoryPositionEnum.ACCESSORY_POSITION_SHIELD); if (WeaponRecord.GetWeapon(item.GID).TwoHanded) { Character.Reply("Vous devez enlevé votre bouclier pour équiper votre arme."); return; } } var equiped = EquipedItem(newposition); if (equiped != null) { UnequipItem(equiped, 63, equiped.GetTemplate(), quantity); SaveTask.UpdateElement(equiped); } if (item.Quantity == 1) { item.Position = newposition; SaveTask.UpdateElement(item); AddItemSkin(item, template); ItemEffectsProvider.AddEffects(Character.Client, item.GetEffects()); } else { var items = ItemCut.Cut(item, quantity, newposition); Add(items.newItem); ItemEffectsProvider.AddEffects(Character.Client, items.BaseItem.GetEffects()); AddItemSkin(item, template); } Character.RefreshGroupInformations(); }
public override void Ready(bool ready, ushort step) { List <CharacterItemRecord> results = new List <CharacterItemRecord>(); Dictionary <uint, uint> removed = new Dictionary <uint, uint>(); if (ready) { var recipe = this.GetRecipe(); if (recipe != null && recipe.ResultLevel <= this.CharacterJob.Level) { var recipeResult = recipe.Result; if (recipeResult == null) // Tables load ordering problem. Temporary solution? { recipeResult = ItemRecord.Items.Find(it => it.Id == recipe.ResultId); } for (int i = 0; i < this.Count; i++) { if (this.Character.IsInExchange(ExchangeTypeEnum.CRAFT)) { results.Add(recipeResult.GetCharacterItem(this.Character.Id, 1, false)); // True = jet parfait foreach (var ingredient in this.CraftedItems.GetItems()) { if (!removed.ContainsKey(ingredient.UId)) { removed.Add(ingredient.UId, ingredient.Quantity); } else { removed[ingredient.UId] += ingredient.Quantity; } } } else { return; } } this.CraftedItems.Clear(false); this.Character.Inventory.RemoveItems(removed); this.Character.Inventory.AddItems(results); this.OnCraftResulted(CraftResultEnum.CRAFT_SUCCESS, results.Last()); this.Character.SendMap(new ExchangeCraftInformationObjectMessage((sbyte)CraftResultEnum.CRAFT_SUCCESS, recipe.ResultId, (ulong)this.Character.Id)); int craftXpRatio = recipeResult.Weapon ? WeaponRecord.GetWeapon(recipe.ResultId).CraftXpRatio : -1; int exp = FormulasProvider.Instance.GetCraftXpByJobLevel(recipe.ResultLevel, this.CharacterJob.Level, craftXpRatio); this.Character.AddJobExp(this.JobType, (ulong)(exp * this.Count * WorldConfiguration.Instance.JobXpRate)); this.SetCount(1); } else { this.OnCraftResulted(CraftResultEnum.CRAFT_FAILED); } } else { this.OnCraftResulted(CraftResultEnum.CRAFT_FAILED); } }