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

How to make shielding affect armor damage reduction?

Slime

Active Member
Joined
Jan 25, 2014
Messages
115
Reaction score
33
I wanted to make shielding improve armor defense.
if(checkArmor)
{

int32_t armorValue = getArmor(), minArmorReduction = 0,
maxArmorReduction = 0;

if(armorValue > 1)
{
int32_t DefSkill = player->getSkill(SKILL_SHIELD, SKILL_LEVEL); //!!!added line
minArmorReduction = (int32_t)std::ceil(armorValue * 0.475);
maxArmorReduction = (int32_t)std::ceil(
((armorValue * 0.475) - 1) + minArmorReduction);
}
else if(armorValue == 1)
{
minArmorReduction = 1;
maxArmorReduction = 1;
}

damage -= random_range(minArmorReduction, maxArmorReduction);
if(damage <= 0)
{
damage = 0;
blockType = BLOCK_ARMOR;
}
}
I thought it would be easy, like just pasting DefSkill into the formula. When trying to compile i get 'player' was not declared in this scope error. Is it because armor reffers not only to players but creatures in general?
 
@Flatlander
What do you mean?
int32_t DefSkill = this->getSkill(SKILL_SHIELD, SKILL_LEVEL);
or
int32_t DefSkill = getSkill(SKILL_SHIELD, SKILL_LEVEL);
Sorry but I didn't understand. None of these work by the way. I'm using TFS 0.3.6
 
int32_t DefSkill = this->getSkill(SKILL_SHIELD, SKILL_LEVEL);
This should fix your "player" not declared issue.

Check for anywhere else in players.cpp getSkill() is used, and copy how it is used.
 
947 C:\Users\Putregon\Desktop\DWO\server\creature.cpp 'class Creature' has no member named 'getSkill'

Here's an example of getSkill usage from player.cpp

int32_t Player::getDefense() const
{
int32_t baseDefense = 0,

defenseValue = baseDefense,
defenseSkill = getSkill(SKILL_CLUB, SKILL_LEVEL);

if(!defenseSkill)
return 0;

if(vocation->getMultiplier(MULTIPLIER_DEFENSE) != 1.0)
defenseValue = int32_t(defenseValue * vocation->getMultiplier(MULTIPLIER_DEFENSE));

return ((int32_t)std::ceil(((float)(defenseSkill * 2.5))));
}

But it doesn't work since I'm editing creature.cpp, not player.cpp.
 
Actually, it is incredibly simple.
Your first attempt, got the skill (lets say its 10) but then never added it to the armor.
A good way to see how it should work would be look at getDefense since it is very similar to getArmor and it also adds in shielding.
 
@Flatlander
Actually it didn't get the skill, TFS does not compile because of 947 C:\Users\Putregon\Desktop\DWO\server\creature.cpp 'class Creature' has no member named 'getSkill'
If it did, I'd just do something like this:

if(checkArmor)
{
int32_t armorValue = getArmor(), minArmorReduction = 0,
maxArmorReduction = 0;
if(armorValue > 1)
{
int32_t DefSkill = this->getSkill(SKILL_SHIELD, SKILL_LEVEL);
minArmorReduction = (int32_t)std::ceil((armorValue * 0.475) + DefSkill ); - something like this
maxArmorReduction = (int32_t)std::ceil(
((armorValue * 0.475) - 1) + minArmorReduction);
}
and so on...

Sorry for tagging you in every post, I just feel like you have huge knowledge and can help me with this.
I think the problem is that both player and monster have shield but only players have armor (even xml files with monsters say so). Monsters doesn't have skills and that's why I can't reffer to getSkill in creature.cpp. I'd have to do probably something like this in player.cpp

int32_t Player::getDefense() const
{
int32_t baseDefense = 0,

defenseValue = baseDefense,
defenseSkill = getSkill(SKILL_CLUB, SKILL_LEVEL);

if(!defenseSkill)
return 0;

if(vocation->getMultiplier(MULTIPLIER_DEFENSE) != 1.0)
defenseValue = int32_t(defenseValue * vocation->getMultiplier(MULTIPLIER_DEFENSE));

return ((int32_t)std::ceil(((float)(defenseSkill * 2.5))));
}

Copy it and remake into int32_t Player::getArmor() const etc. etc.
And change everything according to armor (if you are wondering why is Club Fighting affecting shield defense - I want to remake shieldblock into dodge, Club Fighting=Agility on my server).
 
in player.cpp
All you need to change is getArmor() to have the following:
Code:
int32_t defenseSkill = getSkill(SKILL_CLUB, SKILL_LEVEL);
Then make a formula for how defenseSkill is added to your armor.
If you copy defense it would look like this:
Code:
armor = ((int32_t)std::ceil(((float)(defenseSkill * (armor* 0.015)) + (armor* 0.1))));
Put this right before:
Code:
return armor;
 
Ok, I figured it out just a second ago.
In player.cpp
int32_t Player::getArmor() const
{

int32_t armor = getSkill(SKILL_SHIELD, SKILL_LEVEL);
return armor;
}
Works exactly as I wanted it to work, from now on armors will not have armor value, just add shielding skill. By the way, I have a question according to remaking shield blocking into flee/dodge/whatever. I'm almost there, just need a little help with defining dodge chance. Can I send you a PM?
 

Similar threads

Back
Top