Skip to content

Commit

Permalink
Merge pull request #73080 from GuardianDll/eoc_death_effect
Browse files Browse the repository at this point in the history
killed monster can run EoC directly
  • Loading branch information
Maleclypse authored Apr 18, 2024
2 parents 0853a71 + b94e137 commit 5401efb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/EFFECT_ON_CONDITION.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ For example, `{ "npc_has_effect": "Shadow_Reveal" }`, used by shadow lieutenant,
| mutation: "deactivated_eocs" | character (Character) | NONE |
| mutation: "processed_eocs" | character (Character) | NONE |
| recipe: "result_eocs" | crafter (Character) | NONE |
| monster death: "death_function" | killed monster (monster) | you (avatar) |

Using `use_action: "type": "effect_on_conditions"` automatically passes the context variable `id`, that stores the id of an item that was activated
Using `bionics: "activated_eocs"` automatically passes the context variable `act_cost` that stores the value of `act_cost` field
Expand Down
3 changes: 2 additions & 1 deletion doc/MONSTERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ How the monster behaves on death.
{
"corpse_type": "NORMAL", // can be: BROKEN, NO_CORPSE, NORMAL (default)
"message": "The %s dies!", // substitute %s for the monster's name.
"effect": { "id": "death_boomer", "hit_self": true } // the actual effect that gets called when the monster dies. follows the syntax of fake_spell.
"effect": { "id": "death_boomer", "hit_self": true } // the spell that gets called when the monster dies. follows the syntax of fake_spell.
"eoc": "debug_eoc_message", // eoc that would be run when monster dies. Alpha talker is monster, beta talker is player (always).
}
```

Expand Down
11 changes: 11 additions & 0 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "cursesdef.h"
#include "debug.h"
#include "effect.h"
#include "effect_on_condition.h"
#include "effect_source.h"
#include "event.h"
#include "event_bus.h"
Expand Down Expand Up @@ -2841,6 +2842,16 @@ void monster::die( Creature *nkiller )
}
}

if( type->mdeath_effect.eoc.has_value() ) {
//Not a hallucination, go process the death effects.
if( type->mdeath_effect.eoc.value().is_valid() ) {
dialogue d( get_talker_for( *this ), nullptr );
type->mdeath_effect.eoc.value()->activate( d );
} else {
debugmsg( "eoc id %s is not valid", type->mdeath_effect.eoc.value().str() );
}
}

// scale overkill damage by enchantments
if( nkiller && ( nkiller->is_npc() || nkiller->is_avatar() ) ) {
int current_hp = get_hp();
Expand Down
1 change: 1 addition & 0 deletions src/monstergenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1815,6 +1815,7 @@ void monster_death_effect::load( const JsonObject &jo )
optional( jo, was_loaded, "effect", sp );
has_effect = sp.is_valid();
optional( jo, was_loaded, "corpse_type", corpse_type, mdeath_type::NORMAL );
optional( jo, was_loaded, "eoc", eoc );
}

void monster_death_effect::deserialize( const JsonObject &data )
Expand Down
1 change: 1 addition & 0 deletions src/mtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ struct monster_death_effect {
bool was_loaded = false;
bool has_effect = false;
fake_spell sp;
std::optional<effect_on_condition_id> eoc;
translation death_message;
mdeath_type corpse_type = mdeath_type::NORMAL;

Expand Down

0 comments on commit 5401efb

Please sign in to comment.