How do I exchange stats on 'Equip' ?

Get help using Construct 2

Post » Sun Apr 16, 2017 12:14 pm

Hey there! ^_^
So im currently designing an 'Equip' system, and i need some advice on how to exchange the stats of the item, on the character when replacing the current item with a different item.

Example;
Say Hero has 'Dagger' equipped (+2 Strength and +1 Health)
Player replaces 'Dagger' with a sword that has '+1 Strength and +5 Health.

Now there are random stats on the items so doing a constant factor does not work, as a dagger may have 2 strength or 5 strength.

Do we in this case save the stats of 'Equipped' Item, and deduct it from the Hero, THEN equip the Sword and add the stats to the Hero?
How would that go? Thanks in advance! ^_^
B
12
S
3
Posts: 164
Reputation: 1,530

Post » Sun Apr 16, 2017 5:16 pm

One method would keep two separate stats for the player - base stats and equipment stats. Then you can just replace the equipment stat if you get new equipment. Any calculations done would simply add them together. This gives you more fine control over what stats are additive and multiplicative as well. However, this can be harder to implement if you have a lot of equipment categories modifying the same stats. You only have to do it once to set up the system though, and it should be flexible.

An alternative is to subtract out the stats when you unequip as you mentioned, but to me that method raises immediate concerns about possible number bugs/mistakes that can be cumulative. Also if you have any stat modifiers more complex than straight addition and subtraction you will need to work backwards for those too.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Mon Apr 17, 2017 5:12 am

oosyrag wrote:One method would keep two separate stats for the player - base stats and equipment stats. Then you can just replace the equipment stat if you get new equipment. Any calculations done would simply add them together. This gives you more fine control over what stats are additive and multiplicative as well. However, this can be harder to implement if you have a lot of equipment categories modifying the same stats. You only have to do it once to set up the system though, and it should be flexible.

An alternative is to subtract out the stats when you unequip as you mentioned, but to me that method raises immediate concerns about possible number bugs/mistakes that can be cumulative. Also if you have any stat modifiers more complex than straight addition and subtraction you will need to work backwards for those too.


Hey there! Thanks for the reply! ^_^
So basically we have 10 equipment slots. Each equipment slot needs a variable of what is equipped, example -
''Helm slot''
Strength = X
Dexterity = X
Health = X
Mana = X

And so on....... And then when u equip, u will add to these variables the items stats and add them to the Heros stats.
When u unequip, u subtrack the variable stats from the Hero stats, and replace the variable stats with the new item u equipped and add them to the Hero.

Since we have alot of slots and items and stats, this will mean 10-15 variables for each slot. Is this really the easiest way to do it?
B
12
S
3
Posts: 164
Reputation: 1,530

Post » Mon Apr 17, 2017 4:16 pm

With that amount of slots and stats, it makes more sense to use a single array to keep track of each slots' stats seperately. Each x column can represent one stat, and each y row can be an equipment slot. Then with all the data available to you at any given time, you can apply the numbers however you like, and they are easily replaceable.
Mistakes were made.
B
49
S
24
G
107
Posts: 1,581
Reputation: 60,303

Post » Mon Apr 17, 2017 6:30 pm

oosyrag wrote:With that amount of slots and stats, it makes more sense to use a single array to keep track of each slots' stats seperately. Each x column can represent one stat, and each y row can be an equipment slot. Then with all the data available to you at any given time, you can apply the numbers however you like, and they are easily replaceable.


Yeh dont really know how to do that, thanks anyway ^_^
B
12
S
3
Posts: 164
Reputation: 1,530


Return to How do I....?

Who is online

Users browsing this forum: adamebastin, ketramtu18 and 8 guests