Page 1 of 1

runFromTarget support in autoSwitch

Posted: 08 Apr 2008, 15:40
by fallen
I wrote a quick patch to add runFromTarget and runFromTarget_dist to the autoSwitch options. It's still experimental, but seems to work OK so far on SVN version.

Dunno if this is the right place to post it, or if there is forms to fulfil - feel free to move/correct me if I am doing anything wrong.

I have 2 situations where this is useful:
- an Auto Spell sage killing geographers (distant cast only, no auto spell :P damn those DEX plants)
- an Exorcist on Pyramids and maps with Drainliars, Familiars and the like - I'd rather use a stunner to kill them than use a Phen accessory (where I play, there is no Phen card drop - only thru ROPs; too expensive to let it get caught on a bot)

There are probably more situations where it could be useful, but those are my motives for patching :)

Enough talk, here is the snippet of code, added in AI.pm.

on function "sub attack", right after the "useWeapon' check in autoSwitches:

Code: Select all

                                if ($config{"autoSwitch_$i"."_useWeapon"} ne "") {
                                        $ai_v{'attackUseWeapon'} = $config{'attackUseWeapon'};
                                        $config{'attackUseWeapon'} = $config{"autoSwitch_$i"."_useWeapon"};
                                        message TF("Change Attack useWeapon to : %s\n", $config{'attackUseWeapon'}), "equip";
                                }
                                # Patch starts here
                                if ($config{"autoSwitch_$i"."_runFromTarget"} ne "") {
                                        $ai_v{'runFromTarget'} = $config{'runFromTarget'};
                                        $config{'runFromTarget'} = $config{"autoSwitch_$i"."_runFromTarget"};
                                        message TF("Change runFromTarget to : %s\n", $config{'runFromTarget'}), "equip";
                                }
                                if ($config{"autoSwitch_$i"."_runFromTarget_dist"} ne "") {
                                        $ai_v{'runFromTarget_dist'} = $config{'runFromTarget_dist'};
                                        $config{'runFromTarget_dist'} = $config{"autoSwitch_$i"."_runFromTarget_dist"};
                                        message TF("Change runFromTarget_dist to : %s\n", $config{'runFromTarget_dist'}), "equip";
                                }
                                # Patch ends here
                                last AUTOEQUIP;
A little bit further down, there is the ai_v "restore" code. Again, right after the useWeapon check:

Code: Select all

                if ($ai_v{'attackUseWeapon'} ne "" && $config{'attackUseWeapon'} != $ai_v{'attackUseWeapon'}) {
                        $config{'attackUseWeapon'} = $ai_v{'attackUseWeapon'};
                        message TF("Change Attack useWeapon to default : %s\n", $config{'attackUseWeapon'}), "equip";
                }
                # Patch starts here
                if ($ai_v{'runFromTarget'} ne "" && $config{'runFromTarget'} != $ai_v{'runFromTarget'}) {
                        $config{'runFromTarget'} = $ai_v{'runFromTarget'};
                        message TF("Change runFromTarget to default : %s\n", $config{'runFromTarget'}), "equip";
                }
                if ($ai_v{'runFromTarget_dist'} ne "" && $config{'runFromTarget_dist'} != $ai_v{'runFromTarget_dist'}) {
                        $config{'runFromTarget_dist'} = $ai_v{'runFromTarget_dist'};
                        message TF("Change runFromTarget_dist to default : %s\n", $config{'runFromTarget_dist'}), "equip";
                }
                # Patch ends here
        } #END OF BLOCK AUTOEQUIP
And now the configuration example:

Code: Select all

autoSwitch Geographer,Flora {
        useWeapon 0          
        runFromTarget 1
        runFromTarget_dist 6
}
I would appreciate your thoughts on this.

Re: runFromTarget support in autoSwitch

Posted: 08 Apr 2008, 17:50
by shakespeare
i like this idea ^^

Re: runFromTarget support in autoSwitch

Posted: 09 Apr 2008, 04:40
by Bibian
you might want to post a diff file and test it in every possible way.
we'll commit it if we think its usefull and working properly

Re: runFromTarget support in autoSwitch

Posted: 24 Mar 2009, 22:33
by kali
Post a diff, I'll move it to the commit queue.

Time to wake up :P

Re: runFromTarget support in autoSwitch

Posted: 24 Mar 2009, 23:42
by ulun
Nice implementation :) I look forward at this.

Re: runFromTarget support in autoSwitch

Posted: 27 May 2011, 13:51
by help_us
AI.pm already changes