From fad28d0138d364cecd53d96f3dc12746b4ac291a Mon Sep 17 00:00:00 2001 From: Casey Date: Mon, 29 Aug 2022 23:46:59 -0400 Subject: [PATCH] Micro hiding! --- code/game/objects/micro_structures.dm | 354 ++++++++++++++++++++++++++ 1 file changed, 354 insertions(+) create mode 100644 code/game/objects/micro_structures.dm diff --git a/code/game/objects/micro_structures.dm b/code/game/objects/micro_structures.dm new file mode 100644 index 0000000000..203f12137c --- /dev/null +++ b/code/game/objects/micro_structures.dm @@ -0,0 +1,354 @@ +/obj/structure/micro_tunnel + name = "mouse hole" + desc = "A tiny little hole... where does it go?" + icon = 'icons/obj/structures/micro_structures.dmi' + icon_state = "mouse_hole" + + anchored = TRUE + density = FALSE + + var/magic = FALSE //For events and stuff, if true, this tunnel will show up in the list regardless of whether it's in valid range, of if you're in a tunnel with this var, all tunnels of the same faction will show up redardless of range + micro_target = TRUE + +/obj/structure/micro_tunnel/Initialize() + . = ..() + if(name == initial(name)) + var/area/our_area = get_area(src) + name = "[our_area.name] [name]" + if(pixel_x || pixel_y) + return + offset_tunnel() + +/obj/structure/micro_tunnel/Destroy() + visible_message("\The [src] collapses!") + for(var/mob/thing in src.contents) + visible_message("\The [thing] tumbles out!") + thing.forceMove(get_turf(src.loc)) + + return ..() + +/obj/structure/micro_tunnel/set_dir(new_dir) + . = ..() + offset_tunnel() + +/obj/structure/micro_tunnel/proc/offset_tunnel() + + pixel_x = 0 + pixel_y = 0 + + switch(dir) + if(1) + pixel_y = 32 + if(2) + pixel_y = -32 + if(4) + pixel_x = 32 + if(8) + pixel_x = -32 + +/obj/structure/micro_tunnel/attack_hand(mob/user) + if(!isliving(user)) + return ..() + if(user.loc == src) + var/choice = tgui_alert(user,"It's dark and gloomy in here. What would you like to do?","Tunnel",list("Exit", "Move", "Cancel")) + switch(choice) + if("Exit") + user.forceMove(get_turf(src.loc)) + user.visible_message("\The [user] climbs out of \the [src]!") + return + if("Move") + var/list/destinations = list() + var/turf/myturf = get_turf(src.loc) + var/datum/planet/planet + for(var/datum/planet/P in SSplanets.planets) + if(myturf.z in P.expected_z_levels) + planet = P + else + for(var/obj/structure/micro_tunnel/t in world) + if(t == src) + continue + if(magic || t.magic) + destinations |= t + continue + if(t.z == z) + destinations |= t + continue + var/turf/targetturf = get_turf(t.loc) + if(planet) + if(targetturf.z in planet.expected_z_levels) + destinations |= t + continue + else + var/above = GetAbove(myturf) + if(above && t.z == z + 1) + destinations |= t + continue + var/below = GetBelow(myturf) + if(below && t.z == z - 1) + destinations |= t + + if(!destinations.len) + to_chat(user, "There are no other tunnels connected to this one!") + return + else if(destinations.len == 1) + choice = pick(destinations) + else + choice = tgui_input_list(user, "Where would you like to go?", "Pick a tunnel", destinations) + if(!choice) + return + to_chat(user,"You begin moving...") + if(!do_after(user, 10 SECONDS, exclusive = TRUE)) + return + user.forceMove(choice) + var/obj/structure/micro_tunnel/da_oddawun = choice + da_oddawun.tunnel_notify(user) + return + if("Cancel") + return + + if(!can_enter(user)) + user.visible_message("\The [user] reaches into \the [src]. . .","You reach into \the [src]. . .") + if(!do_after(user, 3 SECONDS, exclusive = TRUE)) + user.visible_message("\The [user] pulls their hand out of \the [src].","You pull your hand out of \the [src]") + return + if(!src.contents.len) + to_chat(user, "There was nothing inside.") + user.visible_message("\The [user] pulls their hand out of \the [src].","You pull your hand out of \the [src]") + return + var/grabbed = pick(src.contents) + if(!grabbed) + to_chat(user, "There was nothing inside.") + user.visible_message("\The [user] pulls their hand out of \the [src].","You pull your hand out of \the [src]") + return + + if(ishuman(user)) + var/mob/living/carbon/human/h = user + var/mob/living/l = grabbed + if(isliving(grabbed)) + l.attempt_to_scoop(h) + else + var/atom/movable/whatever = grabbed + whatever.forceMove(get_turf(src.loc)) + + user.visible_message("\The [user] pulls \the [grabbed] out of \the [src]! ! !") + return + + else if(isanimal(user)) + var/mob/living/simple_mob/a = user + var/mob/living/l = grabbed + if(!a.has_hands || isliving(grabbed)) + l.attempt_to_scoop(user) + else + var/atom/movable/whatever = grabbed + whatever.forceMove(get_turf(src.loc)) + user.visible_message("\The [user] pulls \the [grabbed] out of \the [src]! ! !") + return + + if(tgui_alert(user,"Do you want to go into the tunnel?","Enter Tunnel",list("Yes", "No")) != "Yes") + return + user.visible_message("\The [user] begins climbing into \the [src]!") + if(!do_after(user, 10 SECONDS, exclusive = TRUE)) + to_chat(user, "You didn't go into \the [src]!") + return + + enter_tunnel(user) + +/obj/structure/micro_tunnel/proc/can_enter(var/mob/living/user) + if(user.mob_size <= MOB_TINY || user.get_effective_size(TRUE) <= micro_accepted_scale) + return TRUE + + return FALSE + +/obj/structure/micro_tunnel/attack_generic(mob/user, damage, attack_verb) + attack_hand(user) + return ..() + +/obj/structure/micro_tunnel/MouseDrop_T(mob/living/M, mob/living/user) + . = ..() + if(M != user) + return + + if(!can_enter(user)) + return + + var/mob/living/k = M + + k.visible_message("\The [k] begins climbing into \the [src]!") + if(!do_after(k, 3 SECONDS, exclusive = TRUE)) + to_chat(k, "You didn't go into \the [src]!") + return + + enter_tunnel(k) + +/obj/structure/micro_tunnel/proc/enter_tunnel(mob/living/k) + k.visible_message("\The [k] climbs into \the [src]!") + k.forceMove(src) + to_chat(k,"You are inside of \the [src]. It's dark and gloomy inside of here. You can click upon the tunnel to exit, or travel to another tunnel if there are other tunnels linked to it.") + tunnel_notify(k) + +/obj/structure/micro_tunnel/proc/tunnel_notify(var/mob/living/user) + var/our_message = "You can see " + var/found_stuff = FALSE + for(var/thing in src.contents) + if(thing == user) + continue + found_stuff = TRUE + our_message = "[our_message] [thing], " + if(isliving(thing)) + var/mob/living/t = thing + to_chat(t, "\The [user] enters \the [src]!") + if(found_stuff) + to_chat(user, "[our_message]inside of \the [src]!") + if(prob(25)) + visible_message("Something moves inside of \the [src]. . .") + +/obj/structure/micro_tunnel/magic + magic = TRUE + +/obj + var/micro_accepted_scale = 0.5 + var/micro_target = FALSE + +/obj/Initialize(mapload) + . = ..() + if(micro_target) + verbs += /obj/proc/micro_interact + +/obj/proc/micro_interact() + set name = "Micro Interact" + set desc = "Micros can enter, or move between objects with this! Non-micros can reach into objects to search for micros!" + set category = "Object" + set src in oview(1) + + if(!isliving(usr)) + return + + var/list/contained_mobs = list() + for(var/mob/living/issamob in src.contents) + if(isliving(issamob)) + contained_mobs |= issamob + + if(usr.loc == src) + var/choice = tgui_alert(usr,"What would you like to do?","[src]",list("Exit", "Move", "Cancel")) + switch(choice) + if("Exit") + usr.forceMove(get_turf(src.loc)) + usr.visible_message("\The [usr] climbs out of \the [src]!") + return + + if("Move") + var/list/destinations = list() + var/turf/myturf = get_turf(src.loc) + for(var/obj/o in range(1,myturf)) + if(!istype(o,/obj)) + continue + if(o == src) + continue + if(o.micro_target) + destinations |= o + + if(!destinations.len) + to_chat(usr, "There is nowhere to move to!") + return + else if(destinations.len == 1) + choice = pick(destinations) + else + choice = tgui_input_list(usr, "Where would you like to go?", "Pick a destination", destinations) + if(!choice) + return + to_chat(usr,"You begin moving...") + if(!do_after(usr, 10 SECONDS, exclusive = TRUE)) + return + var/obj/our_choice = choice + + var/list/new_contained_mobs = list() + for(var/mob/living/issamob in src.contents) + if(isliving(issamob)) + contained_mobs |= issamob + + usr.forceMove(our_choice) + + to_chat(usr,"You are inside of \the [our_choice]. You can click upon the thing you are in to exit, or travel to a nearby thing if there are other tunnels linked to it.") + + var/our_message = "You can see " + var/found_stuff = FALSE + for(var/thing in new_contained_mobs) + if(thing == usr) + continue + found_stuff = TRUE + our_message = "[our_message] [thing], " + if(isliving(thing)) + var/mob/living/t = thing + to_chat(t, "\The [usr] enters \the [src]!") + if(found_stuff) + to_chat(usr, "[our_message]inside of \the [src]!") + if(prob(25)) + our_choice.visible_message("Something moves inside of \the [src]. . .") + return + if("Cancel") + return + + if(!(usr.mob_size <= MOB_TINY || usr.get_effective_size(TRUE) <= micro_accepted_scale)) + usr.visible_message("\The [usr] reaches into \the [src]. . .","You reach into \the [src]. . .") + if(!do_after(usr, 3 SECONDS, exclusive = TRUE)) + usr.visible_message("\The [usr] pulls their hand out of \the [src].","You pull your hand out of \the [src]") + return + + if(!contained_mobs.len) + to_chat(usr, "There was nothing inside.") + usr.visible_message("\The [usr] pulls their hand out of \the [src].","You pull your hand out of \the [src]") + return + var/grabbed = pick(contained_mobs) + if(!grabbed) + to_chat(usr, "There was nothing inside.") + usr.visible_message("\The [usr] pulls their hand out of \the [src].","You pull your hand out of \the [src]") + return + + if(ishuman(usr)) + var/mob/living/carbon/human/h = usr + var/mob/living/l = grabbed + if(isliving(grabbed)) + l.attempt_to_scoop(h) + else + var/atom/movable/whatever = grabbed + whatever.forceMove(get_turf(src.loc)) + + usr.visible_message("\The [usr] pulls \the [grabbed] out of \the [src]! ! !") + return + + else if(isanimal(usr)) + var/mob/living/simple_mob/a = usr + var/mob/living/l = grabbed + if(!a.has_hands || isliving(grabbed)) + l.attempt_to_scoop(usr) + else + var/atom/movable/whatever = grabbed + whatever.forceMove(get_turf(src.loc)) + usr.visible_message("\The [usr] pulls \the [grabbed] out of \the [src]! ! !") + return + + if(tgui_alert(usr,"Do you want to go into \the [src]?","Enter [src]",list("Yes", "No")) != "Yes") + return + usr.visible_message("\The [usr] begins climbing into \the [src]!") + if(!do_after(usr, 10 SECONDS, exclusive = TRUE)) + to_chat(usr, "You didn't go into \the [src]!") + return + + usr.visible_message("\The [usr] climbs into \the [src]!") + usr.forceMove(src) + to_chat(usr,"You are inside of \the [src]. You can click upon the tunnel to exit, or travel to another tunnel if there are other tunnels linked to it.") + + var/our_message = "You can see " + var/found_stuff = FALSE + for(var/thing in contained_mobs) + if(thing == usr) + continue + found_stuff = TRUE + our_message = "[our_message] [thing], " + if(isliving(thing)) + var/mob/living/t = thing + to_chat(t, "\The [usr] enters \the [src]!") + if(found_stuff) + to_chat(usr, "[our_message]inside of \the [src]!") + if(prob(25)) + visible_message("Something moves inside of \the [src]. . .")