Jump to content

(item_modifier.xml) Use a CVAR to roll a value and then use that CVAR as an entry


Recommended Posts

Hello! I am looking for some assistance on an item_modifier idea.

The idea: an item_modifier when created, has a CVAR that rolls a value between 10 to 25, that CVAR value then can be used for a passive_effect value entry, and a display_type value entry:

<!-- Create a CVAR and roll a value within a range. -->
<!-- cvar="rolled_value" -->
<!-- value="randomint(10,25)" -->

<!-- Use the CVAR for the value's entry -->
<passive_effect name="EntityDamage" operation="perc_add" value="@rolled_value"/>
<display_value name="dEntityDamage" value="@rolled_value"/>

 

 

Note, I cant do something like this:

<passive_effect name="EntityDamage" operation="perc_add" value="randomint(10,25)"/>
<display_value name="dEntityDamage" value="randomint(10,25)"/>

Because, for example, if the passive_effect rolled a 15, and the display_value rolled a 21, when you equip the item_mod to an item, you'd actually get 15% Entity Damage, but the text on the item would display 21.

 

 

This may sound silly, but am I to use the triggered_effect tag for generating and rolling a value? So something like this:

<triggered_effect trigger="???" action="ModifyCVar" cvar="rolled_value" operation="set" value="randomint(10,25)"/>
<passive_effect name="EntityDamage" operation="perc_add" value="@rolled_value"/>
<display_value name="dEntityDamage" value="@rolled_value"/>

If so, what would I want to use as the trigger entry value?

 


Thanks for the read!

Link to comment
Share on other sites

Yes you have to use a triggered effect to set or edit a cvar.

 


				<triggered_effect trigger="onSelfEquipStart" action="ModifyCVar" cvar="CustomDroneLightPlayer" operation="set" value="0"/>


That's part of my mod. It will work for your case, but in this instance, when player holds the drone to deploy it, it will set the cvar CustomDroneLightPlayer. You can have a onSelfEquipStop to remove it. Do note that each time you equip and unequip, your cvar will randomly roll again. I'm not sure what your end game is for it, but if its a one time roll, you can put a requirement check for cvar being higher than 0 before the roll. That way, if you have equipped the item before, it will not re roll... Though that then raises more issues with w/e item you're using this for becomes upgraded or something, the cvar won't reroll... Without knowing the exact plans, this is about as far as I can offer. lol.

Link to comment
Share on other sites

 

3 hours ago, Telric said:

Yes you have to use a triggered effect to set or edit a cvar.
 

<triggered_effect trigger="onSelfEquipStart" action="ModifyCVar" cvar="CustomDroneLightPlayer" operation="set" value="0"/>


That's part of my mod. It will work for your case, but in this instance, when player holds the drone to deploy it, it will set the cvar CustomDroneLightPlayer. You can have a onSelfEquipStop to remove it. Do note that each time you equip and unequip, your cvar will randomly roll again. 

 

Thanks for the info! I think I'm understanding how to set it up!
 

  

3 hours ago, Telric said:

I'm not sure what your end game is for it, but if its a one time roll, you can put a requirement check for cvar being higher than 0 before the roll. That way, if you have equipped the item before, it will not re roll... Though that then raises more issues with w/e item you're using this for becomes upgraded or something, the cvar won't reroll... Without knowing the exact plans, this is about as far as I can offer. lol.

It is to be a one time roll, and not an upgradable Item Modifier.


The goal is to have an Item Modifier that when created, rolls a value within a range. That value would be used for the passive_effect, and display_value tags.

Lets use the existing Bunker Buster mod as an example, it currently grants a 15% Damage Modifier to Stone. Now lets say I want to make it so that Bunker Buster, when it is created (via from Looting, or Crafted) would roll a value between 15 to 25. So if you find a Bunker Buster item modifier, it would be any value between 15% to 25% Damage Modifier to Stone. So you might have one with 17%, a second one with 24% and a third with 22%, you could be lucky and the first one you find might have a value of 25% (perfect roll).

 

 

I have yet to test this, and it might fail, due to the item being created, but the CVAR not being created until onSelfEquipStart occurs (Displaying / Using a value that isnt created yet)

<configs>
<append xpath="/item_modifiers">
<item_modifier name="modWeaponGemstoneBrutality" installable_tags="melee,archery" modifier_tags="gemstone_brutality" blocked_tags="noMods" type="attachment">
	<property name="Extends" value="modGeneralMaster"/>
	<property name="CustomIcon" value="modWeaponGemstoneBrutality"/>
	<property name="DisplayType" value="modGemstoneBrutality"/>
	<property name="DescriptionKey" value="modWeaponGemstoneBrutalityBasicDesc"/>
	<effect_group>
		<!-- Roll a value between 10 to 25 -->
		<triggered_effect trigger="onSelfEquipStart" action="ModifyCVar" cvar="rolled_value" operation="set" value="randomint(10,25)">
			<requirement name="CVarCompare" cvar="rolled_value" operation="GT" value="0"/>
		</triggered_effect>
		
		<!-- Use the rolled value for Passive Effect and Displaying of Value -->
		<passive_effect name="EntityDamage" operation="perc_add" value="@rolled_value"/>
		<display_value name="dEntityDamage" value="@rolled_value"/>
	</effect_group>
</item_modifier>
</configs>
</append>

 

Link to comment
Share on other sites

Can you not use the way vanilla uses for items?

 

<passive_effect name="EntityDamage" operation="perc_add" value="-.15,.15" tags="perkJavelinMaster"/>



The problem with the randomroll stuff is it's applied to the player. So that requirement is on the player, not the item. Once you roll that number, that number is applied to the player, meaning any items equipped after that will still have that first randomroll. So if you have two different item modifier items, equipping the 2nd will do nothing, unless you reset the cvar on the player, which then if you equip the first item modifier again, it will reroll, making that item not feel like the same item. What you'll need is a way to do this on the item itsself...

Under the buff reference stuff, you have this:

 

Quote

        RandomRoll:             target, min_max, operation, value, seed_type, seed_additive
                seed_type:        Item, Player, Random
                                Random is the default in most cases. A simple random number.
                                Player is the static seed of this player on this map. You can create random "genetic" effects that permanently remain with this player.
                                Item uses a seed that is generated based on creation time of the item. (so yes, that could detect dupes with some certainty, you're welcome)



So you might could use that in some way. Ive done 0 randomrolls using an items ID, so you're on your own for that part, but there's an idea.

Link to comment
Share on other sites

5 hours ago, Telric said:

Can you not use the way vanilla uses for items?

<passive_effect name="EntityDamage" operation="perc_add" value="-.15,.15" tags="perkJavelinMaster"/>

 

 

I wanna do this, but the issue I ran into using that method, is I cant find a way for display_value to read passive_effect's value.

item_modifier.xml


<configs>
<append xpath="/item_modifiers">
<item_modifier name="modWeaponGemstoneBrutality" installable_tags="melee,archery" modifier_tags="gemstone_brutality" blocked_tags="noMods" type="attachment">
	<!-- When the player hovers over the item, it shows the item's stats -->
	<property name="DisplayType" value="modGemstoneBrutality"/>
  
  	<!-- Effect and Display-->
	<effect_group>
		<passive_effect name="EntityDamage" operation="perc_add" value="10,25"/>
		<display_value name="dEntityDamage" value="[READ FROM PASSIVE_EFFECT PLZ]"/>
	</effect_group>
</item_modifier>
</configs>
</append>

 

ui_display.xml

<configs>
<append xpath="ui_display_info/item_display">
	<item_display_info display_type="modGemstoneBrutality" display_group="modAttire">
		<display_entry name="dEntityDamage" title_key="statEntityDamageMelee" display_type="Percent" display_leading_plus="true" />
		<display_entry name="dEntityDamage" title_key="statEntityDamageRanged" display_type="Percent" display_leading_plus="true" />
	</item_display_info>
</append>
</configs>

 

 

Here is what it should look like in-game, but instead of 0% it would/should display the passive_effect's value:

image.png.50cbbeab4d14dd58b9d40d0b9965a328.png

 

 

6 hours ago, Telric said:

The problem with the randomroll stuff is it's applied to the player. So that requirement is on the player, not the item. Once you roll that number, that number is applied to the player, meaning any items equipped after that will still have that first randomroll. So if you have two different item modifier items, equipping the 2nd will do nothing, unless you reset the cvar on the player, which then if you equip the first item modifier again, it will reroll, making that item not feel like the same item. What you'll need is a way to do this on the item itsself...

Quote

        RandomRoll:             target, min_max, operation, value, seed_type, seed_additive
                seed_type:        Item, Player, Random
                                Random is the default in most cases. A simple random number.
                                Player is the static seed of this player on this map. You can create random "genetic" effects that permanently remain with this player.
                                Item uses a seed that is generated based on creation time of the item. (so yes, that could detect dupes with some certainty, you're welcome)


So you might could use that in some way. Ive done 0 randomrolls using an items ID, so you're on your own for that part, but there's an idea.

Ahhh, I see, I'll look into messing around with RandomRoll / seed_type.

Link to comment
Share on other sites

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...