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

TFS 1.X+ Attack attribute on shields

WikiArk21

Member
Joined
Oct 24, 2023
Messages
30
Reaction score
6
I noticed that it's possible to add an attack to the shield, which appears in the look, but that damage isn't calculated in the final damage. Does anyone have an explanation for this? And where do I need to change it so that the shield's attack is accounted for?
 
Last edited:
On OTS it's not 'attacking', it's 'using weapon'.

When you attack with basic attack, it goes to weapons.cpp and calculates damage for weapon you wear (by type: club, axe, sword, distance or wand), not check all equipped items 'attack'.
There are 3 functions that calculate weapon damage in TFS 1.4:
1. Melee (club, axe, sword):
2. Distance:
3. Wand:

You have Player* player variable in these functions, so you can add in player.cpp and player.h function ex. getShieldAttack() that will check both hands (left/right hand inventory slots), find shield and return it's attack attribute and call it in these functions ex. for 'melee' you can add shield attack to weapon (item) attack (in forgottenserver/src/weapons.cpp at 1.4 · otland/forgottenserver (https://github.com/otland/forgottenserver/blob/1.4/src/weapons.cpp#L593) ):
C++:
int32_t attackValue = std::max<int32_t>(0, item->getAttack() + player->getShieldAttack());
 
This function contains the logic you seek!


Inside that function is exactly where you need to add your check for the other hand... if you had a system which allows attack to be added to armors or legs or w/e and wanted to include a bunch of slots, you would simply iterate over all the slots, continue on the ones you wish to ignore, and the rest would be grabbing the item from the players inventory and counting it's attack.

I have given you exactly enough information to be able to work the problem out. I recommend trying to write the code yourself, but you could always get AI to help you if you basic questions about the language...
 
Back
Top