Tweak crosshair logic
This commit is contained in:
parent
f2c7d0910c
commit
cda719c9a2
@ -620,6 +620,18 @@ public class LoadingThread extends Thread {
|
|||||||
//give evil goblin sword
|
//give evil goblin sword
|
||||||
Entity goblinSword = ItemUtils.spawnBasicItem("Katana");
|
Entity goblinSword = ItemUtils.spawnBasicItem("Katana");
|
||||||
AttachUtils.attachEntityToEntityAtBone(goblin, goblinSword, "Bone.031");
|
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
|
// //attach ai to evil goblin
|
||||||
// MindlessAttacker.attachToCreature(goblin);
|
// MindlessAttacker.attachToCreature(goblin);
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package electrosphere.game.client.targeting.crosshair;
|
package electrosphere.game.client.targeting.crosshair;
|
||||||
|
|
||||||
|
import electrosphere.entity.CameraEntityUtils;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.main.Globals;
|
import electrosphere.main.Globals;
|
||||||
@ -28,27 +29,29 @@ public class Crosshair {
|
|||||||
public static void checkTargetable(){
|
public static void checkTargetable(){
|
||||||
if(crossHairEntity != null && Globals.playerCharacter != null){
|
if(crossHairEntity != null && Globals.playerCharacter != null){
|
||||||
Vector3d parentPos = EntityUtils.getPosition(Globals.playerCharacter);
|
Vector3d parentPos = EntityUtils.getPosition(Globals.playerCharacter);
|
||||||
if(currentTarget == null){
|
// if(currentTarget == null){
|
||||||
Entity target = null;
|
Entity target = null;
|
||||||
double dist = 100;
|
double dist = 100;
|
||||||
for(Entity entity : Globals.entityManager.getTargetables()){
|
for(Entity entity : Globals.entityManager.getTargetables()){
|
||||||
double currentDist = parentPos.distance(EntityUtils.getPosition(entity));
|
Vector3d entityPos = EntityUtils.getPosition(entity);
|
||||||
if(currentDist < dist && currentDist <= TARGET_MAX_DIST && entity != Globals.playerCharacter){
|
double currentDist = parentPos.distance(entityPos);
|
||||||
target = entity;
|
double currentAngleDiff = new Vector3d(entityPos).sub(parentPos).normalize().dot(new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera)));
|
||||||
dist = currentDist;
|
if(currentDist + currentAngleDiff < dist && currentDist <= TARGET_MAX_DIST && entity != Globals.playerCharacter){
|
||||||
}
|
target = entity;
|
||||||
|
dist = currentDist + currentAngleDiff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(target != null){
|
if(target != null){
|
||||||
// System.out.println("Found target!");
|
// System.out.println("Found target!");
|
||||||
currentTarget = target;
|
currentTarget = target;
|
||||||
EntityUtils.setVisible(crossHairEntity, true);
|
EntityUtils.setVisible(crossHairEntity, true);
|
||||||
}
|
}
|
||||||
} else {
|
// } else {
|
||||||
if(parentPos.distance(EntityUtils.getPosition(currentTarget)) > TARGET_MAX_DIST){
|
// if(parentPos.distance(EntityUtils.getPosition(currentTarget)) > TARGET_MAX_DIST){
|
||||||
currentTarget = null;
|
// currentTarget = null;
|
||||||
EntityUtils.setVisible(crossHairEntity, false);
|
// EntityUtils.setVisible(crossHairEntity, false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user