Hammerfall RPG Helper

By Dusty Last update Jun 27, 2009 — Installed 2,505 times.

Oblivion Code

in
Subscribe to Oblivion Code 24 posts, 4 voices



John Fau User

I hope this isn't too dirty. My scripting is minimal...

I've tested and added this code when a monster has a lot of health and Oblivion seems like the best spell to use. Of course, you had to have acquired the Oblivion spell. I use this to farm the Sea Beast Spirit.

you can add it at line 950 (current code) just after the lines that say:

if (autoAttackEnabled)
{

This is the code to add:

//Oblivion code
var vsTDs = $J('table.vsBox td > h1').parent();
var monsterTD = vsTDs.eq(vsTDs.length - 1);
var monsterHealthMatch = $J(monsterTD).find("td:contains('health')").eq(0).text().match("([0-9]+)/([0-9]+)");
var monsterHealth = monsterHealthMatch[1];
if (attribs.energy >= 25 && (monsterHealth*.10 >=75) ) autoPlay.push(375); // Oblivion
// end Oblivion Code

 
Dusty Script's Author

In the current code, Oblivion is defined this way at line 1156:

if (attribs.energy >= 25 && attribs.monsterHealth > 1250) autoPlay.push(375); // oblivion

Does this suit your need?

 
Dusty Script's Author

I also have Inferno defined on line 1157 in my non-released version (I modify it almost daily for my own needs), but I usually have it commented out since it only is effective on a subset of the monsters:

//if (attribs.energy >= 50) autoPlay.push(370); // inferno

I might add a button to the attack screen to enable/disable use of Inferno. Ideas are welcomed.

 
Dusty Script's Author

And I modified Vikram's special case on line 1155:

if (attribs.energy >= 5 && (pageId == "1494" || pageId == "1744" || pageId == "991745") && attribs.monsterEnergy >= 100) autoPlay.push(20); // basic attack to Vikram (he heals too fast for anything else it seems? wait until his energy is low enough before really attacking)

If someone else has a better idea on how to deal with Vikram, I'm all ears. (notice the 991745? it's really 1745 but the 99 basically makes that one a no-op since the rule doesn't work so well with job #1745 since his energy is excessively high and probably very expensive to outlive)

 
Dusty Script's Author

If anyone knows which attacks are specifically effective on which monsters, I want to know. I need the job # for the attacks (if not in current code already) and the job # for the monster being attacked. Or better yet, code would do great too.

 
galro User

*I will work on some :) Again, just working with the logic side first.
*Agreed, if a monster is >1000 energy to start the battle, waiting for him to run out is probably a really bad idea, but if it happens, I am ecstatic.

*Vikram kalamar (1494), can be dealt with but creating a specific routine is hard.
If you get lucky, you can get 3-4 poison clouds in a row to work and he will die. Waiting for energy to run out is probably the easiest.

*The Twin Giants & Hydra, likewise can be tough early on in the game. Easier to wait for them to run out of energy. Later on, its far easier to just do the Oblivion/Inferno routine.

*The Amrit Revealed & Balrog & Vikram Falhill (Kraken?), just should not be done with an autofight. Not unless the logic gets pretty good. I will work on putting something together. Frankly any monster that has Regen and/or Energy Drain will be a bit of a problem.
*Oh, and oblivion needs to be excluded for the Ward Dragons. Won't work on them.

*Be nice to have something for the Earth Elementals :) Atk/Def 50,000
My routine for him:
Defense Up, Attack Up.
If my health < (70% max -30 heal spell), cast heal
If my energy < 50, use black elixir (will never be low enough health if healing all the time to make a difference even w/ the 100 health loss). YMMV
If EE health >= 650 Oblivion
If EE health >100 but less than 650, Inferno
If EE health < 26, basic attack
If EE health < 40, dual slash
If EE health < 50, fire burst,
If EE health =< 100, lightning bolt.

 
galro User

Code for Earth Elemental autofight.
if (pageId == "1890" && attribs.energy >= 25 && attribs.monsterHealth >= 650) autoPlay.push(375); // Oblivion when EE health 650+
if (pageId == "1890" && attribs.energy >= 50 && attribs.monsterHealth >= 100) autoPlay.push(370); // Inferno when EE health 100-649
if (pageId == "1890" && attribs.energy >= 20 && attribs.monsterHealth >= 50) autoPlay.push(368); // Lightning Bolt when EE health 50-99
if (pageId == "1890" && attribs.energy >= 10 && attribs.monsterHealth >= 40) autoPlay.push(367); // Fire Blast when EE health 40-49
if (pageId == "1890" && attribs.energy >= 8 && attribs.monsterHealth >= 28) autoPlay.push(45); // TwoHanded Slash when EE health 28-39
if (pageId == "1890" && attribs.energy >= 5) autoPlay.push(20); // Basic Strike when EE health 1-27
-----
Code for Black Elixir autoenergy
if (attribs.energy < 50) autoPlay.push(1586); // Black Elixir if Energy < 50
-----
So, same code for the autofight could be modded to work for any monster. Still need to do some changes because most monsters don't have 50k attack/defense. Like for Wyrms, I would look for a more energy efficient fight routine.

 
galro User

Ok, I think I have a better formula (generic) for Oblivion.
if (attribs.energy >= 25 && attribs.monsterHealth > (1250 - attribs.monsterDefense / attribs.attack * 175)) autoPlay.push(375); // Oblivion when health high

It yields an oblivion threshold of:
Against EE or Kraken (50k), its 521 @ 12k, 667 @ 15k.
Against Vikram (20k), its 959 @ 12k & 1017 @ 15k.
Against a 5000 defense monster, its 1075 @5k, 1177 @ 12k, 1192 @ 15k.

Could probably use a little tweaking on the low end, but gives a reasonable result at the higher end.
-----
Edit: doesn't seem to work right. will look to fix

 
Dusty Script's Author

Thanks for these, galro. If you can figure out what might be wrong with that last one, let me know. I'd like to include it into the script.

 
M.P. Ranger User

I found reading this particular topic interesting as it enabled me to see the logic you may use to fight a creature. Here is an example of a fight that I must program in, the farming of wyrm. I select a wyrm location around Guildin Falls in the Lindelin Forest, I choose two attacks, the first a lightening strike, the second a fire blast, both on the same basic level page. This kills the wyrm and may give me 1 or two points of damage. I will wish to continue killing the wyrm at this location until I have no more stanima or Energy whichever comes first. This is not unlike farming for bread in Sulindal. Now before I begin these two very obvious code enhancements, has someone already done this?

 
M.P. Ranger User

I wrote the code and applied it and it works except for the messages I am unsure about which say "No Autoplay Jobs in this area" Here is the code:
jobReq[549] = new Object(); // Wyrm @ Lindellin Forest 4
jobReq[549].attack = 1;
autoPlay.push(368); // Lightening
autoPlay.push(367); // Fire Blast

 
Dusty Script's Author

If I remember correctly, that message just means there aren't any jobs of that kind on the quest screen? I can't remember. If it's working, I wouldn't worry about it. I'll probably just remove that message when not on the quest screen.

 
M.P. Ranger User

Thank you kind sir; I am sure keeping the code clean and concise keeps you busy. For those of you on Facebook who really care, I can be found and added to your guild. As you can tell by my tasks, I have maxed out my character, except for farming lava links and I will be working on this code to be added soon as well.

 
galro User

This code has been working great for me. Tested against Stags, Wyrms, Earth Elementals and most Bosses. (I have 15k att/def). If your attack/defense is less, you might want to adjust the numbers up or down.
---
if (attribs.energy >= 25 && attribs.monsterHealth > 999) autoPlay.push(375); // Oblivion when health high
if (attribs.energy >= 50 && attribs.monsterHealth > 160) autoPlay.push(370); // Inferno when health 161-999
if (attribs.energy >= 40 && attribs.monsterHealth > 120) autoPlay.push(114); // Ice Strike when health 121-160
if (attribs.energy >= 20 && attribs.monsterHealth > 56) autoPlay.push(368); // Lightning Bolt when health 57-120
if (attribs.energy >= 10 && attribs.monsterHealth > 44) autoPlay.push(367); // Fire Blast when health 45-56
if (attribs.energy >= 8 && attribs.monsterHealth > 30) autoPlay.push(45); // TwoHanded Slash when health 31-44
if (attribs.energy >= 5) autoPlay.push(20); // Basic Strike when health 1-30
----
For the Wyrm, yes this would just use Ice Strike and waste 10 energy (compared to LB & FB), but its a good generic code

 
M.P. Ranger User

Ikay then, I have made a grave error in comprehension. Doesn't the be;ow script monitor my health and do a heal if I fall below the healthHealmin?
or do I need some additional coding to tell it to push heal if I am dying? I died very quickly with a beginning health above 1200
jobReq[1893] = new Object(); // Lava Chainling @ Barrenhoff Volcano
jobReq[1893].energyMin = 80;
jobReq[1893].healthHealMin = 875;
jobReq[1893].energyHealMin = 40;
if (attribs.energy >= 25 && attribs.monsterHealth > 999) autoPlay.push(375); // Oblivion when health high
if (attribs.energy >= 50 && attribs.monsterHealth > 160) autoPlay.push(370); // Inferno when health 161-999
if (attribs.energy >= 40 && attribs.monsterHealth > 120) autoPlay.push(114); // Ice Strike when health 121-160
if (attribs.energy >= 20 && attribs.monsterHealth > 56) autoPlay.push(368); // Lightning Bolt when health 57-120
if (attribs.energy >= 10 && attribs.monsterHealth > 44) autoPlay.push(367); // Fire Blast when health 45-56
if (attribs.energy >= 8 && attribs.monsterHealth > 30) autoPlay.push(45); // TwoHanded Slash when health 31-44
if (attribs.energy >= 5) autoPlay.push(20); // Basic Strike when health 1-30

 
M.P. Ranger User

Understanding that I have set these variables:
// set some state info
var thisJobReq = jobReq[pageId] || (isAttack ? jobReq[0] : jobReq[pageId]); // the job or the default-if-fighting (used in the fight itself, not from the quests page)
var autoAttackEnabled = GM_getValue('autofight/attack') || 0; // enable if you don't wish to pick your own attacks
var autoHealEnabled = GM_getValue('autofight/heal') || 1; // enable if you don't wish to pick your own heals
var autoEnergyEnabled = GM_getValue('autofight/energy') || 1; // enable if you don't wish to pick your own energy
var autoRunAway = GM_getValue('autofight/runaway') || 0; // enable if you want to auto-runaway when out of needed supplies
var autoDefUpEnabled = GM_getValue('autofight/defup') || 1; // enable if you want to autouse Defense Up spell
var autoAtkUpEnabled = GM_getValue('autofight/atkup') || 0; // enable if you want to autouse Attack Up spell

 
galro User

Ok, it looks like that should heal if your health is < 875. One problem, it looks like it will let you attack if you are 80+ energy. You probably want to be at/near max health and energy to start. You probably want to autoatkup if their defense is >12k and you use a lot of inferno. Will be a net savings of energy, most of the time.
----
I am not using the individual code blocks, and rather concentrating on making a good "generic" set of instructions (tailored for high level, so should work for you also).
----my default job block
// jobReq entries (used for battles)
jobReq[0] = new Object(); // DEFAULT FIGHT OPTIONS
jobReq[0].attack = 1;
jobReq[0].healthMin = attribs.healthMax * 0.9;
jobReq[0].energyMin = attribs.energyMax * 0.8;
jobReq[0].healthHealMin = attribs.healthMax * 0.70 - 30;
jobReq[0].energyHealMin = 49;
----
if (attribs.monsterEnergy >= 100)
{ // don't waste big energy items if the monster can't attack you
if (attribs.energy < 50) autoPlay.push(1586,1321, 1101); // Black Elixir, Dragontear, Green Elixir if Energy < 50
I commented out the rest of the autoenergy lines.
----
if (autoHealEnabled)
{
if ((attribs.health + 30) / attribs.healthMax < 0.7 && attribs.energy >= 25) autoPlay.push(1080); // heal spell (+30% of max health + 30 hp)
Again, commenting out the rest of the healing as I only use heal spells now. This basically states that if I ever get below what my heal spell does, then cast heal.

 
Dusty Script's Author

The way the logic works is this: (when an action is performed, the page reloads and then the logic starts from the top again)

- Do you have enough health? If not and if we're allowed to auto-heal, do it if there are sufficient health items. If not and we're allowed to run away, try to run away. If not, stop and wait for user.

- Do you have enough energy? If not and if we're allowed to auto-energy, do it if there are sufficient health items. If not and we're allowed to run away, try to run away. If not, stop and wait for user.

- If we're allowed to auto-def-up and we haven't done it yet and we have enough energy for it, do it.

- If we're allowed to auto-atk-up and we haven't done it yet and we have enough energy for it, do it.

- If we're allowed to auto-attack, find an attack and do it.

- If we've gotten this far, wait for the user to do something.

 
M.P. Ranger User

I have read the logic and it is sound. As I now play with the auto attack enabled I note two things:There is no escape from the logic unless I simply disable Greasemonkey. The logic works so fast that if after say 15 auto attacks I wish to escape to another place in the game for other activities, I may not until my stamina is gone and I have the ability to reclick on the auto play button.
The other is the red health warning in the text. I my health goes below the maxhealth even 1 point a question begins to appear asking if I have enough health and then the logic goes on to the next step without there being any method to tell the logic that yes my health is okay don't display the message (My max health is 1170, if it goes to 1167 the red displays)
I wish I would have found this earlier! It is so helpful in reducing that tedious repetitive tasks issue like fighting a wyrm to generate some trade items to but health and energy items, obviously I am not a player after gold just a nice game.

 
galro User

There is a button in the attack screen to disable "auto attack repeat" or something. Unclick this and it will stop the fighting routine once the current fight is finished.

 
Dusty Script's Author

Yes, if you click the "auto-attack repeat" button (in the top-left corner, so it turns red), it will not auto-attack that monster after the battle is over. It is the exact same as clicking it (so it is red) for the monster on the quests screen. The two buttons affect the same state variable.

If your health goes under what you have set as your minimum health before heal, it will treat it as too low, even if just one health point under. If you want to change what your minimum health is, you have to do it in the code, either in the default setting (jobReq[0]) or a specific jobReq for the monster you're fighting. There are a lot of commented-out examples that you can use as a starting point or just used blindly if you like.

 
M.P. Ranger User

Dismay! I unloaded the script and downloaded the current version. I then used Word to do a document compare. Wow, what the heck did I have? You see the new version has the buttons on the right I can stop the auto attack. Now, the dismay. I went into the Fahill dungeon and attacked Balrog, not auto-attack, just plain attack. Auto attack kicked in and I died because auto-heal does not function. To test this theory I went to the Barrenhoff Volcano and di an auto-attack of the Lava Chainling with Auto heal enabled, again I was killed. WTF? I have looked over the code I now have and can not discern where the failure is. Has anyone used the auto heal feature successfully? I know, ths is scripting contributed by many for the purpose of a distributed improvement. I am beginning to doubt my 10 years of scripting skill.

 
galro User

The code I am using is from about 10 days ago, because I have made many changes to it. Let me download and do a compare. I don't want to lose my changes either. I have used autoheal very successfully though, and I am healing consistently.

Only a couple monsters where I want to turn it off. When I am trying to get killed. Need to remember :)

 
Dusty Script's Author

Just in case, be sure to go to your inventory list before you fight. That's the primary way the script knows your inventory. It shouldn't matter, though, because it should try to use the heal items anyway (as long as they appear as a choice during the fight without the script).

I haven't had any auto-heal problems at all. Of course if I did, I'd fix it! :-)

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel