Ejemplo n.º 1
0
void vm_sleep(const ScriptArguments& args)
{
	args.getThread()->wakeCounter = args[0].integerValue();
	if( args.getThread()->wakeCounter == 0 ) {
		args.getThread()->wakeCounter = -1;
	}
}
Ejemplo n.º 2
0
void vm_if(const ScriptArguments& args)
{
	auto n = args[0].integer;
	if( n <= 7 ) {
		args.getThread()->conditionCount = n+1;
		args.getThread()->conditionMask = 0xFF;
		args.getThread()->conditionAND = true;
	}
	else {
		args.getThread()->conditionCount = n-19;
		args.getThread()->conditionMask = 0x00;
		args.getThread()->conditionAND = false;
	}
}
Ejemplo n.º 3
0
void game_create_vehicle(const ScriptArguments& args)
{
	auto id	= args[0].integer;
	glm::vec3 position(args[1].real, args[2].real, args[3].real);
	if( position.z < -99.f ) {
		position = args.getWorld()->getGroundAtPosition(position);
	}
	position += spawnMagic;

	auto vehicle = args.getWorld()->createVehicle(id, position);

	if ( args.getThread()->isMission )
	{
		args.getState()->missionObjects.push_back(vehicle->getGameObjectID());
	}

	*args[4].globalInteger = vehicle->getGameObjectID();
}
Ejemplo n.º 4
0
void game_create_character(const ScriptArguments& args)
{
	auto type = args[0].integer;
	auto id	= args[1].integer;
	glm::vec3 position(args[2].real, args[3].real, args[4].real);
	
	if( type == 21 ) {
		
	}
	if( position.z < -99.f ) {
		position = args.getWorld()->getGroundAtPosition(position);
	}
	
	auto character = args.getWorld()->createPedestrian(id, position + spawnMagic);
	/* Controller will give ownership to character */
	new DefaultAIController(character);
	
	if ( args.getThread()->isMission )
	{
		args.getState()->missionObjects.push_back(character->getGameObjectID());
	}
	
	*args[5].globalInteger = character->getGameObjectID();
}
Ejemplo n.º 5
0
void vm_global_int_eq_int(const ScriptArguments& args)
{
	args.getThread()->conditionResult =  *args[0].globalInteger == args[1].integerValue();
}
Ejemplo n.º 6
0
void vm_global_int_ge_int(const ScriptArguments& args)
{
	args.getThread()->conditionResult =  *args[0].globalInteger >= args[1].integer;
}
Ejemplo n.º 7
0
void vm_global_float_gt_float(const ScriptArguments& args)
{
	args.getThread()->conditionResult =  *args[0].globalReal > args[1].real;
}
Ejemplo n.º 8
0
void vm_name_thread(const ScriptArguments& args)
{
	strncpy(args.getThread()->name, args[0].string, 16);
}
Ejemplo n.º 9
0
void vm_jump(const ScriptArguments& args)
{
	args.getThread()->programCounter = localizeLabel(args.getThread(), args[0].integer);
}
Ejemplo n.º 10
0
void vm_return(const ScriptArguments& args)
{
	args.getThread()->programCounter = args.getThread()->calls[--args.getThread()->stackDepth];
}
Ejemplo n.º 11
0
void vm_call(const ScriptArguments& args)
{
	args.getThread()->calls[args.getThread()->stackDepth++] = args.getThread()->programCounter;
	args.getThread()->programCounter = localizeLabel(args.getThread(), args[0].integer);
}
Ejemplo n.º 12
0
void vm_halt_thread(const ScriptArguments& args)
{
	// ensure the thread is immediately yeilded
	args.getThread()->wakeCounter = -1;
	args.getThread()->finished = true;
}
Ejemplo n.º 13
0
void vm_jump_if_false(const ScriptArguments& args)
{
	if( ! args.getThread()->conditionResult ) {
		args.getThread()->programCounter = localizeLabel(args.getThread(), args[0].integer);
	}
}