mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-08 08:33:22 +08:00
Broadcast global value changes
This commit is contained in:
parent
01766a0303
commit
bd59da8853
@ -5,6 +5,7 @@ import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
||||
import emu.grasscutter.game.ability.Ability;
|
||||
import emu.grasscutter.game.entity.GameEntity;
|
||||
import emu.grasscutter.server.packet.send.PacketServerGlobalValueChangeNotify;
|
||||
|
||||
@AbilityAction(AbilityModifierAction.Type.CopyGlobalValue)
|
||||
public final class ActionCopyGlobalValue extends AbilityActionHandler {
|
||||
@ -30,6 +31,11 @@ public final class ActionCopyGlobalValue extends AbilityActionHandler {
|
||||
// Apply the new global value.
|
||||
destination.getGlobalAbilityValues().put(action.dstKey, value);
|
||||
destination.onAbilityValueUpdate();
|
||||
|
||||
// Send a value update packet.
|
||||
entity.getScene().getHost().sendPacket(
|
||||
new PacketServerGlobalValueChangeNotify(entity, action.dstKey, value));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
package emu.grasscutter.game.ability.actions;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
||||
import emu.grasscutter.game.ability.Ability;
|
||||
import emu.grasscutter.game.entity.GameEntity;
|
||||
import emu.grasscutter.server.packet.send.PacketServerGlobalValueChangeNotify;
|
||||
|
||||
@AbilityAction(AbilityModifierAction.Type.SetGlobalValue)
|
||||
public final class ActionSetGlobalValue extends AbilityActionHandler {
|
||||
@Override
|
||||
public boolean execute(
|
||||
Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) {
|
||||
// Get the key & value.
|
||||
var valueKey = action.key;
|
||||
var value = action.ratio;
|
||||
|
||||
// Set the global value.
|
||||
target.getGlobalAbilityValues().put(valueKey, value.get(ability));
|
||||
// Update the target.
|
||||
target.onAbilityValueUpdate();
|
||||
|
||||
// Send a value update packet.
|
||||
target.getScene().getHost().sendPacket(
|
||||
new PacketServerGlobalValueChangeNotify(target, valueKey, value.get(ability)));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -5,9 +5,10 @@ import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
|
||||
import emu.grasscutter.game.ability.Ability;
|
||||
import emu.grasscutter.game.entity.*;
|
||||
import emu.grasscutter.server.packet.send.PacketServerGlobalValueChangeNotify;
|
||||
|
||||
@AbilityAction(AbilityModifierAction.Type.SetGlobalValueToOverrideMap)
|
||||
public class ActionSetGlobalValueToOverrideMap extends AbilityActionHandler {
|
||||
public final class ActionSetGlobalValueToOverrideMap extends AbilityActionHandler {
|
||||
@Override
|
||||
public boolean execute(
|
||||
Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) {
|
||||
@ -36,8 +37,11 @@ public class ActionSetGlobalValueToOverrideMap extends AbilityActionHandler {
|
||||
ability
|
||||
.getAbilitySpecials()
|
||||
.put(action.overrideMapKey, globalValue.floatValue()); // Override our own.
|
||||
entity.onAbilityValueUpdate();
|
||||
|
||||
// TODO: ChangeServerGlobalValueNotify
|
||||
// Send a value update packet.
|
||||
entity.getScene().getHost().sendPacket(
|
||||
new PacketServerGlobalValueChangeNotify(entity, globalValueKey, globalValue));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import emu.grasscutter.net.proto.ServerGlobalValueChangeNotifyOuterClass.ServerG
|
||||
import emu.grasscutter.utils.Utils;
|
||||
|
||||
public final class PacketServerGlobalValueChangeNotify extends BasePacket {
|
||||
public PacketServerGlobalValueChangeNotify(GameEntity entity, String abilityHash, int value) {
|
||||
public PacketServerGlobalValueChangeNotify(GameEntity entity, String abilityHash, float value) {
|
||||
super(PacketOpcodes.ServerGlobalValueChangeNotify);
|
||||
|
||||
this.setData(
|
||||
@ -17,7 +17,7 @@ public final class PacketServerGlobalValueChangeNotify extends BasePacket {
|
||||
.setKeyHash(Utils.abilityHash(abilityHash)));
|
||||
}
|
||||
|
||||
public PacketServerGlobalValueChangeNotify(int entityId, String abilityHash, int value) {
|
||||
public PacketServerGlobalValueChangeNotify(int entityId, String abilityHash, float value) {
|
||||
super(PacketOpcodes.ServerGlobalValueChangeNotify);
|
||||
|
||||
this.setData(
|
||||
|
Loading…
Reference in New Issue
Block a user