OpenXcom Forum

Modding => OpenXcom Extended => OXCE Support => Topic started by: The Martian on May 02, 2020, 09:09:04 am

Title: [Answered] Restricting weapon use by Stats/Armor/Unit Type?
Post by: The Martian on May 02, 2020, 09:09:04 am
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 (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Soldier_Transformation)' to a specific type.

I'm still reading up on Transformation (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Soldier_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 (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Soldier_Transformation).

Title: Re: Restricting weapon use by Stats/Armor/Unit Type?
Post by: Meridian on May 02, 2020, 10:39:19 am
no
Title: Re: Restricting weapon use by Stats/Armor/Unit Type?
Post by: The Martian on May 02, 2020, 11:01:43 am
That is disappointing.

I will adapt my plans to work around the limitation.
Title: Re: Restricting weapon use by Stats/Armor/Unit Type?
Post by: Meridian on May 02, 2020, 11:30:33 am
it's not a limitation, it's a feature
Title: Re: Restricting weapon use by Stats/Armor/Unit Type?
Post by: vadracas 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.
Title: Re: Restricting weapon use by Stats/Armor/Unit Type?
Post by: Solarius Scorch 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.
Title: Re: Restricting weapon use by Stats/Armor/Unit Type?
Post by: Nord on May 02, 2020, 04:51:35 pm
You can restrict using of item via script, but you can not restrict equipping
Title: Re: Restricting weapon use by Stats/Armor/Unit Type?
Post by: Meridian 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.
Title: Re: Restricting weapon use by Stats/Armor/Unit Type?
Post by: The Martian 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 (https://www.ufopaedia.org/index.php/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.
Title: Re: Restricting weapon use by Stats/Armor/Unit Type?
Post by: Nord 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.
Title: Re: Restricting weapon use by Stats/Armor/Unit Type?
Post by: The Martian 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: (https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Inventory) variable to prevent the item from being placed into the soldier's hand slots if they don't have the requirements.
Title: Re: Restricting weapon use by Stats/Armor/Unit Type?
Post by: Nord 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.