Call of Duty 4: Replacement for devAdd motion functions

From COD Modding & Mapping Wiki
Revision as of 23:27, 2 February 2012 by CoDEmanX (talk | contribs) (Created page with "Motion functions for development: * devAddPitch * [[Call_of_Duty_4:_Scripting_Reference_-_Motion::DevAddYaw|devAddY...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Motion functions for development:

These 3 development functions add a given angle to an entitiy without interpolation and in local space (relative change of pitch, yaw or roll). The stock CreateFX (ingame fx placer) script uses them.

Unfortunately, they aren't functional in the retail executable of the game. However, the same functionality can be scripted:

Variant 1

addPitch(pitch)
{
	angle = pitch + self.angles[0];
	return (limited_angle(angle), self.angles[1], self.angles[2]);
}

addYaw(yaw)
{
	angle = yaw + self.angles[1];
	return (self.angles[0], limited_angle(angle), self.angles[2]);
}

addRoll(roll)
{
	angle = roll + self.angles[2];
	return (self.angles[0], self.angles[1], limited_angle(angle));
}

limited_angle(angle)
{
	if (!isdefined(angle))
		return 0;
		
	while( angle >= 360 )
		angle -= 360;
	while( angle < 0 )
		angle += 360;
	return angle;
}

This variation can be used just like the devAdd* functions. You can call it like ent addRoll(20);


Variant 2

addPitch(pitch, source_angles)
{
	angle = pitch + source_angles[0];
	return (limited_angle(angle), source_angles[1], source_angles[2]);
}

addYaw(yaw, source_angles)
{
	angle = yaw + source_angles[1];
	return (source_angles[0], limited_angle(angle), source_angles[2]);
}

addRoll(roll, source_angles)
{
	angle = roll + source_angles[2];
	return (source_angles[0], source_angles[1], limited_angle(angle));
}

limited_angle(angle)
{
	if (!isdefined(angle))
		return 0;
		
	while( angle >= 360 )
		angle -= 360;
	while( angle < 0 )
		angle += 360;
	return angle;
}

Instead of calling ent devAddPitch(20); you would call addPitch(20, ent.angles);


--CoDEmanX 20:27, 2 February 2012 (UTC)