28 #define sqr(x) ((x)*(x)) 50 int write_rune(
object *op,
object *caster,
object *spell,
int dir,
const char *runename) {
51 object *rune_spell, *rune;
66 "Can't make a rune there!");
70 if (tmp->type == RUNE) {
72 "You can't write a rune there.");
77 if (spell->other_arch) {
84 int bestmatch = 0, ms;
86 if (!runename || *runename == 0) {
88 "Write a rune of what?");
94 if (tmp->type == SPELL) {
105 "You don't know any spell named %s",
109 if (rune_spell->skill != spell->skill) {
112 "You can't cast %s with %s",
113 rune_spell->name, spell->name);
116 if (caster->path_denied&spell->path_attuned) {
118 "%s belongs to a spell path denied to you.",
122 if (
caster_level(caster, rune_spell) < rune_spell->level) {
124 "%s is beyond your ability to cast!",
130 "You don't have enough mana.");
134 if ((gr > 0) && (gr > op->stats.grace)) {
136 "You don't have enough grace.");
139 op->stats.grace -= gr;
143 if (rune_spell->type == RUNE) {
149 snprintf(buf,
sizeof(buf),
"You set off a rune of %s\n", rune_spell->name);
155 rune->face = spell->face;
158 rune->stats.Cha = rune->level/2;
159 rune->direction = dir;
177 tag_t tag = victim->count;
178 hit_player(victim, op->stats.dam, op, op->attacktype, 1);
179 if (object_was_destroyed(victim, tag))
183 create_treasure(op->randomitems, op, 0, (victim->map ? victim->map->difficulty : 1), 0);
184 if (op->inv && op->inv->type == DISEASE) {
185 object *disease = op->inv;
192 hit_map(op, 0, op->attacktype, 1);
207 tag_t trap_tag = trap->count;
212 if (trap->stats.hp <= 0)
219 has_spell = ((trap->inv && trap->inv->type == SPELL) || (trap->other_arch && trap->other_arch->clone.type == SPELL));
239 if (victim && victim->type == PLAYER && trap->msg != NULL && trap->msg[0] !=
'\0')
256 if (object_was_destroyed(trap, trap_tag))
259 for (i = 0; i <
MAX(1, trap->stats.maxhp); i++) {
261 cast_spell(trap, trap, trap->direction, trap->inv, NULL);
264 cast_spell(trap, trap, trap->direction, spell, NULL);
270 if (object_was_destroyed(trap, trap_tag))
274 if (trap->stats.hp <= 0) {
276 trap->stats.food = 20;
299 int dispel_rune(
object *op,
object *caster,
object *spell,
object *skill,
int dir) {
316 "There's nothing there!");
332 if (tmp->type == RUNE || tmp->type == TRAP) {
341 if (tmp->type == SIGN && !strcmp(tmp->arch->name,
"rune_mark")) {
345 "You wipe out the rune of marking!");
362 "There's nothing there!");
386 if ((trap->stats.Cha == 1)
387 || (chance >
MIN(95,
MAX(5, ((
int)((
float)(op->map->difficulty+trap->level+trap->stats.Cha-op->level)/10.0*50.0)))))) {
415 if (trap->animation || trap->temp_animation)
418 tmp2->face = trap->face;
437 int trap_disarm(
object *disarmer,
object *trap,
int risk,
object *skill) {
442 trapworth =
MAX(1, trap->level)*disarmer->map->difficulty*
443 sqr(
MAX(trap->stats.dam, trap->inv ? trap->inv->level : 1))/skill->level;
450 "You successfully disarm the %s!",
457 if (owner != NULL && owner->type != PLAYER && risk)
464 "You fail to disarm the %s.",
470 "In fact, you set it off!");
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
int caster_level(const object *caster, const object *spell)
#define MSG_TYPE_COMMAND_FAILURE
object * object_get_env_recursive(object *op)
#define MSG_TYPE_APPLY_TRAP
#define MSG_TYPE_SPELL_FAILURE
short freearr_x[SIZEOFFREE]
int16_t SP_level_spellpoint_cost(object *caster, object *spell, int flags)
#define GET_ANIMATION(ob, anim)
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
short freearr_y[SIZEOFFREE]
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
void object_set_owner(object *op, object *owner)
void object_free_drop_inventory(object *ob)
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
object * object_new(void)
object * object_insert_in_ob(object *op, object *where)
#define MSG_TYPE_SPELL_SUCCESS
#define MSG_TYPE_COMMAND_SUCCESS
object * arch_to_object(archetype *at)
object * create_archetype(const char *name)
#define MSG_TYPE_SPELL_ERROR
int trap_disarm(object *disarmer, object *trap, int risk, object *skill)
int hit_map(object *op, int dir, uint32_t type, int full_hit)
int infect_object(object *victim, object *disease, int force)
#define QUERY_FLAG(xyz, p)
int write_rune(object *op, object *caster, object *spell, int dir, const char *runename)
void spring_trap(object *trap, object *victim)
int dispel_rune(object *op, object *caster, object *spell, object *skill, int dir)
void set_spell_skill(object *op, object *caster, object *spob, object *dest)
void destroy_object(object *op)
int object_matches_string(object *pl, object *op, const char *name)
static void rune_attack(object *op, object *victim)
int trap_see(object *op, object *trap)
void object_copy(const object *src_ob, object *dest_ob)
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
void object_set_msg(object *op, const char *msg)
int trap_show(object *trap, object *where)
int random_roll(int min, int max, const object *op, int goodbad)
int hit_player(object *op, int dam, object *hitter, uint32_t type, int full_hit)
int get_rangevector(object *op1, const object *op2, rv_vector *retval, int flags)
object * object_get_owner(object *op)
#define HAS_RANDOM_ITEMS(op)
#define FOR_INV_PREPARE(op_, it_)
int cast_spell(object *op, object *caster, int dir, object *spell_ob, char *stringarg)
void object_remove(object *op)
object * object_find_by_type2(const object *who, int type1, int type2)