Difference between revisions of "Drop rates/Script"

From Wildermyth Wiki
(Created page with "This is a [https://www.python.org/downloads/ Python] script to generate the Drop rates tables. Copy the code in the box below into a text file named '''<nowiki>wikiDropRat...")
 
m
 
(3 intermediate revisions by the same user not shown)
Line 127: Line 127:


for cat in itemWeights:
for cat in itemWeights:
   line = '|-\n| %s || %s '%(rootNames[cat],str(itemWeights[cat]))
   line = '|-\n| [[%s]] || %s '%(rootNames[cat],str(itemWeights[cat]))
   if cat == 'weapon':
   if cat == 'weapon':
     line += ''.join(['|| %d '%weaponTier(c) for c in range(1,6)])
     line += ''.join(['|| %d '%weaponTier(c) for c in range(1,6)])
Line 166: Line 166:
! Name !! Type !! Effective drop rate
! Name !! Type !! Effective drop rate
'''
'''
for cat in itemList:
for cat in weaponWeights:
   if cat in categoryNames:
   for weapon in itemList[cat]:
    for weapon in itemList[cat]:
    line = '|-\n| [[%s]] || %s || %.3f \n'%(itemList[cat][weapon],categoryNames[cat],weaponWeights[cat]/categoryDividend[cat])
      line = '|-\n| [[%s]] || %s || %.3f \n'%(itemList[cat][weapon],categoryNames[cat],weaponWeights[cat]/categoryDividend[cat])
     weaponTable += line
      weaponTable += line
'''
for cat in itemList:
  if cat not in categoryNames:
     for weapon in itemList[cat]:
      line = '|-\n| %s || [[%s]] || %.3f \n'%(rootNames[cat],itemList[cat][weapon],(itemWeights[cat]/categoryDividend[cat]))
      weaponTable += line
'''
weaponTable += '|-\n|}\n'
weaponTable += '|-\n|}\n'


Line 192: Line 184:


string += '''
string += '''
If a weapon drops, the relative odds of each type of weapon are as follows:
If a [[weapon]] drops, the relative odds of each type of weapon are as follows:
'''
'''
string += weaponCatTable
string += weaponCatTable


string += '''
string += '''
If instead a piece of armor drops, the relative odds of each class are as follows:
If instead a piece of [[armor]] drops, the relative odds of each class are as follows:
'''
'''
string += armorCatTable
string += armorCatTable
Line 204: Line 196:
== Artifacts ==
== Artifacts ==


If weapon is selected to drop, there is a chance that it will be an [[artifact]] weapon. The chance starts at 0, increases by %s each time a non-artifact weapon drops, and decreases by %s each time an artifact weapon drops. The following artifacts can appear as random drops. Each artifact within a given category is equally likely to drop. Accordingly, the table lists each artifact's effective drop rate, which is calculated as the category weight divided by the number of droppable artifacts in that category.
If weapon is selected to drop, there is a chance that it will be an [[artifact]] weapon. The chance starts at 0, increases by %s each time a non-artifact weapon drops, and decreases by %s each time an artifact weapon drops. The following artifacts can appear as random drops. Each artifact of a given type is equally likely to drop. Accordingly, the table lists each artifact's effective drop rate, which is calculated as the weapon type's relative drop rate divided by the number of droppable artifacts of that type.
'''%(artifactSpawnChanceIncreasePerFailure,artifactSpawnChanceDecreasePerSuccess)
'''%(artifactSpawnChanceIncreasePerFailure,artifactSpawnChanceDecreasePerSuccess)
string += weaponTable
string += weaponTable
string += '''
string += '''
An artifact will not drop if a hero in the campaign already possesses it. This behavior can raise the effective drop rate of other artifacts in the same weapon category.
An artifact will not drop if a hero in the campaign already possesses it. This behavior can raise the effective drop rate of other artifacts of the same type.
'''
'''



Latest revision as of 07:50, 27 May 2022

This is a Python script to generate the Drop rates tables. Copy the code in the box below into a text file named wikiDropRates.py (or whatever you want) inside the Wildermyth directory. Then run it by calling python wikiDropRates.py from the command line.[1] It will create a text file named wikiDropRates.txt with the appropriate wiki-formatted content.

  1. More precisely, you can put the script anywhere, but you need to call it from the Wildermyth directory.