Commit fbf3dbbf authored by AnimeGitB's avatar AnimeGitB
Browse files

Move vehicle fightprop hacks

parent 9970aeb9
...@@ -83,33 +83,18 @@ public final class SpawnCommand implements CommandHandler { ...@@ -83,33 +83,18 @@ public final class SpawnCommand implements CommandHandler {
} }
double maxRadius = Math.sqrt(amount * 0.2 / Math.PI); double maxRadius = Math.sqrt(amount * 0.2 / Math.PI);
Position center = (x != 0 && y != 0 && z != 0)
? (new Position(x, y, z))
: (targetPlayer.getPosition());
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
Position pos = GetRandomPositionInCircle(targetPlayer.getPosition(), maxRadius).addY(3); Position pos = GetRandomPositionInCircle(center, maxRadius).addY(3);
if (x != 0 && y != 0 && z != 0) {
pos = GetRandomPositionInCircle(new Position(x, y, z), maxRadius).addY(3);
}
GameEntity entity = null; GameEntity entity = null;
if (itemData != null) { if (itemData != null) {
entity = new EntityItem(scene, null, itemData, pos, 1, true); entity = new EntityItem(scene, null, itemData, pos, 1, true);
} }
if (gadgetData != null) { if (gadgetData != null) {
pos.addY(-3); pos.addY(-3);
entity = new EntityVehicle(scene, targetPlayer.getSession().getPlayer(), gadgetData.getId(), 0, pos, targetPlayer.getRotation()); // TODO: does targetPlayer.getSession().getPlayer() have some meaning? entity = new EntityVehicle(scene, targetPlayer, id, 0, pos, targetPlayer.getRotation());
int gadgetId = gadgetData.getId();
switch (gadgetId) {
// TODO: Not hardcode this. Waverider (skiff)
case 45001001, 45001002 -> {
entity.addFightProperty(FightProperty.FIGHT_PROP_BASE_HP, 10000);
entity.addFightProperty(FightProperty.FIGHT_PROP_BASE_ATTACK, 100);
entity.addFightProperty(FightProperty.FIGHT_PROP_CUR_ATTACK, 100);
entity.addFightProperty(FightProperty.FIGHT_PROP_CUR_HP, 10000);
entity.addFightProperty(FightProperty.FIGHT_PROP_CUR_DEFENSE, 0);
entity.addFightProperty(FightProperty.FIGHT_PROP_CUR_SPEED, 0);
entity.addFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY, 0);
entity.addFightProperty(FightProperty.FIGHT_PROP_MAX_HP, 10000);
}
default -> {}
}
} }
if (monsterData != null) { if (monsterData != null) {
entity = new EntityMonster(scene, monsterData, pos, level); entity = new EntityMonster(scene, monsterData, pos, level);
......
package emu.grasscutter.game.entity; package emu.grasscutter.game.entity;
import emu.grasscutter.game.world.Scene; import emu.grasscutter.game.world.Scene;
import emu.grasscutter.game.world.World;
public abstract class EntityBaseGadget extends GameEntity { public abstract class EntityBaseGadget extends GameEntity {
......
...@@ -2,6 +2,7 @@ package emu.grasscutter.game.entity; ...@@ -2,6 +2,7 @@ package emu.grasscutter.game.entity;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.props.EntityIdType; import emu.grasscutter.game.props.EntityIdType;
import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.props.PlayerProperty; import emu.grasscutter.game.props.PlayerProperty;
import emu.grasscutter.game.world.Scene; import emu.grasscutter.game.world.Scene;
...@@ -10,7 +11,6 @@ import emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.Animat ...@@ -10,7 +11,6 @@ import emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.Animat
import emu.grasscutter.net.proto.EntityAuthorityInfoOuterClass.EntityAuthorityInfo; import emu.grasscutter.net.proto.EntityAuthorityInfoOuterClass.EntityAuthorityInfo;
import emu.grasscutter.net.proto.EntityRendererChangedInfoOuterClass.EntityRendererChangedInfo; import emu.grasscutter.net.proto.EntityRendererChangedInfoOuterClass.EntityRendererChangedInfo;
import emu.grasscutter.net.proto.FightPropPairOuterClass.*; import emu.grasscutter.net.proto.FightPropPairOuterClass.*;
import emu.grasscutter.net.proto.GadgetInteractReqOuterClass.GadgetInteractReq;
import emu.grasscutter.net.proto.MotionInfoOuterClass.MotionInfo; import emu.grasscutter.net.proto.MotionInfoOuterClass.MotionInfo;
import emu.grasscutter.net.proto.PropPairOuterClass.PropPair; import emu.grasscutter.net.proto.PropPairOuterClass.PropPair;
import emu.grasscutter.net.proto.ProtEntityTypeOuterClass.ProtEntityType; import emu.grasscutter.net.proto.ProtEntityTypeOuterClass.ProtEntityType;
...@@ -25,23 +25,25 @@ import emu.grasscutter.utils.ProtoHelper; ...@@ -25,23 +25,25 @@ import emu.grasscutter.utils.ProtoHelper;
import it.unimi.dsi.fastutil.ints.Int2FloatMap; import it.unimi.dsi.fastutil.ints.Int2FloatMap;
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
import lombok.Getter;
import lombok.Setter;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
public class EntityVehicle extends EntityBaseGadget { public class EntityVehicle extends EntityBaseGadget {
private final Player owner; @Getter private final Player owner;
private final Int2FloatOpenHashMap fightProp; private final Int2FloatMap fightProp;
private final Position pos; private final Position pos;
private final Position rot; private final Position rot;
private final int pointId; @Getter private final int pointId;
private final int gadgetId; @Getter private final int gadgetId;
private float curStamina; @Getter @Setter private float curStamina;
private List<VehicleMember> vehicleMembers; @Getter private List<VehicleMember> vehicleMembers;
public EntityVehicle(Scene scene, Player player, int gadgetId, int pointId, Position pos, Position rot) { public EntityVehicle(Scene scene, Player player, int gadgetId, int pointId, Position pos, Position rot) {
super(scene); super(scene);
...@@ -54,25 +56,23 @@ public class EntityVehicle extends EntityBaseGadget { ...@@ -54,25 +56,23 @@ public class EntityVehicle extends EntityBaseGadget {
this.pointId = pointId; this.pointId = pointId;
this.curStamina = 240; this.curStamina = 240;
this.vehicleMembers = new ArrayList<VehicleMember>(); this.vehicleMembers = new ArrayList<VehicleMember>();
}
@Override
public int getGadgetId() { return gadgetId; }
public Player getOwner() { switch (gadgetId) {
return owner; case 45001001,45001002 -> { // TODO: Not hardcode this. Waverider (skiff)
this.addFightProperty(FightProperty.FIGHT_PROP_BASE_HP, 10000);
this.addFightProperty(FightProperty.FIGHT_PROP_BASE_ATTACK, 100);
this.addFightProperty(FightProperty.FIGHT_PROP_CUR_ATTACK, 100);
this.addFightProperty(FightProperty.FIGHT_PROP_CUR_HP, 10000);
this.addFightProperty(FightProperty.FIGHT_PROP_CUR_DEFENSE, 0);
this.addFightProperty(FightProperty.FIGHT_PROP_CUR_SPEED, 0);
this.addFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY, 0);
this.addFightProperty(FightProperty.FIGHT_PROP_MAX_HP, 10000);
}
}
} }
public float getCurStamina() { return curStamina; }
public void setCurStamina(float stamina) { this.curStamina = stamina; }
public int getPointId() { return pointId; }
public List<VehicleMember> getVehicleMembers() { return vehicleMembers; }
@Override @Override
public Int2FloatOpenHashMap getFightProperties() { public Int2FloatMap getFightProperties() {
return fightProp; return fightProp;
} }
......
package emu.grasscutter.game.entity; package emu.grasscutter.game.entity;
import java.util.HashMap;
import java.util.Map;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.props.LifeState; import emu.grasscutter.game.props.LifeState;
...@@ -20,25 +17,28 @@ import emu.grasscutter.server.event.entity.EntityDeathEvent; ...@@ -20,25 +17,28 @@ import emu.grasscutter.server.event.entity.EntityDeathEvent;
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify; import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
import emu.grasscutter.utils.Position; import emu.grasscutter.utils.Position;
import it.unimi.dsi.fastutil.ints.Int2FloatMap; import it.unimi.dsi.fastutil.ints.Int2FloatMap;
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2FloatMap;
import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap;
import lombok.Getter;
import lombok.Setter;
public abstract class GameEntity { public abstract class GameEntity {
protected int id; @Getter protected int id;
private final Scene scene; @Getter private final Scene scene;
private SpawnDataEntry spawnEntry; @Getter @Setter private SpawnDataEntry spawnEntry;
private int blockId; @Getter @Setter private int blockId;
private int configId; @Getter @Setter private int configId;
private int groupId; @Getter @Setter private int groupId;
private MotionState moveState; private MotionState moveState;
private int lastMoveSceneTimeMs; @Getter @Setter private int lastMoveSceneTimeMs;
private int lastMoveReliableSeq; @Getter @Setter private int lastMoveReliableSeq;
// Abilities // Abilities
private Map<String, Float> metaOverrideMap; private Object2FloatMap<String> metaOverrideMap;
private Int2ObjectMap<String> metaModifiers; private Int2ObjectMap<String> metaModifiers;
public GameEntity(Scene scene) { public GameEntity(Scene scene) {
...@@ -46,10 +46,6 @@ public abstract class GameEntity { ...@@ -46,10 +46,6 @@ public abstract class GameEntity {
this.moveState = MotionState.MOTION_STATE_NONE; this.moveState = MotionState.MOTION_STATE_NONE;
} }
public int getId() {
return this.id;
}
public int getEntityType() { public int getEntityType() {
return this.getId() >> 24; return this.getId() >> 24;
} }
...@@ -58,10 +54,6 @@ public abstract class GameEntity { ...@@ -58,10 +54,6 @@ public abstract class GameEntity {
return this.getScene().getWorld(); return this.getScene().getWorld();
} }
public Scene getScene() {
return this.scene;
}
public boolean isAlive() { public boolean isAlive() {
return true; return true;
} }
...@@ -70,9 +62,9 @@ public abstract class GameEntity { ...@@ -70,9 +62,9 @@ public abstract class GameEntity {
return this.isAlive() ? LifeState.LIFE_ALIVE : LifeState.LIFE_DEAD; return this.isAlive() ? LifeState.LIFE_ALIVE : LifeState.LIFE_DEAD;
} }
public Map<String, Float> getMetaOverrideMap() { public Object2FloatMap<String> getMetaOverrideMap() {
if (this.metaOverrideMap == null) { if (this.metaOverrideMap == null) {
this.metaOverrideMap = new HashMap<>(); this.metaOverrideMap = new Object2FloatOpenHashMap<>();
} }
return this.metaOverrideMap; return this.metaOverrideMap;
} }
...@@ -84,7 +76,7 @@ public abstract class GameEntity { ...@@ -84,7 +76,7 @@ public abstract class GameEntity {
return this.metaModifiers; return this.metaModifiers;
} }
public abstract Int2FloatOpenHashMap getFightProperties(); public abstract Int2FloatMap getFightProperties();
public abstract Position getPosition(); public abstract Position getPosition();
...@@ -98,27 +90,11 @@ public abstract class GameEntity { ...@@ -98,27 +90,11 @@ public abstract class GameEntity {
this.moveState = moveState; this.moveState = moveState;
} }
public int getLastMoveSceneTimeMs() {
return lastMoveSceneTimeMs;
}
public void setLastMoveSceneTimeMs(int lastMoveSceneTimeMs) {
this.lastMoveSceneTimeMs = lastMoveSceneTimeMs;
}
public int getLastMoveReliableSeq() {
return lastMoveReliableSeq;
}
public void setLastMoveReliableSeq(int lastMoveReliableSeq) {
this.lastMoveReliableSeq = lastMoveReliableSeq;
}
public void setFightProperty(FightProperty prop, float value) { public void setFightProperty(FightProperty prop, float value) {
this.getFightProperties().put(prop.getId(), value); this.getFightProperties().put(prop.getId(), value);
} }
private void setFightProperty(int id, float value) { public void setFightProperty(int id, float value) {
this.getFightProperties().put(id, value); this.getFightProperties().put(id, value);
} }
...@@ -140,30 +116,6 @@ public abstract class GameEntity { ...@@ -140,30 +116,6 @@ public abstract class GameEntity {
} }
} }
public int getBlockId() {
return blockId;
}
public void setBlockId(int blockId) {
this.blockId = blockId;
}
public int getConfigId() {
return configId;
}
public void setConfigId(int configId) {
this.configId = configId;
}
public int getGroupId() {
return groupId;
}
public void setGroupId(int groupId) {
this.groupId = groupId;
}
protected MotionInfo getMotionInfo() { protected MotionInfo getMotionInfo() {
MotionInfo proto = MotionInfo.newBuilder() MotionInfo proto = MotionInfo.newBuilder()
.setPos(this.getPosition().toProto()) .setPos(this.getPosition().toProto())
...@@ -175,14 +127,6 @@ public abstract class GameEntity { ...@@ -175,14 +127,6 @@ public abstract class GameEntity {
return proto; return proto;
} }
public SpawnDataEntry getSpawnEntry() {
return spawnEntry;
}
public void setSpawnEntry(SpawnDataEntry spawnEntry) {
this.spawnEntry = spawnEntry;
}
public float heal(float amount) { public float heal(float amount) {
if (this.getFightProperties() == null) { if (this.getFightProperties() == null) {
return 0f; return 0f;
......
...@@ -2,7 +2,6 @@ package emu.grasscutter.server.packet.send; ...@@ -2,7 +2,6 @@ package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.entity.EntityVehicle; import emu.grasscutter.game.entity.EntityVehicle;
import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.entity.GameEntity; import emu.grasscutter.game.entity.GameEntity;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
...@@ -40,22 +39,6 @@ public class PacketCreateVehicleRsp extends BasePacket { ...@@ -40,22 +39,6 @@ public class PacketCreateVehicleRsp extends BasePacket {
}); });
EntityVehicle vehicle = new EntityVehicle(player.getScene(), player, vehicleId, pointId, pos, rot); EntityVehicle vehicle = new EntityVehicle(player.getScene(), player, vehicleId, pointId, pos, rot);
switch (vehicleId) {
// TODO: Not hardcode this. Waverider (skiff)
case 45001001,45001002 -> {
vehicle.addFightProperty(FightProperty.FIGHT_PROP_BASE_HP, 10000);
vehicle.addFightProperty(FightProperty.FIGHT_PROP_BASE_ATTACK, 100);
vehicle.addFightProperty(FightProperty.FIGHT_PROP_CUR_ATTACK, 100);
vehicle.addFightProperty(FightProperty.FIGHT_PROP_CUR_HP, 10000);
vehicle.addFightProperty(FightProperty.FIGHT_PROP_CUR_DEFENSE, 0);
vehicle.addFightProperty(FightProperty.FIGHT_PROP_CUR_SPEED, 0);
vehicle.addFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY, 0);
vehicle.addFightProperty(FightProperty.FIGHT_PROP_MAX_HP, 10000);
}
default -> {}
}
player.getScene().addEntity(vehicle); player.getScene().addEntity(vehicle);
proto.setVehicleId(vehicleId); proto.setVehicleId(vehicleId);
......
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