Jump to content
  • 0
ToiletMaster

Dynamic Switch Statement with choices

Question

Hi there!

 

Would like to know if this is possible?

 

for example,

 

i have these quest ID, let's say 1000,2000,3000 as my quest ID.

 

Firstly, upon talking to the NPC,

 

the npc would provide the choices for him to go through

 

switch(select("accept quest 1000:cancel")){  case 1:setquest 1000;break; case 2:mes "ok";close;}

 

however, upon finishing the quest for 1000, the option of 2000 instead would appear now.

 

switch(select("accept quest 1000:accept quest 2000:cancel)){

 

case 1:setquest 1000;break; case 2:setquest 2000;break case 3:mes "ok";close;}

Would like to know if this is possible?

 

I understand there is a alternative where i can set if(questprogress(1000) == 2 && questprogress(2000) == 2)) to appear and make this happen, however, this would if it's sequenced, the scenario would now be if what happens if he finished 1000, and 3000 instead. thus this logic may not be applicable anymore unless it's manually coded for another 1000 && 3000 checking. Would like to know if there are any methods that can be done to check which quest he has done and the case would go accordingly to what he has done.

 

Would appreciate if anyone could provide their advice on this. Thank you.

Edited by ToiletMaster

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Hi Emistry,

 

First and foremost, thank you for your reply. The sample that you've provided definitely worked in this case. However, my apologies as  i guess i missed out one part of the explanation. Currently i've drawn a graph on how the dynamic switch was supposed to be like divided by Level 1, 2, 3. Followed by groups of A B C.

 

For example, within level 1, you can see A B C groupings there, however if the person finished the A group level 1, he can see A group level 2 quests.

 

However, not B group's Level 2 quest unless he has finished the Level 1 for B Group.

 

I hope this explanation is not confusing, once again thank you for your time and i appreciate your help!

 

edit image below for further reference.

 

post-883-0-26601800-1442556767_thumb.png

Edited by ToiletMaster

Share this post


Link to post
Share on other sites
  • 0

Hi emistry,

 

thank you once again for your reply. I've just tested this the moment i got back but unfortunately i can't seem to get it working.

 

i did not change the core part of the scripts aside from minor additions aside from that.

 

i can't seem to select any of the choices i want for quest ID i've specified. I notice it could be this line

 

 

if ( .@avail_quest_count >= .@quest_size )

 

i've checked the variable to see what were the cases and it's either 0,0; 3,3; 3;3 which states that my quest is completed thus disallowing me to continue, i've tried hard to crack this down and even created a script to delete all my quest entries related to the script to ensure that those quests aren't accepted at all.

 

Would highly appreciate if you take a look to advise where i went wrong. Thank you once again.

 

 

 

 

  new_1-2,90,111,5    script    Sample#quest    4_F_KAFRA2,{    mes ""+.@npcname$+"";    mes "Please select category below";    .@category = select    (        "Option 1",        "Option 2",        "Option 3"    ) - 1;        .@quest_size = getd( ".quest_id_"+.@category+"_size" );    copyarray .@quest,getd( ".quest_id_"+.@category ),.@quest_size;        for ( .@i = 0; .@i < .@quest_size; .@i++ )        {        if ( questprogress( .@quest_id[.@i] ) != 2 )            {            .@menu$ = .@menu$ + "Level - "+.@quest_id[.@i];            .@avail_quest_count++;            }        .@menu$ = .@menu$ + ":";        }        if ( .@avail_quest_count >= .@quest_size )    {        mes ""+.@npcname$+"";        mes "All quest finished.";        mes "avail: "+.@avail_quest_count+"quest size: "+.@quest_size+"";        close;    }        .@i = select( .@menu$ ) - 1;    mes ""+.@npcname$+"";    mes "Selected Quest Category "+( .@category+1 )+" - Level "+( .@i+1 )+" - "+.@quest_id[.@i];        if ( .@i > 0 )    {        if ( questprogress( .@quest_id[.@i-1] ) != 2 )        {            mes ""+.@npcname$+"";            mes "You cant take this quest because you haven't finish the previous quests.";            close;        }    }        if ( questprogress( .@quest_id[.@i] ) == 1 )    {        mes ""+.@npcname$+"";        mes "You've already taken this quest but not yet complete.";        close;    }    else  //Quest Requirements started        {    if (.@quest_id[@i] == 20000)    {        mes ""+.@npcname$+"";        mes "You have select quest 20000 as your current quest. ";        setquest .@quest_id[.@i];        close;    }        }        mes "Quest Accepted";        setquest .@quest_id[.@i];        close;OnInit:        .@npcname$ = "[^FF0000 Sample ^000000]";    setarray .quest_id_1,        20001,        20002,        20003;    .quest_id_1_size = getarraysize( .quest_id_1 );        setarray .quest_id_2,        20004,        20005,        20006;    .quest_id_2_size = getarraysize( .quest_id_2 );        setarray .quest_id_3,        20007,        20008,        20009;    .quest_id_3_size = getarraysize( .quest_id_3 );    end;}
Edited by ToiletMaster

Share this post


Link to post
Share on other sites
  • 0

Few things off the top of my head...

 

.@category = select
  (
  "Option 1",
  "Option 2",
  "Option 3"
  ) - 1;

 

// Is setting the .@category to a ZERO based index... where .@category is 0 to 2

 

.@quest_size = getd( ".quest_id_"+.@category+"_size" );

 

// Is setting .@quest_size to .quest_id_(0-2)_size (0 doesn't exist...)

 

There's probably more but that should be a start...

Share this post


Link to post
Share on other sites
  • 0

Thanks for the help! this time it works perfectly! thank you very much! i do have one more question though, as i was understanding your script,  i tried to create an npc that deletes the quest using your method of accessing arrays, previously i did the manually method of deleting each quest by specifying each quest. But i can't seem to make it work, i tried various options such as copying the arrays over, and such and comparing with your script. 

 

the main difference i can see is that all your arrays during the for method is using .@ instead . would that make an impact here? i tried copying the arrays and setting it as .@ as well but it did not work. basically the main method would be checking if you've accepted any quest and upon any of the mentioned arrays were conditioned as 1, it would then erase that ID.

 

Once again thank you for your help!

 

[/s][s]   	 for ( .@i = 0; .@i < .number_quest; .@i++ ){        if (questprogress (.quest_id[.@i] == 1))        erasequest .quest_id[.@i];        }            mes "Quest Deleted";    close;        OnInit:        setarray .quest_id,        20001,        20002,        20003,        20004,        20005,        20006,        20007,        20008,        20009;    .number_quest = getarraysize(.quest_id);    }[/s][s]

 

 

edit:

 

i understand i can set .@i = 20000 and <= 20009 and thus doing the change from there. however, my only concern would be what happens if we have jumping numbers from 20000,30000,40000 and such in this manner.

 

 

 

edit:

 

i managed to fixed it !

 

After referring once again to the script you posted, i managed to find out the problem! here's the one that's working

 

   	 for ( .@i = 0; .@i <= .number_quest ; .@i++ ){	    if (questprogress (.quest_id[.@i]) == 1)	    erasequest .quest_id[.@i];	    }            mes "Quest Deleted";    close;        OnInit:        setarray .quest_id,        20001,        20002,        20003,        20004,        20005,        20006,        20007,        20008,        20009;    .number_quest = getarraysize(.quest_id);    }

 

Thank you so much for the following script @@Emistry! It works brilliantly now! :wow::thx: :thx:

Edited by ToiletMaster

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.