CORTSHIP(OTA CORE运输船)脚本分析- from fonter456

//这是原版core的运输船的脚本,这里只解析运输的原理

#define TA // This is a TA script

#include “sfxtype.h”
#include “exptype.h”

piece base, turret, boom, arm1, arm2, link, door1, door2,
door3, wake1, wake2, magnet, arm3, arm4;

static-var Static_Var_1, Static_Var_2, Static_Var_3, Static_Var_4;

// Signal definitions
#define SIG_MOVE 2

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()
{
start-script SmokeUnit();
}

StartMoving()
{
signal SIG_MOVE;
set-signal-mask SIG_MOVE;
while( TRUE )
{
emit-sfx 2 from wake1;
emit-sfx 2 from wake2;
sleep 300;
}
}

StopMoving()
{
signal SIG_MOVE;
}

SweetSpot(piecenum)
{
piecenum = base;
}

StartDoorOpen() //打开运输舱门
{
signal 4;
set-signal-mask 4;
move door1 to z-axis [-6.000000] speed [10.000000]; //下面3句是开门
move door2 to z-axis [-6.000000] speed [10.000000];
move door3 to z-axis [-6.000000] speed [10.000000];
sleep 5000; //延迟5秒
move door1 to z-axis [0.000000] speed [10.000000]; //下面3句是关门
move door2 to z-axis [0.000000] speed [10.000000];
move door3 to z-axis [0.000000] speed [10.000000];
}

BoomCalc(posxz, posy) //下面这段是三角函数运算
{
var Func_Var_3, Func_Var_4, Func_Var_5;
Func_Var_3 = get PIECE_XZ(turret) - posxz;
Func_Var_4 = posy - get PIECE_Y(turret) - [20.000000]; //这个20具体怎么来的不明
Func_Var_5 = get XZ_HYPOT(Func_Var_3);
Static_Var_1 = get HYPOT(Func_Var_5,Func_Var_4) - [20.000000];
Static_Var_2 = get XZ_ATAN(Func_Var_3);
Static_Var_3 = get ATAN(Func_Var_4,Func_Var_5);
Static_Var_4 = Static_Var_1 < [105.000000]; //这个105是运输臂的去吊单位时的最大长度,105是105像素的长度
}

//这段其实是用来计算吊臂要伸多长的,单位距离越远,就伸越长,要注意最大长度不要乱设,会引起出错

BoomExtend(posxz, posy) //这段就是伸吊臂
{
start-script StartDoorOpen(); //要开舱门
turn turret to y-axis Static_Var_2 speed <50.010989>;
turn magnet to x-axis Static_Var_3 speed <30.005495>;
turn boom to x-axis <0.000000> - Static_Var_3 speed <30.005495>; //
move arm1 to z-axis Static_Var_1 / [0.000024] speed [30.000000]; //伸臂
move arm2 to z-axis Static_Var_1 / [0.000024] speed [30.000000];
move arm3 to z-axis Static_Var_1 / [0.000024] speed [30.000000];
move arm4 to z-axis Static_Var_1 / [0.000024] speed [30.000000]; //这条臂是4节伸缩臂
wait-for-turn turret around y-axis;
wait-for-turn boom around x-axis;
wait-for-move arm1 along z-axis;
wait-for-move arm2 along z-axis;
wait-for-move arm3 along z-axis;
wait-for-move arm4 along z-axis;
}

BoomReset() //这段是吊臂返回原位
{
turn turret to y-axis <0.000000> speed <40.005495>;
turn magnet to x-axis <0.000000> speed <30.005495>;
turn boom to x-axis <0.000000> speed <30.005495>;
move arm1 to z-axis [0.000000] speed [25.000000];
move arm2 to z-axis [0.000000] speed [25.000000];
move arm2 to z-axis [0.000000] speed [25.000000];
move arm3 to z-axis [0.000000] speed [25.000000];
}

BoomToPad()
{
start-script StartDoorOpen();
turn turret to y-axis <0.000000> speed <40.005495>;
turn magnet to x-axis <0.000000> speed <30.005495>;
turn boom to x-axis <0.000000> speed <30.005495>;
move arm1 to z-axis [0.000000] speed [30.000000];
move arm2 to z-axis [0.000000] speed [30.000000];
move arm3 to z-axis [0.000000] speed [30.000000];
move arm4 to z-axis [0.000000] speed [30.000000];
wait-for-turn turret around y-axis;
wait-for-turn boom around x-axis;
wait-for-move arm1 along z-axis;
wait-for-move arm2 along z-axis;
wait-for-move arm3 along z-axis;
wait-for-move arm4 along z-axis;
turn magnet to x-axis <-30.005495> speed <30.005495>;
turn boom to x-axis <30.005495> speed <30.005495>;
wait-for-turn boom around x-axis;
}

TransportPickup(unitid) //抓起单位
{
call-script BoomCalc(get UNIT_XZ(unitid),get UNIT_Y(unitid) + get UNIT_HEIGHT(unitid));
if( Static_Var_4 )
{
set BUSY to 1;
call-script BoomExtend();
move link to y-axis [0.000000] - get UNIT_HEIGHT(unitid) now;
attach-unit unitid to link;
call-script BoomToPad();
attach-unit unitid to 0 - 1;
call-script BoomReset();
set BUSY to 0;
}
}

TransportDrop(unitid, position)
{
call-script BoomCalc(position,get GROUND_HEIGHT(position) + get UNIT_HEIGHT(unitid));
if( Static_Var_4 )
{
set BUSY to 1;
call-script BoomToPad();
move link to y-axis [0.000000] - get UNIT_HEIGHT(unitid) now;
attach-unit unitid to link;
call-script BoomExtend();
drop-unit unitid;
call-script BoomReset();
set BUSY to 0;
}
}

Killed(severity, corpsetype)
{
if( severity <= 25 )
{
corpsetype = 1;
explode boom type BITMAPONLY | BITMAP1;
explode arm1 type BITMAPONLY | BITMAP2;
explode arm2 type BITMAPONLY | BITMAP5;
explode base type BITMAPONLY | BITMAP3;
explode door1 type BITMAPONLY | BITMAP4;
explode door2 type BITMAPONLY | BITMAP5;
explode link type BITMAPONLY | BITMAP1;
explode turret type BITMAPONLY | BITMAP2;
explode wake1 type BITMAPONLY | BITMAP3;
explode wake2 type BITMAPONLY | BITMAP4;
return (0);
}
if( severity <= 50 )
{
corpsetype = 2;
explode boom type BITMAPONLY | BITMAP1;
explode arm1 type SHATTER | BITMAP2;
explode arm2 type SHATTER | BITMAP4;
explode base type BITMAPONLY | BITMAP3;
explode door1 type BITMAPONLY | BITMAP4;
explode door2 type BITMAPONLY | BITMAP5;
explode link type FALL | BITMAP1;
explode turret type BITMAPONLY | BITMAP2;
explode wake1 type FALL | BITMAP3;
explode wake2 type FALL | BITMAP4;
return (0);
}
if( severity <= 99 )
{
corpsetype = 3;
explode boom type BITMAPONLY | BITMAP1;
explode arm1 type SHATTER | BITMAP2;
explode arm2 type SHATTER | BITMAP4;
explode base type BITMAPONLY | BITMAP3;
explode door1 type BITMAPONLY | BITMAP4;
explode door2 type BITMAPONLY | BITMAP5;
explode link type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode turret type BITMAPONLY | BITMAP2;
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 boom type BITMAPONLY | BITMAP1;
explode arm1 type SHATTER | EXPLODE_ON_HIT | BITMAP2;
explode arm2 type SHATTER | BITMAP4;
explode base type BITMAPONLY | BITMAP3;
explode door1 type BITMAPONLY | BITMAP4;
explode door2 type BITMAPONLY | BITMAP5;
explode link type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode turret type BITMAPONLY | BITMAP2;
explode wake1 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP3;
explode wake2 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP4;
}

总结:运输船的脚本比较麻烦,建议照抄,只有吊臂长度可以改改,不过不要改得太长,否则会出错,应该是跟那堆三角函数的有关,懂这方面的可以研究怎么改得更长。