mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-05-28 18:40:39 +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:
+39
@@ -0,0 +1,39 @@
|
||||
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.EntityClientGadget;
|
||||
import emu.grasscutter.game.entity.EntityGadget;
|
||||
import emu.grasscutter.game.entity.GameEntity;
|
||||
|
||||
@AbilityAction(AbilityModifierAction.Type.SetGlobalValueToOverrideMap)
|
||||
public class ActionSetGlobalValueToOverrideMap extends AbilityActionHandler {
|
||||
@Override
|
||||
public boolean execute(Ability ability, AbilityModifierAction action, ByteString abilityData, GameEntity target) {
|
||||
//TODO:
|
||||
var entity = target;
|
||||
if(action.isFromOwner) {
|
||||
if(target instanceof EntityClientGadget gadget)
|
||||
entity = entity.getScene().getEntityById(gadget.getOwnerEntityId());
|
||||
else if(target instanceof EntityGadget gadget)
|
||||
entity = gadget.getOwner();
|
||||
}
|
||||
|
||||
var globalValueKey = action.globalValueKey;
|
||||
var abilityFormula = action.abilityFormula;
|
||||
|
||||
if(!entity.getGlobalAbilityValues().containsKey(globalValueKey))
|
||||
return false;
|
||||
|
||||
var globalValue = entity.getGlobalAbilityValues().getOrDefault(globalValueKey, 0.0f);
|
||||
if(abilityFormula.compareTo("DummyThrowSpeed") == 0) {
|
||||
globalValue = ((globalValue * 30.0f) / ((float)Math.sin(0.9424778) * 100.0f)) - 1.0f;
|
||||
}
|
||||
|
||||
entity.getGlobalAbilityValues().put(globalValueKey, globalValue);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user