05 Aug, 2011, triskaledia wrote in the 1st comment:
Votes: 0
Trying to make it so my undead mage that followers players around will cast spells.
I added
/***
if (IS_NPC (ch))
return skill_lookup (name);
***/

if(IS_NPC(ch))
found = number_range(75, 100);
in magic.c under int_find spell and commented out the bit about npcs not being able to cast spells unless switched into by an immortal in do_cast.

Killed quite a bit of mobs with the mage waiting for it to cast a spell, and it still hasn't casted a spell. *Yes spec_cast_undead is set*
I searched the code repository for a mob_cast, cast, and mob to see if I could find a simple snippet to help me debug this but to no avail.
—Might have to check the standard quickmud to see what it looks like also—
Any help getting mobs to cast via specs again would be nice.

This is the code in special.c
bool spec_cast_undead (CHAR_DATA * ch)
{
CHAR_DATA *victim;
CHAR_DATA *v_next;
char *spell;
int sn;

if (ch->position != POS_FIGHTING)
return FALSE;

for (victim = ch->in_room->people; victim != NULL; victim = v_next)
{
v_next = victim->next_in_room;
if (victim->fighting == ch && number_bits (2) == 0)
break;
}
if (victim == NULL)
return FALSE;

for (;;)
{
int min_level;

switch (number_range (0, 8))
{
case 0:
min_level = 0;
spell = "curse";
break;
case 1:
min_level = 3;
spell = "weaken";
break;
case 2:
min_level = 6;
spell = "chill touch";
break;
case 3:
min_level = 9;
spell = "blindness";
break;
case 4:
min_level = 12;
spell = "poison";
break;
case 5:
min_level = 15;
spell = "energy drain";
break;
case 6:
min_level = 18;
spell = "harm";
break;
case 7:
min_level = 21;
spell = "teleport";
break;
case 8:
min_level = 20;
spell = "plague";
break;
}

if (ch->level >= min_level)
break;

}

if ((sn = skill_lookup (spell)) < 0)
return FALSE;
(*skill_table[sn].spell_fun) (sn, ch->level, ch, victim, TARGET_CHAR);
return TRUE;
}
05 Aug, 2011, David Haley wrote in the 2nd comment:
Votes: 0
Does the NPC fight alongside the player? This might be your issue:

for (victim = ch->in_room->people; victim != NULL; victim = v_next) 
{
v_next = victim->next_in_room;
if (victim->fighting == ch && number_bits (2) == 0)
break;
}


(BTW, please use code tags)

This is saying that it'll only pick a victim if that victim is fighting the NPC, but if the victims are all fighting the player, and not the NPC, it won't pick any of them.

In other words, that function will only have the mob cast spells against other mobs attacking it.
0.0/2