attacking charmed monsters dispels charm, doesn't anger town

This commit is contained in:
2025-09-13 20:16:24 -05:00
parent 8fc3723e76
commit 703707ea6d
4 changed files with 22 additions and 6 deletions

View File

@@ -213,6 +213,23 @@ void start_outdoor_combat(cOutdoors::cCreature encounter,location where,short nu
start_outdoor_combat(encounter.what_monst, where, num_walls);
}
void monst_hit_town_reaction(iLiving& monst_hit, bool print){
if(monst_hit.is_friendly()){
// Charmed enemy is fair game
if(monst_hit.status[eStatus::CHARM] > 0){
monst_hit.status[eStatus::CHARM] = 0;
add_string_to_buf("Charm dispelled.");
if(cCreature* check = dynamic_cast<cCreature*>(&monst_hit)){
check->attitude = eAttitude::HOSTILE_A;
}
}else{
// This message only prints when a spell was cast, not when you've confirmed attacking a friendly
if(print) add_string_to_buf("Damaged an innocent.");
make_town_hostile();
}
}
}
bool pc_combat_move(location destination) {
std::string create_line;
short s1;
@@ -268,8 +285,7 @@ bool pc_combat_move(location destination) {
else if(result == "attack") do_attack = true;
}
if(do_attack) {
if(monst_hit->is_friendly())
make_town_hostile();
monst_hit_town_reaction(*monst_hit);
univ.current_pc().last_attacked = monst_hit;
pc_attack(univ.cur_pc,monst_hit);
return true;
@@ -1186,7 +1202,7 @@ void do_combat_cast(location target) {
else {
cCreature* cur_monst = dynamic_cast<cCreature*>(victim);
if(cur_monst && cur_monst->is_friendly() && spell_being_cast != eSpell::SCRY_MONSTER && spell_being_cast != eSpell::CAPTURE_SOUL)
make_town_hostile();
monst_hit_town_reaction(*cur_monst);
switch(spell_being_cast) {
case eSpell::ACID_SPRAY:
store_m_type = 0;

View File

@@ -28,6 +28,7 @@ bool combat_next_step();
bool pick_next_pc();
void combat_run_monst();
void do_monster_turn();
void monst_hit_town_reaction(iLiving& monst_hit, bool print = false);
void monster_attack(short who_att,iLiving* target);
void monst_fire_missile(short m_num,short bless,std::pair<eMonstAbil,uAbility> abil,location source,iLiving* target);
void monst_basic_abil(short m_num, std::pair<eMonstAbil,uAbility> abil, iLiving* target);

View File

@@ -1576,9 +1576,7 @@ short damage_monst(cCreature& victim, short who_hit, short how_much, eDamageType
if(victim.is_friendly() && who_hit < 7 &&
((!processing_fields && !monsters_going) || (processing_fields && !univ.party.hostiles_present))) {
add_string_to_buf("Damaged an innocent.");
victim.attitude = eAttitude::HOSTILE_A;
make_town_hostile();
monst_hit_town_reaction(victim, true);
}
return how_much;

View File

@@ -243,6 +243,7 @@ void cCreature::sleep(eStatus which_status,int amount,int penalty) {
if(which_status == eStatus::CHARM) {
if(amount <= 0 || amount > 3) amount = 2;
attitude = eAttitude(amount);
status[eStatus::CHARM] = amount;
spell_note(eSpellNote::CHARMED);
} else if(which_status == eStatus::FORCECAGE) {
status[eStatus::FORCECAGE] = amount;