Suggestions for doing scripts for RPG items

I’m thinking of creating a script that has every single possible effect on it.

Needless to say that seems unnecessarily complex.

So maybe make a script that makes the item and attaches different effect scripts?

If there are any good links to tutorials I would really appreciate it.

Thanks!

I’d do something like this.

Have an “ItemEffect” abstract base class with methods “Activate” “Tick” and “Deactivate”

Create child classes that inherit “ItemEffect” and override those methods so they can all do different things.

Your Items could then have a script with a List of ItemEffects and you can add each of the effects you want the item to have.
The item script could activate the effects whenever you want e.g. Weapons activate on hit, potions activate when drunk
It could also loop through the ItemEffects and call the Tick() method in a coroutine.

Each item would work differently, e.g. you might have an amulet item with a “PassiveHealingEffect” that adds 1hp to the player’s health every Tick, and a potion with a “BerserkerEffect” that increases strength when Activate is called, then reduces HP when Deactivate is called.

There are a lot of different ways to do it. It really depends on the type of effects you want your items to have, but abstracting it out to those 3 basic methods should cover quite a few bases.

1 Like