yahar should fix being sucked or blown away from a zone you're nowhere near anymore.

This commit is contained in:
D3athrow
2015-03-09 22:48:26 -05:00
parent 0f9fd315b8
commit 4fad74d811
2 changed files with 81 additions and 68 deletions

View File

@@ -117,7 +117,7 @@ obj/item/check_airflow_movable(n)
//Zones A and B are air zones. n represents the amount of air moved. //Zones A and B are air zones. n represents the amount of air moved.
proc/Airflow(zone/A, zone/B) proc/Airflow(zone/A, zone/B)
set background = 1
var/n = B.air.return_pressure() - A.air.return_pressure() 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. //Don't go any further if n is lower than the lowest value needed for airflow.
@@ -139,95 +139,95 @@ proc/Airflow(zone/A, zone/B)
connected_turfs |= C.B 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) //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() spawn()
var/list/air_repelled = A.movables() var/list/air_sucked = B.movables()
if(n < 0) var/list/air_repelled = A.movables()
//air is moving from zone A to zone B if(n < 0)
var/list/temporary_pplz = air_sucked //air is moving from zone A to zone B
air_sucked = air_repelled var/list/temporary_pplz = air_sucked
air_repelled = temporary_pplz air_sucked = air_repelled
air_repelled = temporary_pplz
if(zas_settings.Get(/datum/ZAS_Setting/airflow_push) || 1) // If enabled if(zas_settings.Get(/datum/ZAS_Setting/airflow_push) || 1) // If enabled
for(var/atom/movable/M in air_sucked) for(var/atom/movable/M in air_sucked)
if(M.last_airflow > world.time - zas_settings.Get(/datum/ZAS_Setting/airflow_delay)) continue if(M.last_airflow > world.time - zas_settings.Get(/datum/ZAS_Setting/airflow_delay)) continue
//Check for knocking people over //Check for knocking people over
if(ismob(M) && n > zas_settings.Get(/datum/ZAS_Setting/airflow_stun_pressure)) if(ismob(M) && n > zas_settings.Get(/datum/ZAS_Setting/airflow_stun_pressure))
if(M:status_flags & GODMODE) continue if(M:status_flags & GODMODE) continue
M:airflow_stun() M:airflow_stun()
if(M.check_airflow_movable(n)) if(M.check_airflow_movable(n))
//Check for things that are in range of the midpoint turfs. //Check for things that are in range of the midpoint turfs.
var/list/close_turfs = list() var/list/close_turfs = list()
for(var/turf/U in connected_turfs) for(var/turf/U in connected_turfs)
if(M in range(U)) close_turfs += U if(M in range(U)) close_turfs += U
if(!close_turfs.len) continue if(!close_turfs.len) continue
//If they're already being tossed, don't do it again. //If they're already being tossed, don't do it again.
if(!M.airflow_speed) if(!M.airflow_speed)
M.airflow_dest = pick(close_turfs) //Pick a random midpoint to fly towards. M.airflow_dest = pick(close_turfs) //Pick a random midpoint to fly towards.
spawn M.GotoAirflowDest(abs(n)/5) M.GotoAirflowDest(abs(n)/5)
//Do it again for the stuff in the other zone, making it fly away. //Do it again for the stuff in the other zone, making it fly away.
for(var/atom/movable/M in air_repelled) for(var/atom/movable/M in air_repelled)
if(M.last_airflow > world.time - zas_settings.Get(/datum/ZAS_Setting/airflow_delay)) continue if(M.last_airflow > world.time - zas_settings.Get(/datum/ZAS_Setting/airflow_delay)) continue
if(ismob(M) && abs(n) > zas_settings.Get(/datum/ZAS_Setting/airflow_medium_pressure)) if(ismob(M) && abs(n) > zas_settings.Get(/datum/ZAS_Setting/airflow_medium_pressure))
if(M:status_flags & GODMODE) continue if(M:status_flags & GODMODE) continue
M:airflow_stun() M:airflow_stun()
if(M.check_airflow_movable(abs(n))) if(M.check_airflow_movable(abs(n)))
var/list/close_turfs = list() var/list/close_turfs = list()
for(var/turf/U in connected_turfs) for(var/turf/U in connected_turfs)
if(M in range(U)) close_turfs += U if(M in range(U)) close_turfs += U
if(!close_turfs.len) continue if(!close_turfs.len) continue
//If they're already being tossed, don't do it again. //If they're already being tossed, don't do it again.
if(!M.airflow_speed) if(!M.airflow_speed)
M.airflow_dest = pick(close_turfs) //Pick a random midpoint to fly towards. M.airflow_dest = pick(close_turfs) //Pick a random midpoint to fly towards.
spawn M.RepelAirflowDest(abs(n)/5) spawn M.RepelAirflowDest(abs(n)/5)
proc/AirflowSpace(zone/A) proc/AirflowSpace(zone/A)
spawn()
//The space version of the Airflow(A,B,n) proc.
//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.
var/n = A.air.return_pressure() if(n < zas_settings.Get(/datum/ZAS_Setting/airflow_lightest_pressure)) return
//Here, n is determined by only the pressure in the room.
if(n < zas_settings.Get(/datum/ZAS_Setting/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.
var/list/connected_turfs = A.unsimulated_tiles //The midpoints are now all the space connections. if(zas_settings.Get(/datum/ZAS_Setting/airflow_push) || 1) // If enabled
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 - zas_settings.Get(/datum/ZAS_Setting/airflow_delay)) continue
if(zas_settings.Get(/datum/ZAS_Setting/airflow_push) || 1) // If enabled if(ismob(M) && n > zas_settings.Get(/datum/ZAS_Setting/airflow_stun_pressure))
for(var/atom/movable/M in pplz) var/mob/O = M
if(M.last_airflow > world.time - zas_settings.Get(/datum/ZAS_Setting/airflow_delay)) continue if(O.status_flags & GODMODE) continue
O.airflow_stun()
if(ismob(M) && n > zas_settings.Get(/datum/ZAS_Setting/airflow_stun_pressure)) if(M.check_airflow_movable(n))
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
var/list/close_turfs = list() //If they're already being tossed, don't do it again.
for(var/turf/U in connected_turfs) if(!M.airflow_speed)
if(M in range(U)) close_turfs += U
if(!close_turfs.len) continue
//If they're already being tossed, don't do it again. M.airflow_dest = pick(close_turfs) //Pick a random midpoint to fly towards.
if(!M.airflow_speed) M.GotoAirflowDest(n/10)
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. //Sometimes shit breaks, and M isn't there after the spawn.
*/ */

View File

@@ -85,7 +85,8 @@ Class Procs:
/connection_edge/proc/tick() /connection_edge/proc/tick()
/connection_edge/proc/flow(list/movable, differential, repelled) /connection_edge/proc/flow(list/movable, differential, repelled, flipped = 0)
//Flipped tells us if we are going from A to B or from B to A.
if(!zas_settings.Get(/datum/ZAS_Setting/airflow_push)) if(!zas_settings.Get(/datum/ZAS_Setting/airflow_push))
return return
for(var/atom/movable/M in movable) for(var/atom/movable/M in movable)
@@ -115,9 +116,19 @@ Class Procs:
if(M) if(M)
if(repelled) if(repelled)
if(flipped)
if(!(M.loc in src:A.contents))
continue
else if(!(M.loc in src:B.contents))
continue
M.RepelAirflowDest(differential/5) M.RepelAirflowDest(differential/5)
else else
M.GotoAirflowDest(differential/10) if(flipped)
if(!(M.loc in src:B.contents))
continue
else if(!(M.loc in src:A.contents))
continue
M.GotoAirflowDest(differential/10)
@@ -176,15 +187,17 @@ Class Procs:
var/list/attracted var/list/attracted
var/list/repelled var/list/repelled
var/flipped = 0
if(differential > 0) if(differential > 0)
attracted = A.movables() attracted = A.movables()
repelled = B.movables() repelled = B.movables()
else else
flipped = 1
attracted = B.movables() attracted = B.movables()
repelled = A.movables() repelled = A.movables()
flow(attracted, abs(differential), 0) flow(attracted, abs(differential), 0, flipped)
flow(repelled, abs(differential), 1) flow(repelled, abs(differential), 1, flipped)
//Helper proc to get connections for a zone. //Helper proc to get connections for a zone.
/connection_edge/zone/proc/get_connected_zone(zone/from) /connection_edge/zone/proc/get_connected_zone(zone/from)