Graal Classic > Classic Main Forum

How did you accomplish the rising water?

<< < (2/4) > >>

maximus_asinus:
Also thanks for replying. I have no scripting experience outside GS1, and it is very frustrating coming against hurdles when there is nobody else willing to help out. It isn't likely I will solve this on my own.

maximus_asinus:
After testing your script visually it only works for square shapes. How would I go about doing other shapes? Like a rectangle? Maybe I am not understanding this script, but it seems very limited.

Thor:

--- Quote from: maximus_asinus on August 15, 2017, 05:01:11 PM ---After testing your script visually it only works for square shapes. How would I go about doing other shapes? Like a rectangle? Maybe I am not understanding this script, but it seems very limited.

--- End quote ---

All this code does is handle the drawing of the polygon based on the water-filled area compared with the total flood-able area, but it can and does work for rectangular areas too, rectangles just require specific math to increment the filled area as the filled width and height would not increment evenly.

When raising the water I increment the areas like so:


--- Code: ---  temp.w = this.waterWidth - (this.boundaryWidth * 2);
  temp.h = this.waterHeight - (this.boundaryWidth * 2);
  temp.xIncrease = 50;
  temp.yIncrease = 50;

  if (this.boundaryWidth > 0) {

    if (this.waterWidth - this.filledWidth <= this.boundaryWidth * 2) {
      temp.w = this.boundaryWidth;
      temp.xIncrease /= 2;
    }

    if (this.waterHeight - this.filledHeight <= this.boundaryWidth * 2) {
      temp.h = this.boundaryWidth;
      temp.yIncrease /= 2;
    }

  }
  temp.xIncrease = (temp.w / temp.xIncrease);
  temp.yIncrease = (temp.h / temp.yIncrease);
  this.filledWidth = min(this.waterWidth, this.filledWidth + temp.xIncrease);
  this.filledHeight = min(this.waterHeight, this.filledHeight + temp.yIncrease);
  this.updatePoly();

--- End code ---

(Boundary width would be the walled area on the outermost tiles of a fill area, where I have the water raise more slowly)

maximus_asinus:
Okay I've run what you gave me and it works, though it looks a bit odd when you're flooding in long skinny sections. Also how would you handle two intersecting flows of water? I am demoing in an L shaped room and want to flood both sections. Here is a demo of what I am talking about.

https://www.youtube.com/watch?v=cj6dqNfGnMw

I'm assuming it was luck that they came together at the same time.

Could this be done with one source of water instead of adding multiple?




maximus_asinus:
Also can you explain how attachplayertoobj works online?

Offline if I use attachplayertoobj it acts as if the player is on a layer above the tileset and ignores blocking tiles. In combination with setshape2 I can make blocking tiles swimmable.


--- Code: ---if (created) {
  setshape2 2,2,{11,11,11,11};
}
if (playertouchsme) {
  attachplayertoobj 0,id;
}

--- End code ---

With the same script (updated to GS2 obviously) the tiles are still swimmable but it doesn't put me on that separate layer.


--- Code: ---//#CLIENTSIDE
function onCreated() {
setshape2(2,2,{11,11,11,11});
}
function onPlayerTouchsMe() {
attachplayertoob(0, id);
}

--- End code ---

And again, thanks for your patience. I am learning a lot from what you've shown me so far. I appreciate the help.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version