/* ------------------------------------------------------------------------------------ */
bool CLogic::GetLTriggerState(const char *Name)
{
	LState *pool;

	char *EntityType = CCD->EntityRegistry()->GetEntityType(Name);

	if(EntityType)
	{
		if(!stricmp(EntityType, "LogicGate"))
		{
			pool=Bottom;

			while(pool != NULL)
			{
				if(!stricmp(Name, pool->Name))
					return pool->state;

				pool = pool->next;
			}

			char szError[256];
			sprintf(szError, "[WARNING] File %s - Line %d: Invalid Trigger Name '%s'\n",
					__FILE__, __LINE__, Name);
			CCD->ReportError(szError, false);
			return false;
		}
	}

	return GetTriggerState(Name);
}
/* ------------------------------------------------------------------------------------ */
bool CChangeLevel::CheckChangeLevel(geWorld_Model *theModel, bool UseKey)
{
	geEntity_EntitySet *pSet;
	geEntity *pEntity;

	//	Ok, see if we have any changelevel entities at all
	pSet = geWorld_GetEntitySet(CCD->World(), "ChangeLevel");

	if(!pSet)
		return false;				// This model is no exit

	//	Look through all of our changelevels to see if the model
	//	..we hit is one of 'em.
	for(pEntity=geEntity_EntitySetGetNextEntity(pSet, NULL); pEntity;
		pEntity=geEntity_EntitySetGetNextEntity(pSet, pEntity))
	{
		ChangeLevel *pItem = (ChangeLevel*)geEntity_GetUserData(pEntity);

		if(pItem->Model == theModel)
		{
			if(UseKey && !pItem->UseKey)
				continue;

			if(!EffectC_IsStringNull(pItem->Trigger))
			{
				if(!GetTriggerState(pItem->Trigger))
				{
					if(!pItem->CallBack)
					{
						pItem->CallBack = GE_TRUE;
						pItem->CallBackCount = 2;
					}

					continue;
				}
				else
				{
					CCD->SetChangeLevelData(pItem);
					return true;
				}
			}
			else
			{
				// Hmm, we DID hit one.  Save offf the new level filename and the
				// ..splash screen name for later, so that the framework can get
				// ..to this information.
				CCD->SetChangeLevelData(pItem);
				return true;
			}
		}
	}

	return false;									// Nope, not a changelevel model
}
/* ------------------------------------------------------------------------------------ */
void CChangeLevel::Tick(geFloat dwTicks)
{
	geEntity_EntitySet *pSet;
	geEntity *pEntity;

	//	Ok, see if we have any changelevel entities at all
	pSet = geWorld_GetEntitySet(CCD->World(), "ChangeLevel");

	if(!pSet)
		return;

	//	Look through all of our changelevels to see if the model
	//	..we hit is one of 'em.
	for(pEntity=geEntity_EntitySetGetNextEntity(pSet, NULL); pEntity;
		pEntity=geEntity_EntitySetGetNextEntity(pSet, pEntity))
	{
		ChangeLevel *pItem = (ChangeLevel*)geEntity_GetUserData(pEntity);

// change RF063
		if(!EffectC_IsStringNull(pItem->TriggerChange))
		{
			if(GetTriggerState(pItem->TriggerChange))
			{
				CCD->SetChangeLevelData(pItem);
// changed RF064
				CCD->SetChangeLevel(true);
				CCD->SetKeyPaused(false);
				//CCD->HUD()->Activate();
// end change RF064
				return;
			}
		}
// end change RF063

		if(pItem->CallBack == GE_TRUE)
		{
			pItem->CallBackCount -= 1;
			if(pItem->CallBackCount == 0)
				pItem->CallBack = GE_FALSE;
		}
	}
}
Exemple #4
0
void EAnalogTrigger::Update()
{
	StateType newState;
	
	newState = GetTriggerState() ? kStateOpen : kStateClosed;
	if (newState == m_trigger.state)
	{
		m_trigger.event = kEventNone;
	}
	else
	{
		if (kStateClosed == newState)
		{
			m_trigger.event = kEventClosed;
		}
		else
		{
			m_trigger.event = kEventOpened;
		}
		m_trigger.state = newState;
	}
}
/* ------------------------------------------------------------------------------------ */
geBoolean CDSpotLight::Tick(geFloat dwTicks)
{
	geEntity_EntitySet *pSet;
	geEntity *pEntity;

	if(CCD->World() == NULL)
		return GE_TRUE;

	pSet = geWorld_GetEntitySet(CCD->World(), "DSpotLight");

	if(!pSet)
		return GE_TRUE;

	for(pEntity=geEntity_EntitySetGetNextEntity(pSet, NULL); pEntity;
		pEntity=geEntity_EntitySetGetNextEntity(pSet, pEntity))
	{
		DSpotLight *Light;
		geFloat		Radius;
		geFloat		Percentage;
		int			Index;
		geVec3d		Pos;
		int32		Leaf;

		Light = (DSpotLight*)geEntity_GetUserData(pEntity);

		if(!EffectC_IsStringNull(Light->TriggerName))
		{
			if(GetTriggerState(Light->TriggerName))
			{
				if(Light->active == GE_FALSE)
				{
					Light->DynLight = geWorld_AddLight(CCD->World());
					Light->active = GE_TRUE;
				}
			}
			else
			{
				if(Light->active == GE_TRUE)
					geWorld_RemoveLight(CCD->World(), Light->DynLight);

				Light->active = GE_FALSE;
			}
		}
		else
		{
			if(Light->active == GE_FALSE)
			{
				Light->DynLight = geWorld_AddLight(CCD->World());
				Light->active = GE_TRUE;
			//	CCD->ReportError("DSpotLight light added", false);
			}
		}

		if(Light->active == GE_TRUE)
		{
			// pass the OriginOffset to SetOrigin
            // so that the light will stay in the same position relative to the model.
            Light->origin = Light->OriginOffset;
			SetOriginOffset(Light->EntityName, Light->BoneName, Light->Model, &(Light->origin));
			geWorld_GetLeaf(CCD->World(), &(Light->origin), &Leaf);
			Pos = Light->origin;

			if(Light->Rotate)
			{
				if(Light->Model)
				{
					geXForm3d Xf;
					geVec3d  Tmp;
					geWorld_GetModelXForm(CCD->World(), Light->Model, &Xf);
					geXForm3d_GetEulerAngles(&Xf, &Tmp);
					geVec3d_Add(&(Light->RealAngle), &Tmp, &(Light->angles));

					geVec3d_Scale(&(Light->angles), GE_180OVERPI, &(Light->angles));
				}
				else if(!EffectC_IsStringNull(Light->EntityName))
				{
					// changed QD 07/15/06
					/*
					geXForm3d BoneXForm;
					geActor	*theActor;

					theActor = GetEntityActor(Light->EntityName);

					if(!EffectC_IsStringNull(Light->BoneName))
					{
						if(geActor_GetBoneTransform(theActor, Light->BoneName, &BoneXForm) != GE_TRUE)
							continue;					// No such bone
					}
					else
					{
						if(geActor_GetBoneTransform(theActor, RootBoneName(theActor), &BoneXForm) != GE_TRUE)
							continue;					// No such bone
					}

					geXForm3d_RotateY(&BoneXForm, Light->RealAngle.Y);
					geXForm3d_GetEulerAngles(&BoneXForm, &(Light->angles));
					Light->angles.Z += Light->RealAngle.Z;

					*/
					SetAngle(Light->EntityName, Light->BoneName, &(Light->angles));

					if(Light->RealAngle.X || Light->RealAngle.Y || Light->RealAngle.Z)
					{
						geXForm3d XForm, BoneXForm;

						geXForm3d_SetZRotation(&XForm, Light->RealAngle.Z);
						geXForm3d_RotateX(&XForm, Light->RealAngle.X);
						geXForm3d_RotateY(&XForm, Light->RealAngle.Y);

						geXForm3d_SetZRotation(&BoneXForm, Light->angles.Z);
						geXForm3d_RotateX(&BoneXForm, Light->angles.X);
						geXForm3d_RotateY(&BoneXForm, Light->angles.Y);

						geXForm3d_Multiply(&BoneXForm, &XForm, &XForm);
						geXForm3d_GetEulerAngles(&XForm, &(Light->angles));
					}
					// end change QD 07/15/06

					// convert to degrees
					geVec3d_Scale(&(Light->angles), GE_180OVERPI, &(Light->angles));

				}
			}


			Percentage = Light->LastTime / Light->RadiusSpeed;

			Index = (int)(Percentage * Light->NumFunctionValues);

			if(Light->InterpolateValues && Index < Light->NumFunctionValues - 1)
			{
				geFloat	Remainder;
				geFloat	InterpolationPercentage;
				int		DeltaValue;
				geFloat	Value;

				Remainder = (geFloat)fmod(Light->LastTime, Light->IntervalWidth);
				InterpolationPercentage = Remainder / Light->IntervalWidth;
				DeltaValue = Light->RadiusFunction[Index + 1] - Light->RadiusFunction[Index];
				Value = Light->RadiusFunction[Index] + DeltaValue * InterpolationPercentage;
				Percentage = ((geFloat)(Value - 'a')) / ((geFloat)('z' - 'a'));
			}
			else
				Percentage = ((geFloat)(Light->RadiusFunction[Index] - 'a')) / ((geFloat)('z' - 'a'));

			Radius = Percentage * (Light->MaxRadius - Light->MinRadius) + Light->MinRadius;

			// angles in degrees
			geWorld_SetSpotLightAttributes(CCD->World(),
										   Light->DynLight,
										   &Pos,
										   &(Light->Color),
										   Radius,
										   Light->arc,
										   &(Light->angles),
										   Light->style,
										   Light->CastShadows);

			Light->LastTime = (geFloat)fmod(Light->LastTime + dwTicks, Light->RadiusSpeed);

			if(EffectC_IsPointVisible(CCD->World(),
					CCD->CameraManager()->Camera(),
					&Pos,
					Leaf,
					EFFECTC_CLIP_LEAF ) == GE_FALSE)
			{
				geWorld_RemoveLight(CCD->World(), Light->DynLight);
				Light->active = GE_FALSE;
			}
		}
	}

	return GE_TRUE;
}
/* ------------------------------------------------------------------------------------ */
bool ControllerObject::method(const skString& methodName, skRValueArray& arguments,
							  skRValue& returnValue, skExecutableContext& ctxt)
{
	char  string1[128], string2[128];
	float float1;
	bool  bool1;
//	int   int1;

	string1[0] = '\0';
	string2[0] = '\0';

	if(IS_METHOD(methodName, "SetPlatformTargetTime"))
	{
		PARMCHECK(2);
		strcpy(string1, arguments[0].str());
		float1 = arguments[1].floatValue();
		MovingPlatform *pEntity;
		CCD->Platforms()->LocateEntity(string1, (void**)&pEntity);
		CCD->ModelManager()->SetTargetTime(pEntity->Model, float1);
		return true;
	}
	else if(IS_METHOD(methodName, "GetPlatformTargetTime"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
		MovingPlatform *pEntity;
		CCD->Platforms()->LocateEntity(string1, (void**)&pEntity);
		CCD->ModelManager()->GetTargetTime(pEntity->Model, &float1);
		returnValue = (float)float1;
		return true;
	}
	else if(IS_METHOD(methodName, "GetPlatformCurrentTime"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
		MovingPlatform *pEntity;
		CCD->Platforms()->LocateEntity(string1, (void**)&pEntity);
		CCD->ModelManager()->GetModelCurrentTime(pEntity->Model, &float1);
		returnValue = (float)float1;
		return true;
	}
	else if(IS_METHOD(methodName, "PlatformCollision"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
		MovingPlatform *pEntity;
		CCD->Platforms()->LocateEntity(string1, (void**)&pEntity);
		CCD->ModelManager()->ModelInCollision(pEntity->Model, &bool1);
		returnValue = (bool)bool1;
		return true;
	}

	if(IS_METHOD(methodName, "SetDoorTargetTime"))
	{
		PARMCHECK(2);
		strcpy(string1, arguments[0].str());
		float1 = arguments[1].floatValue();
		Door *pEntity;
		CCD->Doors()->LocateEntity(string1, (void**)&pEntity);
		CCD->ModelManager()->SetTargetTime(pEntity->Model, float1);
		return true;
	}
	else if(IS_METHOD(methodName, "GetDoorTargetTime"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
		Door *pEntity;
		CCD->Doors()->LocateEntity(string1, (void**)&pEntity);
		CCD->ModelManager()->GetTargetTime(pEntity->Model, &float1);
		returnValue = (float)float1;
		return true;
	}
	else if(IS_METHOD(methodName, "GetDoorCurrentTime"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
		Door *pEntity;
		CCD->Doors()->LocateEntity(string1, (void**)&pEntity);
		CCD->ModelManager()->GetModelCurrentTime(pEntity->Model, &float1);
		returnValue = (float)float1;
		return true;
	}
	else if(IS_METHOD(methodName, "DoorCollision"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
		Door *pEntity;
		CCD->Doors()->LocateEntity(string1, (void**)&pEntity);
		CCD->ModelManager()->ModelInCollision(pEntity->Model, &bool1);
		returnValue = (bool)bool1;
		return true;
	}
	else if(IS_METHOD(methodName, "ShowWallDecal"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
		CCD->WallDecals()->SetProgrammedTrigger(string1, GE_TRUE);
		return true;
	}
	else if(IS_METHOD(methodName, "HideWallDecal"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
		CCD->WallDecals()->SetProgrammedTrigger(string1, GE_FALSE);
		return true;
	}
	else if(IS_METHOD(methodName, "SetWallDecalBitmap"))
	{
		PARMCHECK(2);
		strcpy(string1, arguments[0].str());
		int bmnum = arguments[1].intValue();
		CCD->WallDecals()->SetCurrentBitmap(string1, bmnum);
		return true;
	}
	else if(IS_METHOD(methodName, "ActivateTrigger"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
		CCD->Triggers()->HandleTriggerEvent(string1);
		return true;
	}
	else if(IS_METHOD(methodName, "GetEventState"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
		returnValue = (bool)GetTriggerState(string1);
		return true;
	}
	else if(IS_METHOD(methodName, "SetEventState"))
	{
		PARMCHECK(2);
		strcpy(string1, arguments[0].str());
		bool flag = arguments[1].boolValue();
		CCD->Pawns()->AddEvent(string1, flag);
		return true;
	}
	else if(IS_METHOD(methodName, "Start3DAudioSource"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
		CCD->Audio3D()->SetProgrammedTrigger(string1, GE_TRUE);
		return true;
	}
	else if(IS_METHOD(methodName, "Stop3DAudioSource"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
		CCD->Audio3D()->SetProgrammedTrigger(string1, GE_FALSE);
		return true;
	}
	else if(IS_METHOD(methodName, "Get3DAudioSourceState"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
		bool state = CCD->Audio3D()->IsPlaying(string1);
		returnValue = (bool)state;
		return true;
	}
	else if(IS_METHOD(methodName, "PlaySound"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());

		if(!EffectC_IsStringNull(string1))
		{
			geVec3d Position = CCD->Player()->Position();
			Snd Sound;

			memset(&Sound, 0, sizeof(Sound));
			geVec3d_Copy(&Position, &(Sound.Pos));
			Sound.Min = CCD->GetAudibleRadius();

			if(arguments.entries() == 2)
				Sound.Min = arguments[1].floatValue();

			Sound.Loop = GE_FALSE;
			Sound.SoundDef = SPool_Sound(string1);

			if(Sound.SoundDef != NULL)
				CCD->EffectManager()->Item_Add(EFF_SND, (void*)&Sound);
		}

		return true;
	}
// changed Nout 12/15/05
	// ShowText(Nr, EntityName, Animation, TextString, FontNr, TextSound, ScreenOffsetX, ScreenOffsetY, Align, Alpha);
	// Shows a TextMessage on the screen, attached to a Pawn or Player
	// Align can be Right, Left or Centre. If left open, Right is used.
	// The text can include a # to print it in multiple lines
	else if(IS_METHOD(methodName, "ShowText"))
	{
		int Nr = arguments[0].intValue();

		if(Nr < 0 || Nr >= MAXTEXT)
			return true;

		if(arguments.entries() > 1)
		{
			strcpy(CCD->Pawns()->TextMessage[Nr].EntityName, arguments[1].str());
			strcpy(CCD->Pawns()->TextMessage[Nr].AnimName, arguments[2].str());
			//strcpy(CCD->Pawns()->TextMessage[Nr].TextString, arguments[3].str());
			CCD->Pawns()->TextMessage[Nr].TextString = arguments[3].str();
			Replace(CCD->Pawns()->TextMessage[Nr].TextString, "<Player>", CCD->Player()->GetPlayerName());

			CCD->Pawns()->TextMessage[Nr].FontNr = arguments[4].intValue();
			strcpy(CCD->Pawns()->TextMessage[Nr].TextSound, arguments[5].str());
			CCD->Pawns()->TextMessage[Nr].ScreenOffsetX = arguments[6].intValue();
			CCD->Pawns()->TextMessage[Nr].ScreenOffsetY = arguments[7].intValue();
			strncpy(&(CCD->Pawns()->TextMessage[Nr].Alignment), arguments[8].str(), 1);
			CCD->Pawns()->TextMessage[Nr].Alpha = arguments[9].floatValue();
			CCD->Pawns()->TextMessage[Nr].ShowText = true;
		}
		else
			CCD->Pawns()->TextMessage[Nr].ShowText = false;

		return true;
	}
	else if(IS_METHOD(methodName, "RemoveText"))
	{
		int Nr = arguments[0].intValue();

		if(Nr < 0 || Nr >= MAXTEXT)
			return true;

		CCD->Pawns()->TextMessage[Nr].ShowText = false;

		return true;
	}
	// SetPlatformSpeed(PlatformName, Speed)
	else if(IS_METHOD(methodName, "SetPlatformSpeed"))
	{
		PARMCHECK(2);
		MovingPlatform *pEntity;

		strcpy(string1, arguments[0].str());
		float1 = arguments[1].floatValue();

		CCD->Platforms()->LocateEntity(string1, (void**)&pEntity);
		CCD->ModelManager()->SetAnimationSpeed(pEntity->Model, float1);

		return true;
	}
	// SetDoorSpeed(DoorName, Speed)
	else if(IS_METHOD(methodName, "SetDoorSpeed"))
	{
		PARMCHECK(2);
		Door *pEntity;

		strcpy(string1, arguments[0].str());
		float1 = arguments[1].floatValue();

		CCD->Doors()->LocateEntity(string1, (void**)&pEntity);
		CCD->ModelManager()->SetAnimationSpeed(pEntity->Model, float1);

		return true;
	}
	// move immediately a platform to a given timeposition
	// SetPlatformTimeNow(PlatformName, KeyFrame)
	else if(IS_METHOD(methodName, "SetPlatformToTargetTime"))
	{
		PARMCHECK(2);
		MovingPlatform *pEntity;

		strcpy(string1, arguments[0].str());
		float1 = arguments[1].floatValue();

		CCD->Platforms()->LocateEntity(string1, (void**)&pEntity);
        CCD->ModelManager()->SetToTargetTime(pEntity->Model, float1);

		return true;
	}
	// move immediately a door to a given timeposition
	// SetDoorTimeNow(DoorName, KeyFrame)
	else if(IS_METHOD(methodName, "SetDoorToTargetTime"))
	{
		PARMCHECK(2);
		Door *pEntity;

		strcpy(string1, arguments[0].str());
		float1 = arguments[1].floatValue();

		CCD->Doors()->LocateEntity(string1, (void**)&pEntity);
        CCD->ModelManager()->SetToTargetTime(pEntity->Model, float1);

		return true;
	}
	// SetFlag(FlagNr, BooleanValue)
	else if(IS_METHOD(methodName, "SetFlag"))
	{
		int int1 = arguments[0].intValue();

		if(int1 >= MAXFLAGS)
			return true;

		bool1 = arguments[1].boolValue();
		CCD->Pawns()->SetPawnFlag(int1, bool1);

		return true;
	}
	// Boolean:GetFlag(FlagNr)
	else if(IS_METHOD(methodName, "GetFlag"))
	{
		int int1 = arguments[0].intValue();

		if(int1 >= MAXFLAGS)
		{
			returnValue = false;
			return true;
		}

		returnValue = CCD->Pawns()->GetPawnFlag(int1);

		return true;
	}
	// Distance:PlatformDistance(PlatformName, EntityName, IgnoreHeight)
	// Returns the distance form the platform center to the origin of an Entity
	// Apart from Pawns also 2 special Entity names are supported: "Player" and "Camera"
	else if(IS_METHOD(methodName, "PlatformDistance"))
	{
		PARMCHECK(3);
		geVec3d PlatformPos, EntityPos;
		MovingPlatform *pEntity;

		strcpy(string1, arguments[0].str());

		if(CCD->Platforms()->LocateEntity(string1, (void**)&pEntity) == RGF_SUCCESS)
		{
			CCD->ModelManager()->GetPosition(pEntity->Model, &PlatformPos);
			strcpy(string1, arguments[1].str());

			if(!stricmp(string1, "Player"))
				EntityPos = CCD->Player()->Position();
			else if(!stricmp(string1, "Camera"))
				CCD->CameraManager()->GetPosition(&EntityPos);
			else
				CCD->ActorManager()->GetPosition(CCD->ActorManager()->GetByEntityName(string1), &EntityPos);

			if(arguments.entries() > 2)
				if(arguments[2].boolValue())
					PlatformPos.Y = EntityPos.Y;

   			returnValue = geVec3d_DistanceBetween(&PlatformPos, &EntityPos);
		}
		else
			returnValue = 0;

		return true;
	}
	// Distance:DoorDistance(DoorName, EntityName, IgnoreHeight)
	// Gives the distance from the platform centre to the origin of an Entity
	// Apart from Pawns also 2 special Entity names are supported: "Player" and "Camera"
	else if (IS_METHOD(methodName, "DoorDistance"))
	{
		PARMCHECK(3);
		geVec3d DoorPos, EntityPos;
		Door *pEntity;

		strcpy(string1, arguments[0].str());

		if(CCD->Doors()->LocateEntity(string1, (void**)&pEntity) == RGF_SUCCESS)
		{
			CCD->ModelManager()->GetPosition(pEntity->Model, &DoorPos);
			strcpy(string1, arguments[1].str());

			if(!stricmp(string1, "Player"))
				EntityPos = CCD->Player()->Position();
			else if(!stricmp(string1, "Camera"))
				CCD->CameraManager()->GetPosition(&EntityPos);
			else
				CCD->ActorManager()->GetPosition(CCD->ActorManager()->GetByEntityName(string1), &EntityPos);

			if(arguments.entries() > 2)
				if(arguments[2].boolValue())
					DoorPos.Y = EntityPos.Y;
				if(arguments.entries() > 2)
			returnValue = geVec3d_DistanceBetween(&DoorPos, &EntityPos);
		}
		else
			returnValue = 0;

		return true;
	}
// end change
	else if(IS_METHOD(methodName, "Console"))
	{
		PARMCHECK(1);
		console = arguments[0].boolValue();

		if(console)
		{
			ConsoleHeader = (char*)malloc(128);
			*ConsoleHeader = '\0';
			ConsoleError = (char*)malloc(128);
			*ConsoleError = '\0';

			for(int i=0; i<DEBUGLINES; i++)
			{
				ConsoleDebug[i] = (char*)malloc(64);
				*ConsoleDebug[i] = '\0';
			}
		}
		else
		{
			if(ConsoleHeader)
				free(ConsoleHeader);

			if(ConsoleError)
				free(ConsoleError);

			for(int i=0; i<DEBUGLINES; i++)
			{
				if(ConsoleDebug[i])
					free(ConsoleDebug[i]);
			}
		}

		return true;
	}
	else if(IS_METHOD(methodName, "debug"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());

		if(console)
		{
			int index = -1;
			int i;

			for(i=0; i<DEBUGLINES; i++)
			{
				if(EffectC_IsStringNull(ConsoleDebug[i]))
				{
					index = i;
					break;
				}
			}

			if(index != -1)
			{
				strcpy(ConsoleDebug[index], string1);
			}
			else
			{
				for(i=1; i<DEBUGLINES; i++)
				{
					strcpy(ConsoleDebug[i-1], ConsoleDebug[i]);
				}

				strcpy(ConsoleDebug[DEBUGLINES-1], string1);
			}
		}

		return true;
	}
	else if(IS_METHOD(methodName, "random"))
	{
		PARMCHECK(2);
		int param1 = arguments[0].intValue();
		int param3 = arguments[1].intValue();

		if(param1 < param3)
			returnValue = EffectC_rand(param1, param3);
		else
			returnValue = EffectC_rand(param3, param1);

		return true;
	}
	else if(IS_METHOD(methodName, "StringCopy"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
		returnValue = skString(string1);
		return true;
	}
	else if(IS_METHOD(methodName, "LeftCopy"))
	{
		PARMCHECK(2);

		int temp = arguments[1].intValue();
		// changed QD 07/15/06
		/*
		char* cstemp="";
		strncpy(cstemp,arguments[0].str(),temp);
		cstemp[temp]='\0';
		returnValue = skString(cstemp);
		*/
		temp = (temp<127)?temp:127;
		strncpy(string1, arguments[0].str(), temp);
		string1[temp] = 0;
		returnValue = skString(string1);
		// end change
		return true;
	}
	else if(IS_METHOD(methodName, "Integer"))
	{
		PARMCHECK(1);
		int temp = arguments[0].intValue();
		returnValue = (int)temp;
		return true;
	}
	else if(IS_METHOD(methodName, "ModifyAttribute")) // changed QD 12/15/05
	{
		PARMCHECK(2);
		strcpy(string1, arguments[0].str());
// changed QD 12/15/05
		//CPersistentAttributes *theInv = CCD->ActorManager()->Inventory(CCD->Player()->GetActor());
		CPersistentAttributes *theInv;

		if(arguments.entries() > 2)
		{
			strcpy(string2, arguments[2].str());

			if(!stricmp(string2, "Player"))
				theInv = CCD->ActorManager()->Inventory(CCD->Player()->GetActor());
			else
				theInv = CCD->ActorManager()->Inventory(CCD->ActorManager()->GetByEntityName(string2));
		}
		else
			theInv = CCD->ActorManager()->Inventory(CCD->Player()->GetActor());
// end change
		returnValue = (int)theInv->Modify(string1, arguments[1].intValue());
		return true;
	}
	else if(IS_METHOD(methodName, "GetAttribute"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
// changed QD 12/15/05
		//CPersistentAttributes *theInv = CCD->ActorManager()->Inventory(CCD->Player()->GetActor());
		CPersistentAttributes *theInv;

		if(arguments.entries() > 1)
		{
			strcpy(string2, arguments[1].str());

			if(!stricmp(string2, "Player"))
				theInv = CCD->ActorManager()->Inventory(CCD->Player()->GetActor());
			else
				theInv = CCD->ActorManager()->Inventory(CCD->ActorManager()->GetByEntityName(string2));
		}
		else
			theInv = CCD->ActorManager()->Inventory(CCD->Player()->GetActor());
// end change
		returnValue = (int)theInv->Value(string1);
		return true;
	}

	else if(IS_METHOD(methodName, "SetAttribute"))
	{
		PARMCHECK(2);
		strcpy(string1, arguments[0].str());
// changed QD 12/15/05
		//CPersistentAttributes *theInv = CCD->ActorManager()->Inventory(CCD->Player()->GetActor());
		CPersistentAttributes *theInv;

		if(arguments.entries() > 2)
		{
			strcpy(string2, arguments[2].str());

			if(!stricmp(string2, "Player"))
				theInv = CCD->ActorManager()->Inventory(CCD->Player()->GetActor());
			else
				theInv = CCD->ActorManager()->Inventory(CCD->ActorManager()->GetByEntityName(string2));
		}
		else
			theInv = CCD->ActorManager()->Inventory(CCD->Player()->GetActor());
// end change
		returnValue = (int)theInv->Set(string1, arguments[1].intValue());
		return true;
	}
// changed QD 12/15/05
	else if(IS_METHOD(methodName, "AddAttribute"))
	{
		// USAGE:	AddAttribute(char *Attribute)
		//			AddAttribute(char *Attribute, char *EntityName)

		// changed QD 07/15/06 - add optional arguments
		//			AddAttribute(char *Attribute, int LowValue, int HighValue)
		//			AddAttribute(char *Attribute, int LowValue, int HighValue, char *EntityName)

		PARMCHECK(1);
		strcpy(string1, arguments[0].str());

		CPersistentAttributes *theInv;

		if(arguments.entries() == 2 || arguments.entries() == 4)
		{
			strcpy(string2, arguments[arguments.entries()-1].str());

			if(!stricmp(string2, "Player"))
				theInv = CCD->ActorManager()->Inventory(CCD->Player()->GetActor());
			else
				theInv = CCD->ActorManager()->Inventory(CCD->ActorManager()->GetByEntityName(string2));
		}
		else
			theInv = CCD->ActorManager()->Inventory(CCD->Player()->GetActor());

		returnValue = (int)theInv->Add(string1);

		if(arguments.entries() > 2)
		{
			theInv->SetValueLimits(string1, arguments[1].intValue(), arguments[2].intValue());
		}
		// end change QD 07/15/06

		return true;
	}
// end change
// changed QD 07/15/06
	else if(IS_METHOD(methodName, "SetAttributeValueLimits"))
	{
		// USAGE:	SetAttributeValueLimits(char* Attribute, int LowValue, int HighValue),
		//			SetAttributeValueLimits(char* Attribute, int LowValue, int HighValue, char* EntityName)

		PARMCHECK(3);
		strcpy(string1, arguments[0].str());

		CPersistentAttributes *theInv;

		if(arguments.entries() > 3)
		{
			strcpy(string2, arguments[3].str());

			if(!stricmp(string2, "Player"))
				theInv = CCD->ActorManager()->Inventory(CCD->Player()->GetActor());
			else
				theInv = CCD->ActorManager()->Inventory(CCD->ActorManager()->GetByEntityName(string2));
		}
		else
			theInv = CCD->ActorManager()->Inventory(CCD->Player()->GetActor());

		theInv->SetValueLimits(string1, arguments[1].intValue(), arguments[2].intValue());

		return true;
	}
	else if(IS_METHOD(methodName, "RightCopy"))
	{
		int length;
		int temp = arguments[1].intValue();
		temp = (temp<127)?temp:127;
		strncpy(string1, arguments[0].str(), 127);
		string1[127] = 0;
		length = strlen(string1);

		strncpy(string2, &string1[length-temp], temp);
		string2[temp] = 0;
		returnValue = skString(string2);
		return true;
	}
	else if(IS_METHOD(methodName, "sin"))
	{
		PARMCHECK(1);
		returnValue = (float)sin((double)arguments[0].floatValue());

		return true;
	}
	else if(IS_METHOD(methodName, "cos"))
	{
		PARMCHECK(1);
		returnValue = (float)cos((double)arguments[0].floatValue());

		return true;
	}
	else if(IS_METHOD(methodName, "tan"))
	{
		PARMCHECK(1);
		returnValue = (float)tan((double)arguments[0].floatValue());

		return true;
	}
// end change QD 07/15/06
// changed QD 02/01/07
	else if(IS_METHOD(methodName, "asin"))
	{
		PARMCHECK(1);
		returnValue = (float)asin((double)arguments[0].floatValue());

		return true;
	}
	else if(IS_METHOD(methodName, "acos"))
	{
		PARMCHECK(1);
		returnValue = (float)acos((double)arguments[0].floatValue());

		return true;
	}
	else if(IS_METHOD(methodName, "atan"))
	{
		PARMCHECK(1);
		returnValue = (float)atan((double)arguments[0].floatValue());

		return true;
	}
// end change
	else if(IS_METHOD(methodName, "SetPlayerWeapon"))
	{
		PARMCHECK(1);
		int temp = arguments[0].intValue();
		CCD->Weapons()->SetWeapon(temp);
		return true;
	}
	else if(IS_METHOD(methodName, "SetUseItem"))
	{
		PARMCHECK(1);
		strcpy(string1, arguments[0].str());
		CCD->Player()->SetUseAttribute(string1);
		CCD->HUD()->ActivateElement(string1, true);
		return true;
	}
// changed RF071A
	else if(IS_METHOD(methodName, "IsKeyDown"))
	{
		PARMCHECK(1);
		int temp = arguments[0].intValue();
		returnValue = false;

		if(CCD->Input()->GetKeyCheck(temp) == true)
			returnValue = true;

		return true;
	}
// changed QD 12/15/05
	else if(IS_METHOD(methodName, "SetFixedCameraPosition"))
	{
		// USAGE: SetFixedCameraPosition(PosX, PosY, PosZ)
		PARMCHECK(3);

		geVec3d Pos;
		Pos.X = arguments[0].floatValue();
		Pos.Y = arguments[1].floatValue();
		Pos.Z = arguments[2].floatValue();
		CCD->FixedCameras()->SetPosition(Pos);

		return true;
	}
	else if(IS_METHOD(methodName, "SetFixedCameraRotation"))
	{
		// USAGE: SetFixedCameraRotation(RotX, RotY, RotZ)
		PARMCHECK(3);

		geVec3d Rot;
		Rot.X = GE_PIOVER180*arguments[0].floatValue();
		Rot.Y = GE_PIOVER180*arguments[1].floatValue();
		Rot.Z = GE_PIOVER180*arguments[2].floatValue();
		CCD->FixedCameras()->SetRotation(Rot);

		return true;
	}
	else if(IS_METHOD(methodName, "SetFixedCameraFOV"))
	{
		// USAGE: SetFixedCameraFOV(float FOV)
		PARMCHECK(1);

		CCD->FixedCameras()->SetFOV(arguments[0].floatValue());

		return true;
	}
	else if(IS_METHOD(methodName, "MoveFixedCamera"))
	{
		// USAGE: MoveFixedCamera(PosX, PosY, PosZ)
		PARMCHECK(3);

		geVec3d Pos;
		Pos.X = arguments[0].floatValue();
		Pos.Y = arguments[1].floatValue();
		Pos.Z = arguments[2].floatValue();
		CCD->FixedCameras()->Move(Pos);

		return true;
	}
	else if(IS_METHOD(methodName, "RotateFixedCamera"))
	{
		// USAGE: RotateFixedCamera(RotX, RotY, RotZ)
		PARMCHECK(3);

		geVec3d Rot;
		Rot.X = GE_PIOVER180*arguments[0].floatValue();
		Rot.Y = GE_PIOVER180*arguments[1].floatValue();
		Rot.Z = GE_PIOVER180*arguments[2].floatValue();
		CCD->FixedCameras()->Rotate(Rot);

		return true;
	}
// end change
	else
	{
		return skScriptedExecutable::method(methodName, arguments, returnValue, ctxt);
	}
}
/* ------------------------------------------------------------------------------------ */
void CRain::Tick(geFloat dwTicks)
{
	geEntity_EntitySet *pSet;
	geEntity *pEntity;
	int i;
	Spray Sp;

	pSet = geWorld_GetEntitySet(CCD->World(), "Rain");

	if(!pSet)
		return;

	for(pEntity=geEntity_EntitySetGetNextEntity(pSet, NULL); pEntity;
		pEntity=geEntity_EntitySetGetNextEntity(pSet, pEntity))
	{
		Rain *R = (Rain*)geEntity_GetUserData(pEntity);

		if(!EffectC_IsStringNull(R->TriggerName))
		{
			if(GetTriggerState(R->TriggerName))
			{
				if(R->active == GE_FALSE)
				{
					for(i=0; i<R->EffectCount; i++)
						R->EffectList[i] = Create(R);

					R->active = GE_TRUE;
				}
			}
			else
			{
				if(R->active == GE_TRUE)
				{
					for(i=0; i<R->EffectCount; i++)
						CCD->EffectManager()->Item_Delete(EFF_SPRAY, R->EffectList[i]);

					R->active = GE_FALSE;
				}
			}
		}
		else
		{
			if(R->active == GE_FALSE)
			{
				for(i=0; i<R->EffectCount; i++)
					R->EffectList[i] = Create(R);

				R->active = GE_TRUE;
			}
		}

		if(R->active == GE_TRUE)
		{
			R->origin = R->OriginOffset;

			if(SetOriginOffset(R->EntityName, R->BoneName, R->Model, &(R->origin)))
			{
	  			geVec3d_Copy(&(R->origin), &(Sp.Source));
				geVec3d_AddScaled(&(Sp.Source), &(Sp.Gravity), Sp.MinUnitLife, &(Sp.Dest));

				// adjust position
				for(i=0; i<R->EffectCount; i++)
					CCD->EffectManager()->Item_Modify(EFF_SPRAY, R->EffectList[i], (void *)&Sp, SPRAY_SOURCE | SPRAY_ACTUALDEST);
			}
	    }
	}
}
/* ------------------------------------------------------------------------------------ */
geBoolean CDynalite::Tick(geFloat dwTicks)
{
	geEntity_EntitySet *pSet;
	geEntity *pEntity;

	if(CCD->World() == NULL)
		return GE_TRUE;

	pSet = geWorld_GetEntitySet(CCD->World(), "DynamicLight");

	if(!pSet)
		return GE_TRUE;

	for(pEntity=geEntity_EntitySetGetNextEntity(pSet, NULL); pEntity;
		pEntity=geEntity_EntitySetGetNextEntity(pSet, pEntity))
	{
		DynamicLight	*Light;
		geFloat			Radius;
		geFloat			Percentage;
		int				Index;
		geVec3d			Pos;
		int32			Leaf;

		Light = (DynamicLight*)geEntity_GetUserData(pEntity);

		if(!EffectC_IsStringNull(Light->TriggerName))
		{
			if(GetTriggerState(Light->TriggerName))
			{
				if(Light->active == GE_FALSE)
				{
					Light->DynLight = geWorld_AddLight(CCD->World());
					Light->active = GE_TRUE;
				}
			}
			else
			{
				if(Light->active == GE_TRUE)
					geWorld_RemoveLight(CCD->World(), Light->DynLight );

				Light->active = GE_FALSE;
			}
		}
		else
		{
			if(Light->active == GE_FALSE)
			{
				Light->DynLight = geWorld_AddLight(CCD->World());
				Light->active = GE_TRUE;
			}
		}

		if(Light->active==GE_TRUE)
		{
			//MOD010124 - Added next line of code to pass the OriginOffset to SetOrigin
            //            so that the light will stay in the same position relative to the model.
            //            Also we now call SetOriginOffset instead of SetOffset in the line after.
            Light->origin = Light->OriginOffset;
			SetOriginOffset(Light->EntityName, Light->BoneName, Light->Model, &(Light->origin));
			geWorld_GetLeaf(CCD->World(), &(Light->origin), &Leaf);
			Pos = Light->origin;

			Percentage = Light->LastTime / Light->RadiusSpeed;

			Index = (int)(Percentage * Light->NumFunctionValues);

			if(Light->InterpolateValues && Index < Light->NumFunctionValues - 1)
			{
				geFloat	Remainder;
				geFloat	InterpolationPercentage;
				int		DeltaValue;
				geFloat	Value;

				Remainder = (geFloat)fmod(Light->LastTime, Light->IntervalWidth);
				InterpolationPercentage = Remainder / Light->IntervalWidth;
				DeltaValue = Light->RadiusFunction[Index + 1] - Light->RadiusFunction[Index];
				Value = Light->RadiusFunction[Index] + DeltaValue * InterpolationPercentage;
				Percentage = ((geFloat)(Value - 'a')) / ((geFloat)('z' - 'a'));
			}
			else
				Percentage = ((geFloat)(Light->RadiusFunction[Index] - 'a')) / ((geFloat)('z' - 'a'));

			Radius = Percentage * (Light->MaxRadius - Light->MinRadius) + Light->MinRadius;

			geWorld_SetLightAttributes(CCD->World(),
									   Light->DynLight,
									   &Pos,
									   &(Light->Color),
									   Radius,
									   GE_TRUE);

			Light->LastTime = (geFloat)fmod(Light->LastTime + dwTicks, Light->RadiusSpeed);

			if(EffectC_IsPointVisible(CCD->World(),
					CCD->CameraManager()->Camera(),
					&Pos,
					Leaf,
					EFFECTC_CLIP_LEAF ) == GE_FALSE )
			{
				geWorld_RemoveLight(CCD->World(), Light->DynLight);
				Light->active = GE_FALSE;
			}
		}
	}

	return GE_TRUE;
}
/* ------------------------------------------------------------------------------------ */
void CAutoDoors::Tick(geFloat dwTicks)
{
	geEntity_EntitySet *pSet;
	geEntity *pEntity;

	if(m_DoorCount == 0)
		return;											// No need to waste time here.

	//	Ok, check to see if there are automatic doors in this world
	pSet = geWorld_GetEntitySet(CCD->World(), "Door");

	if(!pSet)
		return;									// No doors, how odd...

	//	Ok, we have doors somewhere.  Dig through 'em all.
	for(pEntity=geEntity_EntitySetGetNextEntity(pSet, NULL); pEntity;
		pEntity=geEntity_EntitySetGetNextEntity(pSet, pEntity))
	{
		Door *pDoor= (Door*)geEntity_GetUserData(pEntity);

		if(!pDoor->Model)
			continue;

		if(!EffectC_IsStringNull(pDoor->TriggerName))
		{
			if(GetTriggerState(pDoor->TriggerName))
			{
				if((!pDoor->bInAnimation) && (pDoor->bActive == GE_TRUE) &&
					(!pDoor->bTrigger) && (pDoor->bNoCollide)
					&& (!pDoor->UseKey)) // changed QD 03/05/2005
				{
					pDoor->bTrigger = true;			// It's this one, trigger the animation

					if(pDoor->bRunWhileTrig || pDoor->bRunFromList ||
						pDoor->bRunTimed    || pDoor->bRunToNextEvent)
					{
						if(CCD->ModelManager()->HasMoved(pDoor->Model))
						{
							CCD->ModelManager()->ReStart(pDoor->Model);
						}
						else
						{
							CCD->ModelManager()->Start(pDoor->Model);
						}
					}
					else
					{
						CCD->ModelManager()->Start(pDoor->Model);
					}

					pDoor->bInAnimation = GE_TRUE;
					pDoor->SoundHandle = PlaySound(pDoor->theSound, pDoor->origin, pDoor->bAudioLoops);

					// Now check to see if there's a linked door that we also need to
					// ..trigger.
					if(pDoor->NextToTrigger != NULL)
						TriggerNextDoor(pDoor->NextToTrigger, false);
				}
			}
			else
			{
				if(pDoor->bInAnimation && (pDoor->bActive == GE_TRUE) &&
					pDoor->bTrigger && pDoor->bNoCollide && pDoor->bRunWhileTrig)
				{
					// If bRunWhileTrig is true then un-trigger the animation
					pDoor->bTrigger = GE_FALSE;
					CCD->ModelManager()->Stop(pDoor->Model);

					if(pDoor->SoundHandle != -1)
					{
						CCD->EffectManager()->Item_Delete(EFF_SND, pDoor->SoundHandle);
						pDoor->SoundHandle = -1;
					}
				}
			}
		}

		if(pDoor->CallBack == GE_TRUE)
		{
			pDoor->CallBackCount -= 1;

			if(pDoor->CallBackCount == 0)
				pDoor->CallBack = GE_FALSE;
		}

		if((pDoor->bInAnimation == GE_TRUE) &&
			(CCD->ModelManager()->IsRunning(pDoor->Model) == false))
		{
			// Animation has stopped/not running, handle it.
			CCD->ModelManager()->Stop(pDoor->Model);

			if((pDoor->bOneShot != GE_TRUE) && (pDoor->bActive == GE_TRUE))
			{
				// Ok, not one-shot, reset the door
				pDoor->bInAnimation = GE_FALSE;
				pDoor->bTrigger = GE_FALSE;
			}

			if(pDoor->SoundHandle != -1)
			{
				CCD->EffectManager()->Item_Delete(EFF_SND, pDoor->SoundHandle);
				pDoor->SoundHandle = -1;
			}
		}

// Start Aug2003DCS
		//Handle the case where the model is animating on command from a script
		if(CCD->ModelManager()->IsRunning(pDoor->Model)
			&& (pDoor->bInAnimation == GE_FALSE)
			&& (pDoor->SoundHandle == -1))
		{
			pDoor->SoundHandle = PlaySound(pDoor->theSound, pDoor->origin, pDoor->bAudioLoops);
		}

		if(!CCD->ModelManager()->IsRunning(pDoor->Model)
			&& (pDoor->SoundHandle != -1))
		{
			CCD->EffectManager()->Item_Delete(EFF_SND, pDoor->SoundHandle);
			pDoor->SoundHandle = -1;
		}
// End Aug2003DCS
	}

	return;
}
/* ------------------------------------------------------------------------------------ */
void CAutoDoors::TriggerNextDoor(geWorld_Model *pModel,	bool bTriggerCall)
{
	geEntity_EntitySet *pSet;
	geEntity *pEntity;

	if(m_DoorCount == 0)
		return;									// None here, ignore call.

	pSet = geWorld_GetEntitySet(CCD->World(), "Door");

	if(!pSet)
	{
		CCD->ReportError("CAutoDoors.cpp: TriggerNextDoor: no doors", false);
		return;
	}

	//	Once more we scan the door list.  Does this get old, or what?
	for(pEntity=geEntity_EntitySetGetNextEntity(pSet, NULL); pEntity;
		pEntity=geEntity_EntitySetGetNextEntity(pSet, pEntity))
	{
		// Get the door data so we can compare models
		Door *pDoor = (Door*)geEntity_GetUserData(pEntity);

		// changed QD 07/15/06
		if(!pDoor->Model)
			continue;
		// end change

		if(pDoor->Model == pModel)
		{
			if((!pDoor->bShoot) && (bTriggerCall == true))
				return;

// changed QD 03/05/2005 - don't care if it want to collide, it is triggered by another door
// and therefore it just has to be activcated
 			//	Models match, we hit this one.  If the entity doesn't activate
			//	..on collide AND this isn't a call from a trigger, don't
			//	..activate the entity.

			//if((pDoor->bNoCollide))
			//	return;								// Fake a no-hit situation
// end change

			bool state = true;

			if(!EffectC_IsStringNull(pDoor->TriggerName))
				state = GetTriggerState(pDoor->TriggerName);

			//	Ok, if the entity isn't already activated AND the entity is
			//	..available for activation AND it's not already triggered,
			//	..ACTIVATE IT!
			if((!pDoor->bInAnimation) && (pDoor->bActive == GE_TRUE) &&
				(!pDoor->bTrigger) && state)
			{
				pDoor->bTrigger = GE_TRUE;			// It's this one, trigger the animation

				//	MOD010122 - Changed this section too.  You just can't call Start anymore!
				//		You might have to call ReStart.
				if(pDoor->bRunWhileTrig || pDoor->bRunFromList ||
					pDoor->bRunTimed     || pDoor->bRunToNextEvent)
				{
					if(CCD->ModelManager()->HasMoved(pDoor->Model))
					{
						CCD->ModelManager()->ReStart(pDoor->Model);
					}
					else
					{
						CCD->ModelManager()->Start(pDoor->Model);
					}
				}
				else
				{
					CCD->ModelManager()->Start(pDoor->Model);
				}

				pDoor->bInAnimation = GE_TRUE;
				pDoor->SoundHandle = PlaySound(pDoor->theSound, pDoor->origin, pDoor->bAudioLoops);

				//	Now check to see if there's a linked door that we also need to
				//	..trigger.
				if(pDoor->NextToTrigger != NULL)
					TriggerNextDoor(pDoor->NextToTrigger, bTriggerCall);
			}

			return;					// Hmmph, we hit an automatic door.
		}
	}

	return;							// We hit no known doors
}
// changed RF063
bool CAutoDoors::HandleCollision(geWorld_Model *pModel,	bool bTriggerCall, bool UseKey, geActor *theActor)
{
	geEntity_EntitySet *pSet;
	geEntity *pEntity;

	if(m_DoorCount == 0)
		return false;									// None here, ignore call.

	pSet = geWorld_GetEntitySet(CCD->World(), "Door");

	if(!pSet)
	{
		CCD->ReportError("CAutoDoors.cpp: HandleCollision: no doors", false);
		return false;
	}

	//	Once more we scan the door list.  Does this get old, or what?
	for(pEntity=geEntity_EntitySetGetNextEntity(pSet, NULL); pEntity;
		pEntity=geEntity_EntitySetGetNextEntity(pSet, pEntity))
	{
		// Get the door data so we can compare models
		Door *pDoor = (Door*)geEntity_GetUserData(pEntity);

		// changed QD 07/15/06
		if(!pDoor->Model)
			continue;
		// end change

		if(pDoor->Model == pModel)
		{
// changed RF063
			if(pDoor->PlayerOnly && theActor != CCD->Player()->GetActor())
				return false;

			if(UseKey && !pDoor->UseKey)
				return false;
// end change RF063

			if((!pDoor->bShoot) && bTriggerCall)
				return false;

			if(pDoor->bShoot && !bTriggerCall)
				return false;

			//	Models match, we hit this one.  If the entity doesn't activate
			//	..on collide AND this isn't a call from a trigger, don't
			//	..activate the entity.
// changed RF063
			if(pDoor->bNoCollide && !UseKey)
				return true;			// Fake a no-hit situation
// end change RF063

			bool state = true;

			if(!EffectC_IsStringNull(pDoor->TriggerName))
				state = GetTriggerState(pDoor->TriggerName);

			if(!state)
			{
				pDoor->CallBack = GE_TRUE;
				pDoor->CallBackCount = 2;
				return true;
			}

			//	Ok, if the entity isn't already activated AND the entity is
			//	..available for activation AND it's not already triggered,
			//	..ACTIVATE IT!
			if((!pDoor->bInAnimation) && (pDoor->bActive == GE_TRUE) &&
				(!pDoor->bTrigger) && state)
			{
				pDoor->bTrigger = GE_TRUE;			// It's this one, trigger the animation

				if(pDoor->bRunWhileTrig || pDoor->bRunFromList ||
					pDoor->bRunTimed    || pDoor->bRunToNextEvent)
				{
					if(CCD->ModelManager()->HasMoved(pDoor->Model))
					{
						CCD->ModelManager()->ReStart(pDoor->Model);
					}
					else
					{
						CCD->ModelManager()->Start(pDoor->Model);
					}
				}
				else
				{
					CCD->ModelManager()->Start(pDoor->Model);
				}

				pDoor->bInAnimation = GE_TRUE;
				pDoor->SoundHandle = PlaySound(pDoor->theSound, pDoor->origin, pDoor->bAudioLoops);
			}

			//	Now check to see if there's a linked door that we also need to
			//	..trigger.
			if(pDoor->NextToTrigger != NULL)
				TriggerNextDoor(pDoor->NextToTrigger, bTriggerCall);

			return true;									// Hmmph, we hit an automatic door.
		}
	}

	return false;							// We hit no known doors
}
/* ------------------------------------------------------------------------------------ */
void CCutScene::Tick(geFloat dwTicks)
{

	geEntity_EntitySet *pSet;
	geEntity *pEntity;

	pSet = geWorld_GetEntitySet(CCD->World(), "CutScene");

	if(!pSet)
		return;   // Not on this level.

	// Ok, we have CutScenes somewhere.  Dig through 'em all.
	for(pEntity=geEntity_EntitySetGetNextEntity(pSet, NULL); pEntity;
		pEntity=geEntity_EntitySetGetNextEntity(pSet, pEntity))
	{
		CutScene *pCutScene = (CutScene*)geEntity_GetUserData(pEntity);

		if(pCutScene->played)
			continue;

		if(!EffectC_IsStringNull(pCutScene->TriggerName))
		{
			if(GetTriggerState(pCutScene->TriggerName))
			{
				if(pCutScene->active == GE_FALSE)
				{
					pCutScene->active = GE_TRUE;
				}
				// prevent looping of the file when trigger is on
				else
					pCutScene->triggeron = GE_TRUE;
			}
			else
			{
				if(pCutScene->active == GE_TRUE)
				{
					pCutScene->active = GE_FALSE;
					pCutScene->triggeron = GE_FALSE;
				}
			}

			if(pCutScene->triggeron == GE_TRUE)
				continue;
		}
		else
		{
			if(pCutScene->active == GE_FALSE)
			{
				pCutScene->active = GE_TRUE;
				pCutScene->played = GE_TRUE;
			}
		}

		if(pCutScene->active == GE_TRUE)
		{
			CCD->Player()->DisableFog();		// Turn off fogging for cut scene
			CCD->Player()->DisableClipPlane();	// Turn off the clipping plane as well

			// Play the cut scene
			CCD->Play(pCutScene->szCutScene, pCutScene->XPos, pCutScene->YPos, pCutScene->Center);

			CCD->Player()->ShowFog();			// Show fog, if enabled
			CCD->Player()->ActivateClipPlane();	//  Activate clipping plane, if enabled

			CCD->Engine()->ResetSystem();
		}
	}

	return;
}