Not sure what it's called, I just need a script to change how spells are cast

Post Reply
Guilend
Posts: 36
Joined: Fri Mar 09, 2018 1:21 am

Not sure what it's called, I just need a script to change how spells are cast

Post by Guilend »

I think at one point i asked this question and I didn't give enough info to figure it out and i was way to narrow minded on how i wanted it done and couldn't even get across what i wanted, but this time I have come more prepared and I am more open minded.

I play Avalon The Legend Lives, in it there are 3 ways a spell can be cast. Here are the different ways.

chant <spell>;cast <spell> [parameters]
point <spell> [parameters]
read spellbook <spell> [parameters]

The parameters can be a target, yourself as target, target + direction, just direction, or no parameters at all.
What i want is a script that allows me to use the same alias to choose which way I cast the spell and the parameters. Some that needs a target I can also use to cast on myself for a defense, like making myself blind.

this is one of the ways i have been doing it now, but I can only do two types of casting and can't make the parameters change if the script is using both types.
Code: [show] | [select all] lua
function CharmArt(spell,target)
 if target then
 send("point " .. spell .. " " .. target)
else
send("chant " .. spell .. ";cast " .. target)
end
end

That is one of the few i have been using, but it's limited, especially when I want to have one change parameters, like hit myself with it.
Now, you can also cast a spell as long as you have already chanted it, and i have a prompt to show me what my last chant was, I have a trigger to make that a variable, though for some reason they decided to make the last chant text all caps, like instead of it saying fireball, it shows FIREBALL. I was wanting to also add in there that if i want to chant the spell that if my last chant was that spell, then it just casts it, but if it wasn't, then it will just chant it and i will have to hit the alias a second time to cast it, that way if i am in a constricted mist and can only use one command aliases, it will still work. However if that isn't possible, then it isn't possible. Thank you all and if there are any questions, I will try and answer them, I am sure i covered everything. I only know very little about scripting, or lua for that matter, or even coding, just want little i have learned over the past year or so, which isn't much. So I apologize now for when i asked a million questions when you do try and help me lol.

Guilend
Posts: 36
Joined: Fri Mar 09, 2018 1:21 am

Re: Not sure what it's called, I just need a script to change how spells are cast

Post by Guilend »

Also, it doesn't matter if it's a few scripts, like for those that don't need targets, or those that just need directions etc, I just want a more uniform way of doing it, right now it's all over the place.

User avatar
Vadi
Posts: 5041
Joined: Sat Mar 14, 2009 3:13 pm

Re: Not sure what it's called, I just need a script to change how spells are cast

Post by Vadi »

I'm guessing you'd like this topic in the help forum?

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Not sure what it's called, I just need a script to change how spells are cast

Post by Jor'Mox »

What you want is certainly possible... but I say that without actually being clear about what it is that you want to do. It is clear that you want an alias that will easily let you use one of three different casting techniques, but then you go on about parameters in a way that doesn't really make any sense to me. The coding task is actually quite simple, it is just some basic switching logic applied however many times is required, but in order for that to work the desired input and output have to be made very clear, along with any extra information that might influence how a decision is made.

In this case, you have three casting styles, chanting, pointing, and reading. And presumably three types of spells, self only, other only, and self or other. You also mention a specific condition that places a limit on chanting style casting, in that you can only use one command at a time while in a 'constricting mist'. But then you talk about parameters, at which point I get a bit lost. I'm used to spells essentially either having a target or not having one, and that is more or less the extent of the options available. Say I'm casting a fireball, I normally have to cast it at a target, but if I'm in combat I can cast without a target and it will hit whoever I'm fighting automatically. It is also fairly common to see aliases keep track of the most recent target and use that if one isn' provided, and it also isn't unheard of to have some sort of generic alias that can perform several commands that remembers the command it sent last and resends that if not instructed to do otherwise. So, for example, I could have an alias that I direct like this: "c fireball goblin", and then any time I want to cast another fireball at a goblin, I can just type: "c". If I want to cast a different spell at a goblin, like blind, I would do this: "c blind", with it remembering to target the goblin. And if you want to occasionally be able to target yourself with certain spells, but have it default to going back to your normal target when you don't explicitly tell it to cast at you (i.e. so you can "c blind self" once and then "c blind" and it goes back to trying to blind the goblin), that is also fairly straightforward. BUT, all of that depends on clearly knowing what you actually want to have happen, and how much you want to put into making the alias.

Guilend
Posts: 36
Joined: Fri Mar 09, 2018 1:21 am

Re: Not sure what it's called, I just need a script to change how spells are cast

Post by Guilend »

Vadi wrote:
Wed Sep 19, 2018 7:23 am
I'm guessing you'd like this topic in the help forum?
Sorry, I thought i had posted this in the help section of the forum. It was a late night last night lol.

Guilend
Posts: 36
Joined: Fri Mar 09, 2018 1:21 am

Re: Not sure what it's called, I just need a script to change how spells are cast

Post by Guilend »

"Chant <spell>;cast"
"Point <spell>"
"Read spellbook <spell>"
example:
Code: [show] | [select all] lua
^cwl$ 
         if lastchant == "WERELIGHT" then 
            send("cast") 
               else 
                 send("chant werelight")
                    end
Code: [show] | [select all] lua
^cwl P$ 
           send("point werelight")
Code: [show] | [select all] lua
^cwl b$
           send("read spellbook werelight")
"Chant <spell>;cast <target>"
"Point <spell> <target>"
"Read spellbook <target>"
examples:
Code: [show] | [select all] lua
^hb$ 
         if lastchant == "HANDBURN" then
            send("cast " .. target)
             else
               send("chant handburn")
                 end
Code: [show] | [select all] lua
^hb p$
           send("point handburn " .. target)
^hb b$
send("read spellbook handburn " .. target)
"Chant <spell>;cast <direction>"
"Point <spell> <direction>"
"Read spellbook <spell> <direction>"
examples:
Code: [show] | [select all] lua
^ciw (\w+)$
           if lastchant == "ICEWALL" then
               send("cast " .. matches[2])
                else
                 send("chant icewall")
                   end
Code: [show] | [select all] lua
^ciw p (\w+)$  
           send("point icewall " .. matches[2])
Code: [show] | [select all] lua
^ciw b (\w+)$ 
           send("read spellbook icewall " .. matches[2])

"Chant <spell>;cast <target or myself>"
"Point <spell> <target or myself>"
"Read spellbook <spell> <target or myself>"
examples:
Code: [show] | [select all] lua
^chh$ 
          if lastchant == "HEARING" then
             send("cast " .. target)
               else
                 send("chant hearing")
                   end
Code: [show] | [select all] lua
^chh m$
           if lastchant == "HEARING" then
             send("cast myself")
               else
                send("chant hearing")
                  end
Code: [show] | [select all] lua
^chh p$
          send("point hearing " .. target)
Code: [show] | [select all] lua
^chh pm$ 
           send("point hearing myself")
Code: [show] | [select all] lua
^chh b$
          send("read spellbook hearing " .. target)
Code: [show] | [select all] lua
^chh bm
           send("read spellbook hearing myself")
"Chant <spell>;cast <myself or target02>"
"Point <spell> <myself or target02>"
"Read spellbook <spell> <myself or target02>"
examples:
Code: [show] | [select all] lua
^hh$
          if lastchant == "HEALHAND" then
               send("cast myself")
                 else
                  send("chant healhand")
                    end 
Code: [show] | [select all] lua
^hh t$
          if lastchant == "HEALHAND" then
           send("cast " .. target02)
            else
             send("chant healhand")
               end
Code: [show] | [select all] lua
^hh p$
          send("point healhand myself")
Code: [show] | [select all] lua
^hh pt$
           send("point healhand " .. target02)
Code: [show] | [select all] lua
^hh b$
          send("read spellbook healhand myself")
Code: [show] | [select all] lua
^hh bt
          send("read spellbook healhand " .. target02)
"Chant <spell>;cast <target or target02>"
"Point <spell> <target or target02>"
"Read spellbook <spell> <target or target02>"
examples:
Code: [show] | [select all] lua
^csu$
          if lastchant == "SUMMON" then
             send("cast " .. target)
              else
                send("chant summon")
                  end
Code: [show] | [select all] lua
^csu t$
           if lastchant == "SUMMON" then
            send("cast " .. target02)
             else
              send("chant summon")
               end
Code: [show] | [select all] lua
^csu p$
          send("point summon " .. target)
Code: [show] | [select all] lua
^csu pt$
          send("point summon " .. target02)
Code: [show] | [select all] lua
^csu b$
          send("read spellbook summon " .. target)
Code: [show] | [select all] lua
^csu bt$
          send("read spellbook summon " .. target02)
"Chant <spell>;cast <target>" or "Chant <spell>;cast <target> <direction>"
"Point <spell> <target>" or "Point <spell> <target> <direction>"
"Read spellbook <spell> <target>" or "Read spellbook <spell> <target> <direction>"
examples:
Code: [show] | [select all] lua
^fbt$
           if lastchant == "FIREBOLT" then
              send("cast " .. target")
                else
                  send("chant firebolt")
                     end
Code: [show] | [select all] lua
^fbt (\w+)$
          if lastchant == "FIREBOLT" then
               send("cast " .. target .. " " .. matches[2])
                else
                 send("chant firebolt")
                  end
Code: [show] | [select all] lua
^fbt p$
           send("point firebolt " .. target)
Code: [show] | [select all] lua
^fbt p (\w+)$ 
           send("point firebolt " .. target .. " " .. matches[2])
Code: [show] | [select all] lua
^fbt b$
          send("read spellbook firebolt " .. target)
Code: [show] | [select all] lua
^fbt b (\w+)$ 
          send("read spellbook firebolt " .. target .. " " .. matches[2])
"Chant <spell>;cast <target>" or "Chant <spell>;cast <direction>"
"Point <spell> <target>" or "Point <spell> <direction>"
"Read spellbook <target>" or "Read spellbook <direction>"
examples:
Code: [show] | [select all] lua
^fbl$
          if lastchant == "FIREBALL" then
           send("cast " .. target)
            else
             send("chant fireball")
              end
Code: [show] | [select all] lua
^fbl (\w+)$ 
           if lastchant == "FIREBALL" then
               send("cast " .. matches[2])
                else
                  send("chant fireball")
                   end
Code: [show] | [select all] lua
^fbl p$ 
          send("point fireball " .. target)
Code: [show] | [select all] lua
^fbl p (\w+)$
           send("point fireball " .. matches[2])
Code: [show] | [select all] lua
^fbl b$
           send("read spellbook fireball " .. target)
Code: [show] | [select all] lua
^fbl b (\w+)$
          send("read spellbook fireball " .. matches[2])
"Chant <spell>;cast <matches[2]>"
"Point <spell> <matches[2]>"
"Read spellbook <spell> <matches[2]>"
examples:
Code: [show] | [select all] lua
^cdg (\w+)$
          if lastchant == "DISGUISE" then
             send("cast " .. matches[2])
                else
                 send("chant disguise")
                    end
Code: [show] | [select all] lua
^cdg p (\w+)$
          send("point disguise " .. matches[2])
Code: [show] | [select all] lua
^cdg b (\w+)$
          send("read spellbook disguise " .. matches[2])
"Chant <spell>;cast <target>" or "Chant <spell>;cast <target> <matches[2]>"
"Point <spell> <target>" or "Point <spell> <target> <matches[2]>"
"Read spellbook <spell> <target>" or "Read spellbook <spell> <target> <matches[2]>"
examples:
Code: [show] | [select all] lua
^pj$
         if lastchant == "PROJECTION" then
            send("cast " .. target)
             else
              send("chant projection")
                end
Code: [show] | [select all] lua
^pj (\w+)$
          if lastchant == "PROJECTION" then
              send("cast " .. target .. " " .. matches[2])
               else
                 send("chant projection")
                  end
Code: [show] | [select all] lua
^pj p$
         send("point projection " .. target)
Code: [show] | [select all] lua
^pj p (\w+)$
           send("point projection " .. target .. " " .. matches[2])
Code: [show] | [select all] lua
^pj b$
           send("read spellbook projection " .. target)
Code: [show] | [select all] lua
^pj b (\w+)$ = send("read spellbook projection " .. target .. " " .. matches[2])

Guilend
Posts: 36
Joined: Fri Mar 09, 2018 1:21 am

Re: Not sure what it's called, I just need a script to change how spells are cast

Post by Guilend »

Each example is how it would work if each alias were written. it would be over 100 aliases if that happened. But I what i want to is to be able to combine those into a few scripts, even a script per set of spells. Like have a script just for all the spells that you just cast, point or read, then another script for the ones you cast <target>. point <target> or read spellbook <target>.

But i am open minded at other ways to do this same thing. The reason I have the way i have in the examples is I am a slow typist and I suck at spelling, so having to type out any words, it will not end well. I am dyslexic, so I get words backwords, or the letters in the words mixed up, add that to bad spelling and things get ugly. So while "c blind" would cast/chant blind, it would be hard for me to type under pressure of combat, especially when i start having to type out the longer spells, like projection. I tried something similar for using poisons and in the heat of battle I forgot how to spell poisons lol.

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Not sure what it's called, I just need a script to change how spells are cast

Post by Jor'Mox »

Okay, so it looks like you have four different target possibilities, none, "myself", target, and target02, and you are obviously setting target and target02 some other way. It also looks like there are a greater variety of types of spells than I expected, with some preferring you as a target but able to be cast at target, some preferring target, some preferring target02, etc. But we can work with that.

So what about an alias that looks like this: ^c(\w{2,3})(?: ([pbtm]+))?(?: (\w+))?$
That would give you two or three letters in matches[2] to specify the spell you want to cast, the optional pbtm codes you indicated in matches[3] ("" or nil if nothing is given), and an optional following argument in matches[4] (nil if nothing is given). Then we just need a function that takes those three things and does what you want with them.

This may not be perfect, but I think it should allow for everything you listed, and while it might need some adjustment to what it does, it is probably a good start. Hopefully you will just have to fill in the tables at the top with spells and the abbreviations you want to use for each.
Code: [show] | [select all] lua
-- make tables of different types of spells, one for each way the spells should be handled
local self_spells = {}
local target_spells = {hb = "handburn", fbt = "firebolt", pj = "projection"}
local target_arg_switch_spells = {fbl = "fireball"}
local target_self_spells = {hr = "hearing"} -- I changed "hh" for hearing to "hr" so it wasn't the same as "hh" for healhand
local target2_self_spells = {hh = "healhand"}
local target_switch_spells = {su = "summon"}
local general_spells = {iw = "icewall", wl = "werelight", dg = "disguise"}

function cast_alias(spell, params, arg)
    params = params or ""   -- replaces nil with ""
    -- check for each parameter, and make a variable for each
    local is_point = params:find("p")
    local is_book = params:find("b")
    local is_self = params:find("m")
    local is_target = params:find("t")
    -- store a copy of last chant in all lower case for easy comparison
    local chant = lastchant:lower()
    -- make some variables to use later
    local chant_match = false
    local cmd = ""
    -- now we look to see which category of spells the spell you chose is in to decide how to handle it
    if table.contains(self_spells, spell) then
        spell = self_spells[spell]
        cmd = "" -- didn't see an example of this, so not certain the syntax to use
    elseif table.contains(target_spells, spell) then
        spell = target_spells[spell]
        if arg then
            cmd = " " .. target .. " " .. arg
        else
            cmd = " " .. target
        end
    elseif table.contains(target_arg_switch_spells, spell) then
        spell = target_arg_switch_spells[spell]
        if arg then
            cmd = " " .. arg
        else
            cmd = " " .. target
        end
    elseif table.contains(target_self_spells, spell) then
        spell = target_self_spells[spell]
        if is_self then
            cmd = " myself"
        else
            cmd = " " .. target
        end
    elseif table.contains(target2_self_spells, spell) then
        spell = target2_self_spells[spell]
        if is_self then
            cmd = " myself"
        else
            cmd = " " .. target02
        end
    elseif table.contains(target_switch_spells, spell) then
        spell = target_switch_spells[spell]
        if is_target then
            cmd = " " .. target
        else
            cmd = " " .. target02
        end
    elseif table.contains(general_spells, spell) then
        spell = general_spells[spell]
        if arg then
            cmd = " " .. arg
        else
            cmd = ""
        end
    else -- this is when the spell isn't found
        print("Spell not found.")
        return
    end
    -- now we know WHAT we are doing, we decide how to do it
    if is_point then
        cmd = "point " .. spell .. cmd
    elseif is_book then
        cmd = "read spellbook " .. spell .. cmd
    else
        if spell == chant then
            cmd = "cast " .. cmd
        else
            cmd = "chant " .. spell
        end
    end
    -- now we have put everything together, so we send the command
    send(cmd)
end

Guilend
Posts: 36
Joined: Fri Mar 09, 2018 1:21 am

Re: Not sure what it's called, I just need a script to change how spells are cast

Post by Guilend »

Wow, that looks awesome, and just as complex looking as i figured it would. I am busy right now, but later i will log on and see about getting that fancy do hicky to working. Thank you so much. And i will have tons of questions that i will probably be asking either here or on the discord Mudlet help server.

Post Reply