Managing multiple arrays. RPG Inventory help?

0 favourites
  • 5 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Howdy Scirra forums. I've used the search function and I've seen some examples. I'm requesting someone basically walk through what I need to do in C2. If C2 were a scripting language, I think I could handle this. But well, C2 isn't a scripting language. I'm still new to WYSIWYG game editors.

    I'll try to explain what I need help with to the best of my abilities.

    Theory

    I'd have three arrays for what I need to accomplish.

    1] The first array would be a 1 dimensional array for inventory "slots".

    [0][1][2][3][4][5][6][7][8][9][10]...

    Each address would have a value.

    0 = empty, 1=Item.animation frame 1, 2=Item.animation frame 3=Item.animation frame 3,etc . . . .

    2] The second array would also be 1 dimensional. For equipped items.

    [0]Feet

    [1]Body

    [2]R_arm

    [3]L_arm

    [4]Head

    [6]Weapon

    [7]Trinket1

    [8]Trinket2

    Each address would have a value.

    0 = empty, 1=Item.animation frame 1, 2=Item.animation frame 3=Item.animation frame 3,etc . . . .

    3] The third array would connect the two arrays and contain all the info for items. It'd be multi dimensional.

    [0] Animation frame to show

    [0a] Item Name

    [0b] STR to add

    [0c] DEF to add

    [0d] INT to add

    [0e] LCK to add

    [0f] CON to add

    [0g] MP to add

    [0h] Hp to add

    The action would work like this:

    o Player kills monster

    o Computer does a random number roll.

    o If the number roll is a success, the monster spawns a random item

    o When the player collides("picks up") the item, the items corresponding number is added to the Slot array.

    There'd be a menu that shows the inventory with each item number having a specific animation frame that would show in the inventory. Then you'd be able to drag from the slots into the equip. The slot address would become 0, and the Equip Inventory would gain the previous address.

    Then, the third array would run the calculation and add whatever specific stats to the player's stats.

    _________________________________________________

    Does the basic game theory for what I want to achieve make sense? Is there a simpler way to implement what I want to add?

  • Bump

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey there.

    Your basic game workflow should work.

    I have a concern though. The third array is more like a database than a dynamic array. I would suggest using the CSV plugin to do that, so you could access the datas with something more clear to read (column names is realy nice when you have lots of data for each items, plus it's easier to check/complete/modify item stats through Excel).

    Now let's take a look through your actions :

    o Player kills monster > call function "handle loot", passing monster.UID as parameter, before destruction of the monster object

    o Computer does a random number roll. > handled by the function

    o If the number roll is a success, the monster spawns a random item > handled by the function. spawn an item on the monster coordinates.

    o When the player collides("picks up") the item, the items corresponding number is added to the Slot array.

    Player On collision with Item, call function "pick up item" passing item.UID as parameter.

    The pick up function would first look for the first empty slot, then if it found one store the item in it, destroy the item object from the game. You should have a function that would update the "slot" display on the screen to call here.

    Then, you'll need a new "item object" (let's call it item2), different from the first one as it will be in your inventory, and would have a drag-drop behavior.

    item2 on drop on equipSlot : if the equip slot isn't empty, handle the unequipment of the object first. Then, update the EquipSlot with the caracteristics of the new item. Last, remove item from inventory/destroy the item2 object.

    I tried to described a little more what would be the script-flow, hope it helps.

  • inventory basic example

    i created a basic demo of some of the things you will need, and how you can use the array, i would use only one array, the itemlist, the rest is only states, and you get the info always from itemlist

    from there you can random generate, give information, whatever you like

    using x array for the list and y for properties

  • Thanks guys!

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