Home   Help Search Login Register  

Author Topic: Recording Script - Unknown Bug  (Read 1082 times)

0 Members and 1 Guest are viewing this topic.

Offline Rommel92

  • Members
  • *
Recording Script - Unknown Bug
« on: 10 Mar 2008, 07:01:16 »
Code: [Select]
private ["_a","_b","_c","_d","_e","_f","_h","_i","_t"];

_a = _this select 0;
_b = _this select 1;
_t = _this select 2;

_i = getPos _a;

_c = 0;

_t = _t * 20;

dir = [];
anim = [];
pos = [];

while {_c < _t} do
{
sleep 0.05;

_i = getPos _a;
_d = getDir _a;
_e = animationState _a;

dir = dir + [_d];
anim = anim + [_e];
pos = pos + [_i];
_c = _c + 1;
};

_c = 0;
_h = _c + 1;

_b setdir (dir select _c);
_b setpos (pos select _c);
_b playmove (anim select _c);

while {_c < _t} do
{
sleep 0.05;
_c = _c + 1;
_h = _c + 1;

_b setdir (dir select _c);

If ((anim select _h) != (anim select _c)) then
{
_b playmove (anim select _h);
}
};

if (true) exitWith {};

Aside from just releasing it cause its quite handy especially if you know how to convert the recordings to copy-able text.
Does anyone know why this works most times, but sometimes the mime just goes completely off?

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Recording Script - Unknown Bug
« Reply #1 on: 10 Mar 2008, 09:04:21 »
Nothing really to do with the problem at hand but why do you have the line if (true) exitWith {}; at the end?
You don't have to exit scripts, they do that automatically when they 'run out'.
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Recording Script - Unknown Bug
« Reply #2 on: 10 Mar 2008, 10:53:38 »
1 - About recording, you may create a dialog with one or more edit controls and set their contents with the contents of your arrays, so the user will be able to copy/paste them.

2 - Fors anims you are using always playMove, Im not sure, but might be some of the recorded anims might be switchMoves in some cases.

3 - You are using setDir to set unit direction. setDir resets vectorUp of units. Not sure how noticeable might be the impact of this. Other option would be to store vectorUp and vectorDir and then play the "movie" with setVectorDir and setVectorUp instead of setDir.

4 - Your script ends when time ends, not when last animation is completed. So you might be starting the re-play code while the unit is still executing its last real animation and the result might be a desync of the first part of the re-play. Between the first while and the second while you may include a Sleep of a pair of seconds, or just wait until there is no "movement" animation present in the unit.

Offline Rommel92

  • Members
  • *
Re: Recording Script - Unknown Bug
« Reply #3 on: 10 Mar 2008, 11:24:08 »
1 - About recording, you may create a dialog with one or more edit controls and set their contents with the contents of your arrays, so the user will be able to copy/paste them.

2 - Fors anims you are using always playMove, Im not sure, but might be some of the recorded anims might be switchMoves in some cases.

3 - You are using setDir to set unit direction. setDir resets vectorUp of units. Not sure how noticeable might be the impact of this. Other option would be to store vectorUp and vectorDir and then play the "movie" with setVectorDir and setVectorUp instead of setDir.

4 - Your script ends when time ends, not when last animation is completed. So you might be starting the re-play code while the unit is still executing its last real animation and the result might be a desync of the first part of the re-play. Between the first while and the second while you may include a Sleep of a pair of seconds, or just wait until there is no "movement" animation present in the unit.

3. Thanks mate, I'll look into setVector, have never seen it before, I figured I'd have to make the dialog to edit the code, just haven't gotten round to it.
It was quite random as I may do a pattern of left right left right on the spot then maybe a walk forward then stop and watch the result, and he'll copy it up to a point then just do the exact opposite. This was fixed slightly when I realised the Ai was trying to interrupt the routine where possible due to it being forced to do something it didn't want to, but it still had one or two random spins/running opposite direction.

4: This area was quite tricky, because at first it was stacking up the playmoves until each animation had finished which created an exact mimic, exept on a much larger scale then normal, so 2m would be 5m for example because it plays out the entire animation. Switchmove didn't prove much better as it would just constantly reset the animation, so I had to find a balance, hence it has the check for if its the same animation don't stack it, but even then it seems to be play animations for too less, so I have to find a median.