private void AddChestArmour(ChestArmour.ChestArmourEnum chestArmour, DataOvlReference.EQUIPMENT equipment) { ChestArmour armour = new ChestArmour(chestArmour, equipment, dataOvlRef, gameStateByteArray); ChestArmours.Add(armour); ItemsFromEquipment.Add(equipment, armour); }
//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); }
//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) public CombatItem(DataOvlReference.EQUIPMENT specificEquipment, DataOvlReference dataOvlRef, List <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; }
public Weapon(WeaponTypeEnum weapon, WeaponTypeSpriteEnum sprite, DataOvlReference.EQUIPMENT equipment, DataOvlReference dataOvlRef, List <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); }
/// <summary> /// Gets the Combat Item (inventory item) based on the equipped item /// </summary> /// <param name="equipment">type of combat equipment</param> /// <returns>combat item object</returns> public CombatItem GetItemFromEquipment(DataOvlReference.EQUIPMENT equipment) { foreach (CombatItem item in ReadyItems) { if (item.SpecificEquipment == equipment) { return(item); } } throw new Exception("Requested " + equipment.ToString() + " but is not a combat type"); }
public Weapon GetWeaponFromEquipment(DataOvlReference.EQUIPMENT equipment) { if (equipment == DataOvlReference.EQUIPMENT.Nothing) { return(null); } if (!ItemsFromEquipment.ContainsKey(equipment)) { return(null); } return(ItemsFromEquipment[equipment]); }
/// <summary> /// Gets the defense of a particular piece of equipment /// </summary> /// <param name="equipment"></param> /// <returns></returns> private int GetDefense(DataOvlReference.EQUIPMENT equipment) { if (TheWeapons.GetWeaponFromEquipment(equipment) != null) { return(TheWeapons.GetWeaponFromEquipment(equipment).AttackStat); } if (ProtectiveArmour.GetArmourFromEquipment(equipment) != null) { return(ProtectiveArmour.GetArmourFromEquipment(equipment).DefendStat); } return(0); }
/// <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 Amulet(AmuletEnum amuletType, DataOvlReference.EQUIPMENT equipment, DataOvlReference dataOvlRef, List <byte> gameStateByteArray) : base(equipment, dataOvlRef, gameStateByteArray, (int)amuletType, AMULET_SPRITE) { AmuletType = amuletType; }
public Ring(RingEnum ringType, DataOvlReference.EQUIPMENT equipment, DataOvlReference dataOvlRef, List <byte> gameStateByteArray) : base(equipment, dataOvlRef, gameStateByteArray, (int)ringType, RING_SPRITE) { RingType = ringType; }
public Helm(HelmEnum helmType, DataOvlReference.EQUIPMENT equipment, DataOvlReference dataOvlRef, List <byte> gameStateByteArray) : base(equipment, dataOvlRef, gameStateByteArray, (int)helmType, HELM_SPRITE) { HelmType = helmType; }
public ChestArmour(ChestArmourEnum chestArmourType, DataOvlReference.EQUIPMENT equipment, DataOvlReference dataOvlRef, List <byte> gameStateByteArray) : base(equipment, dataOvlRef, gameStateByteArray, (int)chestArmourType, CHEST_ARMOUR_SPRITE) { ChestArmourType = chestArmourType; }
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 Shield(ShieldTypeEnum shieldType, DataOvlReference.EQUIPMENT equipment, DataOvlReference dataOvlRef, List <byte> gameStateByteArray) : base(equipment, dataOvlRef, gameStateByteArray, (int)shieldType, SHIELD_SPRITE) { ShieldType = shieldType; }
public bool IsEquipped(DataOvlReference.EQUIPMENT equipment) { return(Helmet == equipment || Armor == equipment || LeftHand == equipment || RightHand == equipment || Ring == equipment || Amulet == equipment); }
public Armour(DataOvlReference.EQUIPMENT specificEquipment, DataOvlReference dataOvlRef, List <byte> gameStateByteRef, int nOffset, int nSpriteNum) : base(specificEquipment, dataOvlRef, gameStateByteRef, nOffset, nSpriteNum) { }