'bFriendly = true' does not reduce monster count

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 a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: 'bFriendly = true' does not reduce monster count

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

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

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

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

by 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.

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

by 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.

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

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

Ok, but it is strange how it works with one method but not with another.

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

by 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.

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

by 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.

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

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

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.

'bFriendly = true' does not reduce monster count

by 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.
Attachments
testmonster.pk3
(1.04 KiB) Downloaded 22 times

Top