Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
Dravencour

Hitting a snag with a monster door...

Question

So I'm designing a "miniboss battle" to end a map (more of a test-map really), and I am using ACS.

 

I have four Hellknights, and while I could just use a while/ThingCount loop to handle the fight in general (I did the same thing with a battle with spawned imps to open a previous door), I want to set things up so that it counts the number remaining as each of them fall ("three more to go...", "two more to go...", what have you), with the intent of opening the final door once all of them are dead. Only both of the methods that I have used so far (switch/case and suspend) fail the Double Kill Test. In other words, when you kill two or more of them at once (which is quite easy with weapons like rocket launchers, super shotguns and BFGs), the script only counts it as one kill, resulting in the countdown not finishing and the door not opening. For obvious reasons, this is not acceptable.

 

I want to make this work, but everything I am trying so far is meeting with failure. What do I have to do?

Edited by Dravencour

Share this post


Link to post

6 answers to this question

Recommended Posts

  • 1

Assuming the monsters call the script upon death, make sure to set their action to ACS_ExecuteAlways instead of ACS_Execute, because the latter doesn't allow multiple instances of the same script to be running at the same time, which may cause problems if multiple monsters die at once.

Share this post


Link to post
  • 0

You should give all the hell knights the same thing ID then in the script poll the amount of living HKs by using ThingCount on them and checking to see if it returns 0, if it does then they are dead so open the door, if it isn't 0 they aren't all dead so do nothing. The zdoom wiki actually has an example for this exact thing on the page for ThingCount

 

https://zdoom.org/wiki/ThingCount

 

Just replace T_BARON with T_HELLKNIGHT and Floor_LowerToLowest with Door_Raise or Door_LockedRaise or whatever function you want your door to have and of course put in the right sector and arguments for your particular door

 

Share this post


Link to post
  • 0
29 minutes ago, scifista42 said:

Assuming the monsters call the script upon death, make sure to set their action to ACS_ExecuteAlways instead of ACS_Execute, because the latter doesn't allow multiple instances of the same script to be running at the same time, which may cause problems if multiple monsters die at once.

I tested your advice out with both of my previous approaches. It didn't work with Suspend, which to be perfectly frank shouldn't be used with a monster door anyway, but it did work with Switch/Case, which I tested out by using the BFG on them. It killed two of them at a time, and it jumped straight to Case 2 instead of Case 3.

 

Thank you very much!

Share this post


Link to post
  • 0
41 minutes ago, therektafire said:

You should give all the hell knights the same thing ID then in the script poll the amount of living HKs by using ThingCount on them and checking to see if it returns 0, if it does then they are dead so open the door, if it isn't 0 they aren't all dead so do nothing. The zdoom wiki actually has an example for this exact thing on the page for ThingCount

 

https://zdoom.org/wiki/ThingCount

 

Just replace T_BARON with T_HELLKNIGHT and Floor_LowerToLowest with Door_Raise or Door_LockedRaise or whatever function you want your door to have and of course put in the right sector and arguments for your particular door

 

I mentioned the while/ThingCount loop thing in my OP, and it's something I used for a spawned imp battle earlier on in the map with much success. If I didn't want to put a countdown on screen ("three more to go...", "two more to go...") as each of them fell, I would have just reused that script for the Hellknights. Thankfully, Switch/Case combined with ACS_ExecuteAlways did just what I needed to handle the problem.

Share this post


Link to post
  • 0

Describing your script merely by words like "while/ThingCount loop" or "switch/case method" is too vague to tell why it's not working as you wanted it and what you should change to make it work. Next time, post your script's actual code, and possibly also properties of the lines/things that execute it.

Share this post


Link to post
  • 0

These were the two codes I used for the Imp fight and Hell Knight fight, respectively:

 

This code was used for the Imp spawner fight in the second room of the map. The Imp Spawner activates when the player crosses the linedef to pick up the chaingun, and spawns Imps four times before quitting. A simple While loop using ThingCount was used to keep the door closed until all the Imps were dead.

script 2 (void) // Imp Spawner Fight
{
// Imps spawn from the four same-tagged map spots when the player hits the linedef.
// This For loop activates four times before it quits with a two second delay, so the
// player will have to kill sixteen Imps before the door will open.
	print (s:"Show them no mercy!");
	for (int i = 0; i < 4; i++)
	{
		Thing_SpawnFacing (1, T_IMP, 0, 8);
		Delay (35 * 2);
	}
// When all spawned Imps are dead, the door opens	
	while (ThingCount(T_IMP, 8) > 0)
	{
		Delay (35);
	}
	print (s:"Well Done!");
	Door_Open (2, 32, 0);
}

For the Hell Knight fight that I was talking about in the OP, I used a different tack:

script 4 (void) // Hell Knight Showdown
{
	knightCount--;
	switch(knightCount)
	{
// Three Hell Knights left		
		case 3:
		print (s:"Three more to go...");
		break;
// Two Hell Knights left		
		case 2:
		print (s:"Two more to go...");
		break;
// One Hell Knight left		
		case 1:
		print (s:"One enemy remains! Finish it!");
		break;
// All Hell Knights killed		
		case 0:
		print (s:"Well Done!");
		Door_Open (4, 32, 0);
	}
}

knightCount is a variable that I defined near the beginning of the script, after the two bools for the switches in the very first room. I had this variable set to the number of Hell Knights in the room (4) before the final door. Before, killing two Hell Knights at once would have advanced the script to the next numbered case instead of jumping to the case it was supposed to have gone to. But because I now have all four Hell Knights set to ACS_ExecuteAlways, killing two Hell Knights instead jumps the script to the case corresponding to the number of Hell Knights actually remaining.

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×