Author Topic: Duplicating/Inheriting Rules?  (Read 2872 times)

Offline skyhawk

  • Colonel
  • ****
  • Posts: 115
    • View Profile
Duplicating/Inheriting Rules?
« on: November 24, 2019, 01:03:21 pm »
Let me open by saying I'm fairly new to actually creating new rules [Rather than tweaking what's already there] in OpenXCom. I apologize if some of the terminology I'm using is incorrect, or if this is a stupid question with an obvious answer right over there.

In the interests of reducing potential inter-mod conflict, I'd like to create a new thing, but have it based on an existing thing that I then specify my modifications to.

For example:

Take this stock rule from TFTD
Code: [Select]
  - id: STR_COELACANTH_GAUSS
    type_id: 13
    section: STR_HEAVY_WEAPONS_PLATFORMS
    weapon: STR_DAMAGE_LASER_BEAM
    image_id: UP068.BDY
    requires:
      - STR_GAUSS_CANNON
      - STR_NEW_FIGHTER_FLYING_SUB
    text: STR_COELACANTH_GAUSS_UFOPEDIA

I'd like a way to specify something like the following:

Code: [Select]
  - id: STR_PLASTIC_COELACANTH_GAUSS
    derive_from: STR_COELACANTH_GAUSS
    requires:
      - STR_AQUA_PLASTICS
    text: STR_PLASTIC_COELACANTH_GAUSS_UFOPEDIA

This way if another mod makes changes to this unit [Like my own remove-magnetic-navigation prerequisite mod] the new unit will inherit those changes.

Does this make any sense or am I babbling crazy talk?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: Duplicating/Inheriting Rules?
« Reply #1 on: November 24, 2019, 01:17:48 pm »
The first example (laser sniper rifle) on this page: https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)

Offline skyhawk

  • Colonel
  • ****
  • Posts: 115
    • View Profile
Re: Duplicating/Inheriting Rules?
« Reply #2 on: November 25, 2019, 09:27:30 pm »
Thanks Meridian,

Unfortunately, while this may be useful within one's own mod, it does not appear to be helpful regarding vanilla resources.  Take the following example

This is defined in standard/xcom2/crafts.rul
Code: [Select]
crafts: #done
  - type: STR_TRITON
    sprite: 0
    fuelMax: 1400
    damageMax: 160
    speedMax: 790
    accel: 2
    soldiers: 14
    vehicles: 3
    costBuy: 500000
    costRent: 500000
    forceShowInMonthlyCosts: true
    refuelRate: 50
    transferTime: 72
    score: 200
    maxAltitude: 4
    battlescapeTerrainData:
      name: TRITON
      mapDataSets:
        - BLANKS
        - TRITON
      mapBlocks:
        - name: TRITON
          width: 10
          length: 20
    deployment:
      - [5, 7, 0, 4]
      - [4, 7, 0, 4]
      - [5, 6, 0, 4]
      - [4, 6, 0, 4]
      - [5, 5, 0, 4]
      - [4, 5, 0, 4]
      - [5, 4, 0, 4]
      - [4, 4, 0, 4]
      - [5, 3, 0, 4]
      - [4, 3, 0, 4]
      - [5, 2, 0, 4]
      - [4, 2, 0, 4]
      - [3, 7, 0, 4]
      - [3, 6, 0, 4]

If I want to make a variant of the Triton, without modifying the original game files, how am I supposed to include the anchor?

This doesn't work
Code: [Select]
crafts:
  - &STR_TRITON
    type: STR_TRITON
  - type: STR_PLASTIC_TRITON
    refNode: *STR_TRITON
    damageMax: 250
    accel: 3
    costRent: 80000

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: Duplicating/Inheriting Rules?
« Reply #3 on: November 25, 2019, 09:42:32 pm »
Not possible.

Offline Starving Poet

  • Colonel
  • ****
  • Posts: 265
    • View Profile
Re: Duplicating/Inheriting Rules?
« Reply #4 on: November 26, 2019, 04:52:07 pm »
In short, you have to redefine the triton in your mod if you want to make variants.

It's never going to change, so other than wasting a couple bytes of hard disk space, there's no downside.