Page 1 of 212 1 2 3 11 51 101 ... LastLast
Results 1 to 10 of 2112

Thread: BatBrain -- a central nervous system for consult scripts

  1. #1
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,490

    Lightbulb BatBrain -- a central nervous system for consult scripts

    BatBrain

    BatBrain (Battle Brain) -- part of my ongoing BatMan project -- is a function library for script authors who want to write a consult script. Years of work and lots of collaborative effort (from scripters, devs, Wiki scrapers, and lots of users) have gone into this and it is pretty much the awesomest ASH library script to come down the pike since ASH was a twinkle in Hola's eye.

    For Users

    Like ZLib (which BatBrain also requires), BatBrain is a function library for use by other scripts. Running this script will do basically nothing; don't even bother. However, without this script sitting somewhere in your mafia directory, other scripts which want to use these functions won't work. So that's all you have to do -- download it. You're done.

    For Scripters

    This script is designed to provide you a comprehensive picture of the combat environment, then give you easy-to-use tools to decide what to do with your available options. Using this library, your script will approach omniscience regarding your current battle. You can then predictively build your combat, finally submitting the entire thing as a macro when you're done.

    Server-friendly consult scripts with capabilities far exceeding both a normal CCS and a BALLS macro are now within even a mediocre ASH scripter's grasp.

    Any consult script that uses BatBrain must call act(pg) before doing anything else, or your combat environment will not be built correctly. Like so:

    PHP Code:
    import <BatBrain.ash>

    void main(int initroundmonster foestring pg) {
       
    act(pg);
      
    // now you can smack down the monster with BatBrain-powered gusto!

    Actually, I recommend importing SmartStasis instead -- then you'll have the power of both scripts at your disposal!

    If you'd like examples of BatBrain in use, I have attached a very simple sample script of just under 50 lines called, appropriately, SimpleSmack. This is the script I use for exactly everything, in order to run BatBrain through its paces. It takes advantage of BatBrain's queueing ability to attempt to build and then submit a full combat as a macro, with just a few custom actions and safeguards in place to preserve automation. Something much more involved, like WHAM, is also possible if you want further ideas.

    BatBrain documentation: click here or type "ashwiki batbrain" in your CLI.

    batfactors documentation: click here or type "ashwiki batfactors" in your CLI.

    Installation

    Type this in your CLI:
    Code:
    svn checkout https://svn.code.sf.net/p/batbrain/code
    Changelog
    Code:
    5.01.11 - Mayday! Mayday!  BatBrain version 1.0 posted.  Now that it's predictive in combat I figured it's finally ready for release.
    6.02.11 - 1.1 changes: lots.  Some highlights (because I don't remember them all): slightly reformatted advevents to include the number of rounds an event takes (and made some progress on integrating stats more), cleaned up some output, new functions kill_rounds() and die_rounds(), and automatic acquisition of stat-appropriate Juju Gazes.
    6.03.11 - 1.2 changes: reworked monster stuff a bit -- there's now a function m_event() which returns the entire monster event, including damage, self-heals, beaten up, and special moves.  Still needs some fleshing out but it's a marked improvement.  BatBrain now uses this in its predictions.  NSN and quiet healer never deal damage.  Some functions were altering opts[] -- change those to work on copies.  Predictive adjustment now works for multi-round events -- it factors in the base round and monster attack for each round.
    6.04.11 - 1.3 changes: consolidate round-building code in one place.  Don't include monster value in meat if the action wins the combat -- that's the job of an importing script.  Fix copying advevents -- use new (blank) advevents rather than the variable being initialized.
    6.14.11 - 1.4 changes: fix divide by zero error.  Consolidate success chance code for all actions into hitchance(), and factor all actions by their success chance when adding to opts[].  Use proper critical hit chance (with modifiers) to calculate both hitchance and damage.  Use 11 rather than 10.5 for hit chance based on info on KoLspading.  Change low-HP aborts in macros to be recalculated each round, and skip if the monster is stunned -- and allow autoAbortThreshold to determine the abort cutoff if it's set higher than the monster's damage.
    6.14.11 - 1.5 changes: hard on the heels of 1.4, more stuff revamped thanks to this attentive community and me actually having a few free hours at work.  Rework the way rounds are added to events -- an advevent now takes 0 rounds unless the round number is specified.  This fixes the issue where Bander augmentation made an action take 2 rounds, and allows me to remove a lot of rounds = 0 statements.  Fix the way fumbles and crits are used in hitchance.  Include blocking for skills/attack.  Black Cat means pickpocket should never consider items at 100%.  Allow enqueueing (yes, definitely sexy) up to maxround.
    6.19.11 - 1.6 changes: hitchance for more skills, fumbles only apply to attacks, one more little fix to hitchance formula.  Hardcode damage for Clobber.  Remove stat == ML checks for determining unknown stats.  Account for Spiciness; it doesn't count for non-sauce skills.  Fix resistance for booty crab.  Account for Clockwork Apparatus transforming fumbles into awesome.  Bee thoven is multistun-immune.  n Bottles of Beer on a Golem blocks spells.
    6.21.11 - Happy summer to those of you in the Northern Hemisphere!  1.7 changes: don't factor skill cost by hitchance.  Don't name the fumble event since it interferes with the attack event.
    7.02.11 - Happy in between Canada Day and American Independence Day!  1.8 changes: fix a bounds issue in hitchance.  Fix a bounds issue in Harpoon! formula.  Expand my_stat() to include all stats, sensitive to speculation using "whatif".  Using the previous feature, only remove dangerous poisons.  Tracking for once-per-combat issues is now saved in an external map, to give BatBrain-powered relay scripts accurate information.  During enqueueing, precede deleveling skills with Mistletoe if you haven't used that yet this combat.  More efficient parsing of events using a matcher rather than a bunch of stringslinging.  Added the critical event to regular attacks.  Items granting special results for a critical hit mostly added to batfactors.
    7.08.11 - 1.9 changes: Include deleveling in to_profit().  When selecting stasis action, consider all actions that will never kill the monster equal in terms of damage.  Ranged smacks are impossible.  Mistletoe precedes only appropriate skills, and only if you have MP enough (predictively) for both. Automatically add "hascombatitem" and "hasskill" conditions to all repeat-enqueued actions.  Buzzerker is multistun-immune.  eval() substats rather than to_int()ing them.
    9.06.11 - 1.10 changes: it's been a while, so it's hard to say what all was changed. Fixed stasis item selection sort.  Allow pipe-delimited lists of monsters in "monster" and "notmonster" tags.  Support for Fist skills, including Master's passive augmentation of unarmed attack.  Filter all melee skills when wielding a ranged weapon.  Where appropriate, consider your effective familiar in the event you're using a Doppelshifter or costume wardrobe.  Miscellaneous other improvements.
    9.22.11 - 1.11 changes: Use mafia's Unarmed modifier for Fist detection, also check fistSkillsKnown rather than my_path().  Don't keep considering skills if you acquire Amnesia mid-combat.
    11.30.11 - 1.12 changes: Improvements galore! Revert erroneous unarmed checks -- instead, add a simple little unarmed() function.  Add a "once" keyword to batfactors -- any action flagged with "once" will only be available -- you guessed it -- once.  Rework happenings -- now all actions that are enqueued officially "happen" and use canonical action names.  Enqueueing also triggers an options rebuild, since some actions may be unavailable or different after the first use.  Fix hitchance for moxman.  Resistance for nemesis demons appears to be 40% across the board.  Fancypants Scarecrow support.  Naughty shuriken support.  Chilled Monkey Brain support.  Feed support.  New attack_action() function which returns a decent option for killing the monster.  Quiet healer does have an attack.  Stickler for Promptness support.  Monster meat drops are capped at 12 in Fistcore, before bonuses.  All items are worth no less than 50 meat, to avoid thinking nontradeables such as paperclip sproingers are free.  In kill_rounds(), but not monster_stat(), assume the pessimistic side of monsters' 5% HP variance, capped at +5.  Convert page into a global variable containing the most recent page load -- removed as a parameter for most functions.
    12.2.11 - 1.14 changes: Fix for detecting unknown bang potions/spheres.  Fix for Knee hitchance.
    12.6.11 - 1.15 changes: Fix round detection on multi-round pages.  Complete the happenings revamp -- BB now records all actions and the number of times they have happened this fight.  Resetting the queue will wipe enqueued happenings which have not yet happened.  Add deleveling doubling for Mistletoe.  Now that dangerpoisons uses the rather expensive attack_action(), significantly speed things up by building the list of dangerous poisons only once at the beginning of combat.
    1.15.12 - 1.16 changes: Reformatted BB -- you can now initialize BB to a specific monster using the set_monster() command, thus making BB useful speculatively outside of combat.  If you don't initialize BB it will initialize to last_monster() automatically in act().  Safer, better attack action selection.  Don't erroneously factor monster special moves by monster hit chance.  Speed: cache base round and monster events per round.  Detect combat completion in act() and don't continue with options rebuild and responses.
    3.12.12 - 1.17 changes: New format for batfactors, allowing for greater accuracy in spreads.  HP is now handled as player damage and is a spread.  Better support for some Boris skills (still doesn't know about hitchance though).
    3.14.12 - 1.18 changes: Fixed player damage having a minimum of 1, even for 0-pdmg actions.  Improved Boris support for Cleave and Song of Fortune's auto-crit.  Normalize "perfect" damage type.
    3.31.12 - 1.19 changes: Added Black Cat and O.A.F. item/skill blocking/replacement.  Rework enqueue() and macro() commands to keep macro information out of the queue.  Implement auto-funk when enqueueing two consecutive item throws!  Support for Sick Pythons, Bifurcating Blow, clumsiness bark, and orange agent. Speed: cache profit of advevents to make to_profit() much less expensive, and refactor detections/responses in both act() and batround() to use a faster and more accurate switch statement.  Track base pairs thrown at Cyrus using BB's happenings detection rather than the previous error-prone method in SS.  Only return 50 for items with no accessible value.  Fix combat completion detection for monsters with no Adventure Again link.  Significantly improve the sort in attack_action().  Holy crap this was a big update.
    4.01.12 - 1.20 changes: Fix a devious little bug which allowed empty macros to be submitted.
    4.14.12 - 1.21 changes: Refine the refinement to attack_action().  Continue to cache profit in the profit field of advevents, but always recalculate in to_profit(). Fix damage calculations for "regular" attacks.  Fix auto-funk, and avoid performing it when you don't need the combat to be faster.
    4.19.12 - 1.22 changes: Add an important line back in which was unintentionally removed previously.  When detecting happenings on the final page of combat, my_turncount() has already advanced, so set the occurrence to turncount - 1.
    4.29.12 - 1.23 changes: Fix inconsistencies in happenings tracking for relay play vs. automated play.  Fix kill_rounds() erroneously having a minimum of 2.  Don't add fumbles to melee attack skills.  Don't allow enqueueing of more items than you have.  Song of Battle grants 100% hitchance.  Cache action type functions in global variables smack, plink, and buytime.  Considerably improve the stun_action() sort.  Use recent effect() function in formulas to eliminate several fvars and checks.  Include material component cost for skills.  Be completely pessimistic about monster HP variance throughout.  Speed improvement: only consider m.poison, not all possible poison effects.  Despite appearing in the menu, Mighty Axing is not available with Trusty unequipped.
    7.12.12 - 1.24 changes: Hopefully final combat completion detection method -- not fooled by CAB or Bugged Bugbear.  Improved support for: Boshing Smack Slap, OPS, enchanted fire extinguisher, PADL phones, communications windchimes, double-ice shards, Mighty Axing, Cleave. Record compound happenings individually.  Properly account for MP/HP regen for both gain and loss.  Hold back possibly needed tower items in all known locations.  Ignore deleveling profit when your attack will one-shot the monster.  Improve DB action detection for Mistletoe insertion.  Don't include empty batrounds in the macro.
    8.10.12 - 1.25 changes: Don't use a reserved word for a variable name.  Don't throw goal items.
    11.05.12 - 1.26 changes: Two MP updates for Zombiecore: 1) ignore all MP loss other than skill costs, and 2) ignore all MP gain not from infecting zombies (only 2.5 skills can do this).  Add ongoing infection damage to base event for Infectious Bite.  QWOPped Up grants Clumsy.  Skeletal scabbard doubles damage from swords.  Support for Bear Hug, Grizzly Scene, Ravenous Pounce, Howl of the Alpha thanks to Winterbay.  Misses are now glancing blows.  Also, don't factor fumbles and crits by hitchance.  Move declarations outside foreach loop for greater efficiency.
    11.23.12 - 1.27 changes: Mafia monster name changes.  In Zombiecore my_maxmp() may be 0, so don't divide by that. Fix Pop and Lock It matcher. Restore BatBrain's knowledge of equipment and effects to its former glory.
    12.01.12 - 1.28 changes: Support for Jalapeño and Jabañero Saucespheres, new physically resistant monsters, and Raging Animal.  Differentiate monster attack/defense elements for determining monster attack/resistances.
    1.03.12 - 1.29 changes: If player has Manuel, use his supplied stats without any adjustments for unknown_ml or HP variance.  When simulating a round, cap gains to HP/MP from player actions before applying the monster event.  Moxious Maneuver uses moxie for damage.
    1.18.13 - 1.30 changes: Unknown monster stats are now -1.  Properly remove items for Mother Slime and Chester.  Properly filter skills based on page text.  Ignore mafia's "Found in this fight" message when parsing items.  SC Nemesis fixes: Track seal pup wailing with happened("sealwail").  Smacks work with the Sledgehammer.  Remove all non-weapon sources of damage from options when facing mother hellseals.
    1.27.13 - 1.31 changes: Add special attacks for elemental hobos and frustrating knight.  Don't ignore elemental damage in die_rounds().
    1.31.13 - 1.31.1 changes: Complete monster attack as a spread fix and the final death of the longstanding Salve/Bandages bug.  Only include double-ice cap retaliation event if it hasn't happened.
    4.1.13 - /\/\^v^/\/\ changes: multifarious!  Described here.
    5.1.13 - ~(^._.^) changes: Fix elemental form bug, more to_event() refactoring.  Integrate endscombat in several more places.
    5.8.13 - 1.35 changes: Names of phyla have changed.  Reset spell damage before compensating for Spiciness.  Allow enqueueing up to 3 rounds beyond end of combat.
    5.29.13 - 1.36 changes: Multifarious again!
    6.02.13 - 1.37 changes: BRICKO reactors only do huge damage to BRICKO monsters.  Faster, better skills filtering regardless of browser-added quotation marks. More yellow-ray delay tweaking.
    6.07.13 - 1.38 changes: Don't count Master of the Surprising Fist twice.  Add fvar wpnpower support for Silent skills.  Fix endless loop with Juju mask equipped.
    6.19.13 - 1.39 changes: BatBrain is on SourceForge!  Read about the changes to this version at the link below.
    Changes beyond this point are listed on BatBrain's SourceForge changelog; however, I will continue to post more in-depth update notes in this thread.
    Attached Files
    Last edited by zarqon; 10-04-2017 at 05:56 PM.
    Sig by JakAtk
    My scripts: Prefref Plus | One-Click Wossname | Om******t (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mer********d (?!) | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | CanAdv | Script Registry | Map Manager | About Bats
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

  2. #2
    Senior Member Winterbay's Avatar
    Join Date
    Feb 2010
    Posts
    5,033

    Default

    Note from Minion, Bale: Originally, this thread was split from another discussion just after BatBrain was first written. This post does not discuss BatBrain, but it forms the basis for the discussion that follows. Consequently this post was retained both here (and there) after the threads were split. At the time BatBrain was posted in the SmartStasis thread.

    I've poked around a bit in my version of this and made it cast spells if you are a myst class. It generates a macro of up to 7 spells (entangling noodles, 5 dynamically generated spells followed by spaghetti spear or salsaballs depending on class) and executes that. It also makes sure that you have enough MP when you start casting for the planned spells. It does not take advantage of sauce synergy and the handling of elemental spell bonuses could be better, but since unless you tune your spells they are randomly choosen it's a bit more work than I have time for atm to fix.
    Last edited by Bale; 05-02-2011 at 10:51 PM. Reason: split thread.
    My scripts:
    Best sushi for Profit
    Winterbay's Helpful Automatic Monsterbasher (WHAM)

    Scripts maintained by me:
    Autobasement
    Smashlib

    A small programmer joke:
    Wife: Honey, please go to the market and buy 1 bottle of milk. If they have eggs, bring 6.
    The man came back with 6 bottles of milk.
    Wife: Why did you buy 6 bottles of milk.
    Man: Because they had eggs...

    The 6 Stages of Debugging: 1 )That can't happen. 2) That shouldn't happen. 3) Hmmm, weird. 4) Why does that happen? 5) Oh, I see. 6 )How did that ever work?

    All programs can be optimized, and all programs have bugs; therefore all programs can be optimized to one line that doesn’t work. /Bob Fitch, Blizzard

  3. #3
    Senior Member Theraze's Avatar
    Join Date
    Mar 2010
    Posts
    8,735

    Default

    Looks like BatBrain has a function, regular, that could return how much damage a regular hit will do and could be used to decide if that's enough/better as a myst class... regular(1) should return the value of regular hits...

    Edit: Winterbay said this:
    It only uses spells for mystclasses, for everyone else it just attacks just like the original spamattack. It currently attacks if I can kill the monster in 10 rounds, and it cannot kill me in the same amount of rounds even if you're a myst class. No need to waste MP when you are backfarming.
    Originally Posted by Winterbay View Post
    However, looking at the download, I don't see myst classes ever using attack.

  4. #4
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,490

    Default

    Do it! Import BatBrain!

    Quite a few BatBrain functions are useful here -- your first command in main() should be page = act(page); then your action list will be built and the current round will be detected and saved to the global variable round.

    All combat actions are a BatBrain record type called advevents, but there are enough functions that you shouldn't need to deal much with those directly.

    get_action(skill) returns a skill action from your options list.

    get_action("attack") returns your regular weapon attack. You can also use "jiggle" to get your chefstaff action in the event you want to use that.

    There's also a get_action(item), but I think that's outside the scope of your script here. For all forms of get_action(), if you don't have the action available, get_action(whatever).id will be an empty string.

    get_action(whatever).dmg returns a spread of how much raw damage it will do, tuned by any cookbooks or skills in effect.

    dmg_dealt(get_action(whatever).dmg) will return a float of the actual damage dealt to the monster, after accounting for resistances, vulnerabilities, and Bander augmentation.

    macro(get_action(whatever),"") will build and execute a macro that spams the skill -- but with all the appropriate autoresponses built in. Presently there is no detection for running out of MP, however the string parameter is the repeat condition, so you could easily build your own macro to spam an action X times. You can also call macro(advevent) without the second parameter to perform the action only one time.

    Anytime you call macro(), that also includes a call to act(), so your available action list will be rebuilt.

    m_dpr(0,0) returns a float -- the average amount of damage the monster will do to you per round, accounting for player resistances. The two parameters are monster attack adjustment and stun adjustment, respectively. For this situation using 0's ought to be fine.

    Assuming no stunning or deleveling, the monster will kill the player in ceil(my_hp() / m_dpr(0,0)) rounds.

    A variable named maxround is also available. It is usually 30, but will be 50 for the appropriate monsters. If the above number of rounds until player death > maxround, the monster can't kill you. If ceil(monster_stat("hp") / dmg_dealt(get_action("attack").dmg)) < maxround, your regular attack can kill the monster before combat ends.

    Also, rather than using ASH's monster_hp(), monster_attack(), and monster_defense(), I recommend using BatBrain's wrapper function monster_stat(string). The string supplied should be either "att", "def", or "hp". This allows your script to respond appropriately to monsters of unknown ML.

    Have fun!
    Sig by JakAtk
    My scripts: Prefref Plus | One-Click Wossname | Om******t (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mer********d (?!) | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | CanAdv | Script Registry | Map Manager | About Bats
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

  5. #5
    Senior Member Winterbay's Avatar
    Join Date
    Feb 2010
    Posts
    5,033

    Default

    I could do that I guess, but then I would, as part of how I work, have to understsnd BatBrain and last time I tried to do that my head almsot exploded. I find the code way too obfuscated for my level of programing and as such hard to read, and I like to understand what I do when writing code. It took me several tries of tiral and error before I finally managed to figure our how to build my darn map of skills and damages (I tried a lot of a lot more complex versions first because I didn't think of the current, almost obvious, one...).

    And the script is in no way meant to be optimal, it just tries to build the most cost-efficient way to kill the current monster with your available spells in order to not make me think so much when trying to decide what to cast
    My scripts:
    Best sushi for Profit
    Winterbay's Helpful Automatic Monsterbasher (WHAM)

    Scripts maintained by me:
    Autobasement
    Smashlib

    A small programmer joke:
    Wife: Honey, please go to the market and buy 1 bottle of milk. If they have eggs, bring 6.
    The man came back with 6 bottles of milk.
    Wife: Why did you buy 6 bottles of milk.
    Man: Because they had eggs...

    The 6 Stages of Debugging: 1 )That can't happen. 2) That shouldn't happen. 3) Hmmm, weird. 4) Why does that happen? 5) Oh, I see. 6 )How did that ever work?

    All programs can be optimized, and all programs have bugs; therefore all programs can be optimized to one line that doesn’t work. /Bob Fitch, Blizzard

  6. #6
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,271

    Default

    I've just started to review BatBrain and it is a thing of beauty. I won't claim to understand most of it yet, but it is kinda fun trying to figure it out. Unlike Winterbay, this does not make my head explode. dj_d's scripting makes my head explode, but this makes my head feel like it is full of bees. Happy bees.

    BTW, zarqon I noticed an error on line 279 which could hurt people who are not using UR. That is no longer how seltzer is accessed. Now you need to check dispensary_available() since you can sell off the outfit and still access the dispensary.
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


  7. #7
    Senior Member Winterbay's Avatar
    Join Date
    Feb 2010
    Posts
    5,033

    Default

    I've managed to sort through farm.ash which is the only of dj_d's scripts that I'm really poking around in and now have a fairly good idea of how it works. Good enough to be able to add features and change the normal behaviour even though the setup options atthe top still baffles the hell out of me. Eatdrink is a mess of gartantuan proportions so I only use that as part of farm, and that's about it.

    I tried adding poison removal to SmartishStasis/BatBrain a while back (before zarqon fixed that bug) and it failed miserably because I couldn't figure out anything of what the script was doing well enough to get it to do what i wanted it to.
    My scripts:
    Best sushi for Profit
    Winterbay's Helpful Automatic Monsterbasher (WHAM)

    Scripts maintained by me:
    Autobasement
    Smashlib

    A small programmer joke:
    Wife: Honey, please go to the market and buy 1 bottle of milk. If they have eggs, bring 6.
    The man came back with 6 bottles of milk.
    Wife: Why did you buy 6 bottles of milk.
    Man: Because they had eggs...

    The 6 Stages of Debugging: 1 )That can't happen. 2) That shouldn't happen. 3) Hmmm, weird. 4) Why does that happen? 5) Oh, I see. 6 )How did that ever work?

    All programs can be optimized, and all programs have bugs; therefore all programs can be optimized to one line that doesn’t work. /Bob Fitch, Blizzard

  8. #8
    Senior Member zarqon's Avatar
    Join Date
    Nov 2007
    Location
    Seoul, Korea
    Posts
    3,490

    Default

    @Winterbay: But... that's why I just explained it. You can ignore the rest -- just use the functions I mentioned as though they exist in ASH. That's the point of a library -- you don't need to understand the inner workings.

    @Bale: thanks again! I'll fix that dispensary_available issue in the next update, when I swap potions/spheres back into the data file.
    Sig by JakAtk
    My scripts: Prefref Plus | One-Click Wossname | Om******t (??) | Psychose-a-Matic | RandBot
    Combat suite: Best Between Battle | Mer********d (?!) | SmartStasis | BatMan | BatMan RE
    For script authors: ASH Wiki | ZLib | BatBrain | CLI Links | CanAdv | Script Registry | Map Manager | About Bats
    If you appreciate my work, help me become BAT KING OF THE WORLD! Thanks to all donators!

  9. #9
    Senior Member Winterbay's Avatar
    Join Date
    Feb 2010
    Posts
    5,033

    Default

    @Winterbay: But... that's why I just explained it. You can ignore the rest -- just use the functions I mentioned as though they exist in ASH. That's the point of a library -- you don't need to understand the inner workings.
    Originally Posted by zarqon View Post
    Yes, I know. But I've only just started including zlib in anything I've done because well, I want to understand what the function I use does
    I may take a look at the monster_stat()-function though since my workaround may fail with unkown monsters as you say. But I've probably wasted enough work time getting this version together to start doing that now, I should probaby do some work as well
    My scripts:
    Best sushi for Profit
    Winterbay's Helpful Automatic Monsterbasher (WHAM)

    Scripts maintained by me:
    Autobasement
    Smashlib

    A small programmer joke:
    Wife: Honey, please go to the market and buy 1 bottle of milk. If they have eggs, bring 6.
    The man came back with 6 bottles of milk.
    Wife: Why did you buy 6 bottles of milk.
    Man: Because they had eggs...

    The 6 Stages of Debugging: 1 )That can't happen. 2) That shouldn't happen. 3) Hmmm, weird. 4) Why does that happen? 5) Oh, I see. 6 )How did that ever work?

    All programs can be optimized, and all programs have bugs; therefore all programs can be optimized to one line that doesn’t work. /Bob Fitch, Blizzard

  10. #10
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,271

    Default

    Winterbay: To help me work out BatBrain I decided to rewrite a simpler introduction to BatBrain than zarqon's post above. As he said, everything runs on advevents - adventure events. You do need to know a little bit about them. First of all, you need to turn any action into an adventure event.

    get_action(skill) - converts a skill into an advevent.
    get_action("attack") - your regular weapon attack.
    get_action("jiggle") -your chefstaff action.
    get_action(item) - creates an advevent for item use.
    Think of get_action() as a to_advevent() function. Now for the only thing you really need to know about them:

    advevent.dmg is the damage spread for the action. This is a map of average damage mapped by element: typedef float[element] spread; To turn this into the damage being dealt by a given action is this AMAZING function:

    dmg_dealt(get_action(whatever).dmg) - will return a float of the actual damage dealt to the monster, after accounting for resistances, vulnerabilities, and Bander augmentation.
    In other words, you can tell how much damage Weapon of the Pastalord will do to your current target accounting for flavor, half physical damage and monster element this easily!

    PHP Code:
    print("Weapon of the Pastalord will do: "
         
    dmg_dealt(get_action($skill[Weapon of the Pastalord]).dmg)
         + 
    " damage to this "last_monster() +"."); 
    After you've used that wonderful damage information to determine what actions to use, you can build and submit the macro with this:

    macro(get_action("attack"), "") - the second parameter tells it how many times to repeat the action. "0" is only once and "" is forever.
    This builds in antidote use, gremlin tool gathering, whipping turtles when you're taming them to beat your nemesis, learning rave combos, yellow ray usage and other awesomeness. It's off the chart how much great stuff is built in based on your current situation.

    Right now you're thinking that you still cannot make a more complicated macro that uses two different spells, but zarqon actually has support for that. Here's how to submit a macro that uses Stringozzi Serpent followed by Weapon of the Pastalord.

    PHP Code:
    queue.clear();
    queue[count(queue)] = get_action($skill[Stringozzi Serpent]);
    queue[count(queue)] = get_action($skill[Weapon of the Pastalord]);
    macro() 
    It's just that simple. The only weakness I can see is that there's no way to add a repeat on the end of that macro or wrap it in a loop.

    =====================
    zarqon, correct me if I'm wrong. But it might be nice to have something like this, so that sauce splashing could be looped...


    PHP Code:
    string macro(string firststring last) {   // executes the advevent[int] variable named queue
       
    buffer m;
       
    m.append(batround());
       if(
    first != ""m.append(first+"; ");
       foreach 
    i,o in queue m.append(o.id+"; call batround; ");
       if (
    have_skill($skill[funkslinging])) {  // compact any consecutive item throws if you can funksling
          
    matcher funky create_matcher("(use \\d+); call batround; use (\\d+;)",m);
          while (
    funky.find()) m.replace_string(funky.group(0),funky.group(1)+","+funky.group(2));
       }
       
    vprint("Executing macro: "+m,9);
       if(
    last != ""m.append(last+"; ");
       return 
    macro(to_string(m));
    }
    string macro() { return macro(""""); } 
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


Similar Threads

  1. Feature - Implemented random_attributes not being passed to consult scripts
    By DoctorRotelle in forum Bug Reports
    Replies: 7
    Last Post: 05-25-2015, 05:38 AM
  2. Replies: 25
    Last Post: 04-05-2015, 08:20 PM
  3. Feature - Implemented Duplicate scripts cause "not found" error for consult scripts
    By nightslide in forum Bug Reports
    Replies: 6
    Last Post: 06-10-2013, 08:07 PM
  4. Multiple consult scripts?
    By fxer in forum Scripting Discussion
    Replies: 2
    Last Post: 03-04-2013, 08:43 PM
  5. Passing variables to consult scripts from the ccs
    By Captain Kirk in forum Custom Combat Settings
    Replies: 0
    Last Post: 08-17-2008, 06:53 AM

Posting Permissions

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