Terrain check script.

I need a script, it is desirable that it can be used in "Conditional Branch" Script box, that checks for a special Terrain Tag between event and Player.

Like, for example, if there a tile with Terrain Tag number two between turret and player, turret don't will shoot.
For 4directions?  8directions would be hard.
What happens if the player and target are not in a vertical or horizontal line?
With the get Location Info Eventcommand you can ask for Terain ID or Region ID for Certain coodinatetes destinated through Variables.

You could use it somehow for this.
Yes, but the OP is not after a single tile - they want to check ALL tiles between the two. You could do this with a loop, variables and the Get Location Info if you were only interested in horizontal or vertical lines, otherwise it becomes more complicated.
Why not have the projectile check the terrain tag it's on instead?  It's much easier.

The built-in editor should be able to do that.

As for the "line" check, it's more like a path-finding that returns true/false.

So i am sure there's already a script for this out there.

And, you still can do it with editor only, simply have the turret fires a "dummy" projectile(that checks its own terrain tag) at the player,

If it reaches the player without any error, let the projectile tells the turret it's clear to fire the real ammo.

If it hits a terrain tag on its way to the player, return false.
Theoreticly yes, but Map Coordinates are not very good if the Target is moving fast, because

the Mapcoordinate of a Event Switches, than it starts Moving to that Tile, that means it could look like the bullet hits the target but it doesnt count as Hit.

Thats why i used Screencoordinates insteed of Map Coordinates in the end in a Zelda Experiment. Same could count for the Region stuff.

But iam not sure if its the Case in this Scenario.
With the get Location Info Eventcommand you can ask for Terain ID or Region ID for Certain coodinatetes destinated through Variables.

You could use it somehow for this.
Well, I played with this a little. Took this lesson: http://forums.rpgmakerweb.com/index.php?/topic/3452-direction-based-line-of-sight-events/. Created a simple "line of sight", put my math-formula for right-directioned monsters and tested. Like if after player enters monster line of sight, formula checks if monster can see player. Well, it's worked fine, but RMVX not much into saving value in variables like fraction (0.5 or 0.3), because it's always save like integers (-2, -1, 0, 1, 2). And in case if you stand on one line with event, or closer than 2-4 tiles it work nice, even too good. But if you too far, or stand too close (7-8 tiles), numbers values became too low and inaccurate. And monster begin to see you no matter if there a wall between you and it. So, no. It's don't will work well with var and switches only.

[IMG]http://i.imgur.com/jmULQP3.png[/IMG]

And, you still can do it with editor only, simply have the turret fires a "dummy" projectile(that checks its own terrain tag) at the player,
If you mean to use events as projectile, then this possibly don't will work well, because even on max speed they are still too slow. And if there is few turrets? I need to create a huge amount of these projectiles then. I need a simple Ruby script, which will create the equation of a line by two points (event and player xy coordinates), and then by slowly checking (adding 0.4 or less after every check) x or y (it's depend from event direction) coordinate from A to player coordinate, and check if line cross a tile with special Terrain Tag.
What i mentioned is making an event to "mimic" the pathfinder and return true if it hits the player (*an easy way out)

As for the game variables, it can store anything,integers(1,-5), floats(0.1, -0.5), boolean(true,false), even strings ("ABCD").
You just need to do the math using script calls and not the built in click-click buttons. 😉

Original thread: https://forums.rpgmakerweb.com/threads/terrain-check-script.44506/