Skip to content

Commit

Permalink
more unatomic changes removed
Browse files Browse the repository at this point in the history
  • Loading branch information
FalloutFalcon committed Sep 29, 2024
1 parent b900fcd commit 3f3ffdf
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 164 deletions.
1 change: 0 additions & 1 deletion code/_compile_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@

#ifdef ALL_TESTS
#define BASIC_TESTS
//#define EXTRA_ICON_TESTS
#define CREATE_AND_DESTROY_TEST
#define PLANET_GEN_TEST
#define RUIN_PLACEMENT_TEST
Expand Down
34 changes: 5 additions & 29 deletions code/modules/mob/living/carbon/human/human_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,11 @@
/mob/living/carbon/human/proc/check_shields(atom/AM, damage, attack_text = "the attack", attack_type = MELEE_ATTACK, armour_penetration = 0)
var/block_chance_modifier = round(damage / -3)

var/obj/item/shield = get_best_shield()
if(shield)
var/final_block_chance = shield.block_chance - (clamp((armour_penetration - shield.armour_penetration)/2,0,100)) + block_chance_modifier
var/shield_result = shield.hit_reaction(src, AM, attack_text, final_block_chance, damage, attack_type)
if(shield_result >= 1)
return TRUE
if(shield_result == -1)
return -1
for(var/obj/item/I in held_items)
if(!istype(I, /obj/item/clothing) || I == get_active_held_item() || istype(I ,/obj/item/shield))
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
if(I.hit_reaction(src, AM, attack_text, final_block_chance, damage, attack_type))
return TRUE

if(wear_suit)
var/final_block_chance = wear_suit.block_chance - (clamp((armour_penetration - wear_suit.armour_penetration)/2,0,100)) + block_chance_modifier
Expand All @@ -133,27 +130,6 @@

return FALSE


/mob/living/carbon/human/proc/get_best_shield()
var/obj/item/l_hand = held_items[1]
var/obj/item/r_hand = held_items[2]
var/datum/component/parry/left_hand_parry = l_hand?.GetComponent(/datum/component/parry)
var/datum/component/parry/right_hand_parry = r_hand?.GetComponent(/datum/component/parry)
if(!right_hand_parry && !left_hand_parry)
if(!(r_hand || l_hand))
return r_hand || l_hand
else if(r_hand?.block_chance > l_hand?.block_chance)
return r_hand
else
return l_hand

if(right_hand_parry && left_hand_parry)
if(right_hand_parry.stamina_coefficient > left_hand_parry.stamina_coefficient) // try and parry with your best item
return left_hand_parry.parent
else
return right_hand_parry.parent
return right_hand_parry?.parent || left_hand_parry?.parent // parry with whichever hand has an item that can parry

/mob/living/carbon/human/proc/check_block()
if(mind)
if(mind.martial_art && prob(mind.martial_art.block_chance) && mind.martial_art.can_use(src) && throw_mode && !incapacitated(FALSE, TRUE))
Expand Down
2 changes: 0 additions & 2 deletions code/modules/unit_tests/_unit_tests.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
#define TEST_OUTPUT_GREEN(text) (text)
#endif

#define EXTRA_ICON_TESTS

#ifdef BASIC_TESTS
#include "icons/inhands.dm"
#include "icons/missing_icons.dm"
Expand Down
55 changes: 17 additions & 38 deletions code/modules/unit_tests/icons/missing_icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,52 +26,31 @@
//generate_possible_icon_states_list("your/folder/path/")
var/list/bad_list = list()
for(var/obj/obj_path as anything in subtypesof(/obj))
var/list/icons_to_find = list()
var/search_for_w = FALSE
var/search_for_on = FALSE

if(isbadpath(obj_path))
continue
if(ispath(obj_path, /obj/item))
var/obj/item/item_path = obj_path
if(initial(item_path.item_flags) & ABSTRACT)
continue
if(ispath(obj_path, /obj/item/melee))
if(obj_path != /obj/item/melee/sword/supermatter)
var/obj/item/melee/melee_item = new item_path()
if(melee_item.GetComponent(/datum/component/two_handed))
search_for_w = TRUE
if(melee_item.GetComponent(/datum/component/transforming))
search_for_on = TRUE

var/icon = initial(obj_path.icon)
var/init_icon_path = initial(obj_path.icon_state)
icons_to_find += init_icon_path
if(!isnull(init_icon_path))
if(search_for_w)
icons_to_find += "[init_icon_path]_w"
if(search_for_on)
icons_to_find += "[init_icon_path]_on"

for(var/icon_state in icons_to_find)
if(isnull(icon))
continue
if(isnull(icon_state))
continue
if(isnull(icon))
continue
var/icon_state = initial(obj_path.icon_state)
if(isnull(icon_state))
continue

if(length(bad_list) && (icon_state in bad_list[icon]))
continue
if(length(bad_list) && (icon_state in bad_list[icon]))
continue

if(icon_exists(icon, icon_state))
continue
if(icon_exists(icon, icon_state))
continue

if(icon_state == "nothing")
continue
if(icon_state == "nothing")
continue

bad_list[icon] += list(icon_state)
bad_list[icon] += list(icon_state)

var/match_message
if(icon_state in possible_icon_states)
for(var/file_place in possible_icon_states[icon_state])
match_message += (match_message ? " & '[file_place]'" : " - Matching sprite found in: '[file_place]'")
TEST_FAIL("Missing icon_state for [obj_path] in '[icon]'.\n\ticon_state = \"[icon_state]\"[match_message]")
var/match_message
if(icon_state in possible_icon_states)
for(var/file_place in possible_icon_states[icon_state])
match_message += (match_message ? " & '[file_place]'" : " - Matching sprite found in: '[file_place]'")
TEST_FAIL("Missing icon_state for [obj_path] in '[icon]'.\n\ticon_state = \"[icon_state]\"[match_message]")
94 changes: 0 additions & 94 deletions code/modules/unit_tests/icons/worn_icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,97 +114,3 @@

if(fail_reasons)
TEST_FAIL(fail_reasons)

#ifdef EXTRA_ICON_TESTS
//The exact same test expect this time we warn instead of fail because most items dont really NEED to apear on a player
for(var/obj/item/item_path as anything in (subtypesof(/obj/item/melee) + subtypesof(/obj/item/gun)))
var/cached_slot_flags = initial(item_path.slot_flags)
if(!cached_slot_flags || (cached_slot_flags & ITEM_SLOT_LPOCKET) || (cached_slot_flags & ITEM_SLOT_RPOCKET) || initial(item_path.item_flags) & ABSTRACT || isbadpath(item_path))
continue

var/mob_overlay_icon = initial(item_path.mob_overlay_icon) //override icon file. where our sprite is contained if set. (ie modularity stuff)
var/mob_overlay_state = initial(item_path.mob_overlay_state) //overrides icon_state.
var/icon_state = mob_overlay_state || initial(item_path.icon_state) //icon_state. what sprite name we are looking for.

if(isnull(icon_state))
continue //no sprite for the item.
if(icon_state in already_warned_icons)
continue

var/match_message
if(icon_state in possible_icon_states)
for(var/file_place in possible_icon_states[icon_state])
match_message += (match_message ? " & '[file_place]'" : " - Matching sprite found in: '[file_place]'")

if(mob_overlay_icon) //easiest to check since we override everything. this automatically includes downstream support.
if(!(icon_state in icon_states(mob_overlay_icon, 1)))
log_world("[item_path] using invalid [mob_overlay_state ? "mob_overlay_state" : "icon_state"], \"[icon_state]\" in mob_overlay_icon override file, '[mob_overlay_icon]'[match_message]")
continue

var/icon_file //checks against all the default icon locations if one isn't defined.
var/fail_reasons
var/spacer


if(cached_slot_flags & ITEM_SLOT_BACK)
icon_file = 'icons/mob/clothing/back.dmi'

if(!(icon_state in icon_states(icon_file, 1)))
already_warned_icons += icon_state
fail_reasons += "[item_path] using invalid [mob_overlay_state ? "mob_overlay_state" : "icon_state"], \"[icon_state]\" in '[icon_file]'[match_message]"
spacer = "\n\t"

/*
if(cached_slot_flags & ITEM_SLOT_ID)
icon_file = 'icons/mob/clothing/id.dmi'
if(!(icon_state in icon_states(icon_file, 1)))
already_warned_icons += icon_state
fail_reasons += "[spacer][item_path] using invalid [mob_overlay_state ? "mob_overlay_state" : "icon_state"], \"[icon_state]\" in '[icon_file]'[match_message]"
spacer = "\n\t"
*/

if(cached_slot_flags & ITEM_SLOT_GLOVES)
icon_file = 'icons/mob/clothing/hands.dmi'
if(!(icon_state in icon_states(icon_file, 1)))
already_warned_icons += icon_state
fail_reasons += "[spacer][item_path] using invalid [mob_overlay_state ? "mob_overlay_state" : "icon_state"], \"[icon_state]\" in '[icon_file]'[match_message]"
spacer = "\n\t"

if(cached_slot_flags & ITEM_SLOT_EYES)
icon_file = 'icons/mob/clothing/eyes.dmi'
if(!(icon_state in icon_states(icon_file, 1)))
already_warned_icons += icon_state
fail_reasons += "[spacer][item_path] using invalid [mob_overlay_state ? "mob_overlay_state" : "icon_state"], \"[icon_state]\" in '[icon_file]'[match_message]"
spacer = "\n\t"

if(cached_slot_flags & ITEM_SLOT_EARS)
icon_file = 'icons/mob/clothing/ears.dmi'
if(!(icon_state in icon_states(icon_file, 1)))
already_warned_icons += icon_state
fail_reasons += "[spacer][item_path] using invalid [mob_overlay_state ? "mob_overlay_state" : "icon_state"], \"[icon_state]\" in '[icon_file]'[match_message]"
spacer = "\n\t"

if(cached_slot_flags & ITEM_SLOT_NECK)
icon_file = 'icons/mob/clothing/neck.dmi'
if(!(icon_state in icon_states(icon_file, 1)))
already_warned_icons += icon_state
fail_reasons += "[spacer][item_path] using invalid [mob_overlay_state ? "mob_overlay_state" : "icon_state"], \"[icon_state]\" in '[icon_file]'[match_message]"
spacer = "\n\t"

if(cached_slot_flags & ITEM_SLOT_MASK)
icon_file = 'icons/mob/clothing/mask.dmi'
if(!(icon_state in icon_states(icon_file, 1)))
already_warned_icons += icon_state
fail_reasons += "[spacer][item_path] using invalid [mob_overlay_state ? "mob_overlay_state" : "icon_state"], \"[icon_state]\" in '[icon_file]'[match_message]"
spacer = "\n\t"

if(cached_slot_flags & ITEM_SLOT_BELT)
icon_file = 'icons/mob/clothing/belt.dmi'
if(!(icon_state in icon_states(icon_file, 1)))
already_warned_icons += icon_state
fail_reasons += "[spacer][item_path] using invalid [mob_overlay_state ? "mob_overlay_state" : "icon_state"], \"[icon_state]\" in '[icon_file]'[match_message]"
spacer = "\n\t"

if(fail_reasons)
log_world(fail_reasons)
#endif //EXTRA_ICON_TESTS

0 comments on commit 3f3ffdf

Please sign in to comment.