mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-05-23 06:23:51 +08:00
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:
@@ -11,6 +11,7 @@ import emu.grasscutter.game.entity.gadget.GadgetWorktop;
|
||||
import emu.grasscutter.game.entity.gadget.platform.ConfigRoute;
|
||||
import emu.grasscutter.game.entity.gadget.platform.PointArrayRoute;
|
||||
import emu.grasscutter.game.props.ClimateType;
|
||||
import emu.grasscutter.game.props.EntityIdType;
|
||||
import emu.grasscutter.game.props.EntityType;
|
||||
import emu.grasscutter.game.quest.enums.QuestCond;
|
||||
import emu.grasscutter.game.quest.enums.QuestContent;
|
||||
@@ -459,9 +460,9 @@ public class ScriptLib {
|
||||
private void printLog(String source, String msg){
|
||||
var currentGroup = this.currentGroup.getIfExists();
|
||||
if(currentGroup!=null) {
|
||||
logger.debug("[LUA] {} {} {}", source, currentGroup.id, msg);
|
||||
Grasscutter.getLogger().warn("[LUA] {} {} {}", source, currentGroup.id, msg);
|
||||
} else {
|
||||
logger.debug("[LUA] {} {}", source, msg);
|
||||
Grasscutter.getLogger().warn("[LUA] {} {}", source, msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,9 +491,16 @@ public class ScriptLib {
|
||||
public int SetMonsterBattleByGroup(int configId, int groupId) {
|
||||
logger.debug("[LUA] Call SetMonsterBattleByGroup with {} {}",
|
||||
configId,groupId);
|
||||
// TODO implement scene50008_group250008057.lua uses incomplete group numbers
|
||||
return 0;
|
||||
}
|
||||
// TODO implement scene50008_group250008057.lua uses incomplete group numbers
|
||||
|
||||
// -> MonsterForceAlertNotify
|
||||
var entity = getSceneScriptManager().getScene().getEntityByConfigId(configId, groupId);
|
||||
if (entity instanceof EntityMonster monster) {
|
||||
this.getSceneScriptManager().getScene().broadcastPacket(new PacketMonsterForceAlertNotify(monster.getId()));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int CauseDungeonFail(){
|
||||
logger.debug("[LUA] Call CauseDungeonFail with");
|
||||
@@ -809,7 +817,7 @@ public class ScriptLib {
|
||||
}
|
||||
public int IsPlayerAllAvatarDie(int sceneUid){
|
||||
logger.warn("[LUA] Call unimplemented IsPlayerAllAvatarDie {}", sceneUid);
|
||||
var playerEntities = getSceneScriptManager().getScene().getEntities().values().stream().filter(e -> e.getEntityType() == EntityType.Avatar.getValue()).toList();
|
||||
var playerEntities = getSceneScriptManager().getScene().getEntities().values().stream().filter(e -> e.getEntityType() == EntityIdType.AVATAR.getId()).toList();
|
||||
for (GameEntity p : playerEntities){
|
||||
var player = (EntityAvatar)p;
|
||||
if(player.isAlive()){
|
||||
@@ -1581,14 +1589,23 @@ public class ScriptLib {
|
||||
return gadget.getGroupId();
|
||||
}
|
||||
|
||||
public int SetGadgetEnableInteract(int groupId, int configId, boolean enable) {
|
||||
EntityGadget gadget = getCurrentEntityGadget();
|
||||
if(gadget.getGroupId() != groupId || gadget.getConfigId() != configId) return -1;
|
||||
|
||||
gadget.setInteractEnabled(enable);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int[] GetGatherConfigIdList() {
|
||||
EntityGadget gadget = getCurrentEntityGadget();
|
||||
|
||||
GameEntity[] children = (GameEntity[]) gadget.getChildren().toArray();
|
||||
var children = gadget.getChildren();
|
||||
|
||||
int[] configIds = new int[children.length + 1];
|
||||
for(int i = 0; i < children.length; i++) {
|
||||
configIds[i] = children[i].getConfigId();
|
||||
int[] configIds = new int[children.size()];
|
||||
for(int i = 0; i < children.size(); i++) {
|
||||
configIds[i] = children.get(i).getConfigId();
|
||||
}
|
||||
|
||||
return configIds;
|
||||
|
||||
@@ -3,6 +3,8 @@ package emu.grasscutter.scripts.data;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ToString
|
||||
@Setter
|
||||
public class SceneMonster extends SceneObject {
|
||||
@@ -13,4 +15,6 @@ public class SceneMonster extends SceneObject {
|
||||
public int title_id;
|
||||
public int special_name_id;
|
||||
public String drop_tag;
|
||||
public List<Integer> affix;
|
||||
public boolean isElite;
|
||||
}
|
||||
|
||||
@@ -79,6 +79,11 @@ public class ScriptArgs {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ScriptArgs setEventSource(int source) {
|
||||
this.source = Integer.toString(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getGroupId() {
|
||||
return group_id;
|
||||
}
|
||||
|
||||
@@ -5,29 +5,32 @@ import com.fasterxml.jackson.annotation.Nulls;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.*;
|
||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.type.CollectionType;
|
||||
import com.fasterxml.jackson.databind.type.MapType;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import org.luaj.vm2.LuaTable;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class LuaTableJacksonSerializer extends JsonSerializer<LuaTable> implements Serializer {
|
||||
|
||||
private static ObjectMapper objectMapper;
|
||||
|
||||
public LuaTableJacksonSerializer() {
|
||||
if (objectMapper == null) {
|
||||
objectMapper = new ObjectMapper();
|
||||
objectMapper.configure(MapperFeature.PROPAGATE_TRANSIENT_MARKER, true);
|
||||
// Some properties in Lua table but not in java field
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
objectMapper = JsonMapper.builder()
|
||||
.configure(MapperFeature.PROPAGATE_TRANSIENT_MARKER, true)
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
.build();
|
||||
objectMapper
|
||||
.configOverride(List.class)
|
||||
.setSetterInfo(JsonSetter.Value.forContentNulls(Nulls.AS_EMPTY));
|
||||
SimpleModule luaSerializeModule = new SimpleModule();
|
||||
|
||||
var luaSerializeModule = new SimpleModule();
|
||||
luaSerializeModule.addSerializer(LuaTable.class, this);
|
||||
objectMapper.registerModule(luaSerializeModule);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user