Deployment Script

Deployment Script

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Deployment Script

Post by Pressure Line »

This is for a semi-mobile turret im working on, but should work for any mobile unit that has to stop to do a certain action (ie fire, build something etc)

NB, atm its a little bit broken, the unit will start moving before its pack up animation is completed. **edit** fixed, danke KDR

Code: Select all

StartMoving()
{
	signal SIG_MOVE;
	set-signal-mask SIG_MOVE;
	sleep 10;
	if( deployed )
	{
		call-script PackUp();
	}
}

StopMoving()
{
	signal SIG_MOVE;
	set-signal-mask SIG_MOVE;
	sleep 250;
	if( !overwater )
	{
		call-script Deploy();
	}
}
the overwater thing is because its a hover unit, and stops it from deploying over water. obviously not needed for vehicles/walkers or ships.

Code: Select all

Create()
{
	fbispeed = 3;
	restore_delay = 2000;
	hide flare1;
	deployed = 0;
	start-script SmokeUnit();
	start-script SlopeAdjust();
}

Code: Select all

PackUp()
{
	move turret to y-axis [0.000000] speed [0.800000];
	wait-for-move turret along y-axis;
	move frontthrust to y-axis [0.000000] speed [0.400000];
	move rearthrust to y-axis [0.000000] speed [0.400000];
	wait-for-move frontthrust along y-axis;
	wait-for-move rearthrust along y-axis;
	deployed = 0;
	set MAX_SPEED to fbispeed * 65536;
}
	
Deploy()
{
	move frontthrust to y-axis [-0.400000] speed [0.400000];
	move rearthrust to y-axis [-0.400000] speed [0.400000];
	wait-for-move frontthrust along y-axis;
	wait-for-move frontthrust along y-axis;
	move turret to y-axis [0.800000] speed [0.800000];
	wait-for-move turret along y-axis;
	deployed = 1;
	set MAX_SPEED to 1;
}
'fbispeed' is the unit's speed given in the fbi ( manually set in Create() )

and here is a sample of the code that stops it from shooting if it isnt deployed...

Code: Select all

AimPrimary(heading, pitch)
{
	signal SIG_AIM1;
	set-signal-mask SIG_AIM1;
	if( deployed )
	{
		turn turret to y-axis heading speed <90.000000>;
		turn sleeve to x-axis <0.000000> - pitch speed <45.000000>;
		wait-for-turn turret around y-axis;
		wait-for-turn sleeve around x-axis;
		start-script RestoreAfterDelay();
		return(TRUE);
	}
}
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Post by Guessmyname »

Hint: To get the initial speed without having to check the fbi, do this:

normspeed = get MAX_SPEED;
put this in Create()

Another tip is that you can just put speeds in [] rather than having to put the multiplier on the end. Though if you use the above method, you won't need to. The []'s tell scriptor to multiply whatever's in it by that multiplier.
Post Reply

Return to “Game Development”