aliens

Author Topic: [Solved] How is "nameAsAmmo" used?  (Read 2607 times)

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
[Solved] How is "nameAsAmmo" used?
« on: October 28, 2019, 12:50:14 am »
I noticed a variable called "nameAsAmmo" in the UFOpaedia "Ruleset Reference Nightly > Items > Naming, Categorization and Storage" section.

Unfortunately a search of the forum for information on the use of nameAsAmmo came up empty.

Could someone please explain its use and the syntax required to code it into an entry in the items: section?


I'm hoping that meaning of the variable's description "Extension for the name of weapons loaded with this item as ammo." is that you can store a second string of text in it which is added to the end of the text for the equipment the ammo is loaded into.

Example images of how that would be useful are attached to this post:

« Last Edit: February 12, 2023, 09:36:09 am by Meridian »

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: (OXCE) How is "nameAsAmmo" used?
« Reply #1 on: October 28, 2019, 01:06:06 am »
Wonderful!

It is what I was hoping and this is how you use it:
On the ammo item place the nameAsAmmo: followed by the string variable you want to use, example:

Code: [Select]
  - type: STR_LAUNCHER_SMOKE
    size: 0.1
    costBuy: 300
    costSell: 200
    weight: 3
    bigSprite: 63
    floorSprite: 2
    hitSound: 0
    hitAnimation: 96
    power: 60
    damageType: 9
    clipSize: 1
    battleType: 2
    armor: 20
    attraction: 6
    listOrder: 3413
    nameAsAmmo: STR_NAME_OF_THE_STRING

In extraStrings: define the contents of STR_NAME_OF_THE_STRING and now when the weapon is loaded with that ammo this text is added to the end of the weapons name.

Very useful.

Offline Varana

  • Captain
  • ***
  • Posts: 52
    • View Profile
nameAsAmmo: example code
« Reply #2 on: June 02, 2020, 03:27:06 pm »
The code example here is a bit confusing.

The nameAsAmmo: has to be set for the ammo, not for the launcher.
See this TFTD example:

Code: [Select]
items:
  - type: STR_HYDRO_JET_CANNON
    compatibleAmmo:
      - STR_HJC_AP_AMMO
      - STR_HJC_HE_AMMO
      - STR_HJC_P_AMMO
  - type: STR_HJC_AP_AMMO
    nameAsAmmo: STR_NAMEASAMMO_AP
  - type: STR_HJC_HE_AMMO
    nameAsAmmo: STR_NAMEASAMMO_HE
  - type: STR_HJC_P_AMMO
    nameAsAmmo: STR_NAMEASAMMO_IN
extraStrings:
  - type: en-US
    strings:
      STR_NAMEASAMMO_AP: ":AP:"   # damageType 1 - Armor Piercing
      STR_NAMEASAMMO_IN: ":IN:"   # damageType 2 - Incendiary =Fire
      STR_NAMEASAMMO_HE: ":HE:"   # damageType 3 - High Explosive
« Last Edit: June 02, 2020, 03:43:26 pm by Varana »

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: nameAsAmmo: example code
« Reply #3 on: June 02, 2020, 06:49:34 pm »
You are right, now that I'm looking at it again that name should have been more clear for the sake of the code example.

Sorry about that.