Jump to content
  • 0

QuestNPC improvement(Just like BTS)


Question

Posted (edited)

Hello goodevening,

I just coded this simple NPC and wanted to modify / change to the following:

( 1 ) Whenever a person already done the first quest then the NPC wont let him do it again. instead it skips to the next.

( 2 ) They are only able to take this quest every 3 Days.

( 3 ) After they select Yes, I want to remove this message "Want to proceed to the next step?"

crystilia,73,73,4	script	try	100,{
// FIRST STEP
mes "You want to start this quest?";
mes "You need to have this Items:";
mes "10 Jellopies";
mes "10 zRo Coins";
next;
mes "Let me check";
next;
if(countitem(909) < 10 || countitem(20103) < 10) goto L_wala;
announce ""+strcharinfo(0)+" has started the Godly quest!",0;
delitem 909,10;
delitem 20103,10;
next;
mes "Want to proceed to the next step?";
menu "Yes",L_yes1,"No",L_no;

// second step
L_yes1:
mes "This is the second step, get me these items";
mes "10 TCG";
mes "10 zRo Coins";
next;
mes "Let me check it again.";
next;
if(countitem(20103) < 10 || countitem(7227) < 10) goto L_wala2;
delitem 7227,10;
delitem 20103,10;
mes "You receive 1 Emblem of the sun gold!";
getitem 1009,1;
next;
next;
mes "Want to proceed to the next step?";
menu "Yes",L_yes2,"No",L_no;

//last step
L_yes2:
mes "This is the last step";
mes "Bring me these items";
mes "1 Emblem of the Sun Gold";
mes "1 Yggdrasil Berry";
next;
mes "Check!";
next;
if(countitem(607) < 1 || countitem(1009) < 1) goto L_wala2;
delitem 607,1;
delitem 1009,1;
mes "Congratulations! you receive Godly item!";
getitem 20107,1;
announce ""+strcharinfo(0)+" has finished the Godly quest!",0;
close;

L_wala:
mes "Sorry, please bring those items to me";
close;

L_wala2:
mes "Sorry, please bring those items to me";
close;

L_no:
close;

}

Thank you moderators.

Edited by Emistry
Please use [CODEBOX] or Attachments for long contents.

11 answers to this question

Recommended Posts

Posted (edited)

( 1 ) Whenever a person already done the first quest then the NPC wont let him do it again. instead it skips to the next.

( 2 ) They are only able to take this quest every 3 Days.

It's a bit paradoxical but I think you mean after 3 days that the player finish the quest, he could do the same quest.

Also do you mean player or account ?

Player

They are only able to take this quest every 3 Days.

//	~~~~~ show time left in days, hours, minutes and seconds ~~~~~
function	script	timeleft__	{
if ( ( .@left = getarg(0) ) <= 0 ) return getarg(0);
.@day = .@left / 86400;
.@hour = .@left % 86400 / 3600;
.@min = .@left % 3600 / 60;
.@sec = .@left % 60;
if ( .@day )
	return .@day +" day "+ .@hour +" hour";
else if ( .@hour )
	return .@hour +" hour "+ .@min +" min";
else if ( .@min )
	return .@min +" min "+ .@sec +" sec";
else
	return .@sec +" sec";
}

prontera,150,150,4	script	try	100,{

if( quest_step == 2 ) goto L_yes2;
else if( quest_step == 1 ) goto L_yes1;
else if( quest_step > 2 && quest_step > gettimetick(2) ) {
	mes "You must wait for "+ callfunc( "timeleft__", ( quest_step - gettimetick(2) ) ) +".";
	close;
}
// FIRST STEP
mes "You want to start this quest?";
mes "You need to have this Items:";
mes "10 Jellopies";
mes "10 zRo Coins";
next;
mes "Let me check";
next;
if( countitem(909) < 10 || countitem(20103) < 10 ) goto L_wala;
announce ""+strcharinfo(0)+" has started the Godly quest!",0;
delitem 909,10;
delitem 20103,10;
set quest_step, 1;
close;

// second step
L_yes1:
mes "This is the second step, get me these items";
mes "10 TCG";
mes "10 zRo Coins";
next;
mes "Let me check it again.";
next;
if( countitem(20103) < 10 || countitem(7227) < 10 ) goto L_wala;
delitem 7227,10;
delitem 20103,10;
mes "You receive 1 Emblem of the sun gold!";
getitem 1009,1;
set quest_step, 2;
close;
//last step
L_yes2:
mes "This is the last step";
mes "Bring me these items";
mes "1 Emblem of the Sun Gold";
mes "1 Yggdrasil Berry";
next;
mes "Check!";
next;
if( countitem(607) < 1 || countitem(1009) < 1 ) goto L_wala;
delitem 607,1;
delitem 1009,1;
mes "Congratulations! you receive Godly item!";
getitem 20107,1;
announce ""+strcharinfo(0)+" has finished the Godly quest!",0;
set quest_step, gettimetick(2) + 3 * 86400;
close;

L_wala:
mes "Sorry, please bring those items to me";
close;

}

Edited by Capuche
Posted

( 1 ) Whenever a person already done the first quest then the NPC wont let him do it again. instead it skips to the next.

( 2 ) They are only able to take this quest every 3 Days.

It's a bit paradoxical but I think you mean after 3 days that the player finish the quest, he could do the same quest.

Also do you mean player or account ?

Player

They are only able to take this quest every 3 Days.

//	~~~~~ show time left in days, hours, minutes and seconds ~~~~~
function	script	timeleft__	{
if ( ( .@left = getarg(0) ) <= 0 ) return getarg(0);
.@day = .@left / 86400;
.@hour = .@left % 86400 / 3600;
.@min = .@left % 3600 / 60;
.@sec = .@left % 60;
if ( .@day )
	return .@day +" day "+ .@hour +" hour";
else if ( .@hour )
	return .@hour +" hour "+ .@min +" min";
else if ( .@min )
	return .@min +" min "+ .@sec +" sec";
else
	return .@sec +" sec";
}

prontera,150,150,4	script	try	100,{

if( quest_step == 2 ) goto L_yes2;
else if( quest_step == 1 ) goto L_yes1;
else if( quest_step > 2 && quest_step > gettimetick(2) ) {
	mes "You must wait for "+ callfunc( "timeleft__", ( quest_step - gettimetick(2) ) ) +".";
	close;
}
// FIRST STEP
mes "You want to start this quest?";
mes "You need to have this Items:";
mes "10 Jellopies";
mes "10 zRo Coins";
next;
mes "Let me check";
next;
if( countitem(909) < 10 || countitem(20103) < 10 ) goto L_wala;
announce ""+strcharinfo(0)+" has started the Godly quest!",0;
delitem 909,10;
delitem 20103,10;
set quest_step, 1;
close;

// second step
L_yes1:
mes "This is the second step, get me these items";
mes "10 TCG";
mes "10 zRo Coins";
next;
mes "Let me check it again.";
next;
if( countitem(20103) < 10 || countitem(7227) < 10 ) goto L_wala;
delitem 7227,10;
delitem 20103,10;
mes "You receive 1 Emblem of the sun gold!";
getitem 1009,1;
set quest_step, 2;
close;
//last step
L_yes2:
mes "This is the last step";
mes "Bring me these items";
mes "1 Emblem of the Sun Gold";
mes "1 Yggdrasil Berry";
next;
mes "Check!";
next;
if( countitem(607) < 1 || countitem(1009) < 1 ) goto L_wala;
delitem 607,1;
delitem 1009,1;
mes "Congratulations! you receive Godly item!";
getitem 20107,1;
announce ""+strcharinfo(0)+" has finished the Godly quest!",0;
set quest_step, gettimetick(2) + 3 * 86400;
close;

L_wala:
mes "Sorry, please bring those items to me";
close;

}

Sorry, Instead of players, i want to set it to account to avoid any abuses.

Thank you let me try your script.

----

edit.

Your script works well without a problem. Thank you sir. And yea about ( instead of player -> account ) how do we set it to that?

Posted

Your script works well without a problem. Thank you sir. And yea about ( instead of player -> account ) how do we set it to that?

Just replace ALL variable

quest_step

to

#quest_step

Posted

Your script works well without a problem. Thank you sir. And yea about ( instead of player -> account ) how do we set it to that?

Just replace ALL variable

quest_step

to

#quest_step

Okay sir let me try that one. Anyway whats the difference between the two? Sorry for asking buy I really want to understand each variable sir. Thank you

Posted
Scope can be:

global - global to all servers

local - local to the server

account - attached to the account of the character identified by RID

character - attached to the character identified by RID

npc - attached to the NPC

scope - attached to the scope of the instance

Extent can be:

permanent - They still exist when the server resets.

temporary - They cease to exist when the server resets.

Prefix: scope and extent

nothing - A permanent variable attached to the character, the default variable

type. They are stored with all the account data in "save\athena.txt"

in TXT versions and in the SQL versions in the `global_reg_value`

table using type 3.

...

....

"#" - A permanent local account variable.

They are stored with all the account data in "save\accreg.txt" in

TXT versions and in the SQL versions in the 'global_reg_value'

table using type 2.

quest_step = attached to character

#quest_step = attached to player account

You can find more informations in your doc/script_commands.txt folder

http://svn.rathena.org/svn/rathena/trunk/doc/script_commands.txt

(this link is for rAthena user~)

Posted (edited)
Scope can be:

global - global to all servers

local - local to the server

account - attached to the account of the character identified by RID

character - attached to the character identified by RID

npc - attached to the NPC

scope - attached to the scope of the instance

Extent can be:

permanent - They still exist when the server resets.

temporary - They cease to exist when the server resets.

Prefix: scope and extent

nothing - A permanent variable attached to the character, the default variable

type. They are stored with all the account data in "save\athena.txt"

in TXT versions and in the SQL versions in the `global_reg_value`

table using type 3.

...

....

"#" - A permanent local account variable.

They are stored with all the account data in "save\accreg.txt" in

TXT versions and in the SQL versions in the 'global_reg_value'

table using type 2.

quest_step = attached to character

#quest_step = attached to player account

You can find more informations in your doc/script_commands.txt folder

http://svn.rathena.org/svn/rathena/trunk/doc/script_commands.txt

(this link is for rAthena user~)

It all worked! thank you sir :)

I edited the NPC to make another step and i guess i've done it correctly, here is my script:

----edited

I've seen some kind of bug, every time i clicked the NPC for 5x or 4x. The hour for the ( 1 day , 23hours ) just kept on reducing and reducing. Other than that, everything is fine I guess

//	~~~~~ show time left in days, hours, minutes and seconds ~~~~~
function	script	timeleft__	{
if ( ( .@left = getarg(0) ) <= 0 ) return getarg(0);
.@day = .@left / 86400;
.@hour = .@left % 86400 / 3600;
.@min = .@left % 3600 / 60;
.@sec = .@left % 60;
if ( .@day )
	return .@day +" day "+ .@hour +" hour";
else if ( .@hour )
	return .@hour +" hour "+ .@min +" min";
else if ( .@min )
	return .@min +" min "+ .@sec +" sec";
else
	return .@sec +" sec";
}

crystilia,73,73,4	script	try	100,{

if( quest_step == 3 ) goto L_yes3;
else if( quest_step == 2 ) goto L_yes2;
else if( quest_step == 1 ) goto L_yes1;
else if( quest_step > 3 && quest_step > gettimetick(3) ) {
mes "You must wait for "+ callfunc( "timeleft__", ( quest_step - gettimetick(3) ) ) +".";
close;

}

// FIRST STEP
mes "You want to start this quest?";
mes "You need to have this Items:";
mes "10 Jellopies";
mes "10 zRo Coins";
next;
mes "Let me check";
next;
if( countitem(909) < 10 || countitem(20103) < 10 ) goto L_wala;
announce ""+strcharinfo(0)+" has started the Godly quest!",0;
delitem 909,10;
delitem 20103,10;
set quest_step, 1;
close;

// second step
L_yes1:
mes "This is the second step, get me these items";
mes "10 TCG";
mes "10 zRo Coins";
next;
mes "Let me check it again.";
next;
if( countitem(20103) < 10 || countitem(7227) < 10 ) goto L_wala;
delitem 7227,10;
delitem 20103,10;
mes "You receive 1 Emblem of the sun gold!";
getitem 1009,1;
set quest_step, 2;
close;
// 3rd step
L_yes2:
mes "This is the last step";
mes "Bring me these items";
mes "1 Emblem of the Sun Gold";
mes "1 Yggdrasil Berry";
next;
mes "Check!";
next;
if( countitem(607) < 1 || countitem(1009) < 1 ) goto L_wala;
delitem 607,1;
delitem 1009,1;
mes "Congratulations! you receive Godly item!";
getitem 20107,1;
set quest_step, 3;
close;
//final
L_yes3:
mes "This is the last and final step";
mes "Bring me these items";
mes "10 TCG";
mes "10 Yggdrasil Berry";
mes "10 zRO Coins";
next;
mes "Check!";
next;
if( countitem(607) < 10 || countitem(20103) < 10 || countitem(7227) < 10 ) goto L_wala;
delitem 607,10;
delitem 20103,10;
delitem 7227,10;
mes "Congratulations! you receive Godly item!";
getitem 20108,1;
announce ""+strcharinfo(0)+" has finished the Godly quest!",0;
set quest_step, gettimetick(3) + 4 * 86400;
close;

L_wala:
mes "Sorry, please bring those items to me";
close;

}

Edited by Emistry
Please use [CODEBOX] or Attachments for long contents.
Posted

Use codebox

http://rathena.org/board/forum-32/announcement-3-codeboxes/

Well there are some step you didn't understand. I will try to explain.

gettimetick(2) get the server time in seconds. You don't need to change this !

• If you want to set variable to account instead of player, change quest_step to #quest_step

• In

set #quest_step, gettimetick(2) + 3 * 86400;

3 * 86400 seconds means 3 days. It's the delay you wanted before taking the new (same) quest.

Otherwise it seems working.

//    ~~~~~ show time left in days, hours, minutes and seconds ~~~~~
function    script    timeleft__    {
   if ( ( .@left = getarg(0) ) <= 0 ) return getarg(0);
   .@day = .@left / 86400;
   .@hour = .@left % 86400 / 3600;
   .@min = .@left % 3600 / 60;
   .@sec = .@left % 60;
   if ( .@day )
       return .@day +" day "+ .@hour +" hour";
   else if ( .@hour )
       return .@hour +" hour "+ .@min +" min";
   else if ( .@min )
       return .@min +" min "+ .@sec +" sec";
   else
       return .@sec +" sec";
}

crystilia,73,73,4    script    try    100,{

   if( #quest_step == 3 ) goto L_yes3;
   else if( #quest_step == 2 ) goto L_yes2;
   else if( #quest_step == 1 ) goto L_yes1;
   else if( #quest_step > 3 && #quest_step > gettimetick(2) ) {
   mes "You must wait for "+ callfunc( "timeleft__", ( #quest_step - gettimetick(2) ) ) +".";
close;

}

// FIRST STEP
   mes "You want to start this quest?";
   mes "You need to have this Items:";
   mes "10 Jellopies";
   mes "10 zRo Coins";
   next;
   mes "Let me check";
   next;
   if( countitem(909) < 10 || countitem(20103) < 10 ) goto L_wala;
   announce ""+strcharinfo(0)+" has started the Godly quest!",0;
   delitem 909,10;
   delitem 20103,10;
   set #quest_step, 1;
   close;

// second step
L_yes1:
   mes "This is the second step, get me these items";
   mes "10 TCG";
   mes "10 zRo Coins";
   next;
   mes "Let me check it again.";
   next;
   if( countitem(20103) < 10 || countitem(7227) < 10 ) goto L_wala;
   delitem 7227,10;
   delitem 20103,10;
   mes "You receive 1 Emblem of the sun gold!";
   getitem 1009,1;
   set #quest_step, 2;
   close;
// 3rd step
L_yes2:
   mes "This is the last step";
   mes "Bring me these items";
   mes "1 Emblem of the Sun Gold";
   mes "1 Yggdrasil Berry";
   next;
   mes "Check!";
   next;
   if( countitem(607) < 1 || countitem(1009) < 1 ) goto L_wala;
   delitem 607,1;
   delitem 1009,1;
   mes "Congratulations! you receive Godly item!";
   getitem 20107,1;
   set #quest_step, 3;
   close;
//final
L_yes3:
   mes "This is the last and final step";
   mes "Bring me these items";
   mes "10 TCG";
   mes "10 Yggdrasil Berry";
   mes "10 zRO Coins";
   next;
   mes "Check!";
   next;
   if( countitem(607) < 10 || countitem(20103) < 10 || countitem(7227) < 10 ) goto L_wala;
   delitem 607,10;
   delitem 20103,10;
   delitem 7227,10;
   mes "Congratulations! you receive Godly item!";
   getitem 20108,1;
   announce ""+strcharinfo(0)+" has finished the Godly quest!",0;
   set #quest_step, gettimetick(2) + 3 * 86400;//-- 3 * 86400 seconds = 3 days
   close;

L_wala:
   mes "Sorry, please bring those items to me";
   close;

}

Posted (edited)

I've changed it to gettimetick(2) and I guess it works now. 2 * 86400 -> 2 days

so at the last i will change it to:

set quest_step, gettimetick(2) + 2 * 86400;

- Is it possible to set an array after the last quest to randomly give #itemid 607 , 608 , 609?

Use codebox

http://rathena.org/b...nt-3-codeboxes/

Well there are some step you didn't understand. I will try to explain.

gettimetick(2) get the server time in seconds. You don't need to change this !

• If you want to set variable to account instead of player, change quest_step to #quest_step

• In

set #quest_step, gettimetick(2) + 3 * 86400;

3 * 86400 seconds means 3 days. It's the delay you wanted before taking the new (same) quest.

Otherwise it seems working.

//	~~~~~ show time left in days, hours, minutes and seconds ~~~~~
function	script	timeleft__	{
if ( ( .@left = getarg(0) ) <= 0 ) return getarg(0);
.@day = .@left / 86400;
.@hour = .@left % 86400 / 3600;
.@min = .@left % 3600 / 60;
.@sec = .@left % 60;
if ( .@day )
	return .@day +" day "+ .@hour +" hour";
else if ( .@hour )
	return .@hour +" hour "+ .@min +" min";
else if ( .@min )
	return .@min +" min "+ .@sec +" sec";
else
	return .@sec +" sec";
}

crystilia,73,73,4	script	try	100,{

if( #quest_step == 3 ) goto L_yes3;
else if( #quest_step == 2 ) goto L_yes2;
else if( #quest_step == 1 ) goto L_yes1;
else if( #quest_step > 3 && #quest_step > gettimetick(2) ) {
mes "You must wait for "+ callfunc( "timeleft__", ( #quest_step - gettimetick(2) ) ) +".";
close;

}

// FIRST STEP
mes "You want to start this quest?";
mes "You need to have this Items:";
mes "10 Jellopies";
mes "10 zRo Coins";
next;
mes "Let me check";
next;
if( countitem(909) < 10 || countitem(20103) < 10 ) goto L_wala;
announce ""+strcharinfo(0)+" has started the Godly quest!",0;
delitem 909,10;
delitem 20103,10;
set #quest_step, 1;
close;

// second step
L_yes1:
mes "This is the second step, get me these items";
mes "10 TCG";
mes "10 zRo Coins";
next;
mes "Let me check it again.";
next;
if( countitem(20103) < 10 || countitem(7227) < 10 ) goto L_wala;
delitem 7227,10;
delitem 20103,10;
mes "You receive 1 Emblem of the sun gold!";
getitem 1009,1;
set #quest_step, 2;
close;
// 3rd step
L_yes2:
mes "This is the last step";
mes "Bring me these items";
mes "1 Emblem of the Sun Gold";
mes "1 Yggdrasil Berry";
next;
mes "Check!";
next;
if( countitem(607) < 1 || countitem(1009) < 1 ) goto L_wala;
delitem 607,1;
delitem 1009,1;
mes "Congratulations! you receive Godly item!";
getitem 20107,1;
set #quest_step, 3;
close;
//final
L_yes3:
mes "This is the last and final step";
mes "Bring me these items";
mes "10 TCG";
mes "10 Yggdrasil Berry";
mes "10 zRO Coins";
next;
mes "Check!";
next;
if( countitem(607) < 10 || countitem(20103) < 10 || countitem(7227) < 10 ) goto L_wala;
delitem 607,10;
delitem 20103,10;
delitem 7227,10;
mes "Congratulations! you receive Godly item!";
getitem 20108,1;
announce ""+strcharinfo(0)+" has finished the Godly quest!",0;
set #quest_step, gettimetick(2) + 3 * 86400;//-- 3 * 86400 seconds = 3 days
close;

L_wala:
mes "Sorry, please bring those items to me";
close;

}

Edited by Yudax

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...