• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Increase damage% from monsters

beenii

Well-Known Member
Joined
Jul 26, 2010
Messages
586
Solutions
1
Reaction score
58
Hi, I noticed that the monsters on my server stick very little to my liking.

From where can I increase the damage monsters make?

No matter if it is .lua or compile.

I Use TFS 1.2
 
I think you shouldn't (in this case, if the tfs sources hasn't been modified) edit monsters dmg in c++, especially if you don't have much experience with tfs project and programming knowledge. This may cause problems with damage output in more places (As far as I remember the dmg function is placed in creature class of which inherit player and monsters classes).

Try edit monsters xml files in <attack> </attack> parts.

This is for example attack part of my Troll monster.

Code:
  <attacks>
    <attack attack="16" interval="1500" name="melee" skill="20"/>
  </attacks>

Increase the values and check the result.
 
Editing methods in monster class might be complicated. For example the functions for subtracting health, printing the damage on screen and others related to do damage are separated. In this case I suggest you to modify the game.cpp file, find the combatChangeHealth method and add new if statement at the begining.

For example:

Code:
bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage& damage)
{
    if (attacker->getMonster())
    {
        damage.primary.value *= 1.5; //base dmg
        damage.secondary.value *= 1.5; //elemental dmg
    }

//... rest of theoriginal method code

This will increase monster damage to 150%.
 
Editing methods in monster class might be complicated. For example the functions for subtracting health, printing the damage on screen and others related to do damage are separated. In this case I suggest you to modify the game.cpp file, find the combatChangeHealth method and add new if statement at the begining.

For example:

Code:
bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage& damage)
{
    if (attacker->getMonster())
    {
        damage.primary.value *= 1.5; //base dmg
        damage.secondary.value *= 1.5; //elemental dmg
    }

//... rest of theoriginal method code

This will increase monster damage to 150%.


i compiled here:

Code:
bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage& damage)
{
    if (attacker->getMonster())
    {
    damage.primary.value *= 1.5;
    damage.secondary.value *= 1.5;
    }

compiling but console crash when server started.

i try change to:
server no crash but dont work xD

Code:
bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage& damage)
{
    const Position& targetPos = target->getPosition();
    if (damage.primary.value > 0) {
        if (target->getHealth() <= 0) {
            return false;
        }
    
    if (attacker->getMonster())
    {
    damage.primary.value *= 1.5;
    damage.secondary.value *= 1.5;
    }
 
Post errors

Have you only add the if stament at the start of the method? The function is very large , I post only the beggining where you should put this.
 
I do not know if it is the most efficient, but I ended up using .lua

Code:
function onHealthChange(player, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if not attacker then
  return primaryDamage, primaryType, secondaryDamage, secondaryType
 end
 
 if attacker:isMonster() and not attacker:getMaster() then
 primaryDamage = primaryDamage*3
 secondaryDamage = secondaryDamage*3
end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

function onManaChange(player, attacker, manaChange, origin)
if not attacker then
  return manaChange
 end

 if attacker:isMonster() and not attacker:getMaster()  then
  manaChange = manaChange *3
  end
    return manaChange
end
 
Back
Top