Commit 9970aeb9 authored by AnimeGitB's avatar AnimeGitB
Browse files

Consolidate random point offsets

parent 6098b51e
...@@ -78,8 +78,8 @@ public class DropSystem extends BaseGameSystem { ...@@ -78,8 +78,8 @@ public class DropSystem extends BaseGameSystem {
} }
if (itemData.isEquip()) { if (itemData.isEquip()) {
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
float range = (5f + (.1f * num)); float range = (2.5f + (.05f * num));
Position pos = em.getPosition().clone().addX((float) (Math.random() * range) - (range / 2)).addY(3f).addZ((float) (Math.random() * range) - (range / 2)); Position pos = em.getPosition().nearby2d(range).addY(3f);
addDropEntity(dd, em.getScene(), itemData, pos, num, gp); addDropEntity(dd, em.getScene(), itemData, pos, num, gp);
} }
} else { } else {
......
...@@ -68,10 +68,7 @@ public class GadgetGatherObject extends GadgetContent { ...@@ -68,10 +68,7 @@ public class GadgetGatherObject extends GadgetContent {
scene, scene,
player, player,
GameData.getItemDataMap().get(itemId), GameData.getItemDataMap().get(itemId),
getGadget().getPosition().clone() getGadget().getPosition().nearby2d(1f).addY(2f),
.addY(2f)
.addX(Utils.randomFloatRange(-1f, 1f))
.addZ(Utils.randomFloatRange(-1f, 1f)),
1, 1,
true); true);
......
...@@ -101,7 +101,7 @@ public class BlossomActivity { ...@@ -101,7 +101,7 @@ public class BlossomActivity {
for (int i = 0; i < willSpawn; i++) { for (int i = 0; i < willSpawn; i++) {
MonsterData monsterData = GameData.getMonsterDataMap().get(candidateMonsters.poll()); MonsterData monsterData = GameData.getMonsterDataMap().get(candidateMonsters.poll());
int level = scene.getEntityLevel(1, worldLevelOverride); int level = scene.getEntityLevel(1, worldLevelOverride);
EntityMonster entity = new EntityMonster(scene, monsterData, pos.nearby2d(40), level); EntityMonster entity = new EntityMonster(scene, monsterData, pos.nearby2d(4f), level);
scene.addEntity(entity); scene.addEntity(entity);
newMonsters.add(entity); newMonsters.add(entity);
} }
......
...@@ -695,14 +695,14 @@ public class Scene { ...@@ -695,14 +695,14 @@ public class Scene {
return; return;
} }
if (itemData.isEquip()) { if (itemData.isEquip()) {
float range = (3f + (.1f * amount)); float range = (1.5f + (.05f * amount));
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
Position pos = bornForm.getPosition().clone().addX((float) (Math.random() * range) - (range / 2)).addZ((float) (Math.random() * range) - (range / 2)).addZ(.9f); Position pos = bornForm.getPosition().nearby2d(range).addZ(.9f); // Why Z?
EntityItem entity = new EntityItem(this, null, itemData, pos, 1); EntityItem entity = new EntityItem(this, null, itemData, pos, 1);
addEntity(entity); addEntity(entity);
} }
} else { } else {
EntityItem entity = new EntityItem(this, null, itemData, bornForm.getPosition().clone().addZ(.9f), amount); EntityItem entity = new EntityItem(this, null, itemData, bornForm.getPosition().clone().addZ(.9f), amount); // Why Z?
addEntity(entity); addEntity(entity);
} }
} }
......
...@@ -6,19 +6,21 @@ import com.google.gson.annotations.SerializedName; ...@@ -6,19 +6,21 @@ import com.google.gson.annotations.SerializedName;
import com.github.davidmoten.rtreemulti.geometry.Point; import com.github.davidmoten.rtreemulti.geometry.Point;
import dev.morphia.annotations.Entity; import dev.morphia.annotations.Entity;
import emu.grasscutter.net.proto.VectorOuterClass.Vector; import emu.grasscutter.net.proto.VectorOuterClass.Vector;
import lombok.Getter;
import lombok.Setter;
@Entity @Entity
public class Position implements Serializable { public class Position implements Serializable {
private static final long serialVersionUID = -2001232313615923575L; private static final long serialVersionUID = -2001232313615923575L;
@SerializedName(value="x", alternate={"_x", "X"}) @SerializedName(value="x", alternate={"_x", "X"})
private float x; @Getter @Setter private float x;
@SerializedName(value="y", alternate={"_y", "Y"}) @SerializedName(value="y", alternate={"_y", "Y"})
private float y; @Getter @Setter private float y;
@SerializedName(value="z", alternate={"_z", "Z"}) @SerializedName(value="z", alternate={"_z", "Z"})
private float z; @Getter @Setter private float z;
public Position() { public Position() {
...@@ -51,30 +53,6 @@ public class Position implements Serializable { ...@@ -51,30 +53,6 @@ public class Position implements Serializable {
this.set(pos); this.set(pos);
} }
public float getX() {
return x;
}
public void setX(float x) {
this.x = x;
}
public float getZ() {
return z;
}
public void setZ(float z) {
this.z = z;
}
public float getY() {
return y;
}
public void setY(float y) {
this.y = y;
}
public Position set(float x, float y) { public Position set(float x, float y) {
this.x = x; this.x = x;
this.y = y; this.y = y;
...@@ -150,10 +128,10 @@ public class Position implements Serializable { ...@@ -150,10 +128,10 @@ public class Position implements Serializable {
return Math.sqrt(detX*detX+detY*detY+detZ*detZ); return Math.sqrt(detX*detX+detY*detY+detZ*detZ);
} }
public Position nearby2d(int range) { public Position nearby2d(float range) {
Position position = clone(); Position position = clone();
position.z += (float)Utils.randomRange(-range,range)/10; position.z += Utils.randomFloatRange(-range, range);
position.x += (float)Utils.randomRange(-range,range)/10; position.x += Utils.randomFloatRange(-range, range);
return position; return position;
} }
public Position translateWithDegrees(float dist, float angle) { public Position translateWithDegrees(float dist, float angle) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment