Jump to content
  • 0

After modifying a .cpp or a .h


syneau

Question

Posted

Hi all.

After modifying a .cpp or a.h file, what should I do ?

Should I generate again the build file with CMake and built the project with visual studio ?

4 answers to this question

Recommended Posts

Posted

Hello again,

Sorry for hijacking this thread but my problem may be related. I don't know how to do a cmake, could you provide a step by step explanation please?

I've been messing around a bit with sort of everything today and hit a snag with the following. I'm trying to add a script to the first boss in Deadmines (Rhahkzor). I just plain copied the script from Herod in Scarlet Monastery and removed the unnecessary bits. I updated the row in mangos.creature_template (UPDATE mangos.creature_template SET ainame = 'boss_rhahkzor' WHERE entry = 644). And compiled, but it doesn't seem to work. I've tried clearing the cache, although it would surprise me if this was the cause. Any help would be appreciated :)

#include "precompiled.h"
#include "deadmines.h"

enum
{
   SAY_AGGRO              = -22,

SPELL_SLAM			   = 6304,
   SPELL_RUSHINGCHARGE    = 8260,
   SPELL_CLEAVE           = 15496,
   SPELL_WHIRLWIND        = 8989,
   SPELL_FRENZY           = 8269
};

struct boss_rhahkzorAI : public ScriptedAI
{
   boss_rhahkzorAI(Creature* pCreature) : ScriptedAI(pCreature) {Reset();}

   bool m_bEnrage;

   uint32 m_uiCleaveTimer;
   uint32 m_uiWhirlwindTimer;

   void Reset() override
   {
       m_bEnrage     = false;

       m_uiCleaveTimer    = 7500;
       m_uiWhirlwindTimer = 14500;
   }

   void Aggro(Unit* /*pWho*/) override
   {
       DoScriptText(SAY_AGGRO, m_creature);
       DoCastSpellIfCan(m_creature, SPELL_RUSHINGCHARGE);
   }

   void UpdateAI(const uint32 uiDiff) override
   {
       if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
       {
           return;
       }

       // If we are < 30% hp enrage
       if (!m_bEnrage && m_creature->GetHealthPercent() <= 30.0f && !m_creature->IsNonMeleeSpellCasted(false))
       {
           if (DoCastSpellIfCan(m_creature, SPELL_FRENZY) == CAST_OK)
           {
               //DoScriptText(EMOTE_GENERIC_ENRAGED, m_creature);
               //DoScriptText(SAY_ENRAGE, m_creature);
               m_bEnrage = true;
           }
       }

       // Cleave
       if (m_uiCleaveTimer < uiDiff)
       {
           DoCastSpellIfCan(m_creature->getVictim(), SPELL_CLEAVE);
           m_uiCleaveTimer = urand(7500, 17500);
       }
       else
           { m_uiCleaveTimer -= uiDiff; }

       if (m_uiWhirlwindTimer < uiDiff)
       {
           if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_WHIRLWIND) == CAST_OK)
           {
               //DoScriptText(SAY_WHIRLWIND, m_creature);
               m_uiWhirlwindTimer = urand(15000, 25000);
           }
       }
       else
           { m_uiWhirlwindTimer -= uiDiff; }

       DoMeleeAttackIfReady();
   }
};

CreatureAI* GetAI_boss_rhahkzor(Creature* pCreature)
{
   return new boss_rhahkzorAI(pCreature);
}

void AddSC_boss_rhahkzor()
{
   Script* pNewScript;

   pNewScript = new Script;
   pNewScript->Name = "boss_rhahkzor";
   pNewScript->GetAI = &GetAI_boss_rhahkzor;
   pNewScript->RegisterSelf();
}

bdebaere

Posted

Hello!

Do you use the release20 branch? It is not recommended, "releases" are usually way outdated.

Again, there are 4 scripting engines with different capabilities. 1) SD2/SD3 (C++), 2) EventAI, 3) Eluna, and 4) simple DB scripts.

In release20, C++ scripts are bound through `creature_template`.`ScriptName` field.

In develop21, C++ scripts are bound through `script_binding` table.

In the both branches, `creature_template`.`AIName` field is related only to EventAI (DB-based scripting). Try

SELECT DISTINCT `AIName` FROM `creature_template`;

If this field contains string 'EventAI', then `creature_ai_scripts` table is consulted, with creature_template.entry=creature_ai_scripts.creature_id. Only single script (either of SD2, Eluna, EventAI) should serve a mob.

UPD. No need to clean the client cache after changing these fields, because they are never shown to the client. However, the server needs to be restarted.

UPD2. Forgot a warning. Adding the whole new C++ script file is a bit more complex procedure. Changes to ScriptLoader.cpp and to the corresponding cmake file are required. With pre-built sln, the new file should be added to the project manually. Developing without cmake will be inefficient though.

Posted
Hello!

Do you use the release20 branch? It is not recommended, "releases" are usually way outdated.

Again, there are 4 scripting engines with different capabilities. 1) SD2/SD3 (C++), 2) EventAI, 3) Eluna, and 4) simple DB scripts.

In release20, C++ scripts are bound through `creature_template`.`ScriptName` field.

In develop21, C++ scripts are bound through `script_binding` table.

In the both branches, `creature_template`.`AIName` field is related only to EventAI (DB-based scripting). Try

SELECT DISTINCT `AIName` FROM `creature_template`;

If this field contains string 'EventAI', then `creature_ai_scripts` table is consulted, with creature_template.entry=creature_ai_scripts.creature_id. Only single script (either of SD2, Eluna, EventAI) should serve a mob.

UPD. No need to clean the client cache after changing these fields, because they are never shown to the client. However, the server needs to be restarted.

UPD2. Forgot a warning. Adding the whole new C++ script file is a bit more complex procedure. Changes to ScriptLoader.cpp and to the corresponding cmake file are required. With pre-built sln, the new file should be added to the project manually. Developing without cmake will be inefficient though.

I'm an idiot. Changed the query to

UPDATE mangos.creature_template SET ainame = '', scriptname = 'boss_rhahkzor' WHERE entry = 644

I updated ScriptLoader.cpp and it's header file.

It's working now. Thank you.

bdebaere

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use