Targeting and Aiming Script Collection

Started by Mr Shiek, April 04, 2020, 05:07:51 AM

Previous topic - Next topic
April 04, 2020, 05:07:51 AM Last Edit: January 12, 2022, 05:56:38 PM by Mr Shiek
Hello everyone!

Since the server fire last year (was it 2020 or 2021?) all of these attachments have been lost. I have not had time to reupload them but I will fix this post in the future.

This is intended to be a collection of scripts that will provide features related to aiming the hero. For the moment, I only have a portion of the features working but they seem to be stable in my testing. Currently, this only works with a mouse and keyboard but I do plan to add support for joypads. The idea behind this is to replicate the system from Dark Souls as closely as possible in a 2D enviroment.

Edit: You will also need a cursor sprite and a target marker sprite to draw on the screen.

These are the initial scripts for this collection; they will allow target lock-on and cursor aiming, in conjunction with the supporting scripts.

  • Aim  --  Makes the hero face the position of the cursor.
  • Draw Cursor  --  Draws the cursor on the screen (it is important to set the system cursor visibility to false).
  • Lock On  --  Whenever 'Q' (or whatever key you choose) is pressed, lock on to an enemy within range and line of sight.
  • Draw Target Marker  --  Draw a marker on the currently selected target.
  • Get Position On Screen (Enemy)  --  Converts the enemy's map coordinates into screen coordinates.
  • On Removed  --  When the currently selected target dies, make sure the lock-on is removed properly.
  • Line of Sight  --  Checks the hero's facing direction and tests for obstacles between hero and target.
  • Get Position On Screen (Hero)  --  Same as previous script, but for the hero rather than enemies.

Each of these scripts utilise the multi_events script included with Solarus. Just add the scripts to your quest directory and require them in the proper script (either features or main; however you add new scripts to your quest). I tried to write the scripts clearly enough that they can be modified easily.

I owe a big thanks to several members of the community for helping with this. Diarandor, Llamazing, and Cluedrew most of all!

Let me know any criticism or critiques you may have!
Build a man a fire, he will be warm for the night. Set a man on fire, he will be warm for the rest of his life.
a.k.a. Kamigousu, Xejk, Sr Xejk