Small fixes and remedy autohotkey tooling

main
Cameron Murphy Reikes 2 years ago
parent 90b11aef4e
commit 669798caef

Binary file not shown.

@ -323,7 +323,6 @@ void create_player(Player *player)
unlock_box(player, BoxMedbay); unlock_box(player, BoxMedbay);
unlock_box(player, BoxSolarPanel); unlock_box(player, BoxSolarPanel);
unlock_box(player, BoxScanner); unlock_box(player, BoxScanner);
} }
void create_player_entity(GameState *gs, Entity *e) void create_player_entity(GameState *gs, Entity *e)
@ -1524,7 +1523,7 @@ float batteries_use_energy(GameState *gs, Entity *grid, float *energy_left_over,
float sun_gravity_at_point(V2 p) float sun_gravity_at_point(V2 p)
{ {
if(V2length(V2sub(p, SUN_POS)) > SUN_NO_MORE_ELECTRICITY_OR_GRAVITY) if (V2length(V2sub(p, SUN_POS)) > SUN_NO_MORE_ELECTRICITY_OR_GRAVITY)
return 0.0f; return 0.0f;
return SUN_GRAVITY_STRENGTH; return SUN_GRAVITY_STRENGTH;
} }
@ -1532,7 +1531,7 @@ float sun_gravity_at_point(V2 p)
void entity_ensure_in_orbit(Entity *e) void entity_ensure_in_orbit(Entity *e)
{ {
assert(e->body != NULL); assert(e->body != NULL);
cpVect pos = v2_to_cp(V2sub(entity_pos(e), SUN_POS)); cpVect pos = v2_to_cp(V2sub(entity_pos(e), SUN_POS));
cpFloat r = cpvlength(pos); cpFloat r = cpvlength(pos);
cpFloat v = cpfsqrt(sun_gravity_at_point(cp_to_v2(pos)) / r) / r; cpFloat v = cpfsqrt(sun_gravity_at_point(cp_to_v2(pos)) / r) / r;
@ -1548,7 +1547,7 @@ V2 box_vel(Entity *box)
void create_station(GameState *gs, V2 pos, enum BoxType platonic_type) void create_station(GameState *gs, V2 pos, enum BoxType platonic_type)
{ {
#define BOX_AT_TYPE(grid, pos, type) \ #define BOX_AT_TYPE(grid, pos, type) \
{ \ { \
Entity *box = new_entity(gs); \ Entity *box = new_entity(gs); \
@ -1598,10 +1597,9 @@ void create_initial_world(GameState *gs)
create_station(gs, (V2){-5.0f,0.0f}, BoxExplosive); create_station(gs, (V2){-5.0f,0.0f}, BoxExplosive);
create_station(gs, (V2){0.0f, 5.0f}, BoxGyroscope); create_station(gs, (V2){0.0f, 5.0f}, BoxGyroscope);
#else #else
create_station(gs, (V2){-50.0f,0.0f}, BoxExplosive); create_station(gs, (V2){-50.0f, 0.0f}, BoxExplosive);
create_station(gs, (V2){0.0f, 100.0f}, BoxGyroscope); create_station(gs, (V2){0.0f, 100.0f}, BoxGyroscope);
#endif #endif
} }
void exit_seat(GameState *gs, Entity *seat_in, Entity *p) void exit_seat(GameState *gs, Entity *seat_in, Entity *p)
@ -1765,10 +1763,10 @@ void process(GameState *gs, float dt)
player->input.rotation = 0.0f; player->input.rotation = 0.0f;
} }
Entity *seat_inside_of = get_entity(gs, p->currently_inside_of_box); Entity *seat_inside_of = get_entity(gs, p->currently_inside_of_box);
// strange rare bug I saw happen, related to explosives, but no idea how to // strange rare bug I saw happen, related to explosives, but no idea how to
// reproduce. @Robust put a breakpoint here, reproduce, and fix it! // reproduce. @Robust put a breakpoint here, reproduce, and fix it!
if(seat_inside_of != NULL && !seat_inside_of->is_box) if (seat_inside_of != NULL && !seat_inside_of->is_box)
{ {
Log("Strange thing happened where player was in non box seat!\n"); Log("Strange thing happened where player was in non box seat!\n");
seat_inside_of = NULL; seat_inside_of = NULL;
@ -1804,12 +1802,12 @@ void process(GameState *gs, float dt)
{ {
if (cur->box_type == BoxThruster) if (cur->box_type == BoxThruster)
{ {
float wanted_thrust = -V2dot(target_direction, box_facing_vector(cur)); float wanted_thrust = -V2dot(target_direction, box_facing_vector(cur));
wanted_thrust = clamp01(wanted_thrust); wanted_thrust = clamp01(wanted_thrust);
cur->wanted_thrust = wanted_thrust; cur->wanted_thrust = wanted_thrust;
} }
if(cur->box_type == BoxGyroscope) if (cur->box_type == BoxGyroscope)
{ {
cur->wanted_thrust = rotation_this_tick; cur->wanted_thrust = rotation_this_tick;
} }
@ -1888,11 +1886,12 @@ void process(GameState *gs, float dt)
if (!e->exists) if (!e->exists)
continue; continue;
if (e->body != NULL) // sun processing
{ {
cpVect p = cpvsub(cpBodyGetPosition(e->body), v2_to_cp(SUN_POS));
cpFloat sqdist = cpvlengthsq(p); cpVect pos_rel_sun = v2_to_cp(V2sub(entity_pos(e), SUN_POS));
if (sqdist > (INSTANT_DEATH_DISTANCE_FROM_SUN * INSTANT_DEATH_DISTANCE_FROM_SUN)) cpFloat sqdist = cpvlengthsq(pos_rel_sun);
if (e->body != NULL && sqdist > (INSTANT_DEATH_DISTANCE_FROM_SUN * INSTANT_DEATH_DISTANCE_FROM_SUN))
{ {
bool platonic_found = false; bool platonic_found = false;
if (e->is_grid) if (e->is_grid)
@ -1909,7 +1908,7 @@ void process(GameState *gs, float dt)
if (platonic_found) if (platonic_found)
{ {
cpBody *body = e->body; cpBody *body = e->body;
cpBodySetVelocity(body, cpvmult(cpBodyGetVelocity(body), -1.0)); cpBodySetVelocity(body, cpvmult(cpBodyGetVelocity(body), -0.5));
cpVect rel_to_sun = cpvsub(cpBodyGetPosition(body), v2_to_cp(SUN_POS)); cpVect rel_to_sun = cpvsub(cpBodyGetPosition(body), v2_to_cp(SUN_POS));
cpBodySetPosition(body, cpvadd(v2_to_cp(SUN_POS), cpvmult(cpvnormalize(rel_to_sun), INSTANT_DEATH_DISTANCE_FROM_SUN))); cpBodySetPosition(body, cpvadd(v2_to_cp(SUN_POS), cpvmult(cpvnormalize(rel_to_sun), INSTANT_DEATH_DISTANCE_FROM_SUN)));
} }
@ -1919,14 +1918,20 @@ void process(GameState *gs, float dt)
} }
continue; continue;
} }
if (sqdist < (SUN_RADIUS * SUN_RADIUS)) if (!e->is_grid) // grids aren't damaged (this edge case sucks!)
{ {
e->damage += 10.0f * dt; sqdist = cpvlengthsq(cpvsub(v2_to_cp(entity_pos(e)), v2_to_cp(SUN_POS)));
if (sqdist < (SUN_RADIUS * SUN_RADIUS))
{
e->damage += 10.0f * dt;
}
} }
cpVect g = cpvmult(p, -sun_gravity_at_point(entity_pos(e)) / (sqdist * cpfsqrt(sqdist)));
cpBodyUpdateVelocity(e->body, g, 1.0f, dt); if (e->body != NULL)
{
cpVect g = cpvmult(pos_rel_sun, -sun_gravity_at_point(entity_pos(e)) / (sqdist * cpfsqrt(sqdist)));
cpBodyUpdateVelocity(e->body, g, 1.0f, dt);
}
} }
if (e->is_explosion) if (e->is_explosion)
@ -1971,9 +1976,9 @@ void process(GameState *gs, float dt)
if (cur_box->box_type == BoxSolarPanel) if (cur_box->box_type == BoxSolarPanel)
{ {
cur_box->sun_amount = clamp01(V2dot(box_facing_vector(cur_box), V2normalize(V2sub(SUN_POS, entity_pos(cur_box))))); cur_box->sun_amount = clamp01(V2dot(box_facing_vector(cur_box), V2normalize(V2sub(SUN_POS, entity_pos(cur_box)))));
// less sun the farther away you are! // less sun the farther away you are!
cur_box->sun_amount *= lerp(1.0f, 0.0f, clamp01(V2length(V2sub(entity_pos(cur_box), SUN_POS))/SUN_NO_MORE_ELECTRICITY_OR_GRAVITY)); cur_box->sun_amount *= lerp(1.0f, 0.0f, clamp01(V2length(V2sub(entity_pos(cur_box), SUN_POS)) / SUN_NO_MORE_ELECTRICITY_OR_GRAVITY));
energy_to_add += cur_box->sun_amount * SOLAR_ENERGY_PER_SECOND * dt; energy_to_add += cur_box->sun_amount * SOLAR_ENERGY_PER_SECOND * dt;
} }
} }
@ -2000,7 +2005,7 @@ void process(GameState *gs, float dt)
{ {
if (cur_box->box_type == BoxThruster) if (cur_box->box_type == BoxThruster)
{ {
float energy_to_consume = cur_box->wanted_thrust * THRUSTER_ENERGY_USED_PER_SECOND * dt; float energy_to_consume = cur_box->wanted_thrust * THRUSTER_ENERGY_USED_PER_SECOND * dt;
if (energy_to_consume > 0.0f) if (energy_to_consume > 0.0f)
{ {
@ -2011,16 +2016,16 @@ void process(GameState *gs, float dt)
cpBodyApplyForceAtWorldPoint(grid->body, v2_to_cp(thruster_force(cur_box)), v2_to_cp(entity_pos(cur_box))); cpBodyApplyForceAtWorldPoint(grid->body, v2_to_cp(thruster_force(cur_box)), v2_to_cp(entity_pos(cur_box)));
} }
} }
if(cur_box->box_type == BoxGyroscope) if (cur_box->box_type == BoxGyroscope)
{ {
float energy_to_consume = fabsf(cur_box->wanted_thrust * GYROSCOPE_ENERGY_USED_PER_SECOND* dt); float energy_to_consume = fabsf(cur_box->wanted_thrust * GYROSCOPE_ENERGY_USED_PER_SECOND * dt);
if (energy_to_consume > 0.0f) if (energy_to_consume > 0.0f)
{ {
cur_box->thrust = 0.0f; cur_box->thrust = 0.0f;
float energy_unconsumed = batteries_use_energy(gs, grid, &non_battery_energy_left_over, energy_to_consume); float energy_unconsumed = batteries_use_energy(gs, grid, &non_battery_energy_left_over, energy_to_consume);
cur_box->thrust = (1.0f - energy_unconsumed / energy_to_consume) * cur_box->wanted_thrust; cur_box->thrust = (1.0f - energy_unconsumed / energy_to_consume) * cur_box->wanted_thrust;
if (fabsf(cur_box->thrust) >= 0.0f) if (fabsf(cur_box->thrust) >= 0.0f)
cpBodySetTorque(grid->body, cpBodyGetTorque(grid->body) + cur_box->thrust*GYROSCOPE_TORQUE); cpBodySetTorque(grid->body, cpBodyGetTorque(grid->body) + cur_box->thrust * GYROSCOPE_TORQUE);
} }
} }
if (cur_box->box_type == BoxMedbay) if (cur_box->box_type == BoxMedbay)

@ -671,7 +671,7 @@ static void ui(bool draw, float dt, float width, float height)
static bool picking_new_boxtype = false; static bool picking_new_boxtype = false;
static float pick_opacity = 0.0f; static float pick_opacity = 0.0f;
{ {
if(keypressed[SAPP_KEYCODE_ESCAPE].pressed) if (keypressed[SAPP_KEYCODE_ESCAPE].pressed)
picking_new_boxtype = false; picking_new_boxtype = false;
AABB pick_modal = (AABB){ AABB pick_modal = (AABB){
.x = width * 0.25f, .x = width * 0.25f,
@ -795,9 +795,15 @@ static void ui(bool draw, float dt, float width, float height)
no_size = lerp(no_size, no_hovered ? 75.0f : 50.0f, dt * 9.0f); no_size = lerp(no_size, no_hovered ? 75.0f : 50.0f, dt * 9.0f);
if (invited && build_pressed && yes_hovered) if (invited && build_pressed && yes_hovered)
{
accept_invite = true; accept_invite = true;
build_pressed = false;
}
if (invited && build_pressed && no_hovered) if (invited && build_pressed && no_hovered)
{
reject_invite = true; reject_invite = true;
build_pressed = false;
}
if (draw) if (draw)
{ {
@ -1761,7 +1767,7 @@ static void frame(void)
sgp_set_image(0, image_solarpanel_charging); sgp_set_image(0, image_solarpanel_charging);
sgp_set_color(1.0f, 1.0f, 1.0f, b->sun_amount); sgp_set_color(1.0f, 1.0f, 1.0f, b->sun_amount);
pipeline_scope(goodpixel_pipeline) pipeline_scope(goodpixel_pipeline)
draw_texture_centered(entity_pos(b), BOX_SIZE); draw_texture_centered(entity_pos(b), BOX_SIZE);
sgp_reset_image(0); sgp_reset_image(0);
sgp_set_color(1.0f, 1.0f, 1.0f, 1.0f - b->sun_amount); sgp_set_color(1.0f, 1.0f, 1.0f, 1.0f - b->sun_amount);
/* Color to_set = colhexcode(0xeb9834); /* Color to_set = colhexcode(0xeb9834);
@ -1797,7 +1803,7 @@ static void frame(void)
set_color(WHITE); set_color(WHITE);
} }
if(b->box_type == BoxScanner) if (b->box_type == BoxScanner)
{ {
set_color(BLUE); set_color(BLUE);
draw_circle(entity_pos(b), SCANNER_RADIUS); draw_circle(entity_pos(b), SCANNER_RADIUS);

@ -1,3 +1,4 @@
git push
call build_release.bat call build_release.bat
call update_server.bat call update_server.bat
tar.exe -a -c -f releases\flight-nonumber.zip flight_release.exe loaded tar.exe -a -c -f releases\flight-nonumber.zip flight_release.exe loaded

@ -9,16 +9,11 @@ SetWorkingDir, %A_ScriptDir%
^b:: ^b::
WinKill, Flight Hosting WinKill, Flight Hosting
Sleep, 20
WinActivate flight.rdbg
Sleep 20
Send, {Shift down}{F5}{Shift up}
Send, {F5}
WinActivate, flightbuild WinActivate, flightbuild
If WinActive("flightbuild") If WinActive("flightbuild")
{ {
Send, {Enter} Send, {Enter}
Send, msbuild{Enter} Send, remedybg continue-execution && sleep 0.1 && remedybg.exe stop-debugging && msbuild && remedybg.exe start-debugging {Enter}
} }
return return

Loading…
Cancel
Save