pufmat / skillsmod

A Minecraft mod that adds a fully configurable skill system to the game.
Other
36 stars 10 forks source link

Team experience share for Kill Entity source #96

Open Trynthlas opened 2 months ago

Trynthlas commented 2 months ago

This is intended to use the vanilla team mechanic to find players within a set range to share experience from kills, if the option is enabled in the kill_entity experience source. team_shared_experience enables the feature when present, and configures the max distance in which to share experience between the attacking player and their teammates.

{
    "type": "puffish_skills:kill_entity",
    "data": {
        "variables": {
            "dropped_xp": {
                "operations": [
                    {
                        "type": "dropped_experience"
                    }
                ]
            },
            "max_health": {
                "operations": [
                    {
                        "type": "killed_living_entity"
                    },
                    {
                        "type": "max_health"
                    }
                ]
            }
        },
        "experience": [
            {
                "expression": "dropped_xp + max_health / 20"
            }
        ],
                "team_shared_experience": {
                        "max_share_distance": 100
                },
        "anti_farming": {
            "limit_per_chunk": 15,
            "reset_after_seconds": 300
        }
    }
}

Experience is shared evenly between all team members in range (including the player who got the final blow), but provide a minimum of 1 xp to all eligible team members.

Additionally, added is_on_team as a supported predicate if a user wishes to leverage this in their operations or experience expression.

I opted to not change the parameters or logic around the anti_farming behavior, because there is likely no net gain for someone to alternate killing blows while in a team (and sharing the xp) vs normal xp gain while not in a team. The existing behavior should suffice.