Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(1 edit)

Thank you for all your responces. I THINK I am following along so far, but the last element of Section 1 is throwing me off. What are you refering to be 'second term' in that function? Its not the argument I assume, so I'm not sure where to place that code. I've tried placing it as the second argument and setting 'include_weapons_we_have' to `global.weapon_data[c][pstat_POSSIBLEUPGRADES][d][dbupgd_MAXUPGRADES]`, but this does not work.


Edit: If by second term you meant of the initially referenced line, I changed it to the following:

`if((global.weapon_upgrades_obtained[c] < global.weapon_data[c][pstat_POSSIBLEUPGRADES][d][dbupgd_MAXUPGRADES]) || allow_surpassing_max_level){ //Can we upgrade it further?`

and got the following error, just in case

___________________________________________

############################################################################################

ERROR in

action number 1

of  Step Eventobj_player

for object parent_collectibleitem:

Push :: Execution Error - Variable Index [14] out of range [2] - -5.weapon_upgrades_obtained(100135,14)

 at gml_Script_playerweapon_randomly_pick_some_random_upgrades (line 97) -                             if((global.weapon_upgrades_obtained[c] < global.weapon_data[c][pstat_POSSIBLEUPGRADES][d][dbupgd_MAXUPGRADES]) || allow_surpassing_max_level){ //Can we upgrade it further?

############################################################################################

gml_Script_playerweapon_randomly_pick_some_random_upgrades (line 97)

gml_Script_ics_exp (line 23) -               playerweapon_randomly_pick_some_random_upgrades(3,true,true,global.player_level >= 3,global.player_level >= 3,true,false)

gml_Object_parent_collectibleitem_Collision_obj_player (line 3) -               collection_script()

Second term as in "global.weapon_data[c][pstat_UPGRADESMAX]".

Hmm, judging by the message everything wasn't set up as expected (the upgrades_obtained array is too short), it should be a two-dimensional array that's got as many slots on the first axis as the number of weapons the player can obtain, and the second axis should have PWD_LOCALDATA_MAX elements (now I'm realizing that's not actually correct, you want this number to be the max number of different upgrade choices any weapon can have - we're addressing by upgrade index and not by stat - but so far none of them has 12 upgrade paths so it should be fine).

But either way, global.weapon_upgrades_obtained should be at least a 6-by-12 element array, but it's only 2 elements along one axis, so something's weird there. The first step would be to print its contents with show_debug_message(global.weapon_upgrades_obtained) at the start of the function and see what's actually in it when the game crashes. (Note that it's not enough to just set array[5][11] to 0 when initializing it, that'll give you a 6 element array which contains a 12-element array in the 6th slot and the number 0 in the prior five slots - 2D arrays are just arrays of 1D arrays so if you want the inner arrays to have the same length you need to manually put one in every slot of the outer array)

Oh yeah, and another issue, you're checking global.weapon_upgrades_obtained[c], but you should check global.weapon_upgrades_obtained[c][d] because upgrade level is per-upgrade now instead of shared for the entire weapon. (You'll need to move this check into the loop over array_length(ups) as well)