I decided to add a necromancer class, and I realized that the entire point of being a necromancer would be to raise a dead corpse. Glancing over the spell creation data, I discovered that spells only affect certain properties of some character/object or another. To raise the corpse, I would need to make it a command. Knowing that, I decided to go ahead and make a raise dead function which looks like the code below. I have successfully added all the necessary amendments to make it a command. However, executing this command from within the game crashes the server.
Basically I have two questions. First, is it possile to make this a spell? Second, what exactly is wrong with the spell right now (example, I typed in raise crawler to raise a carrion crawler)? The code is as follows:
void do_raise_dead( CHAR_DATA *ch, char *argument )
{
OBJ_DATA *corpse;
OBJ_DATA *obj;
MOB_INDEX_DATA *pMobIndex;
CHAR_DATA *victim;
sh_int vnum;
char arg2[MAX_INPUT_LENGTH];
char temp[MAX_INPUT_LENGTH];
char target[MAX_INPUT_LENGTH];
char cname[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
char *ptr;
int hash, cnt, count;
ptr = cname;
if ( ch->class != 13 )
{
send_to_char( "You are not a necromancer!" , ch );
return;
}
if ( argument[0] == '\0' )
{
send_to_char( "Which corpse do you want to raise?" , ch );
return;
}
if ( ( obj = get_obj_here( ch, argument ) ) == NULL )
{
send_to_char( "You do not see that here.\n\r", ch );
return;
}
corpse = get_obj_here( ch , argument );
strcpy(cname,corpse->name);
ptr = one_argument( ptr , temp);
ptr = one_argument( ptr , target);
//from the minvoke code in act_wiz.c
count = number_argument( corpse->name, arg2 );
for ( hash = cnt = 0; hash < MAX_KEY_HASH; hash++ )
for ( pMobIndex = mob_index_hash[hash];
pMobIndex;
pMobIndex = pMobIndex->next )
if ( nifty_is_name( arg2, pMobIndex->player_name )
&& ++cnt == count )
{
vnum = pMobIndex->vnum;
break;
}
victim = create_mobile( pMobIndex );
//players can't raise corpses of other players after pkill
if (!IS_NPC(victim))
{
send_to_char( "You cannot raise that corpse." , ch );
do_purge(ch,victim->name);
return;
}
//renames newly raised creature and basically makes it a pet.
sprintf( buf, "%sA neck tag says 'I belong to %s'.\n\r", victim->description, ch->name );
STRFREE( victim->description );
victim->description = STRALLOC( buf );
char_to_room( victim, ch->in_room );
add_follower( victim, ch );
ch_printf( ch , "The corpse of %s, which you have just risen, now follows you.\n\r", victim->name );
return;
}
Basically I have two questions. First, is it possile to make this a spell? Second, what exactly is wrong with the spell right now (example, I typed in raise crawler to raise a carrion crawler)? The code is as follows:
void do_raise_dead( CHAR_DATA *ch, char *argument )
{
OBJ_DATA *corpse;
OBJ_DATA *obj;
MOB_INDEX_DATA *pMobIndex;
CHAR_DATA *victim;
sh_int vnum;
char arg2[MAX_INPUT_LENGTH];
char temp[MAX_INPUT_LENGTH];
char target[MAX_INPUT_LENGTH];
char cname[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
char *ptr;
int hash, cnt, count;
ptr = cname;
if ( ch->class != 13 )
{
send_to_char( "You are not a necromancer!" , ch );
return;
}
if ( argument[0] == '\0' )
{
send_to_char( "Which corpse do you want to raise?" , ch );
return;
}
if ( ( obj = get_obj_here( ch, argument ) ) == NULL )
{
send_to_char( "You do not see that here.\n\r", ch );
return;
}
corpse = get_obj_here( ch , argument );
strcpy(cname,corpse->name);
ptr = one_argument( ptr , temp);
ptr = one_argument( ptr , target);
//from the minvoke code in act_wiz.c
count = number_argument( corpse->name, arg2 );
for ( hash = cnt = 0; hash < MAX_KEY_HASH; hash++ )
for ( pMobIndex = mob_index_hash[hash];
pMobIndex;
pMobIndex = pMobIndex->next )
if ( nifty_is_name( arg2, pMobIndex->player_name )
&& ++cnt == count )
{
vnum = pMobIndex->vnum;
break;
}
victim = create_mobile( pMobIndex );
//players can't raise corpses of other players after pkill
if (!IS_NPC(victim))
{
send_to_char( "You cannot raise that corpse." , ch );
do_purge(ch,victim->name);
return;
}
//renames newly raised creature and basically makes it a pet.
sprintf( buf, "%sA neck tag says 'I belong to %s'.\n\r", victim->description, ch->name );
STRFREE( victim->description );
victim->description = STRALLOC( buf );
char_to_room( victim, ch->in_room );
add_follower( victim, ch );
ch_printf( ch , "The corpse of %s, which you have just risen, now follows you.\n\r", victim->name );
return;
}