Skip to content

Commit

Permalink
autowiki improvements (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
harryob committed Aug 2, 2024
1 parent 685e09e commit 2f2bf9c
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 3 deletions.
7 changes: 7 additions & 0 deletions code/__DEFINES/autowiki.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifdef AUTOWIKI
#define AUTOWIKI_SKIP(skip) autowiki_skip = skip
#define IS_AUTOWIKI_SKIP(datum) datum.autowiki_skip
#else
#define AUTOWIKI_SKIP(skip)
#define IS_AUTOWIKI_SKIP(datum) FALSE
#endif
2 changes: 2 additions & 0 deletions code/datums/agents/tools/decoy.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/obj/item/explosive/grenade/decoy
AUTOWIKI_SKIP(TRUE)

name = "decoy grenade"
desc = "A grenade typically used to distract the enemy. Emits a loud bang. Detonates in 5 seconds. Has 3 uses"

Expand Down
4 changes: 4 additions & 0 deletions code/datums/datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
var/list/cached_vars
#endif

#ifdef AUTOWIKI
var/autowiki_skip = FALSE
#endif

/**
* Default implementation of clean-up code.
*
Expand Down
4 changes: 4 additions & 0 deletions code/game/objects/items/explosives/grenades/marines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
falloff_mode = EXPLOSION_FALLOFF_SHAPE_LINEAR

/obj/item/explosive/grenade/high_explosive/frag/toy
AUTOWIKI_SKIP(TRUE)

name = "toy HEFA grenade"
desc = "High-Explosive Fragmenting-Antipersonnel. A small, but deceptively strong fragmentation grenade that has been phasing out the M15 fragmentation grenades alongside the M40 HEDP. Capable of being loaded in the M92 Launcher, or thrown by hand. Wait, the labeling on the side indicates this is a toy, what the hell?"
explosion_power = 0
Expand Down Expand Up @@ -865,6 +867,8 @@
return

/obj/item/explosive/grenade/high_explosive/holy_hand_grenade
AUTOWIKI_SKIP(TRUE)

name = "\improper Holy Hand Grenade of Antioch"
desc = "And Saint Attila raised the hand grenade up on high, saying, \"O LORD, bless this Thy hand grenade that with it Thou mayest blow Thine enemies to tiny bits, in Thy mercy.\" And the LORD did grin and the people did feast upon the lambs and sloths and carp and anchovies... And the LORD spake, saying, \"First shalt thou take out the Holy Pin, then shalt thou count to three, no more, no less. Three shall be the number thou shalt count, and the number of the counting shall be three. Four shalt thou not count, neither count thou two, excepting that thou then proceed to three. Five is right out. Once the number three, being the third number, be reached, then lobbest thou thy Holy Hand Grenade of Antioch towards thy foe, who, being naughty in My sight, shall snuff it.\""
icon_state = "grenade_antioch"
Expand Down
2 changes: 1 addition & 1 deletion code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ GLOBAL_LIST_INIT(reboot_sfx, file2list("config/reboot_sfx.txt"))
GLOB.log_directory += "[replacetext(time_stamp(), ":", ".")]"

runtime_logging_ready = TRUE // Setting up logging now, so disabling early logging
#ifndef UNIT_TESTS
#if defined(UNIT_TESTS) || defined(AUTOWIKI)
world.log = file("[GLOB.log_directory]/dd.log")
#endif
backfill_runtime_log()
Expand Down
1 change: 1 addition & 0 deletions code/modules/autowiki/pages/_page.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
/// something that looks like `{{ Autowiki_Circuit|name=Combiner|description=This combines }}`
/// Lists, which must be array-like (no keys), will be turned into a flat list with their key and a number,
/// such that list("food" = list("fruit", "candy")) -> food1=fruit|food2=candy
/// Your page should respect AUTOWIKI_SKIP, and check for this using IS_AUTOWIKI_SKIP
/datum/autowiki/proc/include_template(name, parameters)
var/template_text = "{{[name]"

Expand Down
52 changes: 51 additions & 1 deletion code/modules/autowiki/pages/guns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
for(var/ammo_typepath in valid_mag_types)
var/obj/item/ammo_magazine/generating_mag = new ammo_typepath()

if(IS_AUTOWIKI_SKIP(generating_mag))

Check failure on line 45 in code/modules/autowiki/pages/guns.dm

View workflow job for this annotation

GitHub Actions / Run Linters

control flow condition is a static term

Check failure on line 45 in code/modules/autowiki/pages/guns.dm

View workflow job for this annotation

GitHub Actions / Run Linters

if condition is always false
continue

var/ammo_filename = SANITIZE_FILENAME(escape_value(format_text(generating_mag.name)))

if(!fexists("data/autowiki_files/[ammo_filename].png"))
Expand All @@ -61,25 +64,72 @@
))

generating_gun.current_mag = generating_mag
generating_gun.ammo = current_ammo
generating_gun.in_chamber = null

var/list/gun_ammo_data = generating_gun.ui_data()
var/list/armor_data = list()

var/iterator = 1
for(var/header in gun_ammo_data["damage_armor_profile_headers"])
var/damage = gun_ammo_data["damage_armor_profile_marine"][iterator]
if(!damage)
break
armor_data["armor-[header]"] = damage
iterator++

var/list/damage = list("ammo_name" = escape_value(generating_mag.name))
damage += armor_data
if(length(armor_data))
damage += armor_data

damage_table += include_template("Autowiki/DamageVersusArmorRow", damage)

qdel(generating_mag)

var/grenades = ""
if(istype(generating_gun, /obj/item/weapon/gun/launcher/grenade))
var/obj/item/weapon/gun/launcher/grenade/generating_launcher = generating_gun

var/list/permitted_grenades = list()
for(var/obj/item/explosive/grenade/type as anything in generating_launcher.valid_munitions)
permitted_grenades |= subtypesof(type)

var/list/unique_grenades = list()
var/list/unique_grenade_names = list()
for(var/obj/item/explosive/grenade/grenade_type as anything in permitted_grenades)
if(initial(grenade_type.name) in unique_grenade_names)
continue
unique_grenade_names += initial(grenade_type.name)
unique_grenades += grenade_type

var/list/denied_grenades = list()
for(var/type in generating_launcher.disallowed_grenade_types)
denied_grenades |= typesof(type)

var/valid_grenades = unique_grenades.Copy() - denied_grenades.Copy()

for(var/grenade_path in valid_grenades)
var/obj/item/explosive/grenade/generating_grenade = new grenade_path()

if(IS_AUTOWIKI_SKIP(generating_grenade))

Check failure on line 114 in code/modules/autowiki/pages/guns.dm

View workflow job for this annotation

GitHub Actions / Run Linters

control flow condition is a static term

Check failure on line 114 in code/modules/autowiki/pages/guns.dm

View workflow job for this annotation

GitHub Actions / Run Linters

if condition is always false
continue

var/grenade_filename = SANITIZE_FILENAME(escape_value(format_text(generating_grenade.name)))

if(!fexists("data/autowiki_files/[grenade_filename].png"))
upload_icon(getFlatIcon(generating_grenade, no_anim = TRUE), grenade_filename)

grenades += include_template("Autowiki/Grenade", list(
"icon" = escape_value(grenade_filename),
"name" = escape_value(generating_grenade.name),
"description" = escape_value(generating_grenade.desc)
))

qdel(generating_grenade)

gun_data["ammo_types"] = ammo
gun_data["damage_table"] = damage_table
gun_data["grenades"] = grenades

var/list/attachments_by_slot = list()
for(var/obj/item/attachable/attachment_typepath as anything in generating_gun.attachable_allowed)
Expand Down
2 changes: 2 additions & 0 deletions code/modules/projectiles/ammunition.dm
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ bullets/shells. ~N
*/

/obj/item/ammo_magazine/handful
AUTOWIKI_SKIP(TRUE)

name = "generic handful"
desc = "A handful of rounds to reload on the go."
icon = 'icons/obj/items/weapons/guns/handful.dmi'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@
///Does it launch its grenades in a low arc or a high? Do they strike people in their path, or fly beyond?
var/is_lobbing = FALSE
///Verboten munitions. This is a blacklist. Anything in this list isn't loadable.
var/disallowed_grenade_types = list(/obj/item/explosive/grenade/spawnergrenade, /obj/item/explosive/grenade/alien, /obj/item/explosive/grenade/incendiary/molotov, /obj/item/explosive/grenade/flashbang)
var/disallowed_grenade_types = list(/obj/item/explosive/grenade/spawnergrenade,
/obj/item/explosive/grenade/alien,
/obj/item/explosive/grenade/nerve_gas,
/obj/item/explosive/grenade/incendiary/bursting_pipe,
/obj/item/explosive/grenade/xeno_acid_grenade,
/obj/item/explosive/grenade/incendiary/molotov,
/obj/item/explosive/grenade/flashbang)
///What is this weapon permitted to fire? This is a whitelist. Anything in this list can be fired. Anything.
var/valid_munitions = list(/obj/item/explosive/grenade)

Expand Down
4 changes: 4 additions & 0 deletions code/modules/projectiles/magazines/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@
//rocket launchers

/obj/item/ammo_magazine/rifle/grenadespawner
AUTOWIKI_SKIP(TRUE)

name = "\improper GRENADE SPAWNER AMMO"
desc = "OH GOD OH FUCK"
default_ammo = /datum/ammo/grenade_container/rifle
ammo_band_color = AMMO_BAND_COLOR_LIGHT_EXPLOSIVE

/obj/item/ammo_magazine/rifle/huggerspawner
AUTOWIKI_SKIP(TRUE)

name = "\improper HUGGER SPAWNER AMMO"
desc = "OH GOD OH FUCK"
default_ammo = /datum/ammo/hugger_container
Expand Down
1 change: 1 addition & 0 deletions colonialmarines.dme
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "code\__DEFINES\atmospherics.dm"
#include "code\__DEFINES\autofire.dm"
#include "code\__DEFINES\autolathe.dm"
#include "code\__DEFINES\autowiki.dm"
#include "code\__DEFINES\blood.dm"
#include "code\__DEFINES\bsql.config.dm"
#include "code\__DEFINES\bullet_traits.dm"
Expand Down

0 comments on commit 2f2bf9c

Please sign in to comment.