Skip to content

Commit

Permalink
Added ALL_CREATRS_HAPPY temple reward
Browse files Browse the repository at this point in the history
Disabled by default
  • Loading branch information
Loobinex committed Oct 13, 2024
1 parent 5932f3c commit 183a77c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/fxdata/rules.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,4 @@ NegSpellAll = SPELL_SLOW VAMPIRE DEMONSPAWN
;MkGoodHero = AVATAR KNIGHT SAMURAI WIZARD GIANT MONK
;NegUniqFunc = COSTLIER_IMPS TUNNELLER
;NegUniqFunc = ALL_CREATRS_VER_ANGRY VAMPIRE HORNY
;PosUniqFunc = ALL_CREATRS_HAPPY TIME_MAGE FAIRY
1 change: 1 addition & 0 deletions src/config_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ const struct NamedCommand rules_sacrifices_commands[] = {

const struct NamedCommand sacrifice_unique_desc[] = {
{"ALL_CREATRS_ANGRY", UnqF_MkAllAngry},
{"ALL_CREATRS_HAPPY", UnqF_MkAllHappy},
{"COMPLETE_RESEARCH", UnqF_ComplResrch},
{"COMPLETE_MANUFACTR", UnqF_ComplManufc},
{"KILL_ALL_CHICKENS", UnqF_KillChickns},
Expand Down
1 change: 1 addition & 0 deletions src/config_rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ enum UniqueFunctions {
UnqF_KillChickns,
UnqF_CheaperImp,
UnqF_CostlierImp,
UnqF_MkAllHappy,
};

enum SacrificeReturn {
Expand Down
48 changes: 48 additions & 0 deletions src/creature_states_pray.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,51 @@ TbBool make_all_players_creatures_angry(long plyr_idx)
return true;
}

TbBool anger_make_creature_happy(struct Thing* creatng)
{
struct CreatureStats* crstat = creature_stats_get_from_thing(creatng);
if ((crstat->annoy_level <= 0))
return false;
if (!anger_free_for_anger_decrease(creatng))
{
return false;
}
creature_be_happy(creatng);
anger_set_creature_anger_all_types(creatng, 0);
return true;
}

TbBool make_all_players_creatures_happy(long plyr_idx)
{
SYNCDBG(8, "Starting");
struct Dungeon* dungeon = get_players_num_dungeon(plyr_idx);
unsigned long k = 0;
int i = dungeon->creatr_list_start;
while (i != 0)
{
struct Thing* thing = thing_get(i);
TRACE_THING(thing);
struct CreatureControl* cctrl = creature_control_get_from_thing(thing);
if (thing_is_invalid(thing) || creature_control_invalid(cctrl))
{
ERRORLOG("Jump to invalid creature detected");
break;
}
i = cctrl->players_next_creature_idx;
// Thing list loop body
anger_make_creature_happy(thing);
// Thing list loop body ends
k++;
if (k > CREATURES_COUNT)
{
ERRORLOG("Infinite loop detected when sweeping creatures list");
break;
}
}
SYNCDBG(19, "Finished");
return true;
}

long force_complete_current_manufacturing(long plyr_idx)
{
struct Dungeon* dungeon = get_players_num_dungeon(plyr_idx);
Expand Down Expand Up @@ -461,6 +506,9 @@ long create_sacrifice_unique_award(struct Coord3d *pos, PlayerNumber plyr_idx, l
case UnqF_CostlierImp:
tally_sacrificed_imps(plyr_idx, -1);
return SacR_AngryWarn;
case UnqF_MkAllHappy:
make_all_players_creatures_happy(plyr_idx);
return SacR_Awarded;
default:
ERRORLOG("Unsupported unique sacrifice award!");
return SacR_AngryWarn;
Expand Down

0 comments on commit 183a77c

Please sign in to comment.