Skip to content

Commit

Permalink
Working commit for ability rewrite.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Dec 8, 2024
1 parent 1a62c5d commit c227442
Show file tree
Hide file tree
Showing 53 changed files with 1,063 additions and 1,425 deletions.
25 changes: 0 additions & 25 deletions code/__defines/gamemode.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,6 @@
#define DEFAULT_TELECRYSTAL_AMOUNT 130
#define IMPLANT_TELECRYSTAL_AMOUNT(x) (round(x * 0.49)) // If this cost is ever greater than half of DEFAULT_TELECRYSTAL_AMOUNT then it is possible to buy more TC than you spend

// SPELL FLAGS
#define Z2NOCAST BITFLAG(0) //if this is added, the spell can't be cast at centcomm
#define INCLUDEUSER BITFLAG(1) //does the spell include the caster in its target selection?
#define IGNOREDENSE BITFLAG(2) //are dense turfs ignored in selection?

//End split flags
#define CONSTRUCT_CHECK BITFLAG(12) //used by construct spells - checks for nullrods
#define NO_BUTTON BITFLAG(13) //spell won't show up in the HUD with this

//invocation
#define SpI_SHOUT "shout"
#define SpI_WHISPER "whisper"
#define SpI_EMOTE "emote"
#define SpI_NONE "none"

//upgrading
#define Sp_SPEED "speed"
#define Sp_POWER "power"
#define Sp_TOTAL "total"

//casting costs
#define Sp_RECHARGE "recharge"
#define Sp_CHARGES "charges"
#define Sp_HOLDVAR "holdervar"

//Voting-related
#define VOTE_PROCESS_ABORT 1
#define VOTE_PROCESS_COMPLETE 2
Expand Down
288 changes: 0 additions & 288 deletions code/_onclick/hud/screen/screen_abilities.dm

This file was deleted.

4 changes: 4 additions & 0 deletions code/datums/extensions/abilities/abilities.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@
for(var/datum/ability_handler/handler in ability_handlers)
handler.refresh_login()

/datum/extension/abilities/proc/refresh_element_positioning()
var/row = 0
for(var/datum/ability_handler/handler in ability_handlers)
row += handler.refresh_element_positioning(row)
59 changes: 59 additions & 0 deletions code/datums/extensions/abilities/abilities_mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
return FALSE
handler = new handler_type(abilities, src)
LAZYADD(abilities.ability_handlers, handler)
handler.finalize_ability_handler()
return handler

/mob/proc/remove_ability_handler(handler_type)
Expand All @@ -31,3 +32,61 @@
if(!LAZYLEN(abilities.ability_handlers))
remove_extension(src, /datum/extension/abilities)
return TRUE

/mob/living/proc/copy_abilities_from(mob/living/donor)
var/datum/extension/abilities/abilities = get_extension(src, /datum/extension/abilities)
if(!abilities)
return FALSE
. = FALSE
for(var/datum/ability_handler/handler in abilities.ability_handlers)
if(handler.copy_abilities_to(donor))
. = TRUE

/mob/living/proc/disable_abilities(var/amount = 0)
if(amount < 0)
return
var/datum/extension/abilities/abilities = get_extension(src, /datum/extension/abilities)
for(var/datum/ability_handler/handler in abilities?.ability_handlers)
handler.disable_abilities(amount)

/mob/living/proc/copy_abilities_to(mob/living/donor)
var/datum/extension/abilities/abilities = get_extension(src, /datum/extension/abilities)
for(var/datum/ability_handler/handler in abilities?.ability_handlers)
handler.copy_abilities_to(donor)

/mob/proc/add_ability(ability_type, list/metadata)
var/decl/ability/ability = GET_DECL(ability_type)
if(!istype(ability) || !ability.associated_handler_type)
return FALSE
var/datum/ability_handler/handler = get_ability_handler(ability.associated_handler_type, create_if_missing = TRUE)
return handler.add_ability(ability_type, metadata)

/mob/proc/remove_ability(ability_type)
var/decl/ability/ability = GET_DECL(ability_type)
if(!istype(ability) || !ability.associated_handler_type)
return FALSE
var/datum/extension/abilities/abilities = get_extension(src, /datum/extension/abilities)
var/datum/ability_handler/handler = locate(ability.associated_handler_type) in abilities?.ability_handlers
return handler?.remove_ability(ability_type)

/mob/proc/get_ability_metadata(ability_type)
var/decl/ability/ability = GET_DECL(ability_type)
if(!istype(ability) || !ability.associated_handler_type)
return null
var/datum/extension/abilities/abilities = get_extension(src, /datum/extension/abilities)
var/datum/ability_handler/handler = locate(ability.associated_handler_type) in abilities?.ability_handlers
return handler?.get_metadata(ability_type, create_if_missing = TRUE)

/mob/proc/has_ability(ability_type)
var/decl/ability/ability = GET_DECL(ability_type)
if(!istype(ability) || !ability.associated_handler_type)
return null
var/datum/extension/abilities/abilities = get_extension(src, /datum/extension/abilities)
var/datum/ability_handler/handler = locate(ability.associated_handler_type) in abilities?.ability_handlers
return handler?.provides_ability(ability_type)

/mob/Stat()
if((. = ..()) && client)
var/datum/extension/abilities/abilities = get_extension(src, /datum/extension/abilities)
for(var/datum/ability_handler/handler in abilities?.ability_handlers)
handler.show_stat_string(src)
Loading

0 comments on commit c227442

Please sign in to comment.