Files
Paradise/code/game/objects/effects/portals.dm
T
79bad427c8 Movement cross/uncross implementation. (#26762)
* refactor: Movement cross/uncross implementation.

* wrong var name

* fix unit tests dropping PDAs into nowhere

* Add documentation.

* remove unused constants

* say which procs are off limits

* fix simpleanimal z change runtime

* helps not to leave merge conflicts

* kill me

* fix typecast

* fix projectile/table collision

* treadmills don't cause MC to crash anymore

* connect_loc is appropriate here

* fix windoors and teleporters

* fix bonfires and clarify docs

* fix proximity sensors

Tested with sensors in crates, sensors in modsuits
Tested new proximity component with firing projectiles at singularity
Tested new proximity component with portable flashes
Tested new proximity component with facehuggers

* lint

* fix: polarized access helper false positives

* Revert "fix: polarized access helper false positives"

This reverts commit 9814f98cf6.

* hopefully the right change for mindflayer steam

* Changes following cameras

* fix glass table collision

* appears to fix doorspam

* fix ore bags not picking up ore

* fix signatures of /Exited

* remove debug log

* remove duplicate signal registrar

* fix emptying bags into locations

* I don't trust these nested Move calls

* use connect_loc for upgraded resonator fields

* use moveToNullspace

* fix spiderweb crossing

* fix pass checking for windows from a tile off

* fix bluespace closet/transparency issues

* fix mechs not interacting with doors and probably other things

* fix debug

* fix telepete

* add some docs

* stop trying to shoehorn prox monitor into cards

* I should make sure things build

* kill override signal warning

* undef signal

* not many prox monitors survive going off like this

* small fixes to storage

* make moving wormholes respect signals

* use correct signals for pulse demon

* fix pulse heart too

* fix smoke signals

* may have fucked singulo projectile swerve

* fix singulo projectile arcing

* remove duplicate define

* just look at it

* hopefully last cleanups of incorrect signal usage

* fix squeaking

* may god have mercy on my soul

* Apply suggestions from code review

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Signed-off-by: warriorstar-orion <orion@snowfrost.garden>

* lewc review

* Apply suggestions from code review

Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
Signed-off-by: warriorstar-orion <orion@snowfrost.garden>

* burza review

* fix bad args for grenade assemblies

* Update code/__DEFINES/is_helpers.dm

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Signed-off-by: warriorstar-orion <orion@snowfrost.garden>

---------

Signed-off-by: warriorstar-orion <orion@snowfrost.garden>
Co-authored-by: DGamerL <daan.lyklema@gmail.com>
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
2024-12-21 08:07:44 +00:00

213 lines
6.1 KiB
Plaintext

#define EFFECT_COOLDOWN 0.5 SECONDS
/obj/effect/portal
name = "portal"
desc = "Result of bluespace high tech development."
icon = 'icons/obj/stationobjs.dmi'
icon_state = "portal"
var/obj/item/target = null
/// The UID and `name` of the object that created this portal. For example, a wormhole jaunter.
var/list/creation_obj_data
/// The ckey of the mob which was responsible for the creation of the portal. For example, the mob who used a wormhole jaunter.
var/creation_mob_ckey
var/failchance = 0
var/fail_icon = "portal1"
/// How close to the portal you will teleport. FALSE = on the portal, TRUE = adjacent
var/precision = FALSE
var/can_multitool_to_remove = FALSE
var/ignore_tele_proof_area_setting = FALSE
var/one_use = FALSE // Does this portal go away after one teleport?
/// The time after which the effects should play again. Too many effects can lag the server
var/effect_cooldown = 0
///Whether or not portal use will cause sparks
var/create_sparks = TRUE
var/teleports_this_cycle = 0
/obj/effect/portal/New(loc, turf/_target, obj/creation_object = null, lifespan = 300, mob/creation_mob = null, create_sparks = TRUE)
..()
GLOB.portals += src
target = _target
if(creation_object)
creation_obj_data = list(creation_object.UID(), "[creation_object.name]") // Store the name incase the object is deleted.
else
creation_obj_data = list(null, null)
creation_mob_ckey = creation_mob?.ckey
START_PROCESSING(SSobj, src)
var/static/list/loc_connections = list(
COMSIG_ATOM_ENTERED = PROC_REF(on_atom_entered),
)
AddElement(/datum/element/connect_loc, loc_connections)
if(lifespan > 0)
QDEL_IN(src, lifespan)
/obj/effect/portal/Destroy()
GLOB.portals -= src
var/obj/O = locateUID(creation_obj_data[1])
if(!QDELETED(O))
O.portal_destroyed(src)
target = null
if(create_sparks)
do_sparks(5, 0, loc)
STOP_PROCESSING(SSobj, src)
return ..()
/obj/effect/portal/process()
teleports_this_cycle = 0
/obj/effect/portal/singularity_pull()
return
/obj/effect/portal/singularity_act()
return
/obj/effect/portal/proc/on_atom_entered(datum/source, atom/movable/entered, old_loc)
if(isobserver(entered))
return
if(target && (get_turf(old_loc) == get_turf(target)))
return
if(teleport(entered))
return TRUE
/obj/effect/portal/attack_tk(mob/user)
return
/obj/effect/portal/attack_hand(mob/user)
. = ..()
if(.)
return
if(get_turf(user) == get_turf(src))
teleport(user)
if(Adjacent(user))
user.forceMove(get_turf(src))
/obj/effect/portal/attack_ghost(mob/dead/observer/O)
if(target)
O.forceMove(get_turf(target))
/obj/effect/portal/multitool_act(mob/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
if(can_multitool_to_remove)
qdel(src)
else
user.forceMove(get_turf(src))
/obj/effect/portal/proc/can_teleport(atom/movable/M)
. = TRUE
if(!istype(M))
. = FALSE
if(!M.simulated || iseffect(M))
. = FALSE
/obj/effect/portal/proc/teleport(atom/movable/M)
if(!can_teleport(M))
return FALSE
if(!target)
qdel(src)
return FALSE
if(ismegafauna(M))
var/creator_string = ""
var/obj_name = creation_obj_data[2]
if(creation_mob_ckey)
creator_string = " created by [key_name_admin(GLOB.directory[creation_mob_ckey])][obj_name ? " using \a [obj_name]" : ""]"
else if(obj_name)
creator_string = " created by \a [obj_name]"
message_admins("[M] has used a portal at [ADMIN_VERBOSEJMP(src)][creator_string].")
if(prob(failchance))
icon_state = fail_icon
var/list/target_z = levels_by_trait(SPAWN_RUINS)
target_z -= M.z
if(!attempt_teleport(M, locate(rand(5, world.maxx - 5), rand(5, world.maxy -5), pick(target_z)), 0, FALSE)) // Try to send them to deep space.
return FALSE
else
if(!attempt_teleport(M, target, precision)) // Try to send them to a turf adjacent to target.
return FALSE
if(one_use)
qdel(src)
return TRUE
/obj/effect/portal/proc/attempt_teleport(atom/movable/victim, turf/destination, variance = 0, force_teleport = TRUE)
if(teleports_this_cycle >= MAX_ALLOWED_TELEPORTS_PER_PROCESS)
return
var/use_effects = world.time >= effect_cooldown
var/effect = null // Will result in the default effect being used
if(!use_effects)
effect = NONE // No effect
if(!do_teleport(victim, destination, variance, force_teleport, effect, effect, bypass_area_flag = ignore_tele_proof_area_setting))
invalid_teleport()
return FALSE
effect_cooldown = world.time + EFFECT_COOLDOWN
teleports_this_cycle++
return TRUE
/obj/effect/portal/proc/invalid_teleport()
visible_message("<span class='warning'>[src] flickers and fails due to bluespace interference!</span>")
if(create_sparks)
do_sparks(5, 0, loc)
qdel(src)
#define UNSTABLE_TIME_DELAY 2 SECONDS
/obj/effect/portal/hand_tele
/// After you touch the portal, it will be unstable with high bad teleport chance, this variable contains time when it will be fine again
var/unstable_time = 0
/// If this is TRUE, you will not be able to teleport with that portal
var/inactive = FALSE
/obj/effect/portal/hand_tele/examine(mob/user, infix, suffix)
. = ..()
if(unstable_time > world.time)
. += "<span class='warning'>[src] is shaking, it looks very unstable!</span>"
/obj/effect/portal/hand_tele/can_teleport(atom/movable/M)
if(inactive)
return FALSE
return ..()
/obj/effect/portal/hand_tele/teleport(atom/movable/M)
. = ..()
adjust_unstable()
/obj/effect/portal/hand_tele/proc/adjust_unstable()
unstable_time = world.time + UNSTABLE_TIME_DELAY
icon_state = fail_icon
failchance = 33
inactive = TRUE
addtimer(CALLBACK(src, PROC_REF(check_unstable), unstable_time), UNSTABLE_TIME_DELAY)
addtimer(VARSET_CALLBACK(src, inactive, FALSE), 0.5 SECONDS) // after unstable is setted you have 0.5 safe seconds to think if you want to use it
/obj/effect/portal/hand_tele/proc/check_unstable(current_unstable_time)
if(current_unstable_time != unstable_time)
return
icon_state = initial(icon_state)
failchance = 0
#undef UNSTABLE_TIME_DELAY
/obj/effect/portal/advanced
name = "advanced portal"
desc = "A portal capable of bypassing bluespace interference."
icon_state = "portal1"
failchance = 0
precision = 0
ignore_tele_proof_area_setting = TRUE
#undef EFFECT_COOLDOWN