|Anonymous | Login | Signup for a new account||2019-02-23 23:01 CET|
|Main | My View | View Issues | Change Log | Wiki | Tavern | News|
|Viewing Issue Simple Details|
|ID||Category||Severity||Reproducibility||Date Submitted||Last Update|
|0007488||[DCSS] Patches||feature||have not tried||2013-08-19 22:43||2013-11-16 02:36|
|Status||resolved||Product Branch||0.13 ancient branch|
I added "clua/automagic.lua", to initfile.cc (line 1422) and put the attached file in dat/clua
There is lots more I plan to add but I thought I would throw it up here in case anyone wants to watch progress.
|Tags||No tags attached.|
automagicv6.patch [^] (13,436 bytes) 2013-11-09 09:01 [Show Content]
Automagic rc1.patch [^] (13,519 bytes) 2013-11-11 22:25 [Show Content]
edited on: 2013-09-05 00:25
This patch adds 3 options to init.txt:
Automagic_enabled (Default: disabled)
When the player presses tab (or whatever is bound to hit_closest), if automagic is enabled and there is a spell in slot "a" automagic will attempt to attack by spell.
Set automagic_stop (Default: 30)
If the player's magic points are below this number (percentage of total), this prevents casting. What happens is dependent on behavior setting.
Set automagic_fight (Default: false)
If automagic cannot attack by magic, a message will be printed (not enough magic or magic below threshold) by default. If this is true, a melee attack will be called.
I have included measures to catch any unintended keypresses being sent. Out of magic and no target are handled. I can't think of any other situations that could cause the sendkeys command to actually happen under false situations.
|V2 added. Cleaned up some debug code i had left in on accident. Also added a macroable function to assign which spell slot would be fired on automagic command. Included error handling on that function.|
|Whoops, uploaded a version that had this feature enabled. New one posted.|
It looks like it still refers to "a" in a few places instead of SPELL_SLOT. Also, there might be funny messages if the user presses a strange key so that set_slot doesn't return anything; probably a nil return should be checked alongside "escape".
Finally, functions like "set_slot" need more unique names; remember that all clua code shares the same set of global variables and function names. "automagic_set_slot" or even "am_set_slot" should be fine for avoiding potential conflicts with other lua scripts.
edited on: 2013-09-13 04:07
Ok I replaced all spell functions from "a" to AUTOMAGIC_SPELL_SLOT.
Made the macro stricter on accepting input. On wizmode, I was only allowed to memorize 21 spells (a-u). So the macro will only accept ASCII codes a-u. Otherwise, "Invalid spell slot." is returned to player.
I also made some global variables and functions a little more specific.
PS how come I cant delete the older versions?
|Spell letters can be and frequently are changed, so a-u is not sufficient. I'm not sure what all the valid spell letters are, but it's at least a-z and A-Z, possibly more.|
I looked up isaalpha from libutil.h (which is what spell swapping code uses) and found that it will accept a-z and A-Z. So I had the assign spell slot function accept those keys.
Patch updated Automagic v5.patch
Based off master 1160cc881
I tried this briefly and looked through the patch. In general the basic functionality looks good, and pressing tab to cast conjurations felt pretty nice. :) I thought of a few things that could be improved (mostly should be easy to code):
* add a HP stop for automagic as well as the existing MP stop (called automagic_hp_stop or some such)
* make autofight_no_move (also known as hit_adjacent) act as automagic_no_move when automagic_enable = true
* am_set_spell should allow setting the slot to something that does not currently have a spell in it (since this is a convenient way to turn off automagic in-game)
* AUTOMAGIC_SPELL_SLOT should persist if you save the game and reload (currently it resets to 'a'. This is probably tricky to do, but I know gearset.lua manages this sort of thing somehow. I can try to figure this out myself sometime (I've been meaning to do this anyway for other things).
* options_guide.txt should have some basic documentation of the new functionality
(I also noticed several minor details that I can easily fix before committing, like that automagic probably shouldn't care about nets since you can cast in a net, or that the spell range check should use range^2+1 instead of range^2.)
In autofight I moved the hp_is_low check to hit_closest so more code isn't being processed when we can reach a spot point early.
Function am_set_spell now allows pressing enter to disable automagic (with some nice text responses!).
Removed net check.
|Removed two older files by author request.|
|Uploaded what I think is a finished product. Automagic rc1.patch|
|Thanks, it is in trunk now! (With some minor bugfixes / additions.) If you think of anything, more improvements are always welcome of course... but now it should get more serious testing in trunk.|
|2013-08-19 22:43||Naruni||New Issue|
|2013-08-19 22:43||Naruni||File Added: automagic.lua|
|2013-08-21 10:49||Naruni||Note Added: 0023810|
|2013-09-02 06:40||Naruni||Issue Monitored: Naruni|
|2013-09-05 00:25||Naruni||Note Edited: 0023810|
|2013-09-05 00:26||Naruni||File Added: automagic.patch|
|2013-09-12 05:02||Naruni||Note Added: 0024004|
|2013-09-12 05:03||Naruni||File Added: Automagic v2.patch|
|2013-09-12 17:26||Naruni||Note Added: 0024005|
|2013-09-12 17:27||Naruni||File Added: Automagic v2.1.patch|
|2013-09-12 22:07||neil||Note Added: 0024007|
|2013-09-13 04:06||Naruni||Note Added: 0024008|
|2013-09-13 04:06||Naruni||File Added: Automagic v4.patch|
|2013-09-13 04:07||Naruni||Note Edited: 0024008|
|2013-09-13 13:43||Galefury||Note Added: 0024011|
|2013-09-14 01:01||neil||File Deleted: automagic.lua|
|2013-09-14 01:01||neil||File Deleted: automagic.patch|
|2013-09-14 01:01||neil||File Deleted: Automagic v2.patch|
|2013-09-14 01:01||neil||File Deleted: Automagic v2.1.patch|
|2013-09-15 03:32||Naruni||Note Added: 0024018|
|2013-09-15 03:33||Naruni||File Added: Automagic v5.patch|
|2013-09-15 03:41||neil||File Deleted: Automagic v4.patch|
|2013-11-06 08:07||elliptic||Note Added: 0024310|
|2013-11-09 07:13||Naruni||Note Added: 0024340|
|2013-11-09 08:43||Naruni||File Added: Automagic.patch|
|2013-11-09 09:01||Naruni||File Added: automagicv6.patch|
|2013-11-09 14:39||chris||File Deleted: Automagic v5.patch|
|2013-11-09 14:39||chris||File Deleted: Automagic.patch|
|2013-11-09 14:39||chris||Note Added: 0024341|
|2013-11-11 22:25||Naruni||Note Added: 0024386|
|2013-11-11 22:25||Naruni||File Added: Automagic rc1.patch|
|2013-11-16 02:36||elliptic||Note Added: 0024410|
|2013-11-16 02:36||elliptic||Status||new => resolved|
|2013-11-16 02:36||elliptic||Fixed in Branch||=> 0.14 development branch|
|2013-11-16 02:36||elliptic||Resolution||open => done|
|2013-11-16 02:36||elliptic||Assigned To||=> elliptic|
|Mantis 1.1.8[^] Copyright © 2000 - 2009 Mantis Group|