Two quick questions about actor flags

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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
User avatar
Enjay
 
 
Posts: 27668
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Two quick questions about actor flags

Post by Enjay »

The +SMASHABLE flag isn't explained in the Wiki. As far as I can see, in the original games, it's only used on the Hexen pottery items. I think all it does is make it so that if the item falls, when it hits the floor it gets damaged (to the point of destruction). The relevant code seems to be here. I think it unconditionally does enough damage to kill the actor, and it happens when the actor falls from any height - even a very small drop. Would that be correct?

[edit: for fun, I gave the cyberdemon the +SMASHABLE flag and, sure enough, if you summon one, he appears slightly above the floor, drops and then dies. Interestingly, he does not die if he walks down stairs under his own steam. However, if you push a Hexen pot off even a small step, it will fall and break.[/edit]
[edit2: I've also added the flag to the Actor flags page in the Wiki with my understanding of it, and added the ZScript definitions of the pottery items to their relevant pages because the Wiki only had their DECORATE ones and, for whatever reason, that didn't include the SMASHABLE flag. Sorry to anyone who keeps an eye on the Wiki, I kept making small typos and re-editing. I think it's OK now.
https://zdoom.org/wiki/Actor_flags#SMASHABLE
https://zdoom.org/wiki/Classes:Pottery1
https://zdoom.org/wiki/Classes:Pottery2
https://zdoom.org/wiki/Classes:Pottery3
[/edit]


The second question is about putting flags in the default block of a ZScript actor. I'm confused as to why it doesn't seem to matter whether you follow an actor flag with a ; or not.
+SOLID
and
+SOLID;
both seem to be acceptable, as does a list on one line like so
+SOLID +SHOOTABLE +NOBLOOD;
So, my question is really why does it not matter if an actor flag is followed by a ; or not, when omission of a ; in almost every other type of line is an error? Is there a "best practice" here - i.e. is it better to use a ; or not, or does it really not matter? (Hmmm... I guess technically that's three questions.)
ZzZombo
Posts: 339
Joined: Mon Jul 16, 2012 2:02 am

Re: Two quick questions about actor flags

Post by ZzZombo »

When a monster moves, it more or less teleports to the next spot in the chosen direction. That's why the monster in your test doesn't get killed from dropping off the stair step. Its vertical velocity remains 0, and the code you linked to only gets involved if the actor has negative vertical velocity.
User avatar
phantombeta
Posts: 2223
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Two quick questions about actor flags

Post by phantombeta »

Enjay wrote: Thu Nov 13, 2025 9:33 am The second question is about putting flags in the default block of a ZScript actor. I'm confused as to why it doesn't seem to matter whether you follow an actor flag with a ; or not.
+SOLID
and
+SOLID;
both seem to be acceptable, as does a list on one line like so
+SOLID +SHOOTABLE +NOBLOOD;
So, my question is really why does it not matter if an actor flag is followed by a ; or not, when omission of a ; in almost every other type of line is an error? Is there a "best practice" here - i.e. is it better to use a ; or not, or does it really not matter? (Hmmm... I guess technically that's three questions.)
It's by design. The other lines can have other things coming after them, so they need a delimiter that says with certainty "this thing ends at this point". (e.g., a property can be Height 10 or BloodType "Blood", "BloodSplatter", "AxeBlood")
Flags, on the other hand, can't have more things coming after them. They're always a + or - followed by a name, so there's no need for a delimiter, it already knows where to stop parsing the flag.

You can put semicolons after flags because you can actually just put "floating" semicolons anywhere in the default block :P
Like this:

Code: Select all

default {
    ; Height 50;;;;;;;
    ; ; ; ;
 ; ;+SHOOTABLE;
    ;
    ;
}
User avatar
Enjay
 
 
Posts: 27668
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Two quick questions about actor flags

Post by Enjay »

ZzZombo wrote: Fri Nov 21, 2025 1:36 am When a monster moves, it more or less teleports to the next spot in the chosen direction.
Ah yes! That would certainly explain that. Thanks.

phantombeta wrote: Fri Nov 21, 2025 3:27 am It's by design. The other lines can have other things coming after them...
That makes sense, thanks. So, all the ; I've been putting in hoping that I was being "more correct" were, if anything, less correct, though not actually harmful. I'd seen both in use (including inconsistencies in gzdoom.pk3) so I went with what looked like it should be the safest option.


Bonus question, purely out of interest, why is is when accessing a flag in ZSCript e.g. Wiki example...

Code: Select all

TNT1 A 0
{
  bShootable = true; // Sets the SHOOTABLE flag to true on the calling actor
  bVulnerable = false;  // Sets the VULNERABLE flag to false on the calling actor
}
"b" is used as the character before the flag? Does it have a precedent in some other language or something?
User avatar
phantombeta
Posts: 2223
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Two quick questions about actor flags

Post by phantombeta »

Enjay wrote: Fri Nov 21, 2025 7:38 am That makes sense, thanks. So, all the ; I've been putting in hoping that I was being "more correct" were, if anything, less correct, though not actually harmful. I'd seen both in use (including inconsistencies in gzdoom.pk3) so I went with what looked like it should be the safest option.
Neither is necessarily more correct than the other, it's really up to you whether you prefer to put semicolons after flags or not :P
Enjay wrote: Bonus question, purely out of interest, why is is when accessing a flag in ZSCript e.g. Wiki example...

Code: Select all

TNT1 A 0
{
  bShootable = true; // Sets the SHOOTABLE flag to true on the calling actor
  bVulnerable = false;  // Sets the VULNERABLE flag to false on the calling actor
}
"b" is used as the character before the flag? Does it have a precedent in some other language or something?
As is the case for a lot of other odd things about ZScript, this is yet another thing copied from UnrealScript :P
As for why UnrealScript does it like that, I believe it's because Unreal uses Hungarian notation for names, so the "b" would stand for "bool"/"boolean".
(This is also why if you look in GZDoom's C++ source code, you'll see the type names written as TArray, FName, AActor, etc.)

That said, it's an useful addition, it helps prevent flag names from clashing with variables and such defined in mods.
User avatar
Enjay
 
 
Posts: 27668
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Two quick questions about actor flags

Post by Enjay »

Thank you. I figured there would be some reason. Coming from ZScript's inspiration (UnrealScript) makes sense.

And TIL about Hungarian notification too. Thanks. :)
Post Reply

Return to “Scripting”