Anti-Light Spell Script?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Duncan_B
Posts: 31
Joined: Wed Dec 19, 2012 8:43 pm
Location: Santa Cruz, Calif.-- USA

Anti-Light Spell Script?

Post 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.
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Anti-Light Spell Script?

Post 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 :)
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Duncan_B
Posts: 31
Joined: Wed Dec 19, 2012 8:43 pm
Location: Santa Cruz, Calif.-- USA

Re: Anti-Light Spell Script?

Post by Duncan_B »

Where can I find the asset pack? (edit: never mind, found it!)
User avatar
Duncan_B
Posts: 31
Joined: Wed Dec 19, 2012 8:43 pm
Location: Santa Cruz, Calif.-- USA

Re: Anti-Light Spell Script?

Post 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!)
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Anti-Light Spell Script?

Post by Komag »

simpler to use the party definition onCast hook, and if the spellname is light just return false
Finished Dungeons - complete mods to play
User avatar
Duncan_B
Posts: 31
Joined: Wed Dec 19, 2012 8:43 pm
Location: Santa Cruz, Calif.-- USA

Re: Anti-Light Spell Script?

Post 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?
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: Anti-Light Spell Script?

Post 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
User avatar
Duncan_B
Posts: 31
Joined: Wed Dec 19, 2012 8:43 pm
Location: Santa Cruz, Calif.-- USA

Re: Anti-Light Spell Script?

Post 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.
Post Reply