mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-03-26 17:43:07 +01:00
Fix whitespace [skip actions]
This commit is contained in:
@@ -56,7 +56,7 @@ public final class AbilityManager extends BasePlayerManager {
|
||||
}
|
||||
|
||||
// Check if the caster matches the player.
|
||||
if(player.getTeamManager().getCurrentAvatarEntity().getId() != casterId) {
|
||||
if (player.getTeamManager().getCurrentAvatarEntity().getId() != casterId) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class AbilityManager extends BasePlayerManager {
|
||||
}
|
||||
|
||||
// Check if the skill is an elemental burst.
|
||||
if(skillData.getCostElemVal() <= 0) {
|
||||
if (skillData.getCostElemVal() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public final class AbilityManager extends BasePlayerManager {
|
||||
}
|
||||
|
||||
// Check if the player is invulnerable.
|
||||
if(!this.abilityInvulnerable) {
|
||||
if (!this.abilityInvulnerable) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,21 +39,21 @@ public class PlayerActivityData {
|
||||
String detail;
|
||||
@Transient Player player;
|
||||
@Transient ActivityHandler activityHandler;
|
||||
public void save(){
|
||||
public void save() {
|
||||
DatabaseHelper.savePlayerActivityData(this);
|
||||
}
|
||||
|
||||
public static PlayerActivityData getByPlayer(Player player, int activityId){
|
||||
public static PlayerActivityData getByPlayer(Player player, int activityId) {
|
||||
return DatabaseHelper.getPlayerActivityData(player.getUid(), activityId);
|
||||
}
|
||||
|
||||
public synchronized void addWatcherProgress(int watcherId){
|
||||
public synchronized void addWatcherProgress(int watcherId) {
|
||||
var watcherInfo = watcherInfoMap.get(watcherId);
|
||||
if(watcherInfo == null){
|
||||
if (watcherInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(watcherInfo.curProgress >= watcherInfo.totalProgress){
|
||||
if (watcherInfo.curProgress >= watcherInfo.totalProgress) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -67,13 +67,13 @@ public class PlayerActivityData {
|
||||
.toList();
|
||||
}
|
||||
|
||||
public void setDetail(Object detail){
|
||||
public void setDetail(Object detail) {
|
||||
this.detail = JsonUtils.encode(detail);
|
||||
}
|
||||
|
||||
public void takeWatcherReward(int watcherId) {
|
||||
var watcher = watcherInfoMap.get(watcherId);
|
||||
if(watcher == null || watcher.isTakenReward()){
|
||||
if (watcher == null || watcher.isTakenReward()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class PlayerActivityData {
|
||||
.map(ActivityWatcherData::getRewardID)
|
||||
.map(id -> GameData.getRewardDataMap().get(id.intValue()));
|
||||
|
||||
if(reward.isEmpty()){
|
||||
if (reward.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -106,11 +106,11 @@ public class PlayerActivityData {
|
||||
int curProgress;
|
||||
boolean isTakenReward;
|
||||
|
||||
public ActivityWatcherData getMetadata(){
|
||||
public ActivityWatcherData getMetadata() {
|
||||
return GameData.getActivityWatcherDataMap().get(watcherId);
|
||||
}
|
||||
|
||||
public static WatcherInfo init(ActivityWatcher watcher){
|
||||
public static WatcherInfo init(ActivityWatcher watcher) {
|
||||
return WatcherInfo.of()
|
||||
.watcherId(watcher.getWatcherId())
|
||||
.totalProgress(watcher.getActivityWatcherData().getProgress())
|
||||
@@ -118,7 +118,7 @@ public class PlayerActivityData {
|
||||
.build();
|
||||
}
|
||||
|
||||
public ActivityWatcherInfoOuterClass.ActivityWatcherInfo toProto(){
|
||||
public ActivityWatcherInfoOuterClass.ActivityWatcherInfo toProto() {
|
||||
return ActivityWatcherInfoOuterClass.ActivityWatcherInfo.newBuilder()
|
||||
.setWatcherId(watcherId)
|
||||
.setCurProgress(curProgress)
|
||||
|
||||
@@ -681,7 +681,7 @@ public class Avatar {
|
||||
}
|
||||
|
||||
private boolean calcConstellationExtraLevels(OpenConfigEntry entry) {
|
||||
int skillId = switch(entry.getExtraTalentIndex()) {
|
||||
int skillId = switch (entry.getExtraTalentIndex()) {
|
||||
case 9 -> this.skillDepot.getEnergySkill(); // Ult skill
|
||||
case 2 -> (this.skillDepot.getSkills().size() >= 2) ? this.skillDepot.getSkills().get(1) : 0; // E skill
|
||||
default -> 0;
|
||||
|
||||
@@ -41,28 +41,28 @@ import it.unimi.dsi.fastutil.ints.Int2FloatMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
|
||||
|
||||
public class EntityAvatar extends GameEntity {
|
||||
private final Avatar avatar;
|
||||
private final Avatar avatar;
|
||||
|
||||
private PlayerDieType killedType;
|
||||
private int killedBy;
|
||||
private PlayerDieType killedType;
|
||||
private int killedBy;
|
||||
|
||||
public EntityAvatar(Scene scene, Avatar avatar) {
|
||||
super(scene);
|
||||
this.avatar = avatar;
|
||||
this.avatar.setCurrentEnergy();
|
||||
this.id = getScene().getWorld().getNextEntityId(EntityIdType.AVATAR);
|
||||
public EntityAvatar(Scene scene, Avatar avatar) {
|
||||
super(scene);
|
||||
this.avatar = avatar;
|
||||
this.avatar.setCurrentEnergy();
|
||||
this.id = getScene().getWorld().getNextEntityId(EntityIdType.AVATAR);
|
||||
|
||||
GameItem weapon = this.getAvatar().getWeapon();
|
||||
if (weapon != null) {
|
||||
weapon.setWeaponEntityId(getScene().getWorld().getNextEntityId(EntityIdType.WEAPON));
|
||||
}
|
||||
}
|
||||
GameItem weapon = this.getAvatar().getWeapon();
|
||||
if (weapon != null) {
|
||||
weapon.setWeaponEntityId(getScene().getWorld().getNextEntityId(EntityIdType.WEAPON));
|
||||
}
|
||||
}
|
||||
|
||||
public EntityAvatar(Avatar avatar) {
|
||||
super(null);
|
||||
this.avatar = avatar;
|
||||
this.avatar.setCurrentEnergy();
|
||||
}
|
||||
public EntityAvatar(Avatar avatar) {
|
||||
super(null);
|
||||
this.avatar = avatar;
|
||||
this.avatar.setCurrentEnergy();
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return avatar.getPlayer();
|
||||
@@ -71,41 +71,41 @@ public class EntityAvatar extends GameEntity {
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return getPlayer().getPosition();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getRotation() {
|
||||
return getPlayer().getRotation();
|
||||
}
|
||||
@Override
|
||||
public Position getRotation() {
|
||||
return getPlayer().getRotation();
|
||||
}
|
||||
|
||||
public Avatar getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
public Avatar getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public int getKilledBy() {
|
||||
return killedBy;
|
||||
}
|
||||
public int getKilledBy() {
|
||||
return killedBy;
|
||||
}
|
||||
|
||||
public PlayerDieType getKilledType() {
|
||||
return killedType;
|
||||
}
|
||||
public PlayerDieType getKilledType() {
|
||||
return killedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
return this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) > 0f;
|
||||
}
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
return this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) > 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Int2FloatOpenHashMap getFightProperties() {
|
||||
return getAvatar().getFightProperties();
|
||||
}
|
||||
@Override
|
||||
public Int2FloatOpenHashMap getFightProperties() {
|
||||
return getAvatar().getFightProperties();
|
||||
}
|
||||
|
||||
public int getWeaponEntityId() {
|
||||
if (getAvatar().getWeapon() != null) {
|
||||
return getAvatar().getWeapon().getWeaponEntityId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public int getWeaponEntityId() {
|
||||
if (getAvatar().getWeapon() != null) {
|
||||
return getAvatar().getWeapon().getWeaponEntityId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(int killerId) {
|
||||
@@ -116,31 +116,31 @@ public class EntityAvatar extends GameEntity {
|
||||
clearEnergy(ChangeEnergyReason.CHANGE_ENERGY_REASON_NONE);
|
||||
}
|
||||
|
||||
public void onDeath(PlayerDieType dieType, int killerId) {
|
||||
public void onDeath(PlayerDieType dieType, int killerId) {
|
||||
super.onDeath(killerId); // Invoke super class's onDeath() method.
|
||||
|
||||
this.killedType = dieType;
|
||||
this.killedBy = killerId;
|
||||
clearEnergy(ChangeEnergyReason.CHANGE_ENERGY_REASON_NONE);
|
||||
}
|
||||
this.killedType = dieType;
|
||||
this.killedBy = killerId;
|
||||
clearEnergy(ChangeEnergyReason.CHANGE_ENERGY_REASON_NONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float heal(float amount) {
|
||||
float healed = super.heal(amount);
|
||||
@Override
|
||||
public float heal(float amount) {
|
||||
float healed = super.heal(amount);
|
||||
|
||||
if (healed > 0f) {
|
||||
getScene().broadcastPacket(
|
||||
if (healed > 0f) {
|
||||
getScene().broadcastPacket(
|
||||
new PacketEntityFightPropChangeReasonNotify(this, FightProperty.FIGHT_PROP_CUR_HP, healed, PropChangeReason.PROP_CHANGE_REASON_ABILITY, ChangeHpReason.CHANGE_HP_REASON_ADD_ABILITY)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return healed;
|
||||
}
|
||||
return healed;
|
||||
}
|
||||
|
||||
public void clearEnergy(ChangeEnergyReason reason) {
|
||||
// Fight props.
|
||||
FightProperty curEnergyProp = this.getAvatar().getSkillDepot().getElementType().getCurEnergyProp();
|
||||
FightProperty maxEnergyProp = this.getAvatar().getSkillDepot().getElementType().getMaxEnergyProp();
|
||||
public void clearEnergy(ChangeEnergyReason reason) {
|
||||
// Fight props.
|
||||
FightProperty curEnergyProp = this.getAvatar().getSkillDepot().getElementType().getCurEnergyProp();
|
||||
FightProperty maxEnergyProp = this.getAvatar().getSkillDepot().getElementType().getMaxEnergyProp();
|
||||
|
||||
// Get max energy.
|
||||
float maxEnergy = this.avatar.getFightProperty(maxEnergyProp);
|
||||
@@ -151,174 +151,174 @@ public class EntityAvatar extends GameEntity {
|
||||
// Send packets.
|
||||
this.getScene().broadcastPacket(new PacketEntityFightPropUpdateNotify(this, curEnergyProp));
|
||||
|
||||
if (reason == ChangeEnergyReason.CHANGE_ENERGY_REASON_SKILL_START) {
|
||||
this.getScene().broadcastPacket(new PacketEntityFightPropChangeReasonNotify(this, curEnergyProp, -maxEnergy, reason));
|
||||
}
|
||||
}
|
||||
if (reason == ChangeEnergyReason.CHANGE_ENERGY_REASON_SKILL_START) {
|
||||
this.getScene().broadcastPacket(new PacketEntityFightPropChangeReasonNotify(this, curEnergyProp, -maxEnergy, reason));
|
||||
}
|
||||
}
|
||||
|
||||
public void addEnergy(float amount, PropChangeReason reason) {
|
||||
this.addEnergy(amount, reason, false);
|
||||
}
|
||||
public void addEnergy(float amount, PropChangeReason reason, boolean isFlat) {
|
||||
// Get current and maximum energy for this avatar.
|
||||
FightProperty curEnergyProp = this.getAvatar().getSkillDepot().getElementType().getCurEnergyProp();
|
||||
FightProperty maxEnergyProp = this.getAvatar().getSkillDepot().getElementType().getMaxEnergyProp();
|
||||
public void addEnergy(float amount, PropChangeReason reason) {
|
||||
this.addEnergy(amount, reason, false);
|
||||
}
|
||||
public void addEnergy(float amount, PropChangeReason reason, boolean isFlat) {
|
||||
// Get current and maximum energy for this avatar.
|
||||
FightProperty curEnergyProp = this.getAvatar().getSkillDepot().getElementType().getCurEnergyProp();
|
||||
FightProperty maxEnergyProp = this.getAvatar().getSkillDepot().getElementType().getMaxEnergyProp();
|
||||
|
||||
float curEnergy = this.getFightProperty(curEnergyProp);
|
||||
float maxEnergy = this.getFightProperty(maxEnergyProp);
|
||||
float curEnergy = this.getFightProperty(curEnergyProp);
|
||||
float maxEnergy = this.getFightProperty(maxEnergyProp);
|
||||
|
||||
// Get energy recharge.
|
||||
float energyRecharge = this.getFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY);
|
||||
// Get energy recharge.
|
||||
float energyRecharge = this.getFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY);
|
||||
|
||||
// Scale amount by energy recharge, if the amount is not flat.
|
||||
if (!isFlat) {
|
||||
amount *= energyRecharge;
|
||||
}
|
||||
|
||||
// Determine the new energy value.
|
||||
float newEnergy = Math.min(curEnergy + amount, maxEnergy);
|
||||
// Determine the new energy value.
|
||||
float newEnergy = Math.min(curEnergy + amount, maxEnergy);
|
||||
|
||||
// Set energy and notify.
|
||||
if (newEnergy != curEnergy) {
|
||||
this.avatar.setCurrentEnergy(curEnergyProp, newEnergy);
|
||||
// Set energy and notify.
|
||||
if (newEnergy != curEnergy) {
|
||||
this.avatar.setCurrentEnergy(curEnergyProp, newEnergy);
|
||||
|
||||
this.getScene().broadcastPacket(new PacketAvatarFightPropUpdateNotify(this.getAvatar(), curEnergyProp));
|
||||
this.getScene().broadcastPacket(new PacketEntityFightPropChangeReasonNotify(this, curEnergyProp, newEnergy, reason));
|
||||
}
|
||||
}
|
||||
this.getScene().broadcastPacket(new PacketAvatarFightPropUpdateNotify(this.getAvatar(), curEnergyProp));
|
||||
this.getScene().broadcastPacket(new PacketEntityFightPropChangeReasonNotify(this, curEnergyProp, newEnergy, reason));
|
||||
}
|
||||
}
|
||||
|
||||
public SceneAvatarInfo getSceneAvatarInfo() {
|
||||
SceneAvatarInfo.Builder avatarInfo = SceneAvatarInfo.newBuilder()
|
||||
.setUid(this.getPlayer().getUid())
|
||||
.setAvatarId(this.getAvatar().getAvatarId())
|
||||
.setGuid(this.getAvatar().getGuid())
|
||||
.setPeerId(this.getPlayer().getPeerId())
|
||||
.addAllTalentIdList(this.getAvatar().getTalentIdList())
|
||||
.setCoreProudSkillLevel(this.getAvatar().getCoreProudSkillLevel())
|
||||
.putAllSkillLevelMap(this.getAvatar().getSkillLevelMap())
|
||||
.setSkillDepotId(this.getAvatar().getSkillDepotId())
|
||||
.addAllInherentProudSkillList(this.getAvatar().getProudSkillList())
|
||||
.putAllProudSkillExtraLevelMap(this.getAvatar().getProudSkillBonusMap())
|
||||
.addAllTeamResonanceList(this.getAvatar().getPlayer().getTeamManager().getTeamResonances())
|
||||
.setWearingFlycloakId(this.getAvatar().getFlyCloak())
|
||||
.setCostumeId(this.getAvatar().getCostume())
|
||||
.setBornTime(this.getAvatar().getBornTime());
|
||||
public SceneAvatarInfo getSceneAvatarInfo() {
|
||||
SceneAvatarInfo.Builder avatarInfo = SceneAvatarInfo.newBuilder()
|
||||
.setUid(this.getPlayer().getUid())
|
||||
.setAvatarId(this.getAvatar().getAvatarId())
|
||||
.setGuid(this.getAvatar().getGuid())
|
||||
.setPeerId(this.getPlayer().getPeerId())
|
||||
.addAllTalentIdList(this.getAvatar().getTalentIdList())
|
||||
.setCoreProudSkillLevel(this.getAvatar().getCoreProudSkillLevel())
|
||||
.putAllSkillLevelMap(this.getAvatar().getSkillLevelMap())
|
||||
.setSkillDepotId(this.getAvatar().getSkillDepotId())
|
||||
.addAllInherentProudSkillList(this.getAvatar().getProudSkillList())
|
||||
.putAllProudSkillExtraLevelMap(this.getAvatar().getProudSkillBonusMap())
|
||||
.addAllTeamResonanceList(this.getAvatar().getPlayer().getTeamManager().getTeamResonances())
|
||||
.setWearingFlycloakId(this.getAvatar().getFlyCloak())
|
||||
.setCostumeId(this.getAvatar().getCostume())
|
||||
.setBornTime(this.getAvatar().getBornTime());
|
||||
|
||||
for (GameItem item : avatar.getEquips().values()) {
|
||||
if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) {
|
||||
avatarInfo.setWeapon(item.createSceneWeaponInfo());
|
||||
} else {
|
||||
avatarInfo.addReliquaryList(item.createSceneReliquaryInfo());
|
||||
}
|
||||
avatarInfo.addEquipIdList(item.getItemId());
|
||||
}
|
||||
for (GameItem item : avatar.getEquips().values()) {
|
||||
if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) {
|
||||
avatarInfo.setWeapon(item.createSceneWeaponInfo());
|
||||
} else {
|
||||
avatarInfo.addReliquaryList(item.createSceneReliquaryInfo());
|
||||
}
|
||||
avatarInfo.addEquipIdList(item.getItemId());
|
||||
}
|
||||
|
||||
return avatarInfo.build();
|
||||
}
|
||||
return avatarInfo.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SceneEntityInfo toProto() {
|
||||
EntityAuthorityInfo authority = EntityAuthorityInfo.newBuilder()
|
||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder())
|
||||
.setRendererChangedInfo(EntityRendererChangedInfo.newBuilder())
|
||||
.setAiInfo(SceneEntityAiInfo.newBuilder().setIsAiOpen(true).setBornPos(Vector.newBuilder()))
|
||||
.setBornPos(Vector.newBuilder())
|
||||
.build();
|
||||
@Override
|
||||
public SceneEntityInfo toProto() {
|
||||
EntityAuthorityInfo authority = EntityAuthorityInfo.newBuilder()
|
||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder())
|
||||
.setRendererChangedInfo(EntityRendererChangedInfo.newBuilder())
|
||||
.setAiInfo(SceneEntityAiInfo.newBuilder().setIsAiOpen(true).setBornPos(Vector.newBuilder()))
|
||||
.setBornPos(Vector.newBuilder())
|
||||
.build();
|
||||
|
||||
SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder()
|
||||
.setEntityId(getId())
|
||||
.setEntityType(ProtEntityType.PROT_ENTITY_TYPE_AVATAR)
|
||||
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
|
||||
.setEntityClientData(EntityClientData.newBuilder())
|
||||
.setEntityAuthorityInfo(authority)
|
||||
.setLastMoveSceneTimeMs(this.getLastMoveSceneTimeMs())
|
||||
.setLastMoveReliableSeq(this.getLastMoveReliableSeq())
|
||||
.setLifeState(this.getLifeState().getValue());
|
||||
SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder()
|
||||
.setEntityId(getId())
|
||||
.setEntityType(ProtEntityType.PROT_ENTITY_TYPE_AVATAR)
|
||||
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
|
||||
.setEntityClientData(EntityClientData.newBuilder())
|
||||
.setEntityAuthorityInfo(authority)
|
||||
.setLastMoveSceneTimeMs(this.getLastMoveSceneTimeMs())
|
||||
.setLastMoveReliableSeq(this.getLastMoveReliableSeq())
|
||||
.setLifeState(this.getLifeState().getValue());
|
||||
|
||||
if (this.getScene() != null) {
|
||||
entityInfo.setMotionInfo(this.getMotionInfo());
|
||||
}
|
||||
if (this.getScene() != null) {
|
||||
entityInfo.setMotionInfo(this.getMotionInfo());
|
||||
}
|
||||
|
||||
for (Int2FloatMap.Entry entry : getFightProperties().int2FloatEntrySet()) {
|
||||
if (entry.getIntKey() == 0) {
|
||||
continue;
|
||||
}
|
||||
FightPropPair fightProp = FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build();
|
||||
entityInfo.addFightPropList(fightProp);
|
||||
}
|
||||
for (Int2FloatMap.Entry entry : getFightProperties().int2FloatEntrySet()) {
|
||||
if (entry.getIntKey() == 0) {
|
||||
continue;
|
||||
}
|
||||
FightPropPair fightProp = FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build();
|
||||
entityInfo.addFightPropList(fightProp);
|
||||
}
|
||||
|
||||
PropPair pair = PropPair.newBuilder()
|
||||
.setType(PlayerProperty.PROP_LEVEL.getId())
|
||||
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, getAvatar().getLevel()))
|
||||
.build();
|
||||
entityInfo.addPropList(pair);
|
||||
PropPair pair = PropPair.newBuilder()
|
||||
.setType(PlayerProperty.PROP_LEVEL.getId())
|
||||
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, getAvatar().getLevel()))
|
||||
.build();
|
||||
entityInfo.addPropList(pair);
|
||||
|
||||
entityInfo.setAvatar(this.getSceneAvatarInfo());
|
||||
entityInfo.setAvatar(this.getSceneAvatarInfo());
|
||||
|
||||
return entityInfo.build();
|
||||
}
|
||||
return entityInfo.build();
|
||||
}
|
||||
|
||||
public AbilityControlBlock getAbilityControlBlock() {
|
||||
AvatarData data = this.getAvatar().getAvatarData();
|
||||
AbilityControlBlock.Builder abilityControlBlock = AbilityControlBlock.newBuilder();
|
||||
int embryoId = 0;
|
||||
public AbilityControlBlock getAbilityControlBlock() {
|
||||
AvatarData data = this.getAvatar().getAvatarData();
|
||||
AbilityControlBlock.Builder abilityControlBlock = AbilityControlBlock.newBuilder();
|
||||
int embryoId = 0;
|
||||
|
||||
// Add avatar abilities
|
||||
if (data.getAbilities() != null) {
|
||||
for (int id : data.getAbilities()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
}
|
||||
// Add default abilities
|
||||
for (int id : GameConstants.DEFAULT_ABILITY_HASHES) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
// Add team resonances
|
||||
for (int id : this.getPlayer().getTeamManager().getTeamResonancesConfig()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
// Add skill depot abilities
|
||||
AvatarSkillDepotData skillDepot = GameData.getAvatarSkillDepotDataMap().get(this.getAvatar().getSkillDepotId());
|
||||
if (skillDepot != null && skillDepot.getAbilities() != null) {
|
||||
for (int id : skillDepot.getAbilities()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
}
|
||||
// Add equip abilities
|
||||
if (this.getAvatar().getExtraAbilityEmbryos().size() > 0) {
|
||||
for (String skill : this.getAvatar().getExtraAbilityEmbryos()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(Utils.abilityHash(skill))
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
}
|
||||
// Add avatar abilities
|
||||
if (data.getAbilities() != null) {
|
||||
for (int id : data.getAbilities()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
}
|
||||
// Add default abilities
|
||||
for (int id : GameConstants.DEFAULT_ABILITY_HASHES) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
// Add team resonances
|
||||
for (int id : this.getPlayer().getTeamManager().getTeamResonancesConfig()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
// Add skill depot abilities
|
||||
AvatarSkillDepotData skillDepot = GameData.getAvatarSkillDepotDataMap().get(this.getAvatar().getSkillDepotId());
|
||||
if (skillDepot != null && skillDepot.getAbilities() != null) {
|
||||
for (int id : skillDepot.getAbilities()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
}
|
||||
// Add equip abilities
|
||||
if (this.getAvatar().getExtraAbilityEmbryos().size() > 0) {
|
||||
for (String skill : this.getAvatar().getExtraAbilityEmbryos()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(Utils.abilityHash(skill))
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return abilityControlBlock.build();
|
||||
}
|
||||
//
|
||||
return abilityControlBlock.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move this entity to a new position.
|
||||
|
||||
@@ -5,14 +5,14 @@ import emu.grasscutter.game.world.World;
|
||||
|
||||
public abstract class EntityBaseGadget extends GameEntity {
|
||||
|
||||
public EntityBaseGadget(Scene scene) {
|
||||
super(scene);
|
||||
}
|
||||
public EntityBaseGadget(Scene scene) {
|
||||
super(scene);
|
||||
}
|
||||
|
||||
public abstract int getGadgetId();
|
||||
public abstract int getGadgetId();
|
||||
|
||||
@Override
|
||||
public void onDeath(int killerId) {
|
||||
@Override
|
||||
public void onDeath(int killerId) {
|
||||
super.onDeath(killerId); // Invoke super class's onDeath() method.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,140 +22,140 @@ import emu.grasscutter.utils.ProtoHelper;
|
||||
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
|
||||
|
||||
public class EntityClientGadget extends EntityBaseGadget {
|
||||
private final Player owner;
|
||||
private final Player owner;
|
||||
|
||||
private final Position pos;
|
||||
private final Position rot;
|
||||
private final Position pos;
|
||||
private final Position rot;
|
||||
|
||||
private int configId;
|
||||
private int campId;
|
||||
private int campType;
|
||||
private int ownerEntityId;
|
||||
private int targetEntityId;
|
||||
private boolean asyncLoad;
|
||||
private int configId;
|
||||
private int campId;
|
||||
private int campType;
|
||||
private int ownerEntityId;
|
||||
private int targetEntityId;
|
||||
private boolean asyncLoad;
|
||||
|
||||
private int originalOwnerEntityId;
|
||||
private int originalOwnerEntityId;
|
||||
|
||||
public EntityClientGadget(Scene scene, Player player, EvtCreateGadgetNotify notify) {
|
||||
super(scene);
|
||||
this.owner = player;
|
||||
this.id = notify.getEntityId();
|
||||
this.pos = new Position(notify.getInitPos());
|
||||
this.rot = new Position(notify.getInitEulerAngles());
|
||||
this.configId = notify.getConfigId();
|
||||
this.campId = notify.getCampId();
|
||||
this.campType = notify.getCampType();
|
||||
this.ownerEntityId = notify.getPropOwnerEntityId();
|
||||
this.targetEntityId = notify.getTargetEntityId();
|
||||
this.asyncLoad = notify.getIsAsyncLoad();
|
||||
public EntityClientGadget(Scene scene, Player player, EvtCreateGadgetNotify notify) {
|
||||
super(scene);
|
||||
this.owner = player;
|
||||
this.id = notify.getEntityId();
|
||||
this.pos = new Position(notify.getInitPos());
|
||||
this.rot = new Position(notify.getInitEulerAngles());
|
||||
this.configId = notify.getConfigId();
|
||||
this.campId = notify.getCampId();
|
||||
this.campType = notify.getCampType();
|
||||
this.ownerEntityId = notify.getPropOwnerEntityId();
|
||||
this.targetEntityId = notify.getTargetEntityId();
|
||||
this.asyncLoad = notify.getIsAsyncLoad();
|
||||
|
||||
GameEntity owner = scene.getEntityById(this.ownerEntityId);
|
||||
if (owner instanceof EntityClientGadget ownerGadget) {
|
||||
this.originalOwnerEntityId = ownerGadget.getOriginalOwnerEntityId();
|
||||
}
|
||||
else {
|
||||
this.originalOwnerEntityId = this.ownerEntityId;
|
||||
}
|
||||
}
|
||||
GameEntity owner = scene.getEntityById(this.ownerEntityId);
|
||||
if (owner instanceof EntityClientGadget ownerGadget) {
|
||||
this.originalOwnerEntityId = ownerGadget.getOriginalOwnerEntityId();
|
||||
}
|
||||
else {
|
||||
this.originalOwnerEntityId = this.ownerEntityId;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGadgetId() {
|
||||
return configId;
|
||||
}
|
||||
@Override
|
||||
public int getGadgetId() {
|
||||
return configId;
|
||||
}
|
||||
|
||||
public Player getOwner() {
|
||||
return owner;
|
||||
}
|
||||
public Player getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public int getCampId() {
|
||||
return campId;
|
||||
}
|
||||
public int getCampId() {
|
||||
return campId;
|
||||
}
|
||||
|
||||
public int getCampType() {
|
||||
return campType;
|
||||
}
|
||||
public int getCampType() {
|
||||
return campType;
|
||||
}
|
||||
|
||||
public int getOwnerEntityId() {
|
||||
return ownerEntityId;
|
||||
}
|
||||
public int getOwnerEntityId() {
|
||||
return ownerEntityId;
|
||||
}
|
||||
|
||||
public int getTargetEntityId() {
|
||||
return targetEntityId;
|
||||
}
|
||||
public int getTargetEntityId() {
|
||||
return targetEntityId;
|
||||
}
|
||||
|
||||
public boolean isAsyncLoad() {
|
||||
return this.asyncLoad;
|
||||
}
|
||||
public boolean isAsyncLoad() {
|
||||
return this.asyncLoad;
|
||||
}
|
||||
|
||||
public int getOriginalOwnerEntityId() {
|
||||
return this.originalOwnerEntityId;
|
||||
}
|
||||
public int getOriginalOwnerEntityId() {
|
||||
return this.originalOwnerEntityId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(int killerId) {
|
||||
@Override
|
||||
public void onDeath(int killerId) {
|
||||
super.onDeath(killerId); // Invoke super class's onDeath() method.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Int2FloatOpenHashMap getFightProperties() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Int2FloatOpenHashMap getFightProperties() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.pos;
|
||||
}
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getRotation() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.rot;
|
||||
}
|
||||
@Override
|
||||
public Position getRotation() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.rot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SceneEntityInfo toProto() {
|
||||
EntityAuthorityInfo authority = EntityAuthorityInfo.newBuilder()
|
||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder())
|
||||
.setRendererChangedInfo(EntityRendererChangedInfo.newBuilder())
|
||||
.setAiInfo(SceneEntityAiInfo.newBuilder().setIsAiOpen(true).setBornPos(Vector.newBuilder()))
|
||||
.setBornPos(Vector.newBuilder())
|
||||
.build();
|
||||
@Override
|
||||
public SceneEntityInfo toProto() {
|
||||
EntityAuthorityInfo authority = EntityAuthorityInfo.newBuilder()
|
||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder())
|
||||
.setRendererChangedInfo(EntityRendererChangedInfo.newBuilder())
|
||||
.setAiInfo(SceneEntityAiInfo.newBuilder().setIsAiOpen(true).setBornPos(Vector.newBuilder()))
|
||||
.setBornPos(Vector.newBuilder())
|
||||
.build();
|
||||
|
||||
SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder()
|
||||
.setEntityId(getId())
|
||||
.setEntityType(ProtEntityType.PROT_ENTITY_TYPE_GADGET)
|
||||
.setMotionInfo(MotionInfo.newBuilder().setPos(getPosition().toProto()).setRot(getRotation().toProto()).setSpeed(Vector.newBuilder()))
|
||||
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
|
||||
.setEntityClientData(EntityClientData.newBuilder())
|
||||
.setEntityAuthorityInfo(authority)
|
||||
.setLifeState(1);
|
||||
SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder()
|
||||
.setEntityId(getId())
|
||||
.setEntityType(ProtEntityType.PROT_ENTITY_TYPE_GADGET)
|
||||
.setMotionInfo(MotionInfo.newBuilder().setPos(getPosition().toProto()).setRot(getRotation().toProto()).setSpeed(Vector.newBuilder()))
|
||||
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
|
||||
.setEntityClientData(EntityClientData.newBuilder())
|
||||
.setEntityAuthorityInfo(authority)
|
||||
.setLifeState(1);
|
||||
|
||||
PropPair pair = PropPair.newBuilder()
|
||||
.setType(PlayerProperty.PROP_LEVEL.getId())
|
||||
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, 1))
|
||||
.build();
|
||||
entityInfo.addPropList(pair);
|
||||
PropPair pair = PropPair.newBuilder()
|
||||
.setType(PlayerProperty.PROP_LEVEL.getId())
|
||||
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, 1))
|
||||
.build();
|
||||
entityInfo.addPropList(pair);
|
||||
|
||||
ClientGadgetInfoOuterClass.ClientGadgetInfo clientGadget = ClientGadgetInfoOuterClass.ClientGadgetInfo.newBuilder()
|
||||
.setCampId(this.getCampId())
|
||||
.setCampType(this.getCampType())
|
||||
.setOwnerEntityId(this.getOwnerEntityId())
|
||||
.setTargetEntityId(this.getTargetEntityId())
|
||||
.setAsyncLoad(this.isAsyncLoad())
|
||||
.build();
|
||||
ClientGadgetInfoOuterClass.ClientGadgetInfo clientGadget = ClientGadgetInfoOuterClass.ClientGadgetInfo.newBuilder()
|
||||
.setCampId(this.getCampId())
|
||||
.setCampType(this.getCampType())
|
||||
.setOwnerEntityId(this.getOwnerEntityId())
|
||||
.setTargetEntityId(this.getTargetEntityId())
|
||||
.setAsyncLoad(this.isAsyncLoad())
|
||||
.build();
|
||||
|
||||
SceneGadgetInfo.Builder gadgetInfo = SceneGadgetInfo.newBuilder()
|
||||
.setGadgetId(this.getGadgetId())
|
||||
.setOwnerEntityId(this.getOwnerEntityId())
|
||||
.setIsEnableInteract(true)
|
||||
.setClientGadget(clientGadget)
|
||||
.setPropOwnerEntityId(this.getOwnerEntityId())
|
||||
.setAuthorityPeerId(this.getOwner().getPeerId());
|
||||
SceneGadgetInfo.Builder gadgetInfo = SceneGadgetInfo.newBuilder()
|
||||
.setGadgetId(this.getGadgetId())
|
||||
.setOwnerEntityId(this.getOwnerEntityId())
|
||||
.setIsEnableInteract(true)
|
||||
.setClientGadget(clientGadget)
|
||||
.setPropOwnerEntityId(this.getOwnerEntityId())
|
||||
.setAuthorityPeerId(this.getOwner().getPeerId());
|
||||
|
||||
entityInfo.setGadget(gadgetInfo);
|
||||
entityInfo.setGadget(gadgetInfo);
|
||||
|
||||
return entityInfo.build();
|
||||
}
|
||||
return entityInfo.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ public class EntityGadget extends EntityBaseGadget {
|
||||
.setIsEnableInteract(true)
|
||||
.setAuthorityPeerId(this.getScene().getWorld().getHostPeerId());
|
||||
|
||||
if(this.metaGadget != null) {
|
||||
if (this.metaGadget != null) {
|
||||
gadgetInfo.setDraftId(this.metaGadget.draft_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,64 +25,64 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public abstract class GameEntity {
|
||||
protected int id;
|
||||
private final Scene scene;
|
||||
private SpawnDataEntry spawnEntry;
|
||||
protected int id;
|
||||
private final Scene scene;
|
||||
private SpawnDataEntry spawnEntry;
|
||||
|
||||
private int blockId;
|
||||
private int configId;
|
||||
private int groupId;
|
||||
private int blockId;
|
||||
private int configId;
|
||||
private int groupId;
|
||||
|
||||
private MotionState moveState;
|
||||
private int lastMoveSceneTimeMs;
|
||||
private int lastMoveReliableSeq;
|
||||
private MotionState moveState;
|
||||
private int lastMoveSceneTimeMs;
|
||||
private int lastMoveReliableSeq;
|
||||
|
||||
// Abilities
|
||||
private Map<String, Float> metaOverrideMap;
|
||||
private Int2ObjectMap<String> metaModifiers;
|
||||
// Abilities
|
||||
private Map<String, Float> metaOverrideMap;
|
||||
private Int2ObjectMap<String> metaModifiers;
|
||||
|
||||
public GameEntity(Scene scene) {
|
||||
this.scene = scene;
|
||||
this.moveState = MotionState.MOTION_STATE_NONE;
|
||||
}
|
||||
public GameEntity(Scene scene) {
|
||||
this.scene = scene;
|
||||
this.moveState = MotionState.MOTION_STATE_NONE;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int getEntityType() {
|
||||
return this.getId() >> 24;
|
||||
}
|
||||
public int getEntityType() {
|
||||
return this.getId() >> 24;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return this.getScene().getWorld();
|
||||
}
|
||||
public World getWorld() {
|
||||
return this.getScene().getWorld();
|
||||
}
|
||||
|
||||
public Scene getScene() {
|
||||
return this.scene;
|
||||
}
|
||||
public Scene getScene() {
|
||||
return this.scene;
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return true;
|
||||
}
|
||||
public boolean isAlive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public LifeState getLifeState() {
|
||||
return this.isAlive() ? LifeState.LIFE_ALIVE : LifeState.LIFE_DEAD;
|
||||
}
|
||||
public LifeState getLifeState() {
|
||||
return this.isAlive() ? LifeState.LIFE_ALIVE : LifeState.LIFE_DEAD;
|
||||
}
|
||||
|
||||
public Map<String, Float> getMetaOverrideMap() {
|
||||
if (this.metaOverrideMap == null) {
|
||||
this.metaOverrideMap = new HashMap<>();
|
||||
}
|
||||
return this.metaOverrideMap;
|
||||
}
|
||||
public Map<String, Float> getMetaOverrideMap() {
|
||||
if (this.metaOverrideMap == null) {
|
||||
this.metaOverrideMap = new HashMap<>();
|
||||
}
|
||||
return this.metaOverrideMap;
|
||||
}
|
||||
|
||||
public Int2ObjectMap<String> getMetaModifiers() {
|
||||
if (this.metaModifiers == null) {
|
||||
this.metaModifiers = new Int2ObjectOpenHashMap<>();
|
||||
}
|
||||
return this.metaModifiers;
|
||||
}
|
||||
public Int2ObjectMap<String> getMetaModifiers() {
|
||||
if (this.metaModifiers == null) {
|
||||
this.metaModifiers = new Int2ObjectOpenHashMap<>();
|
||||
}
|
||||
return this.metaModifiers;
|
||||
}
|
||||
|
||||
public abstract Int2FloatOpenHashMap getFightProperties();
|
||||
|
||||
@@ -215,12 +215,12 @@ public abstract class GameEntity {
|
||||
|
||||
// Invoke entity damage event.
|
||||
EntityDamageEvent event = new EntityDamageEvent(this, amount, this.getScene().getEntityById(killerId));
|
||||
event.call();
|
||||
event.call();
|
||||
if (event.isCanceled()) {
|
||||
return; // If the event is canceled, do not damage the entity.
|
||||
}
|
||||
|
||||
if(getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) != Float.POSITIVE_INFINITY){
|
||||
|
||||
if (getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) != Float.POSITIVE_INFINITY) {
|
||||
// Add negative HP to the current HP property.
|
||||
this.addFightProperty(FightProperty.FIGHT_PROP_CUR_HP, -(event.getDamage()));
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ public class GadgetChest extends GadgetContent {
|
||||
return false;
|
||||
}else {
|
||||
boolean success;
|
||||
if(handler instanceof BossChestInteractHandler bossChestInteractHandler){
|
||||
if (handler instanceof BossChestInteractHandler bossChestInteractHandler) {
|
||||
success = bossChestInteractHandler.onInteract(this, player,
|
||||
req.getResinCostType()== ResinCostTypeOuterClass.ResinCostType.RESIN_COST_TYPE_CONDENSE);
|
||||
}else{
|
||||
}else {
|
||||
success = handler.onInteract(this, player);
|
||||
}
|
||||
if (!success) {
|
||||
|
||||
@@ -13,46 +13,46 @@ import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
|
||||
public class GadgetWorktop extends GadgetContent {
|
||||
private IntSet worktopOptions;
|
||||
private IntSet worktopOptions;
|
||||
private WorktopWorktopOptionHandler handler;
|
||||
|
||||
public GadgetWorktop(EntityGadget gadget) {
|
||||
super(gadget);
|
||||
}
|
||||
public GadgetWorktop(EntityGadget gadget) {
|
||||
super(gadget);
|
||||
}
|
||||
|
||||
public IntSet getWorktopOptions() {
|
||||
return worktopOptions;
|
||||
}
|
||||
public IntSet getWorktopOptions() {
|
||||
return worktopOptions;
|
||||
}
|
||||
|
||||
public void addWorktopOptions(int[] options) {
|
||||
if (this.worktopOptions == null) {
|
||||
this.worktopOptions = new IntOpenHashSet();
|
||||
}
|
||||
Arrays.stream(options).forEach(this.worktopOptions::add);
|
||||
}
|
||||
public void addWorktopOptions(int[] options) {
|
||||
if (this.worktopOptions == null) {
|
||||
this.worktopOptions = new IntOpenHashSet();
|
||||
}
|
||||
Arrays.stream(options).forEach(this.worktopOptions::add);
|
||||
}
|
||||
|
||||
public void removeWorktopOption(int option) {
|
||||
if (this.worktopOptions == null) {
|
||||
return;
|
||||
}
|
||||
this.worktopOptions.remove(option);
|
||||
}
|
||||
public void removeWorktopOption(int option) {
|
||||
if (this.worktopOptions == null) {
|
||||
return;
|
||||
}
|
||||
this.worktopOptions.remove(option);
|
||||
}
|
||||
|
||||
public boolean onInteract(Player player, GadgetInteractReq req) {
|
||||
return false;
|
||||
}
|
||||
public boolean onInteract(Player player, GadgetInteractReq req) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onBuildProto(SceneGadgetInfo.Builder gadgetInfo) {
|
||||
if (this.worktopOptions == null) {
|
||||
return;
|
||||
}
|
||||
public void onBuildProto(SceneGadgetInfo.Builder gadgetInfo) {
|
||||
if (this.worktopOptions == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorktopInfo worktop = WorktopInfo.newBuilder()
|
||||
.addAllOptionList(this.getWorktopOptions())
|
||||
.build();
|
||||
WorktopInfo worktop = WorktopInfo.newBuilder()
|
||||
.addAllOptionList(this.getWorktopOptions())
|
||||
.build();
|
||||
|
||||
gadgetInfo.setWorktop(worktop);
|
||||
}
|
||||
gadgetInfo.setWorktop(worktop);
|
||||
}
|
||||
|
||||
public void setOnSelectWorktopOptionEvent(WorktopWorktopOptionHandler handler) {
|
||||
this.handler = handler;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class BossChestInteractHandler implements ChestInteractHandler{
|
||||
|
||||
public boolean onInteract(GadgetChest chest, Player player,boolean useCondensedResin) {
|
||||
var blossomRewards = player.getScene().getBlossomManager().onReward(player,chest.getGadget(),useCondensedResin);
|
||||
if(blossomRewards!=null) {
|
||||
if (blossomRewards!=null) {
|
||||
player.getInventory().addItems(blossomRewards, ActionReason.OpenWorldBossChest);
|
||||
player.sendPacket(new PacketGadgetAutoPickDropInfoNotify(blossomRewards));
|
||||
return true;
|
||||
|
||||
@@ -3,4 +3,4 @@ package emu.grasscutter.game.entity.gadget.worktop;
|
||||
import emu.grasscutter.game.entity.gadget.GadgetWorktop;
|
||||
public interface WorktopWorktopOptionHandler {
|
||||
boolean onSelectWorktopOption(GadgetWorktop gadgetWorktop,int option);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,31 +47,31 @@ public enum MaterialType {
|
||||
MATERIAL_ACTIVITY_ROBOT (38),
|
||||
MATERIAL_ACTIVITY_GEAR (39),
|
||||
MATERIAL_ACTIVITY_JIGSAW (40);
|
||||
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<MaterialType> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, MaterialType> stringMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
stringMap.put(e.name(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private MaterialType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static MaterialType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, MATERIAL_NONE);
|
||||
}
|
||||
|
||||
public static MaterialType getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, MATERIAL_NONE);
|
||||
}
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<MaterialType> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, MaterialType> stringMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
stringMap.put(e.name(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private MaterialType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static MaterialType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, MATERIAL_NONE);
|
||||
}
|
||||
|
||||
public static MaterialType getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, MATERIAL_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class FurnitureManager extends BasePlayerManager {
|
||||
|
||||
public synchronized boolean unlockFurnitureOrSuite(GameItem useItem) {
|
||||
ItemUseOp itemUseOp = useItem.getItemData().getItemUse().get(0).getUseOp();
|
||||
|
||||
|
||||
// Check
|
||||
if (itemUseOp != ItemUseOp.ITEM_USE_UNLOCK_FURNITURE_SUITE && itemUseOp != ItemUseOp.ITEM_USE_UNLOCK_FURNITURE_FORMULA) {
|
||||
return false;
|
||||
|
||||
@@ -54,36 +54,36 @@ public class BlossomActivity {
|
||||
challengeTriggers.add(new KillMonsterTrigger());
|
||||
//this.challengeTriggers.add(new InTimeTrigger());
|
||||
}
|
||||
public WorldChallenge getChallenge(){
|
||||
public WorldChallenge getChallenge() {
|
||||
return this.challenge;
|
||||
}
|
||||
public void setMonsters(List<EntityMonster> monsters) {
|
||||
this.activeMonsters.clear();
|
||||
this.activeMonsters.addAll(monsters);
|
||||
for(EntityMonster monster : monsters){
|
||||
for (EntityMonster monster : monsters) {
|
||||
monster.setGroupId(this.tempSceneGroup.id);
|
||||
}
|
||||
}
|
||||
public int getAliveMonstersCount(){
|
||||
public int getAliveMonstersCount() {
|
||||
int count=0;
|
||||
for(EntityMonster monster: activeMonsters) {
|
||||
if(monster.isAlive()){
|
||||
for (EntityMonster monster: activeMonsters) {
|
||||
if (monster.isAlive()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
public boolean getPass(){
|
||||
public boolean getPass() {
|
||||
return pass;
|
||||
}
|
||||
public void start(){
|
||||
public void start() {
|
||||
challenge.start();
|
||||
}
|
||||
public void onTick() {
|
||||
Scene scene = gadget.getScene();
|
||||
Position pos = gadget.getPosition();
|
||||
if(getAliveMonstersCount() <= 2){
|
||||
if(generatedCount<goal){
|
||||
if (getAliveMonstersCount() <= 2) {
|
||||
if (generatedCount<goal) {
|
||||
step++;
|
||||
|
||||
WorldLevelData worldLevelData = GameData.getWorldLevelDataMap().get(worldLevel);
|
||||
@@ -94,7 +94,7 @@ public class BlossomActivity {
|
||||
|
||||
List<EntityMonster> newMonsters = new ArrayList<>();
|
||||
int willSpawn = Utils.randomRange(3,5);
|
||||
if(generatedCount+willSpawn>goal){
|
||||
if (generatedCount+willSpawn>goal) {
|
||||
willSpawn = goal - generatedCount;
|
||||
}
|
||||
generatedCount+=willSpawn;
|
||||
@@ -106,19 +106,19 @@ public class BlossomActivity {
|
||||
newMonsters.add(entity);
|
||||
}
|
||||
setMonsters(newMonsters);
|
||||
}else{
|
||||
if(getAliveMonstersCount() == 0) {
|
||||
}else {
|
||||
if (getAliveMonstersCount() == 0) {
|
||||
this.pass = true;
|
||||
this.challenge.done();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public EntityGadget getGadget(){
|
||||
public EntityGadget getGadget() {
|
||||
return gadget;
|
||||
}
|
||||
public EntityGadget getChest(){
|
||||
if(chest==null) {
|
||||
public EntityGadget getChest() {
|
||||
if (chest==null) {
|
||||
EntityGadget rewardGadget = new EntityGadget(gadget.getScene(), BLOOMING_GADGET_ID, gadget.getPosition());
|
||||
SceneGadget metaGadget = new SceneGadget();
|
||||
metaGadget.boss_chest = new SceneBossChest();
|
||||
|
||||
@@ -37,10 +37,10 @@ public class BlossomManager {
|
||||
|
||||
private final List<SpawnDataEntry> blossomConsumed = new ArrayList<>();
|
||||
|
||||
public void onTick(){
|
||||
synchronized (blossomActivities){
|
||||
public void onTick() {
|
||||
synchronized (blossomActivities) {
|
||||
var it = blossomActivities.iterator();
|
||||
while(it.hasNext()){
|
||||
while (it.hasNext()) {
|
||||
var active = it.next();
|
||||
active.onTick();
|
||||
if (active.getPass()) {
|
||||
@@ -54,24 +54,24 @@ public class BlossomManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void recycleGadgetEntity(List<GameEntity> entities){
|
||||
for(var entity : entities){
|
||||
if(entity instanceof EntityGadget gadget){
|
||||
public void recycleGadgetEntity(List<GameEntity> entities) {
|
||||
for (var entity : entities) {
|
||||
if (entity instanceof EntityGadget gadget) {
|
||||
createdEntity.remove(gadget);
|
||||
}
|
||||
}
|
||||
notifyIcon();
|
||||
}
|
||||
|
||||
public void initBlossom(EntityGadget gadget){
|
||||
if(createdEntity.contains(gadget)){
|
||||
public void initBlossom(EntityGadget gadget) {
|
||||
if (createdEntity.contains(gadget)) {
|
||||
return;
|
||||
}
|
||||
if(blossomConsumed.contains(gadget.getSpawnEntry())){
|
||||
if (blossomConsumed.contains(gadget.getSpawnEntry())) {
|
||||
return;
|
||||
}
|
||||
var id = gadget.getGadgetId();
|
||||
if(BlossomType.valueOf(id)==null){
|
||||
if (BlossomType.valueOf(id)==null) {
|
||||
return;
|
||||
}
|
||||
gadget.buildContent();
|
||||
@@ -91,19 +91,19 @@ public class BlossomManager {
|
||||
|
||||
int volume=0;
|
||||
IntList monsters = new IntArrayList();
|
||||
while(true){
|
||||
while (true) {
|
||||
var remain = GameDepot.getBlossomConfig().getMonsterFightingVolume() - volume;
|
||||
if(remain<=0){
|
||||
if (remain<=0) {
|
||||
break;
|
||||
}
|
||||
var rand = Utils.randomRange(1,100);
|
||||
if(rand>85 && remain>=50){//15% ,generate strong monster
|
||||
if (rand>85 && remain>=50) {//15% ,generate strong monster
|
||||
monsters.addAll(getRandomMonstersID(2,1));
|
||||
volume+=50;
|
||||
}else if(rand>50 && remain>=20) {//35% ,generate normal monster
|
||||
}else if (rand>50 && remain>=20) {//35% ,generate normal monster
|
||||
monsters.addAll(getRandomMonstersID(1,1));
|
||||
volume+=20;
|
||||
}else{//50% ,generate weak monster
|
||||
}else {//50% ,generate weak monster
|
||||
monsters.addAll(getRandomMonstersID(0,1));
|
||||
volume+=10;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class BlossomManager {
|
||||
scene.broadcastPacket(new PacketBlossomBriefInfoNotify(blossoms));
|
||||
}
|
||||
|
||||
public int getWorldLevel(){
|
||||
public int getWorldLevel() {
|
||||
return scene.getWorld().getWorldLevel();
|
||||
}
|
||||
|
||||
@@ -226,10 +226,10 @@ public class BlossomManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IntList getRandomMonstersID(int difficulty,int count){
|
||||
public static IntList getRandomMonstersID(int difficulty,int count) {
|
||||
IntList result = new IntArrayList();
|
||||
List<Integer> monsters = GameDepot.getBlossomConfig().getMonsterIdsPerDifficulty().get(difficulty);
|
||||
for(int i=0; i<count; i++){
|
||||
for (int i=0; i<count; i++) {
|
||||
result.add((int) monsters.get(Utils.randomRange(0, monsters.size()-1)));
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -554,9 +554,9 @@ public class Player {
|
||||
|
||||
public void onEnterRegion(SceneRegion region) {
|
||||
getQuestManager().forEachActiveQuest(quest -> {
|
||||
if(quest.getTriggers().containsKey("ENTER_REGION_"+ String.valueOf(region.config_id))) {
|
||||
if (quest.getTriggers().containsKey("ENTER_REGION_"+ String.valueOf(region.config_id))) {
|
||||
// If trigger hasn't been fired yet
|
||||
if(!Boolean.TRUE.equals(quest.getTriggers().put("ENTER_REGION_"+ String.valueOf(region.config_id), true))) {
|
||||
if (!Boolean.TRUE.equals(quest.getTriggers().put("ENTER_REGION_"+ String.valueOf(region.config_id), true))) {
|
||||
//getSession().send(new PacketServerCondMeetQuestListUpdateNotify());
|
||||
getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_TRIGGER_FIRE, quest.getTriggerData().get("ENTER_REGION_"+ String.valueOf(region.config_id)).getId(),0);
|
||||
}
|
||||
@@ -567,9 +567,9 @@ public class Player {
|
||||
|
||||
public void onLeaveRegion(SceneRegion region) {
|
||||
getQuestManager().forEachActiveQuest(quest -> {
|
||||
if(quest.getTriggers().containsKey("LEAVE_REGION_"+ String.valueOf(region.config_id))) {
|
||||
if (quest.getTriggers().containsKey("LEAVE_REGION_"+ String.valueOf(region.config_id))) {
|
||||
// If trigger hasn't been fired yet
|
||||
if(!Boolean.TRUE.equals(quest.getTriggers().put("LEAVE_REGION_"+ String.valueOf(region.config_id), true))) {
|
||||
if (!Boolean.TRUE.equals(quest.getTriggers().put("LEAVE_REGION_"+ String.valueOf(region.config_id), true))) {
|
||||
getSession().send(new PacketServerCondMeetQuestListUpdateNotify());
|
||||
getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_TRIGGER_FIRE, quest.getTriggerData().get("LEAVE_REGION_"+ String.valueOf(region.config_id)).getId(),0);
|
||||
}
|
||||
|
||||
@@ -18,16 +18,16 @@ import lombok.Getter;
|
||||
@Getter(AccessLevel.PRIVATE)
|
||||
public class PlayerBuffManager extends BasePlayerManager {
|
||||
private int nextBuffUid;
|
||||
|
||||
|
||||
private final List<PlayerBuff> pendingBuffs;
|
||||
private final Int2ObjectMap<PlayerBuff> buffs; // Server buffs
|
||||
|
||||
|
||||
public PlayerBuffManager(Player player) {
|
||||
super(player);
|
||||
this.buffs = new Int2ObjectOpenHashMap<>();
|
||||
this.pendingBuffs = new LinkedList<>();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a new uid for a server buff
|
||||
* @return New integer buff uid
|
||||
@@ -35,7 +35,7 @@ public class PlayerBuffManager extends BasePlayerManager {
|
||||
private int getNextBuffUid() {
|
||||
return ++nextBuffUid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the player has a buff with this group id
|
||||
* @param groupId Buff group id
|
||||
@@ -44,7 +44,7 @@ public class PlayerBuffManager extends BasePlayerManager {
|
||||
public synchronized boolean hasBuff(int groupId) {
|
||||
return this.getBuffs().containsKey(groupId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears all player buffs
|
||||
*/
|
||||
@@ -53,11 +53,11 @@ public class PlayerBuffManager extends BasePlayerManager {
|
||||
getPlayer().sendPacket(
|
||||
new PacketServerBuffChangeNotify(getPlayer(), ServerBuffChangeType.SERVER_BUFF_CHANGE_TYPE_DEL_SERVER_BUFF, getBuffs().values())
|
||||
);
|
||||
|
||||
|
||||
// Clear
|
||||
getBuffs().clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a server buff to the player.
|
||||
* @param buffId Server buff id
|
||||
@@ -66,7 +66,7 @@ public class PlayerBuffManager extends BasePlayerManager {
|
||||
public boolean addBuff(int buffId) {
|
||||
return addBuff(buffId, -1f);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a server buff to the player.
|
||||
* @param buffId Server buff id
|
||||
@@ -77,32 +77,32 @@ public class PlayerBuffManager extends BasePlayerManager {
|
||||
// Get buff excel data
|
||||
BuffData buffData = GameData.getBuffDataMap().get(buffId);
|
||||
if (buffData == null) return false;
|
||||
|
||||
|
||||
// Set duration
|
||||
if (duration < 0f) {
|
||||
duration = buffData.getTime();
|
||||
}
|
||||
|
||||
|
||||
// Dont add buff if duration is equal or less than 0
|
||||
if (duration <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Clear previous buff if it exists
|
||||
if (this.hasBuff(buffData.getGroupId())) {
|
||||
this.removeBuff(buffData.getGroupId());
|
||||
}
|
||||
|
||||
|
||||
// Create and store buff
|
||||
PlayerBuff buff = new PlayerBuff(getNextBuffUid(), buffData, duration);
|
||||
getBuffs().put(buff.getGroupId(), buff);
|
||||
|
||||
|
||||
// Packet
|
||||
getPlayer().sendPacket(new PacketServerBuffChangeNotify(getPlayer(), ServerBuffChangeType.SERVER_BUFF_CHANGE_TYPE_ADD_SERVER_BUFF, buff));
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes a buff by its group id
|
||||
* @param buffGroupId Server buff group id
|
||||
@@ -110,36 +110,36 @@ public class PlayerBuffManager extends BasePlayerManager {
|
||||
*/
|
||||
public synchronized boolean removeBuff(int buffGroupId) {
|
||||
PlayerBuff buff = this.getBuffs().get(buffGroupId);
|
||||
|
||||
|
||||
if (buff != null) {
|
||||
getPlayer().sendPacket(
|
||||
new PacketServerBuffChangeNotify(getPlayer(), ServerBuffChangeType.SERVER_BUFF_CHANGE_TYPE_DEL_SERVER_BUFF, buff)
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public synchronized void onTick() {
|
||||
// Skip if no buffs
|
||||
if (getBuffs().size() == 0) return;
|
||||
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
|
||||
// Add to pending buffs to remove if buff has expired
|
||||
for (PlayerBuff buff : getBuffs().values()) {
|
||||
if (currentTime > buff.getEndTime()) {
|
||||
this.getPendingBuffs().add(buff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (this.getPendingBuffs().size() > 0) {
|
||||
// Send packet
|
||||
getPlayer().sendPacket(
|
||||
new PacketServerBuffChangeNotify(getPlayer(), ServerBuffChangeType.SERVER_BUFF_CHANGE_TYPE_DEL_SERVER_BUFF, this.pendingBuffs)
|
||||
);
|
||||
|
||||
|
||||
// Remove buff from player buff map
|
||||
for (PlayerBuff buff : this.getPendingBuffs()) {
|
||||
getBuffs().remove(buff.getGroupId());
|
||||
@@ -147,19 +147,19 @@ public class PlayerBuffManager extends BasePlayerManager {
|
||||
this.getPendingBuffs().clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Getter
|
||||
public static class PlayerBuff {
|
||||
private final int uid;
|
||||
private final BuffData buffData;
|
||||
private final long endTime;
|
||||
|
||||
|
||||
public PlayerBuff(int uid, BuffData buffData, float duration) {
|
||||
this.uid = uid;
|
||||
this.buffData = buffData;
|
||||
this.endTime = System.currentTimeMillis() + ((long) duration * 1000);
|
||||
}
|
||||
|
||||
|
||||
public int getGroupId() {
|
||||
return getBuffData().getGroupId();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class PlayerProgressManager extends BasePlayerDataManager {
|
||||
// that particular statue interactable.
|
||||
this.player.getUnlockedScenePoints(3).add(7);
|
||||
this.player.getUnlockedSceneAreas(3).add(1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************************************************
|
||||
@@ -199,9 +199,9 @@ public class PlayerProgressManager extends BasePlayerDataManager {
|
||||
public boolean unlockTransPoint(int sceneId, int pointId, boolean isStatue) {
|
||||
// Check whether the unlocked point exists and whether it is still locked.
|
||||
String key = sceneId + "_" + pointId;
|
||||
ScenePointEntry scenePointEntry = GameData.getScenePointEntries().get(key);
|
||||
ScenePointEntry scenePointEntry = GameData.getScenePointEntries().get(key);
|
||||
|
||||
if (scenePointEntry == null || this.player.getUnlockedScenePoints(sceneId).contains(pointId)) {
|
||||
if (scenePointEntry == null || this.player.getUnlockedScenePoints(sceneId).contains(pointId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,60 +10,60 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import lombok.Getter;
|
||||
|
||||
public enum ElementType {
|
||||
None (0, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY),
|
||||
Fire (1, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY, 10101, "TeamResonance_Fire_Lv2", 2),
|
||||
Water (2, FightProperty.FIGHT_PROP_CUR_WATER_ENERGY, FightProperty.FIGHT_PROP_MAX_WATER_ENERGY, 10201, "TeamResonance_Water_Lv2", 3),
|
||||
Grass (3, FightProperty.FIGHT_PROP_CUR_GRASS_ENERGY, FightProperty.FIGHT_PROP_MAX_GRASS_ENERGY),
|
||||
Electric (4, FightProperty.FIGHT_PROP_CUR_ELEC_ENERGY, FightProperty.FIGHT_PROP_MAX_ELEC_ENERGY, 10401, "TeamResonance_Electric_Lv2", 7),
|
||||
Ice (5, FightProperty.FIGHT_PROP_CUR_ICE_ENERGY, FightProperty.FIGHT_PROP_MAX_ICE_ENERGY, 10601, "TeamResonance_Ice_Lv2", 5),
|
||||
Frozen (6, FightProperty.FIGHT_PROP_CUR_ICE_ENERGY, FightProperty.FIGHT_PROP_MAX_ICE_ENERGY),
|
||||
Wind (7, FightProperty.FIGHT_PROP_CUR_WIND_ENERGY, FightProperty.FIGHT_PROP_MAX_WIND_ENERGY, 10301, "TeamResonance_Wind_Lv2", 4),
|
||||
Rock (8, FightProperty.FIGHT_PROP_CUR_ROCK_ENERGY, FightProperty.FIGHT_PROP_MAX_ROCK_ENERGY, 10701, "TeamResonance_Rock_Lv2", 6),
|
||||
AntiFire (9, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY),
|
||||
Default (255, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY, 10801, "TeamResonance_AllDifferent");
|
||||
|
||||
@Getter private final int value;
|
||||
@Getter private final int teamResonanceId;
|
||||
@Getter private final FightProperty curEnergyProp;
|
||||
@Getter private final FightProperty maxEnergyProp;
|
||||
@Getter private int depotValue;
|
||||
@Getter private final int configHash;
|
||||
private static final Int2ObjectMap<ElementType> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, ElementType> stringMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
stringMap.put(e.name(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ElementType(int value, FightProperty curEnergyProp, FightProperty maxEnergyProp) {
|
||||
this(value, curEnergyProp, maxEnergyProp, 0, null);
|
||||
}
|
||||
|
||||
private ElementType(int value, FightProperty curEnergyProp, FightProperty maxEnergyProp, int teamResonanceId, String configName) {
|
||||
this.value = value;
|
||||
this.curEnergyProp = curEnergyProp;
|
||||
this.maxEnergyProp = maxEnergyProp;
|
||||
this.teamResonanceId = teamResonanceId;
|
||||
if (configName != null) {
|
||||
this.configHash = Utils.abilityHash(configName);
|
||||
} else {
|
||||
this.configHash = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private ElementType(int value, FightProperty curEnergyProp, FightProperty maxEnergyProp, int teamResonanceId, String configName, int depotValue) {
|
||||
this(value, curEnergyProp, maxEnergyProp, teamResonanceId, configName);
|
||||
this.depotValue = depotValue;
|
||||
}
|
||||
None (0, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY),
|
||||
Fire (1, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY, 10101, "TeamResonance_Fire_Lv2", 2),
|
||||
Water (2, FightProperty.FIGHT_PROP_CUR_WATER_ENERGY, FightProperty.FIGHT_PROP_MAX_WATER_ENERGY, 10201, "TeamResonance_Water_Lv2", 3),
|
||||
Grass (3, FightProperty.FIGHT_PROP_CUR_GRASS_ENERGY, FightProperty.FIGHT_PROP_MAX_GRASS_ENERGY),
|
||||
Electric (4, FightProperty.FIGHT_PROP_CUR_ELEC_ENERGY, FightProperty.FIGHT_PROP_MAX_ELEC_ENERGY, 10401, "TeamResonance_Electric_Lv2", 7),
|
||||
Ice (5, FightProperty.FIGHT_PROP_CUR_ICE_ENERGY, FightProperty.FIGHT_PROP_MAX_ICE_ENERGY, 10601, "TeamResonance_Ice_Lv2", 5),
|
||||
Frozen (6, FightProperty.FIGHT_PROP_CUR_ICE_ENERGY, FightProperty.FIGHT_PROP_MAX_ICE_ENERGY),
|
||||
Wind (7, FightProperty.FIGHT_PROP_CUR_WIND_ENERGY, FightProperty.FIGHT_PROP_MAX_WIND_ENERGY, 10301, "TeamResonance_Wind_Lv2", 4),
|
||||
Rock (8, FightProperty.FIGHT_PROP_CUR_ROCK_ENERGY, FightProperty.FIGHT_PROP_MAX_ROCK_ENERGY, 10701, "TeamResonance_Rock_Lv2", 6),
|
||||
AntiFire (9, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY),
|
||||
Default (255, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY, 10801, "TeamResonance_AllDifferent");
|
||||
|
||||
public static ElementType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, None);
|
||||
}
|
||||
|
||||
public static ElementType getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, None);
|
||||
}
|
||||
@Getter private final int value;
|
||||
@Getter private final int teamResonanceId;
|
||||
@Getter private final FightProperty curEnergyProp;
|
||||
@Getter private final FightProperty maxEnergyProp;
|
||||
@Getter private int depotValue;
|
||||
@Getter private final int configHash;
|
||||
private static final Int2ObjectMap<ElementType> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, ElementType> stringMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
stringMap.put(e.name(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ElementType(int value, FightProperty curEnergyProp, FightProperty maxEnergyProp) {
|
||||
this(value, curEnergyProp, maxEnergyProp, 0, null);
|
||||
}
|
||||
|
||||
private ElementType(int value, FightProperty curEnergyProp, FightProperty maxEnergyProp, int teamResonanceId, String configName) {
|
||||
this.value = value;
|
||||
this.curEnergyProp = curEnergyProp;
|
||||
this.maxEnergyProp = maxEnergyProp;
|
||||
this.teamResonanceId = teamResonanceId;
|
||||
if (configName != null) {
|
||||
this.configHash = Utils.abilityHash(configName);
|
||||
} else {
|
||||
this.configHash = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private ElementType(int value, FightProperty curEnergyProp, FightProperty maxEnergyProp, int teamResonanceId, String configName, int depotValue) {
|
||||
this(value, curEnergyProp, maxEnergyProp, teamResonanceId, configName);
|
||||
this.depotValue = depotValue;
|
||||
}
|
||||
|
||||
public static ElementType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, None);
|
||||
}
|
||||
|
||||
public static ElementType getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, None);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,25 +48,25 @@ public enum ItemUseOp {
|
||||
ITEM_USE_UNLOCK_HOME_MODULE (44),
|
||||
ITEM_USE_UNLOCK_HOME_BGM (45),
|
||||
ITEM_USE_ADD_REGIONAL_PLAY_VAR (46);
|
||||
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<ItemUseOp> map = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ItemUseOp(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ItemUseOp getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, ITEM_USE_NONE);
|
||||
}
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<ItemUseOp> map = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ItemUseOp(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ItemUseOp getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, ITEM_USE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,25 +12,25 @@ public enum ItemUseTarget {
|
||||
ITEM_USE_TARGET_SPECIFY_AVATAR (3),
|
||||
ITEM_USE_TARGET_SPECIFY_ALIVE_AVATAR (4),
|
||||
ITEM_USE_TARGET_SPECIFY_DEAD_AVATAR (5);
|
||||
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<ItemUseTarget> map = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ItemUseTarget(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ItemUseTarget getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, ITEM_USE_TARGET_NONE);
|
||||
}
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<ItemUseTarget> map = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ItemUseTarget(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ItemUseTarget getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, ITEM_USE_TARGET_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,25 +10,25 @@ public enum ServerBuffType {
|
||||
SERVER_BUFF_AVATAR (1),
|
||||
SERVER_BUFF_TEAM (2),
|
||||
SERVER_BUFF_TOWER (3);
|
||||
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<ServerBuffType> map = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ServerBuffType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ServerBuffType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, SERVER_BUFF_NONE);
|
||||
}
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<ServerBuffType> map = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ServerBuffType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ServerBuffType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, SERVER_BUFF_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,17 +41,17 @@ import static emu.grasscutter.config.Configuration.SCRIPT;
|
||||
|
||||
@Entity(value = "quests", useDiscriminator = false)
|
||||
public class GameMainQuest {
|
||||
@Id private ObjectId id;
|
||||
@Indexed @Getter private int ownerUid;
|
||||
@Transient @Getter private Player owner;
|
||||
@Id private ObjectId id;
|
||||
@Indexed @Getter private int ownerUid;
|
||||
@Transient @Getter private Player owner;
|
||||
@Transient @Getter private QuestManager questManager;
|
||||
@Getter private Map<Integer, GameQuest> childQuests;
|
||||
@Getter private int parentQuestId;
|
||||
@Getter private int[] questVars;
|
||||
@Getter private Map<Integer, GameQuest> childQuests;
|
||||
@Getter private int parentQuestId;
|
||||
@Getter private int[] questVars;
|
||||
//QuestUpdateQuestVarReq is sent in two stages...
|
||||
@Getter private List<Integer> questVarsUpdate;
|
||||
@Getter private ParentQuestState state;
|
||||
@Getter private boolean isFinished;
|
||||
@Getter private ParentQuestState state;
|
||||
@Getter private boolean isFinished;
|
||||
@Getter List<QuestGroupSuite> questGroupSuites;
|
||||
|
||||
@Getter int[] suggestTrackMainQuestList;
|
||||
@@ -60,25 +60,25 @@ public class GameMainQuest {
|
||||
private Map<Integer,Position> rewindPositions;
|
||||
private Map<Integer,Position> rewindRotations;
|
||||
|
||||
@Deprecated // Morphia only. Do not use.
|
||||
public GameMainQuest() {}
|
||||
@Deprecated // Morphia only. Do not use.
|
||||
public GameMainQuest() {}
|
||||
|
||||
public GameMainQuest(Player player, int parentQuestId) {
|
||||
this.owner = player;
|
||||
this.ownerUid = player.getUid();
|
||||
public GameMainQuest(Player player, int parentQuestId) {
|
||||
this.owner = player;
|
||||
this.ownerUid = player.getUid();
|
||||
this.questManager = player.getQuestManager();
|
||||
this.parentQuestId = parentQuestId;
|
||||
this.childQuests = new HashMap<>();
|
||||
this.parentQuestId = parentQuestId;
|
||||
this.childQuests = new HashMap<>();
|
||||
this.talks = new HashMap<>();
|
||||
//official server always has a list of 5 questVars, with default value 0
|
||||
this.questVars = new int[] {0,0,0,0,0};
|
||||
this.state = ParentQuestState.PARENT_QUEST_STATE_NONE;
|
||||
this.questVars = new int[] {0,0,0,0,0};
|
||||
this.state = ParentQuestState.PARENT_QUEST_STATE_NONE;
|
||||
this.questGroupSuites = new ArrayList<>();
|
||||
this.rewindPositions = new HashMap<>();
|
||||
this.rewindRotations = new HashMap<>();
|
||||
addAllChildQuests();
|
||||
addRewindPoints();
|
||||
}
|
||||
}
|
||||
|
||||
private void addAllChildQuests() {
|
||||
List<Integer> subQuestIds = Arrays.stream(GameData.getMainQuestDataMap().get(this.parentQuestId).getSubQuests()).map(SubQuestData::getSubId).toList();
|
||||
@@ -88,10 +88,10 @@ public class GameMainQuest {
|
||||
}
|
||||
}
|
||||
|
||||
public void setOwner(Player player) {
|
||||
if (player.getUid() != this.getOwnerUid()) return;
|
||||
this.owner = player;
|
||||
}
|
||||
public void setOwner(Player player) {
|
||||
if (player.getUid() != this.getOwnerUid()) return;
|
||||
this.owner = player;
|
||||
}
|
||||
|
||||
public int getQuestVar(int i) {
|
||||
return questVars[i];
|
||||
@@ -115,71 +115,71 @@ public class GameMainQuest {
|
||||
}
|
||||
|
||||
|
||||
public GameQuest getChildQuestById(int id) {
|
||||
return this.getChildQuests().get(id);
|
||||
}
|
||||
public GameQuest getChildQuestById(int id) {
|
||||
return this.getChildQuests().get(id);
|
||||
}
|
||||
public GameQuest getChildQuestByOrder(int order) {
|
||||
return this.getChildQuests().values().stream().filter(p -> p.getQuestData().getOrder() == order).toList().get(0);
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
this.isFinished = true;
|
||||
this.state = ParentQuestState.PARENT_QUEST_STATE_FINISHED;
|
||||
this.isFinished = true;
|
||||
this.state = ParentQuestState.PARENT_QUEST_STATE_FINISHED;
|
||||
|
||||
this.getOwner().getSession().send(new PacketFinishedParentQuestUpdateNotify(this));
|
||||
this.getOwner().getSession().send(new PacketCodexDataUpdateNotify(this));
|
||||
this.getOwner().getSession().send(new PacketFinishedParentQuestUpdateNotify(this));
|
||||
this.getOwner().getSession().send(new PacketCodexDataUpdateNotify(this));
|
||||
|
||||
this.save();
|
||||
this.save();
|
||||
|
||||
// Add rewards
|
||||
MainQuestData mainQuestData = GameData.getMainQuestDataMap().get(this.getParentQuestId());
|
||||
for (int rewardId : mainQuestData.getRewardIdList()) {
|
||||
RewardData rewardData = GameData.getRewardDataMap().get(rewardId);
|
||||
// Add rewards
|
||||
MainQuestData mainQuestData = GameData.getMainQuestDataMap().get(this.getParentQuestId());
|
||||
for (int rewardId : mainQuestData.getRewardIdList()) {
|
||||
RewardData rewardData = GameData.getRewardDataMap().get(rewardId);
|
||||
|
||||
if (rewardData == null) {
|
||||
continue;
|
||||
}
|
||||
if (rewardData == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
getOwner().getInventory().addItemParamDatas(rewardData.getRewardItemList(), ActionReason.QuestReward);
|
||||
}
|
||||
getOwner().getInventory().addItemParamDatas(rewardData.getRewardItemList(), ActionReason.QuestReward);
|
||||
}
|
||||
|
||||
// handoff main quest
|
||||
if(mainQuestData.getSuggestTrackMainQuestList() != null){
|
||||
if (mainQuestData.getSuggestTrackMainQuestList() != null) {
|
||||
Arrays.stream(mainQuestData.getSuggestTrackMainQuestList())
|
||||
.forEach(getQuestManager()::startMainQuest);
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO
|
||||
public void fail() {}
|
||||
public void cancel() {}
|
||||
|
||||
// Rewinds to the last finished/unfinished rewind quest, and returns the avatar rewind position (if it exists)
|
||||
public List<Position> rewind() {
|
||||
if(this.questManager == null) {
|
||||
if (this.questManager == null) {
|
||||
this.questManager = getOwner().getQuestManager();
|
||||
}
|
||||
List<GameQuest> sortedByOrder = new ArrayList<>(getChildQuests().values().stream().filter(q -> q.getQuestData().isRewind()).toList());
|
||||
sortedByOrder.sort((a,b) -> {
|
||||
if( a == b){
|
||||
if ( a == b) {
|
||||
return 0;
|
||||
}
|
||||
return a.getQuestData().getOrder() > b.getQuestData().getOrder() ? 1 : -1;});
|
||||
boolean didRewind = false;
|
||||
for (GameQuest quest : sortedByOrder) {
|
||||
int i = sortedByOrder.indexOf(quest);
|
||||
if( i == sortedByOrder.size()) {
|
||||
if ( i == sortedByOrder.size()) {
|
||||
didRewind = quest.rewind(null);
|
||||
} else {
|
||||
didRewind = quest.rewind(sortedByOrder.get(i+1));
|
||||
}
|
||||
if(didRewind) {
|
||||
if (didRewind) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<GameQuest> rewindQuests = getChildQuests().values().stream()
|
||||
.filter(p -> (p.getState() == QuestState.QUEST_STATE_UNFINISHED || p.getState() == QuestState.QUEST_STATE_FINISHED) && p.getQuestData().isRewind()).toList();
|
||||
for (GameQuest quest : rewindQuests) {
|
||||
if(rewindPositions.containsKey(quest.getSubQuestId())) {
|
||||
if (rewindPositions.containsKey(quest.getSubQuestId())) {
|
||||
List<Position> posAndRot = new ArrayList<>();
|
||||
posAndRot.add(0,rewindPositions.get(quest.getSubQuestId()));
|
||||
posAndRot.add(1,rewindRotations.get(quest.getSubQuestId()));
|
||||
@@ -206,17 +206,17 @@ public class GameMainQuest {
|
||||
cs.eval(bindings);
|
||||
|
||||
var rewindDataMap = ScriptLoader.getSerializer().toMap(RewindData.class, bindings.get("rewind_data"));
|
||||
for(String subId : rewindDataMap.keySet()) {
|
||||
for (String subId : rewindDataMap.keySet()) {
|
||||
RewindData questRewind = rewindDataMap.get(subId);
|
||||
if(questRewind != null) {
|
||||
if (questRewind != null) {
|
||||
RewindData.AvatarData avatarData = questRewind.getAvatar();
|
||||
if(avatarData != null) {
|
||||
if (avatarData != null) {
|
||||
String avatarPos = avatarData.getPos();
|
||||
QuestData.Guide guide = GameData.getQuestDataMap().get(Integer.valueOf(subId)).getGuide();
|
||||
if (guide != null) {
|
||||
int sceneId = guide.getGuideScene();
|
||||
ScriptSceneData fullGlobals = GameData.getScriptSceneDataMap().get("flat.luas.scenes.full_globals.lua.json");
|
||||
if(fullGlobals != null) {
|
||||
if (fullGlobals != null) {
|
||||
ScriptSceneData.ScriptObject dummyPointScript = fullGlobals.getScriptObjectList().get(sceneId + "/scene" + sceneId + "_dummy_points.lua");
|
||||
if (dummyPointScript != null) {
|
||||
Map<String, List<Float>> dummyPointMap = dummyPointScript.getDummyPoints();
|
||||
@@ -287,10 +287,10 @@ public class GameMainQuest {
|
||||
|
||||
for (int i = 0; i < subQuestWithCond.getQuestData().getFailCond().size(); i++) {
|
||||
QuestData.QuestCondition condition = failCond.get(i);
|
||||
if(condition.getType() == condType) {
|
||||
if (condition.getType() == condType) {
|
||||
boolean result = this.getOwner().getServer().getQuestSystem().triggerContent(subQuestWithCond, condition, paramStr, params);
|
||||
subQuestWithCond.getFailProgressList()[i] = result ? 1 : 0;
|
||||
if(result) {
|
||||
if (result) {
|
||||
getOwner().getSession().send(new PacketQuestProgressUpdateNotify(subQuestWithCond));
|
||||
}
|
||||
}
|
||||
@@ -322,10 +322,10 @@ public class GameMainQuest {
|
||||
|
||||
for (int i = 0; i < finishCond.size(); i++) {
|
||||
QuestData.QuestCondition condition = finishCond.get(i);
|
||||
if(condition.getType() == condType) {
|
||||
if (condition.getType() == condType) {
|
||||
boolean result = this.getOwner().getServer().getQuestSystem().triggerContent(subQuestWithCond, condition, paramStr, params);
|
||||
subQuestWithCond.getFinishProgressList()[i] = result ? 1 : 0;
|
||||
if(result) {
|
||||
if (result) {
|
||||
getOwner().getSession().send(new PacketQuestProgressUpdateNotify(subQuestWithCond));
|
||||
}
|
||||
}
|
||||
@@ -343,14 +343,14 @@ public class GameMainQuest {
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
DatabaseHelper.saveQuest(this);
|
||||
}
|
||||
public void save() {
|
||||
DatabaseHelper.saveQuest(this);
|
||||
}
|
||||
|
||||
public ParentQuest toProto() {
|
||||
ParentQuest.Builder proto = ParentQuest.newBuilder()
|
||||
.setParentQuestId(getParentQuestId())
|
||||
.setIsFinished(isFinished());
|
||||
public ParentQuest toProto() {
|
||||
ParentQuest.Builder proto = ParentQuest.newBuilder()
|
||||
.setParentQuestId(getParentQuestId())
|
||||
.setIsFinished(isFinished());
|
||||
|
||||
|
||||
proto.setParentQuestState(getState().getValue())
|
||||
@@ -371,7 +371,7 @@ public class GameMainQuest {
|
||||
}
|
||||
|
||||
|
||||
return proto.build();
|
||||
}
|
||||
return proto.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,33 +29,33 @@ import java.util.Map;
|
||||
|
||||
@Entity
|
||||
public class GameQuest {
|
||||
@Transient @Getter @Setter private GameMainQuest mainQuest;
|
||||
@Transient @Getter private QuestData questData;
|
||||
@Transient @Getter @Setter private GameMainQuest mainQuest;
|
||||
@Transient @Getter private QuestData questData;
|
||||
|
||||
@Getter private int subQuestId;
|
||||
@Getter private int mainQuestId;
|
||||
@Getter @Setter
|
||||
@Getter private int subQuestId;
|
||||
@Getter private int mainQuestId;
|
||||
@Getter @Setter
|
||||
private QuestState state;
|
||||
|
||||
@Getter @Setter private int startTime;
|
||||
@Getter @Setter private int acceptTime;
|
||||
@Getter @Setter private int finishTime;
|
||||
@Getter @Setter private int startTime;
|
||||
@Getter @Setter private int acceptTime;
|
||||
@Getter @Setter private int finishTime;
|
||||
|
||||
@Getter private int[] finishProgressList;
|
||||
@Getter private int[] failProgressList;
|
||||
@Getter private int[] finishProgressList;
|
||||
@Getter private int[] failProgressList;
|
||||
@Transient @Getter private Map<String, TriggerExcelConfigData> triggerData;
|
||||
@Getter private Map<String, Boolean> triggers;
|
||||
private transient Bindings bindings;
|
||||
|
||||
@Deprecated // Morphia only. Do not use.
|
||||
public GameQuest() {}
|
||||
@Deprecated // Morphia only. Do not use.
|
||||
public GameQuest() {}
|
||||
|
||||
public GameQuest(GameMainQuest mainQuest, QuestData questData) {
|
||||
this.mainQuest = mainQuest;
|
||||
this.subQuestId = questData.getId();
|
||||
this.mainQuestId = questData.getMainId();
|
||||
this.questData = questData;
|
||||
this.state = QuestState.QUEST_STATE_UNSTARTED;
|
||||
public GameQuest(GameMainQuest mainQuest, QuestData questData) {
|
||||
this.mainQuest = mainQuest;
|
||||
this.subQuestId = questData.getId();
|
||||
this.mainQuestId = questData.getMainId();
|
||||
this.questData = questData;
|
||||
this.state = QuestState.QUEST_STATE_UNSTARTED;
|
||||
this.triggerData = new HashMap<>();
|
||||
this.triggers = new HashMap<>();
|
||||
}
|
||||
@@ -66,11 +66,11 @@ public class GameQuest {
|
||||
this.state = QuestState.QUEST_STATE_UNFINISHED;
|
||||
List<QuestData.QuestCondition> triggerCond = questData.getFinishCond().stream()
|
||||
.filter(p -> p.getType() == QuestTrigger.QUEST_CONTENT_TRIGGER_FIRE).toList();
|
||||
if(triggerCond.size() > 0) {
|
||||
if (triggerCond.size() > 0) {
|
||||
for (QuestData.QuestCondition cond : triggerCond) {
|
||||
TriggerExcelConfigData newTrigger = GameData.getTriggerExcelConfigDataMap().get(cond.getParam()[0]);
|
||||
if(newTrigger != null) {
|
||||
if(this.triggerData == null) {
|
||||
if (newTrigger != null) {
|
||||
if (this.triggerData == null) {
|
||||
this.triggerData = new HashMap<>();
|
||||
}
|
||||
triggerData.put(newTrigger.getTriggerName(), newTrigger);
|
||||
@@ -92,7 +92,7 @@ public class GameQuest {
|
||||
getQuestData().getBeginExec().forEach(e -> getOwner().getServer().getQuestSystem().triggerExec(this, e, e.getParam()));
|
||||
|
||||
|
||||
if (ChapterData.beginQuestChapterMap.containsKey(subQuestId)){
|
||||
if (ChapterData.beginQuestChapterMap.containsKey(subQuestId)) {
|
||||
mainQuest.getOwner().sendPacket(new PacketChapterStateNotify(
|
||||
ChapterData.beginQuestChapterMap.get(subQuestId).getId(),
|
||||
ChapterStateOuterClass.ChapterState.CHAPTER_STATE_BEGIN
|
||||
@@ -108,7 +108,7 @@ public class GameQuest {
|
||||
|
||||
public String getTriggerNameById(int id) {
|
||||
TriggerExcelConfigData trigger = GameData.getTriggerExcelConfigDataMap().get(id);
|
||||
if(trigger != null) {
|
||||
if (trigger != null) {
|
||||
String triggerName = trigger.getTriggerName();
|
||||
return triggerName;
|
||||
}
|
||||
@@ -116,38 +116,38 @@ public class GameQuest {
|
||||
return "";
|
||||
}
|
||||
|
||||
public Player getOwner() {
|
||||
return this.getMainQuest().getOwner();
|
||||
}
|
||||
public Player getOwner() {
|
||||
return this.getMainQuest().getOwner();
|
||||
}
|
||||
|
||||
public void setConfig(QuestData config) {
|
||||
if (getSubQuestId() != config.getId()) return;
|
||||
this.questData = config;
|
||||
}
|
||||
public void setConfig(QuestData config) {
|
||||
if (getSubQuestId() != config.getId()) return;
|
||||
this.questData = config;
|
||||
}
|
||||
|
||||
public void setFinishProgress(int index, int value) {
|
||||
finishProgressList[index] = value;
|
||||
}
|
||||
public void setFinishProgress(int index, int value) {
|
||||
finishProgressList[index] = value;
|
||||
}
|
||||
|
||||
public void setFailProgress(int index, int value) {
|
||||
failProgressList[index] = value;
|
||||
}
|
||||
public void setFailProgress(int index, int value) {
|
||||
failProgressList[index] = value;
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
this.state = QuestState.QUEST_STATE_FINISHED;
|
||||
this.finishTime = Utils.getCurrentSeconds();
|
||||
public void finish() {
|
||||
this.state = QuestState.QUEST_STATE_FINISHED;
|
||||
this.finishTime = Utils.getCurrentSeconds();
|
||||
|
||||
if (getQuestData().finishParent()) {
|
||||
// This quest finishes the questline - the main quest will also save the quest to db, so we don't have to call save() here
|
||||
getMainQuest().finish();
|
||||
}
|
||||
if (getQuestData().finishParent()) {
|
||||
// This quest finishes the questline - the main quest will also save the quest to db, so we don't have to call save() here
|
||||
getMainQuest().finish();
|
||||
}
|
||||
|
||||
getQuestData().getFinishExec().forEach(e -> getOwner().getServer().getQuestSystem().triggerExec(this, e, e.getParam()));
|
||||
//Some subQuests have conditions that subQuests are finished (even from different MainQuests)
|
||||
getOwner().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_QUEST_STATE_EQUAL, this.subQuestId, this.state.getValue(),0,0,0);
|
||||
getOwner().getQuestManager().triggerEvent(QuestTrigger.QUEST_COND_STATE_EQUAL, this.subQuestId, this.state.getValue(),0,0,0);
|
||||
|
||||
if (ChapterData.endQuestChapterMap.containsKey(subQuestId)){
|
||||
if (ChapterData.endQuestChapterMap.containsKey(subQuestId)) {
|
||||
mainQuest.getOwner().sendPacket(new PacketChapterStateNotify(
|
||||
ChapterData.endQuestChapterMap.get(subQuestId).getId(),
|
||||
ChapterStateOuterClass.ChapterState.CHAPTER_STATE_END
|
||||
@@ -155,7 +155,7 @@ public class GameQuest {
|
||||
}
|
||||
|
||||
Grasscutter.getLogger().debug("Quest {} is finished", subQuestId);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
public void fail() {
|
||||
@@ -171,9 +171,9 @@ public class GameQuest {
|
||||
// Return true if ParentQuest should rewind to this childQuest
|
||||
public boolean rewind(GameQuest nextRewind) {
|
||||
if (questData.isRewind()) {
|
||||
if(nextRewind == null) {return true;}
|
||||
if (nextRewind == null) {return true;}
|
||||
// if the next isRewind subQuest is none or unstarted, reset all subQuests with order higher than this one, and restart this quest
|
||||
if(nextRewind.getState() == QuestState.QUEST_STATE_NONE|| nextRewind.getState() == QuestState.QUEST_STATE_UNSTARTED) {
|
||||
if (nextRewind.getState() == QuestState.QUEST_STATE_NONE|| nextRewind.getState() == QuestState.QUEST_STATE_UNSTARTED) {
|
||||
getMainQuest().getChildQuests().values().stream().filter(p -> p.getQuestData().getOrder() > this.getQuestData().getOrder()).forEach(q -> q.setState(QuestState.QUEST_STATE_UNSTARTED));
|
||||
this.start();
|
||||
return true;
|
||||
@@ -181,31 +181,31 @@ public class GameQuest {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void save() {
|
||||
getMainQuest().save();
|
||||
}
|
||||
public void save() {
|
||||
getMainQuest().save();
|
||||
}
|
||||
|
||||
public Quest toProto() {
|
||||
Quest.Builder proto = Quest.newBuilder()
|
||||
.setQuestId(getSubQuestId())
|
||||
.setState(getState().getValue())
|
||||
.setParentQuestId(getMainQuestId())
|
||||
.setStartTime(getStartTime())
|
||||
.setStartGameTime(438)
|
||||
.setAcceptTime(getAcceptTime());
|
||||
public Quest toProto() {
|
||||
Quest.Builder proto = Quest.newBuilder()
|
||||
.setQuestId(getSubQuestId())
|
||||
.setState(getState().getValue())
|
||||
.setParentQuestId(getMainQuestId())
|
||||
.setStartTime(getStartTime())
|
||||
.setStartGameTime(438)
|
||||
.setAcceptTime(getAcceptTime());
|
||||
|
||||
if (getFinishProgressList() != null) {
|
||||
for (int i : getFinishProgressList()) {
|
||||
proto.addFinishProgressList(i);
|
||||
}
|
||||
}
|
||||
if (getFinishProgressList() != null) {
|
||||
for (int i : getFinishProgressList()) {
|
||||
proto.addFinishProgressList(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (getFailProgressList() != null) {
|
||||
for (int i : getFailProgressList()) {
|
||||
proto.addFailProgressList(i);
|
||||
}
|
||||
}
|
||||
if (getFailProgressList() != null) {
|
||||
for (int i : getFailProgressList()) {
|
||||
proto.addFailProgressList(i);
|
||||
}
|
||||
}
|
||||
|
||||
return proto.build();
|
||||
}
|
||||
return proto.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import lombok.Getter;
|
||||
|
||||
public class QuestManager extends BasePlayerManager {
|
||||
|
||||
@Getter private final Player player;
|
||||
@Getter private final Player player;
|
||||
@Getter private final Int2ObjectMap<GameMainQuest> mainQuests;
|
||||
@Getter private List<GameQuest> addToQuestListUpdateNotify;
|
||||
/*
|
||||
@@ -62,17 +62,17 @@ public class QuestManager extends BasePlayerManager {
|
||||
|
||||
*/
|
||||
|
||||
public static long getQuestKey(int mainQuestId){
|
||||
public static long getQuestKey(int mainQuestId) {
|
||||
QuestEncryptionKey questEncryptionKey = GameData.getMainQuestEncryptionMap().get(mainQuestId);
|
||||
return questEncryptionKey != null ? questEncryptionKey.getEncryptionKey() : 0L;
|
||||
}
|
||||
public QuestManager(Player player) {
|
||||
public QuestManager(Player player) {
|
||||
|
||||
super(player);
|
||||
this.player = player;
|
||||
this.mainQuests = new Int2ObjectOpenHashMap<>();
|
||||
this.player = player;
|
||||
this.mainQuests = new Int2ObjectOpenHashMap<>();
|
||||
this.addToQuestListUpdateNotify = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public void onNewPlayerCreate() {
|
||||
|
||||
@@ -86,9 +86,9 @@ public class QuestManager extends BasePlayerManager {
|
||||
public void onLogin() {
|
||||
|
||||
List<GameMainQuest> activeQuests = getActiveMainQuests();
|
||||
for(GameMainQuest quest : activeQuests) {
|
||||
for (GameMainQuest quest : activeQuests) {
|
||||
List<Position> rewindPos = quest.rewind(); // <pos, rotation>
|
||||
if(rewindPos != null) {
|
||||
if (rewindPos != null) {
|
||||
getPlayer().getPosition().set(rewindPos.get(0));
|
||||
getPlayer().getRotation().set(rewindPos.get(1));
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class QuestManager extends BasePlayerManager {
|
||||
|
||||
private List<GameMainQuest> addMultMainQuests(Set<Integer> mainQuestIds) {
|
||||
List<GameMainQuest> newQuests = new ArrayList<>();
|
||||
for(Integer id : mainQuestIds) {
|
||||
for (Integer id : mainQuestIds) {
|
||||
getMainQuests().put(id.intValue(),new GameMainQuest(this.player, id));
|
||||
getMainQuestById(id).save();
|
||||
newQuests.add(getMainQuestById(id));
|
||||
@@ -130,9 +130,9 @@ public class QuestManager extends BasePlayerManager {
|
||||
Grasscutter.getLogger().debug("Decremented questGlobalVar {} value from {} to {}", variable, previousValue, previousValue - dec);
|
||||
}
|
||||
|
||||
public GameMainQuest getMainQuestById(int mainQuestId) {
|
||||
return getMainQuests().get(mainQuestId);
|
||||
}
|
||||
public GameMainQuest getMainQuestById(int mainQuestId) {
|
||||
return getMainQuests().get(mainQuestId);
|
||||
}
|
||||
|
||||
public GameQuest getQuestById(int questId) {
|
||||
QuestData questConfig = GameData.getQuestDataMap().get(questId);
|
||||
@@ -140,7 +140,7 @@ public class QuestManager extends BasePlayerManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
GameMainQuest mainQuest = getMainQuests().get(questConfig.getMainId());
|
||||
GameMainQuest mainQuest = getMainQuests().get(questConfig.getMainId());
|
||||
|
||||
if (mainQuest == null) {
|
||||
return null;
|
||||
@@ -149,34 +149,34 @@ public class QuestManager extends BasePlayerManager {
|
||||
return mainQuest.getChildQuests().get(questId);
|
||||
}
|
||||
|
||||
public void forEachQuest(Consumer<GameQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
callback.accept(quest);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void forEachQuest(Consumer<GameQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
callback.accept(quest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void forEachMainQuest(Consumer<GameMainQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
callback.accept(mainQuest);
|
||||
}
|
||||
}
|
||||
public void forEachMainQuest(Consumer<GameMainQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
callback.accept(mainQuest);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
public void forEachActiveQuest(Consumer<GameQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
if (quest.getState() != QuestState.QUEST_STATE_FINISHED) {
|
||||
callback.accept(quest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
public void forEachActiveQuest(Consumer<GameQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
if (quest.getState() != QuestState.QUEST_STATE_FINISHED) {
|
||||
callback.accept(quest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GameMainQuest addMainQuest(QuestData questConfig) {
|
||||
GameMainQuest mainQuest = new GameMainQuest(getPlayer(), questConfig.getMainId());
|
||||
getMainQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
||||
public GameMainQuest addMainQuest(QuestData questConfig) {
|
||||
GameMainQuest mainQuest = new GameMainQuest(getPlayer(), questConfig.getMainId());
|
||||
getMainQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
||||
|
||||
getPlayer().sendPacket(new PacketFinishedParentQuestUpdateNotify(mainQuest));
|
||||
|
||||
@@ -200,14 +200,14 @@ public class QuestManager extends BasePlayerManager {
|
||||
// Sub quest
|
||||
GameQuest quest = mainQuest.getChildQuestById(questId);
|
||||
|
||||
// Forcefully start
|
||||
quest.start();
|
||||
// Forcefully start
|
||||
quest.start();
|
||||
|
||||
// Save main quest
|
||||
mainQuest.save();
|
||||
|
||||
// Send packet
|
||||
getPlayer().sendPacket(new PacketQuestListUpdateNotify(mainQuest.getChildQuests().values().stream()
|
||||
// Send packet
|
||||
getPlayer().sendPacket(new PacketQuestListUpdateNotify(mainQuest.getChildQuests().values().stream()
|
||||
.filter(p -> p.getState() != QuestState.QUEST_STATE_UNSTARTED)
|
||||
.toList()));
|
||||
|
||||
@@ -230,12 +230,12 @@ public class QuestManager extends BasePlayerManager {
|
||||
}
|
||||
|
||||
//TODO
|
||||
public void triggerEvent(QuestTrigger condType, String paramStr, int... params) {
|
||||
public void triggerEvent(QuestTrigger condType, String paramStr, int... params) {
|
||||
Grasscutter.getLogger().debug("Trigger Event {}, {}, {}", condType, paramStr, params);
|
||||
List<GameMainQuest> checkMainQuests = this.getMainQuests().values().stream()
|
||||
.filter(i -> i.getState() != ParentQuestState.PARENT_QUEST_STATE_FINISHED)
|
||||
.toList();
|
||||
switch(condType){
|
||||
switch (condType) {
|
||||
//accept Conds
|
||||
case QUEST_COND_STATE_EQUAL:
|
||||
case QUEST_COND_STATE_NOT_EQUAL:
|
||||
@@ -295,12 +295,12 @@ public class QuestManager extends BasePlayerManager {
|
||||
default:
|
||||
Grasscutter.getLogger().error("Unhandled QuestTrigger {}", condType);
|
||||
}
|
||||
if(this.addToQuestListUpdateNotify.size() != 0){
|
||||
if (this.addToQuestListUpdateNotify.size() != 0) {
|
||||
this.getPlayer().getSession().send(new PacketQuestListUpdateNotify(this.addToQuestListUpdateNotify));
|
||||
this.addToQuestListUpdateNotify.clear();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public List<QuestGroupSuite> getSceneGroupSuite(int sceneId) {
|
||||
return getMainQuests().values().stream()
|
||||
@@ -317,14 +317,14 @@ public class QuestManager extends BasePlayerManager {
|
||||
for (GameMainQuest mainQuest : quests) {
|
||||
mainQuest.setOwner(this.getPlayer());
|
||||
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
quest.setMainQuest(mainQuest);
|
||||
quest.setConfig(GameData.getQuestDataMap().get(quest.getSubQuestId()));
|
||||
}
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
quest.setMainQuest(mainQuest);
|
||||
quest.setConfig(GameData.getQuestDataMap().get(quest.getSubQuestId()));
|
||||
}
|
||||
|
||||
this.getMainQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
||||
}
|
||||
}
|
||||
this.getMainQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
||||
}
|
||||
}
|
||||
|
||||
public List<GameMainQuest> getActiveMainQuests() {
|
||||
return getMainQuests().values().stream().filter(p -> !p.isFinished()).toList();
|
||||
|
||||
@@ -9,9 +9,9 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_COND_LUA_NOTIFY)
|
||||
public class ConditionLuaNotify extends QuestBaseHandler {
|
||||
//Wrong implementation. Example: 7010226 has no paramStr
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
return condition.getParam()[0] == Integer.parseInt(paramStr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@ public class ConditionQuestGlobalVarEqual extends QuestBaseHandler {
|
||||
Grasscutter.getLogger().debug("questGlobarVar {} : {}", params[0],questGlobalVarValue);
|
||||
return questGlobalVarValue.intValue() == params[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@ public class ConditionQuestGlobalVarGreater extends QuestBaseHandler {
|
||||
Grasscutter.getLogger().debug("questGlobarVar {} : {}", params[0],questGlobalVarValue);
|
||||
return questGlobalVarValue.intValue() > params[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@ public class ConditionQuestGlobalVarLess extends QuestBaseHandler {
|
||||
Grasscutter.getLogger().debug("questGlobarVar {} : {}", params[0],questGlobalVarValue);
|
||||
return questGlobalVarValue.intValue() < params[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_COND_STATE_EQUAL)
|
||||
public class ConditionStateEqual extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
GameQuest checkQuest = quest.getOwner().getQuestManager().getQuestById(condition.getParam()[0]);
|
||||
if (checkQuest == null) {
|
||||
/*
|
||||
@@ -22,6 +22,6 @@ public class ConditionStateEqual extends QuestBaseHandler {
|
||||
return false;
|
||||
}
|
||||
return checkQuest.getState().getValue() == condition.getParam()[1];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_ADD_QUEST_PROGRESS)
|
||||
public class ContentAddQuestProgress extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
/*
|
||||
//paramStr is a lua group, params[0] may also be a lua group!
|
||||
questid = xxxxxx lua group = xxxxxxyy
|
||||
count seems relevant only for lua group
|
||||
*/
|
||||
return condition.getParam()[0] == params[0]; //missing params[1], paramStr, and count
|
||||
}
|
||||
return condition.getParam()[0] == params[0]; //missing params[1], paramStr, and count
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,4 +19,4 @@ public class ContentCompleteAnyTalk extends QuestBaseHandler {
|
||||
return talkData == null || condition.getParamStr().contains(paramStr) || checkMainQuest.getChildQuestById(params[0]) != null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,17 +11,17 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_COMPLETE_TALK)
|
||||
public class ContentCompleteTalk extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
GameMainQuest checkMainQuest = quest.getOwner().getQuestManager().getMainQuestById(params[0] / 100);
|
||||
if (checkMainQuest == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
MainQuestData.TalkData talkData = checkMainQuest.getTalks().get(condition.getParam()[0]);
|
||||
return talkData != null;
|
||||
|
||||
// This expression makes zero sense.
|
||||
// return talkData == null || condition.getParamStr().contains(paramStr) || checkMainQuest.getChildQuestById(params[0]) != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_ENTER_DUNGEON)
|
||||
public class ContentEnterDungeon extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
return condition.getParam()[0] == params[0]; //missing params[1]
|
||||
}
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
return condition.getParam()[0] == params[0]; //missing params[1]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_FINISH_PLOT)
|
||||
public class ContentFinishPlot extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
MainQuestData.TalkData talkData = quest.getMainQuest().getTalks().get(Integer.valueOf(params[0]));
|
||||
GameQuest subQuest = quest.getMainQuest().getChildQuestById(params[0]);
|
||||
return talkData != null || subQuest != null;
|
||||
|
||||
@@ -9,11 +9,11 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_QUEST_STATE_EQUAL)
|
||||
public class ContentQuestStateEqual extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
GameQuest checkQuest = quest.getOwner().getQuestManager().getQuestById(condition.getParam()[0]);
|
||||
if (checkQuest == null) {return false;}
|
||||
return checkQuest.getState().getValue() == params[1];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,4 +20,4 @@ public class ContentQuestStateNotEqual extends QuestBaseHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class ContentTriggerFire extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) {
|
||||
if(quest.getTriggers().containsKey(quest.getTriggerNameById(params[0]))) {
|
||||
if (quest.getTriggers().containsKey(quest.getTriggerNameById(params[0]))) {
|
||||
//We don't want to put a new key here
|
||||
return quest.getTriggers().get(quest.getTriggerNameById(params[0]));
|
||||
} else {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package emu.grasscutter.game.quest.enums;
|
||||
|
||||
public enum QuestState {
|
||||
QUEST_STATE_NONE (0),
|
||||
QUEST_STATE_UNSTARTED (1),
|
||||
QUEST_STATE_UNFINISHED (2),
|
||||
QUEST_STATE_FINISHED (3),
|
||||
QUEST_STATE_FAILED (4),
|
||||
QUEST_STATE_NONE (0),
|
||||
QUEST_STATE_UNSTARTED (1),
|
||||
QUEST_STATE_UNFINISHED (2),
|
||||
QUEST_STATE_FINISHED (3),
|
||||
QUEST_STATE_FAILED (4),
|
||||
|
||||
// Used by lua
|
||||
NONE (0),
|
||||
@@ -14,13 +14,13 @@ public enum QuestState {
|
||||
FINISHED(3),
|
||||
FAILED(4);
|
||||
|
||||
private final int value;
|
||||
private final int value;
|
||||
|
||||
QuestState(int id) {
|
||||
this.value = id;
|
||||
}
|
||||
QuestState(int id) {
|
||||
this.value = id;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@ public class ExecIncQuestGlobalVar extends QuestExecHandler {
|
||||
quest.getOwner().getQuestManager().incQuestGlobalVarValue(Integer.valueOf(paramStr[0]),Integer.valueOf(paramStr[1]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -725,7 +725,7 @@ public class InventorySystem extends BaseGameSystem {
|
||||
// Invoke player use food event.
|
||||
PlayerUseFoodEvent event = new PlayerUseFoodEvent(player, itemData, target.getAsEntity());
|
||||
// Call the event.
|
||||
event.call(); if(!event.isCanceled()) {
|
||||
event.call(); if (!event.isCanceled()) {
|
||||
used = player.getTeamManager().reviveAvatar(target) ? 1 : 0;
|
||||
}
|
||||
} else {
|
||||
@@ -741,7 +741,7 @@ public class InventorySystem extends BaseGameSystem {
|
||||
// Invoke player use food event.
|
||||
PlayerUseFoodEvent event = new PlayerUseFoodEvent(player, itemData, target.getAsEntity());
|
||||
// Call the event.
|
||||
event.call(); if(!event.isCanceled()) {
|
||||
event.call(); if (!event.isCanceled()) {
|
||||
int[] SatiationParams = itemData.getSatiationParams();
|
||||
used = player.getTeamManager().healAvatar(target, SatiationParams[0], SatiationParams[1]) ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -547,9 +547,9 @@ public class Scene {
|
||||
.flatMap(Collection::stream)
|
||||
.toList();
|
||||
|
||||
onLoadGroup(groups);
|
||||
Grasscutter.getLogger().info("Scene {} Block {} loaded.", this.getId(), block.id);
|
||||
}
|
||||
onLoadGroup(groups);
|
||||
Grasscutter.getLogger().info("Scene {} Block {} loaded.", this.getId(), block.id);
|
||||
}
|
||||
public void loadTriggerFromGroup(SceneGroup group, String triggerName) {
|
||||
//Load triggers and regions
|
||||
getScriptManager().registerTrigger(group.triggers.values().stream().filter(p -> p.name.contains(triggerName)).toList());
|
||||
|
||||
Reference in New Issue
Block a user