|
1 | | -# open.mp Easing-Functions Component |
| 1 | +# Pawn Randomix |
2 | 2 |
|
3 | | -An open.mp server component that adds textdraw easing and animation functionality. |
4 | | -It is essentially a component-based version of the original |
5 | | -[pawn-easing-functions](https://github.com/alexchwoj/pawn-easing-functions.git) by [alexchwoj](https://github.com/alexchwoj), with improvements and optimized performance for large-scale animations. |
6 | | - |
7 | | ---- |
| 3 | +Enhanced random number generator and utility for open.mp servers (SA-MP support planned), providing a PRNG (PCG32) for game mechanics and a CSPRNG (ChaCha20) for cryptographic security. |
8 | 4 |
|
9 | 5 | ## Installation |
10 | 6 |
|
11 | | -1. Go to the **Releases** page and download the archive or binary matching your server platform (Windows `.dll`, Linux `.so`). |
12 | | -2. Extract it and place the component file into your open.mp server `components/` directory. |
13 | | -3. Copy `omp_easing.inc` into the include directory used by your Pawn compiler (e.g. `gamemodes/qawno/include/`). |
14 | | -4. Add |
15 | | - |
16 | | - ```pawn |
17 | | - #include <omp_easing> |
18 | | - ``` |
19 | | - |
20 | | - to any script where you want to use easing native functions, then recompile your scripts. |
21 | | - |
22 | | ---- |
| 7 | +1. Download component binary for your platform (Windows `.dll`, Linux `.so`) |
| 8 | +2. Place in server `components/` directory |
| 9 | +3. Copy `Randomix.inc` to Pawn include directory |
| 10 | +4. Add `#include <Randomix>` to your scripts |
| 11 | +5. Recompile |
23 | 12 |
|
24 | 13 | ## Functions |
25 | 14 |
|
| 15 | +### PRNG (Fast Game Mechanics) |
26 | 16 | ```pawn |
27 | | -// Utility |
28 | | -native Float:GetEasingValue(Float:t, easeType); |
29 | | -native Float:Lerp(Float:start, Float:end, Float:t); |
30 | | -native LerpColor(color1, color2, Float:t); |
31 | | -
|
32 | | -// Position |
33 | | -native PlayerText_MoveTo(playerid, PlayerText:textdraw, Float:x, Float:y, duration, easeType, bool:silent = false); |
34 | | -native PlayerText_MoveToX(playerid, PlayerText:textdraw, Float:x, duration, easeType, bool:silent = false); |
35 | | -native PlayerText_MoveToY(playerid, PlayerText:textdraw, Float:y, duration, easeType, bool:silent = false); |
36 | | -
|
37 | | -// Size |
38 | | -native PlayerText_MoveLetterSize(playerid, PlayerText:textdraw, Float:y, duration, easeType, bool:silent = false); |
39 | | -native PlayerText_MoveTextSize(playerid, PlayerText:textdraw, Float:x, duration, easeType, bool:silent = false); |
40 | | -native PlayerText_MoveSize(playerid, PlayerText:textdraw, Float:x, Float:y, duration, easeType, bool:silent = false); |
41 | | -
|
42 | | -// Color |
43 | | -native PlayerText_InterpolateColor(playerid, PlayerText:textdraw, color, duration, easeType, bool:silent = false); |
44 | | -native PlayerText_InterpolateBoxColor(playerid, PlayerText:textdraw, color, duration, easeType, bool:silent = false); |
45 | | -native PlayerText_InterpolateBGColor(playerid, PlayerText:textdraw, color, duration, easeType, bool:silent = false); |
46 | | -
|
47 | | -// General |
48 | | -native PlayerText_PlaceOnTop(playerid, PlayerText:textdraw); |
49 | | -native PlayerText_StopAnimation(animator_id); |
50 | | -native IsAnimationActive(animator_id); |
51 | | -
|
52 | | -// Debug and monitoring |
53 | | -native GetActiveAnimationsCount(); |
54 | | -native GetAnimationStats(&totalCreated, &peakConcurrent, &totalCallbacks); |
| 17 | +PRandom(max) // 0 to max-1 |
| 18 | +PRandRange(min, max) // Range integer |
| 19 | +PRandFloatRange(Float:min, Float:max) // Range float |
| 20 | +PRandBool(Float:probability) // Probability boolean |
| 21 | +PRandWeighted(weights[], count) // Weighted selection |
| 22 | +PRandShuffle(array[], count) // Fisher-Yates shuffle |
| 23 | +PRandGaussian(Float:mean, Float:stddev) // Normal distribution |
| 24 | +PRandDice(sides, count) // Dice roll (2d6, 1d20, etc.) |
| 25 | +SeedPRNG(seed) // Set PRNG seed |
55 | 26 | ``` |
56 | 27 |
|
57 | | ---- |
58 | | - |
59 | | -## Callback |
60 | | - |
| 28 | +### CSPRNG (Cryptographic Security) |
61 | 29 | ```pawn |
62 | | -OnAnimatorFinish(playerid, animatorid, textdrawid, types); |
| 30 | +CSPRandom(max) // Secure 0 to max-1 |
| 31 | +CSPRandRange(min, max) // Secure range |
| 32 | +CSPRandFloatRange(Float:min, Float:max) // Secure float |
| 33 | +CSPRandBool(Float:probability) // Secure boolean |
| 34 | +CSPRandToken(length) // Hex token (1-8 digits) |
| 35 | +CSPRandBytes(dest[], length) // Cryptographic bytes |
| 36 | +CSPRandUUID(uuid[]) // UUID v4 string |
| 37 | +SeedCSPRNG(seed) // Set CSPRNG seed (testing only) |
63 | 38 | ``` |
64 | 39 |
|
65 | | ---- |
66 | | - |
67 | | -## Easing Types |
| 40 | +## Usage |
68 | 41 |
|
69 | | -``` |
70 | | -EASE_IN_SINE |
71 | | -EASE_OUT_SINE |
72 | | -EASE_IN_OUT_SINE |
73 | | -EASE_IN_QUAD |
74 | | -EASE_OUT_QUAD |
75 | | -EASE_IN_OUT_QUAD |
76 | | -EASE_IN_CUBIC |
77 | | -EASE_OUT_CUBIC |
78 | | -EASE_IN_OUT_CUBIC |
79 | | -EASE_IN_QUART |
80 | | -EASE_OUT_QUART |
81 | | -EASE_IN_OUT_QUART |
82 | | -EASE_IN_QUINT |
83 | | -EASE_OUT_QUINT |
84 | | -EASE_IN_OUT_QUINT |
85 | | -EASE_IN_EXPO |
86 | | -EASE_OUT_EXPO |
87 | | -EASE_IN_OUT_EXPO |
88 | | -EASE_IN_CIRC |
89 | | -EASE_OUT_CIRC |
90 | | -EASE_IN_OUT_CIRC |
91 | | -EASE_IN_BACK |
92 | | -EASE_OUT_BACK |
93 | | -EASE_IN_OUT_BACK |
94 | | -EASE_IN_ELASTIC |
95 | | -EASE_OUT_ELASTIC |
96 | | -EASE_IN_OUT_ELASTIC |
97 | | -EASE_IN_BOUNCE |
98 | | -EASE_OUT_BOUNCE |
99 | | -EASE_IN_OUT_BOUNCE |
100 | | -EASE_NONE |
| 42 | +```pawn |
| 43 | +#include <pawn-randomix> |
| 44 | +
|
| 45 | +// Game mechanics (fast PRNG) |
| 46 | +new damage = PRandom(100); |
| 47 | +new position = PRandRange(10, 50); |
| 48 | +new lootIndex = PRandWeighted(lootWeights, 4); |
| 49 | +ShuffleArray(players); |
| 50 | +
|
| 51 | +// Security operations (CSPRNG) |
| 52 | +new token = CSPRandToken(8); |
| 53 | +new uuid[37]; |
| 54 | +CSPRandUUID(uuid); |
101 | 55 | ``` |
102 | 56 |
|
103 | | ---- |
| 57 | +## Helper Macros |
104 | 58 |
|
105 | | -## Animation Enum |
106 | | -``` |
107 | | -enum eAnimatorTypes |
108 | | -{ |
109 | | - ANIMATOR_POSITION, |
110 | | - ANIMATOR_LETTER_SIZE, |
111 | | - ANIMATOR_TEXT_SIZE, |
112 | | - ANIMATOR_FULL_SIZE, |
113 | | - ANIMATOR_COLOR, |
114 | | - ANIMATOR_BOX_COLOR, |
115 | | - ANIMATOR_BACKGROUND_COLOR |
116 | | -} |
| 59 | +```pawn |
| 60 | +RandomChance(25) // 25% chance |
| 61 | +CoinFlip() // 50/50 chance |
| 62 | +RollD20() // 1d20 dice roll |
| 63 | +RandomElement(array, size) // Random array element |
| 64 | +SecureRandomElement(array, size) // Secure random element |
| 65 | +ShuffleArray(array) // Shuffle entire array |
117 | 66 | ``` |
118 | 67 |
|
119 | | -You can preview each easing type visually here: [https://easings.net/](https://easings.net/) |
120 | | - |
121 | | ---- |
122 | | - |
123 | 68 | ## Credits |
124 | | -- [alexchwoj](https://github.com/alexchwoj) and all pawn-easing-functions contributors |
125 | | -- [AmyrAhmady](https://github.com/AmyrAhmady) for the open.mp component SDK |
126 | | -- [Fanorisky](https://github.com/Fanorisky) (me) |
| 69 | +- PCG Random by Melissa O'Neill |
| 70 | +- ChaCha20 by Daniel J. Bernstein |
| 71 | +- open.mp Component SDK by AmyrAhmady |
| 72 | +- Fanorisky (me) |
| 73 | + |
| 74 | +GitHub: https://github.com/Fanorisky/pawn-randomix |
0 commit comments