ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/resurrection.C
(Generate patch)

Comparing deliantra/server/server/resurrection.C (file contents):
Revision 1.10 by root, Mon Dec 11 21:32:18 2006 UTC vs.
Revision 1.24 by root, Thu Nov 8 19:43:28 2007 UTC

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 (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * Deliantra 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
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version. 11 * (at your option) any later version.
11 12 *
12 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,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 You should have received a copy of the GNU General Public License 18 * 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 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 *
20 21 * The authors can be reached via e-mail to <support@deliantra.net>
21 The authors can be reached via e-mail at <crossfire@schmorp.de>
22*/ 22 */
23 23
24/* the contents of this file were create solely by peterm@soda.berkeley.edu 24/* the contents of this file were create solely by peterm@soda.berkeley.edu
25 all of the above disclaimers apply. */ 25 all of the above disclaimers apply. */
26 26
27#include <global.h> 27#include <global.h>
28#ifndef __CEXTRACT__
29# include <sproto.h> 28#include <sproto.h>
30#endif
31#include <spells.h> 29#include <spells.h>
32#include <errno.h> 30#include <errno.h>
33#ifdef sequent
34
35/* stoopid sequent includes don't do this like they should */
36extern char *sys_errlist[];
37extern int sys_nerr;
38#endif
39extern char **classname;
40extern object *objects;
41
42
43 31
44/* name of the person to resurrect and which spell was used 32/* name of the person to resurrect and which spell was used
45 * to resurrect 33 * to resurrect
46 */ 34 */
47static int 35static int
56 char buf2[MAX_BUF]; 44 char buf2[MAX_BUF];
57 const char *race = NULL; 45 const char *race = NULL;
58 sint64 exp; 46 sint64 exp;
59 int Con; 47 int Con;
60 48
61
62 /* reincarnation, which changes the race */ 49 /* reincarnation, which changes the race */
63 if (spell->race) 50 if (spell->race)
64 { 51 {
65 treasurelist *tl = find_treasurelist (spell->race); 52 treasurelist *tl = treasurelist::find (spell->race);
66 treasure *t; 53 treasure *t;
67 int value; 54 int value;
68 55
69 if (!tl) 56 if (!tl)
70 { 57 {
71 LOG (llevError, "resurrect_player: race set to %s, but no treasurelist of that name!\n", &spell->race); 58 LOG (llevError, "resurrect_player: race set to %s, but no treasurelist of that name!\n", &spell->race);
72 return 0; 59 return 0;
73 } 60 }
61
74 value = RANDOM () % tl->total_chance; 62 value = RANDOM () % tl->total_chance;
63
75 for (t = tl->items; t; t = t->next) 64 for (t = tl->items; t; t = t->next)
76 { 65 {
77 value -= t->chance; 66 value -= t->chance;
78 if (value < 0) 67 if (value < 0)
79 break; 68 break;
80 } 69 }
81 if (!t) 70
71 if (!t || !t->item)
82 { 72 {
83 LOG (llevError, "resurrect_player: got null treasure from treasurelist %s!\n", &spell->race); 73 LOG (llevError, "resurrect_player: got null treasure from treasurelist %s!\n", &spell->race);
84 return 0; 74 return 0;
85 } 75 }
76
86 race = t->item->name; 77 race = t->item->archname;
87 } 78 }
88 79
89 /* set up our paths/strings... */ 80 /* set up our paths/strings... */
90 sprintf (path, "%s/%s/%s/%s", settings.localdir, settings.playerdir, playername, playername); 81 sprintf (path, "%s/%s/%s/%s", settings.localdir, settings.playerdir, playername, playername);
91 82
189 temp = NULL; 180 temp = NULL;
190 else 181 else
191 { 182 {
192 /* First we need to find a corpse, if any. */ 183 /* First we need to find a corpse, if any. */
193 /* If no object, temp will be set to NULL */ 184 /* If no object, temp will be set to NULL */
194 for (temp = get_map_ob (m, sx, sy); temp != NULL; temp = temp->above) 185 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 */ 186 /* If it is corpse, this must be what we want to raise */
196 if (temp->type == CORPSE) 187 if (temp->type == CORPSE)
197 break; 188 break;
198 } 189 }
199 190
208 /* no matter what, we fry the corpse. */ 199 /* no matter what, we fry the corpse. */
209 if (temp && temp->map) 200 if (temp && temp->map)
210 { 201 {
211 /* replace corpse object with a burning object */ 202 /* replace corpse object with a burning object */
212 newob = arch_to_object (archetype::find ("burnout")); 203 newob = arch_to_object (archetype::find ("burnout"));
213 if (newob != NULL) 204 if (newob)
214 { 205 newob->insert_at (temp, op);
215 newob->x = temp->x; 206
216 newob->y = temp->y;
217 insert_ob_in_map (newob, temp->map, op, 0);
218 }
219 leveldead = temp->level; 207 leveldead = temp->level;
220 remove_ob (temp); 208 temp->destroy ();
221 free_object (temp);
222 } 209 }
223 210
224 if (resurrection_fails (clevel, leveldead)) 211 if (resurrection_fails (clevel, leveldead))
225 { 212 {
226 if (spell->randomitems) 213 if (spell->randomitems)
227 {
228 treasure *t;
229
230 for (t = spell->randomitems->items; t; t = t->next) 214 for (treasure *t = spell->randomitems->items; t; t = t->next)
231 { 215 if (t->item)
232 summon_hostile_monsters (op, t->nrof, t->item->name); 216 summon_hostile_monsters (op, t->nrof, t->item->archname);
233 }
234 217
235 }
236 return 1; 218 return 1;
237 219
238 } 220 }
239 else 221 else
240 {
241 return resurrect_player (op, name_to_resurrect, spell); 222 return resurrect_player (op, name_to_resurrect, spell);
242 }
243
244 return 1;
245} 223}
246 224
247 225
248int 226int
249resurrection_fails (int levelcaster, int leveldead) 227resurrection_fails (int levelcaster, int leveldead)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines