mirror of
https://github.com/araxiaonline/mod-individual-xp.git
synced 2026-06-13 02:32:23 -04:00
Update of module Still WIP DO NOT USE
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
[worldserver]
|
||||
|
||||
#
|
||||
# PlayerAnnounce
|
||||
# Description: This will show the console on what players are logged in
|
||||
# Default: Enabled = 1
|
||||
# Disabled = 0
|
||||
PlayerAnnounce = 1
|
||||
# MaxXPRate
|
||||
# Description: This is the max amount a player can set their xp to.
|
||||
# Default: Default = 1
|
||||
#
|
||||
MaxXPRate = 10
|
||||
@@ -17,9 +17,11 @@ class PlayerXpRate : public DataMap::Base
|
||||
public:
|
||||
PlayerXpRate() {}
|
||||
PlayerXpRate(uint32 XPRate) : XPRate(XPRate) {}
|
||||
uint32 XPRate = 0;
|
||||
uint32 XPRate = 1;
|
||||
};
|
||||
|
||||
uint32 MaxRate;
|
||||
|
||||
class Individual_XP : public PlayerScript
|
||||
{
|
||||
public:
|
||||
@@ -45,13 +47,13 @@ public:
|
||||
CharacterDatabase.PQuery("REPLACE INTO `individualxp` (`CharacterGUID`, `XPRate`) VALUES (%u, %u);", p->GetGUIDLow(), data->XPRate);
|
||||
}
|
||||
|
||||
void OnGiveXP(Player* p, uint32& amount, Unit* victim) override
|
||||
void OnGiveXP(Player* p, uint32& amount, Unit* victim)
|
||||
{
|
||||
uint32 bonus_xp = amount * p->CustomData.Get<PlayerXpRate>("Individual_XP")->XPRate ;
|
||||
uint32 curXP = p->GetUInt32Value(PLAYER_XP);
|
||||
uint32 nextLvlXP = p->GetUInt32Value(PLAYER_NEXT_LEVEL_XP);
|
||||
uint32 bonus_xp = p->CustomData.Get<PlayerXpRate>("Individual_XP")->XPRate * amount;
|
||||
uint32 newXP = curXP + amount + bonus_xp;
|
||||
uint8 level = p->getLevel();
|
||||
uint32 newXP = curXP + bonus_xp - amount;
|
||||
|
||||
while (newXP >= nextLvlXP && level < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL))
|
||||
{
|
||||
@@ -64,8 +66,8 @@ public:
|
||||
nextLvlXP = p->GetUInt32Value(PLAYER_NEXT_LEVEL_XP);
|
||||
}
|
||||
|
||||
p->SendLogXPGain(amount, victim, bonus_xp, false, 1.0f);
|
||||
p->SetUInt32Value(PLAYER_XP, newXP);
|
||||
p->SetUInt32Value(PLAYER_XP, (newXP));
|
||||
p->SendLogXPGain(bonus_xp, victim, NULL, false, 1.0f);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -85,21 +87,20 @@ public:
|
||||
|
||||
static bool HandleIndividualXPCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
Player* me = handler->GetSession()->GetPlayer();
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player* me = handler->GetSession()->GetPlayer();
|
||||
|
||||
// Crash before Set
|
||||
me->CustomData.Get<PlayerXpRate>("Individual_XP")->XPRate = (uint32)atoi(args); //Return int from command
|
||||
|
||||
if (!me)
|
||||
return false;
|
||||
|
||||
me->GetSession()->SendAreaTriggerMessage("You have Updated your XP rate to %u", me->CustomData.Get<PlayerXpRate>("Individual_XP")->XPRate);
|
||||
if (atoi(args) > MaxRate || (atoi(args) == 0))
|
||||
return false;
|
||||
|
||||
me->CustomData.Get<PlayerXpRate>("Individual_XP")->XPRate = (uint32)atoi(args); //Return int from command
|
||||
|
||||
me->GetSession()->SendAreaTriggerMessage("You have updated your XP rate to %u", me->CustomData.Get<PlayerXpRate>("Individual_XP")->XPRate);
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -117,6 +118,7 @@ public:
|
||||
sConfigMgr->LoadMore(cfg_def_file.c_str());
|
||||
|
||||
sConfigMgr->LoadMore(cfg_file.c_str());
|
||||
MaxRate = sConfigMgr->GetIntDefault("MaxXPRate", 10);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
if ( MSVC )
|
||||
add_custom_command(TARGET worldserver
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_Individual_XP_DIR}/conf/Individual_XP.conf.dist ${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_Individual_XP_DIR}/conf/Individual-XP.conf.dist ${CMAKE_BINARY_DIR}/bin/$(ConfigurationName)/
|
||||
)
|
||||
elseif ( MINGW )
|
||||
add_custom_command(TARGET worldserver
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_Individual_XP_DIR}/conf/Individual_XP.conf.dist ${CMAKE_BINARY_DIR}/bin/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_Individual_XP_DIR}/conf/Individual-XP.conf.dist ${CMAKE_BINARY_DIR}/bin/
|
||||
)
|
||||
endif()
|
||||
|
||||
install(FILES "${CMAKE_Individual_XP_DIR}/conf/Individual_XP.conf.dist" DESTINATION ${CONF_DIR})
|
||||
install(FILES "${CMAKE_Individual_XP_DIR}/conf/Individual-XP.conf.dist" DESTINATION ${CONF_DIR})
|
||||
|
||||
Reference in New Issue
Block a user