Sign In Register

How can we help you today?

Start a new topic

VirtualGoods custom properties per player instance.

Dear GameSparks community,


My team is evaluating GameSparks for our GPaaS, and some of the features we're eager to see supported natively are virtual goods and inventory management.  GameSparks looks to have rich support in this area, but we can't quite determine how VirtualGoods can have custom properties per player instance.


For example, we'd like VirtualGoodA to have a custom property of "Level".  As players upgrade their VirtualGoodA, this property would reflect an appropriate value for each individual player.


We're not sure if we would implement this using Properties/PropertySets for the VirtualGood (whether those values are static)?  Or Tags on the VirtualGood?  Or something else entirely (e.g., Spark.SetScriptData()).  The documentation around these areas aren't as comprehensive as we'd hoped.


If someone could provide some clarity for how we could accomplish this with GameSparks, we'd be hugely obliged.


Thank you!


1 person has this question

 Hi John,


Segmentation should work for this. With it you would be able to configure a Virtual Good for each type of good and then segment it's configuration by level. So you could have "Sword" and then segment it's configuration by level. Then when the Virtual Good is retrieved by a player the configuration returned is relevant to the segment that they are currently on. Does that make sense ? We have a guide on how to segment players on registration. You can find it here. This would be useful for adding new players to a "level01" segment or something similar.


Regards,

Liam

Sorry I don't understand how segments can be used to allow a user to upgrade individual items.

Let's say I have multiple virtual goods...

Sword, shield, shoes, powerBoost, barracks, warrior, etc...

all of those items have a varied amount of upgrades available to them. 5, 15, 20, etc...

All of these items the user also may have a varied count of. For example they might have 5 "powerBoost" items or "barracks" which could be at different levels.

Those upgrades are purchased by the user, so how do I keep track of each separate item having been upgrade by each separate user?

The linked tutorial shows setting a global value for a user :

 "segments": {"faction":"Viking"},

But what I need ( and I assume many others ), is to track the upgrading of a specific item, not just globally set all items or items of that type for that user to be leveled up. Cuz if I have a base setup with 4 of the same item, I need to maintain which of those items have been upgraded to which level. And ideally be able to use segments ( or something in the admin ) to define the price of these different prices of each level of this item


thanks!,

Gareth

Hi Gareth,


I think for your use case it may be worth looking into Segmented Virtual Goods. This will allow you to have a "base" configured virtual good item with multiple configured "levels" that the player can purchase. If you haven't already seen, we have a great tutorial on Saving and Loading Data - Player Inventory and Item Management from Admin here. This will allow you to create and manage a players inventory through the use of a meta collection, it will also allow you to add items to the meta collection through an easy to use Admin Screen. 

The flow for tying something this all together might look something like this.


Configure virtual good and add segment queries -> Player chooses the segmented virtual good "level" they want for their item -> In the BuyVirtualGoodsResponse get the items shortCode, consume the item and add it to the Inventory metaCollection with its configured values.


Does this seem like it could work for your use case?


Thanks,

Ronan



Hey Ronan,


I have been looking through the Segmented Virtual Goods, but I don't see quite how to set the user to be holding a VirtualGood at a certain segment on a per-item basis. I only see how to use segments on a global scale for the player. Can you demonstrate this concept somehow please?


thanks

Hi Gareth,


Could you possibly give me some more information on how you are storing and saving the players inventory, is it in a document or in the virtual goods array, or some other method? When you say "purchase" a new item do you mean each upgrade is a monetary transaction from a Store?

I'm just trying to gather as much information as possible on your use case to better help with a solution.


Thanks,

Ronan

yes so... the store has a certain amount of items. and each item has a certain amount of upgrades which are purchased.

Buy the sword, use the sword, upgrade the sword, repeat upgrading through a premade list of available upgrade levels.

Right now all my code is using manual tracking of these concepts, without any VirtualGoods at all. I'm trying to upgrade it to use GameSparks features instead.

Hi Gareth,


You will need a virtual good for each purchasable item as they need to be assigned their own Product ID. For your use case I think it would be best to make use of Properties and Property Sets. You can find more about how to use both here.


I will outline two different approaches on how you might configure your Properties, which one you might use is down to personal preference. 


First

-Create base Virtual Good item "Sword".

-Create Virtual Good item for each purchasable upgrade for "Sword".

-Create different Properties for each available upgrade.

-Bundle all Properties together into a Property set and attach the Property Set to base "Sword" item Virtual Good.


Second

-Create base Virtual Good item "Sword".

-Create Virtual Good item for each purchasable upgrade for "Sword".

-Create different Properties for each available upgrade and bundle them into property sets by upgrade.

-Attach the relevant property set to the individual upgrade on the upgrade Virtual good.


So one approach will have all properties on the base item and the other will have the properties added to the individual Virtual Good upgrade item.

Following from this you might access the Property Value of the Virtual good purchased in the buyVirtualGoodsResponse and update the player inventory with the added value you have defined for each Upgrade, through their corresponding property.


Does this seem like it would work for your Use Case?


Thanks,

Ronan






I'm walking through the steps now...

but I'm not seeing a way to hold values for these properties for each VG.

so let's say for Sword

each level needs values for Speed, Strength, Length, and Weight

none of these value combinations are going to repeat into other VG's.


So does this mean I'd make..

VG: Sword_1, Sword_2, Sword_2, Sword_3

Property: Sword_1, Sword_2, Sword_2, Sword_3

PropertySet: Sword_1, Sword_2, Sword_2, Sword_3


because the only place I can see to set values is in a "properties" item.

so each PropertySet would have just one Property in it... and so if I have items with 60 levels of updates, I'd have 60 of each VG/PS/P for each game item? So for my game I'd end up with hundreds of each of those 3 item types. And nothing in the data really linking them together as upgrades of each other... just my code would have to track them by using a keyword pattern. right?

Hi Gareth,


I think there still may be some confusion on my part from how your upgrade system is aimed to be implemented. The way I have suggested it would work for you is if you have Individual Items e.g individual types of sword i.e 

Small-Sword, Long-Sword which would each have different Level upgrades that increase different values for each sword. E.g Small-Sword Level 1 upgrade would increase its Stats by +2,+3,+1,+4 respectively and Long-Sword Level 1 upgrade Increases its stats differently by +3,+4,+1,+5 and so on.


For this use case you would configure the following:


Configure your base Virtual Good, e.g SmallSword, LongSword

Configure your Virtual Good upgrade. e.g SmallSwordLevel1, LongSwordLevel1, SmallSwordLevel2, LongSwordLevel2, etc.

Configure the properties for SmallSwordLevel1 e.g Strength, Speed, Weight, Length and LongSwordLevel1 Strength, Speed, Weight, Length

Add the SmallSword properties to a Property Set for SmallSwordLevel1 and attach them to the SmallSwordLevel1 Virtual Good.

Add the LongSword properties to a Property Set for LongswordLevel1 and attach them to the LongSwordLevel1 Virtual Good.


In case I have misunderstood your upgrade system, another way this could be implemented if this is not how you intended on implementing your upgrade system is if:


You have Individual Items e.g  Small-Sword, Long-Sword would each have different Level upgrades but each upgrade increases the level on each sword the same, for example all stats for level1 upgrade are increased the same across the different types of sword. E.g SmallSword and LongSword Level 1 upgrade increase Stats by 10%. For this you would configure a SwordLevel1 upgrade Virtual Good and when the item is bought increase the Swords stats by the level1 upgrade of 10% and this would be universal for swords across the board. To achieve this you could store the players items and their stats in a runtimecollection and update them when the SwordLevel1 Virtual Good is purchased by accessing it properties which will tell the item what to incease its stats by. 



An example Flow.


Create the different base sword Virtual Good item i.e Smallsword, LongSword.

Create each purchasable upgrade Virtual Good i.e SwordLevel1, SwordLevel2.

Create new properties for the SmallSword1 upgrade i.e stats +10% or what ever you deem necessary for a level 1 item.

Add these properties to a SwordLevel1 Property set that you have created and attach them to the SwordLevel1 Virtual Good.

Increase the stats of the weapon the player chooses to add their level one upgrade to i.e add swordLevel1 upgrade to SmallSword or LongSword and increase stats by 10%.


Note:

This would need to be configured for each type of VG i.e SwordLevel1 upgrade increase all swords by the same amount. ShieldLevel1 upgrades increase all shields by the same amount. For Individual by item stat increases the first approach may be suited better. 


I hope I've explained this thoroughly.

Do you think either of these approaches would work for your use case?


Thanks,

Ronan







the different item types would not have same upgrade amounts per level

Sword, Shield, Shoes, Home, Barracks, etc...

all have different amounts of levels and different changes per level.

Think of how every city building/battle game for phones work. Star Wars Commander, Simpsons, etc...

You buy an item, put it in your map, upgrade that specific instance of that item. And keep doing more of that to the same item instance and others

*Simpsons Tapped Out, I mean specifically

does that not exist? It seems like a pretty common thing in games... vast inventories with individual specific values on upgrade levels.

Hi Gareth Pursehouse,


Any item or upgrade that may be purchased from a third party store will need to have its own Virtual Good item configured as it needs its own product-ID. One way around this would be to allow users to purchase currency to buy and upgrade individual items with the currency

Each item could be configured in a Meta Collection of "Items" and each upgrade and value could be defined in another Metacollection called "Upgrades". For each player I would give them a document for every weapon or item they acquire and store it in a Runtime collection called "playerInventory". This document would store the "item type" its stats, the "players id" for referencing it and also store a unique id for the individual item so the player can access the exact item they want to upgrade.

E.g Player has sword level 1, sword level 3 and sword level 2 in their inventory collection. The player wants to upgrade their sword level 1 so they send an event that requests the specific item they want from the Player inventory collection and using the item name, the player id, and the unique weapon id they will be able to pull the exact document they want. The player then requests the upgrade properties from the upgrade collection and through some custom logic will upgrade the specific item from the player inventory. This will allow you to maintain and persist different items for upgrade and purchase through the use of a "currency" purchased by the player from a third party store. This tutorial here is particularly useful to this example solution.


Regards,

Ronan

Hey, is there a more direct way to do this yet? Collections are deprecated now. And nothing in my plans involved buying 3rd party items. The goal is all intended to be internal functionality.


What I need is literally to have upgrade versions of a virtual item. And there would be hundreds of these levels across the different items. And each level for each item is not a re-usable parameter. Think exactly the same as how Clash of Clans items are separated and leveled up individually.


So "property sets" would be a borderline impossible pattern to use. Because it would mean 500 virtual goods, 500 properties and 500 property sets.... with no built in hierarchy structure between them. Each level of each virtual good needs its own price and separate specs. So if there was a concept of a virtual good having direct levels with different params per level that would be ideal. So what sort of setup can handle that in the current gamesparks system?


Thanks!

Login to post a comment