Atrinik Server 2.5
Defines | Functions
server/attack.c File Reference
#include <global.h>

Go to the source code of this file.

Defines

#define ATTACK_HIT_DAMAGE(_op, _anum)   dam = dam * ((double) _op->attack[_anum] * (double) 0.01); dam >= 1.0f ? (damage = (int) dam) : (damage = 1)
#define ATTACK_PROTECT_DAMAGE(_op, _anum)   dam = dam * ((double) (100 - _op->protection[_anum]) * (double) 0.01)

Functions

static void thrown_item_effect (object *hitter, object *victim)
static int get_attack_mode (object **target, object **hitter, int *simple_attack)
static int abort_attack (object *target, object *hitter, int simple_attack)
static int attack_ob_simple (object *op, object *hitter, int base_dam, int base_wc)
static void send_attack_msg (object *op, object *hitter, int attacknum, int dam, int damage)
static int hit_player_attacktype (object *op, object *hitter, int damage, uint32 attacknum)
static void poison_player (object *op, object *hitter, float dam)
static void slow_living (object *op)
static void blind_living (object *op, object *hitter, int dam)
static int adj_attackroll (object *hitter, object *target)
static int is_aimed_missile (object *op)
int attack_ob (object *op, object *hitter)
int hit_player (object *op, int dam, object *hitter, int type)
int hit_map (object *op, int dir, int reduce)
static void share_kill_exp_one (object *op, sint64 exp, object *skill)
static void share_kill_exp (object *op, sint64 exp, object *skill)
int kill_object (object *op, int dam, object *hitter, int type)
objecthit_with_arrow (object *op, object *victim)
void confuse_living (object *op)
void paralyze_living (object *op, int dam)
int is_melee_range (object *hitter, object *enemy)
int spell_attack_missed (object *hitter, object *enemy)

Detailed Description

This handles all attacks, magical or not.

Definition in file attack.c.


Function Documentation

static int abort_attack ( object target,
object hitter,
int  simple_attack 
) [static]

Check if target and hitter are still in a relation similar to the one determined by get_attack_mode().

Parameters:
targetWho is attacked.
hitterWho is attacking.
simple_attackPrevious mode as returned by get_attack_mode().
Returns:
1 if the relation has changed, 0 otherwise.

Definition at line 1164 of file attack.c.

static int adj_attackroll ( object hitter,
object target 
) [static]

Adjustments to attack rolls by various conditions.

Parameters:
hitterWho is hitting.
targetVictim of the attack.
Returns:
Adjustment to attack roll.

Definition at line 1605 of file attack.c.

int attack_ob ( object op,
object hitter 
)

Simple wrapper for attack_ob_simple(), will use hitter's values.

Parameters:
opVictim.
hitterAttacker.
Returns:
Dealt damage.

Definition at line 52 of file attack.c.

static int attack_ob_simple ( object op,
object hitter,
int  base_dam,
int  base_wc 
) [static]

Handles simple attack cases.

Parameters:
opVictim.
hitterAttacker.
base_damDamage to do.
base_wcWC to hit with.
Returns:
Dealt damage.

Definition at line 74 of file attack.c.

static void blind_living ( object op,
object hitter,
int  dam 
) [static]

Blind a living thing.

Parameters:
opVictim.
hitterWho is attacking.
damDamage to deal.

Definition at line 1488 of file attack.c.

void confuse_living ( object op)

Confuse a living thing.

Parameters:
opVictim.

Definition at line 1452 of file attack.c.

static int get_attack_mode ( object **  target,
object **  hitter,
int *  simple_attack 
) [static]

Find correct parameters for attack, do some sanity checks.

Parameters:
targetWill point to victim's head.
hitterWill point to hitter's head.
simple_attackWill be 1 if one of victim or target isn't on a map, 0 otherwise.
Returns:
0 if hitter can attack target, 1 otherwise.

Definition at line 1123 of file attack.c.

int hit_map ( object op,
int  dir,
int  reduce 
)

Attack a spot on the map.

Parameters:
opObject hitting the map.
dirDirection op is hitting/going.
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 storms more fair against multi-arch monsters.
Returns:
0.

Definition at line 471 of file attack.c.

int hit_player ( object op,
int  dam,
object hitter,
int  type 
)

Object is attacked by something.

This isn't used just for players, but in fact most objects.

Parameters:
opObject to be hit.
damBase damage - protections/vulnerabilities/slaying matches can modify it.
hitterWhat is hitting the object.
typeAttacktype.
Returns:
Dealt damage.

Definition at line 247 of file attack.c.

static int hit_player_attacktype ( object op,
object hitter,
int  damage,
uint32  attacknum 
) [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.
damageMaximum dealt damage.
attacknumNumber of the attacktype of the attack.
Returns:
Damage to actually do.

Definition at line 628 of file attack.c.

object* hit_with_arrow ( object op,
object victim 
)

Disassembles the missile, attacks the victim and reassembles the missile.

Parameters:
opMissile hitting.
victimWho is hit by op.
Returns:
Pointer to the reassembled missile, or NULL if the missile isn't available anymore.

Definition at line 1191 of file attack.c.

static int is_aimed_missile ( object op) [static]

Determine if the object is an 'aimed' missile.

Parameters:
opObject to check.
Returns:
1 if aimed missile, 0 otherwise.

Definition at line 1669 of file attack.c.

int is_melee_range ( object hitter,
object enemy 
)

Test if objects are in range for melee attack.

Parameters:
hitterAttacker.
enemyEnemy.
Return values:
0Enemy target is not in melee range.
1Target is in range and we're facing it.

Definition at line 1685 of file attack.c.

int kill_object ( object op,
int  dam,
object hitter,
int  type 
)

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

Parameters:
opWhat is being killed.
damDamage done to it.
hitterWhat is hitting it.
typeThe attacktype.
Returns:
Dealt damage.

Definition at line 938 of file attack.c.

void paralyze_living ( object op,
int  dam 
)

Paralyze a living thing.

Parameters:
opVictim.
damDamage to deal.

Definition at line 1539 of file attack.c.

static void poison_player ( object op,
object hitter,
float  dam 
) [static]

Poison a living thing.

Parameters:
opVictim.
hitterWho is attacking.
damDamage to deal.

Definition at line 1302 of file attack.c.

static void send_attack_msg ( object op,
object hitter,
int  attacknum,
int  dam,
int  damage 
) [static]

Send attack message for players.

Parameters:
opVictim of the attack.
hitterAttacker.
attacknumID of the attack type.
damActual damage done.
damageHow much damage should have been done, not counting resists/protections/etc.

Definition at line 832 of file attack.c.

static void share_kill_exp ( object op,
sint64  exp,
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.
expExperience to share.
skillSkill that was used to kill the monster.

Definition at line 871 of file attack.c.

static void share_kill_exp_one ( object op,
sint64  exp,
object skill 
) [static]

One player gets exp by killing a monster.

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

Definition at line 852 of file attack.c.

static void slow_living ( object op) [static]

Slow a living thing.

Parameters:
opVictim.

Definition at line 1423 of file attack.c.

int spell_attack_missed ( object hitter,
object enemy 
)

Checks if a spell attack missed its enemy.

Parameters:
hitterThe spell.
enemyThe enemy.
Returns:
1 if the attack missed, 0 otherwise.

Definition at line 1720 of file attack.c.

static void thrown_item_effect ( object hitter,
object victim 
) [static]

Handles any special effects of thrown items (like attacking living creatures -- a potion thrown at a monster).

Parameters:
hitterThrown item.
victimObject that is hit by hitter.

Definition at line 1570 of file attack.c.