Forum

> > CS2D > Scripts > What Does The fow_in Function Do
Forums overviewCS2D overview Scripts overviewLog in to reply

English What Does The fow_in Function Do

9 replies
To the start Previous 1 Next To the start

old Re: What Does The fow_in Function Do

DC
Admin On Online

Quote
Oh interesting. It's not documented.
It checks if something is inside fog of war or not.
parameters:
• player ID (it checks if the coordinate is inside the visible area of THAT specific player)
• X coordinate to check (in pixels, not tiles)
• Y coordinate to check (in pixels, not tiles)

returns:
0: coordinate is NOT covered by fog of war (= visible)
1: coordinate IS covered by / is inside the fog of war (= invisible)

old Re: What Does The fow_in Function Do

Masea
Super User Off Offline

Quote
Jesus Christ, user DC. I even asked for that in the ideas thread back in the day. Also remember user Rainoth was against the idea because he didn't get the point of such a function and he claimed you can do a very similar checker with just basic Lua on your own. I always thought it'd be cool to have it in the original game since it is kinda expensive to do it yourself (also would be less accurate). I wish it was documented all these years, can't imagine how many beautiful things you could have done with it...

old Re: What Does The fow_in Function Do

SQ
Moderator Off Offline

Quote
@user Masea: I've added it not long ago. Probably in the last version.
I might have looked at old ideas thread at that time and this seemed like easy implementation to do.
Took a few minutes.

old Re: What Does The fow_in Function Do

The Dark Shadow
User Off Offline

Quote
Tested it several times, and all the times it returned 1, whether the player exists or not. Does that even work? Also, would you guys mind teaching us how to do the calculations and maths in LUA without fow_in? Maybe sharing the fow_in related code would be cool! For a very long time I wanted to understand how the fow system works, and I never understood it yet.

old Re: What Does The fow_in Function Do

DC
Admin On Online

Quote
@user The Dark Shadow: What does the script look like which always gives you a 1 as return value? Make sure you're getting the parameters right. Especially the order and the fact that the coordinates are in pixels and not in tiles.

I'm not sure if that command works to be honest. I think user SQ implemented it and I never tested it.

The fog of war calculation works with simple ray casts which are shot from the player to reveal the area and which are stopped by walls. It's a pretty inefficient way of doing it. There are much better ways.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview