How do I Make An Loot Drop Function From Multiple Arrays?

0 favourites
  • 7 posts
From the Asset Store
Perfect, complete, easy to use to use, out-of-the-box inventory system
  • ALright. So I have two Arrays called arr_enemy and arr_drops and i set them up as On Start of Layout, set size (#,#,#) and then populated each according to the screenshot below.

    I am following this wonderful guide (https://gamedevelopment.tutsplus.com/tutorials/how-to-code-monster-loot-drops--cms-20449). So now I have arr_stats and arr_temp to help assist with the function I am trying to make. The end goal is to have a enemy drop collectibles upon death but not every monster can drop every drop 100% of the time. Here is a screenie of the example I am following from the link above:

    I am confused on were the following variables are going on line 22-24.

    int BeastType

    int DropChance

    int Rarity

    Correct me if I am wrong but are they inst.variables I have to set on each enemy? Am I reading this right?

  • In the example and the tutorial, they are part of a function.

    So it is actually more local variables than instances variables which are temporary used for the logic when in the function.

    You can click on the "Download attachments" button on the right, and open the "BeastDropBatch.capx" file in order to see the implementation in Construct of this code.

  • Wow thanks! I missed that link. Ill see what i can do with these and get back to you.

  • In the example and the tutorial, they are part of a function.

    So it is actually more local variables than instances variables which are temporary used for the logic when in the function.

    You can click on the "Download attachments" button on the right, and open the "BeastDropBatch.capx" file in order to see the implementation in Construct of this code.

    Alright. I managed to get something with the example and changed a few things to match my monster drop function needs. The debugger shows the function is running and variables are changing (not yet sure to the correct values). However, the monsters aren't dropping anything upon death. I have the monster 'Enemy_001' in a family and when its HP reaches 0 it destroys itself and calls function 'mon_killed'. The function is as below:

    The obj_Drops has separate animations for each kind of drop because I am looking to animate each drop type later. Can I get a second set of eyes on this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You do not pass a parameter to your function, yet uses a reference to this parameter when you check that DropChance is less than some value.

    The value is then always 0. Few chances that DropChances is less or equal 0.

  • I STRONGLY suggest you dont use arrays for this. Either use json (with the awesome plugin that a member made - French Yann iirc) or a mix of arrays and dictionaries, populating them from a configuration file.

  • You do not pass a parameter to your function, yet uses a reference to this parameter when you check that DropChance is less than some value.

    The value is then always 0. Few chances that DropChances is less or equal 0.

    Hmm that seems like whats happening after I got a closer look. The obj_drop was spawning but at 0,0. I tried referencing my 'Enemy 1' and the Enemy Family but they still make the drop object somewhere off screen. I thought using the function as the parameter will reference the coordinates were the function was run. Im running out of things for the system to create this drop object.

    I STRONGLY suggest you dont use arrays for this. Either use json (with the awesome plugin that a member made - French Yann iirc) or a mix of arrays and dictionaries, populating them from a configuration file.

    THis plugin looks awsome! thanks! I plan on making a JSON file in Sublime for importing after i get the drop function to work with a smaller array. I am following this tutorial by English Acorn once I get to that point. (https://www.youtube.com/watch?v=ZPG1t-gZfds&t=1861s)

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