Exploring System

Forum
Last Post
Threads / Messages

PTGigi

Crazily Friendly~HoF
Premium Member
Joined
Jul 17, 2009
Messages
363
Points
0
Age
29
Location
Somewhere >.>
Mysidian Dollar
15,125
EDIT (5/23/12) I am no longer updating this (seeing as I no longer am working on MM2+). But please note this tutorial is apparently outdated and may not work properly with the main script without lots of extra work.

Alright, so since MM2+ is heavily explore based I have to do this a lot XD So I figured I'd post up a tutorial to maybe help some people make their own systems! Now note:
MY EXPLORE SYSTEM IS NOT 100% COMPLETE

Thus, I will be posting this information as I go through.

Also:
I'm going to assume each part is long and will go over the limit per post (because my code kindly already does this XD) And it'll be easier to see each separate part. :D EDIT: Actually I just tested, it wouldn't go over this magical limit (hopefully) but it'll make it easier so I can link to the second/third post to save you the scrolling :3 The three parts of this tutorial will be:
-'Simple' NPC interactive with user-Complete
-Exploring, finding, seeking, etc-Nearly done
-Extra stuff (finding something, interacting with the environment, getting a new adoptable, etc, etc)-Not started? IDK

So now for PART 1!!!


Part 1--NPC Interaction

Your user is stuck in the randomness of empty space of the internet OH NO!!! But wait! There's a random person here too! Oh! IT'S AN NPC *shot*

NPC stands for Non-Person-Controlled. Basically it's a character who is not controlled by you, but can still interact (or not?) with their environment given user input.

So now we need some information before we make our code. We need to make this NPC. Here's some things to keep in mind:

-Name-
Seriously, you need one. Unless it's some random dude who wears a cloak (not a Mewtwo reference) who you don't know who it is you can not have a name. But otherwise make a name. You could do something common like Bob, or Mary, or Chris, or Susan or something, so do something epical like Huyji, Frezro, etc. Also feel free to make up based upon stuff, like if you have a fire lizard go ahead with Char, Blaze, Fiora, etc as a name :3
-Species-
Is it a human? Is it a talking dog? Is it some magical made up creature? Make sure people know (images can do good or a quick discrete description)
-Looks-
whether you character looks like you might want to make clear so the user can visualize the situation. (Images are good once again). Maybe the person is tall and looms over peeps, maybe they're really small so you have to pick them up in your hand to speak to them.
-Speech-
How do they talk? Do they use proper grammar? Do they use slang? What about accents? Or occasionally shifting to their native language. NOTE: Under no means use chatspeak! It looks VERY unprofessional...
Here's some quick examples (all the same saying just different ways of saying it):
"Hello there!"
"Hiya!"
"Well hello there!"
"Howdy!"
"Hola!"
"Welcome stranger!"

And so on! If I can make one phrase in 6+ different ways you can make your characters speeches the same!

Now that we got our speech complete maybe we begin coding! But you need to plan! Where are these/this people/person? Are they in a snowy field, a volcano, a jungle?

For the sake of this example we'll be in a magical forest (shush). In this magical forest there are mysteries, so what would someone do in a new place? Ask for help!

Now we begin coding!

Part 1b--Beginning the code

So what you need to do is find a file in your main folder called "blank.php". On your computer, right click the file and go down to copy (yours might have a duplicate button, IDK), after you've copied it right click again (not on a file, on a blank space in your folder) and hit 'paste'. Your pasted document should be called "blank copy.php" If not it'll ask you to rename it or change it's name to "blank (2).php". Either way just accept that. Now rename your file to something you can remember, I suggest not 'explore.php' since you might want more explore areas. For this example we'll be using a fake file called "forest.php".

Now open up your file and go down to "Output to user". Underneath that we'll begin our quest! But first paste in:
PHP:
$act = $_GET["act"];
$act = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $act);
$act = secure($act);

$num = $_GET["num"];
$num = preg_replace("/[^a-zA-Z0-9\\040.]/", "", $num);
$num = secure($num);
Act is for the action, and Num is for speech (you'll see in a bit)

Now we can't just throw ourselves into a conversation! Introduce the area, what do you see?
So now we add:
PHP:
if ($act == ""){
$article_title = "Magical Forest!";
$article_content = "You find yourself in a Magical Forest. Many small   dragons dance about in the sunlit air (blah, blah, add more  description,  don't take mine please) Oh look a dragon! It seems  friendly want to go  talk to it?<br><br>
<a href='/forest.php?act=talk'>Talk to the dragon!</a><br>
<a href='/forest.php?act=enter'>IGNORE FOR NOW (part 2)</a>";
}
So the $act == "" is just saying when nothing is defined. But wait! My first link has defined an $act for us! It's called 'talk'.

So we need to define this conversation, but we don't just jump right in! We need to introduce the situation :OHSHITALION:

So in order to do that we must define $act == talk! Let's do that now:
PHP:
else if ($act == "talk"){
$article_title = "Talking";
$article_content = "You head over to take to the dragon, but as you do   so another dragon and a puppy come over as well. 'Hello there!' shouts   the purple, serpentine female dragon, 'Can we help you with something?   My name is Lavendra, and this is my mate Kyto. That's Fluffy.'  She  says  this while pointing to the dragon first, then the puppy. She  smiles at  you and waits for a response. The orange male watches you,  not sure if  he trusts you. The puppy honestly doesn't care and is just  rolling  around in the grass.<br><br>
<a href='/forest.php?act=lavendra&num=0'>Talk with Lavendra</a><br>
<a href='/forest.php?act=kyto&num=0'>Talk with Kyto</a><br>
<a href='/forest.php?act=fluffy'>Pet Fluffy</a><br>
<a href='/forest.php?act=enter'>IGNORE FOR NOW (part 2)</a>";
}
So now we add even more areas we need to define! We have two characters to speak with, and a single character to interact with! The bottom link is for those people who want to explore but we're not there yet :happyfaic:

So the conversation for Lavendra and Kyto is exactly the same, excluding what they say exactly and how they say it. Since they are the same I'll walk you through Lavendra and assume you can do others as well after this :meow:

So now we start with a simple definition of $act == lavendra and $num==0:
PHP:
else if ($act == "lavendra"){
$article_title = "Lavendra";
    if ($num == "0") {
    $article_content = "Lavendra: 'What can I do for you?'<br><br>";
    }
    else {
    $article_content = "Lavendra: 'I'm sorry I don't understand, what can I do for you?'<br><br>";
    }
    $article_content = $article_content."<a href='/forest.php?act=talk2'>You: 'Nevermind.'</a>";

}
Now you see the two extra elements I added? Since the 'greeting' is in 0 and we are defining conversation by number, what if the user wants to be sneaky or an error occurs and a wrong number is entered? Just make the character not understand.

The last bit is to end the conversation, you need this so you can...well...stop talking XD You see it's called 'talk2' I'll explain that in a second. :meow:

But that's boring, a simple "How can I help you" then stop talking? No! We need to talk! Let's now define a question, how about we ask them about Kyto? He's an interesting guy.
PHP:
else if ($act == "lavendra"){
$article_title = "Lavendra";
    if ($num == "0") {
    $article_content = "Lavendra: 'What can I do for you?'<br><br>";
    }
    else if ($num == "1"){
    $article_content = "Lavendra: 'Oh Kyto? He's my mate!' She smiles at   this, 'We've been together for over one hundred years. I've heard this   is a long time for you humans. He isn't very human-friendly though, he   was attacked as a child you see...Anyway, can I help you with  something  else?'<br><br>";
     }
    else {
    $article_content = "Lavendra: 'I'm sorry I don't understand, what can I do for you?'<br><br>";
    }
    if ($num != "1"){
    $article_content = $article_content."<a   href='/forest.php?act=lavendra&num=1'>You: 'Tell me about   Kyto.'</a><br>";
     }
    $article_content = $article_content."<a href='/forest.php?act=talk2'>You: 'Nevermind.'</a>";

}
Right, so now I've added in two key areas. We've added in the conversation about Kyto and a link to this conversation. Now you may have noticed the "if ($num != "1") " around the Kyto question link. This is because we do not want to re-ask the question we are on! So if we are on 'num=1' we do not want a link for 'num=1'. For those who did not know != means 'does not equal'. :meow:

Now we can add as many more topics as we want! Just remember to make a link to each one and make each a new number. So here's our example again after adding some more!

PHP:
else if ($act == "lavendra"){
$article_title = "Lavendra";
    if ($num == "0") {
    $article_content = "Lavendra: 'What can I do for you?'<br><br>";
    }
    else if ($num == "1"){
    $article_content = "Lavendra: 'Oh Kyto? He's my mate!' She smiles at   this, 'We've been together for over one hundred years. I've heard this   is a long time for you humans. He isn't very human-friendly though, he   was attacked as a child you see...Anyway, can I help you with  something  else?'<br><br>";
     }
    else if ($num == "2"){
     $article_content = "Lavendra: 'Fluffy is the cutest, lil' puppy   ever! And that's all you need to know! Can I help you with something   else?'<br><br>";
      }
    else if ($num == "3"){
     $article_content = "Lavendra: 'This forest is a MAGICAL forest.   Serious, what more do you need to know than that?...Anyway, can I help   you with something  else?'<br><br>";
      }
      else {
    $article_content = "Lavendra: 'I'm sorry I don't understand, what can I do for you?'<br><br>";
    }
    if ($num != "1"){
    $article_content = $article_content."<a   href='/forest.php?act=lavendra&num=1'>You: 'Tell me about   Kyto.'</a><br>";
     }
    if ($num != "2"){
     $article_content = $article_content."<a   href='/forest.php?act=lavendra&num=1'>You: 'Tell me about  Fluffy.'</a><br>";
      }
     if ($num != "3"){
     $article_content = $article_content."<a   href='/forest.php?act=lavendra&num=1'>You: 'Tell me about this  forest.'</a><br>";
      }
     $article_content = $article_content."<a href='/forest.php?act=talk2'>You: 'Nevermind.'</a>";

}
There, now we see a bit more of the world beginning to develop! You can add as much conversation topics as you want too. You can also add follow-up questions by setting the "if ($num == "#")" the # being the number of the conversation you are responding to :meow:

Once again you can add as many characters as you want interacting in this fashion. The only thing you need to change is the "else if($act == "name")", "$article_title", and the actual answers.

But what about a non-speaking NPC who just reacts? Like say...A PUPPY!!! :OHSHITALION: What if we want to go ahead and pet the cute puppy! Well let's do that shall we?

Part 1c-Petting The Puppy (etc)

Now if you remember our talk page one of the links was Pet Fluffy! (see the third link?):
PHP:
else if ($act == "talk"){
$article_title = "Talking";
$article_content = "You head over to take to the dragon, but as you do   so another dragon and a puppy come over as well. 'Hello there!' shouts   the purple, serpentine female dragon, 'Can we help you with something?   My name is Lavendra, and this is my mate Kyto. That's Fluffy.'  She  says  this while pointing to the dragon first, then the puppy. She  smiles at  you and waits for a response. The orange male watches you,  not sure if  he trusts you. The puppy honestly doesn't care and is just  rolling  around in the grass.<br><br>
<a href='/forest.php?act=lavendra&num=0'>Talk with Lavendra</a><br>
<a href='/forest.php?act=kyto&num=0'>Talk with Kyto</a><br>
<a href='/forest.php?act=fluffy'>Pet Fluffy</a><br>
<a href='/forest.php?act=enter'>IGNORE FOR NOW (part 2)</a>";
}
Now you should notice something right away. There is no "&num=0". This is because it is not necessarily needed. If you want to add more interactions once you select to interact with the puppy just follow the above but paste in our finished code (excluding the $num !=)

So first we need to define the actual subpage of our puppy:
PHP:
else if ($act == "fluffy"){
    $rand = rand(0,1);
    $article_title = "Fluffy";
    if ($rand == 0){
    $article_content = "Fluffy just keeps rolling on the grass and ignores you.";
    }
    else if ($rand == 1){
    $article_content = "Fluffy lets you pet him. He barks happily while you do so.";
    }
    else {
    $article_content = "Fluffy completely ignores you and walks away.";
    }
    $article_content = $article_content."<br><br>
    <a href='/forest.php?act=fluffy'>Pet Fluffy again</a><br>
    <a href='/forest.php?act=talk2'>Stop petting Fluffy</a>";
}
Now you'll see I actually just finished the whole code for you! Shocking isn't it? Now what do we have here? Well I'll explain.

First, you are defining to new subpage of Fluffy. Fluffy is subpage worthy :OHSHITALION:

Secondly, you are defining a rand number with this statement:
PHP:
     $rand = rand(0,1);
This specific statement will create a random number between 0 and 1 (ie, 1 or 0) and make the variable $rand equal that number.

Next we define the article title, pretty boring? XD

Fourth, we are defining all the random actions this puppy could do. For simplicity I only added 3. The first two are actions the puppy does while the 3rd is just in case of an error we have our backs covered.
PHP:
    if ($rand == 0){
    $article_content = "Fluffy just keeps rolling on the grass and ignores you.";
    }
    else if ($rand == 1){
    $article_content = "Fluffy lets you pet him. He barks happily while you do so.";
    }
    else {
    $article_content = "Fluffy completely ignores you and walks away.";
    }
And at long last we end with an option to continue petting this cute bundle of fur or to just stop. (the <br><br> right after our random action is to prevent the first link from latching onto the end of our random paragraph)

NOTE: When working with random outcomes it's always good to keep in mind a couple times.
1) The less options you have the higher chance of a repeat. Since I only have two that chance is extremely high.
2) Every time you add a new outcome MAKE SURE to change the second number in the $rand to be equal to that of your highest number, that'll make sure all your options work.

Now you may ask: Are we done now? NO! We still have to make the 'talk2', 'talk3' and 'enter' work!

Part 1d-Talk2, Talk 3, and Enter

Okay, so now we have already defined links for 'talk2' and 'enter', but what are these exactly? We'll begin with Talk2 and Talk3.

Now if you remember 'talk' is when we first met these dragon, we don't know who they are, we just got there. But after chatting with them you do know them a bit better, also they'll be standing there and not walking into the picture.

'talk2' is just like 'talk' because it lists the people you can converse with but it changes the $article_content because the people are already there and we know them a bit better. So just to put simply your talk2 should look a bit like:
PHP:
else if ($act == "talk2"){
 $article_title = "Talking";
 $article_content = "After chatting, you turn back to the main group.  Fluffy is just rolling around at the feet of Lavendra and Kyto, while  those two both watch you. What will you do?<br><br>
 <a href='/forest.php?act=lavendra&num=0'>Talk with Lavendra</a><br>
 <a href='/forest.php?act=kyto&num=0'>Talk with Kyto</a><br>
 <a href='/forest.php?act=fluffy'>Pet Fluffy</a><br>
 <a href='/forest.php?act=enter'>IGNORE FOR NOW (part 2)</a>";
 }
See? easy! Just like before!

But now you must wonder why we need ANOTHER talk. 'talk3' is for when you return from your valiant exploration!

PHP:
else if ($act == "talk3"){
 $article_title = "Talking";
 $article_content = "You come back from exploring to find the group in the same place. What will you do?<br><br>
 <a href='/forest.php?act=lavendra&num=0'>Talk with Lavendra</a><br>
 <a href='/forest.php?act=kyto&num=0'>Talk with Kyto</a><br>
 <a href='/forest.php?act=fluffy'>Pet Fluffy</a><br>
 <a href='/forest.php?act=enter'>IGNORE FOR NOW (part 2)</a>";
 }
And there! Done! Easy right?

But what is this 'enter'? Why is it so special? Well that actually has to wait for part 2 XD

BUT! Keep thinking of a few things!

-What areas are there to explore? Yeah, yeah it's a forest, but what's IN the forest? Maybe a thicket, maybe deeper in the forest, maybe a stream, or whatnot! These 'subareas' will be defined in part 2, as well as what you can find/interact with while exploring!
-What can you find? Pets, items, money, nothing, new areas, etc! And yes I just stated everything I will cover XD (note: items is not, item items, because I do not know that YET. It's just items as in OMG I FOUND A BOTTLE *action**action**action*)
-How can you interact with your environment?
-What does the landscape look like? Yes, you'll need to make images for part 2
-How should the page be set up? More will come later but basically it'll have an Event, an Image, and a Description of the Event.
 
Last edited:
<post saving section for part 2--Exploring-exploring> :meow:

Gah sorry for taking so long D: Okay before we start please note, I'm sure there is a faster and more efficient way to do whatever I post and you may happily do that! (ie iframes for whatnot) But as Gigi I tend to find a simple, yet effective way to do things XD Also I tend to find a way that involves a lot of rand(); I love random stuff 8D

Being worked on

-Random Search System
-Finding and gaining Money (works with multiple currencies)
-Finding random 'items' (not item-items, but stuff you can interact with)
-Finding nothing (durr easy XD)
-Finding a new path
-Multiple areas within one area (i.e. Within the magical forest a stream area, a mushroom area, and maybe just a deeper part of the forest)
-Background image for location
-Overlayed image for the event (i.e. a pile of coins or an adoptable or whatnot on top of your image of the background for the location)
 
Last edited:
<post saved for part 3--Extra add-ons> :BIGO:

Will/Might include:
-Design of Explore Page
-Save Points
-Quest Log
-Adventure ideas?
-Riddles
-Guest Block
-Area Block
-Pet Block (?)
-Possible 'Mini' battles (not full since I haven't gotten there yet X3)
-Possible page redirect for when you FAIL :OHSHITALION:
-Possible change of images by time of day (yeah I like this time of day stuff from my Javascript-ness :ooo:)
-Possible Random bg images
-Different style of exploring (just the look of the page, nothing massive)
 
Last edited:
Thank you :D

Hopefully I can get more done in the next couple days but with midyear exams it might be hard D:
 
I was pretty sure NPC stood for Non-Player-Character... I guess its the same principle just a different word

Looks good, btw, I'd like to see more :D
 
Oh really? I thought it stood for Non-Person Controlled [Character] X3 Lolz but you're right it's the same thing XD

Thank you both of you :D I do hope it helps ^-^ The second part should be the most helpful X3
 
Thank you :D

Okay, I am ALMOST done with my explore system. Though me being me I just doubled my work by wanting to add a whole new area >.> So....IDK XD

When I go to type up part 2 that might take me 1-2 days because I have a MASSIVE chunk of code to sort through and attempt to explain XD I expect this to go over 2,000 lines (though lines don't mean much it just means it's A LOT ._.)
 
This is gonna be really helpful, thank you so much for writing it Gigi. Cant wait to see the second and third part of this tutorial. I'd like to suggest the usage of Iframe though, since it allows an NPC to 'speak' to you with a textbox shown on the same exploration page instead of opening a new one.
 
@HoF- Never heard of IFrames :O I'll have to try that out sometime :usedusedused: Though I really should finish this first XD

@Elf-Thank you :meow:

@Other Peeps--ALMOST DONE! XD I just am doing a bit more work. NOTE: This code is LONG o_O Lol, I just hope I can explain it all properly XD Also note I love 'rand' Random is the best XD
 
Well Iframes are useful if you do not wish to direct users away from the current page after they click on an NPC. Here's an example of how Clover used Iframes on her pokemon fansite:

http://www.sweetcharm.net/PokemonSite/Museum/museummain.html

Also I wonder how you make it possible for users to click on an NPC to speak with them. Mind explaining a little bit more of this?
 
OMG That's cool :BIGO: I am definately going to check that out X3

Well for my original method it just lists out the characters in the current area. (you can also be a bit more stealthy with it than "Talk to ____" if you need to, I believe for one of my pages it describes the area and when there is something of interest there is a link on the object's name). If you use that Iframes thing I'd assume you either make links or an image map type thing. I got to work with it more XD

I'll throw up my explore area as an example when I finish it :smile: That may help out more :meow:
 
umm I am afraid this is considered necro-posting? The OP hasnt visited this support forum for months, and its better for her to update this thread herself when she has a chance.
 
Oh, okay. ^^ Sorry about that then. I don't really pay attention to dates, not sure why.
 
First off, I LOVE this code, but I have a little bit of a question --

I tried to imput the whole code, and it wouldn't work, but I did not have an 'output to user' code in my actual file. Is this a problem, or would I have to add this to the actual code to get it to work?
 
I haven't been here for awhile so I don't know what's changed D: I assume that page has been removed?

Also I lost my files for this so I can't finish this D': Sorry!
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,280
Messages
33,130
Members
1,603
Latest member
Monako
BETA

Latest Threads

Latest Posts

Top