Skip to content

Commit

Permalink
EO Text Adventure
Browse files Browse the repository at this point in the history
Adds a text adventure minigame to the EO's area.
  • Loading branch information
InsightfulParasite committed Nov 11, 2023
1 parent 081d94b commit e750fcf
Show file tree
Hide file tree
Showing 3 changed files with 227 additions and 0 deletions.
152 changes: 152 additions & 0 deletions ModularTegustation/lc13_adventuredatum.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/*TEXT BASED ADVENTURES!!! Adventures that are mostly predefined paths.
This was difficult to finalize since i havent made a text based
adventure before. */
/*-------------\
|Adventure Code|
\-------------*/
/datum/adventure_layout
var/virtual_integirty = 100
var/virtual_coins = 1
var/display_event = FALSE

/datum/adventure_layout/proc/UI_Display(mob/living/carbon/human/H)
. = "|USER:[H.name]|HP:[virtual_integirty]|COINS:[virtual_coins]|<br>"
. += " <A href='byond://?src=[REF(interface_caller)];choice=[path_change]'>[path_change]</A>[choice_desc]<br>"

Check failure on line 14 in ModularTegustation/lc13_adventuredatum.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "interface_caller"

Check failure on line 14 in ModularTegustation/lc13_adventuredatum.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "path_change"

Check failure on line 14 in ModularTegustation/lc13_adventuredatum.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "path_change"

Check failure on line 14 in ModularTegustation/lc13_adventuredatum.dm

View workflow job for this annotation

GitHub Actions / Run Linters

undefined var: "choice_desc"

/*
This definition requires the destination of the path change,
the description of the choice, and the interface recieving this
definition. Hopefully this definition makes creating these easier.
*/
#define BUTTON_FORMAT(path_change,choice_desc,interface_caller) . += " <A href='byond://?src=[REF(interface_caller)];choice=[path_change]'>[path_change]</A>[choice_desc]<br>"

/*---------\
|Event Code|
\---------*/
/datum/adventure_event
//Name of adventure, displayed at top.
var/name
//Description of adventure.
var/desc
//Where the user is.
var/cords = 1
//Discriptions of areas. If cords is 2 then B will be displayed for flavor_desc in UI_Display()
var/list/adventure_cords = list(
"A",
"B",
"C",
)

/*This is where most of the choices and effects will appear.
After your condition for the choice is made with
"if(cords == 2)" remember to add a return if you do not
want the continue button to appear.*/
/datum/adventure_event/proc/EventChoiceFormat(obj/machinery/M, mob/living/carbon/human/H)
if(cords)
BUTTON_FORMAT(0,"CONTINUE", M)

/* This proc is called by the machine in order to build the UI.
Its like a hub where all other general things are called. */
/datum/adventure_event/proc/Event(obj/machinery/caller, mob/living/carbon/human/H)
if(cords == 0)
EventComplete(caller,H)
return

//UI Data for machine that calls us.
. = UI_Display()
. += EventChoiceFormat(caller, H)

if(!caller)
return "<br>ERROR: USERFACE SOURCE MISSING"

/* Formating stuff such as UI display that is
returned to the calling userface such as
the events name, current cords, and
flavor text. */
/datum/adventure_event/proc/UI_Display(mob/living/carbon/human/H)
var/flavor_desc = adventure_cords[cords]
. += "<b>[name]:[cords]</b><br>"
. += "-----------<br>[flavor_desc]<br>-----------<br>"

//Code that runs when the event is complete. Mostly resets things.
/datum/adventure_event/proc/EventComplete(obj/machinery/machine_thingly/M, mob/living/carbon/human/H)
cords = 1

//Called by console after a choice is recieved.
/datum/adventure_event/proc/EventReact(new_cords)
cords = new_cords

/*------------\
|Unique Events|
\------------*/

//Refrence to a shot from the early access trailer to lobotomy corp where a cowering agent is surrounded by a void of monsters.
/datum/adventure_event/legacy
name = "The Falling World"
desc = "Adrift in a dark sea is the silloette of a doorway and a cowering figure."
adventure_cords = list(
"A twisting green hue pours out from a door. Silhouetted against that light is a humanoid figure. \
<br>The figure grabs their head and cowers as the edges of the room crumble away. \
<br>Encircling the doorway at the edge of your visions are the writhing outline of monsters.",
//Not great story results i know -IP
"You remain silent as the shadows obscure your view of the figure",
"The figure looks towards you, and so do the shadows. You are not alone.",
)

/datum/adventure_event/legacy/EventChoiceFormat(obj/machinery/M, mob/living/carbon/human/H)
if(cords == 1)
BUTTON_FORMAT(2,"HIDE", M)
BUTTON_FORMAT(3,"REACH OUT", M)
return
if(cords == 3)
playsound(get_turf(H), 'sound/effects/creak1.ogg', 20, FALSE)
. = ..()

/datum/adventure_event/match
name = "Final Match"
desc = "The window to a warm house in a chilly winters eve."
adventure_cords = list(
"You stand in the snow peering into a nicely lit home. Inside is the scene of a family \
having dinner. Next to you is a small girl holding a box of matches, she stands there \
watching blankly as the world ignores her.",
"The window breaks as the inside of the house erupts into flames. The warmth of the fire \
is comforting in the bitter chill. The girl next to you smiles weakly before the fire \
dies down leaving nothing but cold ash and burnt matches.",
//You cannot change the outcome of the story.
"You feel strangely out of place while you fish out a coin from your pocket and request a \
match. The girl turns to you, her form starts to sizzle and burn. After handing you a \
match she erupts into a fire that carries no warmth.",
)

/datum/adventure_event/match/EventChoiceFormat(obj/machinery/M, mob/living/carbon/human/H)
if(cords == 1)
BUTTON_FORMAT(2,"CONTINUE TO WATCH", M)
BUTTON_FORMAT(3,"REQUEST A MATCH", M)
return
. = ..()

//This event is mostly based on what i THINK the creators of forsaken murderer are trying to say. -IP
/datum/adventure_event/murderer
name = "The Forsaken Killer"
desc = "A metal table and a killer ripe for the reaping."
adventure_cords = list(
"Before you is a emaciated man strapped to a table. Next to him on a metal table are \
documents of his crimes and a medical diagram indicating the location of something \
of value within his brain.",
"Within his brain you find what you wanted. The glee of the oppertunity to gain so much \
passes your mind as the man slumps over, still alive but wrong... ",
"As you turn to leave the monsterous man strapped to his table you hear the muffled \
screams and tearing of flesh. You look back at the fading scene of a shadowy woman \
tearing out something from the mans brain.",
)

/datum/adventure_event/murderer/EventChoiceFormat(obj/machinery/M, mob/living/carbon/human/H)
if(cords == 1)
BUTTON_FORMAT(2,"BUTCHER THE MANS BRAIN", M)
BUTTON_FORMAT(3,"LEAVE", M)
return
if(cords == 2)
new /obj/item/coin/gold(get_turf(H))
. = ..()

#undef BUTTON_FORMAT
74 changes: 74 additions & 0 deletions ModularTegustation/lc13_machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,77 @@
new type(T)
break
return TRUE

/*------------------\
|Text Adventure Code|
\------------------*/
/obj/machinery/machine_thingly
name = "UI TEST"
desc = "UI TEST."
icon = 'icons/obj/money_machine.dmi'
icon_state = "bogdanoff"
density = TRUE
var/datum/adventure_layout/adventure_data
var/datum/adventure_event/event_data
var/list/event_options = list()
var/static/list/events = list()

/obj/machinery/machine_thingly/Initialize()
. = ..()
if(!events.len)
for(var/_event in subtypesof(/datum/adventure_event))
events += new _event()
event_options = events.Copy()

/obj/machinery/machine_thingly/ui_interact(mob/user)
. = ..()
if(isliving(user))
playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE)

var/dat
if(!event_data)
dat += "~~~~~~~~~~<br>CHOOSE AN ADVENTURE<br>~~~~~~~~~~<br>"
for(var/_option in event_options)
var/datum/adventure_event/A = _option
dat += " <A href='byond://?src=[REF(src)];adventure=[REF(A)]'>[A.name]</A>[A.desc]<br>"

//Some insane statments where the copyright should be.
dat += "~~~~~~~~~~<br><b>[pick("THE RUINS ARE CLOSING IN","THEY ALL MARCH OUTWARDS<br>LEAVING THE CITY BEHIND",\
"IS THAT YOU","I REMEMBER ALL THEIR NAMES","I WILL MEND THIS SHATTERED WORLD","WHAT CANT THE BEHOLDERS SEE",\
"THE CITY IS STARVING")]</b>"
else
dat += event_data.Event(src, user)
var/datum/browser/popup = new(user, "Adventure", "AdventureTest", 440, 640)
popup.set_content(dat)
popup.open()
return

/obj/machinery/machine_thingly/Topic(href, href_list)
. = ..()
if(.)
return .
if(ishuman(usr))
usr.set_machine(src)
add_fingerprint(usr)
if(href_list["adventure"])
/* There must be a better way of doing this because returning
A itself just brings the name instead of the instance. -IP */
event_data = locate(href_list["adventure"]) in event_options
playsound(get_turf(src), 'sound/machines/uplinkpurchase.ogg', 50, TRUE)
updateUsrDialog()
return TRUE
if(href_list["choice"])
var/reaction = text2num(href_list["choice"])
//Remotely call event reaction with our choice.
event_data.EventReact(reaction)
//Essential for refreshing the UI after completing a event.
if(reaction == 0)
PickNewEvent()
playsound(get_turf(src), 'sound/machines/pda_button2.ogg', 50, TRUE)
updateUsrDialog()
return TRUE

//Called by event datum
/obj/machinery/machine_thingly/proc/PickNewEvent()
event_data = null
updateUsrDialog()
1 change: 1 addition & 0 deletions lobotomy-corp13.dme
Original file line number Diff line number Diff line change
Expand Up @@ -3816,6 +3816,7 @@
#include "interface\skin.dmf"
#include "ModularTegustation\engineering_bounties.dm"
#include "ModularTegustation\languagebooks.dm"
#include "ModularTegustation\lc13_adventuredatum.dm"
#include "ModularTegustation\lc13_machinery.dm"
#include "ModularTegustation\looc.dm"
#include "ModularTegustation\resindoor.dm"
Expand Down

0 comments on commit e750fcf

Please sign in to comment.