CS2D
Scripts What Does The fow_in Function Do What Does The fow_in Function Do
9 replies While snooping around with CS2D I found a function called fow_in
, but I do not know what it does.
Does anybody know? mrc User Offline
Yes, I know. But I don't wanna do that. DC Admin Offline
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) @ DC: Does that function always return 0 if fog of war is disabled? Jesus Christ, DC. I even asked for that in the ideas thread back in the day. Also remember 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... SQ Moderator Offline
@ 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. DC Admin Offline
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. DC Admin Offline
@ 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 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. @ DC: I don't know why last time it didn't work, I tested it once again and it worked properly, maybe there is something wrong with it sometimes. Anyways, thanks!