Skip to content

Commit

Permalink
QoL + Corrections.
Browse files Browse the repository at this point in the history
- Незаряживаемое незаряжается. Не заряжается сверх меры.
  • Loading branch information
Daeberdir committed Oct 10, 2024
1 parent fe0ab2a commit f3df3e7
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 58 deletions.
12 changes: 5 additions & 7 deletions code/datums/spells/charge.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@


/obj/effect/proc_holder/spell/charge/cast(list/targets, mob/user = usr)
var/charged_item
var/atom/charged_item
var/charge_result

var/mob/living/living = targets[1]

if(living.pulling)
charge_result = pulling.magic_charge_act(pulling)

if(!(charge_result & RECHARGE_SUCCESSFUL))
if(charge_result & RECHARGE_SUCCESSFUL)
charged_item = pulling

if(!charged_item)
var/list/hand_items = list(living.get_active_hand(), living.get_inactive_hand())

Expand All @@ -39,14 +39,12 @@
charged_item = item
break

if(!charged_item)
if(!(charge_result & RECHARGE_SUCCESSFUL) || QDELETED(charged_item))
to_chat(user, span_notice("You feel magical power surging to your hands, but the feeling rapidly fades..."))
return

if(charge_result & RECHARGE_BURNOUT)
to_chat(user, span_caution("[charged_item] is reacting poorly to the spell!"))
return

to_chat(user, span_notice("[charged_item] suddenly feels very warm!"))
return

14 changes: 9 additions & 5 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -719,12 +719,16 @@
/atom/proc/rcd_construct_act(mob/user, obj/item/rcd/our_rcd, rcd_mode)
return RCD_NO_ACT


/atom/proc/magic_charge_act(mob/user)
if(contents)
for(var/obj/item/stock_parts/cell/cell in contents)
. |= cell.magic_charge_act()

return .
. = NONE

if(!contents)
return

for(var/obj/item/stock_parts/cell/cell in contents)
. |= cell.magic_charge_act(user)


/atom/proc/hitby(atom/movable/AM, skipcatch, hitpush, blocked, datum/thrownthing/throwingdatum)
if(density && !AM.has_gravity()) //thrown stuff bounces off dense stuff in no grav, unless the thrown stuff ends up inside what it hit(embedding, bola, etc...).
Expand Down
17 changes: 10 additions & 7 deletions code/game/gamemodes/wizard/spellbook.dm
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,9 @@
..()
initialize()


/obj/item/spellbook/magic_charge_act(mob/user)
. |= RECHARGE_SUCCESSFUL|RECHARGE_BURNOUT
. = RECHARGE_SUCCESSFUL|RECHARGE_BURNOUT

to_chat(user, span_caution("Glowing red letters appear on the front cover..."))
to_chat(user, span_warning(pick("NICE TRY BUT NO!", \
Expand All @@ -776,7 +777,6 @@
"CUTE!", \
"YOU DIDN'T THINK IT'D BE THAT EASY, DID YOU?")))

return .

/obj/item/spellbook/attackby(obj/item/I, mob/living/user, params)
if(user.a_intent == INTENT_HARM || skip_refunds)
Expand Down Expand Up @@ -1027,19 +1027,22 @@
uses = 1
desc = "This template spellbook was never meant for the eyes of man..."


/obj/item/spellbook/oneuse/magic_charge_act(mob/user)
. = NONE

if(!used)
return

used = FALSE
. |= RECHARGE_SUCCESSFUL

if(prob(80))
visible_message(span_warning("[src] catches fire!"))
user.temporarily_remove_item_from_inventory(src)
qdel(src)

. |= RECHARGE_BURNOUT

return .

used = FALSE
return .

/obj/item/spellbook/oneuse/New()
..()
Expand Down
13 changes: 8 additions & 5 deletions code/game/objects/items/granters/_granters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,22 @@
/obj/item/book/granter/proc/can_learn(mob/living/user)
return TRUE


/obj/item/book/granter/magic_charge_act(mob/user)
. = NONE

if(uses >= initial(uses))
return

uses++
. |= RECHARGE_SUCCESSFUL

if(prob(80))
visible_message(span_warning("[src] catches fire!"))
user.temporarily_remove_item_from_inventory(src)
qdel(src)

. |= RECHARGE_BURNOUT

return .

uses++
return .

// Generic action giver
/obj/item/book/granter/action
Expand Down
15 changes: 5 additions & 10 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2303,27 +2303,22 @@
/mob/living/proc/update_movespeed_damage_modifiers()
return


/mob/living/magic_charge_act(mob/user)
if(LAZYLEN(mob_spell_list))
for(var/obj/effect/proc_holder/spell/spell as anything in mob_spell_list)
if(spell.cooldown_handler.is_on_cooldown())
continue

spell.revert_cast()
. |= RECHARGE_SUCCESSFUL
. |= RECHARGE_SUCCESSFUL

if(LAZYLEN(mind?.spell_list))
for(var/obj/effect/proc_holder/spell/spell as anything in mind?.spell_list)
if(spell.cooldown_handler.is_on_cooldown())
continue

spell.revert_cast()
. |= RECHARGE_SUCCESSFUL
. |= RECHARGE_SUCCESSFUL

if(!.)
to_chat(src, span_notice("You feel very strange for a moment, but then it passes."))
return .

to_chat(src, span_notice("You feel raw magical energy flowing through you, it feels good!"))
return .

to_chat(src, span_notice("You feel [(. & RECHARGE_SUCCESSFUL) ? "raw magical energy flowing through you, it feels good!" : "very strange for a moment, but then it passes."]"))
23 changes: 13 additions & 10 deletions code/modules/power/cell.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,31 @@
STOP_PROCESSING(SSobj, src)
return ..()


/obj/item/stock_parts/cell/magic_charge_act(mob/user)
. |= RECHARGE_SUCCESSFUL
. = NONE

if(charge >= maxcharge)
return

if(prob(80) && !adjust_maxcharge(-200))
if(prob(80) && adjust_maxcharge(-200))
. |= RECHARGE_BURNOUT

charge = maxcharge
update_icon()

return .
. |= RECHARGE_SUCCESSFUL

update_appearance(UPDATE_ICON)


/obj/item/stock_parts/cell/proc/adjust_maxcharge(amount)
if(self_recharge)
return FALSE // SelfCharging uses static charge values ​​per tick, so we don't want it to mess up the recharge balance.

var/oldcharge = maxcharge
var/old_maxcharge = maxcharge
maxcharge = max(maxcharge + amount, 1)

if(charge > maxcharge)
charge = maxcharge
return maxcharge != old_maxcharge

return maxcharge != oldcharge

/obj/item/stock_parts/cell/vv_edit_var(var_name, var_value)
. = ..()
Expand Down
20 changes: 12 additions & 8 deletions code/modules/projectiles/guns/magic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,22 @@
charges--//... drain a charge
return


/obj/item/gun/magic/magic_charge_act(mob/user)
. |= RECHARGE_SUCCESSFUL
. = NONE

if(prob(80) && !can_charge)
max_charges--
if(charges >= max_charges)
return

if(!can_charge && prob(80))
max_charges = max(0, max_charges - 1)

if(max_charges <= 0)
max_charges = 0
. |= RECHARGE_BURNOUT

charges = max_charges
return .
. |= RECHARGE_SUCCESSFUL

if(!max_charges)
. |= RECHARGE_BURNOUT


/obj/item/gun/magic/Initialize()
. = ..()
Expand Down
8 changes: 2 additions & 6 deletions code/modules/projectiles/guns/magic/wand.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,11 @@
return ATTACK_CHAIN_PROCEED
return ..()


/obj/item/gun/magic/wand/magic_charge_act(mob/user)
. = ..()
update_appearance(UPDATE_ICON_STATE)

if(!max_charges)
. |= RECHARGE_BURNOUT

update_icon_state()

return .

/obj/item/gun/magic/wand/afterattack(atom/target, mob/living/user, proximity, params)
if(!charges)
Expand Down

0 comments on commit f3df3e7

Please sign in to comment.