Author Topic: [Solved] Animated armor  (Read 10443 times)

Offline bulletdesigner

  • Commander
  • *****
  • Posts: 685
    • View Profile
[Solved] Animated armor
« on: May 18, 2018, 06:26:13 pm »
Yankes a while ago posted something about animating armor´s , a script with a image A and B on torso,
does this still works?, i tried it does nothing :P ps: im testing in UFO not TFTD

armors:
  - type: STR_NONE_UC
    spriteSheet: TEST.PCK
    spriteScript: |
      #remember about proper indent! Because of symbol `|` all things that are currently 6 spaces indented will be treated as text
      if eq blit_part BODYPART_TORSO; #do we currently draw torso?
        set r0 anim_frame; #we set to register0 value of current frame (its start from 0 to infinity or more accurate MAX_INT)
        unit.getId r1; #get id of current unit to register1, used to difference animation offset
        add r0 r1; #we add id to animation frame
        div r0 4; #reduce animation speed by dividing
        mod r0 2; #warp it to have only {0, 1} values
        offset r0 8 272; #272 is position of new torsos, this operation change possible values {0, 1} to {272, 280}
        add r0 i1; #we add rotation of body from input1 arg
        ret r0; #we return offset that will be used for `spriteSheet`
      end;
      add i0 i1; #default behavior
      ret i0;
« Last Edit: February 12, 2023, 02:31:56 pm by Meridian »

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: Animated armor
« Reply #1 on: May 18, 2018, 06:31:44 pm »
The syntax and variable names have changed a bit for this particular script; I recently re-wrote it for Nord so he can have breathing animations for unit torsos in his TFTD mod, but I had a test version of it working in UFO - I'll post that with some instructions on how to modifying it once I find it again and make sure it's working.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Animated armor
« Reply #2 on: May 18, 2018, 07:55:18 pm »
The syntax and variable names have changed a bit for this particular script; I recently re-wrote it for Nord so he can have breathing animations for unit torsos in his TFTD mod, but I had a test version of it working in UFO - I'll post that with some instructions on how to modifying it once I find it again and make sure it's working.
Exactly this, this script was before big overhaul.
New version should look like:
Code: [Select]
      var int reg0;
      var int reg1;
      var int reg2;
      var int reg3;
      var int in0 sprite_index; #init `in0` with value from `sprite_index`
      var int in1 sprite_offset;
     
      if eq blit_part BODYPART_TORSO;
        set reg0 anim_frame;
        unit.getId reg1;
        add reg0 reg1;
        div reg0 4;
        mod reg0 2;
        offset reg0 8 270;
        add reg0 in1;
        return reg0;
      end;
      add in0 in1;
      return in0;

Offline bulletdesigner

  • Commander
  • *****
  • Posts: 685
    • View Profile
Re: Animated armor
« Reply #3 on: June 15, 2018, 04:31:19 pm »
so how do i put that new version ? like this?

armors:
  - type: STR_NONE_UC
    spriteSheet: TEST.PCK
    spriteScript: |
      var int reg0;
      var int reg1;
      var int reg2;
      var int reg3;
      var int in0 sprite_index; #init `in0` with value from `sprite_index`
      var int in1 sprite_offset;
     
      if eq blit_part BODYPART_TORSO;
        set reg0 anim_frame;
        unit.getId reg1;
        add reg0 reg1;
        div reg0 4;
        mod reg0 2;
        offset reg0 8 270;
        add reg0 in1;
        return reg0;
      end;
      add in0 in1;
      return in0;

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Animated armor
« Reply #4 on: June 15, 2018, 08:28:29 pm »
No, scripts have its own node, and name of this script  was changed,
something like this:
Code: [Select]
armors:
  - type: PARROT_ARMOR
    scripts: # <- this node
      selectUnitSprite: |
        var int temp;
        var int walking;
        unit.isWalking walking;
        if eq walking 0;
          unit.getId temp;
          offsetmod temp 11 0 8; #desync animation of different units
          add temp anim_frame;
          wavegen_saw temp 8 8 7;
          mul sprite_offset 8;
          add sprite_offset 8;
          add sprite_offset temp;
          set sprite_index sprite_offset;
        else;
          add sprite_index sprite_offset;
        end;
        return sprite_index;

Offline bulletdesigner

  • Commander
  • *****
  • Posts: 685
    • View Profile
Re: Animated armor
« Reply #5 on: June 15, 2018, 10:16:11 pm »
i´m missing something :P, to be honest i´m  doing it by trial , since i can´t understant what i´m doing  i can´t get there hhaha

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Animated armor
« Reply #6 on: June 16, 2018, 04:28:05 pm »
Best if you send small mod example what you currently have, I will check it and fix bugs in it.

Offline bulletdesigner

  • Commander
  • *****
  • Posts: 685
    • View Profile
Re: Animated armor
« Reply #7 on: June 18, 2018, 04:39:59 pm »
so basically i want flies hovering chaos nurgle armors


armors:
  - type: MUTON_ARMORNURGLEA #NURGLE ANIMATED
    spriteSheet: CNURGLEA.PCK
    spriteInv: CNINV
    allowInv: true
    corpseBattle:
      - STR_NURGLES_CORPSE
    frontArmor: 55
    sideArmor: 55
    rearArmor: 55
    underArmor: 45
    drawingRoutine: 10
    damageModifier: #CHAOS ARMOR
      - 1.0 #none
      - 1.0 #AP
      - 0.8 #FLAMES
      - 1.0 #HE
      - 0.8 #LASCANON
      - 1.1 #PLASMA
      - 1.1 #STUN
      - 1.1 #MELEE
      - 1.0 #ACID
      - 0.0 #SMOKE
    loftempsSet: [ 3 ]

extraSprites:
  - type: CNURGLEA.PCK #Chaos Nurgle Animated
    width: 512
    height: 720
    subX: 32
    subY: 40
    files:
      0: Resources/FOES/battlesprite/chaosNA.png


note : i didn´t insert the script since i was doing it wrong

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Animated armor
« Reply #8 on: June 18, 2018, 07:23:41 pm »
In what order it should animate? Today I will prepare working example of animation.

Offline bulletdesigner

  • Commander
  • *****
  • Posts: 685
    • View Profile
Re: Animated armor
« Reply #9 on: June 18, 2018, 09:00:20 pm »
A B A B (etc),  i guess, supposed to emulate fly running around, to be honest i cant be certain it will have the desired effect

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Animated armor
« Reply #10 on: June 19, 2018, 01:19:02 am »
Problem was that offset (270) do not match place where you place animated frames.
I added as attachment working rule that I use for tests. As bonus I added another animation using palette trick (you can disable it removing `recolorUnitSprite`).
This new animation made flesh pulse with heart beat :)

[ps]

Is possible to made flies move in better way, instead of crating multiple frames you draw fly path using one specific color group that is not used anywhere else in this graphic. And in each frame only one shade of this color will be drawn, something like this trick: https://www.youtube.com/watch?v=c-aQvP7CUAI&index=9&list=PLi29TNPrdbwJLiB-VcWSSg-3iNTGJnn_L
« Last Edit: June 19, 2018, 01:23:54 am by Yankes »

Offline bulletdesigner

  • Commander
  • *****
  • Posts: 685
    • View Profile
Re: Animated armor
« Reply #11 on: June 19, 2018, 05:24:49 pm »
 :o still haven´t managed to work, maybe a need the latest OXCE version? i done a clear copy paste, do i need to rebbot pc? i´m a missing something?
Men i sorry i really being a pain in the ass because of small fly´s , so thks for the patient 
i understand the concept of switching colors and palet´s but i´m 0 at script i won´t atempt that even

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Animated armor
« Reply #12 on: June 20, 2018, 03:05:58 am »
Could you paste rule for this unit?

Offline bulletdesigner

  • Commander
  • *****
  • Posts: 685
    • View Profile
Re: Animated armor
« Reply #13 on: June 20, 2018, 12:01:10 pm »
ok just managed to work it, an error in my part , unit was with the wrong armor !  :P
thks for the patient

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Animated armor
« Reply #14 on: June 20, 2018, 11:14:09 pm »
No problem,

btw what you think about color animation I added? It fit unit?