gtylll 发表于 2016-2-12 14:49:14

趁着3D编辑器刚出做个任务玩玩 脚本遇到了问题

之前很少做任务也涉及到用脚本 用也是用别人的直接套入
难得做一次任务 这次想在任务中通过脚本实现以下几个效果
4个可控单位 语音分别独立
单位每次换弹 播放声效reloading 这类
单位没有任何主武器弹药时播放声效 I'm out
单位投掷手雷播放声效
ACE revive modules放置并开启环境下 单位倒地昏迷 播放声效
ACE环境下用肾上腺素救起其他单位时播放声效

声效定义进description以及单位分别定义名称并带入sqf没什么问题
投掷手雷的也没问题了
ghost addEventHandler ["Fired", {
   if (_this select 2 == "HandGrenadeMuzzle") then {ghost say3D "frag"};
}]
现在不知道其他几个的条件判定一段该如何写
特别是换弹
现在用的一个sqs但是问题很多
if (needReload ghost == 1) then {ghost say3D "reload",reload ghost};
然后定义一个循环时间执行
每次判定单位弹夹空时播放语音并且自动为该单位换弹不开自动换弹吧单位播放音效了却没动作开自动换了作为ARMA又感觉比较恶心
脚本能虽然成功 但是单位没弹夹时就会重复播放语音所以问题很大
所以还是想做成该单位自己手动执行换弹操作时 播放语音

revive开启后单位倒地自己播放声效条件判定自己想了一下大概是这样if(_target getVariable ["ACE_isUnconsious",true] 不知道可不可行 这个暂时没去实验
用肾上腺素救助其他单位的判定更是一头雾水了

脚本小白 希望论坛老鸟帮一下

gtylll 发表于 2016-2-12 15:02:39

为何reload unit作为结果可以执行
如果把这段放在前面一段作为条件,游戏并不会提示脚本错误,但实际用该单位换弹并不会执行后面的结果感觉作为条件有问题

gtylll 发表于 2016-2-12 16:02:31

本帖最后由 gtylll 于 2016-2-12 17:04 编辑

单位弹药为空的判定找到了
? not (someAmmo ghost) : ghost say3D "out";
    if (needReload ghost == 1) then {ghost say3D "reload",reload ghost};
不过怎样做一个循环才合适? 游戏中换弹动作结束前 弹夹判定一直是空

曾经沧海 发表于 2016-2-12 20:24:51

gtylll 发表于 2016-2-12 16:02
单位弹药为空的判定找到了
? not (someAmmo ghost) : ghost say3D "out";
    if (needReload ghost == 1 ...

while(弹药名称 ==0)then{ghost say3d"reload",reload ghost};这个循环判断不知可行否?

gtylll 发表于 2016-2-12 21:30:45

曾经沧海 发表于 2016-2-12 20:24
while(弹药名称 ==0)then{ghost say3d"reload",reload ghost};这个循环判断不知可行否?

条件地方的格式好像就有问题 试了一下直接就提示脚本错误
我的意思是无任何弹夹播放out 有弹夹武器无弹药播放reload
而且不太清楚你这个是想判定当前弹夹还是总弹夹数 那两行分出来都能执行 我不知道该怎么整合起来好
当前弹夹弹药残余如果判定为空 效果和 needReload ghost == 1 一样
身上是否还有弹夹 someAmmo ghost 可以返回布尔值 真就有 假就没

换弹播放声音我现在用的sqs
#loop
if (needReload ghost == 1) then {ghost say3D "reload",reload ghost};
~4
goto "loop"
感觉很低级 而且自动换弹会延时但是不加延时换弹时间少于4秒武器的会重复执行
还是希望知道单位执行换弹作为条件 改怎么写 就可以不用这个了

曾经沧海 发表于 2016-2-12 21:35:50

gtylll 发表于 2016-2-12 21:30
条件地方的格式好像就有问题 试了一下直接就提示脚本错误
我的意思是无任何弹夹播放out 有弹夹武器无弹 ...

哦,忘了在弹药名称前面应该要加COUNT这一单词了

曾经沧海 发表于 2016-2-12 21:36:33

并且要用空格格开啊

gtylll 发表于 2016-2-12 22:10:43

while{someammo ghost} do {
        if (needReload ghost == 1) then {
                ghost say3D "reload";
                reload ghost;
                sleep 4;
        };
};
有弹药时会持续执行判定没有换弹的延迟但是我不知道这种会不会造成任务卡顿

曾经沧海 发表于 2016-2-12 22:36:13

gtylll 发表于 2016-2-12 22:10
while{someammo ghost} do {
        if (needReload ghost == 1) then {
                ghost say3D "reload";


那我想问一句你这个不是写在脚本里的吗?难道是输入在编辑器里原某一栏里?加Q私聊吧498701682

啤酒冲米二 发表于 2016-2-13 00:11:53

本帖最后由 啤酒冲米二 于 2016-2-13 00:31 编辑

显示并复制玩家当前动作代码
hintSilent str (animationState player);
copyToClipBoard format ["%1",animationState player];

////////////////////////这是一个循环///////////////////////////////
Reload_moves = ["换弹夹动作码1", "换弹夹动作码2"...n个更多代码];//区分大小写
fn_needReload = {
    waitUntil {animationState _this in Reload_moves || {!alive _this}};
               if(!alive _this)exitWith {};
        ghost say3D "reload";
        waitUntil {!(animationState _this in Reload_moves) ||{!alive _this}};
            if(alive _this)then {_then call fn_needReload};
};
_unit call fn_needReload;//继续重新判断除非该单位死亡
/////////////////////////////////////////////////////////////////////

gtylll 发表于 2016-2-13 00:47:05

现在发现了问题
单位有备弹 弹夹为空时 needReload ghost == 1
没备弹 弹夹也为空时 needReload ghost 不等于1
while {needReload player == 1} 作为条件不能顺利执行虽然脚本不会报错 if就OK 但是没有循环

gtylll 发表于 2016-2-13 12:32:03

啤酒冲米二 发表于 2016-2-13 00:11
显示并复制玩家当前动作代码
hintSilent str (animationState player);
copyToClipBoard format ["%1",an ...

前两行读动作的无法读出换弹的动作换弹动作好像定义成的是手势一类
然后我从MX步枪的CFG里找到了reloadAction = "GestureReloadMX";
把后面的动作名称放到你下面的参数里运行依然没有效果 不知道是哪里出的问题

啤酒冲米二 发表于 2016-2-13 13:10:16

gtylll 发表于 2016-2-13 12:32
前两行读动作的无法读出换弹的动作换弹动作好像定义成的是手势一类
然后我从MX步枪的CFG里找到了reloa ...

换弹夹时动作码确实没变用你说的条件判断吧

fn_needReload = {
    waitUntil {needReload _this == 1 || {!alive _this}};
    if(!alive _this)exitWith {};
        reload _this;//为了同步还是强制单位换弹吧,满弹不动作
    ghost say3D "reload"; hint "换弹音效";//
    waitUntil {needReload _this == 0 || {!alive _this}};
    if(alive _this)then {_this call fn_needReload};//继续重新判断除非该单位死亡
};
_unit call fn_needReload;

啤酒冲米二 发表于 2016-2-13 18:27:58

{!alive _this}改成ACE倒地时的相关变量就行,播放不同的声效看下面的套用
fn_needReload = {
_unit = _this select 0;
_sound = _this select 1;
   waitUntil {needReload _this == 1 || {!alive _this}};
.........

[单位,音效] call fn_needReload;

gtylll 发表于 2016-2-14 00:02:40

果然垃圾脚本严重影响性能
换弹和扔雷各1个 3单位分别单独加载 一共6个直接卡的我任务都进不去了
ghost addEventHandler ["Fired", {
   if (_this select 2 == "HandGrenadeMuzzle") then {ghost say3D "frag"};
}]
扔雷判定是找的安全区禁止使用武器脚本抠出来的

while{someammo ghost} do {
        if (needReload ghost == 1) then {
                ghost say3D "reload";
                reload ghost;
                sleep 5;
        };
}

果然还是要多测试
页: [1] 2
查看完整版本: 趁着3D编辑器刚出做个任务玩玩 脚本遇到了问题