I'm trying to compare the player's position with the position of an event to determine when a player is within 2 tiles of the event horizontally and 3 tiles vertically north of the event. I'm wanting this to work for the current event that the code is placed within so it works with each event of this type, but I can't figure out the correct java variables to use for the current event position.
An example of this would be (according to my limited java script knowledge):
if (($gamePlayer._x <= ($currentEvent._x + 2)) && ($gamePlayer._x >= ($currentEvent._x - 2)) && ($gamePlayer._y <= ($currentEvent._y + 3)) && ($gamePlayer._y >= $currentEvent._y))
but I know that $currentEvent isn't correct.
Does any one know how to access the position of the current event to use in a condition that's compared with the player's position?
Game_Interpreter.prototype.character = function(param) {
if ($gameParty.inBattle()) {
return null;
} else if (param < 0) {
return $gamePlayer;
} else if (this.isOnCurrentMap()) {
return $gameMap.event(param > 0 ? param : this._eventId);
} else {
return null;
}
};
character(0) is this._eventId
This means you can copy & paste the event and not have to change the code to insert every event id. Each event will only compare the player's position with its own position.
I would still look for another way. If you have a few dozen trees and you're going to make each one a parallel process event, that is very likely going to make your game lag.
I would use a single region id to cover ALL areas where you want a tree to change opacity, and a single event set to parallel process that has a wait for a few frames, checks if the player is on the special region id, and if they are, find out which tree (there could be several), and set the events opacity for each one. It would also need to check if there WAS a tree that was semi-transparent, and the player is no longer behind it, so sets it back to fully opaque.
The other thing you could do, which would remove events and conditions entirely, is to have two versions of the tree in the tileset. One version would be fully opaque and would be below the player (you could use my terrain tag script in the development section so this tree's passage settings are ignored and it looks at what's underneath), and the other version would be semi transparent and would be drawn exactly over the first version. This would make it look like there's a fully opaque tree on that spot, but when the player walks behind it, the opaque layer is below the player, and the semi transparent layer is above the player. It would LOOK like the tree is becoming semi-transparent when the player walks behind it, but really nothing at all is happening. This could be a very good option if your trees are not overlapping, or you don't have other things you want to put on either of the top layers - takes advantage of MV's two-top-layer feature.
If you don't follow what I mean, but you think it could be useful if you can get it working, let me know (tag me in the post to make sure I see it), and I'll do up a quick demo for you.
The no event idea would be great, but my trees are 7x7 tiles large and they'll take up a huge amount of my tile space on my tile bitmaps if I have a solid and a transparent one too. I also want the full branch/leaves transparent to make a line of sight effect and not just the immediate portion of the image that's over the character so I think the first option where there's a single parallel process running, the region id to cover all areas, the conditions for each tree and the actions to flip the switches of the affected trees all from one event would be best.
Thanks for all of your insight.