コード例 #1
0
ファイル: g_script.c プロジェクト: ETrun/ETrun
/*
=============
G_Script_ScriptRun

  returns qtrue if the script completed
=============
*/
qboolean G_Script_ScriptRun(gentity_t *ent) {
	g_script_stack_t *stack;

	if (!ent->scriptEvents) {
		ent->scriptStatus.scriptEventIndex = -1;
		return qtrue;
	}

	// if we are still doing a gotomarker, process the movement
	if (ent->scriptStatus.scriptFlags & SCFL_GOING_TO_MARKER) {
		G_ScriptAction_GotoMarker(ent, NULL);
	}

	// if we are animating, do the animation
	if (ent->scriptStatus.scriptFlags & SCFL_ANIMATING) {
		G_ScriptAction_PlayAnim(ent, ent->scriptStatus.animatingParams);
	}

	if (ent->scriptStatus.scriptEventIndex < 0) {
		return qtrue;
	}

	stack = &ent->scriptEvents[ent->scriptStatus.scriptEventIndex].stack;

	if (!stack->numItems) {
		ent->scriptStatus.scriptEventIndex = -1;
		return qtrue;
	}
	//
	// show debugging info
	if (g_scriptDebug.integer &&
	    ent->scriptStatus.scriptStackChangeTime == level.time &&
	    ent->scriptStatus.scriptStackHead < stack->numItems) {
		G_Printf("%i : (%s) GScript command: %s %s\n", level.time, ent->scriptName, stack->items[ent->scriptStatus.scriptStackHead].action->actionString, (stack->items[ent->scriptStatus.scriptStackHead].params ? stack->items[ent->scriptStatus.scriptStackHead].params : ""));
	}
	//
	while (ent->scriptStatus.scriptStackHead < stack->numItems) {
		int oldScriptId = ent->scriptStatus.scriptId;

		if (!stack->items[ent->scriptStatus.scriptStackHead].action->actionFunc(ent, stack->items[ent->scriptStatus.scriptStackHead].params)) {
			ent->scriptStatus.scriptFlags &= ~SCFL_FIRST_CALL;
			return qfalse;
		}
		//if the scriptId changed, a new event was triggered in our scripts which did not finish
		if (oldScriptId != ent->scriptStatus.scriptId) {
			return qfalse;
		}
		// move to the next action in the script
		ent->scriptStatus.scriptStackHead++;
		// record the time that this new item became active
		ent->scriptStatus.scriptStackChangeTime = level.time;
		//
		ent->scriptStatus.scriptFlags |= SCFL_FIRST_CALL;
		// show debugging info
		if (g_scriptDebug.integer && ent->scriptStatus.scriptStackHead < stack->numItems) {
			G_Printf("%i : (%s) GScript command: %s %s\n", level.time, ent->scriptName, stack->items[ent->scriptStatus.scriptStackHead].action->actionString, (stack->items[ent->scriptStatus.scriptStackHead].params ? stack->items[ent->scriptStatus.scriptStackHead].params : ""));
		}
	}

	ent->scriptStatus.scriptEventIndex = -1;

	return qtrue;
}
コード例 #2
0
ファイル: g_script.c プロジェクト: JackalFrost/RTCW-WSGF
/*
=============
G_Script_ScriptRun

  returns qtrue if the script completed
=============
*/
qboolean G_Script_ScriptRun( gentity_t *ent ) {
	g_script_stack_t *stack;

	if ( saveGamePending ) {
		return qfalse;
	}

	if ( strlen( g_missionStats.string ) > 1 ) {
		return qfalse;
	}

	//if (!g_scripts.integer)
	//	return qtrue;

	trap_Cvar_Update( &g_scriptDebug );

	if ( !ent->scriptEvents ) {
		ent->scriptStatus.scriptEventIndex = -1;
		return qtrue;
	}

	// if we are still doing a gotomarker, process the movement
	if ( ent->scriptStatus.scriptFlags & SCFL_GOING_TO_MARKER ) {
		G_ScriptAction_GotoMarker( ent, NULL );
	}

	// if we are animating, do the animation
	if ( ent->scriptStatus.scriptFlags & SCFL_ANIMATING ) {
		G_ScriptAction_PlayAnim( ent, ent->scriptStatus.animatingParams );
	}

	if ( ent->scriptStatus.scriptEventIndex < 0 ) {
		return qtrue;
	}

	stack = &ent->scriptEvents[ent->scriptStatus.scriptEventIndex].stack;

	if ( !stack->numItems ) {
		ent->scriptStatus.scriptEventIndex = -1;
		return qtrue;
	}
	//
	// show debugging info
	if ( g_scriptDebug.integer && ent->scriptStatus.scriptStackChangeTime == level.time ) {
		if ( ent->scriptStatus.scriptStackHead < stack->numItems ) {
			G_Printf( "%i : (%s) GScript command: %s %s\n", level.time, ent->scriptName, stack->items[ent->scriptStatus.scriptStackHead].action->actionString, ( stack->items[ent->scriptStatus.scriptStackHead].params ? stack->items[ent->scriptStatus.scriptStackHead].params : "" ) );
		}
	}
	//
	while ( ent->scriptStatus.scriptStackHead < stack->numItems )
	{
		if ( !stack->items[ent->scriptStatus.scriptStackHead].action->actionFunc( ent, stack->items[ent->scriptStatus.scriptStackHead].params ) ) {
			return qfalse;
		}
		// move to the next action in the script
		ent->scriptStatus.scriptStackHead++;
		// record the time that this new item became active
		ent->scriptStatus.scriptStackChangeTime = level.time;
		//
		// show debugging info
		if ( g_scriptDebug.integer ) {
			if ( ent->scriptStatus.scriptStackHead < stack->numItems ) {
				G_Printf( "%i : (%s) GScript command: %s %s\n", level.time, ent->scriptName, stack->items[ent->scriptStatus.scriptStackHead].action->actionString, ( stack->items[ent->scriptStatus.scriptStackHead].params ? stack->items[ent->scriptStatus.scriptStackHead].params : "" ) );
			}
		}
	}

	ent->scriptStatus.scriptEventIndex = -1;

	return qtrue;
}