• 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!

C++ Help: Implementing Global Multipliers for Monster Attack Speed and Damage

_M4G0_

Intermediate OT User
Joined
Feb 6, 2016
Messages
540
Solutions
16
Reaction score
106
Hello everyone,
I'm trying to implement a system where I can globally modify the attack interval and damage of all monsters through values set in config.lua. The idea is to avoid having to edit each monster individually, and instead apply a global multiplier for both melee and spell attacks.
Something like this in config.lua:
LUA:
monsterAttackIntervalMultiplier = 1.0
monsterDamageMultiplier = 1.0
I’d like to know the best way to hook into the monster behavior so I can apply these multipliers dynamically, affecting all monsters’ melee and spell attacks.
Has anyone done something similar or could point me in the right direction (e.g., which part of the source to modify, or how to intercept the attack calculations)?

Thanks in advance!

tfs 1.4
 
Last edited:
Hi everyone,
I found this snippet in a post and I was wondering if it actually works as intended:
Code:
if ((attr = node.attribute("speed")) || (attr = node.attribute("interval"))) {
    sb.speed = std::max<int32_t>(1, pugi::cast<int32_t>(attr.value() * NUMBER_MULTIPLIER));
}
I’m trying to globally modify all monster attack speeds using a multiplier from config.lua.
In my case, I'm using:
Code:
double attackSpeedMultiplier = g_config.getNumber(ConfigManager::ATTACK_SPEED_MULTIPLIER);
Then trying to apply it like this:
Code:
int32_t modifiedSpeed = std::max<int32_t>(1, static_cast<int32_t>(originalValue / attackSpeedMultiplier));
However, I didn’t notice any difference during tests.
Does this method really work, or is there something I might be missing?

Thanks in advance!
 
I was testing same approach and nothing worked here so might be a dead end
Maybe we don’t know the correct place for this change, but I believe it’s possible. It might be a lot of changes, which would make it unfeasible, or maybe it’s something very simple.
 
Hi everyone,
I found this snippet in a post and I was wondering if it actually works as intended:
Code:
if ((attr = node.attribute("speed")) || (attr = node.attribute("interval"))) {
    sb.speed = std::max<int32_t>(1, pugi::cast<int32_t>(attr.value() * NUMBER_MULTIPLIER));
}
I’m trying to globally modify all monster attack speeds using a multiplier from config.lua.
In my case, I'm using:
Code:
double attackSpeedMultiplier = g_config.getNumber(ConfigManager::ATTACK_SPEED_MULTIPLIER);
Then trying to apply it like this:
Code:
int32_t modifiedSpeed = std::max<int32_t>(1, static_cast<int32_t>(originalValue / attackSpeedMultiplier));
However, I didn’t notice any difference during tests.
Does this method really work, or is there something I might be missing?

Thanks in advance!
speed is for the movement not the attack rate... for monsters to attack they have both an attack interval and chance, and that's per attack, which they can have many of... many of which are designed to happen more often than others... if you only want melee, then that's probably what you want to target... but the monsters attacks and spells are weird and not the same as the players

There is literally hardcoded tick intervals for the different types of attacks for monsters
1744848442875.webp

Todo what you guys were trying to do, you make your config modifier divide the tickInterval on the line directly above this bit of code right here

1744848624156.webp

and that will get you the results you seek, but remember, if you do it like that, it's going to increase the rate of ALL it's "attacks" that are not scripted spells... and I didn't read far enough, it might actually increase those too, doubtful, but it may..
 
Last edited:
speed is for the movement not the attack rate... for monsters to attack they have both an attack interval and chance, and that's per attack, which they can have many of... many of which are designed to happen more often than others... if you only want melee, then that's probably what you want to target... but the monsters attacks and spells are weird and not the same as the players

There is literally hardcoded tick intervals for the different types of attacks for monsters
View attachment 91851

Todo what you guys were trying to do, you make your config modifier divide the tickInterval on the line directly above this bit of code right here

View attachment 91852

and that will get you the results you seek, but remember, if you do it like that, it's going to increase the rate of ALL it's "attacks" that are not scripted spells... and I didn't read far enough, it might actually increase those too, doubtful, but it may..
Thanks for your response! I’ll test this out and share the results soon.
 
register in configmanager 3 values
increaseDamageMonsters
increaseSpeedMonsters
increaseAttackInterval (not sure if monster can attack less than 1second)

then in monster.cpp in line where monster obtaining speed from monsterType class add our increaseSpeedMonsters multiplier, same for speed attack interval (this one might be not possible without some hard edit's)

about increaseDamage just in game.cpp in function changeHealth add a condition like if (attacker->isMonster()) add increaseDamageMonsters multiplier.
 
Back
Top