How do I attribute mechanics?

0 favourites
  • 2 posts
From the Asset Store
Top down zombie survival mechanics pack in the style of Cannon Fodder.
  • Hello everyone.

    I'm making a turn-based game where items, weapons, potions can positively or negatively cause a player's attribute.

    So, for example:

    Amulet: +2 STRENGTH and -1 INTELLIGENCE for 2 turns

    Sword: +1 STRENGTH for 10 turns

    Potion: +1 STRENGTH for 3 turns

    That is, these elements can increase and decrease the player's attributes for a certain time (turns).

    But I don't know how to make these calculations.

    I thought of making an array for each attribute:

    array_force,

    array_intelligence...

    and any input matrix are added to the attribute:

    matrix_strength atX [0] = 2 <(would be the same as +1 strength for 2 turns)

    matrix_strength atX [1] = 3 <(would be the same as +1 strength for 3 turns)

    matrix_strength atX [2] = 2 <(would be the same as +1 strength for 2 turns)

    But then I would have a problem because I can only add, I would have to have another array_force only for negative values...

    Cut me a little tricky... do you guys have any tips on how to do this smarter?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could use one array with the relevant info in columns.

    Using your items as an example it could look like this :

    (add/subtract) / (value) / (buff) / (turns)

    + / 2 / str / 2

    - / 1 / int / 2

    + / 1 / str / 10

    + / 1 / str / 3

    And you run through it like for each row,

    if y2 = str, if y0 = + then strength(variable)+y1, if y0= - then strength(var)-y1

    if y2 = int, if y0 = + then int(var)+y1, if y0 = - then int(var)-y1

    and so on.

    Then after applying the buffs you subtract 1 from y3 for each row.

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