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 )(object_type *o_ptr, int y, int x)
 ranged_attack is a function pointer, used to execute a kind of attack.

Functions

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

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)(object_type *o_ptr, 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 object_type o_ptr,
bool  hit_target 
)
void do_cmd_fire ( struct command cmd)
void do_cmd_fire_at_nearest ( void  )
void do_cmd_throw ( struct command cmd)
void py_attack ( 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, FALSE, MDESC_DEFAULT, monster::mflag, mflag_has, monster_desc(), angband_constants::move_energy, player_state::num_blows, py_attack_real(), square_monster(), player::state, TRUE, 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 object_type 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, and player_state::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().