How to create Item suffix prefix system,. (in general)

I have Item.cs with weapon.cs and equip.cs and i don’t know where should i start.
Should i make class enchantment.cs with i don’t even know what in it, or just …
ehm i mean, could anyone poke me in right direction please ? :- )

There is simply no right answer to this. :slight_smile:

If you have something specific in mind, then some (subjective) advice can be offered. Otherwise, just start adding code in what seems to be a reasonable way. You will find your own style over time. Don’t be afraid to make mistakes - they are the most powerful way to learn, after all.

What are you trying to do? I would suggest starting by writing a list of requirements - things that your system has to be able to support.
“The player can pick up items.”
“Some items are weapons. Weapons can be equipped, and then used to attack.”
“Some items are consumables. Consumables can be consumed, which does to the player.”
“Items can be Enchanted. This does to the Item.”

Once you have all of that, you can ask specific questions about the ones you’re having trouble designing or implementing in code.

1 Like

i can pickup anything and equip it and attack, i can eat or drink potions or buff the player .
i just have no idea how to do the enchantment,. that’s why in title it says “in general”.

most intriguingly, that’s the reason why i am asking. you too didn’t wrote anything at least tiny specific, if it should be whatever. : -)

… i think she didn’t took anything from it in that situation. but moments later he pointed her to to mad hatter, didn’t he?

I think it may help if the question was a little clearer.

Are you asking how to name the file, or the ‘enchantment’ itself? Or are you asking how to code an enchantment? Also, what is an enchantment exactly- does it add power, increase attack frequency, range?

In truth, I don’t recall for sure but I think that is correct. :slight_smile:

yes, so … I tried a few things around but none of that seems generic enough.
so i imagine a sword can have one of those infamous “of might” for example.
which should just (in theory) say Player.Might += enchant[0].might,…but that is just too over complex
because if a leather armor should be “of cold resist” and it should Player.ColdResits += enchant[1].coldResist that’s just way too much.
well that is the dumb way.
i just can’t think of any other dumb way. i don’t even know if it should be class Enchant.cs or what.
how would i define any kind of enchantment. you, know ,it would, help, if i could just ficks theeeesee watchers… í
p.s. oh and it don’t have to be random , just predefined 'll do

There are always going to be trade-offs between being ‘generic’ and ‘complex’ - being more generic will typically require it being more complex. For example, having myPower += boostPower; is simpler than using, say, a strategy pattern.

Maybe you could just have something simple, like having attack and defence enchantments as just a plain float (defaulting to 1.0). When calculating an attack done by a character, multiply its attack power by its current attack enchantment. Do likewise when calculating the defence strength.

well i think i am onto something better, althought i use similar strategy when dealing with buffs,like in regen tick i do
if (buff.regen.active) health += 2; instead of 1 for example.
to the point of enchants, now i added into each weapon fields a string enchant name.when equiping i send it to CalcEnchant(string enchantName) which switches on enchant name and acts directly.(it does the math)
it works because if i unequip i do loop through all slots for math,and if the slot is empty, i simply send empty string to CalcEnchant and it does nothing.
:slight_smile: thanks for the input . always appreciated.