mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-02-09 04:43:20 +08:00
Consolidate random point offsets
This commit is contained in:
parent
6098b51e4f
commit
9970aeb94d
@ -78,8 +78,8 @@ public class DropSystem extends BaseGameSystem {
|
||||
}
|
||||
if (itemData.isEquip()) {
|
||||
for (int i = 0; i < num; i++) {
|
||||
float range = (5f + (.1f * num));
|
||||
Position pos = em.getPosition().clone().addX((float) (Math.random() * range) - (range / 2)).addY(3f).addZ((float) (Math.random() * range) - (range / 2));
|
||||
float range = (2.5f + (.05f * num));
|
||||
Position pos = em.getPosition().nearby2d(range).addY(3f);
|
||||
addDropEntity(dd, em.getScene(), itemData, pos, num, gp);
|
||||
}
|
||||
} else {
|
||||
|
@ -68,10 +68,7 @@ public class GadgetGatherObject extends GadgetContent {
|
||||
scene,
|
||||
player,
|
||||
GameData.getItemDataMap().get(itemId),
|
||||
getGadget().getPosition().clone()
|
||||
.addY(2f)
|
||||
.addX(Utils.randomFloatRange(-1f, 1f))
|
||||
.addZ(Utils.randomFloatRange(-1f, 1f)),
|
||||
getGadget().getPosition().nearby2d(1f).addY(2f),
|
||||
1,
|
||||
true);
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class BlossomActivity {
|
||||
for (int i = 0; i < willSpawn; i++) {
|
||||
MonsterData monsterData = GameData.getMonsterDataMap().get(candidateMonsters.poll());
|
||||
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);
|
||||
newMonsters.add(entity);
|
||||
}
|
||||
|
@ -695,14 +695,14 @@ public class Scene {
|
||||
return;
|
||||
}
|
||||
if (itemData.isEquip()) {
|
||||
float range = (3f + (.1f * amount));
|
||||
float range = (1.5f + (.05f * amount));
|
||||
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);
|
||||
addEntity(entity);
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
@ -6,19 +6,21 @@ import com.google.gson.annotations.SerializedName;
|
||||
import com.github.davidmoten.rtreemulti.geometry.Point;
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.grasscutter.net.proto.VectorOuterClass.Vector;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Entity
|
||||
public class Position implements Serializable {
|
||||
private static final long serialVersionUID = -2001232313615923575L;
|
||||
|
||||
@SerializedName(value="x", alternate={"_x", "X"})
|
||||
private float x;
|
||||
@Getter @Setter private float x;
|
||||
|
||||
@SerializedName(value="y", alternate={"_y", "Y"})
|
||||
private float y;
|
||||
@Getter @Setter private float y;
|
||||
|
||||
@SerializedName(value="z", alternate={"_z", "Z"})
|
||||
private float z;
|
||||
@Getter @Setter private float z;
|
||||
|
||||
public Position() {
|
||||
|
||||
@ -51,30 +53,6 @@ public class Position implements Serializable {
|
||||
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) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@ -150,10 +128,10 @@ public class Position implements Serializable {
|
||||
return Math.sqrt(detX*detX+detY*detY+detZ*detZ);
|
||||
}
|
||||
|
||||
public Position nearby2d(int range) {
|
||||
public Position nearby2d(float range) {
|
||||
Position position = clone();
|
||||
position.z += (float)Utils.randomRange(-range,range)/10;
|
||||
position.x += (float)Utils.randomRange(-range,range)/10;
|
||||
position.z += Utils.randomFloatRange(-range, range);
|
||||
position.x += Utils.randomFloatRange(-range, range);
|
||||
return position;
|
||||
}
|
||||
public Position translateWithDegrees(float dist, float angle) {
|
||||
|
Loading…
Reference in New Issue
Block a user