Skip to content

Commit

Permalink
refactor: Porting and Refactoring Official Paradise Spells System (#3168
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Gottfrei authored Jul 27, 2023
1 parent 6e69185 commit 92d12d8
Show file tree
Hide file tree
Showing 196 changed files with 7,624 additions and 4,867 deletions.
4 changes: 2 additions & 2 deletions code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,9 @@
#define COMSIG_ITEM_PICKUP "item_pickup"
///from base of mob/living/carbon/attacked_by(): (mob/living/carbon/target, mob/living/user, hit_zone)
#define COMSIG_ITEM_ATTACK_ZONE "item_attack_zone"
///return a truthy value to prevent ensouling, checked in /obj/effect/proc_holder/spell/targeted/lichdom/cast(): (mob/user)
///return a truthy value to prevent ensouling, checked in /obj/effect/proc_holder/spell/lichdom/cast(): (mob/user)
#define COMSIG_ITEM_IMBUE_SOUL "item_imbue_soul"
///called before marking an object for retrieval, checked in /obj/effect/proc_holder/spell/targeted/summonitem/cast() : (mob/user)
///called before marking an object for retrieval, checked in /obj/effect/proc_holder/spell/summonitem/cast() : (mob/user)
#define COMSIG_ITEM_MARK_RETRIEVAL "item_mark_retrieval"
#define COMPONENT_BLOCK_MARK_RETRIEVAL (1<<0)
///from base of obj/item/hit_reaction(): (list/args)
Expand Down
7 changes: 4 additions & 3 deletions code/__DEFINES/flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@
#define PASSBLOB 8
#define PASSMOB 16
#define LETPASSTHROW 32
#define PASSFENCE 64
#define PASS_OTHER_THINGS 128
#define PASS_EVERYTHING PASSTABLE|PASSGLASS|PASSGRILLE|PASSBLOB|PASSMOB|LETPASSTHROW|PASSFENCE|PASS_OTHER_THINGS
#define PASSFENCE 64
#define PASSDOOR 128
#define PASS_OTHER_THINGS 256
#define PASS_EVERYTHING PASSTABLE|PASSGLASS|PASSGRILLE|PASSBLOB|PASSMOB|LETPASSTHROW|PASSFENCE|PASSDOOR|PASS_OTHER_THINGS

//turf-only flags
#define NOJAUNT 1
Expand Down
3 changes: 3 additions & 0 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@
#define isnymph(A) (istype((A), /mob/living/simple_animal/diona))
#define ishostile(A) (istype(A, /mob/living/simple_animal/hostile))
#define isterrorspider(A) (istype((A), /mob/living/simple_animal/hostile/poison/terror_spider))
#define isslaughterdemon(A) (istype((A), /mob/living/simple_animal/demon/slaughter))
#define isdemon(A) (istype((A), /mob/living/simple_animal/demon))
#define ismorph(A) (istype((A), /mob/living/simple_animal/hostile/morph))

#define issilicon(A) (istype((A), /mob/living/silicon))
#define isAI(A) (istype((A), /mob/living/silicon/ai))
Expand Down
3 changes: 2 additions & 1 deletion code/__DEFINES/span.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@
//#define span_hypnophrase(str) ("<span class='hypnophrase'>" + str + "</span>")
//#define span_icon(str) ("<span class='icon'>" + str + "</span>")
#define span_info(str) ("<span class='info'>" + str + "</span>")
#define span_italics(str) ("<span class='italics'>" + str + "</span>")
//#define span_infoplain(str) ("<span class='infoplain'>" + str + "</span>")
#define span_interface(str) ("<span class='interface'>" + str + "</span>")
#define span_italics(str) ("<span class='italics'>" + str + "</span>")
#define span_looc(str) ("<span class='looc'>" + str + "</span>")
#define span_medal(str) ("<span class='medal'>" + str + "</span>")
#define span_medradio(str) ("<span class='medradio'>" + str + "</span>")
Expand Down Expand Up @@ -113,6 +113,7 @@
#define span_secradio(str) ("<span class='secradio'>" + str + "</span>")
//#define span_servradio(str) ("<span class='servradio'>" + str + "</span>")
//#define span_singing(str) ("<span class='singing'>" + str + "</span>")
#define span_sinister(str) ("<span class='sinister'>" + str + "</span>")
#define span_slime(str) ("<span class='slime'>" + str + "</span>")
//#define span_small(str) ("<span class='small'>" + str + "</span>")
//#define span_smallnotice(str) ("<span class='smallnotice'>" + str + "</span>")
Expand Down
2 changes: 2 additions & 0 deletions code/__HELPERS/_logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,10 @@ GLOBAL_PROTECT(log_end)
//sending logs to Log Viewer and then logs into game.log
if(istype(MU))
MU.create_log(ATTACK_LOG, what_done, target, get_turf(user))
MU.create_attack_log("<font color='red'>Attacked [target_str]: [what_done]</font>")
if(istype(MT))
MT.create_log(DEFENSE_LOG, what_done, user, get_turf(MT))
MT.create_attack_log("<font color='orange'>Attacked by [user_str]: [what_done]</font>")
var/mob/living/alive = target
if(istype(alive))
newhp += "\[HP:[alive.health]:[alive.getOxyLoss()]-[alive.getToxLoss()]-[alive.getFireLoss()]-[alive.getBruteLoss()]-[alive.getStaminaLoss()]-[alive.getBrainLoss()]-[alive.getCloneLoss()]\]"
Expand Down
19 changes: 19 additions & 0 deletions code/__HELPERS/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,25 @@
return picked
return null


/**
* Picks multiple unique elements from the suplied list.
* If the given list has a length less than the amount given then it will return a list with an equal amount
*
* Arguments:
* * listfrom - The list where to pick from
* * amount - The amount of elements it tries to pick.
*/
/proc/pick_multiple_unique(list/listfrom, amount)
var/list/result = list()
var/list/copy = listfrom.Copy() // Ensure the original ain't modified
while(length(copy) && length(result) < amount)
var/picked = pick(copy)
result += picked
copy -= picked
return result


//Returns the top(last) element from the list and removes it from the list (typical stack function)
/proc/pop(list/L)
if(L.len)
Expand Down
7 changes: 5 additions & 2 deletions code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
update_all_mob_security_hud()
return 1

/proc/do_mob(mob/user, mob/target, time = 30, uninterruptible = 0, progress = 1, list/extra_checks = list())
/proc/do_mob(mob/user, mob/target, time = 30, progress = 1, list/extra_checks = list(), only_use_extra_checks = FALSE)
if(!user || !target)
return 0
var/user_loc = user.loc
Expand All @@ -307,7 +307,10 @@
if(!user || !target)
. = 0
break
if(uninterruptible)
if(only_use_extra_checks)
if(check_for_true_callbacks(extra_checks))
. = 0
break
continue

if(drifting && !user.inertia_dir)
Expand Down
4 changes: 4 additions & 0 deletions code/__HELPERS/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
//
// common trait sources
#define TRAIT_GENERIC "generic"
#define MAGIC_TRAIT "magic"
#define ROUNDSTART_TRAIT "roundstart" //cannot be removed without admin intervention
#define CULT_TRAIT "cult"
#define CLOCK_TRAIT "clockwork_cult"
Expand All @@ -110,3 +111,6 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai

/// This mob heals from cult pylons.
#define TRAIT_HEALS_FROM_CULT_PYLONS "heals_from_cult_pylons"

//traits that should be properly converted to genetic mutations one day
#define TRAIT_LASEREYES "laser_eyes"
22 changes: 14 additions & 8 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -549,14 +549,20 @@ Returns 1 if the chain up to the area contains the given typepath

return 1

/proc/is_blocked_turf(turf/T, exclude_mobs)
if(T.density)
return 1
for(var/i in T)
var/atom/A = i
if(A.density && (!exclude_mobs || !ismob(A)))
return 1
return 0

/proc/is_blocked_turf(turf/target_turf, exclude_mobs)
if(target_turf.density)
return TRUE

if(locate(/mob/living/silicon/ai) in target_turf) //Prevents jaunting onto the AI core cheese, AI should always block a turf due to being a dense mob even when unanchored
return TRUE

for(var/atom/target in target_turf)
if(target.density && (!exclude_mobs || !ismob(target)))
return TRUE

return FALSE


/proc/get_step_towards2(var/atom/ref , var/atom/trg)
var/base_dir = get_dir(ref, get_step_towards(ref,trg))
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ GLOBAL_LIST_INIT(traits_by_type, list(
"TRAIT_MUTE" = TRAIT_MUTE,
"TRAIT_DEAF" = TRAIT_DEAF,
"SECDEATH" = TRAIT_SECDEATH,
"TRAIT_LASEREYES" = TRAIT_LASEREYES,
"TRAIT_AI_UNTRACKABLE" = TRAIT_AI_UNTRACKABLE,
"TRAIT_FAKEDEATH" = TRAIT_FAKEDEATH,
"TRAIT_XENO_HOST" = TRAIT_XENO_HOST,
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/other_mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
return

if(!GLOB.pacifism_after_gt)
if((LASER in mutations) && a_intent == INTENT_HARM)
if(HAS_TRAIT(src, TRAIT_LASEREYES) && a_intent == INTENT_HARM)
LaserEyes(A)

if(TK in mutations)
Expand Down
93 changes: 47 additions & 46 deletions code/datums/action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
var/invisibility = FALSE
var/obj/screen/movable/action_button/button = null
var/button_icon = 'icons/mob/actions/actions.dmi'
var/button_icon_state = "default"
var/button_background_icon = 'icons/mob/actions/actions.dmi'
var/background_icon_state = "bg_default"
var/buttontooltipstyle = ""
var/icon_icon = 'icons/mob/actions/actions.dmi'
var/button_icon_state = "default"
var/mob/owner

/datum/action/New(var/Target)
Expand Down Expand Up @@ -119,7 +120,7 @@
button.icon = ui_style2icon(owner.client.prefs.UI_style)
button.icon_state = "template"
else
button.icon = button_icon
button.icon = button_background_icon
button.icon_state = background_icon_state
button.name = name
button.desc = desc
Expand All @@ -129,12 +130,13 @@
if(IsMayActive())
toggle_active_overlay()

// If the action isn't available, darken the button
if(!IsAvailable())
var/obj/effect/proc_holder/spell/spell = target
if(istype(spell) && spell.cooldown_handler.should_draw_cooldown() || !IsAvailable())
apply_unavailable_effect()
else
return TRUE


/datum/action/proc/apply_unavailable_effect()
var/image/img = image('icons/mob/screen_white.dmi', icon_state = "template")
img.alpha = 200
Expand Down Expand Up @@ -603,13 +605,14 @@

/datum/action/spell_action/New(Target)
..()
var/obj/effect/proc_holder/spell/S = target
S.action = src
name = S.name
desc = S.desc
button_icon = S.action_icon
button_icon_state = S.action_icon_state
background_icon_state = S.action_background_icon_state
var/obj/effect/proc_holder/spell/spell = target
spell.action = src
name = spell.name
desc = spell.desc
button_icon = spell.action_icon
button_background_icon = spell.action_background_icon
button_icon_state = spell.action_icon_state
background_icon_state = spell.action_background_icon_state
button.name = name

/datum/action/spell_action/Destroy()
Expand All @@ -618,53 +621,62 @@
return ..()

/datum/action/spell_action/Trigger()
if(!..())
if(!IsAvailable(TRUE))
return FALSE

if(target)
var/obj/effect/proc_holder/spell = target
spell.Click()
return TRUE

/datum/action/spell_action/IsAvailable()
/datum/action/spell_action/IsAvailable(message = FALSE)
if(!target)
return FALSE
var/obj/effect/proc_holder/spell/spell = target

if(spell.special_availability_check)
return TRUE

if(owner)
return spell.can_cast(owner)
return spell.can_cast(owner, show_message = message)
return FALSE


/datum/action/spell_action/IsMayActive()
if(!target)
return FALSE
var/obj/effect/proc_holder/spell/targeted/click/S = target
if(istype(S) || S?.can_select)

var/obj/effect/proc_holder/spell/spell = target
if(istype(spell) && spell.need_active_overlay)
return TRUE
else
return ..()

return FALSE


/datum/action/spell_action/toggle_active_overlay()
var/obj/effect/proc_holder/spell/targeted/click/S = target
var/obj/effect/proc_holder/spell/spell = target
var/image/I = image('icons/mob/screen_gen.dmi', icon_state = "selector")
I.plane = FLOAT_PLANE + 1.1
I.layer = FLOAT_LAYER
if(S.active)
button.overlays += I
I.appearance_flags |= RESET_COLOR | RESET_ALPHA
I.plane = FLOAT_PLANE + 1.2
if(spell.active)
button.add_overlay(I)
else
button.overlays -= I
button.cut_overlay(I)


/datum/action/spell_action/ApplyIcon(obj/screen/movable/action_button/current_button)
current_button.cut_overlays()
if(button_icon && button_icon_state)
var/image/img = image(button_icon, current_button, button_icon_state)
img.appearance_flags = RESET_COLOR | RESET_ALPHA
img.pixel_x = 0
img.pixel_y = 0
current_button.add_overlay(img)


/datum/action/spell_action/apply_unavailable_effect()
var/obj/effect/proc_holder/spell/S = target
if(!istype(S))
var/obj/effect/proc_holder/spell/spell = target
if(!istype(spell))
return ..()
var/progress = S.get_availability_percentage()
if(progress == 1)
return ..() // This means that the spell is charged but unavailable due to something else

var/alpha = 220 - 140 * progress
var/alpha = spell.cooldown_handler.get_cooldown_alpha()

var/image/img = image('icons/mob/screen_white.dmi', icon_state = "template")
img.alpha = alpha
Expand All @@ -675,21 +687,10 @@
// Make a holder for the charge text
var/image/count_down_holder = image('icons/effects/effects.dmi', icon_state = "nothing")
count_down_holder.plane = FLOAT_PLANE + 1.1
count_down_holder.maptext = "<div style=\"font-size:6pt;color:[recharge_text_color];font:'Small Fonts';text-align:center;\" valign=\"bottom\">[round_down(progress * 100)]%</div>"
var/text = spell.cooldown_handler.statpanel_info()
count_down_holder.maptext = "<div style=\"font-size:6pt;color:[recharge_text_color];font:'Small Fonts';text-align:center;\" valign=\"bottom\">[text]</div>"
button.add_overlay(count_down_holder)

/*
/datum/action/spell_action/alien
/datum/action/spell_action/alien/IsAvailable()
if(!target)
return 0
var/obj/effect/proc_holder/alien/ab = target
if(owner)
return ab.cost_check(ab.check_turf, owner, 1)
return 0
*/

//Preset for general and toggled actions
/datum/action/innate
Expand Down
24 changes: 12 additions & 12 deletions code/datums/mind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2277,16 +2277,16 @@
SSticker.mode.devils -= src
SSticker.mode.update_devil_icons_removed(src)
special_role = null
RemoveSpell(/obj/effect/proc_holder/spell/targeted/infernal_jaunt)
RemoveSpell(/obj/effect/proc_holder/spell/targeted/click/fireball/hellish)
RemoveSpell(/obj/effect/proc_holder/spell/targeted/click/summon_contract)
RemoveSpell(/obj/effect/proc_holder/spell/targeted/conjure_item/pitchfork)
RemoveSpell(/obj/effect/proc_holder/spell/targeted/conjure_item/pitchfork/greater)
RemoveSpell(/obj/effect/proc_holder/spell/targeted/conjure_item/pitchfork/ascended)
RemoveSpell(/obj/effect/proc_holder/spell/targeted/conjure_item/violin)
RemoveSpell(/obj/effect/proc_holder/spell/targeted/summon_dancefloor)
RemoveSpell(/obj/effect/proc_holder/spell/targeted/sintouch)
RemoveSpell(/obj/effect/proc_holder/spell/targeted/sintouch/ascended)
RemoveSpell(/obj/effect/proc_holder/spell/infernal_jaunt)
RemoveSpell(/obj/effect/proc_holder/spell/fireball/hellish)
RemoveSpell(/obj/effect/proc_holder/spell/summon_contract)
RemoveSpell(/obj/effect/proc_holder/spell/conjure_item/pitchfork)
RemoveSpell(/obj/effect/proc_holder/spell/conjure_item/pitchfork/greater)
RemoveSpell(/obj/effect/proc_holder/spell/conjure_item/pitchfork/ascended)
RemoveSpell(/obj/effect/proc_holder/spell/conjure_item/violin)
RemoveSpell(/obj/effect/proc_holder/spell/summon_dancefloor)
RemoveSpell(/obj/effect/proc_holder/spell/sintouch)
RemoveSpell(/obj/effect/proc_holder/spell/sintouch/ascended)
if(issilicon(current))
var/mob/living/silicon/S = current
S.laws.clear_sixsixsix_laws()
Expand Down Expand Up @@ -2584,9 +2584,9 @@
for(var/type in exceptions)
if(istype(S, type))
continue
S.charge_counter = delay
S.cooldown_handler?.recharge_duration = delay
spawn(0)
S.start_recharge()
S.cooldown_handler?.start_recharge()
S.updateButtonIcon()

/datum/mind/proc/get_ghost(even_if_they_cant_reenter)
Expand Down
6 changes: 3 additions & 3 deletions code/datums/outfits/outfit_admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1402,11 +1402,11 @@
H.mind.vampire.bloodusable = 9999
H.mind.vampire.bloodtotal = 9999
H.mind.vampire.check_vampire_upgrade(0)
H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/shapeshift/bats)
H.mind.AddSpell(new /obj/effect/proc_holder/spell/shapeshift/bats)
to_chat(H, "You have gained the ability to shapeshift into bat form. This is a weak form with no abilities, only useful for stealth.")
H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/shapeshift/hellhound)
H.mind.AddSpell(new /obj/effect/proc_holder/spell/shapeshift/hellhound)
to_chat(H, "You have gained the ability to shapeshift into lesser hellhound form. This is a combat form with different abilities, tough but not invincible. It can regenerate itself over time by resting.")
H.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/raise_vampires)
//H.mind.AddSpell(new /obj/effect/proc_holder/spell/raise_vampires)
to_chat(H, "You have gained the ability to Raise Vampires. This extremely powerful AOE ability affects all humans near you. Vampires/thralls are healed. Corpses are raised as vampires. Others are stunned, then brain damaged, then killed.")
H.dna.SetSEState(GLOB.jumpblock, 1)
genemutcheck(H, GLOB.jumpblock, null, MUTCHK_FORCED)
Expand Down
Loading

0 comments on commit 92d12d8

Please sign in to comment.