efilnikufecin
Member
I've been going around in circles with this for quite a while now, and am hoping for some suggestions from the other scripters out there.
a script can easily be written to answer the question "do I have a tiny plastic sword?" and even locate it for you.
Now notice boolean drinkviatps(stat: PrefStat) does not contain the code for actual drinking? Well, I may have a skewered lime, but be wanting to drink a sangria which requires a skewered cherry. The solution is to go ahead and drink a skewered lime drink instead. I want the script to focus on using any TPS item other than the actual TPS first, then if no other TPS item is found, create a drink using the actual TPS.
I call drinkviatps with the (my_primestat()) parameter here only for example. The actual call in the end will be with the parameter (my_preferredstat()).
The purpose is to want to drink a tps drink which boosts the stat passed to the function but actually drink a tps drink of any stat type when it's not possible. This means that in the event of a failure for any reason, the tps could be lost in just about any tps item form possible.
So how would you go about finishing the function drinkviatps?
a script can easily be written to answer the question "do I have a tiny plastic sword?" and even locate it for you.
Code:
record ItemPairs
{
Item Item1;
Item Item2;
};
item[int] TPSItems;
item[int] possessed_items;
item[int] drinks;
item[int] skewers;
item[stat] StatSkewers;
ItemPairs[stat] TPSStatDrinks;
void initTPSItems()
{
StatSkewers[$stat[muscle]] = $item[skewered lime];
StatSkewers[$stat[moxie]] = $item[skewered jumbo olive];
StatSkewers[$stat[mysticality]] = $item[skewered cherry];
TPSStatDrinks[$stat[muscle]].item1 = $item[grogtini];
TPSStatDrinks[$stat[muscle]].item2 = $item[bodyslam];
TPSStatDrinks[$stat[moxie]].item1 = $item[vesper];
TPSStatDrinks[$stat[moxie]].item2 = $item[dirty martini];
TPSStatDrinks[$stat[mysticality]].item1 = $item[cherry bomb];
TPSStatDrinks[$stat[mysticality]].item2 = $item[sangria del diablo];
skewers[0] = $item[skewered jumbo olive];
skewers[1] = $item[skewered lime];
skewers[2] = $item[skewered cherry];
drinks[0] = $item[dirty martini];
drinks[1] = $item[grogtini];
drinks[2] = $item[cherry bomb];
drinks[3] = $item[vesper];
drinks[4] = $item[bodyslam];
drinks[5] = $item[sangria del diablo];
int count;
TPSItems[count] = $item[tiny plastic sword];
foreach key in skewers
{
count = count + 1;
TPSItems[count] = skewers[key];
}
foreach key in drinks
{
count = count + 1;
TPSItems[count] = drinks[key];
}
}
boolean drinkviatps(stat: PrefStat)
{
//drink based on the data obtained
}
int TPSItemCount;
void possesseditemadd(item toadd)
{
possessed_items[TPSItemCount] := toadd;
TPSItemCount := TPSItemCount + 1;
}
boolean HaveTPS()
{
boolean Results;
Results = false;
//clear the array for subsequent calls
Clear(possessed_items);
foreach key in TPSItems
{
if(closet_amount(TPSItems[key]) > 0) {take_closet(closet_amount(TPSItems[key]), TPSItems[key]);}
if(item_amount(TPSItems[key]) > 0)
{
possesseditemadd(TPSItems[key]);
Results = true;
}
}
return Results;
}
Boolean DrinkAway()
{
if(usetps)
{
//only call HaveTPS if usetps is true
//if the above if statement were "if(usetps && haveTPS())" then
//havetps() would be called when not needed
//re-call haveTPS each time to re-load the map of items.
while(HaveTPS() && (my_inebriety() < inebriety_limit() - 7))
{
//needs some change, use a function to return the preferred stat instead of my_primestat
drinkviatps(my_primestat());
}
}
}
//this function call is intentionally sitting outside of a function.
//I use the space right before void main() as an initialization section
//to avoid the need for forward declaration of functions.
initTPSItems();
void main()
{
DrinkAway();
}
Now notice boolean drinkviatps(stat: PrefStat) does not contain the code for actual drinking? Well, I may have a skewered lime, but be wanting to drink a sangria which requires a skewered cherry. The solution is to go ahead and drink a skewered lime drink instead. I want the script to focus on using any TPS item other than the actual TPS first, then if no other TPS item is found, create a drink using the actual TPS.
I call drinkviatps with the (my_primestat()) parameter here only for example. The actual call in the end will be with the parameter (my_preferredstat()).
Code:
boolean balance_stats = true;
stat my_preferredstat()
{
if(balance_stats)
{
if(mus < mox)
{
if(mus < myst){return $stat[muscle];}
else{retun $stat[mysticality];}
}
else
{
if(mox < myst){return $stat[moxie];}
else{retun $stat[mysticality];}
}
}
else
{return my_primestat();}
}
The purpose is to want to drink a tps drink which boosts the stat passed to the function but actually drink a tps drink of any stat type when it's not possible. This means that in the event of a failure for any reason, the tps could be lost in just about any tps item form possible.
So how would you go about finishing the function drinkviatps?