Erikas Kontenis
Veteran OT User
This code have been used to sell as request but it was needed some scripting part and I feeling very tired of my scripting/programming services. Also I just started up my real map server my free time overloaded. I have nothing bad against buyer who told me to do this.
So result of this code is a lua function that increases player any health damage to target. And sendAnimatedMessage how much boosted his hit is with increasement.
this works with simple formula: (Real damage + Real Damage*param); sendAnimatedMessage formula: (Real Damage*param - real damage)
Tested and works like angel on tfs 0.3.6 (8.54 protocol) -- I just love outdated this version
However it won't be a problem too much to update it for 0.4 or something.
player.cpp
after this line make new line with code:
in the end of player.cpp add this code:
player.h
after this line make new line with code:
after this line make new line with code:
creature.cpp
found this function:
and replace it all to this:
configmanager.cpp
after this line make new line with code:
configmanager.h
after this line make new line with code:
luascript.cpp
after this line make new line with code:
after this function make new line with code:
luascript.h
after this line make new line with code:
config.lua
extraDamageColor = 50 -- anywhere place it in config.lua
how to use function:
Script example: http://otland.net/f81/ring-increase-attack-damage-179504/ & http://otland.net/f82/increase-player-damage-rebirth-181840/
So result of this code is a lua function that increases player any health damage to target. And sendAnimatedMessage how much boosted his hit is with increasement.
this works with simple formula: (Real damage + Real Damage*param); sendAnimatedMessage formula: (Real Damage*param - real damage)
Tested and works like angel on tfs 0.3.6 (8.54 protocol) -- I just love outdated this version
player.cpp
Code:
lastAttack = idleTime = marriage = blessings = balance = premiumDays = mana = manaMax = manaSpent = extraAttackSpeed = 0;
after this line make new line with code:
Code:
extraMagicDamage = 1; // Erikas
in the end of player.cpp add this code:
Code:
void Player::setPlayerExtraMagicDamage(uint32_t damage)
{
extraMagicDamage = damage;
}
player.h
Code:
uint32_t getMagicLevel() const {return getPlayerInfo(PLAYERINFO_MAGICLEVEL);}
uint64_t getSpentMana() const {return manaSpent;}
after this line make new line with code:
Code:
uint32_t getExtraMagicDamage() const {return extraMagicDamage;}
void setPlayerExtraMagicDamage(uint32_t damage);
Code:
uint32_t idleTime;
after this line make new line with code:
Code:
uint32_t extraAttackSpeed;
creature.cpp
found this function:
Code:
void Creature::drainHealth(Creature* attacker, CombatType_t combatType, int32_t damage)
and replace it all to this:
Code:
void Creature::drainHealth(Creature* attacker, CombatType_t combatType, int32_t damage)
{
lastDamageSource = combatType;
onAttacked();
if(attacker->getPlayer())
{
if(attacker->getPlayer()->getExtraMagicDamage() > 1)
{
int16_t color = g_config.getNumber(ConfigManager::EXTRA_DAMAGE_COLOR);
if(color < 0)
color = random_range(0, 255);
int realDamage = damage;
damage = damage * attacker->getPlayer()->getExtraMagicDamage();
std::stringstream ss;
ss << "+" << damage - realDamage;
g_game.addAnimatedText(attacker->getPosition(), (uint8_t)color, ss.str());
}
}
changeHealth(-damage);
if(attacker)
attacker->onAttackedCreatureDrainHealth(this, damage);
}
configmanager.cpp
Code:
m_confNumber[EXPERIENCE_COLOR] = getGlobalNumber("gainExperienceColor", COLOR_WHITE);
after this line make new line with code:
Code:
//Erikas
m_confNumber[EXTRA_DAMAGE_COLOR] = getGlobalNumber("extraDamageColor", COLOR_WHITE);
//Erikas
configmanager.h
Code:
EXPERIENCE_COLOR,
after this line make new line with code:
Code:
EXTRA_DAMAGE_COLOR,
luascript.cpp
Code:
//doPlayerAddSoul(cid, soul)
lua_register(m_luaState, "doPlayerAddSoul", LuaScriptInterface::luaDoPlayerAddSoul);
after this line make new line with code:
Code:
//doPlayerSetExtraMagicDamage(cid, damage)
lua_register(m_luaState, "doPlayerSetExtraMagicDamage", LuaScriptInterface::luaDoPlayerSetExtraMagicDamage);
Code:
int32_t LuaScriptInterface::luaDoPlayerAddSoul(lua_State* L)
{
//doPlayerAddSoul(cid, soul)
int32_t soul = popNumber(L);
ScriptEnviroment* env = getEnv();
if(Player* player = env->getPlayerByUID(popNumber(L)))
{
player->changeSoul(soul);
lua_pushboolean(L, true);
}
else
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}
after this function make new line with code:
Code:
int32_t LuaScriptInterface::luaDoPlayerSetExtraMagicDamage(lua_State *L)
{
uint32_t damage = popNumber(L);
ScriptEnviroment* env = getEnv();
if(Player* player = env->getPlayerByUID(popNumber(L))){
player->setPlayerExtraMagicDamage(damage);
lua_pushnumber(L, true);
}
else{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushnumber(L, false);
}
return 1;
}
luascript.h
Code:
static int32_t luaDoPlayerAddSoul(lua_State* L);
after this line make new line with code:
Code:
static int32_t luaDoPlayerSetExtraMagicDamage(lua_State* L);
config.lua
extraDamageColor = 50 -- anywhere place it in config.lua
how to use function:
Lua:
doPlayerSetExtraMagicDamage(cid, 1) -- Default no boost damage
doPlayerSetExtraMagicDamage(cid, 2) -- formula boost
Script example: http://otland.net/f81/ring-increase-attack-damage-179504/ & http://otland.net/f82/increase-player-damage-rebirth-181840/
Last edited: