Browse Source

animation work

combat-2
FatBoy-DOTC 7 months ago
parent
commit
3f3d85fb36
  1. 87
      src/engine/gameManager/CombatManager.java

87
src/engine/gameManager/CombatManager.java

@ -278,16 +278,7 @@ public enum CombatManager { @@ -278,16 +278,7 @@ public enum CombatManager {
if (target.getObjectType() == mbEnums.GameObjectType.Building)
hitChance = 100;
int passiveAnim = getSwingAnimation(null, null, slot.equals(mbEnums.EquipSlotType.RHELD));
if(attacker.getObjectType().equals(mbEnums.GameObjectType.Mob)){
if (weapon != null) {
passiveAnim = getSwingAnimation(weapon.template, null, true);
}
}else {
if (attacker.charItemManager.getEquipped().get(slot) != null) {
passiveAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, true);
}
}
int passiveAnim = getPassiveAnimation(mbEnums.PassiveType.None); // checking for a miss due to ATR vs Def
if (ThreadLocalRandom.current().nextInt(100) > hitChance) {
TargetedActionMsg msg = new TargetedActionMsg(attacker, target, 0f, passiveAnim);
@ -326,6 +317,7 @@ public enum CombatManager { @@ -326,6 +317,7 @@ public enum CombatManager {
if (!passiveType.equals(mbEnums.PassiveType.None)) {
passiveAnim = getPassiveAnimation(passiveType);
TargetedActionMsg msg = new TargetedActionMsg(attacker, passiveAnim, target, passiveType.value);
if (target.getObjectType() == mbEnums.GameObjectType.PlayerCharacter)
@ -430,13 +422,13 @@ public enum CombatManager { @@ -430,13 +422,13 @@ public enum CombatManager {
else
((Building) target).modifyHealth(-damage, attacker);
int attackAnim = getSwingAnimation(null, null, slot.equals(mbEnums.EquipSlotType.RHELD));
int attackAnim = getSwingAnimation(null, null, slot);
if (attacker.charItemManager.getEquipped().get(slot) != null) {
if (attacker.getObjectType().equals(mbEnums.GameObjectType.PlayerCharacter)) {
DeferredPowerJob weaponPower = ((PlayerCharacter) attacker).getWeaponPower();
attackAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, weaponPower, slot.equals(mbEnums.EquipSlotType.RHELD));
attackAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, weaponPower, slot);
} else {
attackAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, slot.equals(mbEnums.EquipSlotType.RHELD));
attackAnim = getSwingAnimation(attacker.charItemManager.getEquipped().get(slot).template, null, slot);
}
}
TargetedActionMsg cmm = new TargetedActionMsg(attacker, target, (float) damage, attackAnim);
@ -518,7 +510,11 @@ public enum CombatManager { @@ -518,7 +510,11 @@ public enum CombatManager {
target.setCombatTarget(attacker);
}
public static int getSwingAnimation(ItemTemplate wb, DeferredPowerJob dpj, boolean mainHand) {
public static int getSwingAnimation(ItemTemplate wb, DeferredPowerJob dpj, mbEnums.EquipSlotType slot) {
//No weapon, return default animation
if (wb == null)
return 75;
int token;
@ -528,28 +524,61 @@ public enum CombatManager { @@ -528,28 +524,61 @@ public enum CombatManager {
if (token == 563721004) //kick animation
return 79;
}
if (wb != null) {
if (mainHand) {
int random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size());
int anim = wb.weapon_attack_anim_right.get(random)[0];
return anim;
//Item has no equipment slots and should not try to return an animation, return default instead
if(wb.item_eq_slots_or == null || wb.item_eq_slots_or.size() == 0){
return 75;
}
//declare variables
int anim;
int random;
//Item can only be equipped in one slot, return animation for that slot
if(wb.item_eq_slots_or.size() == 1){
if (wb.item_eq_slots_or.iterator().next().equals(mbEnums.EquipSlotType.RHELD)) {
anim = wb.weapon_attack_anim_right.get(0)[0];
if (dpj != null) {
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size());
anim = wb.weapon_attack_anim_right.get(random)[0];
}
}else {
int random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size());
return wb.weapon_attack_anim_left.get(random)[0];
anim = wb.weapon_attack_anim_left.get(0)[0];
if (dpj != null) {
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size());
anim = wb.weapon_attack_anim_left.get(random)[0];
}
}
return anim;
}
if (wb == null)
return 75;
if(wb.item_skill_used.equals("Bow") || wb.obj_name.equals("Siege Bow"))
return wb.weapon_attack_anim_left.get(0)[0];
if (mainHand)
return wb.weapon_attack_anim_right.get(0)[0];
else
return wb.weapon_attack_anim_left.get(0)[0];
//Item can be equipped in either hand, and should have animation sets for each hand
if (slot.equals(mbEnums.EquipSlotType.RHELD)) {
anim = wb.weapon_attack_anim_right.get(0)[0];
if (dpj != null) {
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_right.size());
anim = wb.weapon_attack_anim_right.get(random)[0];
}
}else {
anim = wb.weapon_attack_anim_left.get(0)[0];
if (dpj != null) {
random = ThreadLocalRandom.current().nextInt(wb.weapon_attack_anim_left.size());
anim = wb.weapon_attack_anim_left.get(random)[0];
}
}
return anim;
}
public static int getPassiveAnimation(mbEnums.PassiveType passiveType){
switch(passiveType){
case Block:
return 298;
case Parry:
return 299;
default:
return 0;
}
}
public static void setAutoAttackJob(AbstractCharacter attacker, mbEnums.EquipSlotType slot, long delay) {

Loading…
Cancel
Save