From 669798caef39a1c8d8b1837af0843ce0878ac956 Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Sun, 20 Nov 2022 02:01:49 -0800 Subject: [PATCH] Small fixes and remedy autohotkey tooling --- flight.rdbg | Bin 1205 -> 1435 bytes gamestate.c | 57 ++++++++++++++++++++++++++---------------------- main.c | 12 +++++++--- release_all.bat | 1 + tooling.ahk | 7 +----- 5 files changed, 42 insertions(+), 35 deletions(-) diff --git a/flight.rdbg b/flight.rdbg index a01c5d2c43b28489a560ac8374af393ed78698d9..f805329acbb0de2660c566c281716bef2333b948 100644 GIT binary patch delta 275 zcmdnWIh%VzE-McM1B1)t^^A_}PWdU7ddW5u=NnAE#>CI4HF3V`+1LVfL(N1lm);2PBG96HDSV^NKT5QseW}WPu_Y$ps+0wKP$sbnTLWqGBKgu6ZSy zB|rrR6-Lgc#zvMd2FB(F(mJ^(^~QRDys delta 176 zcmbQuy_Iu9E(IN=V#~V#HXiKOrFSO%xDf3=7tIv=w-lE zPWENup8SDPhtVCXW^x3hAeUoNQf5hNkzTUy SUN_NO_MORE_ELECTRICITY_OR_GRAVITY) + if (V2length(V2sub(p, SUN_POS)) > SUN_NO_MORE_ELECTRICITY_OR_GRAVITY) return 0.0f; return SUN_GRAVITY_STRENGTH; } @@ -1532,7 +1531,7 @@ float sun_gravity_at_point(V2 p) void entity_ensure_in_orbit(Entity *e) { assert(e->body != NULL); - + cpVect pos = v2_to_cp(V2sub(entity_pos(e), SUN_POS)); cpFloat r = cpvlength(pos); 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) { - + #define BOX_AT_TYPE(grid, pos, type) \ { \ 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){0.0f, 5.0f}, BoxGyroscope); #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); #endif - } 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; } 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 // 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"); seat_inside_of = NULL; @@ -1804,12 +1802,12 @@ void process(GameState *gs, float dt) { if (cur->box_type == BoxThruster) { - + float wanted_thrust = -V2dot(target_direction, box_facing_vector(cur)); wanted_thrust = clamp01(wanted_thrust); cur->wanted_thrust = wanted_thrust; } - if(cur->box_type == BoxGyroscope) + if (cur->box_type == BoxGyroscope) { cur->wanted_thrust = rotation_this_tick; } @@ -1888,11 +1886,12 @@ void process(GameState *gs, float dt) if (!e->exists) continue; - if (e->body != NULL) + // sun processing { - cpVect p = cpvsub(cpBodyGetPosition(e->body), v2_to_cp(SUN_POS)); - cpFloat sqdist = cpvlengthsq(p); - if (sqdist > (INSTANT_DEATH_DISTANCE_FROM_SUN * INSTANT_DEATH_DISTANCE_FROM_SUN)) + + cpVect pos_rel_sun = v2_to_cp(V2sub(entity_pos(e), SUN_POS)); + 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; if (e->is_grid) @@ -1909,7 +1908,7 @@ void process(GameState *gs, float dt) if (platonic_found) { 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)); 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; } - 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) @@ -1971,9 +1976,9 @@ void process(GameState *gs, float dt) 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))))); - + // 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; } } @@ -2000,7 +2005,7 @@ void process(GameState *gs, float dt) { if (cur_box->box_type == BoxThruster) { - + float energy_to_consume = cur_box->wanted_thrust * THRUSTER_ENERGY_USED_PER_SECOND * dt; 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))); } } - 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) { cur_box->thrust = 0.0f; 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; 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) diff --git a/main.c b/main.c index 84fec73..d322702 100644 --- a/main.c +++ b/main.c @@ -671,7 +671,7 @@ static void ui(bool draw, float dt, float width, float height) static bool picking_new_boxtype = false; static float pick_opacity = 0.0f; { - if(keypressed[SAPP_KEYCODE_ESCAPE].pressed) + if (keypressed[SAPP_KEYCODE_ESCAPE].pressed) picking_new_boxtype = false; AABB pick_modal = (AABB){ .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); if (invited && build_pressed && yes_hovered) + { accept_invite = true; + build_pressed = false; + } if (invited && build_pressed && no_hovered) + { reject_invite = true; + build_pressed = false; + } if (draw) { @@ -1761,7 +1767,7 @@ static void frame(void) sgp_set_image(0, image_solarpanel_charging); sgp_set_color(1.0f, 1.0f, 1.0f, b->sun_amount); 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_set_color(1.0f, 1.0f, 1.0f, 1.0f - b->sun_amount); /* Color to_set = colhexcode(0xeb9834); @@ -1797,7 +1803,7 @@ static void frame(void) set_color(WHITE); } - if(b->box_type == BoxScanner) + if (b->box_type == BoxScanner) { set_color(BLUE); draw_circle(entity_pos(b), SCANNER_RADIUS); diff --git a/release_all.bat b/release_all.bat index cdcd402..5d93e67 100644 --- a/release_all.bat +++ b/release_all.bat @@ -1,3 +1,4 @@ +git push call build_release.bat call update_server.bat tar.exe -a -c -f releases\flight-nonumber.zip flight_release.exe loaded \ No newline at end of file diff --git a/tooling.ahk b/tooling.ahk index 617678c..7925ae5 100644 --- a/tooling.ahk +++ b/tooling.ahk @@ -9,16 +9,11 @@ SetWorkingDir, %A_ScriptDir% ^b:: WinKill, Flight Hosting -Sleep, 20 -WinActivate flight.rdbg -Sleep 20 -Send, {Shift down}{F5}{Shift up} -Send, {F5} WinActivate, flightbuild If WinActive("flightbuild") { Send, {Enter} - Send, msbuild{Enter} + Send, remedybg continue-execution && sleep 0.1 && remedybg.exe stop-debugging && msbuild && remedybg.exe start-debugging {Enter} } return