PNJ Métiers
Ce script permet de créer un pnj qui met votre métier à sa compétence maximum.

src\server\scripts\Custom\Pnj_metier.cpp
[code=cpp]
#include "ScriptPCH.h"

#define METIER1 "alchimie"
#define METIER2 "calligraphie"
#define METIER3 "couture"
#define METIER4 "enchantement"
#define METIER5 "depecage"
#define METIER6 "forge"
#define METIER7 "herboristerie"
#define METIER8 "ingenierie"
#define METIER9 "joaillerie"
#define METIER10 "minage"
#define METIER11 "Travail du cuir"
#define METIER12 "cuisine"
#define METIER13 "peche"
#define METIER14 "secourisme"

class Pnj_metier : public CreatureScript
{
public:

Pnj_metier()
: CreatureScript("Pnj_metier")
{
}
bool OnGossipHello(Player* pPlayer, Creature* pCreature)
{
pPlayer->ADD_GOSSIP_ITEM( 9, METIER1, GOSSIP_SENDER_MAIN, 1000);
pPlayer->ADD_GOSSIP_ITEM( 9, METIER2, GOSSIP_SENDER_MAIN, 1001);
pPlayer->ADD_GOSSIP_ITEM( 9, METIER3, GOSSIP_SENDER_MAIN, 1002);
pPlayer->ADD_GOSSIP_ITEM( 9, METIER4, GOSSIP_SENDER_MAIN, 1003);
pPlayer->ADD_GOSSIP_ITEM( 9, METIER5, GOSSIP_SENDER_MAIN, 1004);
pPlayer->ADD_GOSSIP_ITEM( 9, METIER6, GOSSIP_SENDER_MAIN, 1005);
pPlayer->ADD_GOSSIP_ITEM( 9, METIER7, GOSSIP_SENDER_MAIN, 1006);
pPlayer->ADD_GOSSIP_ITEM( 9, METIER8, GOSSIP_SENDER_MAIN, 1007);
pPlayer->ADD_GOSSIP_ITEM( 9, METIER9, GOSSIP_SENDER_MAIN, 1008);
pPlayer->ADD_GOSSIP_ITEM( 9, METIER10, GOSSIP_SENDER_MAIN, 1009);
pPlayer->ADD_GOSSIP_ITEM( 9, METIER11, GOSSIP_SENDER_MAIN, 1010);
pPlayer->ADD_GOSSIP_ITEM( 9, METIER12, GOSSIP_SENDER_MAIN, 1011);
pPlayer->ADD_GOSSIP_ITEM( 9, METIER13, GOSSIP_SENDER_MAIN, 1012);
pPlayer->ADD_GOSSIP_ITEM( 9, METIER14, GOSSIP_SENDER_MAIN, 1013);

pPlayer->PlayerTalkClass->SendGossipMenu(68, pCreature->GetGUID());
return true;
}

void SendDefaultMenu_metier(Player* pPlayer, Creature* pCreature, uint32 uiAction)
{
pPlayer->CLOSE_GOSSIP_MENU();
// Not allow in combat
if (pPlayer->isInCombat())
{
pCreature->MonsterSay("Vous etes en combat !", LANG_UNIVERSAL, pPlayer->GetGUID());
return;
}

int32 skill = 0;

switch(uiAction)
{
case 1000:
{
skill = 171;

SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill);
if (sl)
{
if (sl->categoryId == SKILL_CATEGORY_PROFESSION || sl->categoryId == SKILL_CATEGORY_SECONDARY)
{
if (pPlayer->GetSkillValue(skill))
{
uint16 maxLevel = pPlayer->GetPureMaxSkillValue(sl->id);
pPlayer->SetSkill(sl->id, pPlayer->GetSkillStep(sl->id), maxLevel, maxLevel);

pCreature->MonsterWhisper("Votre metier a sa competence au maximum", pPlayer->GetGUID());
}
else
{
pCreature->MonsterWhisper("Vous devez apprendre ce metier avant d'utiliser la commande", pPlayer->GetGUID());
}
}
}

break;
}
case 1001:
{
skill = 773;

SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill);
if (sl)
{
if (sl->categoryId == SKILL_CATEGORY_PROFESSION || sl->categoryId == SKILL_CATEGORY_SECONDARY)
{
if (pPlayer->GetSkillValue(skill))
{
uint16 maxLevel = pPlayer->GetPureMaxSkillValue(sl->id);
pPlayer->SetSkill(sl->id, pPlayer->GetSkillStep(sl->id), maxLevel, maxLevel);

pCreature->MonsterWhisper("Votre metier a sa competence au maximum", pPlayer->GetGUID());
}
else
{
pCreature->MonsterWhisper("Vous devez apprendre ce metier avant d'utiliser la commande", pPlayer->GetGUID());
}
}
}

break;
}
case 1002:
{
skill = 197;

SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill);
if (sl)
{
if (sl->categoryId == SKILL_CATEGORY_PROFESSION || sl->categoryId == SKILL_CATEGORY_SECONDARY)
{
if (pPlayer->GetSkillValue(skill))
{
uint16 maxLevel = pPlayer->GetPureMaxSkillValue(sl->id);
pPlayer->SetSkill(sl->id, pPlayer->GetSkillStep(sl->id), maxLevel, maxLevel);

pCreature->MonsterWhisper("Votre metier a sa competence au maximum", pPlayer->GetGUID());
}
else
{
pCreature->MonsterWhisper("Vous devez apprendre ce metier avant d'utiliser la commande", pPlayer->GetGUID());
}
}
}

break;
}
case 1003:
{
skill = 333;

SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill);
if (sl)
{
if (sl->categoryId == SKILL_CATEGORY_PROFESSION || sl->categoryId == SKILL_CATEGORY_SECONDARY)
{
if (pPlayer->GetSkillValue(skill))
{
uint16 maxLevel = pPlayer->GetPureMaxSkillValue(sl->id);
pPlayer->SetSkill(sl->id, pPlayer->GetSkillStep(sl->id), maxLevel, maxLevel);

pCreature->MonsterWhisper("Votre metier a sa competence au maximum", pPlayer->GetGUID());
}
else
{
pCreature->MonsterWhisper("Vous devez apprendre ce metier avant d'utiliser la commande", pPlayer->GetGUID());
}
}
}

break;
}
case 1004:
{
skill = 393;

SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill);
if (sl)
{
if (sl->categoryId == SKILL_CATEGORY_PROFESSION || sl->categoryId == SKILL_CATEGORY_SECONDARY)
{
if (pPlayer->GetSkillValue(skill))
{
uint16 maxLevel = pPlayer->GetPureMaxSkillValue(sl->id);
pPlayer->SetSkill(sl->id, pPlayer->GetSkillStep(sl->id), maxLevel, maxLevel);

pCreature->MonsterWhisper("Votre metier a sa competence au maximum", pPlayer->GetGUID());
}
else
{
pCreature->MonsterWhisper("Vous devez apprendre ce metier avant d'utiliser la commande", pPlayer->GetGUID());
}
}
}

break;
}
case 1005:
{
skill = 164;

SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill);
if (sl)
{
if (sl->categoryId == SKILL_CATEGORY_PROFESSION || sl->categoryId == SKILL_CATEGORY_SECONDARY)
{
if (pPlayer->GetSkillValue(skill))
{
uint16 maxLevel = pPlayer->GetPureMaxSkillValue(sl->id);
pPlayer->SetSkill(sl->id, pPlayer->GetSkillStep(sl->id), maxLevel, maxLevel);

pCreature->MonsterWhisper("Votre metier a sa competence au maximum", pPlayer->GetGUID());
}
else
{
pCreature->MonsterWhisper("Vous devez apprendre ce metier avant d'utiliser la commande", pPlayer->GetGUID());
}
}
}

break;
}
case 1006:
{
skill = 182;

SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill);
if (sl)
{
if (sl->categoryId == SKILL_CATEGORY_PROFESSION || sl->categoryId == SKILL_CATEGORY_SECONDARY)
{
if (pPlayer->GetSkillValue(skill))
{
uint16 maxLevel = pPlayer->GetPureMaxSkillValue(sl->id);
pPlayer->SetSkill(sl->id, pPlayer->GetSkillStep(sl->id), maxLevel, maxLevel);

pCreature->MonsterWhisper("Votre metier a sa competence au maximum", pPlayer->GetGUID());
}
else
{
pCreature->MonsterWhisper("Vous devez apprendre ce metier avant d'utiliser la commande", pPlayer->GetGUID());
}
}
}

break;
}
case 1007:
{
skill = 202;

SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill);
if (sl)
{
if (sl->categoryId == SKILL_CATEGORY_PROFESSION || sl->categoryId == SKILL_CATEGORY_SECONDARY)
{
if (pPlayer->GetSkillValue(skill))
{
uint16 maxLevel = pPlayer->GetPureMaxSkillValue(sl->id);
pPlayer->SetSkill(sl->id, pPlayer->GetSkillStep(sl->id), maxLevel, maxLevel);

pCreature->MonsterWhisper("Votre metier a sa competence au maximum", pPlayer->GetGUID());
}
else
{
pCreature->MonsterWhisper("Vous devez apprendre ce metier avant d'utiliser la commande", pPlayer->GetGUID());
}
}
}

break;
}
case 1008:
{
skill = 755;

SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill);
if (sl)
{
if (sl->categoryId == SKILL_CATEGORY_PROFESSION || sl->categoryId == SKILL_CATEGORY_SECONDARY)
{
if (pPlayer->GetSkillValue(skill))
{
uint16 maxLevel = pPlayer->GetPureMaxSkillValue(sl->id);
pPlayer->SetSkill(sl->id, pPlayer->GetSkillStep(sl->id), maxLevel, maxLevel);

pCreature->MonsterWhisper("Votre metier a sa competence au maximum", pPlayer->GetGUID());
}
else
{
pCreature->MonsterWhisper("Vous devez apprendre ce metier avant d'utiliser la commande", pPlayer->GetGUID());
}
}
}

break;
}
case 1009:
{
skill = 186;

SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill);
if (sl)
{
if (sl->categoryId == SKILL_CATEGORY_PROFESSION || sl->categoryId == SKILL_CATEGORY_SECONDARY)
{
if (pPlayer->GetSkillValue(skill))
{
uint16 maxLevel = pPlayer->GetPureMaxSkillValue(sl->id);
pPlayer->SetSkill(sl->id, pPlayer->GetSkillStep(sl->id), maxLevel, maxLevel);

pCreature->MonsterWhisper("Votre metier a sa competence au maximum", pPlayer->GetGUID());
}
else
{
pCreature->MonsterWhisper("Vous devez apprendre ce metier avant d'utiliser la commande", pPlayer->GetGUID());
}
}
}

break;
}
case 1010:
{
skill = 165;

SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill);
if (sl)
{
if (sl->categoryId == SKILL_CATEGORY_PROFESSION || sl->categoryId == SKILL_CATEGORY_SECONDARY)
{
if (pPlayer->GetSkillValue(skill))
{
uint16 maxLevel = pPlayer->GetPureMaxSkillValue(sl->id);
pPlayer->SetSkill(sl->id, pPlayer->GetSkillStep(sl->id), maxLevel, maxLevel);

pCreature->MonsterWhisper("Votre metier a sa competence au maximum", pPlayer->GetGUID());
}
else
{
pCreature->MonsterWhisper("Vous devez apprendre ce metier avant d'utiliser la commande", pPlayer->GetGUID());
}
}
}

break;
}
case 1011:
{
skill = 185;

SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill);
if (sl)
{
if (sl->categoryId == SKILL_CATEGORY_PROFESSION || sl->categoryId == SKILL_CATEGORY_SECONDARY)
{
if (pPlayer->GetSkillValue(skill))
{
uint16 maxLevel = pPlayer->GetPureMaxSkillValue(sl->id);
pPlayer->SetSkill(sl->id, pPlayer->GetSkillStep(sl->id), maxLevel, maxLevel);

pCreature->MonsterWhisper("Votre metier a sa competence au maximum", pPlayer->GetGUID());
}
else
{
pCreature->MonsterWhisper("Vous devez apprendre ce metier avant d'utiliser la commande", pPlayer->GetGUID());
}
}
}

break;
}
case 1012:
{
skill = 356;

SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill);
if (sl)
{
if (sl->categoryId == SKILL_CATEGORY_PROFESSION || sl->categoryId == SKILL_CATEGORY_SECONDARY)
{
if (pPlayer->GetSkillValue(skill))
{
uint16 maxLevel = pPlayer->GetPureMaxSkillValue(sl->id);
pPlayer->SetSkill(sl->id, pPlayer->GetSkillStep(sl->id), maxLevel, maxLevel);

pCreature->MonsterWhisper("Votre metier a sa competence au maximum", pPlayer->GetGUID());
}
else
{
pCreature->MonsterWhisper("Vous devez apprendre ce metier avant d'utiliser la commande", pPlayer->GetGUID());
}
}
}

break;
}
case 1013:
{
skill = 129;

SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill);
if (sl)
{
if (sl->categoryId == SKILL_CATEGORY_PROFESSION || sl->categoryId == SKILL_CATEGORY_SECONDARY)
{
if (pPlayer->GetSkillValue(skill))
{
uint16 maxLevel = pPlayer->GetPureMaxSkillValue(sl->id);
pPlayer->SetSkill(sl->id, pPlayer->GetSkillStep(sl->id), maxLevel, maxLevel);

pCreature->MonsterWhisper("Votre metier a sa competence au maximum", pPlayer->GetGUID());
}
else
{
pCreature->MonsterWhisper("Vous devez apprendre ce metier avant d'utiliser la commande", pPlayer->GetGUID());
}
}
}

break;
}
}
}

bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 uiSender, uint32 uiAction)
{
pPlayer->PlayerTalkClass->ClearMenus();
// Main menu
if (uiSender == GOSSIP_SENDER_MAIN)
SendDefaultMenu_metier(pPlayer, pCreature, uiAction);

return true;
}
};

void AddSC_Pnj_metier()
{
new Pnj_metier();
}[/code]

src\server\scripts\Custom\CMakeLists.txt
[code=diff]@@ -3,6 +3,7 @@
${scripts_STAT_SRCS}
+ Custom/Pnj_metier.cpp
)

message(" -> Prepared: Custom")[/code]

src/server/game/Scripting/ScriptLoader.cpp
[code=diff]@@ -1144,6 +1144,7 @@
void AddSC_npc_teleport();
void AddSC_npc_outils();
void AddSC_BG_npc_tp_aleatoire();
+void AddSC_Pnj_metier();
#endif

void AddCustomScripts()
@@ -1153,5 +1154,6 @@
AddSC_npc_teleport();
AddSC_npc_outils();
AddSC_BG_npc_tp_aleatoire();
+ AddSC_Pnj_metier();
#endif
}[/code]
Merci Hihi Langue
Mais je conseil de mettre des Majuscules dans t'es variables =)

Retourner en haut Accueil