Skip to content

Commit

Permalink
Adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorDinamit committed Sep 23, 2023
1 parent 1bcd808 commit 35e5c13
Show file tree
Hide file tree
Showing 57 changed files with 327 additions and 68 deletions.
1 change: 0 additions & 1 deletion baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -3116,7 +3116,6 @@
#include "code\modules\species\station\unathi.dm"
#include "code\modules\species\station\unathi_subspecies.dm"
#include "code\modules\spellbook\_spellbook.dm"
#include "code\modules\spellbook\apprentice.dm"
#include "code\modules\spells\_spell.dm"
#include "code\modules\spells\_spell_procs.dm"
#include "code\modules\spells\artifacts.dm"
Expand Down
2 changes: 1 addition & 1 deletion code/datums/outfits/wizardry.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
l_ear = /obj/item/device/radio/headset
r_pocket = /obj/item/teleportation_scroll
l_hand = /obj/item/staff
r_hand = /obj/item/spellbook
r_hand = /obj/item/spellbook/all_book_spells
back = /obj/item/storage/backpack
backpack_contents = list(/obj/item/storage/box = 1)
hierarchy_type = /decl/hierarchy/outfit/wizard
Expand Down
6 changes: 6 additions & 0 deletions code/game/antagonist/outsider/wizard.dm
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ GLOBAL_DATUM_INIT(wizards, /datum/antagonist/wizard, new)
var/decl/hierarchy/outfit/wizard_outfit = outfit_by_type(outfit_type)
wizard_outfit.equip(wizard_mob)

// Gives high mana & spell points
wizard_mob.mana.mana_level_max = 100
wizard_mob.mana.mana_level = 100
wizard_mob.mana.mana_recharge_speed = 2
wizard_mob.mana.spell_points = 15 // Should allow wizard to buy 2-3 dangerous spells, or a bunch of small stuff

return 1

/datum/antagonist/wizard/print_player_summary()
Expand Down
3 changes: 3 additions & 0 deletions code/modules/mana/mana.dm
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// Stores a lot of things related to magic, not just mana
/datum/mana
var/mana_level = 10
var/mana_level_max = 10
/// Amount of mana restored per second
var/mana_recharge_speed = 0.25
var/recharging = FALSE
/// Personal spell points used for purchasing spells
var/spell_points = 2

/datum/mana/proc/UseMana(mob/user, amount = 0, silent = TRUE)
if(mana_level < amount)
Expand Down
145 changes: 106 additions & 39 deletions code/modules/spellbook/_spellbook.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Assoc list of category = spell type
GLOBAL_LIST_EMPTY(categories_to_spells)
// Reverse assoc list for "reasons"
// Assoc list of spell types and their categories
GLOBAL_LIST_EMPTY(spells_by_categories)

// Does exactly what it says: Unless dispelled, only wizards can use it.
Expand All @@ -22,16 +20,30 @@ GLOBAL_LIST_EMPTY(spells_by_categories)
var/book_flags = 0
/// Current owner of the book, none other than them can use it; Can be dispelled to remove that and other locks.
var/mob/owner = null
/// List of shown spells.
var/list/allowed_spells = list()
/// Currently applied spell categories that will be shown; If none - all spells are shown.
var/list/spell_categories = list()

/obj/item/spellbook/Initialize()
. = ..()
// Create the global list if empty
if(!LAZYLEN(GLOB.spells_by_categories))
for(var/spell_type in subtypesof(/datum/spell))
var/datum/spell/S = new spell_type()
GLOB.spells_by_categories[S.type] = S.categories
qdel(S)

/obj/item/spellbook/Destroy()
RemoveOwner()
return ..()

/obj/item/spellbook/attack_self(mob/user)
/obj/item/spellbook/attack_self(mob/living/user)
if(!user.mind)
return
if(!user.mana)
to_chat(user, SPAN_WARNING("You cannot see anything in the book..."))
return
if(user.mind.special_role != ANTAG_WIZARD && (book_flags & WIZARD_ONLY))
to_chat(user, SPAN_WARNING("The book refuses to open for you!"))
return
Expand All @@ -52,26 +64,15 @@ GLOBAL_LIST_EMPTY(spells_by_categories)

interact(user)

/obj/item/spellbook/interact(mob/user)
/obj/item/spellbook/interact(mob/living/user)
var/dat = null

// Create the global lists if empty
if(!LAZYLEN(GLOB.categories_to_spells) || !LAZYLEN(GLOB.spells_by_categories))
for(var/spell_type in subtypesof(/datum/spell))
var/datum/spell/S = new spell_type()
for(var/category in S.categories)
if(!(category in GLOB.categories_to_spells))
GLOB.categories_to_spells[category] = list()
GLOB.categories_to_spells[category] += S.type
GLOB.spells_by_categories[S.type] = S.categories
qdel(S)

for(var/spell_type in GLOB.spells_by_categories)
dat += "Your spell points: [user.mana.spell_points].<br>"
dat += "Applied categories: [english_list(spell_categories, "None")].<br>"
dat += "<hr>"
for(var/spell_type in allowed_spells)
var/datum/spell/S = spell_type
if(LAZYLEN(spell_categories) && !(GLOB.spells_by_categories[spell_type] & spell_categories))
continue
if(!initial(S.spell_book_visible))
continue

dat += "<A href='byond://?src=\ref[src];spell=[spell_type]'>[initial(S.name)]</a><br>"

Expand All @@ -98,32 +99,53 @@ GLOBAL_LIST_EMPTY(spells_by_categories)
return ..()

/obj/item/spellbook/OnTopic(mob/user, href_list)
if(href_list["temp"])
temp = null
. = TOPIC_REFRESH

else if(href_list["path"])
var/path = text2path(href_list["path"])
if(href_list["spell"])
var/datum/spell/S = text2path(href_list["spell"])
if(!ispath(S))
return TOPIC_REFRESH
var/dat = null
dat += "<A href='byond://?src=\ref[src];purchase=[S]'>Purchase ([initial(S.spell_cost)] points)</a> "
dat += "<br><hr>"
dat += "[initial(S.name)]<br>"
dat += "[initial(S.desc)]<br>"
dat += "<hr>"
dat += "Mana cost: [initial(S.mana_cost)].<br>"
dat += "Categories: <A href='byond://?src=\ref[src];categories=1'>[english_list(GLOB.spells_by_categories[S], "None")].</a><br>"

var/datum/browser/popup = new(user, "spellbook_[S]", "Spell Book - [initial(S.name)]")
popup.set_content(dat)
popup.open()
return TOPIC_NOACTION

else if(href_list["purchase"])
var/path = text2path(href_list["purchase"])
if(!path)
return TOPIC_HANDLED
return TOPIC_NOACTION
SendFeedback(path) //feedback stuff
if(ispath(path, /datum/spell))
temp = AddSpell(user, path)
to_chat(user, AddSpell(user, path))
else
var/obj/O = new path(get_turf(user))
temp = "You have purchased \a [O]."
to_chat(user, SPAN_NOTICE("You have purchased \a [O]."))
//finally give it a bit of an oomf
playsound(get_turf(user),'sound/effects/phasein.ogg',50,1)
. = TOPIC_REFRESH

else if(href_list["reset"])
var/area/map_template/wizard_station/A = get_area(user)
if(istype(A))
user.spellremove()
temp = "All spells and investments have been removed. You may now memorize a new set of spells."
SSstatistics.add_field_details("wizard_spell_learned","UM") //please do not change the abbreviation to keep data processing consistent. Add a unique id to any new spells
else
to_chat(user, "<span class='warning'>You must be in the wizard academy to re-memorize your spells.</span>")
else if(href_list["categories"])
var/option = "Add"
if(LAZYLEN(spell_categories))
option = input(user, "What do you want to do?", "Options") as anything in list("Add", "Remove", "Clear")
switch(option)
if("Add")
var/cat = input(user, "What category do you want to add?", "Add Category") as anything in (GLOB.spell_categories - spell_categories)
if(cat && !(cat in spell_categories) && (cat in GLOB.spell_categories))
spell_categories |= cat
if("Remove")
var/cat = input(user, "What category do you want to remove?", "Remove Category") as anything in spell_categories
if(cat && (cat in spell_categories))
spell_categories -= cat
if("Clear")
spell_categories = list()
. = TOPIC_REFRESH

interact(user)
Expand Down Expand Up @@ -158,7 +180,7 @@ GLOBAL_LIST_EMPTY(spells_by_categories)
var/obj/O = path
SSstatistics.add_field_details("wizard_spell_learned","[initial(O.name)]")

/obj/item/spellbook/proc/AddSpell(mob/user, spell_path)
/obj/item/spellbook/proc/AddSpell(mob/living/user, spell_path)
for(var/datum/spell/S in user.mind.learned_spells)
if(istype(S,spell_path))
if(!S.can_improve())
Expand All @@ -176,6 +198,51 @@ GLOBAL_LIST_EMPTY(spells_by_categories)
else if(S.can_improve(UPGRADE_SPEED))
return S.quicken_spell()

var/datum/spell/SP = spell_path
if(user.mana.spell_points < initial(SP.spell_cost))
return SPAN_WARNING("Not enough points!")

var/datum/spell/S = new spell_path()
user.add_spell(S)
return "You learn the spell [S]"
user.mana.spell_points -= S.spell_cost
return SPAN_NOTICE("You learn the spell [S]")

/* Subtypes */
// A spell book with EVERY spell available
/obj/item/spellbook/all_spells/Initialize()
. = ..()
for(var/spell_type in subtypesof(/datum/spell))
var/datum/spell/S = spell_type
if(isnull(initial(S.name)))
continue
allowed_spells |= S

// All spells available via spell book
/obj/item/spellbook/all_book_spells/Initialize()
. = ..()
for(var/spell_type in GLOB.spells_by_categories)
var/datum/spell/S = spell_type
if(isnull(initial(S.name)))
continue
if(initial(S.spell_book_visible))
allowed_spells |= spell_type

// A book spawned to wizard apprentices
/obj/item/spellbook/apprentice
allowed_spells = list(
/datum/spell/aoe_turf/knock,
/datum/spell/targeted/ethereal_jaunt,
/datum/spell/targeted/projectile/magic_missile,
)

// Free for all spell book!
/obj/item/spellbook/minor_free
book_flags = NO_OWNER
allowed_spells = list(
/datum/spell/noclothes,
/datum/spell/aimed/passage,
/datum/spell/aoe_turf/knock,
/datum/spell/targeted/ethereal_jaunt,
/datum/spell/targeted/heal_target/touch,
/datum/spell/area_teleport,
)
1 change: 0 additions & 1 deletion code/modules/spellbook/apprentice.dm

This file was deleted.

22 changes: 20 additions & 2 deletions code/modules/spells/_spell.dm
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
// All possible categories. Please follow them.
#define SPELL_CATEGORY_FIRE "Fire"
#define SPELL_CATEGORY_EXPLOSIVE "Explosive"
#define SPELL_CATEGORY_HEALING "Healing"
#define SPELL_CATEGORY_PASSIVE "Passive"
#define SPELL_CATEGORY_FORBIDDEN "Forbidden arts"

// A global list of them
GLOBAL_LIST_INIT(spell_categories, list(
SPELL_CATEGORY_FIRE,
SPELL_CATEGORY_EXPLOSIVE,
SPELL_CATEGORY_HEALING,
SPELL_CATEGORY_PASSIVE,
SPELL_CATEGORY_FORBIDDEN,
))

/datum/spell
parent_type = /datum
var/name = "Spell"
var/name = null
var/desc = "A spell."
/// What panel the proc holder needs to go on.
var/panel = "Spells"

// Spell book representation
// Spell book variables
/// List of categories for the spellbook
var/list/categories = list()
/// If TRUE - will be available via spell book
var/spell_book_visible = TRUE
/// Amount of points required to purchase the spell
var/spell_cost = 1

/// Can be recharge or charges, see charge_max and charge_counter descriptions; can also be based on the holder's vars now, use "holder_var" for that
var/charge_type = SPELL_RECHARGE
Expand Down
1 change: 0 additions & 1 deletion code/modules/spells/aimed/_aimed.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/datum/spell/aimed
name = "aimed projectile spell"
hud_state = "projectile"

var/projectile_type = /obj/item/projectile
Expand Down
4 changes: 4 additions & 0 deletions code/modules/spells/aimed/fireball.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

level_max = list(UPGRADE_TOTAL = 5, UPGRADE_SPEED = 0, UPGRADE_POWER = 5)

categories = list(SPELL_CATEGORY_EXPLOSIVE)
spell_cost = 5
mana_cost = 20

var/ex_severe = -1
var/ex_heavy = 1
var/ex_light = 2
Expand Down
3 changes: 3 additions & 0 deletions code/modules/spells/aimed/passage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
hud_state = "gen_project"
cast_sound = 'sound/magic/lightning_bolt.ogg'

spell_cost = 2
mana_cost = 10

/datum/spell/aimed/passage/prox_cast(list/targets, atom/spell_holder)
for(var/mob/living/L in targets)
L.Paralyse(amt_paralysis)
Expand Down
5 changes: 4 additions & 1 deletion code/modules/spells/aoe_turf/blink.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/datum/spell/aoe_turf/blink
name = "Blink"
name = "Random blink"
desc = "This spell randomly teleports you a short distance."
charge_max = 20
spell_flags = Z2NOCAST | IGNOREDENSE | IGNORESPACE
Expand All @@ -13,6 +13,9 @@
hud_state = "wiz_blink"
cast_sound = 'sound/magic/blink.ogg'

spell_cost = 1
mana_cost = 2

/datum/spell/aoe_turf/blink/cast(var/list/targets, mob/user)
if(!targets.len)
return
Expand Down
5 changes: 4 additions & 1 deletion code/modules/spells/aoe_turf/charge.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
hud_state = "wiz_charge"
cast_sound = 'sound/magic/charge.ogg'

spell_cost = 2
mana_cost = 25

/datum/spell/aoe_turf/charge/cast(var/list/targets, mob/user)
for(var/turf/T in targets)
depth_cast(T)
Expand Down Expand Up @@ -68,4 +71,4 @@

charge_type = SPELL_HOLDVAR
holder_var_type = "bruteloss"
holder_var_amount = 30
holder_var_amount = 30
1 change: 0 additions & 1 deletion code/modules/spells/aoe_turf/conjure/conjure.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ How they spawn stuff is decided by behaviour vars, which are explained below
*/

/datum/spell/aoe_turf/conjure
name = "Conjure"
desc = "This spell conjures objs of the specified types in range."

var/list/summon_type = list() //determines what exactly will be summoned
Expand Down
3 changes: 3 additions & 0 deletions code/modules/spells/aoe_turf/conjure/druidic_spells.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@

hud_state = "wiz_bats"

spell_cost = 2
mana_cost = 10

/datum/spell/aoe_turf/conjure/summon/bats/empower_spell()
if(!..())
return 0
Expand Down
3 changes: 3 additions & 0 deletions code/modules/spells/aoe_turf/conjure/faithful_hound.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
summon_type = list(/mob/living/simple_animal/faithful_hound)
hud_state = "wiz_hound"

spell_cost = 3
mana_cost = 10

/datum/spell/aoe_turf/conjure/faithful_hound/before_cast()
..()
var/password = sanitize(input("What password will this beast listen to?") as text, MAX_NAME_LEN)
Expand Down
5 changes: 4 additions & 1 deletion code/modules/spells/aoe_turf/conjure/force_portal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

hud_state = "wiz_force"

spell_cost = 2
mana_cost = 20

/datum/spell/aoe_turf/conjure/force_portal/tower
charge_max = 2
spell_flags = 0
spell_flags = 0
Loading

0 comments on commit 35e5c13

Please sign in to comment.