mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-27 12:42:57 +08:00
fix some region errors
This commit is contained in:
parent
b54341a923
commit
b974e61165
10
proto/DungeonShowReminderNotify.proto
Normal file
10
proto/DungeonShowReminderNotify.proto
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option java_package = "emu.grasscutter.net.proto";
|
||||||
|
|
||||||
|
// CmdId: 930
|
||||||
|
// EnetChannelId: 0
|
||||||
|
// EnetIsReliable: true
|
||||||
|
message DungeonShowReminderNotify {
|
||||||
|
uint32 reminder_id = 10;
|
||||||
|
}
|
@ -71,4 +71,8 @@ public class EntityRegion extends GameEntity{
|
|||||||
*/
|
*/
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getFirstEntityId() {
|
||||||
|
return entities.stream().findFirst().orElse(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import emu.grasscutter.data.GameData;
|
|||||||
import emu.grasscutter.data.excels.MonsterData;
|
import emu.grasscutter.data.excels.MonsterData;
|
||||||
import emu.grasscutter.data.excels.WorldLevelData;
|
import emu.grasscutter.data.excels.WorldLevelData;
|
||||||
import emu.grasscutter.game.entity.*;
|
import emu.grasscutter.game.entity.*;
|
||||||
|
import emu.grasscutter.game.props.EntityType;
|
||||||
import emu.grasscutter.game.world.Scene;
|
import emu.grasscutter.game.world.Scene;
|
||||||
import emu.grasscutter.net.proto.VisionTypeOuterClass;
|
import emu.grasscutter.net.proto.VisionTypeOuterClass;
|
||||||
import emu.grasscutter.scripts.constants.EventType;
|
import emu.grasscutter.scripts.constants.EventType;
|
||||||
@ -167,11 +168,11 @@ public class SceneScriptManager {
|
|||||||
public boolean isInit() {
|
public boolean isInit() {
|
||||||
return isInit;
|
return isInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadBlockFromScript(SceneBlock block) {
|
public void loadBlockFromScript(SceneBlock block) {
|
||||||
block.load(scene.getId(), meta.context);
|
block.load(scene.getId(), meta.context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadGroupFromScript(SceneGroup group) {
|
public void loadGroupFromScript(SceneGroup group) {
|
||||||
group.load(getScene().getId());
|
group.load(getScene().getId());
|
||||||
|
|
||||||
@ -188,13 +189,17 @@ public class SceneScriptManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (var region : this.regions.values()) {
|
for (var region : this.regions.values()) {
|
||||||
|
// currently all condition_ENTER_REGION Events check for avatar, so we have no necessary to add other types of entity
|
||||||
getScene().getEntities().values()
|
getScene().getEntities().values()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(e -> e.getEntityType() <= 2 && region.getMetaRegion().contains(e.getPosition()))
|
.filter(e -> e.getEntityType() == EntityType.Avatar.getValue() && region.getMetaRegion().contains(e.getPosition()))
|
||||||
.forEach(region::addEntity);
|
.forEach(region::addEntity);
|
||||||
|
|
||||||
if (region.hasNewEntities()) {
|
if (region.hasNewEntities()) {
|
||||||
callEvent(EventType.EVENT_ENTER_REGION, new ScriptArgs(region.getConfigId()).setSourceEntityId(region.getId()));
|
callEvent(EventType.EVENT_ENTER_REGION, new ScriptArgs(region.getConfigId())
|
||||||
|
.setSourceEntityId(region.getId())
|
||||||
|
.setTargetEntityId(region.getFirstEntityId())
|
||||||
|
);
|
||||||
|
|
||||||
region.resetNewEntities();
|
region.resetNewEntities();
|
||||||
}
|
}
|
||||||
@ -409,18 +414,18 @@ public class SceneScriptManager {
|
|||||||
|
|
||||||
this.getScriptMonsterSpawnService()
|
this.getScriptMonsterSpawnService()
|
||||||
.onMonsterCreatedListener.forEach(action -> action.onNotify(entity));
|
.onMonsterCreatedListener.forEach(action -> action.onNotify(entity));
|
||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEntity(GameEntity gameEntity){
|
public void addEntity(GameEntity gameEntity){
|
||||||
getScene().addEntity(gameEntity);
|
getScene().addEntity(gameEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void meetEntities(List<? extends GameEntity> gameEntity){
|
public void meetEntities(List<? extends GameEntity> gameEntity){
|
||||||
getScene().addEntities(gameEntity, VisionTypeOuterClass.VisionType.VISION_TYPE_MEET);
|
getScene().addEntities(gameEntity, VisionTypeOuterClass.VisionType.VISION_TYPE_MEET);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addEntities(List<? extends GameEntity> gameEntity){
|
public void addEntities(List<? extends GameEntity> gameEntity){
|
||||||
getScene().addEntities(gameEntity);
|
getScene().addEntities(gameEntity);
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,13 @@ import emu.grasscutter.game.entity.EntityMonster;
|
|||||||
import emu.grasscutter.game.entity.GameEntity;
|
import emu.grasscutter.game.entity.GameEntity;
|
||||||
import emu.grasscutter.game.entity.gadget.GadgetWorktop;
|
import emu.grasscutter.game.entity.gadget.GadgetWorktop;
|
||||||
import emu.grasscutter.game.dungeons.challenge.factory.ChallengeFactory;
|
import emu.grasscutter.game.dungeons.challenge.factory.ChallengeFactory;
|
||||||
|
import emu.grasscutter.game.props.EntityType;
|
||||||
|
import emu.grasscutter.game.quest.enums.QuestState;
|
||||||
|
import emu.grasscutter.game.quest.enums.QuestTrigger;
|
||||||
import emu.grasscutter.scripts.data.SceneGroup;
|
import emu.grasscutter.scripts.data.SceneGroup;
|
||||||
import emu.grasscutter.scripts.data.SceneRegion;
|
import emu.grasscutter.scripts.data.SceneRegion;
|
||||||
import emu.grasscutter.server.packet.send.PacketCanUseSkillNotify;
|
import emu.grasscutter.server.packet.send.PacketCanUseSkillNotify;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketDungeonShowReminderNotify;
|
||||||
import emu.grasscutter.server.packet.send.PacketWorktopOptionNotify;
|
import emu.grasscutter.server.packet.send.PacketWorktopOptionNotify;
|
||||||
import io.netty.util.concurrent.FastThreadLocal;
|
import io.netty.util.concurrent.FastThreadLocal;
|
||||||
import org.luaj.vm2.LuaTable;
|
import org.luaj.vm2.LuaTable;
|
||||||
@ -502,4 +506,47 @@ public class ScriptLib {
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetEntityType(int entityId){
|
||||||
|
var entity = getSceneScriptManager().getScene().getEntityById(entityId);
|
||||||
|
if(entity == null){
|
||||||
|
return EntityType.None.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
return entity.getEntityType();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetQuestState(int entityId, int questId){
|
||||||
|
var player = getSceneScriptManager().getScene().getWorld().getHost();
|
||||||
|
|
||||||
|
var quest = player.getQuestManager().getQuestById(questId);
|
||||||
|
if(quest == null){
|
||||||
|
return QuestState.QUEST_STATE_NONE.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
return quest.getState().getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ShowReminder(int reminderId){
|
||||||
|
getSceneScriptManager().getScene().broadcastPacket(new PacketDungeonShowReminderNotify(reminderId));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int RemoveEntityByConfigId(int groupId, int entityType, int configId){
|
||||||
|
logger.debug("[LUA] Call RemoveEntityByConfigId");
|
||||||
|
|
||||||
|
var entity = getSceneScriptManager().getScene().getEntities().values().stream()
|
||||||
|
.filter(e -> e.getGroupId() == groupId)
|
||||||
|
.filter(e -> e.getEntityType() == entityType)
|
||||||
|
.filter(e -> e.getConfigId() == configId)
|
||||||
|
.findFirst();
|
||||||
|
|
||||||
|
if(entity.isEmpty()){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
getSceneScriptManager().getScene().removeEntity(entity.get());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package emu.grasscutter.scripts;
|
|||||||
|
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.game.props.EntityType;
|
import emu.grasscutter.game.props.EntityType;
|
||||||
|
import emu.grasscutter.game.quest.enums.QuestState;
|
||||||
import emu.grasscutter.scripts.constants.EventType;
|
import emu.grasscutter.scripts.constants.EventType;
|
||||||
import emu.grasscutter.scripts.constants.ScriptGadgetState;
|
import emu.grasscutter.scripts.constants.ScriptGadgetState;
|
||||||
import emu.grasscutter.scripts.constants.ScriptRegionShape;
|
import emu.grasscutter.scripts.constants.ScriptRegionShape;
|
||||||
@ -67,6 +68,10 @@ public class ScriptLoader {
|
|||||||
Arrays.stream(EntityType.values()).forEach(e -> table.set(e.name().toUpperCase(), e.getValue()));
|
Arrays.stream(EntityType.values()).forEach(e -> table.set(e.name().toUpperCase(), e.getValue()));
|
||||||
ctx.globals.set("EntityType", table);
|
ctx.globals.set("EntityType", table);
|
||||||
|
|
||||||
|
LuaTable table1 = new LuaTable();
|
||||||
|
Arrays.stream(QuestState.values()).forEach(e -> table1.set(e.name().toUpperCase(), e.getValue()));
|
||||||
|
ctx.globals.set("QuestState", table1);
|
||||||
|
|
||||||
ctx.globals.set("EventType", CoerceJavaToLua.coerce(new EventType())); // TODO - make static class to avoid instantiating a new class every scene
|
ctx.globals.set("EventType", CoerceJavaToLua.coerce(new EventType())); // TODO - make static class to avoid instantiating a new class every scene
|
||||||
ctx.globals.set("GadgetState", CoerceJavaToLua.coerce(new ScriptGadgetState()));
|
ctx.globals.set("GadgetState", CoerceJavaToLua.coerce(new ScriptGadgetState()));
|
||||||
ctx.globals.set("RegionShape", CoerceJavaToLua.coerce(new ScriptRegionShape()));
|
ctx.globals.set("RegionShape", CoerceJavaToLua.coerce(new ScriptRegionShape()));
|
||||||
|
@ -5,9 +5,9 @@ public class ScriptArgs {
|
|||||||
public int param2;
|
public int param2;
|
||||||
public int param3;
|
public int param3;
|
||||||
public int source_eid; // Source entity
|
public int source_eid; // Source entity
|
||||||
|
public int target_eid;
|
||||||
public ScriptArgs() {
|
public ScriptArgs() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptArgs(int param1) {
|
public ScriptArgs(int param1) {
|
||||||
@ -54,4 +54,13 @@ public class ScriptArgs {
|
|||||||
this.source_eid = source_eid;
|
this.source_eid = source_eid;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTargetEntityId() {
|
||||||
|
return target_eid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScriptArgs setTargetEntityId(int target_eid) {
|
||||||
|
this.target_eid = target_eid;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
|
import emu.grasscutter.net.packet.BasePacket;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.proto.DungeonShowReminderNotifyOuterClass;
|
||||||
|
|
||||||
|
public class PacketDungeonShowReminderNotify extends BasePacket {
|
||||||
|
|
||||||
|
public PacketDungeonShowReminderNotify(int reminderId) {
|
||||||
|
super(PacketOpcodes.DungeonShowReminderNotify);
|
||||||
|
|
||||||
|
var proto = DungeonShowReminderNotifyOuterClass.DungeonShowReminderNotify.newBuilder();
|
||||||
|
|
||||||
|
proto.setReminderId(reminderId);
|
||||||
|
|
||||||
|
this.setData(proto);
|
||||||
|
}
|
||||||
|
}
|
@ -18,8 +18,9 @@ public class PacketGroupSuiteNotify extends BasePacket {
|
|||||||
|
|
||||||
var proto = GroupSuiteNotifyOuterClass.GroupSuiteNotify.newBuilder();
|
var proto = GroupSuiteNotifyOuterClass.GroupSuiteNotify.newBuilder();
|
||||||
|
|
||||||
npcBornEntries.forEach(x ->
|
npcBornEntries.stream()
|
||||||
x.getSuiteIdList().forEach(y ->
|
.filter(x -> x.getGroupId() > 0 && x.getSuiteIdList() != null)
|
||||||
|
.forEach(x -> x.getSuiteIdList().forEach(y ->
|
||||||
proto.putGroupMap(x.getGroupId(), y)
|
proto.putGroupMap(x.getGroupId(), y)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user