• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Random Exp

Status
Not open for further replies.

Nightfox

New Member
Joined
Jun 3, 2007
Messages
1
Reaction score
0
This is code is 100% maded by me
This code give extra exp in many times, when you gain extra exp the color of exp is other.

This code tested in Evolutions 0.7.7

On "int64_t Creature::getGainedExperience(Creature* attacker) const"
replace:
Code:
return (int64_t)std::floor(getDamageRatio(attacker) * lostExperience * g_config.getNumber(ConfigManager::RATE_EXPERIENCE));

with:
Code:
#ifdef __FOX_RAND_EXP__
	Player* player = attacker->getPlayer();
	if(player){
	   int32_t randomExp = random_range(0, 100);
	   int32_t x = (uint32_t)g_config.getNumber(ConfigManager::DOUBLE_EXP_CHANCE);
	   int32_t y = (uint32_t)g_config.getNumber(ConfigManager::TRIPLE_EXP_CHANCE);
	   int32_t z = (uint32_t)g_config.getNumber(ConfigManager::HALF_EXP_CHANCE);
	   if(randomExp <= x){
          g_game.addAnimatedText(attacker->getPosition(), 906, "DoubleExp"); //blue
          return (int64_t)std::floor(getDamageRatio(attacker) * lostExperience * g_config.getNumber(ConfigManager::RATE_EXPERIENCE) * 2);
       }
	   else if(randomExp <= x+y){
          g_game.addAnimatedText(attacker->getPosition(), 966, "TripleExp"); // 966, orange
	      return (int64_t)std::floor(getDamageRatio(attacker) * lostExperience * g_config.getNumber(ConfigManager::RATE_EXPERIENCE) * 3);
	   }
       else if(randomExp <= x+y+z){
          g_game.addAnimatedText(attacker->getPosition(), 906, "Half Exp!"); //black
          return (int64_t)std::floor(getDamageRatio(attacker) * lostExperience * g_config.getNumber(ConfigManager::RATE_EXPERIENCE) / 2);
	   }
       else{
          //g_game.addAnimatedText(attacker->getPosition(), 906, "NormalExp!");
	      return (int64_t)std::floor(getDamageRatio(attacker) * lostExperience * g_config.getNumber(ConfigManager::RATE_EXPERIENCE));
       }
    }
    else
       return (int64_t)std::floor(getDamageRatio(attacker) * lostExperience * g_config.getNumber(ConfigManager::RATE_EXPERIENCE));
    #else
	return (int64_t)std::floor(getDamageRatio(attacker) * lostExperience * g_config.getNumber(ConfigManager::RATE_EXPERIENCE));
	#endif

CONFIGMANAGER.CPP
add:
Code:
	#ifdef __FOX_RAND_EXP__
	m_confInteger[DOUBLE_EXP_CHANCE] = getGlobalNumber(L, "doubleExpChance", 5);
	m_confInteger[TRIPLE_EXP_CHANCE] = getGlobalNumber(L, "tripleExpChance", 2);
	m_confInteger[HALF_EXP_CHANCE] = getGlobalNumber(L, "halfExpChance", 2);
	#endif

CONFIGMANAGER.H
add:

Code:
	#ifdef __FOX_RAND_EXP__
	DOUBLE_EXP_CHANCE,
	TRIPLE_EXP_CHANCE,
	HALF_EXP_CHANCE,
    #endif

CONFIG.LUA
add:

Code:
-- random exp chance (in %)
doubleExpChance = 5
tripleExpChance = 2
halfExpChance = 2

In LINKERS add:
Code:
-D__FOX_RAND_EXP__

Coments Please
 
nice :> make one for TFS and ill use it its very nice! :>
 
Isn't that code from Ixidor (now BlackOnix)?
 
what can people use this for though.. like.. i dont get why you made it, great script btw
 
Status
Not open for further replies.
Back
Top