Skip to content

Commit

Permalink
The Big Ol' Trait Organization (#2982)
Browse files Browse the repository at this point in the history
* The Big Ol' Trait Organization

* cleanups, gonna try to comment out unused traits later

* alright lessgo

* weh

* fix script error

* Wow, somehow I got this done.

* I'l prolly port the rest later, this is enough for now i think

* remove txt file i was using to help comment out unused traits

* get rid of MAD_WIZARD_TRAIT

* wew thats a bug!

* improve VV modify traits by A LOT

* some formatting/alignment
  • Loading branch information
Absolucy authored Sep 8, 2024
1 parent 5fd2254 commit b024183
Show file tree
Hide file tree
Showing 36 changed files with 2,017 additions and 956 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ jobs:
- name: Check Define Sanity
if: steps.linter-setup.conclusion == 'success' && !cancelled()
run: tools/bootstrap/python -m define_sanity.check
- name: Check Trait Validity
if: steps.linter-setup.conclusion == 'success' && !cancelled()
run: tools/bootstrap/python -m trait_validity.check
- name: Run DreamChecker
if: steps.linter-setup.conclusion == 'success' && !cancelled()
shell: bash
Expand Down
29 changes: 0 additions & 29 deletions code/__DEFINES/bloodsuckers.dm
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
///Uncomment this to enable testing of Bloodsucker features (such as vassalizing people with a mind instead of a client).
//#define BLOODSUCKER_TESTING

/// You have special interactions with bloodsuckers and the occult
#define TRAIT_OCCULTIST "occultists"

/**
* Blood-level defines
*/
Expand Down Expand Up @@ -152,32 +149,6 @@
#define ROLE_MONSTERHUNTER "Monster Hunter"
#define ROLE_INFILTRATOR "Infiltrator"

/**
* Traits
*/
/// Falsifies Health analyzer blood levels
#define TRAIT_MASQUERADE "masquerade"
/// Your body is literal room temperature. Does not make you immune to the temp
#define TRAIT_COLDBLOODED "coldblooded"

/**
* Sources
*/
/// Source trait for Bloodsuckers-related traits
#define BLOODSUCKER_TRAIT "bloodsucker_trait"
/// Source trait for bloodsuckers in torpor.
#define TORPOR_TRAIT "torpor_trait"
/// Source trait for bloodsuckers using fortitude.
#define FORTITUDE_TRAIT "fortitude_trait"
/// Source trait for bloodsucker mesmerization.
#define MESMERIZED_TRAIT "mesmerized_trait"
/// Source trait for Monster Hunter-related traits
#define HUNTER_TRAIT "monsterhunter_trait"
/// Source trait while Feeding
#define FEED_TRAIT "feed_trait"
/// Source trait during a Frenzy
#define FRENZY_TRAIT "frenzy_trait"

/**
* Macros
*/
Expand Down
4 changes: 0 additions & 4 deletions code/__DEFINES/stamina.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,3 @@
/// Chance to resist out of chokeholds grabs.
#define STAMINA_GRAB_CHOKE_RESIST_CHANCE 45

////
/// TRAITS
////
#define TRAIT_CANT_STAMCRIT "cant_stamcrit"
122 changes: 122 additions & 0 deletions code/__DEFINES/traits/_traits.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#define SIGNAL_ADDTRAIT(trait_ref) "addtrait [trait_ref]"
#define SIGNAL_REMOVETRAIT(trait_ref) "removetrait [trait_ref]"

// trait accessor defines
#define ADD_TRAIT(target, trait, source) \
do { \
var/list/_L; \
if (!target._status_traits) { \
target._status_traits = list(); \
_L = target._status_traits; \
_L[trait] = list(source); \
SEND_SIGNAL(target, SIGNAL_ADDTRAIT(trait), trait); \
} else { \
_L = target._status_traits; \
if (_L[trait]) { \
_L[trait] |= list(source); \
} else { \
_L[trait] = list(source); \
SEND_SIGNAL(target, SIGNAL_ADDTRAIT(trait), trait); \
} \
} \
} while (0)
#define REMOVE_TRAIT(target, trait, sources) \
do { \
var/list/_L = target._status_traits; \
var/list/_S; \
if (sources && !islist(sources)) { \
_S = list(sources); \
} else { \
_S = sources\
}; \
if (_L?[trait]) { \
for (var/_T in _L[trait]) { \
if ((!_S && (_T != ROUNDSTART_TRAIT)) || (_T in _S)) { \
_L[trait] -= _T \
} \
};\
if (!length(_L[trait])) { \
_L -= trait; \
SEND_SIGNAL(target, SIGNAL_REMOVETRAIT(trait), trait); \
}; \
if (!length(_L)) { \
target._status_traits = null \
}; \
} \
} while (0)
#define REMOVE_TRAIT_NOT_FROM(target, trait, sources) \
do { \
var/list/_traits_list = target._status_traits; \
var/list/_sources_list; \
if (sources && !islist(sources)) { \
_sources_list = list(sources); \
} else { \
_sources_list = sources\
}; \
if (_traits_list?[trait]) { \
for (var/_trait_source in _traits_list[trait]) { \
if (!(_trait_source in _sources_list)) { \
_traits_list[trait] -= _trait_source \
} \
};\
if (!length(_traits_list[trait])) { \
_traits_list -= trait; \
SEND_SIGNAL(target, SIGNAL_REMOVETRAIT(trait), trait); \
}; \
if (!length(_traits_list)) { \
target._status_traits = null \
}; \
} \
} while (0)
#define REMOVE_TRAITS_NOT_IN(target, sources) \
do { \
var/list/_L = target._status_traits; \
var/list/_S = sources; \
if (_L) { \
for (var/_T in _L) { \
_L[_T] &= _S;\
if (!length(_L[_T])) { \
_L -= _T; \
SEND_SIGNAL(target, SIGNAL_REMOVETRAIT(_T), _T); \
}; \
};\
if (!length(_L)) { \
target._status_traits = null\
};\
}\
} while (0)

#define REMOVE_TRAITS_IN(target, sources) \
do { \
var/list/_L = target._status_traits; \
var/list/_S = sources; \
if (sources && !islist(sources)) { \
_S = list(sources); \
} else { \
_S = sources\
}; \
if (_L) { \
for (var/_T in _L) { \
_L[_T] -= _S;\
if (!length(_L[_T])) { \
_L -= _T; \
SEND_SIGNAL(target, SIGNAL_REMOVETRAIT(_T)); \
}; \
};\
if (!length(_L)) { \
target._status_traits = null\
};\
}\
} while (0)

#define HAS_TRAIT(target, trait) (target._status_traits?[trait] ? TRUE : FALSE)
#define HAS_TRAIT_FROM(target, trait, source) (HAS_TRAIT(target, trait) && (source in target._status_traits[trait]))
#define HAS_TRAIT_FROM_ONLY(target, trait, source) (HAS_TRAIT(target, trait) && (source in target._status_traits[trait]) && (length(target._status_traits[trait]) == 1))
#define HAS_TRAIT_NOT_FROM(target, trait, source) (HAS_TRAIT(target, trait) && (length(target._status_traits[trait] - source) > 0))
/// Returns a list of trait sources for this trait. Only useful for wacko cases and internal futzing
/// You should not be using this
#define GET_TRAIT_SOURCES(target, trait) (target._status_traits?[trait] || list())
/// Returns the amount of sources for a trait. useful if you don't want to have a "thing counter" stuck around all the time
#define COUNT_TRAIT_SOURCES(target, trait) length(GET_TRAIT_SOURCES(target, trait))
/// A simple helper for checking traits in a mob's mind
#define HAS_MIND_TRAIT(target, trait) (HAS_TRAIT(target, trait) || (target.mind ? HAS_TRAIT(target.mind, trait) : FALSE))
Loading

0 comments on commit b024183

Please sign in to comment.