Skip to content
Open
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
44 changes: 44 additions & 0 deletions RELEASE/scripts/CONSUME.ash
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,12 @@ void handle_organ_expanders(Diet d, OrganSpace space, OrganSpace max, boolean ni
Diet get_diet(OrganSpace space, OrganSpace max, boolean nightcap)
{
evaluate_consumables_if_needed();

//Some foods and booze clear spleen, so this acts as a buffer
//If space.spleen is too low, we might waste those cleanses
//Also fixes a bug where spleen is filled up past the intended limit (test: CONSUME SIM ORGANS 10 10 0 NOMEAT)
int spleen_buffer = spleen_limit() - space.spleen;
if (spleen_buffer > 0) space.spleen = spleen_limit();

Diet d;
d.nightcap = nightcap;
Expand Down Expand Up @@ -853,6 +859,14 @@ Diet get_diet(OrganSpace space, OrganSpace max, boolean nightcap)
if(space.fullness > 0)
break;
}
//Fill spleen again if stomache cleared spleen
//This ensures that if the booze also clears spleen, that wouldn't be wasted
if(space.spleen > 0)
{
fill_spleen(d, space, max);
if(space.spleen > 0)
break;
}
Comment on lines +862 to +869
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really necessary? Hitting an organ cleanser that would overcleanse an organ should automatically be triggering for that organ to be filled in first, if I recall correctly.

Copy link
Author

@Pantocyclus Pantocyclus Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect it is necessary because of how we are manipulating space.spleen by temporarily buffering it to a larger value/size. This may not trigger the spleen to be "overcleansed".

The reason for the buffer is to actually allow spleen consumables to be used. If space.spleen was set to 0, we would never use any spleen consumables, even if we could clear said spleen usage with cleansers after

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it has been years since I've looked at this, and I'm not sure how relevant this is anymore in view of the hobopolis consumable nerfs

if(space.inebriety > 0)
{
fill_liver(d, space, max);
Expand Down Expand Up @@ -949,6 +963,36 @@ Diet get_diet(OrganSpace space, OrganSpace max, boolean nightcap)
d.insert_action(ode, 0);
}

// go through spleen actions from the end and remove usage of our spleen buffer
if (spleen_buffer > 0)
{
for(int i = d.actions.count() - 1; i >= 0; --i)
{
if(d.actions[i].organ == ORGAN_SPLEEN)
{
if (d.actions[i].space <= spleen_buffer)
{
spleen_buffer -= d.actions[i].space;
d.remove_action(i);
}
else
{
int spaceToFill = d.actions[i].space - spleen_buffer;
spleen_buffer = 0;
d.remove_action(i);
while(spaceToFill > 0)
{
Consumable filler = d.best_spleen(spaceToFill);
spaceToFill -= filler.space;
d.insert_action(filler.to_action(d), i);
++i;
}
}
}
if (spleen_buffer <= 0) break;
}
}

// go through your spleen actions from the end and replace with
// sweet synthesis as appropriate
if(have_skill($skill[Sweet Synthesis]) && BASE_MEAT > 0)
Expand Down