Author Topic: Need help with soldier transformation into playable aliens.  (Read 3173 times)

Offline Avarlia

  • Squaddie
  • *
  • Posts: 3
    • View Profile
Need help with soldier transformation into playable aliens.
« on: August 19, 2019, 01:22:29 am »
Hi there!

Dug up X-Com: UFO defense yesterday and thought: Why not add aliens to your team. Maybe renegade aliens?

This turned into, "why not transforming Soldiers into Alien Soldiers?" (Which seemed easier at first glance)

I've looked into this: https://openxcom.org/forum/index.php/topic,6331.0.html

And came up with this:

Code: [Select]
soldierTransformation:
  - name: STR_Create_Alien
    listOrder: 1
    producedSoldierType: STR_REPTOID
    producedSoldierArmor: REPTOID_ARMOR0
    keepSoldierArmor: false
    createsClone: false
    needsCorpseRecovered: false
    allowsDeadSoldiers: true
    allowsLiveSoldiers: true
    allowsWoundedSoldiers: true  # adding these guys too, if we want to sack them
    allowedSoldierTypes:
      - STR_SOLDIER
    forbiddenPreviousTransformations:
      - STR_Create_Alien
    requiredMinStats: # The minimum stats a soldier must have in order to be eligible for this project, defaults to all 0 so any soldier is eligible
      tu: 0
      stamina: 0
      health: 0
      bravery: 0
      reactions: 0
      firing: 0
      throwing: 0
      strength: 0
      psiStrength: 0
      psiSkill: 0
      melee: 0
    requiredItems: # A list of items that must be consumed from the base's stores in which you start this project, the default empty list means no items are used
      #STR_REPTOID_CORPSE
    cost: 50000 # The cost of the project in dollars
    transferTime: 0 # Soldiers can be put in a transfer back to the base where they started if this parameter is greater than the default of 0 hours. New clones or resurrected soldiers are automatically given a transfer to the base with a default of 24 hours.
    recoveryTime: 0 # The amount of wound recovery time a soldier is given after this project completes and the transfer, if any, is completed. The default value is 0 days.
    flatOverallStatChange: # A direct change to the soldier's overall stats when undergoing this project, can be positive or negative - tu: 5 means the soldier will gain 5 max time units, while tu: -5 means the soldier will lose 5 max time units. The default of 0 means no change.
      tu: 0
      stamina: 0
      health: 0
      bravery: 0
      reactions: 0
      firing: 0
      throwing: 0
      strength: 0
      psiStrength: 0
      psiSkill: 0
      melee: 0
    percentOverallStatChange: # A percent change to the soldier's overall stats when undergoing this project, can be positive or negative - tu: 5 means the soldier will gain an extra 5% of their max time units, while tu: -5 means the soldier will lose 5% of their max time units. The default of 0 means no change.
      tu: 0
      stamina: 0
      health: 0
      bravery: 0
      reactions: 0
      firing: 0
      throwing: 0
      strength: 0
      psiStrength: 0
      psiSkill: 0
      melee: 0
    percentGainedStatChange: # A percent change to the soldier's stats, but instead of taking a portion of the overall stats, this only applies to the stats they've trained up from their initial values, can be positive or negative - firing: -100 means the soldier will lose all of the firing accuracy they trained since joining, while firing: 10 means they gain 10% of the amount they trained over their initial values. The default of 0 means no change.
      tu: 0
      stamina: 0
      health: 0
      bravery: 0
      reactions: 0
      firing: 0
      throwing: 0
      strength: 0
      psiStrength: 0
      psiSkill: 0
      melee: 0
    useRandomStats: false
    lowerBoundAtMinStats: true
    upperBoundAtMaxStats: false
    upperBoundAtStatCaps: true
extraStrings:
  - type: en-US
    strings:
      STR_Create_Alien: "Create Alien"

I hoped it would be easy (again) and that this (above) would work, of course it didn't work...

Code: [Select]
[18-08-2019_23-47-02] [FATAL] A fatal error has occurred: Segmentation fault.
[18-08-2019_23-47-03] [FATAL] 0x585c30 OpenXcom::CrossPlatform::stackTrace(void*)
[18-08-2019_23-47-03] [FATAL] 0x586fb0 OpenXcom::CrossPlatform::crashDump(void*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
[18-08-2019_23-47-03] [FATAL] 0x41c850 signalLogger(int)
[18-08-2019_23-47-03] [FATAL] 0x9192b0 OpenXcom::UfopaediaStartState::think()
[18-08-2019_23-47-03] [FATAL] 0x7ff94990c5e0 _C_specific_handler
[18-08-2019_23-47-03] [FATAL] 0x7ff949921080 _chkstk
[18-08-2019_23-47-03] [FATAL] 0x7ff9498e9e90 RtlRaiseException
[18-08-2019_23-47-03] [FATAL] 0x7ff94991fde0 KiUserExceptionDispatcher
[18-08-2019_23-47-03] [FATAL] 0x7ae840 OpenXcom::RuleSoldier::getMinStats() const
[18-08-2019_23-47-03] [FATAL] 0x89d060 OpenXcom::Soldier::calculateStatChanges(OpenXcom::Mod const*, OpenXcom::RuleSoldierTransformation*, OpenXcom::Soldier*)
[18-08-2019_23-47-03] [FATAL] 0x4a4c70 OpenXcom::SoldierTransformationState::initTransformationData()
[18-08-2019_23-47-03] [FATAL] 0x4a7ad0 OpenXcom::SoldierTransformationState::SoldierTransformationState(OpenXcom::RuleSoldierTransformation*, OpenXcom::Base*, OpenXcom::Soldier*, std::vector<OpenXcom::Soldier*, std::allocator<OpenXcom::Soldier*> >*)
[18-08-2019_23-47-03] [FATAL] 0x49f830 OpenXcom::SoldiersState::lstSoldiersClick(OpenXcom::Action*)
[18-08-2019_23-47-03] [FATAL] 0x6d5c00 OpenXcom::TextList::mouseClick(OpenXcom::Action*, OpenXcom::State*)
[18-08-2019_23-47-03] [FATAL] 0x5a18a0 OpenXcom::InteractiveSurface::handle(OpenXcom::Action*, OpenXcom::State*)
[18-08-2019_23-47-03] [FATAL] 0x6d5900 OpenXcom::TextList::handle(OpenXcom::Action*, OpenXcom::State*)
[18-08-2019_23-47-03] [FATAL] 0x657c90 OpenXcom::State::handle(OpenXcom::Action*)
[18-08-2019_23-47-03] [FATAL] 0x59ee70 OpenXcom::Game::run()
[18-08-2019_23-47-03] [FATAL] 0x41c8c0 SDL_main
[18-08-2019_23-47-03] [FATAL] 0x91adc0 console_main
[18-08-2019_23-47-03] [FATAL] 0x91aee0 WinMain
[18-08-2019_23-47-03] [FATAL] ??
[18-08-2019_23-47-03] [FATAL] ??
[18-08-2019_23-47-03] [FATAL] 0x7ff947e47bc0 BaseThreadInitThunk
[18-08-2019_23-47-03] [FATAL] 0x7ff9498ece50 RtlUserThreadStart
[18-08-2019_23-47-05] [FATAL] OpenXcom has crashed: Segmentation fault.

So, I'm not really sure what to do and appreciate any help/hints

I did look for similar threads, but didn't find anything satisfying...

Thank you!

Side node: If recruiting playable aliens is easier than transforming soldiers into aliens, I will take that too. Seriously thou I have no idea where even to start with this error.
« Last Edit: August 19, 2019, 01:28:44 am by Avarlia »

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: Need help with soldier transformation into playable aliens.
« Reply #1 on: August 19, 2019, 05:19:01 pm »
Segfault errors usually mean that you're either missing something that should've been defined or have a typo that means you're referencing something that isn't defined. From the stack trace, it shows we error looking for the minStats of a soldier type ruleset - have you defined your STR_REPTOID soldier type in a soldiers ruleset? You can't transform a soldier from one type to another that doesn't exist. Try starting by making a copy of STR_SOLDIER and renaming it STR_REPTOID and seeing if that fixes this specific crash.

Your transformations ruleset looks good, but you should comment out the "requiredItems:" line if you're going to comment out everything it contains. Leaving an empty key like that will make a YAML error. You can also write it as "requiredItems: []" instead.

If you just want to hire alien soldiers, you just need the entry in the soldiers ruleset and either give them a hiring cost or use a manufacturing project to turn captured live aliens into a soldier of that type. Both the Piratez and 40k mods have examples of multiple soldier types and manufacturing them if you want to see some ways that this is done.

Offline Avarlia

  • Squaddie
  • *
  • Posts: 3
    • View Profile
Re: Need help with soldier transformation into playable aliens.
« Reply #2 on: August 19, 2019, 11:04:07 pm »
Segfault errors usually mean that you're either missing something that should've been defined or have a typo that means you're referencing something that isn't defined. From the stack trace, it shows we error looking for the minStats of a soldier type ruleset - have you defined your STR_REPTOID soldier type in a soldiers ruleset? You can't transform a soldier from one type to another that doesn't exist. Try starting by making a copy of STR_SOLDIER and renaming it STR_REPTOID and seeing if that fixes this specific crash.

Your transformations ruleset looks good, but you should comment out the "requiredItems:" line if you're going to comment out everything it contains. Leaving an empty key like that will make a YAML error. You can also write it as "requiredItems: []" instead.

If you just want to hire alien soldiers, you just need the entry in the soldiers ruleset and either give them a hiring cost or use a manufacturing project to turn captured live aliens into a soldier of that type. Both the Piratez and 40k mods have examples of multiple soldier types and manufacturing them if you want to see some ways that this is done.

Managed to do that, tinkered a bit, sadly, got another error. I also took a look that these mods you've mentioned. First things first, the error I encountered:

Code: [Select]
[19-08-2019_21-53-14] [INFO] Scanning user mods in 'D:/Program Files (x86)/SteamApps/common/XCom UFO Defense/OpenXcom - Copy - Copy/user/'...
[19-08-2019_21-53-50] [FATAL] A fatal error has occurred: Sprite inventory_REPTOID.SPK not found
[19-08-2019_21-53-50] [FATAL] 0x585c30 OpenXcom::CrossPlatform::stackTrace(void*)
[19-08-2019_21-53-50] [FATAL] 0x586fb0 OpenXcom::CrossPlatform::crashDump(void*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
[19-08-2019_21-53-50] [FATAL] 0x41c780 exceptionLogger()
[19-08-2019_21-53-50] [FATAL] 0xaff950 MPEGaction::MPEGaction()
[19-08-2019_21-53-50] [FATAL] 0xcb9060 void std::iter_swap<__gnu_cxx::__normal_iterator<OpenXcom::ScriptProcData*, std::vector<OpenXcom::ScriptProcData, std::allocator<OpenXcom::ScriptProcData> > >, __gnu_cxx::__normal_iterator<OpenXcom::ScriptProcData*, std::vector<OpenXcom::ScriptProcData, std::allocator<OpenXcom::ScriptProcData> > > >(__gnu_cxx::__normal_iterator<OpenXcom::ScriptProcData*, std::vector<OpenXcom::ScriptProcData, std::allocator<OpenXcom::ScriptProcData> > >, __gnu_cxx::__normal_iterator<OpenXcom::ScriptProcData*, std::vector<OpenXcom::ScriptProcData, std::allocator<OpenXcom::ScriptProcData> > >)
[19-08-2019_21-53-50] [FATAL] 0xcbdf60 OpenXcom::ScriptGlobal::addTagType<OpenXcom::ScriptTag<OpenXcom::RuleItem, unsigned char> >()::{lambda(unsigned long long)#1}::_FUN(unsigned long long)
[19-08-2019_21-53-50] [FATAL] 0xba34f0 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
[19-08-2019_21-53-50] [FATAL] 0x7530a0 OpenXcom::Mod::getSurface(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)
[19-08-2019_21-53-50] [FATAL] 0x532180 OpenXcom::InventoryState::init()
[19-08-2019_21-53-50] [FATAL] 0x5a18a0 OpenXcom::InteractiveSurface::handle(OpenXcom::Action*, OpenXcom::State*)
[19-08-2019_21-53-50] [FATAL] 0x657c90 OpenXcom::State::handle(OpenXcom::Action*)
[19-08-2019_21-53-50] [FATAL] 0x533620 OpenXcom::InventoryState::handle(OpenXcom::Action*)
[19-08-2019_21-53-50] [FATAL] 0x59ee70 OpenXcom::Game::run()
[19-08-2019_21-53-50] [FATAL] 0x41c8c0 SDL_main
[19-08-2019_21-53-50] [FATAL] 0x91adc0 console_main
[19-08-2019_21-53-50] [FATAL] 0x91aee0 WinMain
[19-08-2019_21-53-50] [FATAL] ??
[19-08-2019_21-53-50] [FATAL] ??
[19-08-2019_21-53-50] [FATAL] 0x7ff947e47bc0 BaseThreadInitThunk
[19-08-2019_21-53-50] [FATAL] 0x7ff9498ece50 RtlUserThreadStart
[19-08-2019_21-53-55] [FATAL] OpenXcom has crashed: Sprite inventory_REPTOID.SPK not found

How do I assign that missing inventory sprite? I did look for it. I can find it, but as mentioned, no idea how to assign it...

For the sake of easiness and hope I will not end up being sued, I used the Reptoid from "FinalModPack"

Thank you for helping me =)

armors.rul
Code: [Select]
  - type: REPTOID_ARMOR0
    spriteSheet: REPTOID.PCK
    spriteInv: inventory_REPTOID
    corpseBattle:
      - STR_REPTOID_CORPSE
    frontArmor: 15
    sideArmor: 15
    rearArmor: 12
    underArmor: 10
    drawingRoutine: 0
    movementType: 0
    damageModifier:
      - 1.0
      - 1.0
      - 0.5
      - 0.9
      - 0.8
      - 0.8
      - 1.0
      - 0.8
      - 1.4
      - 0.0
    loftempsSet: [ 3 ]
  - type: REPTOID_ARMOR1
    spriteSheet: REPTOID.PCK
    spriteInv: inventory_REPTOID
    corpseBattle:
      - STR_REPTOID_CORPSE
    frontArmor: 20
    sideArmor: 20
    rearArmor: 15
    underArmor: 14
    drawingRoutine: 0
    movementType: 0
    damageModifier:
      - 1.0
      - 1.0
      - 0.5
      - 0.9
      - 0.8
      - 0.8
      - 1.0
      - 0.8
      - 1.4
      - 0.0
    loftempsSet: [ 3 ]
  - type: REPTOID_ARMOR2
    spriteSheet: REPTOID.PCK
    spriteInv: inventory_REPTOID
    corpseBattle:
      - STR_REPTOID_CORPSE
    frontArmor: 24
    sideArmor: 24
    rearArmor: 18
    underArmor: 16
    drawingRoutine: 0
    movementType: 0
    damageModifier:
      - 1.0
      - 1.0
      - 0.5
      - 0.9
      - 0.8
      - 0.8
      - 1.0
      - 0.8
      - 1.4
      - 0.0
    loftempsSet: [ 3 ]

extraSprites.rul
Code: [Select]
  - type: inventory_REPTOID
    singleImage: true
    files:
      0: Resources/FinalModPack/Races_Compilation/ReptoidRace/inventory_REPTOID.png

soldiers.rul
Code: [Select]
soldiers:
  - type: STR_REPTOID_COMMANDER
    costBuy: 40000
    costSalary: 0
    minStats:
      tu: 50
      stamina: 40
      health: 25
      bravery: 10
      reactions: 30
      firing: 40
      throwing: 50
      strength: 20
      psiStrength: 0
      psiSkill: 0
      melee: 20
    maxStats:
      tu: 100
      stamina: 150
      health: 80
      bravery: 100
      reactions: 100
      firing: 110
      throwing: 110
      strength: 80
      psiStrength: 100
      psiSkill: 110
      melee: 110
    statCaps:
      tu: 100
      stamina: 150
      health: 80
      bravery: 100
      reactions: 100
      firing: 110
      throwing: 110
      strength: 80
      psiStrength: 100
      psiSkill: 110
      melee: 110
    armor: STR_NONE_UC
    standHeight: 22
    kneelHeight: 14
    femaleFrequency: 100
    soldierNames:
      - delete
      - SoldierName/

Folder path: D:\Program Files (x86)\SteamApps\common\XCom UFO Defense\OpenXcom - Copy - Copy\standard\Final Mod Pack\Resources\FinalModPack\Races_Compilation\ReptoidRace -> inventory_REPTOID.png (I made a copy of the folder everytime I did something with the mod)

soldierTransformation.rul
Code: [Select]
soldierTransformation:
  - name: STR_Create_Alien
    listOrder: 1
    producedSoldierType: STR_REPTOID
    producedSoldierArmor: REPTOID_ARMOR0
    keepSoldierArmor: false
    createsClone: false
    needsCorpseRecovered: false
    allowsDeadSoldiers: true
    allowsLiveSoldiers: true
    allowsWoundedSoldiers: true  # adding these guys too, if we want to sack them
    allowedSoldierTypes:
      - STR_SOLDIER
    forbiddenPreviousTransformations:
      - STR_Create_Alien
    requiredMinStats: # The minimum stats a soldier must have in order to be eligible for this project, defaults to all 0 so any soldier is eligible
      tu: 0
      stamina: 0
      health: 0
      bravery: 0
      reactions: 0
      firing: 0
      throwing: 0
      strength: 0
      psiStrength: 0
      psiSkill: 0
      melee: 0
    requiredItems: # A list of items that must be consumed from the base's stores in which you start this project, the default empty list means no items are used
      #
    cost: 50000 # The cost of the project in dollars
    transferTime: 0 # Soldiers can be put in a transfer back to the base where they started if this parameter is greater than the default of 0 hours. New clones or resurrected soldiers are automatically given a transfer to the base with a default of 24 hours.
    recoveryTime: 0 # The amount of wound recovery time a soldier is given after this project completes and the transfer, if any, is completed. The default value is 0 days.
    flatOverallStatChange: # A direct change to the soldier's overall stats when undergoing this project, can be positive or negative - tu: 5 means the soldier will gain 5 max time units, while tu: -5 means the soldier will lose 5 max time units. The default of 0 means no change.
      tu: 0
      stamina: 0
      health: 0
      bravery: 0
      reactions: 0
      firing: 0
      throwing: 0
      strength: 0
      psiStrength: 0
      psiSkill: 0
      melee: 0
    percentOverallStatChange: # A percent change to the soldier's overall stats when undergoing this project, can be positive or negative - tu: 5 means the soldier will gain an extra 5% of their max time units, while tu: -5 means the soldier will lose 5% of their max time units. The default of 0 means no change.
      tu: 0
      stamina: 0
      health: 0
      bravery: 0
      reactions: 0
      firing: 0
      throwing: 0
      strength: 0
      psiStrength: 0
      psiSkill: 0
      melee: 0
    percentGainedStatChange: # A percent change to the soldier's stats, but instead of taking a portion of the overall stats, this only applies to the stats they've trained up from their initial values, can be positive or negative - firing: -100 means the soldier will lose all of the firing accuracy they trained since joining, while firing: 10 means they gain 10% of the amount they trained over their initial values. The default of 0 means no change.
      tu: 0
      stamina: 0
      health: 0
      bravery: 0
      reactions: 0
      firing: 0
      throwing: 0
      strength: 0
      psiStrength: 0
      psiSkill: 0
      melee: 0
    useRandomStats: false
    lowerBoundAtMinStats: true
    upperBoundAtMaxStats: false
    upperBoundAtStatCaps: true
extraStrings:
  - type: en-US
    strings:
      STR_Create_Alien: "Create Alien"

Edit: Added a few codes...

Edit 2: Adding folder path to "Reptoid"

Edit 3: Adding updated soldierTransformation.rul
« Last Edit: August 19, 2019, 11:19:28 pm by Avarlia »

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: Need help with soldier transformation into playable aliens.
« Reply #3 on: August 20, 2019, 01:22:21 am »
The second line of the log file you posted is telling you exactly what is wrong - the game is looking for an extra sprite entry called "inventory_REPTOID.SPK" and what you have is called "inventory_REPTOID". That ".SPK" is appended for soldiers' armors to handle the different look variants and original game files. It's a naming convention that you wouldn't have known until you ran into it. Fortunately the fix is just adding the image and extraSprites entry for it into your mod.

As a point of preference, I'd make a separate armor entry for your new soldiers as alien armor entries often lack parameters like limiting the armor to your new soldier type or possibly using items in your stores.

Offline Avarlia

  • Squaddie
  • *
  • Posts: 3
    • View Profile
Re: Need help with soldier transformation into playable aliens.
« Reply #4 on: August 20, 2019, 02:37:30 am »
The second line of the log file you posted is telling you exactly what is wrong - the game is looking for an extra sprite entry called "inventory_REPTOID.SPK" and what you have is called "inventory_REPTOID". That ".SPK" is appended for soldiers' armors to handle the different look variants and original game files. It's a naming convention that you wouldn't have known until you ran into it. Fortunately the fix is just adding the image and extraSprites entry for it into your mod.

As a point of preference, I'd make a separate armor entry for your new soldiers as alien armor entries often lack parameters like limiting the armor to your new soldier type or possibly using items in your stores.

Hi there again!

I've made a few changes and now it's working... almost! I can access inventory and do other things... The only thing missing is literally their heads. In Inventory, everything is working fine, even switching weapons. The issues is, when a battle starts, the head is missing. I can turn around, shoot at aliens thou... Any idea how to fix that?

Thank you again for helping me =)