hight0ps's Forum Posts

  • 8 posts
  • Thanks.

  • (I realize the syntax is off above—sorry about that. It's correct in my testing, however.)

  • I'm wondering if it's possible to store data such as a weapon's damage range as a dictionary value. For example, "Sword" as the key and "floor(5,10)" as the value. It doesn't seem to be working for me and I'm wondering whether I'm missing something.

  • I find myself using JSON object more and more often, even convert existing arrays (like inventory) to JSON. It's much more flexible than arrays, if you organize its structure right you can access any data with ease, without having to iterate through its values. For example, it can be something like JSON.Get("abilities.attack.strength_modifier")

    That's really interesting — thanks for the idea.

    In the meantime, it occurred to me that I can use another dictionary to achieve what I'm trying to do, and it's much simpler as there's no looping or comparing needed. Just a key for each number within the range of possible ability scores, and the corresponding modifier is the value of each key.

  • The array exists to "translate" the character's Ability Score (Strength = 5) into the Ability Modifier (-3 on strength-based attacks, because 5 is a small amount of Strength in this example). The character is assigned a Strength score between 5 and 15. A strength score of 5 has a -3 modifier, while a strength score of 6 has a -2 modifier, and so forth. I'm ultimately just trying to figure out the most efficient way to "look up" the correct modifier for each score, and then to feed that number to the character's stat sheet.

    The dictionary serves as the character's stat sheet, and I figured it was easier to reference the character's attributes/skills/etc as key names rather than array elements.

  • Hi guys. I'm tinkering with various ways of using arrays and/or dictionaries to store various types of data such as character stats and inventory information. I'd like some insight on a specific use case just to be sure that I'm doing things efficiently.

    In tabletop RPG games, characters will typically have Ability Scores or Attributes which determine stats such as Strength, Intelligence, Dexterity, and so forth. There is often also an Ability Modifier, which is a bonus or penalty that applies to attack rolls or skill checks as a reflection of the character's general capability. I have a Dictionary object that holds all of the Player's ability scores, which are generated and assigned at the start of the layout. After assigning the ability scores, I'd like to determine the modifiers based on each of those scores.

    I have an array which is several elements wide, and two elements tall. The X index contains the possible ability scores that could be generated, and the Y index contains the Modifier for each score — so if the player has Strength 5, and we find the number 5 at index (4, 0), then the correct modifier is located at index (4, 1) and should be assigned as the player's Strength Modifier.

    My thought is to loop through the X index looking for player's ability score, and once located, to grab the corresponding modifier from the Y element. Could someone enlighten me as to whether this is the best way to achieve this, and if so, what the code snippet for the loop and for copying the modifier from the array to the dictionary with the player's stats should look like?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi there and thanks for your reply.

    I've input this code, but looking at the debug it seems that it's just generating the variable only in the element at 0,0 in Array. It doesn't seem to want to move on to the next available X element, and then to the new row once Array.Width-1 has been reached.

  • I'm trying to generate characters by randomly generating a name and 'rolling' several ability scores. I can do that without issue. What I can't seem to figure out is how to move on to the next row of the array to generate another character.

    If there are 10 different cells I want to populate with information about a character (e.g. name, age, ability scores, etc.), once that final attribute is generated and entered into the array, how do I get it to start over on the next row of the array with a new character?

  • 8 posts