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.9 by pippijn, Mon Dec 11 21:06:59 2006 UTC vs.
Revision 1.22 by root, Mon Jun 4 12:19:09 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT 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 * Crossfire TRT is free software; you can redistribute it and/or modify it
8 it under the terms of the GNU General Public License as published by 9 * under the terms of the GNU General Public License as published by the Free
9 the Free Software Foundation; either version 2 of the License, or 10 * Software Foundation; either version 2 of the License, or (at your option)
10 (at your option) any later version. 11 * 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, but
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 GNU General Public License for more details. 16 * 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 along
18 along with this program; if not, write to the Free Software 19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 21 *
21 The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
22*/ 23 */
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 */
36extern char *sys_errlist[];
37extern int sys_nerr;
38#endif
39extern char **classname;
40extern 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 */
47static int 36static 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 = treasurelist::find (spell->race);
66 treasure *t; 54 treasure *t;
67 int value; 55 int value;
68 56
69 if (!tl) 57 if (!tl)
70 { 58 {
71 LOG (llevError, "resurrect_player: race set to %s, but no treasurelist of that name!\n", &spell->race); 59 LOG (llevError, "resurrect_player: race set to %s, but no treasurelist of that name!\n", &spell->race);
72 return 0; 60 return 0;
73 } 61 }
62
74 value = RANDOM () % tl->total_chance; 63 value = RANDOM () % tl->total_chance;
64
75 for (t = tl->items; t; t = t->next) 65 for (t = tl->items; t; t = t->next)
76 { 66 {
77 value -= t->chance; 67 value -= t->chance;
78 if (value < 0) 68 if (value < 0)
79 break; 69 break;
80 } 70 }
81 if (!t) 71
72 if (!t || !t->item)
82 { 73 {
83 LOG (llevError, "resurrect_player: got null treasure from treasurelist %s!\n", &spell->race); 74 LOG (llevError, "resurrect_player: got null treasure from treasurelist %s!\n", &spell->race);
84 return 0; 75 return 0;
85 } 76 }
77
86 race = t->item->name; 78 race = t->item->archname;
87 } 79 }
88 80
89 /* set up our paths/strings... */ 81 /* set up our paths/strings... */
90 sprintf (path, "%s/%s/%s/%s", settings.localdir, settings.playerdir, playername, playername); 82 sprintf (path, "%s/%s/%s/%s", settings.localdir, settings.playerdir, playername, playername);
91 83
120 { 112 {
121 fgets (buf, 255, deadplayer); 113 fgets (buf, 255, deadplayer);
122 sscanf (buf, "%s", buf2); 114 sscanf (buf, "%s", buf2);
123 if (!(strcmp (buf2, "exp"))) 115 if (!(strcmp (buf2, "exp")))
124 { 116 {
125 long long exp_;
126
127 sscanf (buf, "%s %" I64_PFd, buf2, &exp_); 117 sscanf (buf, "%s %" SCNd64, buf2, &exp);
128 exp = exp_;
129 if (spell->stats.exp) 118 if (spell->stats.exp)
130 { 119 {
131 exp -= exp / spell->stats.exp; 120 exp -= exp / spell->stats.exp;
132 sprintf (buf, "exp %" I64_PFd "\n", exp_); 121 sprintf (buf, "exp %" PRId64 "\n", exp);
133 exp = exp_;
134 } 122 }
135 } 123 }
136 if (!(strcmp (buf2, "Con"))) 124 if (!(strcmp (buf2, "Con")))
137 { 125 {
138 sscanf (buf, "%s %d", buf2, &Con); 126 sscanf (buf, "%s %d", buf2, &Con);
193 temp = NULL; 181 temp = NULL;
194 else 182 else
195 { 183 {
196 /* First we need to find a corpse, if any. */ 184 /* First we need to find a corpse, if any. */
197 /* If no object, temp will be set to NULL */ 185 /* If no object, temp will be set to NULL */
198 for (temp = get_map_ob (m, sx, sy); temp != NULL; temp = temp->above) 186 for (temp = GET_MAP_OB (m, sx, sy); temp != NULL; temp = temp->above)
199 /* If it is corpse, this must be what we want to raise */ 187 /* If it is corpse, this must be what we want to raise */
200 if (temp->type == CORPSE) 188 if (temp->type == CORPSE)
201 break; 189 break;
202 } 190 }
203 191
212 /* no matter what, we fry the corpse. */ 200 /* no matter what, we fry the corpse. */
213 if (temp && temp->map) 201 if (temp && temp->map)
214 { 202 {
215 /* replace corpse object with a burning object */ 203 /* replace corpse object with a burning object */
216 newob = arch_to_object (archetype::find ("burnout")); 204 newob = arch_to_object (archetype::find ("burnout"));
217 if (newob != NULL) 205 if (newob)
218 { 206 newob->insert_at (temp, op);
219 newob->x = temp->x; 207
220 newob->y = temp->y;
221 insert_ob_in_map (newob, temp->map, op, 0);
222 }
223 leveldead = temp->level; 208 leveldead = temp->level;
224 remove_ob (temp); 209 temp->destroy ();
225 free_object (temp);
226 } 210 }
227 211
228 if (resurrection_fails (clevel, leveldead)) 212 if (resurrection_fails (clevel, leveldead))
229 { 213 {
230 if (spell->randomitems) 214 if (spell->randomitems)
231 {
232 treasure *t;
233
234 for (t = spell->randomitems->items; t; t = t->next) 215 for (treasure *t = spell->randomitems->items; t; t = t->next)
235 { 216 if (t->item)
236 summon_hostile_monsters (op, t->nrof, t->item->name); 217 summon_hostile_monsters (op, t->nrof, t->item->archname);
237 }
238 218
239 }
240 return 1; 219 return 1;
241 220
242 } 221 }
243 else 222 else
244 {
245 return resurrect_player (op, name_to_resurrect, spell); 223 return resurrect_player (op, name_to_resurrect, spell);
246 }
247
248 return 1;
249} 224}
250 225
251 226
252int 227int
253resurrection_fails (int levelcaster, int leveldead) 228resurrection_fails (int levelcaster, int leveldead)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines