• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

gun attachments .

random person

New member
i woke up in the morning and said to my self, i am not waiting for alpha 17 to upgrade my guns , so i started modding .

i started with the scope , the results were nice

screenshot 1.jpg

but i had a little problem, the scope was there if its either attached or not

screenshot 3.jpg

screenshot5.jpg

screenshot 2.png

<item id="48" name="gunAK47">

<property name="Meshfile" value="#AK47?AK47"/>

<property name="Material" value="metal"/>

<property name="RepairTools" value="repairKit"/>

<property name="HoldType" value="48"/>

<property name="DegradationBreaksAfter" value="false"/>

<property name="SoundJammed" value="weapon_jam"/>

<property name="Attachments" value="Scope"/>

<property name="CrosshairOnAim" value="false"/> <!-- aimTest -->

<property name="CrosshairUpAfterShot" value="true"/> <!-- aimTest -->

<property class="Parts">

<property name="Stock" value="partsAK47_stock"/>

<property name="Receiver" value="partsAK47_receiver"/>

<property name="Pump" value="partsAK47_parts"/>

<property name="Barrel" value="partsAK47_barrel"/>

</property>

<property name="Sound_Sight_In" value="rifle_sight_in"/>

<property name="Sound_Sight_Out" value="rifle_sight_out"/>

<property class="Action0"> <!-- AttackAction -->

<property name="Class" value="Ranged"/>

<property name="Delay" value="0.150"/>

<property name="Auto_fire" value="true"/>

<property name="Crosshair_min_distance" value="13"/> <!-- 13 -->

<property name="Crosshair_max_distance" value="16"/> <!-- 16 -->

<property name="Magazine_size" value="30"/>

<property name="Magazine_items" value="762mmBullet"/>

<property name="Magazine_item_ray_counts" value="1"/>

<property name="Magazine_item_ray_spreads" value="0"/>

<property name="Reload_time" value="3.9"/>

<property name="Bullet_icon" value="uzi"/>

<property name="Sound_start" value="ak47_fire_start"/>

<property name="Sound_repeat" value="Weapons/Ranged/AK47/ak47_fire_lp"/>

<property name="Sound_end" value="Weapons/Ranged/AK47/ak47_fire_end"/>

<property name="Sound_empty" value="weapon_empty"/>

<property name="Sound_reload" value="ak47_reload"/>

<property name="Horde_meter_rate" value="2.5"/>

<property name="Horde_meter_distance" value="20"/>

<property name="Particles_muzzle_fire" value="nozzleflash_ak"/>

<property name="Particles_muzzle_smoke" value="nozzlesmokeuzi"/>

<property name="DamageBonus.head" value="3"/>

<property name="DamageBonus.wood" value="5"/>

<property name="DamageBonus.earth" value="0.2"/>

<property name="DamageBonus.glass" value="1"/>

<property name="Buff" value="critGunAK47"/>

<property name="Buff_chance" value="0.1"/>

<property name="ActionExp" value="1"/>

</property>

<property class="Action1"> <!-- UseAction -->

<property name="Class" value="Zoom"/>

<property name="Zoom_overlay" value="Items/Weapons/HUD/sniper_zoom_overlay"/>

<property name="Zoom_max_out" value="40"/>

<property name="Zoom_max_in" value="15"/>

</property>

<property name="LightSource" value="Scope"/> <!-- Start: Needed for the attachment flashlight -->

<property name="ActivateObject" value="Scope"/>

<property name="AttachmentFlashlight" value="Scope"/> <!-- End: Needed for the attachment flashlight -->

<property name="Group" value="Ammo/Weapons"/>

<property name="ActionSkillGroup" value="Rifles"/>

<property name="CraftingSkillGroup" value="craftSkillGuns"/>

<property name="RepairExpMultiplier" value="10.8"/>

<property name="LightValue" value="0.45"/>

</item>

what am i doing wrong ?

 
Not sure, as I have not messed with attachments in Unity, but try unchecking the scope child object to deactivate it before you export the .unity3d file. That way it defaults to no attachment visible.

 
Not sure, as I have not messed with attachments in Unity, but try unchecking the scope child object to deactivate it before you export the .unity3d file. That way it defaults to no attachment visible.
nope , now the scope isnt there anymore even when its attached .

 
Last edited by a moderator:
So some code needs to run in order to "show" the scope; my guess is that the code is already in the game, you just need to have the right object name and placement in the tree for it to activate.

 
So some code needs to run in order to "show" the scope; my guess is that the code is already in the game, you just need to have the right object name and placement in the tree for it to activate.
i know the function exists , i saw pacco using it in his sdx ranged weapons guide to add a flashlight , but in his video its apears when it assembled to the gun and doesnt apear when its not , but in my case its always there .

 
Like Guppy said, you probably cant do what your trying without custom code. That's how we add scopes in Starvation. Add them as a child object and turn that object on and off in code.

In the case of the flashlight, the code is already available via xml.

<property name="LightSource" value="lightSource"/> <!-- Start: Needed for the attachment flashlight -->

<property name="ActivateObject" value="Attachments/flashlight/lightSource"/>

<property name="AttachmentFlashlight" value="flashlight02"/> <!-- End: Needed for the attachment flashlight -->

Pacco used the child name Lightsource, so vanilla code toggle that attachment on and off, and the activate line turns the light on and off.

 
Like Guppy said, you probably cant do what your trying without custom code. That's how we add scopes in Starvation. Add them as a child object and turn that object on and off in code.
In the case of the flashlight, the code is already available via xml.

<property name="LightSource" value="lightSource"/> <!-- Start: Needed for the attachment flashlight -->

<property name="ActivateObject" value="Attachments/flashlight/lightSource"/>

<property name="AttachmentFlashlight" value="flashlight02"/> <!-- End: Needed for the attachment flashlight -->

Pacco used the child name Lightsource, so vanilla code toggle that attachment on and off, and the activate line turns the light on and off.
youre right, i tried with a flashlight and it worked, but do you have any coding guides?

where did you learn coding?

as i said i am not waiting for alpha 17 to upgrade my guns.

 
Last edited by a moderator:
Tbh, I just had 2 different gun types. One scoped (with it's own assemble recipe) and one without the scope (again, with it's own assemble recipe).

It seems to be the best way around it.

 
Back
Top