UprisingValkyrie Posted March 15, 2014 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 79 Reputation: 1 Joined: 02/24/14 Last Seen: April 21, 2016 Share Posted March 15, 2014 What's Up rAthena! can, I request an Quest NPC that can give multiple rewards & requiremesnts? on each Quest? Like for example: Requirements 500 Apple 2000 Dark Essence 1500 Black Beans Reward 1 Supernovice Suit 1 Supernovice Garment 1 Supernovice Shoes Thanks! Quote Link to comment Share on other sites More sharing options...
Pneuma Posted March 15, 2014 Group: Members Topic Count: 82 Topics Per Day: 0.02 Content Count: 846 Reputation: 138 Joined: 02/26/14 Last Seen: March 7, 2018 Share Posted March 15, 2014 What's Up rAthena! can, I request an Quest NPC that can give multiple rewards & requiremesnts? on each Quest? Like for example: Requirements 500 Apple 2000 Dark Essence 1500 Black Beans Reward 1 Supernovice Suit 1 Supernovice Garment 1 Supernovice Shoes Thanks! We're going to need more info that just that "Quest NPC that can give multiple rewards & requiremesnts? on each Quest?" Do you mean you want all the requirements you listed to be one quest with all three of those rewards or have all the requirements placed for each reward? Quote Link to comment Share on other sites More sharing options...
Patskie Posted March 15, 2014 Group: Members Topic Count: 50 Topics Per Day: 0.01 Content Count: 1702 Reputation: 241 Joined: 09/05/12 Last Seen: 15 hours ago Share Posted March 15, 2014 prontera,150,150,0 script Sample 100,{ for ( .@i = 0; .@i < getarraysize( .r ); .@i += 2 ) { if ( countitem( .r[ .@i ] ) < .r[ .@i + 1 ] ) { mes "Lack of requirements"; close; } } for ( .@i = 0; .@i < getarraysize( .r ); .@i += 2 ) delitem .r[ .@i ], .r[ .@i + 1 ]; for ( .@i = 0; .@i < getarraysize( .p ); .@i += 2 ) getitem .p[ .@i ], .p[ .@i + 1 ]; mes "Nice!"; close; OnInit: // item id, amount ( r = requirements | p = prize ) setarray .r[0],7227,5,7179,5; setarray .p[0],1202,1,5013,1; end; } Quote Link to comment Share on other sites More sharing options...
ToastOfDoom Posted March 15, 2014 Group: Members Topic Count: 4 Topics Per Day: 0.00 Content Count: 44 Reputation: 49 Joined: 11/19/11 Last Seen: January 4, 2019 Share Posted March 15, 2014 @Patskie You want to use a variable with the getarraysize value as opposed to calling the function directly inside the for loop. prontera,150,150,0 script Sample 100,{ for ( .@i = 0; .@i < .num_r; .@i += 2 ) { if ( countitem( .r[ .@i ] ) < .r[ .@i + 1 ] ) { mes "Lack of requirements"; close; } } for ( .@i = 0; .@i < .num_r; .@i += 2 ) delitem .r[ .@i ], .r[ .@i + 1 ]; for ( .@i = 0; .@i < .num_p; .@i += 2 ) getitem .p[ .@i ], .p[ .@i + 1 ]; mes "Nice!"; close; OnInit: // item id, amount ( r = requirements | p = prize ) setarray .r[0],7227,5,7179,5; setarray .p[0],1202,1,5013,1; set .num_r, getarraysize(.r); set .num_p, getarraysize(.p); end; } The getarraysize() function quite literally goes through the array checking if each value exists till the end. To put it in a loop like that means the processing time will increase quadratically as you add items. static int32 getarraysize(struct script_state* st, int32 id, int32 idx, int isstring, struct DBMap** ref) { int32 ret = idx; if( isstring ) { for( ; idx < SCRIPT_MAX_ARRAYSIZE; ++idx ) { char* str = (char*)get_val2(st, reference_uid(id, idx), ref); if( str && *str ) ret = idx + 1; script_removetop(st, -1, 0); } } else { for( ; idx < SCRIPT_MAX_ARRAYSIZE; ++idx ) { int32 num = (int32)__64BPRTSIZE(get_val2(st, reference_uid(id, idx), ref)); if( num ) ret = idx + 1; script_removetop(st, -1, 0); } } return ret; } 2 Quote Link to comment Share on other sites More sharing options...
UprisingValkyrie Posted March 16, 2014 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 79 Reputation: 1 Joined: 02/24/14 Last Seen: April 21, 2016 Author Share Posted March 16, 2014 @Pneuma Yes that's what i need... @Patskie Thanks for the responced. but as i can see that script can only do 1 kind of quest. i've got 12 quest @ToastOfDoom Now im confused with it. Quote Link to comment Share on other sites More sharing options...
Aureon Posted March 16, 2014 Group: Members Topic Count: 34 Topics Per Day: 0.01 Content Count: 281 Reputation: 14 Joined: 10/14/13 Last Seen: October 9, 2017 Share Posted March 16, 2014 Hello! i made a simple quest script as what requested...Is this what you are looking for? prontera,155,176,4 script Random 100,{ if (quest1 == 0) { mes "Want random Quest?"; next; switch(rand(1,3)){ case 1: mes "Requirements:"; mes "500 Apples"; mes "Come back when you're done"; set quest1,1; close; case 2: mes "Requirements:"; mes "2000 Bananas"; mes "Come back when you're done"; set quest1,2; close; case 3: mes "Requirements:"; mes "1500 Grapes"; mes "Come back when you're done"; set quest1,3; close; } } // countitem(itemID) < itemquantity ) // delitem itemID,itemquantity; // getitem rewarditemID,itemquantity; if (quest1 == 1) { if(countitem(512) < 500 ) goto NotEnough1; delitem 512,500; getitem 5119,1; set quest1,0; mes "You completed the task!"; mes "Congrats~"; close; } if (quest1 == 2) { if(countitem(513) < 2000 ) goto NotEnough2; delitem 513,2000; getitem 5120,1; set quest1,0; mes "You completed the task!"; mes "Congrats~"; close; } if (quest1 == 3) { if(countitem(514) < 1500 ) goto NotEnough3; delitem 514,1500; getitem 5121,1; set quest1,0; mes "You completed the task!"; mes "Congrats~"; close; } NotEnough1: mes "Sorry but you forgot to bring the exact requirements i told you"; mes "Requirements:"; mes "500 Apples"; close; NotEnough2: mes "Sorry but you forgot to bring the exact requirements i told you"; mes "Requirements:"; mes "2000 Bananas"; close; NotEnough3: mes "Sorry but you forgot to bring the exact requirements i told you"; mes "Requirements:"; mes "1500 Grapes"; close; } Quote Link to comment Share on other sites More sharing options...
Patskie Posted March 16, 2014 Group: Members Topic Count: 50 Topics Per Day: 0.01 Content Count: 1702 Reputation: 241 Joined: 09/05/12 Last Seen: 15 hours ago Share Posted March 16, 2014 @Pneuma Yes that's what i need... @Patskie Thanks for the responced. but as i can see that script can only do 1 kind of quest. i've got 12 quest @ToastOfDoom Now im confused with it. My script is just a template. What TOD said is that i should instead declare a variable on the OnInit part and give the array size of .r and .p into those 2 variables and access them on the for loop instead. Well in terms of processing TOD script is more efficient than mine. Quote Link to comment Share on other sites More sharing options...
Question
UprisingValkyrie
What's Up rAthena!
can, I request an Quest NPC that can give multiple rewards & requiremesnts? on each Quest?
Like for example:
Requirements
Reward
Thanks!
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.