Thursday, July 30, 2015

Unleashed Pixel Dungeon - Auto-Aiming

One of the most important things I find important when I design programs is the User Interface.  I am a firm believer that things should just work the way you think they should.

When I was looking to put my own stamp on Unleashed Pixel Dungeon the first thing I noticed was that pressing on the Quick-Slot item brought up a targeting dialogue, but did not auto-select any of the available enemies.  I wanted to make it so that if a previous (still living mob) has not been targetted it will randomly select a visible mob from those available to use as a default.  Pressing the Quick-Slot item again (double tap) will auto-target that mob.  You could always select a different mob if you prefer, this is just for convenience.


I started playing with the QuickSlotButton.java, visible enemies are stored in the Dungeon.Hero structure, so in the useTarget() function (which is called when we click the Quick Slot Button with something that uses targetting) we first check to see if we already have a target selected and it is one of the available targets, otherwise we iterate through the list of visible targets and randomly select one of them...

I guess we could select the closest, or the weakest, or the toughest, or the one that is awake... for right now I am just selecting a random target.  The only thing left to do is save off that target so that we can continue attacking it the next turn.  I am also saving the lastTarget off in the Hero structure so we can potentially link Melee attacks against the same target in the future.

It was a fairly painless mod to implement and a nice introduction (for me) into the code.  The full fix is available on GitHub.

Enjoy,
David

4 comments:

  1. A "charge" attack would be nifty. If you tap on a target that isnt adjacent to you, you charge it and if The attack hits you do 150% damage. But if you miss The mob gets a Free attack on you (perhaps 150% too)?

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hi! Thanks for all the work you put into this project dude. As a Pixel Dungeon veteran (and All its iterations) I enjoyed many, too many, hours of play. The stuff you did is great. I am suprised this blog is so sparse!

    Something I meant to mention to you that I found out yesterday. I like your Endless mode, a lot. Probably too much. And while I could enumerate the bugs, endlessly lol, there is one thing in partucular I wanted to share.

    It is not endless.

    If you somehow manage- and it took a Long time for me to pull it off- to get to floor level 36, filled with many Yogs everywhere (like the dwarf king levels) and you get to the exit stairs to go to floor 37: the game hard locks on a strange NES game genie-like crash pixel map of all possible traps.

    I took pictures if youre interested.

    What really stinks about that is once you hit the lock screen on floir 37: thats where your file loads every time. No char, no inventory, nothing. So you dont even complete it or anything. No amulet, no ascension etc. And no hall of fame or stats etc.

    Theres loads of other issues but I took them in stride for fun of the challenge. But not being endless lol, that caught me off guard haha!

    I was primed and stocked like Never before and ready for 10 or 20 more levels before the scaling of the level 10 eq cap couldnt keep up with increasing trap damage and mob hits. (You can pass lvl 10 gear, but not only is it like a Terrible statistical chamce of success on scroll use- but anything over 10 Resets to lvl 10 after you exit and restart the game).

    Anyway. Let us know if you do an update and thanks for the awesome variant!

    ReplyDelete
  4. ...Awww... your email account is dead :(

    ReplyDelete