Angband
Data Structures | Typedefs | Functions
player-attack.h File Reference

Attacks (both throwing and melee) by the player. More...

#include "cmd-core.h"

Go to the source code of this file.

Data Structures

struct  attack_result
 

Typedefs

typedef struct attack_result(* ranged_attack )(struct player *p, struct object *obj, int y, int x)
 ranged_attack is a function pointer, used to execute a kind of attack. More...
 

Functions

void do_cmd_fire (struct command *cmd)
 Fire an object from the quiver, pack or floor at a target. More...
 
void do_cmd_fire_at_nearest (void)
 Front-end command which fires at the nearest target with default ammo. More...
 
void do_cmd_throw (struct command *cmd)
 Throw an object from the quiver, pack or floor. More...
 
int breakage_chance (const struct object *obj, bool hit_target)
 Returns percent chance of an object breaking after throwing or shooting. More...
 
bool test_hit (int chance, int ac, int vis)
 Determine if the player "hits" a monster. More...
 
void py_attack (struct player *p, int y, int x)
 Attack the monster at the given location. More...
 
int py_attack_hit_chance (const struct player *p, const struct object *weapon)
 Return the player's chance to hit with a particular weapon. More...
 

Detailed Description

Attacks (both throwing and melee) by the player.

Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Typedef Documentation

typedef struct attack_result(* ranged_attack)(struct player *p, struct object *obj, int y, int x)

ranged_attack is a function pointer, used to execute a kind of attack.

This allows us to abstract details of throwing, shooting, etc. out while keeping the core projectile tracking, monster cleanup, and display code in common.

Function Documentation

int breakage_chance ( const struct object obj,
bool  hit_target 
)

Returns percent chance of an object breaking after throwing or shooting.

Artifacts will never break.

Beyond that, each item kind has a percent chance to break (0-100). When the object hits its target this chance is used.

When an object misses it also has a chance to break. This is determined by squaring the normaly breakage probability. So an item that breaks 100% of the time on hit will also break 100% of the time on a miss, whereas a 50% hit-breakage chance gives a 25% miss-breakage chance, and a 10% hit breakage chance gives a 1% miss-breakage chance.

References object::artifact, object_kind::base, object_base::break_perc, and object::kind.

Referenced by obj_known_misc_combat(), ranged_helper(), and test_breakage_chance().

void do_cmd_fire ( struct command cmd)
void do_cmd_fire_at_nearest ( void  )
void do_cmd_throw ( struct command cmd)
void py_attack ( struct player p,
int  y,
int  x 
)

Attack the monster at the given location.

We get blows until energy drops below that required for another blow, or until the target monster dies. Each blow is handled by py_attack_real(). We don't allow @ to spend more than 100 energy in one go, to avoid slower monsters getting double moves.

References add_monster_message(), cave, disturb(), player::energy, player_upkeep::energy_use, monster_is_visible(), angband_constants::move_energy, player_state::num_blows, py_attack_real(), square_monster(), player::state, player::upkeep, and z_info.

Referenced by do_cmd_alter_aux(), do_cmd_close(), do_cmd_disarm(), do_cmd_open(), do_cmd_tunnel(), and move_player().

int py_attack_hit_chance ( const struct player p,
const struct object weapon 
)

Return the player's chance to hit with a particular weapon.

References BTH_PLUS_ADJ, SKILL_TO_HIT_MELEE, player_state::skills, player::state, player_state::to_h, and object::to_h.

Referenced by lore_append_toughness(), and py_attack_real().

bool test_hit ( int  chance,
int  ac,
int  vis 
)

Determine if the player "hits" a monster.

References randint0.

Referenced by check_hit(), make_ranged_shot(), make_ranged_throw(), py_attack_real(), and trap_check_hit().