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

7 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
  5. I had the same bug occur in the exact same way. I was so stoked to finally get a sustainable build going, killed like 4 yogs for good measure then bam, maplock next floor. Now that I know it wasn't a fluke I guess I am done with your version unless you are working on updatez =[. You said the other guys email didn't work? mattluy@hotmail.com I'd gladly help in any way I can I know PD pretty thoroughly.

    ReplyDelete
  6. I am Shelley from Los Angeles,California, I want to testify on how i got cured from cervical dystonia, I have suffered from cervical dystonia since the year 2011 with so mush pain,that i have to spend so mush money getting pain relief in the hospital, and I have visited several doctor ,but all to no avail, my world was gradually coming to an end because of the constant muscle contractions and pain , until i saw a post in a health forum about a herbal Dr Williams who use herbal portion in curing people from different kind of diseases including dystonia, at first i doubted if it we be able to cure me, but i decided to give it a try, when i contacted this herbal doctor via his email, he prepared a herbal portion and sent it to me via courier service, when i received this herbal medicine, he gave me step by step instructions on how to apply it, when i applied it as instructed, i was completely free from dystonia just for 1 months of usage,i we recommend this to all my friend family in the world today who still suffering from dystonia you can contact him through his email on drwilliams098675@gmail.com for help.

    ReplyDelete
  7. I am Shelley from Los Angeles,California, I want to testify on how i got cured from cervical dystonia, I have suffered from cervical dystonia since the year 2011 with so mush pain,that i have to spend so mush money getting pain relief in the hospital, and I have visited several doctor ,but all to no avail, my world was gradually coming to an end because of the constant muscle contractions and pain , until i saw a post in a health forum about a herbal Dr Williams who use herbal portion in curing people from different kind of diseases including dystonia, at first i doubted if it we be able to cure me, but i decided to give it a try, when i contacted this herbal doctor via his email, he prepared a herbal portion and sent it to me via courier service, when i received this herbal medicine, he gave me step by step instructions on how to apply it, when i applied it as instructed, i was completely free from dystonia just for 1 months of usage,i we recommend this to all my friend family in the world today who still suffering from dystonia you can contact him through his email on drwilliams098675@gmail.com for help.

    ReplyDelete