wyvern.kernel.player
Class Skills

java.lang.Object
  extended bywyvern.kernel.player.Skills

public final class Skills
extends java.lang.Object

Special handling for various skills players can train in.

Version:
1.0, Jan 6, 2001
Author:
Steve Yegge

Field Summary
static int MAX_LORE_LEVEL
          Don't allow player to train higher than this.
 
Method Summary
static int[] drainXPForDeath(Player defender, GameObject attacker)
          Handles adjusting a player's XP when they die.
static int ensureCorrectSkillPoints(Player p)
          Ensures the player has the correct number of skill points.
static long getAdjustedBuyPrice(long price, int skill)
          Returns the price a player would pay for an item in a shop, taking into account the player's merchant skill.
static int getAdjustedSellPrice(int gold_value, int skill)
          Returns the amount a shop will pay for an item, adjusted for the player's merchant skill.
static int getCritChance(Commandable agent)
          Returns the chance of scoring a critical hit, based on the agent's find-weakness skill.
static int getDodgeBonus(int dodge)
          Returns the dodge bonus, as a percentage, given the player's dodge skill level.
static int getExpectedLorePoints(int lore)
          Returns the total number of lore points a player of the specified level should have, including spent and unspent points.
static int getExpectedSkillPoints(Player p)
          Returns the number of skill points a player should have, based on their race and level.
static int getHurledBonus(int hurled)
          Returns the to-hit bonus, as a percentage, given the player's hurled-weapons skill level (sk-hurled).
static int getMeleeSpeedBonus(int skill)
          Returns the attack-speed bonus for a given skill level in Melee.
static int getRangeBonus(int range)
          Returns the to-hit bonus, as a percentage, given the player's range-weapons skill level (sk-range).
static java.lang.String getSkillName(java.lang.String name)
          Translates a skill property name to a player-visible skill name.
static int getSkillPointsForLevel(Commandable agent, int level)
          Returns the number of skill points to give to the player for advancing to the specified level.
static int getSneak(Commandable agent)
          Returns the sneak percent chance for the agent.
static int getSneak(int skill)
          Returns the sneak percent chance for a given skill level.
static int getSpentSkillPoints(Player p)
          Returns the total number of skill-points the player has spent on training in their skills.
static int getStrength(Commandable agent)
          Returns the number of pounds the passed player can carry.
static int getStrengthDamageBonus(Commandable agent)
          Returns the extra damage done by the agent from their strength.
static int getToHitBonus(int skill)
          Returns the to-hit bonus, as a percentage, given the player's weapon skill level for the weapon they're using.
static java.lang.String getTrainerTitle(java.lang.String skill, int max)
          Returns the title to use for a trainer who can train to a given train-max value.
static int getXPLevelForLoreLevel(int lore)
          Returns the experience level you have to have in order to train to a given lore level.
static void main(java.lang.String[] args)
          Tests out the various functions.
static boolean trainInForestry(Commandable agent)
          Improves the player's move-speed over forest terrain.
static boolean trainInLore(Commandable agent)
          When a player trains in the "lore" skill, they get a certain number of lore points.
static boolean trainInSkill(java.lang.String skill, Commandable agent)
          Called when a player trains in a specific skill.
static boolean untrainInLore(Commandable agent)
          Removes a skill point in Lore, and also removes any lore points they got for that skill point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_LORE_LEVEL

public static final int MAX_LORE_LEVEL
Don't allow player to train higher than this.

See Also:
Constant Field Values
Method Detail

getDodgeBonus

public static int getDodgeBonus(int dodge)
Returns the dodge bonus, as a percentage, given the player's dodge skill level.

Parameters:
dodge - the dodge skill level
Returns:
the percentage bonus, subtracted from 100 to give the percent chance that the player/monster can be hit. Can return a negative number, producing a chance > 100%.

getRangeBonus

public static int getRangeBonus(int range)
Returns the to-hit bonus, as a percentage, given the player's range-weapons skill level (sk-range).

Parameters:
range - the sk-range skill level
Returns:
the to-hit percentage bonus

getHurledBonus

public static int getHurledBonus(int hurled)
Returns the to-hit bonus, as a percentage, given the player's hurled-weapons skill level (sk-hurled).

Parameters:
hurled - the sk-hurled skill level
Returns:
the to-hit percentage bonus

getToHitBonus

public static int getToHitBonus(int skill)
Returns the to-hit bonus, as a percentage, given the player's weapon skill level for the weapon they're using.

Parameters:
skill - the weapon skill level
Returns:
the percentage to-hit bonus, used in combat calculations. A zero or negative weapon skill results in a zero to-hit bonus.

drainXPForDeath

public static int[] drainXPForDeath(Player defender,
                                    GameObject attacker)
Handles adjusting a player's XP when they die.

Parameters:
defender - the player who died
attacker - the thing that killed the player
Returns:
the amount of xp they lost: first element is regular xp, second element is guild xp

getMeleeSpeedBonus

public static int getMeleeSpeedBonus(int skill)
Returns the attack-speed bonus for a given skill level in Melee.

Returns:
a number to ADD to the attack-speed - for a positive melee skill, the number will be negative

getAdjustedBuyPrice

public static long getAdjustedBuyPrice(long price,
                                       int skill)
Returns the price a player would pay for an item in a shop, taking into account the player's merchant skill.

Parameters:
price - the price the buyer would pay with no merchant skill. You can pass a price in silver, gold or any currency, but it's most accurate if you use silver.
skill - the buyer's skill level in sk-merchant
Returns:
the price the shop will sell it for, taking into account adjustments for the merchant skill.

getAdjustedSellPrice

public static int getAdjustedSellPrice(int gold_value,
                                       int skill)
Returns the amount a shop will pay for an item, adjusted for the player's merchant skill.

Parameters:
gold_value - the full value of the item. Must be passed in GOLD for the calculation to work correctly, because of the cap.
skill - the agent's effective merchant skill level
Returns:
the price the shop will pay for the item. It's computed as a percentage of the item's full value, ranging from 25% on upwards as the merchant skill increases. It is then filtered against a cap, starting at 1000 gold and going up as the merchant skill increases. Return value is in SILVER

trainInSkill

public static boolean trainInSkill(java.lang.String skill,
                                   Commandable agent)
Called when a player trains in a specific skill. For some skills, it just increments their counter for that skill, and that's all that's required. For others, such as the Forestry skill or the Lore skill, it modifies other properties on the player.

This method handles deducting a skill point (or more, if the skill requires more than one skill points to train in it). If the player has maxed out in the skill, it will issue the appropriate message to the player and not change any properties or deduct any skill points.

Parameters:
skill - the skill to train in, e.g. "sk-lore". Skill names should always begin with "sk-".
agent - the player who's training in the skill
Returns:
true if they trained in the skill successfully, false if they failed for some reason (e.g. maxed out already).

trainInLore

public static boolean trainInLore(Commandable agent)
When a player trains in the "lore" skill, they get a certain number of lore points. Lore points can be spent on spells - every (wizard) spell in the game has a certain number of lore points you need to spend in order to learn it. To train in the "lore" skill, you have to call this method so the player gets the appropriate number of lore points to spend.

Parameters:
agent - the player to train in lore
Returns:
true if they went up a level in the skill, false if they were maxed out.

untrainInLore

public static boolean untrainInLore(Commandable agent)
Removes a skill point in Lore, and also removes any lore points they got for that skill point. The player has to forget enough spells to free up the requisite number of lore points.


getXPLevelForLoreLevel

public static int getXPLevelForLoreLevel(int lore)
Returns the experience level you have to have in order to train to a given lore level.

Parameters:
lore - the lore level you're trying to attain
Returns:
the XP level you need, or -1 if the passed lore level is less than zero or greater than MAX_LORE_LEVEL.

getExpectedLorePoints

public static int getExpectedLorePoints(int lore)
Returns the total number of lore points a player of the specified level should have, including spent and unspent points.

Parameters:
lore - the player's persistent sk-lore skill
Returns:
the total number of lore points they should have

trainInForestry

public static boolean trainInForestry(Commandable agent)
Improves the player's move-speed over forest terrain. Permanently sets their "sk-speed-forest" property based on the skill.

Parameters:
agent - the player to train
Returns:
true if successful

getStrength

public static int getStrength(Commandable agent)
Returns the number of pounds the passed player can carry. Factors in their base strength and strength skill.

Parameters:
agent - the player
Returns:
the number of pounds they can carry

getSneak

public static int getSneak(int skill)
Returns the sneak percent chance for a given skill level.

Parameters:
skill - the agent's total skill in sk-sneak
Returns:
the percentage change of sneaking successfully on a move. Can be negative (interpret that how you like).

getSneak

public static int getSneak(Commandable agent)
Returns the sneak percent chance for the agent.

Parameters:
agent - the agent
Returns:
the percentage change of sneaking successfully on a move. Can be negative (interpret that how you like).

getSkillPointsForLevel

public static int getSkillPointsForLevel(Commandable agent,
                                         int level)
Returns the number of skill points to give to the player for advancing to the specified level.

Parameters:
agent - the player to advance
level - the level they're advancing to
Returns:
the skill points to add to their total

getStrengthDamageBonus

public static int getStrengthDamageBonus(Commandable agent)
Returns the extra damage done by the agent from their strength.

Parameters:
agent - the agent doing the attacking
Returns:
a number of points (max) extra damage to do from crushing damage.

getSkillName

public static java.lang.String getSkillName(java.lang.String name)
Translates a skill property name to a player-visible skill name.

Parameters:
name - sk-whatever
Returns:
the user-visible name for a skill

getCritChance

public static int getCritChance(Commandable agent)
Returns the chance of scoring a critical hit, based on the agent's find-weakness skill.

Parameters:
agent - the agent doing the attack

getTrainerTitle

public static java.lang.String getTrainerTitle(java.lang.String skill,
                                               int max)
Returns the title to use for a trainer who can train to a given train-max value.

Parameters:
skill - the skill (e.g. "sk-blacksmith")
max - the maximum level the trainer can train you to

ensureCorrectSkillPoints

public static int ensureCorrectSkillPoints(Player p)
Ensures the player has the correct number of skill points. Sometimes training or untraining bugs cause you to gain or lose points permanently.

Parameters:
p - the player - updates their skill-points, which can go negative if they were over.
Returns:
amount by which the player's "skill-points" prop was adjusted, or 0 if there was no change.

getExpectedSkillPoints

public static int getExpectedSkillPoints(Player p)
Returns the number of skill points a player should have, based on their race and level.

Parameters:
p - the player
Returns:
the number of skill points they should have, total (including spent and unspent points)

getSpentSkillPoints

public static int getSpentSkillPoints(Player p)
Returns the total number of skill-points the player has spent on training in their skills. Does not include racial, guild, or magical bonuses.

Parameters:
p - the player
Returns:
number of points they've spent in skills training

main

public static void main(java.lang.String[] args)
Tests out the various functions.