Tutorial de Script C++ World of Warcraft 3

Iniciado por Nuzak, Abr 20, 2025, 02:29 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Abr 20, 2025, 02:29 PM Ultima modificación: Abr 22, 2025, 12:01 PM por Syrus
Todos los créditos a mariodanny91 por su publicación original en WoWCreador
Tutorial de Script C++ World of Warcraft 3:

En esta guía, enseñaré una de las maneras de hacer un script C++ para el emulador JadeCore que está basado en TrinityCore antiguo. Les servirá de conocimiento base para otros emuladores más actualizados y motivarlos a investigar mas sobre el tema. Vale aclarar que todo lo planteado aquí es de manera autodidacta no soy programador, solo comparto lo que he aprendido.

Para esta guia deben tener instalado Visual Studio, Cmake y otras dependencias que exija el core ya sea OpenSSL,Boost,Mysql en sus versiones x86 o x64.


Tutoriales anteriores:
You are not allowed to view links. Register or Login
You are not allowed to view links. Register or Login

Punto sobre los cuales hablare:
-Como hacer un Areatrigger en C++.

Estructura del Script.
Esta es una plantilla de Script de la cual partiremos:

* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptPCH.h"
enum Npc
{
};
enum Movie
{
};
enum Quest
{
   
};
class AreaTrigger_tutorial: public AreaTriggerScript
{
public:
    AreaTrigger_tutorial() : AreaTriggerScript("AreaTrigger_tutorial")
    {
       
    }
};
void AddSC_tutorial()
{
    new AreaTrigger_tutorial();
}

1-Enumerar los datos que vamos a utilizar:
enum Npc
{
    NPC_KILLCREDIT = 123,
};
enum Movie
{
    MOVIE = 321,
};
enum Quest
{
    QUEST_X    = 12345,
};

2-Explicar cada funcion:

-Cuando el player entra área y se activa el areatrigger.

bool OnTrigger(Player* player, AreaTriggerEntry const* trigger)    {return false;}
3-Le agregamos una condicion:
if (player->GetQuestStatus(QUEST_X) == QUEST_STATUS_INCOMPLETE)
{
   
}

El Script deberia ir quedando asi:

/*
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "ScriptPCH.h"
enum Npc
{
    NPC_KILLCREDIT = 123,
};
enum Movie
{
    MOVIE = 321,
};
enum Quest
{
    QUEST_X    = 12345,
};
class AreaTrigger_tutorial : public AreaTriggerScript
{
public:
    AreaTrigger_tutorial() : AreaTriggerScript("AreaTrigger_tutorial")
    {
    }
    bool OnTrigger(Player* player, AreaTriggerEntry const* trigger)
    {
       
        if (player->GetQuestStatus(QUEST_X) == QUEST_STATUS_INCOMPLETE)
        {
            player->KilledMonsterCredit(NPC_KILLCREDIT, 0);
            player->SendMovieStart(MOVIE);
        }
       
        return false;
    }
};
   
void AddSC_tutorial()
{
    new AreaTrigger_tutorial();
}

Explico que hace el AreaTrigger_tutorial sencillo:

Si el player tiene la mision X incompleta, cuando entre al área se activa el areatrigger y

le cumple un objectivo de la mision X y le muestra un video.
*(no se debe hacer con misiones de mas de un objectivo, puede generar bucle o crash ya que mientra el player

tenga la mision incompleta y este en el area se va a seguir ejecutando el areatrigger).


*El ID del video lo encontramos en Movie.dbc y podemos ir mirando cuales son con el comando
.debug play movie

Syntax: .debug play movie #movieid (Play movie #movieid for you.)


*El killcredit esta definido en creature_template, columna KillCredit1 o KillCredit2 y tiene relacion con el objectivo de la mision en quest_template,
columna RequiredNpcOrGo1-10.



Ahora vamos a la parte de SQL:

Este script debemos vincularlo con la base de datos en la tabla areatrigger_scripts, la entry del areatrigger se encuentra en Areatrigger.dbc.
Para saber cual es utilizamos el comando (solo funciona estando en GM ON):

.debug areatriggers
Syntax: .debug areatriggers (Toggle debug mode for areatriggers. In debug mode GM will be notified if reaching an areatrigger)

Nos ira mostrando en el chat el id del areatrigger a medida que entremos y salgamos de las areas, escojemos el que necesitamos y ese será el entry.

En ScriptName es el nombre del script AreaTrigger_tutorial.

DELETE FROM areatrigger_scripts WHERE entry=1234;
INSERT INTO `areatrigger_scripts`(`entry`, `ScriptName`) VALUES
(1234, 'AreaTrigger_tutorial');

*No ejecuten este ejemplo en su base de datos, puede que no coincida con ningun areatrigger.


Compilamos y que lo disfruten.
  •