#define TA // This is a TA script
#include "sfxtype.h"
#include "exptype.h"
piece base, hull, turret, firepoint, barrel, leftturret, leftcannon, rightturret, rightcannon, leftflare, rightflare;
static-var exp, restore_delay, leftgun, rightgun;
// Signal definitions
#define SIG_AIM 2
#define SIG_AIM_2 4
#define SIG_AIM_3 8
SetMaxReloadTime(Func_Var_1)
{
restore_delay = Func_Var_1 * 2;
}
RestoreAfterDelay()
{
sleep restore_delay;
turn turret to y-axis <0.000000> speed <90.000000>;
turn barrel to x-axis <0.000000> speed <90.000000>;
}
RestoreAfterDelay1()
{
sleep restore_delay;
turn leftturret to y-axis <0.000000> speed <90.000000>;
turn leftcannon to x-axis <0.000000> speed <90.000000>;
}
RestoreAfterDelay2()
{
sleep restore_delay;
turn rightturret to y-axis <0.000000> speed <90.000000>;
turn rightcannon to x-axis <0.000000> speed <90.000000>;
}
AimPrimary(heading, pitch)
{
signal SIG_AIM;
set-signal-mask SIG_AIM;
turn turret to y-axis heading speed <180.000000>;
turn barrel to x-axis <0.000000> - pitch speed <180.000000>;
wait-for-turn turret around y-axis;
wait-for-turn barrel around x-axis;
start-script RestoreAfterDelay();
return (1);
}
AimWeapon2(heading, pitch)
{
while (leftgun == 0);
{
sleep 1000;
}
signal SIG_AIM_2;
set-signal-mask SIG_AIM_2;
turn leftturret to y-axis heading speed <180.000000>;
turn leftcannon to x-axis <0.000000> - pitch speed <180.000000>;
wait-for-turn leftturret around y-axis;
wait-for-turn leftcannon around x-axis;
start-script RestoreAfterDelay1();
return (1);
}
AimWeapon3(heading, pitch)
{
while (rightgun == 0);
{
sleep 1000;
}
signal SIG_AIM_3;
set-signal-mask SIG_AIM_3;
turn rightturret to y-axis heading speed <180.000000>;
turn rightcannon to x-axis <0.000000> - pitch speed <180.000000>;
wait-for-turn rightturret around y-axis;
wait-for-turn rightcannon around x-axis;
start-script RestoreAfterDelay2();
return (1);
}
FirePrimary()
{
}
GetExp()
{
exp = GET VETERAN_LEVEL;
if (exp > 30);
{
show leftturret;
show leftcannon;
leftgun=1;
}
if (exp > 60);
{
show rightturret;
show rightcannon;
rightgun=1;
}
sleep 500;
start-script GetExp();
}
Create()
{
restore_delay = 3000;
leftgun = 0;
rightgun = 0;
exp = 0;
start-script GetExp();
hide leftturret;
hide leftcannon;
hide rightturret;
hide rightcannon;
}
AimFromPrimary(piecenum)
{
piecenum = turret;
}
QueryPrimary(piecenum)
{
piecenum = firepoint;
}
AimFromWeapon2(piecenum)
{
piecenum = leftturret;
}
QueryWeapon2(piecenum)
{
piecenum = leftflare;
}
AimFromWeapon3(piecenum)
{
piecenum = rightturret;
}
QueryWeapon3(piecenum)
{
piecenum = rightflare;
}
SweetSpot(piecenum)
{
piecenum = base;
}
Killed(severity, corpsetype)
{
}
I need scripting help...
Moderator: Moderators
I need scripting help...
I have a script and it seems to not work, at all, the unit will not fire ANY of the 3 guns, and it refuses to hide the extra guns.
hmm
What do you suggest, I want it to be set that once the gun is enabled, after a set experience number, it enables the gun.
Note: As of right now, the tank will not shoot any guns, even though all the guns show up in the game.
EDIT: I think, that if I use "IF" then it checks every frame, and seeing as how there will be around 20 of these in a game most of the time, that would lag bad.
Note: As of right now, the tank will not shoot any guns, even though all the guns show up in the game.
EDIT: I think, that if I use "IF" then it checks every frame, and seeing as how there will be around 20 of these in a game most of the time, that would lag bad.
ok but
that isn't the problem, the unit is A. showing the guns all the time, and B. Refuses to attack, thus it never gains experience, and never gets access to the other guns.
EDIT: This is the cob, looks a lot different eh?
EDIT: This is the cob, looks a lot different eh?
#define TA // This is a TA script
#include "sfxtype.h"
#include "exptype.h"
piece base, hull, turret, firepoint, barrel, leftturret, leftcannon, rightturret,
rightcannon, leftflare, rightflare;
static-var Static_Var_1, Static_Var_2, Static_Var_3, Static_Var_4;
SetMaxReloadTime(Func_Var_1)
{
Static_Var_2 = Func_Var_1 * 2;
}
RestoreAfterDelay()
{
sleep Static_Var_2;
turn turret to y-axis <-1.> speed <-1.>;
turn barrel to x-axis <-1.> speed <-1.>;
turn leftturret to y-axis <-1.> speed <-1.>;
turn leftcannon to x-axis <-1.> speed <-1.>;
turn rightturret to y-axis <-1.> speed <-1.>;
turn rightcannon to x-axis <-1.> speed <-1.>;
}
AimPrimary(heading, pitch)
{
signal 2;
set-signal-mask 2;
turn turret to y-axis heading speed <-1.>;
turn barrel to x-axis <-1.> - pitch speed <-1.>;
wait-for-turn turret around y-axis;
wait-for-turn barrel around x-axis;
start-script RestoreAfterDelay();
return (1);
}
AimWeapon2(Func_Var_1, Func_Var_2)
{
while( Static_Var_3 == 0 )
{
}
sleep 1000;
signal 4;
set-signal-mask 4;
turn leftturret to y-axis Func_Var_1 speed <-1.>;
turn leftcannon to x-axis <-1.> - Func_Var_2 speed <-1.>;
wait-for-turn leftturret around y-axis;
wait-for-turn leftcannon around x-axis;
start-script RestoreAfterDelay();
return (1);
}
AimWeapon3(Func_Var_1, Func_Var_2)
{
while( Static_Var_4 == 0 )
{
}
sleep 1000;
signal 8;
set-signal-mask 8;
turn rightturret to y-axis Func_Var_1 speed <-1.>;
turn rightcannon to x-axis <-1.> - Func_Var_2 speed <-1.>;
wait-for-turn rightturret around y-axis;
wait-for-turn rightcannon around x-axis;
start-script RestoreAfterDelay();
return (1);
}
FirePrimary()
{
}
GetExp()
{
Static_Var_1 = get VETERAN_LEVEL;
if( Static_Var_1 > 30 )
{
}
show leftturret;
show leftcannon;
Static_Var_3 = 1;
if( Static_Var_1 > 60 )
{
}
show rightturret;
show rightcannon;
Static_Var_4 = 1;
sleep 500;
start-script GetExp();
}
AimFromPrimary(piecenum)
{
piecenum = turret;
}
QueryPrimary(piecenum)
{
piecenum = firepoint;
}
AimFromWeapon2(Func_Var_1)
{
Func_Var_1 = 5;
}
QueryWeapon2(Func_Var_1)
{
Func_Var_1 = 9;
}
AimFromWeapon3(Func_Var_1)
{
Func_Var_1 = 7;
}
QueryWeapon3(Func_Var_1)
{
Func_Var_1 = 10;
}
SweetSpot(piecenum)
{
piecenum = base;
}
Create()
{
hide leftturret;
hide leftcannon;
hide rightturret;
hide rightcannon;
Static_Var_2 = 3000;
Static_Var_3 = 0;
Static_Var_4 = 0;
Static_Var_1 = 0;
start-script GetExp();
}
Killed(severity, corpsetype)
{
}
#define TAK // This is a TA script
#include "sfxtype.h"
#include "exptype.h"
piece torso, shieldcenter, ruparm, luparm, rbigflash, pelvis, lfirept, footleft, footright, head, flare1, flare2, headlaser1, headlaser2, energyleft, energyright, armor1r, armor1l, armor2r, armor2l,
lthigh, rthigh, biggun, rleg, lleg, rocketpack, rocket1, rocket2, rocket3, rocket4,
weapon1r, weapon1l, weapon1rbarrel, weapon1lbarrel, headlaserstrong, impulsegun, impulseflare, nuclear, slot,
weapon2r, weapon2l, weapon2rrotator, weapon2lrotator, flare2r, flare2l, flareback, lvlup;
static-var random, bMoving, exp, bAiming, Static_Var_3, Static_Var_4, gun_1, Static_Var_Rockets_4, gun_4, gun_5, gun_6, nuke, miniguns, plasma,
level, headlaser, rockets, nukemissile, impulse, extraarmour, shield, shield2;
// Signal definitions
#define SIG_AIM 2
#define SIG_AIM_2 4
#define SIG_AIM_3 8
#define SIG_AIM_4 16
#define SIG_AIM_5 32
#define SIG_AIM_6 64
#define SIG_AIM_7 128
#define SIG_AIM_8 256
#define SIG_AIM_9 512
#define SIG_AIM_11 1024
walk()
{
if( bMoving )
{
play-sound("stomp1", 36);
play-sound("machinereply", 12);
move pelvis to y-axis [-0.700000] now;
move head to y-axis [0.000000] now;
turn pelvis to x-axis <6.670330> now;
turn lthigh to x-axis <-41.835165> now;
turn rthigh to x-axis <17.571429> now;
turn torso to y-axis <4.203297> now;
turn ruparm to x-axis <-11.247253> now;
turn luparm to x-axis <11.247253> now;
turn biggun to x-axis <-62.582418> now;
turn rleg to x-axis <39.368132> now;
turn lleg to x-axis <41.835165> now;
sleep 40;
}
if( bMoving )
{
turn torso to y-axis <3.857143> now;
turn ruparm to x-axis <-13.346154> now;
turn luparm to x-axis <12.302198> now;
sleep 40;
}
if( bMoving )
{
move pelvis to y-axis [-0.550000] now;
turn pelvis to x-axis <5.269231> now;
turn lthigh to x-axis <-29.527473> now;
turn rthigh to x-axis <8.769231> now;
turn torso to y-axis <3.159341> now;
turn ruparm to x-axis <-8.071429> now;
turn luparm to x-axis <6.313187> now;
turn biggun to x-axis <-62.582418> now;
turn rleg to x-axis <51.681319> now;
turn lleg to x-axis <28.467033> now;
sleep 100;
}
if( bMoving )
{
move pelvis to y-axis [-0.300000] now;
turn pelvis to x-axis <4.560440> now;
turn lthigh to x-axis <-16.170330> now;
turn rthigh to x-axis <0.000000> now;
turn torso to y-axis <1.390110> now;
turn ruparm to x-axis <-3.148352> now;
turn luparm to x-axis <0.000000> now;
turn biggun to x-axis <-62.582418> now;
turn rleg to x-axis <58.005495> now;
turn lleg to x-axis <16.170330> now;
sleep 90;
}
if( bMoving )
{
move pelvis to y-axis [0.000000] now;
turn pelvis to x-axis <3.505495> now;
turn lthigh to x-axis <7.027473> now;
turn rthigh to x-axis <-6.313187> now;
turn torso to y-axis <0.000000> now;
turn ruparm to x-axis <3.159341> now;
turn luparm to x-axis <-6.313187> now;
turn rleg to x-axis <44.291209> now;
turn lleg to x-axis <5.615385> now;
sleep 90;
}
if( bMoving )
{
move pelvis to y-axis [-0.200000] now;
turn pelvis to x-axis <4.560440> now;
turn lthigh to x-axis <10.890110> now;
turn rthigh to x-axis <-34.456044> now;
turn torso to y-axis <-1.390110> now;
turn ruparm to x-axis <6.670330> now;
turn luparm to x-axis <-8.071429> now;
turn biggun to x-axis <-62.582418> now;
turn rleg to x-axis <71.368132> now;
turn lleg to x-axis <20.027473> now;
sleep 80;
}
if( bMoving )
{
move pelvis to y-axis [-0.300000] now;
turn lthigh to x-axis <13.000000> now;
turn rthigh to x-axis <-42.890110> now;
turn torso to y-axis <-2.456044> now;
turn ruparm to x-axis <8.423077> now;
turn luparm to x-axis <-9.137363> now;
turn rleg to x-axis <54.500000> now;
sleep 70;
}
if( bMoving )
{
move pelvis to y-axis [-0.400000] now;
turn pelvis to x-axis <5.269231> now;
turn lthigh to x-axis <16.868132> now;
turn rthigh to x-axis <-48.170330> now;
turn torso to y-axis <-3.159341> now;
turn ruparm to x-axis <10.192308> now;
turn luparm to x-axis <-10.192308> now;
turn biggun to x-axis <-62.582418> now;
turn rleg to x-axis <34.456044> now;
turn lleg to x-axis <20.027473> now;
sleep 80;
}
if( bMoving )
{
move pelvis to y-axis [-0.700000] now;
turn pelvis to x-axis <6.670330> now;
turn lthigh to x-axis <15.456044> now;
turn rthigh to x-axis <-40.423077> now;
turn torso to y-axis <-4.203297> now;
turn ruparm to x-axis <11.247253> now;
turn luparm to x-axis <-11.247253> now;
turn biggun to x-axis <-62.582418> now;
turn rleg to x-axis <40.423077> now;
turn lleg to x-axis <30.582418> now;
sleep 40;
}
if( bMoving )
{
turn ruparm to x-axis <13.346154> now;
turn luparm to x-axis <-12.302198> now;
turn biggun to x-axis <-62.582418> now;
sleep 40;
}
if( bMoving )
{
play-sound("stomp1", 36);
play-sound("machinereply", 12);
move pelvis to y-axis [-0.550000] now;
turn pelvis to x-axis <5.269231> now;
turn lthigh to x-axis <9.478022> now;
turn rthigh to x-axis <-34.456044> now;
turn torso to y-axis <-3.159341> now;
turn ruparm to x-axis <8.423077> now;
turn luparm to x-axis <-8.423077> now;
turn biggun to x-axis <-62.225275> now;
turn lleg to x-axis <43.934066> now;
sleep 100;
}
if( bMoving )
{
move pelvis to y-axis [-0.300000] now;
turn pelvis to x-axis <4.560440> now;
turn lthigh to x-axis <0.692308> now;
turn rthigh to x-axis <-26.357143> now;
turn torso to y-axis <-1.747253> now;
turn ruparm to x-axis <3.148352> now;
turn luparm to x-axis <-3.159341> now;
turn biggun to x-axis <-62.582418> now;
turn lleg to x-axis <54.489011> now;
sleep 90;
}
if( bMoving )
{
move pelvis to y-axis [0.000000] now;
turn pelvis to x-axis <3.505495> now;
turn lthigh to x-axis <-16.868132> now;
turn rthigh to x-axis <3.857143> now;
turn torso to y-axis <0.000000> now;
turn ruparm to x-axis <-3.159341> now;
turn luparm to x-axis <3.857143> now;
turn biggun to x-axis <-62.582418> now;
turn rleg to x-axis <8.071429> now;
turn lleg to x-axis <60.467033> now;
sleep 80;
}
if( bMoving )
{
move pelvis to y-axis [-0.200000] now;
turn pelvis to x-axis <4.560440> now;
turn lthigh to x-axis <-29.527473> now;
turn rthigh to x-axis <10.181319> now;
turn torso to y-axis <1.747253> now;
turn ruparm to x-axis <-6.670330> now;
turn luparm to x-axis <8.769231> now;
turn biggun to x-axis <-62.582418> now;
turn rleg to x-axis <26.005495> now;
turn lleg to x-axis <56.258242> now;
sleep 80;
}
if( bMoving )
{
move pelvis to y-axis [-0.300000] now;
turn lthigh to x-axis <-43.934066> now;
turn rthigh to x-axis <12.291209> now;
turn torso to y-axis <2.456044> now;
turn ruparm to x-axis <-7.027473> now;
turn luparm to x-axis <9.835165> now;
turn lleg to x-axis <55.901099> now;
sleep 70;
}
move pelvis to y-axis [-0.400000] now;
turn pelvis to x-axis <5.269231> now;
turn lthigh to x-axis <-43.934066> now;
turn rthigh to x-axis <14.401099> now;
turn torso to y-axis <3.159341> now;
turn ruparm to x-axis <-8.769231> now;
turn luparm to x-axis <10.192308> now;
turn biggun to x-axis <-62.582418> now;
turn lleg to x-axis <25.659341> now;
play-sound("stomp1", 36);
sleep 80;
}
walklegs()
{
if( bMoving )
{
play-sound("stomp1", 36);
play-sound("machinereply", 10);
move pelvis to y-axis [-0.700000] now;
move head to y-axis [0.000000] now;
turn pelvis to x-axis <6.670330> now;
turn lthigh to x-axis <-41.835165> now;
turn rthigh to x-axis <17.571429> now;
turn rleg to x-axis <39.368132> now;
turn lleg to x-axis <41.835165> now;
sleep 40;
}
if( bMoving )
{
sleep 40;
}
if( bMoving )
{
move pelvis to y-axis [-0.550000] now;
turn pelvis to x-axis <5.269231> now;
turn lthigh to x-axis <-29.527473> now;
turn rthigh to x-axis <8.769231> now;
turn rleg to x-axis <51.681319> now;
turn lleg to x-axis <28.467033> now;
sleep 100;
}
if( bMoving )
{
move pelvis to y-axis [-0.300000] now;
turn pelvis to x-axis <4.560440> now;
turn lthigh to x-axis <-16.170330> now;
turn rthigh to x-axis <0.000000> now;
turn rleg to x-axis <58.005495> now;
turn lleg to x-axis <16.170330> now;
sleep 90;
}
if( bMoving )
{
move pelvis to y-axis [0.000000] now;
turn pelvis to x-axis <3.505495> now;
turn lthigh to x-axis <7.027473> now;
turn rthigh to x-axis <-6.313187> now;
turn rleg to x-axis <44.291209> now;
turn lleg to x-axis <5.615385> now;
sleep 90;
}
if( bMoving )
{
move pelvis to y-axis [-0.200000] now;
turn pelvis to x-axis <4.560440> now;
turn lthigh to x-axis <10.890110> now;
turn rthigh to x-axis <-34.456044> now;
turn rleg to x-axis <71.368132> now;
turn lleg to x-axis <20.027473> now;
sleep 80;
}
if( bMoving )
{
move pelvis to y-axis [-0.300000] now;
turn lthigh to x-axis <13.000000> now;
turn rthigh to x-axis <-42.890110> now;
turn rleg to x-axis <54.500000> now;
sleep 70;
}
if( bMoving )
{
move pelvis to y-axis [-0.400000] now;
turn pelvis to x-axis <5.269231> now;
turn lthigh to x-axis <16.868132> now;
turn rthigh to x-axis <-48.170330> now;
turn rleg to x-axis <34.456044> now;
turn lleg to x-axis <20.027473> now;
sleep 80;
}
if( bMoving )
{
move pelvis to y-axis [-0.700000] now;
turn pelvis to x-axis <6.670330> now;
turn lthigh to x-axis <15.456044> now;
turn rthigh to x-axis <-40.423077> now;
turn rleg to x-axis <40.423077> now;
turn lleg to x-axis <30.582418> now;
sleep 40;
}
if( bMoving )
{
sleep 40;
}
if( bMoving )
{
play-sound("stomp1", 36);
play-sound("machinereply", 10);
move pelvis to y-axis [-0.550000] now;
turn pelvis to x-axis <5.269231> now;
turn lthigh to x-axis <9.478022> now;
turn rthigh to x-axis <-34.456044> now;
turn lleg to x-axis <43.934066> now;
sleep 100;
}
if( bMoving )
{
move pelvis to y-axis [-0.300000] now;
turn pelvis to x-axis <4.560440> now;
turn lthigh to x-axis <0.692308> now;
turn rthigh to x-axis <-26.357143> now;
turn lleg to x-axis <54.489011> now;
sleep 90;
}
if( bMoving )
{
move pelvis to y-axis [0.000000] now;
turn pelvis to x-axis <3.505495> now;
turn lthigh to x-axis <-16.868132> now;
turn rthigh to x-axis <3.857143> now;
turn rleg to x-axis <8.071429> now;
turn lleg to x-axis <60.467033> now;
sleep 80;
}
if( bMoving )
{
move pelvis to y-axis [-0.200000] now;
turn pelvis to x-axis <4.560440> now;
turn lthigh to x-axis <-29.527473> now;
turn rthigh to x-axis <10.181319> now;
turn rleg to x-axis <26.005495> now;
turn lleg to x-axis <56.258242> now;
sleep 80;
}
if( bMoving )
{
move pelvis to y-axis [-0.300000] now;
turn lthigh to x-axis <-43.934066> now;
turn rthigh to x-axis <12.291209> now;
turn lleg to x-axis <55.901099> now;
sleep 70;
}
move pelvis to y-axis [-0.400000] now;
turn pelvis to x-axis <5.269231> now;
turn lthigh to x-axis <-43.934066> now;
turn rthigh to x-axis <14.401099> now;
turn lleg to x-axis <25.659341> now;
play-sound("stomp1", 36);
sleep 80;
}
MotionControl(moving, aiming, justmoved)
{
justmoved = TRUE;
while( TRUE )
{
moving = bMoving;
aiming = bAiming;
if( moving )
{
if( aiming )
{
Static_Var_3 = 1;
call-script walklegs();
}
if( !aiming )
{
Static_Var_3 = 0;
call-script walk();
}
justmoved = TRUE;
}
if( !moving )
{
Static_Var_3 = 1;
if( justmoved )
{
move pelvis to y-axis [0.000000] speed [1.000000];
turn rthigh to x-axis <0.000000> speed <200.000000>;
turn rleg to x-axis <0.000000> speed <200.000000>;
turn lthigh to x-axis <0.000000> speed <200.000000>;
turn lleg to x-axis <0.000000> speed <200.000000>;
if( !aiming )
{
turn torso to x-axis <0.000000> speed <90.000000>;
}
justmoved = FALSE;
}
sleep 100;
}
}
}
ShieldOn()
{
shield = 1;
}
ShieldOff()
{
shield = 0;
}
missileReload()
{
sleep 10000;
show rocket1;
sleep 1000;
show rocket2;
sleep 1000;
show rocket3;
sleep 1000;
show rocket4;
sleep 1000;
Static_Var_Rockets_4 = 16;
}
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 energyright;
emit-sfx smoketype from rocket1;
}
if( healthpercent < 33 )
{
emit-sfx smoketype from head;
emit-sfx smoketype from impulsegun;
emit-sfx smoketype from ruparm;
}
sleeptime = healthpercent * 50;
if( sleeptime < 200 )
{
sleeptime = 200;
}
sleep sleeptime;
}
}
showlvlup()
{
show lvlup;
spin lvlup around y-axis speed <300.00000>;
sleep 4000;
hide lvlup;
}
Randomize()
{
random = Rand(1,6);
if (random == 1 AND headlaser == 0)
{
start-script showlvlup();
show headlaserstrong;
headlaser = 1;
level = level +1;
}
if (random == 2 AND rockets == 0)
{
start-script showlvlup();
show rocketpack;
show rocket1;
show rocket2;
show rocket3;
show rocket4;
rockets = 1;
level = level +1;
}
if (random == 3 AND extraarmour == 0)
{
start-script showlvlup();
set ARMORED to 1;
show armor1r;
show armor1l;
show armor2r;
show armor2l;
extraarmour = 1;
level = level +1;
}
if (random == 4 AND nukemissile == 0)
{
start-script showlvlup();
show nuclear;
nukemissile = 1;
nuke = 1;
level = level +1;
}
if (random == 5 AND impulse == 0)
{
start-script showlvlup();
show impulsegun;
impulse = 1;
level = level +1;
}
if (random == 6 AND shield2 == 0)
{
start-script showlvlup();
level = level +1;
shield2 = 1;
show energyleft;
show energyright;
call-script ShieldOn();
}
sleep 500;
}
GetExp()
{
exp = GET VETERAN_LEVEL;
if ( exp > 6 AND level == 0)
{
start-script Randomize();
}
if ( exp > 15 AND level == 1)
{
start-script Randomize();
}
if ( exp > 30 AND level == 2)
{
start-script Randomize();
}
if ( exp > 50 AND level == 3)
{
start-script Randomize();
}
if ( exp > 80 AND level == 4)
{
start-script Randomize();
}
if ( exp > 120 AND level == 5)
{
start-script Randomize();
}
sleep 500;
start-script GetExp();
}
Create()
{
hide lvlup;
hide headlaserstrong;
hide nuclear;
hide impulsegun;
hide rocketpack;
hide rocket1;
hide rocket2;
hide rocket3;
hide rocket4;
hide energyright;
hide energyleft;
hide rbigflash;
hide lfirept;
hide armor1r;
hide armor1l;
hide armor2r;
hide armor2l;
hide weapon2l;
hide weapon2lrotator;
hide weapon2r;
hide weapon2rrotator;
bMoving = FALSE;
bAiming = FALSE;
level = 0;
Static_Var_3 = 1;
Static_Var_4 = 0;
gun_1 = 0;
gun_4 = 0;
gun_5 = 0;
gun_6 = 0;
nuke = 1;
exp = 0;
extraarmour = 0;
impulse = 0;
nukemissile = 0;
rockets = 0;
headlaser = 0;
shield2 = 0;
miniguns = 0;
plasma = 1;
set ARMORED to 0;
Static_Var_Rockets_4 = 16;
call-script ShieldOff();
start-script MotionControl();
start-script SmokeUnit();
start-script GetExp();
}
// for switching weapons
Activate()
{
play-sound("weapchange", 25);
plasma = 0;
hide weapon1l;
hide weapon1lbarrel;
hide weapon1r;
hide weapon1rbarrel;
sleep 2000;
play-sound("weapchanged", 25);
miniguns = 1;
show weapon2l;
show weapon2lrotator;
show weapon2r;
show weapon2rrotator;
plasma = 0;
hide weapon1l;
hide weapon1lbarrel;
hide weapon1r;
hide weapon1rbarrel;
}
Deactivate()
{
play-sound("weapchange", 25);
miniguns = 0;
hide weapon2l;
hide weapon2lrotator;
hide weapon2r;
hide weapon2rrotator;
sleep 2000;
play-sound("weapchanged", 25);
plasma = 1;
show weapon1l;
show weapon1lbarrel;
show weapon1r;
show weapon1rbarrel;
miniguns = 0;
hide weapon2l;
hide weapon2lrotator;
hide weapon2r;
hide weapon2rrotator;
}
// end switching weapons
StartMoving()
{
bMoving = TRUE;
}
StopMoving()
{
bMoving = FALSE;
}
SweetSpot(piecenum)
{
piecenum = torso;
}
RestoreAfterDelay()
{
sleep 1000;
stop-spin weapon2rrotator around z-axis decelerate <20>;
stop-spin weapon2lrotator around z-axis decelerate <20>;
sleep 3000;
turn head to y-axis <0.000000> speed <140.000000>;
turn torso to y-axis <0.000000> speed <80.000000>;^
turn ruparm to x-axis <0> speed <45.000000>;
turn luparm to x-axis <0> speed <45.000000>;
// start-script GetExp();
}
RestorePosition()
{
Static_Var_4 = 0;
turn head to y-axis <0.000000> speed <140.000000>;
turn torso to y-axis <0.000000> speed <80.000000>;
turn ruparm to x-axis <0.000000> speed <45.000000>;
turn luparm to x-axis <0.000000> speed <45.000000>;
wait-for-turn torso around y-axis;
wait-for-turn ruparm around x-axis;
wait-for-turn luparm around x-axis;
bAiming = FALSE;
}
AimFromPrimary(piecenum)
{
piecenum = weapon1rbarrel;
}
QueryPrimary(piecenum)
{
piecenum = weapon1rbarrel;
}
AimPrimary(heading, pitch)
{
while (plasma == 0)
{
sleep 1000;
}
if( Static_Var_4 == 1 )
{
return (0);
}
signal SIG_AIM;
set-signal-mask SIG_AIM;
bAiming = TRUE;
while( !Static_Var_3 )
{
sleep 100;
}
turn torso to y-axis heading speed <80.000000>;
turn ruparm to x-axis <0.000000> - pitch speed <80.000000>;
wait-for-turn torso around y-axis;
wait-for-turn ruparm around x-axis;
start-script RestoreAfterDelay();
return (1);
}
FirePrimary()
{
play-sound("plasbomb", 22);
move weapon1rbarrel to z-axis [-3.000000] speed [500.000000];
turn ruparm to x-axis <50> speed <500.0>;
sleep 110;
move weapon1rbarrel to z-axis [0.000000] speed [10.000000];
turn ruparm to x-axis <0> speed <30.0>;
}
// ------------ begin weapon 2
AimWeapon2(heading, pitch)
{
while (plasma == 0)
{
sleep 1000;
}
bAiming = TRUE;
signal SIG_AIM_2;
set-signal-mask SIG_AIM_2;
turn torso to y-axis heading speed <80.000000>;
turn luparm to x-axis <0.000000> - pitch speed <80.000000>;
wait-for-turn torso around y-axis;
wait-for-turn luparm around x-axis;
start-script RestoreAfterDelay();
return (1);
}
FireWeapon2()
{
play-sound("plasbomb", 22);
move weapon1lbarrel to z-axis [-3.000000] speed [500.000000];
turn luparm to x-axis <50> speed <500.0>;
sleep 110;
move weapon1lbarrel to z-axis [0.000000] speed [10.000000];
turn luparm to x-axis <0> speed <30.0>;
}
AimFromWeapon2(piecenum)
{
piecenum = weapon1lbarrel;
return(0);
}
QueryWeapon2(piecenum)
{
piecenum = weapon1lbarrel;
}
// ------------ end weapon 2
// ------------ begin weapon 3
AimWeapon3(heading, pitch)
{
signal SIG_AIM_3;
set-signal-mask SIG_AIM_3;
turn head to y-axis heading speed <140.000000>;
wait-for-turn head around y-axis;
start-script RestoreAfterDelay();
return (1);
}
FireWeapon3()
{
if( gun_1 == 0 )
{
play-sound("laser200", 20);
show flare1;
sleep 500;
hide flare1;
}
if( gun_1 == 1 )
{
play-sound("laser200", 20);
show flare2;
sleep 500;
hide flare2;
}
gun_1 = gun_1 + 1;
if( gun_1==2 )
{
gun_1=0;
}
sleep 100;
}
AimFromWeapon3(piecenum)
{
if( gun_1 == 0 )
{
piecenum = head;
}
if( gun_1 == 1 )
{
piecenum = head;
}
}
QueryWeapon3(piecenum)
{
if( gun_1 == 0 )
{
piecenum = headlaser1;
}
if( gun_1 == 1 )
{
piecenum = headlaser2;
}
}
// ------------ end weapon 3
// ------------ begin weapon 4
AimWeapon4(heading, pitch)
{
while (rockets == 0)
{
sleep 1000;
}
signal SIG_AIM_4;
set-signal-mask SIG_AIM_4;
turn torso to y-axis heading speed <80.000000>;
wait-for-turn torso around y-axis;
while( Static_Var_Rockets_4 == 0 )
{
sleep 200;
}
return (1);
}
FireWeapon4()
{
if( Gun_4== 0 )
{
hide rocket1;
}
if( Gun_4== 1 )
{
hide rocket2;
}
if( Gun_4== 2 )
{
hide rocket3;
}
if( Gun_4== 3 )
{
hide rocket4;
Static_Var_Rockets_4 = 0;
start-script missileReload();
}
++Gun_4;
if( Gun_4== 4 )
{
Gun_4= 0;
}
}
AimFromWeapon4(piecenum)
{
if( Gun_4== 0 )
{
piecenum = rocket1;
}
if( Gun_4== 1 )
{
piecenum = rocket2;
}
if( Gun_4== 2 )
{
piecenum = rocket3;
}
if( Gun_4== 3 )
{
piecenum = rocket4;
}
}
QueryWeapon4(piecenum)
{
if( Gun_4== 0 )
{
piecenum = rocket1;
}
if( Gun_4== 1 )
{
piecenum = rocket2;
}
if( Gun_4== 2 )
{
piecenum = rocket3;
}
if( Gun_4== 3 )
{
piecenum = rocket4;
}
}
// ------------ end weapon 4
// ------------ begin weapon 5
AimWeapon5(heading, pitch)
{
while (headlaser == 0)
{
sleep 1000;
}
signal SIG_AIM_5;
set-signal-mask SIG_AIM_5;
turn head to y-axis heading speed <140.000000>;
wait-for-turn head around y-axis;
start-script RestoreAfterDelay();
return (1);
}
FireWeapon5()
{
sleep 100;
}
AimFromWeapon5(piecenum)
{
piecenum = head;
}
QueryWeapon5(piecenum)
{
piecenum = headlaserstrong;
}
// ------------ end weapon 5
AimWeapon6(heading, pitch)
{
while (impulse == 0)
{
sleep 1000;
}
signal SIG_AIM_6;
set-signal-mask SIG_AIM_6;
turn torso to y-axis heading speed <80.000000>;
wait-for-turn torso around y-axis;
start-script RestoreAfterDelay();
return (1);
}
FireWeapon6()
{
move impulsegun to z-axis [-2.000000] speed [500.000000];
sleep 100;
move impulsegun to z-axis [0.000000] speed [6.000000];
}
AimFromWeapon6(piecenum)
{
piecenum = torso;
}
QueryWeapon6(piecenum)
{
piecenum = impulseflare;
}
// ------------ end weapon 6
reloadNuke()
{
sleep 5000;
nuke = 1;
}
AimWeapon7(heading, pitch)
{
while (nuke == 0)
{
sleep 1000;
}
while (nukemissile == 0)
{
sleep 1000;
}
signal SIG_AIM_7;
set-signal-mask SIG_AIM_7;
return (1);
}
FireWeapon7()
{
show slot;
sleep 5000;
hide slot;
}
AimFromWeapon7(piecenum)
{
piecenum = nuclear;
}
QueryWeapon7(piecenum)
{
piecenum = slot;
}
// ------------ end weapon 7
// ------------ begin weapon 8
AimWeapon8(heading, pitch)
{
while (miniguns == 0)
{
sleep 1000;
}
bAiming = TRUE;
signal SIG_AIM_8;
set-signal-mask SIG_AIM_8;
turn torso to y-axis heading speed <80.000000>;
turn ruparm to x-axis <0.000000> - pitch speed <80.000000>;
wait-for-turn torso around y-axis;
wait-for-turn ruparm around x-axis;
start-script RestoreAfterDelay();
return (1);
}
FireWeapon8()
{
play-sound("gatling-1", 20);
show flare2r;
spin weapon2rrotator around z-axis speed <750.00000>;
hide flare2r;
sleep 500;
}
AimFromWeapon8(piecenum)
{
piecenum = torso;
}
QueryWeapon8(piecenum)
{
piecenum = flare2r;
}
// ------------ end weapon 8
// ------------ begin weapon 9
AimWeapon9(heading, pitch)
{
while (miniguns == 0)
{
sleep 1000;
}
bAiming = TRUE;
signal SIG_AIM_9;
set-signal-mask SIG_AIM_9;
turn torso to y-axis heading speed <80.000000>;
turn ruparm to x-axis <0.000000> - pitch speed <80.000000>;
wait-for-turn torso around y-axis;
wait-for-turn ruparm around x-axis;
start-script RestoreAfterDelay();
return (1);
}
FireWeapon9()
{
play-sound("gatling-1", 20);
show flare2l;
spin weapon2lrotator around z-axis speed <750.00000>;
hide flare2l;
sleep 500;
}
AimFromWeapon9(piecenum)
{
piecenum = torso;
}
QueryWeapon9(piecenum)
{
piecenum = flare2l;
}
// ------------ end weapon 9
AimWeapon10(heading, pitch)
{
sleep 100;
return (shield);
}
FireWeapon10()
{
sleep 100;
}
QueryWeapon10(piecenum)
{
piecenum = shieldcenter;
}
AimFromWeapon10(piecenum)
{
piecenum = shieldcenter;
}
// ------------ end weapon 10
AimWeapon11(heading, pitch)
{
signal SIG_AIM_11;
set-signal-mask SIG_AIM_11;
turn flareback to y-axis heading speed <160.000000>;
wait-for-turn flareback around y-axis;
sleep 100;
return (1);
}
FireWeapon11()
{
show flareback;
sleep 100;
hide flareback;
}
QueryWeapon11(piecenum)
{
piecenum = flareback;
}
AimFromWeapon11(piecenum)
{
piecenum = flareback;
}
StartBuilding(Func_Var_1, Func_Var_2)
{
bAiming = TRUE;
while( !Static_Var_3 )
{
sleep 100;
}
turn torso to y-axis Func_Var_1 speed <80.000000>;
turn luparm to x-axis <-30.005495> speed <45.000000>;
wait-for-turn torso around y-axis;
wait-for-turn luparm around x-axis;
set INBUILDSTANCE to 1;
}
TargetCleared(Func_Var_1)
{
signal SIG_AIM;
set-signal-mask SIG_AIM;
call-script RestorePosition();
}
StopBuilding()
{
set INBUILDSTANCE to 0;
signal SIG_AIM;
set-signal-mask SIG_AIM;
call-script RestorePosition();
}
Killed(severity, corpsetype)
{
hide rbigflash;
hide lfirept;
corpsetype = 1;
explode pelvis type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode lthigh type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode lleg type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode rthigh type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode rleg type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode head type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode headlaser1 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode headlaser2 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode footleft type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode footright type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode armor1l type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode armor2r type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode armor2l type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode armor1r type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode rocket1 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode rocket3 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode weapon1r type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode weapon1l type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode weapon2r type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode weapon1l type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode weapon1rbarrel type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode weapon1lbarrel type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode weapon2rrotator type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode weapon2lrotator type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
}
You have empty while cycles in your script.
This will lag so bad the game might hang. If that is really just your compiled script after decompiling, then your BOS compiler has problems.
Also, you GetExp() recusrively restarts itself. That can be the problem, too. Try to redo it with a while cycle, like this:
Code: Select all
while( Static_Var_4 == 0 )
{
}
Also, you GetExp() recusrively restarts itself. That can be the problem, too. Try to redo it with a while cycle, like this:
Code: Select all
GetExp()
while(TRUE)
{
... <put your current GetExp() code here> ...
sleep 500;
}
Remove that semicolon here. It's what cause your while to be sleepless.while (rightgun == 0);
{
sleep 1000;
}
To make a function that is run over and over, instead of having the function "start-script" itself, I'm more used to adding a big while(TRUE){ ... } around the part that must be repeated. But maybe your way works too, I dunno if that's important.
I heard once from a Spring dev that one must not mix the Aiming/Firing/etc... named Primary,Secondary,Tertiary with those named 1,2,3,4,... I have no idea what would be the consequences however.
While(something) {} should crash the game if that something is true. Spring will only stop running the COB and start doing anything else once it hits a sleep or wait statement, an infinite loop without any sleep or wait statements will make Spring hang.
You're supposed to write
signal SIG_Aim;
set-signal-mask SIG_Aim;
while(!ready) {
sleep 30;
}
or something. Just think how your code will execute, if you always catch the AimWeapon call in a loop it won't stop running until the loop ends. How many AimWeapon calls will be received before the unit gets those extra weapons, 100? 200? Each of these calls will get stuck in the loop and Spring only lets each COB have a certain number of threads, after that new threads get dropped so after a while it won't be able to use AimWeapon or QueryWeapon anymore.
A signal ends any function that has the matching signal mask set so if you put the loop after the signal stuff each time the AimWeapon is called it will stop the previous call that's caught in the loop.
You're supposed to write
signal SIG_Aim;
set-signal-mask SIG_Aim;
while(!ready) {
sleep 30;
}
or something. Just think how your code will execute, if you always catch the AimWeapon call in a loop it won't stop running until the loop ends. How many AimWeapon calls will be received before the unit gets those extra weapons, 100? 200? Each of these calls will get stuck in the loop and Spring only lets each COB have a certain number of threads, after that new threads get dropped so after a while it won't be able to use AimWeapon or QueryWeapon anymore.
A signal ends any function that has the matching signal mask set so if you put the loop after the signal stuff each time the AimWeapon is called it will stop the previous call that's caught in the loop.