示例#1
0
        public ShoppeKeeperReferences(DataOvlReference dataOvlReference, NonPlayerCharacterReferences npcReferences)
        {
            _dataOvlReference = dataOvlReference;

            // we load a list of all shoppe keeper locations which we unfortunately had to map
            // ourselves because it appears most shoppe keeper data is in the code (OVL) files
            _shoppeKeepersByIndex = ShoppeKeeperReferences.LoadShoppeKeepersByIndex(_dataOvlReference);

            List <string> shoppeNames = dataOvlReference.GetDataChunk(DataOvlReference.DataChunkName.STORE_NAMES)
                                        .GetChunkAsStringList().Strs;
            List <string> shoppeKeeperNames = dataOvlReference
                                              .GetDataChunk(DataOvlReference.DataChunkName.SHOPPE_KEEPER_NAMES).GetChunkAsStringList().Strs;

            // Dammit Simplon, how the hell did you sneak into the Shoppe Keeper array!?!
            shoppeKeeperNames.Remove(@"Simplon");

            Debug.Assert(shoppeNames.Count == shoppeKeeperNames.Count, "Must be same number of shoppe keepers to shoppes");

            for (int i = 0; i < shoppeNames.Count; i++)
            {
                // create a new shoppe keeper object then add it to the list
                ShoppeKeeperReference shoppeKeeper = _shoppeKeepersByIndex[i];//new TheShoppeKeeperReference();
                string shoppeKeeperName            = shoppeKeeperNames[i];
                shoppeKeeper.ShoppeName       = shoppeNames[i];
                shoppeKeeper.ShoppeKeeperName = shoppeKeeperName;

                List <NonPlayerCharacterReference> npcRefs = npcReferences.GetNonPlayerCharacterByLocationAndNPCType(shoppeKeeper.ShoppeKeeperLocation, shoppeKeeper.TheShoppeKeeperType);
                Debug.Assert(npcRefs.Count == 1);

                shoppeKeeper.NpcRef = npcRefs[0];
                _shoppeKeepers.Add(shoppeKeeperName, shoppeKeeper);

                // we keep track of the location + type for easier world access to shoppe keeper reference
                if (!_shoppeKeepersByLocationAndType.ContainsKey(shoppeKeeper.ShoppeKeeperLocation))
                {
                    _shoppeKeepersByLocationAndType.Add(shoppeKeeper.ShoppeKeeperLocation, new Dictionary <NonPlayerCharacterReference.NPCDialogTypeEnum, ShoppeKeeperReference>());
                }

                _shoppeKeepersByLocationAndType[shoppeKeeper.ShoppeKeeperLocation]
                .Add(shoppeKeeper.TheShoppeKeeperType, shoppeKeeper);

                // if it's a blacksmith then we load their items for sale
                if (shoppeKeeper.NpcRef.NPCType == NonPlayerCharacterReference.NPCDialogTypeEnum.Blacksmith)
                {
                    shoppeKeeper.EquipmentForSaleList = GetEquipmentList(i);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Gets a random string from a datachunk string list
        /// It automatically prevents the same string from being selected twice in a row
        /// </summary>
        /// <param name="chunkName"></param>
        /// <returns></returns>
        protected string GetRandomStringFromChoices(DataOvlReference.DataChunkName chunkName)
        {
            List <string> responses = DataOvlReference.GetDataChunk(chunkName)
                                      .GetChunkAsStringList().Strs;

            // if this hasn't been access before, then lets add a chunk to make sure we don't repeat the same thing
            // twice in a row
            if (!_previousRandomSelectionByChunk.ContainsKey(chunkName))
            {
                _previousRandomSelectionByChunk.Add(chunkName, -1);
            }

            int nResponseIndex = ShoppeKeeperDialogueReference.GetRandomIndexFromRange(0, responses.Count);

            // if this response is the same as the last response, then we add one and make sure it is still in bounds
            // by modding it
            if (nResponseIndex == _previousRandomSelectionByChunk[chunkName])
            {
                nResponseIndex = (nResponseIndex + 1) % responses.Count;
            }

            _previousRandomSelectionByChunk[chunkName] = nResponseIndex;

            return(responses[nResponseIndex]);
        }
示例#3
0
        /// <summary>
        /// Constructor building xy table
        /// </summary>
        /// <param name="dataRef">data ovl reference for extracting xy coordinates</param>
        public LargeMapLocationReferences(DataOvlReference dataRef)
        {
            // Load the location XYs and map them against the location
            List <byte> xLocs = dataRef.GetDataChunk(DataOvlReference.DataChunkName.LOCATIONS_X).GetAsByteList();
            List <byte> yLocs = dataRef.GetDataChunk(DataOvlReference.DataChunkName.LOCATIONS_Y).GetAsByteList();

            Debug.Assert(xLocs.Count == yLocs.Count);

            for (int nVector = 0; nVector < N_TOTAL_LOCATIONS; nVector++)
            {
                Point2D mapPoint = new Point2D(xLocs[nVector], yLocs[nVector]);
                SmallMapReferences.SingleMapReference.Location location = (SmallMapReferences.SingleMapReference.Location)nVector + 1;
                LocationXY.Add(location, mapPoint);
                LocationXYLocations.Add(mapPoint, location);
            }
        }
示例#4
0
        public Armours(DataOvlReference dataOvlRef, List <byte> gameStateByteArray) : base(dataOvlRef, gameStateByteArray)
        {
            _equipmentNames = dataOvlRef.GetDataChunk(DataOvlReference.DataChunkName.EQUIP_INDEXES).GetAsStringListFromIndexes();

            InitializeHelms();
            //InitializeShields();
            InitializeChestArmour();
            InitializeAmulets();
            InitializeRings();
        }
示例#5
0
        public static int GetRequiredStrength(DataOvlReference dataOvlRef, int nIndex)
        {
            List <byte> requiredStrengthValueList = dataOvlRef.GetDataChunk(DataOvlReference.DataChunkName.REQ_STRENGTH_EQUIP).GetAsByteList();

            if (nIndex >= requiredStrengthValueList.Count)
            {
                return(0);
            }
            return(requiredStrengthValueList[nIndex]);
        }
示例#6
0
        public static int GetDefense(DataOvlReference dataOvlRef, int nIndex)
        {
            List <byte> defenseValueList = dataOvlRef.GetDataChunk(DataOvlReference.DataChunkName.DEFENSE_VALUES).GetAsByteList();

            if (nIndex >= defenseValueList.Count)
            {
                return(0);
            }
            return(defenseValueList[nIndex]);
        }
示例#7
0
        public static int GetAttack(DataOvlReference dataOvlRef, int nIndex)
        {
            List <byte> attackValueList = dataOvlRef.GetDataChunk(DataOvlReference.DataChunkName.ATTACK_VALUES).GetAsByteList();

            if (nIndex >= attackValueList.Count)
            {
                return(0);
            }
            return(attackValueList[nIndex]);
        }
示例#8
0
        public void InitializeLocationNames()
        {
            // get the data chunks that have the offsets to the strings in the data.ovl file, representing each location (most)
            DataChunk locationNameOffsetChunk = _dataRef.GetDataChunk(DataOvlReference.DataChunkName.LOCATION_NAME_INDEXES);

            // get the offsets
            List <ushort> locationOffsets = locationNameOffsetChunk.GetChunkAsUint16List();

            _locationNames = new List <string>(locationOffsets.Count + 1);

            // I happen to know that the underworld and overworld is [0], so let's add a placeholder
            _locationNames.Add("Overworld/Underworld");

            // grab each location string
            // it isn't the most efficient way, but it gets the job done
            foreach (ushort offset in locationOffsets)
            {
                _locationNames.Add(_dataRef.GetDataChunk(DataChunk.DataFormatType.SimpleString, string.Empty, offset, 20).GetChunkAsString().Replace("_", " "));
            }
        }
示例#9
0
        private List <DataOvlReference.Equipment> GetEquipmentList(int nTown)
        {
            if (nTown > 9)
            {
                return(new List <DataOvlReference.Equipment>());
            }

            List <byte> equipmentByteList = _dataOvlReference
                                            .GetDataChunk(DataOvlReference.DataChunkName.WEAPONS_SOLD_BY_MERCHANTS).GetAsByteList();
            const int nMaxItemsPerTown = 8;
            int       nStartIndex      = nTown * nMaxItemsPerTown;

            List <byte> equipmentByteListForTown            = equipmentByteList.GetRange(nStartIndex, nMaxItemsPerTown);
            List <DataOvlReference.Equipment> equipmentList = equipmentByteListForTown
                                                              .Select(b => (DataOvlReference.Equipment)b).ToList();

            equipmentList.Remove(DataOvlReference.Equipment.Nothing);
            return(equipmentList);
        }
示例#10
0
        public Weapons(DataOvlReference dataOvlRef, List <byte> gameStateByteArray) : base(dataOvlRef, gameStateByteArray)
        {
            _equipmentNames = dataOvlRef.GetDataChunk(DataOvlReference.DataChunkName.EQUIP_INDEXES).GetAsStringListFromIndexes();

            // we need to actually add shields because they can be equipped as weapons
            // but you should not expose shields twice in the UI
            AddWeapon(Weapon.WeaponTypeEnum.SmallShield, Weapon.WeaponTypeSpriteEnum.SmallShield, DataOvlReference.Equipment.SmallShield);
            AddWeapon(Weapon.WeaponTypeEnum.LargeShield, Weapon.WeaponTypeSpriteEnum.LargeShield, DataOvlReference.Equipment.LargeShield);
            AddWeapon(Weapon.WeaponTypeEnum.SpikedShield, Weapon.WeaponTypeSpriteEnum.SpikedShield, DataOvlReference.Equipment.SpikedShield);
            AddWeapon(Weapon.WeaponTypeEnum.MagicShield, Weapon.WeaponTypeSpriteEnum.MagicShield, DataOvlReference.Equipment.MagicShield);
            AddWeapon(Weapon.WeaponTypeEnum.JewelShield, Weapon.WeaponTypeSpriteEnum.JewelShield, DataOvlReference.Equipment.JewelShield);

            AddWeapon(Weapon.WeaponTypeEnum.Dagger, Weapon.WeaponTypeSpriteEnum.Dagger, DataOvlReference.Equipment.Dagger);
            AddWeapon(Weapon.WeaponTypeEnum.Sling, Weapon.WeaponTypeSpriteEnum.Sling, DataOvlReference.Equipment.Sling);
            AddWeapon(Weapon.WeaponTypeEnum.Club, Weapon.WeaponTypeSpriteEnum.Club, DataOvlReference.Equipment.Club);
            AddWeapon(Weapon.WeaponTypeEnum.FlamingOil, Weapon.WeaponTypeSpriteEnum.FlamingOil, DataOvlReference.Equipment.FlamingOil);
            AddWeapon(Weapon.WeaponTypeEnum.MainGauche, Weapon.WeaponTypeSpriteEnum.MainGauche, DataOvlReference.Equipment.MainGauche);
            AddWeapon(Weapon.WeaponTypeEnum.Spear, Weapon.WeaponTypeSpriteEnum.Spear, DataOvlReference.Equipment.Spear);
            AddWeapon(Weapon.WeaponTypeEnum.ThrowingAxe, Weapon.WeaponTypeSpriteEnum.ThrowingAxe, DataOvlReference.Equipment.ThrowingAxe);
            AddWeapon(Weapon.WeaponTypeEnum.ShortSword, Weapon.WeaponTypeSpriteEnum.ShortSword, DataOvlReference.Equipment.ShortSword);
            AddWeapon(Weapon.WeaponTypeEnum.Mace, Weapon.WeaponTypeSpriteEnum.Mace, DataOvlReference.Equipment.Mace);
            AddWeapon(Weapon.WeaponTypeEnum.MorningStar, Weapon.WeaponTypeSpriteEnum.MorningStar, DataOvlReference.Equipment.MorningStar);
            AddWeapon(Weapon.WeaponTypeEnum.Bow, Weapon.WeaponTypeSpriteEnum.Bow, DataOvlReference.Equipment.Bow);
            AddWeapon(Weapon.WeaponTypeEnum.Arrows, Weapon.WeaponTypeSpriteEnum.Arrows, DataOvlReference.Equipment.Arrows);
            AddWeapon(Weapon.WeaponTypeEnum.Crossbow, Weapon.WeaponTypeSpriteEnum.Crossbow, DataOvlReference.Equipment.Crossbow);
            AddWeapon(Weapon.WeaponTypeEnum.Quarrels, Weapon.WeaponTypeSpriteEnum.Quarrels, DataOvlReference.Equipment.Quarrels);
            AddWeapon(Weapon.WeaponTypeEnum.LongSword, Weapon.WeaponTypeSpriteEnum.LongSword, DataOvlReference.Equipment.LongSword);
            AddWeapon(Weapon.WeaponTypeEnum.TwoHHammer, Weapon.WeaponTypeSpriteEnum.TwoHHammer, DataOvlReference.Equipment.TwoHHammer);
            AddWeapon(Weapon.WeaponTypeEnum.TwoHAxe, Weapon.WeaponTypeSpriteEnum.TwoHAxe, DataOvlReference.Equipment.TwoHAxe);
            AddWeapon(Weapon.WeaponTypeEnum.TwoHSword, Weapon.WeaponTypeSpriteEnum.TwoHSword, DataOvlReference.Equipment.TwoHSword);
            AddWeapon(Weapon.WeaponTypeEnum.Halberd, Weapon.WeaponTypeSpriteEnum.Halberd, DataOvlReference.Equipment.Halberd);
            AddWeapon(Weapon.WeaponTypeEnum.SwordofChaos, Weapon.WeaponTypeSpriteEnum.SwordofChaos, DataOvlReference.Equipment.SwordofChaos);
            AddWeapon(Weapon.WeaponTypeEnum.MagicBow, Weapon.WeaponTypeSpriteEnum.MagicBow, DataOvlReference.Equipment.MagicBow);
            AddWeapon(Weapon.WeaponTypeEnum.SilverSword, Weapon.WeaponTypeSpriteEnum.SilverSword, DataOvlReference.Equipment.SilverSword);
            AddWeapon(Weapon.WeaponTypeEnum.MagicAxe, Weapon.WeaponTypeSpriteEnum.MagicAxe, DataOvlReference.Equipment.MagicAxe);
            AddWeapon(Weapon.WeaponTypeEnum.GlassSword, Weapon.WeaponTypeSpriteEnum.GlassSword, DataOvlReference.Equipment.GlassSword);
            AddWeapon(Weapon.WeaponTypeEnum.JeweledSword, Weapon.WeaponTypeSpriteEnum.JeweledSword, DataOvlReference.Equipment.JeweledSword);
            AddWeapon(Weapon.WeaponTypeEnum.MysticSword, Weapon.WeaponTypeSpriteEnum.MysticSword, DataOvlReference.Equipment.MysticSword);
        }
示例#11
0
        /// <summary>
        /// Construct a compressed word reference using the Data.OVL reference
        /// </summary>
        /// <param name="dataRef"></param>
        public CompressedWordReference(DataOvlReference dataRef)
        {
            _compressedWords = dataRef.GetDataChunk(DataOvlReference.DataChunkName.TALK_COMPRESSED_WORDS).GetChunkAsStringList();
            _compressedWords.PrintSomeStrings();

            // we are creating a lookup map because the indexes are not concurrent
            _compressWordLookupMap = new Dictionary <int, byte>(_compressedWords.Strs.Count);

            // this is kind of gross, but these define the index gaps in the lookup table
            // I have no idea why there are gaps, but alas, this works around them
            int i = 0;

            AddByteLookupMapping(1, 7, --i);
            AddByteLookupMapping(9, 27, --i);
            AddByteLookupMapping(29, 49, --i);
            AddByteLookupMapping(51, 64, --i);
            AddByteLookupMapping(66, 66, --i);
            AddByteLookupMapping(68, 69, --i);
            AddByteLookupMapping(71, 71, --i);
            i -= 4;
            AddByteLookupMapping(76, 129, i);
        }
示例#12
0
        public U5StringRef(DataOvlReference dataRef)
        {
            this._dataRef = dataRef;
            _strMap       = new Dictionary <Type, SomeStrings>();
            //SomeStrings strs = dataRef.GetDataChunk(DataOvlReference.DataChunkName.TRAVEL).GetChunkAsStringList();

            _strMap.Add(typeof(DataOvlReference.ChunkPhrasesConversation), dataRef.GetDataChunk(DataOvlReference.DataChunkName.PHRASES_CONVERSATION).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.TravelStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.TRAVEL).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.LocationStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.LOCATION_NAMES).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.WorldStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.WORLD).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.ChitChatStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.CHIT_CHAT).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.KeypressCommandsStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.KEYPRESS_COMMANDS).GetChunkAsStringList());
            //_strMap.Add(typeof(DataOvlReference.Vision1Strings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.VISION1).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.Vision2Strings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.VISION2).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.OpeningThingsStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.OPENING_THINGS_STUFF).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.KlimbingStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.KLIMBING).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.GetThingsStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.GET_THINGS).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.SpecialItemNamesStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.SPECIAL_ITEM_NAMES).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.WearUseItemStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.WEAR_USE_ITEM).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.ShardsStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.SHARDS).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.ShadowlordStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.WORDS_OF_POWER).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.PotionsStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.POTIONS).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.SpellStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.SPELLS).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.SpecialItemNames2Strings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.SPECIAL_ITEM_NAMES2).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.LongArmourString), dataRef.GetDataChunk(DataOvlReference.DataChunkName.LONG_ARMOUR).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.ShortArmourString), dataRef.GetDataChunk(DataOvlReference.DataChunkName.SHORT_ARMOUR).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.EquippingStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.EQUIPPING).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.ZstatsStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.ZSTATS).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.SleepTransportStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.SLEEP_TRANSPORT).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.ReagentStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.REAGENTS).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.ExclaimStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.EXCLAIMS).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.ThingsIFindStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.THINGS_I_FIND).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.ShoppeKeeperSellingStrings), dataRef.GetDataChunk(DataOvlReference.DataChunkName.SHOPPE_KEEPER_SELLING).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.ShoppeKeeperBlacksmithPositiveExclamation), dataRef.GetDataChunk(DataOvlReference.DataChunkName.SHOPPE_KEEPER_BLACKSMITH_POS_EXCLAIM).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.ShoppeKeeperBlacksmithHello), dataRef.GetDataChunk(DataOvlReference.DataChunkName.SHOPPE_KEEPER_BLACKSMITH_HELLO).GetChunkAsStringList());
            _strMap.Add(typeof(DataOvlReference.ShoppeKeeperBlacksmithWeHave), dataRef.GetDataChunk(DataOvlReference.DataChunkName.SHOPPE_KEEPER_BLACKSMITH_WE_HAVE).GetChunkAsStringList());
        }
示例#13
0
 private void InitializePrices(DataOvlReference dataOvlRef)
 {
     BasePrice = dataOvlRef.GetDataChunk(DataOvlReference.DataChunkName.EQUIPMENT_BASE_PRICE).GetChunkAsUint16List()[
         (int)SpecificEquipment];
 }
示例#14
0
        public static string GetEquipmentString(DataOvlReference dataOvlRef, int nString)
        {
            List <string> equipmentNames = dataOvlRef.GetDataChunk(DataOvlReference.DataChunkName.EQUIP_INDEXES).GetAsStringListFromIndexes();

            return(nString == 0xFF ? " " : equipmentNames[nString]);
        }
示例#15
0
 /// <summary>
 /// Build references for moon phases and anything that they may affects
 /// </summary>
 /// <param name="dataOvlReference"></param>
 public MoonPhaseReferences(DataOvlReference dataOvlReference)
 {
     this._moonPhaseChunk = dataOvlReference.GetDataChunk(DataOvlReference.DataChunkName.MOON_PHASES);
 }