/* Copyright (c) 2002-2012 Croteam Ltd. All rights reserved. */ 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