VetRanch allows the player to purchase items. These can take the form of animals, decor, buildings, or even some extra land. Persistent data is becoming a growing trend in flash games, giving the player an in-game currency and allowing them the ability to purchase items and have them still there when they come back to play again the next day. It’s little things like this that increase the fun and replayability of the game.
The store in VetRanch offers the player extra experience when they purchase the item, this is one of the ways that the player can help raise their level in the game.
To trigger the building of an item in the store, we use the following IsoMap function:
setCurrentBuilding(ref:int, type:String, cost:int)
The reference is the unique id found in the itemlist.xml file talked about earlier, the cost is obviously how much should be deducted for building the item once it has succesfully been built. The type variable is what we’re interested in, this is what we use to determine how the item should behave.
For instance, if we set the type to “item” then it will behave exactly like a static item as we would expect. However, if we set the type to be “zoo” then it will take on the characteristics of an animal.
Placing an Item in the Store
Once we have inserted a new item into the game, we need a way to add it into the store so it can be purchased and placed on the players map.
The store currently loads the decoration information from the storedecorations.xml, which has a typical format of:
<item fl=’3′ f=’5′ p=’500′ i=’isopics/statue1.jpg’ uid=’31′ box=’0′ xp=’1′ pt=” t1=’0′ t2=’0′ >Statue 1</item>
<item fl=’10′ f=’5′ p=’500′ i=’isopics/statue2.jpg’ uid=’32′ box=’0′ xp=’1′ pt=” t1=’0′ t2=’0′ >Statue 2</item>
<item fl=’1′ f=’0′ p=’10000′ i=’isopics/pool.jpg’ uid=’30′ box=’0′ xp=’1′ pt=” t1=’0′ t2=’0′ >Pool</item>
<item fl=’10′ f=’25′ p=’250000′ i=’isopics/mediumhouse.jpg’ uid=’43′ box=’0′ xp=’1′ pt=” t1=’0′ t2=’0′ >Medium House</item>
The two important attributes we’re interested in here are the “uid” field, which links directly back to the uid specified in the itemlist.xml file earlier, and the “i” attribute which links to a thumbnail image of our statue. “p” is also of importance, and refers to the price that the item will be sold for.
To add in our large statue, we could place something along these lines in the .xml file:
<item fl=’3′ f=’5′ p=’500′ i=’our_statue.jpg’ uid=’4′ box=’0′ xp=’1′ pt=” t1=’0′ t2=’0′ >Our Statue</item>
Now our item should appear in the decoration tab in the store, and can be purchased and placed into the game with no additional compilation of the main game needed.
The game also comes with a clothes store to give the player compete customisation over their appearance in the game. Feel like dressing your character in the style of a certain adventurous archaeologist? No problem.
By letting the player dress their character any way they please gives them the much needed ability to express themselves and this helps them to truly get hooked into the game. All of the characters clothing can be externally loaded, this means we can add hundreds of costumes into the game, giving the player no end to the possibile combinations to choose from.
The clothing store is fairly self-contained, and can be shown or hidden by calling the following two functions Main.as.
If you’re wanting to play around with how the clothing store works, open up AvatarShop.as, this is also where we can set the prices of the various hair styles, tops, bottoms and shoes along with various other details.