You are viewing a potentially older version of this package. View all versions.
GurneyArena-EWP_Player_Reward-1.1.0 icon

EWP Player Reward

Adds configurable reward scaling based on nearby players and creature levels to Expand World Prefabs.

Date uploaded 2 weeks ago
Version 1.1.0
Download link GurneyArena-EWP_Player_Reward-1.1.0.zip
Downloads 109
Dependency string GurneyArena-EWP_Player_Reward-1.1.0

This mod requires the following mods to function

JereKuusela-Expand_World_Prefabs-1.60.0 icon
JereKuusela-Expand_World_Prefabs

Allows creating rules for objects being spawned, destroyed and more.

Preferred version: 1.60.0

README

EWP Player Reward

A small extension for Expand World Prefabs (EWP) that calculates item stack rewards based on nearby player count and the level of the creature that triggered a rule.

Requirements

  • Valheim with BepInEx
  • Expand World Prefabs 1.60.0 or newer

Features

  • Configurable radius for counting nearby players.
  • Configurable base reward.
  • Configurable bonus for each additional nearby player.
  • Configurable bonus for each creature level after level 1.
  • Returns an integer reward that can be used as an item stack value in EWP rules.
  • Includes GoblinReward, a testing function that counts nearby Goblins instead of players.

Reward formula

LevelReward = BaseReward * (1 + (Level - 1) * LevelBonus)
PlayerMultiplier = 1 + PlayerBonus * (Players - 1)
Reward = LevelReward * PlayerMultiplier

The first creature level gives the base reward; each subsequent level adds LevelBonus times the base reward. The first nearby player gives no extra bonus; each additional player adds PlayerBonus times the level-adjusted reward.

The function treats a count of zero like a count of one for reward calculation. The current implementation rounds positive fractional rewards to the nearest integer, with .5 rounded up.

Example

With BaseReward = 100, LevelBonus = 0.5 (+50% per level after the first) and PlayerBonus = 0.2 (+20% per extra player):

Creature level 1 player 2 players 3 players
1 100 120 140
2 150 180 210
3 200 240 280
4 250 300 350
5 300 360 420

For a level 3 creature and three nearby players:

LevelReward = 100 * (1 + (3 - 1) * 0.5) = 200
PlayerMultiplier = 1 + 0.2 * (3 - 1) = 1.4
Reward = 200 * 1.4 = 280

EWP usage

The function accepts eight arguments in this order:

<PlayerReward_X:Y:Z:Radius:BaseReward:Level:PlayerBonus:LevelBonus>
  • X:Y:Z — position around which players are counted; normally <x>:<y>:<z>.
  • Radius — detection radius in meters.
  • BaseReward — base item quantity.
  • Level — creature level; normally <int_level=1>.
  • PlayerBonus — additional reward per player after the first; 0.2 means +20%.
  • LevelBonus — additional base reward per creature level after the first; 0.5 means +50%.

Example rule for a Troll:

- prefab: Troll
  type: destroy
  spawn:
  - prefab: Coins
    data: int, stack, <PlayerReward_<x>:<y>:<z>:100:100:<int_level=1>:0.2:0.5>

This example searches within 100 meters, starts from 100 coins, adds 20% for each extra player, and adds 50% of the base reward for each level above 1.

Another example

- prefab: Neck
  type: destroy
  spawn:
  - prefab: Coins
    data: int, stack, <PlayerReward_<x>:<y>:<z>:20:5:<int_level=1>:0.5:0.25>

This example uses a 20-meter radius, 5 base coins, +50% per additional player, and +25% per level after the first.

GoblinReward (testing)

GoblinReward uses the same eight arguments and formula, but counts nearby Goblin characters rather than players. Goblin levels do not affect the calculation; Level is the level passed by the EWP rule.

- prefab: Troll
  type: destroy
  spawn:
  - prefab: Coins
    data: int, stack, <GoblinReward_<x>:<y>:<z>:100:100:<int_level=1>:0.2:0.5>

Upgrading from 1.0.0

Breaking change: Both PlayerReward and GoblinReward now require an eighth argument, LevelBonus.

Old syntax (1.0.0):

<PlayerReward_<x>:<y>:<z>:100:100:<int_level=1>:0.2>

New syntax (1.1.0):

<PlayerReward_<x>:<y>:<z>:100:100:<int_level=1>:0.2:0.5>

To preserve the old full base-reward increase for every additional level, use 1.0 as the eighth argument:

<PlayerReward_<x>:<y>:<z>:100:100:<int_level=1>:0.2:1.0>

Update all existing EWP rules that call these functions when upgrading.

Installation

Thunderstore Mod Manager / r2modman

Install the package through your mod manager. Its declared dependencies will be installed automatically.

Manual installation

Install BepInEx and Expand World Prefabs, then place the mod DLL (CoinReward.dll or EWPPlayerReward.dll, depending on the build name) into BepInEx/plugins/.

Important notes

  • The mod does not automatically add drops. You must configure item spawns in your EWP YAML rules.
  • PlayerReward counts player objects visible to the game instance evaluating the rule. Verify multiplayer behavior in your server setup.
  • Decimal arguments use a period (0.2), not a comma.

Version

1.1.0

CHANGELOG

Changelog

1.1.0

  • Added an eighth argument, LevelBonus, to PlayerReward and GoblinReward.
  • Creature levels now use a configurable additive bonus per level after the first, instead of always multiplying the base reward by the full level.
  • Updated reward calculation to round positive .5 values up.
  • Updated examples and documentation for the new eight-argument syntax.
  • Breaking change: Existing EWP rules must supply the new eighth argument. Use 1.0 to retain the previous level-scaling behavior.

1.0.0

  • Initial release.
  • Added PlayerReward for rewards based on nearby player count.
  • Added configurable detection radius, base reward, creature level, and bonus per additional player.
  • Included GoblinReward for testing with nearby Goblins.