aliens

Author Topic: [Answered] Restricting weapon use by Stats/Armor/Unit Type?  (Read 3651 times)

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Is it possible to prevent a piece of equipment (Weapon or device) from being used if the unit carrying it doesn't have one or all of the following:
- A high enough value in a specific stat (For example strength.)
- Unit is not wearing a specific armor.
- Unit has not had a 'Soldier Transformation' to a specific type.

I'm still reading up on Transformation so I may have misunderstood how it works.

My current understanding is it allows the increase or decrease of max stat caps as well as the increase or decrease of existing stat values the unit has. Sounds pretty useful.


So for example a soldier may not be able to fire a heavy cannon if not wearing power armor or having Strength above X or having undergone a specific Transformation.

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

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8719
    • View Profile
Re: Restricting weapon use by Stats/Armor/Unit Type?
« Reply #1 on: May 02, 2020, 10:39:19 am »
no

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Restricting weapon use by Stats/Armor/Unit Type?
« Reply #2 on: May 02, 2020, 11:01:43 am »
That is disappointing.

I will adapt my plans to work around the limitation.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8719
    • View Profile
Re: Restricting weapon use by Stats/Armor/Unit Type?
« Reply #3 on: May 02, 2020, 11:30:33 am »
it's not a limitation, it's a feature

Offline vadracas

  • Colonel
  • ****
  • Posts: 285
  • Just another player/modder combo.
    • View Profile
Re: Restricting weapon use by Stats/Armor/Unit Type?
« Reply #4 on: May 02, 2020, 12:31:02 pm »
no

I hate to contradict, but in a very limited manner, weapons can be attached to a single stat and their attacks can be made to require that stat, mana.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11583
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Restricting weapon use by Stats/Armor/Unit Type?
« Reply #5 on: May 02, 2020, 01:14:26 pm »
Well, requiring a stat/armour/soldier type is one thing, and having a cost in one of the bars is another. But yes, I agree that it might work, depending on Martian's intentions.

Also, I think something can be done with scripts here.

Offline Nord

  • Commander
  • *****
  • Posts: 1680
  • The Gate is open.
    • View Profile
Re: Restricting weapon use by Stats/Armor/Unit Type?
« Reply #6 on: May 02, 2020, 04:51:35 pm »
You can restrict using of item via script, but you can not restrict equipping

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8719
    • View Profile
Re: Restricting weapon use by Stats/Armor/Unit Type?
« Reply #7 on: May 02, 2020, 04:54:41 pm »
I hate to contradict, but in a very limited manner, weapons can be attached to a single stat and their attacks can be made to require that stat, mana.

I only answered the questions that were asked.
The answer to all 3 of them is no.

Other options and speculations were not part of my answer.

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Restricting weapon use by Stats/Armor/Unit Type?
« Reply #8 on: May 04, 2020, 04:12:40 pm »
You can restrict using of item via script, but you can not restrict equipping

That would work perfectly, I only need them not to be activated / fired by the X-Com soldier holding them.

Is there an already coded example of this script available that I can adapt?

I hate to contradict, but in a very limited manner, weapons can be attached to a single stat and their attacks can be made to require that stat, mana.

Mana would work however I've already set that stat aside for use with costAimed, costSnap and costAuto so using the max amount of mana as a limiting factor isn't an option in this case.

I can see how this would be a good method though. Just setup your armor to regen all of the unit's mana at the start of every turn. Then make the weapon's action require certain amounts of mana that can only be provided if the unit's equipped armor or transformation increased the mana's max stat cap high enough to activate that equipment.



Alternatively another way of limiting certain weapons is you could take over the "Melee Accuracy" stat and then cap the max really low, only raising that stat's value max via armor or transformation. Then slave the output of the equipment directly to that stat via the damageBonus: variable.

So a soldier could equip it, use it... but without the right other equipment it just wouldn't do any damage.

Messy but theoretically it would also function, I think.

The two disadvantages I see to this method are:
. Actual melee weapons that rely on that stat would be effected limiting their use.
. If not used for melee equipment the relied on stat's name could be counterintuitive.

Offline Nord

  • Commander
  • *****
  • Posts: 1680
  • The Gate is open.
    • View Profile
Re: Restricting weapon use by Stats/Armor/Unit Type?
« Reply #9 on: May 04, 2020, 04:25:28 pm »
That would work perfectly, I only need them not to be activated / fired by the X-Com soldier holding them.

Is there an already coded example of this script available that I can adapt?
Ok, looks like i was too optimistic. All i can do is "wrong target"message instead of damage. But tu's will be spent.
Other way, maybe inventory restrictions will work? I shall check.

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: Restricting weapon use by Stats/Armor/Unit Type?
« Reply #10 on: May 04, 2020, 05:07:38 pm »
Ok, looks like i was too optimistic. All i can do is "wrong target"message instead of damage. But tu's will be spent.

Stylistically it could be implied the unit wasted the TU trying to activate the device, but failed.

So that would still do the job. Are you causing that to happen based on the unit's stats, armor or unit transformation?

Other way, maybe inventory restrictions will work?

That would be an interesting way of doing it.

If I understand correctly you're attempting to wire it into the the supportedInventorySections: variable to prevent the item from being placed into the soldier's hand slots if they don't have the requirements.

Offline Nord

  • Commander
  • *****
  • Posts: 1680
  • The Gate is open.
    • View Profile
Re: Restricting weapon use by Stats/Armor/Unit Type?
« Reply #11 on: May 04, 2020, 09:05:31 pm »
Are you causing that to happen based on the unit's stats, armor or unit transformation?
based on armor tags mostly.