track slimeling fullness (diff attached)

churl2

New member
Attached is a patch to kolmafia which tracks how full your slimeling is, and displays it next to its name (like the bander, lama, sandworm, or pixie tracking).

UPDATED: now resets properly on ascension, and tracks fractional fullness.

Code:
Index: src/net/sourceforge/kolmafia/webui/CharPaneDecorator.java
===================================================================
--- src/net/sourceforge/kolmafia/webui/CharPaneDecorator.java	(revision 8297)
+++ src/net/sourceforge/kolmafia/webui/CharPaneDecorator.java	(working copy)
@@ -152,6 +152,8 @@
 				fam.getModifiedWeight() / 5;
 		case FamiliarPool.HARE:
 			return Preferences.getInteger( "extraRolloverAdventures" ) + " adv";
+		case FamiliarPool.SLIMELING:
+			return "~" + Preferences.getFloat( "slimelingFullness" ) + " full";
 		}
 		return null;
 	}
Index: src/net/sourceforge/kolmafia/session/ValhallaManager.java
===================================================================
--- src/net/sourceforge/kolmafia/session/ValhallaManager.java	(revision 8297)
+++ src/net/sourceforge/kolmafia/session/ValhallaManager.java	(working copy)
@@ -233,6 +233,7 @@
 
 	public static final void resetPerAscensionCounters()
 	{
+		Preferences.setFloat( "slimelingFullness", (float) 0.0 );
 		Preferences.setInteger( "currentBountyItem", 0 );
 		Preferences.setString( "currentHippyStore", "none" );
 		Preferences.setString( "currentWheelPosition", "muscle" );
Index: src/net/sourceforge/kolmafia/request/UseItemRequest.java
===================================================================
--- src/net/sourceforge/kolmafia/request/UseItemRequest.java	(revision 8297)
+++ src/net/sourceforge/kolmafia/request/UseItemRequest.java	(working copy)
@@ -58,6 +58,7 @@
 import net.sourceforge.kolmafia.objectpool.FamiliarPool;
 import net.sourceforge.kolmafia.objectpool.ItemPool;
 import net.sourceforge.kolmafia.persistence.AdventureDatabase;
+import net.sourceforge.kolmafia.persistence.EquipmentDatabase;
 import net.sourceforge.kolmafia.persistence.ConcoctionDatabase;
 import net.sourceforge.kolmafia.persistence.FamiliarDatabase;
 import net.sourceforge.kolmafia.persistence.ItemDatabase;
@@ -3553,6 +3554,16 @@
 		String name = item.getName();
 		String useString = "feed " + count + " " + name + " to " + familiar.getRace();
 
+        // estimate slimeling charges
+        if (id == FamiliarPool.SLIMELING)
+        {
+            // round down for now, since we don't know how this really works
+            float charges = item.getCount() * EquipmentDatabase.getPower(item.getItemId()) / 10.0F;
+            Preferences.setFloat("slimelingFullness", Preferences.getFloat("slimelingFullness") + charges);
+			// Preferences.increment( "slimelingFullness", charges );
+            useString += " (estimated " + charges + " charges)";
+        }
+
 		RequestLogger.updateSessionLog();
 		RequestLogger.updateSessionLog( useString );
 		
Index: src/net/sourceforge/kolmafia/request/FightRequest.java
===================================================================
--- src/net/sourceforge/kolmafia/request/FightRequest.java	(revision 8297)
+++ src/net/sourceforge/kolmafia/request/FightRequest.java	(working copy)
@@ -1843,6 +1843,15 @@
 			}
 		}
 
+        // "[slimeling] leaps on your opponent, sliming it for XX damage.  It's inspiring!"
+		if ( responseText.indexOf( "leaps on your opponent" ) != -1 )
+        {
+            Preferences.setFloat("slimelingFullness", Preferences.getFloat("slimelingFullness") - 1.0F);
+			// Preferences.increment( "slimelingFullness", -1 );
+            if (Preferences.getFloat("slimelingFullness") < 0.0)
+                Preferences.setFloat("slimelingFullness",(float) 0.0);
+        }
+
 		// "As you're trying to get away, you sink in the silty muck on
 		// the sea floor. You manage to get yourself unmired, but your
 		// greaves seem to have gotten instantly rusty in the process..."
 
Last edited:

slyz

Developer
That's nice, let's see what Jason or Veracity think about it.
From the wiki's discussion page, if power/10 isn't an integer, the number of charges is rolled for. I would like to see Mafia being conservative and show the lower bound :
Code:
int charges = item.getCount() * floor( EquipmentDatabase.getPower(item.getItemId()) / 10 );
(if floor() works the same way in java)
 

churl2

New member
Slyz: your change isn't necessary -- the code as I have it rounds down.

Where it could be improved is, suppose you consume two 15-power items. The fullness should be 3, but currently it'll report it as 2.
 

slyz

Developer
Oh ok, I didn't know if non ints would be rounded to the closest int or the floor.

Why should the fullness be 3 for two 15 power items? wouldn't that be the average?
 

garjon

Member
If you have the room, it might be preferred to track confirmed charges (equipment power / 10), and guesstimated charges (equipment power mod 10, total / 10), and display it like the other familiar drops. Ex: Llama starts the day displaying 0/5. Slimeling starts the run displaying 0/0. Slimeling is fed two power 15 pieces of equipment. Slimeling now displays 2/1. 2 confirmed charges, and an average 1 guesstimated charge.
 

lostcalpolydude

Developer
Staff member
I would expect it to display 2/3 in that case, but that's still confusing since all other cases in mafia are X used out of Y available.
 

slyz

Developer
Using more than one number would be confusing. That's why I think just the lower bound is nice. At most, maybe "min - max".
 

churl2

New member
So, this patch has been posted here for coming on two months now... I hear that AFH has rolled the patch into their forked version of mafia.

How does this become official? Or, if it's not going to, could one of the committers please comment why?
 

jasonharper

Developer
Speaking personally, I just don't understand the slimeling mechanics well enough to judge whether this patch is correct or useful. The lack of anyone speaking up for it puts it way behind a huge number of other features I could choose to spend my time working on.
 

slyz

Developer
I'll try to understand how to apply diff files automatically when building from source and try this out.
It would play very nicely with my Familiar Feeder.
 

fronobulax

Developer
Staff member
How does this become official? Or, if it's not going to, could one of the committers please comment why?
I have neither the knowledge nor slimeling to let me determine whether it is useful or correct. However, since there does seem to be some interest in it, I will look at it and commit it if I don't see anything that concerns me. That said, however, I would much prefer to start from copies of the files you changed and not try and derive the changes from your patch/diff log.
 
Last edited:

Bale

Minion
I tried out this patch and unfortunately it has a flaw. If the slimeling is empty, but still has fullness being tracked, the residual fullness will remain FOREVER. The extra fullness can accumulate when fractional equipment has bad luck on filling up the slimeling (this happened to me), or some turns are run outside of mafia.

To fix this, mafia would need to notice in combat that the slimeling is not giving hungry messages and then reset fullness to 0.
 

churl2

New member
Bale, you're right, it does have that problem. I couldn't figure out an easy way to detect when the slimeling messages have stopped appearing in combat.
I'll have another go at that part.

slyz: it does work very well with your feeder script, which I am also using.

frono: All you need to do is "patch -p0 < mypatch" from your svn working dir. But, I'm happy to submit the changes in another way if you prefer.
 

Bale

Minion
Bale, you're right, it does have that problem. I couldn't figure out an easy way to detect when the slimeling messages have stopped appearing in combat.

You might find some useful hints in zarqon's FirstThingsFirst and SmartStasis which detects a lack of slimeling messages. His simple answer is that if the slimeling does nothing on any turn and you didn't skip a turn with saucy salve or Stealth Mistletoe, then your slimeling is empty.

Code:
      case $familiar[slimeling]: if (!contains_text(action,"/slimeling.gif") && !contains_text(action,"You quickly conjure a saucy salve")) {
            print("Your slimeling needs sating.","olive"); famspent = true; } break;

That code doesn't mention anything about the Stealth Mistletoe message ("You deftly dart around behind your opponent and hang a sprig of mistletoe above its head while it isn't looking.") so he probably checks for it elsewhere.
 

fronobulax

Developer
Staff member
frono: All you need to do is "patch -p0 < mypatch" from your svn working dir. But, I'm happy to submit the changes in another way if you prefer.
I think you're making an awful lot of presumptions about my development environment ;-) For starters there is no executable named "patch" on my system. I'm using SVN from NetBeans and the usual 5 minute search didn't turn up a way to apply your patch although that is not to say it wouldn't turn up with 6 minutes of search.
 
Top