'bFriendly = true' does not reduce monster count

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
User avatar
Ichor
Posts: 1783
Joined: Wed Jul 23, 2003 9:22 pm

'bFriendly = true' does not reduce monster count

Post by Ichor »

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.
Attachments
testmonster.pk3
(1.04 KiB) Downloaded 22 times
User avatar
m8f
 
 
Posts: 1457
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Location: Siberia (UTC+7)
Contact:

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

Post by m8f »

Well, you can always adjust total monster count manually by doing

Code: Select all

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
Ichor
Posts: 1783
Joined: Wed Jul 23, 2003 9:22 pm

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

Post by Ichor »

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
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49225
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

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

Post by Graf Zahl »

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
Ichor
Posts: 1783
Joined: Wed Jul 23, 2003 9:22 pm

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

Post by Ichor »

Ok, but it is strange how it works with one method but not with another.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49225
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

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

Post by Graf Zahl »

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
Ichor
Posts: 1783
Joined: Wed Jul 23, 2003 9:22 pm

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

Post by Ichor »

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.
Blue Shadow
Posts: 5041
Joined: Sun Nov 14, 2010 12:59 am

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

Post by Blue Shadow »

There's now [wiki=A_SetFriendly]this[/wiki], for whoever might need it.
Post Reply

Return to “Closed Bugs [GZDoom]”