Merge pull request #954 from cadyn/newportals

Some simple portals for kassc
This commit is contained in:
Razgriz
2020-11-30 23:58:33 -07:00
committed by GitHub
5 changed files with 129 additions and 10 deletions
+2
View File
@@ -41,3 +41,5 @@ temp.dmi
/maps/yw/backup
icons/mecha/mecha_ch.dmi
.vscode/settings.json
+113
View File
@@ -0,0 +1,113 @@
/obj/effect/simple_portal
name = "Portal"
desc = "It looks like a portal that leads to somewhere, although you can't quite see through it."
icon = 'icons/obj/stationobjs.dmi'
icon_state = "portal"
density = 1
unacidable = TRUE
anchored = TRUE
var/atom/destination
var/teleport_sound = 'sound/effects/portal_effect.ogg'
/obj/effect/simple_portal/Bumped(atom/movable/AM)
. = ..()
handle_teleport(AM)
/obj/effect/simple_portal/Crossed(atom/movable/AM)
. = ..()
handle_teleport(AM)
/obj/effect/simple_portal/proc/handle_teleport(atom/movable/AM)
if(destination)
AM.forceMove(destination)
if(!AM.is_incorporeal())
playsound(get_turf(src),teleport_sound,60,1)
playsound(get_turf(destination),teleport_sound,60,1)
/obj/effect/simple_portal/coords
var/tele_x
var/tele_y
var/tele_z
/obj/effect/simple_portal/coords/handle_teleport(atom/movable/AM)
destination = null
if(!isnull(tele_x) && !isnull(tele_y) && !isnull(tele_z))
destination = locate(tele_x,tele_y,tele_z)
. = ..()
/obj/effect/simple_portal/linked
icon_state = "portal1"
var/obj/effect/simple_portal/linked/linked_portal
var/portal_id
/obj/effect/simple_portal/linked/handle_teleport(atom/movable/AM)
destination = null
update_icon()
if(linked_portal && icon_state == "portal")
var/rel_x = round(rand(-1,1))
var/rel_y = round(rand(-1,1))
var/movingdir = get_dir(AM,src)
if(!isnull(movingdir))
destination = get_step(get_turf(linked_portal),movingdir)
else
while(rel_x == 0 && rel_y == 0)
rel_x = round(rand(-1,1))
rel_y = round(rand(-1,1))
destination = locate(linked_portal.loc.x + rel_x, linked_portal.loc.y + rel_y, linked_portal.loc.z)
if(!valid_destination(destination))
var/list/possible_x = shuffle(list(-1,0,1))
var/list/possible_y = shuffle(list(-1,0,1))
for(rel_x in possible_x)
for(rel_y in possible_y)
if(rel_x == 0 && rel_y == 0)
continue
destination = locate(linked_portal.loc.x + rel_x, linked_portal.loc.y + rel_y, linked_portal.loc.z)
if(valid_destination(destination))
break
. = ..()
/obj/effect/simple_portal/linked/proc/valid_destination(var/turf/dest,var/atom/movable/AM)
if(!dest)
return FALSE
if(dest.density)
return FALSE
if(dest == get_turf(linked_portal))
return FALSE
var/windows = 0
for(var/obj/struct in dest)
var/obj/structure/window/window = struct
if(istype(window))
windows++
if(window.fulltile)
return FALSE
else
if(!struct.density)
continue
if(struct.throwpass || struct.flags & ON_BORDER)
continue
else
return FALSE
if(windows>2)
return FALSE
return TRUE
/obj/effect/simple_portal/linked/proc/link_portal()
if(!portal_id)
return "SET PORTAL ID FIRST"
var/list/candidates = get_all_of_type(/obj/effect/simple_portal/linked)
for(var/obj/effect/simple_portal/linked/candidate in candidates)
if(istype(candidate) && portal_id == candidate.portal_id && candidate != src)
linked_portal = candidate
break
update_icon()
/obj/effect/simple_portal/linked/update_icon()
if(linked_portal && !QDELETED(linked_portal))
icon_state = "portal"
else
icon_state = "portal1"
/obj/effect/simple_portal/linked/Initialize()
. = ..()
if(portal_id)
link_portal()
@@ -1,5 +1,9 @@
/turf/simulated
var/triggers = FALSE
/obj/effect/ctrigger
name = "Step Trigger"
icon = null
anchored = 1
invisibility = INVISIBILITY_OBSERVER
density = 0
var/list/potential_triggerers = list() //What can set off our trigger?
var/list/trig_target_paths = list() //What are the paths of whatever we want to call our proc on?
var/trig_target_trigger_uid //What is the trigger_uid of whatever we want to call our proc on?
@@ -14,8 +18,7 @@
var/trig_single_use_per_triggerer = FALSE //Do we want to make so each atom can only trigger this once?
var/trig_target_is_trigerrer = FALSE //Do we want to use the atom that trigerred us as the target?
/turf/simulated/proc/can_use_trigger(atom/movable/mover)
/obj/effect/ctrigger/proc/can_use_trigger(atom/movable/mover)
if(trig_single_use && has_been_used)
return FALSE
if(trig_single_use_per_triggerer && (mover in been_triggered_by))
@@ -30,9 +33,9 @@
continue
return FALSE
/turf/simulated/Entered(atom/movable/mover, atom/oldloc)
/obj/effect/ctrigger/Crossed(atom/movable/mover)
. = ..()
if(triggers && can_use_trigger(mover))
if(can_use_trigger(mover))
if(trig_proc)
if(trig_target_is_trigerrer)
trig_targets = list(mover)
@@ -66,7 +69,7 @@
else
return
/turf/simulated/proc/update_trig_targets()
/obj/effect/ctrigger/proc/update_trig_targets()
trig_targets = list()
for(var/path in trig_target_paths)
var/trig_target_path = text2path(path)
@@ -82,7 +85,7 @@
if(!trig_targets.len)
message_admins("TRIGGER ERROR: trig_targets STILL EMPTY AFTER CALLED update_trig_targets()")
/turf/simulated/Initialize(mapload)
/obj/effect/ctrigger/Initialize(mapload)
. = ..()
if(triggers)
if(trig_target_paths.len)
update_trig_targets()
Binary file not shown.
+2 -1
View File
@@ -1096,6 +1096,8 @@
#include "code\game\objects\effects\spiders_vr.dm"
#include "code\game\objects\effects\step_triggers.dm"
#include "code\game\objects\effects\zone_divider.dm"
#include "code\game\objects\effects\zz_portals_ch.dm"
#include "code\game\objects\effects\zz_triggers_ch.dm"
#include "code\game\objects\effects\alien\alien egg.dm"
#include "code\game\objects\effects\alien\alien.dm"
#include "code\game\objects\effects\alien\aliens.dm"
@@ -1584,7 +1586,6 @@
#include "code\game\turfs\simulated.dm"
#include "code\game\turfs\simulated_ch.dm"
#include "code\game\turfs\simulated_vr.dm"
#include "code\game\turfs\triggers_ch.dm"
#include "code\game\turfs\turf.dm"
#include "code\game\turfs\turf_ch.dm"
#include "code\game\turfs\turf_changing.dm"