1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game for X-windows |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (C) 2003 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2003 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * (at your option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * along with this program; if not, write to the Free Software |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <sproto.h> |
26 | #include <sproto.h> |
27 | #include <spells.h> |
27 | #include <spells.h> |
… | |
… | |
34 | * write_rune: |
34 | * write_rune: |
35 | * op: rune writer |
35 | * op: rune writer |
36 | * skop: skill object used for casting this rune |
36 | * skop: skill object used for casting this rune |
37 | * dir: orientation of rune, direction rune's contained spell will |
37 | * dir: orientation of rune, direction rune's contained spell will |
38 | * be cast in, if applicable |
38 | * be cast in, if applicable |
39 | * inspell: spell object to put into the rune, can be null if doing |
39 | * spell: spell object to put into the rune |
40 | * a marking rune. |
|
|
41 | * level: level of casting of the rune |
40 | * level: level of casting of the rune |
42 | * runename: name of the rune or message displayed by the rune for |
41 | * runename: name of the rune or message displayed by the rune for |
43 | * a rune of marking |
42 | * a rune of marking |
44 | */ |
43 | */ |
45 | |
|
|
46 | int |
44 | int |
47 | write_rune (object *op, object *caster, object *spell, int dir, const char *runename) |
45 | write_rune (object *op, object *caster, object *spell, int dir, const char *runename) |
48 | { |
46 | { |
49 | object *tmp, *rune_spell, *rune; |
47 | object *tmp, *rune_spell, *rune; |
50 | char buf[MAX_BUF]; |
|
|
51 | maptile *m; |
48 | maptile *m; |
52 | sint16 nx, ny; |
49 | sint16 nx, ny; |
53 | |
50 | |
54 | if (!dir) |
51 | if (!dir) |
55 | dir = 1; |
52 | dir = 1; |
56 | |
53 | |
57 | nx = op->x + freearr_x[dir]; |
54 | nx = op->x + freearr_x[dir]; |
58 | ny = op->y + freearr_y[dir]; |
55 | ny = op->y + freearr_y[dir]; |
59 | m = op->map; |
56 | m = op->map; |
60 | |
57 | |
61 | if (get_map_flags (m, &m, nx, ny, &nx, &ny) && (P_OUT_OF_MAP | P_SAFE | P_NO_MAGIC | P_NO_CLERIC)) |
58 | if (get_map_flags (m, &m, nx, ny, &nx, &ny) & (P_OUT_OF_MAP | P_SAFE | P_NO_MAGIC | P_NO_CLERIC)) |
62 | { |
59 | { |
63 | new_draw_info (NDI_UNIQUE, 0, op, "Can't make a rune there!"); |
60 | new_draw_info (NDI_UNIQUE, 0, op, "Can't make a rune there!"); |
64 | return 0; |
61 | return 0; |
65 | } |
62 | } |
66 | |
63 | |
… | |
… | |
68 | if (tmp->type == RUNE) |
65 | if (tmp->type == RUNE) |
69 | break; |
66 | break; |
70 | |
67 | |
71 | if (tmp) |
68 | if (tmp) |
72 | { |
69 | { |
73 | new_draw_info (NDI_UNIQUE, 0, op, "You can't write a rune there."); |
70 | new_draw_info (NDI_UNIQUE, 0, op, "You can't write a rune on top of another rune."); |
74 | return 0; |
71 | return 0; |
75 | } |
72 | } |
76 | |
73 | |
77 | if (spell->other_arch) |
74 | if (spell->other_arch) |
78 | rune_spell = arch_to_object (spell->other_arch); |
75 | rune_spell = spell->other_arch->instance (); |
79 | else |
76 | else |
80 | { |
77 | { |
81 | /* Player specified spell. The player has to know the spell, so |
78 | /* Player specified spell. The player has to know the spell, so |
82 | * lets just look through the players inventory see if they know it |
79 | * lets just look through the players inventory see if they know it |
83 | * use the item_matched_string for our typical matching method. |
80 | * use the item_matched_string for our typical matching method. |
… | |
… | |
90 | return 0; |
87 | return 0; |
91 | } |
88 | } |
92 | |
89 | |
93 | rune_spell = NULL; |
90 | rune_spell = NULL; |
94 | for (tmp = op->inv; tmp; tmp = tmp->below) |
91 | for (tmp = op->inv; tmp; tmp = tmp->below) |
95 | { |
|
|
96 | if (tmp->type == SPELL) |
92 | if (tmp->type == SPELL) |
97 | { |
93 | { |
98 | ms = item_matched_string (op, tmp, runename); |
94 | ms = item_matched_string (op, tmp, runename); |
99 | if (ms > bestmatch) |
95 | if (ms > bestmatch) |
100 | { |
96 | { |
101 | bestmatch = ms; |
97 | bestmatch = ms; |
102 | rune_spell = tmp; |
98 | rune_spell = tmp; |
103 | } |
99 | } |
104 | } |
100 | } |
105 | } |
|
|
106 | |
101 | |
107 | if (!rune_spell) |
102 | if (!rune_spell) |
108 | { |
103 | { |
109 | new_draw_info_format (NDI_UNIQUE, 0, op, "You don't know any spell named %s", runename); |
104 | new_draw_info_format (NDI_UNIQUE, 0, op, "You don't know any spell named %s.", runename); |
110 | return 0; |
105 | return 0; |
111 | } |
106 | } |
112 | |
107 | |
113 | if (rune_spell->skill != spell->skill) |
108 | if (rune_spell->skill != spell->skill) |
114 | { |
109 | { |
115 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can't cast %s with %s", &rune_spell->name, &spell->name); |
110 | new_draw_info_format (NDI_UNIQUE, 0, op, "You can't cast %s with %s. H<The spell must be of the %s spell school.>", &rune_spell->name, &spell->name, &spell->skill); |
116 | return 0; |
111 | return 0; |
117 | } |
112 | } |
118 | |
113 | |
119 | if (caster->path_denied & spell->path_attuned) |
114 | if (caster->path_denied & spell->path_attuned && !caster->flag [FLAG_WIZCAST]) |
120 | { |
115 | { |
121 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s belongs to a spell path denied to you.", &rune_spell->name); |
116 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s belongs to a spell path denied to you.", &rune_spell->name); |
122 | return 0; |
117 | return 0; |
123 | } |
118 | } |
124 | |
119 | |
125 | if (caster_level (caster, rune_spell) < rune_spell->level) |
120 | if (casting_level (caster, rune_spell) < rune_spell->level && !caster->flag [FLAG_WIZCAST]) |
126 | { |
121 | { |
127 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s is beyond your ability to cast!", &rune_spell->name); |
122 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s is beyond your ability to cast! H<Your effetcive casting level is too low.>", &rune_spell->name); |
128 | return 0; |
123 | return 0; |
129 | } |
124 | } |
130 | |
125 | |
131 | if (SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA) > op->stats.sp) |
126 | if (SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA) > op->stats.sp) |
132 | { |
127 | { |
… | |
… | |
139 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough grace."); |
134 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough grace."); |
140 | return 0; |
135 | return 0; |
141 | } |
136 | } |
142 | |
137 | |
143 | op->stats.grace -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_GRACE); |
138 | op->stats.grace -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_GRACE); |
144 | op->stats.sp -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA); |
139 | op->stats.sp -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA); |
145 | } |
140 | } |
146 | |
141 | |
147 | /* already proper rune. Note this should only be the case if other_arch was set */ |
142 | /* already proper rune. Note this should only be the case if other_arch was set */ |
148 | if (rune_spell->type == RUNE) |
143 | if (rune_spell->type == RUNE) |
149 | rune = rune_spell; |
144 | rune = rune_spell; |
150 | else |
145 | else |
151 | { |
146 | { |
152 | rune = get_archetype (GENERIC_RUNE); |
147 | rune = archetype::get (GENERIC_RUNE); |
153 | sprintf (buf, "You set off a rune of %s\n", &rune_spell->name); |
148 | rune->msg = format ("You set off a rune of %s\n", &rune_spell->name); |
154 | rune->msg = buf; |
|
|
155 | rune->insert (rune_spell->clone ()); |
149 | rune->insert (rune_spell->clone ()); |
156 | |
150 | |
157 | if (spell->face != blank_face) |
151 | if (spell->face != blank_face) |
158 | rune->face = spell->face; |
152 | rune->face = spell->face; |
159 | } |
153 | } |
160 | |
154 | |
161 | rune->level = caster_level (caster, spell); |
155 | rune->level = casting_level (caster, spell); |
162 | rune->stats.Cha = rune->level / 2; /* the invisibility parameter */ |
156 | rune->stats.Cha = rune->level / 2; /* the invisibility parameter */ |
163 | rune->direction = dir; /* where any spell will go upon detonation */ |
157 | rune->direction = dir; /* where any spell will go upon detonation */ |
164 | rune->set_owner (op); /* runes without need no owner */ |
158 | rune->set_owner (op); /* runes without need no owner */ |
165 | set_spell_skill (op, caster, spell, rune); |
159 | set_spell_skill (op, caster, spell, rune); |
166 | |
160 | |
… | |
… | |
187 | if (!op->level) |
181 | if (!op->level) |
188 | return; |
182 | return; |
189 | |
183 | |
190 | int det = op->invisible; |
184 | int det = op->invisible; |
191 | |
185 | |
192 | if (!(rndm (0, MAX (1, (op->stats.Cha)) - 1))) |
186 | if (!(rndm (0, max (0, op->stats.Cha - 1)))) |
193 | { |
187 | { |
194 | op->invisible = 0; |
188 | op->invisible = 0; |
195 | op->speed_left -= 1; |
189 | op->speed_left -= 1; |
196 | } |
190 | } |
197 | else |
191 | else |
198 | op->invisible = 1; |
192 | op->invisible = 1; |
199 | |
193 | |
200 | if (op->invisible != det) |
194 | if (op->invisible != det) |
201 | update_object (op, UP_OBJ_FACE); |
195 | update_object (op, UP_OBJ_CHANGE); |
202 | } |
196 | } |
203 | |
|
|
204 | |
197 | |
205 | /* peterm: rune_attack |
198 | /* peterm: rune_attack |
206 | * function handles those runes which detonate but do not cast spells. |
199 | * function handles those runes which detonate but do not cast spells. |
207 | */ |
200 | */ |
208 | |
201 | static void |
209 | |
|
|
210 | void |
|
|
211 | rune_attack (object *op, object *victim) |
202 | rune_attack (object *op, object *victim) |
212 | { |
203 | { |
213 | if (victim) |
204 | if (victim) |
214 | { |
205 | { |
215 | hit_player (victim, op->stats.dam, op, op->attacktype, 1); |
206 | hit_player (victim, op->stats.dam, op, op->attacktype, 1); |
… | |
… | |
246 | |
237 | |
247 | /* Prevent recursion */ |
238 | /* Prevent recursion */ |
248 | if (trap->stats.hp <= 0) |
239 | if (trap->stats.hp <= 0) |
249 | return; |
240 | return; |
250 | |
241 | |
251 | if (QUERY_FLAG (trap, FLAG_IS_LINKED)) |
242 | if (trap->flag [FLAG_IS_LINKED]) |
252 | use_trigger (trap); |
243 | use_trigger (trap, victim); |
253 | |
244 | |
254 | /* Only living objects can trigger runes that don't cast spells, as |
245 | /* Only living objects can trigger runes that don't cast spells, as |
255 | * doing direct damage to a non-living object doesn't work anyway. |
246 | * doing direct damage to a non-living object doesn't work anyway. |
256 | * Typical example is an arrow attacking a door. |
247 | * Typical example is an arrow attacking a door. |
257 | */ |
248 | */ |
258 | if (!QUERY_FLAG (victim, FLAG_ALIVE) && !trap->inv && !trap->other_arch) |
249 | if (!victim->flag [FLAG_ALIVE] && !trap->inv && !trap->other_arch) |
259 | return; |
250 | return; |
260 | |
251 | |
261 | trap->stats.hp--; /*decrement detcount */ |
252 | trap->stats.hp--; /*decrement detcount */ |
262 | |
253 | |
263 | if (victim && victim->type == PLAYER) |
254 | if (victim && victim->type == PLAYER) |
264 | new_draw_info (NDI_UNIQUE, 0, victim, trap->msg); |
255 | new_draw_info (NDI_UNIQUE, 0, victim, trap->msg); |
265 | |
256 | |
266 | /* Flash an image of the trap on the map so the poor sod |
257 | /* Flash an image of the trap on the map so the poor sod |
267 | * knows what hit him. |
258 | * knows what hit him. |
268 | */ |
259 | */ |
269 | env = object_get_env_recursive (trap); |
260 | env = trap->outer_env_or_self (); |
270 | |
261 | |
271 | /* If the victim is not next to this trap, don't set it off. |
262 | /* If the victim is not next to this trap, don't set it off. |
272 | * players shouldn't get hit by firing arrows at a door for example. |
263 | * players shouldn't get hit by firing arrows at a door for example. |
273 | * At the same time, the trap will stick around until detonated |
264 | * At the same time, the trap will stick around until detonated |
274 | */ |
265 | */ |
275 | get_rangevector (env, victim, &rv, 0); |
266 | get_rangevector (env, victim, &rv, 0); |
276 | if (rv.distance > 1) |
267 | if (rv.distance > 1) |
277 | return; |
268 | return; |
278 | |
269 | |
|
|
270 | env->play_sound (trap->sound ? trap->sound : sound_find ("trap_spring")); |
|
|
271 | |
279 | trap_show (trap, env); |
272 | trap_show (trap, env); |
280 | |
273 | |
|
|
274 | if (victim->type == PLAYER) // only count players as enemies |
|
|
275 | trap->enemy = victim; // set the victim as the traps enemy, so that summoned |
|
|
276 | // creatures know who to attack. |
|
|
277 | |
281 | /* Only if it is a spell do we proceed here */ |
278 | /* Only if it is a spell do we proceed here */ |
282 | if ((trap->inv && trap->inv->type == SPELL) || (trap->other_arch && trap->other_arch->clone.type == SPELL)) |
279 | if ((trap->inv && trap->inv->type == SPELL) || (trap->other_arch && trap->other_arch->type == SPELL)) |
283 | { |
280 | { |
284 | |
|
|
285 | if (trap->destroyed ()) |
281 | if (trap->destroyed ()) |
286 | return; |
282 | return; |
287 | |
283 | |
288 | // breaks summon golem spells, which, for inexplicable reasons, |
284 | // breaks summon golem spells, which, for inexplicable reasons, |
289 | // do not work like summon golem spells at all but still require |
285 | // do not work like summon golem spells at all but still require |
290 | // direction "0" to work at all. |
286 | // direction "0" to work at all. |
291 | //if (trap->direction) |
287 | //if (trap->direction) |
292 | // rv.direction = trap->direction; |
288 | // rv.direction = trap->direction; |
293 | |
289 | |
294 | for (i = 0; i < MAX (1, trap->stats.maxhp); i++) |
290 | for (i = 0; i < max (1, trap->stats.maxhp); i++) |
295 | { |
291 | { |
296 | if (trap->inv) |
292 | if (trap->inv) |
297 | cast_spell (env, trap, trap->direction, trap->inv, NULL); |
293 | cast_spell (env, trap, trap->direction, trap->inv, NULL); |
298 | else |
294 | else |
299 | { |
295 | { |
300 | object *spell = arch_to_object (trap->other_arch); |
296 | object *spell = trap->other_arch->instance (); |
301 | |
297 | |
302 | cast_spell (env, trap, trap->direction, spell, NULL); |
298 | cast_spell (env, trap, trap->direction, spell, NULL); |
303 | spell->destroy (); |
299 | spell->destroy (); |
304 | } |
300 | } |
305 | } |
301 | } |
… | |
… | |
313 | |
309 | |
314 | if (trap->stats.hp <= 0) |
310 | if (trap->stats.hp <= 0) |
315 | { |
311 | { |
316 | trap->type = SIGN; /* make the trap impotent */ |
312 | trap->type = SIGN; /* make the trap impotent */ |
317 | trap->stats.food = 20; /* make it stick around until its spells are gone */ |
313 | trap->stats.food = 20; /* make it stick around until its spells are gone */ |
318 | SET_FLAG (trap, FLAG_IS_USED_UP); |
314 | trap->set_flag (FLAG_IS_USED_UP); |
319 | } |
315 | } |
320 | } |
316 | } |
321 | |
317 | |
322 | /* dispel_rune: by peterm |
318 | /* dispel_rune: by peterm |
323 | * dispels the target rune, depending on the level of the actor |
319 | * dispels the target rune, depending on the level of the actor |
… | |
… | |
345 | { |
341 | { |
346 | new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); |
342 | new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); |
347 | return 0; |
343 | return 0; |
348 | } |
344 | } |
349 | |
345 | |
350 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
346 | for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above) |
351 | { |
347 | { |
352 | if (tmp->type == RUNE || tmp->type == TRAP) |
348 | if (tmp->type == RUNE || tmp->type == TRAP) |
353 | break; |
349 | break; |
354 | |
350 | |
355 | /* we could put a probability chance here, but since nothing happens |
351 | /* we could put a probability chance here, but since nothing happens |
356 | * if you fail, no point on that. I suppose we could do a level |
352 | * if you fail, no point on that. I suppose we could do a level |
357 | * comparison so low level players can't erase high level players runes. |
353 | * comparison so low level players can't erase high level players runes. |
358 | */ |
354 | */ |
359 | if (tmp->type == SIGN && !strcmp (tmp->arch->name, "rune_mark")) |
355 | if (tmp->type == SIGN && tmp->arch->archname == shstr_rune_mark) |
360 | { |
356 | { |
361 | tmp->destroy (); |
357 | tmp->destroy (); |
362 | new_draw_info (NDI_UNIQUE, 0, op, "You wipe out the rune of marking!"); |
358 | new_draw_info (NDI_UNIQUE, 0, op, "You wipe out the rune of marking!"); |
363 | return 1; |
359 | return 1; |
364 | } |
360 | } |
365 | |
361 | |
366 | /* now search tmp's inventory for traps |
362 | /* now search tmp's inventory for traps |
367 | * This is for chests, where the rune is in the chests inventory. |
363 | * This is for chests, where the rune is in the chests inventory. |
368 | */ |
364 | */ |
369 | for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) |
365 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
370 | { |
366 | { |
371 | if (tmp2->type == RUNE || tmp2->type == TRAP) |
367 | if (tmp2->type == RUNE || tmp2->type == TRAP) |
372 | { |
368 | { |
373 | tmp = tmp2; |
369 | tmp = tmp2; |
374 | searchflag = 0; |
370 | searchflag = 0; |
375 | break; |
371 | break; |
376 | } |
372 | } |
377 | } |
373 | } |
|
|
374 | |
378 | if (!searchflag) |
375 | if (!searchflag) |
379 | break; |
376 | break; |
380 | } |
377 | } |
381 | |
378 | |
382 | /* no rune there. */ |
379 | /* no rune there. */ |
383 | if (tmp == NULL) |
380 | if (tmp == NULL) |
384 | { |
381 | { |
385 | new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); |
382 | new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); |
386 | return 0; |
383 | return 0; |
387 | } |
384 | } |
|
|
385 | |
388 | trap_disarm (op, tmp, 0, skill); |
386 | trap_disarm (op, tmp, 0, skill); |
389 | return 1; |
387 | return 1; |
390 | |
|
|
391 | } |
388 | } |
392 | |
389 | |
393 | int |
390 | int |
394 | trap_see (object *op, object *trap) |
391 | trap_see (object *op, object *trap) |
395 | { |
392 | { |
396 | int chance; |
|
|
397 | |
|
|
398 | chance = random_roll (0, 99, op, PREFER_HIGH);; |
393 | int chance = random_roll (0, 99, op, PREFER_HIGH); |
399 | |
394 | |
400 | /* decide if we see the rune or not */ |
395 | /* decide if we see the rune or not */ |
401 | if ((trap->stats.Cha == 1) || (chance > MIN (95, MAX (5, ((int) ((float) (op->map->difficulty |
396 | if ((trap->stats.Cha == 1) || (chance > min (95, max (5, ((int) ((float) (op->map->difficulty |
402 | + trap->level + trap->stats.Cha - op->level) / 10.0 * 50.0)))))) |
397 | + trap->level + trap->stats.Cha - op->level) / 10.0 * 50.0)))))) |
403 | { |
398 | { |
404 | new_draw_info_format (NDI_UNIQUE, 0, op, "You spot a %s!", &trap->name); |
399 | new_draw_info_format (NDI_UNIQUE, 0, op, "You spot a %s!", &trap->name); |
405 | return 1; |
400 | return 1; |
406 | } |
401 | } |
|
|
402 | |
407 | return 0; |
403 | return 0; |
408 | } |
404 | } |
409 | |
405 | |
410 | int |
406 | int |
411 | trap_show (object *trap, object *where) |
407 | trap_show (object *trap, object *where) |
412 | { |
408 | { |
413 | if (where == NULL) |
409 | if (where == NULL) |
414 | return 0; |
410 | return 0; |
415 | |
411 | |
416 | object *tmp = get_archetype ("runedet"); |
412 | object *tmp = archetype::get (shstr_runedet); |
417 | tmp->face = &new_faces[GET_ANIMATION (trap, 0)]; |
413 | tmp->face = trap->get_anim_frame (0); |
418 | tmp->insert_at (where, 0); |
414 | tmp->insert_at (where, 0); |
419 | |
415 | |
420 | return 1; |
416 | return 1; |
421 | } |
417 | } |
422 | |
418 | |
423 | int |
419 | int |
424 | trap_disarm (object *disarmer, object *trap, int risk, object *skill) |
420 | trap_disarm (object *disarmer, object *trap, int risk, object *skill) |
425 | { |
421 | { |
426 | int trapworth; /* need to compute the experience worth of the trap |
422 | int trapworth; /* need to compute the experience worth of the trap before we kill it */ |
427 | before we kill it */ |
|
|
428 | |
423 | |
429 | /* this formula awards a more reasonable amount of exp */ |
424 | /* this formula awards a more reasonable amount of exp */ |
430 | trapworth = MAX (1, trap->level) * disarmer->map->difficulty * |
425 | trapworth = max (1, trap->level) |
|
|
426 | * disarmer->map->difficulty |
431 | sqr (MAX (trap->stats.dam, trap->inv ? trap->inv->level : 1)) / skill->level; |
427 | * sqr (max (trap->stats.dam, trap->inv ? trap->inv->level : 1)) |
|
|
428 | / skill->level; |
432 | |
429 | |
433 | if (!(random_roll (0, (MAX (2, MIN (20, trap->level - skill->level + 5 - disarmer->stats.Dex / 2)) - 1), disarmer, PREFER_LOW))) |
430 | if (!(random_roll (0, (max (2, min (20, trap->level - skill->level + 5 - disarmer->stats.Dex / 2)) - 1), disarmer, PREFER_LOW))) |
434 | { |
431 | { |
435 | new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You successfully disarm the %s!", &trap->name); |
432 | new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You successfully disarm the %s!", &trap->name); |
436 | trap->destroy (1); |
433 | trap->destroy (); |
437 | |
434 | |
438 | /* If it is your own trap, (or any players trap), don't you don't |
435 | /* If it is your own trap, (or any players trap), don't you don't |
439 | * get exp for it. |
436 | * get exp for it. |
440 | */ |
437 | */ |
441 | if (trap->owner && trap->owner->type != PLAYER && risk) |
438 | if (trap->owner && trap->owner->type != PLAYER && risk) |
… | |
… | |
444 | return 1; /* give minimal exp and say success */ |
441 | return 1; /* give minimal exp and say success */ |
445 | } |
442 | } |
446 | else |
443 | else |
447 | { |
444 | { |
448 | new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You fail to disarm the %s.", &trap->name); |
445 | new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You fail to disarm the %s.", &trap->name); |
449 | if (!(random_roll (0, (MAX (2, skill->level - trap->level + disarmer->stats.Dex / 2 - 6)) - 1, disarmer, PREFER_LOW)) && risk) |
446 | if (!(random_roll (0, (max (2, skill->level - trap->level + disarmer->stats.Dex / 2 - 6)) - 1, disarmer, PREFER_LOW)) && risk) |
450 | { |
447 | { |
451 | new_draw_info (NDI_UNIQUE, 0, disarmer, "In fact, you set it off!"); |
448 | new_draw_info (NDI_UNIQUE, 0, disarmer, "In fact, you set it off!"); |
452 | spring_trap (trap, disarmer); |
449 | spring_trap (trap, disarmer); |
453 | } |
450 | } |
454 | return 0; |
451 | return 0; |
455 | } |
452 | } |
456 | } |
453 | } |
457 | |
|
|
458 | |
454 | |
459 | /* traps need to be adjusted for the difficulty of the map. The |
455 | /* traps need to be adjusted for the difficulty of the map. The |
460 | * default traps are too strong for wimpy level 1 players, and |
456 | * default traps are too strong for wimpy level 1 players, and |
461 | * unthreatening to anyone of high level |
457 | * unthreatening to anyone of high level |
462 | */ |
458 | */ |
463 | |
|
|
464 | void |
459 | void |
465 | trap_adjust (object *trap, int difficulty) |
460 | trap_adjust (object *trap, int difficulty) |
466 | { |
461 | { |
467 | int i; |
462 | int i; |
468 | |
463 | |