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

How do i add attachments a weapon in a starter kit?

BearMemo3

New member
So this is my xml for a starter bundle, but how to "spawn" the MP5N WITH attachments, like suppressor, optic, lamp etcetc....

Not like other "item" in my inventory from bundle.

From the bundle, give me the weapon with the accessories on it.

Code:
<configs>

<append xpath="/items">
<!-- PLAYER STARTING ITEM BUNDLE -->
	<item name="PlayerStarterKit">
		<property name="Extends" value="noteTestersDelightAdmin"/>
		<property name="DisplayInfo" value="PlayerStarterKit"/>
		<property name="DescriptionKey" value="PlayerStarterKitDesc"/>
		<property class="Action0">
			<property name="Class" value="OpenBundle"/>
			<property name="Delay" value="0"/>
			<property name="Sound_start" value="wrench_harvest"/>
			<property name="Create_item" value="armorScavengerHelmet,armorScavengerOutfit,armorScavengerGloves,armorScavengerBoots,medicalBandage,meleeToolTorch,vehicleBicyclePlaceable,medicalFirstAidKit,medicalSplint,meleeWpnBladeT1HuntingKnife,meleeToolPickT1IronPickaxe,meleeToolAxeT1IronFireaxe,meleeToolShovelT1IronShovel,drinkJarPureMineralWater,foodSteakAndPotato,MP5N,ammo9mmBulletBall"/>
			<property name="Create_item_count" value="1,1,1,1,3,1,1,2,1,1,1,1,1,2,2,1,450"/>
		</property>
	</item>

	<item name="PlayerHazardNote">
		<property name="CustomIconTint" value="1e8300" />
		<property name="Extends" value="noteDuke01"/>
		<property name="CreativeMode" value="Player"/>
		<property name="DisplayInfo" value="PlayerHazardNote"/>
		<property name="DescriptionKey" value="PlayerHazardNoteDesc"/>
		<property name="CustomIcon" value="challengeQuestMaster"/>
	</item>
</append>

</configs>
That is, so not like "Create_item" value=".......EOTech_EXPS3, pistolSuppressor,TAFlashLight(barrel),......." but to have these accessories on the weapon.
 
You can do this. Here is some code that will put a mod in an item to be found in the world.

Weapon mods: modGunSoundSuppressorSilencer

Weapon: SMG

///loot.xml
<!--ensure the smg spawns as level 6-->

<lootqualitytemplates>
<lootqualitytemplate name="MY_level6QualityTemplate">
<qualitytemplate level="0,999999" default_quality="6">
<loot quality="6" prob="1"/>
</qualitytemplate>
</lootqualitytemplate>
</lootqualitytemplates>


<lootgroup name="installedModsGroup" count="all" loot_quality_template="MY_level6QualityTemplate">
<item name="gunHandgunT3SMG5" mods="MY_Suppressor" mod_chance="1"/>
</lootgroup>

////end loot.xml

<!--add MY_Suppressor tag to the suppressor item_modifier-->

///item_modifiers.xml

<set xpath="/item_modifiers/item_modifier[@name ='modGunSoundSuppressorSilencer']/@modifier_tags">MY_Suppressor,barrelAttachment</set>

///END item_modifiers.xml




Pretty sure thats about it though may have missed something, its been a while.

Post again if it doesnt work and I'll see if I can sort it.

Cheers

 
Last edited by a moderator:
So I was playing with this and just extended it a bit. This is  more than you asked but I got fiddling.

Here is some code that defines a quest: quest_StarterCrateSpawn

If you give this quest to the player when they start (or whenever) it will spawn a supply crate (with parachute and all).

The Supply Create contains the start items including the level 6 smg with the suppressor mod attached.

///loot.xml
<!--ensure the smg spawns as level 6-->

<lootqualitytemplates>
<lootqualitytemplate name="MY_level6QualityTemplate">
<qualitytemplate level="0,999999" default_quality="6">
<loot quality="6" prob="1"/>
</qualitytemplate>
</lootqualitytemplate>
</lootqualitytemplates>


<lootgroup name="startSMGGroup" count="all" loot_quality_template="MY_level6QualityTemplate">
<item name="gunHandgunT3SMG5" mods="MY_Suppressor" mod_chance="1"/>
</lootgroup>
<lootgroup name="startLootGroup" count="all">
<item group="startSMGGroup" count="1"/>
<item name="other stuff" count="1"/>
<item name="other stuff2" count="1"/>
</lootgroup>

<lootcontainer name="starterDropCrate" count="1" size="8,4" destroy_on_close="true" sound_open="SupplyDrops/open_supply_crate" sound_close="SupplyDrops/close_supply_crate" loot_quality_template="qualBaseTemplate" ignore_loot_abundance="true">
<item group="startLootGroup"/>
</lootcontainer>
////end loot.xml


///item_modifiers.xml

<set xpath="/item_modifiers/item_modifier[@name ='modGunSoundSuppressorSilencer']/@modifier_tags">MY_Suppressor,barrelAttachment</set>

///END item_modifiers.xml


Entityclasses.xml:
<entity_class name="starterDropCrate">
<property name="Class" value="EntitySupplyCrate"/>
<property name="Parent" value="SupplyCrates"/>
<property name="Prefab" value="SupplyCrate"/>
<property name="Mesh" value="SupplyCrate/SupplyCrateEntityPrefab"/>
<property name="ModelType" value="SupplyCrate"/>
<property name="TintColor" value="00a9FF"/>
<property name="Faction" value="none"/>
<property name="MaxHealth" value="1200"/>
<property name="Weight" value="100"/>
<property name="HasRagdoll" value="false"/>
<property name="SurfaceCategory" value="wood"/>
<property name="ParticleOnDeath" value="supply_crate_gib_Prefab"/>
<property name="LootListAlive" value="starterDropCrate"/> <!--loot container is here-->
<property name="IsEnemyEntity" value="false"/>
<property name="SoundParachuteOpen" value="SupplyDrops/Parachute_Opens"/>
<property name="SoundLanding" value="SupplyDrops/Supply_Crate_Land"/>
<property name="TimeStayAfterDeath" value="0"/>
<effect_group name="Base Effects">
<passive_effect name="HealthMax" operation="base_set" value="1200"/>
</effect_group>
<property name="NavObject" value="supply_drop" />
<!-- If set this entity shows on the map -->
<property name="MapIcon" value="map_supply_crate"/>
</entity_class>

Entitygroups.xml:
<entitygroup name="starterDrop">
starterDropCrate
</entitygroup>

Localization.xml:
starterDropCrate,items,Supply Drop,,,"Starter Crate"

gamestages.xml:
<spawner name="StarterCrateSpawner">
<gamestage stage="1">
<spawn group="starterDrop" num="1" maxAlive="1" duration="1000"/>
</gamestage>
</spawner>
<group name="StarterCrateSpawner" emptyChance="0" decoyChance="0" decoy1hpChance="0">
<spawner name="StarterCrateSpawner" count="1"/>
</group>


quests.xml:
<quest id="quest_StarterCrateSpawn">
<property name="name_key" value="quest_StartCrateSpawn" param1="name" />
<property name="offer_key" value="quest_StartCrateSpawnDesc" param1="offer" />
<property name="description_key" value="quest_StartCrateSpawnDesc" param1="offer" />
<property name="subtitle_key" value="quest_StartCrateSpawnSubtitle"/> <!--this is what appears on screen top right during a quest-->
<property name="repeatable" value="true"/>
<property name="category_key" value="reward"/>
<property name="difficulty" value="medium"/>
<property name="shareable" value="true"/>
<action type="SpawnGSEnemy">
<property name="gamestage_list" value="StarterCrateSpawner" />
<property name="count" value="1" param1="finish_spawn_count" />
<property name="phase" value="1" />
</action>
<!--gather something from the crate to the quest doesnt end until the player finds and opens the crate-->
<objective type="FetchKeep" id="someItemFromTheStarterPack" value="1" phase="1"/>
</quest>




Just some thoughts

cheers

 
Last edited by a moderator:
Just some thoughts

cheers


For the tags, would append or csv be better than set so all you need to do in your code is add the new tag to the existing tags?    That way you would not have to worry if any of the tags change in the future and could use the same code for every item you want to add your custom tag to, including other mods.

 
For the tags, would append or csv be better than set so all you need to do in your code is add the new tag to the existing tags?    That way you would not have to worry if any of the tags change in the future and could use the same code for every item you want to add your custom tag to, including other mods.
That would be the correct thing to do. I wrote the code a while ago, I dont remember exactly but I believe I tried the 'append' and it didnt work, it had issues with appending to a string. ("MY_Suppressor,barrelAttachment"). In general <append> is adding whole elements or strings to other parent-elements. In this case we are appending a string to a string within an element.

edit: so it looks like this <"barrelAttachment" ",MY_Suppressor"> instead of <"barrelAttachment,MY_Suppressor"> , 2 strings in the element instead of 1.

But this is just my thoughts from playing around with it, I wouldnt have spent much time trying to resolve it (maybe syntax issue on my part etc)

I would suggest just trying it with the full <set> to get it working then try just <append> and see if it still works but I seem to remember that there was a reason I coded it that way at the time.

Cheers

 
Last edited by a moderator:
Just add add something, the supply crate spawn is used in the Grim Tales mod and also includes the overhead airplane sound.

To add the airplane sound amend the quests code and add some supporting code:

The following defines a buff called buff_airplaneSound, give this buff to the player on startup before the quest and an airplane will sound overhead like it dropped the supply crate. The buff deletes itself after it has played the overhead sound.

quests.xml:
<quest id="quest_StarterCrateSpawn">
<property name="name_key" value="quest_StartCrateSpawn" param1="name" />
<property name="offer_key" value="quest_StartCrateSpawnDesc" param1="offer" />
<property name="description_key" value="quest_StartCrateSpawnDesc" param1="offer" />
<property name="subtitle_key" value="quest_StartCrateSpawnSubtitle"/> <!--this is what appears on screen top right during a quest-->
<property name="repeatable" value="true"/>
<property name="category_key" value="reward"/>
<property name="difficulty" value="medium"/>
<property name="shareable" value="true"/>

///new stuff - this will trigger the listening buff (buff_airplaneSound) defined below to start the sound playing///
<action type="SetCVar">
<property name="cvar" value="playSupplyCrateAirplaneSound" />
<property name="value" value="1" />
</action>
///new stuff////

<action type="SpawnGSEnemy">
<property name="gamestage_list" value="StarterCrateSpawner" />
<property name="count" value="1" param1="finish_spawn_count" />
<property name="phase" value="1" />
<!--NEW CODE - add delay so that the airplane sound can play for a couple seconds before the drop-->
<property name="delay" value="6"/>
</action>
<!--gather something from the crate so the quest doesnt end until the player finds and opens the crate-->
<objective type="FetchKeep" id="someItemFromTheStarterPack" value="1" phase="1"/>
</quest>

gameevents.xml:
<action_sequence name="action_AirplaneSoundStart">
<action class="PlaySound">
<property name="sound" value="distantAirplaneSound" />
<property name="loop_duration" value="20"/> <!--this is where you adjust the length of time the airplane sound plays for-->
<property name="phase" value="1" />
</action>
</action_sequence>

sounds.xml:
<SoundDataNode name="distantAirplaneSound"> <AudioSource name="Sounds/AudioSource_Distant"/>
<Noise ID="5" noise="0" time="3" heat_map_strength="0" heat_map_time="0"/>
<AudioClip ClipName="Sounds/SupplyDrops/Supply_Crate_Plane_lp" Loop="true"/>
<IgnoreDistanceCheck/>
<LocalCrouchVolumeScale value="0.5"/> <CrouchNoiseScale value="0.5"/> <NoiseScale value="1"/> <MaxVoices value="3"/> <MaxRepeatRate value="0.01"/> </SoundDataNode>

buffs.xml
<buff name="buff_airplaneSound" hidden="true" remove_on_death="true" >
<stack_type value="ignore"/>
<duration value="0"/>
<effect_group>
<!--wait for trigger-->
<requirement name="CVarCompare" cvar="playSupplyCrateAirplaneSound" operation="GTE" value="1"/>
<triggered_effect trigger="onSelfBuffUpdate" action="CallGameEvent" event="action_AirplaneSoundStart"/>
<!--remove after use-->
<triggered_effect trigger="onSelfBuffUpdate" action="RemoveBuff" buff="buff_airplaneSound"/>
</effect_group>

<!--cleanup-->
<effect_group>
<triggered_effect trigger="onSelfBuffRemove" action="RemoveCVar" cvar="playSupplyCrateAirplaneSound"/>
</effect_group>
</buff>




Cheers

 
Last edited by a moderator:
That would be the correct thing to do. I wrote the code a while ago, I dont remember exactly but I believe I tried the 'append' and it didnt work, it had issues with appending to a string. ("MY_Suppressor,barrelAttachment"). In general <append> is adding whole elements or strings to other parent-elements. In this case we are appending a string to a string within an element.

edit: so it looks like this <"barrelAttachment" ",MY_Suppressor"> instead of <"barrelAttachment,MY_Suppressor"> , 2 strings in the element instead of 1.

But this is just my thoughts from playing around with it, I wouldnt have spent much time trying to resolve it (maybe syntax issue on my part etc)

I would suggest just trying it with the full <set> to get it working then try just <append> and see if it still works but I seem to remember that there was a reason I coded it that way at the time.

Cheers
I got one of my mods coded that way, I will check them and see if I can locate the code example.  I should have it also in the new csv format.

 
I got one of my mods coded that way, I will check them and see if I can locate the code example.  I should have it also in the new csv format.
If you were able to post the code that would be helpful to both myself and anyone else who might read the thread.

cheers

 
If you were able to post the code that would be helpful to both myself and anyone else who might read the thread.

cheers


Here is how I did it with append (A21)

    <append xpath="/items/item[@name='gunRifleT0PipeRifle']/property[@name='Tags']/@value">,PipeRifle,noMods</append>    




Here is how I did it with csv (V1.x)

Code:
    <csv xpath="//item[contains(@name,'T0')]/property[@name='Tags']/@value" delim="," op="add">noMods</csv>
 
BFT2020 said:
Here is how I did it with append (A21)

    <append xpath="/items/item[@name='gunRifleT0PipeRifle']/property[@name='Tags']/@value">,PipeRifle,noMods</append>    




Here is how I did it with csv (V1.x)

    <csv xpath="//item[contains(@name,'T0')]/property[@name='Tags']/@value" delim="," op="add">noMods</csv>



Thanks for that, look straightforward. Am now thinking it was my code that was the issue - I had an Invalid String Error.

Looks like I have some code cleanup in my near future...

Cheers

 
Back
Top