I have been working to get evolution items into the game. I have them working, for the most part. You can select it from the items menu, and then use it on a monster, who will evolve if they have an item based evolution that matches the used item. However, once the evolution ends and the room fades out, the game crashes and I'm not quite sure how to fix it. Here is the crash message:
############################################################################################
ERROR in action number 1
of Step Event0 for object obj_roomchangefade:
room_goto argument 1 invalid reference to (room) - requested -12341 max is 8
at gml_Object_obj_roomchangefade_Step_0 (line 7) - room_goto(my_room)
############################################################################################
gml_Object_obj_roomchangefade_Step_0 (line 7)
Here is the code of the evolution item:
///itemuse_evolution(amp_id,EvoItem)
function itemuse_evolution(argument0, argument1) {
var monamp = argument0;
var monid = global.active_monster_party[argument0,amp_MONID];
var nevo = NONE;
for(c = 0; c < global.monster_data[monid,mond_TOTALEVOLUTIONS]; c++)
{
if(global.monster_evolution_type[monid,c] == evotype_ITEM)
{
show_debug_message("Evolution type equals item")
if(global.monster_evolution_arg[ monid,c] == argument1)
{
nevo = global.monster_evolution_mon[ monid,c]
inventory_lose_item(my_item,1)
ds_queue_enqueue(global.pending_evolutions_queue,[monamp,nevo])
room_goto_fade_dontdestroy(rm_evolution,60)
break;
}
}
}
if (nevo == NONE)
{
msh_itemuse_show_party_effects("It wouldn't have any effect.")
}
}
I feel like I must be missing something about the room_goto_fade_dontdestroy function, but I don't know what. Any help would be appreciated. If you need any more details, let me know.
-12341 is the value of the NONE constant (one of the reasons I picked that number was to make it instantly recognizable). You need to set global.load_room to the current room before changing to the evolution room (and also the global.load_x, load_y and load_direction variables to the player's current x / y / drawdir respectively) otherwise it doesn't know where to put you back - and that's exactly what's happening right now.
(For an example of how to do this, check out player_step_fill which handles the "steps in tall grass to the next random battle" counter, and which sets these before changing to the battle room if an encounter is triggered - side note, this function would also be where you put things like "monsters in daycare gets EXP" and "countdown to eggs hatching" happening)
← Return to asset pack
Comments
Log in with itch.io to leave a comment.
Hey,
I have been working to get evolution items into the game. I have them working, for the most part. You can select it from the items menu, and then use it on a monster, who will evolve if they have an item based evolution that matches the used item. However, once the evolution ends and the room fades out, the game crashes and I'm not quite sure how to fix it. Here is the crash message:
Here is the code of the evolution item:
I feel like I must be missing something about the room_goto_fade_dontdestroy function, but I don't know what. Any help would be appreciated. If you need any more details, let me know.
-12341 is the value of the NONE constant (one of the reasons I picked that number was to make it instantly recognizable). You need to set global.load_room to the current room before changing to the evolution room (and also the global.load_x, load_y and load_direction variables to the player's current x / y / drawdir respectively) otherwise it doesn't know where to put you back - and that's exactly what's happening right now.
(For an example of how to do this, check out player_step_fill which handles the "steps in tall grass to the next random battle" counter, and which sets these before changing to the battle room if an encounter is triggered - side note, this function would also be where you put things like "monsters in daycare gets EXP" and "countdown to eggs hatching" happening)