bow&arrow part 1

This commit is contained in:
austin 2022-03-14 22:35:45 -04:00
parent 0cc3057d51
commit 7cee38e268
20 changed files with 428 additions and 85 deletions

View File

@ -189,9 +189,10 @@
{ {
"attackMoveId" : "Sword1HSlash1", "attackMoveId" : "Sword1HSlash1",
"type" : "MELEE_WEAPON_SWING_ONE_HAND", "type" : "MELEE_WEAPON_SWING_ONE_HAND",
"animationName" : "Armature|Sword1HSlash1", "attackAnimationName" : "Armature|Sword1HSlash1",
"damageStartFrame" : 30, "damageStartFrame" : 30,
"damageEndFrame" : 60, "damageEndFrame" : 60,
"firesProjectile" : false,
"nextMoveId" : "Sword1HSlash2", "nextMoveId" : "Sword1HSlash2",
"nextAttackMoveWindowStart" : 0, "nextAttackMoveWindowStart" : 0,
"nextAttackMoveWindowEnd" : 1, "nextAttackMoveWindowEnd" : 1,
@ -203,9 +204,10 @@
{ {
"attackMoveId" : "Sword1HSlash2", "attackMoveId" : "Sword1HSlash2",
"type" : "MELEE_WEAPON_SWING_ONE_HAND", "type" : "MELEE_WEAPON_SWING_ONE_HAND",
"animationName" : "Armature|Sword1HSlash2", "attackAnimationName" : "Armature|Sword1HSlash2",
"damageStartFrame" : 30, "damageStartFrame" : 30,
"damageEndFrame" : 60, "damageEndFrame" : 60,
"firesProjectile" : false,
"nextMoveId" : "Sword1HSlash1", "nextMoveId" : "Sword1HSlash1",
"nextAttackMoveWindowStart" : 0, "nextAttackMoveWindowStart" : 0,
"nextAttackMoveWindowEnd" : 1, "nextAttackMoveWindowEnd" : 1,
@ -213,6 +215,23 @@
"movementEnd" : 10, "movementEnd" : 10,
"movementGoal" : 0.1, "movementGoal" : 0.1,
"initialMove" : false "initialMove" : false
},
{
"attackMoveId" : "Bow2HFire",
"type" : "RANGED_WEAPON_BOW_TWO_HAND",
"windupAnimationName" : "Armature|HoldBowString",
"holdAnimationName" : "Armature|HoldBow",
"attackAnimationName" : "Armature|HoldBowString",
"damageStartFrame" : 30,
"damageEndFrame" : 60,
"firesProjectile" : true,
"nextMoveId" : "",
"nextAttackMoveWindowStart" : 0,
"nextAttackMoveWindowEnd" : 1,
"movementStart" : 0,
"movementEnd" : 0,
"movementGoal" : 0,
"initialMove" : false
} }
], ],
"healthSystem" : { "healthSystem" : {

View File

@ -6,23 +6,26 @@
{ {
"itemId" : "Katana", "itemId" : "Katana",
"modelPath" : "Models/katana1alt.fbx", "modelPath" : "Models/katana1alt.fbx",
"hitboxes" : [ "weaponData" : {
{ "weaponClass" : "sword1h",
"type": "hit", "hitboxes" : [
"bone": "Blade1", {
"radius": 0.04 "type": "hit",
}, "bone": "Blade1",
{ "radius": 0.04
"type": "hit", },
"bone": "Blade2", {
"radius": 0.04 "type": "hit",
}, "bone": "Blade2",
{ "radius": 0.04
"type": "hit", },
"bone": "Blade3", {
"radius": 0.04 "type": "hit",
} "bone": "Blade3",
], "radius": 0.04
}
]
},
"tokens" : [ "tokens" : [
"GRAVITY", "GRAVITY",
"BLENDER_TRANSFORM", "BLENDER_TRANSFORM",
@ -43,8 +46,12 @@
"iconPath" : "Textures/icons/itemIconWeapon.png" "iconPath" : "Textures/icons/itemIconWeapon.png"
}, },
{ {
"itemId" : "Bow", "itemId" : "bow1",
"modelPath": "Models/bow1.fbx", "modelPath": "Models/bow1.fbx",
"weaponData" : {
"weaponClass" : "bow2h",
"projectileModel" : "Models/arrow1.fbx"
},
"tokens" : [ "tokens" : [
"GRAVITY", "GRAVITY",
"RANGED", "RANGED",

Binary file not shown.

Binary file not shown.

View File

@ -701,7 +701,17 @@ public class ControlHandler {
AttackTree attackTree = CreatureUtils.getAttackTree(Globals.playerCharacter); AttackTree attackTree = CreatureUtils.getAttackTree(Globals.playerCharacter);
if(attackTree != null){ if(attackTree != null){
// CreatureUtils.setFacingVector(Globals.playerCharacter, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).normalize()); // CreatureUtils.setFacingVector(Globals.playerCharacter, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).normalize());
attackTree.start(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND); attackTree.start();
}
}
}});
controls.get(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY).setOnRelease(new ControlMethod(){public void execute(){
if(Globals.playerCharacter != null){
// Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
AttackTree attackTree = CreatureUtils.getAttackTree(Globals.playerCharacter);
if(attackTree != null){
// CreatureUtils.setFacingVector(Globals.playerCharacter, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).normalize());
attackTree.release();
} }
} }
}}); }});

View File

@ -5,7 +5,7 @@ import electrosphere.controls.ControlHandler;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.ApplyRotationTree; import electrosphere.entity.state.movement.ApplyRotationTree;
import electrosphere.game.collision.CollisionEngine; import electrosphere.game.collision.CollisionEngine;
import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.item.ItemUtils; import electrosphere.entity.types.item.ItemUtils;
@ -677,8 +677,10 @@ public class LoadingThread extends Thread {
EntityUtils.getPosition(sword).set(new Vector3f(1,0.1f,2)); EntityUtils.getPosition(sword).set(new Vector3f(1,0.1f,2));
Entity shorts = ItemUtils.spawnBasicItem("boots1"); Entity shorts = ItemUtils.spawnBasicItem("boots1");
EntityUtils.getPosition(shorts).set(new Vector3f(2,0.1f,2)); EntityUtils.getPosition(shorts).set(new Vector3f(2,0.1f,2));
Entity hair = ItemUtils.spawnBasicItem("hairshort1"); // Entity hair = ItemUtils.spawnBasicItem("hairshort1");
EntityUtils.getPosition(hair).set(new Vector3f(2,0.1f,1)); // EntityUtils.getPosition(hair).set(new Vector3f(2,0.1f,1));
Entity bow = ItemUtils.spawnBasicItem("bow1");
EntityUtils.getPosition(bow).set(new Vector3f(2,0.1f,1));
// //center flame // //center flame
// Entity fire = ParticleUtils.spawnStaticBillboardParticle(); // Entity fire = ParticleUtils.spawnStaticBillboardParticle();

View File

@ -149,6 +149,8 @@ public class EntityDataStrings {
public static final String ITEM_EQUIP_CLASS = "itemEquipClass"; public static final String ITEM_EQUIP_CLASS = "itemEquipClass";
public static final String ITEM_ICON = "itemIcon"; public static final String ITEM_ICON = "itemIcon";
public static final String ITEM_IN_WORLD_REPRESENTATION = "itemInWorldRepresentation"; public static final String ITEM_IN_WORLD_REPRESENTATION = "itemInWorldRepresentation";
public static final String ITEM_WEAPON_CLASS = "itemWeaponClass";
public static final String ITEM_WEAPON_DATA_RAW = "itemWeaponDataRaw";
/* /*
@ -158,6 +160,7 @@ public class EntityDataStrings {
public static final String ATTACK_MOVE_TYPE_ACTIVE = "attackMoveTypeActive"; public static final String ATTACK_MOVE_TYPE_ACTIVE = "attackMoveTypeActive";
public static final String ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND = "MELEE_WEAPON_SWING_ONE_HAND"; public static final String ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND = "MELEE_WEAPON_SWING_ONE_HAND";
public static final String ATTACK_MOVE_TYPE_BOW_TWO_HAND = "RANGED_WEAPON_BOW_TWO_HAND";
/* /*
Health System Health System

View File

@ -8,14 +8,21 @@ import electrosphere.entity.state.equip.EquipState;
import electrosphere.entity.types.collision.CollisionObjUtils; import electrosphere.entity.types.collision.CollisionObjUtils;
import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.hitbox.HitboxUtils; import electrosphere.entity.types.hitbox.HitboxUtils;
import electrosphere.entity.types.item.ItemUtils;
import electrosphere.entity.types.projectile.ProjectileUtils;
import electrosphere.game.collision.collidable.Collidable; import electrosphere.game.collision.collidable.Collidable;
import electrosphere.game.data.creature.type.attack.AttackMove; import electrosphere.game.data.creature.type.attack.AttackMove;
import electrosphere.game.data.creature.type.equip.EquipPoint;
import electrosphere.main.Globals; import electrosphere.main.Globals;
import electrosphere.net.parser.net.message.EntityMessage; import electrosphere.net.parser.net.message.EntityMessage;
import electrosphere.renderer.actor.Actor; import electrosphere.renderer.actor.Actor;
import electrosphere.renderer.anim.Animation; import electrosphere.renderer.anim.Animation;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import org.joml.Quaterniond;
import org.joml.Quaternionf;
import org.joml.Quaternionfc;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.joml.Vector3f; import org.joml.Vector3f;
@ -23,6 +30,7 @@ public class AttackTree {
public static enum AttackTreeState { public static enum AttackTreeState {
WINDUP, WINDUP,
HOLD,
ATTACK, ATTACK,
COOLDOWN, COOLDOWN,
IDLE, IDLE,
@ -47,6 +55,13 @@ public class AttackTree {
List<AttackMove> currentMoveset = null; List<AttackMove> currentMoveset = null;
AttackMove currentMove = null; AttackMove currentMove = null;
Entity currentWeapon = null;
boolean currentMoveHasWindup;
boolean currentMoveCanHold;
boolean stillHold = true;
boolean firesProjectile = false;
String projectileToFire = null;
String attackingPoint = null;
public AttackTree(Entity e){ public AttackTree(Entity e){
state = AttackTreeState.IDLE; state = AttackTreeState.IDLE;
@ -57,37 +72,61 @@ public class AttackTree {
return state; return state;
} }
public void start(String attackType){ public void start(){
currentMoveCanHold = false;
currentMoveHasWindup = false;
stillHold = true;
firesProjectile = false;
projectileToFire = null;
currentWeapon = null;
attackingPoint = null;
//figure out attack type we should be doing
String attackType = getAttackType();
//if we can attack, setup doing so
if(canAttack(attackType)){ if(canAttack(attackType)){
parent.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, attackType); parent.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, attackType);
currentMoveset = (List<AttackMove>)parent.getData(attackType); currentMoveset = (List<AttackMove>)parent.getData(attackType);
switch(attackType){ if(currentMoveset != null){
case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND: if(currentMove == null){
if(currentMove == null){ currentMove = currentMoveset.get(0);
currentMove = currentMoveset.get(0); } else {
} else { currentMove = getNextMove(currentMoveset,currentMove.getNextMoveId());
currentMove = getNextMove(currentMoveset,currentMove.getNextMoveId()); }
if(currentMove != null){
damageStartFrame = currentMove.getDamageStartFrame();
damageEndFrame = currentMove.getDamageEndFrame();
firesProjectile = currentMove.getFiresProjectile();
if(firesProjectile){
projectileToFire = ItemUtils.getWeaponDataRaw(currentWeapon).getProjectileModel();
} }
if(currentMove != null){
damageStartFrame = currentMove.getDamageStartFrame(); animationName = currentMove.getAttackAnimationName();
damageEndFrame = currentMove.getDamageEndFrame(); //intuit windup from presence of windup anim
animationName = currentMove.getAnimationName(); currentMoveHasWindup = currentMove.getWindupAnimationName() != null;
//stop movement tree if(currentMoveHasWindup){
if(parent.getDataKeys().contains(EntityDataStrings.DATA_STRING_MOVEMENT_BT)){ animationName = currentMove.getWindupAnimationName();
CreatureUtils.getEntityMovementTree(parent).interrupt();
}
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
EntityUtils.getRotation(parent).rotationTo(new Vector3f(0,0,1), new Vector3f((float)movementVector.x,(float)movementVector.y,(float)movementVector.z));
//set initial stuff
state = AttackTreeState.WINDUP;
frameCurrent = 0;
} else {
state = AttackTreeState.IDLE;
} }
break; //intuit can hold from presence of windup anim
currentMoveCanHold = currentMove.getHoldAnimationName() != null;
//stop movement tree
if(parent.getDataKeys().contains(EntityDataStrings.DATA_STRING_MOVEMENT_BT)){
CreatureUtils.getEntityMovementTree(parent).interrupt();
}
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
EntityUtils.getRotation(parent).rotationTo(new Vector3f(0,0,1), new Vector3f((float)movementVector.x,(float)movementVector.y,(float)movementVector.z));
//set initial stuff
state = AttackTreeState.WINDUP;
frameCurrent = 0;
} else {
state = AttackTreeState.IDLE;
}
} }
} }
} }
public void release(){
stillHold = false;
}
public void interrupt(){ public void interrupt(){
state = AttackTreeState.IDLE; state = AttackTreeState.IDLE;
@ -152,7 +191,11 @@ public class AttackTree {
} }
frameCurrent++; frameCurrent++;
if(frameCurrent > damageStartFrame){ if(frameCurrent > damageStartFrame){
state = AttackTreeState.ATTACK; if(currentMoveCanHold && stillHold){
state = AttackTreeState.HOLD;
} else {
state = AttackTreeState.ATTACK;
}
} }
if(Globals.RUN_SERVER){ if(Globals.RUN_SERVER){
Globals.server.broadcastMessage( Globals.server.broadcastMessage(
@ -186,6 +229,48 @@ public class AttackTree {
); );
} }
break; break;
case HOLD:
if(entityActor != null){
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(animationName)){
entityActor.playAnimation(animationName,1);
entityActor.incrementAnimationTime(0.01);
}
}
if(!stillHold){
state = AttackTreeState.ATTACK;
}
// if(Globals.RUN_SERVER){
// Globals.server.broadcastMessage(
// EntityMessage.constructattackUpdateMessage(
// parent.getId(),
// System.currentTimeMillis(),
// (float)position.x,
// (float)position.y,
// (float)position.z,
// movementVector.x,
// movementVector.y,
// movementVector.z,
// velocity,
// 0
// )
// );
// } else if(Globals.RUN_CLIENT && parent.getId() == Globals.clientCharacterID){
// Globals.clientConnection.queueOutgoingMessage(
// EntityMessage.constructattackUpdateMessage(
// parent.getId(),
// System.currentTimeMillis(),
// (float)position.x,
// (float)position.y,
// (float)position.z,
// movementVector.x,
// movementVector.y,
// movementVector.z,
// velocity,
// 0
// )
// );
// }
break;
case ATTACK: case ATTACK:
if(parent.getDataKeys().contains(EntityDataStrings.ATTACH_CHILDREN_LIST)){ if(parent.getDataKeys().contains(EntityDataStrings.ATTACH_CHILDREN_LIST)){
List<Entity> attachedEntities = (List<Entity>)parent.getData(EntityDataStrings.ATTACH_CHILDREN_LIST); List<Entity> attachedEntities = (List<Entity>)parent.getData(EntityDataStrings.ATTACH_CHILDREN_LIST);
@ -198,6 +283,39 @@ public class AttackTree {
} }
} }
} }
if(firesProjectile && projectileToFire != null){
//spawn projectile
//TODO: solve spawnPosition, initialVector
Vector3d spawnPosition = new Vector3d(0,0,0);
Quaternionf arrowRotation = new Quaternionf();
String targetBone = null;
EquipState equipState = (EquipState)parent.getData(EntityDataStrings.EQUIP_STATE);
EquipPoint weaponPoint = null;
if((weaponPoint = equipState.getEquipPoint(attackingPoint)) != null){
targetBone = weaponPoint.getBone();
}
if(targetBone != null){
Actor parentActor = EntityUtils.getActor(parent);
//transform bone space
spawnPosition = new Vector3d(parentActor.getBonePosition(targetBone));
spawnPosition = spawnPosition.mul(((Vector3f)EntityUtils.getScale(parent)));
Quaternionf rotation = EntityUtils.getRotation(parent);
spawnPosition = spawnPosition.rotate(new Quaterniond(rotation.x,rotation.y,rotation.z,rotation.w));
//transform worldspace
spawnPosition.add(new Vector3d(EntityUtils.getPosition(parent)));
//set
// EntityUtils.getPosition(currentEntity).set(position);
//set rotation
// Quaternionf rotation = parentActor.getBoneRotation(targetBone);
// EntityUtils.getRotation(currentEntity).set(rotation).normalize();
// Vector3d facingAngle = CreatureUtils.getFacingVector(parent);
arrowRotation = parentActor.getBoneRotation(targetBone);
// EntityUtils.getRotation(currentEntity).rotationTo(new Vector3f(0,0,1), new Vector3f((float)facingAngle.x,(float)facingAngle.y,(float)facingAngle.z)).mul(parentActor.getBoneRotation(targetBone)).normalize();
}
Vector3f initialVector = new Vector3f((float)movementVector.x,(float)movementVector.y,(float)movementVector.z).normalize();
ProjectileUtils.spawnBasicProjectile(projectileToFire, spawnPosition, arrowRotation, 200, initialVector, 0.03f);
projectileToFire = null;
}
frameCurrent++; frameCurrent++;
if(frameCurrent > damageEndFrame){ if(frameCurrent > damageEndFrame){
state = AttackTreeState.COOLDOWN; state = AttackTreeState.COOLDOWN;
@ -293,10 +411,35 @@ public class AttackTree {
public void addNetworkMessage(EntityMessage networkMessage) { public void addNetworkMessage(EntityMessage networkMessage) {
networkMessageQueue.add(networkMessage); networkMessageQueue.add(networkMessage);
} }
String getAttackType(){
String rVal = null;
if(parent.getDataKeys().contains(EntityDataStrings.EQUIP_STATE)){
EquipState equipState = (EquipState)parent.getData(EntityDataStrings.EQUIP_STATE);
for(String point : equipState.equippedPoints()){
Entity item = equipState.getEquippedItemAtPoint(point);
if(ItemUtils.isWeapon(item)){
attackingPoint = point;
currentWeapon = item;
switch(ItemUtils.getWeaponClass(item)){
case "sword1h":
rVal = EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND;
break;
case "bow2h":
rVal = EntityDataStrings.ATTACK_MOVE_TYPE_BOW_TWO_HAND;
break;
}
}
}
}
return rVal;
}
boolean canAttack(String attackType){ boolean canAttack(String attackType){
boolean rVal = true; boolean rVal = true;
if(state != AttackTreeState.IDLE){ if(attackType == null){
return false;
} else if(state != AttackTreeState.IDLE){
if(currentMove.getNextMoveId() != null && !currentMove.getNextMoveId().equals("")){ if(currentMove.getNextMoveId() != null && !currentMove.getNextMoveId().equals("")){
rVal = true; rVal = true;
} }

View File

@ -96,6 +96,7 @@ public class EquipState {
Globals.entityManager.setTargetable(toEquip, false); Globals.entityManager.setTargetable(toEquip, false);
} }
} }
// if(!hasEquipPrimary() && ItemUtils.isItem(toEquip) && !AttachUtils.isAttached(toEquip)){ // if(!hasEquipPrimary() && ItemUtils.isItem(toEquip) && !AttachUtils.isAttached(toEquip)){
// if(ItemUtils.hasEquipList(toEquip)){ // if(ItemUtils.hasEquipList(toEquip)){
// String parentCreatureId = CreatureUtils.getType(parent); // String parentCreatureId = CreatureUtils.getType(parent);
@ -139,6 +140,19 @@ public class EquipState {
// } // }
// } // }
} }
public EquipPoint getEquipPoint(String name){
for(EquipPoint point : equipPoints){
if(point.getEquipPointId().equals(name)){
return point;
}
}
return null;
}
public Entity getEquippedItemAtPoint(String point){
return equipMap.get(point);
}
// public void drop(Entity entity){ // public void drop(Entity entity){
// if(hasEquipPrimary()){ // if(hasEquipPrimary()){

View File

@ -1,10 +1,11 @@
package electrosphere.entity.state; package electrosphere.entity.state.movement;
import org.joml.Quaterniond; import org.joml.Quaterniond;
import org.joml.Quaternionf; import org.joml.Quaternionf;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.BehaviorTree;
public class ApplyRotationTree implements BehaviorTree { public class ApplyRotationTree implements BehaviorTree {

View File

@ -0,0 +1,38 @@
package electrosphere.entity.state.movement;
import org.joml.Vector3d;
import org.joml.Vector3f;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.BehaviorTree;
import electrosphere.main.Globals;
public class ProjectileTree implements BehaviorTree {
Entity parent;
int maxLife;
int lifeCurrent = 0;
Vector3f vector;
public ProjectileTree(Entity parent, int maxLife, Vector3f initialVector, float velocity){
this.parent = parent;
this.maxLife = maxLife;
this.vector = initialVector.mul(velocity);
}
@Override
public void simulate() {
lifeCurrent++;
if(lifeCurrent >= maxLife){
Globals.entityManager.deregisterEntity(parent);
Globals.entityManager.removeBehaviorTree(this);
}
Vector3d positionCurrent = EntityUtils.getPosition(parent);
positionCurrent.add(vector);
}
}

View File

@ -168,11 +168,15 @@ public class CreatureUtils {
//add all attack moves //add all attack moves
if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){ if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){
for(AttackMove attackMove : rawType.getAttackMoves()){ for(AttackMove attackMove : rawType.getAttackMoves()){
switch(attackMove.getType()){ rVal.putData(attackMove.getType(), rawType.getAttackMoveResolver().getMoveset(attackMove.getType()));
case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND: // switch(attackMove.getType()){
rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, rawType.getAttackMoveResolver().getMoveset(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND)); // case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
break; // rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, rawType.getAttackMoveResolver().getMoveset(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND));
} // break;
// case EntityDataStrings.ATTACK_MOVE_TYPE_BOW_TWO_HAND:
// rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, rawType.getAttackMoveResolver().getMoveset(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND));
// break;
// }
} }
} }
break; break;

View File

@ -17,6 +17,7 @@ import electrosphere.game.data.creature.type.CollidableTemplate;
import electrosphere.game.data.creature.type.CreatureType; import electrosphere.game.data.creature.type.CreatureType;
import electrosphere.game.data.item.type.EquipWhitelist; import electrosphere.game.data.item.type.EquipWhitelist;
import electrosphere.game.data.item.type.Item; import electrosphere.game.data.item.type.Item;
import electrosphere.game.data.item.type.WeaponData;
import electrosphere.main.Globals; import electrosphere.main.Globals;
import electrosphere.net.parser.net.message.EntityMessage; import electrosphere.net.parser.net.message.EntityMessage;
import electrosphere.net.parser.net.message.NetworkMessage; import electrosphere.net.parser.net.message.NetworkMessage;
@ -43,14 +44,20 @@ public class ItemUtils {
public static Entity spawnBasicItem(String name){ public static Entity spawnBasicItem(String name){
Item item = Globals.gameConfigCurrent.getItemMap().getItem(name); Item item = Globals.gameConfigCurrent.getItemMap().getItem(name);
Entity rVal = EntityUtils.spawnDrawableEntity(item.getModelPath()); Entity rVal = EntityUtils.spawnDrawableEntity(item.getModelPath());
if(item.getHitboxes() != null){ if(item.getWeaponData() != null){
List<Entity> hitboxList = new LinkedList<Entity>(); rVal.putData(EntityDataStrings.ITEM_IS_WEAPON, true);
for(HitboxData hitboxdata : item.getHitboxes()){ WeaponData weaponData = item.getWeaponData();
Entity hitbox = HitboxUtils.spawnRegularHitbox(rVal, hitboxdata.getBone(), hitboxdata.getRadius()); if(weaponData.getHitboxes() != null){
Globals.hitboxManager.registerHitbox(hitbox); List<Entity> hitboxList = new LinkedList<Entity>();
hitboxList.add(hitbox); for(HitboxData hitboxdata : weaponData.getHitboxes()){
Entity hitbox = HitboxUtils.spawnRegularHitbox(rVal, hitboxdata.getBone(), hitboxdata.getRadius());
Globals.hitboxManager.registerHitbox(hitbox);
hitboxList.add(hitbox);
}
rVal.putData(EntityDataStrings.HITBOX_ASSOCIATED_LIST,hitboxList);
} }
rVal.putData(EntityDataStrings.HITBOX_ASSOCIATED_LIST,hitboxList); rVal.putData(EntityDataStrings.ITEM_WEAPON_CLASS,weaponData.getWeaponClass());
rVal.putData(EntityDataStrings.ITEM_WEAPON_DATA_RAW,weaponData);
} }
if(item.getCollidable() != null){ if(item.getCollidable() != null){
CollidableTemplate physicsTemplate = item.getCollidable(); CollidableTemplate physicsTemplate = item.getCollidable();
@ -244,6 +251,10 @@ public class ItemUtils {
} }
} }
public static String getWeaponClass(Entity item){
return (String)item.getData(EntityDataStrings.ITEM_WEAPON_CLASS);
}
public static void destroyInInventoryItem(Entity item){ public static void destroyInInventoryItem(Entity item){
Globals.entityManager.deregisterEntity(item); Globals.entityManager.deregisterEntity(item);
} }
@ -264,4 +275,8 @@ public class ItemUtils {
return (Entity) inInventory.getData(EntityDataStrings.ITEM_IN_WORLD_REPRESENTATION); return (Entity) inInventory.getData(EntityDataStrings.ITEM_IN_WORLD_REPRESENTATION);
} }
public static WeaponData getWeaponDataRaw(Entity item){
return (WeaponData) item.getData(EntityDataStrings.ITEM_WEAPON_DATA_RAW);
}
} }

View File

@ -0,0 +1,30 @@
package electrosphere.entity.types.projectile;
import org.joml.Quaterniond;
import org.joml.Quaternionf;
import org.joml.Quaternionfc;
import org.joml.Vector3d;
import org.joml.Vector3f;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.movement.ProjectileTree;
import electrosphere.main.Globals;
public class ProjectileUtils {
public static Entity spawnBasicProjectile(String model, Vector3d initialPosition, Quaternionf rotation, int maxLife, Vector3f initialVector, float velocity){
Entity rVal = EntityUtils.spawnDrawableEntity(model);
Globals.assetManager.addModelPathToQueue(model);
ProjectileTree tree = new ProjectileTree(rVal,maxLife,initialVector,velocity);
EntityUtils.getPosition(rVal).set(initialPosition);
// EntityUtils.getRotation(currentEntity).rotationTo(new Vector3f(0,0,1), new Vector3f((float)facingAngle.x,(float)facingAngle.y,(float)facingAngle.z)).mul(parentActor.getBoneRotation(targetBone)).normalize();
EntityUtils.getRotation(rVal).rotationTo(new Vector3f(0,0,1), new Vector3f((float)initialVector.x,(float)initialVector.y,(float)initialVector.z)).normalize();
// ParticleTree particleTree = new ParticleTree(rVal, maxLife, destination, velocity, acceleration, true);
// rVal.putData(EntityDataStrings.PARTICLE_TREE, particleTree);
// rVal.putData(EntityDataStrings.IS_PARTICLE, true);
Globals.entityManager.registerBehaviorTree(tree);
return rVal;
}
}

View File

@ -1,16 +1,36 @@
package electrosphere.game.data.creature.type.attack; package electrosphere.game.data.creature.type.attack;
import java.util.List;
/** /**
* *
* @author amaterasu * @author amaterasu
*/ */
public class AttackMove { public class AttackMove {
/*
*/
String attackMoveId; String attackMoveId;
String type; String type;
String animationName;
/*
Animation stuff
*/
String windupAnimationName;
String holdAnimationName;
String attackAnimationName;
/*
Damage stuff
*/
int damageStartFrame; int damageStartFrame;
int damageEndFrame; int damageEndFrame;
boolean firesProjectile;
/*
move chaining stuff
*/
String nextMoveId; String nextMoveId;
String movementStart; String movementStart;
String movementEnd; String movementEnd;
@ -25,8 +45,16 @@ public class AttackMove {
return type; return type;
} }
public String getAnimationName() { public String getWindupAnimationName() {
return animationName; return windupAnimationName;
}
public String getHoldAnimationName() {
return holdAnimationName;
}
public String getAttackAnimationName() {
return attackAnimationName;
} }
public int getDamageStartFrame() { public int getDamageStartFrame() {
@ -48,6 +76,10 @@ public class AttackMove {
public boolean isInitialMove(){ public boolean isInitialMove(){
return initialMove; return initialMove;
} }
public boolean getFiresProjectile(){
return firesProjectile;
}
} }

View File

@ -8,13 +8,13 @@ public class Item {
String itemId; String itemId;
String modelPath; String modelPath;
List<HitboxData> hitboxes;
List<String> tokens; List<String> tokens;
CollidableTemplate collidable; CollidableTemplate collidable;
List<EquipWhitelist> equipWhitelist; List<EquipWhitelist> equipWhitelist;
String idleAnim; String idleAnim;
String iconPath; String iconPath;
String equipClass; String equipClass;
WeaponData weaponData;
public String getItemId() { public String getItemId() {
return itemId; return itemId;
@ -24,10 +24,6 @@ public class Item {
return modelPath; return modelPath;
} }
public List<HitboxData> getHitboxes() {
return hitboxes;
}
public List<String> getTokens() { public List<String> getTokens() {
return tokens; return tokens;
} }
@ -51,5 +47,9 @@ public class Item {
public String getEquipClass(){ public String getEquipClass(){
return equipClass; return equipClass;
} }
public WeaponData getWeaponData(){
return weaponData;
}
} }

View File

@ -0,0 +1,25 @@
package electrosphere.game.data.item.type;
import java.util.List;
import electrosphere.entity.types.hitbox.HitboxData;
public class WeaponData {
String weaponClass;
List<HitboxData> hitboxes;
String projectileModel;
public String getWeaponClass(){
return weaponClass;
}
public List<HitboxData> getHitboxes(){
return hitboxes;
}
public String getProjectileModel(){
return projectileModel;
}
}

View File

@ -60,7 +60,7 @@ public class MindlessAttacker extends AI{
if(attackCooldown == 0){ if(attackCooldown == 0){
attackCooldown = attackCooldownMax; attackCooldown = attackCooldownMax;
AttackTree attackTree = CreatureUtils.getAttackTree(character); AttackTree attackTree = CreatureUtils.getAttackTree(character);
attackTree.start(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND); attackTree.start();
} else { } else {
attackCooldown--; attackCooldown--;
} }

View File

@ -152,7 +152,7 @@ public class OpportunisticAttacker extends AI {
if(attackCooldown == 0){ if(attackCooldown == 0){
attackCooldown = attackCooldownMax; attackCooldown = attackCooldownMax;
AttackTree attackTree = CreatureUtils.getAttackTree(character); AttackTree attackTree = CreatureUtils.getAttackTree(character);
attackTree.start(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND); attackTree.start();
} else { } else {
attackCooldown--; attackCooldown--;
} }

View File

@ -179,19 +179,19 @@ public class Main {
// Globals.assetManager.addModelPathToQueue("/Models/baseman.fbx"); // Globals.assetManager.addModelPathToQueue("/Models/baseman.fbx");
// Globals.assetManager.loadAssetsInQueue(); // Globals.assetManager.loadAssetsInQueue();
// Model model = Globals.assetManager.fetchModel("/Models/baseman.fbx"); // Model model = Globals.assetManager.fetchModel("/Models/baseman.fbx");
// for(electrosphere.renderer.anim.Animation anim : model.animations){ // // for(electrosphere.renderer.anim.Animation anim : model.animations){
// if(anim.name.equals("Armature|Idle1")){ // // if(anim.name.equals("Armature|Idle1")){
// System.out.println(anim.duration); // // System.out.println(anim.duration);
// for(electrosphere.renderer.anim.AnimChannel channel : anim.channels){ // // for(electrosphere.renderer.anim.AnimChannel channel : anim.channels){
// if(channel.getNodeID().equals("Torso")){ // // if(channel.getNodeID().equals("Torso")){
// channel.fullDescribeChannel(); // // channel.fullDescribeChannel();
// } // // }
// // System.out.println("CHannel: " + channel.getNodeID()); // // // System.out.println("CHannel: " + channel.getNodeID());
// } // // }
// break; // // break;
// } // // }
// } // // }
// // model.describeHighLevel(); // model.describeHighLevel();
// System.exit(0); // System.exit(0);
// } // }