In most respects, the following system is an enhancement of that proposed by Susramanian (http://forums.te4.org//viewtopic.php?f=39&t=23105).
The main features of this system are:
A budget based on power level that is used to allocate powers to a randart
A list of cost and rarity factors for all random characteristics
A single and easily tunable randomness factor (RF) to set how focused the powers are
A system to base randarts on currently generated egos that ensures that competitive randarts are generated
I’m not a LUA programmer, so I’ll present this algorithm in pseudocode. The main tuning parameters in this algorithm are the database of costs and rarity factors, the budget calculation, and the randomness factor.
Code: Select all
Pregame set up:
Set up a database of cost and rarity values for powers that can be added to randarts. (Susramanian has a good starting point in his post). To this add fields that specify the amount of the power to be added, and a classification for the power (stats, resists, melee, ranged, etc.)
For example:
Abbreviation Cost Rarity Amount Classification
STR 1.0 10 1d3 stats
ColdResist: 0.03, 8 1d5 resists
StunResist: 0.1, 4 1d10 resists
MeleeFire 0.5 5 1d5 melee
etc....
Where rarity ranges from 1 to 10, with 10 being common and 1 being very rare.
Set up a Budget adjustment per slot (BAL):
Weapons 1.0
Shields 0.8
Rings 0.8
Amulets 0.5
Lights 0.4
Body armor 1.0
Cloak 0.7
Helms 0.9
Belt 0.7
Gloves 0.6
Footwear 0.7
Tools 0.4
Probability of any power is its rarity/sum of all the rarities in the database. (Compute this during game startup)
Set RF: Randomness factor (0-1.0, 0= totally random, 1=totally focused, suggest 0.5)
Set MBGT =15 the minimum budget for an artifact on level 1 (This depends heavily on the cost factors)
MAIN MODULE
Inputs:
APL: Artifact power level ~= equivalent dungeon level (i.e. a level 40 monster should have an artifact of APL=40)
PROCEDURE:
A: Compute the item budget:
BGT = MBGT*BAL*(1+APL/15)*(1+rand(0:0.5))
(i.e ~4.5x as many points at level 50 as at level 1, based on massacre going from 8% to 33%, and then multiplied by a random factor from 1 to 1.5)
B: Adjust the budget down for material quality (optional):
x1 for voratun
x0.9 for strilite
x0.8 for dwarven steel
x0.7 for steel
x0.6 for iron
C: With probability RF, Randomly generate an ego drop as a base item. Otherwise start out with a plain item.
D: Compute the budget already allocated to the item and subtract it from BGT.
MAIN LOOP (Minimum once through; don’t stop adding powers until the budget is exceeded.)
E: With probability RF, select one of the powers the item already has. Otherwise select a random power from the database. [POWER SELECTION]
F: Add the power to the item and subtract its cost from BGT.
G: If BGT > 0 return to step E
END MAIN LOOP
Set appropriate variables, etc. to finish generating the object.
POWER SELECTION:
a1: Compute IDX =rand(0-1)*table size.
a2: Select the power from the database table such that sum(powers (1:index) <= IDX
a3: Check power against restrictions (Melee only, No resists etc) and fall through to regular stat generation if it's not allowed.)
a4: Compute the quantity of the power to add (i.e. STR is added in chunks of 1d3 points) and the budget required.
Return the power and its budget cost.