Skip to content

Commit

Permalink
fix enum reading and improve exponential exp calculation docs
Browse files Browse the repository at this point in the history
  • Loading branch information
b3brodie committed Dec 15, 2024
1 parent 9937048 commit 0e25b8e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion doc/MAGIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ In `data/mods/Magiclysm` there is a template spell, copied here for your perusal
"components": [requirement_id] // an id from a requirement, like the ones you use for crafting. spell components require to cast.
"difficulty": 12, // the difficulty to learn/cast the spell
"max_level": 10, // maximum level you can achieve in the spell
"exp_formula": "constant", // choose between "constant", "linear", "exponential". Exp Per level: Constant: a, Linear: a(level), Exponential (probably): e^(level * b) * e^(b) * e^(-c * b) - e^(level * b) * e^(-c * b). Defaults to exponential if no value is given.
"exp_formula": "constant", // choose between "constant", "linear", "exponential". Exp Per level: Constant: a, Linear: a(level), Exponential (probably): e^(level * b) * e^(-c * b) * ( e^(b) - 1 ). Defaults to exponential if no value is given.
"experience_calc_constant_a": 1000, // adjusts the constants used in the experience level calculation formula.
"experience_calc_constant_b": 0.146661,
"experience_calc_constant_c": -62.5,
Expand Down
4 changes: 1 addition & 3 deletions src/magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ std::string enum_to_string<xp_formula>( xp_formula data )
case xp_formula::exponential: return "exponential";
case xp_formula::linear: return "linear";
case xp_formula::constant: return "constant";
case xp_formula::num_formulas: break;
}
cata_fatal( "Invalid xp_formula" );
}
Expand Down Expand Up @@ -1668,9 +1669,6 @@ bool spell::ignore_by_species_id( const tripoint_bub_ms &p ) const
return valid;
}




std::string spell::description() const
{
return type->description.translated();
Expand Down
11 changes: 6 additions & 5 deletions src/magic.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,13 @@ enum class spell_shape : int {
};

enum class xp_formula : int {
// e^(level * b) * e^(b) * e^(-c * b) - e^(level * b) * e^(-c * b). Probably
// e^(level * b) * e^(-c * b) * ( e^(b) - 1 ) per level. Probably
exponential,
// a(level)
// a(level) per level
linear,
// a
constant
// a per level
constant,
num_formulas
};

template<>
Expand All @@ -159,7 +160,7 @@ struct enum_traits<spell_flag> {

template<>
struct enum_traits<xp_formula> {
static constexpr xp_formula last = xp_formula::exponential;
static constexpr xp_formula last = xp_formula::num_formulas;
};

struct fake_spell {
Expand Down

0 comments on commit 0e25b8e

Please sign in to comment.