[Question] Monster Killed By Friendly Does Not Add to Count

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!)
That Blind Guy
Posts: 20
Joined: Fri Mar 10, 2017 8:18 am

[Question] Monster Killed By Friendly Does Not Add to Count

Post by That Blind Guy »

The subject line says it all.

-Attack certain monsters until their health reaches a certain point where they effectively switch sides.
-Said monster starts shooting other monsters.
-This does not contribute toward 100% kills

This is kind of important, because my mod rewards completion of maps, including a health upgrade for 100% kills. How do I go about fixing this?
Blue Shadow
Posts: 5039
Joined: Sun Nov 14, 2010 12:59 am

Re: [Question] Monster Killed By Friendly Does Not Add to Co

Post by Blue Shadow »

As far as I know, a hostile monster should count towards the map's kills as long as it has the COUNTKILL flag, regardless of the means it was killed by.

How are you setting all this up (code-wise, I mean)?
That Blind Guy
Posts: 20
Joined: Fri Mar 10, 2017 8:18 am

Re: [Question] Monster Killed By Friendly Does Not Add to Co

Post by That Blind Guy »

Blue Shadow wrote:As far as I know, a hostile monster should count towards the map's kills as long as it has the COUNTKILL flag, regardless of the means it was killed by.

How are you setting all this up (code-wise, I mean)?
It's all handled in the Missile state and a custom one. It acts more like confusion, since they'll re-acquire targets after every shot. It applies to Mancubi and Revenants, so here's the DECORATE code from the Mancubus.

Code: Select all

	Missile:
	    FATT G 20 A_FatRaise
	    FATT H 10 bright A_FatAttack1
	    FATT IG 5 A_FaceTarget
	    FATT H 10 bright A_FatAttack2
	    FATT IG 5 A_FaceTarget
	    FATT H 10 bright A_FatAttack3
	    FATT IG 5 A_FaceTarget
		FATT G 0 A_JumpIfHealthLower(300, "ClearTarget")
	    goto See
	ClearTarget:
		DAED G 0 A_ChangeFlag("FRIENDLY", true)
		FATT G 1 A_ClearTarget
		Goto See
Blue Shadow
Posts: 5039
Joined: Sun Nov 14, 2010 12:59 am

Re: [Question] Monster Killed By Friendly Does Not Add to Co

Post by Blue Shadow »

I couldn't produce the issue you describe, I'm afraid. The monster kill count was always correct during my testing.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49223
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: [Question] Monster Killed By Friendly Does Not Add to Co

Post by Graf Zahl »

Posting code fragments is never going to help.
But this one may contain a hint: Your code changes the FRIENDLY flag during gameplay and this affects how a monster affects kill %. When killed while friendly the kill won't register on the counter.
Blue Shadow
Posts: 5039
Joined: Sun Nov 14, 2010 12:59 am

Re: [Question] Monster Killed By Friendly Does Not Add to Co

Post by Blue Shadow »

That shouldn't affect the ability to get 100% kills in the end, since the monster is completely excluded from the total monster count when it turns friendly.
That Blind Guy
Posts: 20
Joined: Fri Mar 10, 2017 8:18 am

Re: [Question] Monster Killed By Friendly Does Not Add to Co

Post by That Blind Guy »

Blue Shadow wrote:That shouldn't affect the ability to get 100% kills in the end, since the monster is completely excluded from the total monster count when it turns friendly.
The monster total does decrement when they turn friendly, but anything they kill won't add to the kill counter.

I'll just try a different effect for Mancubi and Revenants if there's nothing that can be done about this.
Blue Shadow
Posts: 5039
Joined: Sun Nov 14, 2010 12:59 am

Re: [Question] Monster Killed By Friendly Does Not Add to Co

Post by Blue Shadow »

My tests were done using that piece of code. All the monsters the friendly-turned monster killed counted as kills.

You might want to upload your mod for debugging.
That Blind Guy
Posts: 20
Joined: Fri Mar 10, 2017 8:18 am

Re: [Question] Monster Killed By Friendly Does Not Add to Co

Post by That Blind Guy »

Blue Shadow wrote:My tests were done using that piece of code. All the monsters the friendly-turned monster killed counted as kills.

You might want to upload your mod for debugging.
Don';t know why I didn't think of this earlier. I would be willing to bet it has something to do with the spawners. They're not RandomSpawner derivatives (an artifact of previous incarnations of the mod, QuakeStyle and QuakeStyle ZX), and they have produced strange issues before.

I'm gonna give this one last shot at fixing, then put it up for debugging.
That Blind Guy
Posts: 20
Joined: Fri Mar 10, 2017 8:18 am

Re: [Question] Monster Killed By Friendly Does Not Add to Co

Post by That Blind Guy »

I am a complete idiot...

I was looking at the wrong counter the whole time (my handle is actually true; I can barely see 3 feet in front of me :P ). The missing monsters were ones that failed to go through trap teleporters. I got frustrated and gave up on turning monsters friendly, changed it for something else, then noticed I was looking at the item counter just now. Oh well, I'm not putting it back in.

Nine years as a programmer, one of the top coders at my university, and I still do stuff like this.

Return to “Scripting”