Skip to main content

Implementation of Key Features

1. Battle Chat

Related topic:

Instant chat

1.1 Gerenate chat channel ID

In the battle, each player joins 2 channels,palyers in the channel "All" can chat with all the players in the battle. Team channel "GREEN" or "RED" is used for chatting with players in the same team.

  • The ChatChannelId for the "ALL" channel is simply the BattleSessionId (for example: "8031bde8-190e-4776-881b-e5ef8a6545f9").
  • The ChatChannelId for the "RED" channel can use "8031bde8-190e-4776-881b-e5ef8a6545f9#RED".
  • The ChatChannelId for the "GREEN" channel can use "8031bde8-190e-4776-881b-e5ef8a6545f9#GREEN".

1.2 Join Chat in the Client

Players can join the specific channel using ChatChannelId

Join the channel "All" all

Join the channel "RED" or "GREEN": team

2. Friends & Blocklist

Pingpong Shooter provides a friend list and blocklist.

Get Friend List is called in WidgetBlueprint'/Game/PGOS/UI/Friend/FriendList.FriendList'

Get Blocklist is also called in WidgetBlueprint'/Game/PGOS/UI/Friend/FriendList.FriendList'

FriendList

getblocklist_bp

Developers can also check a player's friends and blocklist in the PGOS web portal.

friend_webprotal

Update Player Presence

it is called in WidgetBlueprint'/Game/PGOS/UI/Friend/FriendList.FriendList'

presence_16179532613084

3. Lobby

3.1 Set a Lobby Configuration

Pingpong Shooter allows two types of lobbies to be created. Each lobby type corresponds to a Lobby Configuration on the PGOS web portal.

Lobby TypeLobby Configuration Name
Lobby with 5v5 Game Modelobby_dota
Lobby with 1v1 Game Modesoloracing

Using Lobby with 1v1 Game Mode as an example, the lobby configuration details are as follows:

1610075884856

3.2 Creating Lobby

Blueprint reference path:

WidgetBlueprint'/Game/PGOS/UI/Lobby/CreateLobbyUI.CreateLobbyUI'

Generate the lobby configuration name:

1610076809224

Create the lobby with the lobby configuration name and lobby data:

1610076863770

3.3 Lobby Data

Pingpong Shooter uses lobby data to store the Game Mode which is displayed in both the lobby list and the lobby creation page.

1610077045133

1610077066399

Using the 5v5 Game Mode as an example:

  • Save the Game Mode when creating the lobby

1610077170630

  • Input the lobby data with Key-Value pairs

    1610077210362

4. Voice Chat

4.1 Join a Voice Channel

All the players in the battle joined a same positional voice channel. Used battle-session-id as the voice channel id, and different teams have different team id.

Voice_16138119794879

4.2 World Channel

Open/close the world channel.

Voice_16138160245768

4.3 Leave the Voice Channel

When the player leaves the battle, they will also leave the voice channel.

Voice_16138120019401

5. Simple Battle Season

5.1 Virtual Servers

Virtual currencies rewarded to players for login and battle result calculation are implemented by using virtual servers. You must create virtual servers and Virtual currencies on the web portal to implement this function.

image-20210625174122771

image-20210818205615954

5.2 Environment Variables

Set required environment variables for economy_battle_season virtual servers.

  • login_reward_currency_amount: The amount of currency reward to players when the player logs in.

  • currency_code: Defined by developers.

  • sign_up_currency_amount: The amount of currency required to join the season.

  • grant_currency_amount: The amount of currency that the player will be rewarded after winning the game.

image-20210818205715428

6. Player Data Templates

Set the data for needed for the battle season in the player data template.

  • battle_pass_signed: Used to indicate whether the player has joined the season. 1 means player has joined the season. Other values mean the player has not.
  • last_event_award_time_stamp: The last login timestamp for the player.
  • level
  • level_exp
  • hit_point
  • attack_point
  • helmet
  • clothing
  • weapon
  • currency_buff
  • level_buff

image-20210818210031629

6.1 Title Region Config Data

Set the data for needed for the battle season in the title region config data.

  • sign_up_battle_season_gold: The number of gold coins required to join the battle season.
  • login_reward_gold: The number of gold coins to reward players who log in within the specified time frame.
  • battle_season_player_num: The total number of players signed into the season.

image-20210419103635952

6.2 Set a Matchmaking Rule

In addition, a matchmaking rule for the battle season must be created to stipulate that only players who have joined the season can be matched in a battle. The rule filters players using the player's "battle_pass_signed" value.

Virtual_Server_4

6.3 Sample

How to get season information in the sample client:

Virtual_Server_5

Season data are saved in "Func Result", which is JSON format.

How to set the battle on the sample DS:

// PGOSBattleGameMode.cpp
UPgosServerAPIInvokeVirtualServer* Proxy = UPgosServerAPIInvokeVirtualServer::InvokeVirtualServer(
CurrentBattleSession.battle_session_id,
TEXT("sample_battle_report_process"),
TEXT("battle_report_process"),
json_args);
Proxy->OnSuccess.AddDynamic(this, &APGOSBattleGameMode::OnInvokeVirtualServerCallback);
Proxy->OnFailure.AddDynamic(this, &APGOSBattleGameMode::OnInvokeVirtualServerCallback);
Proxy->Activate();

7. Economy

7.1 Balances

7.1.1 Add Currency

On the Portal, go to Economy -> Currencies and click "Add Virtual Currency" to create a currency.

Economy_16244998422494

Here, Currency Icon indicates the path of the in-game currency icon resource. An example is the GetCurrencyIcon display in the Sample's Content/PGOS/Util path.

Blueprint'/Game/PGOS/Util/Utils.Utils'

Economy_16245045665809

7.1.2 Display Currency

After creating a currency, the Sample will acquire Player Balances and filters the currencies to use by Currency Code. The valid currencies are shown in the upper-right of the Store and Inventory pages.

Economy_16244995712019

Display and filter Currency's blueprint code location:

WidgetBlueprint'/Game/PGOS/UI/Economy/BaseEconomyUI.BaseEconomyUI'

Economy_16245090063947

7.2 Store

7.2.1 Create InGameItem

On the Portal, go to Economy -> In-game Items and click "Add Normal Item" to create scrolls and gear for this Sample. Then, go to the Bundle and Container tabs to create containers and bundles.

Economy_16245093746534

An example of InGameItem creation is provided below:

Economy_162450937465dddd

Pay special attention to the following fields:

  • Default Prices: Set the default price of the item.
  • Valid Duration: The validity time of the item instance after it is placed in the player inventory.
  • Consumer Action: Set the virtual server function to call when a player consumes this item instance.

7.2.2 Create Container/Bundle

Economy_16245101271960

Pay special attention to the following fields:

  • Content: Set the content of the Container/Bundle by adding previously defined InGameItems and setting their quantities.

7.2.3 Add Store

On the Portal, go to the Economy -> Stores page.Click "Add Store" to add a store and get the Store ID. Use the Store ID in the game to call the GetStore API of the PGOS SDK Client and obtain the store information.

Economy_16245108408008

7.2.4 Add Item

Click an added store in the store list to go to the store details page.

Economy_16245150473102

Click "Add Item" to go to the item selection page. Select to add a normal item/bundle/container created in the previous step.

Economy_16245153795442

By default, each store has an "All" category. Developers can independently edit the categories in store as needed.

Economy_16245163977652

7.2.5 Display Store

Store's blueprint code location in the Sample:

WidgetBlueprint'/Game/PGOS/UI/Economy/StoreUI.StoreUI'

Economy_16245174301808

7.3 Inventory

The inventory stores all the item instances of a player. Currently, all item instances in this Sample are obtained by purchasing from the store.

7.3.1 Purchase Item

First, buy 10 items from the store and add them to your inventory.

Economy_16245174301808

After purchase, the number of item instances in the inventory will increase correspondingly.

Economy_16245181447050

7.3.2 Display Inventory

Open your inventory to view the new item instances just added.

Economy_16245193069726

Currently, inventory categories are displayed by filtering specific kv values of InGameItem tags.

Economy_16245242601138

7.3.3 Use Item Instance

The sample currently provides two types of item instances: gear and buff. These item instances are used by calling virtual servers and adding the relevant Instance ID to PlayerData.

Economy_16245197936416

Then, when the player enters a battle, the SDK will acquire the corresponding field values from PlayerData and use the DS Server API to obtain specific property information.

// PGOSSample/DataTasks/BattlePlayerDataTask.cpp
IPgosSDKCpp::Get().GetServerEconomyAPI()->GetPlayerInventory(
player.Key, Ids,
[this, &res, SuspendedEvent](const FPgosResult& Error, const FServerGetPlayerInventoryResult* Result)
{
res = res && OnFetchPlayerEquipmentIntanceCallback(Error, Result);
SuspendedEvent->Trigger();
});

The item instance information is displayed on the UI and used to calculate damage inflicted and received during the battle.

Economy_16245206896935