PDA

View Full Version : Ignoring blocking tiles?


maximus_asinus
08-06-2017, 04:05 PM
function onCreated() {
setshape2(10,10,{
11,11,11,11,11,11,11,11,11,11,
11,11,11,11,11,11,11,11,11,11,
11,11,11,11,11,11,11,11,11,11,
11,11,11,11,11,11,11,11,11,11,
11,11,11,11,11,11,11,11,11,11,
11,11,11,11,11,11,11,11,11,11,
11,11,11,11,11,11,11,11,11,11,
11,11,11,11,11,11,11,11,11,11,
11,11,11,11,11,11,11,11,11,11,
11,11,11,11,11,11,11,11,11,11,
});
showpoly(200,{30,30,40,30,40,40,30,40});
with (findimg(200)) {
red = 0;
green = 0;
blue = 1;
alpha = 0.75;
layer = 0;
}
}

I'm trying to emulate the rising water from Link to the Past. This method gives me the desired effect visually, but I still need to override the blocking tiles in the affected area to turn them into swimming tiles.

http://forums.graalonline.com/forums/attachment.php?attachmentid=56012&stc=1&d=1502032978

My best method would be to draw the castle tiles on another layer, put non-blocking tiles underneath, and then use setshape to block the player when the water is drained. I'm just wondering if there is a better way.

Crow
08-06-2017, 09:41 PM
I'm just wondering if there is a better way.

Nope.

maximus_asinus
08-06-2017, 11:08 PM
Nope.is it possible to change which layer the player is on?

Kamaeru
08-07-2017, 02:40 AM
I can think of a few approaches you could use to accomplish it, but no matter what you'd have to be creative and create a hack of a solution. From having 2 sets of the wall tiles, the second on swimmable tile indices on the tileset, to making the walls npcs. There is no way to do legit layers on graal without some sort of scripted solution or visual trickery. But I could pull it off while maintaining the illusion of layers yeah. Sometimes when something seems impossible with the scripting engine, you have to remember there are also scripted ganis you can do a lot with.

It would be possible to use a special tileset where the underwater wall tiles would be swimmable tiles, and then have a script triggered by a level variable to update the board every time it switches.

The problem with that however is that there are not many swimmable tiles on the tileset. Perhaps you can use setshape2 to make it detect as water tiles.

There are easier ways to do it like warp the player to a different level, or just make the underwater wall tiles drawunderplayer images, or to not even show the walls underwater.

As far as changing it so that you can walk over blocking tiles, setshape2 does that. You can save the array for setshape2 into a variable and reload it using something like setshape2(x,y,this.array), making it so you could save 2 arrays, one for before the change and one for after.

Kirko
08-08-2017, 07:40 PM
Maybe attachPlayerToObj()? Could attach the player then change their gani to swim. I'm not sure if you can change the size of the npc while the player is attached though.

maximus_asinus
08-08-2017, 09:24 PM
Maybe attachPlayerToObj()? Could attach the player then change their gani to swim. I'm not sure if you can change the size of the npc while the player is attached though.I experimented with that command offline and it works perfectly, but I am having problems getting it to work online. I talked about it briefly in my GS1 thread.

Also...

I'm using showpoly to create the effect, but I don't know how to manipulate showpoly into making it look like the water is rising or falling other than inputting the coordinates manually and that is not feasible at all. What I think needs to happen is that I stick to simple 4 sided shapes and assign each set of points to an array, find where I want to move to, subtract to find the distance, then somehow move the coordinates to my final location. But that last step is over my head.

In all honesty I am having trouble just getting off the ground with this and would appreciate some help.

maximus_asinus
08-09-2017, 04:18 AM
I created the desired fill effect, but I hit another snag. I want to break the loop when 'this.current' is equal to 'this.final', but with how the math is done 'this.current' is always going to be off by a few fractions of a decimal. How can I get around this without messing with how fluid the animation is?

// Created by maximus_asinus

//#CLIENTSIDE
function onPlayerChats() {
if (player.chat == "debug") {
this.final = {9,39,47,39,47,27,55,27,55,47,9,47};
this.current = {11,41,49,41,49,29,53,29,53,45,11,45};
player.chat = " ";
showpoly(200,this.current);
changeimgcolors 200,0,0,1,0.75;
setTimer(0.05);
}
}
function onTimeout() {
for (i=0;i<13;i++;) {
temp.distx = this.final[0+i] - this.current[0+i];
temp.disty = this.final[1+i] - this.current[1+i];
temp.movelength = (temp.distx * temp.distx + temp.disty * temp.disty) ^ 0.5;
temp.distx = temp.distx / temp.movelength;
temp.disty = temp.disty / temp.movelength;
this.current[0+i] = this.current[0+i] + temp.distx * 0.05;
this.current[1+i] = this.current[1+i] + temp.disty * 0.05;
showpoly(200,this.current);
i++;
setTimer(0.05);
}
}

maximus_asinus
08-09-2017, 11:34 PM
I have a hacked solution for now where the script runs on a timer for the amount of time it takes to fill the area, but I hope someone can post a more elegant solution. The goal is that the user only has to change coordinates for the target area.

Now I need to move onto trying to get attachplayertoobj to work.

[EDIT]

I ran into a bug / problem. Depending on the size of the window the showpoly disappears when the player moves around. Any way to fix this?