1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
3 | |
3 | |
|
|
4 | Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | |
7 | This program is free software; you can redistribute it and/or modify |
8 | 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 | it under the terms of the GNU General Public License as published by |
… | |
… | |
23 | |
24 | |
24 | /* the contents of this file were create solely by peterm@soda.berkeley.edu |
25 | /* the contents of this file were create solely by peterm@soda.berkeley.edu |
25 | all of the above disclaimers apply. */ |
26 | all of the above disclaimers apply. */ |
26 | |
27 | |
27 | #include <global.h> |
28 | #include <global.h> |
28 | #ifndef __CEXTRACT__ |
|
|
29 | # include <sproto.h> |
29 | #include <sproto.h> |
30 | #endif |
|
|
31 | #include <spells.h> |
30 | #include <spells.h> |
32 | #include <errno.h> |
31 | #include <errno.h> |
33 | #ifdef sequent |
|
|
34 | |
|
|
35 | /* stoopid sequent includes don't do this like they should */ |
|
|
36 | extern char *sys_errlist[]; |
|
|
37 | extern int sys_nerr; |
|
|
38 | #endif |
|
|
39 | extern char **classname; |
|
|
40 | extern object *objects; |
|
|
41 | |
|
|
42 | |
|
|
43 | |
32 | |
44 | /* name of the person to resurrect and which spell was used |
33 | /* name of the person to resurrect and which spell was used |
45 | * to resurrect |
34 | * to resurrect |
46 | */ |
35 | */ |
47 | static int |
36 | static int |
… | |
… | |
56 | char buf2[MAX_BUF]; |
45 | char buf2[MAX_BUF]; |
57 | const char *race = NULL; |
46 | const char *race = NULL; |
58 | sint64 exp; |
47 | sint64 exp; |
59 | int Con; |
48 | int Con; |
60 | |
49 | |
61 | |
|
|
62 | /* reincarnation, which changes the race */ |
50 | /* reincarnation, which changes the race */ |
63 | if (spell->race) |
51 | if (spell->race) |
64 | { |
52 | { |
65 | treasurelist *tl = find_treasurelist (spell->race); |
53 | treasurelist *tl = find_treasurelist (spell->race); |
66 | treasure *t; |
54 | treasure *t; |
… | |
… | |
76 | { |
64 | { |
77 | value -= t->chance; |
65 | value -= t->chance; |
78 | if (value < 0) |
66 | if (value < 0) |
79 | break; |
67 | break; |
80 | } |
68 | } |
81 | if (!t) |
69 | if (!t || !t->item) |
82 | { |
70 | { |
83 | LOG (llevError, "resurrect_player: got null treasure from treasurelist %s!\n", &spell->race); |
71 | LOG (llevError, "resurrect_player: got null treasure from treasurelist %s!\n", &spell->race); |
84 | return 0; |
72 | return 0; |
85 | } |
73 | } |
86 | race = t->item->name; |
74 | race = t->item->name; |
… | |
… | |
189 | temp = NULL; |
177 | temp = NULL; |
190 | else |
178 | else |
191 | { |
179 | { |
192 | /* First we need to find a corpse, if any. */ |
180 | /* First we need to find a corpse, if any. */ |
193 | /* If no object, temp will be set to NULL */ |
181 | /* If no object, temp will be set to NULL */ |
194 | for (temp = get_map_ob (m, sx, sy); temp != NULL; temp = temp->above) |
182 | for (temp = GET_MAP_OB (m, sx, sy); temp != NULL; temp = temp->above) |
195 | /* If it is corpse, this must be what we want to raise */ |
183 | /* If it is corpse, this must be what we want to raise */ |
196 | if (temp->type == CORPSE) |
184 | if (temp->type == CORPSE) |
197 | break; |
185 | break; |
198 | } |
186 | } |
199 | |
187 | |
… | |
… | |
208 | /* no matter what, we fry the corpse. */ |
196 | /* no matter what, we fry the corpse. */ |
209 | if (temp && temp->map) |
197 | if (temp && temp->map) |
210 | { |
198 | { |
211 | /* replace corpse object with a burning object */ |
199 | /* replace corpse object with a burning object */ |
212 | newob = arch_to_object (archetype::find ("burnout")); |
200 | newob = arch_to_object (archetype::find ("burnout")); |
213 | if (newob != NULL) |
201 | if (newob) |
214 | { |
202 | newob->insert_at (temp, op); |
215 | newob->x = temp->x; |
203 | |
216 | newob->y = temp->y; |
|
|
217 | insert_ob_in_map (newob, temp->map, op, 0); |
|
|
218 | } |
|
|
219 | leveldead = temp->level; |
204 | leveldead = temp->level; |
220 | remove_ob (temp); |
205 | temp->destroy (); |
221 | free_object (temp); |
|
|
222 | } |
206 | } |
223 | |
207 | |
224 | if (resurrection_fails (clevel, leveldead)) |
208 | if (resurrection_fails (clevel, leveldead)) |
225 | { |
209 | { |
226 | if (spell->randomitems) |
210 | if (spell->randomitems) |
227 | { |
|
|
228 | treasure *t; |
|
|
229 | |
|
|
230 | for (t = spell->randomitems->items; t; t = t->next) |
211 | for (treasure *t = spell->randomitems->items; t; t = t->next) |
231 | { |
212 | if (t->item) |
232 | summon_hostile_monsters (op, t->nrof, t->item->name); |
213 | summon_hostile_monsters (op, t->nrof, t->item->name); |
233 | } |
|
|
234 | |
214 | |
235 | } |
|
|
236 | return 1; |
215 | return 1; |
237 | |
216 | |
238 | } |
217 | } |
239 | else |
218 | else |
240 | { |
|
|
241 | return resurrect_player (op, name_to_resurrect, spell); |
219 | return resurrect_player (op, name_to_resurrect, spell); |
242 | } |
|
|
243 | |
|
|
244 | return 1; |
|
|
245 | } |
220 | } |
246 | |
221 | |
247 | |
222 | |
248 | int |
223 | int |
249 | resurrection_fails (int levelcaster, int leveldead) |
224 | resurrection_fails (int levelcaster, int leveldead) |