Skip to content

Character Generation

Allofich edited this page Apr 11, 2020 · 5 revisions

Dice rolling

In the following, roll represents this algorithm:

function roll(n) <-
   if n <= 8 then return rnd(n)
   test <- n
   while true
      if test mod 6 == 0 then X,Y <- test/6, 6
      else if test mod 5 == 0 then X,Y <- test/5, 5
      else if test mod 4 == 0 then X,Y <- test/4, 4
      else test <- test + 1
   end while
   do
      value <- throwXdY(X, Y)
   while value > n
   return value

Character generation

pc <- new Player
pc.class <- askClass()
pc.giveWeapon()
do
   pc.name <- askName()
while pc.name == ""
pc.female <- askGender()
pc.race <- askProvince(hideExitButton: true)
pc.homeCity <- rnd(32) + pc.race * 32
do
   pc.initStats()
   distribute bonus points
until askConfirmStats()
pc.updateStats()
if pc.class & IS_SPELLCASTER then
   pc.spells.append(61)
   pc.spells.append(62)
endif
load "FACESxnn.CIF"
select portrait
pc.portraits[0] <- pc.race * 10 + portraitId
if pc.female then pc.portraits[0] <- pc.portraits[0] | 0x80
pc.experience <- 700
pc.gold <- rnd(50, 200)
pc.status <- pc.status | PCF_PLAYER # 0x4000

function pc::giveWeapon() <-
   classId <- class & 0x1F
   if classId >= 12 then weapon <- WEAP_BROADSWORD
   else if classId >= 6 then weapon <- WEAP_SHORTSWORD
   else weapon <- WEAP_DAGGER
   inventory[0] <- generatePlainWeapon(weapon)

function pc::initStats() <-
   arrayId <- race * 2
   if female then arrayId <- arrayId + 1
   copyArray(pc.attrib, 0, raceAttribs, arrayId, 8)
   for i <- 0 to 7
      pc.attrib[i] <- pc.attrib[i] + roll(20)
   pc.baseAttrib <- pc.attrib
   updateStats()
   bonuspoints <- roll(25)

Attribute values are stored in an array @39cf3. There are 16 8-byte subarrays for males and females of each of 8 races, followed by guard stats (9 entries), followed by 24 entries for each monster type.

Health roll

Max health is rolled before bonus points are distributed. +25 is then added to this roll. Although adding bonus points to Endurance to increase the health bonus value doesn't change the character health displayed during character generation, the change can be seen to have taken effect once character generation is over.

Clone this wiki locally