Closed SonicX8000 closed 4 years ago
How about the following examples?
Attribute: generic.attackDamage Amount: -0.25 Operation: 2 Maximum Hunger: 6
This makes you deal 25% less damage if you are at or below 6 hunger, without having to resort to the Weakness effect.
Attribute: generic.movementSpeed Amount: 0.10 Operation: 2 Minimum Hunger: 50 Maximum Hunger: 200
This makes you walk/run 10% faster if your hunger level is above 50, but below 200. The bonus is lost if your hunger goes above 200, and re-gained if your hunger goes below that same value.
Yea, just like that. I was editing my post to show the min/max hunger example but guess I got ninja'd before I could finish the edit.
By the way, -1 is 'unlimited' meaning no cap.
So mods like Hunger Overhaul and CraftTweaker should allow you to grant potion effects at any hunger level with a script like
events.onPlayerTick(function(event as crafttweaker.event.PlayerTickEvent)
{
if(event.player.foodStats.foodLevel < 3)
{
event.player.addPotionEffect(<potion:midnight:darkness>.makePotionEffect(100, 0, false, false));
}
if(event.player.foodStats.foodLevel < 4)
{
event.player.addPotionEffect(<potion:minecraft:weakness>.makePotionEffect(100, 2, false, false));
}
if(event.player.foodStats.foodLevel < 5)
{
event.player.addPotionEffect(<potion:minecraft:mining_fatigue>.makePotionEffect(100, 2, false, false));
}
if(event.player.foodStats.foodLevel < 6)
{
event.player.addPotionEffect(<potion:minecraft:slowness>.makePotionEffect(100, 2, false, false));
}
});
Now I believe foodLevel won't take into account any extra hunger you have over 20 (since it refers to the foodLevel field in the IPlayer's food stats), but please correct me if I'm wrong. Adding potion effects based on hunger level would be as simple as just allowing CraftTweaker to access ScalingFeast's food levels, which was something that was being considered, but I hadn't decided to do it because I couldn't think of use cases to justify it, which I now have.
As for attributes, I'm not sure how easy it is to modify player attributes using ZenScript (I know they can be accessed at least). If it's not too bad, then I see no point adding such a feature to Scaling Feast if it can be replicated with ZenScript and CraftTweaker integration. If someone could follow up with an answer to that (and maybe a CT script as proof of concept if it's possible), that'd be great. If it's possible, this issue just boils down to CraftTweaker integration.
If not already made, would it be possible for you to make a seperate mod to expose attribute API methods to CraftTweaker so as to essentially replicate the functionality of the /attribute
command? In other words, API functions should be provided to:
/attribute get
)/attribute base get
)/attribute base set
)/attribute modifier add
)/attribute modifier remove
)/attribute modifier get
)/attribute modifier set
)Use cases would include something similar to the original intent for this issue, but also many others that don't have to involve Scaling Feast at all, such as a direct movement speed slowdown and projectile damage decrease if the player is at low health for example.
If it doesn't exist, making an addon mod would probably be simple to do (and small), so I'll happily take up the reins on that.
I've looked through mods on CurseForge and I couldn't find anything related to modifying attributes with CT so I'm still not sure if it's possible
Take a look at this snippet from ScalingFeast's source: https://github.com/yeelp/Scaling-Feast/blob/50d90d86e86f6449a57e2edf0d3a91df0aed9377/src/main/java/yeelp/scalingfeast/handlers/HUDOverlayHandler.java#L230-L231
Been a while since I looked at this part of the source, as this is for drawing HUD elements. Notice how I'm using Minecraft's methods for getting hunger values and saturation values. AppleCore nicely expands food stats to accomodate a variable maximum hunger. So, additional CraftTweaker integration shouldn't be needed for supporting such a feature (at least for potion effects). You should be able to access the extra foodLevel just fine.
I will still however expose certain elements to CraftTweaker, like accessing a player's max hunger and adding modifiers to that max hunger, accessing a player's bloated hunger amount, and other constants from the config.
I... forget if something like this was suggested before, so forgive me for the duped suggestion.
Being that we can increase our hunger, I wonder if we can apply attribute modifiers as long as you're above x hunger, like if you keep your hunger bar above a certain value... you get certain bonuses applied, much like how with vanilla if you didn't keep your hunger above 6... you're unable to sprint. Here's some examples.
Attribute: generic.movementSpeed Amount: 0.05 Operation: 2 Minimum Hunger needed: 20 Maximum Hunger needed: -1
This will grant you a +5% boost to your movement speed as long as you're above 20+ hunger.
Attribute: generic.attackDamage Amount: 2 Operation: 0 Minimum Hunger needed: 30 Maximum Hunger needed: -1
This will give you a +2 damage boost to your melee attacks if you have 30+ hunger.
Some modded attribute examples.
Attribute: generic.attackDamage, potioncore.projectileDamage, potioncore.magicDamage Amount: 3 Operation: 0 Minimum Hunger needed: 40 Maximum Hunger needed: 60
This will give you a +3 damage boost to your melee attacks, as well a +3 damage boost for Projectile/Magic attacks as long as you're at 40+ Hunger. However... due to the Maximum Hunger value being set at 60, you'll lose this boost if you go above 60 hunger so it'll need to be between 40-60 to get the bonus.
Now being that you already have a +2 attack boost from the other Hunger attribute bonuses, your attack damage actually gets boosted to +5 attack damage. So you have +5% Speed, +5 Attack Damage, +3 Projectile Damage & +3 Magic Damage right now.
=====
As long as you know what the attribute modifiers are, you can customize the amount of buffs that the player gets for increasing max hunger as well as maintaining it above the limits. You could even apply negative attribute modifiers as a punishment for not keeping your hunger topped off. Here's some examples.
=====
Attribute: generic.attackDamage, potioncore.projectileDamage, potioncore.magicDamage Amount: -0.1 Operation: 2 Minimum Hunger needed: -1 Maximum Hunger needed: 10
This will lower your damage for melee, projectile & magic attacks by -10% if you should drop at 10 hunger or less. Once you go above 10 hunger this bonus will be removed.
Attribute: generic.movementSpeed Amount: -0.2 Operation: 2 Minimum Hunger needed: -1 Maximum Hunger needed: 0
Movement speed is lowered by -20% if hunger hits 0. You're starving and you barely have any energy left. This bonus will clear once you get above 0 hunger.
=====
Potion Effects could be applied this way as well, as I dunno if there's a vanilla dig speed attribute. Was thinking of giving Mining Fatigue if you had 0 hunger aka starving. One example...
Effect: minecraft:mining_fatigue Level: 1 Minimum Hunger needed: -1 Maximum Hunger needed: 0
This gives the player Mining Fatigue II, as long as they're at 0 hunger. It'll clear once you go above 0 hunger.