Jump to content

Please Help With "ScopeOffset" When Modifying Attachments

Recommended Posts

So I found an interesting mod called PIP Optic Overhaul, it was originally for A18, then updated to A19 by another, and I'm attempting to update it to A20 for my own personal use.

The mod adds Picture in Picture optics for the 2x, 4x and 8x scopes.
Now a days, weapons are modelled with attachments, and the XML would set visible attachments when required. This system seems to conflict with me trying to add custom attachments to existing weapons and offsetting the scope offset. the exception to this is the Tactical Assault Rifle, which does not have an internal attachment for the 2x Scope.

So far, I have the new 2x Scope prefab loading into the game just fine. For the Tactical Assault Rifle, I am able to use the "ScopeOffset" override property for it just fine. It moves the scope around as expected. All the other guns I've tried to use the "ScopeOffset" property with seem to completely ignore it, some weapons having the scope model float, or staying at a default position of 0,0,0.



Note: I do not intend to publish this mod, however, any help I get, I'll pass on to the original mod authors.



Properly position Tactical Assault Rifle with Scope using "ScopeOffset": 


Hovering scope on the Pistol, ignoring "ScopeOffset":



Default position scope on the AK, ignoring "ScopeOffset":



Here is my current code snippet:

  <!-- Remove the original scope and create our own -->
    <remove xpath="/item_modifiers/item_modifier[@name='modGunScopeSmall']"/>
    <append xpath="/item_modifiers">
        <item_modifier name="modGunScopeSmall" installable_tags="smallTopAttachments" modifier_tags="scope" blocked_tags="noMods,noScopes" type="attachment">
      <property name="Extends" value="modGeneralMaster"/>
      <property name="UnlockedBy" value="modGunScopeSmallSchematic"/>
      <item_property_overrides name="*">
                <property name="CrosshairOnAim" value="true"/>
                <property name="Zoom_max_out" value="55"/>
                <property name="Zoom_max_in" value="55"/>
      <!-- Make offsets and changes for the Pistol, TAR, and AK -->
      <item_property_overrides name="gunHandgunT1Pistol">
                <property name="ScopeOffset" value="0,0.1,.078"/>
                <property name="ScopeScale" value="1,1,1"/>
                <property name="ScopeCameraOffset" value="0,-0.021,0"/>
            <item_property_overrides name="gunMGT1AK47">
                <property name="ScopeOffset" value="0,0.595,-.075"/>
                <property name="ScopeScale" value="1.5,1.5,1.5"/>
                <property name="ScopeCameraOffset" value="0,-0.0095,0.4"/>
                <property name="ScopeRotation" value="1.6,0,0"/>
            <item_property_overrides name="gunMGT2TacticalAR">
                <property name="ScopeOffset" value="-0.0015,0.105,-.075"/>
                <property name="ScopeScale" value="3,3,3"/>
                <property name="ScopeCameraOffset" value="0.0008,-.0099,0.07"/>
                <property name="ScopeRotation" value="-2,0,0"/>
            <!-- Attach the new prefab to the weapon and toggle the PIP Optic. -->
      <effect_group tiered="false" name="npip - please work">
        <triggered_effect trigger="onSelfHoldingItemCreated" action="AttachPrefabToHeldItem" prefab="#@modfolder:Resources/2xmag.unity3d?2xmag.prefab" parent_transform="Attachments/Scope"/>
        <triggered_effect trigger="onSelfAimingGunStart" action="SetTransformActive" active="true" parent_transform="2xmag" transform_path="RenderLens"/>
        <triggered_effect trigger="onSelfAimingGunStop" action="SetTransformActive" active="false" parent_transform="2xmag" transform_path="RenderLens"/>
      <!-- Normal scope mod effects -->
            <effect_group tiered="false" name="mod effects">
        <passive_effect name="SpreadMultiplierAiming" operation="perc_add" value="-.1" tags="perkGunslinger,perkDeadEye,perkMachineGunner,perkArchery,admin"/>
        <passive_effect name="SpreadMultiplierAiming" operation="perc_add" value="-.1" tags="perkDeadEye,perkArchery,admin">
          <requirement name="ItemHasTags" tags="perkDeadEye,crossbow"/>
        <passive_effect name="EntityDamage" operation="perc_add" value=".1">
          <requirement name="ProgressionLevel" progression_name="perkSniperDamage" operation="Equals" value="1"/>
          <requirement name="HasBuff" buff="buffHoldBreathAiming01"/>


Link to comment
Share on other sites

I don't know why I didn't think of this earlier. Changed the prefab to use the default ingame scope with the same results, that is, incorrect positioning ignoring "ScopeOffset".
There has been no further progress on figuring out why specific weapons do or do not ignore the "ScopeOffset" property.
Screenshot with the default built in scope:


Code update: Simply swapped the modded prefab to the default game prefab

from "#@modfolder:Resources/2xmag.unity3d?2xmag.prefab" to "#Other/Items?Mods/Scopes/scope_2xPrefab.prefab"

Link to comment
Share on other sites

  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...