Angband
Macros | Functions | Variables
mon-summon.c File Reference

Monster summoning. More...

#include "angband.h"
#include "cave.h"
#include "datafile.h"
#include "mon-group.h"
#include "mon-make.h"
#include "mon-summon.h"
#include "mon-util.h"
#include "parser.h"
#include "list-mon-race-flags.h"

Macros

#define RF(a, b, c)   #a,
 

Functions

static enum parser_error parse_summon_name (struct parser *p)
 

Initialize monster summon types

More...
 
static enum parser_error parse_summon_message_type (struct parser *p)
 
static enum parser_error parse_summon_unique (struct parser *p)
 
static enum parser_error parse_summon_base (struct parser *p)
 
static enum parser_error parse_summon_race_flag (struct parser *p)
 
static enum parser_error parse_summon_fallback (struct parser *p)
 
static enum parser_error parse_summon_desc (struct parser *p)
 
struct parserinit_parse_summon (void)
 
static errr run_parse_summon (struct parser *p)
 
static errr finish_parse_summon (struct parser *p)
 
static void cleanup_summon (void)
 
int summon_name_to_idx (const char *name)
 Lookup function to translate names of summons to indices. More...
 
int summon_message_type (int summon_type)
 The message type for a particular summon. More...
 
int summon_fallback_type (int summon_type)
 The fallback type for a particular summon. More...
 
const char * summon_desc (int type)
 The description for a particular summon. More...
 
static bool summon_specific_okay (struct monster_race *race)
 Decide if a monster race is "okay" to summon. More...
 
static bool can_call_monster (struct loc grid, struct monster *mon)
 Check to see if you can call the monster. More...
 
static int call_monster (struct loc grid)
 Calls a monster from the level and moves it to the desired spot. More...
 
int summon_specific (struct loc grid, int lev, int type, bool delay, bool call)
 Places a monster (of the specified "type") near the given location. More...
 
struct monster_raceselect_shape (struct monster *mon, int type)
 Select a race for a monster shapechange from its possible summons. More...
 

Variables

static int summon_specific_type = 0
 The "type" of the current "summon specific". More...
 
static int summon_max = 0
 Maximum number of summon types. More...
 
struct monster_basekin_base
 The kin base for S_KIN. More...
 
struct summonsummons
 The summon array. More...
 
static const char * mon_race_flags []
 
struct file_parser summon_parser
 

Detailed Description

Monster summoning.

Copyright (c) 1997-2007 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.

Macro Definition Documentation

◆ RF

#define RF (   a,
  b,
 
)    #a,

Function Documentation

◆ call_monster()

static int call_monster ( struct loc  grid)
static

◆ can_call_monster()

static bool can_call_monster ( struct loc  grid,
struct monster mon 
)
static

Check to see if you can call the monster.

References cave, monster::grid, los(), monster::race, and summon_specific_okay().

Referenced by call_monster().

◆ cleanup_summon()

static void cleanup_summon ( void  )
static

◆ finish_parse_summon()

static errr finish_parse_summon ( struct parser p)
static

◆ init_parse_summon()

struct parser* init_parse_summon ( void  )

◆ parse_summon_base()

static enum parser_error parse_summon_base ( struct parser p)
static

◆ parse_summon_desc()

static enum parser_error parse_summon_desc ( struct parser p)
static

◆ parse_summon_fallback()

static enum parser_error parse_summon_fallback ( struct parser p)
static

◆ parse_summon_message_type()

static enum parser_error parse_summon_message_type ( struct parser p)
static

◆ parse_summon_name()

static enum parser_error parse_summon_name ( struct parser p)
static


Initialize monster summon types

References h, mem_zalloc(), summon::name, summon::next, parser_getstr(), parser_priv(), parser_setpriv(), and string_make().

Referenced by init_parse_summon().

◆ parse_summon_race_flag()

static enum parser_error parse_summon_race_flag ( struct parser p)
static

◆ parse_summon_unique()

static enum parser_error parse_summon_unique ( struct parser p)
static

◆ run_parse_summon()

static errr run_parse_summon ( struct parser p)
static

◆ select_shape()

struct monster_race* select_shape ( struct monster mon,
int  type 
)

Select a race for a monster shapechange from its possible summons.

References player::depth, get_mon_num(), get_mon_num_prep(), summon_specific_okay(), summon_specific_type, and type.

Referenced by monster_change_shape().

◆ summon_desc()

const char* summon_desc ( int  type)

The description for a particular summon.

References summon::desc, summon_max, and type.

Referenced by describe_effect().

◆ summon_fallback_type()

int summon_fallback_type ( int  summon_type)

The fallback type for a particular summon.

References summon::fallback.

Referenced by effect_handler_SUMMON().

◆ summon_message_type()

int summon_message_type ( int  summon_type)

The message type for a particular summon.

References summon::message_type.

Referenced by effect_handler_SUMMON().

◆ summon_name_to_idx()

int summon_name_to_idx ( const char *  name)

Lookup function to translate names of summons to indices.

Functions.

References i, streq, and summon_max.

Referenced by effect_handler_SUMMON(), effect_subtype(), finish_parse_summon(), monster_change_shape(), summon_specific(), and summon_specific_okay().

◆ summon_specific()

int summon_specific ( struct loc  grid,
int  lev,
int  type,
bool  delay,
bool  call 
)

Places a monster (of the specified "type") near the given location.

Return the siummoned monster's level iff a monster was actually summoned.

We will attempt to place the monster up to 10 times before giving up.

This function takes the "monster level" of the summoning monster as a parameter, and use that, along with the current dungeon level, to help determine the level of the desired monster. Note that this is an upper bound, and also tends to "prefer" monsters of that level. Currently, we use the average of the dungeon and monster levels, and then add five to allow slight increases in monster power.

Note that we use the new "monster allocation table" creation code to restrict the "get_mon_num()" function to the set of "legal" monsters, making this function much faster and more reliable.

Note that this function may not succeed, though this is very rare.

References call_monster(), cave, player::depth, monster::energy, get_mon_num(), get_mon_num_prep(), i, monster_group::index, monster_group_info::index, monster_race::level, monster::m_timed, chunk::mon_current, MON_GROUP_SUMMON, place_new_monster(), monster::race, monster_group_info::role, scatter(), monster_race::speed, player_state::speed, square_isdecoyed(), square_isempty(), square_iswarded(), square_monster(), player::state, summon_group(), summon_name_to_idx(), summon_specific_okay(), summon_specific_type, turns, and type.

Referenced by effect_handler_SUMMON().

◆ summon_specific_okay()

static bool summon_specific_okay ( struct monster_race race)
static

Decide if a monster race is "okay" to summon.

Compares the given monster to the monster type specified by summon_specific_type. Returns true if the monster is eligible to be summoned, false otherwise.

References monster_base_list::base, monster_race::base, summon::bases, monster_race::flags, monster_base_list::next, summon::race_flag, rf_has, summon_name_to_idx(), summon_specific_type, and summon::unique_allowed.

Referenced by can_call_monster(), select_shape(), and summon_specific().

Variable Documentation

◆ kin_base

struct monster_base* kin_base

The kin base for S_KIN.

Variables.

Referenced by effect_handler_SUMMON(), and monster_change_shape().

◆ mon_race_flags

const char* mon_race_flags[]
static

Referenced by parse_summon_race_flag().

◆ summon_max

int summon_max = 0
static

◆ summon_parser

struct file_parser summon_parser
Initial value:
= {
"summon",
}
static void cleanup_summon(void)
Definition: mon-summon.c:195
struct parser * init_parse_summon(void)
Definition: mon-summon.c:144
static errr finish_parse_summon(struct parser *p)
Definition: mon-summon.c:162
static errr run_parse_summon(struct parser *p)
Definition: mon-summon.c:158

◆ summon_specific_type

int summon_specific_type = 0
static

The "type" of the current "summon specific".

Referenced by select_shape(), summon_specific(), and summon_specific_okay().

◆ summons

struct summon* summons

The summon array.