• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Mehah Client] "Minigame Arrows" by Fresh

Fresh

Quack!
Joined
Oct 21, 2009
Messages
1,845
Solutions
18
Reaction score
646
Location
Poland
Hello OTLanders,
Today I was a little bored and wanted to practice my "coding skills" by creating something unique, at least for me.
I coded an simple "Arrows Minigame" (only client-side), click on video below to see "what is this".


📽️ GIF, for better FPS - click here to watch it in video format.
C4PAK1q.gif

This is standalone module tested and worked as intended on Mehah client, however, it can works on v8 client too, but needs to expose function called intersects (from rect.h) to Lua.


⚠️ Disclaimer
I want to share it because I consider that someone can find it useful or want to learn something, or, whatever.
Remember - this is only client-side code (module), if you want to use it on your server you need to adapt this module, rewrite certain functions to fit your requirements and logic, handle it by server, etc, etc.
However, I think - its an "enough base" for "start".
🔍 What "useful" things can I learn from this?
  • Simply "animations";
  • Base usage of intersects function that checks if certain widgetA is in range of rectangle of certain widgetB;
  • Base usage of events;
  • Base usage of keyBindings inside certain Widget;
  • Just to see "how something can be done" and maybe to inspire someone ❤️;
❓Any config or instructions..
Just simply open arrowgame.lua and at the top of the document, edit the variables in the START_GAME_CONFIG table.
For instructions, I've left a few comments inside arrowgame.lua for better understanding.
And of course, if you want to learn or understand something from it, you'll unfortunately need to read the entire code. 🫨
I haven't cleaned up the code too much, so a little bit of rewriting could be done, but I think it's a small amount.
📦 Installation
Download & unpack the .rar from attached file, then, drag it into your client/modules/ folder or mods or whatever you use to store modules in your client.
It has autoload: true in .otmod file, so it should be loaded properly upon client start, for testing purposes.
You don't need any additional files, UI images required and used by this module are already in pack and I not used any other extra stuff here.


8️⃣ How to make it work on OTClient V8?
You need to "expose" few functions from C++ client source code to .Lua, so..

1) in uiwidget.h needs to be added:
C++:
bool intersects(const Rect rect) { return m_rect.intersects(rect); }

2) in luafunctions.cpp in <UIWidget> objects list, needs to be added:
C++:
g_lua.bindClassMemberFunction<UIWidget>("intersects", &UIWidget::intersects);

3) I think that's all, however if not - just try to read everything about intersects function from Mehah repository [rect.h](Click) and adapt the code from sources into your V8.


Enjoy,
Have a good day!​
 

Attachments

Last edited:
Thank you very much for your collaboration, very good module, you can use it in several quests.
 
This mini game looks great, and with some criativity server owners can change it do make many new interesting things.

I for one wasn't aware of this intersects method, and always wanted some kind of way to make mini games like this to add into some player actions like mining, fishing, etc

I will check this minigame for sure
 
Hello OTLanders,
Today I was a little bored and wanted to practice my "coding skills" by creating something unique, at least for me.
I coded an simple "Arrows Minigame" (only client-side), click on video below to see "what is this".


📽️ GIF, for better FPS - click here to watch it in video format.
C4PAK1q.gif




⚠️ Disclaimer

🔍 What "useful" things can I learn from this?

❓Any config or instructions..

📦 Installation



8️⃣ How to make it work on OTClient V8?

You need to "expose" few functions from C++ client source code to .Lua, so..

1) in uiwidget.h needs to be added:
C++:
bool intersects(const Rect rect) { return m_rect.intersects(rect); }

2) in luafunctions.cpp in <UIWidget> objects list, needs to be added:
C++:
g_lua.bindClassMemberFunction<UIWidget>("intersects", &UIWidget::intersects);

3) I think that's all, however if not - just try to read everything about intersects function from Mehah repository [rect.h](Click) and adapt the code from sources into your V8.


Enjoy,
Have a good day!​
EPIC! thanks for share!

LEGENDS!!! PLEASE More of such amazing out of the box things! xD
 
This is awesome! I have long dreamed of having a Music system just like New World, where you are able to play with up to 4 friends in a band, playing all a song together on different instruments, this comes very close to that idea, I will definitely play around with this!

If something comes out of it I will let you guys know to see what is possible with this system :)
 
Back
Top