CoreT1PulseBike脚本分析-from fonter456

//下面TA-EXCESS II alpha1e版的CORE的T1侦查摩托的脚本,估计每个版本的都一样,如果你的版本不一样也可以对照看看
//解析这个脚本的目的是介绍:如何用脚本控制摩托车运动时侧身
#define TA
#include “sfxtype.h”
#include “exptype.h”
piece base, hull, btire, ftire, turret, pitchturret, barrel, flare1, flare2, fire, hubcap1, hubcap2, hubcap3, hubcap4;
static-var DamageNow, LastDamage, UnitHeading;
SmokeUnit(HealthPercent, SleepTime)
{
signal 8;
set-signal-mask 8;
while( get BUILD_PERCENT_LEFT )
{
sleep 500;
}
while( TRUE )
{
HealthPercent = get HEALTH;
if( HealthPercent < 60 )
{
emit-sfx 256 | 1 from ftire;
SleepTime = 300;
}
if( HealthPercent < 30 )
{
emit-sfx 256 | 2 from turret;
SleepTime = 200;
}
sleep SleepTime;
}
}
HitByWeapon(AngleX, AngleZ)
{
DamageNow = get HEALTH;
if( DamageNow <= LastDamage - 10 )
{
signal 128;
set-signal-mask 128;
LastDamage = DamageNow;
turn base to z-axis AngleZ speed <105.000000>;
turn base to x-axis AngleX speed <105.000000>;
wait-for-turn base around z-axis;
wait-for-turn base around x-axis;
turn base to z-axis <0.000000> speed <30.000000>;
turn base to x-axis <0.000000> speed <30.000000>;
return (0);
}
LastDamage = DamageNow;
}
Create()
{
DamageNow = 100;
LastDamage = 100;
dont-cache flare1;
dont-cache flare2;
hide flare1;
hide flare2;

spin flare1 around z-axis speed <200.00>;
spin flare2 around z-axis speed <-210.00>;

start-script SmokeUnit();
}
StartMoving() //开始移动
{
set-signal-mask 4; //设置信号4
spin ftire around x-axis speed <810.000000> accelerate <225.000000>; //前轮加速旋转
spin btire around x-axis speed <810.000000> accelerate <225.000000>; //后轮加速旋转
while( TRUE )
{
UnitHeading = UnitHeading - get XZ_ATAN(7); //运算方向的公式了,不会C语言的照抄,会的可以改得更复杂
turn hull to z-axis 2 * UnitHeading speed <50.00>;//车身侧身,
UnitHeading = get XZ_ATAN(7);
sleep 100;
}
}
//这就是摩托侧身的脚本了,具体原理就是根据7个像素的运动来评估车的方向,从而决定往左侧还是右侧,侧的程度就根据侧身那行来决定,2和speed <50.00>都可以改(越大侧得越厉害),UnitHeading越大,也就是转弯月厉害侧得也自然越大。
StopMoving() //停止移动
{
signal 4; //杀掉信号4
spin ftire around x-axis speed <0.000000> accelerate <-225.000000>; //前轮减速旋转到停止
spin btire around x-axis speed <0.000000> accelerate <-225.000000>; //后轮减速旋转到停止
turn hull to z-axis <0.00> speed <50.00>; //车身回归原位,不侧身了
}
MoveRate1()
{
signal 16;
turn hull to x-axis <0.00> speed <90.00>;
move hull to y-axis [0.00] speed [7.50];
}
MoveRate2()
{
var Random;
Random = Rand( 1, 10 );
if( Random <= 1 )
{
set-signal-mask 16;
turn hull to x-axis <-45.00> speed <90.00>;
move hull to y-axis [3.75] speed [7.50];
sleep 1000;
turn hull to x-axis <0.00> speed <90.00>;
move hull to y-axis [0.00] speed [7.50];
}
}
RestoreAfterDelay()
{
sleep 1000;
turn turret to y-axis <0.000000> speed <240.000000>;
turn pitchturret to x-axis <0.000000> speed <120.000000>;
start-script SmokeUnit();//Smoke script seems to disappear sometimes. This should fix the issue.
}
SweetSpot(PieceNum)
{
PieceNum = turret;
}
QueryPrimary(PieceNum)
{
PieceNum = fire;
}
AimFromPrimary(PieceNum)
{
PieceNum = pitchturret;
}
AimPrimary(Heading, Pitch)
{
signal 2;
set-signal-mask 2;
turn turret to y-axis Heading speed <480.00>;
turn pitchturret to x-axis <0.00> - Pitch speed <240.00>;
wait-for-turn turret around y-axis;
wait-for-turn pitchturret around x-axis;
start-script RestoreAfterDelay();
return (1);
}
FirePrimary()
{
move flare1 to z-axis [0.00] now;
move flare2 to z-axis [0.00] now;

move barrel to z-axis [-0.50] speed [5.00];
move flare1 to z-axis [-0.25] speed [2.50];
move flare2 to z-axis [-0.25] speed [2.50];
show flare1;
show flare2;
sleep 100;
hide flare1;
hide flare2;
move barrel to z-axis [0.00] speed [2.00];
}
Killed(Severity, CorpseType)
{
hide flare1;
hide flare2;
if( Severity <= 50 )
{
CorpseType = 1;
explode btire type BITMAPONLY | BITMAP3;
explode ftire type BITMAPONLY | BITMAP3;
explode hubcap1 type SHATTER | BITMAP5;
explode hubcap2 type SHATTER | BITMAP5;
return (0);
}
CorpseType = 2;
explode btire type BITMAPONLY | BITMAP3;
explode ftire type BITMAPONLY | BITMAP3;
explode hull type SHATTER | BITMAP5;
explode btire type FALL | SMOKE | EXPLODE_ON_HIT | BITMAP1;
explode ftire type FALL | SMOKE | EXPLODE_ON_HIT | BITMAP1;
}
CoreT1PulseBike.rar (3.08 KB)
CoreT1PulseBike.jpg