mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-13 13:54:37 +01:00
Retreating/losing a battle should teleport to the nearest anchor
This commit is contained in:
@@ -241,11 +241,17 @@ public class BattleService extends BaseGameService {
|
|||||||
|
|
||||||
// Teleport to anchor if player has lost/retreated. On official servers, the player party is teleported to the nearest anchor.
|
// Teleport to anchor if player has lost/retreated. On official servers, the player party is teleported to the nearest anchor.
|
||||||
if (teleportToAnchor) {
|
if (teleportToAnchor) {
|
||||||
var anchor = player.getScene().getFloorInfo().getStartAnchorInfo();
|
var anchorProp = player.getScene().getNearestSpring();
|
||||||
|
if (anchorProp != null && anchorProp.getPropInfo() != null) {
|
||||||
|
var anchor = player.getScene().getFloorInfo().getAnchorInfo(
|
||||||
|
anchorProp.getPropInfo().getAnchorGroupID(),
|
||||||
|
anchorProp.getPropInfo().getAnchorID()
|
||||||
|
);
|
||||||
if (anchor != null) {
|
if (anchor != null) {
|
||||||
player.moveTo(anchor.clonePos());
|
player.moveTo(anchor.clonePos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Done - Clear battle object from player
|
// Done - Clear battle object from player
|
||||||
player.setBattle(null);
|
player.setBattle(null);
|
||||||
|
|||||||
@@ -367,22 +367,15 @@ public class Player {
|
|||||||
// Sanity
|
// Sanity
|
||||||
if (this.getScene() == null) return;
|
if (this.getScene() == null) return;
|
||||||
|
|
||||||
boolean anchorRange = false;
|
|
||||||
|
|
||||||
// Check anchors. We can optimize this later.
|
// Check anchors. We can optimize this later.
|
||||||
for (EntityProp anchor : this.getScene().getHealingSprings()) {
|
EntityProp nearestAnchor = this.getScene().getNearestSpring(25_000_000); // 5000^2
|
||||||
long dist = getPos().getFast2dDist(anchor.getPos());
|
boolean isInRange = nearestAnchor != null;
|
||||||
if (dist > 25_000_000) continue; // 5000^2
|
|
||||||
|
|
||||||
anchorRange = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only heal if player isnt already in anchor range
|
// Only heal if player isnt already in anchor range
|
||||||
if (anchorRange && anchorRange != this.inAnchorRange) {
|
if (isInRange && isInRange != this.inAnchorRange) {
|
||||||
this.getCurrentLineup().heal(10000);
|
this.getCurrentLineup().heal(10000);
|
||||||
}
|
}
|
||||||
this.inAnchorRange = anchorRange;
|
this.inAnchorRange = isInRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveTo(int entryId, Position pos) {
|
public void moveTo(int entryId, Position pos) {
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ public class Scene {
|
|||||||
);
|
);
|
||||||
prop.setInstId(propInfo.getID());
|
prop.setInstId(propInfo.getID());
|
||||||
prop.setGroupId(group.getId());
|
prop.setGroupId(group.getId());
|
||||||
|
prop.setPropInfo(propInfo);
|
||||||
|
|
||||||
// Hacky fixes
|
// Hacky fixes
|
||||||
if (prop.getPropId() == 1003) {
|
if (prop.getPropId() == 1003) {
|
||||||
@@ -252,6 +253,36 @@ public class Scene {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the nearest spring (Space Anchor) to the player in the scene
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public EntityProp getNearestSpring() {
|
||||||
|
return getNearestSpring(Long.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the nearest spring (Space Anchor) to the player in the scene
|
||||||
|
* @param minDistSq Only checks springs in below this distance
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public EntityProp getNearestSpring(long minDistSq) {
|
||||||
|
EntityProp spring = null;
|
||||||
|
long springDist = 0;
|
||||||
|
|
||||||
|
for (EntityProp prop : this.getHealingSprings()) {
|
||||||
|
long dist = getPlayer().getPos().getFast2dDist(prop.getPos());
|
||||||
|
if (dist > minDistSq) continue;
|
||||||
|
|
||||||
|
if (spring == null || dist < springDist) {
|
||||||
|
spring = prop;
|
||||||
|
springDist = dist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return spring;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
public void fireTrigger(PropTriggerType type, int param1, int param2) {
|
public void fireTrigger(PropTriggerType type, int param1, int param2) {
|
||||||
for (PropTrigger trigger : this.getTriggers()) {
|
for (PropTrigger trigger : this.getTriggers()) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package emu.lunarcore.game.scene.entity;
|
package emu.lunarcore.game.scene.entity;
|
||||||
|
|
||||||
|
import emu.lunarcore.data.config.PropInfo;
|
||||||
import emu.lunarcore.data.excel.PropExcel;
|
import emu.lunarcore.data.excel.PropExcel;
|
||||||
import emu.lunarcore.game.enums.PropState;
|
import emu.lunarcore.game.enums.PropState;
|
||||||
import emu.lunarcore.game.scene.Scene;
|
import emu.lunarcore.game.scene.Scene;
|
||||||
@@ -23,6 +24,9 @@ public class EntityProp implements GameEntity {
|
|||||||
private final Position pos;
|
private final Position pos;
|
||||||
private final Position rot;
|
private final Position rot;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private PropInfo propInfo;
|
||||||
|
|
||||||
public EntityProp(Scene scene, PropExcel excel, Position pos) {
|
public EntityProp(Scene scene, PropExcel excel, Position pos) {
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
this.excel = excel;
|
this.excel = excel;
|
||||||
|
|||||||
Reference in New Issue
Block a user