03 Feb, 2010, deathrow35 wrote in the 1st comment:
Votes: 0
Ok, i wanted to try something new. I want to check to see if an item is on a questmob to complete the quest. I was originally going to go the route of just checking the character to see if the item was there. Vassago quest addition where the questor will give the pc a item to deliver to a random mob. Anyways, here is what i have
else if (ch->questbox > 0 && ch->countdown > 0)
{

for (victim = char_list; victim != NULL; victim = victim->next)
{

if (!IS_NPC(victim)) continue;


{
bool obj_found = FALSE;
for (obj = victim->carrying; obj != NULL; obj = obj_next)
{
obj_next = obj->next_content;
if (obj->pIndexData->vnum == ch->questbox)
{
obj_found = TRUE;
break;
}
}

if (obj_found == TRUE)

{

Then comes the rewards and I do have the brackets closed lower. weird thing is, this worked once and hasnt worked since.
03 Feb, 2010, jurdendurden wrote in the 2nd comment:
Votes: 0
First thing I would do is a clean make and a reboot. I have had some issues where I've added code and added code for about a week or so, and just did copyover after copyover, then had some REALLY random/weird bugs. (buffers getting thrown into the wholist that didn't belong, etc…). Try that first because as far as I can tell your code looks sound (initializes obj_found before using it, checks victim instead of ch for the item in question).
03 Feb, 2010, elanthis wrote in the 3rd comment:
Votes: 0
It tends to help if you post what the actual problem is. "Doesn't work" is not even remotely descriptive enough. Compilation error? Command not do what expected? What's the issue?
03 Feb, 2010, deathrow35 wrote in the 4th comment:
Votes: 0
I actually got the code to work to an extent. When i close the brackets in certain spot and object is not found on the victim, it will say "You must request a quest first", but then when i take the } down to after the stock go get item section it won't let me complete the quest. It will say you're quest is not complete but there is still time. So maybe my problem the whole time was the bracket placement. So I guess I ask you this…Whats wrong with my brackets or is it finding the object but not finding it on the victim, instead finding it on the char? Sounds more like the brackets to me but this was just another thought i had.
if (IS_SET(ch->act, PLR_QUESTOR))
{
if (ch->questmob == -1 && ch->countdown > 0)
{
int reward, pointreward, pracreward;

reward = number_range(2500,45000);
pointreward = number_range(25,75);

sprintf(buf, "Congratulations on completing your quest!");
do_say(questman,buf);
sprintf(buf,"As a reward, I am giving you %d quest points, and%d gold.",pointreward,reward);
do_say(questman,buf);
if (chance(15))
{
pracreward = number_range(1,6);
sprintf(buf, "You gain %d practices!\n\r",pracreward);
send_to_char(buf, ch);
ch->practice += pracreward;
}

REMOVE_BIT(ch->act, PLR_QUESTOR);
ch->questgiver = NULL;
ch->countdown = 0;
ch->questmob = 0;
ch->questobj = 0;
ch->questbox = 0;
ch->nextquest = 1;
ch->gold += reward;

return;
}
else if (ch->questbox > 0 && ch->countdown > 0)

{
for (victim = char_list; victim != NULL; victim = victim->next)


if (IS_NPC(victim))


{
bool obj_found = FALSE;
for (obj = victim->carrying; obj != NULL; obj = obj_next)
{
obj_next = obj->next_content;
if (obj->pIndexData->vnum == ch->questbox)
{
obj_found = TRUE;
break;
}
}
if (obj_found == TRUE)

{


int reward, pointreward, pracreward;

reward = number_range(2500,45000);
pointreward = number_range(25,75);

sprintf(buf, "Congratulations on completing your quest!");
do_say(questman,buf);
sprintf(buf,"As a reward, I am giving you %d quest points, and %d gold.",pointreward,reward);
do_say(questman,buf);
if (chance(15))
{
pracreward = number_range(1,6);
sprintf(buf, "You gain %d practices!\n\r",pracreward);
send_to_char(buf, ch);
ch->practice += pracreward;
}

REMOVE_BIT(ch->act, PLR_QUESTOR);
ch->questgiver = NULL;
ch->countdown = 0;
ch->questmob = 0;
ch->questobj = 0;
ch->questbox = 0;
ch->nextquest = 1;
ch->gold += reward;
ch->questpoints += pointreward;
extract_obj(obj);

return;
}
} }


else if (ch->questobj > 0 && ch->countdown > 0)
{
bool obj_found = FALSE;
for (obj = ch->carrying; obj != NULL; obj= obj_next)
{
obj_next = obj->next_content;

if (obj != NULL && obj->pIndexData->vnum == ch->questobj)
{
obj_found = TRUE;
break;
}
}
if (obj_found == TRUE)
{
int reward, pointreward, pracreward;

reward = number_range(2500,45000);
pointreward = number_range(25,75);

act("You hand $p to $N.",ch, obj, questman, TO_CHAR);
act("$n hands $p to $N.",ch, obj, questman, TO_ROOM);

sprintf(buf, "Congratulations on completing your quest!");
do_say(questman,buf);
sprintf(buf,"As a reward, I am giving you %d quest points,and %d gold.",pointreward,reward);
do_say(questman,buf);
if (chance(15))
{
pracreward = number_range(1,6);
sprintf(buf, "You gain %d practices!\n\r",pracreward);
send_to_char(buf, ch);
ch->practice += pracreward;
}

REMOVE_BIT(ch->act, PLR_QUESTOR);
ch->questgiver = NULL;
ch->countdown = 0;
ch->questmob = 0;
ch->questobj = 0;
ch->nextquest = 1;
ch->gold += reward;
ch->questpoints += pointreward;
extract_obj(obj);
return;
}
else
{
sprintf(buf, "You haven't completed the quest yet, but there is still time!");
do_say(questman, buf);
return;
}
return;
}

else if ((ch->questmob > 0 || ch->questobj > 0 || ch->questbox > 0) && ch->countdown > 0)
{
sprintf(buf, "You haven't completed the quest yet, but there is still time!");
do_say(questman, buf);
return;


}
if (ch->nextquest > 0)
sprintf(buf,"But you didn't complete your quest in time!");
else sprintf(buf, "You have to REQUEST a quest first, %s.",ch->name);
do_say(questman, buf);
return;
}

send_to_char("QUEST commands: POINTS INFO TIME REQUEST COMPLETE LIST BUY.\n\r",ch);
send_to_char("For more information, type 'HELP QUEST'.\n\r",ch);
return;
}

and thats what i have so far
03 Feb, 2010, jurdendurden wrote in the 5th comment:
Votes: 0
Looks like you have two else if statements that do the same thing. ( else if (ch->questobj > 0 && ch->countdown > 0)). I know they check victim/ch respectively, but the fact that the if statements themselves are identical could possibly be confusing the game.
03 Feb, 2010, deathrow35 wrote in the 6th comment:
Votes: 0
Yea but they are defined differently. They are different vnum objects. That would make it work wouldn't it? It seems to work fine when the quest is generated. I don't understand why it wouldn't work here?
03 Feb, 2010, jurdendurden wrote in the 7th comment:
Votes: 0
Hmm after a second look I notice that one says questbox and one says questobj. I have a suggestion for you. I wrote a quest system from scratch and in it there are several different 'quest types' (ITEM_RETRIEVE, READ_HELP, MOB_KILL, AREA_EXPLORE, and any combination of these). To handle this, I wrote a function called bool quest_complete. Then, instead of having one huge if/else if/else statement for every type of quest, i simply did a switch statement to check what type of quest they are on, (which you could set up to handle automated/non-auto quests as well), and then check for the appropriate values from there. I also set up every quest in my game into a table with several settings for each (type of quest, description, vnums for mobs/items to kill/find, helpfile names to read, etc…). Below is that bool quest_complete code, from about a month ago (i'm at work with only my flash drive which I haven't backed up my mud to in some time :D).

bool quest_complete( CHAR_DATA *ch )
{
int type;

type = quest_table[ch->quest].type;

switch (type)
{
default: return FALSE; break;
case MOB_KILL:
if (ch->multiples >= quest_table[ch->quest].multiples)
{
return TRUE;
break;
}
break;
case ITEM_RETRIEVE:
if (ch->multiples >= quest_table[ch->quest].multiples)
{
return TRUE;
break;
}
break;
case MOB_HELP_COMBO:
if (ch->multiples >= quest_table[ch->quest].multiples)
{
if (!strcmp ("", quest_table[ch->quest].help1 ) || ch->qread1 == TRUE)
{
if ( !strcmp ("", quest_table[ch->quest].help2 ) || ch->qread2 == TRUE )
{
if ( !strcmp ("", quest_table[ch->quest].help3 ) || ch->qread3 == TRUE )
{
return TRUE;
break;
}
}
}
}
break;
case HELP_READ:
if (ch->qread1 == TRUE)
{
if ( !strcmp ("", quest_table[ch->quest].help2 ) || ch->qread2 == TRUE )
{
if ( !strcmp ("", quest_table[ch->quest].help3 ) || ch->qread3 == TRUE )
{
return TRUE;
break;
}
}
}
break;
}


return FALSE;
}


So then I would just go to the appropriate places in the code and increment things like ch->multiples, etc… by placing checks in the raw_kill func (for mob killing), do_help (helpfile reading), move_char (for the area explore), and get_obj (for obj retrieval). Anyway I figure this could give you a little insight into making your quest system work more coherently instead of like I said earlier using multiple else if's and getting confused by some silly brackets ;)
03 Feb, 2010, deathrow35 wrote in the 8th comment:
Votes: 0
I think I finally got it. Ended up just writing an else for each individual one. best I could do. Thanks for yours quest_complete code. I was thinking about using it but I am not very good at tables and struct stuff. I always get array errors. I intend on getting better at those in the future. But I appreciate the help with everything. Good learning experience
0.0/8