Increase Exhaustion when far from spawn

Discussion in 'Plugin Development' started by White_King, Nov 19, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    White_King

    I've been looking for a solution on how to put an Exhaustion modifier on players depending on how far away are they from the spawn. I want them to get hungrier faster depending on how far they are.

    I'm thinking on something like:
    Code:
    player.setExhaustion( player.getExhaustion() * spawnLocation.distanceSquared( player.getLocation() )*mod )
    An interesting thing will be when to set it (which event) I want it to be easy on performance so I'm thinking this:
    1. The onFoodLevelChange event
    2. Every 10 seconds
    The problem is that I'm not sure but I bet the game will modify the Exhaustion level depending on the activities of the player (running, swimming,...) and totally ignore the modifier that I'm adding on it.

    Does someone knows what to do to make the modifier stick until it is recalculated by the function again? or suggest me another solution?

    Thank you!
     
    Last edited by a moderator: Nov 19, 2018
  2. @White_King

    The best way to investigate this behavior is to test it. For testing, you can add a simple timer that executes every 5 seconds and broadcasts your current exhaustion. You can also add a command that multiplier your exhaustion and just see when the modifier disappears. This should give you very useful info to develop your plug-in. Also, make sure you don't let your exhaustion 'stack'. (You multiply the current exhaustion, so what would happen if you call that line of code again before the exhaustion resets?)
     
Thread Status:
Not open for further replies.

Share This Page