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

📄 scriptslave.cpp

📁 this keik game source
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		e = new Event( EV_Trigger_ActivateTargets );
		//fixme
		//get "other"
		e->AddEntity( world );
		ProcessEvent( e );
		}
	}

void ScriptSlave::GotoNextWaypoint
	( 
	Event *ev
	)

	{
	int ent;

	commandswaiting = true;

	if ( !waypoint )
		{
		ev->Error( "%s is currently not at a waypoint", TargetName() );
		return;
		}

	ent = G_FindTarget( 0, waypoint->Target() );
	if ( !ent )
		{
		ev->Error( "%s could not find waypoint %s", TargetName(), waypoint->Target() );
		return;
		}

	waypoint = ( Waypoint * )G_GetEntity( ent );
	if ( waypoint )
		{
		NewPos = waypoint->worldorigin;
		}
	}

void ScriptSlave::JumpTo
	(
	Event *ev
	)

	{
	Entity *part;

   //
   // see if it is a vector
   //
   if ( ev->IsVectorAt( 1 ) )
      {
      NewPos = ev->GetVector( 1 );
		if ( bindmaster )
			{
			origin = bindmaster->getLocalVector( NewPos - bindmaster->worldorigin );
			}
		else
			{
			origin = NewPos;
			}

		for( part = this; part; part = part->teamchain )
			{
			part->setOrigin( part->origin );
			part->worldorigin.copyTo( part->edict->s.old_origin );
			part->edict->s.renderfx |= RF_FRAMELERP;
			}
      }
   else
      {
	   waypoint = ( Waypoint * )ev->GetEntity( 1 );
	   if ( waypoint )
		   {
		   NewPos = waypoint->origin;
		   if ( bindmaster )
			   {
			   origin = bindmaster->getLocalVector( NewPos - bindmaster->worldorigin );
			   }
		   else
			   {
			   origin = NewPos;
			   }

		   for( part = this; part; part = part->teamchain )
			   {
			   part->setOrigin( part->origin );
			   part->worldorigin.copyTo( part->edict->s.old_origin );
			   part->edict->s.renderfx |= RF_FRAMELERP;
			   }
		   }
      }
	}

void ScriptSlave::MoveToEvent
	( 
	Event *ev
	)

	{
	commandswaiting = true; 

   //
   // see if it is a vector
   //
   if ( ev->IsVectorAt( 1 ) )
      {
      NewPos = ev->GetVector( 1 );
      }
   else
      {
	   waypoint = ( Waypoint * )ev->GetEntity( 1 );
	   if ( waypoint )
		   {
		   NewPos = waypoint->worldorigin;
		   }
      }
	}

void ScriptSlave::SetSpeed
	(
	Event *ev
	)

	{
	speed = ev->GetFloat( 1 );
	traveltime = 0;
	}

void ScriptSlave::SetTime
	(
	Event *ev
	)

	{
	traveltime = ev->GetFloat( 1 );
	}

// Relative move commands

void ScriptSlave::MoveUp
	(
	Event *ev
	)

	{
	commandswaiting = true; 
	NewPos[ 2 ] += ev->GetDouble( 1 );
	}

void ScriptSlave::MoveDown
	(
	Event *ev
	)

	{
	commandswaiting = true; 
	NewPos[ 2 ] -= ev->GetDouble( 1 );
	}

void ScriptSlave::MoveNorth
	(
	Event *ev
	)

	{
	commandswaiting = true; 
	NewPos[ 1 ] += ev->GetDouble( 1 );
	}

void ScriptSlave::MoveSouth
	(
	Event *ev
	)

	{
	commandswaiting = true; 
	NewPos[ 1 ] -= ev->GetDouble( 1 );
	}

void ScriptSlave::MoveEast
	(
	Event *ev
	)

	{
	commandswaiting = true; 
	NewPos[ 0 ] += ev->GetDouble( 1 );
	}

void ScriptSlave::MoveWest
	(
	Event *ev
	)

	{
	commandswaiting = true; 
	NewPos[ 0 ] -= ev->GetDouble( 1 );
	}

void ScriptSlave::MoveForward
	(
	Event *ev
	)

	{
	Vector v;
	Vector t;

	commandswaiting = true; 

	t = NewAngles + ForwardDir;
	t.AngleVectors( &v, NULL, NULL );

	NewPos += v * ev->GetDouble( 1 );
	}

void ScriptSlave::MoveBackward
	(
	Event *ev
	)

	{
	Vector v;
	Vector t;

	commandswaiting = true;

	t = NewAngles + ForwardDir;
	t.AngleVectors( &v, NULL, NULL );

	NewPos -= v * ev->GetDouble( 1 );
	}

void ScriptSlave::MoveLeft
	(
	Event *ev
	)

	{
	Vector v;
	Vector t;

	commandswaiting = true; 

	t = NewAngles + ForwardDir;
	t.AngleVectors( NULL, &v, NULL );

	NewPos -= v * ev->GetDouble( 1 );
	}

void ScriptSlave::MoveRight
	(
	Event *ev
	)

	{
	Vector t;
	Vector v;

	commandswaiting = true; 

	t = NewAngles + ForwardDir;
	t.AngleVectors( NULL, &v, NULL );

	NewPos += v * ev->GetDouble( 1 );
	}

// exact rotate commands

void ScriptSlave::RotateXdownto
	(
	Event *ev
	)

	{
	commandswaiting = true; 

	NewAngles[ 0 ] = ev->GetFloat( 1 );
	if ( NewAngles[ 0 ] > angles[ 0 ] )
		{
		NewAngles[ 0 ] -= 360;
		}
	}

void ScriptSlave::RotateYdownto
	(
	Event *ev
	)

	{
	commandswaiting = true; 

	NewAngles[ 1 ] = ev->GetFloat( 1 );
	if ( NewAngles[ 1 ] > angles[ 1 ] )
		{
		NewAngles[ 1 ] -= 360;
		}
	}

void ScriptSlave::RotateZdownto
	(
	Event *ev
	)

	{
	commandswaiting = true; 

	NewAngles[ 2 ] = ev->GetFloat( 1 );
	if ( NewAngles[ 2 ] > angles[ 2 ] )
		{
		NewAngles[ 2 ] -= 360;
		}
	}

void ScriptSlave::RotateAxisdownto
	(
	Event *ev
	)

	{
   int axis;
	commandswaiting = true; 

   axis = ev->GetInteger( 1 );
	NewAngles[ axis ] = ev->GetFloat( 2 );
	if ( NewAngles[ axis ] > angles[ axis ] )
		{
		NewAngles[ axis ] -= 360;
		}
	}

void ScriptSlave::RotateXupto
	(
	Event *ev
	)

	{
	commandswaiting = true; 

	NewAngles[ 0 ] = ev->GetFloat( 1 );
	if ( NewAngles[ 0 ] < angles[ 0 ] )
		{
		NewAngles[ 0 ] += 360;
		}
	}

void ScriptSlave::RotateYupto
	(
	Event *ev
	)

	{
	commandswaiting = true; 

	NewAngles[ 1 ] = ev->GetFloat( 1 );
	if ( NewAngles[ 1 ] < angles[ 1 ] )
		{
		NewAngles[ 1 ] += 360;
		}
	}

void ScriptSlave::RotateZupto
	(
	Event *ev
	)

	{
	commandswaiting = true; 

	NewAngles[ 2 ] = ev->GetFloat( 1 );
	if ( NewAngles[ 2 ] < angles[ 2 ] )
		{
		NewAngles[ 2 ] += 360;
		}
	}

void ScriptSlave::RotateAxisupto
	(
	Event *ev
	)

	{
   int axis;
	commandswaiting = true; 

   axis = ev->GetInteger( 1 );
	NewAngles[ axis ] = ev->GetFloat( 2 );
	if ( NewAngles[ axis ] < angles[ axis ] )
		{
		NewAngles[ axis ] += 360;
		}
	}

// full vector rotation

void ScriptSlave::Rotatedownto
	(
	Event *ev
	)

	{
   Vector ang;
	commandswaiting = true; 

   ang = ev->GetVector( 1 );

	NewAngles[ 0 ] = ang[ 0 ];
	if ( NewAngles[ 0 ] > angles[ 0 ] )
		{
		NewAngles[ 0 ] -= 360;
		}
	NewAngles[ 1 ] = ang[ 1 ];
	if ( NewAngles[ 1 ] > angles[ 1 ] )
		{
		NewAngles[ 1 ] -= 360;
		}
	NewAngles[ 2 ] = ang[ 2 ];
	if ( NewAngles[ 2 ] > angles[ 2 ] )
		{
		NewAngles[ 2 ] -= 360;
		}
	}

void ScriptSlave::Rotateupto
	(
	Event *ev
	)

	{
   Vector ang;
	commandswaiting = true; 

   ang = ev->GetVector( 1 );

	NewAngles[ 0 ] = ang[ 0 ];
	if ( NewAngles[ 0 ] < angles[ 0 ] )
		{
		NewAngles[ 0 ] += 360;
		}
	NewAngles[ 1 ] = ang[ 1 ];
	if ( NewAngles[ 1 ] < angles[ 1 ] )
		{
		NewAngles[ 1 ] += 360;
		}
	NewAngles[ 2 ] = ang[ 2 ];
	if ( NewAngles[ 2 ] < angles[ 2 ] )
		{
		NewAngles[ 2 ] += 360;
		}
	}

void ScriptSlave::Rotateto
	(
	Event *ev
	)

	{
   Vector ang;
	commandswaiting = true; 

   ang = ev->GetVector( 1 );

   NewAngles = ang;
	}

// Relative rotate commands

void ScriptSlave::RotateXdown
	(
	Event *ev
	)

	{
	commandswaiting = true; 
	NewAngles[ 0 ] = angles[ 0 ] - ev->GetFloat( 1 );
	}

void ScriptSlave::RotateYdown
	(
	Event *ev
	)

	{
	commandswaiting = true; 
	NewAngles[ 1 ] = angles[ 1 ] - ev->GetFloat( 1 );
	}

void ScriptSlave::RotateZdown
	(
	Event *ev
	)

	{
	commandswaiting = true; 
	NewAngles[ 2 ] = angles[ 2 ] - ev->GetFloat( 1 );
	}

void ScriptSlave::RotateAxisdown
	(
	Event *ev
	)

	{
   int axis;
	commandswaiting = true; 

   axis = ev->GetInteger( 1 );
	NewAngles[ axis ] = angles[ axis ] - ev->GetFloat( 2 );
	}

void ScriptSlave::RotateXup
	(
	Event *ev
	)

	{
 	commandswaiting = true; 
	NewAngles[ 0 ] = angles[ 0 ] + ev->GetFloat( 1 );
	}

void ScriptSlave::RotateYup
	(
	Event *ev
	)

	{
 	commandswaiting = true; 
	NewAngles[ 1 ] = angles[ 1 ] + ev->GetFloat( 1 );
	}

void ScriptSlave::RotateZup
	(
	Event *ev
	)

	{
 	commandswaiting = true; 
	NewAngles[ 2 ] = angles[ 2 ] + ev->GetFloat( 1 );
	}

void ScriptSlave::RotateAxisup
	(
	Event *ev
	)

	{
   int axis;
	commandswaiting = true; 

   axis = ev->GetInteger( 1 );
	NewAngles[ axis ] = angles[ axis ] + ev->GetFloat( 2 );
	}

void ScriptSlave::RotateX
	(
	Event *ev
	)

	{
	avelocity[ 0 ] = ev->GetFloat( 1 );
	}

void ScriptSlave::RotateY
	(
	Event *ev
	)

	{
	avelocity[ 1 ] = ev->GetFloat( 1 );
	}

void ScriptSlave::RotateZ
	(
	Event *ev
	)

	{
	avelocity[ 2 ] = ev->GetFloat( 1 );
	}

void ScriptSlave::RotateAxis
	(
	Event *ev
	)

	{
   int axis;

   axis = ev->GetInteger( 1 );
   avelocity[ axis ] = ev->GetFloat( 2 );
	}


void ScriptSlave::OnTouch
	(
	Event *ev
	)

	{
	const char *jumpto;

	touchlabel = "";

	jumpto = ev->GetString( 1 );
	touchthread = ev->GetThread();

	assert( jumpto && touchthread );
	if ( touchthread && !touchthread->labelExists( jumpto ) )
		{
		ev->Error( "Label '%s' not found", jumpto );
		return;
		}

	touchlabel = jumpto;
	}

void ScriptSlave::NoTouch
	(
	Event *ev
	)

	{
	touchlabel = "";
	}

void ScriptSlave::TouchFunc
	(
	Event *ev
	)

	{
	Event *e;
	Entity *other;

	if ( touchlabel.length() )
		{
      // since we use a SafePtr, the thread pointer will be NULL if the thread has ended
      // so we should just clear our label and continue
      if ( !touchthread )
			{
         touchlabel = "";
         return;
         }

      other = ev->GetEntity( 1 );

		e = new Event( EV_ScriptThread_Callback );
		e->AddEntity( this );
		e->AddString( touchlabel );
		e->AddEntity( other );
  		touchthread->ProcessEvent( e );

⌨️ 快捷键说明

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