What about the following code is a radical improvement over current methods?
Code: Select all
piece base, body, platform, box, upperdoor, lowerdoor;
piece rfbodyshaft, rfpiston, rfpistonarm;
piece lfbodyshaft, lfpiston, lfpistonarm;
piece rrbodyshaft, rrpiston, rrpistonarm;
piece lrbodyshaft, lrpiston, lrpistonarm;
piece upperrotator, lowerrotator, shaftnull, platformnull;
piece firepointone;
static-var bMoving;
static-var pitch_01;
static-var heading_01;
#define SIG_RESTORE 2
#define SIG_AIM1 4
#define SIG_MOVE 1
#define SMOKEPIECE1 base
#include "smokeunit.h"
#include "exptype.h"
#include "sfxtype.h"
Go()
{
// normal steps
if (bMoving)
{
// RightFront fronts
wait-for-turn rfbodyshaft around x-axis;
turn rfbodyshaft to x-axis <-50> speed <325>;
wait-for-turn rfbodyshaft around x-axis;
move rfpistonarm to y-axis [-0.3] speed [15];
turn rfbodyshaft to x-axis <0> speed <325>;
}
if (bMoving)
{
// RightFront backs
wait-for-turn rfbodyshaft around x-axis;
turn rfbodyshaft to x-axis <50> speed <325>;
move rfpistonarm to y-axis [0.4] speed [10];
wait-for-turn rfbodyshaft around x-axis;
turn rfbodyshaft to x-axis <0> speed <325>;
}
return 0;
}
Go2()
{
// normal steps
if (bMoving)
{
// RightBack backs
wait-for-turn rrbodyshaft around x-axis;
turn rrbodyshaft to x-axis <50> speed <325>;
move rrpistonarm to y-axis [0.4] speed [10];
wait-for-turn rrbodyshaft around x-axis;
turn rrbodyshaft to x-axis <0> speed <325>;
}
if (bMoving)
{
// RightBack fronts
wait-for-turn rrbodyshaft around x-axis;
turn rrbodyshaft to x-axis <-50> speed <325>;
wait-for-turn rrbodyshaft around x-axis;
move rrpistonarm to y-axis [-0.3] speed [15];
turn rrbodyshaft to x-axis <0> speed <325>;
}
return 0;
}
Go3()
{
// normal steps
if (bMoving)
{
// LeftBack fronts
wait-for-turn lrbodyshaft around x-axis;
turn lrbodyshaft to x-axis <-50> speed <325>;
wait-for-turn lrbodyshaft around x-axis;
move lrpistonarm to y-axis [-0.3] speed [15];
turn lrbodyshaft to x-axis <0> speed <325>;
}
if (bMoving)
{
// LeftBack backs
wait-for-turn lrbodyshaft around x-axis;
turn lrbodyshaft to x-axis <50> speed <325>;
move lrpistonarm to y-axis [0.4] speed [10];
wait-for-turn lrbodyshaft around x-axis;
turn lrbodyshaft to x-axis <0> speed <325>;
}
return 0;
}
Go4()
{
// normal steps
if (bMoving)
{
// LeftFront backs
wait-for-turn lfbodyshaft around x-axis;
turn lfbodyshaft to x-axis <50> speed <325>;
move lfpistonarm to y-axis [0.4] speed [10];
wait-for-turn lfbodyshaft around x-axis;
turn lfbodyshaft to x-axis <0> speed <325>;
}
if (bMoving)
{
// LeftFront fronts
wait-for-turn lfbodyshaft around x-axis;
turn lfbodyshaft to x-axis <-50> speed <325>;
wait-for-turn lfbodyshaft around x-axis;
move lfpistonarm to y-axis [-0.3] speed [15];
turn lfbodyshaft to x-axis <0> speed <325>;
}
return 0;
}
Stop()
// stop motion
{
sleep 200;
// RF and LR legs to start
turn rfbodyshaft to x-axis <0> now;
move rfpistonarm to y-axis [0] now;
turn lrbodyshaft to x-axis <10.2> now;
move lfpistonarm to y-axis [0] now;
sleep 100;
// RR and LF legs to start
turn rrbodyshaft to x-axis <10.2> now;
move rrpistonarm to y-axis [0] now;
turn lfbodyshaft to x-axis <0> now;
move lfpistonarm to y-axis [0] now;
sleep 100;
return 0;
}
MotionControl()
{ var moving,just_moved;
just_moved = 1;
WHILE ( TRUE )
{ moving = bMoving ;
IF (moving)
{
just_moved = 1;
call-script Go(bMoving);
}
IF (!moving)
{ IF (just_moved)
{ just_moved = 0;
call-script Stop();
}
SLEEP 50;
}
}
}
MotionControl2()
{ var moving,just_moved;
just_moved = 1;
WHILE ( TRUE )
{ moving = bMoving ;
IF (moving)
{
just_moved = 1;
call-script Go2();
}
IF (!moving)
{ IF (just_moved)
{
just_moved = 0;
}
SLEEP 100;
}
}
}
MotionControl3()
{ var moving,just_moved;
just_moved = 1;
WHILE ( TRUE )
{ moving = bMoving ;
IF (moving)
{
just_moved = 1;
call-script Go3();
}
IF (!moving)
{ IF (just_moved)
{
just_moved = 0;
}
SLEEP 100;
}
}
}
MotionControl4()
{ var moving,just_moved;
just_moved = 1;
WHILE ( TRUE )
{ moving = bMoving ;
IF (moving)
{
just_moved = 1;
call-script Go4();
}
IF (!moving)
{ IF (just_moved)
{
just_moved = 0;
}
SLEEP 100;
}
}
}
RestoreAfterDelay()
{
signal SIG_RESTORE;
set-signal-mask SIG_RESTORE;
sleep 5000;
turn platformnull to y-axis <0> speed <100.0>;
turn shaftnull to x-axis <0> speed <100.0>;
turn upperrotator to x-axis <-90> now;
turn lowerrotator to x-axis <90> now;
sleep 150;
turn upperrotator to x-axis <-45> now;
turn lowerrotator to x-axis <45> now;
sleep 150;
turn upperrotator to x-axis <0> now;
turn lowerrotator to x-axis <0> now;
return 0;
}
SweetSpot (piecenum)
{
piecenum = base;
}
Create()
{
hide base;
turn rrbodyshaft to x-axis <10.2> now;
turn lrbodyshaft to x-axis <10.2> now;
turn rfpiston to z-axis <-15> now;
turn rrpiston to z-axis <-15> now;
turn lfpiston to z-axis <15> now;
turn lrpiston to z-axis <15> now;
start-script SmokeUnit();
start-script MotionControl();
start-script MotionControl2();
start-script MotionControl3();
start-script MotionControl4();
bMoving = 0;
}
StartMoving()
{
bMoving = 1;
return 0;
}
StopMoving()
{
bMoving = 0;
return 0;
}
AimFromPrimary (piecenum)
{
piecenum = shaftnull;
}
AimPrimary(heading, pitch)
{
signal SIG_AIM1;
set-signal-mask SIG_AIM1;
wait-for-turn upperrotator around x-axis;
turn upperrotator to x-axis <225> speed <100>;
turn lowerrotator to x-axis <135> speed <100>;
pitch_01 = pitch;
IF ( pitch_01 <= 32768 )
{
turn shaftnull to x-axis 0 - pitch speed <100.0>;
}
IF ( pitch_01 > 32768 )
{
turn shaftnull to x-axis pitch speed <100.0>;
}
heading_01 = heading;
IF ( heading_01 <= 32768 )
{
turn platformnull to y-axis heading speed <100.0>;
}
IF ( heading_01 > 32768 )
{
turn platformnull to y-axis 0 - heading speed <100.0>;
}
wait-for-turn upperrotator around x-axis;
wait-for-turn platformnull around y-axis;
wait-for-turn shaftnull around x-axis;
start-script RestoreAfterDelay();
return(TRUE);
}
QueryPrimary(piecenum)
{
piecenum = firepointone;
return 0;
}
FirePrimary()
{
return 0;
}
Killed(severity, corpsetype)
{
//explode body type BITMAPONLY | BITMAP1;
//hide platform;
//hide box;
//hide upperdoor;
//explode lowerdoor type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
//explode rfbodyshaft type FALL | SMOKE | BITMAP1;
//explode rfpiston type FALL | SMOKE | BITMAP1;
//explode rfpistonarm type FALL | SMOKE | BITMAP1;
//hide lfbodyshaft;
//hide lfpiston;
//hide lfpistonarm;
//hide rrbodyshaft;
//hide rrpiston;
//hide rrpistonarm;
//explode lrbodyshaft type FALL | SMOKE | BITMAP1;
//explode lrpiston type FALL | SMOKE | BITMAP1;
//explode lrpistonarm type FALL | SMOKE | BITMAP1;
return (0);
}