Simon Volpert zdoomrl / master nukebarrel / NukeBarrelMarkers.acs
master

Tree @master (Download .tar.gz)

NukeBarrelMarkers.acs @masterraw · history · blame

// ZDoomRL - Gameplay Modifications for DoomRL Arsenal
// Author: Simon Volpert <simon@simonvolpert.com>
// Project page: https://simonvolpert.com/zdoomrl/
// This program is free software, released under the MIT license. See the LICENSE file for more information

#library "NukeBarrelMarkers"
#include "zcommon.acs"

bool nukes;


// Mark the positions on nuclear barrels on the automap
script "NuclearBarrelEarlyWarningSystem" Enter {
	if (GetCvar("Debug")) {
		Log(s:"nuclear barrel early warning system activated");
	}
	// Let normal pickup/level start messages to time out
	Delay(2);
	while (CheckInventory("ZSNukeWarningDelay")){
		Delay(1);
	}
	while (TRUE) {
		// Place the detector ping
		GiveInventory("ZSNuclearBarrelDetector", 1);
		Delay(18);
		// Warn about any active nukes
		if (nukes) {
			Print(s:"\caWarning: \cgNuclear device detected!");
			PlaySound(0, "misc/nukebeep", CHAN_AUTO);
			nukes = FALSE;
		}
	}
}


// Mark the position of the calling nuclear barrel
script "PlaceDangerSign" (void) {
	// Don't place redundant marks
	if (CheckInventory("ZSNuclearBarrelBeacon")) {
		terminate;
	}
	GiveInventory("ZSNuclearBarrelBeacon", 1);
	// Tell the Early Warning script there are nukes on the level
	nukes = TRUE;
	// Place the map marker
	int tid = UniqueTID();
	if (GetCvar("Debug")) {
		Log(s:"marked nuclear barrel ", i:tid);
	}
	Spawn("ZSNuclearBarrelMapMarker", GetActorX(0), GetActorY(0), GetActorZ(0), tid, 0);
	// Remove the map marker once the barrel is destroyed
	while (GetActorProperty(0, APROP_Health) > 0) {
		Delay(1);
	}
	if (GetCvar("Debug")) {
		Log(s:"removed nuclear barrel marker ", i:tid);
	}
	Thing_Remove(tid);
}