@ -8,11 +8,11 @@
package engine.gameManager ;
package engine.gameManager ;
import engine.Enum ;
import engine.job.JobContainer ;
import engine.job.JobContainer ;
import engine.job.JobScheduler ;
import engine.job.JobScheduler ;
import engine.jobs.AttackJob ;
import engine.jobs.AttackJob ;
import engine.jobs.DeferredPowerJob ;
import engine.jobs.DeferredPowerJob ;
import engine.mbEnums ;
import engine.net.DispatchMessage ;
import engine.net.DispatchMessage ;
import engine.net.client.ClientConnection ;
import engine.net.client.ClientConnection ;
import engine.net.client.msg.TargetedActionMsg ;
import engine.net.client.msg.TargetedActionMsg ;
@ -46,40 +46,40 @@ public enum CombatManager {
case PlayerCharacter :
case PlayerCharacter :
case Mob :
case Mob :
PlayerBonuses bonuses = ( ( AbstractCharacter ) target ) . getBonuses ( ) ;
PlayerBonuses bonuses = ( ( AbstractCharacter ) target ) . getBonuses ( ) ;
if ( bonuses ! = null & & bonuses . getBool ( Enum . ModType . ImmuneToAttack , Enum . SourceType . None ) )
if ( bonuses ! = null & & bonuses . getBool ( mb Enums . ModType . ImmuneToAttack , mb Enums . SourceType . None ) )
return ;
return ;
break ;
break ;
case NPC :
case NPC :
return ;
return ;
}
}
Item mainWeapon = attacker . charItemManager . getEquipped ( ) . get ( Enum . EquipSlotType . RHELD ) ;
Item mainWeapon = attacker . charItemManager . getEquipped ( ) . get ( mb Enums . EquipSlotType . RHELD ) ;
Item offWeapon = attacker . charItemManager . getEquipped ( ) . get ( Enum . EquipSlotType . LHELD ) ;
Item offWeapon = attacker . charItemManager . getEquipped ( ) . get ( mb Enums . EquipSlotType . LHELD ) ;
if ( mainWeapon = = null & & offWeapon = = null ) {
if ( mainWeapon = = null & & offWeapon = = null ) {
//no weapons equipped, punch with both fists
//no weapons equipped, punch with both fists
processAttack ( attacker , target , Enum . EquipSlotType . RHELD ) ;
processAttack ( attacker , target , mb Enums . EquipSlotType . RHELD ) ;
processAttack ( attacker , target , Enum . EquipSlotType . LHELD ) ;
processAttack ( attacker , target , mb Enums . EquipSlotType . LHELD ) ;
} else if ( mainWeapon = = null & & offWeapon ! = null & & offWeapon . template . item_skill_required . containsKey ( "Block" ) ) {
} else if ( mainWeapon = = null & & offWeapon ! = null & & offWeapon . template . item_skill_required . containsKey ( "Block" ) ) {
//no weapon equipped with a shield, punch with one hand
//no weapon equipped with a shield, punch with one hand
processAttack ( attacker , target , Enum . EquipSlotType . RHELD ) ;
processAttack ( attacker , target , mb Enums . EquipSlotType . RHELD ) ;
} else if ( mainWeapon ! = null & & offWeapon ! = null & & offWeapon . template . item_skill_required . containsKey ( "Block" ) ) {
} else if ( mainWeapon ! = null & & offWeapon ! = null & & offWeapon . template . item_skill_required . containsKey ( "Block" ) ) {
//one weapon equipped with a shield, swing with one hand
//one weapon equipped with a shield, swing with one hand
processAttack ( attacker , target , Enum . EquipSlotType . RHELD ) ;
processAttack ( attacker , target , mb Enums . EquipSlotType . RHELD ) ;
} else if ( mainWeapon ! = null & & offWeapon ! = null & & offWeapon . template . item_skill_required . containsKey ( "Block" ) = = false ) {
} else if ( mainWeapon ! = null & & offWeapon ! = null & & offWeapon . template . item_skill_required . containsKey ( "Block" ) = = false ) {
//two weapons equipped, swing both hands
//two weapons equipped, swing both hands
processAttack ( attacker , target , Enum . EquipSlotType . RHELD ) ;
processAttack ( attacker , target , mb Enums . EquipSlotType . RHELD ) ;
processAttack ( attacker , target , Enum . EquipSlotType . LHELD ) ;
processAttack ( attacker , target , mb Enums . EquipSlotType . LHELD ) ;
} else if ( mainWeapon = = null & & offWeapon ! = null & & offWeapon . template . item_skill_required . containsKey ( "Block" ) = = false ) {
} else if ( mainWeapon = = null & & offWeapon ! = null & & offWeapon . template . item_skill_required . containsKey ( "Block" ) = = false ) {
//swing left hand only
//swing left hand only
processAttack ( attacker , target , Enum . EquipSlotType . LHELD ) ;
processAttack ( attacker , target , mb Enums . EquipSlotType . LHELD ) ;
} else if ( mainWeapon ! = null & & offWeapon = = null ) {
} else if ( mainWeapon ! = null & & offWeapon = = null ) {
//swing left hand only
//swing left hand only
processAttack ( attacker , target , Enum . EquipSlotType . RHELD ) ;
processAttack ( attacker , target , mb Enums . EquipSlotType . RHELD ) ;
}
}
}
}
public static void processAttack ( AbstractCharacter attacker , AbstractWorldObject target , Enum . EquipSlotType slot ) {
public static void processAttack ( AbstractCharacter attacker , AbstractWorldObject target , mb Enums . EquipSlotType slot ) {
// heck if character can even attack yet
// heck if character can even attack yet
@ -98,12 +98,12 @@ public enum CombatManager {
if ( weapon ! = null ) {
if ( weapon ! = null ) {
if ( bonus ! = null )
if ( bonus ! = null )
rangeMod + = bonus . getFloatPercentAll ( Enum . ModType . WeaponRange , Enum . SourceType . None ) ;
rangeMod + = bonus . getFloatPercentAll ( mb Enums . ModType . WeaponRange , mb Enums . SourceType . None ) ;
attackRange = weapon . template . item_weapon_max_range * rangeMod ;
attackRange = weapon . template . item_weapon_max_range * rangeMod ;
}
}
if ( attacker . getObjectType ( ) . equals ( Enum . GameObjectType . Mob ) )
if ( attacker . getObjectType ( ) . equals ( mb Enums . GameObjectType . Mob ) )
if ( ( ( Mob ) attacker ) . isSiege ( ) )
if ( ( ( Mob ) attacker ) . isSiege ( ) )
attackRange = 300 ;
attackRange = 300 ;
@ -133,7 +133,7 @@ public enum CombatManager {
//get the proper stats based on which slot is attacking
//get the proper stats based on which slot is attacking
if ( slot = = Enum . EquipSlotType . LHELD ) {
if ( slot = = mb Enums . EquipSlotType . LHELD ) {
min = attacker . minDamageHandTwo ;
min = attacker . minDamageHandTwo ;
max = attacker . maxDamageHandTwo ;
max = attacker . maxDamageHandTwo ;
atr = attacker . atrHandTwo ;
atr = attacker . atrHandTwo ;
@ -156,10 +156,10 @@ public enum CombatManager {
else
else
hitChance = ( ( int ) ( 450 * ( dif - 0 . 8f ) ) + 4 ) ;
hitChance = ( ( int ) ( 450 * ( dif - 0 . 8f ) ) + 4 ) ;
if ( target . getObjectType ( ) = = Enum . GameObjectType . Building )
if ( target . getObjectType ( ) = = mb Enums . GameObjectType . Building )
hitChance = 100 ;
hitChance = 100 ;
int passiveAnim = getSwingAnimation ( null , null , slot . equals ( Enum . EquipSlotType . RHELD ) ) ;
int passiveAnim = getSwingAnimation ( null , null , slot . equals ( mb Enums . EquipSlotType . RHELD ) ) ;
if ( attacker . charItemManager . getEquipped ( ) . get ( slot ) ! = null ) {
if ( attacker . charItemManager . getEquipped ( ) . get ( slot ) ! = null ) {
passiveAnim = getSwingAnimation ( attacker . charItemManager . getEquipped ( ) . get ( slot ) . template , null , true ) ;
passiveAnim = getSwingAnimation ( attacker . charItemManager . getEquipped ( ) . get ( slot ) . template , null , true ) ;
}
}
@ -167,8 +167,8 @@ public enum CombatManager {
if ( ThreadLocalRandom . current ( ) . nextInt ( 100 ) > hitChance ) {
if ( ThreadLocalRandom . current ( ) . nextInt ( 100 ) > hitChance ) {
TargetedActionMsg msg = new TargetedActionMsg ( attacker , target , 0f , passiveAnim ) ;
TargetedActionMsg msg = new TargetedActionMsg ( attacker , target , 0f , passiveAnim ) ;
if ( target . getObjectType ( ) = = Enum . GameObjectType . PlayerCharacter )
if ( target . getObjectType ( ) = = mb Enums . GameObjectType . PlayerCharacter )
DispatchMessage . dispatchMsgToInterestArea ( target , msg , Enum . DispatchChannel . PRIMARY , MBServerStatics . CHARACTER_LOAD_RANGE , true , false ) ;
DispatchMessage . dispatchMsgToInterestArea ( target , msg , mb Enums . DispatchChannel . PRIMARY , MBServerStatics . CHARACTER_LOAD_RANGE , true , false ) ;
else
else
DispatchMessage . sendToAllInRange ( attacker , msg ) ;
DispatchMessage . sendToAllInRange ( attacker , msg ) ;
@ -177,8 +177,8 @@ public enum CombatManager {
//calculate passive chances only if target is AbstractCharacter
//calculate passive chances only if target is AbstractCharacter
if ( EnumSet . of ( Enum . GameObjectType . PlayerCharacter , Enum . GameObjectType . NPC , Enum . GameObjectType . Mob ) . contains ( target . getObjectType ( ) ) ) {
if ( EnumSet . of ( mb Enums . GameObjectType . PlayerCharacter , mb Enums . GameObjectType . NPC , mb Enums . GameObjectType . Mob ) . contains ( target . getObjectType ( ) ) ) {
Enum . PassiveType passiveType = Enum . PassiveType . None ;
mb Enums . PassiveType passiveType = mb Enums . PassiveType . None ;
int hitRoll = ThreadLocalRandom . current ( ) . nextInt ( 100 ) ;
int hitRoll = ThreadLocalRandom . current ( ) . nextInt ( 100 ) ;
float dodgeChance = ( ( AbstractCharacter ) target ) . getPassiveChance ( "Dodge" , attacker . getLevel ( ) , true ) ;
float dodgeChance = ( ( AbstractCharacter ) target ) . getPassiveChance ( "Dodge" , attacker . getLevel ( ) , true ) ;
@ -192,18 +192,18 @@ public enum CombatManager {
parryChance = Math . max ( 0 , Math . min ( 75 , parryChance ) ) ;
parryChance = Math . max ( 0 , Math . min ( 75 , parryChance ) ) ;
if ( hitRoll < dodgeChance )
if ( hitRoll < dodgeChance )
passiveType = Enum . PassiveType . Dodge ;
passiveType = mb Enums . PassiveType . Dodge ;
else if ( hitRoll < blockChance )
else if ( hitRoll < blockChance )
passiveType = Enum . PassiveType . Block ;
passiveType = mb Enums . PassiveType . Block ;
else if ( hitRoll < parryChance )
else if ( hitRoll < parryChance )
passiveType = Enum . PassiveType . Parry ;
passiveType = mb Enums . PassiveType . Parry ;
if ( passiveType . equals ( Enum . PassiveType . None ) = = false ) {
if ( passiveType . equals ( mb Enums . PassiveType . None ) = = false ) {
TargetedActionMsg msg = new TargetedActionMsg ( attacker , passiveAnim , target , passiveType . value ) ;
TargetedActionMsg msg = new TargetedActionMsg ( attacker , passiveAnim , target , passiveType . value ) ;
if ( target . getObjectType ( ) = = Enum . GameObjectType . PlayerCharacter )
if ( target . getObjectType ( ) = = mb Enums . GameObjectType . PlayerCharacter )
DispatchMessage . dispatchMsgToInterestArea ( target , msg , Enum . DispatchChannel . PRIMARY , MBServerStatics . CHARACTER_LOAD_RANGE , true , false ) ;
DispatchMessage . dispatchMsgToInterestArea ( target , msg , mb Enums . DispatchChannel . PRIMARY , MBServerStatics . CHARACTER_LOAD_RANGE , true , false ) ;
else
else
DispatchMessage . sendToAllInRange ( attacker , msg ) ;
DispatchMessage . sendToAllInRange ( attacker , msg ) ;
@ -218,15 +218,15 @@ public enum CombatManager {
//get the damage type
//get the damage type
Enum . DamageType damageType ;
mb Enums . DamageType damageType ;
if ( attacker . charItemManager . getEquipped ( ) . get ( slot ) = = null ) {
if ( attacker . charItemManager . getEquipped ( ) . get ( slot ) = = null ) {
damageType = Enum . DamageType . CRUSHING ;
damageType = mb Enums . DamageType . CRUSHING ;
if ( attacker . getObjectType ( ) . equals ( Enum . GameObjectType . Mob ) )
if ( attacker . getObjectType ( ) . equals ( mb Enums . GameObjectType . Mob ) )
if ( ( ( Mob ) attacker ) . isSiege ( ) )
if ( ( ( Mob ) attacker ) . isSiege ( ) )
damageType = Enum . DamageType . SIEGE ;
damageType = mb Enums . DamageType . SIEGE ;
} else {
} else {
damageType = ( Enum . DamageType ) attacker . charItemManager . getEquipped ( ) . get ( slot ) . template . item_weapon_damage . keySet ( ) . toArray ( ) [ 0 ] ;
damageType = ( mb Enums . DamageType ) attacker . charItemManager . getEquipped ( ) . get ( slot ) . template . item_weapon_damage . keySet ( ) . toArray ( ) [ 0 ] ;
}
}
//get resists
//get resists
@ -298,16 +298,16 @@ public enum CombatManager {
else
else
( ( Building ) target ) . setCurrentHitPoints ( target . getCurrentHitpoints ( ) - damage ) ;
( ( Building ) target ) . setCurrentHitPoints ( target . getCurrentHitpoints ( ) - damage ) ;
int attackAnim = getSwingAnimation ( null , null , slot . equals ( Enum . EquipSlotType . RHELD ) ) ;
int attackAnim = getSwingAnimation ( null , null , slot . equals ( mb Enums . EquipSlotType . RHELD ) ) ;
if ( attacker . charItemManager . getEquipped ( ) . get ( slot ) ! = null ) {
if ( attacker . charItemManager . getEquipped ( ) . get ( slot ) ! = null ) {
attackAnim = getSwingAnimation ( attacker . charItemManager . getEquipped ( ) . get ( slot ) . template , null , slot . equals ( Enum . EquipSlotType . RHELD ) ) ;
attackAnim = getSwingAnimation ( attacker . charItemManager . getEquipped ( ) . get ( slot ) . template , null , slot . equals ( mb Enums . EquipSlotType . RHELD ) ) ;
}
}
TargetedActionMsg cmm = new TargetedActionMsg ( attacker , target , ( float ) damage , attackAnim ) ;
TargetedActionMsg cmm = new TargetedActionMsg ( attacker , target , ( float ) damage , attackAnim ) ;
DispatchMessage . sendToAllInRange ( target , cmm ) ;
DispatchMessage . sendToAllInRange ( target , cmm ) ;
}
}
DeferredPowerJob dpj = null ;
DeferredPowerJob dpj = null ;
if ( attacker . getObjectType ( ) . equals ( Enum . GameObjectType . PlayerCharacter ) ) {
if ( attacker . getObjectType ( ) . equals ( mb Enums . GameObjectType . PlayerCharacter ) ) {
dpj = ( ( PlayerCharacter ) attacker ) . getWeaponPower ( ) ;
dpj = ( ( PlayerCharacter ) attacker ) . getWeaponPower ( ) ;
@ -326,11 +326,11 @@ public enum CombatManager {
int wepSpeed = ( int ) ( weapon . template . item_weapon_wepspeed ) ;
int wepSpeed = ( int ) ( weapon . template . item_weapon_wepspeed ) ;
if ( weapon . getBonusPercent ( Enum . ModType . WeaponSpeed , Enum . SourceType . None ) ! = 0f ) //add weapon speed bonus
if ( weapon . getBonusPercent ( mb Enums . ModType . WeaponSpeed , mb Enums . SourceType . None ) ! = 0f ) //add weapon speed bonus
wepSpeed * = ( 1 + weapon . getBonus ( Enum . ModType . WeaponSpeed , Enum . SourceType . None ) ) ;
wepSpeed * = ( 1 + weapon . getBonus ( mb Enums . ModType . WeaponSpeed , mb Enums . SourceType . None ) ) ;
if ( attacker . getBonuses ( ) ! = null & & attacker . getBonuses ( ) . getFloatPercentAll ( Enum . ModType . AttackDelay , Enum . SourceType . None ) ! = 0f ) //add effects speed bonus
if ( attacker . getBonuses ( ) ! = null & & attacker . getBonuses ( ) . getFloatPercentAll ( mb Enums . ModType . AttackDelay , mb Enums . SourceType . None ) ! = 0f ) //add effects speed bonus
wepSpeed * = ( 1 + attacker . getBonuses ( ) . getFloatPercentAll ( Enum . ModType . AttackDelay , Enum . SourceType . None ) ) ;
wepSpeed * = ( 1 + attacker . getBonuses ( ) . getFloatPercentAll ( mb Enums . ModType . AttackDelay , mb Enums . SourceType . None ) ) ;
if ( wepSpeed < 10 )
if ( wepSpeed < 10 )
wepSpeed = 10 ; //Old was 10, but it can be reached lower with legit buffs,effects.
wepSpeed = 10 ; //Old was 10, but it can be reached lower with legit buffs,effects.
@ -368,7 +368,7 @@ public enum CombatManager {
UpdateStateMsg rwss = new UpdateStateMsg ( ) ;
UpdateStateMsg rwss = new UpdateStateMsg ( ) ;
rwss . setPlayer ( playerCharacter ) ;
rwss . setPlayer ( playerCharacter ) ;
DispatchMessage . dispatchMsgToInterestArea ( playerCharacter , rwss , Enum . DispatchChannel . PRIMARY , MBServerStatics . CHARACTER_LOAD_RANGE , false , false ) ;
DispatchMessage . dispatchMsgToInterestArea ( playerCharacter , rwss , mb Enums . DispatchChannel . PRIMARY , MBServerStatics . CHARACTER_LOAD_RANGE , false , false ) ;
}
}
public static void toggleSit ( boolean toggle , ClientConnection origin ) {
public static void toggleSit ( boolean toggle , ClientConnection origin ) {
@ -381,7 +381,7 @@ public enum CombatManager {
playerCharacter . setSit ( toggle ) ;
playerCharacter . setSit ( toggle ) ;
UpdateStateMsg rwss = new UpdateStateMsg ( ) ;
UpdateStateMsg rwss = new UpdateStateMsg ( ) ;
rwss . setPlayer ( playerCharacter ) ;
rwss . setPlayer ( playerCharacter ) ;
DispatchMessage . dispatchMsgToInterestArea ( playerCharacter , rwss , Enum . DispatchChannel . PRIMARY , MBServerStatics . CHARACTER_LOAD_RANGE , true , false ) ;
DispatchMessage . dispatchMsgToInterestArea ( playerCharacter , rwss , mb Enums . DispatchChannel . PRIMARY , MBServerStatics . CHARACTER_LOAD_RANGE , true , false ) ;
}
}
@ -395,7 +395,7 @@ public enum CombatManager {
if ( attacker . equals ( target ) )
if ( attacker . equals ( target ) )
return ;
return ;
if ( target . isMoving ( ) & & target . getObjectType ( ) . equals ( Enum . GameObjectType . PlayerCharacter ) )
if ( target . isMoving ( ) & & target . getObjectType ( ) . equals ( mb Enums . GameObjectType . PlayerCharacter ) )
return ;
return ;
if ( ! target . isAlive ( ) | | ! attacker . isAlive ( ) )
if ( ! target . isAlive ( ) | | ! attacker . isAlive ( ) )