PDA

View Full Version : kludged-together combat consult script



kain
05-13-2009, 03:13 PM
--disclaimer-- I wrote very little of the original code for this --disclaimer--

So I've been using FTF and SmartStasis for a while now. But I've got multiple chars who have different equipment and skill sets and it's been bothersome to try and modify their individual ccs settings on the fly as needed.

So I've adapted a combat consult script that I've had for a long long time called casualcombat.ash. I can't for the life of me remember who wrote it, nor can I find any reference to it on the forums. If this is yours, thanks, and speak up!

It's not all-encompassing, nor does it work 100% right all the time (sometimes it hangs at the end of combat). I haven't tested the plink portion, either.

It prefers to shieldbutt, followed by LTS if you're a seal clubber, else it throws some spells or attacks if you're able to hit the monster. Obviously, if you don't have the skills referenced by the script and can't hit automatically, it's not going to work for you.

But it works "well enough" for me right now. I'm putting it up in the hopes that it can be improved upon, tweaked and polished. Or so that someone with a far more-better script will laugh heartily at me (and share)

It's designed to work (IE, I tried to remove all the duplicate functionality) with FTF/SS so it's not going to noodle or anything like that.

My CCS looks like so:
[ default ]
1: consult smartstasis.ash
2: consult casualcombat.ash

mredge73
09-23-2009, 04:34 PM
are you still working on this script?

I attached a few edits, not much but it has fixed a few problems that I have encountered

halfvoid
09-24-2009, 07:05 PM
Oh, this makes me very happy.

mredge73
09-24-2009, 07:58 PM
it really really needs a rewrite,

I could make an attempt but I would need the community support since not everyone plays like I do since my main strategy for everything is to attack with weapon unless I am a myst class. A combat script ccs would be a good project for the entire scripting community to get involved in. Kain did a good job collecting from many different scripts and putting them in one but it is definitly kludged-together.

Bale
09-24-2009, 08:51 PM
Looking at it now. My first project: Make the formatting consistent and improve clarity so that I can work with it.

Bale
09-24-2009, 09:13 PM
My first improvement: second_plinkitem didn't always work. Fixed it:


item second_plinkitem(monster opponent, item firstplink) {
boolean check_second(item it) {
return (item_amount(it) - to_int(firstplink == it) > 0);
}

switch {
case check_second($item[Miniborg Destroy-O-Bot]):
return $item[Miniborg Destroy-O-Bot];
case check_second($item[toy merc]):
return $item[toy merc];
case check_second($item[spectre scepter]):
return $item[spectre scepter];
case check_second($item[spices]):
return $item[spices];
case check_second($item[seal tooth]):
return $item[seal tooth];
case check_second($item[turtle totem]):
return $item[turtle totem];
}
return $item[none];
}

Attached my local version of casualcombat.ash below. This mostly includes a number of legibility changes.

halfvoid
09-24-2009, 10:24 PM
while using this in a softcore run it became apparent that i could have just been attacking with my weapon and still would have one hit killed most of the enemies i was fighting.

it became apparent as my meat was rapidly disappearing to refill my MP.

is there a way to put that "fallback strategy" in the beginning to avoid the waste of MP on skills that don't need to be used?

halfvoid
09-24-2009, 10:28 PM
oh. after looking at the script its allready in there unless you added it bale.

its around lines 321 - 332.

Bale
09-24-2009, 10:59 PM
Turned 4 clunky functions into 2 tidy functions


item unknown_sphere() {
string [item] sphere_list;
sphere_list[$item[mossy stone sphere]] = "lastStoneSphere2174";
sphere_list[$item[smooth stone sphere]] = "lastStoneSphere2175";
sphere_list[$item[cracked stone sphere]] = "lastStoneSphere2176";
sphere_list[$item[rough stone sphere]] = "lastStoneSphere2177";
foreach sphere, prop in sphere_list
if(get_property(prop) == "" && item_amount(sphere) > 0)
return sphere;
return $item[none];
}

// Returns an unknown bang potion to identify if you have an extra
item unknown_bang_potion() {
string [item] bang_list;
for i from 819 to 827
bang_list[to_item(i)] = "lastBangPotion" + to_string(i);
foreach potion, prop in bang_list
if(get_property(prop) == "" && item_amount(potion) > 1)
return potion;
return $item[none];
}

Bale
09-25-2009, 02:53 AM
Made some more fixes to better support funkslinging with potion identification.

This script sucks. combat() need a serious rewrite. It needs to be pulled apart and rebuilt. I'm not up for that yet...

Edit: Attachment is removed because it won't work. Bug is fixed in my next post.

halfvoid
09-25-2009, 07:43 AM
This occurred with a sauceror without funkslinging. I'm guessing it was trying to toss two items or something.


[68] Giant's Castle
Encounter: Goth Giant
Strategy: C:\Documents and Settings\halfvoid\My Documents\kolmafia\ccs\default.ccs [default]
Round 0: vaelith wins initiative!
Round 1: vaelith casts SAUCY SALVE!
You gain 15 hit points
Casual Combat, revamped.
opponent : Goth Giant
monster att/def : 141/141
Array index out of bounds (casualcombat.ash, line 109)
You're on your own, partner.

Bale
09-25-2009, 08:00 AM
Stupid error. Try this.

halfvoid
09-25-2009, 08:05 AM
Works peachy keen. Thanks Bale!

kain
09-25-2009, 01:48 PM
Oh wow.

I haven't been working on this at all recently. Yes, the layout, etc sucks (it's still mostly formatted from the original script writer) and it is/was a bit buggy.

Pretty much my only contribution was to make it work at the time. (not well, just work period)

Bale
09-25-2009, 04:28 PM
I agree with mredge73 that it might be fun for the community here to work on this together, contributing what they can. I'm going to try working with it from time to time, but the real problem is the main function. That needs to be completely pulled apart and have some of it's parts put into other functions for the sake of comprehension and rewritability.

halfvoid
09-25-2009, 09:12 PM
i'm of no use with maps. i've tryed looking through it to see what i'd change and all i can really think of is adding more skills to the big bad section, or making a regular attack more of a priority to use to save MP in ronin.

Rinn
09-25-2009, 11:54 PM
Here's the basics to add support for spring raindrop attack, I have mine in a completely different script that occurs in my css after ftf but before I start killing things, but the concept is the same:



string use_spring_raindrop_attack(string url)
{
if (my_mp() == my_maxmp())
return url;

if (equipped_item($slot[weapon]) == $item[haiku katana] && url.contains_text(">Spring Raindrop Attack"))
{
url = use_skill($skill[Spring Raindrop Attack]);

if (my_mp() == my_maxmp())
return url;
}

if (url.contains_text(">Consume Burrowgrub"))
{
url = use_skill($skill[Consume Burrowgrub]);

if (my_mp() == my_maxmp())
return url;
}

if (equipped_item($slot[off-hand]) == $item[haiku katana] && url.contains_text(">Spring Raindrop Attack"))
url = use_skill($skill[Spring Raindrop Attack]);

return url;
}

void main(int round, string foe, string url)
{
url = use_spring_raindrop_attack(url);
}


Same kind of thing for mayfly bait:



string use_summon_mayfly_swarm(string page)
{
if (have_equipped($item[mayfly bait necklace]) && page.contains_text(">Summon Mayfly Swarm"))
page = use_skill($skill[Summon Mayfly Swarm]);

return page;
}

void main(int round, string foe, string url)
{
url = use_summon_mayfly_swarm(url);
}


Checking the page source for ">skill" is a good way to check if you can currently cast something.

Bale
09-28-2009, 04:27 AM
Included Rinn's suggestions for spring raindrop, summon burrowgrove & mayfly bait.

Gave the main loop a thorough rewrite to clean up a couple of bugs and drastically improve clarity. It's still awful, but now it is comprehensible so that it is obvious how to fix it or add new combat options. I'm not sure if I'll rewrite it into something more in line with good combat practices since it is now understandable.

I find it amusing how the file is still getting smaller. :p

halfvoid, please continue to give feedback on what works and what doesn't work.

halfvoid
09-28-2009, 04:56 AM
will do sir. I've been adding moxious manuever for my main since he's only been a disco bandit thus far and has none of the skills in the script.

Bale
09-28-2009, 05:02 AM
Well, you won't ever have to add moxious maneuver again. I just added it. Though I'm not sure it was added optimally. Ideas?

Enjoy.

Bale
09-28-2009, 08:34 AM
One more bug fix to make shieldbutt work properly. This was was somewhat serious. It is amazing that this script used to work at all.

mredge73
09-28-2009, 03:45 PM
I just completed a rewrite using Bale's latest post as a reference.
My rewrite requires FTF, SS, and Zlib.

It will call FTF and SS before executing the combat so you no longer will need to have FTF before you casualcombat in your ccs.

I am assuming that whoever is reading this is familiar with FTF, SS, and Zlib and already have them in downloaded in your script folder.

...the file size keeps shrinking

Bale
09-28-2009, 09:54 PM
I don't mind folding SS and FTF into this script, but your script is a big clusterfuck because you didn't differentiate rounds of combat or recognize that an action was taken so it should return to the beginning.

As it is, it will first check to see if the monster needs special handling and do one attack with the monster's special handling, then check for spring raindrop attack, then decide to throw bang potions if some aren't identified, then attack with weapon (even if the monster is physically immune), then it will shieldbutt, then lunging-thrust smack, then thrust-smack, then... Well, you get the idea and the script doesn't even realize we've finished the first round of combat.

Also, it really annoys me that you entirely changed my preferred formatting to yours, though that isn't the biggest complaint.

mredge73
09-29-2009, 01:30 AM
oops...
This should make it less clusterfucked but Bale will still be annoyed.

Rinn
09-29-2009, 06:14 PM
I don't see why you'd add FTF and SS directly into the script, there's really no reason someone couldn't just add another entry into their CCS. The more you try to do with one script the more confusing it's going to be.

For example my default CCS is currently:

[ default ]
1: consult SmartStasis.ash
2: consult raindrop.ash
3: consult flyer.ash
4: consult FeatherExpress.ash
5: note Roc Feather
6: special
10: consult action.ashDifferent actions are separated out into different steps, additionally I have other scripts that identify potions and spheres (from before mafia automatically handed it), using mayfly bait, using spooky putty, doing a disco combos, etc. I think you'd go a long way into creating a package of small one task consult scripts rather then a giant confusing mess of a single one. The script that is tasked with actually killing a monster is going to be a big enough mess as it is. I'm just trying to help you out here, I tried to do the same kind of thing a long time ago (before consult scripts were allowed to return without taking an action) and it was one of the hardest things I wrote to maintain for myself so I dropped it.

Oh also:


boolean is_physically_resistant(monster m)
{
switch (m)
{
case $monster[chalkdust wraith]:
case $monster[ghost miner]:
case $monster[Snow Queen]:
case $monster[ancient protector spirit]:
case $monster[Protector Spectre]:
return true;
}

return false;
}

mredge73
09-29-2009, 06:56 PM
I am not good enough at executing combat during the game manually to actually tackle a CCS from the bottom up. I thought I would just help a little by rewriting this one. I included FTF and SS because I wanted to use some of Zarqon's tools and I did not want the script to repeat an action that FTF or SS already completed. With FTF before casual combat it would sometimes cast entangling noodles twice or flyer twice or so on. I just wanted them to work together, this is the problem that I have found with chaining multable ccs scripts from different authors. The script is working fine for me now but it needs some polish. If the action that I took is not suitable to the needs of the community we can start over from the previous version.