Code:
#define MOB_ZOMBIE 11 /**< vnum for the zombie mob. */
void mag_summons(int level, struct char_data *ch, struct obj_data *obj,
int spellnum, int savetype)
{
struct char_data *mob = NULL;
struct obj_data *tobj, *next_obj;
int pfail = 0, msg = 0, fmsg = 0, num = 1, handle_corpse = FALSE, i;
mob_vnum mob_num;
if (ch == NULL)
return;
switch (spellnum) {
case SPELL_CLONE:
msg = 10;
fmsg = rand_number(2, 6); /* Random fail message. */
mob_num = MOB_CLONE;
/*
* We have designated the clone spell as the example for how to use the
* mag_materials function.
* In stock tbaMUD it checks to see if the character has item with
* vnum 161 which is a set of sacrificial entrails. If we have the entrails
* the spell will succeed, and if not, the spell will fail 102% of the time
* (prevents random success... see below).
* The object is extracted and the generic cast messages are displayed.
*/
if( !mag_materials(ch, OBJ_CLONE, NOTHING, NOTHING, TRUE, TRUE) )
pfail = 102; /* No materials, spell fails. */
else
pfail = 0; /* We have the entrails, spell is successfully cast. */
break;
case SPELL_ANIMATE_DEAD:
if (obj == NULL || !IS_CORPSE(obj)) {
act(mag_summon_fail_msgs[7], FALSE, ch, 0, 0, TO_CHAR);
return;
}
handle_corpse = TRUE;
msg = 11;
fmsg = rand_number(2, 6); /* Random fail message. */
mob_num = MOB_ZOMBIE;
pfail = 10; /* 10% failure, should vary in the future. */
break;
default:
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM)) {
send_to_char(ch, "You are too giddy to have any followers!\r\n");
return;
}
if (rand_number(0, 101) < pfail) {
send_to_char(ch, "%s", mag_summon_fail_msgs[fmsg]);
return;
}
for (i = 0; i < num; i++) {
if (!(mob = read_mobile(mob_num, VIRTUAL))) {
send_to_char(ch, "You don't quite remember how to make that creature.\r\n");
return;
}
char_to_room(mob, IN_ROOM(ch));
IS_CARRYING_W(mob) = 0;
IS_CARRYING_N(mob) = 0;
SET_BIT_AR(AFF_FLAGS(mob), AFF_CHARM);
if (spellnum == SPELL_CLONE) {
/* Don't mess up the prototype; use new string copies. */
mob->player.name = strdup(GET_NAME(ch));
mob->player.short_descr = strdup(GET_NAME(ch));
}
act(mag_summon_msgs[msg], FALSE, ch, 0, mob, TO_ROOM);
load_mtrigger(mob);
add_follower(mob, ch);
if (GROUP(ch) && GROUP_LEADER(GROUP(ch)) == ch)
join_group(mob, GROUP(ch));
}
The code currently just loads the zombie mob (vnum 11). If you want to do other things, add levels and hit dice, etc. after the loading, or make a lot of different zombie mobs and choose one in the "case SPELL_ANIMATE_DEAD" section.
Your other question about letting them gain levels is somewhat more advanced. Mobs don't level up in TBA - they just gain exp (
). Changing this could mean quite some changes to the way mobs work.