Jump to content

Counting kills with ACS and Infighting


Recommended Posts

Hi!

In my map I'm creating an encounter that only ends (opens up Doors etc.) when a certain killcount is met. What I have noticed is that, at least with GZDoom, kills that happen via infighting do NOT call my script. That basically means that if too many infighting kills happen, the doors just won't open. Is there a fix for that, some kind of property I can set so that infighting kills also count as script triggers?

 

This is how my script is setup right now, though I doubt that's the problem:

int killCount1;

script "LightRoomEncounterCounter" (void){
	killCount1++;
	Print(s:"Trigger!", i:killCount1);
	if (killCount1 >= 16){
		Delay(105);
		Sector_SetColor(22,255,255,255,0);
		Light_ChangeToValue(24,150);
		Delay(70);
		Door_Open(21,32);
		Floor_LowerByValueTimes8(23,32,20);
	}
}

 

Thank you!

Share this post


Link to post

And of course, as it so happens all the time... I figured it out two minutes after I posted here lol.

 

The solution is using Action 226 "Script Execute Always" on the monsters, not 80 "Script Execute".

Share this post


Link to post

It's weird that the infighting is causing this issue, because the script (if called from a monster) will activate whenever the monster dies, no matter how.

Usually what causes issues in examples like this is when 2 or more monsters die simultaneously.

 

You can actually get rid of any possible issue with a script that's not triggered by the monsters though, like this:

//let the player activate a trigger to call this script
script "LightRoomEncounterCounter" (int tid) { //you could also have a ENTER or OPEN script if you want to let it run at the very beginning of the map, but then you can't use the tid argument
	while(ThingCount(T_NONE, tid) > 0)
		Delay(7); //the script will be stuck in this loop until there are monster with the specified "tid"
	//when they are all dead, then it will pas through
	Delay(105); 
	Sector_SetColor(22,255,255,255,0);
	Light_ChangeToValue(24,150);
	Delay(70);
	Door_Open(21,32);
	Floor_LowerByValueTimes8(23,32,20);
}

 

just give all of the monsters you want a specific tag and set the script argument (in the action/tag/misc. tab of the trigger) "tid" to be exactly that number and you're done.

Remember, of course, to not give other monsters that are not meant to be killed in this instance the same tag.

Share this post


Link to post

Huh this is interesting, though it doesn't seem like them dying simultaneously is a problem. I've tried this encounter countless times now and I kill multiple enemies with one SS shot all the time, no issues with the script. Is there something else that could kill multiple enemies in the same tic that causes this issue?

Thanks though, that is an interesting way to do this kind of stuff as well.

Share this post


Link to post

An advantage of the solution Kan3 posted (which is indeed the most common solution to this problem) is that it's independent of the number of monsters, and doesn't require all monsters to have the action set. So if you have different monsters on different difficulties it'll just work out of the box.

Share this post


Link to post
23 hours ago, dasfrodo said:

Huh this is interesting, though it doesn't seem like them dying simultaneously is a problem. I've tried this encounter countless times now and I kill multiple enemies with one SS shot all the time, no issues with the script. Is there something else that could kill multiple enemies in the same tic that causes this issue?

Thanks though, that is an interesting way to do this kind of stuff as well.

Unfortunately I couldn't recreate that "behavior": I set up 6 shotgunners with your same script and let them infight without killing myself any one of them except for the last one, but the script run 6 times (one for each monster) as expected.

 

Anything that may kill more than 1 monster in the same tic can cause the issue, literally, simply because the same script cannot run simultaneously (unless using ExecuteAlways). If you never encountered this kind of issue while killing 2 or more monsters at once, is because they didn't die in the exact same tic.

Share this post


Link to post

 

41 minutes ago, Kan3 said:

Unfortunately I couldn't recreate that "behavior": I set up 6 shotgunners with your same script and let them infight without killing myself any one of them except for the last one, but the script run 6 times (one for each monster) as expected.

 

Anything that may kill more than 1 monster in the same tic can cause the issue, literally, simply because the same script cannot run simultaneously (unless using ExecuteAlways). If you never encountered this kind of issue while killing 2 or more monsters at once, is because they didn't die in the exact same tic.

 

When I was still using the default Execute Script I had the issue that my counter didn't work, and that was due to the infighting and maybe also due to kills on the same tic. I just can't confirm that since you know, the script didn't run as intended in the first place due to the infighting. But ever since I switched to ExecuteAlways I don't have either of these problems, which makes sense considering ExecuteAlways doesn't have the limitation of one execution per tic.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...