PDA

View Full Version : Gmap


Jeffyy
12-27-2007, 08:29 PM
Is it possible to make 2d images or flowers and trees lay randomly over a 2d gmap? If it is can anyone explain to me how?

Angel_Light
12-27-2007, 08:36 PM
have you read the levelgenerator tutorial/doc yet?

Jeffyy
12-27-2007, 08:40 PM
Yes, I generated a g map with mountains and everything, im talking about images though not tiles.

Angel_Light
12-27-2007, 09:09 PM
oh, no, there no way to automatically add NPC's (Images)

Jeffyy
12-27-2007, 09:26 PM
Ah, damn... thanks anyways.

DustyPorViva
12-27-2007, 09:43 PM
Yes you can, in the editor at least:
Make a txt file in the folder levels/npcs... save it as something like
editnpcRandomTrees.txt
make sure the editnpc is at the beginning.
Then inside put:
if (mousedown && leftmousebutton) {
treecount=10;
for (i=0;i<treecount;i++) putnpc door.png,tree.txt,(int(mousex/64)*64)+int(random(0,64)),(int(mousey/64)*64)+int(random(0,64));
}
You'll also have to make a file called tree.txt and put it in your Graal folder. Inside the tree.txt, have the script for your tree.
This will drop 10 random trees in the level, but you can change treecount to change that. Not much, but I'm sure you get the idea and can work from it.
Afterwords, open up the editor, then go to Predefined NPCs and go down to Editor Control-NPCs and click it, you should see the editnpc you created in the list. Select it, then just click on the level and it'll drop the trees in the level. DON'T click again unless you want to add more trees, change the tabs to like tiles or such so you won't drop anymore, then simply save the level.

Jeffyy
12-27-2007, 09:58 PM
You'll also have to make a file called tree.txt and put it in your Graal folder. Inside the tree.txt, have the script for your tree.

What do you mean by "tree script"?

Nabru
12-27-2007, 10:18 PM
What do you mean by "tree script"?

something of the setshape brand, for the most part.

Codein
12-27-2007, 10:18 PM
What do you mean by "tree script"?

Like if you're using setshape2 and what not, so only part of it's blocking and the rest is walk under.

DustyPorViva
12-27-2007, 10:26 PM
If you're using NPCs for trees, then you'll be using GANI's and setshape. How about you post the tree image and such so we can better help you?

Jeffyy
12-27-2007, 10:47 PM
Well here,its not a tree, but the same basic idea... and i did as you said. But i have no idea what you mean by setting shape. I don't think i ever used it before. I'm fairly new to scripting if you couldn't tell. ;)

DustyPorViva
12-27-2007, 10:56 PM
//#CLIENTSIDE
function oncreated() {
setshape(0,48,32);
}

This will set the shape of the rock to 48x32 pixels. But in reality it sets the blocking shape, IE, how much of the NPC is like a wall. It really is hard to explain this stuff to a new scripter because manipulating setshapes for GANI's is slightly complicated in terms of explanation.

Codein
12-27-2007, 11:55 PM
If you're using NPCs for trees, then you'll be using GANI's and setshape. How about you post the tree image and such so we can better help you?

Why? I just use setshape2 in a class and join it to the trees :P

DustyPorViva
12-28-2007, 12:33 AM
Because if you're doing something like a tree or house where you want the tree to have an overlapping top and only block at the base of the trunk, you're going to have to position it correctly in Graalshop and understand that setshape on Gani's start at the (0,0) position of the showcharacter(if using showcharacter, which you should) character box, and not at the corner of the gani like regular NPCs.

Codein
12-28-2007, 01:37 AM
Because if you're doing something like a tree or house where you want the tree to have an overlapping top and only block at the base of the trunk, you're going to have to position it correctly in Graalshop and understand that setshape on Gani's start at the (0,0) position of the showcharacter(if using showcharacter, which you should) character box, and not at the corner of the gani like regular NPCs.

But why a gani?

cbk1994
12-28-2007, 01:41 AM
Because if you've got a script in it, when you're using the editor, you can see what it will look like online, versus where it will just show the image.

DustyPorViva
12-28-2007, 02:01 AM
But why a gani?
Gani's let you specify where the setshape will be. I'll write up a tutorial on it later and make a webpage out of it. Right now, dinner must be cooked.

Codein
12-28-2007, 03:37 AM
Gani's let you specify where the setshape will be. I'll write up a tutorial on it later and make a webpage out of it. Right now, dinner must be cooked.

Hrm. To the pixel?

Jeffyy
12-28-2007, 04:06 AM
//#CLIENTSIDE
function oncreated() {
setshape(0,48,32);
}

This will set the shape of the rock to 48x32 pixels. But in reality it sets the blocking shape, IE, how much of the NPC is like a wall. It really is hard to explain this stuff to a new scripter because manipulating setshapes for GANI's is slightly complicated in terms of explanation.

The script doesn't work because of "setshape(0,48,32);" isn't correct... or somthing

cbk1994
12-28-2007, 04:08 AM
The script doesn't work because of "setshape(0,48,32);" isn't correct... or somthing

Remove the parenthasis.

In a GANI, you can always do something to see if it's online, carry this out offline, this out online.

I think there is if (playeronline) or something, if not you could do something like if ( serverr.onlineVar == 27) then online, else offline.

DustyPorViva
12-28-2007, 06:01 AM
Well, a couple things wrong with what I posted earlier. I assumed this was for online... Either way, there are going to be some complications... You can either go ahead with this and do it for GS1 so you can see it offline in the editor... or do it in GS2 and not see the immediate effects offline... but make things way easier for you later. If you do it for the editor you're going to have a HELL of a lot of editing to do if you need to change even the slightest thing in the NPCs.
I suggest just going and putting this in the qstone.txt:

//#CLIENTSIDE
// (not sure if this script needs to be clientside or not)
function onCreated() {
this.join("qstone");
}

And have the script inside the 'qstone' class on the server. This way if you need to change anything, you simply change the class script and tada, all the trees are changed. You won't be able to see the effects offline, but I think the pros outweigh the cons. You'll still be able to see where the NPCs are placed in the editor, though.

EDIT: oh ya, and it's setshape(1,32,32); not 0, sorry about that.

cbk1994
12-28-2007, 03:44 PM
Well, a couple things wrong with what I posted earlier. I assumed this was for online... Either way, there are going to be some complications... You can either go ahead with this and do it for GS1 so you can see it offline in the editor... or do it in GS2 and not see the immediate effects offline... but make things way easier for you later. If you do it for the editor you're going to have a HELL of a lot of editing to do if you need to change even the slightest thing in the NPCs.
I suggest just going and putting this in the qstone.txt:

//#CLIENTSIDE
// (not sure if this script needs to be clientside or not)
function onCreated() {
this.join("qstone");
}

And have the script inside the 'qstone' class on the server. This way if you need to change anything, you simply change the class script and tada, all the trees are changed. You won't be able to see the effects offline, but I think the pros outweigh the cons. You'll still be able to see where the NPCs are placed in the editor, though.

EDIT: oh ya, and it's setshape(1,32,32); not 0, sorry about that.

First, the class should be joined serverside, not clientside.
but yah, I agree with you.

DustyPorViva
12-28-2007, 08:45 PM
Hence my little comment, thanks for the correction :)