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

📄 t_script.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 2 页
字号:
    }                }static runningscript_t *T_SaveCurrentScript(){  runningscript_t *runscr;  int i;  runscr = new_runningscript();  runscr->script = current_script;  runscr->savepoint = rover;  // leave to other functions to set wait_type: default to wt_none  runscr->wait_type = wt_none;  // hook into chain at start    runscr->next = runningscripts.next;  runscr->prev = &runningscripts;  runscr->prev->next = runscr;  if(runscr->next)    runscr->next->prev = runscr;    // save the script variables   for(i=0; i<VARIABLESLOTS; i++)    {      runscr->variables[i] = current_script->variables[i];            // remove all the variables from the script variable list      // to prevent them being removed when the script stops      while(current_script->variables[i] &&	    current_script->variables[i]->type != svt_label)	current_script->variables[i] =	  current_script->variables[i]->next;    }  runscr->trigger = current_script->trigger;      // save trigger    killscript = true;      // stop the script  return runscr;}// script functionvoid SF_Wait(){  runningscript_t *runscr;  if(t_argc != 1)    {      script_error("incorrect arguments to function\n");      return;    }  runscr = T_SaveCurrentScript();  runscr->wait_type = wt_delay;  runscr->wait_data = (intvalue(t_argv[0]) * 35) / 100;}// wait for sector with particular tag to stop movingvoid SF_TagWait(){  runningscript_t *runscr;  if(t_argc != 1)    {      script_error("incorrect arguments to function\n");      return;    }  runscr = T_SaveCurrentScript();  runscr->wait_type = wt_tagwait;  runscr->wait_data = intvalue(t_argv[0]);}// wait for a script to finishvoid SF_ScriptWait(){  runningscript_t *runscr;  if(t_argc != 1)    {      script_error("incorrect arguments to function\n");      return;    }  runscr = T_SaveCurrentScript();  runscr->wait_type = wt_scriptwait;  runscr->wait_data = intvalue(t_argv[0]);}extern mobj_t *trigger_obj;           // in t_func.cvoid SF_StartScript(){  runningscript_t *runscr;  script_t *script;  int i, snum;    if(t_argc != 1)    {      script_error("incorrect arguments to function\n");      return;    }  snum = intvalue(t_argv[0]);    script = levelscript.children[snum];    if(!script)    {      script_error("script %i not defined\n", snum);    }    runscr = new_runningscript();  runscr->script = script;  runscr->savepoint = script->data; // start at beginning  runscr->wait_type = wt_none;      // start straight away  // hook into chain at start    runscr->next = runningscripts.next;  runscr->prev = &runningscripts;  runscr->prev->next = runscr;  if(runscr->next)    runscr->next->prev = runscr;    // save the script variables   for(i=0; i<VARIABLESLOTS; i++)    {      runscr->variables[i] = script->variables[i];            // in case we are starting another current_script:      // remove all the variables from the script variable list      // we only start with the basic labels      while(runscr->variables[i] &&	    runscr->variables[i]->type != svt_label)	runscr->variables[i] =	  runscr->variables[i]->next;    }  // copy trigger  runscr->trigger = current_script->trigger;}void SF_ScriptRunning(){  runningscript_t *current;  int snum;  if(t_argc < 1)    {      script_error("not enough arguments to function\n");      return;    }  snum = intvalue(t_argv[0]);    for(current=runningscripts.next; current; current=current->next)    {      if(current->script->scriptnum == snum)	{	  // script found so return	  t_return.type = svt_int;	  t_return.value.i = 1;	  return;	}    }  // script not found  t_return.type = svt_int;  t_return.value.i = 0;}// running scriptsvoid COM_T_Running_f (void){  runningscript_t *current;    current = runningscripts.next;    CONS_Printf("running scripts\n");    if(!current)    CONS_Printf("no running scripts.\n");    while(current)    {      CONS_Printf("%i:", current->script->scriptnum);      switch(current->wait_type)	{	case wt_none:	  CONS_Printf("waiting for nothing?\n");	  break;	case wt_delay:	  CONS_Printf("delay %i tics\n", current->wait_data);	  break;	case wt_tagwait:	  CONS_Printf("waiting for tag %i\n", current->wait_data);	  break;	case wt_scriptwait:	  CONS_Printf("waiting for script %i\n", current->wait_data);	  break;	default:	  CONS_Printf("unknown wait type \n");	  break;	}      current = current->next;    }}void clear_runningscripts(){  runningscript_t *runscr, *next;    runscr = runningscripts.next;    // free the whole chain  while(runscr)    {      next = runscr->next;      free_runningscript(runscr);      runscr = next;    }  runningscripts.next = NULL;}mobj_t *MobjForSvalue(svalue_t svalue){  int intval ;    if(svalue.type == svt_mobj)    return svalue.value.mobj;    // this requires some creativity. We use the intvalue  // as the thing number of a thing in the level.    intval = intvalue(svalue);            if(intval < 0 || intval >= nummapthings || !mapthings[intval].mobj)    { script_error("no levelthing %i\n", intval); return NULL;}  return mapthings[intval].mobj;}/*********************            ADD SCRIPT *********************/// when the level is first loaded, all the// scripts are simply stored in the levelscript.// before the level starts, this script is// preprocessed and run like any other. This allows// the individual scripts to be derived from the// levelscript. When the interpreter detects the// 'script' keyword this function is calledvoid spec_script(){  int scriptnum;  int datasize;  script_t *script;  if(!current_section)    {      script_error("need seperators for script\n");      return;    }    // presume that the first token is "script"    if(num_tokens < 2)    {      script_error("need script number\n");      return;    }  scriptnum = intvalue(evaluate_expression(1, num_tokens-1));    if(scriptnum < 0)    {      script_error("invalid script number\n");      return;    }  script = Z_Malloc(sizeof(script_t), PU_LEVEL, 0);  // add to scripts list of parent  current_script->children[scriptnum] = script;    // copy script data  // workout script size: -2 to ignore { and }  datasize = current_section->end - current_section->start - 2;  // alloc extra 10 for safety  script->data = Z_Malloc(datasize+10, PU_LEVEL, 0);   // copy from parent script (levelscript)   // ignore first char which is {  memcpy(script->data, current_section->start+1, datasize);  // tack on a 0 to end the string  script->data[datasize] = '\0';    script->scriptnum = scriptnum;  script->parent = current_script; // remember parent    // preprocess the script now  preprocess(script);      // restore current_script: usefully stored in new script  current_script = script->parent;  // rover may also be changed, but is changed below anyway    // we dont want to run the script, only add it  // jump past the script in parsing    rover = current_section->end + 1;}/****** scripting command list *******/void T_AddCommands(){#ifdef FRAGGLESCRIPT  COM_AddCommand("t_dumpscript",  COM_T_DumpScript_f);  COM_AddCommand("t_runscript",   COM_T_RunScript_f);  COM_AddCommand("t_running",     COM_T_Running_f);#endif}//---------------------------------------------------------------------------//// $Log: t_script.c,v $// Revision 1.2  2001/03/13 22:14:20  stroggonmeth// Long time no commit. 3D floors, FraggleScript, portals, ect.//// Revision 1.1  2000/11/02 17:57:28  stroggonmeth// FraggleScript files...//// Revision 1.1.1.1  2000/04/30 19:12:08  fraggle// initial import//////---------------------------------------------------------------------------

⌨️ 快捷键说明

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