Started by
swelkinn_n
on
Topic category: Help with Minecraft modding (Java Edition)
Very similar in concept to the Feral Bite effect from Terraria, I want to make a potion effect that will, as the player has it, randomly inflict other potion effects, or (for example) play a sound, etc
I am unsure on how exactly to go about this, since I want those effects to be independent from the custom potion effect, and have their own timers and can expire separately from the custom effect, etc
I know that it would be an RNG procedure along with a timer procedure (to make sure it doesnt randomly inflict an effect every tick or so), but I am unable to get any I know to work
I've tried doing something similar- an RNG thing that randomly decides the duration between applying effects and the effect to apply should suffice, but I have had some issues where potion effects that are chosen using random generation sometimes don't work properly. (To fix this, I made the effects based on something sort of random- like the cycles of the moon.) You could also make it so that the duration between applying effects is random, and the potion effect itself is determined based on, say, the position of the entity, or the last digit of the time of day. (Something that's random enough to be... random, but not actually an RNG generator.)
Mindthemoods, mind sending an example ? I'm not the best with these things lol
Ideally, something like this should work- the only thing you need to change is make the 'delay' a global, player-lifetime variable rather than a local one.
Hook this up to your custom effect; every second, if the player has no delay left from the effect, there's a 10% chance of the player getting one minute of one of the randomly selected status effects. Afterwords, it sets the delay to one minute. If the player has any delay left, the effect decreases the delay instead.
You can add as many effects as you want, and can have this trigger other custom effects as well; you could also add another variable to randomize the duration of the effect, and set the delay to the same duration.
...The only thing I'd be careful of is I have had bugs in the past where trying to randomly inflict a potion effect adds particles and the effect icon, but not the effect itself. However, this is probably the most straightforward solution.
Finally got around to testing this, it seems like the first time it doesn't work but all subsequent procs of the effect work which I'm more than fine with
You actually had it right in the image, as (at least in my testing) it doesn't actually work with the global variable for some reason.
Nonetheless, thank you a lot for this !! I'm very glad to get this working
How did you add more potion effects? do you just add the and block or do i add more if do blocks
Add more 'else-if' blocks to the middle section with the other effects, and just make sure you change the randomizer to include however many effects you want. If you want some effects to be more likely than others, you can set the triggers to a certain range, (say, if the random number is greater than 5 and less than 8), to increase their likelihood.