Alright, I’ve been scripting for a long time and I think now’s the time for me to step up my game, and make a rolling system. If you’re not familiar with a rolling system it’s just like opening a loot crate in mm2.
Now the question, where do I start? I’ve got an idea for how the UI would look and feel, but I just hit a roadblock when it comes to actually scripting the system. I’ve searched on YouTube, but most of the tutorials are just too outdated. Thus here I am
I optionally want to create a guaranteed feature where you can get the highest rarity item after some rolls, but how in the world do you manipulate the exact frame housing the item to be the one to land on?
Ideas greatly appreciated, pls don’t give code unless it’s a skeleton to represent your idea
Some ideas I lost sleep formulating
Using math.cos()/math.sin() to emulate the smooth slowing down of the ui
Translating the ui with respect to the players frame rate, so it is appropriate for all refresh rates
You decide what item you’re going to give before you spin the wheel, then you just fill the other slots with items distributed by rarity. It’s not real gambling, so you can be as sadistic as you want; put rare items right next to where the wheel lands. If you have guaranteed hits after a certain amount of time, don’t show the player that directly, show like a “luck” percentage that gets close to but never reaches 100%.
Well, firstly, actually getting the item should not rely on the animation of the crate loot, it should be the animation that relies on the item that you got, this means that when the client opens a crate loot, it tells the server to determine what item you got and send it to the client for it to make that crate loot animation. This way you avoid the player exploiting or using cheats to get the rarest items if it relies totally on the animation and thus, the player, which you should never trust the player.
Now for the animation on the client side, you can let the player have all control over it, let’s say it randomly decides to travel 23 item frames before landing on the item that was already calculated and passed by the server to the client. Now you can just use a math function such as math.cos((pi/2)*TimeSinceRoll/DesiredAnimationTime)
that gives a value from 1 to 0 within your desired animation time (which you can also declare it randomly in the client) and you can use it for the position of the UI bar that tells where the roulette is gonna land on
You could use that function where 1 is, in this scenario, 23 item frames offset from the real item frame you’re gonna get, and 0 where it is 0 frames offset (You can just multiply the final value of the math function by the size of the item frames times 23)
I hope I can explain myself clearly, I’ve probably got a lot of grammar errors since english isn’t my main language