mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
New ZAS version, stable and efficient. Git broke the everything so it's in one commit.
This commit is contained in:
@@ -1,53 +1,3 @@
|
||||
/*
|
||||
|
||||
CONTAINS:
|
||||
All AirflowX() procs, all Variable Setting Controls for airflow, save/load variable tweaks for airflow.
|
||||
|
||||
VARIABLES:
|
||||
|
||||
atom/movable/airflow_dest
|
||||
The destination turf of a flying object.
|
||||
|
||||
atom/movable/airflow_speed
|
||||
The speed (1-15) at which a flying object is traveling to airflow_dest. Decays over time.
|
||||
|
||||
|
||||
OVERLOADABLE PROCS:
|
||||
|
||||
mob/airflow_stun()
|
||||
Contains checks for and results of being stunned by airflow.
|
||||
Called when airflow quantities exceed airflow_medium_pressure.
|
||||
RETURNS: Null
|
||||
|
||||
atom/movable/check_airflow_movable(n)
|
||||
Contains checks for moving any object due to airflow.
|
||||
n is the pressure that is flowing.
|
||||
RETURNS: 1 if the object moves under the air conditions, 0 if it stays put.
|
||||
|
||||
atom/movable/airflow_hit(atom/A)
|
||||
Contains results of hitting a solid object (A) due to airflow.
|
||||
A is the dense object hit.
|
||||
Use airflow_speed to determine how fast the projectile was going.
|
||||
|
||||
|
||||
AUTOMATIC PROCS:
|
||||
|
||||
Airflow(zone/A, zone/B)
|
||||
Causes objects to fly along a pressure gradient.
|
||||
Called by zone updates. A and B are two connected zones.
|
||||
|
||||
AirflowSpace(zone/A)
|
||||
Causes objects to fly into space.
|
||||
Called by zone updates. A is a zone connected to space.
|
||||
|
||||
atom/movable/GotoAirflowDest(n)
|
||||
atom/movable/RepelAirflowDest(n)
|
||||
Called by main airflow procs to cause the object to fly to or away from destination at speed n.
|
||||
Probably shouldn't call this directly unless you know what you're
|
||||
doing and have set airflow_dest. airflow_hit() will be called if the object collides with an obstacle.
|
||||
|
||||
*/
|
||||
|
||||
mob/var/tmp/last_airflow_stun = 0
|
||||
mob/proc/airflow_stun()
|
||||
if(stat == 2)
|
||||
@@ -108,124 +58,6 @@ obj/item/check_airflow_movable(n)
|
||||
if(4,5)
|
||||
if(n < vsc.airflow_medium_pressure) return 0
|
||||
|
||||
//The main airflow code. Called by zone updates.
|
||||
//Zones A and B are air zones. n represents the amount of air moved.
|
||||
|
||||
proc/Airflow(zone/A, zone/B)
|
||||
|
||||
var/n = B.air.return_pressure() - A.air.return_pressure()
|
||||
|
||||
//Don't go any further if n is lower than the lowest value needed for airflow.
|
||||
if(abs(n) < vsc.airflow_lightest_pressure) return
|
||||
|
||||
//These turfs are the midway point between A and B, and will be the destination point for thrown objects.
|
||||
var/list/connection/connections_A = A.connections
|
||||
var/list/turf/connected_turfs = list()
|
||||
for(var/connection/C in connections_A) //Grab the turf that is in the zone we are flowing to (determined by n)
|
||||
if( ( A == C.A.zone || A == C.zone_A ) && ( B == C.B.zone || B == C.zone_B ) )
|
||||
if(n < 0)
|
||||
connected_turfs |= C.B
|
||||
else
|
||||
connected_turfs |= C.A
|
||||
else if( ( A == C.B.zone || A == C.zone_B ) && ( B == C.A.zone || B == C.zone_A ) )
|
||||
if(n < 0)
|
||||
connected_turfs |= C.A
|
||||
else
|
||||
connected_turfs |= C.B
|
||||
|
||||
//Get lists of things that can be thrown across the room for each zone (assumes air is moving from zone B to zone A)
|
||||
var/list/air_sucked = B.movables()
|
||||
var/list/air_repelled = A.movables()
|
||||
if(n < 0)
|
||||
//air is moving from zone A to zone B
|
||||
var/list/temporary_pplz = air_sucked
|
||||
air_sucked = air_repelled
|
||||
air_repelled = temporary_pplz
|
||||
|
||||
for(var/atom/movable/M in air_sucked)
|
||||
|
||||
if(M.last_airflow > world.time - vsc.airflow_delay) continue
|
||||
|
||||
//Check for knocking people over
|
||||
if(ismob(M) && n > vsc.airflow_stun_pressure)
|
||||
if(M:status_flags & GODMODE) continue
|
||||
M:airflow_stun()
|
||||
|
||||
if(M.check_airflow_movable(n))
|
||||
|
||||
//Check for things that are in range of the midpoint turfs.
|
||||
var/list/close_turfs = list()
|
||||
for(var/turf/U in connected_turfs)
|
||||
if(M in range(U)) close_turfs += U
|
||||
if(!close_turfs.len) continue
|
||||
|
||||
//If they're already being tossed, don't do it again.
|
||||
if(!M.airflow_speed)
|
||||
|
||||
M.airflow_dest = pick(close_turfs) //Pick a random midpoint to fly towards.
|
||||
|
||||
spawn M.GotoAirflowDest(abs(n)/5)
|
||||
|
||||
//Do it again for the stuff in the other zone, making it fly away.
|
||||
for(var/atom/movable/M in air_repelled)
|
||||
|
||||
if(M.last_airflow > world.time - vsc.airflow_delay) continue
|
||||
|
||||
if(ismob(M) && abs(n) > vsc.airflow_medium_pressure)
|
||||
if(M:status_flags & GODMODE) continue
|
||||
M:airflow_stun()
|
||||
|
||||
if(M.check_airflow_movable(abs(n)))
|
||||
|
||||
var/list/close_turfs = list()
|
||||
for(var/turf/U in connected_turfs)
|
||||
if(M in range(U)) close_turfs += U
|
||||
if(!close_turfs.len) continue
|
||||
|
||||
//If they're already being tossed, don't do it again.
|
||||
if(!M.airflow_speed)
|
||||
|
||||
M.airflow_dest = pick(close_turfs) //Pick a random midpoint to fly towards.
|
||||
|
||||
spawn M.RepelAirflowDest(abs(n)/5)
|
||||
|
||||
proc/AirflowSpace(zone/A)
|
||||
|
||||
//The space version of the Airflow(A,B,n) proc.
|
||||
|
||||
var/n = A.air.return_pressure()
|
||||
//Here, n is determined by only the pressure in the room.
|
||||
|
||||
if(n < vsc.airflow_lightest_pressure) return
|
||||
|
||||
var/list/connected_turfs = A.unsimulated_tiles //The midpoints are now all the space connections.
|
||||
var/list/pplz = A.movables() //We only need to worry about things in the zone, not things in space.
|
||||
|
||||
for(var/atom/movable/M in pplz)
|
||||
|
||||
if(M.last_airflow > world.time - vsc.airflow_delay) continue
|
||||
|
||||
if(ismob(M) && n > vsc.airflow_stun_pressure)
|
||||
var/mob/O = M
|
||||
if(O.status_flags & GODMODE) continue
|
||||
O.airflow_stun()
|
||||
|
||||
if(M.check_airflow_movable(n))
|
||||
|
||||
var/list/close_turfs = list()
|
||||
for(var/turf/U in connected_turfs)
|
||||
if(M in range(U)) close_turfs += U
|
||||
if(!close_turfs.len) continue
|
||||
|
||||
//If they're already being tossed, don't do it again.
|
||||
if(!M.airflow_speed)
|
||||
|
||||
M.airflow_dest = pick(close_turfs) //Pick a random midpoint to fly towards.
|
||||
spawn
|
||||
if(M) M.GotoAirflowDest(n/10)
|
||||
//Sometimes shit breaks, and M isn't there after the spawn.
|
||||
|
||||
|
||||
/atom/movable/var/tmp/turf/airflow_dest
|
||||
/atom/movable/var/tmp/airflow_speed = 0
|
||||
/atom/movable/var/tmp/airflow_time = 0
|
||||
@@ -416,4 +248,4 @@ zone/proc/movables()
|
||||
for(var/atom/A in T)
|
||||
if(istype(A, /obj/effect) || istype(A, /mob/aiEye))
|
||||
continue
|
||||
. += A
|
||||
. += A
|
||||
Reference in New Issue
Block a user