A downloadable tool

Download NowName your own price

A simple plugin that let's you change the items in the shop menu dynamically! Simply create placeholder items with unique tags, add them to your shop, and assign the conversion through C# events, then call the apply function, and any shop can have items that are dynamically placed based on your preferences!

ショップメニューのアイテムを動的に変更できるシンプルなプラグイン!一意のタグを持つプレースホルダーアイテムを作成し、ショップに追加。C#イベントで変換を割り当て、適用関数を呼び出すだけで、任意のショップに好みに基づいて動的に配置されるアイテムを実現できます!

Addon Usage | アドオンの使用

EN

First, download the plugin and extract it.

Next, add the script to any event that can open a shop while it exists (a shopkeeper, for example). It's preferable to keep this script assigned per shop rather than trying to use it in a common event, but your mileage may vary.

It's recommended to toggle a switch ON just before opening your shop event and then turning it off when the shop interface is closed. This is because we'll be adding a parallel event to the shopkeeper that only runs while the switch you defined is ON.

In that new parallel event, add the C# event "ReplaceShopItemsInLayout".

Without any item replacements assigned, nothing will happen. We first need to create item replacements and item ids.

In the Item database, each item that you want to appear in the shop should have a unique tag:

$item_id(Y)

Replace Y with a unique number just for that item. Don't give the number to different items.

When you added the tag to the items in the database that you care about, next, create entirely new items acting as your placeholder items.

Each placeholder item should have a unique tag in their tags:

$placeholder_id(X)

Replace X with a unique number, in a similar way to the normal items.

Next, edit the shopkeeper NPC you have the script in, and change the contents of their store to sell your placeholder items.

Since these placeholder items won't be seen by the player, or let alone be purchasable, it's a good idea to create multiple placeholder items with unique purposes for your shop, for example, making a placeholder item that's dedicated to being replaced by rare items in a rogue-like for example. The more items you have in a shop that you want dynamically replaced, the more item placeholders you'll need to create, even if what you replace them by will be similar. Using the same placeholder item in the store will lead to duplicate items in the store.

Finally, depending on how your managing your dynamic shop, you might want to set the dynamic shop contents once, and not every time you visit the shop, but that's entirely up to you.

For each placeholder item, you will run a C# event "AddReplacement", with X being the placeholder item ID, Y being the replacement item ID, and Z being the item price you want the seller to sell it at. If you keep Z at 0, the price will be automatically adjusted to the one in the database.

And that's it! How you call the AddReplacement function is entirely up to you, as it is your game.

Theory Section: So long as you're running the "ReplaceShopItemsInLayout" code in a parallel sheet, any time a "AddReplacement" event is added, it should dynamically replace the placeholder items in the store. In theory, it might be possible to add placeholder IDs onto real items and replace existing items in the shop in real time, but you'll probably need to have a lot of planning for such a scenario.

JP

まず、プラグインをダウンロードして解凍してください。

次に、ショップが存在している間、ショップを開くことができるイベント(例:店主)にこのスクリプトを追加します。共通イベントで使用しようとするよりも、ショップごとにこのスクリプトを割り当てたままにしておく方が望ましいですが、状況によって異なる場合があります。

ショップイベントを開く直前にスイッチをONにし、ショップインターフェースを閉じた際にOFFにすることを推奨します。これは、定義したスイッチがONの間にのみ動作する並行イベントをショップキーパーに追加するためです。

その新しい並列イベントに、C# イベント「ReplaceShopItemsInLayout」を追加してください。

アイテム置換が割り当てられていない場合、何も起こりません。まずアイテム置換とアイテムIDを作成する必要があります。

アイテムデータベースでは、ショップに表示させたい各アイテムには固有のタグが必要です:

$item_id(Y) 

Yをそのアイテム専用の固有番号に置き換えてください。異なるアイテムに同じ番号を割り当てないでください。

データベース内の対象アイテムにタグを追加したら、次にプレースホルダーとして機能する全く新しいアイテムを作成します。

各プレースホルダー項目は、タグに固有のタグを持つ必要があります:

$placeholder_id(X)

Xを固有の番号に置き換えてください。通常のアイテムと同様の方法で。

次に、スクリプトを配置した店主NPCを編集し、その店の商品内容をプレースホルダーアイテムに変更してください。

これらのプレースホルダーアイテムはプレイヤーに表示されず、ましてや購入可能なものでもないため、ショップ用に複数のプレースホルダーアイテムを作成し、それぞれに固有の目的を持たせるのが良い方法です。例えば、ローグライクゲームでレアアイテムと置き換える専用のプレースホルダーアイテムを作成するといった具合です。ショップ内で動的に置換したいアイテムが増えるほど、たとえ置換対象が類似品であっても、作成すべきアイテムプレースホルダーの数は増加します。同一のプレースホルダーアイテムを店内で使用すると、商品リストに重複アイテムが生じます。

最後に、動的ショップの管理方法によっては、ショップにアクセスするたびにではなく、一度だけ動的ショップの内容を設定したい場合もあるでしょう。ただし、それは完全にあなた次第です。

各プレースホルダーアイテムに対して、C#イベント「AddReplacement」を実行します。XはプレースホルダーアイテムID、Yは置換アイテムID、Zは売り手に設定してほしいアイテム価格です。Zを0のままにすると、価格はデータベース内の価格に自動的に調整されます。

以上です!AddReplacement関数の呼び出し方法は完全にあなた次第です。何しろあなたのゲームですから。

理論セクション:「ReplaceShopItemsInLayout」コードを並列シートで実行している限り、「AddReplacement」イベントが追加されるたびに、店舗内のプレースホルダーアイテムが動的に置き換えられるはずです。理論上は、実際のアイテムにプレースホルダーIDを追加し、店舗内の既存アイテムをリアルタイムで置き換えることも可能かもしれませんが、そのようなシナリオにはおそらく綿密な計画が必要になるでしょう。


Download

Download NowName your own price

Click download now to get access to the following files:

ShopItemReplacer.zip 2.1 kB

Development log

Leave a comment

Log in with itch.io to leave a comment.