attack animation sounds
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
cdfa594c06
commit
920f3912de
BIN
assets/Audio/weapons/swoosh-03.ogg
Normal file
BIN
assets/Audio/weapons/swoosh-03.ogg
Normal file
Binary file not shown.
@ -375,21 +375,27 @@
|
||||
"driftFrameStart" : 7,
|
||||
"driftFrameEnd" : 15,
|
||||
"initialMove" : true,
|
||||
"animationWindup" : {
|
||||
"windupState" : {
|
||||
"animation" : {
|
||||
"nameFirstPerson" : "Sword1HSlash1",
|
||||
"nameThirdPerson" : "Sword1HSlash1",
|
||||
"priorityCategory" : "MOVEMENT_MODIFIER"
|
||||
}
|
||||
},
|
||||
"animationHold" : {
|
||||
"holdState" : {
|
||||
"animation" : {
|
||||
"nameFirstPerson" : "Sword1HSlash1",
|
||||
"nameThirdPerson" : "Sword1HSlash1",
|
||||
"priorityCategory" : "MOVEMENT_MODIFIER"
|
||||
}
|
||||
},
|
||||
"animationAttack" : {
|
||||
"attackState" : {
|
||||
"animation" : {
|
||||
"nameFirstPerson" : "Sword1HSlash1",
|
||||
"nameThirdPerson" : "Sword1HSlash1",
|
||||
"priorityCategory" : "MOVEMENT_MODIFIER"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"attackMoveId" : "Sword1HSlash2",
|
||||
@ -405,21 +411,27 @@
|
||||
"driftFrameStart" : 1,
|
||||
"driftFrameEnd" : 10,
|
||||
"initialMove" : false,
|
||||
"animationWindup" : {
|
||||
"windupState" : {
|
||||
"animation" : {
|
||||
"nameFirstPerson" : "Jump",
|
||||
"nameThirdPerson" : "Jump",
|
||||
"priorityCategory" : "MOVEMENT_MODIFIER"
|
||||
}
|
||||
},
|
||||
"animationHold" : {
|
||||
"holdState" : {
|
||||
"animation" : {
|
||||
"nameFirstPerson" : "Jump",
|
||||
"nameThirdPerson" : "Jump",
|
||||
"priorityCategory" : "MOVEMENT_MODIFIER"
|
||||
}
|
||||
},
|
||||
"animationAttack" : {
|
||||
"attackState" : {
|
||||
"animation" : {
|
||||
"nameFirstPerson" : "Sword1HSlash2",
|
||||
"nameThirdPerson" : "Sword1HSlash2",
|
||||
"priorityCategory" : "MOVEMENT_MODIFIER"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"attackMoveId" : "Sword2HSlash1",
|
||||
@ -434,10 +446,15 @@
|
||||
"driftFrameStart" : 1,
|
||||
"driftFrameEnd" : 10,
|
||||
"initialMove" : true,
|
||||
"animationAttack" : {
|
||||
"attackState" : {
|
||||
"animation" : {
|
||||
"nameFirstPerson" : "SwordR2HSlash",
|
||||
"nameThirdPerson" : "SwordR2HSlash",
|
||||
"priorityCategory" : "MOVEMENT_MODIFIER"
|
||||
},
|
||||
"audioData" : {
|
||||
"audioPath" : "Audio/weapons/swoosh-03.ogg"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -453,22 +470,28 @@
|
||||
"movementEnd" : 0,
|
||||
"movementGoal" : 0,
|
||||
"initialMove" : true,
|
||||
"animationWindup" : {
|
||||
"windupState" : {
|
||||
"animation" : {
|
||||
"nameFirstPerson" : "Jump",
|
||||
"nameThirdPerson" : "HoldBowString",
|
||||
"priorityCategory" : "MOVEMENT_MODIFIER"
|
||||
}
|
||||
},
|
||||
"animationHold" : {
|
||||
"holdState" : {
|
||||
"animation" : {
|
||||
"nameFirstPerson" : "Jump",
|
||||
"nameThirdPerson" : "HoldBow",
|
||||
"priorityCategory" : "MOVEMENT_MODIFIER"
|
||||
}
|
||||
},
|
||||
"animationAttack" : {
|
||||
"nameFirstPerson" : "Jump",
|
||||
"attackState" : {
|
||||
"animation" : {
|
||||
"nameFirstPerson" : "Sword1HSlash2",
|
||||
"nameThirdPerson" : "HoldBowString",
|
||||
"priorityCategory" : "MOVEMENT_MODIFIER"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"healthSystem" : {
|
||||
"maxHealth" : 100,
|
||||
|
||||
@ -16,3 +16,12 @@ Things that feel bad:
|
||||
No audio
|
||||
Short movement bursts feel jittery
|
||||
Part of this may be cylinder collidable instead of capsule
|
||||
|
||||
|
||||
Sound effect on hit
|
||||
Sound effect on walk
|
||||
Sound effect on jump
|
||||
Sound effect on land
|
||||
Sound effect on block
|
||||
Allow block hotboxes to block damage
|
||||
Server packet on damage collision
|
||||
|
||||
@ -508,6 +508,7 @@ Audio on block state transitions
|
||||
|
||||
(08/04/2024)
|
||||
Strafe/backpedal movement speed multipliers
|
||||
Properly equipping/unequipping 2hand items
|
||||
|
||||
# TODO
|
||||
|
||||
|
||||
@ -135,7 +135,7 @@ public class Globals {
|
||||
public static boolean RUN_DEMO = false;
|
||||
public static boolean RUN_CLIENT = true;
|
||||
public static boolean RUN_HIDDEN = false; //glfw session will be created with hidden window
|
||||
public static boolean RUN_AUDIO = false;
|
||||
public static boolean RUN_AUDIO = true;
|
||||
public static int clientCharacterID;
|
||||
|
||||
//
|
||||
@ -469,6 +469,7 @@ public class Globals {
|
||||
"/Audio/closeMenu.ogg",
|
||||
"/Audio/ambienceWind1SeamlessMono.ogg",
|
||||
"/Audio/weapons/swordUnsheath1.ogg",
|
||||
"/Audio/weapons/swoosh-03.ogg",
|
||||
};
|
||||
LoggerInterface.loggerStartup.INFO("Loading default audio resources");
|
||||
for(String path : audioToInit){
|
||||
|
||||
@ -6,7 +6,6 @@ import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.AnimationPriorities;
|
||||
import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
|
||||
import electrosphere.game.data.common.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.TreeDataAudio;
|
||||
@ -181,7 +180,7 @@ public class StateTransitionUtil {
|
||||
if(state.onComplete != null){
|
||||
state.onComplete.run();
|
||||
}
|
||||
} else if(!poseActor.isPlayingAnimation() && state.onComplete != null && state.startedAnimation == true){
|
||||
} else if(!poseActor.isPlayingAnimation(animation) && state.onComplete != null && state.startedAnimation == true){
|
||||
//state transition if this isn't set to loop
|
||||
state.onComplete.run();
|
||||
state.startedAnimation = false;
|
||||
|
||||
@ -8,7 +8,8 @@ import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
|
||||
import electrosphere.entity.btree.StateTransitionUtil;
|
||||
import electrosphere.entity.btree.StateTransitionUtil.StateTransitionUtilItem;
|
||||
import electrosphere.entity.state.collidable.Impulse;
|
||||
import electrosphere.entity.state.equip.ClientEquipState;
|
||||
import electrosphere.entity.state.hitbox.HitboxCollectionState;
|
||||
@ -17,12 +18,12 @@ import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.game.data.common.TreeDataState;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
import electrosphere.net.synchronization.annotation.SyncedField;
|
||||
import electrosphere.net.synchronization.annotation.SynchronizableEnum;
|
||||
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@ -94,10 +95,95 @@ public class ClientAttackTree implements BehaviorTree {
|
||||
String projectileToFire = null;
|
||||
String attackingPoint = null;
|
||||
|
||||
//The state transition util
|
||||
StateTransitionUtil stateTransitionUtil;
|
||||
|
||||
private ClientAttackTree(Entity e, Object ... params){
|
||||
setState(AttackTreeState.IDLE);
|
||||
setDriftState(AttackTreeDriftState.NO_DRIFT);
|
||||
parent = e;
|
||||
this.stateTransitionUtil = StateTransitionUtil.create(parent, false, new StateTransitionUtilItem[]{
|
||||
StateTransitionUtilItem.create(
|
||||
AttackTreeState.WINDUP,
|
||||
() -> {
|
||||
TreeDataState state = currentMove.getWindupState();
|
||||
if(state == null){
|
||||
return null;
|
||||
} else {
|
||||
return state.getAnimation();
|
||||
}
|
||||
},
|
||||
() -> {
|
||||
TreeDataState state = currentMove.getWindupState();
|
||||
if(state == null){
|
||||
return null;
|
||||
} else {
|
||||
return state.getAudioData();
|
||||
}
|
||||
},
|
||||
null
|
||||
),
|
||||
StateTransitionUtilItem.create(
|
||||
AttackTreeState.HOLD,
|
||||
() -> {
|
||||
TreeDataState state = currentMove.getHoldState();
|
||||
if(state == null){
|
||||
return null;
|
||||
} else {
|
||||
return state.getAnimation();
|
||||
}
|
||||
},
|
||||
() -> {
|
||||
TreeDataState state = currentMove.getHoldState();
|
||||
if(state == null){
|
||||
return null;
|
||||
} else {
|
||||
return state.getAudioData();
|
||||
}
|
||||
},
|
||||
null
|
||||
),
|
||||
StateTransitionUtilItem.create(
|
||||
AttackTreeState.ATTACK,
|
||||
() -> {
|
||||
TreeDataState state = currentMove.getAttackState();
|
||||
if(state == null){
|
||||
return null;
|
||||
} else {
|
||||
return state.getAnimation();
|
||||
}
|
||||
},
|
||||
() -> {
|
||||
TreeDataState state = currentMove.getAttackState();
|
||||
if(state == null){
|
||||
return null;
|
||||
} else {
|
||||
return state.getAudioData();
|
||||
}
|
||||
},
|
||||
null
|
||||
),
|
||||
StateTransitionUtilItem.create(
|
||||
AttackTreeState.COOLDOWN,
|
||||
() -> {
|
||||
TreeDataState state = currentMove.getCooldownState();
|
||||
if(state == null){
|
||||
return null;
|
||||
} else {
|
||||
return state.getAnimation();
|
||||
}
|
||||
},
|
||||
() -> {
|
||||
TreeDataState state = currentMove.getCooldownState();
|
||||
if(state == null){
|
||||
return null;
|
||||
} else {
|
||||
return state.getAudioData();
|
||||
}
|
||||
},
|
||||
null
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,7 +234,6 @@ public class ClientAttackTree implements BehaviorTree {
|
||||
@Override
|
||||
public void simulate(float deltaTime){
|
||||
frameCurrent = frameCurrent + (float)Globals.timekeeper.getDeltaFrames();
|
||||
Actor entityActor = EntityUtils.getActor(parent);
|
||||
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
|
||||
|
||||
//
|
||||
@ -237,49 +322,13 @@ public class ClientAttackTree implements BehaviorTree {
|
||||
if(parent.containsKey(EntityDataStrings.CLIENT_ROTATOR_TREE)){
|
||||
RotatorTree.getClientRotatorTree(parent).setActive(true);
|
||||
}
|
||||
if(currentMove != null && entityActor != null && currentMove.getAnimationWindup() != null){
|
||||
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(currentMove.getAnimationWindup())){
|
||||
entityActor.playAnimation(
|
||||
currentMove.getAnimationWindup(),
|
||||
true
|
||||
);
|
||||
entityActor.incrementAnimationTime(0.0001);
|
||||
}
|
||||
FirstPersonTree.conditionallyPlayAnimation(
|
||||
parent,
|
||||
currentMove.getAnimationWindup()
|
||||
);
|
||||
}
|
||||
this.stateTransitionUtil.simulate(AttackTreeState.WINDUP);
|
||||
} break;
|
||||
case HOLD: {
|
||||
if(entityActor != null && currentMove.getAnimationHold() != null){
|
||||
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(currentMove.getAnimationHold())){
|
||||
entityActor.playAnimation(
|
||||
currentMove.getAnimationHold(),
|
||||
true
|
||||
);
|
||||
entityActor.incrementAnimationTime(0.0001);
|
||||
}
|
||||
FirstPersonTree.conditionallyPlayAnimation(
|
||||
parent,
|
||||
currentMove.getAnimationHold()
|
||||
);
|
||||
}
|
||||
this.stateTransitionUtil.simulate(AttackTreeState.HOLD);
|
||||
} break;
|
||||
case ATTACK: {
|
||||
if(entityActor != null && currentMove != null){
|
||||
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(currentMove.getAnimationAttack())){
|
||||
entityActor.playAnimation(
|
||||
currentMove.getAnimationAttack(),
|
||||
true
|
||||
);
|
||||
entityActor.incrementAnimationTime(0.0001);
|
||||
}
|
||||
FirstPersonTree.conditionallyPlayAnimation(
|
||||
parent,
|
||||
currentMove.getAnimationAttack()
|
||||
);
|
||||
}
|
||||
this.stateTransitionUtil.simulate(AttackTreeState.ATTACK);
|
||||
//activate hitboxes
|
||||
List<Entity> attachedEntities = AttachUtils.getChildrenList(parent);
|
||||
if(attachedEntities != null){
|
||||
@ -292,6 +341,7 @@ public class ClientAttackTree implements BehaviorTree {
|
||||
}
|
||||
} break;
|
||||
case COOLDOWN: {
|
||||
this.stateTransitionUtil.simulate(AttackTreeState.COOLDOWN);
|
||||
//deactive hitboxes
|
||||
List<Entity> attachedEntities = AttachUtils.getChildrenList(parent);
|
||||
if(attachedEntities != null){
|
||||
|
||||
@ -12,7 +12,8 @@ import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.state.AnimationPriorities;
|
||||
import electrosphere.entity.btree.StateTransitionUtil;
|
||||
import electrosphere.entity.btree.StateTransitionUtil.StateTransitionUtilItem;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeDriftState;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState;
|
||||
import electrosphere.entity.state.collidable.Impulse;
|
||||
@ -25,14 +26,15 @@ import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
import electrosphere.entity.types.projectile.ProjectileUtils;
|
||||
import electrosphere.game.data.common.TreeDataState;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
import electrosphere.net.synchronization.annotation.SyncedField;
|
||||
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.server.datacell.Realm;
|
||||
import electrosphere.server.poseactor.PoseActor;
|
||||
import electrosphere.util.math.MathUtils;
|
||||
|
||||
import java.util.List;
|
||||
@ -80,10 +82,91 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
String projectileToFire = null;
|
||||
String attackingPoint = null;
|
||||
|
||||
//The state transition util
|
||||
StateTransitionUtil stateTransitionUtil;
|
||||
|
||||
private ServerAttackTree(Entity e, Object ... params){
|
||||
state = AttackTreeState.IDLE;
|
||||
driftState = AttackTreeDriftState.NO_DRIFT;
|
||||
parent = e;
|
||||
this.stateTransitionUtil = StateTransitionUtil.create(parent, true, new StateTransitionUtilItem[]{
|
||||
StateTransitionUtilItem.create(
|
||||
AttackTreeState.WINDUP,
|
||||
() -> {
|
||||
TreeDataState state = currentMove.getWindupState();
|
||||
if(state == null){
|
||||
return null;
|
||||
} else {
|
||||
return state.getAnimation();
|
||||
}
|
||||
},
|
||||
() -> {
|
||||
TreeDataState state = currentMove.getWindupState();
|
||||
if(state == null){
|
||||
return null;
|
||||
} else {
|
||||
return state.getAudioData();
|
||||
}
|
||||
},
|
||||
() -> {
|
||||
if(currentMoveCanHold && stillHold){
|
||||
setState(AttackTreeState.HOLD);
|
||||
} else {
|
||||
setState(AttackTreeState.ATTACK);
|
||||
}
|
||||
this.stateTransitionUtil.interrupt(AttackTreeState.WINDUP);
|
||||
}
|
||||
),
|
||||
StateTransitionUtilItem.create(
|
||||
AttackTreeState.HOLD,
|
||||
() -> {
|
||||
TreeDataState state = currentMove.getHoldState();
|
||||
if(state == null){
|
||||
return null;
|
||||
} else {
|
||||
return state.getAnimation();
|
||||
}
|
||||
},
|
||||
() -> {
|
||||
TreeDataState state = currentMove.getHoldState();
|
||||
if(state == null){
|
||||
return null;
|
||||
} else {
|
||||
return state.getAudioData();
|
||||
}
|
||||
},
|
||||
null
|
||||
),
|
||||
StateTransitionUtilItem.create(
|
||||
AttackTreeState.ATTACK,
|
||||
() -> {
|
||||
TreeDataState state = currentMove.getAttackState();
|
||||
if(state == null){
|
||||
return null;
|
||||
} else {
|
||||
return state.getAnimation();
|
||||
}
|
||||
},
|
||||
null,
|
||||
() -> {
|
||||
this.setState(AttackTreeState.COOLDOWN);
|
||||
this.stateTransitionUtil.interrupt(AttackTreeState.ATTACK);
|
||||
}
|
||||
),
|
||||
StateTransitionUtilItem.create(
|
||||
AttackTreeState.COOLDOWN,
|
||||
() -> {
|
||||
TreeDataState state = currentMove.getCooldownState();
|
||||
if(state == null){
|
||||
return null;
|
||||
} else {
|
||||
return state.getAnimation();
|
||||
}
|
||||
},
|
||||
null,
|
||||
null
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,14 +205,19 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
projectileToFire = ItemUtils.getWeaponDataRaw(currentWeapon).getProjectileModel();
|
||||
}
|
||||
|
||||
animationName = currentMove.getAnimationAttack().getNameThirdPerson();
|
||||
//intuit windup from presence of windup anim
|
||||
currentMoveHasWindup = currentMove.getAnimationWindup() != null;
|
||||
if(currentMoveHasWindup){
|
||||
animationName = currentMove.getAnimationWindup().getNameThirdPerson();
|
||||
//set initial stuff (this alerts the client as well)
|
||||
setCurrentMoveId(currentMove.getAttackMoveId());
|
||||
|
||||
//start tree
|
||||
if(currentMove.getWindupState() != null){
|
||||
setState(AttackTreeState.WINDUP);
|
||||
} else if(currentMove.getAttackState() != null){
|
||||
setState(AttackTreeState.ATTACK);
|
||||
} else {
|
||||
LoggerInterface.loggerEngine.ERROR(new IllegalStateException("Trying to start attacking tree, but current move does not have windup or attack states defined!"));
|
||||
}
|
||||
//intuit can hold from presence of windup anim
|
||||
currentMoveCanHold = currentMove.getAnimationHold() != null;
|
||||
currentMoveCanHold = currentMove.getHoldState() != null;
|
||||
//stop movement tree
|
||||
if(parent.containsKey(EntityDataStrings.SERVER_MOVEMENT_BT)){
|
||||
BehaviorTree movementTree = CreatureUtils.serverGetEntityMovementTree(parent);
|
||||
@ -139,9 +227,6 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
}
|
||||
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
|
||||
EntityUtils.getRotation(parent).rotationTo(MathUtils.getOriginVector(), new Vector3d(movementVector.x,movementVector.y,movementVector.z));
|
||||
//set initial stuff (this alerts the client as well)
|
||||
setCurrentMoveId(currentMove.getAttackMoveId());
|
||||
setState(AttackTreeState.WINDUP);
|
||||
frameCurrent = 0;
|
||||
} else {
|
||||
setState(AttackTreeState.IDLE);
|
||||
@ -166,7 +251,6 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
public void simulate(float deltaTime){
|
||||
frameCurrent = frameCurrent + (float)Globals.timekeeper.getDeltaFrames();
|
||||
float velocity = CreatureUtils.getVelocity(parent);
|
||||
PoseActor entityPoseActor = EntityUtils.getPoseActor(parent);
|
||||
Vector3d position = EntityUtils.getPosition(parent);
|
||||
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
|
||||
|
||||
@ -216,22 +300,7 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
if(parent.containsKey(EntityDataStrings.SERVER_ROTATOR_TREE)){
|
||||
ServerRotatorTree.getServerRotatorTree(parent).setActive(true);
|
||||
}
|
||||
if(entityPoseActor != null){
|
||||
if(!entityPoseActor.isPlayingAnimation() || !entityPoseActor.isPlayingAnimation(animationName)){
|
||||
entityPoseActor.playAnimation(
|
||||
animationName,
|
||||
AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER)
|
||||
);
|
||||
entityPoseActor.incrementAnimationTime(0.0001);
|
||||
}
|
||||
}
|
||||
if(frameCurrent > currentMove.getWindupFrames()){
|
||||
if(currentMoveCanHold && stillHold){
|
||||
setState(AttackTreeState.HOLD);
|
||||
} else {
|
||||
setState(AttackTreeState.ATTACK);
|
||||
}
|
||||
}
|
||||
this.stateTransitionUtil.simulate(AttackTreeState.WINDUP);
|
||||
Globals.server.broadcastMessage(
|
||||
EntityMessage.constructattackUpdateMessage(
|
||||
parent.getId(),
|
||||
@ -248,26 +317,14 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
);
|
||||
} break;
|
||||
case HOLD: {
|
||||
if(entityPoseActor != null){
|
||||
if(!entityPoseActor.isPlayingAnimation() || !entityPoseActor.isPlayingAnimation(animationName)){
|
||||
entityPoseActor.playAnimation(
|
||||
animationName,
|
||||
AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER)
|
||||
);
|
||||
entityPoseActor.incrementAnimationTime(0.0001);
|
||||
}
|
||||
}
|
||||
this.stateTransitionUtil.simulate(AttackTreeState.HOLD);
|
||||
if(!stillHold){
|
||||
setState(AttackTreeState.ATTACK);
|
||||
this.stateTransitionUtil.interrupt(AttackTreeState.HOLD);
|
||||
}
|
||||
} break;
|
||||
case ATTACK: {
|
||||
if(entityPoseActor != null && currentMove != null){
|
||||
if(!entityPoseActor.isPlayingAnimation() || !entityPoseActor.isPlayingAnimation(currentMove.getAnimationAttack())){
|
||||
entityPoseActor.playAnimation(currentMove.getAnimationAttack());
|
||||
entityPoseActor.incrementAnimationTime(0.0001);
|
||||
}
|
||||
}
|
||||
this.stateTransitionUtil.simulate(AttackTreeState.ATTACK);
|
||||
//activate hitboxes
|
||||
List<Entity> attachedEntities = AttachUtils.getChildrenList(parent);
|
||||
for(Entity currentAttached : attachedEntities){
|
||||
@ -310,9 +367,6 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
ProjectileUtils.serverSpawnBasicProjectile(parentRealm, projectileToFire, spawnPosition, arrowRotation, 750, initialVector, 0.03f);
|
||||
projectileToFire = null;
|
||||
}
|
||||
if(frameCurrent > currentMove.getWindupFrames() + currentMove.getAttackFrames()){
|
||||
setState(AttackTreeState.COOLDOWN);
|
||||
}
|
||||
Globals.server.broadcastMessage(
|
||||
EntityMessage.constructattackUpdateMessage(
|
||||
parent.getId(),
|
||||
@ -329,6 +383,7 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
);
|
||||
} break;
|
||||
case COOLDOWN: {
|
||||
this.stateTransitionUtil.simulate(AttackTreeState.COOLDOWN);
|
||||
//deactive hitboxes
|
||||
List<Entity> attachedEntities = AttachUtils.getChildrenList(parent);
|
||||
for(Entity currentAttached : attachedEntities){
|
||||
@ -339,6 +394,7 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
}
|
||||
if(frameCurrent > currentMove.getWindupFrames() + currentMove.getAttackFrames() + currentMove.getCooldownFrames()){
|
||||
setState(AttackTreeState.IDLE);
|
||||
this.stateTransitionUtil.interrupt(AttackTreeState.COOLDOWN);
|
||||
frameCurrent = 0;
|
||||
if(parent.containsKey(EntityDataStrings.SERVER_ROTATOR_TREE)){
|
||||
ServerRotatorTree.getServerRotatorTree(parent).setActive(false);
|
||||
|
||||
@ -84,9 +84,18 @@ public class CreatureDataValidator {
|
||||
List<TreeDataAnimation> animations = new LinkedList<TreeDataAnimation>();
|
||||
if(data.getAttackMoves() != null){
|
||||
for(AttackMove move : data.getAttackMoves()){
|
||||
animations.add(move.getAnimationAttack());
|
||||
animations.add(move.getAnimationHold());
|
||||
animations.add(move.getAnimationWindup());
|
||||
if(move.getWindupState() != null){
|
||||
animations.add(move.getWindupState().getAnimation());
|
||||
}
|
||||
if(move.getHoldState() != null){
|
||||
animations.add(move.getHoldState().getAnimation());
|
||||
}
|
||||
if(move.getAttackState() != null){
|
||||
animations.add(move.getAttackState().getAnimation());
|
||||
}
|
||||
if(move.getCooldownState() != null){
|
||||
animations.add(move.getCooldownState().getAnimation());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(data.getEquipPoints() != null){
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package electrosphere.game.data.creature.type.attack;
|
||||
|
||||
import electrosphere.game.data.common.TreeDataAnimation;
|
||||
import electrosphere.game.data.common.TreeDataState;
|
||||
|
||||
/**
|
||||
* Data about a single attack move this creature is capable of
|
||||
@ -16,9 +16,10 @@ public class AttackMove {
|
||||
/*
|
||||
Animation stuff
|
||||
*/
|
||||
TreeDataAnimation animationWindup;
|
||||
TreeDataAnimation animationHold;
|
||||
TreeDataAnimation animationAttack;
|
||||
TreeDataState windupState;
|
||||
TreeDataState holdState;
|
||||
TreeDataState attackState;
|
||||
TreeDataState cooldownState;
|
||||
|
||||
/*
|
||||
Damage stuff
|
||||
@ -61,27 +62,35 @@ public class AttackMove {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the animation to play for the windup
|
||||
* @return the animation
|
||||
* Gets the state to play for the windup
|
||||
* @return the state data
|
||||
*/
|
||||
public TreeDataAnimation getAnimationWindup() {
|
||||
return animationWindup;
|
||||
public TreeDataState getWindupState() {
|
||||
return windupState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the animation to play for the hold
|
||||
* @return the animation
|
||||
* Gets the state to play for the hold
|
||||
* @return the state data
|
||||
*/
|
||||
public TreeDataAnimation getAnimationHold() {
|
||||
return animationHold;
|
||||
public TreeDataState getHoldState() {
|
||||
return holdState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the animation to play for the attack
|
||||
* @return the animation
|
||||
* Gets the state to play for the attack
|
||||
* @return the state data
|
||||
*/
|
||||
public TreeDataAnimation getAnimationAttack() {
|
||||
return animationAttack;
|
||||
public TreeDataState getAttackState() {
|
||||
return attackState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the state to play for the cooldown
|
||||
* @return the state data
|
||||
*/
|
||||
public TreeDataState getCooldownState() {
|
||||
return cooldownState;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user