1. Full Defense Exhaust
The first thing we will be looking at is Full Defense Exhaust.
This is located in players.cpp and I don't think many people notice that this is coded into the source.
Code:
float Player::getDefenseFactor() const
{
switch (fightMode) {
case FIGHTMODE_ATTACK:
return 1.0f;
case FIGHTMODE_BALANCED:
return 1.2f;
case FIGHTMODE_DEFENSE: {
if ((OTSYS_TIME() - lastAttack) < getAttackSpeed()) {
return 1.0f;
}
return 2.0f;
}
default:
return 1.0f;
}
}
If we look at getDefenseFactor, this is used when getting your shielding multiplier when you are on either Full Attack, Balanced, or Full Defense mode.
If we look at these lines:
Code:
case FIGHTMODE_DEFENSE: {
if ((OTSYS_TIME() - lastAttack) < getAttackSpeed()) {
return 1.0f;
}
return 2.0f;
}
It says "If the player is in Full Defense, and has attacked, return 1.0 instead of 2.0"
Originally, 2.0 would double your defense (Multiplies it by 2) but if are attacking while on full defense, you are then given 1.0 (no bonus defense).
This literally makes it so if you are attacking on full defense, you have HALF the attack, and normal defense. I suspect most people would think being in full defense would make you more defensive while attacking... but this is not the case, it just makes you hit less, and take the same damage.
So, in my personal opinion it should be changed, but some people might want the original system, or maybe you want to configure how much defense you gain when in balanced and defense modes. So the best thing to do would be to add this into the config.lua so you can change it whenever you want.
Tutorial: Adding Variables to Config.lua
To fix the above, I would suggest adding it to the config, rather than just changing the values.
First, I would add what variables you want to the configmanager.
So first we should add the True/False (or Yes/No) in configmanager.h
For TFS: 1.0:
Add a line in this Table:
Right before the end (Add the next number in line)
Code:
DEFENSE_EXHAUST = 15, //Added here (You can name it whatever you want)
LAST_BOOLEAN_CONFIG /* this must be the last one */
};
For TFS 0.3
Add a line in this table:
Right before the end again:
Code:
DEFENSE_EXHAUST, //No number needed for TFS 0.3
LAST_BOOL_CONFIG /* this must be the last one */
};
Then we will add in the numbers.
For TFS 1.0:
Add 6 lines to this table:
You can name them whatever you want, but make sure you number them in order.
Code:
STANCE_A_ATTACK = 31, //Attack Stance AttackFactor
STANCE_B_ATTACK = 32, //Balanced Stance AttackFactor
STANCE_D_ATTACK = 33, //Defense Stance AttackFactor
STANCE_A_DEFENSE = 34, //Attack Stance DefenseFactor
STANCE_B_DEFENSE = 35, //Balanced Stance DefenseFactor
STANCE_D_DEFENSE = 36, //Defense Stance DefenseFactor
LAST_INTEGER_CONFIG /* this must be the last one */
};
For TFS 0.3
Put your lines in the Table:
Add the 6 lines to the end of this table:
Code:
STANCE_A_ATTACK, //Attack Stance AttackFactor
STANCE_B_ATTACK, //Balanced Stance AttackFactor
STANCE_D_ATTACK, //Defense Stance AttackFactor
STANCE_A_DEFENSE, //Attack Stance DefenseFactor
STANCE_B_DEFENSE, //Balanced Stance DefenseFactor
STANCE_D_DEFENSE, //Defense Stance DefenseFactor
LAST_DOUBLE_CONFIG /* this must be the last one */
};
Now we have to add these into configmanager.cpp
For TFS 1.0:
Add after this line:
Code:
m_confBoolean[STAMINA_SYSTEM] = booleanString(getGlobalString(L, "staminaSystem", "yes"));
m_confBoolean[DEFENSE_EXHAUST] = booleanString(getGlobalString(L, "defenseExhaust", "yes"));
And add your 6 numbers after this line:
Code:
m_confInteger[MAX_PACKETS_PER_SECOND] = getGlobalNumber(L, "maxPacketsPerSecond", 40);
m_confInteger[STANCE_A_ATTACK] = getGlobalNumber(L, "stanceAAttack", 1.0);
m_confInteger[STANCE_B_ATTACK] = getGlobalNumber(L, "stanceBAttack", 1.2);
m_confInteger[STANCE_D_ATTACK] = getGlobalNumber(L, "stanceDAttack", 2.0);
m_confInteger[STANCE_A_DEFENSE] = getGlobalNumber(L, "stanceADefense", 1.0);
m_confInteger[STANCE_B_DEFENSE] = getGlobalNumber(L, "stanceBDefense", 1.2);
m_confInteger[STANCE_D_DEFENSE] = getGlobalNumber(L, "stanceDDefense", 2.0);
For TFS 0.3:
A little different but we do the same things:
Add everything at the "end":
Code:
m_confBool[DEFENSE_EXHAUST] = getGlobalBool("defenseExhaust", true);
m_confDouble[STANCE_A_ATTACK] = getGlobalDouble("stanceAAttack", 1.0);
m_confDouble[STANCE_B_ATTACK] = getGlobalDouble("stanceBAttack", 1.2);
m_confDouble[STANCE_D_ATTACK] = getGlobalDouble("stanceDAttack", 2.0);
m_confDouble[STANCE_A_DEFENSE] = getGlobalDouble("stanceADefense", 1.0);
m_confDouble[STANCE_B_DEFENSE] = getGlobalDouble("stanceBDefense", 1.2);
m_confDouble[STANCE_D_DEFENSE] = getGlobalDouble("stanceDDefense", 2.0);
//Add Above this
m_loaded = true;
return true;
}
Now we need to add these variables into players.cpp.
For TFS 1.0:
Change:
Code:
float Player::getAttackFactor() const
{
switch (fightMode) {
case FIGHTMODE_ATTACK:
return 1.0f;
case FIGHTMODE_BALANCED:
return 1.2f;
case FIGHTMODE_DEFENSE:
return 2.0f;
default:
return 1.0f;
}
}
float Player::getDefenseFactor() const
{
switch (fightMode) {
case FIGHTMODE_ATTACK:
return 1.0f;
case FIGHTMODE_BALANCED:
return 1.2f;
case FIGHTMODE_DEFENSE: {
if ((OTSYS_TIME() - lastAttack) < getAttackSpeed()) {
return 1.0f;
}
return 2.0f;
}
default:
return 1.0f;
}
}
To:
Code:
float Player::getAttackFactor() const
{
float aFactor;
switch (fightMode) {
case FIGHTMODE_ATTACK:
aFactor = (float)g_config.getNumber(ConfigManager::STANCE_A_ATTACK);
case FIGHTMODE_BALANCED:
aFactor = (float)g_config.getNumber(ConfigManager::STANCE_B_ATTACK);
case FIGHTMODE_DEFENSE:
aFactor = (float)g_config.getNumber(ConfigManager::STANCE_D_ATTACK);
default:
aFactor = (float)g_config.getNumber(ConfigManager::STANCE_A_ATTACK);
}
return aFactor;
}
float Player::getDefenseFactor() const
{
float dFactor;
switch (fightMode) {
case FIGHTMODE_ATTACK:
dFactor = (float)g_config.getNumber(ConfigManager::STANCE_A_DEFENSE);
case FIGHTMODE_BALANCED:
dFactor = (float)g_config.getNumber(ConfigManager::STANCE_B_DEFENSE);
case FIGHTMODE_DEFENSE: {
if (((OTSYS_TIME() - lastAttack) < getAttackSpeed()) && g_config.getBoolean(ConfigManager::DEFENSE_EXHAUST)) {
dFactor = (float)g_config.getNumber(ConfigManager::STANCE_A_DEFENSE);
}
dFactor = (float)g_config.getNumber(ConfigManager::STANCE_D_DEFENSE);
}
default:
dFactor = (float)g_config.getNumber(ConfigManager::STANCE_A_DEFENSE);
}
return dFactor;
}
For TFS 0.3:Change them both to:
Code:
float Player::getAttackFactor() const
{
float aFactor;
switch(fightMode)
{
case FIGHTMODE_BALANCED:
aFactor = (float)g_config.getDouble(ConfigManager::STANCE_A_ATTACK);
case FIGHTMODE_DEFENSE:
aFactor = (float)g_config.getDouble(ConfigManager::STANCE_B_ATTACK);
case FIGHTMODE_ATTACK:
aFactor = (float)g_config.getDouble(ConfigManager::STANCE_D_ATTACK);
default:
aFactor = (float)g_config.getDouble(ConfigManager::STANCE_A_ATTACK);
}
return aFactor;
}
float Player::getDefenseFactor() const
{
float dFactor;
switch(fightMode)
{
case FIGHTMODE_BALANCED:
dFactor = (float)g_config.getDouble(ConfigManager::STANCE_B_DEFENSE);
case FIGHTMODE_DEFENSE:
{
if (((OTSYS_TIME() - lastAttack) < getAttackSpeed()) && g_config.getBool(ConfigManager::DEFENSE_EXHAUST)) {
dFactor = (float)g_config.getNumber(ConfigManager::STANCE_A_DEFENSE);
}
dFactor = (float)g_config.getDouble(ConfigManager::STANCE_D_DEFENSE);
}
case FIGHTMODE_ATTACK:
dFactor = (float)g_config.getDouble(ConfigManager::STANCE_A_DEFENSE);
default:
dFactor = (float)g_config.getDouble(ConfigManager::STANCE_A_DEFENSE);
}
return dFactor;
}
Now you can change this in your config.lua, and it will work

.
Example:
Code:
--Stance Config
defenseExhaust = true --(Or Yes for TFS 1.0)
stanceAAttack = 1.0
stanceBAttack = 1.2
stanceDAttack = 2.0
stanceADefense = 1.0
stanceBDefense = 1.2
stanceDDefense = 2.0
If you have any issues or get any errors let me know and I will fix them. It is possible I made mistakes, I made this tutorial without a copy of TFS to test it on, because I just reformatted my computer.