Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 36

Thread: Vlad's Familiar Changing Frankenscript

  1. #1
    Senior Member VladYvhuce's Avatar
    Join Date
    Feb 2016
    Location
    Kansas
    Posts
    179

    Cool Vlad's Familiar Changing Frankenscript

    I've finally figured it out! When set as a between battle script, this script will run through the listed familiars, farming their items in the priority of the listed familiars (5 turkey boozes, then 1 tales of spelunking, and so on), and then switch to the Intergnat, if you have enough adventures left over. If you run out of adventures before the list is through, you'll just have the familiar you were farming with equipped. Also: For whatever reason, once you stop adventuring, if your familiar was changed while adventuring, you will receive a minor error message "Your" [current familiar] "can't wear a" [the equipment the familiar you had when you started adventuring had]. I'm sure that there are ways to make the script more elegant. You can customize it to work with any set of familiars with droppable item limits, and replace "intergnat" with whatever familiar you want to use after farming. And I'm sure someone may be able to figure out how to get it to only farm a specific number of droppable items, if they want it to do that.
    Code:
    void main ()
        if (my_familiar() != $familiar[fist turkey] && $familiar[fist turkey].drops_today < $familiar[fist turkey].drops_limit) 
    		use_familiar($familiar[fist turkey]);
    	if (my_familiar() == $familiar[fist turkey] && $familiar[fist turkey].drops_today == $familiar[fist turkey].drops_limit) 
    		use_familiar($familiar[adventurous spelunker]);
    	if (my_familiar() == $familiar[adventurous spelunker] && $familiar[adventurous spelunker].drops_today == $familiar[adventurous spelunker].drops_limit) 
    		use_familiar($familiar[machine elf]);
    	if (my_familiar() == $familiar[machine elf] && $familiar[machine elf].drops_today == $familiar[machine elf].drops_limit) 
    		use_familiar($familiar[astral badger]);
    	if (my_familiar() == $familiar[astral badger] && $familiar[astral badger].drops_today == $familiar[astral badger].drops_limit) 
    		use_familiar($familiar[unconscious collective]);
    	if (my_familiar() == $familiar[unconscious collective] && $familiar[unconscious collective].drops_today == $familiar[unconscious collective].drops_limit) 
    		use_familiar($familiar[baby sandworm]);
    	if (my_familiar() == $familiar[baby sandworm] && $familiar[baby sandworm].drops_today == $familiar[baby sandworm].drops_limit) 
    		use_familiar($familiar[golden monkey]);
    	if (my_familiar() == $familiar[golden monkey] && $familiar[golden monkey].drops_today == $familiar[golden monkey].drops_limit) 
    		use_familiar($familiar[rogue program]);
    	if (my_familiar() == $familiar[rogue program] && $familiar[rogue program].drops_today == $familiar[rogue program].drops_limit) 
    		use_familiar($familiar[green pixie]);
    	if (my_familiar() == $familiar[green pixie] && $familiar[green pixie].drops_today == $familiar[green pixie].drops_limit) 
    		use_familiar($familiar[li'l xenomorph]);
    	if (my_familiar() == $familiar[li'l xenomorph] && $familiar[li'l xenomorph].drops_today == $familiar[li'l xenomorph].drops_limit) 
    		use_familiar($familiar[intergnat]);
    In KOL: VladYvhuce (#1798867)

  2. #2
    Senior Member Theraze's Avatar
    Join Date
    Mar 2010
    Posts
    8,652

    Default

    Alternatively:
    Code:
    familiar next_familiar() {
    	foreach f in $familiars[fist turkey, adventurous spelunker, machine elf, astral badger, unconscious collective, baby sandworm, golden monkey, rogue program, green pixie, li'l xenomorph]
    		if (have_familiar(f) && f.drops_today < f.drops_limit)
    			return f;
    	if (have_familiar($familiar[intergnat])) return $familiar[intergnat];
    	return my_familiar();
    }
    
    void main() {
    	next = next_familiar();
    	if (next != my_familiar()) use_familiar(next);
    }
    Last edited by Theraze; 05-14-2016 at 11:30 PM.

  3. #3
    Senior Member VladYvhuce's Avatar
    Join Date
    Feb 2016
    Location
    Kansas
    Posts
    179

    Default

    Well, that certainly looks more elegant. And it's got some more complex stuff than my previous attempts at simplifying it, which may have been why I kept running into weird glitches in those attempts. I'll give it a shot tonight.

  4. #4
    Senior Member Theraze's Avatar
    Join Date
    Mar 2010
    Posts
    8,652

    Default

    Well, the main problem (not a problem if it's on purpose) with your script is that it only changes if you never change your familiar manually. If your familiar is not exactly the prior familiar before the familiar drop changes, it won't swap. The only full-entry point in the script is when your fist turkey doesn't have drops done yet. After that's done, if you change familiars out of the chain, the script won't trigger anymore.

    If you wanted that feature though, to allow setting a non-drop, non-intergnat familiar (If you actually possess the intergnat. If you don't have an intergnat, it will leave you on whatever your current familiar is.), you'd need to write up a few changes to the script I made. Not difficult, just something to be aware of.

    It's good to practice though. It's something like 8 years of ASH scripting at this point and it's not as elegant as some of the more experienced writers would do. I'm just good at kludge. Sometimes elegant kludge, but utilitarian nonetheless.

  5. #5
    Senior Member VladYvhuce's Avatar
    Join Date
    Feb 2016
    Location
    Kansas
    Posts
    179

    Default

    Yeah... I kept running into problems when trying to get my previous versions to switch familiars, without doing a "let's just shuffle through the list until we satisfy the conditions" or a "let's just skip over everyone except the xenomorph" scenario... I dare say it's not a bad effort for someone with more like 8 days worth of ASH scripting knowledge, huh? The script will evolve as I learn new tricks and stuff.

  6. #6
    Senior Member Theraze's Avatar
    Join Date
    Mar 2010
    Posts
    8,652

    Default

    Yep! The easiest way to do what you want without too much scripting fanciness is simply to move the familiar selector into a different function, as I did. Then return the familiar type that you want, and as soon as that happens, it won't keep trying anymore, because the function will have returned your familiar.

    The single biggest problem with your original post, besides that it requires you to either switch to the fist turkey or not have farmed it up already, is that it does the server hit for changing familiars every time it runs through the list, even if the next familiar has already been farmed up fully. That means that if you don't remember if you accidentally switched away at some point and you manually swap it back to the fist turkey, it's 9 wasted hits to get back to the intergnat and figure out that you did really have all of your farming done already.

  7. #7
    Senior Member VladYvhuce's Avatar
    Join Date
    Feb 2016
    Location
    Kansas
    Posts
    179

    Default

    Speaking of which... the "next" variable from "next = next_familiar();" came up as undefined. I added "familiar" in front of it, so it now reads "familiar next = next_familiar();" and now it works smoothly. Was that the right thing to put in front of "next"? Or is that something that may foul things up again?

  8. #8
    Senior Member
    Join Date
    Sep 2006
    Posts
    324

    Default

    Yes, that will fix the problem. I'm an old school programmer who learned to always declare variables before they were used. That used to be required in older programming languages. Modern programming languages have relaxed this requirement in many cases and allow variables to be declared at first use. I cling to my old-fashioned ways and always declare my variables in a block at the beginning of a program or function, before any of the executable statements. I'm not sure what modern best practices would say about that, but it's served me well and makes it easier to see where and how things are defined, rather than having to poke around in the code to find them.
    Last edited by Ethelred; 05-16-2016 at 05:49 AM. Reason: Fix typos.

  9. #9
    Senior Member VladYvhuce's Avatar
    Join Date
    Feb 2016
    Location
    Kansas
    Posts
    179

    Default

    Cool.
    Nothing wrong with old-school style, so long as it works, in whatever one does. I grew up on a farm and learned that while new and flashy stuff may be prettier to look at, it may not stand up to abuse, and may be more of a pain in the butt to fix when it breaks down. I'm sure that to some extent, that applies to coding as well.

  10. #10
    Senior Member Theraze's Avatar
    Join Date
    Mar 2010
    Posts
    8,652

    Default

    Yep. I should have done it, but as I warned, never put the code through validation so that was all free-code.

    Defining variables is (almost) always a good idea.

Posting Permissions

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