BadZombie
New member
Hi all,
I am trying to get a buff to play a sound when a specific number is output from the CraftingOutputCount value.
For example I have slot machine on my mod that uses buffs to generate odds/wins etc
First it generates a random number:
<triggered_effect trigger="onSelfBuffUpdate" action="ModifyCVar" cvar="$machineoutput" operation="setvalue" value="randomint(1,5)"/>
This cvar ticks constantly in the background...
Whenever a player crafts an item (read places a bet), whichever number this cvar is on at that precise moment determines the odds of winning.
If the number is between 1 and 4, the player loses, if it is on 5, the player wins.
It is basically a 1 in 5 chance of winning.
To limit losses I have included the following bit of code:
<triggered_effect trigger="onSelfBuffUpdate" action="ModifyCVar" cvar="$machineoutput" operation="setvalue" value="0.1"><!-- If random number is less than/equal to 40, set it to 10% of stake: 0.1 -->
<requirement name="CVarCompare" cvar="$machineoutput" operation="LTE" value="4"/><!-- value must match with multiplication range-->
</triggered_effect>
Which basically says if the number is between 1 and 4 give them 10% of their original stake back.
And then the output is as follows:
<passive_effect name="CraftingOutputCount" operation="perc_set" value="@$machineoutput" tags="SlotOdds1"/>
This works 100%. No issues.
What I would like to also include to enhance the gameplay is for a sound to play if the player wins.
Since CraftingOutputCount is the only way of knowing if the player has won or not I have tried using the following:
<triggered_effect trigger="onSelfBuffUpdate" action="PlaySound" sound="Slot_Open" play_in_head="true">
<requirement name="CraftingOutputCount" cvar="$machineoutput" operation="Equals" value="5"/>
</triggered_effect>
However, nothing works.
Calling on the cvar continually plays the sound over and over again since it is always ticking in the background.
I can't think of any other way to achieve this?
By calling on the values of CraftingOutputCount is it possible to add a buff with a sound?
Any help or suggestions appreciated
I am trying to get a buff to play a sound when a specific number is output from the CraftingOutputCount value.
For example I have slot machine on my mod that uses buffs to generate odds/wins etc
First it generates a random number:
<triggered_effect trigger="onSelfBuffUpdate" action="ModifyCVar" cvar="$machineoutput" operation="setvalue" value="randomint(1,5)"/>
This cvar ticks constantly in the background...
Whenever a player crafts an item (read places a bet), whichever number this cvar is on at that precise moment determines the odds of winning.
If the number is between 1 and 4, the player loses, if it is on 5, the player wins.
It is basically a 1 in 5 chance of winning.
To limit losses I have included the following bit of code:
<triggered_effect trigger="onSelfBuffUpdate" action="ModifyCVar" cvar="$machineoutput" operation="setvalue" value="0.1"><!-- If random number is less than/equal to 40, set it to 10% of stake: 0.1 -->
<requirement name="CVarCompare" cvar="$machineoutput" operation="LTE" value="4"/><!-- value must match with multiplication range-->
</triggered_effect>
Which basically says if the number is between 1 and 4 give them 10% of their original stake back.
And then the output is as follows:
<passive_effect name="CraftingOutputCount" operation="perc_set" value="@$machineoutput" tags="SlotOdds1"/>
This works 100%. No issues.
What I would like to also include to enhance the gameplay is for a sound to play if the player wins.
Since CraftingOutputCount is the only way of knowing if the player has won or not I have tried using the following:
<triggered_effect trigger="onSelfBuffUpdate" action="PlaySound" sound="Slot_Open" play_in_head="true">
<requirement name="CraftingOutputCount" cvar="$machineoutput" operation="Equals" value="5"/>
</triggered_effect>
However, nothing works.
Calling on the cvar continually plays the sound over and over again since it is always ticking in the background.
I can't think of any other way to achieve this?
By calling on the values of CraftingOutputCount is it possible to add a buff with a sound?
Any help or suggestions appreciated