/* Copyright (c) 2002-2012 Croteam Ltd. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ 702 %{ #include "StdH.h" %} class CWatchPlayers: CRationalEntity { name "Watch Players"; thumbnail "Thumbnails\\WatchPlayers.tbn"; features "HasName", "IsTargetable"; properties: 1 CEntityPointer m_penOwner "Owner/Target" 'O' COLOR(C_dBROWN|0xFF), // entity which owns it / target 10 CEntityPointer m_penFar "Far Target" 'F' COLOR(C_BLACK|0xFF), // entity which owns it / target 2 FLOAT m_fWaitTime "Wait time" 'W' = 0.1f, // watch time 3 RANGE m_fDistance "Watch distance" 'D' = 100.0f, // distance when player is seen 4 BOOL m_bRangeWatcher "Range watcher" 'R' = TRUE, // range watcher 5 enum EventEType m_eetEventClose "Close Event type" 'T' = EET_TRIGGER, // type of event to send 6 enum EventEType m_eetEventFar "Far Event type" 'Y' = EET_ENVIRONMENTSTOP, // type of event to send 7 CEntityPointer m_penCurrentWatch, 8 BOOL m_bActive "Active" 'A' = TRUE, 9 CTString m_strName "Name" 'N' = "", components: 1 model MODEL_WATCHPLAYERS "Models\\Editor\\WatchPlayers.mdl", 2 texture TEXTURE_WATCHPLAYERS "Models\\Editor\\WatchPlayers.tex" functions: /************************************************************ * USER FUNCTIONS * ************************************************************/ // check if any player is close BOOL IsAnyPlayerClose(void) { // far enough to not move at all FLOAT fClosest = 100000.0f; FLOAT fDistance; m_penCurrentWatch = NULL; // for all players for (INDEX iPlayer=0; iPlayerGetFlags()&ENF_ALIVE && !(penPlayer->GetFlags()&ENF_INVISIBLE)) { fDistance = 100000.0f; if (m_bRangeWatcher) { // calculate distance to player from wathcer fDistance = (penPlayer->GetPlacement().pl_PositionVector- GetPlacement().pl_PositionVector).Length(); } else { if (m_penOwner!=NULL) { // calculate distance to player from owner fDistance = (penPlayer->GetPlacement().pl_PositionVector- m_penOwner->GetPlacement().pl_PositionVector).Length(); } } if (fDistance