0 Favourites

How do I base item stats on level on drop?

  • Hey there! ^_^

    So bascially an item system like Diablo 3 or Borderlands - where when an item drops, its stats/dmg is based on the character

    level WHEN it was dropped -> Lets say;

    Hero is lvl 5 and a Broadsword drops, - then its stats are dependant on the Hero's level, in this case level 5.

    But now the Hero gains lvl 6 or 7 - however the item stats should stay the same stats it was when it dropped (Hero lvl 5) -

    Is it possible to do that? And in that case, how is it done?

  • Broadsword has a 'level' instance variable. Character has a 'level' instance variable. On Broadsword created, Broadsword.level = Character.level.

  • Broadsword has a 'level' instance variable. Character has a 'level' instance variable. On Broadsword created, Broadsword.level = Character.level.

    Loool ur a smart one xD hoho -

    And then an ItemText base for the weapon??

    If Item lvl X = set text to X ?

    Should i btw have same text for displaying dmg/stregth etc on the item, or 1 text for each variable?

  • That's just for display purposes in a menu but yes I guess so, text can display broadsword.level. The variables will be whatever you need for the gameplay, if the damage and strength both matter to the gameplay then you will need them. The text can be displayed in one or separate textboxes depending on how you want your inventory to look.

  • That's just for display purposes in a menu but yes I guess so, text can display broadsword.level. The variables will be whatever you need for the gameplay, if the damage and strength both matter to the gameplay then you will need them. The text can be displayed in one or separate textboxes depending on how you want your inventory to look.

    How about if i want a random stat on the weapon? Like strength or dexterity or vitality, 1 or 2 randomly??

    Can that be done?

  • On weapon created, weapon.strength = choose(a,b,c) will give strength a value of a or b or c. The stats will just be instance variables, you add them to the object in the creator. You could create a family 'weapons' and add family instance variables such as name, level, strength, damage etc

  • On weapon created, weapon.strength = choose(a,b,c) will give strength a value of a or b or c. The stats will just be instance variables, you add them to the object in the creator. You could create a family 'weapons' and add family instance variables such as name, level, strength, damage etc

    Hehe hey thanks alot for this response! ^_^

    How would that work if i need to 'pick up' or 'equip' that item, i must destroy it and create an equal in bag? How would i transfer those stats to the new items?

  • You are probably looking to use an array inventory, complex at first but useful once you know how. Check out the manual and some tutorials on how to create an inventory from arrays. If you pick up an item that's on the ground you would then add it to a slot in the array. The array can store the stats of the item etc

  • You are probably looking to use an array inventory, complex at first but useful once you know how. Check out the manual and some tutorials on how to create an inventory from arrays. If you pick up an item that's on the ground you would then add it to a slot in the array. The array can store the stats of the item etc

    So these stats created on drop on the item can be stored into the array?

  • 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

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

  • 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.

  • 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.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)