Files
Bubberstation/code/modules/power/tracker.dm
SmArtKar ad111f4950 Spacemove refactor - Newtonian physics (#84869)
## About The Pull Request

This PR significantly enhances how zero-g movement works. Its no longer
locked to one of 8 directions, everything now has inertia and is
affected by weight. This means that throwing a piece of wire will no
longer completely reverse your movement direction, and that being thrown
out of mass driver no longer will slow you down to a halt at some point.

This leads to following gameplay changes:
* Guns now accelerate you. Ballistics have higher acceleration than
lasers, and higher calibers have higher acceleration than smaller ones.
This means that firing full-auto weapons in zero-g will make you drift
and accelerate significantly. While this can be a hilarious way to
travel in space, it makes using them trickier.
* Impacting a wall or an object while moving at high speeds will cause
you to violently crash into it as if you were thrown. Careful when
exploring!
* Jetpacks now have inertia. Changes introduced in #84712 have been
mostly reverted, although speed buff has been reduced to 0.3 instead of
0.5 (although this is compensated by new movement mechanics, so overall
speed should be roughly equal). All MODsuit jetpacks now possess the
speed boost. Advanced MODsuit jets (which has also been added back) and
captain's jetpack instead have higher acceleration and stabilization
power, providing much more precise control over your movement.
* Firing guns while moving on a jetpack will partially negate your
pack's acceleration, slowing you down. Non-advanced jetpacks'
stabilization is not enough to compensate for heavy caliber weaponry as
sniper rifles, shotguns or rocket launchers.
* You no longer instantly decelerate upon sliding along a wall. Instead,
it may take a few tiles if you are moving at extreme speeds. Passing
over lattices still allows you to grab onto them!

As space movement is angle-based instead of dir-based now, its much more
smooth than before due to using new movement logic.

Example of jetpack stabilization in action:

https://github.com/tgstation/tgstation/assets/44720187/6761a4fd-b7de-4523-97ea-38144b8aab41

And, of course, you can do this now.

![jetpack_500](https://github.com/tgstation/tgstation/assets/44720187/37b11cd8-2bd1-4640-ae0c-5e0cc505bf52)

**This pull request requires extensive gameplay testing before
merging**, as a large amount of numbers have been picked arbitrarily in
an attempt to keep consistency with previous behavior (guns and
normal-sized items applying 1 drift force, which is equal to what
everything applied before this PR). Jetpacks and impacts may also
require adjustments as to not be frustrating to use.

Closes #85165

## Why It's Good For The Game

Zero-G refactor - currently our zero-g movement is rather ugly and can
be uncomfortable to work with. A piece of cable being able to accelerate
you the same as a duffelbag full of items when thrown makes no sense,
and so does instantly changing directions. Inertia-based version is
smoother and more intuitive. This also makes being thrown into space
more of a hazard (possibly opening the door for explosive
decompressions?)
Jetpack inertia and gun changes - this is mostly a consequence of
inertia-based movement. However, zero-g combat being preferred during
modes like warops was an issue due to it negatively affecting everyone
without jetpacks which are in limited supply onboard. This reverts the
mobility changes which severely impacted space exploration, while making
zero-g combat more dangerous and having it require more skill to be a
viable option.

## What's left

- [x] Refactor moth wings to use jetpack code
- [x] Refactor functional wings to use jetpack code
- [x] Locate and fix a recursion runtime that sometimes occurs upon
splattering against a wall
- [x] Add craftable tethers and modify engineering MOD tethers to use
the same system

## Changelog
🆑
add: You can now craft tether anchors, which can be secured with a
wrench and attached to with right click. They won't let you drift into
space and you can adjust tether length/cut it via lmb/rmb/ctrl click on
the wire.
add: MOD tethers now remotely place and connect to tether anchors
instead of throwing you at where they landed.
balance: MOD tethers can now be used in gravity
balance: Jetpacks are now inertia-based. 
balance: Guns can accelerate you significantly in zero-g.
balance: All jetpacks now give you equal speed buff, however advanced
MOD ion jets and captain's jetpack have higher acceleration/deceleration
values.
refactor: Refactored zero-g movement to be inertia-based and utilize
angles instead of directions.
/🆑
2024-09-26 02:49:54 -07:00

158 lines
4.8 KiB
Plaintext

#define TRACKER_Z_OFFSET 13
#define TRACKER_EDGE_Z_OFFSET (TRACKER_Z_OFFSET - 2)
//Solar tracker
//Machine that tracks the sun and reports its direction to the solar controllers
//As long as this is working, solar panels on same powernet will track automatically
/obj/machinery/power/tracker
name = "solar tracker"
desc = "A solar directional tracker."
icon = 'icons/obj/machines/solar.dmi'
icon_state = "tracker_base"
density = TRUE
use_power = NO_POWER_USE
max_integrity = 250
integrity_failure = 0.2
var/id = 0
var/obj/machinery/power/solar_control/control
var/obj/effect/overlay/tracker_dish
var/obj/effect/overlay/tracker_dish_edge
var/azimuth_current
/obj/machinery/power/tracker/Initialize(mapload, obj/item/solar_assembly/S)
. = ..()
tracker_dish_edge = add_panel_overlay("tracker_edge", TRACKER_EDGE_Z_OFFSET)
tracker_dish = add_panel_overlay("tracker", TRACKER_Z_OFFSET)
Make(S)
connect_to_network()
RegisterSignal(SSsun, COMSIG_SUN_MOVED, PROC_REF(sun_update))
/obj/machinery/power/tracker/Destroy()
unset_control() //remove from control computer
return ..()
/obj/machinery/power/tracker/on_changed_z_level(turf/old_turf, turf/new_turf, same_z_layer, notify_contents)
. = ..()
if(same_z_layer)
return
SET_PLANE(tracker_dish_edge, PLANE_TO_TRUE(tracker_dish_edge.plane), new_turf)
SET_PLANE(tracker_dish, PLANE_TO_TRUE(tracker_dish.plane), new_turf)
/obj/effect/overlay/tracker
vis_flags = VIS_INHERIT_ID | VIS_INHERIT_ICON
appearance_flags = TILE_BOUND
blocks_emissive = EMISSIVE_BLOCK_UNIQUE
layer = FLY_LAYER
/obj/machinery/power/tracker/proc/add_panel_overlay(icon_state, z_offset)
var/obj/effect/overlay/tracker/overlay = new(src)
overlay.icon_state = icon_state
SET_PLANE_EXPLICIT(overlay, ABOVE_GAME_PLANE, src)
overlay.pixel_z = z_offset
vis_contents += overlay
return overlay
/obj/machinery/power/tracker/proc/set_control(obj/machinery/power/solar_control/SC)
unset_control()
control = SC
SC.connected_tracker = src
//set the control of the tracker to null and removes it from the previous control computer if needed
/obj/machinery/power/tracker/proc/unset_control()
if(control)
if(control.track == SOLAR_TRACK_AUTO)
control.track = SOLAR_TRACK_OFF
control.connected_tracker = null
control = null
/**
* Get the 2.5D transform for the tracker, given an angle
* Arguments:
* * angle - the angle the panel is facing
*/
/obj/machinery/power/tracker/proc/get_tracker_transform(angle)
// 2.5D solar tracker works by using a magic combination of transforms
var/matrix/turner = matrix()
// Rotate towards sun
turner.Turn(angle)
// Make it skinny on the floor plane
turner.Scale(1, 0.5)
return turner
/obj/machinery/power/tracker/proc/visually_turn_part(part, angle)
var/mid_azimuth = (azimuth_current + angle) / 2
// actually flip to other direction?
if(abs(angle - azimuth_current) > 180)
mid_azimuth = reverse_angle(mid_azimuth)
// Split into 2 parts so it doesn't distort on large changes
animate(part,
transform = get_tracker_transform(mid_azimuth),
time = 2.5 SECONDS, easing = CUBIC_EASING|EASE_IN
)
animate(
transform = get_tracker_transform(angle),
time = 2.5 SECONDS, easing = CUBIC_EASING|EASE_OUT
)
///Tell the controller to turn the solar panels
/obj/machinery/power/tracker/proc/sun_update(datum/source, azimuth)
SIGNAL_HANDLER
visually_turn_part(tracker_dish, azimuth)
visually_turn_part(tracker_dish_edge, azimuth)
azimuth_current = azimuth
if(control && control.track == SOLAR_TRACK_AUTO)
control.set_panels(azimuth)
/obj/machinery/power/tracker/proc/Make(obj/item/solar_assembly/S)
if(!S)
S = new /obj/item/solar_assembly(src)
S.glass_type = /obj/item/stack/sheet/glass
S.tracker = 1
S.update_appearance()
S.set_anchored(TRUE)
S.forceMove(src)
/obj/machinery/power/tracker/crowbar_act(mob/user, obj/item/I)
playsound(src.loc, 'sound/machines/click.ogg', 50, TRUE)
user.visible_message(span_notice("[user] begins to take the glass off [src]."), span_notice("You begin to take the glass off [src]..."))
if(I.use_tool(src, user, 50))
playsound(src.loc, 'sound/items/deconstruct.ogg', 50, TRUE)
user.visible_message(span_notice("[user] takes the glass off [src]."), span_notice("You take the glass off [src]."))
deconstruct(TRUE)
return TRUE
/obj/machinery/power/tracker/atom_break(damage_flag)
. = ..()
if(.)
playsound(loc, 'sound/effects/glass/glassbr3.ogg', 100, TRUE)
unset_control()
/obj/machinery/power/tracker/on_deconstruction(disassembled)
if(disassembled)
var/obj/item/solar_assembly/S = locate() in src
if(S)
S.forceMove(loc)
S.give_glass(machine_stat & BROKEN)
else
playsound(src, SFX_SHATTER, 70, TRUE)
new /obj/item/shard(src.loc)
new /obj/item/shard(src.loc)
// Tracker Electronic
/obj/item/electronics/tracker
name = "tracker electronics"
#undef TRACKER_Z_OFFSET
#undef TRACKER_EDGE_Z_OFFSET