den killen Posted April 25, 2023 (edited) I have this script to make a crushing floor move up 32 units each time a switch is hit: script 1 (int rfTag) { int currentHeight = GetSectorFloorZ(rfTag, 0, 0); int targetHeight = currentHeight +32; Delay(35); Floor_MoveToValueAndCrush(rfTag, 16, targetHeight, 200, 3); } It works fine the first time, but on the second press it just goes up into the ceiling indefinitely. I can't for the life of me figure out why this is happening. Even using a regular Floor_MoveToValue has the same issue. Stranger still, if I treat targetHeight in the action as a negative value, the floor goes down the first time, and infinitely up the second time as before. What is going on? Edited April 25, 2023 by den killen 0 Quote Share this post Link to post
jaeden Posted April 25, 2023 (edited) GetSectorFloorZ returns fixed number, which is 65536 times bigger than the integer value you probably expect, so if the sector floor is at height 32, then the "currentHeight" variable will be 2097152 -> target height will be at 2097184, which might look like it goes indefinitely. https://zdoom.org/wiki/GetSectorFloorZ https://zdoom.org/wiki/Fixed_point_number Edited April 25, 2023 by jaeden 0 Quote Share this post Link to post
den killen Posted April 25, 2023 (edited) 41 minutes ago, jaeden said: GetSectorFloorZ returns fixed number, which is 65536 times bigger than the integer value you probably expect, so if the sector floor is at height 32, then the "currentHeight" variable will be 2097152 -> target height will be at 2097184, which might look like it goes indefinitely. https://zdoom.org/wiki/GetSectorFloorZ https://zdoom.org/wiki/Fixed_point_number What is the reason for it doing that without converting to an integer? Would I just need to divide every use of it by 65536 (it finally works, but seems superfluous)? Edited April 25, 2023 by den killen 0 Quote Share this post Link to post
jaeden Posted April 26, 2023 Because ACS has relatively old design, and every variable there is actually an integer. 0 Quote Share this post Link to post
Edward850 Posted April 26, 2023 8 hours ago, den killen said: Would I just need to divide every use of it by 65536 (it finally works, but seems superfluous)? Use the bit shift operator, >> 16. Here's a previous explanation on fixed point numbers: 0 Quote Share this post Link to post
den killen Posted April 26, 2023 (edited) 13 hours ago, Edward850 said: Use the bit shift operator, >> 16. Gotcha. I was originally using a constant but this is much cleaner. Thanks! Edited April 26, 2023 by den killen 0 Quote Share this post Link to post
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.