1 |
elmex |
1.1 |
/* |
2 |
|
|
CrossFire, A Multiplayer game for X-windows |
3 |
|
|
|
4 |
|
|
Copyright (C) 2003 Mark Wedel & Crossfire Development Team |
5 |
|
|
Copyright (C) 1992 Frank Tore Johansen |
6 |
|
|
|
7 |
|
|
This program is free software; you can redistribute it and/or modify |
8 |
|
|
it under the terms of the GNU General Public License as published by |
9 |
|
|
the Free Software Foundation; either version 2 of the License, or |
10 |
|
|
(at your option) any later version. |
11 |
|
|
|
12 |
|
|
This program is distributed in the hope that it will be useful, |
13 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
GNU General Public License for more details. |
16 |
|
|
|
17 |
|
|
You should have received a copy of the GNU General Public License |
18 |
|
|
along with this program; if not, write to the Free Software |
19 |
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 |
|
|
|
21 |
root |
1.5 |
The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 |
elmex |
1.1 |
*/ |
23 |
|
|
|
24 |
|
|
#include <global.h> |
25 |
|
|
#ifndef __CEXTRACT__ |
26 |
root |
1.4 |
# include <sproto.h> |
27 |
elmex |
1.1 |
#endif |
28 |
|
|
#include <spells.h> |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
#ifndef sqr |
32 |
root |
1.4 |
# define sqr(x) ((x)*(x)) |
33 |
elmex |
1.1 |
#endif |
34 |
|
|
|
35 |
|
|
|
36 |
|
|
/* peterm: |
37 |
|
|
* write_rune: |
38 |
|
|
* op: rune writer |
39 |
|
|
* skop: skill object used for casting this rune |
40 |
|
|
* dir: orientation of rune, direction rune's contained spell will |
41 |
|
|
* be cast in, if applicable |
42 |
|
|
* inspell: spell object to put into the rune, can be null if doing |
43 |
|
|
* a marking rune. |
44 |
|
|
* level: level of casting of the rune |
45 |
|
|
* runename: name of the rune or message displayed by the rune for |
46 |
|
|
* a rune of marking |
47 |
|
|
*/ |
48 |
|
|
|
49 |
root |
1.4 |
int |
50 |
|
|
write_rune (object *op, object *caster, object *spell, int dir, const char *runename) |
51 |
|
|
{ |
52 |
|
|
object *tmp, *rune_spell, *rune; |
53 |
|
|
char buf[MAX_BUF]; |
54 |
|
|
mapstruct *m; |
55 |
|
|
sint16 nx, ny; |
56 |
|
|
|
57 |
|
|
if (!dir) |
58 |
|
|
{ |
59 |
|
|
dir = 1; |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
nx = op->x + freearr_x[dir]; |
63 |
|
|
ny = op->y + freearr_y[dir]; |
64 |
|
|
m = op->map; |
65 |
|
|
|
66 |
|
|
if (get_map_flags (m, &m, nx, ny, &nx, &ny)) |
67 |
|
|
{ |
68 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Can't make a rune there!"); |
69 |
|
|
return 0; |
70 |
elmex |
1.1 |
} |
71 |
root |
1.4 |
for (tmp = get_map_ob (m, nx, ny); tmp != NULL; tmp = tmp->above) |
72 |
|
|
if (tmp->type == RUNE) |
73 |
|
|
break; |
74 |
|
|
|
75 |
|
|
if (tmp) |
76 |
|
|
{ |
77 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You can't write a rune there."); |
78 |
elmex |
1.1 |
return 0; |
79 |
|
|
} |
80 |
|
|
|
81 |
root |
1.4 |
if (spell->other_arch) |
82 |
|
|
{ |
83 |
|
|
rune_spell = arch_to_object (spell->other_arch); |
84 |
|
|
} |
85 |
|
|
else |
86 |
|
|
{ |
87 |
|
|
/* Player specified spell. The player has to know the spell, so |
88 |
|
|
* lets just look through the players inventory see if they know it |
89 |
|
|
* use the item_matched_string for our typical matching method. |
90 |
|
|
*/ |
91 |
|
|
int bestmatch = 0, ms; |
92 |
|
|
|
93 |
|
|
if (!runename || *runename == 0) |
94 |
|
|
{ |
95 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "Write a rune of what?"); |
96 |
|
|
return 0; |
97 |
|
|
} |
98 |
|
|
|
99 |
|
|
rune_spell = NULL; |
100 |
|
|
for (tmp = op->inv; tmp; tmp = tmp->below) |
101 |
|
|
{ |
102 |
|
|
if (tmp->type == SPELL) |
103 |
|
|
{ |
104 |
|
|
ms = item_matched_string (op, tmp, runename); |
105 |
|
|
if (ms > bestmatch) |
106 |
|
|
{ |
107 |
|
|
bestmatch = ms; |
108 |
|
|
rune_spell = tmp; |
109 |
root |
1.2 |
} |
110 |
|
|
} |
111 |
|
|
} |
112 |
root |
1.4 |
if (!rune_spell) |
113 |
|
|
{ |
114 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "You don't know any spell named %s", runename); |
115 |
|
|
return 0; |
116 |
|
|
} |
117 |
|
|
if (rune_spell->skill != spell->skill) |
118 |
|
|
{ |
119 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "You can't cast %s with %s", &rune_spell->name, &spell->name); |
120 |
|
|
return 0; |
121 |
|
|
} |
122 |
|
|
if (caster->path_denied & spell->path_attuned) |
123 |
|
|
{ |
124 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "%s belongs to a spell path denied to you.", &rune_spell->name); |
125 |
|
|
return 0; |
126 |
|
|
} |
127 |
|
|
if (caster_level (caster, rune_spell) < rune_spell->level) |
128 |
|
|
{ |
129 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "%s is beyond your ability to cast!", &rune_spell->name); |
130 |
|
|
return 0; |
131 |
|
|
} |
132 |
|
|
if (SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA) > op->stats.sp) |
133 |
|
|
{ |
134 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough mana."); |
135 |
|
|
return 0; |
136 |
|
|
} |
137 |
|
|
if (SP_level_spellpoint_cost (caster, rune_spell, SPELL_GRACE) > op->stats.grace) |
138 |
|
|
{ |
139 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You don't have enough grace."); |
140 |
|
|
return 0; |
141 |
|
|
} |
142 |
|
|
op->stats.grace -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_GRACE); |
143 |
|
|
op->stats.sp -= SP_level_spellpoint_cost (caster, rune_spell, SPELL_MANA); |
144 |
|
|
} |
145 |
|
|
/* already proper rune. Note this should only be the case if other_arch was set */ |
146 |
|
|
if (rune_spell->type == RUNE) |
147 |
|
|
{ |
148 |
|
|
rune = rune_spell; |
149 |
|
|
} |
150 |
|
|
else |
151 |
|
|
{ |
152 |
|
|
rune = get_archetype (GENERIC_RUNE); |
153 |
|
|
sprintf (buf, "You set off a rune of %s\n", &rune_spell->name); |
154 |
|
|
rune->msg = buf; |
155 |
|
|
tmp = get_object (); |
156 |
|
|
copy_object (rune_spell, tmp); |
157 |
|
|
insert_ob_in_ob (tmp, rune); |
158 |
|
|
if (spell->face != blank_face) |
159 |
|
|
rune->face = spell->face; |
160 |
|
|
} |
161 |
|
|
rune->level = caster_level (caster, spell); |
162 |
|
|
rune->stats.Cha = rune->level / 2; /* the invisibility parameter */ |
163 |
|
|
rune->x = nx; |
164 |
|
|
rune->y = ny; |
165 |
|
|
rune->map = m; |
166 |
|
|
rune->direction = dir; /* where any spell will go upon detonation */ |
167 |
|
|
set_owner (rune, op); /* runes without need no owner */ |
168 |
|
|
set_spell_skill (op, caster, spell, rune); |
169 |
|
|
insert_ob_in_map (rune, m, op, 0); |
170 |
|
|
return 1; |
171 |
elmex |
1.1 |
|
172 |
|
|
} |
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
/* move_rune: peterm |
177 |
|
|
comments on runes: |
178 |
|
|
rune->level : level at which rune will cast its spell. |
179 |
|
|
rune->hp : number of detonations before rune goes away |
180 |
|
|
rune->msg : message the rune displays when it goes off |
181 |
|
|
rune->direction : direction it will cast a spell in |
182 |
|
|
rune->dam : damage the rune will do if it doesn't cast spells |
183 |
|
|
rune->attacktype: type of damage it does, if not casting spells |
184 |
|
|
rune->other_arch: spell in the rune |
185 |
|
|
rune->Cha : how hidden the rune is |
186 |
|
|
rune->maxhp : number of spells the rune casts |
187 |
|
|
*/ |
188 |
|
|
|
189 |
root |
1.4 |
void |
190 |
|
|
move_rune (object *op) |
191 |
|
|
{ |
192 |
|
|
int det = 0; |
193 |
|
|
|
194 |
|
|
if (!op->level) |
195 |
|
|
{ |
196 |
|
|
return; |
197 |
|
|
} /* runes of level zero cannot detonate. */ |
198 |
|
|
det = op->invisible; |
199 |
|
|
if (!(rndm (0, MAX (1, (op->stats.Cha)) - 1))) |
200 |
|
|
{ |
201 |
|
|
op->invisible = 0; |
202 |
|
|
op->speed_left -= 1; |
203 |
|
|
} |
204 |
|
|
else |
205 |
|
|
op->invisible = 1; |
206 |
|
|
if (op->invisible != det) |
207 |
|
|
update_object (op, UP_OBJ_FACE); |
208 |
elmex |
1.1 |
} |
209 |
|
|
|
210 |
|
|
|
211 |
|
|
/* peterm: rune_attack |
212 |
|
|
* function handles those runes which detonate but do not cast spells. |
213 |
|
|
*/ |
214 |
|
|
|
215 |
|
|
|
216 |
root |
1.4 |
void |
217 |
|
|
rune_attack (object *op, object *victim) |
218 |
elmex |
1.1 |
{ |
219 |
root |
1.4 |
if (victim) |
220 |
|
|
{ |
221 |
root |
1.6 |
hit_player (victim, op->stats.dam, op, op->attacktype, 1); |
222 |
root |
1.4 |
|
223 |
root |
1.6 |
if (victim->destroyed ()) |
224 |
root |
1.4 |
return; |
225 |
root |
1.6 |
|
226 |
root |
1.4 |
/* if there's a disease in the needle, put it in the player */ |
227 |
|
|
if (HAS_RANDOM_ITEMS (op)) |
228 |
|
|
create_treasure (op->randomitems, op, 0, (victim->map ? victim->map->difficulty : 1), 0); |
229 |
root |
1.6 |
|
230 |
root |
1.4 |
if (op->inv && op->inv->type == DISEASE) |
231 |
|
|
{ |
232 |
|
|
object *disease = op->inv; |
233 |
|
|
|
234 |
|
|
infect_object (victim, disease, 1); |
235 |
|
|
remove_ob (disease); |
236 |
|
|
free_object (disease); |
237 |
|
|
} |
238 |
elmex |
1.1 |
} |
239 |
root |
1.4 |
else |
240 |
|
|
hit_map (op, 0, op->attacktype, 1); |
241 |
elmex |
1.1 |
} |
242 |
|
|
|
243 |
|
|
/* This function generalizes attacks by runes/traps. This ought to make |
244 |
|
|
* it possible for runes to attack from the inventory, |
245 |
|
|
* it'll spring the trap on the victim. |
246 |
|
|
*/ |
247 |
root |
1.4 |
void |
248 |
|
|
spring_trap (object *trap, object *victim) |
249 |
elmex |
1.1 |
{ |
250 |
root |
1.4 |
object *env; |
251 |
|
|
rv_vector rv; |
252 |
|
|
int i; |
253 |
|
|
|
254 |
|
|
/* Prevent recursion */ |
255 |
|
|
if (trap->stats.hp <= 0) |
256 |
|
|
return; |
257 |
|
|
|
258 |
|
|
if (QUERY_FLAG (trap, FLAG_IS_LINKED)) |
259 |
|
|
use_trigger (trap); |
260 |
|
|
|
261 |
|
|
/* Only living objects can trigger runes that don't cast spells, as |
262 |
|
|
* doing direct damage to a non-living object doesn't work anyway. |
263 |
|
|
* Typical example is an arrow attacking a door. |
264 |
|
|
*/ |
265 |
|
|
if (!QUERY_FLAG (victim, FLAG_ALIVE) && !trap->inv && !trap->other_arch) |
266 |
|
|
return; |
267 |
|
|
|
268 |
|
|
trap->stats.hp--; /*decrement detcount */ |
269 |
|
|
|
270 |
|
|
if (victim && victim->type == PLAYER) |
271 |
|
|
new_draw_info (NDI_UNIQUE, 0, victim, trap->msg); |
272 |
|
|
|
273 |
|
|
/* Flash an image of the trap on the map so the poor sod |
274 |
|
|
* knows what hit him. |
275 |
|
|
*/ |
276 |
|
|
env = object_get_env_recursive (trap); |
277 |
|
|
|
278 |
|
|
/* If the victim is not next to this trap, don't set it off. |
279 |
|
|
* players shouldn't get hit by firing arrows at a door for example. |
280 |
|
|
* At the same time, the trap will stick around until detonated |
281 |
|
|
*/ |
282 |
|
|
get_rangevector (env, victim, &rv, 0); |
283 |
|
|
if (rv.distance > 1) |
284 |
|
|
return; |
285 |
|
|
|
286 |
|
|
trap_show (trap, env); |
287 |
|
|
|
288 |
|
|
/* Only if it is a spell do we proceed here */ |
289 |
|
|
if ((trap->inv && trap->inv->type == SPELL) || (trap->other_arch && trap->other_arch->clone.type == SPELL)) |
290 |
|
|
{ |
291 |
elmex |
1.1 |
|
292 |
root |
1.6 |
if (trap->destroyed ()) |
293 |
root |
1.2 |
return; |
294 |
elmex |
1.1 |
|
295 |
root |
1.4 |
// breaks summon golem spells, which, for inexplicable reasons, |
296 |
|
|
// do not work like summon golem spells at all but still require |
297 |
|
|
// direction "0" to work at all. |
298 |
|
|
//if (trap->direction) |
299 |
|
|
// rv.direction = trap->direction; |
300 |
elmex |
1.1 |
|
301 |
root |
1.4 |
for (i = 0; i < MAX (1, trap->stats.maxhp); i++) |
302 |
|
|
{ |
303 |
|
|
if (trap->inv) |
304 |
|
|
cast_spell (env, trap, trap->direction, trap->inv, NULL); |
305 |
|
|
else |
306 |
|
|
{ |
307 |
|
|
object *spell = arch_to_object (trap->other_arch); |
308 |
elmex |
1.1 |
|
309 |
root |
1.4 |
cast_spell (env, trap, trap->direction, spell, NULL); |
310 |
|
|
free_object (spell); |
311 |
root |
1.2 |
} |
312 |
|
|
} |
313 |
root |
1.4 |
} |
314 |
|
|
else |
315 |
|
|
{ |
316 |
|
|
rune_attack (trap, victim); |
317 |
root |
1.6 |
if (trap->destroyed ()) |
318 |
root |
1.4 |
return; |
319 |
elmex |
1.1 |
} |
320 |
|
|
|
321 |
root |
1.4 |
if (trap->stats.hp <= 0) |
322 |
|
|
{ |
323 |
|
|
trap->type = SIGN; /* make the trap impotent */ |
324 |
|
|
trap->stats.food = 20; /* make it stick around until its spells are gone */ |
325 |
|
|
SET_FLAG (trap, FLAG_IS_USED_UP); |
326 |
elmex |
1.1 |
} |
327 |
|
|
} |
328 |
|
|
|
329 |
|
|
/* dispel_rune: by peterm |
330 |
|
|
* dispels the target rune, depending on the level of the actor |
331 |
|
|
* and the level of the rune risk flag, if true, means that there is |
332 |
|
|
* a chance that the trap/rune will detonate |
333 |
|
|
*/ |
334 |
root |
1.4 |
int |
335 |
|
|
dispel_rune (object *op, object *caster, object *spell, object *skill, int dir) |
336 |
elmex |
1.1 |
{ |
337 |
root |
1.4 |
object *tmp, *tmp2; |
338 |
|
|
int searchflag = 1, mflags; |
339 |
|
|
sint16 x, y; |
340 |
|
|
mapstruct *m; |
341 |
|
|
|
342 |
|
|
x = op->x + freearr_x[dir]; |
343 |
|
|
y = op->y + freearr_y[dir]; |
344 |
|
|
m = op->map; |
345 |
|
|
|
346 |
|
|
mflags = get_map_flags (m, &m, x, y, &x, &y); |
347 |
|
|
|
348 |
|
|
/* Should we perhaps not allow player to disable traps if a monster/ |
349 |
|
|
* player is standing on top? |
350 |
|
|
*/ |
351 |
|
|
if (mflags & P_OUT_OF_MAP) |
352 |
|
|
{ |
353 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); |
354 |
|
|
return 0; |
355 |
|
|
} |
356 |
|
|
|
357 |
|
|
for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) |
358 |
|
|
{ |
359 |
|
|
if (tmp->type == RUNE || tmp->type == TRAP) |
360 |
|
|
break; |
361 |
|
|
|
362 |
|
|
/* we could put a probability chance here, but since nothing happens |
363 |
|
|
* if you fail, no point on that. I suppose we could do a level |
364 |
|
|
* comparison so low level players can't erase high level players runes. |
365 |
|
|
*/ |
366 |
|
|
if (tmp->type == SIGN && !strcmp (tmp->arch->name, "rune_mark")) |
367 |
|
|
{ |
368 |
|
|
remove_ob (tmp); |
369 |
|
|
free_object (tmp); |
370 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "You wipe out the rune of marking!"); |
371 |
|
|
return 1; |
372 |
|
|
} |
373 |
|
|
|
374 |
|
|
/* now search tmp's inventory for traps |
375 |
|
|
* This is for chests, where the rune is in the chests inventory. |
376 |
|
|
*/ |
377 |
|
|
for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) |
378 |
|
|
{ |
379 |
|
|
if (tmp2->type == RUNE || tmp2->type == TRAP) |
380 |
|
|
{ |
381 |
|
|
tmp = tmp2; |
382 |
|
|
searchflag = 0; |
383 |
|
|
break; |
384 |
root |
1.2 |
} |
385 |
|
|
} |
386 |
root |
1.4 |
if (!searchflag) |
387 |
|
|
break; |
388 |
elmex |
1.1 |
} |
389 |
root |
1.4 |
|
390 |
|
|
/* no rune there. */ |
391 |
|
|
if (tmp == NULL) |
392 |
|
|
{ |
393 |
|
|
new_draw_info (NDI_UNIQUE, 0, op, "There's nothing there!"); |
394 |
|
|
return 0; |
395 |
|
|
} |
396 |
|
|
trap_disarm (op, tmp, 0, skill); |
397 |
|
|
return 1; |
398 |
|
|
|
399 |
elmex |
1.1 |
} |
400 |
|
|
|
401 |
root |
1.4 |
int |
402 |
|
|
trap_see (object *op, object *trap) |
403 |
|
|
{ |
404 |
|
|
int chance; |
405 |
|
|
|
406 |
|
|
chance = random_roll (0, 99, op, PREFER_HIGH);; |
407 |
elmex |
1.1 |
|
408 |
root |
1.4 |
/* decide if we see the rune or not */ |
409 |
|
|
if ((trap->stats.Cha == 1) || (chance > MIN (95, MAX (5, ((int) ((float) (op->map->difficulty |
410 |
|
|
+ trap->level + trap->stats.Cha - op->level) / 10.0 * 50.0)))))) |
411 |
|
|
{ |
412 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, op, "You spot a %s!", &trap->name); |
413 |
|
|
return 1; |
414 |
elmex |
1.1 |
} |
415 |
root |
1.4 |
return 0; |
416 |
elmex |
1.1 |
} |
417 |
|
|
|
418 |
root |
1.4 |
int |
419 |
|
|
trap_show (object *trap, object *where) |
420 |
|
|
{ |
421 |
|
|
object *tmp2; |
422 |
elmex |
1.1 |
|
423 |
root |
1.4 |
if (where == NULL) |
424 |
|
|
return 0; |
425 |
|
|
tmp2 = get_archetype ("runedet"); |
426 |
|
|
tmp2->face = &new_faces[GET_ANIMATION (trap, 0)]; |
427 |
|
|
tmp2->x = where->x; |
428 |
|
|
tmp2->y = where->y; |
429 |
|
|
tmp2->map = where->map; |
430 |
|
|
insert_ob_in_map (tmp2, where->map, NULL, 0); |
431 |
|
|
return 1; |
432 |
elmex |
1.1 |
|
433 |
|
|
} |
434 |
|
|
|
435 |
|
|
|
436 |
root |
1.4 |
int |
437 |
|
|
trap_disarm (object *disarmer, object *trap, int risk, object *skill) |
438 |
|
|
{ |
439 |
|
|
int trapworth; /* need to compute the experience worth of the trap |
440 |
|
|
before we kill it */ |
441 |
|
|
|
442 |
|
|
/* this formula awards a more reasonable amount of exp */ |
443 |
|
|
trapworth = MAX (1, trap->level) * disarmer->map->difficulty * |
444 |
|
|
sqr (MAX (trap->stats.dam, trap->inv ? trap->inv->level : 1)) / skill->level; |
445 |
|
|
|
446 |
|
|
if (!(random_roll (0, (MAX (2, MIN (20, trap->level - skill->level + 5 - disarmer->stats.Dex / 2)) - 1), disarmer, PREFER_LOW))) |
447 |
|
|
{ |
448 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You successfully disarm the %s!", &trap->name); |
449 |
|
|
destroy_object (trap); |
450 |
|
|
/* If it is your own trap, (or any players trap), don't you don't |
451 |
|
|
* get exp for it. |
452 |
|
|
*/ |
453 |
|
|
if (trap->owner && trap->owner->type != PLAYER && risk) |
454 |
|
|
return trapworth; |
455 |
|
|
else |
456 |
|
|
return 1; /* give minimal exp and say success */ |
457 |
|
|
} |
458 |
|
|
else |
459 |
|
|
{ |
460 |
|
|
new_draw_info_format (NDI_UNIQUE, 0, disarmer, "You fail to disarm the %s.", &trap->name); |
461 |
|
|
if (!(random_roll (0, (MAX (2, skill->level - trap->level + disarmer->stats.Dex / 2 - 6)) - 1, disarmer, PREFER_LOW)) && risk) |
462 |
|
|
{ |
463 |
|
|
new_draw_info (NDI_UNIQUE, 0, disarmer, "In fact, you set it off!"); |
464 |
|
|
spring_trap (trap, disarmer); |
465 |
elmex |
1.1 |
} |
466 |
root |
1.4 |
return 0; |
467 |
|
|
} |
468 |
elmex |
1.1 |
} |
469 |
|
|
|
470 |
|
|
|
471 |
|
|
/* traps need to be adjusted for the difficulty of the map. The |
472 |
|
|
* default traps are too strong for wimpy level 1 players, and |
473 |
|
|
* unthreatening to anyone of high level |
474 |
|
|
*/ |
475 |
|
|
|
476 |
root |
1.4 |
void |
477 |
|
|
trap_adjust (object *trap, int difficulty) |
478 |
|
|
{ |
479 |
|
|
int i; |
480 |
elmex |
1.1 |
|
481 |
root |
1.4 |
/* now we set the trap level to match the difficulty of the level |
482 |
|
|
* the formula below will give a level from 1 to (2*difficulty) with |
483 |
|
|
* a peak probability at difficulty |
484 |
|
|
*/ |
485 |
|
|
|
486 |
|
|
trap->level = rndm (0, difficulty - 1) + rndm (0, difficulty - 1); |
487 |
|
|
if (trap->level < 1) |
488 |
|
|
trap->level = 1; |
489 |
|
|
|
490 |
|
|
/* set the hiddenness of the trap, similar formula to above */ |
491 |
|
|
trap->stats.Cha = rndm (0, 19) + rndm (0, difficulty - 1) + rndm (0, difficulty - 1); |
492 |
|
|
|
493 |
|
|
if (!trap->other_arch && !trap->inv) |
494 |
|
|
{ |
495 |
|
|
/* set the damage of the trap. |
496 |
|
|
* we get 0-4 pts of damage per level of difficulty of the map in |
497 |
|
|
* the trap |
498 |
|
|
*/ |
499 |
|
|
|
500 |
|
|
trap->stats.dam = 0; |
501 |
|
|
for (i = 0; i < difficulty; i++) |
502 |
|
|
trap->stats.dam += rndm (0, 4); |
503 |
|
|
|
504 |
|
|
/* the poison trap special case */ |
505 |
|
|
if (trap->attacktype & AT_POISON) |
506 |
|
|
{ |
507 |
|
|
trap->stats.dam = rndm (0, difficulty - 1); |
508 |
|
|
if (trap->stats.dam < 1) |
509 |
|
|
trap->stats.dam = 1; |
510 |
root |
1.2 |
} |
511 |
elmex |
1.1 |
|
512 |
root |
1.4 |
/* so we get an appropriate amnt of exp for AT_DEATH traps */ |
513 |
|
|
if (trap->attacktype & AT_DEATH) |
514 |
|
|
trap->stats.dam = 127; |
515 |
elmex |
1.1 |
} |
516 |
|
|
|
517 |
|
|
} |