[ZScript] Confusion over MoveFloor and MoveCeiling

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
stan423321
Posts: 32
Joined: Tue Mar 25, 2014 2:35 pm

[ZScript] Confusion over MoveFloor and MoveCeiling

Post by stan423321 »

There are two particularly interesting, yet somewhat undocumented, methods in the Sector class, MoveFloor and MoveCeiling, which sound like they should work similarly. Here is my current understanding of them, based on very rough inspection of dsectoreffect.cpp and associated functions available to other scripts and equally rough common sense. The reason I'm posting it here is that someone may see an error or clarify one of the weirder points marked with (?). But if you didn't know anything about these two, it may be helpful to you I guess - enjoy? This is all based upon testing very specific subset of calls, it's likely something is very wrong here in the parts where I don't think I'm confused.
  • The functions perform one unit worth of surface movement, which may result in maximally "speed" worth of height change. Initially it appeared that internal functions call these every tick, but various oddities in documentation of crushing and surface movement suggest they actually get called every four ticks. (?)
  • Both MoveFloor and MoveCeiling can return 0, 1, or 2 in ZScript. C++ names these as EMoveResult::{ok, crushed, pastdest}. but there don't seem to be equivalent constants available in the gzdoom.pk3 ZScript.
  • The pastdest result is returned if the surface has reached its destination. Otherwise ok or crushed is returned, crushed is probably returned if an actor is being crushed (?).
  • The crushing is performed by applying "crush" worth of damage points sometimes (according to doomwiki.org it should happen every 4 ticks). There is also a "hexencrush" argument. According to doomwiki.org, in Hexen crushers stop somewhat when they crush actors, so that's probably that. Crushing prevention should be implemented by passing a "crush" of -1.
  • There is a "direction" argument, -1 means down and 1 means up. It is unclear to me if this parameter is even necessary (?).
  • MoveFloor has an extra argument "dropactors", which probably makes it move the actors standing or generally present (?) in the sector down while moving.
  • Both MoveCeiling and MoveFloor have a "dest" argument, referring to destination height. However, while MoveCeiling seems to move the ceiling towards destination, MoveFloor seems to move the floor towards minus destination (?). (?) (?) (?) (?) (?)
Okay, the last point may look excessive, but it's really weirding me out! I would probably just quietly keep coding my thing without making this post if it didn't manifest. Why the heck is MoveFloor reversed?! I mean, I can imagine a situation in which negating a number would be useful in maths, perhaps one could use the same function for moving ceilings and floors by reversing some numbers... but, well, this doesn't appear to be the case, there are two separate functions in C++ for that, and at any rate exposing this implementation detail to the user code sounds confusing. What's up with this negation? If you can answer any one of confusion points, but only one, make it this one.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49231
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [ZScript] Confusion over MoveFloor and MoveCeiling

Post by Graf Zahl »

These functions are internal workers for movement thinkers. You shouldn't use them yourself directly. They are public because by their very nature they need to be called from the outside.
stan423321
Posts: 32
Joined: Tue Mar 25, 2014 2:35 pm

Re: [ZScript] Confusion over MoveFloor and MoveCeiling

Post by stan423321 »

This frankly raises even more questions.

What is the closest honestly-public equivalent of functions in question? I can't find any "launch movement thinker" functionality in the Sector class, which seems the most logical place to look for that to me. All I can see is these two.

Also, since there is not much of a documentation yet (and wiki kind of suggests scrapping gzdoom.pk3 for info), is there some telltale sign of a public member function in a provided class being off-limits to a modder? It frankly sounds quite weird that I'm not supposed to move the floor with a function which is named MoveFloor.

In the unnecessary but interesting knowledge category: nothing in gzdoom.pk3 appears to directly use MoveFloor... and modders are not supposed to use it... so whom is the ZScript entrypoint for? Does GZDoom compilation process involve some complex reflection processing?
User avatar
Accensus
Banned User
Posts: 2383
Joined: Thu Feb 11, 2016 9:59 am

Re: [ZScript] Confusion over MoveFloor and MoveCeiling

Post by Accensus »

A few minutes ago I ran into the same issue as Stan here. The solution was to use level.CreateFloor. Trying to figure out MoveFloor didn't work out so well. Unfortunately I read this thread *after* spending half an hour trying to figure it out.
User avatar
Caligari87
Admin
Posts: 6233
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: [ZScript] Confusion over MoveFloor and MoveCeiling

Post by Caligari87 »

So just to clarify then, it seems createFloor() and createCeiling() are implicitly saying "create floor/ceiling thinker with the following parameters."

I see constants nearby in doombase.zs such as floorLowerToLowest so I guess the proper usage is something like this:

Code: Select all

// gzdoom.pk3/zscript/actors/strife/thingstoblowup.zs //
level.CreateFloor(sec, Floor.floorLowerToLowest, null, 65536.);
8-)
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: [ZScript] Confusion over MoveFloor and MoveCeiling

Post by Matt »

Just to be clear here, "create" doesn't mean that if we call this over and over it'll start creating zillions of background thinkers that never get cleared, does it?
User avatar
NicoTheGoat
Posts: 17
Joined: Sun Dec 29, 2019 6:36 pm
Contact:

Re: [ZScript] Confusion over MoveFloor and MoveCeiling

Post by NicoTheGoat »

The ZScript side functions aren't even referenced anywhere (though the underlying C functions are);
If they're internal and not meant to be used by modders, why even export them?
Matt wrote:Just to be clear here, "create" doesn't mean that if we call this over and over it'll start creating zillions of background thinkers that never get cleared, does it?
No, it only creates the thinker if the sector doesn't already have one for the specified plane.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49231
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [ZScript] Confusion over MoveFloor and MoveCeiling

Post by Graf Zahl »

These functions are just the internal workers for all the action specials, so depending on the parameters they just work like those, that includes blocked activation semantics.
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: [ZScript] Confusion over MoveFloor and MoveCeiling

Post by Matt »

NicoTheGoat wrote:
Matt wrote:Just to be clear here, "create" doesn't mean that if we call this over and over it'll start creating zillions of background thinkers that never get cleared, does it?
No, it only creates the thinker if the sector doesn't already have one for the specified plane.
Sweet! Updating HD with this then.

What does speed2 in CreateCeiling do?
User avatar
NicoTheGoat
Posts: 17
Joined: Sun Dec 29, 2019 6:36 pm
Contact:

Re: [ZScript] Confusion over MoveFloor and MoveCeiling

Post by NicoTheGoat »

Matt wrote:What does speed2 in CreateCeiling do?
Speed1 and speed2 override the speed when moving up and down respectively if the ceiling is set to 'crush and raise', 'lower and crush', or a 'stay' variant of one of those two.
Post Reply

Return to “Scripting”