Skip to content

Instantly share code, notes, and snippets.

@callmephil
Created November 9, 2014 14:51
Show Gist options
  • Save callmephil/cc70f9bdd37b7fdc0a90 to your computer and use it in GitHub Desktop.
Save callmephil/cc70f9bdd37b7fdc0a90 to your computer and use it in GitHub Desktop.
Mutli-XP System
class LEVEL_NPC : public CreatureScript
{
public: LEVEL_NPC() : CreatureScript("LEVEL_NPC") {}
bool OnGossipHello(Player* player, Creature* creature)
{
if (player->HasItemCount(600000, 1, true) || player->HasItemCount(600001, 1, true))
ChatHandler(player->GetSession()).SendSysMessage("You are no longer able to acces to this npc.");
if (player->getLevel() == 1)
{
player->ADD_GOSSIP_ITEM(1, "I Want to stop at level 80 (Rate XP Blizzlike)", GOSSIP_SENDER_MAIN, 1);
player->ADD_GOSSIP_ITEM(1, "I Want to stop at level 255 (Rate XP x100)", GOSSIP_SENDER_MAIN, 2);
}
else
ChatHandler(player->GetSession()).SendSysMessage("You are no longer able to acces to this npc.");
player->SEND_GOSSIP_MENU(1, creature->GetGUID());
return true;
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
{
player->PlayerTalkClass->ClearMenus();
if (sender == GOSSIP_SENDER_MAIN)
{
switch (action)
{
case 1:
player->AddItem(600000,1);
player->CLOSE_GOSSIP_MENU();
break;
case 2:
player->AddItem(600001,1);
player->CLOSE_GOSSIP_MENU();
break;
}
}
return true;
}
};
class Stop_XP_Script : public PlayerScript
{
public:
Stop_XP_Script() : PlayerScript("Stop_XP_Script") { }
void OnLevelChanged(Player * player, uint8 oldLevel)
{
if (oldLevel == 79 && player->HasItemCount(600000, 1, false))
{
player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_NO_XP_GAIN);
player->DestroyItemCount(600000, 1, true);
}
if (oldLevel == 254 && player->HasItemCount(600001, 1, false))
player->DestroyItemCount(600001, 1, true);
}
};
void AddSC_MULTI_XP()
{
new LEVEL_NPC();
new Stop_XP_Script();
}
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 680f643..0f0e1e6 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -81,6 +81,8 @@
#include "GameObjectAI.h"
#include "../../../scripts/Custom/NPC/Transmog/Transmogrification.h"
+#include "Config.h"
+
#define ZONE_UPDATE_INTERVAL (1*IN_MILLISECONDS)
#define PLAYER_SKILL_INDEX(x) (PLAYER_SKILL_INFO_1_1 + ((x)*3))
@@ -2970,6 +2972,19 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate)
uint8 level = getLevel();
sScriptMgr->OnGivePlayerXP(this, xp, victim);
+
+ // Custom [Philippovitch - AC-Web] Start
+ // Item 1 level 80
+ float xp_bonus_for_item_1 = 0;
+ if(GetItemByEntry(sConfigMgr->GetIntDefault("Rate.Custom.ItemID_1", 600000)))
+ xp_bonus_for_item_1 = sConfigMgr->GetFloatDefault("Rate.Custom.Item_1.XP", 1.0f);
+ xp = uint32(xp * (1 + xp_bonus_for_item_1)); // Modify also Quest Gain
+ // Item 2 level 255
+ float xp_bonus_for_item_2 = 0;
+ if(GetItemByEntry(sConfigMgr->GetIntDefault("Rate.Custom.ItemID_2", 600001)))
+ xp_bonus_for_item_2 = sConfigMgr->GetFloatDefault("Rate.Custom.Item_2.XP", 1.0f);
+ xp = uint32(xp * (1 + xp_bonus_for_item_2)); // Modify also Quest Gain
+ // Custom [Philippovitch - AC-Web] End
// XP to money conversion processed in Player::RewardQuest
if (level >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
###################################################################################################
###################################################################################################
#
# Custom.Rate.ItemID
# Description : Define an item who's adding bonus in percentage for XP Gain
# Default: 600000 - (Level 80)
# Default: 600001 - (Level 255)
#
Rate.Custom.ItemID_1 = 600000
Rate.Custom.ItemID_2 = 600001
# Rate.Custom.Item : Value
# Default: 0 - (NULL)
# Description : Every float is in percentage, That mean each 1 = 10 %
# if value = 0 there is no modification.
#
Rate.Custom.Item_1.XP = 0
Rate.Custom.Item_2.XP = 2550
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment