Atrinik Server  4.0
Macros | Functions | Variables
attack.c File Reference
#include <global.h>
#include <monster_data.h>
#include <faction.h>
#include <plugin.h>
#include <arch.h>
#include <attack.h>
#include <player.h>
#include <object.h>
#include <exp.h>
#include <disease.h>

Go to the source code of this file.

Macros

#define ATTACK_PROTECT_DAMAGE()
 

Functions

static int attack_check_sanity (object *op, object *hitter, bool *attack_map)
 
static bool attack_check_abort (object *op, object *hitter, bool attack_map)
 
static int attack_roll_adjust (object *op, object *hitter)
 
int attack_object (object *op, object *hitter)
 
static bool attack_block_hit (object *op, object *hitter, double *damage)
 
static void send_attack_msg (object *op, object *hitter, atnr_t atnr, double dam_done, double dam_orig)
 
static double attack_hit_attacktype (object *op, object *hitter, double dam, double dam_orig, atnr_t atnr)
 
int attack_hit (object *op, object *hitter, int dam)
 
void attack_hit_map (object *op, int dir, bool multi_reduce)
 
static void share_kill_exp_one (object *op, int64_t exp_gain, object *skill)
 
static void share_kill_exp (object *op, int64_t exp_gain, object *skill)
 
bool attack_kill (object *op, object *hitter)
 
void attack_perform_poison (object *op, object *hitter, double dam)
 
void attack_perform_slow (object *op)
 
void attack_perform_confusion (object *op)
 
void attack_perform_blind (object *op, object *hitter, double dam)
 
void attack_peform_paralyze (object *op, double dam)
 
void attack_perform_fall (object *op, int fall_floors)
 
bool attack_is_melee_range (object *hitter, object *enemy)
 

Variables

const char *const attack_save [NROFATTACKS]
 
const char *const attack_name [NROFATTACKS]
 

Detailed Description

This handles all attacks, magical or not.

Definition in file attack.c.

Macro Definition Documentation

#define ATTACK_PROTECT_DAMAGE ( )
Value:
do { \
dam *= (100.0 - op->protection[atnr]) / 100.0; \
} while (0)
atnr
Definition: attack.h:36
int8_t protection[NROFATTACKS]
Definition: object.h:439

Function Documentation

static bool attack_block_hit ( object op,
object hitter,
double *  damage 
)
static

Attempt to block a hit using a melee weapon or a shield.

Parameters
opVictim of the attacker.
hitterThe attacker.
[out]damageThe damage to do; may be modified.
Returns
True if the attack was completely blocked, false otherwise.

Definition at line 417 of file attack.c.

static bool attack_check_abort ( object op,
object hitter,
bool  attack_map 
)
static

Check if the attacker and the victim are still in a relation similar to the one determined by attack_check_sanity().

Parameters
opThe victim.
hitterThe attacker.
attack_mapPrevious mode as returned by attack_check_sanity().
Returns
true if the relation has changed, false otherwise.

Definition at line 123 of file attack.c.

static int attack_check_sanity ( object op,
object hitter,
bool *  attack_map 
)
static

Perform sanity checks to make sure the attacker can actually attack the target.

Parameters
opThe victim.
hitterThe attacker.
[out]attack_mapOn success, will contain a value indicating whether the attack is being done on a map or not.
Returns
True if the attacker can hit the victim, false otherwise.

Definition at line 80 of file attack.c.

int attack_hit ( object op,
object hitter,
int  dam 
)

Hit the specified object for the given amount of damage.

Parameters
opObject to be hit.
hitterWhat is hitting the object.
damBase damage. Protections, slaying, blocking, etc, will be taken into account.
Returns
Dealt damage.

Definition at line 669 of file attack.c.

static double attack_hit_attacktype ( object op,
object hitter,
double  dam,
double  dam_orig,
atnr_t  atnr 
)
static

Handles one attacktype's damage.

This doesn't damage the creature, but returns how much it should take. However, it will do other effects (paralyzation, slow, etc).

Parameters
opVictim of the attack.
hitterAttacker.
damDamage to deal.
dam_origOriginal damage that ought to have been done (not counting protections/blocking/etc).
atnrID of the attacktype of the attack.
Returns
Damage to actually do.

Definition at line 522 of file attack.c.

void attack_hit_map ( object op,
int  dir,
bool  multi_reduce 
)

Attack a spot on the map.

Parameters
opObject hitting the map.
dirDirection op is hitting/going.
multi_reduceWhether to reduce the damage for multi-arch monsters. This will make it so that part of 4-tiles monster only gets hit for 1/4 of the damage, making cone spells more fair against multi-arch monsters.

Definition at line 830 of file attack.c.

bool attack_is_melee_range ( object hitter,
object enemy 
)

Test if objects are in range for melee attack.

Parameters
hitterAttacker.
enemyEnemy – the target.
Returns
True if the target is in melee range, false otherwise.

Definition at line 1476 of file attack.c.

bool attack_kill ( object op,
object hitter 
)

An object was killed, handle various things (logging, messages, etc).

Parameters
opWhat is being killed.
hitterWho killed 'op'.
Return values
trueObject was killed.
falseObject was not killed.

Definition at line 981 of file attack.c.

int attack_object ( object op,
object hitter 
)

Make one object hit another for some amount of damage, primarily determined by the attacker's damage attribute.

The attacker's WC and the victim's AC will be considered, and a roll will be done to see if the attacker is successful in hitting the victim.

Parameters
opVictim.
hitterAttacker.
Returns
Dealt damage.

Definition at line 260 of file attack.c.

void attack_peform_paralyze ( object op,
double  dam 
)

Paralyze a living thing.

Parameters
opVictim.
damDamage to deal.

Definition at line 1399 of file attack.c.

void attack_perform_blind ( object op,
object hitter,
double  dam 
)

Blind a living object.

Parameters
opVictim.
hitterWho is attacking.
damDamage to deal.

Definition at line 1342 of file attack.c.

void attack_perform_confusion ( object op)

Confuse a living object.

Parameters
opVictim.

Definition at line 1294 of file attack.c.

void attack_perform_fall ( object op,
int  fall_floors 
)

Cause damage due to falling.

Parameters
opObject.
fall_floorsNumber of floors the object fell down.

Definition at line 1435 of file attack.c.

void attack_perform_poison ( object op,
object hitter,
double  dam 
)

Poison a living object.

Parameters
opVictim.
hitterWho is attacking.
damDamage to deal.

Definition at line 1169 of file attack.c.

void attack_perform_slow ( object op)

Slow a living object.

Parameters
opVictim.

Definition at line 1256 of file attack.c.

static int attack_roll_adjust ( object op,
object hitter 
)
static

Adjustments to attack rolls by various conditions.

Essentially simulates advantaged/disadvantaged rolls.

Parameters
opVictim of the attack.
hitterWho is attacking.
Returns
Adjustment to attack roll.

Definition at line 154 of file attack.c.

static void send_attack_msg ( object op,
object hitter,
atnr_t  atnr,
double  dam_done,
double  dam_orig 
)
static

Send message about an attack for the involved players.

Parameters
opVictim of the attack.
hitterAttacker.
atnrID of the attack type.
dam_doneActual damage done.
dam_origHow much damage should have been done, not counting protections.

Definition at line 471 of file attack.c.

static void share_kill_exp ( object op,
int64_t  exp_gain,
object skill 
)
static

Share experience gained by killing a monster. This will fairly share experience between party members, or if none are present, it will use share_kill_exp_one() instead.

Parameters
opPlayer that killed the monster.
exp_gainExperience to share.
skillSkill that was used to kill the monster.

Definition at line 914 of file attack.c.

static void share_kill_exp_one ( object op,
int64_t  exp_gain,
object skill 
)
inlinestatic

One player gets exp by killing a monster.

Parameters
opPlayer. This should be the killer.
exp_gainExperience to gain.
skillSkill that was used to kill the monster.

Definition at line 888 of file attack.c.

Variable Documentation

const char* const attack_name[NROFATTACKS]
Initial value:
= {
"impact", "slash", "cleave", "pierce", "weapon magic",
"fire", "cold", "electricity", "poison", "acid",
"magic", "lifesteal", "blind", "paralyze", "force",
"godpower", "chaos", "drain", "slow", "confusion",
"internal"
}

Short description of names of the attack types.

Definition at line 57 of file attack.c.

const char* const attack_save[NROFATTACKS]
Initial value:
= {
"impact", "slash", "cleave", "pierce", "weaponmagic",
"fire", "cold", "electricity", "poison", "acid",
"magic", "lifesteal", "blind", "paralyze", "force",
"godpower", "chaos", "drain", "slow", "confusion",
"internal"
}

Names of attack types to use when saving them to file.

Warning
Cannot contain spaces. Use underscores instead.

Definition at line 46 of file attack.c.