summoned NPC isn't charmed (help please!)

Posted by Gogoicarus on Mon 03 Sep 2007 05:16 AM — 3 posts, 17,141 views.

Japan #0
hey, we're working on creating a kind of joke homonculus. using pieces from a pre-existing familiar summoning code as well as animate dead, we thought we had it pretty well worked out.

however, when the NPC is summoned, there is no charm applied to it. it follows the summoner but can't be ordered to do anything. this may just be a bug in our test MUD but i'm baffled.

here is the code. any help is appriciated.

----------------------------
#define MOB_VNUM_DAISY 30807
/* More daisy madness */
ch_ret spell_daisy_daisy( int sn, int level, CHAR_DATA *ch, void *vo )
{
MOB_INDEX_DATA *pMobIndex;
CHAR_DATA *mob;
SKILLTYPE *skill = get_skilltype(sn);
AFFECT_DATA af;

if ( ch->pcdata->pet != NULL )
{
send_to_char("You already have a companion.\n\r",ch);
failed_casting( skill, ch, NULL, NULL );
return rSPELL_FAILED;
}
if(ch->position == POS_FIGHTING)
{
send_to_char("You can't grow flowers while in fighting!\n\r",ch);
failed_casting( skill, ch, NULL, NULL );
return rSPELL_FAILED;
}

if ( ( pMobIndex = get_mob_index(MOB_VNUM_DAISY) ) == NULL )
{
send_to_char( "The daisy mob doesn't exist.\n\r", ch );
return rSPELL_FAILED;
}


if(ch->in_room->sector_type == SECT_INSIDE
|| ch->in_room->sector_type == SECT_WATER_SWIM
|| ch->in_room->sector_type == SECT_WATER_NOSWIM
|| ch->in_room->sector_type == SECT_AIR )
{
send_to_char("This doesn't seem like the place to grow daisies...\n\r",ch);
failed_casting( skill, ch, NULL, NULL );
return rSPELL_FAILED;
}

mob = create_mobile( pMobIndex );
char_to_room( mob, ch->in_room );
mob->level = 1;
mob->hit = mob->max_hit;
mob->damroll = ch->level / 8;
mob->hitroll = ch->level / 6;
mob->alignment = ch->alignment;

act(AT_MAGIC, "$n gardens the ground and grows a daisy!", ch, NULL, NULL, TO_ROOM);
act(AT_MAGIC, "You garden the ground and grow a daisy!", ch, NULL, NULL, TO_CHAR);

add_follower( mob, ch );
/* added some stuff to make the mob your pet */
mob->leader = ch;
ch->pcdata->pet = mob;
xSET_BIT(mob->act, ACT_PET);
xSET_BIT(mob->affected_by, AFF_CHARM);
/* end tochi additions */
af.type = sn;
af.duration = 0; //We want these to follow indefinitely ~Khtall
af.location = 0;
af.modifier = 0;
af.bitvector = meb(AFF_CHARM);
affect_to_char( mob, &af );

return rNONE;

}
---------------------
USA #1
what does your add_follower function look like, because mine does everything your code is trying to do already, and mine is stock, so im assuming your doing things twice right now.


add_follower( mob, ch );
/* added some stuff to make the mob your pet */
mob->leader = ch;
ch->pcdata->pet = mob;
xSET_BIT(mob->act, ACT_PET);
xSET_BIT(mob->affected_by, AFF_CHARM);
/* end tochi additions */
af.type = sn;
af.duration = 0; //We want these to follow indefinitely ~Khtall
af.location = 0;
af.modifier = 0;
af.bitvector = meb(AFF_CHARM);
affect_to_char( mob, &af );


try just this and see if it works


xSET_BIT(mob->act, ACT_PET);
add_follower( mob, ch );
af.type = sn;
af.duration = 0; //We want these to follow indefinitely ~Khtall
af.location = 0;
af.modifier = 0;
af.bitvector = meb(AFF_CHARM);
affect_to_char( mob, &af );
USA #2
Quote:
af.duration = 0; //We want these to follow indefinitely ~Khtall

This should probably be -1 not 0. As soon as your mob is summoned and the check is made on its spell's duration, the spell is removed. A duration of -1 will make the spell last forever, or at least until the mob is dismissed or killed, or the player logs out.