Skip to content

Commit

Permalink
Codebook Optimisation (#4393)
Browse files Browse the repository at this point in the history
# About the pull request
For as long as we've had a codebook it's been a pain in the arse to
read/synchronise from a staff POV. With this, codebooks will all share
the same codes per-faction.
<!-- Remove this text and explain what the purpose of your PR is.

Mention if you have tested your changes. If you changed a map, make sure
you used the mapmerge tool.
If this is an Issue Correction, you can type "Fixes Issue #169420" to
link the PR to the corresponding Issue number #169420.

Remember: something that is self-evident to you might not be to others.
Explain your rationale fully, even if you feel it goes without saying.
-->

# Explain why it's good for the game
Makes events that use codebooks actually viable.
# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl:
add: Codebooks are now faction based rather than individually unique.
/:cl:
  • Loading branch information
realforest2001 authored Sep 13, 2023
1 parent 82ed28e commit 9dbf819
Showing 1 changed file with 42 additions and 10 deletions.
52 changes: 42 additions & 10 deletions code/modules/cm_marines/codebook.dm
Original file line number Diff line number Diff line change
@@ -1,24 +1,56 @@
GLOBAL_LIST_EMPTY(codebook_data)

/obj/item/book/codebook
name = "Almayer Code Book"
unique = 1
dat = ""
/obj/item/book/codebook/proc/create_codebook(faction = FACTION_MARINE)
if(!GLOB.codebook_data[faction])
GLOB.codebook_data[faction] = generate_code()

/obj/item/book/codebook/Initialize()
. = ..()
dat = GLOB.codebook_data[faction]

/obj/item/book/codebook/proc/generate_code()
var/number
var/letter
dat = "<table><tr><th>Call</th><th>Response<th></tr>"
var/code_data = "<table><tr><th>Call</th><th>Response<th></tr>"
for(var/i in 1 to 10)
letter = pick(greek_letters)
number = rand(100,999)
dat += "<tr><td>[letter]-[number]</td>"
code_data += "<tr><td>[letter]-[number]</td>"
letter = pick(greek_letters)
number = rand(100,999)
dat += "<td>[letter]-[number]</td></tr>"
code_data += "<td>[letter]-[number]</td></tr>"
code_data += "</table>"
return code_data

/obj/item/book/codebook
name = "USS Almayer Code Book"
author = "United States Colonial Marines"
unique = 1
dat = ""
var/faction = FACTION_MARINE

/obj/item/book/codebook/Initialize()
. = ..()
title = name
create_codebook(faction)

/obj/item/book/codebook/clf
name = "Liberation Front Authenticators"
faction = FACTION_CLF
author = "\[Obscured Ink\]"

/obj/item/book/codebook/twe
name = "Imperial Authentication Codes"
faction = FACTION_TWE
author = "Royal Marines"

dat += "</table>"
/obj/item/book/codebook/upp
name = "Union Authentication Codes"
faction = FACTION_UPP
author = "People's Army"

/obj/item/book/codebook/wey_yu
name = "Corporate Authentication Codes"
faction = FACTION_WY
author = "Weyland-Yutani Communications Division"

/obj/item/book/codebook/attackby(obj/item/W, mob/living/user)
if(istype(W, /obj/item/tool/kitchen/knife) || HAS_TRAIT(W, TRAIT_TOOL_WIRECUTTERS))
Expand Down

0 comments on commit 9dbf819

Please sign in to comment.