I have changed the script so it doesnt draw nanospray anymore, just one or two particles to make nanos only glow while being used.
Could it make it less laggy if i remove the part which moves at the direction of building? thats pretty useless part anyways, how to remove it properly?
So if anyone of you could point out which parts are useless in this code? just to make it less CPU using, or even less bandwidth using?
Code: Select all
#define TA // This is a TA script
#include "sfxtype.h"
#include "exptype.h"
#define SIG_Build 8
piece base, body, aim, emitnano;
static-var Static_Var_1, Static_Var_2, statechg_DesiredState, statechg_StateChanging;
Activatescr()
{
sleep 1;
}
Deactivatescr()
{
sleep 1;
}
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 aim;
}
sleeptime = healthpercent * 50;
if( sleeptime < 200 )
{
sleeptime = 200;
}
sleep sleeptime;
}
}
Go()
{
call-script Activatescr();
turn aim to y-axis Static_Var_1 speed <160.000000>;
wait-for-turn aim around y-axis;
set INBUILDSTANCE to 1;
}
Stop()
{
set INBUILDSTANCE to 0;
call-script Deactivatescr();
}
InitState()
{
statechg_DesiredState = TRUE;
statechg_StateChanging = FALSE;
}
RequestState(requestedstate, currentstate)
{
if( statechg_StateChanging )
{
statechg_DesiredState = requestedstate;
return (0);
}
statechg_StateChanging = TRUE;
currentstate = statechg_DesiredState;
statechg_DesiredState = requestedstate;
while( statechg_DesiredState != currentstate )
{
if( statechg_DesiredState == 0 )
{
call-script Go();
currentstate = 0;
}
if( statechg_DesiredState == 1 )
{
call-script Stop();
currentstate = 1;
}
}
statechg_StateChanging = FALSE;
}
Create()
{
set ARMORED to 1;
call-script InitState();
start-script SmokeUnit();
Static_Var_1 = 0;
Static_Var_2 = 5000;
sleep 5000;
set ARMORED to 0;
}
RestoreAfterDelay()
{
sleep Static_Var_2;
turn aim to y-axis <0.000000> speed <100.000000>;
wait-for-turn aim around y-axis;
}
Activate()
{
start-script RequestState(0);
}
Deactivate()
{
start-script RequestState(1);
}
QueryWeapon1(piecenum)
{
piecenum=emitnano;
}
AimFromWeapon1(piecenum)
{
piecenum=aim;
}
AimWeapon1(h,p)
{
return 0;
}
StartBuilding(Func_Var_1)
{
Static_Var_1 = Func_Var_1;
start-script RequestState(0);
signal SIG_Build;
set-signal-mask SIG_Build;
set INBUILDSTANCE to 1;
while (1) {
emit-sfx 2048 from emitnano;
sleep 60;
}
}
StopBuilding()
{
start-script RequestState(1);
signal SIG_Build;
set-signal-mask SIG_Build;
set INBUILDSTANCE to 0;
}
QueryNanoPiece(piecenum)
{
piecenum = emitnano;
}
TargetHeading(Func_Var_1)
{
Static_Var_1 = 0 - Func_Var_1;
}
SweetSpot(piecenum)
{
piecenum = aim;
}
Killed(severity, corpsetype)
{
if( severity <= 25 )
{
corpsetype = 1;
explode base type BITMAPONLY | BITMAP1;
explode aim type BITMAPONLY | BITMAP3;
return (0);
}
if( severity <= 50 )
{
corpsetype = 2;
explode base type FALL | BITMAP1;
explode aim type FALL | BITMAP3;
return (0);
}
if( severity <= 99 )
{
corpsetype = 3;
explode base type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode aim type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
return (0);
}
corpsetype = 3;
explode base type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode aim type SHATTER | EXPLODE_ON_HIT | BITMAP3;
}
