Jump to content
  • 0

Beginner Quest NPC Scripting - Guidance needed


BMythes

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  04/15/17
  • Last Seen:  

Hey, I'm new to this forum and to scripting in general, so nice to meet everyone, and hope you're forgiving with mistakes!

I'm writing a script for a friend's server, but I'm new at this (programming in general actually), so I'm having a hard time... I've read rAthena script commands manual thoroughly, although it still gives us beginners a hard time...

Anyway, I'm trying to script a NPC which gives out quests depending on your level. These quests would be one-shots (so you could only do them once on every level gap) and the NPC would have a unique text for the first time you speak to them.

I'm not requesting a full script, but a little push in the right direction, that is, where to start...

I already have the level branches scripted in the form of:

if (BaseLevel < 50) {
                   }
else {
	if (BaseLevel < 80) {
	}
			
	else {
		if (BaseLevel < 100) {
		}
				
		else { //= Base level above 99, e.g. 100+
		}
		

There is probably an easier way to do this, but as stated above, I'm a beginner. I think I could use the baselevel data as an integer and make it match between values to call up different quest levels... But anyway...

If anyone can help me out, I'd be glad to learn.

If anything seems confusing or out of order, let me know.

 

Best regards,

BMythes.

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   84
  • Joined:  08/11/12
  • Last Seen:  

Quote

Anyway, I'm trying to script a NPC which gives out quests depending on your level. These quests would be one-shots (so you could only do them once on every level gap) and the NPC would have a unique text for the first time you speak to them.

So let's break-down these requirements

1. gives out quests depending on your level

if (BaseLevel < 80) {
   mes "You are less than level 80";
   //put quest stuff here
}
else if (BaseLevel <= 99) {
   mes "You are less than or equal to level 99";
   //put quest stuff here
}
else {
   mes "You are more than level 99";
   //put quest stuff here
}
close

2. quests would be one-shots

if (CharHasTakenThisQuest == 1) {
   mes "You have already taken this quest";
   close;
}

3. would have a unique text for the first time you speak

if (CharHasAlreadyTalkedToMe == 0) {
   mes "Hey! This is the first time we've talked!";
   set CharHasAlreadyTalkedToMe, 1;
}

Putting these together would look something like

prontera,150,150,5	script	ThisSampleNPC 63,{
  if (CharHasAlreadyTalkedToMe == 0) {
     mes "Hey! This is the first time we've talked!";
     set CharHasAlreadyTalkedToMe, 1;
  }
  if (CharHasTakenThisQuest == 1) {
     mes "You have already taken this quest";
     close;
  }

  if (CharQuestIsInProgress == 1) {
      //validation of quest
  }

  if (BaseLevel < 80) {
     mes "You are less than level 80";
     //put quest stuff here
  }
  else if (BaseLevel <= 99) {
     mes "You are less than or equal to level 99";
     //put quest stuff here
  }
  else {
     mes "You are more than level 99";
     //put quest stuff here
  }
 
  close;
}

This may not be as clean but more or less it'll look like this.

I'll leave the creation and validation of quests to you :)

Edited by Ninja
  • Upvote 1
Link to comment
Share on other sites

  • 1

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   84
  • Joined:  08/11/12
  • Last Seen:  

1. Temporary variables are freed up once you finish talking to with the npc.

2. All variables(whether temporary or not) can be set and unset manually

3. Your logic is correct regarding #var and ##var

4. Your logic is correct regarding use cases of these variables

:)

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   84
  • Joined:  08/11/12
  • Last Seen:  

If I may suggest on how you should start doing everything, I suggest that you'd use the usual path in learning programming in general.

Start with these in sequence:

  1. Hello World (Your first script even without knowing anything just making the script work)
  2. Basic script structure
  3. Different types of Variables
  4. Conditional Statements (If-statements vs switch-statements)
  5. Looping Statements (While-loops vs For-loops)
  6. Timers
  7. rAthena specific stuff
    1. Mapflags
    2. Monster Spawns
    3. Instances
    4. Warps
  8. Coding best practices (Formatting, spacing, etc.)
  9. A whole lot of reading through the script_commands.txt of rAthena
  10. A whole lot of practice

As for your script,

It is also important that you come up with test data when you create something, hence, approaches in developments were made (i.e. test-driven development, data-driven development, etc.).

Just my piece of advice. Feel free to have it your way :)

 

Edited by Ninja
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  04/15/17
  • Last Seen:  

Hey Ninja,

Thank you for your answer. I know the basic of scripting, as I scripted WC3 before, and I have intermediate knowledge of HTML5. So I have experience in learning it... I'm just having a hard time pretty much. Can you give me some pointers towards quest making in rAthena?
As in, how to start the one I've asked on this thread?

Thanks =)

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  04/15/17
  • Last Seen:  

Number 3 was the one I was having a hard time figuring out... It's a bit different from what I was used to coding.

 

Thank you so much!

 

Hey I just want to be sure on something...

So, if I define the CharHasAlreadyTalkedToMe with a @, $ or .   , they result in the following:

@CharHasAlreadyTalkedToMe = it's temporary, so only valid for this character and will be deleted (I just didn't get WHEN it will be deleted. As soon as NPC stops talking? Or other condition?)

$CharHasAlreadyTalkedToMe = It's global and permanent, so every other player on the server will have the same variable when they talk to the NPC.

.CharHasAlreadyTalkedToMe = Valid for the NPC and resets when NPC is reloaded / when server is reloaded.

 

If the above is correct, I think I have those kinda figured out... My two questions would be:

1 - The difference between #{variable} and ##{variable}. One is stored local, the other global. So, that means, one is stored for the account and the other one for the server?

2 - Follow my logic and tell me if it's flawed: if I want the character to be able to do the quest only once, I can just set the Variable to X, and have the NPC check for Variable =/= X to be able to do the quest. If I want the quest to be doable ONLY ONCE per ACCOUNT, I have to set the #Variable to X and have the NPC check for #Variable =/= X. If it's only doable once per SERVER, ##Variable set to X, and NPC checks ##Variable =/= X.


Thanks!

Link to comment
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.   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.

×
×
  • Create New...