Page 1 of 1

Anti-Light Spell Script?

Posted: Wed Dec 19, 2012 8:49 pm
by Duncan_B
Hello, all. I'm a complete newbie to scripting in LUA and curious about how I might create a script that would prevent players from casting the Light spell. I saw a script for anti-magic, but I'm only interested in blocking this particular spell. Any suggestions? My apologies if this has been covered elsewhere.

Re: Anti-Light Spell Script?

Posted: Wed Dec 19, 2012 8:59 pm
by msyblade
get the LoG asset pack and find "scripts/spells.lua" file and open it. find the light spell in there and copy it. Then go to your "mod_assets/scripts/spells.lua" file and insert the copy. You can then edit the spell however you like. One of the later lines is "onCast", change that from "Light" to "Darkness", and when they try to cast light, it won't work, in fact, if they try again, it will extinguish their torches, I believe. You can also just change the name of the spell to Destroy Light, or something and give the player a surprise when they cast it. Note: All assets can be altered in this way :)

Re: Anti-Light Spell Script?

Posted: Wed Dec 19, 2012 9:12 pm
by Duncan_B
Where can I find the asset pack? (edit: never mind, found it!)

Re: Anti-Light Spell Script?

Posted: Wed Dec 19, 2012 10:01 pm
by Duncan_B
Hmm... I've copied the text for the light spell into "mod_assets\scripts\spells.lua". I changed uiName to "Destroy Light" and onCast to "darkness," but when I cast I'm still getting "Discovered New Spell: Light" and... well, light. What might I be doing wrong?

(edit: fixed, just had to reload my game... thanks for your help!)

Re: Anti-Light Spell Script?

Posted: Wed Dec 19, 2012 11:17 pm
by Komag
simpler to use the party definition onCast hook, and if the spellname is light just return false

Re: Anti-Light Spell Script?

Posted: Thu Dec 20, 2012 2:04 am
by Duncan_B
Okay. That sounds like the sort of thing I need, but I'm afraid I'm at a loss for how to implement it. With apologies-- still totally new-- what would the code for that look like?

Re: Anti-Light Spell Script?

Posted: Thu Dec 20, 2012 3:06 am
by Diarmuid
There:

Code: Select all

cloneObject{
    name = "party",
    baseObject = "party",
    onCastSpell = function(champion, spellName)
        if spellName == 'light' then
            hudPrint("You cannot cast light spells, mouahahaha...")
            return false
        end
    end,
}
:)

PS: Bookmark this, a very useful resource: https://sites.google.com/site/jkosgrimr ... heat-sheet

Re: Anti-Light Spell Script?

Posted: Thu Dec 20, 2012 3:44 am
by Duncan_B
Diarmuid wrote: PS: Bookmark this, a very useful resource: https://sites.google.com/site/jkosgrimr ... heat-sheet
Thanks! This helps a lot and will no doubt cut down on my pesky questions. I appreciate everyone's help.