Jump to content

Buff ammo editing


RAGE PVE

Recommended Posts

Thanks @khzmusik for directing me here.

If I want to have a buff but want to specify the duration is the best way to do something like this below?  I want it specific to particular weapons basically.  Not sure if that append code there is correct

Would I need to type something like:
<append xpath="/buffs">
<buff name="buffBurningZombie" hidden="true">
        <damage_type value="heat"/>
        <stack_type value="ignore"/><duration value="0.1"/>
        <effect_group>
            <triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="$buffBurningElementDuration" operation="set" value="10"/>
            <triggered_effect trigger="onSelfBuffStart" action="AddBuff" buff="buffBurningElement"/>
        </effect_group>
    </buff>
 

Link to comment
Share on other sites

7 hours ago, RAGE PVE said:

Thanks @khzmusik for directing me here.

If I want to have a buff but want to specify the duration is the best way to do something like this below?  I want it specific to particular weapons basically.  Not sure if that append code there is correct

Would I need to type something like:
<append xpath="/buffs">
<buff name="buffBurningZombie" hidden="true">
        <damage_type value="heat"/>
        <stack_type value="ignore"/><duration value="0.1"/>
        <effect_group>
            <triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="$buffBurningElementDuration" operation="set" value="10"/>
            <triggered_effect trigger="onSelfBuffStart" action="AddBuff" buff="buffBurningElement"/>
        </effect_group>
    </buff>
 

 

I'm assuming you're not putting that, verbatim, into your own modlet's buffs.xml file, and that this is an example to get the general idea of what you want to do.

 

In your example, the buffBurningElement's duration is set by the buffBurningElementDuration cvar. That cvar is set to 10 before the buff is applied.

 

In general, if you are using a buff to add another buff, you should be able to first set whatever cvar that it uses for its duration (or any other effect that is determined by a cvar). But, make sure you look at the other buff, because it almost certainly modifies that cvar itself, and it might change that cvar to something you don't want after it starts.

 

In this example, the buffBurningElement buff automatically sets the buffBurningElementDuration to 10 when it starts, if it's below that value. So you couldn't make it a shorter duration than 10. It also will set the cvar to 10 (not add 10) when the buff stacks.

 

Also, that is not the only way (and probably not even the most common way) that buff durations are set. It's often a combination of stack_type and duration values. Using a cvar does allow for more control, which is probably why TFP use it here. For details on that, the comments at the end of buffs.xml are your friends.

 

EDIT: Here's a helpful hint. You can use the "</>" button to add code to posts. It makes the code much easier to read. Here's your code formatted as XML by the forums:

<append xpath="/buffs">
<buff name="buffBurningZombie" hidden="true">
        <damage_type value="heat"/>
        <stack_type value="ignore"/><duration value="0.1"/>
        <effect_group>
            <triggered_effect trigger="onSelfBuffStart" action="ModifyCVar" cvar="$buffBurningElementDuration" operation="set" value="10"/>
            <triggered_effect trigger="onSelfBuffStart" action="AddBuff" buff="buffBurningElement"/>
        </effect_group>
    </buff>

 

Edited by khzmusik (see edit history)
Link to comment
Share on other sites

11 hours ago, khzmusik said:

 

I'm assuming you're not putting that, verbatim, into your own modlet's buffs.xml file, and that this is an example to get the general idea of what you want to do.

 

In your example, the buffBurningElement's duration is set by the buffBurningElementDuration cvar. That cvar is set to 10 before the buff is applied.

 

In general, if you are using a buff to add another buff, you should be able to first set whatever cvar that it uses for its duration (or any other effect that is determined by a cvar). But, make sure you look at the other buff, because it almost certainly modifies that cvar itself, and it might change that cvar to something you don't want after it starts.

 

In this example, the buffBurningElement buff automatically sets the buffBurningElementDuration to 10 when it starts, if it's below that value. So you couldn't make it a shorter duration than 10. It also will set the cvar to 10 (not add 10) when the buff stacks.

 

Also, that is not the only way (and probably not even the most common way) that buff durations are set. It's often a combination of stack_type and duration values. Using a cvar does allow for more control, which is probably why TFP use it here. For details on that, the comments at the end of buffs.xml are your friends.

 

EDIT: Here's a helpful hint. You can use the "</>" button to add code to posts. It makes the code much easier to read. Here's your code formatted as XML by the forums:

 

Originally I added that code into the item file of the mod and renamed the buff name so that we had a new buff (perhaps should have been in buffs file) then I could edit the duration but I found the buff wouldn't fire so I scrapped that idea.  With it being a different name I assumed it would just add to the buffs file and use the same cvar but then I could change the duration and there would be no issues. 

One of the reasons to reduce was the user would get hit also if he missed a shot.  In the end however I managed to use onSelfAttackedOther in triggered effect which  stopped the user setting on fire on a miss; I am still curious on how to go about it but at least can move forward without for now. 

Also someone mentioned !entitytagcompare would also stop it hitting other players (if it does so already haven't tested that), hopefully that is correct, the current ammo is below:

Here I left the actionrayhit in as it shocks the player on a miss which is quite fun I find...probably need to add the entitytagcompare to stop use against other players but wanted to test it out first

<item name="Rageshockammo9mm">
            <property name="Tags" value="ammo"/>
            <property name="DisplayType" value="ammoBullet"/>
            <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="Material" value="Mbrass"/>
            <property name="MeltTimePerUnit" value=".4"/>
            <property name="Stacknumber" value="300"/><!-- STK ammo high -->
            <property name="EconomicValue" value="9"/>
            <property name="Group" value="Ammo/Weapons,Ammo,Ranged Weapons"/>
            <property name="CustomIcon" value="ammo9mmBulletBall"/>
            <property name="CustomIconTint" value="7AA543"/><!--Camo -->
            <effect_group name="ammo9mmBulletBall" tiered="false">
                <passive_effect name="EntityDamage" operation="base_set" value="32" tags="perkGunslinger,9mmGun"/>
                <passive_effect name="BlockDamage" operation="base_set" value="6" tags="perkGunslinger"/>
                <passive_effect name="DamageModifier" operation="perc_add" value="-.8" tags="earth"/>
                <passive_effect name="DamageModifier" operation="perc_add" value="2" tags="wood"/>
                <triggered_effect trigger="onSelfPrimaryActionRayHit " action="AddBuff" target="other" buff="buffShocked"/>
            </effect_group>
        </item>


Heres the burn ammo

	<item name="Rageburnzomammo9mm"><!-- Burn ammo -->
			<property name="Tags" value="ammo"/>
			<property name="DisplayType" value="ammoBullet"/>
			<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="Material" value="Mbrass"/>
			<property name="MeltTimePerUnit" value=".4"/>
			<property name="Stacknumber" value="300"/><!-- STK ammo high -->
			<property name="EconomicValue" value="9"/>
			<property name="Group" value="Ammo/Weapons,Ammo,Ranged Weapons"/>
			<property name="CustomIcon" value="ammo9mmBulletBall"/>
			<property name="CustomIconTint" value="A42ACC"/><!--Purple-->
			<effect_group name="ammo9mmBulletBall" tiered="false">
				<passive_effect name="EntityDamage" operation="base_set" value="32" tags="perkGunslinger,9mmGun"/>
				<passive_effect name="BlockDamage" operation="base_set" value="6" tags="perkGunslinger"/>
				<passive_effect name="DamageModifier" operation="perc_add" value="-.8" tags="earth"/>
				<passive_effect name="DamageModifier" operation="perc_add" value="2" tags="wood"/>
				<triggered_effect trigger="onSelfAttackedOther " action="AddBuff" target="other" buff="buffBurningZombie"/> <!-- onSelfAttackedOther seems to work best at not harming player-->
				<requirement name="!EntityTagCompare" tags="player"/> <!-- stops the ammo harming other players-->
			</effect_group>
		</item>


Next questions are:

How to make this craftable in a workstation
Can sound effects be added when buff ammo is used?

And lastly, I would really like to make a sniper ammo, basically it has 3 rounds, the first one is normal, second one is shock/stun (if there is a good stun buff?) ammo, third one is another normal round but this time it carries a x5 multiplier if a player scores a headshot whilst it hits an entity that has been hit with the shock buff, is that possible? 

Would be very satisfying to stun the enemy, then switch rounds line up the shot and hit a perfect headshot for the finish, or something along these lines......I think of the Vindicare Assasins from 40k when I picture this kind of thing.

Edited by RAGE PVE (see edit history)
Link to comment
Share on other sites

7 hours ago, RAGE PVE said:

Originally I added that code into the item file of the mod and renamed the buff name so that we had a new buff (perhaps should have been in buffs file) then I could edit the duration but I found the buff wouldn't fire so I scrapped that idea.  With it being a different name I assumed it would just add to the buffs file and use the same cvar but then I could change the duration and there would be no issues. 

 

I think there is some knowledge that you're missing about how XML and XPath work in the game. Maybe you know this and I misread what you wrote, but just to make sure, here's how it works.

 

The game scans the "Mods/[mod name]/Config" directories for XML files with names that exactly match the game's XML file names (the ones in the game's "Data/Config" directory). Most operating systems (basically everything other than Windows) are case sensitive with folder and file names, so it's best to match the game's case.

 

If such a file is found, the game reads that XML file for XPath operations. The initial "/" in XPath translates to "the root node of the game's matching XML file." So you can't put "/buffs" in your modlet's items.xml file and expect it to work; the game's items.xml file doesn't have a "buffs" tag, so that XPath won't match anything. You won't mess up anything, the game simply won't perform that XPath command, and you'll get a yellow warning in the console.

 

Also, I hope you already know this, but you can't put XPath commands in the game's XML files (the ones in "Data/Config"). XPath is only supported in the "Mods/[mod name]/Config" directories. Trying to put XPath in the game's XML files will mess things up; you'll almost certainly get red errors in the console, and it's possible the game won't even start.

 

7 hours ago, RAGE PVE said:

One of the reasons to reduce was the user would get hit also if he missed a shot.  In the end however I managed to use onSelfAttackedOther in triggered effect which  stopped the user setting on fire on a miss; I am still curious on how to go about it but at least can move forward without for now. 

Also someone mentioned !entitytagcompare would also stop it hitting other players (if it does so already haven't tested that)

 

You probably want to use "onSelfDamagedOther" rather than "onSelfAttackedOther".

 

Since that should only be triggered when you damage another entity, you probably won't need to compare tags. If other players are immune from damage, then the effect shouldn't trigger; but if they're not immune from damage (if the server allows friendly fire, for example), then you probably want the effect to trigger.

 

7 hours ago, RAGE PVE said:

Next questions are:

How to make this craftable in a workstation
Can sound effects be added when buff ammo is used?

And lastly, I would really like to make a sniper ammo, basically it has 3 rounds, the first one is normal, second one is shock/stun (if there is a good stun buff?) ammo, third one is another normal round but this time it carries a x5 multiplier if a player scores a headshot whilst it hits an entity that has been hit with the shock buff, is that possible?

 

To make it craftable at all, you'll need to create a recipe for it, and put that recipe into recipes.xml. To make it require the workbench, add craft_area="workbench" and tags="workbenchCrafting" to the recipe tag's attributes.

 

If you want the player to not know the recipe immediately, you'll need to add "learnable" to the tags. You'll then have to figure out how you want them to learn it. If you want them to learn it through a schematic, then you'll need to add that schematic as an item in items.xml, and you'll need to add that item to loot groups in loot.xml. If you want the recipe to be unlocked by a perk, then you'll need to add or modify that perk's "RecipeTagUnlocked" property; perks are in progression.xml.

 

For the sound effects, I assume you mean a different sound when the gun is fired with this ammo? If so, I don't know of any way to do that. I'm pretty sure the sounds are tied to the weapon, not the ammo. (You can, of course, trigger sounds when the buff fires, but if you're using vanilla fire/shock buffs then they probably are doing that already.)

 

For the last question, you could use a cvar that increments every time the gun is fired, and if it's greater than 2 it resets to 0 (so the values are 0, 1, and 2). The ammo buff would have three different triggered effects, each with a requirement that the cvar matches (so it triggers the shock buff if the cvar is 1 and a "headshot" buff if the cvar is 2; it wouldn't trigger anything if the cvar is 0). Make sure you also remove the previous buff each time you fire.

 

For a headshot buff, use the "DamageModifier" value of "head". See the comments in buffs.xml for details.

 

To make sure only the sniper rifle can use it, add the ammo to only the sniper rifle's "Magazine_items" property it items.xml.

 

EDIT: I forgot to add - if there is anything that is displayed to the user (like a recipe name or description) then you should add the text to the Localization.txt file. There is a thread in the tutorials section about how to do that.

Edited by khzmusik (see edit history)
Link to comment
Share on other sites

23 hours ago, khzmusik said:

 

I think there is some knowledge that you're missing about how XML and XPath work in the game. Maybe you know this and I misread what you wrote, but just to make sure, here's how it works.

 

The game scans the "Mods/[mod name]/Config" directories for XML files with names that exactly match the game's XML file names (the ones in the game's "Data/Config" directory). Most operating systems (basically everything other than Windows) are case sensitive with folder and file names, so it's best to match the game's case.

 

If such a file is found, the game reads that XML file for XPath operations. The initial "/" in XPath translates to "the root node of the game's matching XML file." So you can't put "/buffs" in your modlet's items.xml file and expect it to work; the game's items.xml file doesn't have a "buffs" tag, so that XPath won't match anything. You won't mess up anything, the game simply won't perform that XPath command, and you'll get a yellow warning in the console.

 

Also, I hope you already know this, but you can't put XPath commands in the game's XML files (the ones in "Data/Config"). XPath is only supported in the "Mods/[mod name]/Config" directories. Trying to put XPath in the game's XML files will mess things up; you'll almost certainly get red errors in the console, and it's possible the game won't even start.

 

 

You probably want to use "onSelfDamagedOther" rather than "onSelfAttackedOther".

 

Since that should only be triggered when you damage another entity, you probably won't need to compare tags. If other players are immune from damage, then the effect shouldn't trigger; but if they're not immune from damage (if the server allows friendly fire, for example), then you probably want the effect to trigger.

 

 

To make it craftable at all, you'll need to create a recipe for it, and put that recipe into recipes.xml. To make it require the workbench, add craft_area="workbench" and tags="workbenchCrafting" to the recipe tag's attributes.

 

If you want the player to not know the recipe immediately, you'll need to add "learnable" to the tags. You'll then have to figure out how you want them to learn it. If you want them to learn it through a schematic, then you'll need to add that schematic as an item in items.xml, and you'll need to add that item to loot groups in loot.xml. If you want the recipe to be unlocked by a perk, then you'll need to add or modify that perk's "RecipeTagUnlocked" property; perks are in progression.xml.

 

For the sound effects, I assume you mean a different sound when the gun is fired with this ammo? If so, I don't know of any way to do that. I'm pretty sure the sounds are tied to the weapon, not the ammo. (You can, of course, trigger sounds when the buff fires, but if you're using vanilla fire/shock buffs then they probably are doing that already.)

 

For the last question, you could use a cvar that increments every time the gun is fired, and if it's greater than 2 it resets to 0 (so the values are 0, 1, and 2). The ammo buff would have three different triggered effects, each with a requirement that the cvar matches (so it triggers the shock buff if the cvar is 1 and a "headshot" buff if the cvar is 2; it wouldn't trigger anything if the cvar is 0). Make sure you also remove the previous buff each time you fire.

 

For a headshot buff, use the "DamageModifier" value of "head". See the comments in buffs.xml for details.

 

To make sure only the sniper rifle can use it, add the ammo to only the sniper rifle's "Magazine_items" property it items.xml.

 

EDIT: I forgot to add - if there is anything that is displayed to the user (like a recipe name or description) then you should add the text to the Localization.txt file. There is a thread in the tutorials section about how to do that.

That's wonderful appreciate the assistance, I will also watch a series on how to edit, currently we have a couple guys helping us but were on different time zones and I'm kind of piggy backing on mods they have made and I'm just looking to create extensions atm so thought might be easy to do that but ahem!

Atm I have ammo all working nicely, the test weapons I place inside the same ammo file work in game perfectly but when I delete the test weapons and apply the buffammo to the items that are already in their own mods they don't pick the ammo up, does the ammo mod need to load before the weapons one or is there some pointing from the weapons mod to the ammo mod required or suchlike?

Sorry for any daft questions also, its my first time attempting a mod and I've not picked an easy one I guess :).  I will crack on with the xml series Max created though

Link to comment
Share on other sites

On 11/6/2022 at 2:09 PM, RAGE PVE said:

Atm I have ammo all working nicely, the test weapons I place inside the same ammo file work in game perfectly but when I delete the test weapons and apply the buffammo to the items that are already in their own mods they don't pick the ammo up, does the ammo mod need to load before the weapons one or is there some pointing from the weapons mod to the ammo mod required or suchlike?

 

I'm not sure I understand what you're asking. Are you saying that you have a mod that has the test weapons and your ammo; but it doesn't work with a different mod that adds new weapons?

 

If that's the case, then you should keep some things in mind:

 

  1. All mods/modlets load alphabetically according to folder name. So a mod in a folder named "MyMod" will load after "AMod" but before "SomeMod".
  2. There is no way for one mod to tell if another is loaded.

If you want your ammo to work with another mod's weapons, then you'll need to decide if you want the weapon mod to be a requirement for your ammo mod.

 

If so, the convention is to name your mod the same as the other, but add a descriptive suffix. So if the other mod is name "AwesomeWeapons" then you could name your mod 'AwesomeWeapons_AwesomeAmmo". You should also make it very, very clear to your users that the weapon mod is required. (There will be a good chance that they will ignore you, install it anyway without the other mod, then complain in these forums. :) )

 

If not, then you'll have no way to know if users have installed the weapon mod. Either you'll have to target the other mod's weapons anyway - which, if the user has not installed the other mod, will fail with console warnings about XPath not applying. Or you won't target the other mod's weapons, in which case either the other mod author or users themselves will have to make the other mod work with yours.

 

Make sense?

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