Skip to content

Commit

Permalink
Attributes for DBNO and Neonatal duration (#1297)
Browse files Browse the repository at this point in the history
* neonatal, dbno timer and never ignore exhaustion attributes

* rename attributes, general fixes

* increase blood exhaustion for healing

* remove healing exhaustion attribute and use blood exhaustion attribute every time

---------

Co-authored-by: cheaterpaul <dev@paube.de>
  • Loading branch information
TheDrOfDoctoring and Cheaterpaul authored Dec 14, 2023
1 parent 1d81f56 commit 32b0230
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import de.teamlapen.vampirism.client.gui.components.CooldownButton;
import de.teamlapen.vampirism.entity.player.vampire.VampirePlayer;
import de.teamlapen.vampirism.network.ServerboundSimpleInputEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
Expand All @@ -13,9 +14,12 @@
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.gui.widget.ExtendedButton;
import net.minecraftforge.common.util.LazyOptional;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Optional;

@OnlyIn(Dist.CLIENT)
public class DBNOScreen extends Screen {

Expand Down Expand Up @@ -75,9 +79,7 @@ public void tick() {
if (this.enableButtonsTimer == 20) {
dieButton.active = true;
}
float prog = this.minecraft.player != null ? VampirePlayer.getOpt(this.minecraft.player).map(v -> v.getDbnoTimer() / (float) v.getDbnoDuration()).orElse(1f) : 1f;
resurrectButton.updateState(prog);

resurrectButton.updateState(Optional.ofNullable(this.minecraft.player).map(VampirePlayer::getOpt).flatMap(LazyOptional::resolve).filter(v -> v.getDbnoDuration() > 0).map(v -> v.getDbnoTimer() / (float) v.getDbnoDuration()).orElse(0f));
}

protected void init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ public class BalanceConfig {
vsBloodVisionDistanceSq = builder.comment("Squared blood vision distance").defineInRange("bloodVisionDistanceSq", 1600, 5, Integer.MAX_VALUE);
vsSmallAttackDamageModifier = builder.comment("Damage added to base damage").defineInRange("smallAttackDamageModifier", 1d, 0, 10d);
vsSmallAttackSpeedModifier = builder.comment("Basic skill - Weapon cooldown = 1/(oldvalue*(1+modifier))").defineInRange("smallAttackSpeedModifier", 0.15, 0, 3);
vsNeonatalReduction = builder.comment("Reduced percentage of the neonatal effect").defineInRange("neonatalReduction", 0.5, 0, 1);
vsDbnoReduction = builder.comment("Reduced percentage of the downed timer required to resurrect").defineInRange("dbnoReduction", 0.5, 0, 1);
vsNeonatalReduction = builder.comment("Reduced percentage of the neonatal effect").defineInRange("neonatalReduction", 0.5, 0, 1024);
vsDbnoReduction = builder.comment("Reduced percentage of the downed timer required to resurrect").defineInRange("dbnoReduction", 0.5, 0, 1024);


//Vampire Player TODO 1.19 rename *MaxMod to *MaxLevelMod and clarify whether it is a multiplicative or additive modifier
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/de/teamlapen/vampirism/core/ModAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ public class ModAttributes {
* Registered for EntityPlayer
*/
public static final RegistryObject<RangedAttribute> BLOOD_EXHAUSTION = ATTRIBUTES.register("blood_exhaustion", () -> (RangedAttribute) new RangedAttribute("vampirism.blood_exhaustion", 1.0, 0.0, 10).setSyncable(true));
/**
* Allows modifying the duration of the neonatal effect.
* Registered for EntityPlayer
*/
public static final RegistryObject<RangedAttribute> NEONATAL_DURATION = ATTRIBUTES.register("neonatal_duration", () -> (RangedAttribute) new RangedAttribute("vampirism.neonatal_duration", 1.0, 0.0, Integer.MAX_VALUE).setSyncable(true));
/**
* Allows modifying the length of the resurrection timer.
* Registered for EntityPlayer
*/
public static final RegistryObject<RangedAttribute> DBNO_DURATION = ATTRIBUTES.register("dbno_duration", () -> (RangedAttribute) new RangedAttribute("vampirism.dbno_duration", 1.0, 0.0, Integer.MAX_VALUE).setSyncable(true));

static void register(IEventBus bus) {
ATTRIBUTES.register(bus);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/de/teamlapen/vampirism/core/ModEntities.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ static void onRegisterEntityTypeAttributes(@NotNull EntityAttributeCreationEvent
static void onModifyEntityTypeAttributes(@NotNull EntityAttributeModificationEvent event) {
event.add(EntityType.PLAYER, ModAttributes.SUNDAMAGE.get());
event.add(EntityType.PLAYER, ModAttributes.BLOOD_EXHAUSTION.get());
event.add(EntityType.PLAYER, ModAttributes.NEONATAL_DURATION.get());
event.add(EntityType.PLAYER, ModAttributes.DBNO_DURATION.get());
}

private static <T extends Entity> RegistryObject<EntityType<T>> prepareEntityType(String id, @NotNull Supplier<EntityType.Builder<T>> builder, boolean spawnable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ public boolean onUpdate() {
if (regen && this.bloodSaturationLevel > 0 && player.isHurt() && this.bloodLevel >= maxBlood) {
++this.bloodTimer;
if (this.bloodTimer >= 10) {
float f = Math.min(this.bloodSaturationLevel, 4F);
player.heal(f / 4F);
this.addExhaustion(f, true);
float f = Math.min(this.bloodSaturationLevel, 6F);
player.heal(f / 6F);
this.addExhaustion(f);
this.bloodTimer = 0;
}
} else if (regen && this.bloodLevel >= (18) && player.isHurt()) {
++this.bloodTimer;

if (this.bloodTimer >= 80) {
player.heal(1.0F);
this.addExhaustion(2.8F, true);
this.addExhaustion(6F);
this.bloodTimer = 0;
}
} else if (this.bloodLevel <= 0) {
Expand Down Expand Up @@ -174,10 +174,9 @@ void addExhaustion(float amount) {
*
* @param ignoreModifier If the entity exhaustion attribute {@link de.teamlapen.vampirism.core.ModAttributes#BLOOD_EXHAUSTION} should be ignored
*/
void addExhaustion(float amount, boolean ignoreModifier) {
void addExhaustion(float amount, @SuppressWarnings("SameParameterValue") boolean ignoreModifier) {
if (!ignoreModifier) {
AttributeInstance attribute = player.getAttribute(ModAttributes.BLOOD_EXHAUSTION.get());
amount *= attribute.getValue();
amount *= (float) player.getAttributeValue(ModAttributes.BLOOD_EXHAUSTION.get());
}
this.bloodExhaustionLevel = Math.min(bloodExhaustionLevel + amount, 40F);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import de.teamlapen.vampirism.entity.player.actions.ActionHandler;
import de.teamlapen.vampirism.entity.player.skills.SkillHandler;
import de.teamlapen.vampirism.entity.player.vampire.actions.VampireActions;
import de.teamlapen.vampirism.entity.player.vampire.skills.VampireSkills;
import de.teamlapen.vampirism.entity.vampire.DrinkBloodContext;
import de.teamlapen.vampirism.fluids.BloodHelper;
import de.teamlapen.vampirism.items.VampirismHunterArmorItem;
Expand Down Expand Up @@ -441,11 +440,7 @@ public void increaseRemainingBarkTicks(int additionalTicks) {
}

public int getDbnoDuration() {
int duration = VampirismConfig.BALANCE.vpDbnoDuration.get() * 20;
if (this.skillHandler.isSkillEnabled(VampireSkills.DBNO_DURATION.get())) {
duration = Math.max(1, (int) (duration * VampirismConfig.BALANCE.vsDbnoReduction.get()));
}
return duration;
return (int) player.getAttributeValue(ModAttributes.DBNO_DURATION.get());
}

public int getDbnoTimer() {
Expand Down Expand Up @@ -1053,10 +1048,7 @@ public void tryResurrect() {
this.player.setForcedPose(null);
this.player.refreshDimensions();
this.sync(true);
int duration = VampirismConfig.BALANCE.vpNeonatalDuration.get() * 20;
if (this.skillHandler.isSkillEnabled(VampireSkills.NEONATAL_DECREASE.get())) {
duration = Math.max(1, (int) (duration * VampirismConfig.BALANCE.vsNeonatalReduction.get()));
}
int duration = (int) player.getAttributeValue(ModAttributes.NEONATAL_DURATION.get());
this.player.addEffect(new MobEffectInstance(ModEffects.NEONATAL.get(), duration));
this.player.awardStat(ModStats.resurrected);
if (this.player instanceof ServerPlayer serverPlayer) {
Expand Down Expand Up @@ -1226,11 +1218,15 @@ protected void writeFullUpdate(@NotNull CompoundTag nbt) {
private void applyEntityAttributes() {
player.getAttribute(ModAttributes.SUNDAMAGE.get()).setBaseValue(VampirismConfig.BALANCE.vpSundamage.get());
player.getAttribute(ModAttributes.BLOOD_EXHAUSTION.get()).setBaseValue(VampirismConfig.BALANCE.vpBloodExhaustionFactor.get());
player.getAttribute(ModAttributes.NEONATAL_DURATION.get()).setBaseValue(VampirismConfig.BALANCE.vpNeonatalDuration.get() * 20);
player.getAttribute(ModAttributes.DBNO_DURATION.get()).setBaseValue(VampirismConfig.BALANCE.vpDbnoDuration.get() * 20);
}

private void removeEntityAttributes() {
player.getAttribute(ModAttributes.SUNDAMAGE.get()).setBaseValue(0);
player.getAttribute(ModAttributes.BLOOD_EXHAUSTION.get()).setBaseValue(0);
player.getAttribute(ModAttributes.NEONATAL_DURATION.get()).setBaseValue(0);
player.getAttribute(ModAttributes.DBNO_DURATION.get()).setBaseValue(0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ protected void getActions(@NotNull Collection<IAction<IVampirePlayer>> list) {
//Config null, so cannot get method ref
@SuppressWarnings({"Convert2MethodRef", "FunctionalExpressionCanBeFolded"})
public static final RegistryObject<ISkill<IVampirePlayer>> VAMPIRE_ATTACK_DAMAGE = SKILLS.register("vampire_attack_damage", () -> new VampirismSkill.SimpleVampireSkill(2, false).registerAttributeModifier(Attributes.ATTACK_DAMAGE, "f2acc818-dc3a-4696-ba63-c3294290ad86", () -> VampirismConfig.BALANCE.vsSmallAttackDamageModifier.get(), AttributeModifier.Operation.ADDITION));
public static final RegistryObject<ISkill<IVampirePlayer>> NEONATAL_DECREASE = SKILLS.register("neonatal_decrease", () -> new VampirismSkill.SimpleVampireSkill(2, true));
public static final RegistryObject<ISkill<IVampirePlayer>> DBNO_DURATION = SKILLS.register("dbno_duration", () -> new VampirismSkill.SimpleVampireSkill(2, true));
public static final RegistryObject<ISkill<IVampirePlayer>> NEONATAL_DECREASE = SKILLS.register("neonatal_decrease", () -> new VampirismSkill.SimpleVampireSkill(2, true).registerAttributeModifier(ModAttributes.NEONATAL_DURATION.get(), "74ecad40-5674-4ee0-8224-f871cdd6543d", () -> VampirismConfig.BALANCE.vsNeonatalReduction.get() - 1, AttributeModifier.Operation.MULTIPLY_TOTAL));
public static final RegistryObject<ISkill<IVampirePlayer>> DBNO_DURATION = SKILLS.register("dbno_duration", () -> new VampirismSkill.SimpleVampireSkill(2, true).registerAttributeModifier(ModAttributes.DBNO_DURATION.get(), "7e5b2fb1-ba74-4838-83e1-68fd419af787", () -> VampirismConfig.BALANCE.vsDbnoReduction.get() - 1, AttributeModifier.Operation.MULTIPLY_TOTAL));
public static final RegistryObject<ISkill<IVampirePlayer>> HISSING = SKILLS.register("hissing", () -> new ActionSkill<>(VampireActions.HISSING, 1, true));
public static final RegistryObject<ISkill<IVampirePlayer>> MINION_COLLECT = SKILLS.register("vampire_minion_collect", () -> new VampirismSkill.LordVampireSkill(2, true));
public static final RegistryObject<ISkill<IVampirePlayer>> MINION_STATS_INCREASE = SKILLS.register("vampire_minion_stats_increase", () -> new VampirismSkill.LordVampireSkill(3, true).setToggleActions(vampire -> vampire.updateMinionAttributes(true), vampire -> vampire.updateMinionAttributes(false)));
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/vampirism/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,8 @@
"vampirism.blood_exhaustion": "Blood Exhaustion",
"vampirism.bite_damage": "Bite Damage",
"vampirism.sundamage": "Sun Damage",
"vampirism.neonatal_duration": "Neonatal Duration",
"vampirism.dbno_duration": "DBNO Duration",
"__comment": "item tooltips",
"item.vampirism.crossbow_arrow_vampire_killer.tooltip": "Instantly kills low level vampire NPCs.",
"item.vampirism.crossbow_arrow_spitfire.tooltip": "Creates a alchemical fire on impact",
Expand Down

0 comments on commit 32b0230

Please sign in to comment.