//private void AddShield(Shield.ShieldTypeEnum shield, DataOvlReference.EQUIPMENT equipment) //{ // Shields.Add(new Shield(shield, equipment, dataOvlRef, gameStateByteArray)); //} private void AddHelm(Helm.HelmEnum helm, DataOvlReference.Equipment equipment) { Helm armour = new Helm(helm, equipment, DataOvlRef, GameStateByteArray); Helms.Add(armour); ItemsFromEquipment.Add(equipment, armour); }
private void AddAmulet(Amulet.AmuletEnum amulet, DataOvlReference.Equipment equipment) { Amulet armour = new Amulet(amulet, equipment, DataOvlRef, GameStateByteArray); Amulets.Add(armour); ItemsFromEquipment.Add(equipment, armour); }
private void AddRing(Ring.RingEnum ring, DataOvlReference.Equipment equipment) { Ring armour = new Ring(ring, equipment, DataOvlRef, GameStateByteArray); Rings.Add(armour); ItemsFromEquipment.Add(equipment, armour); }
private void AddChestArmour(ChestArmour.ChestArmourEnum chestArmour, DataOvlReference.Equipment equipment) { ChestArmour armour = new ChestArmour(chestArmour, equipment, DataOvlRef, GameStateByteArray); ChestArmours.Add(armour); ItemsFromEquipment.Add(equipment, armour); }
/// <summary> /// Constructor builds reference tables from embedded resources /// </summary> public InventoryReferences() { _invRefsDictionary = JsonConvert.DeserializeObject <Dictionary <string, List <InventoryReference> > >(Ultima5Redux.Properties.Resources.InventoryDetails); // we initialize the highlight text list _reagentKeywordHighlightList = new List <string>(); _spellKeywordHighlightList = new List <string>(); _invRefs = new List <InventoryReference>(); foreach (InventoryReference invRef in GetInventoryReferenceList(InventoryReferenceType.Armament)) { _invRefs.Add(invRef); } foreach (InventoryReference invRef in GetInventoryReferenceList(InventoryReferenceType.Item)) { _invRefs.Add(invRef); } // build reagent highlight table foreach (InventoryReference invRef in GetInventoryReferenceList(InventoryReferenceType.Reagent)) //reagentInvRefs) { _invRefs.Add(invRef); if (invRef.ItemNameHighLights.Length == 0) { continue; } foreach (string highlightWord in invRef.ItemNameHighLights) { _reagentKeywordHighlightList.Add(highlightWord); } } //build spell name highlight table foreach (InventoryReference invRef in GetInventoryReferenceList(InventoryReferenceType.Spell)) //spellInvRefs) { _invRefs.Add(invRef); if (invRef.ItemNameHighLights.Length == 0) { continue; } foreach (string highlightWord in invRef.ItemNameHighLights) { _spellKeywordHighlightList.Add(highlightWord); } } _invRefsByEquipment = new Dictionary <DataOvlReference.Equipment, InventoryReference>(); foreach (InventoryReference invRef in _invRefs) { DataOvlReference.Equipment equipment = invRef.GetAsEquipment(); if (Enum.IsDefined(typeof(DataOvlReference.Equipment), equipment)) { _invRefsByEquipment.Add(equipment, invRef); } } }
public InventoryReference GetInventoryReference(DataOvlReference.Equipment equipment) { if (!_invRefsByEquipment.ContainsKey(equipment)) { throw new Ultima5ReduxException("You requested an equipment item that doesn't exist in the dictionary: " + (int)equipment); } return(_invRefsByEquipment[equipment]); }
//public CombatItem(int quantity, string longName, string shortName, int nSpriteNum, int attackStat, int defendStat, DataOvlReference.EQUIPMENT specificEquipment) // : base(quantity, longName, shortName, nSpriteNum) //{ // attackStat = AttackStat; // defendStat = DefendStat; // this.SpecificEquipment = specificEquipment; //} // ChestArmours.Add(new ChestArmour(chestArmour, gameStateByteArray[(int)chestArmour], //equipmentNames[(int)equipment], equipmentNames[(int)equipment], // CombatItem.GetAttack(dataOvlRef, (int) equipment), // CombatItem.GetDefense(dataOvlRef, (int) equipment),equipment)); // CombatItem.GetAttack(dataOvlRef, (int)specificEquipment), CombatItem.GetDefense(dataOvlRef, (int)specificEquipment) protected CombatItem(DataOvlReference.Equipment specificEquipment, DataOvlReference dataOvlRef, IReadOnlyList <byte> gameStateRef, int nOffset, int nSpriteNum) : base(gameStateRef[nOffset], CombatItem.GetEquipmentString(dataOvlRef, (int)specificEquipment), CombatItem.GetEquipmentString(dataOvlRef, (int)specificEquipment), nSpriteNum) { AttackStat = GetAttack(dataOvlRef, (int)specificEquipment); DefendStat = GetDefense(dataOvlRef, (int)specificEquipment); RequiredStrength = GetRequiredStrength(dataOvlRef, (int)specificEquipment); this.SpecificEquipment = specificEquipment; InitializePrices(dataOvlRef); }
public Weapon(WeaponTypeEnum weapon, WeaponTypeSpriteEnum sprite, DataOvlReference.Equipment equipment, DataOvlReference dataOvlRef, IReadOnlyList <byte> gameStateByteArray) : base(equipment, dataOvlRef, gameStateByteArray, (int)weapon, (int)sprite) { IsAmmo = equipment == DataOvlReference.Equipment.Quarrels || equipment == DataOvlReference.Equipment.Arrows; IsTwoHanded = equipment == DataOvlReference.Equipment.TwoHAxe || equipment == DataOvlReference.Equipment.TwoHSword || equipment == DataOvlReference.Equipment.TwoHHammer || equipment == DataOvlReference.Equipment.Bow || equipment == DataOvlReference.Equipment.MagicBow || equipment == DataOvlReference.Equipment.Crossbow || equipment == DataOvlReference.Equipment.Halberd || equipment == DataOvlReference.Equipment.FlamingOil; IsShield = equipment == DataOvlReference.Equipment.SmallShield || equipment == DataOvlReference.Equipment.LargeShield || equipment == DataOvlReference.Equipment.SpikedShield || equipment == DataOvlReference.Equipment.MagicShield || equipment == DataOvlReference.Equipment.JewelShield; }
public bool IsEquipmentEquipped(DataOvlReference.Equipment equipment) { foreach (PlayerCharacterRecord record in Records) { if (record.Equipped.IsEquipped(equipment)) { return(true); } } return(false); }
public Armour GetArmourFromEquipment(DataOvlReference.Equipment equipment) { if (equipment == DataOvlReference.Equipment.Nothing) { return(null); } if (!ItemsFromEquipment.ContainsKey(equipment)) { return(null); } return(ItemsFromEquipment[equipment]); }
/// <summary> /// Creates a character record from a raw record that begins at offset 0 /// </summary> /// <param name="rawRecord"></param> public PlayerCharacterRecord(byte[] rawRecord) { Debug.Assert(rawRecord.Length == (int)CHARACTER_RECORD_BYTE_ARRAY_SIZE); List <byte> rawRecordByteList = new List <byte>(rawRecord); Name = DataChunk.CreateDataChunk(DataChunk.DataFormatType.SimpleString, "Character Name", rawRecordByteList, (int)CharacterRecordOffsets.Name, 9).GetChunkAsString(); Gender = (CharacterGender)rawRecordByteList[(int)CharacterRecordOffsets.Gender]; Class = (CharacterClass)rawRecordByteList[(int)CharacterRecordOffsets.Class]; Status = (CharacterStatus)rawRecordByteList[(int)CharacterRecordOffsets.Status]; Stats.Strength = rawRecordByteList[(int)CharacterRecordOffsets.Strength]; Stats.Dexterity = rawRecordByteList[(int)CharacterRecordOffsets.Dexterity]; Stats.Intelligence = rawRecordByteList[(int)CharacterRecordOffsets.Intelligence]; Stats.CurrentMp = rawRecordByteList[(int)CharacterRecordOffsets.CurrentMP]; Stats.CurrentHp = DataChunk.CreateDataChunk(DataChunk.DataFormatType.UINT16List, "Current hit points", rawRecordByteList, (int)CharacterRecordOffsets.CurrentHP, sizeof(UInt16)).GetChunkAsUint16List()[0]; Stats.MaximumHp = DataChunk.CreateDataChunk(DataChunk.DataFormatType.UINT16List, "Maximum hit points", rawRecordByteList, (int)CharacterRecordOffsets.MaximimumHP, sizeof(UInt16)).GetChunkAsUint16List()[0]; Stats.ExperiencePoints = DataChunk.CreateDataChunk(DataChunk.DataFormatType.UINT16List, "Maximum hit points", rawRecordByteList, (int)CharacterRecordOffsets.ExperiencePoints, sizeof(UInt16)).GetChunkAsUint16List()[0]; Stats.Level = rawRecordByteList[(int)CharacterRecordOffsets.Level]; // this approach is necessary because I have found circumstances where shields and weapons were swapped in the save file // I couldn't guarantee that other items wouldn't do the same so instead we allow each of the equipment save // slots can be "whatever" in "whatever" order. When I save them back to disk, I will save them in the correct order // Also confirmed that Ultima 5 can handle these equipment saves out of order as well List <DataOvlReference.Equipment> allEquipment = new List <DataOvlReference.Equipment>(6); allEquipment.Add((DataOvlReference.Equipment)rawRecordByteList[(int)CharacterRecordOffsets.Helmet]); allEquipment.Add((DataOvlReference.Equipment)rawRecordByteList[(int)CharacterRecordOffsets.Armor]); allEquipment.Add((DataOvlReference.Equipment)rawRecordByteList[(int)CharacterRecordOffsets.Weapon]); allEquipment.Add((DataOvlReference.Equipment)rawRecordByteList[(int)CharacterRecordOffsets.Shield]); allEquipment.Add((DataOvlReference.Equipment)rawRecordByteList[(int)CharacterRecordOffsets.Ring]); allEquipment.Add((DataOvlReference.Equipment)rawRecordByteList[(int)CharacterRecordOffsets.Amulet]); Equipped.Helmet = (DataOvlReference.Equipment)rawRecordByteList[(int)CharacterRecordOffsets.Helmet]; Equipped.Armor = (DataOvlReference.Equipment)rawRecordByteList[(int)CharacterRecordOffsets.Armor]; Equipped.LeftHand = (DataOvlReference.Equipment)rawRecordByteList[(int)CharacterRecordOffsets.Weapon]; Equipped.RightHand = (DataOvlReference.Equipment)rawRecordByteList[(int)CharacterRecordOffsets.Shield]; Equipped.Ring = (DataOvlReference.Equipment)rawRecordByteList[(int)CharacterRecordOffsets.Ring]; Equipped.Amulet = (DataOvlReference.Equipment)rawRecordByteList[(int)CharacterRecordOffsets.Amulet]; // sometimes U5 swaps the shield and weapon, so we are going to be careful and just swap them back if ((int)Equipped.LeftHand <= (int)DataOvlReference.Equipment.JewelShield && (int)Equipped.LeftHand >= (int)DataOvlReference.Equipment.Dagger) { DataOvlReference.Equipment shieldEquip = Equipped.RightHand; Equipped.RightHand = Equipped.LeftHand; Equipped.LeftHand = shieldEquip; } InnOrParty = rawRecordByteList[(int)CharacterRecordOffsets.InnParty]; Unknown1 = rawRecordByteList[(int)CharacterRecordOffsets.Unknown1]; Unknown2 = rawRecordByteList[(int)CharacterRecordOffsets.Unknown2]; }
public Shield(ShieldTypeEnum shieldType, DataOvlReference.Equipment equipment, DataOvlReference dataOvlRef, List <byte> gameStateByteArray) : base(equipment, dataOvlRef, gameStateByteArray, (int)shieldType, SHIELD_SPRITE) { ShieldType = shieldType; //InitializePrices(dataOvlRef); }
public Amulet(AmuletEnum amuletType, DataOvlReference.Equipment equipment, DataOvlReference dataOvlRef, List <byte> gameStateByteArray) : base(equipment, dataOvlRef, gameStateByteArray, (int)amuletType, AMULET_SPRITE) { AmuletType = amuletType; }
public ChestArmour(ChestArmourEnum chestArmourType, DataOvlReference.Equipment equipment, DataOvlReference dataOvlRef, List <byte> gameStateByteArray) : base(equipment, dataOvlRef, gameStateByteArray, (int)chestArmourType, CHEST_ARMOUR_SPRITE) { ChestArmourType = chestArmourType; }
public Ring(RingEnum ringType, DataOvlReference.Equipment equipment, DataOvlReference dataOvlRef, List <byte> gameStateByteArray) : base(equipment, dataOvlRef, gameStateByteArray, (int)ringType, RING_SPRITE) { RingType = ringType; }
protected Armour(DataOvlReference.Equipment specificEquipment, DataOvlReference dataOvlRef, IReadOnlyList <byte> gameStateByteRef, int nOffset, int nSpriteNum) : base(specificEquipment, dataOvlRef, gameStateByteRef, nOffset, nSpriteNum) { }
public bool IsEquipped(DataOvlReference.Equipment equipment) { return(Helmet == equipment || Armor == equipment || LeftHand == equipment || RightHand == equipment || Ring == equipment || Amulet == equipment); }
private void AddWeapon(Weapon.WeaponTypeEnum weapon, Weapon.WeaponTypeSpriteEnum weaponSprite, DataOvlReference.Equipment equipment) { Weapon newWeapon = new Weapon(weapon, weaponSprite, equipment, DataOvlRef, GameStateByteArray); Items.Add(weapon, newWeapon); ItemsFromEquipment.Add(equipment, newWeapon); }
public Helm(HelmEnum helmType, DataOvlReference.Equipment equipment, DataOvlReference dataOvlRef, List <byte> gameStateByteArray) : base(equipment, dataOvlRef, gameStateByteArray, (int)helmType, HELM_SPRITE) { HelmType = helmType; }
/// <summary> /// Gets the blacksmiths specific response to trying to buy a specific piece of equipment /// </summary> /// <param name="equipment">which equipment?</param> /// <param name="nGold">how much does he charge?</param> /// <returns></returns> public string GetEquipmentBuyingOutput(DataOvlReference.Equipment equipment, int nGold) { return(GetEquipmentBuyingOutput((int)equipment, nGold)); }