/* =========================================================================== IceTech GPL Source Code Copyright (C) 2026 Justin Marshall This file is part of the IceTech GPL Source Code (?IceTech Source Code?). IceTech Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. IceTech Source Code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with IceTech Source Code. If not, see . In addition, the IceTech Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the IceTech Source Code. If not, please request a copy in writing from id Software at the address below. If you have questions concerning this license or the applicable additional terms, you may contact in writing Justin Marshall, justinmarshall20@gmail.com =========================================================================== */ #ifndef __GAME_TRIGGER_H__ #define __GAME_TRIGGER_H__ /* =============================================================================== Trigger base. =============================================================================== */ class idTrigger : public idEntity { public: CLASS_PROTOTYPE( idTrigger ); static void DrawDebugInfo( void ); idTrigger(); void Spawn( void ); const function_t * GetScriptFunction( void ) const; void Save( idSaveGame *savefile ) const; void Restore( idRestoreGame *savefile ); virtual void Enable( void ); virtual void Disable( void ); protected: void CallScript( void ) const; ID_SCRIPT_EVENT( "enable", 0 ) void Event_Enable( void ); ID_SCRIPT_EVENT( "disable", 0 ) void Event_Disable( void ); const function_t * scriptFunction; }; /* =============================================================================== Trigger which can be activated multiple times. =============================================================================== */ class idTrigger_Multi : public idTrigger { public: CLASS_PROTOTYPE( idTrigger_Multi ); idTrigger_Multi( void ); void Spawn( void ); void Save( idSaveGame *savefile ) const; void Restore( idRestoreGame *savefile ); private: float wait; float random; float delay; float random_delay; int nextTriggerTime; idStr requires; int removeItem; bool touchClient; bool touchOther; bool triggerFirst; bool triggerWithSelf; bool CheckFacing( idEntity *activator ); void TriggerAction( idEntity *activator ); ID_SCRIPT_EVENT( "", 0 ) void Event_TriggerAction( idEntity *activator ); ID_SCRIPT_EVENT( "activate", 0 ) void Event_Trigger( idEntity *activator ); ID_SCRIPT_EVENT( "", 0 ) void Event_Touch( idEntity *other, trace_t *trace ); }; /* =============================================================================== Trigger which can only be activated by an entity with a specific name. =============================================================================== */ class idTrigger_EntityName : public idTrigger { public: CLASS_PROTOTYPE( idTrigger_EntityName ); idTrigger_EntityName( void ); void Save( idSaveGame *savefile ) const; void Restore( idRestoreGame *savefile ); void Spawn( void ); private: float wait; float random; float delay; float random_delay; int nextTriggerTime; bool triggerFirst; idStr entityName; void TriggerAction( idEntity *activator ); ID_SCRIPT_EVENT( "", 0 ) void Event_TriggerAction( idEntity *activator ); ID_SCRIPT_EVENT( "activate", 0 ) void Event_Trigger( idEntity *activator ); ID_SCRIPT_EVENT( "", 0 ) void Event_Touch( idEntity *other, trace_t *trace ); }; /* =============================================================================== Trigger which repeatedly fires targets. =============================================================================== */ class idTrigger_Timer : public idTrigger { public: CLASS_PROTOTYPE( idTrigger_Timer ); idTrigger_Timer( void ); void Save( idSaveGame *savefile ) const; void Restore( idRestoreGame *savefile ); void Spawn( void ); virtual void Enable( void ); virtual void Disable( void ); private: float random; float wait; bool on; float delay; idStr onName; idStr offName; ID_SCRIPT_EVENT( "", 0 ) void Event_Timer( void ); ID_SCRIPT_EVENT( "activate", 0 ) void Event_Use( idEntity *activator ); }; /* =============================================================================== Trigger which fires targets after being activated a specific number of times. =============================================================================== */ class idTrigger_Count : public idTrigger { public: CLASS_PROTOTYPE( idTrigger_Count ); idTrigger_Count( void ); void Save( idSaveGame *savefile ) const; void Restore( idRestoreGame *savefile ); void Spawn( void ); private: int goal; int count; float delay; ID_SCRIPT_EVENT( "activate", 0 ) void Event_Trigger( idEntity *activator ); ID_SCRIPT_EVENT( "", 0 ) void Event_TriggerAction( idEntity *activator ); }; /* =============================================================================== Trigger which hurts touching entities. =============================================================================== */ class idTrigger_Hurt : public idTrigger { public: CLASS_PROTOTYPE( idTrigger_Hurt ); idTrigger_Hurt( void ); void Save( idSaveGame *savefile ) const; void Restore( idRestoreGame *savefile ); void Spawn( void ); private: bool on; float delay; int nextTime; ID_SCRIPT_EVENT( "", 0 ) void Event_Touch( idEntity *other, trace_t *trace ); ID_SCRIPT_EVENT( "activate", 0 ) void Event_Toggle( idEntity *activator ); }; /* =============================================================================== Trigger which fades the player view. =============================================================================== */ class idTrigger_Fade : public idTrigger { public: CLASS_PROTOTYPE( idTrigger_Fade ); private: ID_SCRIPT_EVENT( "activate", 0 ) void Event_Trigger( idEntity *activator ); }; /* =============================================================================== Trigger which continuously tests whether other entities are touching it. =============================================================================== */ class idTrigger_Touch : public idTrigger { public: CLASS_PROTOTYPE( idTrigger_Touch ); idTrigger_Touch( void ); void Spawn( void ); virtual void Think( void ); void Save( idSaveGame *savefile ); void Restore( idRestoreGame *savefile ); virtual void Enable( void ); virtual void Disable( void ); void TouchEntities( void ); private: idClipModel * clipModel; ID_SCRIPT_EVENT( "activate", 0 ) void Event_Trigger( idEntity *activator ); }; #endif /* !__GAME_TRIGGER_H__ */