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

Function AC

src/entity.cpp:16915–17044  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16913-------------------------------------------------------------------------------*/
16914
16915int AC(Stat* stat)
16916{
16917 if ( !stat )
16918 {
16919 return 0;
16920 }
16921
16922 Entity* playerEntity = nullptr;
16923 int player = -1;
16924 for ( int i = 0; i < MAXPLAYERS; ++i )
16925 {
16926 if ( stat && stats[i] == stat )
16927 {
16928 player = i;
16929 if ( players[i] && players[i]->entity )
16930 {
16931 playerEntity = players[i]->entity;
16932 break;
16933 }
16934 }
16935 }
16936 int armor = statGetCON(stat, playerEntity);
16937 if ( stat->getEffectActive(EFF_FOCI_LIGHT_SANCTUARY) )
16938 {
16939 armor += getSpellDamageFromID(SPELL_FOCI_LIGHT_SANCTUARY, nullptr, nullptr, nullptr);
16940 int tier = std::max(0, (stat->getEffectActive(EFF_FOCI_LIGHT_SANCTUARY) - 1));
16941 armor += tier * getSpellDamageSecondaryFromID(SPELL_FOCI_LIGHT_SANCTUARY, nullptr, nullptr, nullptr);
16942 }
16943 if ( stat->getEffectActive(EFF_GUARD_BODY) )
16944 {
16945 armor += thaumSpellArmorProc(playerEntity, *stat, true, nullptr, EFF_GUARD_BODY);
16946 }
16947 if ( stat->getEffectActive(EFF_DIVINE_GUARD) )
16948 {
16949 armor += thaumSpellArmorProc(playerEntity, *stat, true, nullptr, EFF_DIVINE_GUARD);
16950 }
16951 if ( stat->getEffectActive(EFF_DISRUPTED) )
16952 {
16953 armor -= std::min((Uint8)3, stat->getEffectActive(EFF_DISRUPTED)) * 5;
16954 }
16955
16956 if ( stat->helmet )
16957 {
16958 armor += stat->helmet->armorGetAC(stat);
16959 }
16960 if ( stat->breastplate )
16961 {
16962 armor += stat->breastplate->armorGetAC(stat);
16963 }
16964 if ( stat->gloves )
16965 {
16966 armor += stat->gloves->armorGetAC(stat);
16967 }
16968 if ( stat->shoes )
16969 {
16970 armor += stat->shoes->armorGetAC(stat);
16971 }
16972 if ( !(stat->parrying && stat->weapon) )

Callers 6

actArrowFunction · 0.85
actThrownFunction · 0.85
initIncubusFunction · 0.85
checkBetterEquipmentMethod · 0.85
attackMethod · 0.85

Calls 8

statGetCONFunction · 0.85
getSpellDamageFromIDFunction · 0.85
thaumSpellArmorProcFunction · 0.85
getWeaponSkillFunction · 0.85
armorGetACMethod · 0.80
getPassiveShieldBonusMethod · 0.80
getActiveShieldBonusMethod · 0.80

Tested by

no test coverage detected