Some fix about scene script and quest (#2029)

* [ScriptLib] Query player when not get entity from scene

* Fix NPE when doing quests

* Add QUEST_CONTENT_SKILL trigger

Q353 need it

* Add some missing fields that contain in scene scripts

* Add a lua table serializer implement with jackson

This do not replace the original one,it is useful when debug

* Fix point_array type error

* feat: fix space
This commit is contained in:
ZanyRain
2023-02-10 00:10:07 +08:00
committed by GitHub
Unverified
parent ab5b49b7c5
commit 3b29ba032e
15 changed files with 288 additions and 35 deletions
@@ -0,0 +1,11 @@
package emu.grasscutter.scripts.data;
import lombok.Setter;
import lombok.ToString;
@ToString
@Setter
public class Explore {
public String name;
public int exp;
}
@@ -13,6 +13,13 @@ public class SceneGadget extends SceneObject{
public int interact_id;
public boolean isOneoff;
public int draft_id;
public String drop_tag;
public boolean persistent;
public int mark_flag;
public int route_id;
public Explore explore;
public int trigger_count;
public boolean showcutscene;
public void setIsOneoff(boolean isOneoff) {
this.isOneoff = isOneoff;
@@ -8,5 +8,5 @@ import lombok.ToString;
public class SceneInitConfig {
public int suite;
public int end_suite;
public int rand_suite;
public boolean rand_suite;
}
@@ -9,4 +9,11 @@ public class SceneMonster extends SceneObject{
public int monster_id;
public int pose_id;
public int drop_id;
}
public int special_name_id;
public String drop_tag;
public int climate_area_id;
public boolean disableWander;
public int title_id;
public int[] affix;
public int mark_flag;
}
@@ -4,6 +4,8 @@ import emu.grasscutter.scripts.constants.ScriptRegionShape;
import emu.grasscutter.utils.Position;
import lombok.Setter;
import java.util.List;
@Setter
public class SceneRegion {
@@ -14,6 +16,9 @@ public class SceneRegion {
public Position size;
// for SPHERE
public int radius;
public int area_id;
public float height;
public List<Position> point_array;
public transient SceneGroup group;
public boolean contains(Position position) {
@@ -9,12 +9,13 @@ import lombok.ToString;
@ToString
@Setter
public class SceneSuite {
// make it refer the default empty list to avoid NPE caused by some group
// make it refer the default empty list to avoid NPE caused by some group
public List<Integer> monsters = List.of();
public List<Integer> gadgets = List.of();
public List<String> triggers = List.of();
public List<Integer> regions = List.of();
public int rand_weight;
public int[] npcs;
public transient List<SceneMonster> sceneMonsters = List.of();
public transient List<SceneGadget> sceneGadgets = List.of();
@@ -22,7 +23,7 @@ public class SceneSuite {
public transient List<SceneRegion> sceneRegions = List.of();
public void init(SceneGroup sceneGroup) {
if(sceneGroup.monsters != null){
if(sceneGroup.monsters != null && this.monsters != null){
this.sceneMonsters = new ArrayList<>(
this.monsters.stream()
.filter(sceneGroup.monsters::containsKey)
@@ -31,7 +32,7 @@ public class SceneSuite {
);
}
if(sceneGroup.gadgets != null){
if(sceneGroup.gadgets != null && this.gadgets != null){
this.sceneGadgets = new ArrayList<>(
this.gadgets.stream()
.filter(sceneGroup.gadgets::containsKey)
@@ -40,7 +41,7 @@ public class SceneSuite {
);
}
if(sceneGroup.triggers != null) {
if(sceneGroup.triggers != null && this.triggers != null) {
this.sceneTriggers = new ArrayList<>(
this.triggers.stream()
.filter(sceneGroup.triggers::containsKey)
@@ -48,7 +49,7 @@ public class SceneSuite {
.toList()
);
}
if(sceneGroup.regions != null) {
if(sceneGroup.regions != null && this.regions != null) {
this.sceneRegions = new ArrayList<>(
this.regions.stream()
.filter(sceneGroup.regions::containsKey)
@@ -10,6 +10,9 @@ public class SceneTrigger {
public String source;
public String condition;
public String action;
public boolean forbid_guest;
public int trigger_count;
public String tlog_tag;
public transient SceneGroup currentGroup;
@Override
@@ -34,6 +37,8 @@ public class SceneTrigger {
", source='" + source + '\'' +
", condition='" + condition + '\'' +
", action='" + action + '\'' +
", forbid_guest='" + forbid_guest + '\'' +
", trigger_count='" + trigger_count + '\'' +
'}';
}
}
@@ -9,4 +9,5 @@ public class SceneVar {
public String name;
public int value;
public boolean no_refresh;
public int configId;
}