⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scriptmaster.cpp

📁 this keik game source
💻 CPP
📖 第 1 页 / 共 5 页
字号:
//-----------------------------------------------------------------------------
//
//  $Logfile:: /Quake 2 Engine/Sin/code/game/scriptmaster.cpp                 $
// $Revision:: 156                                                            $
//   $Author:: Jimdose                                                        $
//     $Date:: 2/16/99 8:38p                                                  $
//
// Copyright (C) 1997 by Ritual Entertainment, Inc.
// All rights reserved.
//
// This source is may not be distributed and/or modified without
// expressly written permission by Ritual Entertainment, Inc.
//
// $Log:: /Quake 2 Engine/Sin/code/game/scriptmaster.cpp                      $
// 
// 156   2/16/99 8:38p Jimdose
// moved sin arcade comm stuff to client
// 
// 155   12/18/98 11:03p Jimdose
// removed include of qcommon.h
// 
// 154   12/16/98 12:42a Aldie
// Added endgame command for Sin Arcade
// 
// 153   12/14/98 6:52p Aldie
// Added mapname command
// 
// 152   11/11/98 10:55p Jimdose
// Added RemoveEnt, RemoveClass, KillEnt, KillClass
// 
// 151   11/10/98 4:34p Jimdose
// added ClearSaveGames
// 
// 150   11/07/98 10:15p Markd
// put in forcemusic support
// 
// 149   11/07/98 10:05p Jimdose
// made spawn work with model names
// 
// 148   11/06/98 5:17p Jimdose
// added missionfailed and missionfailedtime to level vars
// when a mission has failed or the player is dead in single player, the game
// code immediately shows the loadmenu, preventing them from letting the game
// continue running if they exit the menu
// 
// 147   11/05/98 2:17a Aldie
// Added a check for the world to cacheplayermodel
// 
// 146   11/04/98 9:50p Aldie
// Added ability to force cache a player model
// 
// 145   10/27/98 9:46p Aldie
// Changed training cvar to level.training
// 
// 144   10/27/98 9:21p Markd
// fixed dialogsound bug
// 
// 143   10/27/98 8:07p Markd
// Added dialogsound command
// 
// 142   10/26/98 9:06p Aldie
// Added stuffcommand
// 
// 141   10/26/98 5:15p Jimdose
// changed recalcpaths to passtopathmanager
// 
// 140   10/26/98 4:42p Jimdose
// added recalcpaths
// 
// 139   10/26/98 2:16p Aldie
// Added AirClamp
// 
// 138   10/26/98 12:42a Markd
// added new print commands and crucial dialog
// 
// 137   10/26/98 12:05a Jimdose
// added MissionFailed
// 
// 136   10/25/98 6:26p Markd
// Added in no_jc abililty
// 
// 135   10/24/98 9:38p Jimdose
// Added GetUniqueThreadNumber
// Made TerminateThread not kill actor threads or thread 0 (an invalid thread)
// 
// 134   10/24/98 12:42a Markd
// changed origins to worldorigins where appropriate
// 
// 133   10/22/98 5:44p Jimdose
// MapEvent now sets doneProcessing to true
// 
// 132   10/22/98 4:32p Aldie
// Added a clear screen print file command
// 
// 131   10/19/98 11:51p Aldie
// Added fixslashes to screen print file
// 
// 130   10/19/98 12:07a Jimdose
// made all code use fast checks for inheritance (no text lookups when
// possible)
// isSubclassOf no longer requires ::_classinfo()
// 
// 129   10/18/98 7:59p Aldie
// Added screenprintfile
// 
// 128   10/14/98 12:12a Aldie
// Added a bunch of intermission commands
// 
// 127   10/12/98 9:07p Markd
// Made it so playermodels are not cached if not in deathmatch
// 
// 126   10/08/98 3:44p Markd
// re-merged my changes back into the checked in file
// 
// 125   10/08/98 12:02a Jimdose
// made GameTime a ScriptVariablePtr
// moved PlayerFrozen to game
// got rid of type in gamescript
// 
// 124   10/01/98 8:00p Markd
// Made dialog use NO_PHS
// 
// 123   9/26/98 7:17p Markd
// Made WaitFor support more than one object with the same target name
// 
// 122   9/25/98 4:36p Markd
// Replaced Event::Find with Event::Exists
// 
// 121   9/23/98 11:00p Markd
// put in some garbage collection on stuff that wasn't freed up
// 
// 120   9/22/98 4:23p Markd
// Fixed some targetname stuff for lights, doors and scriptobjects
// 
// 119   9/19/98 6:13p Aldie
// Added printscreen command
// 
// 118   9/15/98 7:43p Markd
// fixed some typos
// 
// 117   9/15/98 7:35p Markd
// Moved music and soundtrack stuff to specialfx
// 
// 116   9/15/98 6:46p Aldie
// Clear the waitfor's before deleting threads
// 
// 115   9/10/98 8:34p Markd
// removed drawoverlay and drawstats variables from level structure
// 
// 114   9/09/98 3:56p Aldie
// Changed precision of fade floats
// 
// 113   9/02/98 7:47p Aldie
// Added cacheplayermodel function
// 
// 112   8/29/98 9:45p Jimdose
// Changed BeginIntermission to G_BeginIntermission
// 
// 111   8/29/98 7:22p Aldie
// Updated the spawn function
// 
// 110   8/29/98 5:27p Markd
// added specialfx, replaced misc with specialfx where appropriate
// 
// 109   8/26/98 6:43p Jimdose
// fixed bug in Restore
// 
// 108   8/24/98 11:32a Markd
// Added Start method to threads, repladed all ProcessEvent(
// EV_ScriptThread_execute) with thread->Start( -1 )
// 
// 107   8/22/98 10:04p Markd
// added noprecache support for cachemodel and cachesound
// 
// 106   8/22/98 6:34p Markd
// Added Terminate extened behavior
// 
// 105   8/22/98 1:22a Markd
// Added WaitForPlayer support
// 
// 104   8/21/98 5:26p Markd
// Added sv_precache and cl_precache 
// 
// 103   8/21/98 1:43a Markd
// Changed parameters to CreateThread
// 
// 102   8/20/98 4:39p Markd
// Added print vector support
// 
// 101   8/19/98 6:38p Markd
// Added noncinematic event
// 
// 100   8/18/98 11:08p Markd
// Added new Alias System
// 
// 99    8/17/98 7:31p Jimdose
// Added WaitingFor to test if a thread is waiting for the specified entity
// 
// 98    8/17/98 4:34p Markd
// Added cinematic and skipthread events
// 
// 97    8/15/98 11:18p Jimdose
// Restore was always starting the thread up.
// 
// 96    8/15/98 5:31p Jimdose
// Added SetScript to ScriptThread for changing script files without using a
// Goto
// 
// 95    8/14/98 9:09p Jimdose
// added waitUntil to keep track of wait times when marking and restoring (used
// when changing actor states)
// 
// 94    8/14/98 8:14p Aldie
// Added generic overlay system
// 
// 93    8/14/98 3:44p Jimdose
// WaitingFor variables are now all cleared after they're no longer valid
// 
// 92    8/13/98 7:45p Jimdose
// EventEnd now sets doneprocessing to true when doing the callback for model
// scripts
// 
// 91    8/13/98 7:29p Jimdose
// Added type to scriptthreads
// 
// 90    8/13/98 5:00p Jimdose
// ProcessCommand checks if variables are empty before using them with
// commands.
// 
// 89    8/12/98 6:43p Jimdose
// Changed TriggerEvent so that it doesn't add the entities that were triggered
// to the updateList.  This would cause them to eroniously recieve doMove
// commands, overriding their real movethread information.
// 
// 88    8/08/98 7:51p Jimdose
// changed realWorld to world
// 
// 87    8/07/98 5:44p Jimdose
// Process command now uses isVariableCommand to check if a command should be
// sent to a variable as apposed to the object that variable refers to
// 
// 86    8/06/98 10:49p Jimdose
// fixed index out of range bug in ProcessCommand 
// 
// 85    8/06/98 6:59p Jimdose
// Added GameTime
// 
// 84    8/06/98 5:18p Jimdose
// Added ProcessCommandFromEvent
// 
// 83    7/31/98 8:09p Jimdose
// Script commands now include flags to indicate cheats and console commands
// 
// 82    7/26/98 12:12a Markd
// Added precache ability to dialog stuff
// 
// 81    7/25/98 4:37p Aldie
// Menu controls
// 
// 80    7/24/98 6:18p Aldie
// enable and disable huds
// 
// 79    7/24/98 4:52p Jimdose
// Added setcvar command to script
// 
// 78    7/24/98 2:11p Markd
// Changed dialog from VOICE to DIALOG
// 
// 77    7/21/98 9:06p Markd
// Added music and soundtrack events
// 
// 76    7/21/98 4:14p Jimdose
// waitFor now adds the object to the update list so that if no commands have
// been issued, the object will give a moveDone right away
// Made DoMove post the EV_ProcessCommands event so that any callbacks to the
// thread don't clear the updateList
// 
// 75    7/20/98 5:48p Jimdose
// Added map command for changing levels
// 
// 74    7/18/98 7:36p Aldie
// Added support for fades
// 
// 73    7/16/98 5:18p Aldie
// Fixed error message bug.
// 
// 72    7/14/98 11:51p Jimdose
// EventEnd only notifies the owning model if the event comes from script
// 
// 71    7/11/98 9:24p Markd
// Forgot to add SetDialogScript event to ScriptThread
// 
// 70    7/11/98 8:43p Markd
// Added SetDialogScript, added optional label support to CreateThread
// 
// 69    7/11/98 2:49p Markd
// Added dialog event
// 
// 68    7/09/98 1:39a Jimdose
// updateList is now cleared everytime we execute the script to insure that it
// always only contains THIS frame's objects
// 
// 67    7/07/98 11:36p Jimdose
// Added error for unsupported global commands
// made end command signal self if model script
// added ThreadMarker
// 
// 66    7/03/98 4:10p Jimdose
// Added assert and break
// 
// 65    6/27/98 9:48p Jimdose
// Fixed a bug with TriggerEvent
// 
// 64    6/27/98 7:03p Markd
// Added WaitForSound
// 
// 63    6/25/98 8:14p Jimdose
// Made waitFor use *-entnum as well as targetname
// 
// 62    6/24/98 6:47p Jimdose
// Made entity number based commands use "*" prefix consistantly
// 
// 61    6/18/98 8:47p Jimdose
// Added better event error handling
// Added source info to events
// 
// 60    6/17/98 3:03p Markd
// Changed NumArgs back to previous behavior
// 
// 59    6/10/98 9:38p Jimdose
// Since we changed waitingFor to an str, ObjectMoveDone has to check if the
// length of waitingFor is > 0 before comaring it to the object's targetname,
// otherwise, calls to this function can cause threads that aren't waiting for
// objects to continue.
// 
// 58    6/10/98 7:53p Markd
// Made NumArgs behave correctly like argc
// 
// 57    6/10/98 6:08p Jimdose
// Made ProcessCommand add the thread to * commands
// 
// 56    6/09/98 4:22p Jimdose
// Added multi-file scripting
// each script now has its own set of labels that are only processed once
// 
// 55    6/04/98 11:07a Markd
// Made sure to initialize ScriptMaster when CloseScript is called
// 
// 54    5/27/98 5:03a Aldie
// Added warning for ent not found in * commands
// 
// 53    5/26/98 11:59p Markd
// put label support into ScriptMaster
// 
// 52    5/26/98 9:25p Aldie
// Added spawn command
// 
// 51    5/26/98 7:55p Jimdose
// added scripted cameras
// 
// 50    5/26/98 4:46p Aldie
// Added player commands
// 
// 49    5/26/98 4:22p Markd
// Added TargetList stuff and sped up SendToSlaves function
// 
// 48    5/25/98 1:39p Aldie
// Added create console user
// 
// 47    5/24/98 8:46p Jimdose
// Made a lot of functions more str-friendly.
// Got rid of a lot of char * based strings
// Cleaned up get spawn arg functions and sound functions
// sound functions now use consistant syntax
// 
// 46    5/24/98 4:48p Jimdose
// Made char *'s const
// 
// 45    5/22/98 10:57a Markd
// Put in label support parsing
// 
// 44    5/20/98 10:00p Jimdose
// Rewrote KillThread so that it didn't remove the thread from the list before
// calling the destructor, thus causing assertion failures
// 
// 43    5/20/98 5:30p Jimdose
// Added threadDying to prevent threads from executing after an "end" was
// reached.  There was a bug where a thread had a callback on the same frame
// that it was killed that caused it to execute code from another thread.
// 
// 42    5/20/98 4:31p Markd
// bullet-proofed thread code a bit
// 
// 41    5/19/98 4:24p Aldie
// Added DeathCallback and WaitForDeath
// 
// 40    5/13/98 4:57p Jimdose
// EventEnd now posts remove 0 in the future
// 
// 39    5/11/98 5:53p Markd
// Added aliascache command
// 
// 38    5/08/98 2:56p Markd
// Added alias event
// 
// 37    5/05/98 3:46p Aldie
// Uncommented surfaceManager stuff.
// 
// 36    5/04/98 8:31p Markd
// Added setlightstyle, cachemodel and cachesound
// 
// 35    5/04/98 8:11p Aldie
// Updated surfaceManager name
// 
// 34    5/02/98 8:47p Markd
// Added server and client event prefixes also modified CreateThread stuff
// 
// 33    5/01/98 5:05p Jimdose
// Added TriggerEvent
// 
// 32    4/03/98 1:10p Aldie
// Added waitForVariable
// 
// 31    3/28/98 4:35p Jimdose
// Disabled assertion in threadCallback
// 
// 30    3/28/98 3:28p Aldie
// Fixed some console input problems.
// 
// 29    3/27/98 6:46p Jimdose
// Made EventEnd notify waiting threads that it was ending
// 
// 28    3/27/98 6:23p Aldie
// Added some better console input stuff.
// 
// 27    3/26/98 7:15p Aldie
// Added console type vars.
// 
// 26    3/26/98 2:52p Aldie
// Added interface between consoles and scripts.
// 
// 25    3/24/98 8:54p Jimdose
// Added thread management script commands
// 
// 24    3/24/98 4:59p Jimdose
// Fixed various bugs related to the new event system
// 
// 23    3/23/98 1:45p Jimdose
// Fixed bug where GetThread was returning the wrong thread
// 
// 22    3/23/98 1:32p Jimdose
// Revamped event and command system
// Separated threads from controlling object for better thread management
// 
// 21    3/07/98 5:17p Aldie
// Fixed trans_mag and trans_angle.
// 
// 20    3/02/98 8:49p Jimdose
// Changed the classid parameter of CLASS_DECLARATION to a quoted string so
// that you could have a NULL classid.
// 
// 19    2/28/98 4:43p Aldie
// Added Matrix4TransformVector
// 
// 18    2/25/98 2:24p Aldie
// Updated texinfo command system.
// 
// 17    2/24/98 3:38p Aldie
// Added support for texinfo commands.
// 
// 16    2/21/98 1:10p Jimdose
// Changed initThread so that it doesn't search for a label if a NULL pointer
// is passed in and added a parameter to determine if it should execute the
// code immediately.
// 
// 15    2/18/98 8:05p Jimdose
// GetObject replaces getObjectFromScrip, getScriptObject, and FindEntity
// Commands are now sent to all entities with a specified targetname, rather
// than just the first one.
// 
// 
// 13    2/18/98 4:40p Jimdose
// Syntax for conditionals changed from "var condition value label" to "var
// condition value statement"
// Added check for non-numeric values in variables in GetFloat, GetDouble, and
// GetInt
// 
// 12    2/17/98 7:08p Jimdose
// Rewrote script variable support.  New support KICKS ASS. :)
// 
// 11    2/06/98 5:38p Jimdose
// Added check for missing file in setScript
// 
// 10    2/03/98 10:48a Jimdose
// Updated to work with Quake 2 engine
// Got rid of preprocessing stage.
// 
// 8     11/20/97 9:02p Jimdose
// Changed Container class to use ints instead of void *
// 
// 7     11/07/97 6:41p Jimdose
// Changed DoMove to remove entities from the updateList more efficiently.
// Added support for variables.
// 
// 6     10/28/97 4:22p Jimdose
// Made work with any Entity instead of just ScriptSlaves.
// Moved all general entity commands into Entity.  ScriptMaster now only
// handles script flow commands.
// updateList only contains the entities that received commands for the current
// frame and is then clear when processing for that iteration is done.
// 
// 5     10/27/97 3:30p Jimdose
// Removed dependency on quakedef.h
// 
// 4     10/06/97 6:36p Jimdose
// Added control over dynamic lights.
// 
// 3     9/26/97 5:23p Jimdose
// Added standard Ritual headers
//
// DESCRIPTION:
// Script masters are invisible entities that are spawned at the begining of each
// map.  They simple parse the script and send commands to the specified objects
// at the apropriate time.  Using a combination of simple commands, very complex
// scripted events can occur.
// 

#include "g_local.h"
#include "class.h"
#include "scriptmaster.h"
#include "container.h"
#include "scriptvariable.h"
#include "surface.h"
#include "console.h"
#include "misc.h"
#include "specialfx.h"
#include "worldspawn.h"
#include "player.h"

ScriptVariableList gameVars;
ScriptVariableList levelVars;
ScriptVariableList parmVars;
ScriptVariableList consoleVars;
static ScriptVariablePtr GameTime = NULL;

Event EV_ProcessCommands( "processCommands" );
Event EV_Script_NewOrders( "newOrders" );
Event EV_ScriptThread_Execute( "execute" );
Event EV_ScriptThread_Callback( "script_callback" );
Event EV_ScriptThread_ThreadCallback( "thread_callback" );
Event EV_ScriptThread_ConsoleCallback( "console_callback" );
Event EV_ScriptThread_VariableCallback( "variable_callback" );
Event EV_ScriptThread_DeathCallback( "death_callback" );
Event EV_ScriptThread_CreateThread( "thread" );
Event EV_ScriptThread_TerminateThread( "terminate" );
Event EV_ScriptThread_ControlObject( "control" );
Event EV_ScriptThread_Goto( "goto" );
Event EV_ScriptThread_Pause( "pause" );
Event EV_ScriptThread_Wait( "wait" );
Event EV_ScriptThread_WaitFor( "waitFor" );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -