• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

C++ Scripted AI Question

Status
Not open for further replies.

Deewad

Respected Member
Alright, So what im trying to do here is make the creature stop movement, (Hes an Hunter) And want him to continuously fire Arcane shot, And Venom strike, And hunter skills like that, Which I can specify, Which I have equipped to him in the equipment template.
Im looking for a skeleton of how this would work, And is it all in Enter Combat? Or will I need to place more code in the rest of the script? Its a template for scriptedAI In which I found here on EmuDev,
Please, If you decide to help me with this to be rather descriptive so I can understand more of how this works, Here is the full code


Code:
/*
 *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗ 
 *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣
 *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║
 *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝
 *       EmuDevs - (http://emudevs.com)
*/

class Daravan_Scount : public CreatureScript // Daravan_Scount - Class constructor, name this anything that doesn't conflict with another name
{
public:
    Daravan_Scount() : CreatureScript("Daravan_Scount") { } // Daravan_Scount, should be the same as class Daravan_Scount -- CreatureScript("Daravan_Scount") - This is your 'ScriptName' that you will assign in your database

    struct npc_tutAI : public ScriptedAI // npc_tutAI - Structure name. This can be anything that doesn't conflict with your class constructor. 'public ScriptedAI', We're using ScriptedAI, so we call it
    {
        npc_tutAI(Creature* creature) : ScriptedAI(creature) { } // Setting up

        void Reset() // This will be called once the npc resets. (OnSpawn, OnCombatLeave, etc)
        {
        }

        void UpdateAI(uint32 diff) // This function updates every 100 or 1000 (I believe) and is used for the timers, etc
        {
        }

        void EnterCombat(Unit* /*target*/) // This calls when the npc enters combat
        {
			
        }

        void JustDied(Unit* /*killer*/) // This calls when the npc dies
        {
        }

        void KilledUnit(Unit* /*victim*/) // This calls when the npc kills a unit
        {
        }
    };

    CreatureAI* GetAI(Creature* creature) const // We then return new 'npc_tutAI' so the script will load and work ingame
    {
        return new npc_tutAI(creature);
    }
};

void AddSC_ai_tutorial() // This is your ScriptLoader.cpp setup function
{
    new Daravan_Scount(); // Call any new classes here as 'new classname();'
}


Thanks in Advance!
 

Tommy

Founder
TrinityCore doesn't have working 'Ranged' AI (Bows, guns, etc). But, you would put the stop movement on, "Reset()"

Here is the correct function:

Code:
SetCombatMovement(false);

And your Reset should look like:

Code:
        void Reset() // This will be called once the npc resets. (OnSpawn, OnCombatLeave, etc)
        {
          SetCombatMovement(false);
        }

Don't see how I can be further descriptive about that. XD
 
Status
Not open for further replies.
Top