[CF-Devel] Improvement needed on artifact selection code?

Mark Wedel mwedel at scruz.net
Mon Feb 5 21:57:20 CST 2001


Peter Mardahl wrote:
>
     
     
     >
     
      Hello,
     
     >
     
     
     >
     
        I recently added a bunch of rings oriented for fighters,
     
     >
     
      which grant fighting stats at the expense of magic abilities.
     
     >
     
     
     >
     
        These rings are popular among the masses, and unfortunately,
     
     >
     
      they're common.
     
     >
     
     
     >
     
        For some reason, a Ring of Thieves, for example, comes up
     
     >
     
      more often than a Ring of Halvor.
     
     >
     
     
     >
     
      Thieves has a chance of 20
     
     >
     
      Halvor has a chance of 50
     
     >
     
     
     >
     
      Therefore, you should see 2.5 rings of halvor for every ring
     
     >
     
      of thieves.  Instead, you see more rings of thieves.
     
     >
     
     
     >
     
      >From my vague recollections of the code, items up at the top
     
     >
     
      are favored in the artifact selection over items at the bottom.
     
     >
     
     
     >
     
      Is this true?  Or is the observation just a result of chance?
     
     
 At least looking at the code, what you describe should be correct (See 2.5
rings of halvor for every ring of thieves).

 The selection of an artifact does not depending on the ordering.  After load
time, the chance values for all the objects of a type are summed up and stored. 
When it generates a random artifact, it generates a random number from 0 to that
chance value, and traverses the list until the appropriate place is found
(subtracts item chance from roll, if less than 0, use that artifact, otherwise
continue with same roll)

 Now there may be some bug someplace - perhaps it isn't totalling the chance
right or doing something else odd.  But order in the artifact file should not
make a difference.

    
    


More information about the crossfire mailing list