Files
Bubberstation/code/datums/martial/_martial.dm
Zephyr fbec9c14e9 JSON Logging Take Two (#73604)
## About The Pull Request

Converts all logging, excluding perf and investigate, to json.
I focused on making the system as easy to use and as easy to add new
categories as possible.

Due to issues related to logging to world at global creation logger is
now a byond real, which is created directly before Master

Log categories support versioning, secret flagging, and sub-category
filtering. Although all of this is entirely optional for coders.
If you ever want to add a new category and use it, all you need to do is
make the barebones category datum and the define.
I've kept existing procs such as log_game, and simply turned them into a
wrapper for Logger.Log(xxx, ...)
## Why It's Good For The Game

Makes processing and filtering logs much easier in the future, while
only minimally downgrading log crawling experience.
I am also working on a log viewer frontend for admin usage however that
will take a little bit longer to finish up.
Also makes special logging and data tracking much easier thanks to a
data list processing implementation and handling
## Changelog
🆑
server: All logs are now formatted in json, excluding perf and
investigations
/🆑

---------

Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: tattle <66640614+dragomagol@users.noreply.github.com>
Co-authored-by: Kyle Spier-Swenson <kyleshome@gmail.com>
Co-authored-by: GoldenAlpharex <58045821+GoldenAlpharex@users.noreply.github.com>
2023-05-22 14:51:00 +12:00

108 lines
3.9 KiB
Plaintext

/datum/martial_art
var/name = "Martial Art"
var/id = "" //ID, used by mind/has_martialart
var/streak = ""
var/max_streak_length = 6
var/current_target
var/datum/martial_art/base // The permanent style. This will be null unless the martial art is temporary
var/block_chance = 0 //Chance to block melee attacks using items while on throw mode.
var/help_verb
var/allow_temp_override = TRUE //if this martial art can be overridden by temporary martial arts
var/smashes_tables = FALSE //If the martial art smashes tables when performing table slams and head smashes
var/datum/weakref/holder //owner of the martial art
var/display_combos = FALSE //shows combo meter if true
var/combo_timer = 6 SECONDS // period of time after which the combo streak is reset.
var/timerid
/// If set to true this style allows you to punch people despite being a pacifist (for instance Boxing, which does no damage)
var/pacifist_style = FALSE
/datum/martial_art/serialize_list(list/options, list/semvers)
. = ..()
.["name"] = name
.["id"] = id
.["pacifist_style"] = pacifist_style
SET_SERIALIZATION_SEMVER(semvers, "1.0.0")
return .
/datum/martial_art/proc/help_act(mob/living/attacker, mob/living/defender)
return MARTIAL_ATTACK_INVALID
/datum/martial_art/proc/disarm_act(mob/living/attacker, mob/living/defender)
return MARTIAL_ATTACK_INVALID
/datum/martial_art/proc/harm_act(mob/living/attacker, mob/living/defender)
return MARTIAL_ATTACK_INVALID
/datum/martial_art/proc/grab_act(mob/living/attacker, mob/living/defender)
return MARTIAL_ATTACK_INVALID
/datum/martial_art/proc/can_use(mob/living/L)
return TRUE
/datum/martial_art/proc/add_to_streak(element, mob/living/defender)
if(defender != current_target)
reset_streak(defender)
streak = streak+element
if(length(streak) > max_streak_length)
streak = copytext(streak, 1 + length(streak[1]))
if (display_combos)
var/mob/living/holder_living = holder.resolve()
timerid = addtimer(CALLBACK(src, PROC_REF(reset_streak), null, FALSE), combo_timer, TIMER_UNIQUE | TIMER_STOPPABLE)
holder_living?.hud_used?.combo_display.update_icon_state(streak, combo_timer - 2 SECONDS)
/datum/martial_art/proc/reset_streak(mob/living/new_target, update_icon = TRUE)
if(timerid)
deltimer(timerid)
current_target = new_target
streak = ""
if(update_icon)
var/mob/living/holder_living = holder?.resolve()
holder_living?.hud_used?.combo_display.update_icon_state(streak)
/datum/martial_art/proc/teach(mob/living/holder_living, make_temporary=FALSE)
if(!istype(holder_living) || !holder_living.mind)
return FALSE
if(holder_living.mind.martial_art)
if(make_temporary)
if(!holder_living.mind.martial_art.allow_temp_override)
return FALSE
store(holder_living.mind.martial_art, holder_living)
else
holder_living.mind.martial_art.on_remove(holder_living)
else if(make_temporary)
base = holder_living.mind.default_martial_art
if(help_verb)
add_verb(holder_living, help_verb)
holder_living.mind.martial_art = src
holder = WEAKREF(holder_living)
return TRUE
/datum/martial_art/proc/store(datum/martial_art/old, mob/living/holder_living)
old.on_remove(holder_living)
if (old.base) //Checks if old is temporary, if so it will not be stored.
base = old.base
else //Otherwise, old is stored.
base = old
/datum/martial_art/proc/remove(mob/living/holder_living)
if(!istype(holder_living) || !holder_living.mind || holder_living.mind.martial_art != src)
return
on_remove(holder_living)
if(base)
base.teach(holder_living)
else
var/datum/martial_art/default = holder_living.mind.default_martial_art
default.teach(holder_living)
holder = null
/datum/martial_art/proc/on_remove(mob/living/holder_living)
if(help_verb)
remove_verb(holder_living, help_verb)
return
///Gets called when a projectile hits the owner. Returning anything other than BULLET_ACT_HIT will stop the projectile from hitting the mob.
/datum/martial_art/proc/on_projectile_hit(mob/living/attacker, obj/projectile/P, def_zone)
return BULLET_ACT_HIT