Reworked celeste integration
parent
1216378c49
commit
720a1b63c4
|
@ -29,21 +29,23 @@ k_down=3
|
|||
k_jump=4
|
||||
k_dash=5
|
||||
|
||||
-- HACK: used to slow down frame rate
|
||||
frame_counter = 0
|
||||
draw_frame_counter = 0
|
||||
|
||||
|
||||
-- False until the game has initialized
|
||||
hack_ready = false
|
||||
hack_no_shake = true
|
||||
|
||||
-- Skip each nth frame.
|
||||
-- Celeste usually runs at 30 fps, we run it at 60.
|
||||
-- so, a value of 2 gives normal speed
|
||||
-- and a value of 3 gives 3/2 speed.
|
||||
frame_rate_hack = 10
|
||||
-- Slow down frame rate
|
||||
hack_frame_counter = 0
|
||||
hack_frame_freeze = 10 -- Freeze for n frames
|
||||
hack_frame_foward = 3 -- Run this many frames without sending status
|
||||
hack_frame_foward_bonus = 0 -- Set when actions need extra frames (like dashes)
|
||||
|
||||
-- HACK: keep track of player state
|
||||
player_state = {}
|
||||
hack_player_state = {}
|
||||
hack_can_dash = false
|
||||
|
||||
hack_has_sent_first_message = false
|
||||
|
||||
-- entry point --
|
||||
-----------------
|
||||
|
@ -157,9 +159,13 @@ player =
|
|||
local on_ground=this.is_solid(0,1)
|
||||
local on_ice=this.is_ice(0,1)
|
||||
|
||||
if on_ground then
|
||||
hack_can_dash = true
|
||||
end
|
||||
|
||||
-- smoke particles
|
||||
if on_ground and not this.was_on_ground then
|
||||
init_object(smoke,this.x,this.y+4)
|
||||
init_object(smoke,this.x,this.y+4)
|
||||
end
|
||||
|
||||
local jump = btn(k_jump) and not this.p_jump
|
||||
|
@ -269,7 +275,12 @@ player =
|
|||
this.djump-=1
|
||||
this.dash_time=4
|
||||
has_dashed=true
|
||||
this.dash_effect_time=10
|
||||
|
||||
-- HACK: fast-forward dashes
|
||||
hack_frame_foward_bonus = 8
|
||||
hack_can_dash = false
|
||||
|
||||
this.dash_effect_time=10
|
||||
local v_input=(btn(k_up) and -1 or (btn(k_down) and 1 or 0))
|
||||
if input!=0 then
|
||||
if v_input!=0 then
|
||||
|
@ -337,9 +348,8 @@ player =
|
|||
this.was_on_ground=on_ground
|
||||
|
||||
|
||||
-- HACK: print player status
|
||||
hack_ready = true
|
||||
player_state = {
|
||||
hack_player_state = {
|
||||
px = tostr(this.x),
|
||||
py = tostr(this.y),
|
||||
vx = tostr(this.spd.x),
|
||||
|
@ -1194,34 +1204,100 @@ end
|
|||
-----------------------
|
||||
|
||||
|
||||
-- _update30 runs at 30 fps
|
||||
-- _update runs at 30 fps
|
||||
-- _update60 does 60 fps
|
||||
-- default for celeste is 30.
|
||||
function _update60()
|
||||
if frame_counter < frame_rate_hack then
|
||||
frame_counter+=1
|
||||
else
|
||||
frame_counter = 0
|
||||
old_update()
|
||||
function _update()
|
||||
|
||||
if hack_ready then
|
||||
out_string = "dc:" .. tostr(deaths) .. ";"
|
||||
for k, v in pairs(player_state) do
|
||||
out_string = out_string .. k ..":" .. v .. ";"
|
||||
end
|
||||
printh(out_string)
|
||||
-- Skip a few frames at start to initialize
|
||||
if not hack_ready then
|
||||
old_update()
|
||||
old_draw()
|
||||
|
||||
-- Screenshot
|
||||
extcmd("screen")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if hack_frame_counter < hack_frame_freeze then
|
||||
-- Freeze frames
|
||||
hack_frame_counter+=1
|
||||
return
|
||||
elseif hack_frame_counter < (hack_frame_foward + hack_frame_freeze + hack_frame_foward_bonus) then
|
||||
-- Forward frames
|
||||
hack_frame_counter+=1
|
||||
old_update()
|
||||
old_draw()
|
||||
extcmd("screen")
|
||||
else
|
||||
-- Wait for input
|
||||
if (not (
|
||||
btn(k_left) or
|
||||
btn(k_right) or
|
||||
btn(k_up) or
|
||||
btn(k_down) or
|
||||
btn(k_jump) or
|
||||
btn(k_dash)
|
||||
)
|
||||
and hack_has_sent_first_message
|
||||
) then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
hack_frame_counter = 0
|
||||
hack_frame_foward_bonus = 0
|
||||
|
||||
|
||||
old_update()
|
||||
old_draw()
|
||||
extcmd("screen")
|
||||
|
||||
hack_has_sent_first_message = true
|
||||
out_string = "dc:" .. tostr(deaths) .. ";"
|
||||
|
||||
if hack_can_dash then
|
||||
out_string = out_string .. "ds:t;"
|
||||
else
|
||||
out_string = out_string .. "ds:f;"
|
||||
end
|
||||
|
||||
for k, v in pairs(hack_player_state) do
|
||||
out_string = out_string .. k ..":" .. v .. ";"
|
||||
end
|
||||
printh(out_string)
|
||||
end
|
||||
end
|
||||
|
||||
-- Called at the same rate as _update
|
||||
function _draw()
|
||||
if draw_frame_counter < frame_rate_hack then
|
||||
|
||||
--old_draw()
|
||||
|
||||
--[[
|
||||
if not (
|
||||
btn(k_left) or
|
||||
btn(k_right) or
|
||||
btn(k_up) or
|
||||
btn(k_down) or
|
||||
btn(k_jump) or
|
||||
btn(k_dash)
|
||||
) and hack_run_delay then
|
||||
return
|
||||
end
|
||||
|
||||
if draw_frame_counter < frame_rate_hack and hack_run_delay then
|
||||
draw_frame_counter += 1
|
||||
else
|
||||
draw_frame_counter = 0
|
||||
old_draw()
|
||||
end
|
||||
--]]
|
||||
end
|
||||
|
||||
function old_update()
|
||||
|
@ -1248,11 +1324,13 @@ function old_update()
|
|||
if freeze>0 then freeze-=1 return end
|
||||
|
||||
-- screenshake
|
||||
if shake>0 then
|
||||
shake-=1
|
||||
camera()
|
||||
if not hack_no_shake then
|
||||
if shake>0 then
|
||||
camera(-2+rnd(5),-2+rnd(5))
|
||||
shake-=1
|
||||
camera()
|
||||
if shake>0 then
|
||||
camera(-2+rnd(5),-2+rnd(5))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Reference in New Issue