Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONize AEP_EVIL and implement intermittent artifact effects #38221

Merged
merged 1 commit into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions data/json/legacy_artifact_passive.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,21 @@
"type": "enchantment",
"id": "AEP_SPEED_DOWN",
"values": [ { "value": "SPEED", "add": -20 } ]
},
{
"type": "SPELL",
"id": "AEP_EVIL_SPELL",
"name": "EEEEEEVVVVVIIIIILLLL!",
"description": "You debugged in this spell! It makes you evil for 30 minutes.",
"valid_targets": [ "hostile", "ally", "self" ],
"effect": "target_attack",
"effect_str": "evil",
"min_duration": 180000,
"max_duration": 180000
},
{
"type": "enchantment",
"id": "AEP_EVIL",
"intermittent_activation": { "effects": [ { "frequency": "15 minutes", "spell_effects": [ { "id": "AEP_EVIL_SPELL" } ] } ] }
}
]
12 changes: 11 additions & 1 deletion src/magic_enchantment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void enchantment::load( const JsonObject &jo, const std::string & )

if( jo.has_object( "intermittent_activation" ) ) {
JsonObject jobj = jo.get_object( "intermittent_activation" );
for( const JsonObject effect_obj : jo.get_array( "effects" ) ) {
for( const JsonObject effect_obj : jobj.get_array( "effects" ) ) {
time_duration dur = read_from_json_string<time_duration>( *effect_obj.get_raw( "frequency" ),
time_duration::units );
if( effect_obj.has_array( "spell_effects" ) ) {
Expand Down Expand Up @@ -367,6 +367,16 @@ void enchantment::activate_passive( Character &guy ) const

guy.mod_num_dodges_bonus( get_value_add( mod::BONUS_DODGE ) );
guy.mod_num_dodges_bonus( mult_bonus( mod::BONUS_DODGE, guy.get_num_dodges_base() ) );

for( const std::pair<const time_duration, std::vector<fake_spell>> &activation :
intermittent_activation ) {
// a random approximation!
if( one_in( to_seconds<int>( activation.first ) ) ) {
for( const fake_spell &fake : activation.second ) {
fake.get_spell( 0 ).cast_all_effects( guy, guy.pos() );
}
}
}
}

void enchantment::cast_hit_you( Character &caster, const tripoint &target ) const
Expand Down