Implement a proper ability system (#2166)

* Apply fix `21dec2fe`

* Apply fix `89d01d5f`

* Apply fix `d900f154`

this one was already implemented; updated to use call from previous commit

* Ability changing commit

TODO: change info to debug

* Remove use of deprecated methods/fields

* Temp commit v2
(Adding LoseHP and some fixes)

* Oopsie

* Probably fix monster battle

* Fix issue with reflecting into fields

* Fix some things

* Fix ability names for 3.6 resources

* Improve logging

---------

Co-authored-by: StartForKiller <jesussanz2003@gmail.com>
This commit is contained in:
Magix
2023-05-29 23:40:02 -07:00
committed by GitHub
Unverified
parent 9b58105120
commit f00c54cb95
71 changed files with 2015 additions and 995 deletions
@@ -41,14 +41,15 @@ import emu.grasscutter.server.event.player.PlayerTeleportEvent;
import emu.grasscutter.server.packet.send.*;
import emu.grasscutter.utils.objects.KahnsSort;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import lombok.Getter;
import lombok.Setter;
import lombok.val;
import javax.annotation.Nullable;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import lombok.Getter;
import lombok.Setter;
import lombok.val;
public final class Scene {
@Getter private final World world;
@@ -78,6 +79,8 @@ public final class Scene {
@Getter private int tickCount = 0;
@Getter private boolean isPaused = false;
@Getter private GameEntity sceneEntity;
public Scene(World world, SceneData sceneData) {
this.world = world;
this.sceneData = sceneData;
@@ -98,6 +101,7 @@ public final class Scene {
this.scriptManager = new SceneScriptManager(this);
this.blossomManager = new BlossomManager(this);
this.unlockedForces = new HashSet<>();
this.sceneEntity = new EntityScene(this);
}
public int getId() {
@@ -113,7 +117,25 @@ public final class Scene {
}
public GameEntity getEntityById(int id) {
return this.entities.get(id);
// Check if the scene's entity ID is referenced.
if (id == 0x13800001) return this.sceneEntity;
else if (id == this.getWorld().getLevelEntityId())
return this.getWorld().getEntity();
var teamEntityPlayer = players.stream().filter(p -> p.getTeamManager().getEntity().getId() == id).findAny();
if(teamEntityPlayer.isPresent())
return teamEntityPlayer.get().getTeamManager().getEntity();
var entity = this.entities.get(id);
if (entity == null && (id >> 24) == EntityType.Avatar.getValue()) {
for (var player : this.getPlayers()) {
for (var avatar : player.getTeamManager().getActiveTeam()) {
if (avatar.getId() == id) return avatar;
}
}
}
return entity;
}
public GameEntity getEntityByConfigId(int configId) {
@@ -338,6 +360,14 @@ public final class Scene {
addEntities(entities, VisionType.VISION_TYPE_BORN);
}
public void updateEntity(GameEntity entity) {
this.broadcastPacket(new PacketSceneEntityUpdateNotify(entity));
}
public void updateEntity(GameEntity entity, VisionType type) {
this.broadcastPacket(new PacketSceneEntityUpdateNotify(Arrays.asList(entity), type));
}
private static <T> List<List<T>> chopped(List<T> list, final int L) {
List<List<T>> parts = new ArrayList<List<T>>();
final int N = list.size();