ARMVP脚本分析- from fonter456

因为TA-EXCESS II的工厂有点特别,所以这里弄个普通一点的原版ARM T1战车工厂给大家看看

#define TA // This is a TA script
#include “sfxtype.h”
#include “exptype.h”
piece base, pad, beam1, beam2, side1, side2, doo2, door1,
plate2, plate1, nano2, nano1, post1, post2;
static-var spray, unitviewer, statechg_DesiredState, statechg_StateChanging; //定义几个静态变量
// Signal definitions
#define SIG_ACTIVATE 2 //定义信号的ID=2

activatescr()
{
if( TRUE )
{
turn side1 to z-axis <0.000000> now;
turn side1 to z-axis <-89.571429> speed <116.934066>;
turn side2 to z-axis <0.000000> now;
turn side2 to z-axis <89.571429> speed <116.934066>;
sleep 766;
}
if( TRUE )
{
turn doo2 to z-axis <90.021978> speed <210.329670>;
turn door1 to z-axis <-90.467033> speed <211.379121>;
sleep 428;
}
if( TRUE )
{
move doo2 to x-axis [-7.000000] speed [16.355145];
move door1 to x-axis [7.100000] speed [16.588794];
sleep 428;
}
if( TRUE )
{
move plate2 to x-axis [5.850000] speed [13.636371];
move plate1 to x-axis [-6.500006] speed [15.151532];
sleep 429;
}
if( TRUE )
{
turn nano2 to z-axis <-37.357143> speed <86.675824>;
turn nano1 to z-axis <41.857143> speed <97.120879>;
sleep 431;
}
sleep 19;
}
deactivatescr()
{
if( TRUE )
{
move plate2 to x-axis [5.850000] now;
move doo2 to x-axis [-7.000000] now;
move plate1 to x-axis [-6.500006] now;
move door1 to x-axis [7.100000] now;
turn side1 to z-axis <-89.571429> now;
turn side2 to z-axis <89.571429> now;
turn doo2 to z-axis <90.021978> now;
turn nano2 to z-axis <-37.357143> now;
turn nano2 to z-axis <0.000000> speed <89.373626>;
turn door1 to z-axis <-90.467033> now;
turn nano1 to z-axis <41.857143> now;
turn nano1 to z-axis <0.000000> speed <100.142857>;
sleep 418;
}
if( TRUE )
{
move plate2 to x-axis [0.000000] speed [13.732397];
move plate1 to x-axis [0.000000] speed [15.258228];
sleep 426;
}
if( TRUE )
{
move doo2 to x-axis [0.000000] speed [16.355145];
move door1 to x-axis [0.000000] speed [16.588794];
sleep 428;
}
if( TRUE )
{
turn doo2 to z-axis <0.000000> speed <209.351648>;
turn door1 to z-axis <0.000000> speed <210.395604>;
sleep 430;
}
if( TRUE )
{
turn side1 to z-axis <0.000000> speed <122.027473>;
turn side2 to z-axis <0.000000> speed <122.027473>;
sleep 734;
}
sleep 20;
}
//开头的这两段分别是工厂打开和关闭的脚本,反正就是一堆动作,没什么说的。

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;
}
}
OpenYard() //开yard,打开工厂的盖子
{
set YARD_OPEN to 1;
while( !get YARD_OPEN )
{
set BUGGER_OFF to 1;
sleep 1500;
set YARD_OPEN to 1;
}
set BUGGER_OFF to 0;
}
CloseYard() //关yard,合上工厂的盖子
{
set YARD_OPEN to 0;
while( get YARD_OPEN )
{
set BUGGER_OFF to 1;
sleep 1500;
set YARD_OPEN to 0;
}
set BUGGER_OFF to 0;
}
//一般的都是这样把yardmap部分作为子脚本分开放在这里的,TA-excess II的改动比较大,会C语言就是好。

Go()
{
dont-cache doo2;
dont-cache door1;
dont-cache nano1;
dont-cache nano2;
dont-cache pad;
dont-cache plate1;
dont-cache plate2;
dont-cache post1;
dont-cache post2;
dont-cache side1;
dont-cache side2; //这些dont-cache是播放那些贴图动画,例如灯的闪烁
call-script activatescr(); //开始activatescr()脚本
call-script OpenYard(); //开始OpenYard()脚本
set INBUILDSTANCE to 1; //降静态变量INBUILDSTANCE的值设置为1,也就是表明现在是建造状态
}
Stop()
{
set INBUILDSTANCE to 0; //跟上面相反的过程
call-script CloseYard();
call-script deactivatescr();
cache doo2; //阻止那些动画的播放
cache door1;
cache nano1;
cache nano2;
cache pad;
cache plate1;
cache plate2;
cache post1;
cache post2;
cache side1;
cache side2;
}
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(); // 要求状态=0就开始GO()脚本
currentstate = 0; //当前状态=0
}
if( statechg_DesiredState == 1 )
{
call-script Stop(); // 要求状态=1就开始STOP()脚本
currentstate = 1; //当前状态=1
}
}
statechg_StateChanging = FALSE;
}
Create()
{
dont-shade doo2;
dont-shade door1;
dont-shade nano1;
dont-shade nano2;
dont-shade pad;
dont-shade plate1;
dont-shade plate2;
dont-shade post1;
dont-shade post2;
dont-shade side1;
dont-shade side2;
unitviewer = FALSE;
spray = base; //静态变量spray = base部件,作用不明白-_-!!!
call-script InitState();
start-script SmokeUnit();
}
QueryNanoPiece(piecenum) //纳米喷枪,这里是双喷枪
{
if( spray == 0 )
{
piecenum = beam1; //喷枪1是beam1部件
}
if( spray != 0 )
{
piecenum = beam2; //喷枪2是beam2部件
}
spray = !spray;
}
Demo() //单位能否被unitviewer查看,别管这个
{
unitviewer = TRUE;
}
Activate() //活动
{
signal SIG_ACTIVATE;
start-script RequestState(0);
}
Deactivate() //不活动
{
signal SIG_ACTIVATE;
set-signal-mask SIG_ACTIVATE;
if( !unitviewer )
{
sleep 5000; 5000毫秒,不建造的话5秒后就关闭工厂
}
set-signal-mask 0;
start-script RequestState(1);
}
StartBuilding() //开始建造
{
spin pad around y-axis speed <30.005495>; //旋转pad部件,单位在被建造时会跟着转
}
StopBuilding() //停止建造
{
stop-spin pad around y-axis; //停止旋转pad部件
}
QueryBuildInfo(piecenum) //建造托盘
{
piecenum = pad; //托盘是pad部件
}
SweetSpot(piecenum) //焦点
{
piecenum = base; //焦点是base
}
Killed(severity, corpsetype)
{
if( severity <= 25 )
{
corpsetype = 1;
explode base type BITMAPONLY | BITMAP1;
explode doo2 type BITMAPONLY | BITMAP4;
explode door1 type BITMAPONLY | BITMAP5;
explode nano1 type BITMAPONLY | BITMAP1;
explode nano2 type BITMAPONLY | BITMAP2;
explode pad type BITMAPONLY | BITMAP3;
explode plate1 type BITMAPONLY | BITMAP4;
explode plate2 type BITMAPONLY | BITMAP5;
explode post1 type BITMAPONLY | BITMAP1;
explode post2 type BITMAPONLY | BITMAP2;
explode side1 type BITMAPONLY | BITMAP3;
explode side2 type BITMAPONLY | BITMAP4;
return (0);
}
if( severity <= 50 )
{
corpsetype = 2;
explode base type BITMAPONLY | BITMAP1;
explode doo2 type FALL | BITMAP4;
explode door1 type BITMAPONLY | BITMAP5;
explode nano1 type BITMAPONLY | BITMAP1;
explode nano2 type FALL | BITMAP2;
explode pad type BITMAPONLY | BITMAP3;
explode plate1 type SHATTER | BITMAP4;
explode plate2 type BITMAPONLY | BITMAP5;
explode post1 type FALL | BITMAP1;
explode post2 type FALL | BITMAP2;
explode side1 type BITMAPONLY | BITMAP3;
explode side2 type BITMAPONLY | BITMAP4;
return (0);
}
if( severity <= 99 )
{
corpsetype = 3;
explode base type BITMAPONLY | BITMAP1;
explode doo2 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP4;
explode door1 type BITMAPONLY | BITMAP5;
explode nano1 type BITMAPONLY | BITMAP1;
explode nano2 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP2;
explode pad type BITMAPONLY | BITMAP3;
explode plate1 type SHATTER | BITMAP4;
explode plate2 type SHATTER | BITMAP5;
explode post1 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode post2 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP2;
explode side1 type BITMAPONLY | BITMAP3;
explode side2 type BITMAPONLY | BITMAP4;
return (0);
}
corpsetype = 3;
explode base type BITMAPONLY | BITMAP1;
explode doo2 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP4;
explode door1 type BITMAPONLY | BITMAP5;
explode nano1 type BITMAPONLY | BITMAP1;
explode nano2 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP2;
explode pad type BITMAPONLY | BITMAP3;
explode plate1 type SHATTER | EXPLODE_ON_HIT | BITMAP4;
explode plate2 type SHATTER | EXPLODE_ON_HIT | BITMAP5;
explode post1 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP1;
explode post2 type FALL | SMOKE | FIRE | EXPLODE_ON_HIT | BITMAP2;
explode side1 type BITMAPONLY | BITMAP3;
explode side2 type BITMAPONLY | BITMAP4;
}

//需要注意一下的是这个脚本没有调用护甲函数,所以没有护甲系统,你可以自己加,至于在那里加,我不会C语言,不敢莽下结论,需要加的自己研究下其他脚本。
ARMVP.jpg
armvp.rar (3.78 KB)