Call of Duty 4: Replacement for devAdd motion functions

From COD Modding & Mapping Wiki
Revision as of 22:19, 10 February 2012 by Ingram (talk | contribs) (Improved limited_angle code, should be way more efficent.)
(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;
	angle %= 360;
	return (angle<0)*360+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;
	angle %= 360;
	return (angle<0)*360+angle;
}

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


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

--Ingram 19:19, 10 February 2012 (UTC)