Compare commits

...

30 Commits

Author SHA1 Message Date
MagicBot 6572f0c805 Clamp fix for new method 2023-11-18 13:20:17 -05:00
MagicBot 496b49b349 Clamp fix for new method 2023-11-18 13:17:59 -05:00
MagicBot ffac5bf369 Clamp fix for new method 2023-11-18 13:08:09 -05:00
MagicBot 15313b3460 Clamp fix for new method 2023-11-18 12:57:53 -05:00
MagicBot 898e37eedb Clamp fix for new method 2023-11-18 12:49:20 -05:00
MagicBot d42788c694 Clamp fix for new method 2023-11-18 12:38:52 -05:00
MagicBot 46655a1cfe Clamp fix for new method 2023-11-18 12:31:38 -05:00
MagicBot 668e3ee70f Clamp fix for new method 2023-11-18 12:26:50 -05:00
MagicBot 0ec9f01130 Clamp fix for new method 2023-11-18 12:18:28 -05:00
MagicBot ad6f886e1e Mirror lookup 2023-11-18 12:15:27 -05:00
MagicBot 6402d228c0 Mirror lookup 2023-11-18 10:59:58 -05:00
MagicBot a68496d451 Array size helpful if debugging 2023-11-12 14:34:41 -05:00
MagicBot 72fe3c58c6 IDA Pro says 256 2023-11-12 13:01:17 -05:00
MagicBot eb5bc14974 Revert needs new branch. 2023-11-12 11:21:30 -05:00
MagicBot 7e99e8c7a4 Height and width flipped. 2023-11-12 11:13:27 -05:00
MagicBot 9b0f4d5aef Height and width flipped. 2023-11-12 11:09:29 -05:00
MagicBot b58049968f IDA says 256. 2023-11-12 07:36:56 -05:00
MagicBot 9bf0d3f7d1 Devcmd updated. 2023-11-11 07:10:46 -05:00
MagicBot 8300c47e4a Dev cmd updated 2023-11-08 11:59:52 -05:00
MagicBot c73fcc19f2 Dev cmd updated 2023-11-08 11:34:33 -05:00
MagicBot f93573177a Dev cmd updated 2023-11-08 11:27:44 -05:00
MagicBot fe9c6437d8 Dev cmd updated 2023-11-08 11:27:36 -05:00
MagicBot c110ffc4b1 Dev cmd updated 2023-11-02 09:08:28 -04:00
MagicBot 7af63d1519 Nominal after test. 2023-10-25 13:51:54 -04:00
MagicBot 31ba1f2c4c Height from zone center. 2023-10-25 13:46:08 -04:00
MagicBot 33afd13a8c Height from zone center. 2023-10-25 13:36:26 -04:00
MagicBot b341ffacbf Devcmd updated 2023-10-25 13:12:02 -04:00
MagicBot 0d1d1f0f37 Added raw blend value to class 2023-10-25 13:01:21 -04:00
MagicBot 3f59ed48d2 Extra parens removed 2023-10-23 14:13:06 -04:00
MagicBot de832ff497 Long cast needed 2023-10-23 14:12:59 -04:00
3 changed files with 40 additions and 30 deletions
+17 -21
View File
@@ -21,10 +21,13 @@ import static java.lang.Math.PI;
public class Terrain {
public static final HashMap<Integer, short[][]> _heightmap_pixel_cache = new HashMap<>();
public short[][] terrain_pixel_data;
public Vector2f image_size = new Vector2f();
public Vector2f terrain_size = new Vector2f();
public Vector2f cell_size = new Vector2f();
public Vector2f cell_count = new Vector2f();
public float terrain_scale;
public Vector2f blend_values = new Vector2f();
public Vector2f blend_ratio = new Vector2f();
public int heightmap;
Zone zone;
@@ -43,6 +46,7 @@ public class Terrain {
// Load pixel data for this terrain from cache
this.terrain_pixel_data = Terrain._heightmap_pixel_cache.get(heightmap);
this.image_size.set(this.terrain_pixel_data.length, this.terrain_pixel_data[0].length);
if (terrain_pixel_data == null)
Logger.error("Pixel map empty for zone: " + this.zone.getObjectUUID() + ":" + this.zone.zoneName);
@@ -52,8 +56,8 @@ public class Terrain {
this.terrain_size.x = this.zone.major_radius * 2;
this.terrain_size.y = this.zone.minor_radius * 2;
this.cell_count.x = this.terrain_pixel_data.length - 1;
this.cell_count.y = this.terrain_pixel_data[0].length - 1;
this.cell_count.x = this.image_size.x;
this.cell_count.y = this.image_size.y; // Bug in exe
this.cell_size.x = terrain_size.x / this.cell_count.x;
this.cell_size.y = terrain_size.y / this.cell_count.y;
@@ -62,22 +66,14 @@ public class Terrain {
// the blending area between child and parent terrains when
// they are stitched together.
float max_blend = this.zone.template.max_blend;
float min_blend = this.zone.template.min_blend;
this.blend_values.x = this.zone.template.max_blend;
this.blend_values.y = this.zone.template.min_blend;
// Zones with a zero blend inherit from their parent terrain
Vector2f major_blend = new Vector2f(this.blend_values.x / this.zone.major_radius,
this.blend_values.y / this.zone.major_radius);
if (this.zone.template.max_blend == 0) {
Zone parentZone = this.getNextZoneWithTerrain(this.zone.parent);
max_blend = parentZone.template.max_blend;
min_blend = parentZone.template.min_blend;
}
Vector2f major_blend = new Vector2f(max_blend / this.zone.major_radius,
min_blend / this.zone.major_radius);
Vector2f minor_blend = new Vector2f(max_blend / this.zone.minor_radius,
min_blend / this.zone.minor_radius);
Vector2f minor_blend = new Vector2f(this.blend_values.x / this.zone.minor_radius,
this.blend_values.y / this.zone.minor_radius);
if (major_blend.y > 0.4f)
blend_ratio.x = major_blend.y;
@@ -91,7 +87,7 @@ public class Terrain {
// Scale coefficient for this terrain
this.terrain_scale = this.zone.template.terrain_max_y / 255f;
this.terrain_scale = this.zone.template.terrain_max_y / 256;
}
public static Zone getNextZoneWithTerrain(Zone zone) {
@@ -162,14 +158,14 @@ public class Terrain {
public Vector2f getTerrainCell(Vector2f terrain_loc) {
// Calculate terrain cell with offset
// Calculate terrain cell with offset. Bug mirrors the exe
Vector2f terrain_cell = new Vector2f(terrain_loc.x / this.cell_size.x, terrain_loc.y / this.cell_size.y);
Vector2f terrain_cell = new Vector2f(terrain_loc.x / this.cell_size.x, terrain_loc.y / this.cell_size.x);
// Clamp values when standing directly on pole
terrain_cell.x = Math.max(0, Math.min(this.cell_count.x - 1, terrain_cell.x));
terrain_cell.y = Math.max(0, Math.min(this.cell_count.y - 1, terrain_cell.y));
terrain_cell.x = Math.max(0, Math.min(this.cell_count.x - 2, terrain_cell.x));
terrain_cell.y = Math.max(0, Math.min(this.cell_count.y - 2, terrain_cell.y));
return terrain_cell;
}
+21 -7
View File
@@ -49,19 +49,33 @@ public class GetHeightCmd extends AbstractDevCmd {
float blendedHeight = Terrain.getWorldHeight(currentZone, playerCharacter.getLoc());
Vector2f gridSquare = heightmapZone.terrain.getTerrainCell(childZoneLoc);
gridSquare.x = (float) Math.floor(gridSquare.x);
gridSquare.y = (float) Math.floor(gridSquare.y);
Vector2f terrainCell = heightmapZone.terrain.getTerrainCell(childZoneLoc);
Vector2f cell_offset = new Vector2f(terrainCell.x % 1, terrainCell.y % 1);
terrainCell.x = (float) Math.floor(terrainCell.x);
terrainCell.y = (float) Math.floor(terrainCell.y);
short top_left_pixel = heightmapZone.terrain.terrain_pixel_data[(int) terrainCell.x][(int) terrainCell.y];
short top_right_pixel = heightmapZone.terrain.terrain_pixel_data[(int) terrainCell.x + 1][(int) terrainCell.y];
short bottom_left_pixel = heightmapZone.terrain.terrain_pixel_data[(int) terrainCell.x][(int) terrainCell.y + 1];
short bottom_right_pixel = heightmapZone.terrain.terrain_pixel_data[(int) terrainCell.x + 1][(int) terrainCell.y + 1];
this.throwbackInfo(playerCharacter, "Current Zone : " + currentZone.zoneName);
this.throwbackInfo(playerCharacter, "Heightmap Zone : " + heightmapZone.zoneName);
this.throwbackInfo(playerCharacter, "Parent Zone: " + parentZone.zoneName);
this.throwbackInfo(playerCharacter, "Grid : " + "[" + gridSquare.x + "]" + "[" + gridSquare.y + "]");
this.throwbackInfo(playerCharacter, "offset: " + "[" + childZoneOffset.x + "]" + "[" + childZoneOffset.y + "]");
this.throwbackInfo(playerCharacter, "Player loc: " + "[" + playerCharacter.loc.x + "]" + "[" + playerCharacter.loc.y + "]" + "[" + playerCharacter.loc.z + "]");
this.throwbackInfo(playerCharacter, "Terrain Cell : " + "[" + terrainCell.x + "]" + "[" + terrainCell.y + "]");
this.throwbackInfo(playerCharacter, "Cell Offset : " + "[" + cell_offset.x + "]" + "[" + cell_offset.y + "]");
this.throwbackInfo(playerCharacter, "Pixels : " + "[" + top_left_pixel + "]" + "[" + top_right_pixel + "]");
this.throwbackInfo(playerCharacter, "Pixels : " + "[" + bottom_left_pixel + "]" + "[" + bottom_right_pixel + "]");
this.throwbackInfo(playerCharacter, "Child Zone Offset: " + "[" + childZoneOffset.x + "]" + "[" + childZoneOffset.y + "]");
this.throwbackInfo(playerCharacter, "Normalized offset: " + "[" + normalizedOffset.x + "]" + "[" + normalizedOffset.y + "]");
this.throwbackInfo(playerCharacter, "Heightmap blend Values: max/min" + heightmapZone.template.min_blend + " /" + heightmapZone.template.max_blend);
this.throwbackInfo(playerCharacter, "Parent blend Values: nax/min" + parentZone.template.min_blend + " /" + parentZone.template.max_blend);
this.throwbackInfo(playerCharacter, "template blend Values: (max/min): " + heightmapZone.template.max_blend + " /" + heightmapZone.template.min_blend);
this.throwbackInfo(playerCharacter, "terrain values (max/min): " + heightmapZone.terrain.blend_values.x + " /" + heightmapZone.terrain.blend_values.y);
this.throwbackInfo(playerCharacter, "Blend coefficient: " + heightmapZone.terrain.getTerrainBlendCoefficient(childZoneOffset));
this.throwbackInfo(playerCharacter, "------------");
+2 -2
View File
@@ -814,8 +814,8 @@ public class MobAI {
}
}
}
} else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnDelay * 1000))) {
aiAgent.respawnTime = aiAgent.deathTime + (aiAgent.spawnDelay * 1000);
} else if (System.currentTimeMillis() > aiAgent.deathTime + (aiAgent.spawnDelay * 1000L)) {
aiAgent.respawnTime = aiAgent.deathTime + (aiAgent.spawnDelay * 1000L);
Respawner.respawnQueue.put(aiAgent);
}
} catch (Exception e) {