Crossfire Server, Trunk
attack.c File Reference
#include "global.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "living.h"
#include "material.h"
#include "skills.h"
#include "sounds.h"
#include "sproto.h"
+ Include dependency graph for attack.c:

Go to the source code of this file.

Functions

static int abort_attack (object *target, object *hitter, int simple_attack)
 
static int adj_attackroll (object *hitter, object *target)
 
static void attack_message (int dam, int type, object *op, object *hitter)
 
int attack_ob (object *op, object *hitter)
 
static int attack_ob_simple (object *op, object *hitter, int base_dam, int base_wc)
 
objectblame (object *op)
 
void blind_living (object *op, object *hitter, int dam)
 
static void cancellation (object *op)
 
void confuse_living (object *op, object *hitter, int dam)
 
static void deathstrike_living (object *op, object *hitter, int *dam)
 
static int did_make_save_item (object *op, int type, object *originator)
 
int friendly_fire (object *op, object *hitter)
 
static void get_attack_message (int dam, int type, const object *op, const object *hitter, char *buf1, char *buf2)
 
void get_attack_message_for_attack_type (int dam, uint8_t atm_type, const char *victim_name, char *buf1, char *buf2)
 
static uint8_t get_attack_message_type (int type, const object *op, const object *hitter)
 
static int get_attack_mode (object **target, object **hitter, int *simple_attack)
 
int hit_map (object *op, int dir, uint32_t type, int full_hit)
 
int hit_player (object *op, int dam, object *hitter, uint32_t type, int full_hit)
 
objecthit_with_arrow (object *op, object *victim)
 
static int hit_with_one_attacktype (object *op, object *hitter, int dam, uint32_t attacknum)
 
static int is_aimed_missile (object *op)
 
static int kill_object (object *op, int dam, object *hitter)
 
static void object_get_materialtype (object *op, materialtype_t **mt)
 
void paralyze_living (object *op, int dam)
 
static void poison_living (object *op, object *hitter, int dam)
 
static void put_in_icecube (object *op, object *originator)
 
void save_throw_object (object *op, uint32_t type, object *originator)
 
static void scare_creature (object *target, object *hitter)
 
static void slow_living (object *op, object *hitter, int dam)
 
int slow_living_by (object *op, const int speed_penalty)
 
static int stick_arrow (object *op, object *tmp)
 
static void tear_down_wall (object *op)
 
static void thrown_item_effect (object *, object *)
 

Detailed Description

This handles all attacks, magical or not.

Todo:
clean functions. Are all parameters required? Seems quite a mess to send damage/wc etc in attack_ob_simple().

Definition in file attack.c.

Function Documentation

◆ abort_attack()

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 else.

Definition at line 718 of file attack.c.

References obj::env, FLAG_REMOVED, death_message::hitter, on_same_map(), and QUERY_FLAG.

Referenced by attack_ob_simple(), and hit_player().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adj_attackroll()

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 2508 of file attack.c.

References mapdef::darkness, FLAG_ALIVE, FLAG_BLIND, FLAG_CONFUSED, FLAG_REMOVED, FLAG_SCARED, FLAG_UNAGGRESSIVE, death_message::hitter, obj::invisible, is_aimed_missile(), llevError, LOG(), obj::map, monster_can_see_enemy(), monster_stand_in_light(), obj::move_type, object_get_owner(), on_same_map(), PLAYER, player_can_view(), and QUERY_FLAG.

Referenced by attack_ob_simple().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ attack_message()

static void attack_message ( int  dam,
int  type,
object op,
object hitter 
)
static

Send an attack message to someone.

Parameters
damamount of damage done.
typeattack type.
opvictim of the attack.
hitterwho is hitting.
Todo:
move check for player at function start? this function seems called for everyone. use string safe functions.

Definition at line 602 of file attack.c.

References AT_MAGIC, buf, draw_ext_info(), draw_ext_info_format(), FOR_MAP_FINISH, FOR_MAP_PREPARE, get_attack_message(), death_message::hitter, disinfect::map, MAX_BUF, MSG_TYPE_ATTACK, MSG_TYPE_ATTACK_DID_HIT, MSG_TYPE_ATTACK_PET_HIT, MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_WAS_HIT, obj::name, NDI_BLACK, give::next, object_get_owner(), give::op, OUT_OF_REAL_MAP, play_sound_map(), PLAYER, rndm(), SOUND_TYPE_HIT, SP_BULLET, SP_CONE, SP_EXPLOSION, SPELL_EFFECT, is_valid_types_gen::type, and obj::type.

Referenced by hit_player().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ attack_ob()

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 919 of file attack.c.

References attack_ob_simple(), HEAD, death_message::hitter, and give::op.

Referenced by do_skill_attack(), CRECombatSimulator::fight(), monsterFight(), and pets_move_golem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ attack_ob_simple()

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

Handles simple attack cases.

Parameters
opvictim. Should be the head part.
hitterattacked. Should be the head part.
base_damdamage to do.
base_wcwc to hit with.
Returns
dealt damage.
Todo:
fix void return values. Try to remove gotos. Better document when it's called.

Definition at line 749 of file attack.c.

References abort_attack(), adj_attackroll(), apply_anim_suffix(), AT_ACID, AT_PHYSICAL, Settings::casting_time, CLEAR_FLAG, draw_ext_info(), draw_ext_info_format(), EVENT_ATTACKS, events_execute_object_event(), FABS, FLAG_ALIVE, FLAG_HITBACK, FLAG_MONSTER, FLAG_SLEEP, get_attack_mode(), hit_player(), death_message::hitter, is_criminal(), make_visible(), monster_can_see_enemy(), monster_npc_call_help(), MSG_TYPE_ATTACK, MSG_TYPE_ATTACK_FUMBLE, MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_WAS_HIT, MSG_TYPE_VICTIM_WAS_PUSHED, NDI_ALL, NDI_UNIQUE, object_get_owner(), object_value_set(), object_was_destroyed, give::op, play_sound_map(), PLAYER, player_arrest(), PREFER_HIGH, PREFER_LOW, process_object(), QUERY_FLAG, random_roll(), rndm(), SCRIPT_FIX_ALL, settings, SOUND_TYPE_HIT, thrown_item_effect(), TRUE, and is_valid_types_gen::type.

Referenced by attack_ob(), and hit_with_arrow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ blame()

object* blame ( object op)

Definition at line 170 of file attack.c.

References object_get_owner(), give::op, PLAYER, and obj::type.

Referenced by save_throw_object().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ blind_living()

void blind_living ( object op,
object hitter,
int  dam 
)

Blind a living thing.

Parameters
opvictim.
hitterwho is attacking.
damdamage to deal.

Definition at line 2309 of file attack.c.

References ATNR_BLIND, BLINDNESS, change_abil(), create_archetype(), draw_ext_info_format(), fix_object(), FLAG_APPLIED, FLAG_BLIND, death_message::hitter, MAX_BUF, MSG_TYPE_ATTACK, MSG_TYPE_ATTACK_DID_HIT, NDI_UNIQUE, object_get_owner(), object_insert_in_ob(), object_present_in_ob(), give::op, query_name(), SET_FLAG, Ice::tmp, and reputation::victim.

Referenced by hit_with_one_attacktype(), and scroll_failure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancellation()

static void cancellation ( object op)
static

Cancels object *op. Cancellation basically means an object loses its magical benefits.

Parameters
opitem to cancel. Its inventory will also be cancelled.

Definition at line 49 of file attack.c.

References AT_CANCELLATION, CLEAR_FLAG, CONTAINER, did_make_save_item(), esrv_update_item(), FABS, FLAG_ALIVE, FLAG_CURSED, FLAG_DAMNED, FLAG_KNOWN_CURSED, FLAG_KNOWN_MAGICAL, FOR_INV_FINISH, FOR_INV_PREPARE, commongive::inv, give::op, PLAYER, QUERY_FLAG, rndm(), THROWN_OBJ, and UPD_FLAGS.

Referenced by hit_with_one_attacktype(), and save_throw_object().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confuse_living()

void confuse_living ( object op,
object hitter,
int  dam 
)

Confuse a living thing.

Parameters
opvictim.
hitterwho is attacking, unused.
damdamage to deal, unused.
Todo:
vary duration with dam/hitter?

Definition at line 2266 of file attack.c.

References add_string(), ATNR_CONFUSION, create_archetype(), draw_ext_info(), FLAG_APPLIED, FLAG_CONFUSED, FORCE, FORCE_CONFUSION, FORCE_NAME, free_string(), death_message::hitter, MAX, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_BAD_EFFECT_START, NDI_UNIQUE, object_insert_in_ob(), object_present_in_ob_by_name(), give::op, PLAYER, QUERY_FLAG, SET_FLAG, Ice::tmp, and nlohmann::detail::void().

Referenced by charge_mana_effect(), hit_with_one_attacktype(), prayer_failure(), scroll_failure(), spell_failure(), START_TEST(), and write_scroll().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deathstrike_living()

static void deathstrike_living ( object op,
object hitter,
int *  dam 
)
static

Attempts to kill 'op'.

The intention of a death attack is to kill outright things that are a lot weaker than the attacker, have a chance of killing things somewhat weaker than the caster, and no chance of killing something equal or stronger than the attacker.

If a deathstrike attack has a slaying, only a monster whose name or race matches a comma-delimited list in the slaying field of the deathstriking object is affected (this includes undead). If no slaying set, only undead are unaffected.

Parameters
opvictim.
hitterattacker.
[out]damdamage to deal, will contain computed damage or 0 if strike failed.

Definition at line 2404 of file attack.c.

References ATNR_DEATH, FLAG_UNDEAD, death_message::hitter, llevError, LOG(), give::op, PREFER_HIGH, QUERY_FLAG, random_roll(), and undead_name.

Referenced by hit_with_one_attacktype().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ did_make_save_item()

static int did_make_save_item ( object op,
int  type,
object originator 
)
static

Checks to make sure the item actually made its saving throw based on the tables. It does not take any further action (like destroying the item).

Parameters
opobject to check.
typeattack type.
originatorwhat it attacking?
Returns
TRUE if item saved, FALSE else.
Todo:
check meaning of originator.

Definition at line 98 of file attack.c.

References AT_BLIND, AT_CONFUSION, AT_COUNTERSPELL, AT_DEATH, AT_DEPLETE, AT_DRAIN, AT_FEAR, AT_GHOSTHIT, AT_HOLYWORD, AT_LIFE_STEALING, AT_MAGIC, AT_PARALYZE, AT_POISON, AT_SLOW, AT_TURN_UNDEAD, attacks, liv::dam, FALSE, NROFATTACKS, object_get_materialtype(), give::op, rndm(), _materialtype::save, obj::stats, TRUE, and is_valid_types_gen::type.

Referenced by cancellation(), and save_throw_object().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ friendly_fire()

int friendly_fire ( object op,
object hitter 
)

Find out if this is friendly fire (PVP and attacker is peaceful) or not

Parameters
opvictim.
hitterattacker.
Returns
0 this is not friendly fire, 1 if hitter is a peaceful player, 2 if hitter is a pet of a peaceful player.

Definition at line 1811 of file attack.c.

References obj::contr, DISEASE, HEAD, death_message::hitter, object_get_owner(), give::op, pl::peaceful, PLAYER, POISONING, RUNE, SPELL, and obj::type.

Referenced by hit_player().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_attack_message()

static void get_attack_message ( int  dam,
int  type,
const object op,
const object hitter,
char *  buf1,
char *  buf2 
)
static

Compute attack messages. Two versions are done, one for the living doing the action, the other for the victim of the attack.

Parameters
damamount of damage done.
typeattack type.
opvictim of the attack.
hitterwho is hitting.
[out]buf1where to write the message for the one doing the attack, must be at least MAX_BUF long.
[out]buf2where to write the message for the victim of the attack, must be at least MAX_BUF long.

Definition at line 563 of file attack.c.

References DOOR, get_attack_message_for_attack_type(), get_attack_message_type(), death_message::hitter, MAX_BUF, give::op, and is_valid_types_gen::type.

Referenced by attack_message().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_attack_message_for_attack_type()

void get_attack_message_for_attack_type ( int  dam,
uint8_t  atm_type,
const char *  victim_name,
char *  buf1,
char *  buf2 
)

Get the attack message for a damage and a type.

Parameters
damdamage done.
atm_typeone Attack types of type ATM_xxx.
victim_namename of the victim of the attack.
[out]buf1where to write the message for the one doing the attack, must be at least MAX_BUF long.
[out]buf2where to write the message for the victim of the attack, must be at least MAX_BUF long.

Definition at line 532 of file attack.c.

References attack_mess, attackmess::level, MAX_BUF, and MAXATTACKMESS.

Referenced by AttackMessagePanel::currentCellChanged(), and get_attack_message().

+ Here is the caller graph for this function:

◆ get_attack_message_type()

static uint8_t get_attack_message_type ( int  type,
const object op,
const object hitter 
)
static

Figure the Attack types ATM_xxx type for an attack.

Parameters
typebase attack type.
opvictim of the attack.
hitterwho is hitting.
Returns
attack message type.

Definition at line 457 of file attack.c.

References AT_COLD, AT_DRAIN, AT_ELECTRICITY, AT_FIRE, AT_MAGIC, AT_PHYSICAL, AT_POISON, ATM_ARROW, ATM_BASIC, ATM_BLUD, ATM_CLAW, ATM_CLEAVE, ATM_COLD, ATM_CRUSH, ATM_DOOR, ATM_DRAIN, ATM_ELEC, ATM_FIRE, ATM_KARATE, ATM_PIERCE, ATM_PUNCH, ATM_SLASH, ATM_SLICE, ATM_STAB, ATM_SUFFER, ATM_WHIP, ATM_WRAITH_FEED, DISEASE, DOOR, death_message::hitter, IS_ARROW, IS_LIVE, give::op, PLAYER, POISONING, SK_CLAWING, SK_KARATE, SK_PUNCHING, SK_WRAITH_FEED, SYMPTOM, is_valid_types_gen::type, USING_SKILL, WEAP_BLUD, WEAP_CLEAVE, WEAP_CRUSH, WEAP_HIT, WEAP_PIERCE, WEAP_SLASH, WEAP_SLICE, WEAP_STAB, and WEAP_WHIP.

Referenced by get_attack_message().

+ Here is the caller graph for this function:

◆ get_attack_mode()

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 else.
Returns
0 if hitter can attack target, 1 else.

Definition at line 682 of file attack.c.

References FLAG_FREED, FLAG_REMOVED, HEAD, death_message::hitter, llevError, LOG(), on_same_map(), and QUERY_FLAG.

Referenced by attack_ob_simple(), and hit_player().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hit_map()

int hit_map ( object op,
int  dir,
uint32_t  type,
int  full_hit 
)

Attack a spot on the map.

Parameters
opobject hitting the map.
dirdirection op is hitting/going.
typeattacktype.
full_hitif set then monster area does not matter, it gets all damage. Else damage is proportional to affected area vs full monster area.
Returns
1 if it hits something, 0 otherwise.

Definition at line 349 of file attack.c.

References AT_CHAOS, AT_COUNTERSPELL, AT_MAGIC, counterspell(), FLAG_ALIVE, FLAG_FREED, FLAG_REMOVED, FOR_INV_FINISH, FOR_INV_PREPARE, FOR_MAP_FINISH, FOR_MAP_PREPARE, freearr_x, freearr_y, get_map_flags(), HEAD, hit_player(), llevError, LOG(), disinfect::map, object_update(), object_was_destroyed, give::op, P_OUT_OF_MAP, PLAYER, QUERY_FLAG, save_throw_object(), shuffle_attack(), Ice::tmp, TRANSPORT, is_valid_types_gen::type, UP_OBJ_FACE, diamondslots::x, and diamondslots::y.

Referenced by explode_bullet(), explosion(), move_aura(), move_ball_spell(), move_bolt(), move_cone(), move_missile(), and rune_attack().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hit_player()

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

Object is attacked by something.

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

Oct 95 - altered the following slightly for MULTIPLE_GODS hack which needs new attacktype AT_HOLYWORD to work . b.t.

Parameters
opobject to be hit
dambase damage - protections/vulnerabilities/slaying matches can modify it.
hitterwhat is hitting the object
typeattacktype
full_hitset if monster area does not matter.
Returns
dealt damage.
Todo:
rename to something more meaningful.

Definition at line 1860 of file attack.c.

References abort_attack(), AT_CHAOS, AT_DEATH, AT_DRAIN, AT_HOLYWORD, AT_MAGIC, AT_PARALYZE, AT_PHYSICAL, AT_SLOW, ATNR_MAGIC, attack_message(), ATTACKS, change_object(), CLEAR_FLAG, determine_god(), did_make_save(), DOOR, EVENT_ATTACKED, events_execute_object_event(), find_god(), FLAG_ALIVE, FLAG_FREED, FLAG_FRIENDLY, FLAG_MONSTER, FLAG_NO_DAMAGE, FLAG_ONE_HIT, FLAG_RUN_AWAY, FLAG_SPLITTING, FLAG_TEAR_DOWN, FLAG_UNAGGRESSIVE, FLAG_UNDEAD, FLAG_WIZ, FOR_INV_FINISH, FOR_INV_PREPARE, friendly_fire(), get_attack_mode(), GRIMREAPER, hit_with_one_attacktype(), death_message::hitter, commongive::inv, kill_object(), llevDebug, LOG(), monster_npc_call_help(), archt::more, NROFATTACKS, object_find_by_type2(), object_free_drop_inventory(), object_get_owner(), object_remove(), object_set_enemy(), object_was_destroyed, give::op, op_on_battleground(), PLAYER, QUERY_FLAG, RANDOM, remove_friendly_object(), rndm(), RUNE, scare_creature(), SCRIPT_FIX_ALL, SET_FLAG, Settings::set_friendly_fire, settings, spring_trap(), tear_down_wall(), Ice::tmp, TRAP, is_valid_types_gen::type, and undead_name.

Referenced by attack_ob_simple(), cast_destruction(), cast_earth_to_dust(), cast_light(), check_bullet(), check_heal_and_mana(), enter_exit(), gate_type_process(), hit_map(), legacy_ob_process(), monster_check_doors(), monster_check_earthwalls(), move_symptom(), poison_type_apply(), poisoning_type_process(), rune_attack(), spell_effect_type_move_on(), spell_failure(), and START_TEST().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hit_with_arrow()

object* hit_with_arrow ( object op,
object victim 
)

hit_with_arrow() 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 961 of file attack.c.

References add_refcount(), attack_ob_simple(), obj::count, EVENT_ATTACKS, EVENT_CONNECTOR, events_execute_object_event(), fix_stopped_arrow(), FOR_OB_AND_BELOW_FINISH, FOR_OB_AND_BELOW_PREPARE, free_no_drop(), free_string(), death_message::hitter, INS_NO_MERGE, INS_NO_WALK_ON, obj::map, object_free_drop_inventory(), object_insert_in_map_at(), object_insert_in_ob(), object_merge(), object_remove(), object_set_owner(), object_was_destroyed, give::op, SCRIPT_FIX_ALL, obj::skill, stick_arrow(), reputation::victim, obj::x, and obj::y.

Referenced by common_process_projectile(), and common_projectile_move_on().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hit_with_one_attacktype()

static int hit_with_one_attacktype ( object op,
object hitter,
int  dam,
uint32_t  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.
dammaximum dealt damage.
attacknumnumber of the attacktype of the attack. See the ATNR_xxx values.
Returns
damage to actually do.

Definition at line 1172 of file attack.c.

References AMULET, ATNR_ACID, ATNR_BLIND, ATNR_CANCELLATION, ATNR_CHAOS, ATNR_CONFUSION, ATNR_COUNTERSPELL, ATNR_DEATH, ATNR_DEPLETE, ATNR_DRAIN, ATNR_FEAR, ATNR_HOLYWORD, ATNR_INTERNAL, ATNR_LIFE_STEALING, ATNR_PARALYZE, ATNR_PHYSICAL, ATNR_POISON, ATNR_SLOW, ATNR_TURN_UNDEAD, blind_living(), cancellation(), change_exp(), check_physically_infect(), confuse_living(), deathstrike_living(), determine_god(), did_make_save(), DOOR, drain_stat(), draw_ext_info_format(), esrv_update_item(), find_god(), fix_object(), FLAG_ALIVE, FLAG_APPLIED, FLAG_GENERATOR, FLAG_MONSTER, FLAG_UNDEAD, FLAG_WAS_WIZ, FOR_INV_FINISH, FOR_INV_PREPARE, get_turn_bonus(), GIRDLE, GOLEM, death_message::hitter, is_wraith_pl(), obj::level, llevError, LOG(), M_IRON, MAX, MAX_BUF, MAX_FOOD, MIN, MSG_TYPE_VICTIM, MSG_TYPE_VICTIM_WAS_HIT, NDI_RED, NDI_UNIQUE, NROFATTACKS, object_get_owner(), give::op, op_on_battleground(), paralyze_living(), PLAYER, poison_living(), PREFER_HIGH, PREFER_LOW, QUERY_FLAG, query_name(), random_roll(), RING, rndm(), ROD, scare_creature(), SK_EXP_TOTAL, obj::slaying, slow_living(), obj::stats, Ice::tmp, obj::type, undead_name, UPD_NAME, WAND, and liv::Wis.

Referenced by hit_player().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_aimed_missile()

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 else.

Definition at line 2575 of file attack.c.

References ARROW, MOVE_FLYING, give::op, SP_BULLET, SP_EXPLOSION, SPELL_EFFECT, and THROWN_OBJ.

Referenced by adj_attackroll().

+ Here is the caller graph for this function:

◆ kill_object()

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

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

GROS: This code comes from hit_player. It has been made external to allow script procedures to "kill" objects in a combat-like fashion. It was initially used by (kill-object) developed for the Collector's Sword. Note that nothing has been changed from the original version of the following code.

Will LOG pk, handles battleground, and so on.

This function was a bit of a mess with hitter getting changed, values being stored away but not used, etc. I've cleaned it up a bit - I think it should be functionally equivalant. MSW 2002-07-17

Parameters
opwhat is being killed.
damdamage done to it.
hitterwhat is hitting it.
Returns
dealt damage.
Todo:
finish commenting what it does exactly.

Definition at line 1540 of file attack.c.

References BIG_NAME, buf, calc_skill_exp(), change_luck(), check_exp_loss(), obj::chosen_skill, obj::contr, obj::current_weapon, DOOR, draw_ext_info(), draw_ext_info_format(), EVENT_DEATH, EVENT_GKILL, events_execute_global_event(), events_execute_object_event(), find_applied_skill_by_name(), FLAG_BLOCKSVIEW, FLAG_FRIENDLY, FLAG_MONSTER, FLAG_READY_WEAPON, FLAG_WAS_WIZ, FLAG_WIZ, pl::golem_count, death_message::hitter, socket_struct::host, kill_player(), obj::level, llevError, llevInfo, LOG(), MAX_BUF, MIN, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_PLAYER, MSG_TYPE_ATTACK, MSG_TYPE_ATTACK_DID_KILL, MSG_TYPE_ATTACK_PET_DIED, give::name, obj::name, NDI_ALL, NDI_BLACK, NDI_UNIQUE, object_free_drop_inventory(), object_get_owner(), object_handle_death_animation(), object_remove(), object_update_speed(), give::op, op_on_battleground(), pl::party, pl::peaceful, Settings::pk_luck_penalty, Settings::pk_max_experience, Settings::pk_max_experience_percent, play_sound_map(), PLAYER, QUERY_FLAG, query_name(), range_golem, pl::ranges, remove_friendly_object(), SCRIPT_FIX_ALL, settings, share_exp(), Settings::simple_exp, SK_EXP_TOTAL, SKILL, obj::skill, pl::socket, SOUND_TYPE_HIT, Floor::t, pl::title, obj::type, and update_all_los().

Referenced by hit_player().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ object_get_materialtype()

static void object_get_materialtype ( object op,
materialtype_t **  mt 
)
static

Definition at line 73 of file attack.c.

References materialt, name_to_material(), _materialtype::next, and give::op.

Referenced by did_make_save_item().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ paralyze_living()

void paralyze_living ( object op,
int  dam 
)

Paralyze a living thing.

Parameters
opvictim.
damdamage to deal.

Definition at line 2353 of file attack.c.

References ATNR_PARALYZE, draw_ext_info(), FABS, FLAG_PARALYZED, say::max, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_BAD_EFFECT_START, NDI_UNIQUE, give::op, PLAYER, QUERY_FLAG, and SET_FLAG.

Referenced by hit_with_one_attacktype(), prayer_failure(), scroll_failure(), and spell_failure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ poison_living()

static void poison_living ( object op,
object hitter,
int  dam 
)
static

◆ put_in_icecube()

static void put_in_icecube ( object op,
object originator 
)
static

Definition at line 145 of file attack.c.

References arch_to_object(), find_archetype(), FLAG_REMOVED, map_find_by_archetype(), object_insert_in_map_at(), object_insert_in_ob(), object_remove(), give::op, QUERY_FLAG, stop_item(), Ice::tmp, and nlohmann::detail::void().

Referenced by save_throw_object().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save_throw_object()

void save_throw_object ( object op,
uint32_t  type,
object originator 
)

◆ scare_creature()

static void scare_creature ( object target,
object hitter 
)
static

Creature is scared, update its values.

Parameters
targetscared creature.
hitterwho scared target.

Definition at line 1145 of file attack.c.

References obj::enemy, FLAG_SCARED, death_message::hitter, object_get_owner(), object_set_enemy(), and SET_FLAG.

Referenced by hit_player(), and hit_with_one_attacktype().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ slow_living()

static void slow_living ( object op,
object hitter,
int  dam 
)
static

Slow a living thing.

Parameters
opvictim.
hitterwho is attacking.
damdamage to deal.
Todo:
use dam to change the duration, or remove param

Give slow attacks some oomph – always speed -1 was REALLY weak

Daniel Hawkins 2018-05-31

Definition at line 2221 of file attack.c.

References ATNR_SLOW, draw_ext_info(), death_message::hitter, MSG_TYPE_ATTRIBUTE, MSG_TYPE_ATTRIBUTE_BAD_EFFECT_START, NDI_UNIQUE, give::op, PREFER_LOW, random_roll(), slow_living_by(), and nlohmann::detail::void().

Referenced by hit_with_one_attacktype().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ slow_living_by()

int slow_living_by ( object op,
const int  speed_penalty 
)

Definition at line 2182 of file attack.c.

References arch_present_in_ob(), arch_to_object(), find_archetype(), fix_object(), FLAG_APPLIED, object_insert_in_ob(), give::op, SET_FLAG, and Ice::tmp.

Referenced by eat_common(), and slow_living().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stick_arrow()

static int stick_arrow ( object op,
object tmp 
)
static

Try to put an arrow in inventory.

Parameters
oparrow to try to insert.
tmpwhat is stopping the arrow.
Returns
1 if op was inserted into tmp's inventory, 0 otherwise.

Definition at line 934 of file attack.c.

References HEAD, object_insert_in_ob(), object_remove(), give::op, and Ice::tmp.

Referenced by hit_with_arrow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tear_down_wall()

static void tear_down_wall ( object op)
static

Handles wall tearing animation. Will change the face according to the hp/maxhp ration.

If the wall reaches its last animation, either free it or set it non living so it doesn't block anymore.

Parameters
opwall to update.

Definition at line 1096 of file attack.c.

References blank_face, CLEAR_FLAG, FLAG_ALIVE, FLAG_BLOCKSVIEW, GET_ANIM_ID, if(), make_face_from_files::int, llevError, LOG(), NUM_ANIMATIONS, object_free_drop_inventory(), object_remove(), object_update(), give::op, SET_ANIMATION, UP_OBJ_FACE, and update_all_los().

Referenced by hit_player().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ thrown_item_effect()

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.
Todo:
invert parameters for coherence with other functions?

Definition at line 2468 of file attack.c.

References ATNR_MAGIC, ATNR_POISON, FLAG_ALIVE, FLAG_UNDEAD, death_message::hitter, ob_apply(), POISON, POTION, QUERY_FLAG, reputation::victim, and nlohmann::detail::void().

Referenced by attack_ob_simple().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: