Enchant.tf
Jump to navigation
Jump to search
An enchant script. It'll enchant an item until something happens to it, and execute the command given by option -x when it's done. The -i option makes it use information gathered by the identify.tf script, and is its default way of getting the item's type.
This script uses verbose.tf, regen.tf and safechannel.tf so you'll want those if you want to use this script. Regen.tf uses prompt.tf. You should also have TINYPREFIX set in your config file, pointing at the directory with tf scripts like
/set TINYPREFIX=~/tinyfugue/
;Bug reports, suggestions and/or diffs are appreciated, '''sulfar''' _AT_ ''inbox'' +DOT+ ''com'' /loaded __SULFAR__/enchant.tf /eval /require -q %{TINYPREFIX}verbose.tf /eval /require -q %{TINYPREFIX}regen.tf /eval /require -q %{TINYPREFIX}safechannel.tf ;All tf commands have the options before the arguments, e.g. from the commandline ;/enchant -a ring /def -i enchant_usage = \ /echo -aCyellow %%% /enchant <item> Enchant <item> until something happens to it%;\ /echo -aCyellow %%% [-a] item is an armor%;\ /echo -aCyellow %%% [-w] item is a weapon%;\ /echo -aCyellow %%% [-b] item is a bow%;\ /echo -aCyellow %%% [-i] item is a %{identify_type} <- default%;\ /echo -aCyellow %%% [-x<command>] execute <command> on exit ;but it probably will be most useful in another script... /enchant_usage ;Set to 0-3 to override system verbosity level ;Set to -100 to disable script verbosity level and use system verbosity level ;see verbose.tf /verbose -s-100 enchant /set auto_enchant 0 /def -i enchant_init = \ /verbose -o%{verbosity_enchant} -l2 - -aCyellow %%% /%0: Initializing .... %;\ /set auto_enchant=0%;\ /set enchant_item=%;\ /set enchant_type=%;\ /set enchant_post= /enchant_init /def -i enchant = \ /safechannel -q on%;\ /enchant_init%;\ /if (!getopts("awbix:")) /return 0%;/endif%; \ /set enchant_post %{opt_x}%;\ /if (opt_a) /set enchant_type armor%;\ /elseif (opt_w) /set enchant_type weapon%;\ /elseif (opt_b) /set enchant_type bow%;\ /elseif (identify_type !~ "") /set enchant_type %{identify_type}%;\ /else \ /echo -aCyellow %%% No idea how to enchant %*.%;\ /enchant_usage%;\ /return 0%;\ /endif%;\ /set enchant_item %*%;\ /set auto_enchant 1%;\ /verbose -o%{verbosity_enchant} -l1 - -aCcyan %%% /%0: Start enchanting %enchant_item.%;\ /verbose -o%{verbosity_enchant} -l3 - -aCyellow %%% /%0: Type is %enchant_type, post command is %enchant_post%;\ /enchant_do /def -i enchant_do = \ /verbose -o%{verbosity_enchant} -l2 - -aCyellow %%% /%0: Enchanting %{enchant_item} as %{enchant_type}.%;\ c 'enchant %{enchant_type}' %{enchant_item} %;\ ;Stuff that could go wrong /def -i -E(auto_enchant) -p699 -F -t"You are not carrying *!" enchant_no_item = \ /verbose -o%{verbosity_enchant} -l2 - -aBCred %%% Can't find your item, %{enchant_item}! Bailing out.%;\ /enchant_exit /def -i -E(auto_enchant) -p699 -F -mregexp -t"^You do not have enough mana to cast enchant (weapon|bow|armor).$" enchant_no_mana = \ /verbose -o%{verbosity_enchant} -l1 - -aCcyan %%% /%0: Yikes! Out of mana. Calling regen script and retrying.%;\ /regen -x/enchant_do /def -i -E(auto_enchant) -p699 -F -mregexp -t"^That isn't (an|a) (armor|weapon|bow).$" enchant_wrong_type = \ /verbose -o%{verbosity_enchant} -l2 - -aBCred %%% /%0: WRONG TYPE! Trying to enchant %{P1} %{P2} as %{enchant_type}.%;\ /enchant_exit ;armor, weapon, bow /def -i -E(auto_enchant) -p699 -F -mregexp -t"^Nothing seemed to happen.$" enchant_nothing = \ /verbose -o%{verbosity_enchant} -l1 - -aCyellow %%% /%0: Sigh... *yawn* ... Mumble mumph ZZZZZZZZZ ... retrying...%;\ /enchant_do /def -i -E(auto_enchant) -p699 -F -mregexp -t" glows brightly, then fades...oops.$" enchant_fade = \ /verbose -o%{verbosity_enchant} -l2 - -aCyellow %%% /%0: Item fades! Beh.%;\ /enchant_exit ;armor /def -i -E(auto_enchant) -p699 -F -mregexp -t" shimmers with a gold aura.$" enchant_shimmers_gold = \ /verbose -o%{verbosity_enchant} -l2 - -aCyellow %%% /%0: We got gold... But where is Shizaga?%;\ /enchant_exit /def -i -E(auto_enchant) -p699 -F -mregexp -t" glows a brilliant gold!$" enchant_brilliant_gold = \ /verbose -o%{verbosity_enchant} -l2 - -aBCyellow %%% /%0: Yesss!!! A brill!.%;\ /enchant_exit /def -i -E(auto_enchant) -p699 -F -mregexp -t" flares blindingly... and evaporates!$" enchant_vape = \ /verbose -o%{verbosity_enchant} -l2 - -aBCred %%% /%0: Oh nooooooooo.... another one vaped!%;\ /enchant_exit ;weapon, bow /def -i -E(auto_enchant) -p699 -F -mregexp -t" glows blue.$" enchant_blue = \ /verbose -o%{verbosity_enchant} -l2 - -aCyellow %%% /%0: This one enchanted... Shizaga?%;\ /enchant_exit /def -i -E(auto_enchant) -p699 -F -mregexp -t" glows a brilliant blue!$" enchant_brilliant_blue = \ /verbose -o%{verbosity_enchant} -l2 - -aBCblue %%% /%0: I wish this would happen all the time!%;\ /enchant_exit /def -i -E(auto_enchant) -p699 -F -mregexp -t" shivers violently and explodes!$" enchant_explode = \ /verbose -o%{verbosity_enchant} -l2 - -aBCred %%% /%0: Boom boom boom boom... Byebye!!%;\ /enchant_exit ;Finally, we exit /def -i enchant_exit = \ /let post %enchant_post%;\ /enchant_init%;\ /safechannel -q off%;\ /verbose -o%{verbosity_enchant} -l1 - -aCcyan %%% /%0: Done enchanting! Executing post command: %post%;\ /if (post !~ "") /eval -s0 /repeat -0.4 1 %{post}%; /endif