Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(2 edits)

The thing that's happening here is that you try to read the data of a monster that has a NONE AMP reference. It's specifically being done in the block that creates the enemy battlemonster objects.

From what I can see, the issue happens when you start a horde battle without generating enough monsters to fill all enemy horde slots. (This is why it works in 1v1 battles - you always generate 1 enemy monster so creating 1 battlemonster will avoid reading outside the available data)

Should be simple to solve, at least. Wrap this block


in a copy of this condition


and it shouldn't try to read the unset data anymore. (Note how the inner block also changes the monster state from "DEAD" to "NORMAL" when doing this, which will also lead to issues down the line even if you ignore the data reading bit - this is what causes the second crash)

Actually, the reverse is working (horde battles working, 1v1 battles are not) but I tried adding that condition but then got a similar error to what I have been  getting: 

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

ERROR in

action number 1

of Draw Event

for object obj_battlemonsterhud:

Push :: Execution Error - Variable Index [-12341] out of range [419] - -5.active_monster_party(100075,-12341)

 at gml_Script_amp_read_var (line 3) -        return global.active_monster_party[argument0,argument1];

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

gml_Script_amp_read_var (line 3)

gml_Script_monster_get_name (line 4) -        var s = amp_read_var(amp_id,amp_NICKNAME);

gml_Object_obj_battlemonsterhud_Draw_0 (line 12) -               draw_text(xx,yy,monster_get_name(amp))

sorry for the trouble! I really appreciate your help as I am still trying to make sense of the ins and outs of the battle system

(1 edit)

Either way it's still caused by there being NONE monster IDs in the list of enemies to fight. Weird.

I had a little dig in the codebase and I think I have another idea for what could cause this. The code that checks for valid monsters to send out only checks if HP > 0. If the matching AMP ID's amp_MONID is NONE then we have an invalid monster ID and reading data from that will cause issues.

Do you set up / clear data for totems properly (similar to how the engine handles enemy data in random encounters)? It feels like there might be something going on with partially initialized data that causes this.

One idea might be to extend battle_get_valid_reinforcements a bit so that line 6 checks this condition instead:

if(global.active_monster_party[mon,amp_HP] > 0 && global.active_monster_party[mon,amp_MONID] != NONE){

It's not fixing the core issue that causes the invalid data but it at least stops trying to spawn a nonexistant monster. Maybe it'll be enough, since most other AMP manipulation scripts checks if the monster ID is NONE to check if a slot is valid.