Pierre d'aura et de transformations
Voilà encore un petit patch bien sympa Clin

Il permet de pouvoir créez des pierres d'auras et de morph simplement dans la BDD

Exemple d'objets :

Code :
INSERT INTO `item_template` VALUES ('90000', '15', '0', '0', 'Pierre de neige', '44368', '1', '0', '0', '1', '0', '0', '0', '-1', '-1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '18282', '0', '0', '0', '-1', '0', '-1', '0', '0', '0', '0', '-1', '0', '-1', '0', '0', '0', '0', '-1', '0', '-1', '0', '0', '0', '0', '-1', '0', '-1', '0', '0', '0', '0', '-1', '0', '-1', '4', 'Cette pierre projète un froid infernal !', '0', '0', '0', '0', '0', '-1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '-1', '0', '0', '0', '0', 'item_aura_stone', '0', '0', '0', '0', '0');

dans la table stone_aura

ajouter une entry égal à 90000 et une AuraId égal à 74939 ajouter le commentaire que vous voulez c'est pour vous souvenir !

Et hop la pierre est créez

Diff :

Code :
From b1635ef5b899928cb3223257de6a3be56298ec0e Mon Sep 17 00:00:00 2001
From: totomakers <[email protected]>
Date: Sat, 19 Mar 2011 22:33:20 +0100
Subject: [PATCH] Database Stone System add.

Signed-off-by: totomakers <[email protected]>
---
addition/[world]stone_aura.sql                 |    8 +
addition/[world]stone_morph.sql                |    9 ++
src/server/game/CMakeLists.txt                 |    1 +
src/server/game/Scripting/ScriptLoader.cpp     |    6 +-
src/server/game/World/World.cpp                |    3 +
src/server/scripts/Custom/CMakeLists.txt       |    4 +
src/server/scripts/Custom/Stone.cpp            |  166 ++++++++++++++++++++++++
src/server/scripts/Custom/Stone.h              |   95 ++++++++++++++
src/server/scripts/Custom/item_aura_stone.cpp  |   55 ++++++++
src/server/scripts/Custom/item_morph_stone.cpp |   62 +++++++++
10 files changed, 407 insertions(+), 2 deletions(-)
create mode 100644 addition/[world]stone_aura.sql
create mode 100644 addition/[world]stone_morph.sql
create mode 100644 src/server/scripts/Custom/Stone.cpp
create mode 100644 src/server/scripts/Custom/Stone.h
create mode 100644 src/server/scripts/Custom/item_aura_stone.cpp
create mode 100644 src/server/scripts/Custom/item_morph_stone.cpp

diff --git a/addition/[world]stone_aura.sql b/addition/[world]stone_aura.sql
new file mode 100644
index 0000000..5537737
--- /dev/null
+++ b/addition/[world]stone_aura.sql
@@ -0,0 +1,8 @@
+CREATE TABLE IF NOT EXISTS `stone_aura` (
+    `item_entry` int(10) unsigned NOT NULL default '0',
+    `auraId` int(10) NOT NULL default '0',
+    `comment` longtext NOT NULL default '',
+    PRIMARY KEY    (`item_entry`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;
+
+INSERT INTO command (`name`, `security`, `help`) VALUES ('reload stone_aura', 3, 'Syntax : .reload stone_aura');
\ No newline at end of file
diff --git a/addition/[world]stone_morph.sql b/addition/[world]stone_morph.sql
new file mode 100644
index 0000000..8b6ab32
--- /dev/null
+++ b/addition/[world]stone_morph.sql
@@ -0,0 +1,9 @@
+CREATE TABLE IF NOT EXISTS `stone_morph` (
+    `item_entry` int(10) unsigned NOT NULL default '0',
+    `morphId` int(10) NOT NULL default '0',
+    `size` float NOT NULL default '1',
+    `comment` longtext NOT NULL default '',
+    PRIMARY KEY    (`item_entry`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;
+
+INSERT INTO command (`name`, `security`, `help`) VALUES ('reload stone_morph', 3, 'Syntax : .reload stone_morph');
\ No newline at end of file
diff --git a/src/server/game/CMakeLists.txt b/src/server/game/CMakeLists.txt
index 323a3ac..08d8a1b 100644
--- a/src/server/game/CMakeLists.txt
+++ b/src/server/game/CMakeLists.txt
@@ -190,6 +190,7 @@ include_directories(
   ${CMAKE_CURRENT_SOURCE_DIR}/Weather
   ${CMAKE_CURRENT_SOURCE_DIR}/World
   ${CMAKE_SOURCE_DIR}/src/server/scripts/PrecompiledHeaders
+  ${CMAKE_SOURCE_DIR}/src/server/scripts/Custom
   ${ACE_INCLUDE_DIR}
   ${MYSQL_INCLUDE_DIR}
   ${OPENSSL_INCLUDE_DIR}
diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp
index cb1b2c8..ed9a143 100755
--- a/src/server/game/Scripting/ScriptLoader.cpp
+++ b/src/server/game/Scripting/ScriptLoader.cpp
@@ -1203,13 +1203,15 @@ void AddBattlegroundScripts()

#ifdef SCRIPTS
/* This is where custom scripts' loading functions should be declared. */
-
+    void AddSC_item_morph_stone();
+    void AddSC_item_aura_stone();
#endif

void AddCustomScripts()
{
#ifdef SCRIPTS
     /* This is where custom scripts should be added. */
-
+    AddSC_item_morph_stone();
+    AddSC_item_aura_stone();
#endif
}
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index be7c17b..b20feb4 100755
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -71,6 +71,7 @@
#include "CreatureTextMgr.h"
#include "SmartAI.h"
#include "Channel.h"
+#include "Stone.h"

volatile bool World::m_stopEvent = false;
uint8 World::m_ExitCode = SHUTDOWN_EXIT_CODE;
@@ -1615,6 +1616,8 @@ void World::SetInitialWorldSettings()

     sLog->outString("Loading SmartAI scripts...");
     sSmartScriptMgr->LoadSmartAIFromDB();
+    
+    sStone->LoadStone();

     ///- Initialize game time and timers
     sLog->outString("Initialize game time and timers");
diff --git a/src/server/scripts/Custom/CMakeLists.txt b/src/server/scripts/Custom/CMakeLists.txt
index 0dec843..eb09589 100644
--- a/src/server/scripts/Custom/CMakeLists.txt
+++ b/src/server/scripts/Custom/CMakeLists.txt
@@ -1,5 +1,9 @@
set(scripts_STAT_SRCS
   ${scripts_STAT_SRCS}
+    Custom/Stone.h
+    Custom/Stone.cpp
+    Custom/item_aura_stone.cpp
+    Custom/item_morph_stone.cpp
)

message("  -> Prepared: Custom")
diff --git a/src/server/scripts/Custom/Stone.cpp b/src/server/scripts/Custom/Stone.cpp
new file mode 100644
index 0000000..5c6290f
--- /dev/null
+++ b/src/server/scripts/Custom/Stone.cpp
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
+ *
+ * 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/>.
+ *
+ *
+ * Copyright (C) SyldriasCore
+ * Travaille de la communauté Française libre de droit.
+ */
+
+#include "Common.h"
+#include "DatabaseEnv.h"
+#include "SQLStorage.h"
+#include "SQLStorageImpl.h"
+#include "Log.h"
+#include "MapManager.h"
+#include "ObjectMgr.h"
+#include "SpellMgr.h"
+#include "UpdateMask.h"
+#include "World.h"
+#include "Group.h"
+#include "Guild.h"
+#include "ArenaTeam.h"
+#include "Transport.h"
+#include "Language.h"
+#include "GameEventMgr.h"
+#include "Spell.h"
+#include "Chat.h"
+#include "AccountMgr.h"
+#include "InstanceSaveMgr.h"
+#include "SpellAuras.h"
+#include "Util.h"
+#include "WaypointManager.h"
+#include "GossipDef.h"
+#include "Vehicle.h"
+#include "AchievementMgr.h"
+#include "DisableMgr.h"
+#include "ScriptMgr.h"
+#include "SpellScript.h"
+#include "PoolMgr.h"
+#include "ObjectMgr.h"
+#include "Stone.h"
+
+Stone::~Stone()
+{
+}
+
+Stone::Stone()
+{
+}
+
+void Stone::LoadStone()
+{
+    sLog->outString("Loading Aura stone...");
+    sStone->LoadAuraStone();
+    sLog->outString("Loading Morph stone...");
+    sStone->LoadMorphStone();
+}
+
+// Aura Stone
+void Stone::LoadAuraStone()
+{
+    uint32 oldMSTime = getMSTime();
+    
+    m_aurastone.clear();
+    
+    QueryResult result = WorldDatabase.Query("SELECT item_entry,auraId FROM stone_aura");
+    
+    if (!result)
+    {
+        sLog->outString(">> Loaded 0 Stone aura. DB table `stone_aura` is empty.");
+        sLog->outString();
+        return;
+    }
+    
+    uint32 count = 0;
+    
+    do
+    {
+        Field *fields = result->Fetch();
+        
+        uint32 item_entry = fields[0].GetUInt32();
+        uint32 auraId = fields[1].GetUInt32();
+        
+        m_aurastone[item_entry] = auraId;
+        
+        ++count;
+    }
+    while (result->NextRow());
+    
+    sLog->outString(">> Loaded %u Aura stone in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
+    sLog->outString();
+}
+
+uint32 Stone::GetAuraStone(uint32 itemId)
+{
+     AuraStone::const_iterator itr = m_aurastone.find(itemId);
+    
+     if (itr == m_aurastone.end()) return NULL;
+            
+    return itr->second;
+}
+
+// Morph Stone
+
+void Stone::LoadMorphStone()
+{
+    uint32 oldMSTime = getMSTime();
+    
+    m_morphstone.clear();
+    
+    QueryResult result = WorldDatabase.Query("SELECT item_entry,morphId,size FROM stone_morph");
+    
+    if (!result)
+    {
+        sLog->outErrorDb(">> Loaded 0 Stone morph. DB table `stone_morph` is empty !");
+        sLog->outString();
+        return;
+    }
+    
+    uint32 count = 0;
+    
+    do
+    {
+        Field *fields = result->Fetch();
+        
+        uint32 item_entry = fields[0].GetUInt32();
+        
+        MorphStoneData morphstone;
+        
+        morphstone.morphId = fields[1].GetUInt32();
+        morphstone.size = fields[2].GetFloat();
+        
+        m_morphstone[item_entry] = morphstone;
+
+        if(morphstone.size > 10.0f || morphstone.size < 0.1f)
+            sLog->outError("Morph stone id %u have invalid size update. (>10 ou <0.1)", item_entry);
+        
+        ++count;
+    }
+    while (result->NextRow());
+    
+    sLog->outString(">> Loaded %u Stone morph in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
+    sLog->outString();
+}
+
+MorphStoneData const* Stone::GetMorphStone(uint32 itemId) const
+{
+     MorphStone::const_iterator itr = m_morphstone.find(itemId);
+    
+     if (itr == m_morphstone.end()) return NULL;
+    
+    return &itr->second;
+}
diff --git a/src/server/scripts/Custom/Stone.h b/src/server/scripts/Custom/Stone.h
new file mode 100644
index 0000000..df757f1
--- /dev/null
+++ b/src/server/scripts/Custom/Stone.h
@@ -0,0 +1,95 @@
+ /*
+ * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
+ *
+ * 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/>.
+ *
+ *
+ * Copyright (C) SyldriasCore
+ * Travaille de la communauté Française libre de droit.
+ */
+
+#ifndef _STONE_H
+#define _STONE_H
+
+#include "Log.h"
+#include "Object.h"
+#include "Bag.h"
+#include "Creature.h"
+#include "Player.h"
+#include "DynamicObject.h"
+#include "GameObject.h"
+#include "Corpse.h"
+#include "QuestDef.h"
+#include "ItemPrototype.h"
+#include "NPCHandler.h"
+#include "DatabaseEnv.h"
+#include "Mail.h"
+#include "Map.h"
+#include "ObjectAccessor.h"
+#include "ObjectDefines.h"
+#include <ace/Singleton.h>
+#include "SQLStorage.h"
+#include "Vehicle.h"
+#include <string>
+#include <map>
+#include <limits>
+#include "ConditionMgr.h"
+
+//== Stone System =================================================
+
+//== Morph Stone ===
+
+struct MorphStoneData
+{
+    uint32 morphId;
+    float size;
+};
+
+typedef UNORDERED_MAP<uint32, MorphStoneData> MorphStone;
+
+//== Aura Stone ===
+        
+typedef UNORDERED_MAP<uint32, uint32> AuraStone;
+
+class Stone
+{
+    friend class ACE_Singleton<Stone, ACE_Null_Mutex>;
+    ~Stone();
+    Stone();
+    
+    public:
+        void LoadStone();/// Function for load aura stone and morph stone.
+        
+        /* Aura Stone*/
+        void LoadAuraStone();
+        uint32 Stone::GetAuraStone(uint32 itemId);
+        
+        /* Morph Stone */
+        void LoadMorphStone();
+        MorphStoneData const* Stone::GetMorphStone(uint32 itemId) const;
+        
+    protected:
+        
+        AuraStone m_aurastone;
+        MorphStone m_morphstone;
+    
+    private:
+        
+};
+
+
+
+#define sStone ACE_Singleton<Stone, ACE_Null_Mutex>::instance()
+#endif
diff --git a/src/server/scripts/Custom/item_aura_stone.cpp b/src/server/scripts/Custom/item_aura_stone.cpp
new file mode 100644
index 0000000..7b1f329
--- /dev/null
+++ b/src/server/scripts/Custom/item_aura_stone.cpp
@@ -0,0 +1,55 @@
+ /*
+ * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
+ *
+ * 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/>.
+ *
+ *
+ * Copyright (C) SyldriasCore
+ * Travaille de la communauté Française libre de droit.
+ */
+
+
+#include "ScriptPCH.h"
+#include "Spell.h"
+#include "ObjectMgr.h"
+#include "Stone.h"
+
+class item_aura_stone : public ItemScript
+{
+public:
+    item_aura_stone() : ItemScript("item_aura_stone") { }
+    
+    bool OnUse(Player* pPlayer, Item* pItem, const SpellCastTargets & /*pTargets*/)
+    {
+        uint32 itemId = pItem->GetEntry();
+        uint32 auraId = sStone->GetAuraStone(itemId);
+        
+        if(auraId==NULL)
+            return true;
+        
+        if (pPlayer->HasAura(auraId))
+            pPlayer->RemoveAurasDueToSpell(auraId);
+        else
+            pPlayer->CastSpell(pPlayer, auraId, true);
+    
+            
+        return true;
+    }
+};
+
+void AddSC_item_aura_stone()
+{
+    new item_aura_stone;
+}
diff --git a/src/server/scripts/Custom/item_morph_stone.cpp b/src/server/scripts/Custom/item_morph_stone.cpp
new file mode 100644
index 0000000..e0eab91
--- /dev/null
+++ b/src/server/scripts/Custom/item_morph_stone.cpp
@@ -0,0 +1,62 @@
+ /*
+ * Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
+ *
+ * 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/>.
+ *
+ *
+ * Copyright (C) SyldriasCore
+ * Travaille de la communauté Française libre de droit.
+ */
+
+
+#include "ScriptPCH.h"
+#include "Spell.h"
+#include "ObjectMgr.h"
+#include "Stone.h"
+
+bool isMorph = false;
+
+class item_morph_stone : public ItemScript
+{
+public:
+    item_morph_stone() : ItemScript("item_morph_stone") { }
+    
+    bool OnUse(Player* pPlayer, Item* pItem, const SpellCastTargets & /*pTargets*/)
+    {
+        uint32 itemId = pItem->GetEntry();
+        const MorphStoneData *MorphStone = sStone->GetMorphStone(itemId);
+        
+        if(MorphStone==NULL)
+            return true;
+        
+        if(!isMorph)
+        {
+            isMorph = true;
+            pPlayer->SetDisplayId(MorphStone->morphId);
+            pPlayer->SetFloatValue(OBJECT_FIELD_SCALE_X, MorphStone->size);
+            return true;
+        }
+        
+        isMorph = false;
+        pPlayer->DeMorph();
+        pPlayer->SetFloatValue(OBJECT_FIELD_SCALE_X,1.0f);
+        return true;
+    }
+};
+
+void AddSC_item_morph_stone()
+{
+    new item_morph_stone;
+}
--
1.7.3.1.msysgit.0
Intéressant ! Merci pour le partage ! Smile

Retourner en haut Accueil