MCPcopy Create free account
hub / github.com/TurningWheel/Barony / getAttack

Method getAttack

src/entity.cpp:8220–8366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8218-------------------------------------------------------------------------------*/
8219
8220Sint32 Entity::getAttack(Entity* my, Stat* myStats, bool isPlayer, int chargeModifier, int* returnWeaponAttackValue)
8221{
8222 Sint32 attack = 0;
8223
8224 if ( !myStats )
8225 {
8226 return 0;
8227 }
8228
8229 attack = BASE_MELEE_DAMAGE; // base attack strength
8230 bool shapeshifted = (my && my->behavior == &actPlayer && my->effectShapeshift != NOTHING);
8231 if ( myStats->weapon == nullptr || shapeshifted )
8232 {
8233 // bare handed.
8234 if ( isPlayer )
8235 {
8236 attack = BASE_PLAYER_UNARMED_DAMAGE;
8237 attack += (myStats->getModifiedProficiency(PRO_UNARMED) / 20); // 0, 1, 2, 3, 4, 5 damage from total
8238 if ( shapeshifted )
8239 {
8240 if ( my->effectShapeshift == RAT )
8241 {
8242 attack += 2;
8243 }
8244 else if ( my->effectShapeshift == SPIDER )
8245 {
8246 attack += 3;
8247 }
8248 else if ( my->effectShapeshift == TROLL )
8249 {
8250 attack += 5;
8251 }
8252 else if ( my->effectShapeshift == CREATURE_IMP )
8253 {
8254 attack += 2;
8255 }
8256 }
8257 }
8258 if ( myStats->gloves && !shapeshifted )
8259 {
8260 int beatitude = myStats->gloves->beatitude;
8261 if ( myStats->gloves->type == BRASS_KNUCKLES )
8262 {
8263 attack += 1 + (shouldInvertEquipmentBeatitude(myStats) ? abs(beatitude) : beatitude);
8264 }
8265 else if ( myStats->gloves->type == IRON_KNUCKLES )
8266 {
8267 attack += 2 + (shouldInvertEquipmentBeatitude(myStats) ? abs(beatitude) : beatitude);
8268 }
8269 else if ( myStats->gloves->type == SPIKED_GAUNTLETS )
8270 {
8271 attack += 3 + (shouldInvertEquipmentBeatitude(myStats) ? abs(beatitude) : beatitude);
8272 }
8273 }
8274 if ( myStats->ring )
8275 {
8276 int beatitude = myStats->ring->beatitude;
8277 attack += 1 + (shouldInvertEquipmentBeatitude(myStats) ? abs(beatitude) : beatitude);

Callers

nothing calls this directly

Calls 5

statGetDEXFunction · 0.85
statGetSTRFunction · 0.85
weaponGetAttackMethod · 0.80

Tested by

no test coverage detected