EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Bots (https://www.eqemulator.org/forums/forumdisplay.php?f=676)
-   -   Enchanter mez code (https://www.eqemulator.org/forums/showthread.php?t=33814)

Criimson 07-07-2011 08:01 AM

Enchanter mez code
 
SO looking through some of the code I found an agro check and thought I'd start there.

But my C++ knowledge hasn't quite gotten to pointers. Ive only taken early classes at this point and am hoping somone can help.

Code:

//Criimson:  Testing AI mez code
                                        //Say("BotOwner = %s.", GetBotOwner());
                                        //Say("Target = %s.", GetTarget());
                                        //int testMez = (entity_list.GetHatedCount(GetBotOwner(), GetTarget()));
                                        //Say("The number of mobs I could mez is %s.", testMez);

This is the code I was working with. A simple check during the enchanter spell ai to see if the chanter can even see how many mobs the MT has agroing him.

Here is the actual code I am calling:

Code:

int EntityList::GetHatedCount(Mob *attacker, Mob *exclude) {

        // Return a list of how many non-feared, non-mezzed, non-green mobs, within aggro range, hate *attacker

        if(!attacker) return 0;

        int Count = 0;

        LinkedListIterator<NPC*> iterator(npc_list);

        for(iterator.Reset(); iterator.MoreElements(); iterator.Advance()) {

                NPC* mob = iterator.GetData();

                if(!mob || (mob == exclude)) continue;
               
                if(!mob->IsEngaged()) continue;

                if(mob->IsFeared() || mob->IsMezzed()) continue;

                if(attacker->GetLevelCon(mob->GetLevel()) == CON_GREEN) continue;

                if(!mob->CheckAggro(attacker)) continue;

                float AggroRange = mob->GetAggroRange();

                // Square it because we will be using DistNoRoot
                       
                AggroRange = AggroRange * AggroRange;

                if(mob->DistNoRoot(*attacker) > AggroRange) continue;

                Count++;

        }

        return Count;

}

I was hoping this code could be modified a bit to allow the enchanter bot to mez the adds.

I'm guessing I'm missing something simple

Criimson

louis1016 07-07-2011 10:20 AM

If you add in the mez spells to the enchanter bot spell list in the database with the proper spell type (i think 256?) they will mez adds.

Criimson 07-07-2011 10:53 AM

Thank you

I'll try that.
I did notice that the code seemed to be in place, but wasnt behaving.

Criimson

Criimson 07-07-2011 01:41 PM

I added a couple mes spells to the chanter bot list from:
Mes spells


Code:

INSERT INTO `npc_spells_entries` (`id`, `npc_spells_id`, `spellid`, `type`) VALUES (8146, 705, 292, 2048);
Is one of the early ones. And you are right the code starts to fire. !addMob starts spamming the screen during each fight, but even when there is an add it doesn't seem to realize it.

Testing with a level 15 group.

Code:

case SpellType_Mez: {
                        if (tar->GetBodyType() != BT_Giant) {
                                        if(!checked_los) {
                                                if(!CheckLosFN(tar))
                                                        break;        //cannot see target... we assume that no spell is going to work since we will only be casting detrimental spells in this call
                                               
                                                checked_los = true;
                                        }
                                       
                                        botSpell = GetBestBotSpellForMez(this);

                                        if(botSpell.SpellId == 0)
                                                break;

                                        Mob* addMob = GetFirstIncomingMobToMez(this, botSpell);

                                        if(!addMob){
                                                Say("!addMob.");
                                                break;}

                                        if(!(!addMob->IsImmuneToSpell(botSpell.SpellId, this) && addMob->CanBuffStack(botSpell.SpellId, botLevel, true) >= 0))
                                                break;
                                       
                                        castedSpell = AIDoSpellCast(botSpell.SpellIndex, addMob, botSpell.ManaCost);
                        }
                        break;
                                                        }
                default: {
                        break;
                                          }
        }

Did more testing and added a Say("") check where the mez should fire on add and it reaches the say, but no mezzing of any adds.

Criimson 07-07-2011 05:07 PM

Got it working after getting spells set up better. I think the Bot was trying to use a spell it couldn't on first tests, but unsure. Kind of weird, but after I added the line

Code:

//Criimson Added - Test code
                                        //Say("There is an add to be mezzed and I could use %d.", (botSpell.SpellId));

it started working.

Thank you for the advice of where to start work.

Criimson


All times are GMT -4. The time now is 08:47 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.