PDA

View Full Version : Bots won't melee attack


vacare
02-15-2015, 08:20 PM
Hello again,

So I am loving the bots. I have saved a variety of bots to form parties with my PC character, and they are very smart. The casters work perfectly, buffing and healing and casting spells in combat.

However, none of the physical attackers seem to work. Warrior, rogue, et cetera, never attack. I have given them weapons, and they have equipped those weapons. I have tried every stance available. I have tried using the group attack command as well as just initiating the combat myself (either with an attack or via aggro). But no matter what, the melee folks don't attack.

I'm sure I'm just missing something. Any ideas?

Thanks for any help!

Nibiuno
02-15-2015, 08:58 PM
This is due to the hitpoint bug issue/stat issue. You can edit the bot code to hard set their HP based on level, and hard set their stats. I made that change to fix this - I can post the code tomorrow.

vacare
02-15-2015, 09:43 PM
Ahhh, that makes sense. I had noticed when performing a #bot update that the HP were these very large negative numbers.

Yeah! If you don't mind posting the code, that would be awesome! Thanks! It goes in bot.cpp I'm guessing?

dagulus2
02-16-2015, 05:05 AM
I have been using the fix in this thread here: http://www.eqemulator.org/forums/showthread.php?t=39013

Not sure if there is a better solution.

Nibiuno
02-16-2015, 08:11 AM
Here is what I replaced the entire base hp function with - it makes all bots have the same HP, and the base HP is close to what PCs get. With gear, the base HP doesnt really matter much anyways.
int32 Bot::GenerateBaseHitPoints()
{
// MOD - Just make hp level*33 + 5 for bots
// Calc Base Hit Points
int new_base_hp = 0;

new_base_hp =(5)+(GetLevel()*33);

return new_base_hp;
// END MOD
}

vacare
02-16-2015, 06:16 PM
Awesome, thanks, everyone! I'll give this a shot tonight.

vacare
02-16-2015, 07:01 PM
Fantastic. The base hp fix worked like a charm. Thanks so much everyone!

vacare
02-18-2015, 03:05 PM
Thanks again everyone for the help so far. My bots are now attacking, but I have a new an interesting defect - They are indestructible!

Their HP is way too high, based on the code. Here is an example:

1. According to GenerateBaseStats in bot.cpp, an Ogre Warrior adds 97 STA to base
1. According to client_mods.cpp, the class level factor for a level 20 warrior is 220.
2. According to the bots table, the STA of the character in question is 75 (no equipment at all)
3. According to the fixed bots.cpp GenerateBaseHitPoints method, the base HP should be:


int32 Bot::GenerateBaseHitPoints()
{
// Calc Base Hit Points
int new_base_hp = 0;
uint32 lm = GetClassLevelFactor();
uint32 Post255;

if ((GetSTA() - 255) / 2 > 0)
Post255 = (GetSTA() - 255) / 2;
else
Post255 = 0;

new_base_hp = (5) + (GetLevel()*lm / 10) + (((GetSTA() - Post255)*GetLevel()*lm / 3000)) + ((Post255*GetLevel())*lm / 6000);

this->base_hp = new_base_hp;

return new_base_hp;
}


4. In our case, the formula ends up being:

5 + (20 * 220 / 10) + (97 * 20 * 220 / 3000) + (0 * 20 * 220 / 6000)

Which is:

5 + 440 + 142 + 0

So I would expect this naked, level 20, ogre warrior to have 587 HP.

But when my level 20 character does a "#bot create Name 1 10 male" to create a naked, level 20, ogre warrior, the bots table shows a HP value of 716588 for that bot.

In fact every bot I create has HP in the 710000 order of magnitude. Because there is some variation between bots, I'm guessing that the above calculations are being considered, but I'm also guessing that something outside of the code I'm seeing is affecting the final value (or I'm mis-reading the calculation above).

I've walked through about as much as the code as I can easily see (including everything off of the #bot create constructor), but I don't see anything else that should modify the HP value. Since the value is wrong in the DB before spawning, I didn't look at anything except the create constructor and its related code.

Any ideas?

Thanks for any help!

dagulus2
02-18-2015, 03:55 PM
That is the exact same code I am using, and I am not having that issue.

Just created a level 51 ogre warrior to test, and it has 2171 hit points.

dagulus2
02-18-2015, 03:59 PM
Having looked further, interestingly, I do have 5 level 1 bots that someone created on the 25th of the 1st that all have 715861 hit points.

Are you upto date with the rest of the code?

vacare
02-18-2015, 04:33 PM
I wasn't! Looks like there there were a couple commits in early February I was missing. I'll integrate those first.

Out of curiosity, I haven't done a database update to a live install yet. I'm guessing the utils/SQL/ stuff is pretty self explanatory - they probably just transform the database in ways necessary to support the commit.

But I also notice that the PEQ files had an update recently. I haven't opened those to see what the SQL looks like, but are those safe to transform a live DB, or do you need to start with a fresh DB for the PEQ SQL to work?

Thanks again!

vacare
02-19-2015, 04:37 PM
Hmm, I compiled the latest source and did all the required DB updates, but brand new bots are still being created with the large HP value.

Failing anything else, I can probably find where that value is getting initialized and correct it myself - but the fact that you're not seeing the issue makes me think my environment is missing something!

Thanks again for the help!

vacare
02-20-2015, 01:47 AM
OK, it's fixed. Don't know if it was the original code, or my faulty transcription, but something about the unsigned ints and bad bounding was causing the number to flip to the high end. I modified the code to the below, and the HP generate correctly:


int32 Bot::GenerateBaseHitPoints()
{
int new_base_hp = 0;
uint32 lm = GetClassLevelFactor();
uint32 Post255 = 0;
if (GetSTA() > 255) Post255 = (GetSTA() - 255) / 2;
new_base_hp = 5 + (GetLevel() * lm / 10) + ((GetSTA() - Post255) * GetLevel() * lm / 3000) + (GetLevel() * lm / 6000);
return new_base_hp;
}