mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-09 04:32:53 +08:00
Format code [skip actions]
This commit is contained in:
parent
cf6fb275be
commit
583a41ab2c
@ -1,5 +1,7 @@
|
|||||||
package emu.grasscutter.game.entity;
|
package emu.grasscutter.game.entity;
|
||||||
|
|
||||||
|
import static emu.grasscutter.scripts.constants.EventType.EVENT_SPECIFIC_MONSTER_HP_CHANGE;
|
||||||
|
|
||||||
import emu.grasscutter.data.GameData;
|
import emu.grasscutter.data.GameData;
|
||||||
import emu.grasscutter.data.binout.config.ConfigEntityMonster;
|
import emu.grasscutter.data.binout.config.ConfigEntityMonster;
|
||||||
import emu.grasscutter.data.common.PropGrowCurve;
|
import emu.grasscutter.data.common.PropGrowCurve;
|
||||||
@ -28,12 +30,9 @@ import emu.grasscutter.scripts.data.*;
|
|||||||
import emu.grasscutter.server.event.entity.EntityDamageEvent;
|
import emu.grasscutter.server.event.entity.EntityDamageEvent;
|
||||||
import emu.grasscutter.utils.helpers.ProtoHelper;
|
import emu.grasscutter.utils.helpers.ProtoHelper;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import static emu.grasscutter.scripts.constants.EventType.EVENT_SPECIFIC_MONSTER_HP_CHANGE;
|
import lombok.*;
|
||||||
|
|
||||||
public class EntityMonster extends GameEntity {
|
public class EntityMonster extends GameEntity {
|
||||||
@Getter(onMethod_ = @Override)
|
@Getter(onMethod_ = @Override)
|
||||||
@ -41,8 +40,10 @@ public class EntityMonster extends GameEntity {
|
|||||||
|
|
||||||
@Getter(onMethod_ = @Override)
|
@Getter(onMethod_ = @Override)
|
||||||
private final Position position;
|
private final Position position;
|
||||||
|
|
||||||
@Getter(onMethod_ = @Override)
|
@Getter(onMethod_ = @Override)
|
||||||
private final Position rotation;
|
private final Position rotation;
|
||||||
|
|
||||||
@Getter private final MonsterData monsterData;
|
@Getter private final MonsterData monsterData;
|
||||||
@Getter private final ConfigEntityMonster configEntityMonster;
|
@Getter private final ConfigEntityMonster configEntityMonster;
|
||||||
@Getter private final Position bornPos;
|
@Getter private final Position bornPos;
|
||||||
@ -54,7 +55,8 @@ public class EntityMonster extends GameEntity {
|
|||||||
@Getter private List<Player> playerOnBattle;
|
@Getter private List<Player> playerOnBattle;
|
||||||
@Nullable @Getter @Setter private SceneMonster metaMonster;
|
@Nullable @Getter @Setter private SceneMonster metaMonster;
|
||||||
|
|
||||||
public EntityMonster(Scene scene, MonsterData monsterData, Position pos, Position rot, int level) {
|
public EntityMonster(
|
||||||
|
Scene scene, MonsterData monsterData, Position pos, Position rot, int level) {
|
||||||
super(scene);
|
super(scene);
|
||||||
|
|
||||||
this.id = this.getWorld().getNextEntityId(EntityIdType.MONSTER);
|
this.id = this.getWorld().getNextEntityId(EntityIdType.MONSTER);
|
||||||
@ -67,8 +69,9 @@ public class EntityMonster extends GameEntity {
|
|||||||
this.playerOnBattle = new ArrayList<>();
|
this.playerOnBattle = new ArrayList<>();
|
||||||
|
|
||||||
if (GameData.getMonsterMappingMap().containsKey(this.getMonsterId())) {
|
if (GameData.getMonsterMappingMap().containsKey(this.getMonsterId())) {
|
||||||
this.configEntityMonster = GameData.getMonsterConfigData().get(
|
this.configEntityMonster =
|
||||||
GameData.getMonsterMappingMap().get(this.getMonsterId()).getMonsterJson());
|
GameData.getMonsterConfigData()
|
||||||
|
.get(GameData.getMonsterMappingMap().get(this.getMonsterId()).getMonsterJson());
|
||||||
} else {
|
} else {
|
||||||
this.configEntityMonster = null;
|
this.configEntityMonster = null;
|
||||||
}
|
}
|
||||||
@ -77,7 +80,7 @@ public class EntityMonster extends GameEntity {
|
|||||||
if (getMonsterWeaponId() > 0) {
|
if (getMonsterWeaponId() > 0) {
|
||||||
this.weaponEntity = new EntityWeapon(scene, getMonsterWeaponId());
|
this.weaponEntity = new EntityWeapon(scene, getMonsterWeaponId());
|
||||||
scene.getWeaponEntities().put(this.weaponEntity.getId(), this.weaponEntity);
|
scene.getWeaponEntities().put(this.weaponEntity.getId(), this.weaponEntity);
|
||||||
//this.weaponEntityId = getWorld().getNextEntityId(EntityIdType.WEAPON);
|
// this.weaponEntityId = getWorld().getNextEntityId(EntityIdType.WEAPON);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.recalcStats();
|
this.recalcStats();
|
||||||
@ -87,18 +90,15 @@ public class EntityMonster extends GameEntity {
|
|||||||
private void addConfigAbility(String name) {
|
private void addConfigAbility(String name) {
|
||||||
var data = GameData.getAbilityData(name);
|
var data = GameData.getAbilityData(name);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.getWorld().getHost()
|
this.getWorld().getHost().getAbilityManager().addAbilityToEntity(this, data);
|
||||||
.getAbilityManager()
|
|
||||||
.addAbilityToEntity(this, data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initAbilities() {
|
public void initAbilities() {
|
||||||
// Affix abilities
|
// Affix abilities
|
||||||
var optionalGroup = this.getScene().getLoadedGroups().stream()
|
var optionalGroup =
|
||||||
.filter(g -> g.id == this.getGroupId())
|
this.getScene().getLoadedGroups().stream().filter(g -> g.id == this.getGroupId()).findAny();
|
||||||
.findAny();
|
|
||||||
List<Integer> affixes = null;
|
List<Integer> affixes = null;
|
||||||
if (optionalGroup.isPresent()) {
|
if (optionalGroup.isPresent()) {
|
||||||
var group = optionalGroup.get();
|
var group = optionalGroup.get();
|
||||||
@ -118,7 +118,7 @@ public class EntityMonster extends GameEntity {
|
|||||||
var affix = GameData.getMonsterAffixDataMap().get(affixId.intValue());
|
var affix = GameData.getMonsterAffixDataMap().get(affixId.intValue());
|
||||||
if (!affix.isPreAdd()) continue;
|
if (!affix.isPreAdd()) continue;
|
||||||
|
|
||||||
//Add the ability
|
// Add the ability
|
||||||
for (var name : affix.getAbilityName()) {
|
for (var name : affix.getAbilityName()) {
|
||||||
this.addConfigAbility(name);
|
this.addConfigAbility(name);
|
||||||
}
|
}
|
||||||
@ -126,14 +126,12 @@ public class EntityMonster extends GameEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Research if any monster is non humanoid
|
// TODO: Research if any monster is non humanoid
|
||||||
for(var ability : GameData.getConfigGlobalCombat()
|
for (var ability :
|
||||||
.getDefaultAbilities()
|
GameData.getConfigGlobalCombat().getDefaultAbilities().getNonHumanoidMoveAbilities()) {
|
||||||
.getNonHumanoidMoveAbilities()) {
|
|
||||||
this.addConfigAbility(ability);
|
this.addConfigAbility(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.configEntityMonster != null &&
|
if (this.configEntityMonster != null && this.configEntityMonster.getAbilities() != null) {
|
||||||
this.configEntityMonster.getAbilities() != null) {
|
|
||||||
for (var configAbilityData : this.configEntityMonster.getAbilities()) {
|
for (var configAbilityData : this.configEntityMonster.getAbilities()) {
|
||||||
this.addConfigAbility(configAbilityData.abilityName);
|
this.addConfigAbility(configAbilityData.abilityName);
|
||||||
}
|
}
|
||||||
@ -143,9 +141,8 @@ public class EntityMonster extends GameEntity {
|
|||||||
var group = optionalGroup.get();
|
var group = optionalGroup.get();
|
||||||
var monster = group.monsters.get(getConfigId());
|
var monster = group.monsters.get(getConfigId());
|
||||||
if (monster != null && monster.isElite) {
|
if (monster != null && monster.isElite) {
|
||||||
this.addConfigAbility(GameData.getConfigGlobalCombat()
|
this.addConfigAbility(
|
||||||
.getDefaultAbilities()
|
GameData.getConfigGlobalCombat().getDefaultAbilities().getMonterEliteAbilityName());
|
||||||
.getMonterEliteAbilityName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,8 +151,8 @@ public class EntityMonster extends GameEntity {
|
|||||||
var affix = GameData.getMonsterAffixDataMap().get(affixId.intValue());
|
var affix = GameData.getMonsterAffixDataMap().get(affixId.intValue());
|
||||||
if (affix.isPreAdd()) continue;
|
if (affix.isPreAdd()) continue;
|
||||||
|
|
||||||
//Add the ability
|
// Add the ability
|
||||||
for(var name : affix.getAbilityName()) {
|
for (var name : affix.getAbilityName()) {
|
||||||
this.addConfigAbility(name);
|
this.addConfigAbility(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,7 +160,7 @@ public class EntityMonster extends GameEntity {
|
|||||||
|
|
||||||
var levelEntityConfig = getScene().getSceneData().getLevelEntityConfig();
|
var levelEntityConfig = getScene().getSceneData().getLevelEntityConfig();
|
||||||
var config = GameData.getConfigLevelEntityDataMap().get(levelEntityConfig);
|
var config = GameData.getConfigLevelEntityDataMap().get(levelEntityConfig);
|
||||||
if (config == null){
|
if (config == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +191,8 @@ public class EntityMonster extends GameEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInteract(Player player, GadgetInteractReq interactReq) {
|
public void onInteract(Player player, GadgetInteractReq interactReq) {
|
||||||
EnvAnimalGatherConfigData gatherData = GameData.getEnvAnimalGatherConfigDataMap().get(this.getMonsterData().getId());
|
EnvAnimalGatherConfigData gatherData =
|
||||||
|
GameData.getEnvAnimalGatherConfigDataMap().get(this.getMonsterData().getId());
|
||||||
|
|
||||||
if (gatherData == null) {
|
if (gatherData == null) {
|
||||||
return;
|
return;
|
||||||
@ -208,7 +206,11 @@ public class EntityMonster extends GameEntity {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
// Lua event
|
// Lua event
|
||||||
getScene().getScriptManager().callEvent(new ScriptArgs(this.getGroupId(), EventType.EVENT_ANY_MONSTER_LIVE, this.getConfigId()));
|
getScene()
|
||||||
|
.getScriptManager()
|
||||||
|
.callEvent(
|
||||||
|
new ScriptArgs(
|
||||||
|
this.getGroupId(), EventType.EVENT_ANY_MONSTER_LIVE, this.getConfigId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -231,10 +233,17 @@ public class EntityMonster extends GameEntity {
|
|||||||
@Override
|
@Override
|
||||||
public void runLuaCallbacks(EntityDamageEvent event) {
|
public void runLuaCallbacks(EntityDamageEvent event) {
|
||||||
super.runLuaCallbacks(event);
|
super.runLuaCallbacks(event);
|
||||||
getScene().getScriptManager().callEvent(new ScriptArgs(this.getGroupId(), EVENT_SPECIFIC_MONSTER_HP_CHANGE, getConfigId(), monsterData.getId())
|
getScene()
|
||||||
.setSourceEntityId(getId())
|
.getScriptManager()
|
||||||
.setParam3((int) this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP))
|
.callEvent(
|
||||||
.setEventSource(getConfigId()));
|
new ScriptArgs(
|
||||||
|
this.getGroupId(),
|
||||||
|
EVENT_SPECIFIC_MONSTER_HP_CHANGE,
|
||||||
|
getConfigId(),
|
||||||
|
monsterData.getId())
|
||||||
|
.setSourceEntityId(getId())
|
||||||
|
.setParam3((int) this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP))
|
||||||
|
.setEventSource(getConfigId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -250,13 +259,17 @@ public class EntityMonster extends GameEntity {
|
|||||||
challenge.ifPresent(c -> c.onMonsterDeath(this));
|
challenge.ifPresent(c -> c.onMonsterDeath(this));
|
||||||
|
|
||||||
if (scriptManager.isInit() && this.getGroupId() > 0) {
|
if (scriptManager.isInit() && this.getGroupId() > 0) {
|
||||||
Optional.ofNullable(scriptManager.getScriptMonsterSpawnService()).ifPresent(s -> s.onMonsterDead(this));
|
Optional.ofNullable(scriptManager.getScriptMonsterSpawnService())
|
||||||
|
.ifPresent(s -> s.onMonsterDead(this));
|
||||||
|
|
||||||
// Ensure each EVENT_ANY_MONSTER_DIE runs to completion.
|
// Ensure each EVENT_ANY_MONSTER_DIE runs to completion.
|
||||||
// Multiple such events firing at the same time may cause
|
// Multiple such events firing at the same time may cause
|
||||||
// the same lua trigger to fire multiple times, when it
|
// the same lua trigger to fire multiple times, when it
|
||||||
// should happen only once.
|
// should happen only once.
|
||||||
var future = scriptManager.callEvent(new ScriptArgs(this.getGroupId(), EventType.EVENT_ANY_MONSTER_DIE, this.getConfigId()));
|
var future =
|
||||||
|
scriptManager.callEvent(
|
||||||
|
new ScriptArgs(
|
||||||
|
this.getGroupId(), EventType.EVENT_ANY_MONSTER_DIE, this.getConfigId()));
|
||||||
try {
|
try {
|
||||||
future.get();
|
future.get();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -264,19 +277,45 @@ public class EntityMonster extends GameEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Battle Pass trigger
|
// Battle Pass trigger
|
||||||
scene.getPlayers().forEach(p -> p.getBattlePassManager().triggerMission(WatcherTriggerType.TRIGGER_MONSTER_DIE, this.getMonsterId(), 1));
|
scene
|
||||||
|
.getPlayers()
|
||||||
|
.forEach(
|
||||||
|
p ->
|
||||||
|
p.getBattlePassManager()
|
||||||
|
.triggerMission(
|
||||||
|
WatcherTriggerType.TRIGGER_MONSTER_DIE, this.getMonsterId(), 1));
|
||||||
|
|
||||||
scene.getPlayers().forEach(p -> p.getQuestManager().queueEvent(QuestContent.QUEST_CONTENT_MONSTER_DIE, this.getMonsterId()));
|
scene
|
||||||
scene.getPlayers().forEach(p -> p.getQuestManager().queueEvent(QuestContent.QUEST_CONTENT_KILL_MONSTER, this.getMonsterId()));
|
.getPlayers()
|
||||||
scene.getPlayers().forEach(p -> p.getQuestManager().queueEvent(QuestContent.QUEST_CONTENT_CLEAR_GROUP_MONSTER, this.getGroupId()));
|
.forEach(
|
||||||
|
p ->
|
||||||
|
p.getQuestManager()
|
||||||
|
.queueEvent(QuestContent.QUEST_CONTENT_MONSTER_DIE, this.getMonsterId()));
|
||||||
|
scene
|
||||||
|
.getPlayers()
|
||||||
|
.forEach(
|
||||||
|
p ->
|
||||||
|
p.getQuestManager()
|
||||||
|
.queueEvent(QuestContent.QUEST_CONTENT_KILL_MONSTER, this.getMonsterId()));
|
||||||
|
scene
|
||||||
|
.getPlayers()
|
||||||
|
.forEach(
|
||||||
|
p ->
|
||||||
|
p.getQuestManager()
|
||||||
|
.queueEvent(QuestContent.QUEST_CONTENT_CLEAR_GROUP_MONSTER, this.getGroupId()));
|
||||||
|
|
||||||
SceneGroupInstance groupInstance = scene.getScriptManager().getGroupInstanceById(this.getGroupId());
|
SceneGroupInstance groupInstance =
|
||||||
if(groupInstance != null && metaMonster != null)
|
scene.getScriptManager().getGroupInstanceById(this.getGroupId());
|
||||||
|
if (groupInstance != null && metaMonster != null)
|
||||||
groupInstance.getDeadEntities().add(metaMonster.config_id);
|
groupInstance.getDeadEntities().add(metaMonster.config_id);
|
||||||
|
|
||||||
scene.triggerDungeonEvent(DungeonPassConditionType.DUNGEON_COND_KILL_GROUP_MONSTER, this.getGroupId());
|
scene.triggerDungeonEvent(
|
||||||
scene.triggerDungeonEvent(DungeonPassConditionType.DUNGEON_COND_KILL_TYPE_MONSTER, this.getMonsterData().getType().getValue());
|
DungeonPassConditionType.DUNGEON_COND_KILL_GROUP_MONSTER, this.getGroupId());
|
||||||
scene.triggerDungeonEvent(DungeonPassConditionType.DUNGEON_COND_KILL_MONSTER, this.getMonsterId());
|
scene.triggerDungeonEvent(
|
||||||
|
DungeonPassConditionType.DUNGEON_COND_KILL_TYPE_MONSTER,
|
||||||
|
this.getMonsterData().getType().getValue());
|
||||||
|
scene.triggerDungeonEvent(
|
||||||
|
DungeonPassConditionType.DUNGEON_COND_KILL_MONSTER, this.getMonsterId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recalcStats() {
|
public void recalcStats() {
|
||||||
@ -284,86 +323,107 @@ public class EntityMonster extends GameEntity {
|
|||||||
MonsterData data = this.getMonsterData();
|
MonsterData data = this.getMonsterData();
|
||||||
|
|
||||||
// Get hp percent, set to 100% if none
|
// Get hp percent, set to 100% if none
|
||||||
float hpPercent = this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) <= 0 ? 1f : this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) / this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP);
|
float hpPercent =
|
||||||
|
this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) <= 0
|
||||||
|
? 1f
|
||||||
|
: this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP)
|
||||||
|
/ this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP);
|
||||||
|
|
||||||
// Clear properties
|
// Clear properties
|
||||||
this.getFightProperties().clear();
|
this.getFightProperties().clear();
|
||||||
|
|
||||||
// Base stats
|
// Base stats
|
||||||
MonsterData.definedFightProperties.forEach(prop -> this.setFightProperty(prop, data.getFightProperty(prop)));
|
MonsterData.definedFightProperties.forEach(
|
||||||
|
prop -> this.setFightProperty(prop, data.getFightProperty(prop)));
|
||||||
|
|
||||||
// Level curve
|
// Level curve
|
||||||
MonsterCurveData curve = GameData.getMonsterCurveDataMap().get(this.getLevel());
|
MonsterCurveData curve = GameData.getMonsterCurveDataMap().get(this.getLevel());
|
||||||
if (curve != null) {
|
if (curve != null) {
|
||||||
for (PropGrowCurve growCurve : data.getPropGrowCurves()) {
|
for (PropGrowCurve growCurve : data.getPropGrowCurves()) {
|
||||||
FightProperty prop = FightProperty.getPropByName(growCurve.getType());
|
FightProperty prop = FightProperty.getPropByName(growCurve.getType());
|
||||||
this.setFightProperty(prop, this.getFightProperty(prop) * curve.getMultByProp(growCurve.getGrowCurve()));
|
this.setFightProperty(
|
||||||
|
prop, this.getFightProperty(prop) * curve.getMultByProp(growCurve.getGrowCurve()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set % stats
|
// Set % stats
|
||||||
FightProperty.forEachCompoundProperty(c -> this.setFightProperty(c.getResult(),
|
FightProperty.forEachCompoundProperty(
|
||||||
this.getFightProperty(c.getFlat()) + (this.getFightProperty(c.getBase()) * (1f + this.getFightProperty(c.getPercent())))));
|
c ->
|
||||||
|
this.setFightProperty(
|
||||||
|
c.getResult(),
|
||||||
|
this.getFightProperty(c.getFlat())
|
||||||
|
+ (this.getFightProperty(c.getBase())
|
||||||
|
* (1f + this.getFightProperty(c.getPercent())))));
|
||||||
|
|
||||||
// Set current hp
|
// Set current hp
|
||||||
this.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) * hpPercent);
|
this.setFightProperty(
|
||||||
|
FightProperty.FIGHT_PROP_CUR_HP,
|
||||||
|
this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) * hpPercent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SceneEntityInfo toProto() {
|
public SceneEntityInfo toProto() {
|
||||||
var data = this.getMonsterData();
|
var data = this.getMonsterData();
|
||||||
|
|
||||||
var authority = EntityAuthorityInfo.newBuilder()
|
var authority =
|
||||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder())
|
EntityAuthorityInfo.newBuilder()
|
||||||
.setRendererChangedInfo(EntityRendererChangedInfo.newBuilder())
|
.setAbilityInfo(AbilitySyncStateInfo.newBuilder())
|
||||||
.setAiInfo(SceneEntityAiInfo.newBuilder()
|
.setRendererChangedInfo(EntityRendererChangedInfo.newBuilder())
|
||||||
.setIsAiOpen(true)
|
.setAiInfo(
|
||||||
.setBornPos(this.getBornPos().toProto()))
|
SceneEntityAiInfo.newBuilder()
|
||||||
.setBornPos(this.getBornPos().toProto())
|
.setIsAiOpen(true)
|
||||||
.build();
|
.setBornPos(this.getBornPos().toProto()))
|
||||||
|
.setBornPos(this.getBornPos().toProto())
|
||||||
|
.build();
|
||||||
|
|
||||||
var entityInfo = SceneEntityInfo.newBuilder()
|
var entityInfo =
|
||||||
.setEntityId(this.getId())
|
SceneEntityInfo.newBuilder()
|
||||||
.setEntityType(ProtEntityType.PROT_ENTITY_TYPE_MONSTER)
|
.setEntityId(this.getId())
|
||||||
.setMotionInfo(this.getMotionInfo())
|
.setEntityType(ProtEntityType.PROT_ENTITY_TYPE_MONSTER)
|
||||||
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
|
.setMotionInfo(this.getMotionInfo())
|
||||||
.setEntityClientData(EntityClientData.newBuilder())
|
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
|
||||||
.setEntityAuthorityInfo(authority)
|
.setEntityClientData(EntityClientData.newBuilder())
|
||||||
.setLifeState(this.getLifeState().getValue());
|
.setEntityAuthorityInfo(authority)
|
||||||
|
.setLifeState(this.getLifeState().getValue());
|
||||||
|
|
||||||
this.addAllFightPropsToEntityInfo(entityInfo);
|
this.addAllFightPropsToEntityInfo(entityInfo);
|
||||||
|
|
||||||
entityInfo.addPropList(PropPair.newBuilder()
|
entityInfo.addPropList(
|
||||||
.setType(PlayerProperty.PROP_LEVEL.getId())
|
PropPair.newBuilder()
|
||||||
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel()))
|
.setType(PlayerProperty.PROP_LEVEL.getId())
|
||||||
.build());
|
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel()))
|
||||||
|
.build());
|
||||||
|
|
||||||
var monsterInfo = SceneMonsterInfo.newBuilder()
|
var monsterInfo =
|
||||||
.setMonsterId(getMonsterId())
|
SceneMonsterInfo.newBuilder()
|
||||||
.setGroupId(this.getGroupId())
|
.setMonsterId(getMonsterId())
|
||||||
.setConfigId(this.getConfigId())
|
.setGroupId(this.getGroupId())
|
||||||
.addAllAffixList(data.getAffix())
|
.setConfigId(this.getConfigId())
|
||||||
.setAuthorityPeerId(this.getWorld().getHostPeerId())
|
.addAllAffixList(data.getAffix())
|
||||||
.setPoseId(this.getPoseId())
|
.setAuthorityPeerId(this.getWorld().getHostPeerId())
|
||||||
.setBlockId(this.getScene().getId())
|
.setPoseId(this.getPoseId())
|
||||||
.setBornType(MonsterBornType.MONSTER_BORN_TYPE_DEFAULT);
|
.setBlockId(this.getScene().getId())
|
||||||
|
.setBornType(MonsterBornType.MONSTER_BORN_TYPE_DEFAULT);
|
||||||
|
|
||||||
if (this.metaMonster != null) {
|
if (this.metaMonster != null) {
|
||||||
if (this.metaMonster.special_name_id != 0) {
|
if (this.metaMonster.special_name_id != 0) {
|
||||||
monsterInfo.setTitleId(this.metaMonster.title_id)
|
monsterInfo
|
||||||
.setSpecialNameId(this.metaMonster.special_name_id);
|
.setTitleId(this.metaMonster.title_id)
|
||||||
|
.setSpecialNameId(this.metaMonster.special_name_id);
|
||||||
} else if (data.getDescribeData() != null) {
|
} else if (data.getDescribeData() != null) {
|
||||||
monsterInfo.setTitleId(data.getDescribeData().getTitleId())
|
monsterInfo
|
||||||
.setSpecialNameId(data.getSpecialNameId());
|
.setTitleId(data.getDescribeData().getTitleId())
|
||||||
|
.setSpecialNameId(data.getSpecialNameId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getMonsterWeaponId() > 0) {
|
if (this.getMonsterWeaponId() > 0) {
|
||||||
SceneWeaponInfo weaponInfo = SceneWeaponInfo.newBuilder()
|
SceneWeaponInfo weaponInfo =
|
||||||
.setEntityId(this.getWeaponEntity() != null ? this.getWeaponEntity().getId() : 0)
|
SceneWeaponInfo.newBuilder()
|
||||||
.setGadgetId(this.getMonsterWeaponId())
|
.setEntityId(this.getWeaponEntity() != null ? this.getWeaponEntity().getId() : 0)
|
||||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder())
|
.setGadgetId(this.getMonsterWeaponId())
|
||||||
.build();
|
.setAbilityInfo(AbilitySyncStateInfo.newBuilder())
|
||||||
|
.build();
|
||||||
|
|
||||||
monsterInfo.addWeaponList(weaponInfo);
|
monsterInfo.addWeaponList(weaponInfo);
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,9 @@ public class SceneScriptManager {
|
|||||||
public void registerTrigger(SceneTrigger trigger) {
|
public void registerTrigger(SceneTrigger trigger) {
|
||||||
this.triggerInvocations.put(trigger.getName(), new AtomicInteger(0));
|
this.triggerInvocations.put(trigger.getName(), new AtomicInteger(0));
|
||||||
this.getTriggersByEvent(trigger.getEvent()).add(trigger);
|
this.getTriggersByEvent(trigger.getEvent()).add(trigger);
|
||||||
Grasscutter.getLogger().trace("Registered trigger {} from group {}", trigger.getName(), trigger.getCurrentGroup().id);
|
Grasscutter.getLogger()
|
||||||
|
.trace(
|
||||||
|
"Registered trigger {} from group {}", trigger.getName(), trigger.getCurrentGroup().id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deregisterTrigger(List<SceneTrigger> triggers) {
|
public void deregisterTrigger(List<SceneTrigger> triggers) {
|
||||||
@ -145,7 +147,11 @@ public class SceneScriptManager {
|
|||||||
|
|
||||||
public void deregisterTrigger(SceneTrigger trigger) {
|
public void deregisterTrigger(SceneTrigger trigger) {
|
||||||
this.getTriggersByEvent(trigger.getEvent()).remove(trigger);
|
this.getTriggersByEvent(trigger.getEvent()).remove(trigger);
|
||||||
Grasscutter.getLogger().trace("deregistered trigger {} from group {}", trigger.getName(), trigger.getCurrentGroup().id);
|
Grasscutter.getLogger()
|
||||||
|
.trace(
|
||||||
|
"deregistered trigger {} from group {}",
|
||||||
|
trigger.getName(),
|
||||||
|
trigger.getCurrentGroup().id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetTriggers(int eventId) {
|
public void resetTriggers(int eventId) {
|
||||||
@ -468,7 +474,9 @@ public class SceneScriptManager {
|
|||||||
return groupGridsCache.get(sceneId);
|
return groupGridsCache.get(sceneId);
|
||||||
} else {
|
} else {
|
||||||
var path = FileUtils.getCachePath("scene" + sceneId + "_grid.json");
|
var path = FileUtils.getCachePath("scene" + sceneId + "_grid.json");
|
||||||
if (path.toFile().isFile() && !Grasscutter.config.server.game.cacheSceneEntitiesEveryRun && !noCacheGroupGridsToDisk) {
|
if (path.toFile().isFile()
|
||||||
|
&& !Grasscutter.config.server.game.cacheSceneEntitiesEveryRun
|
||||||
|
&& !noCacheGroupGridsToDisk) {
|
||||||
try {
|
try {
|
||||||
var groupGrids = JsonUtils.loadToList(path, Grid.class);
|
var groupGrids = JsonUtils.loadToList(path, Grid.class);
|
||||||
groupGridsCache.put(sceneId, groupGrids);
|
groupGridsCache.put(sceneId, groupGrids);
|
||||||
@ -607,7 +615,8 @@ public class SceneScriptManager {
|
|||||||
file.write(JsonUtils.encode(groupGrids));
|
file.write(JsonUtils.encode(groupGrids));
|
||||||
Grasscutter.getLogger().info("Scene {} saved grid file.", getScene().getId());
|
Grasscutter.getLogger().info("Scene {} saved grid file.", getScene().getId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Grasscutter.getLogger().error("Scene {} unable to save grid file.", getScene().getId(), e);
|
Grasscutter.getLogger()
|
||||||
|
.error("Scene {} unable to save grid file.", getScene().getId(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return groupGrids;
|
return groupGrids;
|
||||||
|
@ -92,7 +92,9 @@ public final class SceneGroup {
|
|||||||
if (overrideScriptPath != null && !overrideScriptPath.equals("")) {
|
if (overrideScriptPath != null && !overrideScriptPath.equals("")) {
|
||||||
cs = ScriptLoader.getScript(overrideScriptPath, true);
|
cs = ScriptLoader.getScript(overrideScriptPath, true);
|
||||||
} else {
|
} else {
|
||||||
cs = ScriptLoader.getScript("Scene/%s/scene%s_group%s.lua".formatted(sceneId, sceneId, this.id));
|
cs =
|
||||||
|
ScriptLoader.getScript(
|
||||||
|
"Scene/%s/scene%s_group%s.lua".formatted(sceneId, sceneId, this.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cs == null) {
|
if (cs == null) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package emu.grasscutter.server.event.game;
|
package emu.grasscutter.server.event.game;
|
||||||
|
|
||||||
import emu.grasscutter.server.event.types.ServerEvent;
|
|
||||||
import emu.grasscutter.scripts.data.SceneBlock;
|
import emu.grasscutter.scripts.data.SceneBlock;
|
||||||
|
import emu.grasscutter.server.event.types.ServerEvent;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
Loading…
Reference in New Issue
Block a user