Browse Source

region height work

combat-2
FatBoy-DOTC 1 year ago
parent
commit
9b7fc0a93b
  1. 41
      src/engine/devcmd/cmds/RegionCmd.java
  2. 4
      src/engine/objects/AbstractCharacter.java
  3. 3
      src/engine/objects/Mob.java
  4. 2
      src/engine/objects/NPC.java

41
src/engine/devcmd/cmds/RegionCmd.java

@ -9,9 +9,9 @@
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
import engine.objects.AbstractGameObject; import engine.objects.*;
import engine.objects.PlayerCharacter;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -25,42 +25,17 @@ public class RegionCmd extends AbstractDevCmd {
protected void _doCmd(PlayerCharacter pc, String[] words, protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) { AbstractGameObject target) {
Regions region = ((AbstractCharacter)target).region;
if (pc.region == null) { if (region == null) {
this.throwbackInfo(pc, "No Region Found."); this.throwbackInfo(pc, "No Region Found.");
return; return;
} }
if(region != null) {
String newLine = System.getProperty("line.separator"); this.throwbackInfo(pc, "Region Info: " + ((AbstractCharacter) target).getName());
String result = ""; this.throwbackInfo(pc, "Region Name: " + region);
result += (pc.region.getClass().getSimpleName()); this.throwbackInfo(pc, "Region Height: " + region.lerpY((AbstractCharacter)target));
result += (" {");
result += (newLine);
Field[] fields = pc.region.getClass().getDeclaredFields();
//print field names paired with their values
for (Field field : fields) {
field.setAccessible(true);
result += (" ");
try {
if (field.getName().contains("Furniture"))
continue;
result += (field.getName());
result += (": ");
//requires access to private field:
result += (field.get(pc.region).toString());
} catch (IllegalAccessException ex) {
System.out.println(ex);
} }
result.trim();
result += (newLine);
}
result += ("}");
this.throwbackInfo(pc, result.toString());
} }

4
src/engine/objects/AbstractCharacter.java

@ -11,6 +11,7 @@ package engine.objects;
import engine.Enum; import engine.Enum;
import engine.Enum.*; import engine.Enum.*;
import engine.InterestManagement.HeightMap;
import engine.InterestManagement.InterestManager; import engine.InterestManagement.InterestManager;
import engine.InterestManagement.WorldGrid; import engine.InterestManagement.WorldGrid;
import engine.exception.SerializationException; import engine.exception.SerializationException;
@ -986,8 +987,9 @@ public abstract class AbstractCharacter extends AbstractWorldObject {
public final void setLoc(final Vector3fImmutable value) { public final void setLoc(final Vector3fImmutable value) {
Regions region = Regions.GetRegionForTeleport(value); Regions region = Regions.GetRegionForTeleport(value);
if(region != null){ if(region != null){
float regionHeight = region.lerpY(this);
this.region = region; this.region = region;
Vector3fImmutable newValue = new Vector3fImmutable(value.x,value.y + region.lerpY(this),value.z); //account for height offset of the current character region Vector3fImmutable newValue = new Vector3fImmutable(value.x,regionHeight,value.z); //account for height offset of the current character region
super.setLoc(newValue); // set the location in the world super.setLoc(newValue); // set the location in the world
this.resetLastSetLocUpdate(); this.resetLastSetLocUpdate();
} else { } else {

3
src/engine/objects/Mob.java

@ -1649,7 +1649,7 @@ public class Mob extends AbstractIntelligenceAgent {
// Setup location for this Mobile // Setup location for this Mobile
this.loc = new Vector3fImmutable(bindLoc); this.setLoc(bindLoc);
this.endLoc = new Vector3fImmutable(bindLoc); this.endLoc = new Vector3fImmutable(bindLoc);
// Initialize inventory // Initialize inventory
@ -1743,6 +1743,7 @@ public class Mob extends AbstractIntelligenceAgent {
this.level = (short) newRank; this.level = (short) newRank;
this.recalculateStats(); this.recalculateStats();
this.setHealth(this.healthMax); this.setHealth(this.healthMax);
this.setLoc(this.bindLoc);
} }
public boolean isRanking() { public boolean isRanking() {

2
src/engine/objects/NPC.java

@ -865,7 +865,7 @@ public class NPC extends AbstractCharacter {
this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon); this.bindLoc = new Vector3fImmutable(this.statLat, this.statAlt, this.statLon);
this.bindLoc = this.parentZone.getLoc().add(this.bindLoc); this.bindLoc = this.parentZone.getLoc().add(this.bindLoc);
this.loc = new Vector3fImmutable(bindLoc); this.setLoc(bindLoc);
// Handle NPCs within buildings // Handle NPCs within buildings

Loading…
Cancel
Save