Merge branch 'master' of gitlab.com:azerothshard/azerothcore

This commit is contained in:
Yehonal
2016-08-05 09:31:32 +02:00
3 changed files with 199 additions and 1 deletions
@@ -0,0 +1,9 @@
DROP TABLE IF EXISTS `azth_character_morph`;
CREATE TABLE `azth_character_morph`(
`guid` INT NOT NULL,
`entry` INT NOT NULL,
`name` TEXT,
`comment` TEXT
);
ALTER TABLE `azth_character_morph`
ADD CONSTRAINT `azth_character_morph` UNIQUE(guid, entry);
@@ -0,0 +1,22 @@
UPDATE `item_template` SET `Flags` = 64, `ScriptName` = 'azth_main_morph', stackable = 1, `spellid_1` = 36177, maxcount = 5 WHERE (entry = 32561);
DROP TABLE IF EXISTS `azth_morph_template`;
CREATE TABLE `azth_morph_template`(
`entry` INT NOT NULL UNIQUE,
`flags` INT DEFAULT 0,
`default_name` TEXT,
`scale` FLOAT DEFAULT 1,
`aura` INT DEFAULT -1,
`comment` TEXT
);
-- some morph
DELETE FROM `azth_morph_template` WHERE entry = 1060;
INSERT INTO `azth_morph_template` VALUES (1060, 0, "MUCCA!", 3, 17, "prova muccaaa");
UPDATE `item_template` SET `Flags` = 64, `ScriptName` = 'azth_get_morph', `spellid_1` = 36177, stackable = 1060, NAME = "Mucca" WHERE (entry = 32543);
DELETE FROM `azth_morph_template` WHERE entry = 30721;
INSERT INTO `azth_morph_template` VALUES (30721, 0, "The Lich King", 3, 17, "Lich King Morph");
UPDATE `item_template` SET `Flags` = 64, `ScriptName` = 'azth_get_morph', `spellid_1` = 36177, stackable = 30721, NAME = "The Lich King" WHERE (entry = 32544);
@@ -8,6 +8,9 @@
#include "WorldPacket.h"
#include "Chat.h"
#include "Spell.h"
#include "Define.h"
#include "GossipDef.h"
#include "Item.h"
#define GOSSIP_ITEM_GIVE_PVE_QUEST "Vorrei ricevere la mia missione PVE giornaliera."
@@ -336,10 +339,174 @@ class item_azth_hearthstone_loot_sack : public ItemScript
}
};
class azth_main_morph : public ItemScript
{
public:
azth_main_morph() : ItemScript("azth_main_morph") { }
bool OnUse(Player* player, Item* item, SpellCastTargets const& /*targets*/) override // Any hook here
{
player->PlayerTalkClass->ClearMenus();
std::string part1 = "SELECT entry, name FROM azth_character_morph WHERE guid = ";
std::string part2 = " LIMIT 0, 200000; ";
std::string temp = part1 + std::to_string(player->GetGUID()) + part2;
const char *query = temp.c_str();
QueryResult result = CharacterDatabase.Query(query);
if (result.null())
return false;
do
{
Field* fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
std::string name = fields[1].GetString();
if (name == "" || name.empty())
{
std::string part1 = "SELECT default_name FROM azth_morph_template WHERE entry = ";
std::string part2 = " LIMIT 0, 200000; ";
std::string temp = part1 + std::to_string(entry) + part2;
const char *query = temp.c_str();
QueryResult result = WorldDatabase.Query(query);
Field* fields = result->Fetch();
name = fields[0].GetString();
}
player->ADD_GOSSIP_ITEM(0, name, GOSSIP_SENDER_MAIN, entry);
} while (result->NextRow());
player->ADD_GOSSIP_ITEM(0, "Demorph", GOSSIP_SENDER_MAIN, 1);
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, item->GetGUID());
return false; // Cast the spell on use normally
}
void OnGossipSelect(Player* player, Item* /*item*/, uint32 /*sender*/, uint32 action) override
{
player->PlayerTalkClass->ClearMenus();
uint32 entry;
if (action == 1)
entry = player->GetDisplayId();
else
entry = action;
std::string part1 = "SELECT flags, scale, aura FROM azth_morph_template WHERE entry = ";
std::string part2 = " LIMIT 0, 1; ";
std::string temp = part1 + std::to_string(entry) + part2;
const char *query = temp.c_str();
QueryResult result = WorldDatabase.Query(query);
if (result.null())
{
player->CLOSE_GOSSIP_MENU();
return;
}
Field* fields = result->Fetch();
uint32 flags = fields[0].GetUInt32();
float scale = fields[1].GetFloat();
uint32 aura = 0;
if (fields[2].GetInt32() != -1)
aura = fields[2].GetUInt32();
switch (action)
{
case 1:
player->DeMorph();
player->SetObjectScale(1);
if (aura > 0)
player->RemoveAura(aura, AURA_REMOVE_BY_DEFAULT);
break;
default:
player->SetDisplayId(action);
player->SetObjectScale(scale);
if (aura > 0)
player->AddAura(aura, player);
//if (flags > 0)
// do something
break;
}
player->CLOSE_GOSSIP_MENU();
}
};
class azth_get_morph : public ItemScript
{
public:
azth_get_morph() : ItemScript("azth_get_morph") { }
bool OnUse(Player* player, Item* item, SpellCastTargets const& /*targets*/) override // Any hook here
{
player->PlayerTalkClass->ClearMenus();
player->ADD_GOSSIP_ITEM(0, "Aggiungi senza soprannome.", GOSSIP_SENDER_MAIN, 1);
player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_CHAT, "Aggiungi con soprannome.", GOSSIP_SENDER_MAIN, 2, "Scrivi un soprannome per questa skin.", 0, true);
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, item->GetGUID());
return false;
}
void OnGossipSelect(Player* player, Item* item, uint32 /*sender*/, uint32 action) override
{
player->PlayerTalkClass->ClearMenus();
if (action != 1)
return;
std::string part1 = "REPLACE INTO azth_character_morph (guid, entry) VALUES (";
std::string part2 = ");";
std::string part3 = ",";
std::string temp = part1 + std::to_string(player->GetGUID()) + part3 + std::to_string(item->GetMaxStackCount()) + part2;
const char *query = temp.c_str();
QueryResult result = CharacterDatabase.Query(query);
player->CLOSE_GOSSIP_MENU();
}
void OnGossipSelectCode(Player* player, Item* item, uint32 /*sender*/, uint32 action, const char* code) override
{
player->PlayerTalkClass->ClearMenus();
if (code == "" || *code == 0)
{
ChatHandler(player->GetSession()).SendSysMessage("Verrà salvata la skin senza soprannome!");
}
if (action != 2)
return;
std::string part1 = "REPLACE INTO azth_character_morph (guid, entry, name) VALUES (";
std::string part2 = ");";
std::string part3 = ",";
std::string apici = "\"";
std::string temp = part1 + std::to_string(player->GetGUID()) + part3 + std::to_string(item->GetMaxStackCount()) + part3 + apici + code + apici + part2;
const char *query = temp.c_str();
QueryResult result = CharacterDatabase.Query(query);
player->CLOSE_GOSSIP_MENU();
}
};
void AddSC_hearthstone()
{
new npc_han_al();
new npc_azth_vendor();
new item_azth_hearthstone_loot_sack();
new azth_main_morph();
new azth_get_morph();
}