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

improve noncombat stat gains with equipment #1112

Merged
merged 24 commits into from
Apr 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
08442a1
Update auto_equipment.ash
quarklikeadork Apr 9, 2022
77e3c1d
Update autoscend_header.ash
quarklikeadork Apr 9, 2022
f74f52a
Update auto_consume.ash
quarklikeadork Apr 9, 2022
c9ec468
Update level_07.ash
quarklikeadork Apr 9, 2022
740668b
Update level_09.ash
quarklikeadork Apr 9, 2022
a5163e4
Update mr2018.ash
quarklikeadork Apr 9, 2022
3e5d77f
replaces 3 hardcoded equips but left some with closet action
quarklikeadork Apr 9, 2022
ba56cfd
Update auto_pre_adv.ash
quarklikeadork Apr 9, 2022
cd2d960
move equipRollover after nightcap
quarklikeadork Apr 9, 2022
9e21163
equip after ode
quarklikeadork Apr 9, 2022
08c365e
Update mr2018.ash
quarklikeadork Apr 9, 2022
0634e02
Merge branch 'Loathing-Associates-Scripting-Society:master' into stat…
quarklikeadork Apr 12, 2022
0cfbc92
Update auto_consume.ash
quarklikeadork Apr 12, 2022
9f9154f
Update auto_equipment.ash
quarklikeadork Apr 12, 2022
3e830c9
Merge branch 'master' into statgain
quarklikeadork Apr 16, 2022
951b5ca
Merge branch 'Loathing-Associates-Scripting-Society:master' into stat…
quarklikeadork Apr 23, 2022
99bc660
Update auto_equipment.ash
quarklikeadork Apr 23, 2022
91311ae
useTonicDjinn()
quarklikeadork Apr 23, 2022
8350dc6
Update autoscend_header.ash
quarklikeadork Apr 23, 2022
caf44d0
Update autoscend.ash
quarklikeadork Apr 23, 2022
8d736f6
Update level_any.ash
quarklikeadork Apr 23, 2022
398eb8a
Update level_any.ash
quarklikeadork Apr 24, 2022
c80031c
fix quest value
quarklikeadork Apr 26, 2022
d629989
Merge branch 'master' into statgain
quarklikeadork Apr 30, 2022
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
8 changes: 3 additions & 5 deletions RELEASE/scripts/autoscend.ash
Original file line number Diff line number Diff line change
Expand Up @@ -846,13 +846,11 @@ void initializeDay(int day)

if(get_property("auto_day_init").to_int() < 2)
{
if((item_amount($item[Tonic Djinn]) > 0) && !get_property("_tonicDjinn").to_boolean())
{
set_property("choiceAdventure778", "2");
use(1, $item[Tonic Djinn]);
}
useTonicDjinn();

if(item_amount($item[gym membership card]) > 0)
{
equipStatgainIncreasers();
use(1, $item[gym membership card]);
}

Expand Down
2 changes: 1 addition & 1 deletion RELEASE/scripts/autoscend/auto_bedtime.ash
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,6 @@ boolean doBedtime()
}
}

equipRollover(false);
heavyrains_doBedtime();

while(my_daycount() == 1 && item_amount($item[resolution: be more adventurous]) > 0 && get_property("_resolutionAdv").to_int() < 10 && !can_interact())
Expand Down Expand Up @@ -1137,6 +1136,7 @@ boolean doBedtime()

auto_beachUseFreeCombs();
auto_drinkNightcap();
equipRollover(false);

if(in_plumber() && fullness_left() > 0)
{
Expand Down
27 changes: 18 additions & 9 deletions RELEASE/scripts/autoscend/auto_consume.ash
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,6 @@ boolean autoDrink(int howMany, item toDrink, boolean silent)

int expectedInebriety = toDrink.inebriety * howMany;

item it = equipped_item($slot[Acc3]);
if((it != $item[Mafia Pinky Ring]) && (item_amount($item[Mafia Pinky Ring]) > 0) && ($items[Bucket of Wine, Psychotic Train Wine, Sacramento Wine, Stale Cheer Wine] contains toDrink) && can_equip($item[Mafia Pinky Ring]))
{
equip($slot[Acc3], $item[Mafia Pinky Ring]);
}

if(canOde(toDrink) && possessEquipment($item[Wrist-Boy]) && (my_meat() > 6500))
{
if((have_effect($effect[Drunk and Avuncular]) < expectedInebriety) && (item_amount($item[Drunk Uncles Holo-Record]) == 0))
Expand All @@ -132,6 +126,14 @@ boolean autoDrink(int howMany, item toDrink, boolean silent)
/*do nothing, the loop condition is doing the work*/;
}

equipStatgainIncreasersFor(toDrink);

item it = equipped_item($slot[Acc3]);
if((it != $item[Mafia Pinky Ring]) && (item_amount($item[Mafia Pinky Ring]) > 0) && ($items[Bucket of Wine, Psychotic Train Wine, Sacramento Wine, Stale Cheer Wine] contains toDrink) && can_equip($item[Mafia Pinky Ring]))
{
equip($slot[Acc3], $item[Mafia Pinky Ring]);
}

boolean retval = false;
while(howMany > 0)
{
Expand Down Expand Up @@ -214,6 +216,8 @@ boolean autoDrinkCafe(int howmany, int id)
// we'll get from the drink.
if(!gnomads_available()) return false;

equipStatgainIncreasersFor(id.to_item());

string name = cafeDrinkName(id);
for (int i=0; i<howmany; i++)
{
Expand All @@ -229,6 +233,8 @@ boolean autoEatCafe(int howmany, int id)
{
if(!canadia_available()) return false;

equipStatgainIncreasersFor(id.to_item());

string name = cafeFoodName(id);
for (int i=0; i<howmany; i++)
{
Expand All @@ -255,6 +261,8 @@ boolean autoChew(int howMany, item toChew)
return false;
}

equipStatgainIncreasersFor(toChew);

boolean retval = chew(howMany, toChew);

if(retval)
Expand Down Expand Up @@ -288,6 +296,8 @@ boolean autoEat(int howMany, item toEat, boolean silent)
return false;
}

equipStatgainIncreasersFor(toEat);

int expectedFullness = toEat.fullness * howMany;
acquireMilkOfMagnesiumIfUnused(true);
consumeMilkOfMagnesiumIfUnused();
Expand Down Expand Up @@ -1736,10 +1746,9 @@ boolean prepare_food_xp_multi()
}
}

//TODO get [That's Just Cloud-Talk, Man] +25% all
//get [That's Just Cloud-Talk, Man] +25% all stats experience is already done by dailyEvents()

//if you try to use shorthand maximizer will provide you with buffed stat % instead of stat XP % gains
maximize("muscle experience percent, mysticality experience percent, moxie experience percent", false);
equipStatgainIncreasers($stats[muscle,mysticality,moxie],true);

pullXWhenHaveY($item[Special Seasoning], 1, 0); //automatically consumed with food and gives extra XP
return true;
Expand Down
266 changes: 266 additions & 0 deletions RELEASE/scripts/autoscend/auto_equipment.ash
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,272 @@ boolean tryAddItemToMaximize(slot s, item it)
return true;
}

item[slot] speculatedMaximizerEquipment(string statement)
{
//make maximizer simulate with the given statement then return the list of equipment it has chosen
item [slot] res;
boolean weaponPicked;
boolean offhandPicked;
foreach i,entry in maximize(statement,0,0,true,true) //can't use autoMaximize "Aggregate reference expected"
{
if(i>15)
{
//there should not be more than 9 or 10 equipment slots and equipment entries come first. so equipment list is done
break;
}
item maximizerItem = entry.item;
if(maximizerItem == $item[none]) continue;
slot maximizerItemSlot = maximizerItem.to_slot();
if(maximizerItemSlot == $slot[none]) continue;
slot overrideSlot;
if(maximizerItemSlot == $slot[weapon])
{
if(weaponPicked && offhandPicked)
{
//this must be familiar weapon
overrideSlot = $slot[familiar];
}
else if(weaponPicked)
{
//this must be offhand weapon
overrideSlot = $slot[off-hand];
offhandPicked = true;
}
else
{
weaponPicked = true;
if(weapon_hands(maximizerItem) > 1) offhandPicked = true;
}
}
else if(maximizerItemSlot == $slot[off-hand])
{
if(offhandPicked)
{
//this must be familiar offhand
overrideSlot = $slot[familiar];
}
else
{
offhandPicked = true;
}
}
else if(maximizerItemSlot == $slot[acc1] && res[$slot[acc1]] != $item[none])
{
//accessory to slot always returns acc1 and has to be switched if more than one, go from 1 to 3 because that is the equip order the maximizer will use
if(res[$slot[acc2]] != $item[none])
{
overrideSlot = $slot[acc3];
}
else
{
overrideSlot = $slot[acc2];
}
}
if(overrideSlot != $slot[none])
{
maximizerItemSlot = overrideSlot;
}
if(res[maximizerItemSlot] != $item[none])
{
auto_log_debug("Duplicate entry skipped for slot " + maximizerItemSlot.to_string() + " in speculatedMaximizerEquipment, something must be wrong", "gold");
continue;
}
res[maximizerItemSlot] = maximizerItem;
}
return res;
}

void equipStatgainIncreasers(boolean[stat] increaseThisStat, boolean alwaysEquip)
{
//want to equip best equipment that increases specified stat gains including out of combat
//should be frequently called by consume actions so try not to lose HP or MP, but will equip anyway if argument alwaysEquip is true
string maximizerStatement;
foreach st in increaseThisStat
Copy link
Member

Choose a reason for hiding this comment

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

will this skip stats which have been set to false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it would not, aggregates written like $stats[] only have true values in them but blocked false values now in case someone uses the function differently,
also added tonic djinn handling

{
if(!increaseThisStat[st]) continue;
string statWeight = "";
if(st == my_primestat())
{
if(disregardInstantKarma())
{
statWeight = "2";
}
}
else if(my_basestat(my_primestat()) > 122 && my_basestat(st) < 70)
{
//>= level 12 or almost there, more offstat experience may be needed for the war outfit (requires 70 mox and 70 mys)
if(st == $stat[mysticality] || st == $stat[moxie])
{
statWeight = "3";
}
}
maximizerStatement += statWeight + st.to_string() + " experience percent,";
}
item [slot] simulatedEquipment = speculatedMaximizerEquipment(maximizerStatement); //simulate and get list of relevant equipment
boolean canIncreaseStatgains = false;
foreach st in increaseThisStat
{
if(!increaseThisStat[st]) continue;
string modifierString = st.to_string() + " experience percent";
if(simValue(modifierString) > numeric_modifier(modifierString))
{
canIncreaseStatgains = true;
break;
}
}
if(!canIncreaseStatgains)
{
return;
}

//list only the maximized equipment that increases statgain
item [slot] statgainIncreasers;
foreach sl in simulatedEquipment
{
foreach st in increaseThisStat
{
if(!increaseThisStat[st]) continue;
if(numeric_modifier(simulatedEquipment[sl],st.to_string() + " experience percent") != 0)
{
statgainIncreasers[sl] = simulatedEquipment[sl];
break;
}
}
}

//equipment would be equipped in the order it was listed. check if HP or MP would be lost by equipping
int HPlost; int mostHPlost;
int MPlost; int mostMPlost;
string speculateOneItem;
string speculateAllItems;
foreach sl in statgainIncreasers
{
speculateOneItem = "equip " + sl.to_string() + " " + statgainIncreasers[sl].to_string() + "; ";
cli_execute("speculate quiet; " + speculateOneItem);
HPlost = my_hp() - simValue("Buffed HP Maximum");
MPlost = my_mp() - simValue("Buffed MP Maximum");
if(HPlost <= 0 && MPlost <= 0)
{ equip(statgainIncreasers[sl],sl); //causes no loss so it can be equipped right now
continue;
}
speculateAllItems += speculateOneItem; //otherwise speculate with all items that have been left out
if(speculateAllItems != speculateOneItem)
{
cli_execute("speculate quiet; " + speculateAllItems);
HPlost = my_hp() - simValue("Buffed HP Maximum");
MPlost = my_mp() - simValue("Buffed MP Maximum");
}
if(HPlost > mostHPlost) mostHPlost = HPlost;
if(MPlost > mostMPlost) mostMPlost = MPlost;
}
if(mostHPlost == 0 && mostMPlost == 0)
{
auto_log_debug("Done increasing incoming stat gains using equipment", "gold");
return;
}

//else try to prevent the HP or MP loss by increasing max HP and MP first using remaining slots
int targetedHP = my_hp()+mostHPlost;
int targetedMP = my_mp()+mostMPlost;
maximizerStatement = "HP " + targetedHP + "min " + targetedHP + "max, MP " + targetedMP + "min " + targetedMP + "max,";
foreach sl in statgainIncreasers
{
maximizerStatement += "-" + sl.to_string() + ","; //ignore slots where statgain increasers should be equipped
if(statgainIncreasers[sl].to_slot() == $slot[weapon]) //ignore slots that will be incompatible
{
if(weapon_hands(statgainIncreasers[sl]) > 1) maximizerStatement += "-off-hand,";
if(weapon_type(statgainIncreasers[sl]) == $stat[moxie]) maximizerStatement += "-melee,";
else maximizerStatement += "+melee,";
}
if(sl == $slot[off-hand] && statgainIncreasers[$slot[weapon]] == $item[none])
{
maximizerStatement += "1handed,"; //ignore incompatible weapons
}
}
if(!maximize(maximizerStatement,true))
{
if(!alwaysEquip)
{ //can't do it, give up
return;
}
}
auto_log_info("Trying to put on some more equipment first to avoid losing HP or MP before equipping to increase incoming statgains", "blue");
clear(simulatedEquipment);
simulatedEquipment = speculatedMaximizerEquipment(maximizerStatement);
foreach sl in simulatedEquipment
{
speculateOneItem = "equip " + sl.to_string() + " " + simulatedEquipment[sl].to_string() + "; ";
cli_execute("speculate quiet; " + speculateOneItem);
if(simValue("Buffed HP Maximum") < my_hp()) continue; //skip on collateral loss
if(simValue("Buffed MP Maximum") < my_mp()) continue;
equip(simulatedEquipment[sl],sl);
}
boolean doEquips;
if(my_maxhp() >= targetedHP && my_maxmp() >= targetedMP)
{
//finished raising max HP and MP so can now equip all statgain equipment hopefully with no HP or MP loss
doEquips = true;
}
else if(alwaysEquip)
{
catch cli_execute("burn " + (targetedMP - my_maxmp()));
doEquips = true;
}

if(doEquips)
{
foreach sl in statgainIncreasers
{
equip(statgainIncreasers[sl],sl);
}
}
}

void equipStatgainIncreasers(stat increaseThisStat, boolean alwaysEquip)
{
boolean[stat] increaseThisStatAggregate;
increaseThisStatAggregate[increaseThisStat] = true;
equipStatgainIncreasers(increaseThisStatAggregate, alwaysEquip);
}

void equipStatgainIncreasers()
{
if(!disregardInstantKarma()) //exclude primestat if level 13
{
if(my_primestat() == $stat[muscle])
{
equipStatgainIncreasers($stats[mysticality,moxie],false);
return;
}
else if(my_primestat() == $stat[mysticality])
{
equipStatgainIncreasers($stats[muscle,moxie],false);
return;
}
else if(my_primestat() == $stat[moxie])
{
equipStatgainIncreasers($stats[muscle,mysticality],false);
return;
}
}
equipStatgainIncreasers($stats[muscle,mysticality,moxie],false);
}

void equipStatgainIncreasersFor(item it)
{
//check what stats a consumable will give and equip increasers for it
boolean [stat] increaseThisStat;
stat excludedStat = disregardInstantKarma() ? $stat[none] : my_primestat(); //exclude primestat if level 13
if(it.muscle != "" && excludedStat != $stat[muscle]) increaseThisStat[$stat[muscle]] = true;
if(it.mysticality != "" && excludedStat != $stat[mysticality]) increaseThisStat[$stat[mysticality]] = true;
if(it.moxie != "" && excludedStat != $stat[moxie]) increaseThisStat[$stat[moxie]] = true;

if(count(increaseThisStat) != 0)
{
equipStatgainIncreasers(increaseThisStat,false);
}
}

string defaultMaximizeStatement()
{
if(in_pokefam())
Expand Down
9 changes: 9 additions & 0 deletions RELEASE/scripts/autoscend/auto_pre_adv.ash
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,15 @@ boolean auto_pre_adventure()
auto_handleRetrocape(); // has to be done after equipMaximizedGear otherwise the maximizer reconfigures it
cli_execute("checkpoint clear");

if(place == $location[The Hidden Bowling Alley] && item_amount($item[Bowling Ball]) > 0 && get_property("hiddenBowlingAlleyProgress").to_int() < 5)
{
equipStatgainIncreasers(); //guaranteed non combat that gives stats
}
else if(place == $location[The Haunted Ballroom] && internalQuestStatus("questM21Dance") == 3)
{
equipStatgainIncreasers(); //guaranteed non combat that gives stats
}

if (isActuallyEd() && is_wearing_outfit("Filthy Hippy Disguise") && place == $location[Hippy Camp]) {
equip($slot[Pants], $item[None]);
put_closet(item_amount($item[Filthy Corduroys]), $item[Filthy Corduroys]);
Expand Down
Loading