Results 1 to 9 of 9

Thread: Way to access Encounter Listing in script?

  1. #1

    Default Way to access Encounter Listing in script?

    I'd like to make use of the apparently stored data of how many X monster I've fought that day, but I've failed find any info on that from my searching around. Anyone know a way to access this?

    I guess I could implement a hackneyed custom solution, but I'd rather not have to.

  2. #2
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    358

    Default

    This might work... Mind you, I haven't tested it

    PHP Code:
    int count;

        if (
    get_property("lastEncounter")=="monster")
    count count +1
    if my_adventures() == 0
    print ("I've encountered " count " monsters that I'm tracking today"); 
    I believe something along those lines would work.

    You can probably do it for multiple monsters too.

    PHP Code:
    int counta;
    int countb;
    int countc;

        if (
    get_property("lastEncounter")=="monster a"
    counta counta 1
        
    if (get_property("lastEncounter")=="monster b"
    countb countb 1
        
    if (get_property("lastEncounter")=="monster c"
    countc countc 1
    if my_adventures() == 0
    print("I've encountered " counta " monster a, " countb " monster b, " countc " monster c today"); 
    This would have to be a between battle script to look at the previous adventure.

  3. #3

    Default

    Yeah, that would be the aforementioned hackneyed custom solution

    I might instead implement those as kolmafia properties so it persists even if you close the client, but otherwise thanks for basically doing it for me, haha.

    Although now that I think of it, I'm not sure how I would detect that they've been defeated or not, which is relevant to my intent...haven't searched it up yet, tho.

    Also in retrospect that might not work with clingy monsters, since I'm not sure if between battle scripts run between multi-stage fights.
    Last edited by Malurth; 05-16-2018 at 07:15 PM.

  4. #4

    Default

    There's nothing built in to give access to that.

  5. #5
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    806

    Default

    I would think the best way of doing what you want is by parsing the session_logs().
    You can then find the encounters, determine if they have been defeated, and you could record free and/or multi-stage fights.
    I will leave the how as an exercise for the reader.

  6. #6

    Default

    Aight, thanks folks. I appreciate the help.

  7. #7
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    358

    Default

    I would think the best way of doing what you want is by parsing the session_logs().
    You can then find the encounters, determine if they have been defeated, and you could record free and/or multi-stage fights.
    I will leave the how as an exercise for the reader.
    Originally Posted by ckb View Post
    HA! I already have a script that does most of this. lol

    I never did figure out how to know if you've defeated a monster though
    Scripts I have written:
    Unlock Dread A Script to save you a bunch of clicks.
    Standard Rollover Bonus A Script that shows best items to pull/equip for bonus turns.
    Standard PVP Bonus A Script that shows the best items to pull/equip for bonus PVP Fights.
    Rollover Management A Script that does all the daily deeds you might have forgotten, or might have missed.
    Chatbot A Chatbot script. Simple start for those who want/need one for their clan.
    Zap Wand A Dungeon of Doom ZAP WAND getting script.

  8. #8

    Default

    Well, I found this code snippet in another thread, from user "darkcodelagsniper":

    Code:
    string LastAdvTxt() {
    	string lastlog = session_logs(1)[0];
    	int nowmark = max(last_index_of(lastlog,"["+my_turncount()+"]"),last_index_of(lastlog,"["+(my_turncount()+1)+"]"));
    	return substring(lastlog,nowmark);
    }
    One would imagine you could just do contains_text(LastAdvTxt(), "You win the fight!") to find out, assuming that code snippet works as advertised. Haven't tried it yet tho.

    Edit: well it's " wins the fight!" in the logs so that instead. And you also have to account for it just being the last encounter, since there can be multiple within that snippet.
    Last edited by Malurth; 05-18-2018 at 01:02 AM.

  9. #9

    Default

    Dang, clingy monsters are still a pain since both pre-adv and post-adv scripts won't run between stages in multi-stage fights, and you'd have to peek potentially the whole log since they can chain, and also have to avoid double-counting the same clingy monsters. I've yet to think of a not-ridiculous way of doing this in an afterAdventureScript/betweenBattleScript.

    Also I'm pretty sure 1337 monsters are going to screw things up too, though I haven't encountered one during testing yet. Really wish mafia would just expose the Encounter Listing for scripting purposes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •