aliens

Author Topic: [Solved] Trouble with a new TFTD Weapon Mod  (Read 3949 times)

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
[Solved] Trouble with a new TFTD Weapon Mod
« on: December 21, 2020, 07:55:08 am »
(OXCE: 6.5.5)

Watching Windwalker's TFTD playthrough got me in the mood to create a new weapon for X-Com's Aquanauts.

The mod is almost done, I just need to finish writting the UFOpaedia articles for each of the new entries before releasing it.

However I have run into two problems:
(1) The game crashes when the first research entry required for the new weapon is finished researching.
(2) The wonderful script written by Ohartenstein23 is not displaying HandObs for the new weapon while it has ammo loaded. Oddly it displays FloorObs & BigObs, but not HandObs.
(The script works fine with X-COM: UFO Defense. Have I utilized it incorrectly or is it incompatible with TFTD?)

This is the first time I've tried creating a mod for X-COM: TFTD instead of X-COM: UFO Defense, perhaps there is a difference I am unaware of?

I've been over the code and crawled around the Ruleset Reference Nightly without any luck.

If someone could give the code a fresh set of eyes I'd appreciate it.


Here is a copy of the openxcom.log file's section where all of the [FATAL] messages occured:
Code: [Select]
[21-12-2020_00-24-19] [FATAL] A fatal error has occurred: Sprite BACK10.SCR not found
[21-12-2020_00-24-19] [FATAL] ./OpenXcomEx(OpenXcom::CrossPlatform::stackTrace(void*)+0x36) [0x5602a36cf716]
[21-12-2020_00-24-19] [FATAL] ./OpenXcomEx(OpenXcom::CrossPlatform::crashDump(void*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x477) [0x5602a36d02b7]
[21-12-2020_00-24-19] [FATAL] ./OpenXcomEx(exceptionLogger()+0x75) [0x5602a350db05]
[21-12-2020_00-24-19] [FATAL] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x92ae6) [0x7f142b37fae6]
[21-12-2020_00-24-19] [FATAL] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x92b21) [0x7f142b37fb21]
[21-12-2020_00-24-19] [FATAL] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x92d54) [0x7f142b37fd54]
[21-12-2020_00-24-19] [FATAL] ./OpenXcomEx(OpenXcom::Surface* OpenXcom::Mod::getRule<OpenXcom::Surface>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, OpenXcom::Surface*, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, OpenXcom::Surface*> > > const&, bool) const+0x1a7) [0x5602a394c957]
[21-12-2020_00-24-19] [FATAL] ./OpenXcomEx(OpenXcom::Mod::getSurface(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)+0x76) [0x5602a391d476]
[21-12-2020_00-24-19] [FATAL] ./OpenXcomEx(OpenXcom::ArticleStateText::ArticleStateText(OpenXcom::ArticleDefinitionText*, std::shared_ptr<OpenXcom::ArticleCommonState>)+0x1a2) [0x5602a3bcdc82]
[21-12-2020_00-24-19] [FATAL] ./OpenXcomEx(OpenXcom::Ufopaedia::createArticleState(std::shared_ptr<OpenXcom::ArticleCommonState>)+0x6c5) [0x5602a3c12995]
[21-12-2020_00-24-19] [FATAL] ./OpenXcomEx(OpenXcom::Ufopaedia::openArticle(OpenXcom::Game*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0xd5) [0x5602a3c13175]
[21-12-2020_00-24-19] [FATAL] ./OpenXcomEx(OpenXcom::ResearchCompleteState::btnReportClick(OpenXcom::Action*)+0xe8) [0x5602a383e588]
[21-12-2020_00-24-19] [FATAL] ./OpenXcomEx(OpenXcom::InteractiveSurface::handle(OpenXcom::Action*, OpenXcom::State*)+0x15a) [0x5602a36f38ba]
[21-12-2020_00-24-19] [FATAL] ./OpenXcomEx(OpenXcom::State::handle(OpenXcom::Action*)+0x73) [0x5602a37c38a3]
[21-12-2020_00-24-19] [FATAL] ./OpenXcomEx(OpenXcom::Game::run()+0x2e3) [0x5602a36efaf3]
[21-12-2020_00-24-19] [FATAL] ./OpenXcomEx(main+0x175) [0x5602a34eb795]
[21-12-2020_00-24-19] [FATAL] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7f142a967b97]
[21-12-2020_00-24-19] [FATAL] ./OpenXcomEx(_start+0x2a) [0x5602a34f228a]
[21-12-2020_00-24-23] [FATAL] OpenXcom has crashed: Sprite BACK10.SCR not found
Log file: ./user/openxcom.log
If this error was unexpected, please report it on OpenXcom forum or discord.
The following can help us solve the problem:
1. a saved game from just before the crash (helps 98%)
2. a detailed description how to reproduce the crash (helps 80%)
3. a log file (helps 10%)
4. a screenshot of this error message (helps 5%)

I've attached both the mod and a screenshot of the error message from when it crashed to this post.
Spoiler:
« Last Edit: February 12, 2023, 10:44:44 am by Meridian »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9091
    • View Profile
Re: (OXCE) Trouble with a new TFTD Weapon Mod
« Reply #1 on: December 21, 2020, 09:36:18 am »
sprite BACK10.SCR is missing

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: (OXCE) Trouble with a new TFTD Weapon Mod
« Reply #2 on: December 21, 2020, 10:51:10 am »
I think BACK10.SCR is a X-COM: UFO Defense background, why is it being called while Terror From The Deep is running?

Inside the mod's ufopaedia_HR_TFTD.rul file's ufopaedia: section I tried to give the entry that crashed a different background UP067.BDY (The Zrbite background) but it is still giving me the BACK10.SCR missing error.

Code: [Select]
ufopaedia:
# Zrbite Hydrogen Reaction
  - id: STR_HR_ZRBITE_HYDROGEN_REACTION
    type_id: 8
    section: STR_ALIEN_RESEARCH_UC
    text: STR_HR_ZRBITE_HYDROGEN_REACTION_UFOPAEDIA
    requires:
      - STR_HR_ZRBITE_HYDROGEN_REACTION
    image_id: UP067.BDY

I've tried using Notepad++'s search feature for BACK10.SCR but it does not appear to be in any of the .rul files in the mod, why is that image attempting to be used?

Could I perhaps have left a variable blank and BACK10.SCR is the default value?
« Last Edit: December 21, 2020, 10:59:51 am by The Martian »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9091
    • View Profile
Re: (OXCE) Trouble with a new TFTD Weapon Mod
« Reply #3 on: December 21, 2020, 11:18:40 am »
type_id: 8 is a UFO Defense article type, using UFO Defense background

if you want TFTD backgrounds, use TFTD article types: https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#UFOpaedia_Article

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: (OXCE) Trouble with a new TFTD Weapon Mod
« Reply #4 on: December 21, 2020, 12:39:52 pm »
Thank you Meridian!!!

That got it.

All research entries are now loading without crashing.
Spoiler:


Now all that remains is the mystery of why an Aquanaut equipped with a loaded Hydrogen Rifle appears to be holding nothing.


When unloaded it uses the rifle's own HandOb sprite set without a problem. However once the weapon is loaded the rifle isn't switching from HandOb 136 to 128 for some reason.

I thought it could be that I'd failed to correctly define HandOb: 128, but that does not appear to be the case as if I change STR_HR_HYDROGEN_RIFLE's handSprite: 136 directly to 128 the loaded rifle's sprite set does display. (But only when the weapon is unloaded)

The tags: NEW_HANDOB_FOR_WEAPON: 128 appears to be having a problem. Is there anything about TFTD that would have changed how the HandObs are being rendered vs X-COM: UFO Defense that could effect Ohartenstein23's script?

Code: [Select]
extended:
  tags: # Remember to add these tags to the same file as items ruleset
    RuleItem:
      ALLOW_AMMO_TO_RESPRITE: int
      NEW_BIGOB_FOR_WEAPON: int
      NEW_FLOOROB_FOR_WEAPON: int
      NEW_HANDOB_FOR_WEAPON: int
      CURRENT_MOD_OFFSET: RuleList

  scripts:
    selectItemSprite:
# Select weapon bigSprite based on ammo item
      - offset: 1
        code: |
          var ptr BattleItem ammoItem;
          var ptr RuleItem weaponRuleset;
          var ptr RuleItem ammoRuleset;
          var int doResprite;
          var int newSprite;
          var int modOffset;

          if eq blit_part blit_item_big;
            item.getRuleItem weaponRuleset;
            weaponRuleset.getTag doResprite Tag.ALLOW_AMMO_TO_RESPRITE;

            if eq doResprite 1;
              item.getAmmoItem ammoItem;
              ammoItem.getRuleItem ammoRuleset;
              ammoRuleset.getTag newSprite Tag.NEW_BIGOB_FOR_WEAPON;

              if neq newSprite 0;
                ammoRuleset.getTag sprite_index Tag.NEW_BIGOB_FOR_WEAPON;
                ammoRuleset.getTag modOffset Tag.CURRENT_MOD_OFFSET;
                rules.getSpriteOffsetBigobs sprite_index modOffset;
                return sprite_index;

              end;

            end;

          end;

          return sprite_index;

# Select weapon floorSprite based on ammo item
      - offset: 2
        code: |
          var ptr BattleItem ammoItem;
          var ptr RuleItem weaponRuleset;
          var ptr RuleItem ammoRuleset;
          var int doResprite;
          var int newSprite;
          var int modOffset;

          if eq blit_part blit_item_floor;
            item.getRuleItem weaponRuleset;
            weaponRuleset.getTag doResprite Tag.ALLOW_AMMO_TO_RESPRITE;

            if eq doResprite 1;
              item.getAmmoItem ammoItem;
              ammoItem.getRuleItem ammoRuleset;
              ammoRuleset.getTag newSprite Tag.NEW_FLOOROB_FOR_WEAPON;

              if neq newSprite 0;
                ammoRuleset.getTag sprite_index Tag.NEW_FLOOROB_FOR_WEAPON;
                ammoRuleset.getTag modOffset Tag.CURRENT_MOD_OFFSET;
                rules.getSpriteOffsetFloorob sprite_index modOffset;
                return sprite_index;

              end;

            end;

          end;

          return sprite_index;

# Select weapon handSprite based on ammo item
      - offset: 3
        code: |
          var ptr BattleItem ammoItem;
          var ptr RuleItem weaponRuleset;
          var ptr RuleItem ammoRuleset;
          var int doResprite;
          var int newSprite;
          var int modOffset;

          if or eq blit_part blit_item_lefthand eq blit_part blit_item_righthand;
            item.getRuleItem weaponRuleset;
            weaponRuleset.getTag doResprite Tag.ALLOW_AMMO_TO_RESPRITE;

            if eq doResprite 1;
              item.getAmmoItem ammoItem;
              ammoItem.getRuleItem ammoRuleset;
              ammoRuleset.getTag newSprite Tag.NEW_HANDOB_FOR_WEAPON;

              if neq newSprite 0;
                add newSprite sprite_offset;
                set sprite_index newSprite;

                ammoRuleset.getTag modOffset Tag.CURRENT_MOD_OFFSET;
                rules.getSpriteOffsetBigobs sprite_index modOffset;
                return sprite_index;

              end;

            end;

          end;

          return sprite_index;

I've used this script with several items before in X-COM: UFO Defense and there hasn't been a problem.

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: (OXCE) Trouble with a new TFTD Weapon Mod
« Reply #5 on: December 21, 2020, 01:15:04 pm »
I quickly converted he mod to work with X-COM: UFO Defense.

After launching a "New Battle" from the main menu I can confirm that Ohartenstein23's script is functioning as it is currently coded while running X-COM: UFO Defense.

Depending on if the weapon is loaded or unloaded a different set of HandObs displays.

It is only in TFTD that it can't swap out the HandObs. (Oddly both BigObs and FloorObs swap via the script without a problem.)


(I've attached the converted X-COM: UFO Defense version of the mod to this post for convenience.)
« Last Edit: December 21, 2020, 01:43:59 pm by The Martian »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9091
    • View Profile
Re: (OXCE) Trouble with a new TFTD Weapon Mod
« Reply #6 on: December 21, 2020, 01:49:52 pm »
Try using indices that are not reserved in TFTD.
Why do you even want to override vanilla resources?

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: (OXCE) Trouble with a new TFTD Weapon Mod
« Reply #7 on: December 21, 2020, 02:40:21 pm »
Try using indices that are not reserved in TFTD.
What values for HandObs are not reserved by TFTD?

Why do you even want to override vanilla resources?

The reason why is that I've created images for the BigObs, FloorObs & HandObs of the weapon while loaded and while unloaded.

Ohartenstein23's script allows instantly overriding the values during the battlescape changing the visual appearance of equipment depending on what ammo is currently loaded (Or not loaded) in the weapon.

Take a look at this X-COM: UFO Defense version of the mod with a functioning script in "New Battle" mode to quickly see what I mean.

It's pretty cool:
Spoiler:

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9091
    • View Profile
Re: (OXCE) Trouble with a new TFTD Weapon Mod
« Reply #8 on: December 21, 2020, 02:44:24 pm »
reserved in UFO  0..127
reserved in TFTD 0..439

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: (OXCE) Trouble with a new TFTD Weapon Mod
« Reply #9 on: December 21, 2020, 02:54:27 pm »
That fixed it.

Thank you for the help.
Spoiler:

Why do you even want to override vanilla resources?

I see what you mean now. It was not my intention to overwrite existing HandObs. I made the mistake of assuming that both X-COM: UFO Defense and X-COM: TFTD had the same number of HandObs reserved by the base game's equipment.

« Last Edit: December 21, 2020, 03:02:10 pm by The Martian »