Last active
December 16, 2021 17:25
-
-
Save Langerz82/1bfc1cbfdce9cf298d634e78de1bbe2c to your computer and use it in GitHub Desktop.
New World - Temp Luck System - Psuedocode (Javascript).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var baseTempLuck = 50; | |
var maxTempLuck = 100; | |
var TempLuckPerLevel = 5; | |
var eliteTempLuckMod = 2; | |
Number.prototype.clamp = function(min, max) { | |
return Math.min(Math.max(this, min), max); | |
}; | |
if (mob.isDead()) | |
{ | |
var divLuck = baseTempLuck / mob.AttackedBy.length; | |
if (mob.elite) | |
divLuck = divLuck * eliteTempLuckMod; | |
for(var i; mob.AttackedBy.length; i++) | |
{ | |
var player = mob.AtttackedBy[i]; | |
// Level diff. | |
var levelDiff = mob.level - player.level; | |
var tempLuck = (levelDiff * TempLuckPerLevel) + divLuck; | |
// If less than 0 then no tempLuck added, and enforce maxTempLuck. | |
tempLuck = tempLuck.clamp(0, maxTempLuck); | |
if (tempLuck > player.tempLuck) | |
player.tempLuck = tempLuck; | |
} | |
} | |
if (chest.isOpened()) | |
{ | |
var luck = player.luck + player.tempLuck; | |
player.tempLuck = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment