From 825adfa29ffac4769a00ba78b6927a311d19b068 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Wed, 25 Mar 2020 21:23:54 -0700 Subject: [PATCH] whew --- code/__DEFINES/combat/block.dm | 1 + code/__DEFINES/{ => flags}/flags.dm | 0 .../{obj_flags.dm => flags/item_flags.dm} | 22 +++---------- code/__DEFINES/flags/obj_flags.dm | 15 +++++++++ code/__HELPERS/cmp.dm | 2 +- code/game/objects/items.dm | 6 ++++ .../mob/living/carbon/human/human_block.dm | 9 +++-- code/modules/mob/living/living_block.dm | 27 +++++++++++---- .../mob/living/living_blocking_parrying.dm | 33 ++++++++++--------- .../chemistry/reagents/alcohol_reagents.dm | 4 +-- 10 files changed, 74 insertions(+), 45 deletions(-) rename code/__DEFINES/{ => flags}/flags.dm (100%) rename code/__DEFINES/{obj_flags.dm => flags/item_flags.dm} (74%) create mode 100644 code/__DEFINES/flags/obj_flags.dm diff --git a/code/__DEFINES/combat/block.dm b/code/__DEFINES/combat/block.dm index 71ba20b22b..d3c6d1e90e 100644 --- a/code/__DEFINES/combat/block.dm +++ b/code/__DEFINES/combat/block.dm @@ -44,6 +44,7 @@ #define DEFAULT_REDIRECT_METHOD_PROJECTILE REDIRECT_METHOD_DEFLECT /// Block priorities. Higher means it's checked sooner. +// THESE MUST NEVER BE 0! Block code uses ! instead of isnull for the speed boost. #define BLOCK_PRIORITY_ACTIVE_PARRY 300 #define BLOCK_PRIORITY_ACTIVE_BLOCK 200 #define BLOCK_PRIORITY_HELD_ITEM 100 diff --git a/code/__DEFINES/flags.dm b/code/__DEFINES/flags/flags.dm similarity index 100% rename from code/__DEFINES/flags.dm rename to code/__DEFINES/flags/flags.dm diff --git a/code/__DEFINES/obj_flags.dm b/code/__DEFINES/flags/item_flags.dm similarity index 74% rename from code/__DEFINES/obj_flags.dm rename to code/__DEFINES/flags/item_flags.dm index d78de86d25..6b754a5956 100644 --- a/code/__DEFINES/obj_flags.dm +++ b/code/__DEFINES/flags/item_flags.dm @@ -1,20 +1,3 @@ -// Flags for the obj_flags var on /obj - - -#define EMAGGED (1<<0) -#define IN_USE (1<<1) //If we have a user using us, this will be set on. We will check if the user has stopped using us, and thus stop updating and LAGGING EVERYTHING! -#define CAN_BE_HIT (1<<2) //can this be bludgeoned by items? -#define BEING_SHOCKED (1<<3) //Whether this thing is currently (already) being shocked by a tesla -#define DANGEROUS_POSSESSION (1<<4) //Admin possession yes/no -#define ON_BLUEPRINTS (1<<5) //Are we visible on the station blueprints at roundstart? -#define UNIQUE_RENAME (1<<6) //can you customize the description/name of the thing? -#define USES_TGUI (1<<7) //put on things that use tgui on ui_interact instead of custom/old UI. -#define FROZEN (1<<8) -#define SHOVABLE_ONTO (1<<9) //called on turf.shove_act() to consider whether an object should have a niche effect (defined in their own shove_act()) when someone is pushed onto it, or do a sanity CanPass() check. -#define BLOCK_Z_FALL (1<<10) - -// If you add new ones, be sure to add them to /obj/Initialize as well for complete mapping support - // Flags for the item_flags var on /obj/item #define BEING_REMOVED (1<<0) @@ -30,6 +13,11 @@ #define SURGICAL_TOOL (1<<10) //Tool commonly used for surgery: won't attack targets in an active surgical operation on help intent (in case of mistakes) #define NO_UNIFORM_REQUIRED (1<<11) //Can be worn on certain slots (currently belt and id) that would otherwise require an uniform. #define NO_ATTACK_CHAIN_SOFT_STAMCRIT (1<<12) //Entirely blocks melee_attack_chain() if user is soft stamcritted. Uses getStaminaLoss() to check at this point in time. THIS DOES NOT BLOCK RANGED AFTERATTACK()S, ONLY MELEE RANGE AFTERATTACK()S. +/// This item can be used to parry. Only a basic check used to determine if we should proceed with parry chain at all. +#define ITEM_CAN_PARRY (1<<0) +/// This item can be used in the directional blocking system. Only a basic check used to determine if we should proceed with directional block handling at all. +#define ITEM_CAN_BLOCK (1<<1) + // Flags for the clothing_flags var on /obj/item/clothing diff --git a/code/__DEFINES/flags/obj_flags.dm b/code/__DEFINES/flags/obj_flags.dm new file mode 100644 index 0000000000..ebb9b4bda0 --- /dev/null +++ b/code/__DEFINES/flags/obj_flags.dm @@ -0,0 +1,15 @@ +// Flags for the obj_flags var on /obj + +#define EMAGGED (1<<0) +#define IN_USE (1<<1) //If we have a user using us, this will be set on. We will check if the user has stopped using us, and thus stop updating and LAGGING EVERYTHING! +#define CAN_BE_HIT (1<<2) //can this be bludgeoned by items? +#define BEING_SHOCKED (1<<3) //Whether this thing is currently (already) being shocked by a tesla +#define DANGEROUS_POSSESSION (1<<4) //Admin possession yes/no +#define ON_BLUEPRINTS (1<<5) //Are we visible on the station blueprints at roundstart? +#define UNIQUE_RENAME (1<<6) //can you customize the description/name of the thing? +#define USES_TGUI (1<<7) //put on things that use tgui on ui_interact instead of custom/old UI. +#define FROZEN (1<<8) +#define SHOVABLE_ONTO (1<<9) //called on turf.shove_act() to consider whether an object should have a niche effect (defined in their own shove_act()) when someone is pushed onto it, or do a sanity CanPass() check. +#define BLOCK_Z_FALL (1<<10) + +// If you add new ones, be sure to add them to /obj/Initialize as well for complete mapping support diff --git a/code/__HELPERS/cmp.dm b/code/__HELPERS/cmp.dm index 9b877e8fb0..5fb4d05d42 100644 --- a/code/__HELPERS/cmp.dm +++ b/code/__HELPERS/cmp.dm @@ -104,7 +104,7 @@ GLOBAL_VAR_INIT(cmp_field, "name") var/a_sign = num2sign(initial(A.value) * -1) var/b_sign = num2sign(initial(B.value) * -1) - // Neutral traits go last. + // Neutral traits go last if(a_sign == 0) a_sign = 2 if(b_sign == 0) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index ed08386f81..50a8273dbb 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -107,6 +107,12 @@ GLOBAL_VAR_INIT(rpg_loot_items, FALSE) var/list/grind_results //A reagent list containing the reagents this item produces when ground up in a grinder - this can be an empty list to allow for reagent transferring only var/list/juice_results //A reagent list containing blah blah... but when JUICED in a grinder! + /* Our block parry data. Should be set in init, or something if you are using it. + * This won't be accessed without ITEM_CAN_BLOCK or ITEM_CAN_PARRY so do not set it unless you have to to save memory. + * If you decide it's a good idea to leave this unset while turning the flags on, you will runtime. Enjoy. + */ + var/datum/block_parry_data/block_parry_data + /obj/item/Initialize() if (attack_verb) diff --git a/code/modules/mob/living/carbon/human/human_block.dm b/code/modules/mob/living/carbon/human/human_block.dm index b1a5153ce5..e95d932cc1 100644 --- a/code/modules/mob/living/carbon/human/human_block.dm +++ b/code/modules/mob/living/carbon/human/human_block.dm @@ -1,8 +1,11 @@ /mob/living/carbon/human/get_blocking_items() . = ..() if(wear_suit) - . += wear_suit + if(!.[wear_suit]) + .[wear_suit] = wear_suit.block_priority if(w_uniform) - . += w_uniform + if(!.[wear_uniform]) + .[wear_uniform] = wear_uniform.block_priority if(wear_neck) - . += wear_neck + if(!.[wear_neck]) + .[wear_neck] = wear_neck.block_priority diff --git a/code/modules/mob/living/living_block.dm b/code/modules/mob/living/living_block.dm index d9e3309e47..f8b62349e6 100644 --- a/code/modules/mob/living/living_block.dm +++ b/code/modules/mob/living/living_block.dm @@ -51,31 +51,46 @@ if((. & BLOCK_SUCCESS) && !(. & BLOCK_CONTINUE_CHAIN)) return var/list/obj/item/tocheck = get_blocking_items() - sortTim(tocheck, /proc/cmp_item_block_priority_asc) + sortTim(tocheck, /proc/cmp_numeric_asc, TRUE) // i don't like this var/block_chance_modifier = round(damage / -3) if(real_attack) for(var/obj/item/I in tocheck) // i don't like this too var/final_block_chance = I.block_chance - (CLAMP((armour_penetration-I.armour_penetration)/2,0,100)) + block_chance_modifier //So armour piercing blades can still be parried by other blades, for example - var/results = I.run_block(src, object, damage, attack_text, attack_type, armour_penetration, attacker, def_zone, final_block_chance, return_list) + var/results + if(I == active_parry_item) + results = I.active_parry(src, object, damage, attack_text, attack_type, armour_penetration, attacker, def_zone, final_block_chance, return_list) + else if(I == active_block_item) + results = I.active_block(src, object, damage, attack_text, attack_type, armour_penetration, attacker, def_zone, final_block_chance, return_list) + else + results = I.run_block(src, object, damage, attack_text, attack_type, armour_penetration, attacker, def_zone, final_block_chance, return_list) . |= results if((results & BLOCK_SUCCESS) && !(results & BLOCK_CONTINUE_CHAIN)) break else for(var/obj/item/I in tocheck) // i don't like this too - var/final_block_chance = I.block_chance - (CLAMP((armour_penetration-I.armour_penetration)/2,0,100)) + block_chance_modifier //So armour piercing blades can still be parried by other blades, for example - I.check_block(src, object, damage, attack_text, attack_type, armour_penetration, attacker, def_zone, final_block_chance, return_list) + if(I == active_block_item) //block is long termed enough we give a damn. parry, not so much. + I.check_active_block(src, object, damage, attack_text, attack_type, armour_penetration, attacker, def_zone, final_block_chance, return_list) + else + var/final_block_chance = I.block_chance - (CLAMP((armour_penetration-I.armour_penetration)/2,0,100)) + block_chance_modifier //So armour piercing blades can still be parried by other blades, for example + I.check_block(src, object, damage, attack_text, attack_type, armour_penetration, attacker, def_zone, final_block_chance, return_list) -/// Gets an unsortedlist of objects to run block checks on. +/// Gets an unsortedlist of objects to run block checks on. List must have associative values for priorities! /mob/living/proc/get_blocking_items() . = list() + if(active_block_item) + .[active_block_item] = active_block_item.block_parry_data.block_active_priority + if(active_parry_item) + .[active_parry_item] = active_parry_item.block_parry_data.parry_active_priority for(var/obj/item/I in held_items) // this is a bad check but i am not removing it until a better catchall is made if(istype(I, /obj/item/clothing)) continue - . |= I + if(.[I]) //don't override block/parry. + continue + .[I] = I.block_priority /obj/item /// The 0% to 100% chance for the default implementation of random block rolls. diff --git a/code/modules/mob/living/living_blocking_parrying.dm b/code/modules/mob/living/living_blocking_parrying.dm index 3ee5431eb6..cc6bae8054 100644 --- a/code/modules/mob/living/living_blocking_parrying.dm +++ b/code/modules/mob/living/living_blocking_parrying.dm @@ -1,7 +1,8 @@ // yell at me later for file naming // This file contains stuff relating to the new directional blocking and parry system. /mob/living - var/obj/item/blocking_item + var/obj/item/active_block_item + var/obj/item/active_parry_item var/parrying = FALSE var/parry_frame = 0 @@ -34,7 +35,7 @@ GLOBAL_LIST_EMPTY(block_parry_data) var/block_end_click_cd_add = 4 /// Disallow attacking during block var/block_lock_attacking = TRUE - /// The priority we get in [mob/do_run_block()] while we're being used. + /// The priority we get in [mob/do_run_block()] while we're being used to parry. var/block_active_priority = BLOCK_PRIORITY_ACTIVE_BLOCK /// Amount of "free" damage blocking absorbs @@ -66,6 +67,8 @@ GLOBAL_LIST_EMPTY(block_parry_data) var/block_stamina_cost_per_second = 1.5 /////////// PARRYING //////////// + /// Prioriry for [mob/do_run_block()] while we're being used to parry. + var/parry_active_priority = BLOCK_PRIORITY_ACTIVE_PARRY /// Parry windup duration in deciseconds var/parry_time_windup = 2 /// Parry spooldown duration in deciseconds @@ -85,24 +88,22 @@ GLOBAL_LIST_EMPTY(block_parry_data) /// Efficiency in percent on perfect parry. var/parry_efficiency_perfect = 120 -/obj/item - /// Defense flags, see defines. - var/defense_flags = NONE - /// Our block parry data. Should be set in init, or something. - var/datum/block_parry_data/block_parry_data +/obj/item/proc/active_block(mob/living/owner, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return) + if(!CHECK_BITFIELD(item_flags, ITEM_CAN_BLOCK)) + return + /// Yadda yadda WIP access block/parry data... -/obj/item/Initialize(mapload) - block_parry_data = get_block_parry_data(/datum/block_parry_data) - return ..() - -/// This item can be used to parry. Only a basic check used to determine if we should proceed with parry chain at all. -#define ITEM_DEFENSE_CAN_PARRY (1<<0) -/// This item can be used in the directional blocking system. Only a basic check used to determine if we should proceed with directional block handling at all. -#define ITEM_DEFENSE_CAN_BLOCK (1<<1) - +/obj/item/proc/active_parry(mob/living/owner, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return) + if(!CHECK_BITFIELD(item_flags, ITEM_CAN_PARRY)) + return + /// Yadda yadda WIP access block/parry data... +/obj/item/proc/check_active_block(mob/living/owner, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return) + if(!CHECK_BITFIELD(item_flags, ITEM_CAN_BLOCK)) + return + /// Yadda yadda WIP access block/parry data... /** * Gets the list of directions we can block. Include DOWN to block attacks from our same tile. diff --git a/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm b/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm index b7f32421aa..a18dcc6210 100644 --- a/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm @@ -1646,7 +1646,7 @@ All effects don't start immediately, but rather get worse over time; the rate is glass_icon_state = "pina_colada" glass_name = "Pina Colada" glass_desc = "If you like pina coladas, and getting caught in the rain... well, you'll like this drink." - + /datum/reagent/consumable/ethanol/grasshopper name = "Grasshopper" description = "A fresh and sweet dessert shooter. Difficult to look manly while drinking this." @@ -2354,7 +2354,7 @@ All effects don't start immediately, but rather get worse over time; the rate is /datum/reagent/consumable/ethanol/hotlime_miami/on_mob_life(mob/living/carbon/M) M.set_drugginess(50) M.adjustStaminaLoss(-2) - return ..() + return ..() /datum/reagent/consumable/ethanol/fruit_wine name = "Fruit Wine"