@ -672,28 +672,28 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
// make sure weapon exists
// make sure weapon exists
boolean noWeapon = false ;
boolean noWeapon = false ;
ItemTemplate wb = null ;
ItemTemplate weaponTemplate = null ;
if ( weapon = = null )
if ( weapon = = null )
noWeapon = true ;
noWeapon = true ;
else {
else {
ItemTemplate ib = weapon . template ;
ItemTemplate itemTemplate = weapon . template ;
if ( ib = = null )
if ( itemTemplate = = null )
noWeapon = true ;
noWeapon = true ;
else if ( ! weapon . template . item_type . equals ( ItemType . WEAPON ) ) {
else if ( ! weapon . template . item_type . equals ( ItemType . WEAPON ) ) {
defaultAtrAndDamage ( abstractCharacter , mainHand ) ;
defaultAtrAndDamage ( abstractCharacter , mainHand ) ;
return ;
return ;
} else
} else
wb = ib ;
weaponTemplate = itemTemplate ;
}
}
float skillPercentage , masteryPercentage ;
float skillPercentage , masteryPercentage ;
float mastDam ;
float mastDam ;
int min , max ;
int min , max ;
float speed = 20f ;
float speed = 20f ;
boolean strBased = false ;
boolean strBased = false ;
ItemTemplate wbMain = ( weapon ! = null ) ? weapon . template : null ;
ItemTemplate wbOff = ( otherHand ! = null ) ? otherHand . template : null ;
// get skill percentages and min and max damage for weapons
// get skill percentages and min and max damage for weapons
if ( noWeapon ) {
if ( noWeapon ) {
if ( mainHand ) {
if ( mainHand ) {
@ -711,6 +711,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
skillPercentage = getModifiedAmount ( abstractCharacter . skills . get ( "Unarmed Combat" ) ) ;
skillPercentage = getModifiedAmount ( abstractCharacter . skills . get ( "Unarmed Combat" ) ) ;
masteryPercentage = getModifiedAmount ( abstractCharacter . skills . get ( "Unarmed Combat Mastery" ) ) ;
masteryPercentage = getModifiedAmount ( abstractCharacter . skills . get ( "Unarmed Combat Mastery" ) ) ;
if ( masteryPercentage = = 0f )
if ( masteryPercentage = = 0f )
mastDam = CharacterSkill . getQuickMastery ( abstractCharacter , "Unarmed Combat Mastery" ) ;
mastDam = CharacterSkill . getQuickMastery ( abstractCharacter , "Unarmed Combat Mastery" ) ;
else
else
@ -733,17 +734,21 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
abstractCharacter . rangeHandTwo * = range_bonus ;
abstractCharacter . rangeHandTwo * = range_bonus ;
}
}
skillPercentage = getModifiedAmount ( abstractCharacter . skills . get ( weapon . template . item_skill_used ) ) ;
skillPercentage = getModifiedAmount ( abstractCharacter . skills . get ( weapon . template . item_skill_used ) ) ;
masteryPercentage = getModifiedAmount ( abstractCharacter . skills . get ( wb . item_skill_mastery_used ) ) ;
masteryPercentage = getModifiedAmount ( abstractCharacter . skills . get ( weaponTemplate . item_skill_mastery_used ) ) ;
if ( masteryPercentage = = 0f )
if ( masteryPercentage = = 0f )
mastDam = 0f ;
mastDam = 0f ;
// mastDam = CharacterSkill.getQuickMastery(this, wb.getMastery());
// mastDam = CharacterSkill.getQuickMastery(this, wb.getMastery());
else
else
mastDam = masteryPercentage ;
mastDam = masteryPercentage ;
int [ ] damages = ( int [ ] ) wb . item_weapon_damage . values ( ) . toArray ( ) [ 0 ] ;
int [ ] damages = ( int [ ] ) weaponTemplate . item_weapon_damage . values ( ) . toArray ( ) [ 0 ] ;
min = damages [ 0 ] ;
min = damages [ 0 ] ;
max = damages [ 1 ] ;
max = damages [ 1 ] ;
strBased = wb . item_primary_attr . equals ( AttributeType . Strength ) ;
strBased = weaponTemplate . item_primary_attr . equals ( AttributeType . Strength ) ;
//
//
// Add parry bonus for weapon and allow parry if needed
// Add parry bonus for weapon and allow parry if needed
@ -803,13 +808,15 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
}
}
//calculate speed
//calculate speed
if ( wb ! = null )
if ( weaponTemplate ! = null )
speed = wb . item_weapon_wepspeed ;
speed = weaponTemplate . item_weapon_wepspeed ;
else
else
speed = 20f ; //unarmed attack speed
speed = 20f ; //unarmed attack speed
if ( weapon ! = null )
if ( weapon ! = null )
speed * = ( 1 + abstractCharacter . bonuses . getFloatPercentAll ( ModType . WeaponSpeed , SourceType . NONE ) ) ;
speed * = ( 1 + abstractCharacter . bonuses . getFloatPercentAll ( ModType . WeaponSpeed , SourceType . NONE ) ) ;
speed * = ( 1 + abstractCharacter . bonuses . getFloatPercentAll ( ModType . AttackDelay , SourceType . NONE ) ) ;
speed * = ( 1 + abstractCharacter . bonuses . getFloatPercentAll ( ModType . AttackDelay , SourceType . NONE ) ) ;
if ( speed < 10 )
if ( speed < 10 )
speed = 10 ;
speed = 10 ;
@ -822,6 +829,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
min + = weapon . getBonus ( ModType . MeleeDamageModifier , SourceType . NONE ) ;
min + = weapon . getBonus ( ModType . MeleeDamageModifier , SourceType . NONE ) ;
max + = weapon . getBonus ( ModType . MeleeDamageModifier , SourceType . NONE ) ;
max + = weapon . getBonus ( ModType . MeleeDamageModifier , SourceType . NONE ) ;
// Finally use any multipliers. DO THIS LAST!
// Finally use any multipliers. DO THIS LAST!
float percentMinDamage = 1 ;
float percentMinDamage = 1 ;
@ -839,8 +847,10 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
}
}
//if duel wielding, cut damage by 30%
//if duel wielding, cut damage by 30%
if ( otherHand ! = null ) {
if ( otherHand ! = null ) {
ItemTemplate ibo = otherHand . template ;
ItemTemplate ibo = otherHand . template ;
if ( ibo ! = null & & otherHand . template . equals ( ItemType . WEAPON ) ) {
if ( ibo ! = null & & otherHand . template . equals ( ItemType . WEAPON ) ) {
min * = 0 . 7f ;
min * = 0 . 7f ;
max * = 0 . 7f ;
max * = 0 . 7f ;
@ -910,9 +920,9 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
if ( ItemTemplate . isShield ( shield ) = = false )
if ( ItemTemplate . isShield ( shield ) = = false )
return 0 ;
return 0 ;
ItemTemplate ab = shield . template ;
ItemTemplate template = shield . template ;
if ( ab = = null )
if ( template = = null )
return 0 ;
return 0 ;
CharacterSkill blockSkill = abstractCharacter . skills . get ( "Block" ) ;
CharacterSkill blockSkill = abstractCharacter . skills . get ( "Block" ) ;
@ -924,9 +934,10 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
} else
} else
skillMod = blockSkill . getModifiedAmount ( ) ;
skillMod = blockSkill . getModifiedAmount ( ) ;
float def = ab . item_defense_rating ;
float def = template . item_defense_rating ;
//apply item defense bonuses
//apply item defense bonuses
if ( shield ! = null ) {
if ( shield ! = null ) {
def + = shield . getBonus ( ModType . DR , SourceType . NONE ) ;
def + = shield . getBonus ( ModType . DR , SourceType . NONE ) ;
def * = ( 1 + shield . getBonusPercent ( ModType . DR , SourceType . NONE ) ) ;
def * = ( 1 + shield . getBonusPercent ( ModType . DR , SourceType . NONE ) ) ;
@ -983,39 +994,45 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
* @ Calculates Defense for weapon
* @ Calculates Defense for weapon
* /
* /
private static float getWeaponDefense ( AbstractCharacter abstractCharacter , ConcurrentHashMap < EquipSlotType , Item > equipped ) {
private static float getWeaponDefense ( AbstractCharacter abstractCharacter , ConcurrentHashMap < EquipSlotType , Item > equipped ) {
Item weapon = equipped . get ( EquipSlotType . RHELD ) ;
Item weapon = equipped . get ( EquipSlotType . RHELD ) ;
ItemTemplate wb = null ;
ItemTemplate weaponTemplate = null ;
CharacterSkill skill , mastery ;
CharacterSkill skill , mastery ;
float val = 0 ;
float val = 0 ;
boolean unarmed = false ;
boolean unarmed = false ;
if ( weapon = = null ) {
if ( weapon = = null ) {
weapon = equipped . get ( EquipSlotType . LHELD ) ;
weapon = equipped . get ( EquipSlotType . LHELD ) ;
if ( weapon = = null | | ItemTemplate . isShield ( weapon ) )
if ( weapon = = null | | ItemTemplate . isShield ( weapon ) )
unarmed = true ;
unarmed = true ;
else
else
wb = weapon . template ;
weaponTemplate = weapon . template ;
} else
} else
wb = weapon . template ;
weaponTemplate = weapon . template ;
if ( wb = = null )
if ( weaponTemplate = = null )
unarmed = true ;
unarmed = true ;
if ( unarmed ) {
if ( unarmed ) {
skill = abstractCharacter . skills . get ( "Unarmed Combat" ) ;
skill = abstractCharacter . skills . get ( "Unarmed Combat" ) ;
mastery = abstractCharacter . skills . get ( "Unarmed Combat Mastery" ) ;
mastery = abstractCharacter . skills . get ( "Unarmed Combat Mastery" ) ;
} else {
} else {
skill = abstractCharacter . skills . get ( weapon . template . item_skill_used ) ;
skill = abstractCharacter . skills . get ( weapon . template . item_skill_used ) ;
mastery = abstractCharacter . skills . get ( wb . item_skill_mastery_used ) ;
mastery = abstractCharacter . skills . get ( weaponTemplate . item_skill_mastery_used ) ;
}
}
if ( skill ! = null )
if ( skill ! = null )
val + = ( int ) skill . getModifiedAmount ( ) / 2f ;
val + = ( int ) skill . getModifiedAmount ( ) / 2f ;
if ( mastery ! = null )
if ( mastery ! = null )
val + = ( int ) mastery . getModifiedAmount ( ) / 2f ;
val + = ( int ) mastery . getModifiedAmount ( ) / 2f ;
return val ;
return val ;
}
}
//Don't call this function directly. linked from pc.calculateSkills()
//Don't call this function directly. linked from pc.calculateSkills()
//through SkillCalcJob. Designed to only run from one worker thread
//through SkillCalcJob. Designed to only run from one worker thread
public static void runSkillCalc ( AbstractCharacter abstractCharacter ) {
public static void runSkillCalc ( AbstractCharacter abstractCharacter ) {
try {
//see if any new skills or powers granted
//see if any new skills or powers granted
CharacterSkill . calculateSkills ( abstractCharacter ) ;
CharacterSkill . calculateSkills ( abstractCharacter ) ;
@ -1024,18 +1041,20 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
//see if any new powers unlocked from previous check
//see if any new powers unlocked from previous check
CharacterPower . calculatePowers ( abstractCharacter ) ;
CharacterPower . calculatePowers ( abstractCharacter ) ;
} catch ( Exception e ) {
}
}
}
//calculate item bonuses here
//calculate item bonuses here
public static void calculateItemBonuses ( AbstractCharacter abstractCharacter ) {
public static void calculateItemBonuses ( AbstractCharacter abstractCharacter ) {
if ( abstractCharacter . charItemManager = = null | | abstractCharacter . bonuses = = null )
if ( abstractCharacter . charItemManager = = null | | abstractCharacter . bonuses = = null )
return ;
return ;
ConcurrentHashMap < EquipSlotType , Item > equipped = abstractCharacter . charItemManager . getEquipped ( ) ;
ConcurrentHashMap < EquipSlotType , Item > equipped = abstractCharacter . charItemManager . getEquipped ( ) ;
for ( Item item : equipped . values ( ) ) {
for ( Item item : equipped . values ( ) ) {
ItemTemplate ib = item . template ;
ItemTemplate ib = item . template ;
if ( ib = = null )
if ( ib = = null )
continue ;
continue ;
//TODO add effect bonuses in here for equipped items
//TODO add effect bonuses in here for equipped items
@ -1046,6 +1065,7 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
* @ Defaults ATR , Defense and Damage for player
* @ Defaults ATR , Defense and Damage for player
* /
* /
private static void defaultAtrAndDamage ( AbstractCharacter abstractCharacter , boolean mainHand ) {
private static void defaultAtrAndDamage ( AbstractCharacter abstractCharacter , boolean mainHand ) {
if ( mainHand ) {
if ( mainHand ) {
abstractCharacter . atrHandOne = 0 ;
abstractCharacter . atrHandOne = 0 ;
abstractCharacter . minDamageHandOne = 0 ;
abstractCharacter . minDamageHandOne = 0 ;
@ -1136,22 +1156,6 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
public final short getUnusedStatPoints ( ) {
public final short getUnusedStatPoints ( ) {
return this . unusedStatPoints ;
return this . unusedStatPoints ;
}
}
public final void setDebug (
final int value ,
final boolean toggle
) {
if ( toggle ) {
this . debug | = value ; //turn on debug
} else {
this . debug & = ~ value ; //turn off debug
}
}
public final boolean getDebug ( final int value ) {
return ( ( this . debug & value ) ! = 0 ) ;
}
@Override
@Override
public String getName ( ) {
public String getName ( ) {
if ( this . firstName . length ( ) = = 0 & & this . lastName . length ( ) = = 0 ) {
if ( this . firstName . length ( ) = = 0 & & this . lastName . length ( ) = = 0 ) {