PDA

View Full Version : Help me make my script better!



Maerit
09-07-2015, 02:07 AM
Ok, I worked on this for a while, and came up with a reasonably reliable script to invoke/cast spells up to a specified duration from a specified container and then infuse those scrolls using the ag'loemar runestone in the specified container.

What I think would be nice is if you could actually turn this into a "waggle" style script with a UI, and if it could keep track of scrolls that are locked (based on messaging from the infuse portion) to prevent you from wasting 14 mana to try and re-infuse a scroll that is already locked.

Here's my script that I named "wagfuse"


spell_duration = <set a number in minutes>
scroll_container = "<container>"
cast_spell = variable[0]


wait_until { checkmana(40) }

if (checkright != nil)
fput "stow right"
end

if (checkleft != nil)
fput "stow left"
end


fput "rummage in my " + scroll_container + " spell " + cast_spell

until (Spell[cast_spell].timeleft > spell_duration) do
fput "invoke " + cast_spell
fput "cast " + variable[1]
waitcastrt
end



if (checkright == nil)
echo "Nothing to do, or spell not in scroll inventory!"

else
fput "rummage in my " + scroll_container + " runestone ag'loenar"
scroll_name = "my " + GameObj.right_hand.noun
fput "prep 714"
fput "cast " + scroll_name
link = waitfor "You focus your mind on the", "Your spell misfires"
link_split = link.split(" the")
waitcastrt?

if (link_split[0] == "You focus your mind on")

infuse_message = ""

until (infuse_message == " The mana dissipates") do
fput "infuse " + scroll_name
infuse_line = waitfor "You focus on a smooth stone"
infuse_split = infuse_line.split(".")
infuse_message = infuse_split[2]
waitcastrt?
end

waitcastrt?

elsif (link == "Your spell misfires.")

echo "Scroll Locked!"

else
echo "Fumble?"
end

fput "stow right"
fput "Stow left"

end

To use the script you simply do ;wagfuse <spell number> <character name (optional)>

Leaving character name blank will self-cast instead.

The above simply rummages in your container for the specified spell, invokes and casts it until you have exceeded the specified duration, then infuses the scroll using 714 and the ag'loemar runestone. It's a "dumb" script in that it assumes the user has the necessary scroll in their specified scroll container, along with a runestone already created for use. It definitely has a lot of potential "break" points.

Areas to bugfix would be:

1. Runestone shattering during the infuse process - not handled.
2. Scroll burns up while invoking - not handled.
3. Personal injury due to failure - not handled.

And I'm sure there are other scenarios that aren't handled.

Areas to improve would be:

1. Add a repository file that can record the item name of scrolls and available spells. A scroll repository system that is already out there is in the scroll.lic that will read all scroll-type objects in a container, and save the results of that read to a file for later use.
2. Add to the repository a value that would indicate if the scroll has been locked or can no longer be infused based on the infuse results during the infuse process. All scrolls start with a "true" flag, and then if the scroll fails to infuse during the infuse process, that flag is updated to false, so a conditional can prevent you from trying to infuse the same scroll again in the future.
3. Create a UI that would leverage the repository to allow for a "waggle style" selection of spells to use from your scrolls.
- This UI would allow you to set "minimum duration", "scroll container", and use the waggle selection method for spells to include when you run wagfuse as well as a "checkbox" to run the infuse routine (making the utility useful for more than just Sorcerers).
4. Mana management for the Infuse portion (similar to waggle with regards to Wracking). This feature would be able to calculate, based on the formulas on the wiki, how much mana is necessary to infuse the specified spell for the number of times it was invoked/cast + 14 for the 714 spell, then wait until there is sufficient mana to re-infuse the used charges.
5. A list of spells that cannot stack (Haste, Perception, Foraging, Sanctuary... yada yada) to allow them to be used with the script without attempting to stack them beyond their "single-cast" duration.

Sooooo, how hard is the above? I could see a waggle tool that works for scrolls to be useful for myself personally, but not sure how many other players would benefit / use anything like this for themselves. Clearly it has greater value for Sorcerers, but the waggle aspect to allow faster spellups with the use of scrolls would be helpful.

Right now, this little script by itself has saved me much typing and made my scrolls last so much longer in the process! Feel free to use it and customize it however you like, obviously!

stormtov
09-10-2015, 05:39 AM
Not really going to be much help to you but just a few thoughts on reading this.

For 1 and 2, tracking by ID of an item would be the ideal way but every time you log in these change ruining that. Relying on the scroll name is not going to be accurate enough, I know I often end up with scrolls with the same name (granted my scroll collection is rather larger than average, but so I assume would be post people who this script would interest. Work around would likely be store the name as well as the spells on it but this would be a bit more complicated to get this working well.

3, if you like coding I would say just look at a script that has a gui and copy that and make changes as needed (this is what I did, while I do not understand it enough to code one from scratch I have still made several workable GUI's. To this end I can provide a basic GUI if you do not feel like doing this yourself.

4, it might just be easier to set a minimum amount of mana (perhaps configurable in the GUI) at which you would like the script to pause at rather than calculating it. For the mana regen side I am sure Tilmen won't mind that being ripped straight from ;waggle.

5. I believe, but not at home to check right now, the "Spell" object already has this information.