File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
MethodSystem/Methods/NumberMethods Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ IsAllowed false
2828 end
2929
3030 # 50% chance to lose the coin
31- if {RandomNum 1 2 int} == 1
31+ if {Chance 50%}
3232 Hint @evPlayer 3s "{$hintInfo}Your coin has turned into dust..."
3333 AdvDestroyItem {@evPlayer heldItemRef}
3434 end
Original file line number Diff line number Diff line change 1+ using JetBrains . Annotations ;
2+ using SER . Code . ArgumentSystem . Arguments ;
3+ using SER . Code . ArgumentSystem . BaseArguments ;
4+ using SER . Code . MethodSystem . BaseMethods . Synchronous ;
5+ using SER . Code . MethodSystem . MethodDescriptors ;
6+ using SER . Code . ValueSystem ;
7+
8+ namespace SER . Code . MethodSystem . Methods . NumberMethods ;
9+
10+ [ UsedImplicitly ]
11+ public class ChanceMethod : ReturningMethod < BoolValue > , IAdditionalDescription
12+ {
13+ public override string Description =>
14+ "Generates a random number; returns true if it is less than your specified percentage threshold." ;
15+
16+ public override Argument [ ] ExpectedArguments { get ; } =
17+ [
18+ new FloatArgument ( "chance" , 0 , 1 )
19+ ] ;
20+
21+ public override void Execute ( )
22+ {
23+ ReturnValue = Args . GetFloat ( "chance" ) < UnityEngine . Random . Range ( 0f , 1f ) ;
24+ }
25+
26+ public string AdditionalDescription =>
27+ "In simple terms, when you use {Chance 20%}, it will return true 20% of the time." ;
28+ }
You can’t perform that action at this time.
0 commit comments