mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-03-13 18:27:17 +08:00
Implement scripting: SetEntityServerGlobalValueByConfigId
w/ help from: Moistcrafter#9172
This commit is contained in:
parent
c1ea2b04ec
commit
71a8ca2a8a
@ -512,8 +512,14 @@ public class ScriptLib {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int SetEntityServerGlobalValueByConfigId(int cfgId, String sgvName, int value){
|
public int SetEntityServerGlobalValueByConfigId(int cfgId, String sgvName, int value){
|
||||||
logger.warn("[LUA] Call unimplemented SetEntityServerGlobalValueByConfigId with {} {} {}", cfgId, sgvName, value);
|
var scriptManager = this.getSceneScriptManager();
|
||||||
//TODO implement
|
if (scriptManager == null) return 1;
|
||||||
|
|
||||||
|
var entity = scriptManager.getScene().getEntityByConfigId(cfgId);
|
||||||
|
if (entity == null) return 2;
|
||||||
|
|
||||||
|
scriptManager.getScene().getWorld().broadcastPacket(
|
||||||
|
new PacketServerGlobalValueChangeNotify(entity, sgvName, value));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
|
import emu.grasscutter.game.entity.GameEntity;
|
||||||
|
import emu.grasscutter.net.packet.BasePacket;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.proto.ServerGlobalValueChangeNotifyOuterClass.ServerGlobalValueChangeNotify;
|
||||||
|
import emu.grasscutter.utils.Utils;
|
||||||
|
|
||||||
|
public final class PacketServerGlobalValueChangeNotify extends BasePacket {
|
||||||
|
public PacketServerGlobalValueChangeNotify(GameEntity entity, String abilityHash, int value) {
|
||||||
|
super(PacketOpcodes.ServerGlobalValueChangeNotify);
|
||||||
|
|
||||||
|
this.setData(ServerGlobalValueChangeNotify.newBuilder()
|
||||||
|
.setEntityId(entity.getId()).setValue(value)
|
||||||
|
.setKeyHash(Utils.abilityHash(abilityHash)));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user