|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.combat.HitCommand
This special Command deals with the to-hit event. The to-hit phase of an attack is encapsulated as a separate event so that hook callbacks can easily manipulate the outcome.
If the to-hit calculations are successful, then the hit will be translated into a DamageEvent.
Method Summary | |
void |
addCommands(java.util.Map map,
CommandList list)
Adds the commands we handle to a player's dictionary. |
int |
computeAccuracy(HitEvent event,
Commandable agent,
Attack attack,
AttackType attackType)
Computes the net accuracy for a given attack. |
static int |
computeDodge(Monster defender,
Commandable attacker)
Computes the net dodge for the attack, based on the defender's level, dodge skill, encumbrance, and magical dodge bonuses. |
void |
computeToHit(Commandable agent,
GameObject defender,
Attack attack,
HitEvent event)
Performs the to-hit computation after the event is created. |
CommandEvent |
createEvent(CommandEvent initialInfo)
Creates a CommandEvent that encapsulates the to-hit check. |
CommandEvent |
createHitEvent(Commandable agent,
GameObject defender,
Attack weapon)
Utility method for creating a to-hit event suitable for placement in the agent's queue. |
boolean |
execute(CommandEvent ev)
Executes the HitEvent by creating a DamageEvent if the hit was successful. |
static HitCommand |
getImpl()
|
boolean |
knowsCommand(java.lang.String command)
Returns true if this Command wants to handle the command. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static HitCommand getImpl()
public void addCommands(java.util.Map map, CommandList list)
addCommands
in interface BuiltInCommand
map
- a Map whose keys are commands, and whose values
are Commands that handle those commands.list
- the CommandList the Command is being added to.public boolean knowsCommand(java.lang.String command)
knowsCommand
in interface Command
command
- the entire command string, including arguments
public CommandEvent createEvent(CommandEvent initialInfo)
createEvent
in interface Command
initialInfo
- a "blank" CommandEvent containing only the
command text and the agent who's performing the command. This
initial event is created by the originator of the event (e.g.
the AI or player's command preprocessor).
public CommandEvent createHitEvent(Commandable agent, GameObject defender, Attack weapon)
agent.commandNow("hit {monster} with {weapon}")
,
as it skips the parsing phase.
agent
- the attackerdefender
- the attackeeweapon
- the thing being used to attack
public void computeToHit(Commandable agent, GameObject defender, Attack attack, HitEvent event)
The percent chance to hit is accuracy * (1 - dodge/100), so as dodge approaches 100, the chance goes to zero. Accuracy is explained in computeAccuracy(), and dodge is explained in computeDodge().
The event is vetoed (with a "You missed" failure message) if the agent misses.
agent
- the attackerdefender
- the defenderattack
- the attack (such as a body part, melee weapon, range
weapon, or hurled weapon)event
- the eventpublic int computeAccuracy(HitEvent event, Commandable agent, Attack attack, AttackType attackType)
public static int computeDodge(Monster defender, Commandable attacker)
defender
- the thing being attackedattacker
- the agent doing the attacking
public boolean execute(CommandEvent ev)
execute
in interface Command
ev
- the CommandEvent to execute
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |