Skip to content

Commit

Permalink
Magic orbs + Moving mana to mind
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorDinamit committed Oct 12, 2023
1 parent 721973f commit 98578af
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 19 deletions.
3 changes: 2 additions & 1 deletion baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,7 @@
#include "code\game\objects\effects\gibs.dm"
#include "code\game\objects\effects\item_pickup_ghost.dm"
#include "code\game\objects\effects\landmarks.dm"
#include "code\game\objects\effects\magic_orb.dm"
#include "code\game\objects\effects\manifest.dm"
#include "code\game\objects\effects\mines.dm"
#include "code\game\objects\effects\misc.dm"
Expand Down Expand Up @@ -2031,7 +2032,7 @@
#include "code\modules\locks\lock.dm"
#include "code\modules\locks\lock_construct.dm"
#include "code\modules\mana\mana.dm"
#include "code\modules\mana\mob.dm"
#include "code\modules\mana\mind.dm"
#include "code\modules\maps\dmm_suite.dm"
#include "code\modules\maps\helper_landmarks.dm"
#include "code\modules\maps\map_template.dm"
Expand Down
2 changes: 2 additions & 0 deletions code/__defines/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#define COMSIG_GLOB_MOB_CREATED "!mob_created"
/// Mob died somewhere : (mob/living, gibbed)
#define COMSIG_GLOB_MOB_DEATH "!mob_death"
/// A magic orb was picked up by a mob: (orb, mob/living)
#define COMSIG_GLOB_ORB_PICKUP "!mob_death"

//////////////////////////////////////////////////////////////////

Expand Down
8 changes: 4 additions & 4 deletions code/game/antagonist/outsider/wizard.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ GLOBAL_DATUM_INIT(wizards, /datum/antagonist/wizard, new)
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
wizard_mob.mind.mana.mana_level_max = 100
wizard_mob.mind.mana.mana_level = 100
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

Expand Down
8 changes: 4 additions & 4 deletions code/game/jobs/job/job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@
to_chat(H, SPAN_DANGER("As a registered psionic, you are fitted with a psi-dampening control implant. Using psi-power while the implant is active will result in neural shocks and your violation being reported."))

if(prob(higher_mana_chance))
H.mana.mana_level_max *= 2
H.mana.mana_level = H.mana.mana_level_max
H.mana.mana_recharge_speed *= 2
H.mind.mana.mana_level_max *= 2
H.mind.mana.mana_level = H.mind.mana.mana_level_max
H.mind.mana.mana_recharge_speed *= 2
if(prob(higher_spell_points_chance))
H.mana.spell_points += pickweight(1 = 30, 2 = 12, 3 = 4, 4 = 1)
H.mind.mana.spell_points += pickweight(1 = 30, 2 = 12, 3 = 4, 4 = 1)

var/decl/hierarchy/outfit/outfit = get_outfit(H, alt_title, branch, grade)
if(outfit) . = outfit.equip(H, title, alt_title)
Expand Down
86 changes: 86 additions & 0 deletions code/game/objects/effects/magic_orb.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/obj/effect/magic_orb
name = "orb of wonders"
desc = "A radiating magic orb. What potential does it hold?"
icon = 'icons/effects/magic_orb.dmi'
icon_state = "orb"
anchored = TRUE
var/datum/sound_token/sound_token
var/sound_id
var/ambient_sound = 'sound/magic/orb_ambience.ogg'

/obj/effect/magic_orb/Initialize()
. = ..()
if(!ambient_sound)
return
sound_id = "[type]_[sequential_id(/obj/effect/magic_orb)]"
sound_token = GLOB.sound_player.PlayLoopingSound(src, sound_id, ambient_sound, volume = 35)
particles = new /particles/magic_orb()

/obj/effect/magic_orb/Destroy()
QDEL_NULL(sound_token)
sound_token = null
return ..()

/obj/effect/magic_orb/attack_hand(mob/living/user)
if(QDELETED(src)) // Should not be possible, but imagine
return
if(!CanUseOrb(user))
return
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_ORB_PICKUP, src, user)
playsound(src, 'sound/magic/orb_pickup.ogg', 50, FALSE, 3)
var/obj/effect/temp_visual/decoy/D = new /obj/effect/temp_visual/decoy(loc, dir, src, 20)
animate(D, alpha = 0, color = "#aaaaff", transform = matrix()*3, time = 20)
OrbEffect(user)
qdel(src)
return

/obj/effect/magic_orb/proc/CanUseOrb(mob/living/user)
return TRUE

/obj/effect/magic_orb/proc/OrbEffect(mob/living/user)
return

/obj/effect/magic_orb/attackby(obj/item/thing, mob/user)
return

// Grants the user some spell points
/obj/effect/magic_orb/spell_points
name = "orb of knowledge"
/// Amount of spell points granted to the user
var/spell_points = 10

/obj/effect/magic_orb/spell_points/CanUseOrb(mob/living/user)
if(!user.mind)
return FALSE
if(!user.mind.mana)
return FALSE
return ..()

/obj/effect/magic_orb/spell_points/OrbEffect(mob/living/user)
user.mind.mana.spell_points += spell_points
show_blurb(user.client, (5 SECONDS), "The knowledge sinks into your mind...", 10, typeout = FALSE)
flash_color(user, COLOR_DIAMOND, 10)
return

// Grants the user additional mana level and regeneration
/obj/effect/magic_orb/mana
name = "orb of power"
/// Amount of max mana level that is added
var/mana_level = 20
/// How much mana regeneration is added
var/mana_regeneration = 1

/obj/effect/magic_orb/mana/CanUseOrb(mob/living/user)
if(!user.mind)
return FALSE
if(!user.mind.mana)
return FALSE
return ..()

/obj/effect/magic_orb/mana/OrbEffect(mob/living/user)
user.mind.mana.mana_level_max += mana_level
user.mind.mana.mana_level = user.mind.mana.mana_level_max
user.mind.mana.mana_recharge_speed += mana_regeneration
show_blurb(user.client, (5 SECONDS), "The power invigorates your mind...", 10, typeout = FALSE)
flash_color(user, COLOR_DIAMOND, 10)
return
15 changes: 15 additions & 0 deletions code/game/objects/effects/particles/particles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,21 @@
drift = generator("circle", 0.4, NORMAL_RAND)
velocity = generator("circle", 0, 3, NORMAL_RAND)

/particles/magic_orb
width = 500
height = 500
count = 2000
spawning = 260
lifespan = 1 SECONDS
fade = 1 SECONDS
position = generator("circle", 28, 36, NORMAL_RAND)
velocity = generator("circle", 0, 3, NORMAL_RAND)
friction = 0.1
gradient = list(0, COLOR_DIAMOND, 0.75, COLOR_BLUE_LIGHT)
color_change = 0.1
color = 0
drift = generator("circle", 0.1, NORMAL_RAND)

//Spawner object
//Maybe we could pool them in and out
/obj/particle_emitter
Expand Down
6 changes: 3 additions & 3 deletions code/modules/mana/mob.dm → code/modules/mana/mind.dm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/mob/living
/datum/mind
var/datum/mana/mana = /datum/mana

/mob/living/Initialize()
/datum/mind/New()
. = ..()
if(ispath(mana))
mana = new mana()

/mob/living/Destroy()
/datum/mind/Destroy()
QDEL_NULL(mana)
. = ..()
8 changes: 4 additions & 4 deletions code/modules/spellbook/_spellbook.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ GLOBAL_LIST_EMPTY(spells_by_categories)
/obj/item/spellbook/attack_self(mob/living/user)
if(!user.mind)
return
if(!user.mana)
if(!user.mind.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))
Expand All @@ -66,7 +66,7 @@ GLOBAL_LIST_EMPTY(spells_by_categories)

/obj/item/spellbook/interact(mob/living/user)
var/dat = null
dat += "Your spell points: [user.mana.spell_points].<br>"
dat += "Your spell points: [user.mind.mana.spell_points].<br>"
dat += "Applied categories: <A href='byond://?src=\ref[src];categories=1'>[english_list(spell_categories, "None")].</a><br>"
dat += "<hr>"
for(var/spell_type in allowed_spells)
Expand Down Expand Up @@ -208,12 +208,12 @@ GLOBAL_LIST_EMPTY(spells_by_categories)
return S.quicken_spell()

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

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

/* Subtypes */
Expand Down
6 changes: 3 additions & 3 deletions code/modules/spells/_spell.dm
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ GLOBAL_LIST_INIT(spell_categories, list(

if(isliving(user))
var/mob/living/L = user
if(!istype(L.mana) || L.mana.mana_level < mana_cost)
if(!istype(L.mind.mana) || L.mind.mana.mana_level < mana_cost)
to_chat(L, SPAN_WARNING("You do not have enough mana!"))
return FALSE

Expand Down Expand Up @@ -352,10 +352,10 @@ GLOBAL_LIST_INIT(spell_categories, list(
return 1

/datum/spell/proc/TakeMana(mob/user = user)
if(!isliving(user))
if(!user.mind)
return FALSE
var/mob/living/L = user
L.mana.UseMana(L, mana_cost)
L.mind.mana.UseMana(L, mana_cost)
return TRUE

/datum/spell/proc/invocation(mob/user = usr, var/list/targets) //spelling the spell out and setting it on recharge/reducing charges amount
Expand Down
Binary file added icons/effects/magic_orb.dmi
Binary file not shown.
Binary file added sound/magic/orb_ambience.ogg
Binary file not shown.
Binary file added sound/magic/orb_pickup.ogg
Binary file not shown.

0 comments on commit 98578af

Please sign in to comment.