How to make a warp..?
Displaying 1-12 of 12 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Scooter7

Hey all, I was wondering what code I could use to make a warp (for example if the player enters a building he/she will be transferred to the map for that building). I looked in the code for Rysen's Ranch, and found this:

void ToTown()
{
AtRanch=FALSE;
CircleOut(100);
Warp(159,57);
if(!IsRaining)
{
MusicFade2(100);
PlayMusic("Music/town.ogg");
SetMusicVolume(MusicVolume);
}
//PlayMusic("Music/Town.ogg");
CircleIn(100);
}


I suppose all I really need is the Warp bit.. however it's not mentioned in any other vc file.. so how do I properly make a warp? I know there's obviously many ways to do it (possibly), but if someone could at least point me in the right direction... thanks. :)

Posted on 2006-06-22 18:21:27

Overkill

My suggestion:
void Warp(int tx, int ty, int ent)
{
entity[ent].x = tx * 16;
entity[ent].y = ty * 16;
}
Rysen Ranch (starting at line 333 of basic.vc)
void Warp(int x, int y)
{
entity.x[player]=x*16;
entity.y[player]=y*16;
}

void WarpEnt(int x, int y, int ent)
{
entity.x[ent]=x*16;
entity.y[ent]=y*16;
}

Posted on 2006-06-22 18:42:53 (last edited on 2006-06-22 18:46:55)

Scooter7

k, thx... guess I didn't notice basic.vc O_o

Posted on 2006-06-22 20:12:58

Scooter7

Okay, this is kind of a stupid question... how exactly do I use your suggestion? Where do I put it? tutorial.vc (my map), or system.vc? Remember, I'm a total noob at VergeC. And the only way to learn is to ask questions, right? :)

Posted on 2006-06-23 18:17:27

Overkill

You'd put it in system.vc. Anything that isn't a specific map event should go in system.vc. Even then, some map events that are reused a lot (like say, opening a door) should be put in the system code as well. Warp() is general purpose, and thus it's better to declare it in there.

Posted on 2006-06-23 20:47:37 (last edited on 2006-06-23 20:49:01)

Scooter7

Um, okay, but then what? How do I specify what map I want the player to warp to? And how to I call the warp event? I assume I have to do something in my map.vc (map being the name of the map) file, but what? I might have a general idea, but.. not one good enough to get this to work.

Posted on 2006-06-24 10:29:43

Overkill

You'd then be able to call my function like this in your map's event script:
// Warp the player to (3, 5) on the map.
Warp(3, 5, player);

Posted on 2006-06-24 10:33:07 (last edited on 2006-06-24 10:33:24)

Gayo

It sounded like you just wanted to move the character to a different spot on the same map (designers usually put the building interiors on the same map as the "outside" town). If you want to change the map and start the character on a specific spot in that map, it's significantly trickier. You can't put the character where you want him to go in the same block of code, because calling map() halts the flow of code. So what do you do? Well, this is the tricky part...

Every V3 map has a function that's executed when it loads. If you're using maped3 (and I guess you must be), you can find this under Map --> Properties. Set "startup script" to some function you want to call when the map loads (without the parentheses following the function name). It has to be a function with no parameters, but it can be from either system.vc or the map vc file. Now, if you always know where the player is going to appear when the map loads you can just stick him there in the startup function. I'd recommend something a little more advanced, however.

Are you putting the player chr on your map in maped, or generating it using EntitySpawn? I guess you're doing the former, but whatever, this works either way:

What you do is something along these lines. Have two global ints, named something like and "newmap_x", "newmap_y". Before you do the mapswitch you set these to where you want the player to go on the new map. Then in the map's startup script you call some map-initialization function, which contains a block of code like this:


// spawn hero entity and set him as player
SetPlayer(EntitySpawn(newmap_x, newmap_y, "darin.chr"));


...or if you already have a player entity set down, you'd set him as player move him to the right place using something like Overkill's code.

Setting the x/y vars each time you do a mapswitch could get a bit annoying, so (assuming you used this method) you might also define a custom mapswitch function along the lines of:

SexyMapSwitch(string mapname, int xc, int yc) {
newmap_x = xc;
newmap_y = yc;
// Some kind of sexy fadeout could go here!
Map(mapname);
}

Posted on 2006-06-24 23:06:12 (last edited on 2006-06-24 23:07:39)

eltimo

I'm also struggling creating a warp.
I am working from v1_rpg by vecna and the code in my map.vc is:

void endofgame()
{
// Warp the player to (3, 5) on the map.
Warp(3, 5, 1);


This should spawn the player at 3,5 and use a fade out. The fade out function works but there is no actual warp. It just fades out.

Posted on 2006-06-30 11:16:30 (last edited on 2006-06-30 11:17:07)

Overkill

Quote:Originally posted by eltimo

I'm also struggling creating a warp.
I am working from v1_rpg by vecna and the code in my map.vc is:

void endofgame()
{
// Warp the player to (3, 5) on the map.
Warp(3, 5, 1);


This should spawn the player at 3,5 and use a fade out. The fade out function works but there is no actual warp. It just fades out.


Uh... Are you SURE entity index 1 is the player? If not, that'd explain the lack of anything happening. Warp() could use better error reporting to tell you if you're accessing an out-of-bounds entity index.

Posted on 2006-06-30 17:23:08

eltimo

its not the entity index, its the effect

Posted on 2006-07-03 15:15:15

Overkill

...Okay, so wait, what? The fade effect isn't happening? Well, looking at that code snippet, you don't even call a fade function.

Posted on 2006-07-03 15:56:41


Displaying 1-12 of 12 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.