… | |
… | |
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; |
143 | return 1; |
144 | } |
144 | } |
145 | |
145 | |
146 | |
146 | static int |
147 | /* raise_dead by peterm and mehlhaff@soda.berkeley.edu |
|
|
148 | * op -- who is doing the resurrecting |
|
|
149 | * spell - spell object |
|
|
150 | * dir -- direction the spell is cast |
|
|
151 | * corpseobj - corpse to raise - can be null, in which case this function will find it |
|
|
152 | */ |
|
|
153 | int |
|
|
154 | cast_raise_dead_spell (object *op, object *caster, object *spell, int dir, const char *arg) |
|
|
155 | { |
|
|
156 | object *temp, *newob; |
|
|
157 | char name_to_resurrect[MAX_BUF]; |
|
|
158 | int leveldead = 25, mflags, clevel; |
|
|
159 | sint16 sx, sy; |
|
|
160 | maptile *m; |
|
|
161 | |
|
|
162 | clevel = casting_level (caster, spell); |
|
|
163 | |
|
|
164 | if (spell->last_heal) |
|
|
165 | { |
|
|
166 | if (!arg) |
|
|
167 | { |
|
|
168 | new_draw_info_format (NDI_UNIQUE, 0, op, "Cast %s on who?", &spell->name); |
|
|
169 | return 0; |
|
|
170 | } |
|
|
171 | strcpy (name_to_resurrect, arg); |
|
|
172 | temp = NULL; |
|
|
173 | } |
|
|
174 | else |
|
|
175 | { |
|
|
176 | sx = op->x + freearr_x[dir]; |
|
|
177 | sy = op->y + freearr_y[dir]; |
|
|
178 | m = op->map; |
|
|
179 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
|
|
180 | if (mflags & P_OUT_OF_MAP) |
|
|
181 | temp = NULL; |
|
|
182 | else |
|
|
183 | { |
|
|
184 | /* First we need to find a corpse, if any. */ |
|
|
185 | /* If no object, temp will be set to NULL */ |
|
|
186 | for (temp = GET_MAP_OB (m, sx, sy); temp != NULL; temp = temp->above) |
|
|
187 | /* If it is corpse, this must be what we want to raise */ |
|
|
188 | if (temp->type == CORPSE) |
|
|
189 | break; |
|
|
190 | } |
|
|
191 | |
|
|
192 | if (temp == NULL) |
|
|
193 | { |
|
|
194 | new_draw_info (NDI_UNIQUE, 0, op, "You need a body for this spell."); |
|
|
195 | return 0; |
|
|
196 | } |
|
|
197 | strcpy (name_to_resurrect, temp->name); |
|
|
198 | } |
|
|
199 | |
|
|
200 | /* no matter what, we fry the corpse. */ |
|
|
201 | if (temp && temp->map) |
|
|
202 | { |
|
|
203 | /* replace corpse object with a burning object */ |
|
|
204 | newob = archetype::get (shstr_burnout); |
|
|
205 | if (newob) |
|
|
206 | newob->insert_at (temp, op); |
|
|
207 | |
|
|
208 | leveldead = temp->level; |
|
|
209 | temp->destroy (); |
|
|
210 | } |
|
|
211 | |
|
|
212 | if (resurrection_fails (clevel, leveldead)) |
|
|
213 | { |
|
|
214 | if (spell->randomitems) |
|
|
215 | for (treasure *t = spell->randomitems->items; t; t = t->next) |
|
|
216 | if (t->item) |
|
|
217 | summon_hostile_monsters (op, t->nrof, t->item->archname); |
|
|
218 | |
|
|
219 | return 1; |
|
|
220 | |
|
|
221 | } |
|
|
222 | else |
|
|
223 | return resurrect_player (op, name_to_resurrect, spell); |
|
|
224 | } |
|
|
225 | |
|
|
226 | |
|
|
227 | int |
|
|
228 | resurrection_fails (int levelcaster, int leveldead) |
147 | resurrection_fails (int levelcaster, int leveldead) |
229 | { |
148 | { |
230 | int chance = 9; |
149 | int chance = 9; |
231 | |
150 | |
232 | /* scheme: equal in level, 50% success. |
151 | /* scheme: equal in level, 50% success. |
… | |
… | |
239 | if (chance > rndm (0, 19)) |
158 | if (chance > rndm (0, 19)) |
240 | return 0; /* resurrection succeeds */ |
159 | return 0; /* resurrection succeeds */ |
241 | return 1; |
160 | return 1; |
242 | } |
161 | } |
243 | |
162 | |
|
|
163 | |
|
|
164 | /* raise_dead by peterm and mehlhaff@soda.berkeley.edu |
|
|
165 | * op -- who is doing the resurrecting |
|
|
166 | * spell - spell object |
|
|
167 | * dir -- direction the spell is cast |
|
|
168 | * corpseobj - corpse to raise - can be null, in which case this function will find it |
|
|
169 | */ |
|
|
170 | int |
|
|
171 | cast_raise_dead_spell (object *op, object *caster, object *spell, int dir, const char *arg) |
|
|
172 | { |
|
|
173 | object *temp, *newob; |
|
|
174 | char name_to_resurrect[MAX_BUF]; |
|
|
175 | int leveldead = 25, mflags, clevel; |
|
|
176 | sint16 sx, sy; |
|
|
177 | maptile *m; |
|
|
178 | |
|
|
179 | clevel = casting_level (caster, spell); |
|
|
180 | |
|
|
181 | if (spell->last_heal) |
|
|
182 | { |
|
|
183 | if (!arg) |
|
|
184 | { |
|
|
185 | new_draw_info_format (NDI_UNIQUE, 0, op, "Cast %s on who?", &spell->name); |
|
|
186 | return 0; |
|
|
187 | } |
|
|
188 | strcpy (name_to_resurrect, arg); |
|
|
189 | temp = NULL; |
|
|
190 | } |
|
|
191 | else |
|
|
192 | { |
|
|
193 | sx = op->x + freearr_x[dir]; |
|
|
194 | sy = op->y + freearr_y[dir]; |
|
|
195 | m = op->map; |
|
|
196 | mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); |
|
|
197 | if (mflags & P_OUT_OF_MAP) |
|
|
198 | temp = NULL; |
|
|
199 | else |
|
|
200 | { |
|
|
201 | /* First we need to find a corpse, if any. */ |
|
|
202 | /* If no object, temp will be set to NULL */ |
|
|
203 | for (temp = GET_MAP_OB (m, sx, sy); temp != NULL; temp = temp->above) |
|
|
204 | /* If it is corpse, this must be what we want to raise */ |
|
|
205 | if (temp->type == CORPSE) |
|
|
206 | break; |
|
|
207 | } |
|
|
208 | |
|
|
209 | if (temp == NULL) |
|
|
210 | { |
|
|
211 | new_draw_info (NDI_UNIQUE, 0, op, "You need a body for this spell."); |
|
|
212 | return 0; |
|
|
213 | } |
|
|
214 | strcpy (name_to_resurrect, temp->name); |
|
|
215 | } |
|
|
216 | |
|
|
217 | /* no matter what, we fry the corpse. */ |
|
|
218 | if (temp && temp->map) |
|
|
219 | { |
|
|
220 | /* replace corpse object with a burning object */ |
|
|
221 | newob = archetype::get (shstr_burnout); |
|
|
222 | if (newob) |
|
|
223 | newob->insert_at (temp, op); |
|
|
224 | |
|
|
225 | leveldead = temp->level; |
|
|
226 | temp->destroy (); |
|
|
227 | } |
|
|
228 | |
|
|
229 | if (resurrection_fails (clevel, leveldead)) |
|
|
230 | { |
|
|
231 | if (spell->randomitems) |
|
|
232 | for (treasure *t = spell->randomitems->items; t; t = t->next) |
|
|
233 | if (t->item) |
|
|
234 | summon_hostile_monsters (op, t->nrof, t->item->archname); |
|
|
235 | |
|
|
236 | return 1; |
|
|
237 | |
|
|
238 | } |
|
|
239 | else |
|
|
240 | return resurrect_player (op, name_to_resurrect, spell); |
|
|
241 | } |
|
|
242 | |
244 | void |
243 | void |
245 | dead_player (object *op) |
244 | dead_player (object *op) |
246 | { |
245 | { |
247 | char filename[MAX_BUF]; |
246 | char filename[MAX_BUF]; |
248 | char newname[MAX_BUF]; |
247 | char newname[MAX_BUF]; |
… | |
… | |
259 | if (rename (filename, newname) != 0) |
258 | if (rename (filename, newname) != 0) |
260 | { |
259 | { |
261 | LOG (llevError, "Cannot rename dead player's file %s into %s: %s\n", filename, newname, strerror (errno)); |
260 | LOG (llevError, "Cannot rename dead player's file %s into %s: %s\n", filename, newname, strerror (errno)); |
262 | } |
261 | } |
263 | } |
262 | } |
264 | |
|
|
265 | |
|
|
266 | |
263 | |
267 | void |
264 | void |
268 | dead_character (const char *name) |
265 | dead_character (const char *name) |
269 | { |
266 | { |
270 | char buf[MAX_BUF]; |
267 | char buf[MAX_BUF]; |
… | |
… | |
278 | { |
275 | { |
279 | LOG (llevError, "Cannot rename dead player's file %s into %s: %s\n", buf2, buf, strerror (errno)); |
276 | LOG (llevError, "Cannot rename dead player's file %s into %s: %s\n", buf2, buf, strerror (errno)); |
280 | } |
277 | } |
281 | } |
278 | } |
282 | |
279 | |
283 | |
|
|
284 | int |
280 | int |
285 | dead_player_exists (const char *name) |
281 | dead_player_exists (const char *name) |
286 | { |
282 | { |
287 | char buf[MAX_BUF]; |
283 | char buf[MAX_BUF]; |
288 | |
284 | |