Call of Duty 4: Replacement for devAdd motion functions: Difference between revisions

From COD Modding & Mapping Wiki
Jump to navigation Jump to search
(Created page with "Motion functions for development: * devAddPitch * [[Call_of_Duty_4:_Scripting_Reference_-_Motion::DevAddYaw|devAddY...")
 
(Improved limited_angle code, should be way more efficent.)
 
Line 32: Line 32:
limited_angle(angle)
limited_angle(angle)
{
{
if (!isdefined(angle))
if(!isDefined(angle))
return 0;
return 0;
angle %= 360;
while( angle >= 360 )
return (angle<0)*360+angle;
angle -= 360;
while( angle < 0 )
angle += 360;
return angle;
}
}
</pre>
</pre>
Line 69: Line 65:
limited_angle(angle)
limited_angle(angle)
{
{
if (!isdefined(angle))
if(!isDefined(angle))
return 0;
return 0;
angle %= 360;
while( angle >= 360 )
return (angle<0)*360+angle;
angle -= 360;
while( angle < 0 )
angle += 360;
return angle;
}
}
</pre>
</pre>
Line 85: Line 77:
--[[User:CoDEmanX|CoDEmanX]] 20:27, 2 February 2012 (UTC)
--[[User:CoDEmanX|CoDEmanX]] 20:27, 2 February 2012 (UTC)


--[[User:Ingram|Ingram]] 19:19, 10 February 2012 (UTC)


[[Category:Call of Duty 4]]
[[Category:Call of Duty 4]]
[[Category:Scripting]]
[[Category:Scripting]]

Latest revision as of 22:19, 10 February 2012

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)