diff --git a/code/__DEFINES/vv.dm b/code/__DEFINES/vv.dm index 2ad4cd6c1ad..c5a80da0b00 100644 --- a/code/__DEFINES/vv.dm +++ b/code/__DEFINES/vv.dm @@ -97,6 +97,9 @@ #define VV_HK_MASS_DEL_TYPE "mass_delete_type" #define VV_HK_ARMOR_MOD "mod_obj_armor" +// /obj/item +#define VV_HK_ADD_FANTASY_AFFIX "add_fantasy_affix" + // /mob #define VV_HK_GIB "gib" #define VV_HK_GIVE_SPELL "give_spell" diff --git a/code/datums/components/fantasy/_fantasy.dm b/code/datums/components/fantasy/_fantasy.dm index 9b9a97e874a..47f955261fc 100644 --- a/code/datums/components/fantasy/_fantasy.dm +++ b/code/datums/components/fantasy/_fantasy.dm @@ -12,6 +12,7 @@ var/static/list/affixListing +///affixes expects an initialized list /datum/component/fantasy/Initialize(quality, list/affixes = list(), canFail=FALSE, announce=FALSE) if(!isitem(parent)) return COMPONENT_INCOMPATIBLE @@ -22,7 +23,10 @@ src.affixes = affixes appliedComponents = list() - randomAffixes() + if(affixes && affixes.len) + setAffixes() + else + randomAffixes() /datum/component/fantasy/Destroy() unmodify() @@ -55,6 +59,7 @@ quality = -quality return quality +///proc on creation for random affixes /datum/component/fantasy/proc/randomAffixes(force) if(!affixListing) affixListing = list() @@ -80,11 +85,20 @@ continue if(!(affix.alignment & alignment)) continue - if(!affix.validate(src)) + if(!affix.validate(parent)) continue affixes += affix usedSlots |= affix.placement +///proc on creation for specific affixes given to the fantasy component +/datum/component/fantasy/proc/setAffixes(force) + var/usedSlots = NONE + for(var/datum/fantasy_affix/affix in affixes) // We want at least 1 affix applied + if((affix.placement & usedSlots) || (!affix.validate(parent))) + affixes.Remove(affix) //bad affix (can't be added to this item) + continue + usedSlots |= affix.placement + /datum/component/fantasy/proc/modify() var/obj/item/master = parent diff --git a/code/datums/components/fantasy/affix.dm b/code/datums/components/fantasy/affix.dm index ad1f44ce4d8..02e09aaf7b9 100644 --- a/code/datums/components/fantasy/affix.dm +++ b/code/datums/components/fantasy/affix.dm @@ -1,10 +1,12 @@ /datum/fantasy_affix + ///only used for admins adding the affix, this is not what players will see. + var/name = "SOMEONE DIDN'T SET AN ADMIN NAME FOR THIS" var/placement // A bitflag of "slots" this affix takes up, for example pre/suffix var/alignment var/weight = 10 // For those occasional affixes which only make sense in certain circumstances -/datum/fantasy_affix/proc/validate(datum/component/fantasy/comp) +/datum/fantasy_affix/proc/validate(obj/item/attached) return TRUE /datum/fantasy_affix/proc/apply(datum/component/fantasy/comp, newName) diff --git a/code/datums/components/fantasy/prefixes.dm b/code/datums/components/fantasy/prefixes.dm index 1c42f0cc6bf..63c1b801e06 100644 --- a/code/datums/components/fantasy/prefixes.dm +++ b/code/datums/components/fantasy/prefixes.dm @@ -1,4 +1,5 @@ /datum/fantasy_affix/cosmetic_prefixes + name = "purely cosmetic prefix" placement = AFFIX_PREFIX alignment = AFFIX_GOOD | AFFIX_EVIL @@ -39,6 +40,7 @@ return "[pick(badPrefixes)] [newName]" /datum/fantasy_affix/tactical + name = "tactical" placement = AFFIX_PREFIX alignment = AFFIX_GOOD weight = 1 // Very powerful, no one should have such power @@ -49,6 +51,7 @@ return "tactical [newName]" /datum/fantasy_affix/pyromantic + name = "pyromantic" placement = AFFIX_PREFIX alignment = AFFIX_GOOD @@ -58,6 +61,7 @@ return "pyromantic [newName]" /datum/fantasy_affix/vampiric + name = "vampiric" placement = AFFIX_PREFIX alignment = AFFIX_GOOD weight = 5 @@ -68,6 +72,7 @@ return "vampiric [newName]" /datum/fantasy_affix/beautiful + name = "beautiful" placement = AFFIX_PREFIX alignment = AFFIX_GOOD @@ -81,6 +86,7 @@ master.RemoveElement(/datum/element/beauty, max(comp.quality, 1) * 250) /datum/fantasy_affix/ugly + name = "ugly" placement = AFFIX_PREFIX alignment = AFFIX_EVIL diff --git a/code/datums/components/fantasy/suffixes.dm b/code/datums/components/fantasy/suffixes.dm index b9e0c47c5cd..43726d7e2ff 100644 --- a/code/datums/components/fantasy/suffixes.dm +++ b/code/datums/components/fantasy/suffixes.dm @@ -1,4 +1,5 @@ /datum/fantasy_affix/cosmetic_suffixes + name = "purely cosmetic suffix" placement = AFFIX_SUFFIX alignment = AFFIX_GOOD | AFFIX_EVIL @@ -47,6 +48,7 @@ //////////// Good suffixes /datum/fantasy_affix/bane + name = "of slaying (random species, carbon or simple animal)" placement = AFFIX_SUFFIX alignment = AFFIX_GOOD @@ -78,6 +80,7 @@ return "[newName] of [initial(picked_mobtype.name)] slaying" /datum/fantasy_affix/summoning + name = "of summoning (dangerous, can pick all but megafauna tier stuff)" placement = AFFIX_SUFFIX alignment = AFFIX_GOOD weight = 5 @@ -115,11 +118,12 @@ return "[newName] of [initial(picked_mobtype.name)] summoning" /datum/fantasy_affix/shrapnel + name = "shrapnel" placement = AFFIX_SUFFIX alignment = AFFIX_GOOD -/datum/fantasy_affix/shrapnel/validate(datum/component/fantasy/comp) - if(isgun(comp.parent)) +/datum/fantasy_affix/shrapnel/validate(obj/item/attached) + if(isgun(attached)) return TRUE return FALSE @@ -149,6 +153,7 @@ return "[newName] of [initial(picked_projectiletype.name)] shrapnel" /datum/fantasy_affix/strength + name = "of strength (knockback)" placement = AFFIX_SUFFIX alignment = AFFIX_GOOD @@ -161,6 +166,7 @@ //////////// Bad suffixes /datum/fantasy_affix/fool + name = "of the fool (honking)" placement = AFFIX_SUFFIX alignment = AFFIX_EVIL diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index 1b1a3e2cff8..767fe1ac0db 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -1115,6 +1115,7 @@ /atom/movable/vv_get_dropdown() . = ..() VV_DROPDOWN_OPTION(VV_HK_DEADCHAT_PLAYS, "Start/Stop Deadchat Plays") + VV_DROPDOWN_OPTION(VV_HK_ADD_FANTASY_AFFIX, "Add Fantasy Affix") /atom/movable/vv_do_topic(list/href_list) . = ..() diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index ff028fb274d..371bcdcf00f 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -364,6 +364,64 @@ GLOBAL_VAR_INIT(embedpocalypse, FALSE) // if true, all items will be able to emb add_fingerprint(usr) return ..() +/obj/item/vv_get_dropdown() + . = ..() + VV_DROPDOWN_OPTION(VV_HK_ADD_FANTASY_AFFIX, "Add Fantasy Affix") + +/obj/item/vv_do_topic(list/href_list) + . = ..() + + if(!.) + return + + if(href_list[VV_HK_ADD_FANTASY_AFFIX] && check_rights(R_FUN)) + + //gathering all affixes that make sense for this item + var/list/prefixes = list() + var/list/suffixes = list() + for(var/datum/fantasy_affix/affix_choice as anything in subtypesof(/datum/fantasy_affix)) + affix_choice = new affix_choice() + if(!affix_choice.validate(src)) + qdel(affix_choice) + else + if(affix_choice.placement & AFFIX_PREFIX) + prefixes[affix_choice.name] = affix_choice + else + suffixes[affix_choice.name] = affix_choice + + //making it more presentable here + var/list/affixes = list("---PREFIXES---") + affixes.Add(prefixes) + affixes.Add("---SUFFIXES---") + affixes.Add(suffixes) + + //admin picks, cleanup the ones we didn't do and handle chosen + var/picked_affix_name = input(usr, "Choose an affix to add to [src]...", "Enchant [src]") as null|anything in affixes + if(!affixes[picked_affix_name] || QDELETED(src)) + return + var/datum/fantasy_affix/affix = affixes[picked_affix_name] + affixes.Remove(affix) + QDEL_LIST_ASSOC(affixes) //remove the rest, we didn't use them + var/fantasy_quality = 0 + if(affix.alignment & AFFIX_GOOD) + fantasy_quality++ + else + fantasy_quality-- + + //name gets changed by the component so i want to store it for feedback later + var/before_name = name + //naming these vars that i'm putting into the fantasy component to make it more readable + var/canFail = FALSE + var/announce = FALSE + //Apply fantasy with affix. failing this should never happen, but if it does it should not be silent. + if(AddComponent(/datum/component/fantasy, fantasy_quality, list(affix), canFail, announce) == COMPONENT_INCOMPATIBLE) + to_chat(usr, "Fantasy component not compatible with [src].") + CRASH("fantasy component incompatible with object of type: [type]") + + to_chat(usr, "[before_name] now has [picked_affix_name]!") + log_admin("[key_name(usr)] has added [picked_affix_name] fantasy affix to [before_name]") + message_admins("[key_name(usr)] has added [picked_affix_name] fantasy affix to [before_name]") + /obj/item/attack_hand(mob/user, list/modifiers) . = ..() if(.)