From d0c97bf38ae0da0fd6455c65fd8a98c8374086d5 Mon Sep 17 00:00:00 2001 From: Reid Date: Wed, 6 Jul 2016 17:46:42 +0200 Subject: Add a logn * baseplayer function to calculate inn and stat reset costs. --- npc/001-2-28/plush.txt | 20 +------------------- npc/functions/main.txt | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/npc/001-2-28/plush.txt b/npc/001-2-28/plush.txt index 77161d0a..f9d0960f 100644 --- a/npc/001-2-28/plush.txt +++ b/npc/001-2-28/plush.txt @@ -39,26 +39,8 @@ } } - // A somehow of BaseLevel * logn (BaseLevel * 100). - function calculate_inn_tax { - .@price = 0; - .@pc_level = BaseLevel * 100; - while (.@pc_level >>= 1) - { - ++.@price; - } - .@price *= BaseLevel; - - if (.@price <= 10) - { - .@price = 10; - } - - return .@price; - } - function register_room { - .@price = calculate_inn_tax; + .@price = lognbaselvl(100, 10); speech 5, l("That will be @@ E to set your respawn point", .@price), diff --git a/npc/functions/main.txt b/npc/functions/main.txt index 12484f11..b71fb339 100644 --- a/npc/functions/main.txt +++ b/npc/functions/main.txt @@ -220,3 +220,26 @@ function script npctalkonce { return true; } + +// A somehow of BaseLevel * logn (BaseLevel * alpha). +// alpha = multiplicator factor. +// min = minimum result value. +function script lognbaselvl { + .@alpha = getarg(0, 1); + .@min = getarg(1, 1); + .@ret = 0; + .@pc_level = BaseLevel * .@alpha; + + while (.@pc_level >>= 1) + { + ++.@ret; + } + .@ret *= BaseLevel; + + if (.@ret <= .@min) + { + .@ret = .@min; + } + + return .@ret; +} -- cgit v1.2.3-70-g09d2