|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.lib.classes.random.WeaponEnchanter
An object that can produce magical weapons of a given level by picking a base weapon and adding enchantments.
To use it, instantiate one and (optionally) configure it by setting properties. Then call generate() to generate a weapon. You can use it to generate more than one weapon. You need to call reset() before each subsequent call to generate().
For example, to generate a random 15th-level weapon with a 20% chance of being cursed, you'd do this:
WeaponEnchanter w = new WeaponEnchanter(); w.setCurseChance(20); GameObject weapon = w.generate();or in Jython:
w = new WeaponEnchanter(); w.setCurseChance(20); weapon = w.generate();
Nested Class Summary | |
static class |
WeaponEnchanter.WeaponEnchantment
A class to encapsulate an enchantment. |
Field Summary | |
protected int |
baseLevel_
The level of nonmagical weapon to start with. |
protected int |
blessChance_
Chance the weapon will be blessed, if it's not cursed. |
protected int |
curseChance_
Chance the weapon will be cursed. |
protected int |
damnationChance_
Chance that the curse on a weapon will be Damnation. |
static int |
DEFAULT_BLESS_CHANCE
The default chance that a randomly generated level-1 weapon have a . |
static int |
DEFAULT_CURSE_CHANCE
The default chance that a randomly generated level-1 weapon have a curse on it. |
static int |
DEFAULT_CURSE_CHANCE_MALIGNED
If we randomly decided that the weapon has reversed ("maligned") enchantments (e.g. -5 strength), this is the chance that the item will be cursed, such that the player can't unwield it. |
static int |
DEFAULT_DAMNATION_CHANCE
Same as cursing, but worse. |
static int |
DEFAULT_MALIGN_CHANCE
The default chance that a randomly generated level-1 weapon will have a cursed enchantment. |
static int |
DEFAULT_MISSILE_MAX_QUANTITY
How much ammo we generate, max, by default. |
protected int |
enchant1_
Level of first random enchantment to add to the item. |
protected int |
enchant2_
Level of second random enchantment to add to the item. |
protected int |
enchantment_
Total levels of enchantment to add to the base item. |
protected int |
level_
Desired level of magical weapon to generate. |
protected int |
malignChance_
Chance the weapon will be maligned; i.e., its enchantments are negative. |
static int |
MAX_BASELEVEL_WEAPON_LEVEL
The highest level non-magical weapon in the game (currently an elven broadsword) |
static int |
MAX_LEVEL
Maximum level of weapon that will be generated. |
static int |
MAX_SINGLE_ENCHANTMENT
The maximum individual enchantment a random weapon can have. |
protected GameObject |
weapon_
the nonmagic weapon we create, then enchant |
Constructor Summary | |
WeaponEnchanter()
|
Method Summary | |
protected void |
addAccuracy(GameObject weapon,
int value)
Adds an enchantment of accuracy to the weapon. |
protected void |
addDamage(GameObject weapon,
int value)
Adds an enchantment of damage to the weapon. |
protected void |
addDurability(GameObject weapon,
int value)
Adds an enchantment of durability to the weapon. |
protected void |
addEnchantments()
Adds 1 or 2 enchantments, depending on the results of the call to determineEnchantments(). |
protected void |
addLight(GameObject weapon,
int value)
Adds an enchantment of light to the weapon. |
protected void |
addQuantityIfNeeded()
If the generated weapon is a missile, or has a "gen-number" property, adds a quantity to the weapon. |
java.lang.String |
addRandomEnchantment(GameObject weapon,
int value,
java.lang.String exclude)
Adds a random enchantment to the passed weapon of the passed value. |
protected void |
addSpeed(GameObject weapon,
int value)
Adds an enchantment of speed to the weapon. |
protected void |
addWeight(GameObject weapon,
int value)
Adds an enchantment of weight to the weapon. |
protected void |
blessOrCurseItem()
Decides whether the item should be blessed or cursed. |
protected int |
chooseBaseLevel()
Chooses the base (i.e. unenchanted) weapon level to use for the item. |
protected int |
chooseWeightedValue(int base)
Uses a normal distribution to choose a value from 1 to n, on average closer to n than 1. |
protected GameObject |
createBaseWeapon(int level)
Creates a random unenchanted weapon of the passed level. |
GameObject |
createLevel1Weapon()
Returns a random level-1 weapon. |
protected void |
createNonMagicWeapon()
Picks a random base weapon level and instantiates a random nonmagic weapon of that level. |
protected void |
curseEnchantments()
Reverses enchantment number(s), and marks the weapon as "is-cursed", for the Appraisal skill. |
void |
curseWeapon()
Curses (with getDamnationChance() of damning) an item. |
protected void |
determineEnchantments()
Sets the total enchantment and the individual enchantment(s), randomly, based on the item level and item base. |
protected void |
flagEnchantmentForAppraisers()
Sets the total enchantment in a "base-enchantment" property for the Appraisal skill. |
GameObject |
generate()
Generates a random weapon. |
static GameObject |
generate(int level,
java.lang.String name,
int value)
Generates a random weapon using the specified single enchantment |
int |
getBaseLevel()
Returns the base level of nonmagical weapon to start with, before adding enchantments. |
int |
getBlessChance()
Returns chance that the item will be blessed (1-100) |
int |
getCurseChance()
Returns chance that the item will be cursed (1-100) |
int |
getDamnationChance()
Returns chance that the item will be damned (1-100), if it rolls the getDamnationChance(). |
int |
getLevel()
Returns level of the weapon to be generated |
int |
getMalignChance()
Returns chance the item will have a maligned (negative) enchantment |
protected java.lang.String |
getMaxWC(GameObject weapon)
Returns the highest weapon class of this weapon. |
int |
getTotalEnchantment()
Returns the total enchantment (the sum of up to 2 individual enchantments) we decided to place on the weapon. |
GameObject |
getWeapon()
Returns the weapon to add enchantments to |
protected GameObject |
instantiate(Archetype arch)
Instantiates an archetype, catching any exception. |
boolean |
isMaligned()
Returns true if the weapon we're generating is maligned (i.e. the enchantments are reversed, and have negative values.) |
static void |
main(java.lang.String[] args)
Tests the enchanter functions. |
java.util.List |
parseEnchantment(java.lang.String input)
Take a string like "of agility +5, damage +2" and parses it into a java.util.List of WeaponEnchantments. |
void |
reset()
Resets the WeaponEnchanter properties to their default values. |
void |
setBaseLevel(int base)
Sets the base level to use for the weapon. |
void |
setBlessChance(int blessChance)
Sets chance that the item will be blessed (1-100) |
void |
setCurseChance(int curseChance)
Sets chance that the item will be cursed (1-100) |
void |
setDamnationChance(int chance)
Sets chance that the item will be damned (1-100) |
void |
setLevel(int level)
Sets level of the weapon to be generated. |
void |
setMalignChance(int malignChance)
Sets chance the item will have a maligned (negative) enchantment |
void |
setWeapon(GameObject weapon)
Sets the weapon to add enchantments to |
protected void |
setWieldLevel()
Sets an appropriate "wield-level" on the weapon, based on its final enchantment(s), so that newbies can't wield it to major advantage. |
protected void |
sortEnchantments()
If 2nd enchantment is greater, swaps them (easier to read). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_MALIGN_CHANCE
public static final int DEFAULT_BLESS_CHANCE
public static final int DEFAULT_CURSE_CHANCE
public static final int DEFAULT_CURSE_CHANCE_MALIGNED
public static final int DEFAULT_DAMNATION_CHANCE
public static final int MAX_LEVEL
public static final int MAX_BASELEVEL_WEAPON_LEVEL
public static final int DEFAULT_MISSILE_MAX_QUANTITY
public static final int MAX_SINGLE_ENCHANTMENT
protected int malignChance_
protected int curseChance_
protected int damnationChance_
protected int blessChance_
protected int level_
protected int baseLevel_
protected GameObject weapon_
protected int enchantment_
protected int enchant1_
protected int enchant2_
Constructor Detail |
public WeaponEnchanter()
Method Detail |
public int getLevel()
public void setLevel(int level)
level
- level of the weapon to be generated (1-MAX_LEVEL)public int getCurseChance()
public void setCurseChance(int curseChance)
curseChance
- chance that the item will be cursed (1-100)public int getDamnationChance()
public void setDamnationChance(int chance)
chance
- chance that the item will be damned (1-100)public int getBlessChance()
public void setBlessChance(int blessChance)
blessChance
- chance that the item will be blessed (1-100)public int getMalignChance()
public void setMalignChance(int malignChance)
malignChance
- chance the item will have a maligned enchantmentpublic int getBaseLevel()
public void setBaseLevel(int base)
base
- the level (1-8) of nonmagical item to enchant,
to reach the desired level.public boolean isMaligned()
public int getTotalEnchantment()
public GameObject getWeapon()
public void setWeapon(GameObject weapon)
weapon
- the weapon to add enchantments topublic void reset()
public java.util.List parseEnchantment(java.lang.String input)
public static GameObject generate(int level, java.lang.String name, int value)
level
- the level of item to generatename
- the enchantment name, such as "accuracy"value
- the enchantment value, from -10 to +10
java.lang.IllegalArgumentException
- if name or value couldn't
be used or parsedpublic GameObject generate()
public java.lang.String addRandomEnchantment(GameObject weapon, int value, java.lang.String exclude)
weapon
- the weaponvalue
- the value of the enchantment (1-10)exclude
- enchantment not to use (meaning it has already
been placed on the item, so exclude it from the possible list)
(i.e. "accuracy", "damage", "durability", "weight", "speed",
or "light") Pass "" (empty string) for no exclusions. I know
this API sucks - sorry 'bout that.protected int chooseWeightedValue(int base)
protected void addAccuracy(GameObject weapon, int value)
protected void addDurability(GameObject weapon, int value)
protected void addSpeed(GameObject weapon, int value)
protected void addDamage(GameObject weapon, int value)
protected java.lang.String getMaxWC(GameObject weapon)
protected void addLight(GameObject weapon, int value)
protected void addWeight(GameObject weapon, int value)
protected GameObject instantiate(Archetype arch)
arch
- the archetype to instantiate
public void curseWeapon()
protected void createNonMagicWeapon()
protected GameObject createBaseWeapon(int level)
protected final int chooseBaseLevel()
public GameObject createLevel1Weapon()
protected void determineEnchantments()
protected void sortEnchantments()
protected void curseEnchantments()
protected void addEnchantments()
protected void blessOrCurseItem()
protected void addQuantityIfNeeded()
protected void flagEnchantmentForAppraisers()
protected void setWieldLevel()
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |