Skip to content

Commit

Permalink
Some tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorDinamit committed Nov 27, 2023
1 parent 21c7439 commit 1f79249
Show file tree
Hide file tree
Showing 19 changed files with 135 additions and 67 deletions.
1 change: 1 addition & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#include "code\__defines\lighting.dm"
#include "code\__defines\lists.dm"
#include "code\__defines\machinery.dm"
#include "code\__defines\magic.dm"
#include "code\__defines\mapping.dm"
#include "code\__defines\materials.dm"
#include "code\__defines\math_physics.dm"
Expand Down
4 changes: 3 additions & 1 deletion code/__defines/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
// /atom signals

// /atom/movable signals
/// When an atom's Dispell() proc is called
/// When an atom's Dispell() proc is called; Passes dispell strength as argument.
#define COMSIG_ATOM_MOVABLE_DISPELL "atom_dispell"
// Return value of a signal handler if dispell should be blocked
#define COMPONENT_DISPELL_BLOCKED (1 << 0)

// /area signals

Expand Down
5 changes: 5 additions & 0 deletions code/__defines/magic.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Defines for dispell strengths
#define DISPELL_WEAK 1
#define DISPELL_MEDIUM 2
#define DISPELL_STRONG 3
#define DISPELL_UNSTOPPABLE 4
62 changes: 29 additions & 33 deletions code/game/antagonist/outsider/wizard.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ GLOBAL_DATUM_INIT(wizards, /datum/antagonist/wizard, new)
faction = "wizard"
base_to_load = /datum/map_template/ruin/antag_spawn/wizard

/datum/antagonist/wizard/create_objectives(var/datum/mind/wizard)
/datum/antagonist/wizard/create_objectives(datum/mind/wizard)

if(!..())
return

var/kill
var/escape
var/steal
var/hijack
var/kill = FALSE
var/escape = FALSE
var/steal = FALSE
var/hijack = FALSE

switch(rand(1,100))
if(1 to 30)
escape = 1
kill = 1
escape = TRUE
kill = TRUE
if(31 to 60)
escape = 1
steal = 1
escape = TRUE
steal = TRUE
if(61 to 99)
kill = 1
steal = 1
kill = TRUE
steal = TRUE
else
hijack = 1
hijack = TRUE

if(kill)
var/datum/objective/assassinate/kill_objective = new
Expand All @@ -61,16 +61,16 @@ GLOBAL_DATUM_INIT(wizards, /datum/antagonist/wizard, new)
wizard.objectives |= hijack_objective
return

/datum/antagonist/wizard/update_antag_mob(var/datum/mind/wizard)
/datum/antagonist/wizard/update_antag_mob(datum/mind/wizard)
..()
wizard.StoreMemory("<B>Remember:</B> do not forget to prepare your spells.", /decl/memory_options/system)
wizard.current.real_name = "[pick(GLOB.wizard_first)] [pick(GLOB.wizard_second)]"
wizard.current.SetName(wizard.current.real_name)

/datum/antagonist/wizard/equip(var/mob/living/carbon/human/wizard_mob)
/datum/antagonist/wizard/equip(mob/living/carbon/human/wizard_mob)

if(!..())
return 0
return FALSE

var/outfit_type = pick(subtypesof(/decl/hierarchy/outfit/wizard))
var/decl/hierarchy/outfit/wizard_outfit = outfit_by_type(outfit_type)
Expand All @@ -82,7 +82,7 @@ GLOBAL_DATUM_INIT(wizards, /datum/antagonist/wizard, new)
wizard_mob.mind.mana.mana_recharge_speed = 2
wizard_mob.mind.mana.spell_points = 15 // Should allow wizard to buy 2-3 dangerous spells, or a bunch of small stuff

return 1
return TRUE

/datum/antagonist/wizard/print_player_summary()
..()
Expand All @@ -107,28 +107,24 @@ GLOBAL_DATUM_INIT(wizards, /datum/antagonist/wizard, new)
for(var/datum/spell/spell_to_remove in mind.learned_spells)
remove_spell(spell_to_remove)

obj/item/clothing
/obj/item/clothing
var/wizard_garb = FALSE

// Does this clothing slot count as wizard garb? (Combines a few checks)
/proc/is_wiz_garb(var/obj/item/clothing/C)
// Does this clothing slot count as wizard garb?
/proc/is_wiz_garb(obj/item/clothing/C)
return istype(C) && C.wizard_garb

/*Checks if the wizard is wearing the proper attire.
Made a proc so this is not repeated 14 (or more) times.*/
// Checks if the wizard is wearing the proper attire.
// Made a proc so this is not repeated 14 (or more) times.
/mob/proc/wearing_wiz_garb()
to_chat(src, "Silly creature, you're not a human. Only humans can cast this spell.")
return 0
return FALSE

// Humans can wear clothes.
/mob/living/carbon/human/wearing_wiz_garb()
if(!is_wiz_garb(src.wear_suit) && (!src.species.hud || (slot_wear_suit in src.species.hud.equip_slots)))
to_chat(src, "<span class='warning'>I don't feel strong enough without my robe.</span>")
return 0
if(!is_wiz_garb(src.shoes) && (!species.hud || (slot_shoes in src.species.hud.equip_slots)))
to_chat(src, "<span class='warning'>I don't feel strong enough without my sandals.</span>")
return 0
if(!is_wiz_garb(src.head) && (!species.hud || (slot_head in src.species.hud.equip_slots)))
to_chat(src, "<span class='warning'>I don't feel strong enough without my hat.</span>")
return 0
return 1
if(!is_wiz_garb(wear_suit) && (!species.hud || (slot_wear_suit in species.hud.equip_slots)))
to_chat(src, SPAN_WARNING("I don't feel strong enough without my robe."))
return FALSE
if(!is_wiz_garb(head) && (!species.hud || (slot_head in species.hud.equip_slots)))
to_chat(src, SPAN_WARNING("I don't feel strong enough without my hat."))
return FALSE
return TRUE
7 changes: 4 additions & 3 deletions code/game/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@
return

/// The effect of being affected by dispells, either a projectile or AOE effects
/atom/movable/proc/Dispell()
SEND_SIGNAL(src, COMSIG_ATOM_MOVABLE_DISPELL)
return
/atom/movable/proc/Dispell(dispell_strength = DISPELL_WEAK)
if(SEND_SIGNAL(src, COMSIG_ATOM_MOVABLE_DISPELL, dispell_strength) & COMPONENT_DISPELL_BLOCKED)
return FALSE
return TRUE
8 changes: 6 additions & 2 deletions code/modules/mana/mana.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Stores a lot of things related to magic, not just mana
// Stores mana-related things and spell points
/datum/mana
var/mana_level = 10
var/mana_level_max = 10
Expand All @@ -18,6 +18,10 @@
StartRecharge()
return TRUE

/datum/mana/proc/AddMana(amount = 0)
mana_level = clamp(mana_level + amount, 0, mana_level_max)
return TRUE

// Starts a "process" of recharging if we should and can
/datum/mana/proc/StartRecharge()
if(recharging)
Expand All @@ -34,6 +38,6 @@
if(mana_level >= mana_level_max)
recharging = FALSE
return FALSE
mana_level = clamp(mana_level + mana_recharge_speed * 0.5, 0, mana_level_max)
AddMana(mana_recharge_speed * 0.5)
addtimer(CALLBACK(src, .proc/RechargeMana), (0.5 SECONDS))
return TRUE
25 changes: 25 additions & 0 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -934,3 +934,28 @@ default behaviour is:
/mob/living/proc/jump_layer_shift_end()
jumping = FALSE
reset_layer()

// If mob has an aimed spell prepared to cast - deactivates it.
// Additionally, puts random spells on cooldown.
/mob/living/Dispell(dispell_strength = DISPELL_WEAK)
. = ..()
if(!.)
return
if(!mind || !LAZYLEN(mind.learned_spells))
return
var/play_sound = FALSE
// It could also be non-aimed, but we should add the deactivation part to other spells then
if(istype(ranged_ability, /datum/spell/aimed))
var/datum/spell/aimed/AS = ranged_ability
AS.remove_ranged_ability(SPAN_DANGER("[ranged_ability] has been dispelled!"))
AS.on_deactivation(src)
play_sound = TRUE
for(var/datum/spell/S in mind.learned_spells)
if(!prob(dispell_strength * 25))
continue
S.charge_counter = S.charge_max * (rand(3, 10) * 0.1)
S.process()
to_chat(src, SPAN_WARNING("[S] has been dispelled and put on cooldown!"))
play_sound = TRUE
if(play_sound)
playsound(get_turf(src), 'sound/magic/blind.ogg', 50, TRUE)
Original file line number Diff line number Diff line change
Expand Up @@ -805,3 +805,18 @@
/datum/reagent/vaccine/mix_data(list/newdata, newamount)
if(istype(newdata))
src.data |= newdata.Copy()

/datum/reagent/concentrated_mana
name = "Concentrated Mana"
description = "A mysterious liquid used by magic-fluent people to restore their internal mana reserves. \
Can also be used in certain tools that utilize magic phenomenon."
taste_description = "cool air"
reagent_state = LIQUID
color = "#47f0ff"

/datum/reagent/concentrated_mana/affect_blood(mob/living/carbon/human/H, alien, removed)
if(!ishuman(H))
return
if(!H.mind || !H.mind?.mana)
return
H.mind.mana.AddMana(2)
2 changes: 1 addition & 1 deletion code/modules/research/part_replacer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
if(istype(target, /obj/machinery))
var/obj/machinery/machine = target
if(machine.component_attackby(src, user))
user.Beam(machine, icon_state = "rped_upgrade", icon = 'icons/effects/effects.dmi', time = 5)
user.Beam(machine, icon_state = "rped_upgrade", time = 5)

/obj/item/storage/part_replacer/bluespace
name = "bluespace rapid part exchange device"
Expand Down
7 changes: 6 additions & 1 deletion code/modules/spellbook/_spellbook.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ GLOBAL_LIST_EMPTY(spells_by_categories)
var/list/allowed_spells = list()
/// Currently applied spell categories that will be shown; If none - all spells are shown.
var/list/spell_categories = list()
/// Defines how strong the dispell must be to successfuly remove the restrictions.
var/dispell_resistance = 0

/obj/item/spellbook/Initialize()
. = ..()
Expand Down Expand Up @@ -152,10 +154,13 @@ GLOBAL_LIST_EMPTY(spells_by_categories)
interact(user)

// Being hit with any source of dispell releases any locks
/obj/item/spellbook/Dispell()
/obj/item/spellbook/Dispell(dispell_strength = DISPELL_WEAK)
. = ..()
if(!istype(owner) && !(book_flags & WIZARD_ONLY) && !(book_flags & APPRENTICE_ONLY))
return
if(dispell_resistance > dispell_strength)
visible_message(SPAN_WARNING("\The [src] repels the surrounding dispelling magic!"))
return
visible_message(SPAN_NOTICE("\The [src] fizzles and sparks!"))
RemoveOwner()
owner = null
Expand Down
32 changes: 16 additions & 16 deletions code/modules/spells/_spell.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ GLOBAL_LIST_INIT(spell_categories, list(
/datum/spell/proc/Click(mob/user = usr, skipcharge = 0) // When action button is pressed
if(cast_check(skipcharge, user))
choose_targets(user)
return 1
return TRUE

/datum/spell/proc/choose_targets(mob/user = usr) //depends on subtype - see targeted.dm, aoe_turf.dm, dumbfire.dm, or code in general folder
return
Expand Down Expand Up @@ -334,28 +334,28 @@ GLOBAL_LIST_INIT(spell_categories, list(
if(SPELL_RECHARGE)
if(charge_counter < charge_max)
to_chat(user, still_recharging_msg)
return 0
return FALSE
if(SPELL_CHARGES)
if(!charge_counter)
to_chat(user, "<span class='notice'>[name] has no charges left.</span>")
return 0
return 1
return FALSE
return TRUE

/datum/spell/proc/take_charge(mob/user = user, var/skipcharge)
if(!skipcharge)
switch(charge_type)
if(SPELL_RECHARGE)
charge_counter = 0 //doesn't start recharging until the targets selecting ends
src.process()
return 1
return TRUE
if(SPELL_CHARGES)
charge_counter-- //returns the charge if the targets selecting fails
return 1
return TRUE
if(SPELL_HOLDVAR)
adjust_var(user, holder_var_type, holder_var_amount)
return 1
return 0
return 1
return TRUE
return FALSE
return TRUE

/datum/spell/proc/TakeMana(mob/user = user)
if(!user.mind)
Expand Down Expand Up @@ -386,25 +386,25 @@ GLOBAL_LIST_INIT(spell_categories, list(

/datum/spell/proc/can_improve(upgrade_type)
if(level_max[UPGRADE_TOTAL] <= ( spell_levels[UPGRADE_SPEED] + spell_levels[UPGRADE_POWER] )) //too many levels, can't do it
return 0
return FALSE

//if(upgrade_type && spell_levels[upgrade_type] && level_max[upgrade_type])
if(upgrade_type && spell_levels[upgrade_type] >= level_max[upgrade_type])
return 0
return FALSE

return 1
return TRUE

/datum/spell/proc/empower_spell()
if(!can_improve(UPGRADE_POWER))
return 0
return FALSE

spell_levels[UPGRADE_POWER]++

return 1
return TRUE

/datum/spell/proc/quicken_spell()
if(!can_improve(UPGRADE_SPEED))
return 0
return FALSE

spell_levels[UPGRADE_SPEED]++

Expand Down Expand Up @@ -441,7 +441,7 @@ GLOBAL_LIST_INIT(spell_categories, list(

/datum/spell/proc/spell_do_after(var/mob/user as mob, delay as num, var/numticks = 5)
if(!user || isnull(user))
return 0
return FALSE

var/incap_flags = INCAPACITATION_STUNNED|INCAPACITATION_RESTRAINED|INCAPACITATION_BUCKLED_FULLY|INCAPACITATION_FORCELYING
if(!(spell_flags & (GHOSTCAST)))
Expand Down
4 changes: 2 additions & 2 deletions code/modules/spells/_spell_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
ability_master.remove_ability(ability_master.get_ability_by_spell(spell_to_remove))
return 1

/mob/proc/silence_spells(var/amount = 0)
if(amount < 0)
/mob/proc/silence_spells(amount = 0)
if(!amount)
return

if(!ability_master)
Expand Down
4 changes: 3 additions & 1 deletion code/modules/spells/aimed/dispell.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
level_max = list(UPGRADE_TOTAL = 2, UPGRADE_SPEED = 0, UPGRADE_POWER = 2)
duration = 15
projectile_type = /obj/item/projectile/spell_projectile/dispell
var/amt_range = 0

active_msg = "You prepare to cast the bolt of dispell!"
deactive_msg = "You decide against using the bolt of dispell."
Expand All @@ -21,6 +20,9 @@
spell_cost = 2
mana_cost = 15

var/amt_range = 0
var/strength = DISPELL_WEAK

/datum/spell/aimed/dispell_projectile/prox_cast(list/targets, atom/spell_holder)
var/atom/movable/A = targets[1]
if(amt_range > 0)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/spells/aimed/flamethrower.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@

flame_power += 20
flame_color = flame_power >= 60 ? COLOR_PURPLE : COLOR_RED
return "The [src] spell is now much more powerful."
return "The [src] spell is now [flame_power >= 60 ? "much " : ""]more powerful."
Loading

0 comments on commit 1f79249

Please sign in to comment.