1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2003 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2003 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * 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 Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
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> |
… | |
… | |
142 | /* 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 */ |
143 | if (rune_spell->type == RUNE) |
143 | if (rune_spell->type == RUNE) |
144 | rune = rune_spell; |
144 | rune = rune_spell; |
145 | else |
145 | else |
146 | { |
146 | { |
147 | rune = get_archetype (GENERIC_RUNE); |
147 | rune = archetype::get (GENERIC_RUNE); |
148 | rune->msg = format ("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); |
149 | rune->insert (rune_spell->clone ()); |
149 | rune->insert (rune_spell->clone ()); |
150 | |
150 | |
151 | if (spell->face != blank_face) |
151 | if (spell->face != blank_face) |
152 | rune->face = spell->face; |
152 | rune->face = spell->face; |
… | |
… | |
181 | if (!op->level) |
181 | if (!op->level) |
182 | return; |
182 | return; |
183 | |
183 | |
184 | int det = op->invisible; |
184 | int det = op->invisible; |
185 | |
185 | |
186 | if (!(rndm (0, max (1, (op->stats.Cha)) - 1))) |
186 | if (!(rndm (0, max (0, op->stats.Cha - 1)))) |
187 | { |
187 | { |
188 | op->invisible = 0; |
188 | op->invisible = 0; |
189 | op->speed_left -= 1; |
189 | op->speed_left -= 1; |
190 | } |
190 | } |
191 | else |
191 | else |
… | |
… | |
237 | |
237 | |
238 | /* Prevent recursion */ |
238 | /* Prevent recursion */ |
239 | if (trap->stats.hp <= 0) |
239 | if (trap->stats.hp <= 0) |
240 | return; |
240 | return; |
241 | |
241 | |
242 | if (QUERY_FLAG (trap, FLAG_IS_LINKED)) |
242 | if (trap->flag [FLAG_IS_LINKED]) |
243 | use_trigger (trap, victim); |
243 | use_trigger (trap, victim); |
244 | |
244 | |
245 | /* 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 |
246 | * 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. |
247 | * Typical example is an arrow attacking a door. |
247 | * Typical example is an arrow attacking a door. |
248 | */ |
248 | */ |
249 | if (!QUERY_FLAG (victim, FLAG_ALIVE) && !trap->inv && !trap->other_arch) |
249 | if (!victim->flag [FLAG_ALIVE] && !trap->inv && !trap->other_arch) |
250 | return; |
250 | return; |
251 | |
251 | |
252 | trap->stats.hp--; /*decrement detcount */ |
252 | trap->stats.hp--; /*decrement detcount */ |
253 | |
253 | |
254 | if (victim && victim->type == PLAYER) |
254 | if (victim && victim->type == PLAYER) |
… | |
… | |
309 | |
309 | |
310 | if (trap->stats.hp <= 0) |
310 | if (trap->stats.hp <= 0) |
311 | { |
311 | { |
312 | trap->type = SIGN; /* make the trap impotent */ |
312 | trap->type = SIGN; /* make the trap impotent */ |
313 | 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 */ |
314 | SET_FLAG (trap, FLAG_IS_USED_UP); |
314 | trap->set_flag (FLAG_IS_USED_UP); |
315 | } |
315 | } |
316 | } |
316 | } |
317 | |
317 | |
318 | /* dispel_rune: by peterm |
318 | /* dispel_rune: by peterm |
319 | * dispels the target rune, depending on the level of the actor |
319 | * dispels the target rune, depending on the level of the actor |
… | |
… | |
388 | } |
388 | } |
389 | |
389 | |
390 | int |
390 | int |
391 | trap_see (object *op, object *trap) |
391 | trap_see (object *op, object *trap) |
392 | { |
392 | { |
393 | int chance; |
|
|
394 | |
|
|
395 | chance = random_roll (0, 99, op, PREFER_HIGH);; |
393 | int chance = random_roll (0, 99, op, PREFER_HIGH); |
396 | |
394 | |
397 | /* decide if we see the rune or not */ |
395 | /* decide if we see the rune or not */ |
398 | 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 |
399 | + trap->level + trap->stats.Cha - op->level) / 10.0 * 50.0)))))) |
397 | + trap->level + trap->stats.Cha - op->level) / 10.0 * 50.0)))))) |
400 | { |
398 | { |
… | |
… | |
409 | trap_show (object *trap, object *where) |
407 | trap_show (object *trap, object *where) |
410 | { |
408 | { |
411 | if (where == NULL) |
409 | if (where == NULL) |
412 | return 0; |
410 | return 0; |
413 | |
411 | |
414 | object *tmp = get_archetype (shstr_runedet); |
412 | object *tmp = archetype::get (shstr_runedet); |
415 | tmp->face = trap->get_anim_frame (0); |
413 | tmp->face = trap->get_anim_frame (0); |
416 | tmp->insert_at (where, 0); |
414 | tmp->insert_at (where, 0); |
417 | |
415 | |
418 | return 1; |
416 | return 1; |
419 | } |
417 | } |