44#include " world/objects/item.h"
55#include " world/world.h"
66#include " world/bullet.h"
7+ #include " gothic.h"
78
8- #include " game/gamesession.h"
9- #include " commandline.h"
9+ // https://forum.worldofplayers.de/forum/threads/127320-Damage-System?p=2198181#post2198181
1010
1111using namespace Daedalus ::GEngineClasses;
1212
@@ -96,7 +96,7 @@ DamageCalculator::Val DamageCalculator::swordDamage(Npc& nsrc, Npc& nother) {
9696 // Swords/Fists
9797 const int dtype = damageTypeMask (nsrc);
9898 uint8_t hitCh = TALENT_UNKNOWN;
99- int s = nsrc.attribute (Attribute::ATR_STRENGTH);
99+ int str = nsrc.attribute (Attribute::ATR_STRENGTH);
100100 int critChance = int (script.rand (100 ));
101101
102102 int value=0 ;
@@ -107,22 +107,37 @@ DamageCalculator::Val DamageCalculator::swordDamage(Npc& nsrc, Npc& nother) {
107107 hitCh = TALENT_1H;
108108 }
109109
110- if (nsrc.isMonster () && hitCh==TALENT_UNKNOWN) {
111- // regular monsters always do critical damage
112- critChance = 0 ;
113- }
110+ if (Gothic::inst ().version ().game ==2 ) {
111+ if (nsrc.isMonster () && hitCh==TALENT_UNKNOWN) {
112+ // regular monsters always do critical damage
113+ critChance = 0 ;
114+ }
114115
115- for (int i=0 ; i<DAM_INDEX_MAX; ++i){
116- if ((dtype & (1 <<i))==0 )
117- continue ;
118- int vd = std::max (s + src.damage [i] - other.protection [i],0 );
119- if (src.hitChance [hitCh]<critChance)
120- vd = (vd-1 )/10 ;
121- if (other.protection [i]>=0 ) // Filter immune
122- value += vd;
123- }
116+ for (int i=0 ; i<DAM_INDEX_MAX; ++i){
117+ if ((dtype & (1 <<i))==0 )
118+ continue ;
119+ int vd = std::max (str + src.damage [i] - other.protection [i],0 );
120+ if (src.hitChance [hitCh]<critChance)
121+ vd = (vd-1 )/10 ;
122+ if (other.protection [i]>=0 ) // Filter immune
123+ value += vd;
124+ }
124125
125- return Val (value,true );
126+ return Val (value,true );
127+ } else {
128+ for (int i=0 ; i<DAM_INDEX_MAX; ++i) {
129+ if ((dtype & (1 <<i))==0 )
130+ continue ;
131+ int vd = std::max (str + src.damage [i] - other.protection [i],0 );
132+ if (src.hitChance [hitCh]<critChance)
133+ vd = std::max (str + src.damage [i] - other.protection [i],0 ); else
134+ vd = std::max (str + src.damage [i]*2 - other.protection [i],0 );
135+ if (other.protection [i]>=0 ) // Filter immune
136+ value += vd;
137+ }
138+
139+ return Val (value,true );
140+ }
126141 }
127142
128143int32_t DamageCalculator::damageTypeMask (Npc& npc) {
0 commit comments