Shop system and upgrades

Godot Version

4.5.1

Question

Hello! I’m making a space shooter (shmup) with a shop for new weapons and upgrades. How do I do that? My problem is: 1. Making a shop that can read/write values of weapons. Like if they’re purchased, equipped, or upgraded. 2. Using that weapon in the game with the upgrades.

This is what I’m thinking so far:

-Create an autoload node with every weapon in the game. The weapon will have the class PlayerWeapon. It will have some exported variables such as cost, owned, equipped, etc.

-Under each weapon, I’ll add a node with class WeaponSpawner. This will be a Node3D with code that will spawn the bullet.

-Under each weapon, I will have nodes with class WeaponUpgrade. They will also have exported variables like cost.

-Shop menu will run a “for each” loop to cycle through the weapons and add them to a list.

-Run another loop in shop menu to add the upgrades.

-For gameplay, at the beginning of loading the player, make the WeaponSpawner for the selected weapon into a PackedScene.

-The bullet will spawn with the upgrades attached as nodes. Have code in the bullet itself to run through each child and apply the upgrade.

I’m a bit lost because all of this is daunting. Am I on the right track? Is there an easier way?

Should I simplify the whole thing to do an easier system? For example, knee pushups come before real pushups. So if there’s a way to do an easier version of this, I’d rather do that, and try a full implementation on my next game.

I’m also worried about the CPU cost of doing all this - specifically adding nodes under each player bullet to apply upgrades. I try to make my games accessible for as many people as possible, but my last game was a bit too rough on older CPU’s. I’m trying to optimize wherever I can, and this feels like it would be a big calculation for a game with lots of bullets and enemies.

For context, I’ve made several smaller games already with menus, options, cutscenes, etc. I’m still at beginner level but I’m trying to challenge myself. This is the next step in my learning for me, but it feels like climbing a mountain.

You could consider using Resources instead of Nodes to hold the data about the weapons. They have less overhead.

2 Likes

I have never done it but it seems straight forward.

Each player, or game save, has an additional saved file of ‘available upgrades’. A resource or json or whatever suits you.

When the game starts, you either attach those upgrades or make them available, however your game works. No different that saving their health really and resetting that on a game load.

The shop works in just the same way, they have 10 tokens they earned, again stored in the save file, when they spend them on an upgrade you reduce the tokens (like health) and add the upgrade to their ‘available upgrades’.

Now the system for doing the upgrades depends on how you are implementing them. A bullet, say, has a damage_applied, a trail effect, a sprite perhaps for the bullet itself, and an area of effect. All your upgrades do is change these numbers.

It can get more complicated, but that is it in essence. No additional nodes needed.

Quick edit:
Actually if you save those numbers, you don’t even need to save the available upgrades, unless the upgrades are optional or the player can swap between them, like this round I want fire bullets, next round remove fire bullets and use ice bullets etc.

Last edit I promise:
Actually I have done that (not the shop) many times and it much easier than you think. The shop, I don’t know, but it does feel like it is straight forward as I described it. When I did it you had three cards appear and you chose one, like health boost, speed boost or damage boost for instance.

Will do, thank you. I haven’t used resources before but this will be a good time to learn it.

Got it, so an upgrade just changes a value. But a further question is - how do I set up a shop that can look for possible upgrades? For example, my blaster weapon can have an ice effect, increased damage, and faster fire rate. These are finite upgrades you buy once. It’s a little different than getting random cards, because those are infinite. A resource can store values but I don’t know how to throw all of them into a shop.