Hammerfall RPG Helper

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

Auto Fight?

in
Subscribe to Auto Fight? 37 posts, 8 voices



Hazado Scriptwright

Auto Fight doesnt seem to be working with the new version.

 
Dusty Script's Author

The way I set it up, you have to define the monsters in the code. If you don't, it won't fight them. I had defined some monsters as I was going through, but I haven't defined them all. I'd like to make it just ask you for the info when you choose to fight them or if you click some "auto-fight" button or checkbox.

 
Dusty Script's Author

BTW: there has been a default fight setting in the code for a version or two.

 
Dusty Script's Author

If autofight doesn't work in the current version, let me know. It's controlled by easy-to-use buttons. At least I think they're easy to use.

 
Isle User

I'm quite nobbish when it comes to scripting. But is there a way I can define the script to use only 1 type of attack or 1 type of healing item or 1 type of energy item when I put it on auto mode?

 
Dusty Script's Author

Yeah, but you'd have to do it in code. Assuming that what you want to do is a good idea, you can just comment out all of the auto-attack lines and put in one line that uses your attack. Same with heal/energy. You need to get the Job IDs for the things you're wanting to do. The code is commented, so you can just open it and do a search for auto-attack. Maybe it'll find you what you need.

If you can't figure it out, let me know and I'll try to help.

 
Dusty Script's Author

Around line 1944 near "// perform auto-fight
" is where you want to be for that.

 
Isle User

ok, only got time after this week to start figuring it out. Thanks. Will let you know if I have problems.

 
Juha User

Hum... Well in previous version Auto-play worked like a charm. But now it dosent. I need to click attack, then it runs the attack normally. I got this script only for that thing. I got tired of this game just for the tiresome grindings, just to get 100 stuff from 1 mob. But no it's gone. Well all the other stuff is nice. But not really to any use for me yet.

 
Juha User

Well the script compains about that my health is to low to run this job. And it is not.

 
Dusty Script's Author

Change the defaults. It assumes you want to be 100% health before you attack. Search for jobReq[0] I think.

 
Dusty Script's Author

Change jobReq[0].healthMin = attribs.healthMax; to a number. If you want it to require only half of your health, do this: jobReq[0].healthMin = attribs.healthMax * 0.5;. Or if you want to have it as a static number, do this: jobReq[0].healthMin = 123; (changing 123 to whatever you want).

 
Juha User

Thanks. U'r a saver :)

 
Dusty Script's Author

And if you want it to do something special just for one specific monster, you can do what you want too. Just use the commented-out examples below where you found the jobReq[0] stuff. Someday I'll make an interface to let you do that without having to code, but at least you have the ability to do what you want. Good luck!

 
galro User

2 Mods I made to the AttackUp / DefenseUp code. Basically only use it if the baddie can hurt you (has energy) & is tough (check attack/defense as appropriate).

if (autoDefUpEnabled && !GM_getValue('attack/hasDefUp') && attribs.energy >= 25 && attribs.monsterEnergy >= 800 && attribs.monsterAttack >= attribs.defense * 0.5)
else if (autoAtkUpEnabled && !GM_getValue('attack/hasAtkUp') && attribs.energy >= 100 && attribs.monsterEnergy >= 800 && attribs.monsterDefense >= attribs.attack * 0.8)
---
Have had mixed results with code above (ie. not sure if it works)

 
galro User

This code does work
if (autoDefUpEnabled && !GM_getValue('attack/hasDefUp') && attribs.energy >= 25 && attribs.monsterEnergy >= 800 && attribs.monsterAttack >= 6000)
else if (autoAtkUpEnabled && !GM_getValue('attack/hasAtkUp') && attribs.energy >= 100 && attribs.monsterEnergy >= 800 && attribs.monsterDefense >= 10000)

 
M.P. Ranger User

Galro, I am spending a good deal of time looking at the code and the feature above looks great. One observation about the code written by our game god is this:
Let's say I am going to collect logs, the young boar can be killed with a two handed slash or double strike (7 or 8 energy) yet the default is lightening from what I can see, A 100% or greater waste of energy. So, how would we rewrite the current scrip to check the total health of the character and determine if a lesser energy attack would work?

 
galro User

In the autoattack section, you could replace the standard code w/ this:
This will mostly, choose the attack w/ the least energy.
Obviously for monsters w/ really high defense, these #s could adjust down, but at a basic level this works great.
It is not smart enough to determine that a wyrm could be killed with a LB & 2Hand Slash instead of an Ice Storm to save energy, as it is just considering the max damage of your attack. If that was your goal, if you got rid of the ice strike line, it would LB if health was 55-160, then TwoHandSlash (health 40).
Feel free to adjust as needed.
----
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 > 54) autoPlay.push(368); // Lightning Bolt when health 55-120
if (attribs.energy >= 10 && attribs.monsterHealth > 44) autoPlay.push(367); // Fire Blast when health 45-54
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

So, around line 1811 you'd just insert the lines we are viewing, or does this "autofight" button open yet another routine? As I search the code for comments about the use of lightening, I find none except those I made in hob 549.

 
M.P. Ranger User

Curiosity arose so I input the script as described and attempted its use. The results were not desirable. In this test I went to Oakwood Forest Dungeon 4 and attacked the Forest Elemental (id 1320) What happened was that only the basic attack was deployed. The creature has a 280 health and 280 energy. During the attack the script reported I was attacking monster ID 20 I believe. I had to stop the script and kill the beast with lightening. So, either I have code inserted elsewhere that supersedes this addition, or something is amis. It also reported it did not know what attrib.monsterHealth was.

 
Dusty Script's Author

Definitely sounds like there's a demand for lesser attacks on lesser creatures and some way to automatically detect that the creature is weak enough for lower attacks. Sounds challenging.

 
M.P. Ranger User

I am considering just creating code for each specific creature based on experience. The latest of which is:
jobReq[1495] = new Object(); // Fernwood Panther @ East Mistyvale Plains 2
jobReq[1495].attack = 1;
jobReq[1495].healthMin = 500;
jobReq[1495].energyMin = 500;
jobReq[1495].healthHealMin = 150;
jobReq[1495].healthHealMin = 450;
jobReq[1495].energyHealMin = 5;
autoPlay.push(368); // Lightening

These more sensitive jobs to resource use are important when farming for Viri's List

 
Dusty Script's Author

Careful with the push there. It will get pushed even if the job doesn't match. You'll probably want that in the auto-attack code. Something like this: (put it somewhere near line 1994)

if (pageId == 1495) autoPlay.push(368); // Lightning

You'd probably want other code to test for that, though.

Maybe I should make a variable for the jobReq items that will let you specify a list of permitted attacks/heals/etc and then the auto-attack logic can just pick from that. Does that sound like a good or a bad idea?

 
M.P. Ranger User

Dusty, thanks for the advice and wisdom. Curiously I am unable to understand how or where you get the attribute numbers for a item, for example I want to modify the code for the Black Elixer use, but am unable to identify this, where do I seek it?

 
M.P. Ranger User

I did a view on the HTML text that was displayed and found it my friends. I suggest these modifications to the code:
Line 1457/58
invInfo[1586].singular = 'Black Elixer';
invInfo[1586].plural = 'Black Elixers';

Lines 2015/2021

add 1586 and the appropriate comma if needed

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