diff --git a/burgerstation.dme b/burgerstation.dme index ef2745eb9d..8253e142a4 100644 --- a/burgerstation.dme +++ b/burgerstation.dme @@ -221,6 +221,7 @@ #include "code\_core\datum\ability\magic\_magic_projectile.dm" #include "code\_core\datum\ability\magic\_magic_summon_item.dm" #include "code\_core\datum\ability\magic\fireball.dm" +#include "code\_core\datum\ability\magic\mana_armor.dm" #include "code\_core\datum\ability\magic\radial_blind.dm" #include "code\_core\datum\ability\magic\smite.dm" #include "code\_core\datum\ability\magic\soul_trap.dm" @@ -817,6 +818,7 @@ #include "code\_core\datum\status_effect\grab.dm" #include "code\_core\datum\status_effect\immortal.dm" #include "code\_core\datum\status_effect\last_breath.dm" +#include "code\_core\datum\status_effect\mana_armor.dm" #include "code\_core\datum\status_effect\mana_void.dm" #include "code\_core\datum\status_effect\paralyzed.dm" #include "code\_core\datum\status_effect\parried.dm" diff --git a/code/__defines/status.dm b/code/__defines/status.dm index e39e2fcff8..3da1957bde 100644 --- a/code/__defines/status.dm +++ b/code/__defines/status.dm @@ -110,3 +110,4 @@ #define BLINDED "blinded" +#define MANA_ARMOR "mana_armor" \ No newline at end of file diff --git a/code/_core/datum/ability/magic/mana_armor.dm b/code/_core/datum/ability/magic/mana_armor.dm new file mode 100644 index 0000000000..04c4a3e9f8 --- /dev/null +++ b/code/_core/datum/ability/magic/mana_armor.dm @@ -0,0 +1,25 @@ +/ability/magic/mana_armor + name = "toggle mana armor" + desc = "A togglable ability that adds 25% of your total overall arcane armor rating to your overall blunt, blade, and pierce armor rating as long as you have more mana than half of your maximum mana. Taking damage removes mana equal to the amount of blunt, blade and pierce damage dealt." + icon_state = "mana_armor" + cost = 25 + cooldown = SECONDS_TO_DECISECONDS(3) + + toggle = TRUE + +/ability/magic/mana_armor/is_active(var/mob/caller) + + if(is_living(caller)) + var/mob/living/L = caller + return L.has_status_effect(MANA_ARMOR) + + return FALSE + +/ability/magic/mana_armor/on_cast(var/mob/caller,var/atom/target,location,params) + . = ..() + if(. && is_living(caller)) + var/mob/living/L = caller + if(L.has_status_effect(MANA_ARMOR)) + L.remove_status_effect(MANA_ARMOR) + else + L.add_status_effect(MANA_ARMOR,25,-1,L,TRUE,FALSE,TRUE) \ No newline at end of file diff --git a/code/_core/datum/health/mob/living/_living.dm b/code/_core/datum/health/mob/living/_living.dm index d5ab5a32f8..fef0f434e8 100644 --- a/code/_core/datum/health/mob/living/_living.dm +++ b/code/_core/datum/health/mob/living/_living.dm @@ -76,6 +76,7 @@ else .[damage_type] = bonus[damage_type] + /health/mob/living/update_health() var/mob/living/L = owner diff --git a/code/_core/datum/health/mob/living/advanced/_advanced.dm b/code/_core/datum/health/mob/living/advanced/_advanced.dm index a092041303..670915e46e 100644 --- a/code/_core/datum/health/mob/living/advanced/_advanced.dm +++ b/code/_core/datum/health/mob/living/advanced/_advanced.dm @@ -249,3 +249,25 @@ clothing_defense *= 0.5 .[damage_type] += FLOOR(clothing_defense,1) .["items"] += C + + var/mana_armor_value = STATUS_EFFECT_MAGNITUDE(A,MANA_ARMOR) + if(mana_armor_value > 0 && mana_current >= mana_max*0.5 && length(A.overall_clothing_defense_rating) && A.overall_clothing_defense_rating[ARCANE] > 0) + var/bonus_mana_armor = (mana_armor_value/100) * A.overall_clothing_defense_rating[ARCANE] + bonus_mana_armor = CEILING(bonus_mana_armor,1) + if(bonus_mana_armor > 0) + for(var/damage_type in list(BLADE,BLUNT,PIERCE)) + if(!.[damage_type]) + .[damage_type] = 0 + else if(IS_INFINITY(.[damage_type])) + continue + var/damage_type_difference = min(bonus_mana_armor,bonus_mana_armor - .[damage_type]) + if(damage_type_difference > 0) + .[damage_type] += damage_type_difference + + + + + + + + diff --git a/code/_core/datum/status_effect/mana_armor.dm b/code/_core/datum/status_effect/mana_armor.dm new file mode 100644 index 0000000000..9246f62b36 --- /dev/null +++ b/code/_core/datum/status_effect/mana_armor.dm @@ -0,0 +1,11 @@ +/status_effect/mana_armor + name = "Mana Armor" + desc = "Your mana protects your health, as long as you have more than half your maximum mana. Protection granted is based on arcane armor." + id = MANA_ARMOR + maximum = SECONDS_TO_DECISECONDS(300) + minimum = SECONDS_TO_DECISECONDS(1) + + default_duration = SECONDS_TO_DECISECONDS(30) + default_magnitude = 10 //Percent of mana taken before health + + affects_dead = FALSE diff --git a/code/_core/mob/living/advanced/health.dm b/code/_core/mob/living/advanced/health.dm index be6a877ae4..056b164287 100644 --- a/code/_core/mob/living/advanced/health.dm +++ b/code/_core/mob/living/advanced/health.dm @@ -14,4 +14,11 @@ . = ..() + if(damage_amount > 0) + var/mana_armor_value = STATUS_EFFECT_MAGNITUDE(src,MANA_ARMOR) + if(mana_armor_value > 0 && src.health && src.health.mana_current > src.health.mana_current*0.5 && length(src.overall_clothing_defense_rating[ARCANE]) > 0 && length(damage_table)) + var/total_brute = SAFENUM(damage_table[BLUNT]) + SAFENUM(damage_table[PIERCE]) + SAFENUM(damage_table[BLADE]) + if(total_brute > 0) + src.health.adjust_mana(-total_brute) + HOOK_CALL("on_damage_received") //For hulking and whatnot. \ No newline at end of file diff --git a/code/_core/obj/hud/buttons/ability.dm b/code/_core/obj/hud/buttons/ability.dm index 9ae18771b5..0e12d87de8 100644 --- a/code/_core/obj/hud/buttons/ability.dm +++ b/code/_core/obj/hud/buttons/ability.dm @@ -66,15 +66,15 @@ I.maptext = id add_overlay(I) if(ability) - if(ability.toggle && ability.is_active(owner)) - var/image/I3 = new/image(initial(icon),"[initial(icon_state)]_selected") - add_overlay(I3) var/image/I2 = new/image(ability.icon,ability.icon_state) I2.maptext = "