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

Random stats on a weapon

Vanblam

New member
I was curious if there is a way to apply a random stat or ability to a weapon upon picking it up? For example, say I find a club that gives me +1 to strength.

 
The only way I could think to do this is to just create many copies of the same weapon with the multiple "Random" stats. Then add to the loot list.

 
vanilla item apparelCigar has the following:

Code:
<effect_group tiered="false">
<passive_effect name="ModSlots" operation="base_set" value="0"/>
<passive_effect name="AttributeLevel" tags="attStrength" operation="base_add" value="1"/>
<passive_effect name="BarteringBuying" operation="base_add" value=".1"/>
<passive_effect name="BarteringSelling" operation="base_add" value=".1"/>
</effect_group>
As for whether it is possible to apply random effect, I don't know, try to ask Snufkin about this. He's like a lego builder of 7 Days to Die assets lol

 
There should also be something similar right at the top of the items (or item mod?) file.

 
Last edited by a moderator:
Ok, I'm not good at this, but I found this line in vanilla items.xml:

Code:
<passive_effect name="EntityDamage" operation="perc_add" value="-.15,.15"/> <!-- random EntityDmg -->
See the comment "random EntityDmg"? Would this randomizer work also on various stats? If so, perhaps, you could just create an item which would boost all the applicable values you want by random values from maybe 0 to 1 or so? So in theory, as a result the item would have a chance to give you +1 to Strength? Just an idea, I haven't tested this, again I'm not good at this lol

 
First.. thanks for asking this question. It made me discover some cool stuff I will be taking advantage of in the near future.

The answer lies in the Shades...

TFP commented it out but it seems to work in very brief testing...

The Shades Item

Code:
<item name="apparelShades"> <!-- item name directly referenced in the code -->
   <property name="Tags" value="head,clothing,canHaveCosmetic"/>
   <property name="DisplayType" value="clothingShades"/>
   <property name="Stacknumber" value="1"/>
   <property name="Material" value="Mmetal"/>
   <property name="DegradationBreaksAfter" value="false"/>
   <property name="Encumbrance" value="0"/>
   <property name="Weight" value="5"/>
   <property name="EconomicValue" value="500"/>
   <property name="HoldType" value="45"/>
   <property name="Meshfile" value="#Other/Items?Misc/sackPrefab.prefab"/>
   <property name="DropMeshfile" value="#Other/Items?Misc/sack_droppedPrefab.prefab"/>
   <property name="EquipSlot" value="Eyes"/>
   <property name="Group" value="Clothing"/>
   <property class="UMA">
   <property name="Mesh" value="gear_shades"/>
   <property name="Overlay0" value="gear_shades"/>
   <property name="Layer" value="1"/>
   <property name="UISlot" value="Eyewear"/>
</property>
<effect_group tiered="false">
   <passive_effect name="ModSlots" operation="base_set" value="0"/>

       <!--
       <passive_effect name="AttributeLevel" tags="attPerception" operation="base_add" value="1">
           <requirement name="RandomRoll" seed_type="Item" min_max="1,100" operation="LTE" value="88"/>
           <triggered_effect trigger="onSelfBuffUpdate" action="ModifyCVar" cvar="$VarTest" operation="setvalue" value="randomfloat(12,13)"/>
       </passive_effect>

       <passive_effect name="AttributeLevel" tags="attPerception" operation="base_add" value="2">
           <requirement name="RandomRoll" seed_type="Item" min_max="1,100" operation="GT" value="88"/>
           <requirement name="RandomRoll" seed_type="Item" min_max="1,100" operation="LTE" value="99"/>
       </passive_effect>

       <passive_effect name="AttributeLevel" tags="attPerception" operation="base_add" value="3">
           <requirement name="RandomRoll" seed_type="Item" min_max="1,100" operation="GT" value="99"/>
       </passive_effect>
   -->

   <passive_effect name="AttributeLevel" tags="attPerception" operation="base_add" value="1"/>

</effect_group>
</item>
The relevant part is here

Code:
<!--
   <passive_effect name="AttributeLevel" tags="attPerception" operation="base_add" value="1">
       <requirement name="RandomRoll" seed_type="Item" min_max="1,100" operation="LTE" value="88"/>
       <triggered_effect trigger="onSelfBuffUpdate" action="ModifyCVar" cvar="$VarTest" operation="setvalue" value="randomfloat(12,13)"/>
   </passive_effect>

   <passive_effect name="AttributeLevel" tags="attPerception" operation="base_add" value="2">
       <requirement name="RandomRoll" seed_type="Item" min_max="1,100" operation="GT" value="88"/>
       <requirement name="RandomRoll" seed_type="Item" min_max="1,100" operation="LTE" value="99"/>
   </passive_effect>

   <passive_effect name="AttributeLevel" tags="attPerception" operation="base_add" value="3">
       <requirement name="RandomRoll" seed_type="Item" min_max="1,100" operation="GT" value="99"/>
   </passive_effect>
-->
I'm still figuring out how this works exactly.. I thought I had it, but I was wrong.

 
Last edited by a moderator:
The method used with the shades surely is a possibility, but is a little overkill. Just use the method posted by Mr.Devolver:

Code:
"<passive_effect name="AttributeLevel" tags="attPerception" operation="base_add" value="0.1,1.9"/>"
I made sure it works by testing it just now. This would give perception+1 in 50% of the weapons you find. BUT the buff only works if you have the weapon equipped i.e. in your hand.

 
The advantage of the passive is that it's easy to display on the item stats.

For complex mechanics like a weapon having a unique but random proc buff you should create an item mod for each such effect with type="mod".

Then edit loot so that your item always spawns with this mod preinstalled.

This way you can have multiple variants of your mod with completely different setups complete with item descriptions and stats pages.

 
The advantage of the passive is that it's easy to display on the item stats.
For complex mechanics like a weapon having a unique but random proc buff you should create an item mod for each such effect with type="mod".

Then edit loot so that your item always spawns with this mod preinstalled.

This way you can have multiple variants of your mod with completely different setups complete with item descriptions and stats pages.
Nice, will the passive show up under the item's stat list or would you need to make a minor modification to one of the UI xml files?

 
it is possible to make it. BTW you can use inheritance in items.xml i.e you have a gun with all attributes and specs, and you have lots of children right after it with single tag for your desired bonus, so no need for randomising the stuff, loot randomiser will do it for you. Or you will play with one and only item, but I didn't find a way to make it add only one attribute a time, so you can end up finding a gun with all attributes +1, where you only wanted it to grant not more than one per item.

 
The method used with the shades surely is a possibility, but is a little overkill. Just use the method posted by Mr.Devolver:

Code:
"<passive_effect name="AttributeLevel" tags="attPerception" operation="base_add" value="0.1,1.9"/>"
I made sure it works by testing it just now. This would give perception+1 in 50% of the weapons you find. BUT the buff only works if you have the weapon equipped i.e. in your hand.
What item did you test this on?

I found that I couldnt get the stats to work unless the "DisplayType" property defined in ui_Display.xml was pointing at a display type that showed that value.

I.E

Code:
<display_entry name="AttributeLevel" tags="attPerception" title_key="statShowPerception" display_leading_plus="true"/>
 
Last edited by a moderator:
What item did you test this on?

I found that I couldnt get the stats to work unless the "DisplayType" property defined in ui_Display.xml was pointing at a display type that showed that value.

I.E

Code:
<display_entry name="AttributeLevel" tags="attPerception" title_key="statShowPerception" display_leading_plus="true"/>
I tested it first on leather armor, then, because I remembered that OP asked about a weapon, on a pistol.

Note I didn't test if I could see it displayed on the items, I only looked at the resulting Perception attribute in my skill-page

 
Last edited by a moderator:
Thanks, guys for looking into this, I just figured if you could discover items that had some random bonuses (besides item level) it could become more immersive.

 
As far as I know something similar is already planned by TFP: legendary weapons. Among the random boni I would expect attribute buffs as well.
I kept bombing them with requests for something similar for ages, but I don't expect them to implement this any time soon. What I had in mind was a system for random mods already pre-installed on the items you find in the loot or in trader's inventory. Maybe such system could also be extended to give certain random attributes too, like special baseball bat that has some heavy weight mod installed on it, plus gives you strength +1 bonus. And if you could find such items with random mods installed and random stats, that would be pretty cool.

 
What is the advantage of the mod in the weapon when you can remove it immediately? Just add a mod as a separate item to find and be done with it.

As far as I know the idea with preinstalled mods was already thought about and maybe even implemented partly by TFP. They finally rejected it (maybe at the same time when they decided not to make them permanently fixed in the weapon). And in that case you can forget about bombing them.

 
Last edited by a moderator:
Back
Top