[Not a bug] 'bFriendly = true' does not reduce monster count

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

'bFriendly = true' does not reduce monster count

Postby Ichor » Sat Apr 03, 2021 10:58 am

If you use the decorate code 'A_ChangeFlag("FRIENDLY",1)', this will reduce the total monster count by one. However, if you use the ZScript code 'bFriendly = true' to do the same thing, then the total monster count will not be reduced. This will give you an extra monster that will not be accounted for if it died and you won't be able to get 100% kills.

Here is an example. The ZScript text contains TestMonster1 that uses 'bFriendly = true' after a few frames. The Decorate text uses TestMonster2 that uses 'A_ChangeFlag("FRIENDLY",1)' instead. Summon both to see the difference.
You do not have the required permissions to view the files attached to this post.
User avatar
Ichor
The fun cannot be halted
 
Joined: 23 Jul 2003

Re: 'bFriendly = true' does not reduce monster count

Postby m8f » Sat Apr 03, 2021 11:18 am

Well, you can always adjust total monster count manually by doing
Code: Select allExpand view
level.total_monsters -= 1;

I think it's expected that changing actor flag doesn't have side effects like changing total monster count.
User avatar
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit

Re: 'bFriendly = true' does not reduce monster count

Postby Ichor » Sat Apr 03, 2021 11:26 am

Except I seem to remember a few years ago that it was changed to reduce monster count on purpose.

Oh yeah, there's a couple of threads here and here.
User avatar
Ichor
The fun cannot be halted
 
Joined: 23 Jul 2003

Re: 'bFriendly = true' does not reduce monster count

Postby Graf Zahl » Sat Apr 03, 2021 1:10 pm

Yes, it does, but the global monster counter lives elsewhere. If you just change the flag the engine only toggles a variable, so you have to take care of the counter yourself.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: 'bFriendly = true' does not reduce monster count

Postby Ichor » Sat Apr 03, 2021 3:46 pm

Ok, but it is strange how it works with one method but not with another.
User avatar
Ichor
The fun cannot be halted
 
Joined: 23 Jul 2003

Re: 'bFriendly = true' does not reduce monster count

Postby Graf Zahl » Sat Apr 03, 2021 3:59 pm

There is no "other method". But if you just change a variable on an actor directly at run time this won't update other related variables. 'bFriendly = true;' is just a variable assignment - it calls no function that updates other state in the engine - all it does is setting bFriendly to true. The global monster counter is a separate variable.

ZScript has no concept of properties like C# or Objective-C where you can overload an assignment with a function call.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: 'bFriendly = true' does not reduce monster count

Postby Ichor » Sat Apr 03, 2021 4:26 pm

Well, as long as there's a way to deal with the actual problem, I should be fine.

Actually, I just found out about A_ChangeCountFlags, which does exactly what I need.
User avatar
Ichor
The fun cannot be halted
 
Joined: 23 Jul 2003

Re: 'bFriendly = true' does not reduce monster count

Postby Blue Shadow » Mon Apr 05, 2021 11:53 am

There's now this, for whoever might need it.
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 2 guests