Author Topic: [DONE][SUGGESTION] flySound - only when unit is flying  (Read 6903 times)

Offline Wolfstarr

  • Colonel
  • ****
  • Posts: 248
    • View Profile
[DONE][SUGGESTION] flySound - only when unit is flying
« on: December 16, 2018, 05:49:08 am »
Would love to be able to config different flying sounds for units depending on whether they are flying or walking :)
« Last Edit: February 01, 2023, 11:39:04 am by Meridian »

Offline Wolfstarr

  • Colonel
  • ****
  • Posts: 248
    • View Profile
Re: [SUGGESTION] flySound - only when unit is flying
« Reply #1 on: December 21, 2018, 12:01:00 pm »
Could this be done with a script? Any for any other state (kneeling, standing, etc)? Have many ideas how could be used for!

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9099
    • View Profile
Re: [SUGGESTION] flySound - only when unit is flying
« Reply #2 on: December 21, 2018, 01:21:53 pm »
Everything can be done via a script.
Same way as everything can be done by implementing it without a script.

But someone first has to implement such feature to be doable via scripts... scripts can ONLY do what we teach them to do... it's not magic, it's hard work!

Please, pretty please, everybody on this forum... stop thinking of scripts as a messiah, a silver bullet, or any kind of can-do-anything-I-want-thing... it's NOT and will never be.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: [SUGGESTION] flySound - only when unit is flying
« Reply #3 on: December 21, 2018, 02:32:43 pm »
Everything can be done via a script.
Same way as everything can be done by implementing it without a script.

But someone first has to implement such feature to be doable via scripts... scripts can ONLY do what we teach them to do... it's not magic, it's hard work!

Please, pretty please, everybody on this forum... stop thinking of scripts as a messiah, a silver bullet, or any kind of can-do-anything-I-want-thing... it's NOT and will never be.
+100,
only difference between code and scripts is that to add something in code it need have enough quality to be accepted by: Me, Meridian, SupSuper or Warboy1982. And for scripts there is no limitation like that, as long script hook was added.
Overall complexity is same (with caveat that script need lot more work up front). This mean if you can write something in scripts you could write it code too.

I thinking about adding script for this, reason is because strife and run use normal move sound, probably some modders would like change this too.

Offline Wolfstarr

  • Colonel
  • ****
  • Posts: 248
    • View Profile
Re: [SUGGESTION] flySound - only when unit is flying
« Reply #4 on: December 21, 2018, 03:31:33 pm »
Thanks Both :)

I would get more involved with the coding aspect if new where to start ... not alien to coding as per say just only have knowledge of java and vb anything else might as well be martian ... or cydonian lol

Offline luke83

  • Commander
  • *****
  • Posts: 1559
    • View Profile
    • openxcommods
Re: [SUGGESTION] flySound - only when unit is flying
« Reply #5 on: December 28, 2018, 01:14:14 am »
Sorry for dumb question, are these scripts written directly into.
 . Rul files in Yaml? I have tried learning programming several  times over the years but usually loose intetest and give up, perhaps if it was for my OXC i would stay focused.

I am camping now with very bad reception so am stuck just reading forum posts for now, i honestly wish i was at home tweaking my mod but my family is having fun.
« Last Edit: December 28, 2018, 04:39:38 pm by luke83 »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: [SUGGESTION] flySound - only when unit is flying
« Reply #6 on: December 28, 2018, 08:40:35 pm »
Sorry for dumb question, are these scripts written directly into.
 . Rul files in Yaml? I have tried learning programming several  times over the years but usually loose intetest and give up, perhaps if it was for my OXC i would stay focused.

I am camping now with very bad reception so am stuck just reading forum posts for now, i honestly wish i was at home tweaking my mod but my family is having fun.
Yes, script is simply string that is transformed to new form that can be run by engine.

Something like:
Code: [Select]
extended:
  tags:
    RuleItem:
      OVERCHARGE_WEAPON: int
     
  scripts:
    hitUnit:
      - offset: 1
        code: |
          var int temp;
          var int primed;
          var ptr RuleItem rule;
          damaging_item.getRuleItem rule;
          damaging_item.getFuseTimer primed;
          rule.getTag temp Tag.OVERCHARGE_WEAPON;
          if and gt temp 0 gt primed 0;
            unit.reduceByResistance temp 4; #4 - laser damage type
            add power temp;
          end;
          return power part side; #part - body part, side - armor side
items:
  - type: STR_LASER_RIFLE
    fuseType: 3
    isExplodingInHands: true
    isConsumable: true #when primed is not recoverable anymore
    primeActionName: STR_LASER_RIFLE_OVERCHARGE
    primeActionMessage: STR_LASER_RIFLE_OVERCHARGE_MESSAGE
    tags:
      OVERCHARGE_WEAPON: 50
    scripts:
      recolorItemSprite: |
        var int color;
        var int temp;
        get_color color new_pixel;
        if eq color 2;
          item.getFuseTimer temp;
          if gt temp 0;
            set temp anim_frame;
            wavegen_tri temp 16 16 15;
            mul temp -1;
            add temp 8;
            add_shade new_pixel temp;
          else;
            set_shade new_pixel 15;
          end;
        end;
        return new_pixel;

extraStrings:
  - type: en-US
    strings:
      STR_LASER_RIFLE_OVERCHARGE: "Overcharge"
      STR_LASER_RIFLE_OVERCHARGE_MESSAGE: "Rifle is Overcharged"
   
This is laser rifle that can be overcharged, it use script that will be run each time unit get hit and then add bonus damage if you overcharge weapon.
With scripts there are custom properties (tags) that can you add and they will be available in scripts.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: [SUGGESTION] flySound - only when unit is flying
« Reply #7 on: January 27, 2019, 06:23:27 pm »
I added new script that allow altering sound of movements. You can now change sound of flaying unit.

Offline Wolfstarr

  • Colonel
  • ****
  • Posts: 248
    • View Profile
Re: [SUGGESTION] flySound - only when unit is flying
« Reply #8 on: January 27, 2019, 11:41:17 pm »
Nice work Yankes, is it something custom I need to put in the ruleset or something added to latest build of OXCE?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9099
    • View Profile
Re: [SUGGESTION] flySound - only when unit is flying
« Reply #9 on: January 27, 2019, 11:58:59 pm »
Nice work Yankes, is it something custom I need to put in the ruleset or something added to latest build of OXCE?

It's a OXCE script, in the armor ruleset, just like you asked for.

Offline Wolfstarr

  • Colonel
  • ****
  • Posts: 248
    • View Profile
Re: [SUGGESTION] flySound - only when unit is flying
« Reply #10 on: January 28, 2019, 12:23:09 am »
Sorry Meridian, had a cerebral weekend so brain cells are lacking ... where is the actual script code to insert into the ruleset?
« Last Edit: January 28, 2019, 12:27:29 am by SideQuests »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: [SUGGESTION] flySound - only when unit is flying
« Reply #11 on: January 28, 2019, 02:07:40 am »
You can look for old readme in https://openxcom.org/forum/index.php/topic,2915.0.html
There are some basic of script usage.

Example of global script for this is:
Code: [Select]
extended:
  scripts:
    selectMoveSoundUnit:
      - offset: 5
        code: |
          if ge sound_index 0;
            set sound_index 14;
          end;
          return sound_index;
This will globally change all move sounds to sound 14.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: [SUGGESTION] flySound - only when unit is flying
« Reply #12 on: February 02, 2019, 01:45:35 am »
Small update, I added info if unit is strafing or running:

Code: [Select]

    selectMoveSoundUnit:
      - offset: 5
        code: |
          var int temp;
          if ge sound_index 0;
            set sound_index walking_phase; #some random noises based on walking_phase, usually 0 - start, 7- end (diagonal move make two full cycles)
            set temp move; #type of move like `move_normal` equal 0, `move_run` equal 1 or `move_strafe` equal 2
            mul temp 5;
            add sound_index temp;
          end;
          return sound_index;