|
Entity Talking
VC has a lot of funky concepts that might be hard to understand at first glance, so you might be sitting there, staring at the glowing phosphorus before you, wondering "So... how do I make somebody say something?" Try this, for a quick start. I'm assuming you have all the VERGE stuff already downloaded, that you know how to create entities in MapEd, (and see their properties) and that you know how to use a text editor.
Okay... first off, open up MapEd, and click on an entity. If you haven't created one yet, hit 'E' to switch to entity mode, then click where you want the entity to go. Make sure that these things are set:
Is obstruction (so that the player and other entities can't walk over this one)
Obstructable (so that this entity can't walk over walls and other entities)
If you're creating a new entity now, you should also put a CHR in the CHR list (see the button?) and set the "CHR" property to correspond to the slot where you put the CHR. (this is covered more in-depth in other articles here on the Source)
Make sure that the "act" property is set to a number higher than 0. For the sake of this example, set it to 1. This number refers to the event in your map VC. So, when you talk to this fellow, VERGE will execute event 1. It's important to note that the first event in the VC file is actually event #0, and it's special, so we'll skip over that one and use #1. :)
Now... code! woohoo! Unfortunately, VC doesn't have a built-in text box script, but here's a quickie, just for fun. (put this in system.vc) Note that everything after the slashes (//) is a comment, and ignored by VC.
void DrawBox(int x1,int y1,int x2,int y2)
{
RectFill(x1,y1,x2,y2,128); // just draws a grey (or in hicolour, almost black) box
}
void Text(string line1,string line2,string line3)
{
Unpress(0); // make sure none of the keys are down
while (!b1) // we want this loop to execute over and over until the player hits the enter key
{
Render(); // draw all the tiles and entities
FillRect(0,0,screenx,fontheight(0)*3); // draw a big text box at the top of the screen. Make it the whole screen wide (screenx), and as wide as 3 lines of text. (fontheight*3)
GotoXY(0,0); // move the text cursor to the upper left
printstring(0,line1); // woohoo! finally!
GotoXY(0,fontheight(0)); // move the text cursor one line down, and all the way back to the left
printstring(0,line2);
GotoXY(0,fontheight(0)*2); // one more line down :)
printstring(0,line3); // yay!
ShowPage(); // make sure the player can see what we've done
UpdateControls(); // this updates b1 (so the loop ends ^_^)
}
Unpress(0); // make sure the player releases enter before we're done
}
Yay! Almost done! You can now, anywhere in your VC, call up the user function "Text". Like so: Text("Heya!","What's up?","");
Note that it expects three strings, so make sure to give it just that! If you only need two lines, just add "" as a string, and VC will be happy with that. :)
Now, for the map vc. It's name is the same as the map, except with a different extension. So, if your map is called TEST.MAP, then you should be opening up TEST.VC right about now. :)
Skip event #0 and put one more underneath it. If you don't have an event 0, then put it in.
Event // #0 - skip this if you've already got one
{
SetPlayer(EntitySpawn(10,10,"person.chr")); // make sure you replace person.chr with a chr that you actually have.
}
Event // #1 - Talkin' to some random peasant
{
Text("Wassap mah homeeeeeeeeez!","Don't be a Menace to South Central While You're Drinkin' Your Juice in the Hood!","");
}
In Closing
Would you believe that that's it? Yeah, I know that looks like a buttload of work, but it gets easier as you get used to it. :)
If you want to have more entities say things, then add more events, and set the "activation" property in the entity editor in MapEd to point to the correct script.
|