Calculate NPC level from total combat power
This commit is contained in:
1 parent
3ce9e59d24
commit
3267bf2930
1 file changed
+31
-2
@@ -22,6 +22,9 @@ module MobHitBars
|
|||||||
LEVEL_FONT_SIZE = 16
|
LEVEL_FONT_SIZE = 16
|
||||||
MAX_NPC_LEVEL = 100
|
MAX_NPC_LEVEL = 100
|
||||||
YELLOW_NPC_LEVEL = 50
|
YELLOW_NPC_LEVEL = 50
|
||||||
|
POWER_REFERENCE = 196.8
|
||||||
|
HEALTH_POWER_CAP = 2500.0
|
||||||
|
STAMINA_POWER_CAP = 3000.0
|
||||||
|
|
||||||
NORMAL_LEVEL_COLOR = Color.new(255, 255, 255, 255)
|
NORMAL_LEVEL_COLOR = Color.new(255, 255, 255, 255)
|
||||||
MEDIUM_LEVEL_COLOR = Color.new(255, 220, 20, 255)
|
MEDIUM_LEVEL_COLOR = Color.new(255, 220, 20, 255)
|
||||||
@@ -94,10 +97,36 @@ module MobHitBars
|
|||||||
"NPC"
|
"NPC"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.base_stat(actor, data, name, maximum = nil)
|
||||||
|
raw = data.send(name) if data && data.respond_to?(name)
|
||||||
|
raw = stat(actor, name) if raw.nil?
|
||||||
|
value = [raw.to_f, 0.0].max
|
||||||
|
maximum ? [value, maximum].min : value
|
||||||
|
rescue
|
||||||
|
0.0
|
||||||
|
end
|
||||||
|
|
||||||
def self.level(actor)
|
def self.level(actor)
|
||||||
data = actor.respond_to?(:npc) ? actor.npc : nil
|
data = actor.respond_to?(:npc) ? actor.npc : nil
|
||||||
value = data && data.respond_to?(:combat) ? data.combat.to_i : 0
|
combat = base_stat(actor, data, "combat", 100.0)
|
||||||
value = stat(actor, "combat").to_i if value <= 0
|
attack = base_stat(actor, data, "atk", 100.0)
|
||||||
|
defense = base_stat(actor, data, "def", 100.0)
|
||||||
|
constitution = base_stat(actor, data, "constitution", 100.0)
|
||||||
|
survival = base_stat(actor, data, "survival", 100.0)
|
||||||
|
wisdom = base_stat(actor, data, "wisdom", 100.0)
|
||||||
|
health = base_stat(actor, data, "health", HEALTH_POWER_CAP)
|
||||||
|
stamina = base_stat(actor, data, "sta", STAMINA_POWER_CAP)
|
||||||
|
|
||||||
|
score = combat * 0.35
|
||||||
|
score += attack * 0.90
|
||||||
|
score += defense * 0.55
|
||||||
|
score += constitution * 0.15
|
||||||
|
score += survival * 0.10
|
||||||
|
score += wisdom * 0.10
|
||||||
|
score += Math.sqrt(health) * 0.80
|
||||||
|
score += Math.sqrt(stamina) * 0.35
|
||||||
|
|
||||||
|
value = (score * MAX_NPC_LEVEL / POWER_REFERENCE).round
|
||||||
[[value, 1].max, MAX_NPC_LEVEL].min
|
[[value, 1].max, MAX_NPC_LEVEL].min
|
||||||
rescue
|
rescue
|
||||||
1
|
1
|
||||||
|
|||||||
Reference in new issue
Block a user