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