fight.php override - action buttons and a little fight-related library

raorn

Member
This script is a rewrite of stationary combat buttons script written by miser.

You will need:

relay/fight.ash - main wrapper, you need to edit this script to enable/disable additional fight.php overrides.
relay/fight_buttons.ash - the script itself.
lib/fight_helper.ash - helper library for damage estimates and stuff. See comments inside.
data/combatskills.txt - list of combat skills. Data files are just a bit easier to maintain.
lib/scriptproperty.ash and relay/script_settings.ash - personal script settings library and UI.
lib/html.ash - simple HTML helpers.

Visit javascript:void(mainpane.location="script_settings.php"); or javascript:void(mainpane.location="fight_buttons.php"); in your relay browser to see some configuration options.




Update 2008.02.19 10:15 UTC: fight_buttons.ash and fight_helper.ash - bugfixes, no new features.
Update 2008.02.19 22:45 UTC: fight_helper.ash - added monster attack information, fight_buttons.ash - unknown_base_damage renamed to will_surely_miss.
Update 2008.02.24 14:05 UTC: fight_buttons.ash and fight_helper.ash updated for recent RuntimeLibrary changes, support for arbitrary actions (steal, jiggle, etc...)
Update 2008.02.28 20:05 UTC: fight_helper.ash - fixed bug in monster defense calculation.
Update 2008.03.02 13:00 UTC: fight_helper.ash - fixed ranged weapon hit chance calculation, fight_buttons.ash - damage range display issues.
Update 2008.03.15 13:05 UTC: Massive update - configuration UI. Download more leet screeptz.
fight_helper.ash - Disco (Crossbow) Fever changes, support for in-combat ML modifiers, report hit chance when calculating possible damage. fight_buttons.ash - "work like KoLmafia" mode. In this mode it's just KoLmafia's fight buttons, with damage estimates and total number of 11 configurable skills which can be autofilled. Check it's configuration page. combatskills.txt - CLEESH, Indigestion, Noodles and MoxMan no longer configurable and added if available.
Update 2008.04.16 10:55 UTC: fight_helper.ash, fight_buttons.ash and combatskills.txt updated for new Pastamancer spells.
Update 2008.04.20 20:15 UTC: fight_helper.ash - honor +ML modifiers when fighting known monsters with unknown stats.
Update 2008.06.10 20:55 UTC: June IotM support.
Update 2008.08.10 09:00 UTC: fight_helper.ash - updated Pastamancer spell damage caps, fight_buttons.ash - allow use of "script" and "jiggle" in bird form, Pastamancer combat ghost support.
 

Attachments

  • fight.ash
    618 bytes · Views: 118
  • combatskills.txt
    962 bytes · Views: 126
  • fight_buttons.ash
    15.6 KB · Views: 89
  • fight_helper.ash
    26 KB · Views: 80

Paragon

Member
Does get damage get the amount of damage that you did to the opponet, or does it get the amount of damage you expect to do to the opponent?
 

raorn

Member
It shows non-critical damage range that you could deliver to opponent if you hit him. However, it does not check whether you can certainly hit opponent, so it may be wrong with Attack with Weapon and melee-based skills like Headbutt if your Muscle is way too low.

For Melee attack I had to change weapon damage formula from

Code:
(Player Muscle × rangeadj) - Monster Defense, (minimum 0)

to

Code:
(Player Muscle × rangeadj) - 90% of Monster Defense, (minimum 0)

Miser's script contains "until it is fixed" comment in this place.
 

Miser

New member
Wow! Very nice, this is so much cleaner than my script. Also, I'm sorry you had to read through the huge mess that is my code (and also this post. I suck at structuring).

The 90% defense is because TPTB recently reduced most monster's defense by 10%, and the attack and defense values KOLmafia uses haven't been updated in quite a while.

I read through the scripts and there are a few things I think are wrong.

First of all, in fight_buttons.ash, line 24f:
Code:
	if (onlyMinDmg || round(dmg.min) != round(dmg.max))
		ret = ret + "-" + round(dmg.max).to_string();
I think it should be
Code:
	if (!onlyMinDmg && round(dmg.min) != round(dmg.max))
		ret = ret + "-" + round(dmg.max).to_string();


In fight_helber.ash, line 200ff, you put the Flavour of Magic skills before the elemental cookbooks, however, the books override the Flavours.


Also, I think your treatment of bonus elemental damage with an elemental form active is wrong.
Line 306ff or so:
Code:
	foreach el in elements
		if (elements[el].to_element() != elementh) {
			bonus_elemental_damage = bonus_elemental_damage + get_damage(enemy, numeric_modifier(elements[el] + " Damage"), elements[el].to_element());
		}
I think should be:
Code:
	foreach el in elements
		if (elementh == NONE) {
			bonus_elemental_damage = bonus_elemental_damage + get_damage(enemy, numeric_modifier(elements[el] + " Damage"), elements[el].to_element());
		} else {
			bonus_elemental_damage = bonus_elemental_damage + get_damage(enemy, numeric_modifier(elements[el] + " Damage"), elementh);
		}
because all damage will be done according to the form element. You'd need to change the lines around 450 as well.


Line 347 or so, Moxious Maneuver not only disregards bonus ranged damage, but all bonus damage.


Spells doing a random damage element will be resisted according to physical damage resistance, when they should not be resisted at all. In my script, I had to create another variable that stores whether the element is random.


Finally, your treatment of Immaculate seasoning is wrong. It will not just adjust the element of the spell according to the element of the opponent, it will actually calculate both elements and use the better one, be it because of resistance or because of bonus elemental damage.


Also, how about adding buttons for pickpocketing and toy mercenaries? Or, I could do it. I actually created both for my old script, but never uploaded it because there seemed to be no demand.
 

raorn

Member
[quote author=Miser link=topic=1543.msg7236#msg7236 date=1203277013]
The 90% defense is because TPTB recently reduced most monster's defense by 10%, and the attack and defense values KOLmafia uses haven't been updated in quite a while.[/quote]
Who is TPTB?

I read through the scripts and there are a few things I think are wrong.
Call it "bugs" please ;-)

First of all, in fight_buttons.ash, line 24f:
Yes. Typo.

In fight_helber.ash, line 200ff, you put the Flavour of Magic skills before the elemental cookbooks, however, the books override the Flavours.
Also, I think your treatment of bonus elemental damage with an elemental form active is wrong.
Line 347 or so, Moxious Maneuver not only disregards bonus ranged damage, but all bonus damage.
Well, maybe I missed some things when read wiki. And it was late night ;-) I'll fix it.

Finally, your treatment of Immaculate seasoning is wrong. It will not just adjust the element of the spell according to the element of the opponent, it will actually calculate both elements and use the better one, be it because of resistance or because of bonus elemental damage.
I'm not sure... Hot monsters will always take Cold damage because of Hot Resistance. Let's look at Spooky monster. It takes double damage from Hot spells. The only way to deliver Cold damage is to have Bonus Cold Damage as big as normal spell damage. Have you seen this in battle?

Also, how about adding buttons for pickpocketing and toy mercenaries? Or, I could do it. I actually created both for my old script, but never uploaded it because there seemed to be no demand.
I just forgot about pickpocket since I don't have it ATM. As for mercenaries, there are bunch of other multiuse combat items, I am planning to add them all.




But let's return to our damage.

Melee attacks always physical unless having Elemental Form. What happens to Bonus Elemental Damage in this case? Is it all converted to Form element or only Form element is used? From your code I can think it is converted.

What about Melee-based skills(spells?) like Spectral Snapper? Does bonus spell damage applies? Does Elemental Spell Damage applies?

Spells (pasta/sauce) only use one Bonus Elemental Spell Damage. For random elements it's better to add minimal possible Elemental Bonus to min. damage and maximal possible to max. damage.

I guess attack_element() should return a record with element and type (Form, Random, Exact).
 

Miser

New member
[quote author=raorn link=topic=1543.msg7240#msg7240 date=1203333879]
Who is TPTB?
[/quote]

The Powers That Be, i.e. the creators of the game.

I'm not sure... Hot monsters will always take Cold damage because of Hot Resistance. Let's look at Spooky monster. It takes double damage from Hot spells. The only way to deliver Cold damage is to have Bonus Cold Damage as big as normal spell damage. Have you seen this in battle?

It matters when the opponent has no element but you have bonus elemental damage of one kind. Say I cast saucegeyser on Ed with Ice-Cold Aluminum Necklace (+40 cold spell damage) equipped. Seasoning will chose cold damage because of the bonus. That makes quite a difference.

I just forgot about pickpocket since I don't have it ATM. As for mercenaries, there are bunch of other multiuse combat items, I am planning to add them all.

I attached the two functions from my old script so you don't have to do everything yourself.

But let's return to our damage.

Melee attacks always physical unless having Elemental Form. What happens to Bonus Elemental Damage in this case? Is it all converted to Form element or only Form element is used? From your code I can think it is converted.

All bonus elemental damage will be converted to the form element. However, my code was incorrect too: I tested each element separately against the resistance, while the game will test it all at once.
E.g. if I would deal 5 regular and 5 cold damage to a spooky monster, but have spookyform active, I would only deal 1 damage instead of 2, like my code would calculate.

What about Melee-based skills(spells?) like Spectral Snapper? Does bonus spell damage applies? Does Elemental Spell Damage applies?

Neither applies.


I don't think I found any more "bugs", if you like, but I haven't actually tested the script yet.
 

Attachments

  • merc_pickpocket.txt
    1 KB · Views: 107

raorn

Member
[quote author=Miser link=topic=1543.msg7241#msg7241 date=1203347978]
The Powers That Be, i.e. the creators of the game.[/quote]
What about Attack value? Is is reduced too?

It matters when the opponent has no element but you have bonus elemental damage of one kind.
Crap! I always forget about that "sixth element"!

I attached the two functions from my old script so you don't have to do everything yourself.
Thanks, I'll take a look.

Everything is fixed, some things are simplified. I'll attach new scripts tomorrow when I test it.
 

Miser

New member
[quote author=raorn link=topic=1543.msg7244#msg7244 date=1203375503]
What about Attack value? Is is reduced too?[/quote]

No, that one stayed the same.
 

raorn

Member
Scripts updated for recent KoLmafia RuntimeLibrary changes. However, my Melee attach damage estimates looks a bit higher than actual damage. At least for lower level areas.
 

Miser

New member
[quote author=raorn link=topic=1543.msg7335#msg7335 date=1203930451]
However, my Melee attach damage estimates looks a bit higher than actual damage. At least for lower level areas.
[/quote]

Line 93 in fight_helper.ash:
Code:
ret.def = min(1, ret.id.monster_defense() * 0.9);
You are basically setting every monter's defense to 1 ;)


Also, I think you misunderstood the meaning of the "?+" I added sometimes before melee attacks. It didn't mean that you would always miss, but that the monster's defense was unknown and one part of the damage couldn't be calculated. However, I still wanted to display the rest of the damage, especially with TT skills.
I suggest just putting out 0 when it is certain that you will miss.
 

raorn

Member
[quote author=Miser link=topic=1543.msg7340#msg7340 date=1203954818]You are basically setting every monter's defense to 1 ;)[/quote]
Aw! I meant "max" of course. But I'd better use ceil() here.

Also, I think you misunderstood the meaning of the "?+" I added sometimes before melee attacks.
Then what would happen if:

1. Monster defense is known and:

  • [li]I will_surely_miss and using TT combos or LTS[/li]
    [li]I will_surely_miss and NOT using and combos/skills[/li]
2. Monster defense is unknown.

I've noticed that TT combos have higher hit rate than normal attacks.
In second case, minDmg should be set to zero, while maxDmg should assume that Monster Defense is really 0. Combo damage added to both (or maxDmg only?).
 

Paragon

Member
I have never used relay override scripts before so I don't know if i am doing something wrong but,
using 12.1, and 12.2 generate errors "undefined reference to item_type()"
using the daily build from today Feb. 26 2008 the script seems to run, however using my lvl 14 pastamancer the only buttons that show up are attack(x-y), jiggle, scr, and CLEESH

The attack seems to be wrong because I am unable to actually hit the monster (it always dodges)
and none of my spells appear.
 

raorn

Member
[quote author=Paragon link=topic=1543.msg7360#msg7360 date=1204052466]using 12.1, and 12.2 generate errors "undefined reference to item_type()" [/quote]
Scripts updated for recent RuntimeLibrary changes and will not work with 12.2 release. Can't remember minimum revision required.

using the daily build from today Feb. 26 2008 the script seems to run, however using my lvl 14 pastamancer the only buttons that show up are attack(x-y), jiggle, scr, and CLEESH
You must edit buttons_main() function in fight_buttons.ash and add your favorite skills after "Add your own leet skillz here" comment. By default this will work only for Bad Moon players since it is possible to have only one class' skills.

Any ideas how to make skill list configureable without need to edit script?

The attack seems to be wrong because I am unable to actually hit the monster (it always dodges)
It's my bug pointed out by Miser. I'm attaching fixed version.

P.S. Sorry for delay, I was cut off the internet for a couple of days.
 

Paragon

Member
Any ideas how to make skill list configureable without need to edit script?

You could use a datafile to hold the hold the skillz that people want, and you can create a fightconfigure script which would go through all combat skills the player has access to, then based on their answers populate the datafile... which then can be loaded by the combat override script to grab the skills from the data file.

-OR-

using the datafile, instead of creating a config script, you could start with just the buttons as they are now, and as players use skills from the drop down menu you could add those skills to the list of buttons and store them in the datafile. That way, only skills that the player use will show up on the top. I am not 100% sure how you would figure out which selection from the drop down menu was chosen and you would proably need to reset the datafile everytime the play assended.
 

Paragon

Member
I really like this script, esp the fight_helper lib. Very nicely done. If you don't mind I think I will use this lib in a Consult script.
Also, the lib doesn't seem to handle scaling monsters such as lord spooky raven, baron von rats worth etc.

Are you planning on incorporating those monsters? I think I can add them, since all it would be is to have a special get_opponent function.

So... I wrote this up... you may not want it, but then again you might:

At global level in fight_helper.ash:
Code:
int [string] special_monsters;
int _SCALES = 1;   #This type of monster is special because it's attack and def depends on your stats
int _SETDMG = 2;   #This type of monster is special becuase it dmg is not dependent on your stats
int _NOINFO = 3;   #This type of monster is special becuase information is missing from the monsters datafile.
special_monsters["baron von ratsworth"] = _SCALES;
special_monsters["candied yam golem"] = _SCALES;
special_monsters["malevolent tofurkey"] = _SCALES;
special_monsters["possessed can of cranberry sauce"] = _SCALES;
special_monsters["stuffing golem"] = _SCALES;
special_monsters["el novio cad´ver"] = _SCALES;
special_monsters["el padre cad´ver"] = _SCALES;
special_monsters["la novia cad´ver"] = _SCALES;
special_monsters["la persona inocente cad´ver"] = _SCALES;

special_monsters["lord spookyraven"] = _SETDMG;
special_monsters["naughty sorceress"] = _SETDMG;
special_monsters["naughty sorceress (second form)"] = _SETDMG;
special_monsters["your shadow"] = _SETDMG;

special_monsters["clownlord beelzebozo"] = _NOINFO;
#special_monsters[""] = _NOINFO;

Just above opponent get_opponent(string name)
Code:
####
## Get info on special monsters
## and fill in some of it's properties
opponent get_special_opponent(string name)
{
  opponent ret;
  int t;
  ret.name = name;
  name = to_lower_case(name);
  if (special_monsters[name] == 0){return ret;}
  if (name == "clownlord beelzebozo"){ret.atk=28; ret.def = 27; return ret;}
  if (name == "baron von ratsworth")
      {
        t = to_int(get_property("numAscensions"))+3;
        ret.atk=my_buffedstat($stat[moxie])+3+min(12,t);
        ret.def = my_buffedstat($stat[muscle])+min(12,t);
        return ret;
      }
  ret.atk = my_buffedstat($stat[moxie])+5;
  ret.def = my_buffedstat($stat[muscle])+5;
  return ret;
}

Replaces if (ret.id == $monster[none]) return ret; in opponent get_opponent(string name)
Code:
  if (ret.id == $monster[none]) return get_special_opponent(name);

Takes care of clownloard beezlebozo, Baron Van Rats worth, thanksgiving monsters and the new holiday monsters (with the dead drinking guys), I left out the obsolete christmass monsters.
Also Has prelimenary support setup for your shadow, the sorceress, and lord spooky raven. Though, these you would just need a defense stat so you can figure out if we can hit them or not... but you would need to have a special monster function for the part of the script that determines how much damage you would recive. (Since they don't deal damage like normal creatures).
Finally, I couldn't find any info on The man, or his hippy counterpart.

P.S: Minor Bugfix -
In damage_range defense_damage(opponent enemy)

the Line: float DA = 1 - damage_absorption_percent();
Should be: float DA = 1-(damage_absorption_percent()/100);
Although this only gets the numbers closer... rather then correct.
 

raorn

Member
[quote author=Paragon link=topic=1543.msg7408#msg7408 date=1204266926]I really like this script, esp the fight_helper lib. Very nicely done. If you don't mind I think I will use this lib in a Consult script. [/quote]
I was planning this script as a general purpose fight library. Feel free to use it.

Also, the lib doesn't seem to handle scaling monsters such as lord spooky raven, baron von rats worth etc.
Doesn't Mafia handles them itself?

Are you planning on incorporating those monsters? I think I can add them, since all it would be is to have a special get_opponent function.
No problem. Attach your changes (unified diff is great if you know what I mean) and I'll import your modifications.
 

raorn

Member
[quote author=raorn link=topic=1543.msg7342#msg7342 date=1203972403]
1. Monster defense is known and:[/quote]
Weapon damage is zeroed, then TT combo damage (if any) is added. Only TT skills/combos adds damage to melee attacks. will_surely_miss (need to rename it back to "unknown_base_damage") is set to true, damage displayed as "?+range" if range is greater than zero, 0 otherwise.

2. Monster defense is unknown.
Monster defence considered to be equal to player's attack, which means zero main weapon damage, but offhand and bonus damage still applies. Should I set will_surely_miss to true here?

Is it OK?
 

raorn

Member
[quote author=Paragon link=topic=1543.msg7408#msg7408 date=1204266926] the Line: float DA = 1 - damage_absorption_percent();
Should be: float DA = 1-(damage_absorption_percent()/100);
Although this only gets the numbers closer... rather then correct.[/quote]
Damn. I double checked KoLmafia sources (RuntimeLibrary and BasementRequest classes) and was 100% sure that damage_absorption_percent() returns 0..1 range. Both formulas looks the same, except in one case it was divided by 10 and in other case it was multiplied by 10 ;-)

Thanks.
 

raorn

Member
Preview of my figth-relay megapack ;-) I haven't tested it yet, so I'm not posting it to first message.

fight_lib.ash - DB's Epic gives bonus damage to DB skills, better damage (and defense damage) estimates for unknown monsters, fixed DA calculations, added special monsters (Ratsworth, FoB and Day of the Dead for now).

fight.ash - support for "check" and "preaction" events (see this message for more info).

fight_buttons.ash - "check" and "preaction" support.

fight_info.ash - new script, shows rounds left until sure death (just funny).

And I think it's time to move fight_helper.ash so separate thread in General Scripting Discussion.

P.S. Updated. Typo in fight_info and added Disco Combos. Also updates scriptproperty.ash, see this theread.
 

Attachments

  • fight-pack.zip
    11.9 KB · Views: 80

raorn

Member
[quote author=raorn link=topic=1543.msg7404#msg7404 date=1204228851]Any ideas how to make skill list configureable without need to edit script?[/quote]

Read first post for more info. Have fun ;-)
 
Top