OpenXcom Forum
Modding => Help => Topic started by: pjlasl on January 17, 2022, 12:35:42 am
-
Is there a way to only allow a unit/soldier to only carry a particular type of weapon?
For example, Say I wanted a new soldier type I'm creating to only be able to carry a pistol. If I tried to assign a rifle at the beginning of a battlescape or try to pick up a plasma weapon, I couldn't.
-
No, such feature doesn't exist and is also not planned.
-
No, such feature doesn't exist and is also not planned.
And it's a pity.
-
And it's a pity.
ditto
-
personally speaking, that was one of the features i liked the least about xcom 2012
-
personally speaking, that was one of the features i liked the least about xcom 2012
I can understand you. It's just that my modification physically needs something like that. Either a ban on certain weapons for different classes of infantry, or a system of bonuses / penalties in weapons for the type of soldier. But, unfortunately, neither one nor the other is likely to happen.
-
Using scripts in OXCE you can make that weapon have different accuracy/power/reaction based on used armor
-
Using scripts in OXCE you can make that weapon have different accuracy/power/reaction based on used armor
You constantly advise using scripts, but how many of them appeared? Seriously, usually after the word "script" the discussion of a new option stops forever. Maybe this is also a script?
-
Is there a way to only allow a unit/soldier to only carry a particular type of weapon?
For example, Say I wanted a new soldier type I'm creating to only be able to carry a pistol. If I tried to assign a rifle at the beginning of a battlescape or try to pick up a plasma weapon, I couldn't.
Nord was able to prevent an item from operating via scripting.
But it could still be used (Without effect) which spent TU and it also could be equipped to the slots in inventory.
See the end of this thread:
Restricting weapon use by Stats/Armor/Unit Type? (https://openxcom.org/forum/index.php/topic,8157.msg126895.html#msg126895)
Alternatively maybe you could use fixedWeapon: to graft the pistol/rifle/etc to that soldier type so it couldn't drop it?
I've been using several scripts in my project and it really does open up new options... however creating them can be difficult compared to YAML in a .rul file.
If you want to give it a try here is some useful information: Scripting Basics (https://www.ufopaedia.org/index.php/Script_(OpenXcom))
No, such feature doesn't exist and is also not planned.
If you did implement a feature in OXCE to be able to prevent certain weapons firing with specific armors it would be very welcome.
Perhaps something like this:
armors:
- type: STR_ARMOR_THAT_CANNOT_USE_SOME_ITEMS_UC
forbiddenWeapons:
- STR_RIFLE
- STR_PISTOL
This armor with forbiddenWeapons: could not use any items on the above list.
armors:
- type: STR_ARMOR_THAT_CAN_USE_SPECIAL_ITEM_UC
allowedWeapons:
- STR_ARMOR_CONNECTED_FLAMETHROWER
This armor with allowedWeapons: acts as if all items have been added to the forbiddenWeapons: list, except for those in the allowedWeapons: list.
Or would it be easier to keep track of lists of forbiddenArmors: allowedArmors: on the item itself?
There are usually less armors than items so maybe that would be better if this was attempted?
items:
- type: STR_SPECIAL_GUN_THAT_CAN_ONLY_BE_USED_BY_SPECIAL_ARMOR
allowedArmors:
- STR_SPECIAL_ARMOR_UC
- STR_OTHER_SPECIAL_ARMOR_UC
Although you are not planning to make it, what would you want if it was present Meridian?
(I'm just curious about how you would phrase the code.)
personally speaking, that was one of the features i liked the least about xcom 2012
I think the problem with xcom 2012 was that there wasn't much you could actually equip each soldier with, so it became more of a 'this soldier is this class and thus has this gun'.
Many OpenXcom mods have a large enough item selection that this should not be a problem.
Of course it would depend on how the person writing the mod implemented the restrictions.
Something like Memmaker's 'Vigilo Confido (https://openxcom.org/forum/index.php/topic,8007.0.html)' would probably deliberately mirror xcom 2012 using this ability.
-
You constantly advise using scripts, but how many of them appeared? Seriously, usually after the word "script" the discussion of a new option stops forever. Maybe this is also a script?
This indeed one feature of scripts :D
And this is as not serious and serious answer, goal of y-script is allow for modders add custom logic that is not supported normally by engine and it move "burden" from developers to modders too. This is preferred in long run as there is only one developer (Meridian, I only spend only couple hours weekly on OXCE) and there is dozen of modders and each want some new features.
Another aspect of this is that y-scripts requite some learning to easy written them, when I throw "scripts" in discursion then person asking do not want spend try write then and simply drop whole idea.
If someone as "how exactly do this" then I or Meridian will show examples how archive logic like this using scripts.
-
Is there a way to only allow a unit/soldier to only carry a particular type of weapon?
For example, Say I wanted a new soldier type I'm creating to only be able to carry a pistol. If I tried to assign a rifle at the beginning of a battlescape or try to pick up a plasma weapon, I couldn't.
You could try changing the size of the hand slots. If the hand slots were 1x2, they could carry a pistol, knife, grenade, medikit, or other small items but nothing bigger such as a mind probe, high explosive, psi amp, or rifle.
To be clear, I have not done this before and am only speculating.
-
If someone as "how exactly do this" then I or Meridian will show examples how archive logic like this using scripts.
Thank you. I'll try to describe.
What was proposed to make the availability of weapons depending on the armor is counterproductive. This only makes sense when there are no interchangeable armor types. What is needed is a dependence on the type of soldier.
I see the construction of bonuses/penalties for the type of soldiers like this:
items:
- type: STR_RIFLE
accuracyAuto: 50
accuracySnap: 70
accuracyAimed: 110
tuAuto: 30
tuSnap: 20
tuAimed: 35
autoRange: 10
snapRange: 15
aimRange: 30
dropoff: 4
soldiersType:
- STR_SOLDIER_SNIPER
accuracyAutoAdd: 10 #=60
accuracySnapAdd: 15 #=85
accuracyAimedAdd: 20 #=130
tuAutoAdd: -5 #=25
tuSnapAdd: -5 #=15
tuAimedAdd: -5 #=30
autoRangeAdd: 5 #=15
snapRangeAdd: 5 #=20
aimRangeAdd: 10 #=40
dropoffAdd: -2 #=2
- STR_SOLDIER_NINJA
accuracyAutoAdd: -10 #=40
accuracySnapAdd: -10 #=60
accuracyAimedAdd: -20 #=90
tuAutoAdd: 5 #=35
tuSnapAdd: 5 #=25
tuAimedAdd: 5 #=40
autoRangeAdd: -3 #=7
snapRangeAdd: -3 #=12
aimRangeAdd: -5 #=25
dropoffAdd: 2 #=6
- type: STR_RIFLE_CLIP
power: 36
damageBonus:
firing: 0.1
soldiersType:
- STR_SOLDIER_SNIPER
power: 4 #=40
damageBonus:
firing: 0.1 #=0.2
- STR_SOLDIER_NINJA
power: -6 #=30
damageBonus:
firing: -0.1 #=0
It looks terribly cumbersome and time-consuming to implement, and I strongly doubt that it is possible to do this with the help of scripts.
It remains an option with restrictions, as in armor.
items:
- type: STR_RIFLE
soldiersType: # Aliens - no restrictions.
- STR_SOLDIER
- STR_SOLDIER_SNIPER
- STR_SOLDIER_MIND
-
Thank you. I'll try to describe.
What was proposed to make the availability of weapons depending on the armor is counterproductive. This only makes sense when there are no interchangeable armor types. What is needed is a dependence on the type of soldier.
I see the construction of bonuses/penalties for the type of soldiers like this:
items:
- type: STR_RIFLE
accuracyAuto: 50
accuracySnap: 70
accuracyAimed: 110
tuAuto: 30
tuSnap: 20
tuAimed: 35
autoRange: 10
snapRange: 15
aimRange: 30
dropoff: 4
soldiersType:
- STR_SOLDIER_SNIPER
accuracyAutoAdd: 10 #=60
accuracySnapAdd: 15 #=85
accuracyAimedAdd: 20 #=130
tuAutoAdd: -5 #=25
tuSnapAdd: -5 #=15
tuAimedAdd: -5 #=30
autoRangeAdd: 5 #=15
snapRangeAdd: 5 #=20
aimRangeAdd: 10 #=40
dropoffAdd: -2 #=2
- STR_SOLDIER_NINJA
accuracyAutoAdd: -10 #=40
accuracySnapAdd: -10 #=60
accuracyAimedAdd: -20 #=90
tuAutoAdd: 5 #=35
tuSnapAdd: 5 #=25
tuAimedAdd: 5 #=40
autoRangeAdd: -3 #=7
snapRangeAdd: -3 #=12
aimRangeAdd: -5 #=25
dropoffAdd: 2 #=6
- type: STR_RIFLE_CLIP
power: 36
damageBonus:
firing: 0.1
soldiersType:
- STR_SOLDIER_SNIPER
power: 4 #=40
damageBonus:
firing: 0.1 #=0.2
- STR_SOLDIER_NINJA
power: -6 #=30
damageBonus:
firing: -0.1 #=0
It looks terribly cumbersome and time-consuming to implement, and I strongly doubt that it is possible to do this with the help of scripts.
Logic like `accuracyAutoAdd` is possible to do today by scripts, I will show example there.
Logic like `tuAutoAdd` probably never will be available in scripts. Action cost is critical for AI to work correctly and scripts will make planing moves a lot of harder.
Rest of options is somewhere in between.
One way to have different cost based on soldier type is skills, this is custom actions that could override default weapons behaviors. Example of its is:
https://openxcom.org/forum/index.php/topic,8007.0.html
For script solution for accuracy.
To reduce number of possible combinations and even add more depth to this each weapon will define only "diff" accuracy based on armor "skill":
FinalAccuracy = BaseAccurace + DiffAccuract * SkillSoldier
I will make only one "skill" (not confuse with soldiers skills that are special actions, this "skill" is pure number assigned to armor)
extended:
tags:
RuleItem:
WEAPON_SKILL_DIFF_AIM: int
WEAPON_SKILL_DIFF_AUTO: int
WEAPON_SKILL_DIFF_SNAP: int
RuleArmor:
WEAPON_SKILL_ARMOR_MUL: int
scripts:
accuracyMultiplierBonusStats:
- offset: 1
code: |
var int weaponDiff 0;
var int soldierSkill 0;
if eq battle_action 9;
weapon.getTag weaponDiff Tag.WEAPON_SKILL_DIFF_AIM; #technicaly this tag should be on rule object from `weapon.getRuleItem r;` but we use short cut and get this tag from item
end;
if eq battle_action 7;
weapon.getTag weaponDiff Tag.WEAPON_SKILL_DIFF_AUTO;
end;
if eq battle_action 8;
weapon.getTag weaponDiff Tag.WEAPON_SKILL_DIFF_SNAP;
end;
unit.getTag soldierSkill Tag.WEAPON_SKILL_ARMOR_MUL; #again we asking unit what tag its armor have
muldiv soldierSkill weaponDiff 10; #result is natural number but we divide by 10 to have option for 1/2 bonuses too, this mean diff 10 and skill 10 will give bonus 10
add bonus soldierSkill;
return bonus;
And item configs will look like:
items:
- type: STR_RIFLE
tags:
WEAPON_SKILL_DIFF_AIM: 40
WEAPON_SKILL_DIFF_AUTO: 20
WEAPON_SKILL_DIFF_SNAP: -20
armors:
- type: STR_NONE_UC
tags:
WEAPON_SKILL_ARMOR_MUL: 10
This is very basic version, there is only one "skill" but its easy to expand this script to add multiple parallel bonuses.
It remains an option with restrictions, as in armor.
items:
- type: STR_RIFLE
soldiersType: # Aliens - no restrictions.
- STR_SOLDIER
- STR_SOLDIER_SNIPER
- STR_SOLDIER_MIND
Restriction can be done by adding:
armors:
- type: STR_NONE_UC
tags:
WEAPON_SKILL_ARMOR_MUL: -30
This will make unit still usable but unpractical.
-
So it's all through the armor, which is no good. The same armor can be worn by different types of infantry, which should have different bonuses. And to make a separate branch of armor for each type of soldier (pieces 8-10) - only clutter up ufopedia, manufactory and the player's brain.
In short - through anything, but not through armor.
-
This is only initial script, you can easy query solider rule from this unit and grab bonus from there too.
There could be too from SoldierBonuses (but this could require couple of more scripts)
code that get bonus from rule solder would look like:
extended:
tags:
RuleItem:
WEAPON_SKILL_DIFF_AIM: int
WEAPON_SKILL_DIFF_AUTO: int
WEAPON_SKILL_DIFF_SNAP: int
RuleArmor:
WEAPON_SKILL_ARMOR_MUL: int
RuleSoldier:
WEAPON_SKILL_SOLDIER_MUL: int
scripts:
accuracyMultiplierBonusStats:
- offset: 1
code: |
var int weaponDiff 0;
var int soldierSkill 0;
if eq battle_action 9;
weapon.getTag weaponDiff Tag.WEAPON_SKILL_DIFF_AIM; #technicaly this tag should be on rule object from `weapon.getRuleItem r;` but we use short cut and get this tag from item
end;
if eq battle_action 7;
weapon.getTag weaponDiff Tag.WEAPON_SKILL_DIFF_AUTO;
end;
if eq battle_action 8;
weapon.getTag weaponDiff Tag.WEAPON_SKILL_DIFF_SNAP;
end;
unit.getTag soldierSkill Tag.WEAPON_SKILL_ARMOR_MUL; #again we asking unit what tag its armor have
begin;
var int temp;
var ptr GeoscapeSoldier s;
unit.getGeoscapeSoldier s;
s.getTag temp Tag.WEAPON_SKILL_SOLDIER_MUL; #if `s == null` then `getTag` will set `0` to `temp`
add soldierSkill temp;
end;
muldiv soldierSkill weaponDiff 10; #result is natural number but we divide by 10 to have option for 1/2 bonuses too, this mean diff 10 and skill 10 will give bonus 10
add bonus soldierSkill;
return bonus;
-
Thanks a lot. It works. I only checked "WEAPON_SKILL_SOLDIER_MUL", because in my modification such bonuses for armor are not suitable. In general, Britney Spears can take a sniper rifle, but only to crack nuts. Yankes, once again, thank you for help!
-
probably, this is offtopic, but still - how do I set tags for GeoscapeSoldier to use it later with commands like
unit.getGeoscapeSoldier s;
s.getTag temp Tag.WEAPON_SKILL_SOLDIER_MUL; #if `s == null` then `getTag` will set `0` to `temp`
-
probably, this is offtopic, but still - how do I set tags for GeoscapeSoldier to use it later with commands like
If I understood you correctly -
items:
- type: STR_HEAVY_LASER
tags:
WEAPON_SKILL_DIFF_AIM: 30
WEAPON_SKILL_DIFF_AUTO: 30
WEAPON_SKILL_DIFF_SNAP: 30
soldiers:
- type: STR_SOLDIER
tags:
WEAPON_SKILL_SOLDIER_MUL: 10
-
probably, this is offtopic, but still - how do I set tags for GeoscapeSoldier to use it later with commands like
unit.getGeoscapeSoldier s;
s.getTag temp Tag.WEAPON_SKILL_SOLDIER_MUL; #if `s == null` then `getTag` will set `0` to `temp`
There two things happens, in this example tag belong to `RuleSoldier` not `GeoscapeSoldier`, but you can as shortcut get rule tag using soldier itself.
And if you use tags that belong to `GeoscapeSoldier` then you can easy use `s.setTag Tag.ZZZZ 10;` to set custom values.
-
Not sure if I can understand how to get `GeoscapeSoldier`'s tag from the unit then...
-
Same way, `getTag` is overloaded for rule tags and soldiers tags, as each tag name is globally unique we can easy chose correct version.