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.31 by root, Mon Oct 12 14:00:59 2009 UTC vs.
Revision 1.39 by root, Mon Oct 29 23:55:55 2012 UTC

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 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 (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 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/* 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
26 all of the above disclaimers apply. */ 26 all of the above disclaimers apply. */
138 fclose (liveplayer); 138 fclose (liveplayer);
139 fclose (deadplayer); 139 fclose (deadplayer);
140 unlink (oldname); 140 unlink (oldname);
141 new_draw_info_format (NDI_UNIQUE, 0, op, "%s lives again!", playername); 141 new_draw_info_format (NDI_UNIQUE, 0, op, "%s lives again!", playername);
142 142
143 return 1;
144}
145
146static int
147resurrection_fails (int levelcaster, int leveldead)
148{
149 int chance = 9;
150
151 /* scheme: equal in level, 50% success.
152 * +5 % for each level below, -5% for each level above.
153 * minimum 20%
154 */
155 chance += levelcaster - leveldead;
156 if (chance < 4)
157 chance = 4;
158 if (chance > rndm (0, 19))
159 return 0; /* resurrection succeeds */
143 return 1; 160 return 1;
144} 161}
145 162
146 163
147/* raise_dead by peterm and mehlhaff@soda.berkeley.edu 164/* raise_dead by peterm and mehlhaff@soda.berkeley.edu
221 } 238 }
222 else 239 else
223 return resurrect_player (op, name_to_resurrect, spell); 240 return resurrect_player (op, name_to_resurrect, spell);
224} 241}
225 242
226
227int
228resurrection_fails (int levelcaster, int leveldead)
229{
230 int chance = 9;
231
232 /* scheme: equal in level, 50% success.
233 * +5 % for each level below, -5% for each level above.
234 * minimum 20%
235 */
236 chance += levelcaster - leveldead;
237 if (chance < 4)
238 chance = 4;
239 if (chance > rndm (0, 19))
240 return 0; /* resurrection succeeds */
241 return 1;
242}
243
244void
245dead_player (object *op)
246{
247 char filename[MAX_BUF];
248 char newname[MAX_BUF];
249 char path[MAX_BUF];
250
251 /* set up our paths/strings... */
252 sprintf (path, "%s/%s/%s/%s", settings.localdir, settings.playerdir, &op->name, &op->name);
253
254 strcpy (filename, path);
255 strcat (filename, ".pl");
256 strcpy (newname, filename);
257 strcat (newname, ".dead");
258
259 if (rename (filename, newname) != 0)
260 {
261 LOG (llevError, "Cannot rename dead player's file %s into %s: %s\n", filename, newname, strerror (errno));
262 }
263}
264
265
266
267void
268dead_character (const char *name)
269{
270 char buf[MAX_BUF];
271 char buf2[MAX_BUF];
272
273 sprintf (buf, "%s/%s/%s/%s.pl", settings.localdir, settings.playerdir, name, name);
274 /* peterm: create a .dead filename.... ***.pl.dead */
275 strcpy (buf2, buf);
276 strcat (buf, ".dead");
277 if (rename (buf2, buf) == -1)
278 {
279 LOG (llevError, "Cannot rename dead player's file %s into %s: %s\n", buf2, buf, strerror (errno));
280 }
281}
282
283
284int
285dead_player_exists (const char *name)
286{
287 char buf[MAX_BUF];
288
289 sprintf (buf, "%s/%s/%s/%s", settings.localdir, settings.playerdir, name, name);
290 strcat (buf, ".pl.dead");
291 return !(access (buf, 0));
292}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines