OpenXcom Forum

Modding => OXCE Support => OpenXcom Extended => OXCE Support Y-scripts => Topic started by: bulletdesigner on May 18, 2018, 06:26:13 pm

Title: [Solved] Animated armor
Post by: bulletdesigner 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;
Title: Re: Animated armor
Post by: ohartenstein23 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.
Title: Re: Animated armor
Post by: Yankes 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;
Title: Re: Animated armor
Post by: bulletdesigner 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;
Title: Re: Animated armor
Post by: Yankes 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;
Title: Re: Animated armor
Post by: bulletdesigner 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
Title: Re: Animated armor
Post by: Yankes 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.
Title: Re: Animated armor
Post by: bulletdesigner 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
Title: Re: Animated armor
Post by: Yankes on June 18, 2018, 07:23:41 pm
In what order it should animate? Today I will prepare working example of animation.
Title: Re: Animated armor
Post by: bulletdesigner 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
Title: Re: Animated armor
Post by: Yankes 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
Title: Re: Animated armor
Post by: bulletdesigner 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
Title: Re: Animated armor
Post by: Yankes on June 20, 2018, 03:05:58 am
Could you paste rule for this unit?
Title: Re: Animated armor
Post by: bulletdesigner 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
Title: Re: Animated armor
Post by: Yankes on June 20, 2018, 11:14:09 pm
No problem,

btw what you think about color animation I added? It fit unit?
Title: Re: Animated armor
Post by: bulletdesigner on June 21, 2018, 12:05:18 pm
y, but now i thinking about removing the flies , i guess it needed smaller pixels to work
Title: Re: Animated armor
Post by: Yankes on June 21, 2018, 07:55:25 pm
smaller? Flies are to big? One way I could see reducing they size by making this pixel "transparent" (it will shift shade of pixel making it darker).
Title: Re: Animated armor
Post by: bulletdesigner on June 29, 2018, 07:22:00 pm
men i guess there is some problem with the shadow of animated armor
Title: Re: Animated armor
Post by: Yankes on June 29, 2018, 07:38:34 pm
this is not bug but feature :D
I forget add in pixel recolor script current shade part.
Code: [Select]
      recolorUnitSprite: |
        var int reg0;
        var int reg1;
        var int color;
       
        get_color color new_pixel;
        get_shade reg0 new_pixel;
       
        if or eq color COLOR_X1_PURPLE0 eq color COLOR_X1_PURPLE1;
          set reg1 anim_frame;
          wavegen_tri reg1 8 4 4;
          add reg0 reg1;
          limit_upper reg0 15;
          set_shade new_pixel reg0;
        end;
       
        add_shade new_pixel shade; #add environment shade
        return new_pixel;
you need add second to last line to add shade back.

It work  this way because it allow adding glowing parts to unit.
Some thing like this: https://www.youtube.com/watch?v=_G34PHMiBv0