How do I base item stats on level on drop?

Get help using Construct 2

Post » Tue Feb 07, 2017 4:02 pm

plinkie wrote:Yes take a look at this https://www.scirra.com/tutorials/583/ea ... g-an-array


Hehe thanks alot - but i didnt understand how i can give a weapon a random stat of either Strength/Dexterity/Vitality, just 1 out of these 3? All 3 variable instances are already on the weapon sprite
B
5
S
1
Posts: 37
Reputation: 451

Post » Tue Feb 07, 2017 4:11 pm

Do you mean give a random value to strength, dexterity and vitality? Or do you mean choose either s, d or v to increase?
B
46
S
15
G
73
Posts: 2,026
Reputation: 43,459

Post » Tue Feb 07, 2017 4:16 pm

plinkie wrote:Do you mean give a random value to strength, dexterity and vitality? Or do you mean choose either s, d or v to increase?


I mean to give a random stat, so when an item drop;
It can have Strength and Vitality
Or Strength and Dexterity
Or just Strength.
B
5
S
1
Posts: 37
Reputation: 451

Post » Tue Feb 07, 2017 4:20 pm

I guess you could do :
On item created choose (1,2,3)
if 1, s=true, v=true, d=false
if 2, s=true, v=false, d=true
if 3, s=true, v=false, d=false

The true or false doesn't really relate to anything though unless you have some other logic setup. Rather than use bools you can have s=random value i guess.
B
46
S
15
G
73
Posts: 2,026
Reputation: 43,459

Post » Tue Feb 07, 2017 4:35 pm

plinkie wrote:I guess you could do :
On item created choose (1,2,3)
if 1, s=true, v=true, d=false
if 2, s=true, v=false, d=true
if 3, s=true, v=false, d=false

The true or false doesn't really relate to anything though unless you have some other logic setup. Rather than use bools you can have s=random value i guess.


How would that go? Basically I want a weapon to give either str or vit or dex, - which takes place when u equip it. (Adds to the same stat) - If strength would be 5 and dexterity would be 3 then when u equip it, those same stats are added to the heroes str and dex.
If the weapon should give vitality instead of dex, then thats whats supposed to be added.

But for now we need a random stat on weapon on created.
B
5
S
1
Posts: 37
Reputation: 451

Post » Tue Feb 07, 2017 4:43 pm

There are different ways to do it. You could have the weapon choose(1,2,3), if 1 is chosen then it is a +strength item, if it is a +strength item then you pick a random value for the strength variable of the weapon i.e. strength=random(1,5), then if 3 is chosen its strength is 3, hence a +3 strength item. Then when the player equips this weapon, wherever the equip logic is, you add weapon.strength to player.strength so it'll be player.strength+3. You could actually put logic in to cover all values for all weapons at this point, since dex and vit will be +0.

So on any equip weapon:
player.str = player.str+weapon.str = player.str+3
player.vit = player.vit+weapon.vit = player.vit+0
player.dex = player.dex+weapon.dex = player.dex+0

You can advance this further later on by choosing multiple initial numbers and assigning negative values so you can gain strength and lose vitality on weapon equip.
B
46
S
15
G
73
Posts: 2,026
Reputation: 43,459

Post » Tue Feb 07, 2017 4:49 pm

plinkie wrote:There are different ways to do it. You could have the weapon choose(1,2,3), if 1 is chosen then it is a +strength item, if it is a +strength item then you pick a random value for the strength variable of the weapon i.e. strength=random(1,5), then if 3 is chosen its strength is 3, hence a +3 strength item. Then when the player equips this weapon, wherever the equip logic is, you add weapon.strength to player.strength so it'll be player.strength+3. You could actually put logic in to cover all values for all weapons at this point, since dex and vit will be +0.

So on any equip weapon:
player.str = player.str+weapon.str = player.str+3
player.vit = player.vit+weapon.vit = player.vit+0
player.dex = player.dex+weapon.dex = player.dex+0

You can advance this further later on by choosing multiple initial numbers and assigning negative values so you can gain strength and lose vitality on weapon equip.


Correct, was my first idea - BUT since we have item stats display, then its bad if it displays 'dex 0, vit 0, str 3' Makes no sense :/
However, choose 1,2,3 how is that done? Varaible on the weapon or?
B
5
S
1
Posts: 37
Reputation: 451

Post » Tue Feb 07, 2017 4:58 pm

It makes some sense if it says +0, +0, +3, -1 in my opinion but you can choose to display whatever you want. Yes you can assign it to an instance variable on the weapon when it is created if you want.
B
46
S
15
G
73
Posts: 2,026
Reputation: 43,459

Post » Tue Feb 07, 2017 5:00 pm

plinkie wrote:It makes some sense if it says +0, +0, +3, -1 in my opinion but you can choose to display whatever you want. Yes you can assign it to an instance variable on the weapon when it is created if you want.


No i mean the text display to the player when hovering over the item with the mouse.
If it said;
Str+3
Dex+0
Vit+0

It seems weird xD - better it says
Str+3
Dex+1
-Done-
B
5
S
1
Posts: 37
Reputation: 451

Post » Tue Feb 07, 2017 5:07 pm

Yes you can choose not to display values that are 0 but these are all just minor tweaks, no need to continue this thread really I would go on and test it out and come back if you require any major assistance.
B
46
S
15
G
73
Posts: 2,026
Reputation: 43,459

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: SputnikCZ and 3 guests