All pastes #965665 Raw Edit

specialized prof

public text v1 · immutable
·published 2008-04-01 02:46 UTC
rendered paste body
#include "../sc_defines.h"
#include "../../../../game/Player.h"
#include "../../../../game/GossipDef.h"
 
#define GOSSIP_SENDER_SEC_UNLEARN 101
 
#define BLACKSMITHING_SKILLID 164
#define ARMORSMITH_QUESTID_ALIANCE 5283
#define ARMORSMITH_QUESTID_HORDE 5301
#define ARMORSMITH_SPELLID 9788
#define WEAPONSMITH_QUESTID_ALIANCE 5284
#define WEAPONSMITH_QUESTID_HORDE 5302
#define WEAPONSMITH_SPELLID 9787
#define AXESMITH_QUESTID 5306
#define AXESMITH_SPELLID 17041
#define HAMMERSMITH_SPELLID 17040
#define SWORDSMITH_SPELLID 17039
 
 
 
bool hasQuest(Player *player, uint32 questID)
{
    return player->GetQuestRewardStatus(questID) == QUEST_STATUS_COMPLETE;
}
 
bool hasLevelAndSkill(Player *player)
{
    return (player->getLevel() >= 50) && (player->GetSkillValue(BLACKSMITHING_SKILLID) >= 250);
}
 
int32 getUnlearnCost(bool weaponsmith, Player *player)
{
    uint32 level = player->getLevel();
    if (weaponsmith)
    {
        if (level < 66)
            return 50000;
        else
            return 100000;
    }
    else
    {
        if (level < 51)
            return 250000;
        else if (level < 66)
            return 500000;
        else
            return 1000000;
    }
}
 
uint32 getMessageId(uint32 cost)
{
    switch(cost)
    {
        case 50000:
            return 100007;
        case 100000:
            return 100008;
        case 250000:
            return 100009;
        case 500000:
            return 100010;
        case 1000000:
            return 100011;
 
    }
}
 
bool GossipHello_Blacksmith(Player *player, Creature *_Creature)
{
    bool hasArmorsmith = player->HasSpell(ARMORSMITH_SPELLID);
    bool hasWeaponsmith = player->HasSpell(WEAPONSMITH_SPELLID);
    bool hasAxesmith = player->HasSpell(AXESMITH_SPELLID);
    bool hasHammersmith = player->HasSpell(HAMMERSMITH_SPELLID);
    bool hasSwordsmith = player->HasSpell(SWORDSMITH_SPELLID);
    bool hasSpecialion = hasArmorsmith || hasWeaponsmith;
    bool hasWeaponSpecialition = hasAxesmith || hasHammersmith || hasSwordsmith;
 
    if (!hasSpecialion && (hasQuest(player, ARMORSMITH_QUESTID_ALIANCE) || hasQuest(player, ARMORSMITH_QUESTID_HORDE)))
        player->ADD_GOSSIP_ITEM( 0, "Learn me armorsmithing."   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
 
    if (hasArmorsmith)
        player->ADD_GOSSIP_ITEM( 0, "Unlearn me armorsmithing."   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
 
    if (!hasSpecialion && (hasQuest(player, WEAPONSMITH_QUESTID_ALIANCE) || hasQuest(player, WEAPONSMITH_QUESTID_HORDE)))
        player->ADD_GOSSIP_ITEM( 0, "Learn me weaponsmithing."   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
 
    if (hasWeaponsmith && !hasWeaponSpecialition)
        player->ADD_GOSSIP_ITEM( 0, "Unlearn me weaponsmithing."   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
 
    if (hasWeaponsmith && !hasWeaponSpecialition && hasLevelAndSkill(player))
        player->ADD_GOSSIP_ITEM( 0, "Learn me axesmithing."   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5);
 
    if (hasAxesmith)
        player->ADD_GOSSIP_ITEM( 0, "Unlearn me axesmithing."   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6);
 
    if (hasWeaponsmith && !hasWeaponSpecialition && hasLevelAndSkill(player))
        player->ADD_GOSSIP_ITEM( 0, "Learn me hammersmithing."   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7);
 
    if (hasHammersmith)
        player->ADD_GOSSIP_ITEM( 0, "Unlearn me hammersmithing."   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 8);
 
    if (hasWeaponsmith && !hasWeaponSpecialition && hasLevelAndSkill(player))
        player->ADD_GOSSIP_ITEM( 0, "Learn me swordsmithing."   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 9);
 
    if (hasSwordsmith)
        player->ADD_GOSSIP_ITEM( 0, "Unlearn me swordsmithing."   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 10);
 
 
    player->ADD_GOSSIP_ITEM( 0, "Nothing."   , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 11);
 
    player->SEND_GOSSIP_MENU(100001, _Creature->GetGUID());
 
    return true;
}
 
void SendDefaultMenu_Blacksmith(Player *player, Creature *_Creature, uint32 action)
{
    switch(action)
    {
        case GOSSIP_ACTION_INFO_DEF + 1:
        {
            //player->learnSpell(ARMORSMITH_SPELLID);
            player->ADD_GOSSIP_ITEM( 0, "Yes"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 1);
            player->ADD_GOSSIP_ITEM( 0, "No"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 11);
            player->SEND_GOSSIP_MENU(100002, _Creature->GetGUID());
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 2:
        {
            //player->removeSpell(ARMORSMITH_SPELLID);
            player->ADD_GOSSIP_ITEM( 0, "Yes"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 2);
            player->ADD_GOSSIP_ITEM( 0, "No"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 11);
            player->SEND_GOSSIP_MENU(getMessageId(getUnlearnCost(false,player)), _Creature->GetGUID());
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 3:
        {
            //player->learnSpell(WEAPONSMITH_SPELLID);
            player->ADD_GOSSIP_ITEM( 0, "Yes"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 3);
            player->ADD_GOSSIP_ITEM( 0, "No"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 11);
            player->SEND_GOSSIP_MENU(100003, _Creature->GetGUID());
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 4:
        {
            //player->removeSpell(WEAPONSMITH_SPELLID);
            player->ADD_GOSSIP_ITEM( 0, "Yes"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 4);
            player->ADD_GOSSIP_ITEM( 0, "No"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 11);
            player->SEND_GOSSIP_MENU(getMessageId(getUnlearnCost(true,player)), _Creature->GetGUID());
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 5:
        {
            //player->learnSpell(AXESMITH_SPELLID);
            player->ADD_GOSSIP_ITEM( 0, "Yes"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 5);
            player->ADD_GOSSIP_ITEM( 0, "no"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 11);
            player->SEND_GOSSIP_MENU(100004, _Creature->GetGUID());
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 6:
        {
            //player->removeSpell(AXESMITH_SPELLID);
            player->ADD_GOSSIP_ITEM( 0, "Yes"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 6);
            player->ADD_GOSSIP_ITEM( 0, "No"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 11);
            player->SEND_GOSSIP_MENU(getMessageId(getUnlearnCost(false,player)), _Creature->GetGUID());
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 7:
        {
            //player->learnSpell(HAMMERSMITH_SPELLID);
            player->ADD_GOSSIP_ITEM( 0, "Yes"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 7);
            player->ADD_GOSSIP_ITEM( 0, "No"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 11);
            player->SEND_GOSSIP_MENU(100005, _Creature->GetGUID());
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 8:
        {
            //player->removeSpell(HAMMERSMITH_SPELLID);
            player->ADD_GOSSIP_ITEM( 0, "Yes"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 8);
            player->ADD_GOSSIP_ITEM( 0, "No"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 11);
            player->SEND_GOSSIP_MENU(getMessageId(getUnlearnCost(false,player)), _Creature->GetGUID());
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 9:
        {
            //player->learnSpell(SWORDSMITH_SPELLID);
            player->ADD_GOSSIP_ITEM( 0, "Yes"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 9);
            player->ADD_GOSSIP_ITEM( 0, "No"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 11);
            player->SEND_GOSSIP_MENU(100006, _Creature->GetGUID());
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 10:
        {
            //player->removeSpell(SWORDSMITH_SPELLID);
            player->ADD_GOSSIP_ITEM( 0, "Yes"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 10);
            player->ADD_GOSSIP_ITEM( 0, "No"   , GOSSIP_SENDER_SEC_UNLEARN, GOSSIP_ACTION_INFO_DEF + 11);
            player->SEND_GOSSIP_MENU(getMessageId(getUnlearnCost(false,player)), _Creature->GetGUID());
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 11:
        {
		    player->CLOSE_GOSSIP_MENU();
            break;
        }
    }
}
 
void SendUnlearnMenu_Blacksmith(Player *player, Creature *_Creature, uint32 action)
{
    switch(action)
    {
        case GOSSIP_ACTION_INFO_DEF + 1:
        {
            player->learnSpell(ARMORSMITH_SPELLID);
            player->CLOSE_GOSSIP_MENU();
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 2:
        {
            if (player->GetMoney() >= getUnlearnCost(false,player))
            {
                player->ModifyMoney(-getUnlearnCost(false,player));
                player->removeSpell(ARMORSMITH_SPELLID);
            }
            else
                _Creature->Say("Not enough money", LANG_UNIVERSAL, 0);
 
            player->CLOSE_GOSSIP_MENU();
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 3:
        {
            player->learnSpell(WEAPONSMITH_SPELLID);
            player->CLOSE_GOSSIP_MENU();
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 4:
        {
            if (player->GetMoney() >= getUnlearnCost(true,player))
            {
                player->ModifyMoney(-getUnlearnCost(true,player));
                player->removeSpell(WEAPONSMITH_SPELLID);
            }
            else
                _Creature->Say("Not enough money", LANG_UNIVERSAL, 0);
 
            player->CLOSE_GOSSIP_MENU();
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 5:
        {
            player->learnSpell(AXESMITH_SPELLID);
            player->CLOSE_GOSSIP_MENU();
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 6:
        {
            if (player->GetMoney() >= getUnlearnCost(false,player))
            {
                player->ModifyMoney(-getUnlearnCost(false,player));
                player->removeSpell(AXESMITH_SPELLID);
            }
            else
                _Creature->Say("Not enough money", LANG_UNIVERSAL, 0);
 
            player->CLOSE_GOSSIP_MENU();
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 7:
        {
            player->learnSpell(HAMMERSMITH_SPELLID);
            player->CLOSE_GOSSIP_MENU();
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 8:
        {
            if (player->GetMoney() >= getUnlearnCost(false,player))
            {
                player->ModifyMoney(-getUnlearnCost(false,player));
                player->removeSpell(HAMMERSMITH_SPELLID);
            }
            else
                _Creature->Say("Not enough money", LANG_UNIVERSAL, 0);
 
            player->CLOSE_GOSSIP_MENU();
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 9:
        {
            player->learnSpell(SWORDSMITH_SPELLID);
            player->CLOSE_GOSSIP_MENU();
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 10:
        {
            if (player->GetMoney() >= getUnlearnCost(false,player))
            {
                player->ModifyMoney(-getUnlearnCost(false,player));
                player->removeSpell(SWORDSMITH_SPELLID);
            }
            else
                _Creature->Say("Not enough money", LANG_UNIVERSAL, 0);
 
            player->CLOSE_GOSSIP_MENU();
            break;
        }
        case GOSSIP_ACTION_INFO_DEF + 11:
        {
		    player->CLOSE_GOSSIP_MENU();
            break;
        }
    }
}
 
 
bool GossipSelect_Blacksmith(Player *player, Creature *_Creature, uint32 sender, uint32 action )
{
 
    switch(sender)
    {
        case GOSSIP_SENDER_MAIN:
        {
            SendDefaultMenu_Blacksmith(player, _Creature, action);
            break;
        }
        case GOSSIP_SENDER_SEC_UNLEARN:
        {
            SendUnlearnMenu_Blacksmith(player, _Creature, action);
            break;
        }
    }
    return true;
}
 
void AddSC_npc_blacksmithspec()
{
    Script *newscript;
 
    newscript = new Script;
    newscript->Name="npc_blacksmithspec";
    newscript->pGossipHello          = &GossipHello_Blacksmith;
    newscript->pGossipSelect         = &GossipSelect_Blacksmith;
 
    m_scripts[nrscripts++] = newscript;
}