Having some issues with adventure consult functions

Rinn

Developer
I'm trying to write a script where I can hijack battle actions without forcing the users to change their ccs, so I remembered the version of adventure that can take in a function name to process the combat. Take this simple script for example, this is the full contents of my test.ash:
Code:
string combat_cleesh(int round, monster opp, string text)
{
    if (opp == $monster[frog] || opp == $monster[newt] || opp == $monster[salamander])
    {
        return "attack";
    }
    
    return "skill CLEESH";
}

void main()
{
    adventure(1, $location[hole in the sky], "combat_cleesh");
}
Returns the following error in the cli:
Code:
Unable to invoke combat_cleesh
You don't have enough ovid leather thing
You're on your own, partner.
Okay so I looked up the original thread and that's the error jason said he got when he declared the consult function as void instead of string. So then I tried this:
Code:
string combat_cleesh(int round, monster opp, string text)
{
    if (opp == $monster[frog] || opp == $monster[newt] || opp == $monster[salamander])
    {
        return "attack";
    }
    
    return "skill CLEESH";
}

adventure(1, $location[hole in the sky], "combat_cleesh");
When I remove main and put the adventure call right in the script, I get a stack trace:
Code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
             KoLmafia r8268, Windows 7, Java 1.6.0_18
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Please note: do not post these logs in the KoLmafia thread.  If 
 you would like us to look at the log, please instead email logs 
 to veracity@hambo.com using the subject "KoLmafia Debug Log" 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Timestamp: Sat Mar 13 20:56:29 PST 2010
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


Unexpected error, debug log printed.
class java.lang.NullPointerException: null
java.lang.NullPointerException
    at net.sourceforge.kolmafia.request.FightRequest.nextRound(FightRequest.java:522)
    at net.sourceforge.kolmafia.request.FightRequest.nextRound(FightRequest.java:490)
    at net.sourceforge.kolmafia.request.FightRequest.runOnce(FightRequest.java:1076)
    at net.sourceforge.kolmafia.request.FightRequest.run(FightRequest.java:1109)
    at net.sourceforge.kolmafia.request.GenericRequest.handleServerRedirect(GenericRequest.java:1505)
    at net.sourceforge.kolmafia.request.GenericRequest.retrieveServerReply(GenericRequest.java:1353)
    at net.sourceforge.kolmafia.request.GenericRequest.execute(GenericRequest.java:1084)
    at net.sourceforge.kolmafia.request.GenericRequest.run(GenericRequest.java:975)
    at net.sourceforge.kolmafia.request.AdventureRequest.run(AdventureRequest.java:208)
    at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:73)
    at net.sourceforge.kolmafia.KoLAdventure.run(KoLAdventure.java:918)
    at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:103)
    at net.sourceforge.kolmafia.KoLmafia.executeAdventureOnce(KoLmafia.java:1423)
    at net.sourceforge.kolmafia.KoLmafia.executeRequestOnce(KoLmafia.java:1441)
    at net.sourceforge.kolmafia.KoLmafia.executeRequest(KoLmafia.java:1313)
    at net.sourceforge.kolmafia.KoLmafia.makeRequest(KoLmafia.java:1198)
    at net.sourceforge.kolmafia.textui.command.AdventureCommand.run(AdventureCommand.java:103)
    at net.sourceforge.kolmafia.KoLmafiaCLI.executeCommand(KoLmafiaCLI.java:527)
    at net.sourceforge.kolmafia.textui.RuntimeLibrary.adventure(RuntimeLibrary.java:1821)
    at net.sourceforge.kolmafia.textui.RuntimeLibrary.adventure(RuntimeLibrary.java:1831)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.sourceforge.kolmafia.textui.parsetree.LibraryFunction.execute(LibraryFunction.java:119)
    at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:166)
    at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:451)
    at net.sourceforge.kolmafia.textui.Interpreter.executeScope(Interpreter.java:240)
    at net.sourceforge.kolmafia.textui.Interpreter.execute(Interpreter.java:194)
    at net.sourceforge.kolmafia.textui.Interpreter.execute(Interpreter.java:187)
    at net.sourceforge.kolmafia.textui.command.CallScriptCommand.call(CallScriptCommand.java:194)
    at net.sourceforge.kolmafia.textui.command.CallScriptCommand.run(CallScriptCommand.java:63)
    at net.sourceforge.kolmafia.KoLmafiaCLI.executeCommand(KoLmafiaCLI.java:527)
    at net.sourceforge.kolmafia.KoLmafiaCLI.executeLine(KoLmafiaCLI.java:401)
    at net.sourceforge.kolmafia.swingui.CommandDisplayFrame$CommandQueueHandler.handleQueue(CommandDisplayFrame.java:191)
    at net.sourceforge.kolmafia.swingui.CommandDisplayFrame$CommandQueueHandler.run(CommandDisplayFrame.java:172)

Am I doing something incorrect, or has this broken at some point and no one noticed because of it's infrequent use?

Relevant thread:
http://kolmafia.us/showthread.php?1609
 
I think it should work if you try this:

Code:
string combat_cleesh(int round, [COLOR="#ff0000"]string[/COLOR] opp, string text)
{
    if (opp == $monster[frog] || opp == $monster[newt] || opp == $monster[salamander])
    {
        return "attack";
    }
    
    return "skill CLEESH";
}

void main()
{
    adventure(1, $location[hole in the sky], "combat_cleesh");
}

That was your problem. :D
 
Last edited:
While declaring your opponent as a string instead of a monster might be a good idea (assuming that you want your script to attempt to fight unknown monsters), that's clearly not the problem here - the error message would have been "bad monster value" in that case. I can confirm that the problem exists, but I have no idea yet what's causing it - I can't think of any recent changes that might be relevant. I'll take a closer look at it tomorrow.
 
I was checking on the wiki on how to do this but the example will not work in either case.
Here is what I am trying:
Code:
string combat_cleesh(int r, monster opp, string text) 
        {
            print(opp,"blue");
            print(r, "blue");
            print(text,"blue");
            if (opp == $monster[frog] || opp == $monster[newt] || opp == $monster[salamander]) return "attack";
            return "skill CLEESH";
        }
        adventure(1, $location[a maze of sewer tunnels], "combat_cleesh");
Here is what I get:
Code:
Encounter: C. H. U. M.
Strategy: attack with weapon
Macro override "combat_cleesh" returned void.
Round 3: mredge73 wins the fight!
You acquire an item: sewer nuggets
You gain 13 Beefiness
You gain 41 Mysteriousness
You gain 12 Sarcasm



Edit:
I think I fixed it, I am just not sure exactly what I did.
 
Last edited:
Back
Top