PDA

View Full Version : Bot issue latest compile...


Trackye
11-05-2012, 08:44 PM
Regardless of what is attempted on a fresh compile of latest svn repo.

Level 1 Berserker Bot crashes zone on attacking..

Have tested with weapon without weapon. What not. All other bots work fine but as soon as a level 1 Berserker Bot is in group and player attacks. Crash.

Tested on level 15 character and using a Berserker bot works fine.

Any more information I can offer please let me know and where I can find it.

Thanks.

Uleat
11-05-2012, 11:28 PM
I haven't followed it back to the database yet, but a shot in the dark says this is a problem...

[bots.cpp::DoClassAttacks()]
if(skill_to_use == FRENZY)
{
int AtkRounds = 3;
int skillmod = 100*GetSkill(FRENZY)/MaxSkill(FRENZY);
sint32 max_dmg = (26 + ((((GetLevel()-6) * 2)*skillmod)/100)) * ((100+RuleI(Combat, FrenzyBonus))/100);
sint32 min_dmg = 0;
DoAnim(anim2HSlashing);

int skillmod = 100*GetSkill(FRENZY)/MaxSkill(FRENZY) could be giving a 'divbyzero' error.

If anyone can look this up, the 'FRENZY' skill id is 74..I'm not near a database atm...


here is the reference code for 'MaxSkill':
uint16 SharedDatabase::GetSkillCap(int8 Class_, SkillType Skill, int8 Level) {
if(Class_ == 0)
return(0);
int SkillMaxLevel = RuleI(Character, SkillCapMaxLevel);
if (SkillMaxLevel < 1) {
SkillMaxLevel = RuleI(Character, MaxLevel);
}
if(Level > SkillMaxLevel){
return EMuShareMemDLL.SkillCaps.GetSkillCap(Class_-1, Skill, SkillMaxLevel);
}
else{
return EMuShareMemDLL.SkillCaps.GetSkillCap(Class_-1, Skill, Level);
}
}


Trackye: try leveling to 2(..3..4...) and see if this bot still crashes zone.

bad_captain
11-06-2012, 12:03 AM
I'll have to take a look. The code is basically a copy of Client:: DoClassAttacks, with a call to database.GetSkillCap(class_, skillid, level), so I'm not sure what would be different.


int16 Bot::MaxSkill(SkillType skillid, int16 class_, int16 level) const {
return(database.GetSkillCap(class_, skillid, level));
}

bad_captain
11-06-2012, 12:44 AM
After thinking about it, I can see how it differs from a client. Clients will only call this when the person uses a hotkey or something, so they would already have to have the skill, MaxSkill would never return 0. It may be an issue if they are charmed or something and call if while under AI control, but there aren't many times when a lvl 1 will be charmed. If that would even work.

I'll try to get a commit in soon to fix this.

A simple check to see if MaxSkill > 0 before assigning the skill mod should suffice, although then you'd have to declare skill mod before assigning to it.. Something like:


if(skill_to_use == FRENZY)
{
int AtkRounds = 3;
int skillmod = 0;

if(MaxSkill(FRENZY) > 0)
skillmod = 100*GetSkill(FRENZY)/MaxSkill(FRENZY);

sint32 max_dmg = (26 + ((((GetLevel()-6) * 2)*skillmod)/100)) * ((100+RuleI(Combat, FrenzyBonus))/100);
sint32 min_dmg = 0;
DoAnim(anim2HSlashing);


Although a more thorough check is probably warranted to see if there are any other similar issues.

Trackye
11-06-2012, 12:51 AM
Is it possible that it is due to the fact that Berserkers do not attain Frenzy until level 6? Maybe there should be some sort of a level check there?

bad_captain
11-06-2012, 12:54 AM
Yeah, but instead of hard coding a level check (which would work), a better solution would be to just check the skill level, since many custom servers may change the level classes receive certain skills. Just make sure they actually have at least a skill of 1 before using that line to set the skillmod.

Uleat
11-06-2012, 01:00 AM
I'll see what I can get from it tonight... I see what you're talking about though. The only difference I saw was where you initiated the timers.

If I run across something definitive, I'll post back.

Trackye
11-20-2012, 03:35 PM
To update this Bad_captain. The crashes did indeed stop once the bot was level 6+. Also i input your code into my core and it stopped the pre level 6 crashes as well.

bad_captain
11-20-2012, 06:11 PM
Thanks. I'll try to get this is as soon as I can.