52 static int resurrect_player(
object *op,
char *playername,
object *spell,
char *accountname) {
53 FILE *deadplayer, *liveplayer;
60 const char *race = NULL;
71 LOG(
llevError,
"resurrect_player: race set to %s, but no treasurelist of that name!\n", spell->
race);
81 LOG(
llevError,
"resurrect_player: got null treasure from treasurelist %s!\n", spell->
race);
90 strcpy(newname, path);
91 strcat(newname,
".pl");
93 strcpy(oldname, newname);
94 strcat(oldname,
".dead");
96 if (!(deadplayer = fopen(oldname,
"r"))) {
98 "The soul of %s cannot be reached.",
103 if (!access(newname, 0)) {
105 "The soul of %s has already been reborn!",
111 liveplayer =
of_open(&of, newname);
112 if (liveplayer == NULL) {
114 "The soul of %s cannot be re-embodied at the moment.",
120 while (!feof(deadplayer)) {
121 if ( fgets(buf, 255, deadplayer) == NULL )
break;
122 sscanf(buf,
"%s", buf2);
123 if (!(strcmp(buf2,
"exp"))) {
124 sscanf(buf,
"%s %" FMT64, buf2, &exp);
127 snprintf(buf,
sizeof(buf),
"exp %" FMT64 "\n", exp);
130 if (!(strcmp(buf2,
"Con"))) {
131 sscanf(buf,
"%s %d", buf2, &Con);
135 snprintf(buf,
sizeof(buf),
"Con %d\n", Con);
137 if (race && !strcmp(buf2,
"race")) {
138 snprintf(buf,
sizeof(buf),
"race %s\n", race);
140 fputs(buf, liveplayer);
144 "The soul of %s cannot be re-embodied at the moment.",
182 object *temp, *newob;
183 char name_to_resurrect[
MAX_BUF];
184 char *corpse_account = NULL;
185 int leveldead = 25, mflags, clevel;
188 int spell_success = 0;
199 safe_strncpy(name_to_resurrect, arg,
sizeof(name_to_resurrect));
214 if (tmp->type ==
CORPSE) {
223 "You need a body for this spell.");
231 if (corpse_account) strcpy(corpse_account, temp->
slaying);
235 if (temp && temp->
map) {
243 leveldead = temp->
level;
258 spell_success =
resurrect_player(op, name_to_resurrect, spell, corpse_account);
261 free(corpse_account);
262 return spell_success;
283 chance += levelcaster-leveldead;
286 if (chance >
rndm(0, 19))
305 strcpy(filename, path);
306 strcat(filename,
".pl");
307 strcpy(newname, filename);
308 strcat(newname,
".dead");
310 if (rename(filename, newname) != 0) {
311 LOG(
llevError,
"Cannot rename dead player's file %s into %s: %s\n", filename, newname, strerror(errno));
316 LOG(
llevError,
"Could not edit the account to indicate permanent death for %s!\n", op->
name);
int make_perma_dead(object *op)
This will edit the character account information so that the character that just died in permadeath w...
Spell-related defines: spellpath, subtypes, ...
int caster_level(const object *caster, const object *spell)
This function returns the effective level the spell is being cast at.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
int rndm(int min, int max)
Returns a number between min and max.
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
archetype * find_archetype(const char *name)
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
#define MSG_TYPE_SPELL
Spell related info.
static int resurrect_player(object *op, char *playername, object *spell, char *accountname)
Resurrect a player.
const char * playerdir
Where the player files are.
#define MSG_TYPE_SPELL_FAILURE
Spell failure messages.
sstring slaying
Which race to do double damage to.
int16_t y
Position in the map for this object.
Global type definitions and header inclusions.
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Sends message to player(s).
bool chance(int a, int b)
Return true with a probability of a/b.
int16_t level
Level of creature or object.
static int resurrection_fails(int levelcaster, int leveldead)
Will the resurrection succeed?
FILE * of_open(OutputFile *of, const char *fname)
Opens an output file.
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
sstring name
More definite name, like "generate_kobold".
#define MSG_TYPE_SPELL_SUCCESS
Spell succeeded messages.
int unmake_perma_dead(char *account, char *player)
This will edit the character account information so that the character that was just resurrected in p...
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
uint8_t chance
Percent chance for this item.
int summon_hostile_monsters(object *op, int n, const char *monstername)
Summons hostile monsters and places them in nearby squares.
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
short freearr_x[SIZEOFFREE]
X offset when searching around a spot.
sstring race
Human, goblin, dragon, etc.
int cast_raise_dead_spell(object *op, object *caster, object *spell, int dir, const char *arg)
This handles the raise dead / resurrection spells.
#define P_OUT_OF_MAP
This space is outside the map.
struct Settings settings
Global settings.
int16_t total_chance
If non-zero, only 1 item on this list should be generated.
living stats
Str, Con, Dex, etc.
#define MAX_BUF
Used for all kinds of things.
struct mapstruct * map
Pointer to the map in which this object is present.
void dead_player(object *op)
Kill a player on a permanent death server with resurrection.
short freearr_y[SIZEOFFREE]
Y offset when searching around a spot.
treasurelist represents one logical group of items to be generated together.
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
struct treasurelist * randomitems
Items to be generated.
static event_registration m
treasure * next
Next treasure-item in a linked list.
const char * localdir
Read/write data files.
sstring name
The name of the object, obviously...
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
This rolls up wall, blocks_magic, blocks_view, etc, all into one function that just returns a P_...
int of_close(OutputFile *of)
Closes an output file.
treasure * items
Items in this list, linked.
uint16_t nrof
Random 1 to nrof items are generated.
treasurelist * find_treasurelist(const char *name)
Search for the given treasurelist by name.
Functions for creating text output files.
treasure is one element in a linked list, which together consist of a complete treasure-list.
#define NDI_UNIQUE
Print immediately, don't buffer.
int32_t last_heal
Last healed.
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Constructs a loop iterating over all objects of a map tile.
struct archetype * item
Which item this link can be.
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Same as object_insert_in_map() except it handle separate coordinates and do a clean job preparing mul...