Skip to content

Commit

Permalink
[Port] Gravity fixes that i forgor (#12009)
Browse files Browse the repository at this point in the history
* 88362

* Update forced_gravity.dm

* 74285

* wew

* Update gravitygenerator.dm

* gravity areas

* Update gravitygenerator.dm

* Update gravitygenerator.dm
  • Loading branch information
XeonMations authored Dec 24, 2024
1 parent 72350f6 commit fe50659
Show file tree
Hide file tree
Showing 27 changed files with 123 additions and 87 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
#define HIDDEN_STASH_LOCATION (1<<10)
/// Indicates that this area uses an APC from another location (Skips the unit tests for APCs)
#define REMOTE_APC (1<<11)
/// This area is prevented from having gravity (ie. space, nearstation, or outside solars)
#define NO_GRAVITY (1<<12)

/*
These defines are used specifically with the atom/pass_flags bitmask
Expand Down
6 changes: 4 additions & 2 deletions code/__DEFINES/gravity.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
* This should only be possible on multi-z maps because it works like shit on maps that aren't.
*/
#define NEGATIVE_GRAVITY -1

#define STANDARD_GRAVITY 1 //Anything above this is high gravity, anything below no grav until negative gravity
/// Used to indicate no gravity
#define ZERO_GRAVITY 0
//Anything above this is high gravity, anything below no grav until negative gravity
#define STANDARD_GRAVITY 1
/// The gravity strength threshold for high gravity damage.
#define GRAVITY_DAMAGE_THRESHOLD 3
/// The scaling factor for high gravity damage.
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ GLOBAL_LIST_INIT(typecache_powerfailure_safe_areas, typecacheof(/area/engine/eng
newA = new area_choice
newA.setup(str)
newA.set_dynamic_lighting()
newA.has_gravity = oldA.has_gravity
newA.default_gravity = oldA.default_gravity
else
newA = area_choice

Expand Down
13 changes: 10 additions & 3 deletions code/datums/elements/forced_gravity.dm
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
/datum/element/forced_gravity
element_flags = ELEMENT_BESPOKE
id_arg_index = 2
///the level of gravity we force unto our target
var/gravity
///whether we will override the turf if it forces no gravity
var/ignore_space

/datum/element/forced_gravity/Attach(datum/target, gravity=1, ignore_space=FALSE, can_override = FALSE)
/datum/element/forced_gravity/Attach(datum/target, gravity = 1, ignore_space = FALSE, can_override = FALSE)
. = ..()
if(!isatom(target))
return ELEMENT_INCOMPATIBLE

var/our_ref = REF(src)
if(HAS_TRAIT_FROM(target, TRAIT_FORCED_GRAVITY, our_ref))
return

src.gravity = gravity
src.ignore_space = ignore_space

RegisterSignal(target, COMSIG_ATOM_HAS_GRAVITY, PROC_REF(gravity_check), override = can_override)
if(isturf(target))
RegisterSignal(target, COMSIG_TURF_HAS_GRAVITY, PROC_REF(turf_gravity_check), override = can_override)

ADD_TRAIT(target, TRAIT_FORCED_GRAVITY, REF(src))
ADD_TRAIT(target, TRAIT_FORCED_GRAVITY, our_ref)

/datum/element/forced_gravity/Detach(datum/source, force)
/datum/element/forced_gravity/Detach(datum/source)
. = ..()
var/static/list/signals_b_gone = list(COMSIG_ATOM_HAS_GRAVITY, COMSIG_TURF_HAS_GRAVITY)
UnregisterSignal(source, signals_b_gone)
REMOVE_TRAIT(source, TRAIT_FORCED_GRAVITY, REF(src))

/datum/element/forced_gravity/proc/gravity_check(datum/source, turf/location, list/gravs)
SIGNAL_HANDLER

if(!ignore_space && location.force_no_gravity)
return FALSE
gravs += gravity
Expand Down
19 changes: 13 additions & 6 deletions code/game/area/Space_Station_13_areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,32 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
power_light = FALSE
power_equip = FALSE
power_environ = FALSE
area_flags = UNIQUE_AREA
area_flags = UNIQUE_AREA | NO_GRAVITY
outdoors = TRUE
ambience_index = null
ambient_music_index = AMBIENCE_SPACE
ambient_buzz = null //Space is deafeningly quiet
sound_environment = SOUND_AREA_SPACE
fullbright_type = FULLBRIGHT_STARLIGHT
default_gravity = ZERO_GRAVITY

/area/space/nearstation
icon_state = "space_near"
dynamic_lighting = DYNAMIC_LIGHTING_IFSTARLIGHT
default_gravity = ZERO_GRAVITY

/area/start
name = "start area"
icon_state = "start"
requires_power = FALSE
dynamic_lighting = DYNAMIC_LIGHTING_DISABLED
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
ambience_index = null
ambient_buzz = null

/area/testroom
requires_power = FALSE
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
name = "Test Room"
icon_state = "storage"

Expand All @@ -62,7 +64,7 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
name = "Asteroid"
icon_state = "asteroid"
always_unpowered = TRUE
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
ambience_index = AMBIENCE_MINING
sound_environment = SOUND_AREA_ASTEROID
area_flags = UNIQUE_AREA
Expand Down Expand Up @@ -965,10 +967,11 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
/area/solar
requires_power = FALSE
dynamic_lighting = DYNAMIC_LIGHTING_IFSTARLIGHT
area_flags = UNIQUE_AREA
area_flags = UNIQUE_AREA | NO_GRAVITY
flags_1 = NONE
ambience_index = AMBIENCE_ENGI
sound_environment = SOUND_AREA_SPACE
default_gravity = ZERO_GRAVITY

/area/solar/fore
name = "Fore Solar Array"
Expand Down Expand Up @@ -1535,11 +1538,15 @@ NOTE: there are two lists of areas in the end of this file: centcom and station

/area/science/test_area
name = "Toxins Test Area"
area_flags = BLOBS_ALLOWED | UNIQUE_AREA
area_flags = BLOBS_ALLOWED | UNIQUE_AREA | NO_GRAVITY
icon_state = "tox_test"
lights_always_start_on = TRUE
always_unpowered = TRUE

/area/science/test_area/planet
name = "Planetary Toxins Test Area"
area_flags = BLOBS_ALLOWED | UNIQUE_AREA

/area/science/mixing
name = "Toxins Mixing Lab"
icon_state = "tox_mix"
Expand Down
3 changes: 2 additions & 1 deletion code/game/area/areas.dm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
var/power_light = TRUE
var/power_environ = TRUE

var/has_gravity = FALSE
/// The default gravity for the area
var/default_gravity = ZERO_GRAVITY
///Are you forbidden from teleporting to the area? (centcom, mobs, wizard, hand teleporter)
var/teleport_restriction = TELEPORT_ALLOW_ALL

Expand Down
6 changes: 3 additions & 3 deletions code/game/area/areas/away_content.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Unused icons for new areas are "awaycontent1" ~ "awaycontent30"
/area/awaymission
name = "Strange Location"
icon_state = "away"
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
ambience_index = AMBIENCE_AWAY
sound_environment = SOUND_ENVIRONMENT_ROOM
airlock_hack_difficulty = AIRLOCK_WIRE_SECURITY_ELITE
Expand All @@ -17,13 +17,13 @@ Unused icons for new areas are "awaycontent1" ~ "awaycontent30"
icon_state = "away"
dynamic_lighting = DYNAMIC_LIGHTING_DISABLED
requires_power = FALSE
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
ambientsounds = list('sound/ambience/shore.ogg', 'sound/ambience/seag1.ogg','sound/ambience/seag2.ogg','sound/ambience/seag2.ogg','sound/ambience/ambiodd.ogg','sound/ambience/ambinice.ogg')

/area/awaymission/errorroom
name = "Super Secret Room"
dynamic_lighting = DYNAMIC_LIGHTING_DISABLED
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY

/area/awaymission/vr
name = "Virtual Reality"
Expand Down
14 changes: 7 additions & 7 deletions code/game/area/areas/centcom.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
icon_state = "centcom"
dynamic_lighting = DYNAMIC_LIGHTING_ENABLED
requires_power = FALSE
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
teleport_restriction = TELEPORT_ALLOW_NONE
area_flags = VALID_TERRITORY | UNIQUE_AREA
flags_1 = NONE
Expand Down Expand Up @@ -86,7 +86,7 @@
icon_state = "yellow"
dynamic_lighting = DYNAMIC_LIGHTING_ENABLED
requires_power = FALSE
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
flags_1 = NONE
camera_networks = list(CAMERA_NETWORK_THUNDERDOME)

Expand Down Expand Up @@ -125,7 +125,7 @@
icon_state = "yellow"
dynamic_lighting = DYNAMIC_LIGHTING_ENABLED
requires_power = FALSE
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
teleport_restriction = TELEPORT_ALLOW_WIZARD
area_flags = VALID_TERRITORY | UNIQUE_AREA
flags_1 = NONE
Expand All @@ -139,7 +139,7 @@
requires_power = FALSE
teleport_restriction = TELEPORT_ALLOW_ABDUCTORS
area_flags = VALID_TERRITORY | UNIQUE_AREA
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
flags_1 = NONE
network_root_id = "ALIENS"
airlock_hack_difficulty = AIRLOCK_WIRE_SECURITY_MAXIMUM
Expand All @@ -149,7 +149,7 @@
name = "Syndicate Mothership"
icon_state = "syndie-ship"
requires_power = FALSE
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
teleport_restriction = TELEPORT_ALLOW_NONE
area_flags = VALID_TERRITORY | UNIQUE_AREA
flags_1 = NONE
Expand All @@ -175,7 +175,7 @@
icon_state = "yellow"
requires_power = FALSE
dynamic_lighting = DYNAMIC_LIGHTING_DISABLED
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
airlock_hack_difficulty = AIRLOCK_WIRE_SECURITY_ELITE

/area/ctf/control_room
Expand Down Expand Up @@ -212,7 +212,7 @@
icon_state = "yellow"
requires_power = FALSE
dynamic_lighting = DYNAMIC_LIGHTING_DISABLED
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
teleport_restriction = TELEPORT_ALLOW_CLOCKWORK
area_flags = VALID_TERRITORY | UNIQUE_AREA | HIDDEN_AREA
ambience_index = AMBIENCE_REEBE
Expand Down
2 changes: 1 addition & 1 deletion code/game/area/areas/iceland.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
flags_1 = NONE
min_ambience_cooldown = 70 SECONDS
max_ambience_cooldown = 220 SECONDS
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
ambience_index = AMBIENCE_SPOOKY
sound_environment = SOUND_AREA_LARGE_SOFTFLOOR
area_flags = UNIQUE_AREA | FLORA_ALLOWED
Expand Down
4 changes: 2 additions & 2 deletions code/game/area/areas/mining.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/area/mine
icon_state = "mining"
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
lighting_colour_tube = "#ffe8d2"
lighting_colour_bulb = "#ffdcb7"
area_flags = VALID_TERRITORY | UNIQUE_AREA | FLORA_ALLOWED
Expand Down Expand Up @@ -88,7 +88,7 @@

/area/lavaland
icon_state = "mining"
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
flags_1 = NONE
sound_environment = SOUND_AREA_LAVALAND
ambient_buzz = 'sound/ambience/magma.ogg'
Expand Down
4 changes: 2 additions & 2 deletions code/game/area/areas/ruins/_ruins.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/area/ruin
name = "\improper Unexplored Location"
icon_state = "away"
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
area_flags = HIDDEN_AREA | BLOBS_ALLOWED
dynamic_lighting = DYNAMIC_LIGHTING_ENABLED
ambience_index = AMBIENCE_RUINS
Expand All @@ -14,7 +14,7 @@
always_unpowered = FALSE

/area/ruin/unpowered/no_grav
has_gravity = FALSE
default_gravity = ZERO_GRAVITY

/area/ruin/powered
requires_power = FALSE
12 changes: 6 additions & 6 deletions code/game/area/areas/ruins/space.dm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//Space Ruin Parents

/area/ruin/space
has_gravity = FALSE
default_gravity = ZERO_GRAVITY
area_flags = UNIQUE_AREA

/area/ruin/space/has_grav
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY

/area/ruin/space/has_grav/powered
requires_power = FALSE
Expand Down Expand Up @@ -228,12 +228,12 @@
/area/ruin/space/has_grav/ancientstation/space
name = "Exposed To Space"
icon_state = "teleporter"
has_gravity = FALSE
default_gravity = ZERO_GRAVITY

/area/ruin/space/has_grav/ancientstation/atmo
name = "Beta Station Atmospherics"
icon_state = "red"
has_gravity = FALSE
default_gravity = ZERO_GRAVITY
ambience_index = AMBIENCE_ENGI

/area/ruin/space/has_grav/ancientstation/betanorth
Expand Down Expand Up @@ -359,12 +359,12 @@
/area/ruin/space/djstation
name = "Ruskie DJ Station"
icon_state = "DJ"
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY

/area/ruin/space/djstation/solars
name = "DJ Station Solars"
icon_state = "DJ"
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY


//ABANDONED TELEPORTER
Expand Down
2 changes: 1 addition & 1 deletion code/game/area/areas/shuttles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
name = "Shuttle"
requires_power = FALSE
dynamic_lighting = DYNAMIC_LIGHTING_ENABLED
has_gravity = STANDARD_GRAVITY
default_gravity = STANDARD_GRAVITY
always_unpowered = FALSE
// Loading the same shuttle map at a different time will produce distinct area instances.
area_flags = NONE
Expand Down
3 changes: 2 additions & 1 deletion code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1923,6 +1923,7 @@ CREATION_TEST_IGNORE_SUBTYPES(/atom)
* Gravity situations:
* * No gravity if you're not in a turf
* * No gravity if this atom is in is a space turf
* * No gravity if the area has NO_GRAVITY flag (space, ordnance bomb site, nearstation, solars)
* * Gravity if the area it's in always has gravity
* * Gravity if there's a gravity generator on the z level
* * Gravity if the Z level has an SSMappingTrait for ZTRAIT_GRAVITY
Expand Down Expand Up @@ -1950,7 +1951,7 @@ CREATION_TEST_IGNORE_SUBTYPES(/atom)

var/area/turf_area = gravity_turf.loc

return !gravity_turf.force_no_gravity && (SSmapping.gravity_by_z_level[gravity_turf.z] || turf_area.has_gravity)
return (!gravity_turf.force_no_gravity && !(turf_area.area_flags & NO_GRAVITY)) && (SSmapping.gravity_by_z_level[gravity_turf.z] || turf_area.default_gravity)

/*
* Called when something made out of plasma is exposed to high temperatures.
Expand Down
16 changes: 8 additions & 8 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -686,23 +686,23 @@
//Return 0 to have src start/keep drifting in a no-grav area and 1 to stop/not start drifting
//Mobs should return 1 if they should be able to move of their own volition, see client/Move() in mob_movement.dm
//movement_dir == 0 when stopping or any dir when trying to move
/atom/movable/proc/Process_Spacemove(movement_dir = 0)
/atom/movable/proc/Process_Spacemove(movement_dir = FALSE)
if(has_gravity(src))
return 1
return TRUE

if(pulledby)
return 1
if(pulledby && (pulledby.pulledby != src || moving_from_pull))
return TRUE

if(throwing)
return 1
return TRUE

if(!isturf(loc))
return 1
return TRUE

if(locate(/obj/structure/lattice) in range(1, get_turf(src))) //Not realistic but makes pushing things in space easier
return 1
return TRUE

return 0
return FALSE


/// Only moves the object if it's under no gravity
Expand Down
Loading

0 comments on commit fe50659

Please sign in to comment.