VIPSergey | Дата: Вторник, 10.07.2012, 15:25 | Сообщение # 3 |
Скаут
Группа: Пользователи
Сообщений: 5
Награды: 0
Репутация: 5
Статус:
| ТРЕНЕР ПРОФЕССИЙ
From 4d8af224da85a510d5a52a8c09e692dae64c398c Mon Sep 17 00:00:00 2001 From: LordPsyan <uppp@juno.com> Date: Wed, 16 Feb 2011 09:50:20 -0500 Subject: [PATCH] 11228-Profession_Npc
--- src/server/game/Scripting/ScriptLoader.cpp | 5 + src/server/scripts/Custom/CMakeLists.txt | 1 + src/server/scripts/Custom/professionnpc.cpp | 367 ++++++++++++++++++++++++++ src/server/worldserver/worldserver.conf.dist | 33 +++- 4 files changed, 405 insertions(+), 1 deletions(-) create mode 100644 src/server/scripts/Custom/professionnpc.cpp
diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp index 49544ca..831cd97 100755 --- a/src/server/game/Scripting/ScriptLoader.cpp +++ b/src/server/game/Scripting/ScriptLoader.cpp @@ -43,6 +43,9 @@ void AddSC_example_spell_scripts(); void AddSC_SmartSCripts(); +//Custom +void AddSC_professionnpc(); + //Commands void AddSC_account_commandscript(); void AddSC_achievement_commandscript(); @@ -1216,5 +1219,7 @@ void AddCustomScripts() #ifdef SCRIPTS /* This is where custom scripts should be added. */ + // Profession Npc + AddSC_professionnpc(); #endif } diff --git a/src/server/scripts/Custom/CMakeLists.txt b/src/server/scripts/Custom/CMakeLists.txt index 0dec843..84d19ca 100644 --- a/src/server/scripts/Custom/CMakeLists.txt +++ b/src/server/scripts/Custom/CMakeLists.txt @@ -1,5 +1,6 @@ set(scripts_STAT_SRCS ${scripts_STAT_SRCS} + Custom/professionnpc.cpp ) message(" -> Prepared: Custom") diff --git a/src/server/scripts/Custom/professionnpc.cpp b/src/server/scripts/Custom/professionnpc.cpp new file mode 100644 index 0000000..c5c9d07 --- /dev/null +++ b/src/server/scripts/Custom/professionnpc.cpp @@ -0,0 +1,367 @@ +/* Copyright (C) 2006 - 2009 ScriptDev2 <https://scriptdev2.svn.sourceforge.net/> + * Rewritten by LordPsyan <http://www.l33t-net.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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* ScriptData +SDName: professionnpc +SD%Complete: 100 +SDComment: Profession Master +SDCategory: NPC +EndScriptData */ + +#include "ScriptPCH.h" +#include "Config.h" + +class professionnpc : public CreatureScript +{ +public: + professionnpc() : CreatureScript("professionnpc") {} + + +bool OnGossipHello(Player* pPlayer, Creature* pCreature) +{ + if(sConfig->GetBoolDefault("ProfessionNPC.OnlyGMs", false)) // If ProfessionNPC.OnlyGMs is enabled in trinitycore.conf + if (pPlayer->GetSession()->GetSecurity() == SEC_PLAYER) + { + pCreature->MonsterWhisper("Sorry, I can only trade to game masters.", pPlayer->GetGUID()); + return true; + } + + bool EnableProfessions = sConfig->GetBoolDefault("ProfessionNPC.EnableProfessions", true); + bool EnableSecondarySkills = sConfig->GetBoolDefault("ProfessionNPC.EnableSecondarySkills", true); + + // Main Menu for Alliance + if (pPlayer->GetTeam() == ALLIANCE) + { + // Check config if "Professions" is enabled or not + if(EnableProfessions) + pPlayer->ADD_GOSSIP_ITEM( 7, "Professions ->" , GOSSIP_SENDER_MAIN, 1000); + // Check config if "Secondary Skills" is enabled or not + if(EnableSecondarySkills) + pPlayer->ADD_GOSSIP_ITEM( 7, "Secondary Skills ->" , GOSSIP_SENDER_MAIN, 2000); + } + else // Main Menu for Horde + { + // Check config if "Professions" is enabled or not + if(EnableProfessions) + pPlayer->ADD_GOSSIP_ITEM( 7, "Professions ->" , GOSSIP_SENDER_MAIN, 1000); + // Check config if "Secondary Skills" is enabled or not + if(EnableSecondarySkills) + pPlayer->ADD_GOSSIP_ITEM( 7, "Secondary Skills ->" , GOSSIP_SENDER_MAIN, 2000); + } + + pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,pCreature->GetGUID()); + +return true; +} + +void SendDefaultMenu(Player* pPlayer, Creature* pCreature, uint32 uiAction) +{ + +// Not allow in combat +if (pPlayer->isInCombat()) +{ + pPlayer->CLOSE_GOSSIP_MENU(); + pCreature->MonsterSay("You are in combat!", LANG_UNIVERSAL, NULL); + return; +} + + bool EnableProfessions = sConfig->GetBoolDefault("ProfessionNPC.EnableProfessions", true); + bool EnableSecondarySkills = sConfig->GetBoolDefault("ProfessionNPC.EnableSecondarySkills", true); + +//Mony Check +if (pPlayer->GetMoney() < (sConfig->GetFloatDefault("SkillGoldCost",0))) +{ + pPlayer->CLOSE_GOSSIP_MENU(); + pCreature->MonsterWhisper("You don't have enough money.", pPlayer->GetGUID()); + return; +} + +switch(uiAction) +{ + +case 1000: //Profession + pPlayer->ADD_GOSSIP_ITEM( 5, "10 points in Alchemy." , GOSSIP_SENDER_MAIN, 1001); + pPlayer->ADD_GOSSIP_ITEM( 5, "10 points in Blacksmithing." , GOSSIP_SENDER_MAIN, 1002); + pPlayer->ADD_GOSSIP_ITEM( 5, "10 points in Enchanting." , GOSSIP_SENDER_MAIN, 1003); + pPlayer->ADD_GOSSIP_ITEM( 5, "10 points in Engineering." , GOSSIP_SENDER_MAIN, 1004); + pPlayer->ADD_GOSSIP_ITEM( 5, "10 points in Herbalism." , GOSSIP_SENDER_MAIN, 1005); + pPlayer->ADD_GOSSIP_ITEM( 5, "10 points in Inscription." , GOSSIP_SENDER_MAIN, 1006); + pPlayer->ADD_GOSSIP_ITEM( 5, "10 points in Jewelcrafting." , GOSSIP_SENDER_MAIN, 1007); + pPlayer->ADD_GOSSIP_ITEM( 5, "10 points in Leatherworking." , GOSSIP_SENDER_MAIN, 1008); + pPlayer->ADD_GOSSIP_ITEM( 5, "10 points in Mining." , GOSSIP_SENDER_MAIN, 1009); + pPlayer->ADD_GOSSIP_ITEM( 5, "10 points in Skinning." , GOSSIP_SENDER_MAIN, 1010); + pPlayer->ADD_GOSSIP_ITEM( 5, "10 points in Tailoring." , GOSSIP_SENDER_MAIN, 1011); + pPlayer->ADD_GOSSIP_ITEM( 7, "<- Main Menu" , GOSSIP_SENDER_MAIN, 3000); + + pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,pCreature->GetGUID()); +break; + +case 2000: //Secondary Skills + pPlayer->ADD_GOSSIP_ITEM( 5, "Cooking." , GOSSIP_SENDER_MAIN, 2001); + pPlayer->ADD_GOSSIP_ITEM( 5, "First Aid." , GOSSIP_SENDER_MAIN, 2002); + pPlayer->ADD_GOSSIP_ITEM( 5, "Fishing." , GOSSIP_SENDER_MAIN, 2003); + //pPlayer->ADD_GOSSIP_ITEM( 5, "Riding." , GOSSIP_SENDER_MAIN, 2004); + pPlayer->ADD_GOSSIP_ITEM( 7, "<- Main Menu" , GOSSIP_SENDER_MAIN, 3000); + + pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,pCreature->GetGUID()); +break; + +case 3000: //Back To Main Menu + // Main Menu for Alliance + if (pPlayer->GetTeam() == ALLIANCE) + { + // Check config if "Professions" is enabled or not + if(EnableProfessions) + pPlayer->ADD_GOSSIP_ITEM( 7, "Professions ->" , GOSSIP_SENDER_MAIN, 1000); + // Check config if "Secondary Skills" is enabled or not + if(EnableSecondarySkills) + pPlayer->ADD_GOSSIP_ITEM( 7, "Secondary Skills ->" , GOSSIP_SENDER_MAIN, 2000); + } + else // Main Menu for Horde + { + // Check config if "Professions" is enabled or not + if(EnableProfessions) + pPlayer->ADD_GOSSIP_ITEM( 7, "Professions ->" , GOSSIP_SENDER_MAIN, 1000); + // Check config if "Secondary Skills" is enabled or not + if(EnableSecondarySkills) + pPlayer->ADD_GOSSIP_ITEM( 7, "Secondary Skills ->" , GOSSIP_SENDER_MAIN, 2000); + } + + pPlayer->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,pCreature->GetGUID()); +break; + +//////////////////////////////////////////////////Professions/////////////////////////////////////////////////////////////// + +case 1001: // Alchemy + if(!pPlayer->UpdateSkill(171,0)) + { + pCreature->MonsterWhisper("You don't have this skill or you allready have the maximum skill value $C.", pPlayer->GetGUID()); + OnGossipHello(pPlayer, pCreature); + return; + } + + pPlayer->UpdateSkill(171,(sConfig->GetFloatDefault("SkillPoints",0))); + pPlayer->ModifyMoney(-(sConfig->GetFloatDefault("SkillGoldCost",0))); + pPlayer->CLOSE_GOSSIP_MENU(); +break; + +case 1002: // Blacksmithing + if(!pPlayer->UpdateSkill(164,0)) + { + pCreature->MonsterWhisper("You don't have this skill or you allready have the maximum skill value $C.", pPlayer->GetGUID()); + OnGossipHello(pPlayer, pCreature); + return; + } + + pPlayer->UpdateSkill(164,(sConfig->GetFloatDefault("SkillPoints",0))); + pPlayer->ModifyMoney(-(sConfig->GetFloatDefault("SkillGoldCost",0))); + pPlayer->CLOSE_GOSSIP_MENU(); +break; + +case 1003: // Enchanting + if(!pPlayer->UpdateSkill(333,0)) + { + pCreature->MonsterWhisper("You don't have this skill or you allready have the maximum skill value $C.", pPlayer->GetGUID()); + OnGossipHello(pPlayer, pCreature); + return; + } + + pPlayer->UpdateSkill(333,(sConfig->GetFloatDefault("SkillPoints",0))); + pPlayer->ModifyMoney(-(sConfig->GetFloatDefault("SkillGoldCost",0))); + pPlayer->CLOSE_GOSSIP_MENU(); +break; + +case 1004: // Engineering + if(!pPlayer->UpdateSkill(202,0)) + { + pCreature->MonsterWhisper("You don't have this skill or you allready have the maximum skill value $C.", pPlayer->GetGUID()); + OnGossipHello(pPlayer, pCreature); + return; + } + + pPlayer->UpdateSkill(202,(sConfig->GetFloatDefault("SkillPoints",0))); + pPlayer->ModifyMoney(-(sConfig->GetFloatDefault("SkillGoldCost",0))); + pPlayer->CLOSE_GOSSIP_MENU(); +break; + +case 1005: // Herbalism + if(!pPlayer->UpdateSkill(182,0)) + { + pCreature->MonsterWhisper("You don't have this skill or you allready have the maximum skill value $C.", pPlayer->GetGUID()); + OnGossipHello(pPlayer, pCreature); + return; + } + + pPlayer->UpdateSkill(182,(sConfig->GetFloatDefault("SkillPoints",0))); + pPlayer->ModifyMoney(-(sConfig->GetFloatDefault("SkillGoldCost",0))); + pPlayer->CLOSE_GOSSIP_MENU(); +break; + +case 1006: // Inscription + if(!pPlayer->UpdateSkill(773,0)) + { + pCreature->MonsterWhisper("You don't have this skill or you allready have the maximum skill value $C.", pPlayer->GetGUID()); + OnGossipHello(pPlayer, pCreature); + return; + } + + pPlayer->UpdateSkill(773,(sConfig->GetFloatDefault("SkillPoints",0))); + pPlayer->ModifyMoney(-(sConfig->GetFloatDefault("SkillGoldCost",0))); + pPlayer->CLOSE_GOSSIP_MENU(); +break; + +case 1007: // Jewelcrafting + if(!pPlayer->UpdateSkill(755,0)) + { + pCreature->MonsterWhisper("You don't have this skill or you allready have the maximum skill value $C.", pPlayer->GetGUID()); + OnGossipHello(pPlayer, pCreature); + return; + } + + pPlayer->UpdateSkill(755,(sConfig->GetFloatDefault("SkillPoints",0))); + pPlayer->ModifyMoney(-(sConfig->GetFloatDefault("SkillGoldCost",0))); + pPlayer->CLOSE_GOSSIP_MENU(); +break; + +case 1008: // Leatherworking + if(!pPlayer->UpdateSkill(165,0)) + { + pCreature->MonsterWhisper("You don't have this skill or you allready have the maximum skill value $C.", pPlayer->GetGUID()); + OnGossipHello(pPlayer, pCreature); + return; + } + + pPlayer->UpdateSkill(165,(sConfig->GetFloatDefault("SkillPoints",0))); + pPlayer->ModifyMoney(-(sConfig->GetFloatDefault("SkillGoldCost",0))); + pPlayer->CLOSE_GOSSIP_MENU(); +break; + +case 1009: // Mining + if(!pPlayer->UpdateSkill(186,0)) + { + pCreature->MonsterWhisper("You don't have this skill or you allready have the maximum skill value $C.", pPlayer->GetGUID()); + OnGossipHello(pPlayer, pCreature); + return; + } + + pPlayer->UpdateSkill(186,(sConfig->GetFloatDefault("SkillPoints",0))); + pPlayer->ModifyMoney(-(sConfig->GetFloatDefault("SkillGoldCost",0))); + pPlayer->CLOSE_GOSSIP_MENU(); +break; + +case 1010: // Skinning + if(!pPlayer->UpdateSkill(393,0)) + { + pCreature->MonsterWhisper("You don't have this skill or you allready have the maximum skill value $C.", pPlayer->GetGUID()); + OnGossipHello(pPlayer, pCreature); + return; + } + + pPlayer->UpdateSkill(393,(sConfig->GetFloatDefault("SkillPoints",0))); + pPlayer->ModifyMoney(-(sConfig->GetFloatDefault("SkillGoldCost",0))); + pPlayer->CLOSE_GOSSIP_MENU(); +break; + +case 1011: // Tailoring + if(!pPlayer->UpdateSkill(197,0)) + { + pCreature->MonsterWhisper("You don't have this skill or you allready have the maximum skill value $C.", pPlayer->GetGUID()); + OnGossipHello(pPlayer, pCreature); + return; + } + + pPlayer->UpdateSkill(197,(sConfig->GetFloatDefault("SkillPoints",0))); + pPlayer->ModifyMoney(-(sConfig->GetFloatDefault("SkillGoldCost",0))); + pPlayer->CLOSE_GOSSIP_MENU(); +break; + +//////////////////////////////////////////////////Secondary Skills/////////////////////////////////////////////////////////////// + +case 2001: // Cooking + if(!pPlayer->UpdateSkill(185,0)) + { + pCreature->MonsterWhisper("You don't have this skill or you allready have the maximum skill value $C.", pPlayer->GetGUID()); + OnGossipHello(pPlayer, pCreature); + return; + } + + pPlayer->UpdateSkill(185,(sConfig->GetFloatDefault("SkillPoints",0))); + pPlayer->ModifyMoney(-(sConfig->GetFloatDefault("SkillGoldCost",0))); + pPlayer->CLOSE_GOSSIP_MENU(); +break; + +case 2002: // First Aid + if(!pPlayer->UpdateSkill(129,0)) + { + pCreature->MonsterWhisper("You don't have this skill or you allready have the maximum skill value $C.", pPlayer->GetGUID()); + OnGossipHello(pPlayer, pCreature); + return; + } + + pPlayer->UpdateSkill(129,(sConfig->GetFloatDefault("SkillPoints",0))); + pPlayer->ModifyMoney(-(sConfig->GetFloatDefault("SkillGoldCost",0))); + pPlayer->CLOSE_GOSSIP_MENU(); +break; + +case 2003: // Fishing + if(!pPlayer->UpdateSkill(356,0)) + { + pCreature->MonsterWhisper("You don't have this skill or you allready have the maximum skill value $C.", pPlayer->GetGUID()); + OnGossipHello(pPlayer, pCreature); + return; + } + + pPlayer->UpdateSkill(356,(sConfig->GetFloatDefault("SkillPoints",0))); + pPlayer->ModifyMoney(-(sConfig->GetFloatDefault("SkillGoldCost",0))); + pPlayer->CLOSE_GOSSIP_MENU(); +break; + +//case 2004: // Riding +// if(!pPlayer->UpdateSkill(,0)) +// { +// pCreature->MonsterWhisper("You don't have this skill or you allready have the maximum skill value $C.", pPlayer->GetGUID()); +// OnGossipHello(pPlayer, pCreature); +// return; +// } +// +// pPlayer->UpdateSkill(,(sConfig->GetFloatDefault("SkillPoints",0))); +// pPlayer->ModifyMoney(-(sConfig->GetFloatDefault("SkillGoldCost",0))); +// pPlayer->CLOSE_GOSSIP_MENU(); +//break; + + pPlayer->CLOSE_GOSSIP_MENU(); + +} // end of switch +} //end of function + +bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction) +{ + // Main menu + pPlayer->PlayerTalkClass->ClearMenus(); + if (uiSender == GOSSIP_SENDER_MAIN) + SendDefaultMenu(pPlayer, pCreature, uiAction); + +return true; +} +}; + +void AddSC_professionnpc() +{ + +new professionnpc(); + +} \ No newline at end of file diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index a8af7bc..3ec15f6 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -3106,4 +3106,35 @@ OutdoorPvP.Wintergrasp.CustomHonorDamagedBuilding = 750 OutdoorPvP.Wintergrasp.CustomHonorIntactBuilding = 1500 OutdoorPvP.Wintergrasp.Antifarm.Enable = 1 OutdoorPvP.Wintergrasp.Antifarm.Atk = 1 -OutdoorPvP.Wintergrasp.Antifarm.Def = 1 \ No newline at end of file +OutdoorPvP.Wintergrasp.Antifarm.Def = 1 + +########################################################## +# Enable or Disable Primary Professions +# default = 1 (Enabled) +# = 0 (Disabled) + +ProfessionNPC.EnableProfessions = 1 + +# Enable or Disable Secondary Professions +# default = 1 (Enabled) +# = 0 (Disabled) + +ProfessionNPC.EnableSecondarySkills = 1 + +# Number of Skill points +# default = 10 + +SkillPoints = 10 + +# GM Only +# default = 0 (Anyone can use) +# = 1 (GM only) + +ProfessionNPC.OnlyGMs = 0 + +# Cost of skill points (in copper) +# default = 10000 (10 gold) + +SkillGoldCost = 10000 + +########################################################## -- 1.7.2.3
|
|
| |