Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-06-2017, 05:05 PM
maximus_asinus maximus_asinus is online now
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,727
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
Ignoring blocking tiles?

Graal Script Code:
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.



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.
Attached Thumbnails
Click image for larger version

Name:	test.png
Views:	76
Size:	23.6 KB
ID:	56012  
__________________
Save Classic!
Reply With Quote
  #2  
Old 08-06-2017, 10:41 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,149
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by maximus_asinus View Post
I'm just wondering if there is a better way.
Nope.
__________________
Reply With Quote
  #3  
Old 08-07-2017, 12:08 AM
maximus_asinus maximus_asinus is online now
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,727
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
Quote:
Originally Posted by Crow View Post
Nope.
is it possible to change which layer the player is on?
__________________
Save Classic!
Reply With Quote
  #4  
Old 08-07-2017, 03:40 AM
Kamaeru Kamaeru is offline
Sandinista!
Kamaeru's Avatar
Join Date: Dec 2001
Posts: 1,024
Kamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud ofKamaeru has much to be proud of
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.
__________________
3DS friendcode: 1118-0226-7975

Last edited by Kamaeru; 08-07-2017 at 03:53 AM..
Reply With Quote
  #5  
Old 08-08-2017, 08:40 PM
Kirko Kirko is offline
Registered Guest
Join Date: Dec 2014
Location: Texas
Posts: 61
Kirko has a spectacular aura aboutKirko has a spectacular aura about
Send a message via Skype™ to Kirko
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.
Reply With Quote
  #6  
Old 08-08-2017, 10:24 PM
maximus_asinus maximus_asinus is online now
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,727
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
Quote:
Originally Posted by Kirko View Post
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.
__________________
Save Classic!
Reply With Quote
  #7  
Old 08-09-2017, 05:18 AM
maximus_asinus maximus_asinus is online now
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,727
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
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?
Graal Script Code:
// 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);
  }

__________________
Save Classic!
Reply With Quote
  #8  
Old 08-10-2017, 12:34 AM
maximus_asinus maximus_asinus is online now
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,727
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
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?
__________________
Save Classic!

Last edited by maximus_asinus; 08-10-2017 at 01:55 AM..
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:16 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.