store damage counter in item.json
This commit is contained in:
parent
e303ac4a03
commit
2764522b16
@ -8,6 +8,7 @@
|
|||||||
"modelPath" : "Models/katana1alt.fbx",
|
"modelPath" : "Models/katana1alt.fbx",
|
||||||
"weaponData" : {
|
"weaponData" : {
|
||||||
"weaponClass" : "sword1h",
|
"weaponClass" : "sword1h",
|
||||||
|
"damage" : 10,
|
||||||
"hitboxes" : [
|
"hitboxes" : [
|
||||||
{
|
{
|
||||||
"type": "hit",
|
"type": "hit",
|
||||||
@ -51,6 +52,7 @@
|
|||||||
"modelPath": "Models/bow1.fbx",
|
"modelPath": "Models/bow1.fbx",
|
||||||
"weaponData" : {
|
"weaponData" : {
|
||||||
"weaponClass" : "bow2h",
|
"weaponClass" : "bow2h",
|
||||||
|
"damage" : 10,
|
||||||
"projectileModel" : "Models/arrow1.fbx"
|
"projectileModel" : "Models/arrow1.fbx"
|
||||||
},
|
},
|
||||||
"tokens" : [
|
"tokens" : [
|
||||||
|
|||||||
@ -154,6 +154,12 @@
|
|||||||
"positionZ"
|
"positionZ"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"messageName" : "Kill",
|
||||||
|
"data" : [
|
||||||
|
"entityID"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"messageName" : "Destroy",
|
"messageName" : "Destroy",
|
||||||
"data" : [
|
"data" : [
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
package electrosphere.entity.state.life;
|
package electrosphere.entity.state.life;
|
||||||
|
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.game.data.creature.type.HealthSystem;
|
import electrosphere.game.data.creature.type.HealthSystem;
|
||||||
|
import electrosphere.main.Globals;
|
||||||
|
import electrosphere.net.parser.net.message.EntityMessage;
|
||||||
|
|
||||||
public class LifeState {
|
public class LifeState {
|
||||||
|
|
||||||
@ -88,6 +93,16 @@ public class LifeState {
|
|||||||
if(lifeCurrent < 0){
|
if(lifeCurrent < 0){
|
||||||
lifeCurrent = 0;
|
lifeCurrent = 0;
|
||||||
isAlive = false;
|
isAlive = false;
|
||||||
|
if(Globals.RUN_SERVER){
|
||||||
|
Vector3d position = EntityUtils.getPosition(parent);
|
||||||
|
Globals.dataCellManager.sendNetworkMessageToChunk(
|
||||||
|
EntityMessage.constructKillMessage(
|
||||||
|
parent.getId()
|
||||||
|
),
|
||||||
|
Globals.serverWorldData.convertRealToChunkSpace(position.x),
|
||||||
|
Globals.serverWorldData.convertRealToChunkSpace(position.z)
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
iFrameCurrent = iFrameMaxCount;
|
iFrameCurrent = iFrameMaxCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,14 +121,15 @@ public class HitboxUtils {
|
|||||||
|
|
||||||
//if the entity is attached to is an item, we need to compare with the parent of the item
|
//if the entity is attached to is an item, we need to compare with the parent of the item
|
||||||
//to make sure you don't stab yourself for instance
|
//to make sure you don't stab yourself for instance
|
||||||
boolean isItem = hitboxParent.containsKey(EntityDataStrings.ITEM_IS_ITEM);
|
boolean isItem = ItemUtils.isItem(hitboxParent);//hitboxParent.containsKey(EntityDataStrings.ITEM_IS_ITEM);
|
||||||
Entity hitboxAttachParent = AttachUtils.getParent(hitboxParent);
|
Entity hitboxAttachParent = AttachUtils.getParent(hitboxParent);
|
||||||
|
|
||||||
if(isItem){
|
if(isItem){
|
||||||
if(hitboxAttachParent != hurtboxParent){
|
if(hitboxAttachParent != hurtboxParent){
|
||||||
LifeState lifeState = LifeUtils.getLifeState(hurtboxParent);
|
LifeState lifeState = LifeUtils.getLifeState(hurtboxParent);
|
||||||
int currentHp = lifeState.getLifeCurrent();
|
int currentHp = lifeState.getLifeCurrent();
|
||||||
LifeUtils.getLifeState(hurtboxParent).damage(20);
|
int damage = ItemUtils.getWeaponDataRaw(hitboxParent).getDamage();
|
||||||
|
LifeUtils.getLifeState(hurtboxParent).damage(damage);
|
||||||
if(currentHp > lifeState.getLifeCurrent()){
|
if(currentHp > lifeState.getLifeCurrent()){
|
||||||
Vector3d hurtboxPos = EntityUtils.getPosition(hurtbox);
|
Vector3d hurtboxPos = EntityUtils.getPosition(hurtbox);
|
||||||
ParticleEffects.spawnBloodsplats(new Vector3f((float)hurtboxPos.x,(float)hurtboxPos.y,(float)hurtboxPos.z).add(0,0.1f,0), 20, 40);
|
ParticleEffects.spawnBloodsplats(new Vector3f((float)hurtboxPos.x,(float)hurtboxPos.y,(float)hurtboxPos.z).add(0,0.1f,0), 20, 40);
|
||||||
@ -139,7 +140,8 @@ public class HitboxUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LifeUtils.getLifeState(hurtboxParent).damage(20);
|
int damage = ItemUtils.getWeaponDataRaw(hitboxParent).getDamage();
|
||||||
|
LifeUtils.getLifeState(hurtboxParent).damage(damage);
|
||||||
if(!LifeUtils.getLifeState(hurtboxParent).isIsAlive()){
|
if(!LifeUtils.getLifeState(hurtboxParent).isIsAlive()){
|
||||||
EntityUtils.getPosition(hurtboxParent).set(Globals.spawnPoint);
|
EntityUtils.getPosition(hurtboxParent).set(Globals.spawnPoint);
|
||||||
LifeUtils.getLifeState(hurtboxParent).revive();
|
LifeUtils.getLifeState(hurtboxParent).revive();
|
||||||
|
|||||||
@ -8,6 +8,7 @@ public class WeaponData {
|
|||||||
|
|
||||||
String weaponClass;
|
String weaponClass;
|
||||||
List<HitboxData> hitboxes;
|
List<HitboxData> hitboxes;
|
||||||
|
int damage;
|
||||||
String projectileModel;
|
String projectileModel;
|
||||||
|
|
||||||
public String getWeaponClass(){
|
public String getWeaponClass(){
|
||||||
@ -22,4 +23,8 @@ public class WeaponData {
|
|||||||
return projectileModel;
|
return projectileModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDamage(){
|
||||||
|
return damage;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
MOVEUPDATE,
|
MOVEUPDATE,
|
||||||
ATTACKUPDATE,
|
ATTACKUPDATE,
|
||||||
MOVE,
|
MOVE,
|
||||||
|
KILL,
|
||||||
DESTROY,
|
DESTROY,
|
||||||
SETBEHAVIORTREE,
|
SETBEHAVIORTREE,
|
||||||
SETPROPERTY,
|
SETPROPERTY,
|
||||||
@ -240,6 +241,12 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
case TypeBytes.ENTITY_MESSAGE_TYPE_KILL:
|
||||||
|
if(byteStream.size() >= TypeBytes.ENTITY_MESSAGE_TYPE_KILL_SIZE){
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_DESTROY:
|
case TypeBytes.ENTITY_MESSAGE_TYPE_DESTROY:
|
||||||
if(byteStream.size() >= TypeBytes.ENTITY_MESSAGE_TYPE_DESTROY_SIZE){
|
if(byteStream.size() >= TypeBytes.ENTITY_MESSAGE_TYPE_DESTROY_SIZE){
|
||||||
return true;
|
return true;
|
||||||
@ -452,6 +459,20 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EntityMessage parseKillMessage(List<Byte> byteStream){
|
||||||
|
EntityMessage rVal = new EntityMessage(EntityMessageType.KILL);
|
||||||
|
stripPacketHeader(byteStream);
|
||||||
|
rVal.setentityID(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EntityMessage constructKillMessage(int entityID){
|
||||||
|
EntityMessage rVal = new EntityMessage(EntityMessageType.KILL);
|
||||||
|
rVal.setentityID(entityID);
|
||||||
|
rVal.serialize();
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
public static EntityMessage parseDestroyMessage(List<Byte> byteStream){
|
public static EntityMessage parseDestroyMessage(List<Byte> byteStream){
|
||||||
EntityMessage rVal = new EntityMessage(EntityMessageType.DESTROY);
|
EntityMessage rVal = new EntityMessage(EntityMessageType.DESTROY);
|
||||||
stripPacketHeader(byteStream);
|
stripPacketHeader(byteStream);
|
||||||
@ -764,6 +785,17 @@ public class EntityMessage extends NetworkMessage {
|
|||||||
rawBytes[30+i] = intValues[i];
|
rawBytes[30+i] = intValues[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case KILL:
|
||||||
|
rawBytes = new byte[2+4];
|
||||||
|
//message header
|
||||||
|
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
||||||
|
//entity messaage header
|
||||||
|
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_KILL;
|
||||||
|
intValues = ByteStreamUtils.serializeIntToBytes(entityID);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[2+i] = intValues[i];
|
||||||
|
}
|
||||||
|
break;
|
||||||
case DESTROY:
|
case DESTROY:
|
||||||
rawBytes = new byte[2+4];
|
rawBytes = new byte[2+4];
|
||||||
//message header
|
//message header
|
||||||
|
|||||||
@ -67,6 +67,11 @@ AUTH_MESSAGE,
|
|||||||
rVal = EntityMessage.parseMoveMessage(byteStream);
|
rVal = EntityMessage.parseMoveMessage(byteStream);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case TypeBytes.ENTITY_MESSAGE_TYPE_KILL:
|
||||||
|
if(EntityMessage.canParseMessage(byteStream,secondByte)){
|
||||||
|
rVal = EntityMessage.parseKillMessage(byteStream);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case TypeBytes.ENTITY_MESSAGE_TYPE_DESTROY:
|
case TypeBytes.ENTITY_MESSAGE_TYPE_DESTROY:
|
||||||
if(EntityMessage.canParseMessage(byteStream,secondByte)){
|
if(EntityMessage.canParseMessage(byteStream,secondByte)){
|
||||||
rVal = EntityMessage.parseDestroyMessage(byteStream);
|
rVal = EntityMessage.parseDestroyMessage(byteStream);
|
||||||
|
|||||||
@ -21,10 +21,11 @@ Message categories
|
|||||||
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE = 3;
|
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE = 3;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE = 4;
|
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE = 4;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_MOVE = 5;
|
public static final byte ENTITY_MESSAGE_TYPE_MOVE = 5;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_DESTROY = 6;
|
public static final byte ENTITY_MESSAGE_TYPE_KILL = 6;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE = 7;
|
public static final byte ENTITY_MESSAGE_TYPE_DESTROY = 7;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY = 8;
|
public static final byte ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE = 8;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY = 9;
|
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY = 9;
|
||||||
|
public static final byte ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY = 10;
|
||||||
/*
|
/*
|
||||||
Entity packet sizes
|
Entity packet sizes
|
||||||
*/
|
*/
|
||||||
@ -33,6 +34,7 @@ Message categories
|
|||||||
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE_SIZE = 74;
|
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE_SIZE = 74;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE_SIZE = 74;
|
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE_SIZE = 74;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_MOVE_SIZE = 38;
|
public static final byte ENTITY_MESSAGE_TYPE_MOVE_SIZE = 38;
|
||||||
|
public static final byte ENTITY_MESSAGE_TYPE_KILL_SIZE = 6;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_DESTROY_SIZE = 6;
|
public static final byte ENTITY_MESSAGE_TYPE_DESTROY_SIZE = 6;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE_SIZE = 22;
|
public static final byte ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE_SIZE = 22;
|
||||||
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY_SIZE = 22;
|
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY_SIZE = 22;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user