Author Topic: Targeting and Aiming Script Collection  (Read 723 times)

Kamigousu

  • Newbie
  • *
  • Posts: 28
  • Game Design 'Hobbyist'
    • View Profile
Targeting and Aiming Script Collection
« on: April 04, 2020, 05:07:51 am »
Hello everyone!

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 hero'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!
« Last Edit: April 05, 2020, 10:00:24 pm by Kamigousu »
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.