Browse Source

animation work

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

Loading…
Cancel
Save