I'm trying to learn how to script a basic unit on Spring.. but it's not being easy. Cause i don't find any spring BOSes as references.
Here's my try. Is an Enforcer with a Raider cannon.. but both cannons doesn't fire nor aim in game. Only the depthcharges are fired.
I searched the forum for examples to copy script fragments... but i've not found any helpfull things.
What am i doing wrong? The img (with piece names) and BOS are attached. Any help would be greatly apreciated.
Weapon 1 = main original cannon
Weapon 2 = the new raider cannon
Weapon 3 = depthcharge

Code: Select all
#define TA // This is a TA script
#include "sfxtype.h"
#include "exptype.h"
piece flarea1, flarea2, flareb, base, turret, sleeves, wake1, wake2,
barrel1, barrel2, fp11, fp12, fp31, turretl, sleevel, barrell, flarel;
static-var fire, restore_delay;
SmokeUnit(healthpercent, sleeptime, smoketype)
{
while( get BUILD_PERCENT_LEFT )
{
sleep 400;
}
while( TRUE )
{
healthpercent = get HEALTH;
if( healthpercent < 66 )
{
smoketype = 256 | 2;
if( Rand( 1, 66 ) < healthpercent )
{
smoketype = 256 | 1;
}
emit-sfx smoketype from base;
}
sleeptime = healthpercent * 50;
if( sleeptime < 200 )
{
sleeptime = 200;
}
sleep sleeptime;
}
}
Create()
{
hide flarea1;
hide flarea2;
hide flareb;
hide flarel;
fire = 0;
restore_delay = 3000;
start-script SmokeUnit();
}
SetMaxReloadTime(time)
{
restore_delay = time * 2;
}
abaim()
{
sleep 4000;
signal 8;
}
RestoreAfterDelay()
{
sleep restore_delay;
turn turret to y-axis 0 speed <35>;
turn sleeves to x-axis 0 speed <15>;
turn turretl to y-axis 0 speed <45>;
turn sleevel to x-axis 0 speed <25>;
}
StartMoving()
{
signal 16;
set-signal-mask 16;
while( TRUE )
{
emit-sfx 2 from wake1;
emit-sfx 4 from wake2;
sleep 300;
}
}
StopMoving()
{
signal 16;
}
AimPrimary(heading, pitch)
{
signal 2;
set-signal-mask 2;
turn turret to y-axis heading speed <70>;
turn sleeves to x-axis 0 - pitch speed <40>;
wait-for-turn turret around y-axis;
wait-for-turn sleeves around x-axis;
start-script RestoreAfterDelay();
return (1);
}
AimTertiary(heading, pitch)
{
signal 8;
set-signal-mask 8;
start-script abaim();
return (1);
}
TargetCleared(time)
{
signal 8;
}
FirePrimary()
{
if( fire == 0 )
{
move barrel1 to z-axis [-2.4] speed [500];
wait-for-move barrel1 along z-axis;
move barrel1 to z-axis [0] speed [3.0];
show flarea1;
sleep 150;
hide flarea1;
}
if( fire == 1 )
{
move barrel2 to z-axis [-2.4] speed [500];
wait-for-move barrel2 along z-axis;
move barrel2 to z-axis [0] speed [3.0];
show flarea2;
sleep 150;
hide flarea2;
}
fire = !fire;
}
FireTertiary()
{
return (1);
}
AimFromPrimary(piecenum)
{
piecenum = turret;
}
QueryPrimary(piecenum)
{
if( fire == 0 )
{
piecenum = flarea1;
}
if( fire == 1 )
{
piecenum = flarea2;
}
}
AimFromTertiary(piecenum)
{
piecenum = fp31;
}
QueryTertiary(piecenum)
{
piecenum = fp31;
}
SweetSpot(piecenum)
{
piecenum = base;
}
AimSecondary(heading,pitch)
{
signal 4;
set-signal-mask 4;
turn turretl to y-axis heading speed <90>;
turn barrell to x-axis (0-pitch) speed <50>;
wait-for-turn turretl around y-axis;
wait-for-turn barrell around x-axis;
start-script RestoreAfterDelay();
return(1);
}
FireSecondary()
{
show flarel;
move barrell to z-axis [-2.4] speed [500];
sleep 150;
hide flarel;
wait-for-move barrell along z-axis;
move barrell to z-axis [0] speed [3.0];
}
AimFromSecondary(piecenum)
{
piecenum=turretl;
}
QuerySecondary(piecenum)
{
piecenum=flarel;
}
Killed(severity, corpsetype)
{
hide flarea1;
hide flarea2;
hide flareb;
hide flarel;
if( severity <= 25 )
{
corpsetype = 1;
explode barrel1 type BITMAPONLY | BITMAP1;
explode barrel2 type BITMAPONLY | BITMAP2;
explode base type BITMAPONLY | BITMAP3;
explode flarea1 type BITMAPONLY | BITMAP4;
explode flarea2 type BITMAPONLY | BITMAP5;
explode flareb type BITMAPONLY | BITMAP5;
explode sleeves type BITMAPONLY | BITMAP5;
explode turret type BITMAPONLY | BITMAP1;
explode wake1 type BITMAPONLY | BITMAP3;
explode wake2 type BITMAPONLY | BITMAP4;
return (0);
}
if( severity <= 50 )
{
corpsetype = 2;
explode barrel1 type FALL | BITMAP1;
explode barrel2 type FALL | BITMAP2;
explode base type BITMAPONLY | BITMAP3;
explode flarea1 type FALL | BITMAP4;
explode flarea2 type FALL | BITMAP5;
explode flareb type FALL | BITMAP5;
explode sleeves type BITMAPONLY | BITMAP5;
explode turret type BITMAPONLY | BITMAP1;
explode wake1 type FALL | BITMAP3;
explode wake2 type FALL | BITMAP4;
return (0);
}
if( severity <= 99 )
{
corpsetype = 3;
explode barrel1 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode barrel2 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP2;
explode base type BITMAPONLY | BITMAP3;
explode flarea1 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP4;
explode flarea2 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP5;
explode flareb type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP5;
explode sleeves type BITMAPONLY | BITMAP5;
explode turret type BITMAPONLY | BITMAP1;
explode wake1 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
explode wake2 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP4;
return (0);
}
corpsetype = 3;
explode barrel1 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode barrel2 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP2;
explode base type BITMAPONLY | BITMAP3;
explode flarea1 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP4;
explode flarea2 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP5;
explode flareb type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP5;
explode sleeves type BITMAPONLY | BITMAP5;
explode turret type BITMAPONLY | BITMAP1;
explode wake1 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
explode wake2 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP4;
}