Map restarts too quickly when this script kills player

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!)
Post Reply
User avatar
Enjay
 
 
Posts: 27070
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Map restarts too quickly when this script kills player

Post by Enjay »

This is just a "joke" Easter egg. If the player uses a vending machine that is clearly visibly malfunctioning (sparks, changing textures etc, and has an "out of order sign" and a "do not touch" one too) it runs a script that will kill the player. The machine is right near the start of the map too, so it's not that annoying.

Code: Select all

//Vending machine that has out of order sign
script 464 (void)
{
	ThrustThing (192, 16);
	DamageThing (20);
	delay(1);
	DamageThing (20);
	delay(1);
	DamageThing (20);
	delay(1);
	DamageThing (20);
	delay(1);
	DamageThing (20);
	delay(1);
	DamageThing (20);
	delay(1);
	DamageThing (20);
	delay(1);
	DamageThing (20);
	delay(1);
	DamageThing (20);
	delay(1);
	DamageThing (20);
	thingsound (23,"wep/rckt", 127);
	Spawnspot ("SpawnedExplosion", 23, 0, 0);
	ambientsound ("misc/chat", 127);

	SetHUDSize (640, 480, 0);
	hudmessage (s:"The sign told you not to touch.";
		HUDMSG_PLAIN|HUDMSG_LOG, 1, CR_GOLD, 320.4, 340.0, 3.0);
}
The problem is, often the player [USE] input seems to carry across and as soon as the player is dead, the map resets like it would do if a dead player pressed [USE]. As a result, the map often resets before the player has a chance to see the message or even for the sounds etc to be obvious. As a result, it feels clumsy - like the map has restarted for no good reason. I'm not sure why this happens - perhaps the player holding the [USE] button too long?

The repeated use of "DamageThing (20);" in the script was merely an attempt to get around this (i.e. I thought a slow-kill rather than an instakill might help. It didn't.)

What I need is a script that will thrust the player away from the machine, kill them, create the associated effects (sounds and explosion actor), put up the message and have it remain on screen long enough for the player to see it and realise what has happened. So, basically I need some way of ensuring that the player has a chance to see the message before they then deliberately press [USE] to restart the map.

Anyone any ideas on how to do this cleanly?
User avatar
Caligari87
Admin
Posts: 6233
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: Map restarts too quickly when this script kills player

Post by Caligari87 »

A few possible solutions:
  1. Give the player the BUDDHA flag so the script it doesn't actually kill them, give the player TOTALLY_FROZEN so they can't react, do your damage and knockback effect, and then kill the player once the effect is complete.
  2. With some ZScript you can block the player's [Use] button with something like player.cmd.buttons&=~BT_USE;. Of course this would require mixing ZScript and ACS, however you could theoretically do this entirely in ZScript to begin with.
  3. Don't kill the player, just damage them and display the message + do the knockback if they use the machine. If they do it again without enough health then, well...
Personally I'd lean toward the latter, just because it's less frustrating and gives the player some agency in the matter.

8-)
User avatar
Enjay
 
 
Posts: 27070
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Map restarts too quickly when this script kills player

Post by Enjay »

Oooh, the BUDDHA flag might be the way forward. Thank you.

Normally I would go for #3 (for the reasons that you state) but the fatal machine (that's a good name for... I dunno, something: a band, a song, a book, a Doom mod, whatever)...

Anyway, the fatal machine is actually part 2 of the "joke". Just beforehand, there is a machine that is visibly faulty, but nothing like as bad as the fatal one. This first machine does a bit of damage, in the way that you suggest. i.e. it gives an even bigger clue that the fatal one is likely to be much worse because it looks much worse. So, I figured that, with all the clues, and the probability of a "training" machine being used, the player should have no excuse for not knowing that [USE]ing the fatal machine is going to be bad, if not fatal. Otherwise, yeah, just killing the player would be a bit of a dick move.

But, also, like I said, it is right at the start of the map (so no real progression will have been made) and the map itself is actually really just a mission and difficulty choice map (same function as the start map in Quake). So the player hasn't really even started playing, chosen a difficulty setting or an actual map when/if this happens.

Even then, I guess the "joke" may fall flat (hence the quotes around joke) so once I have it up and running I will evaluate how worthwhile it is.
Post Reply

Return to “Scripting”