Tweaking attacking

This commit is contained in:
austin 2021-11-19 22:08:34 -05:00
parent 9228fd43ee
commit 992ef0d159
5 changed files with 65 additions and 14 deletions

View File

@ -136,7 +136,7 @@
"type" : "MELEE_WEAPON_SWING_ONE_HAND",
"animationName" : "Armature|SwingWeapon",
"damageStartFrame" : 30,
"damageEndFrame" : 120
"damageEndFrame" : 60
}
],
"healthSystem" : {

View File

@ -393,6 +393,7 @@ public class ControlHandler {
if(controls.get(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY).isIsMouse() && glfwGetMouseButton(Globals.window, controls.get(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY).getKeyValue()) == GLFW_PRESS){
if(controls.get(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY).isState() == false){
if(attackTree != null){
CreatureUtils.setMovementVector(Globals.playerCharacter, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).normalize());
attackTree.start(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND);
}
}

View File

@ -51,19 +51,25 @@ public class AttackTree {
}
public void start(String attackType){
parent.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, attackType);
AttackMove currentMove;
switch(attackType){
case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
currentMove = (AttackMove)parent.getData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND);
damageStartFrame = currentMove.getDamageStartFrame();
damageEndFrame = currentMove.getDamageEndFrame();
animationName = currentMove.getAnimationName();
break;
if(canAttack()){
parent.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, attackType);
AttackMove currentMove;
switch(attackType){
case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
currentMove = (AttackMove)parent.getData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND);
damageStartFrame = currentMove.getDamageStartFrame();
damageEndFrame = currentMove.getDamageEndFrame();
animationName = currentMove.getAnimationName();
break;
}
if(parent.getDataKeys().contains(EntityDataStrings.DATA_STRING_MOVEMENT_BT)){
CreatureUtils.getEntityMovementTree(parent).interrupt();
}
Vector3d movementVector = CreatureUtils.getMovementVector(parent);
EntityUtils.getRotation(parent).rotationTo(new Vector3f(0,0,1), new Vector3f((float)movementVector.x,(float)movementVector.y,(float)movementVector.z));
state = AttackTreeState.WINDUP;
frameCurrent = 0;
}
//TODO: check if can start moving
state = AttackTreeState.WINDUP;
frameCurrent = 0;
}
public void interrupt(){
@ -271,4 +277,12 @@ public class AttackTree {
networkMessageQueue.add(networkMessage);
}
boolean canAttack(){
boolean rVal = true;
if(state != AttackTreeState.IDLE){
rVal = false;
}
return rVal;
}
}

View File

@ -1,9 +1,32 @@
package electrosphere.entity.state.equip;
import electrosphere.entity.Entity;
/**
*
* @author amaterasu
*/
public class EquipState {
Entity parent;
Entity equipPrimary;
public EquipState(Entity parent){
this.parent = parent;
}
public boolean hasEquipPrimary(){
return equipPrimary == null;
}
public Entity getEquipPrimary() {
return equipPrimary;
}
public void setEquipPrimary(Entity equipPrimary) {
this.equipPrimary = equipPrimary;
}
}

View File

@ -8,6 +8,8 @@ import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.AttackTree;
import electrosphere.entity.state.AttackTree.AttackTreeState;
import electrosphere.entity.state.GravityTree;
import electrosphere.entity.state.GravityTree;
import electrosphere.entity.state.movement.SprintTree.SprintTreeState;
@ -76,11 +78,14 @@ public class GroundMovementTree {
public void start(){
//TODO: check if can start moving
state = MovementTreeState.STARTUP;
if(canStartMoving()){
state = MovementTreeState.STARTUP;
}
}
public void interrupt(){
state = MovementTreeState.IDLE;
CreatureUtils.setVelocity(parent, 0);
}
public void slowdown(){
@ -442,6 +447,14 @@ public class GroundMovementTree {
tree.start();
}
}
public boolean canStartMoving(){
boolean rVal = true;
if(parent.getDataKeys().contains(EntityDataStrings.ATTACK_TREE) && ((AttackTree)parent.getData(EntityDataStrings.ATTACK_TREE)).getState() != AttackTreeState.IDLE){
rVal = false;
}
return rVal;
}
public void setAnimationStartUp(String animationStartUp) {
this.animationStartUp = animationStartUp;