Game patching functions
activate_crush_elevator_hack
function activate_crush_elevator_hack(activate: boolean)activate:boolean
Activate custom variables for speed and y coordinate limit for crushing elevator note: because those variables are custom and game does not initiate them, you need to do it yourself for each CrushElevator entity, recommending set_post_entity_spawn default game values are: speed = 0.0125, y_limit = 98.5
activate_hundun_hack
function activate_hundun_hack(activate: boolean)activate:boolean
Activate custom variables for y coordinate limit for hundun and spawn of it's heads note: because those variables are custom and game does not initiate them, you need to do it yourself for each Hundun entity, recommending set_post_entity_spawn default game value are: y_limit = 98.5, rising_speed_x = 0, rising_speed_y = 0.0125, bird_head_spawn_y = 55, snake_head_spawn_y = 71
activate_sparktraps_hack
activate_sparktraps_hack(true);
-- set random speed, direction and distance for the sparkset_post_entity_spawn(function(ent)
direction = 1 if prng:random_chance(2, PRNG_CLASS.ENTITY_VARIATION) then direction = -1 end
ent.speed = prng:random_float(PRNG_CLASS.ENTITY_VARIATION) * 0.1 * direction ent.distance = prng:random_float(PRNG_CLASS.ENTITY_VARIATION) * 10
end, SPAWN_TYPE.ANY, 0, ENT_TYPE.ITEM_SPARK)function activate_sparktraps_hack(activate: boolean)activate:boolean
Activate custom variables for speed and distance in the ITEM_SPARK
note: because those the variables are custom and game does not initiate them, you need to do it yourself for each spark, recommending set_post_entity_spawn
default game values are: speed = -0.015, distance = 3.0
activate_tiamat_position_hack
activate_tiamat_position_hack(true);
set_post_entity_spawn(function(ent)
-- make them same as in the game, but relative to the tiamat entity ent.attack_x = ent.x - 1 ent.attack_y = ent.y + 2
end, SPAWN_TYPE.ANY, 0, ENT_TYPE.MONS_TIAMAT)function activate_tiamat_position_hack(activate: boolean)activate:boolean
Activate custom variables for position used for detecting the player (normally hardcoded) note: because those variables are custom and game does not initiate them, you need to do it yourself for each Tiamat entity, recommending set_post_entity_spawn default game values are: attack_x = 17.5 attack_y = 62.5
change_altar_damage_spawns
function change_altar_damage_spawns(ent_types: ENT_TYPE[])ent_types:ENT_TYPE[]
Change ENT_TYPE's spawned when you damage the altar, by default there are 6:
{MONS_BAT, MONS_BEE, MONS_SPIDER, MONS_JIANGSHI, MONS_FEMALE_JIANGSHI, MONS_VAMPIRE}
Max 255 types.
Use empty table as argument to reset to the game default
change_diceshop_prizes
function change_diceshop_prizes(ent_types: ENT_TYPE[])ent_types:ENT_TYPE[]
Change ENT_TYPE's spawned in dice shops (Madame Tusk as well), by default there are 25:
{ITEM_PICKUP_BOMBBAG, ITEM_PICKUP_BOMBBOX, ITEM_PICKUP_ROPEPILE, ITEM_PICKUP_COMPASS, ITEM_PICKUP_PASTE, ITEM_PICKUP_PARACHUTE, ITEM_PURCHASABLE_CAPE, ITEM_PICKUP_SPECTACLES, ITEM_PICKUP_CLIMBINGGLOVES, ITEM_PICKUP_PITCHERSMITT,
ENT_TYPE_ITEM_PICKUP_SPIKESHOES, ENT_TYPE_ITEM_PICKUP_SPRINGSHOES, ITEM_MACHETE, ITEM_BOOMERANG, ITEM_CROSSBOW, ITEM_SHOTGUN, ITEM_FREEZERAY, ITEM_WEBGUN, ITEM_CAMERA, ITEM_MATTOCK, ITEM_PURCHASABLE_JETPACK, ITEM_PURCHASABLE_HOVERPACK,
ITEM_TELEPORTER, ITEM_PURCHASABLE_TELEPORTER_BACKPACK, ITEM_PURCHASABLE_POWERPACK}
Min 6, Max 255, if you want less then 6 you need to write some of them more then once (they will have higher "spawn chance").
If you use this function in the level with dice shop in it, you have to update item_ids in the ITEM_DICE_PRIZE_DISPENSER.
Use empty table as argument to reset to the game default
change_poison_timer
function change_poison_timer(frames: integer)frames:integer
Change the amount of frames after the damage from poison is applied
change_sunchallenge_spawns
function change_sunchallenge_spawns(ent_types: ENT_TYPE[])ent_types:ENT_TYPE[]
Change ENT_TYPE's spawned by FLOOR_SUNCHALLENGE_GENERATOR, by default there are 4:
{MONS_WITCHDOCTOR, MONS_VAMPIRE, MONS_SORCERESS, MONS_NECROMANCER}
Use empty table as argument to reset to the game default
change_waddler_drop
function change_waddler_drop(ent_types: ENT_TYPE[])ent_types:ENT_TYPE[]
Change ENT_TYPE's spawned when Waddler dies, by default there are 3:
{ITEM_PICKUP_COMPASS, ITEM_CHEST, ITEM_KEY}
Max 255 types.
Use empty table as argument to reset to the game default
disable_floor_embeds
function disable_floor_embeds(disable: boolean): booleandisable:boolean
Returns boolean
Disable all crust item spawns, returns whether they were already disabled before the call
force_olmec_phase_0
function force_olmec_phase_0(b: boolean)b:boolean
Forces Olmec to stay on phase 0 (stomping)
modify_ankh_health_gain
function modify_ankh_health_gain(max_health: integer, beat_add_health: integer)max_health:integerbeat_add_health:integer
Change how much health the ankh gives you after death, with every beat (the heart beat effect) it will add beat_add_health to your health,
beat_add_health has to be divisor of health and can't be 0, otherwise the function does nothing. Set health to 0 to return to the game defaults
If you set health above the game max health it will be forced down to the game max
modify_sparktraps
function modify_sparktraps(angle_increment: number, distance: number)angle_increment:numberdistance:number
Changes characteristics of (all) sparktraps: speed, rotation direction and distance from center Speed: expressed as the amount that should be added to the angle every frame (use a negative number to go in the other direction) Distance from center: if you go above 3.0 the game might crash because a spark may go out of bounds!
replace_drop
function replace_drop(drop_id: DROP, new_drop_entity_type: ENT_TYPE)Changes a particular drop, e.g. what Van Horsing throws at you (use e.g. replace_drop(DROP.VAN_HORSING_DIAMOND, ENT_TYPE.ITEM_PLASMACANNON))
Use 0 as type to reset this drop to default, use -1 as drop_id to reset all to default
Check all the available drops here
set_boss_door_control_enabled
function set_boss_door_control_enabled(enable: boolean)enable:boolean
Allows you to disable the control over the door for Hundun and Tiamat This will also prevent game crashing when there is no exit door when they are in level
set_camera_layer_control_enabled
set_camera_layer_control_enabled(false)
g_current_timer = nil-- default load_time 36function change_layer(layer_to, load_time)
if state.camera_layer == layer_to then return end if g_current_timer ~= nil then clear_callback(g_current_timer) g_current_timer = nil end -- if we don't want the load time, we can just change the actual layer if load_time == nil or load_time == 0 then state.camera_layer = layer_to return end
state.layer_transition_timer = load_time state.transition_to_layer = layer_to state.camera_layer = layer_toendfunction set_camera_layer_control_enabled(enable: boolean)enable:boolean
This disables the state.camera_layer to be forced to the (leader player).layer and setting of the state.layer_transition_timer & state.transition_to_layer when player enters layer door.
Letting you control those manually.
Look at the example on how to mimic game layer switching behavior
set_camp_camera_bounds_enabled
function set_camp_camera_bounds_enabled(b: boolean)b:boolean
Enables or disables the default position based camp camera bounds, to set them manually yourself
set_cursepot_ghost_enabled
function set_cursepot_ghost_enabled(enable: boolean)enable:boolean
Determines whether the ghost appears when breaking the ghost pot
set_drop_chance
function set_drop_chance(dropchance_id: DROPCHANCE, new_drop_chance: integer)dropchance_id:DROPCHANCEnew_drop_chance:integer
Alters the drop chance for the provided monster-item combination (use e.g. set_drop_chance(DROPCHANCE.MOLE_MATTOCK, 10) for a 1 in 10 chance)
Use -1 as dropchance_id to reset all to default
set_ending_unlock
-- change character unlocked by endings to pilotset_ending_unlock(ENT_TYPE.CHAR_PILOT)
-- change texture of the actual savior in endings to pilotset_callback(function() set_post_entity_spawn(function(ent) if state.screen == SCREEN.WIN then ent:set_texture(TEXTURE.DATA_TEXTURES_CHAR_PINK_0) end clear_callback() end, SPAWN_TYPE.SYSTEMIC, MASK.PLAYER)end, ON.WIN)function set_ending_unlock(type: ENT_TYPE)type:ENT_TYPE
Force the character unlocked in either ending to ENT_TYPE. Set to 0 to reset to the default guys. Does not affect the texture of the actual savior. (See example)
set_explosion_mask
function set_explosion_mask(mask: integer)mask:integer
Sets which entities are affected by a bomb explosion. Default = MASK.PLAYER | MASK.MOUNT | MASK.MONSTER | MASK.ITEM | MASK.ACTIVEFLOOR | MASK.FLOOR
set_ghost_spawn_times
function set_ghost_spawn_times(normal: integer, cursed: integer)normal:integercursed:integer
Determines when the ghost appears, either when the player is cursed or not
set_kapala_blood_threshold
function set_kapala_blood_threshold(threshold: integer)threshold:integer
Sets the amount of blood drops in the Kapala needed to trigger a health increase (default = 7).
set_kapala_hud_icon
function set_kapala_hud_icon(icon_index: integer)icon_index:integer
Sets the hud icon for the Kapala (0-6 ; -1 for default behaviour). If you set a Kapala treshold greater than 7, make sure to set the hud icon in the range 0-6, or other icons will appear in the hud!
set_level_logic_enabled
function set_level_logic_enabled(enable: boolean)enable:boolean
Setting to false disables all player logic in SCREEN.LEVEL, mainly the death screen from popping up if all players are dead or missing, but also shop camera zoom and some other small things.
set_liquid_layer
function set_liquid_layer(l: LAYER)l:LAYER
Change layer at which the liquid spawns in, THIS FUNCTION NEEDS TO BE CALLED BEFORE THE LEVEL IS BUILD, otherwise collisions and other stuff will be wrong for the newly spawned liquid This sadly also makes lavamanders extinct, since the logic for their spawn is hardcoded to front layer with bunch of other unrelated stuff (you can still spawn them with script or place them directly in level files) Everything should be working more or less correctly (report on community discord if you find something unusual)
set_max_rope_length
function set_max_rope_length(length: integer)length:integer
Sets the maximum length of a thrown rope (anchor segment not included). Unfortunately, setting this higher than default (6) creates visual glitches in the rope, even though it is fully functional.
set_olmec_cutscene_enabled
function set_olmec_cutscene_enabled(enable: boolean)enable:boolean
Olmec cutscene moves Olmec and destroys the four floor tiles, so those things never happen if the cutscene is disabled, and Olmec will spawn on even ground. More useful for level gen mods, where the cutscene doesn't make sense. You can also set olmec_cutscene.timer to the last frame (809) to skip to the end, with Olmec in the hole.
set_olmec_phase_y_level
function set_olmec_phase_y_level(phase: integer, y: number)phase:integery:number
Sets the Y-level at which Olmec changes phases
set_start_level_paused
function set_start_level_paused(enable: boolean)enable:boolean
Setting to true will stop the state update from unpausing after a screen load, leaving you with state.pause == PAUSE.FADE on the first frame to do what you want.
set_storage_layer
-- Sets the right layer when using the vanilla tile code if waddler is still happy,-- otherwise spawns the floor to the left of this tile.-- Manually spawning FLOOR_STORAGE pre-tilecode doesn't seem to work as expected,-- so we destroy it post-tilecode.set_post_tile_code_callback(function(x, y, layer) if not test_flag(state.quest_flags, 10) then -- Just set the layer and let the vanilla tilecode handle the floor set_storage_layer(layer) else local floor = get_entity(get_grid_entity_at(x, y, layer)) if floor then floor:destroy() end if get_grid_entity_at(x - 1, y, layer) ~= -1 then local left = get_entity(get_grid_entity_at(x - 1, y, layer)) spawn_grid_entity(left.type.id, x, y, layer) end endend, "storage_floor")
-- This fixes a bug in the game that breaks storage on transition.-- The old storage_uid is not cleared after every level for some reason.set_callback(function() state.storage_uid = -1end, ON.TRANSITION)
-- Having a waddler is completely optional for storage,-- but this makes a nice waddler room if he still likes you.define_tile_code("waddler")set_pre_tile_code_callback(function(x, y, layer) if not test_flag(state.quest_flags, 10) then local uid = spawn_roomowner(ENT_TYPE.MONS_STORAGEGUY, x + 0.5, y, layer, ROOM_TEMPLATE.WADDLER) set_on_kill(uid, function() -- Disable current level storage if you kill waddler state.storage_uid = -1 end) end return trueend, "waddler")function set_storage_layer(layer: LAYER)layer:LAYER
Set layer to search for storage items on
set_tiamat_cutscene_enabled
function set_tiamat_cutscene_enabled(enable: boolean)enable:boolean
Tiamat cutscene is also responsible for locking the exit door, so you may need to close it yourself if you still want Tiamat kill to be required
set_time_ghost_enabled
function set_time_ghost_enabled(b: boolean)b:boolean
Determines whether the time ghost appears, including the showing of the ghost toast
set_time_jelly_enabled
function set_time_jelly_enabled(b: boolean)b:boolean
Determines whether the time jelly appears in cosmic ocean