void spell_ventriloquate( int sn, int level, CHAR_DATA *ch,void *vo,int target)
{
char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
char speaker[MAX_INPUT_LENGTH];
// DECLARATION HERE!
CHAR_DATA *vch;
target_name = one_argument( target_name, speaker );
/* old code */
/* sprintf( buf1, "%s says '%s'.\n\r", speaker, target_name );
sprintf( buf2, "Someone makes %s say '%s'.\n\r", speaker, target_name );
*/
/* New code to fix bug in spell.*/
// FIRST USE IS HERE
sprintf(buf1, "%s says '%s'.\n\r",
IS_NPC(vch) ? vch->short_descr : vch->name, target_name);
…
void spell_ventriloquate(int sn, int level, CHAR_DATA *ch, void *vo, int target) {
do_createSound(level, ch, vo);
}
bool_t do_createSound(int level, CHAR_DATA *ch, void *vo) {
if ( !vo) {
send_to_char("You cannot ventriloquate silence, unfortunately indeed.\n\r", ch);
return FALSE;
}
char speaker[MAX_INPUT_LENGTH];
vo = one_argument(vo, speaker);
CHAR_DATA *victim = get_char_room(ch, speaker);
if ( !victim) {
send_to_char("No one around by this name.\n\r", ch);
return FALSE;
}
if (victim == ch) {
send_to_char("Maybe you should just SAY it….\n\r", ch);
return FALSE;
}
char text[MAX_INPUT_LENGTH];
one_argument(vo, text);
if (text[0] == '\0') {
act("Make $m say what ?", ch, victim, NULL, TO_CHAR);
return FALSE;
}
char spellText[MAX_INPUT_LENGTH];
sprintf(spellText, "%s", drunk_text(capitalize(text), ch)); //if you are drunk don't expect to sound sober
short int nbCharsToFool = 0;
CHAR_DATA *vch;
for (vch = ch->in_room->people;vch;vch = vch->next_in_room) {
if (vch == ch || !vch->valid || (IS_AFFECTED(vch,AFF_CHARM) && vch->master == ch))
continue;//your charmies wont say anything but your group member are not devoted to you
nbCharsToFool ++;
}
CHAR_DATA *trigger_char[nbCharsToFool];
short int i = 0;
for (i = 0;i < nbCharsToFool;i ++)
trigger_char[i] = NULL;
i = 0;
char success[MAX_STRING_LENGTH];
char halfFail[MAX_STRING_LENGTH];
char totalFail[MAX_STRING_LENGTH];
short int nbCharsThatSpottedIt = 0;
for (vch = ch->in_room->people;vch;vch = vch->next_in_room) {
if (vch == ch || vch == victim || !vch->valid || (IS_AFFECTED(vch,AFF_CHARM) && vch->master == ch))
continue;
sprintf(success, "%s says '%s'.\n\r", capitalize(PERS(victim, vch)), spellText);
sprintf(halfFail, "Someone makes %s say '%s'.\n\r", PERS(victim, vch), spellText);
sprintf(totalFail, "%s makes %s say '%s'.\n\r", capitalize(PERS(ch, vch)), PERS(victim, vch), spellText);
bool_t failedToFool = saves_spell(level * (IS_AFFECTED(vch, AFF_BLIND) ? 3 : 1.5), vch, DAM_MENTAL);
if (failedToFool && (can_see(vch, ch) || can_see(vch, victim)))
nbCharsThatSpottedIt ++;
send_to_char(COLOR(vch, SAY_COLOR), vch);
send_to_char(!failedToFool ? success : can_see(vch, ch) ? totalFail : can_see(vch, victim) ? halfFail : success, vch);
send_to_char(COLOR(vch, NORMAL_COLOR), vch);
if ( !failedToFool && IS_NPC (vch) && (vch->pIndexData->progtypes & SPEECH_PROG) && nbCharsThatSpottedIt == 0) {
trigger_char[i] = vch;
i ++;
}
}
//specific to victim and char
sprintf(success, "You say '%s'.\n\r", spellText);
sprintf(halfFail, "Someone made you say '%s'.\n\r", spellText);
sprintf(totalFail, "%s made you say '%s'.\n\r", capitalize(PERS(ch, victim)), spellText);
bool_t failedToFool = saves_spell(level * (IS_AFFECTED(victim, AFF_BLIND) ? 3 : 1.5), victim, DAM_MENTAL);
if (failedToFool && can_see(victim, ch))
nbCharsThatSpottedIt ++;
send_to_char(failedToFool ? (can_see(victim, ch) ? totalFail : halfFail) : success, victim);
if (nbCharsThatSpottedIt == nbCharsToFool) //everyone spotted you without a doubt
do_say(ch, spellText);
else if (nbCharsThatSpottedIt == 0)
send_to_char("You fooled everyone.\n\r", ch);
else
send_to_char("Seems like you did not fool everyone.\n\r", ch);
//triggers launch: we do it there as otherwise can die, be transfered elsewhere etc
for (i=0; i< nbCharsToFool; i++) {
if (trigger_char[i] && trigger_char[i]->valid && trigger_char[i]->in_room == victim->in_room)
mprog_wordlist_check(spellText, trigger_char[i], victim, NULL, NULL, SPEECH_PROG);
}
return TRUE;
}
bool_t do_ventriloquate(CHAR_DATA *ch, char *argument) {
if (!argument || argument[0] == '\0'){
send_to_char("You cannot ventriloquate silence, unfortunately indeed.\n\r", ch);
return FALSE;
}
int sn = skill_lookup("ventriloquate");
int chance = get_skill(ch,sn);
if (chance == 0) {
send_to_char("You consider starting a one man show and start carving a wood puppet.\n\r", ch);
return FALSE;
}
do_wait( ch, skill_table[sn].beats );
if (number_percent() > chance) {
do_say(ch, argument);
interpret(ch, "innocent", FALSE);
check_improve(ch, sn, FALSE, 2);
return FALSE;
}
do_createSound(ch->level, ch, argument);
check_improve(ch, sn, TRUE, 2);
return TRUE;
}
I'm not sure I'm understanding why I am being told something is uninitialized. I am being told "warning: 'vch' is used uninitialized in this function", but I don't understand why it is saying that. Could someone explain it to me?
Thanks.