Tweak crosshair logic

This commit is contained in:
austin 2021-11-16 00:15:07 -05:00
parent f2c7d0910c
commit cda719c9a2
2 changed files with 27 additions and 12 deletions

View File

@ -620,6 +620,18 @@ public class LoadingThread extends Thread {
//give evil goblin sword
Entity goblinSword = ItemUtils.spawnBasicItem("Katana");
AttachUtils.attachEntityToEntityAtBone(goblin, goblinSword, "Bone.031");
// goblin = CreatureUtils.spawnBasicCreature("Goblin");
// CollisionObjUtils.positionCharacter(goblin, new Vector3f(3, 0, 4));
// EntityUtils.getScale(goblin).set(0.005f);
//
// goblin = CreatureUtils.spawnBasicCreature("Goblin");
// CollisionObjUtils.positionCharacter(goblin, new Vector3f(4, 0, 3));
// EntityUtils.getScale(goblin).set(0.005f);
//
// goblin = CreatureUtils.spawnBasicCreature("Goblin");
// CollisionObjUtils.positionCharacter(goblin, new Vector3f(3, 0, 3));
// EntityUtils.getScale(goblin).set(0.005f);
// //attach ai to evil goblin
// MindlessAttacker.attachToCreature(goblin);

View File

@ -1,5 +1,6 @@
package electrosphere.game.client.targeting.crosshair;
import electrosphere.entity.CameraEntityUtils;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils;
import electrosphere.main.Globals;
@ -28,27 +29,29 @@ public class Crosshair {
public static void checkTargetable(){
if(crossHairEntity != null && Globals.playerCharacter != null){
Vector3d parentPos = EntityUtils.getPosition(Globals.playerCharacter);
if(currentTarget == null){
// if(currentTarget == null){
Entity target = null;
double dist = 100;
for(Entity entity : Globals.entityManager.getTargetables()){
double currentDist = parentPos.distance(EntityUtils.getPosition(entity));
if(currentDist < dist && currentDist <= TARGET_MAX_DIST && entity != Globals.playerCharacter){
target = entity;
dist = currentDist;
}
Vector3d entityPos = EntityUtils.getPosition(entity);
double currentDist = parentPos.distance(entityPos);
double currentAngleDiff = new Vector3d(entityPos).sub(parentPos).normalize().dot(new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera)));
if(currentDist + currentAngleDiff < dist && currentDist <= TARGET_MAX_DIST && entity != Globals.playerCharacter){
target = entity;
dist = currentDist + currentAngleDiff;
}
}
if(target != null){
// System.out.println("Found target!");
currentTarget = target;
EntityUtils.setVisible(crossHairEntity, true);
}
} else {
if(parentPos.distance(EntityUtils.getPosition(currentTarget)) > TARGET_MAX_DIST){
currentTarget = null;
EntityUtils.setVisible(crossHairEntity, false);
}
}
// } else {
// if(parentPos.distance(EntityUtils.getPosition(currentTarget)) > TARGET_MAX_DIST){
// currentTarget = null;
// EntityUtils.setVisible(crossHairEntity, false);
// }
// }
}
}