Ask a simple question, get a simple answer

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
Thorham
Posts: 80
Joined: Sat May 04, 2013 5:12 pm

Re: Ask a simple question, get a simple answer

Post by Thorham »

LunasC wrote:has anyone gotten one shot spell scrolls worked out?
Seems you have to make an equipment item that looks like a scroll and handle stacks with a party script. This is not well tested, so mess around with it a little to make sure it works properly. It's also a little rough around the edges, but it should serve as a basis.

Edit:

Removed scripts.

Minmay helped refine the scroll script. No need for a party script anymore. See my post farther down.
Last edited by Thorham on Tue Dec 29, 2015 12:12 am, edited 2 times in total.
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Just give the CastSpellComponent a single charge.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Thorham
Posts: 80
Joined: Sat May 04, 2013 5:12 pm

Re: Ask a simple question, get a simple answer

Post by Thorham »

minmay wrote:Just give the CastSpellComponent a single charge.
That's possible, but you don't get nicely stackable scrolls like that. Depends on what's needed.
minmay
Posts: 2768
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

It's the easiest way to make a one-shot spell scroll. Make it like a lightning rod or whatever, but with only one charge.

If you want the stacking behaviour instead then it's better to use ItemActionComponent.onAttack() instead of PartyComponent.onAttack().
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Thorham
Posts: 80
Joined: Sat May 04, 2013 5:12 pm

Re: Ask a simple question, get a simple answer

Post by Thorham »

minmay wrote:It's the easiest way to make a one-shot spell scroll. Make it like a lightning rod or whatever, but with only one charge.
Yes, but making the scrolls consumable items seems nicer.
minmay wrote:If you want the stacking behaviour instead then it's better to use ItemActionComponent.onAttack() instead of PartyComponent.onAttack().
Thanks, didn't see it.

Here's the final scroll:

Code: Select all

defineObject{
    name = "fireball_scroll",
    baseObject = "base_item",
    components = {
        {
            class = "Model",
            model = "assets/models/items/scroll.fbx",
        },
        {
            class = "Item",
            uiName = "Scroll of Fireball",
            description = "",
            gfxIndex = 112,
            weight = 0.3,
            PrimaryAction = "cast_fireball",
            stackable = true,
        },
        {
            class = "CastSpell",
            name = "cast_fireball",
            cooldown = 2,
            spell = "fireball",
            energyCost = 0,
            power = 1,

            onAttack = function(self, champion, slot, chainIndex)
                local a = self.go.item
                local b = a:getStackSize() - 1

                if b < 1 then
                    champion:removeItemFromSlot(slot)
                else
                    a:setStackSize(b)
                end
            end,
        },
    },
}
User avatar
LunasC
Posts: 38
Joined: Sun Feb 10, 2013 1:46 pm

Re: Ask a simple question, get a simple answer

Post by LunasC »

Thorham wrote:
minmay wrote:It's the easiest way to make a one-shot spell scroll. Make it like a lightning rod or whatever, but with only one charge.
Yes, but making the scrolls consumable items seems nicer.
minmay wrote:If you want the stacking behaviour instead then it's better to use ItemActionComponent.onAttack() instead of PartyComponent.onAttack().
Thanks, didn't see it.

Here's the final scroll:

Code: Select all

defineObject{
    name = "fireball_scroll",
    baseObject = "base_item",
    components = {
        {
            class = "Model",
            model = "assets/models/items/scroll.fbx",
        },
        {
            class = "Item",
            uiName = "Scroll of Fireball",
            description = "",
            gfxIndex = 112,
            weight = 0.3,
            PrimaryAction = "cast_fireball",
            stackable = true,
        },
        {
            class = "CastSpell",
            name = "cast_fireball",
            cooldown = 2,
            spell = "fireball",
            energyCost = 0,
            power = 1,

            onAttack = function(self, champion, slot, chainIndex)
                local a = self.go.item
                local b = a:getStackSize() - 1

                if b < 1 then
                    champion:removeItemFromSlot(slot)
                else
                    a:setStackSize(b)
                end
            end,
        },
    },
}


you guys rock! best of all I can actually understand that code enough to learn from it. Thank you !
rsdworker
Posts: 8
Joined: Fri Mar 02, 2012 2:18 pm

Re: Ask a simple question, get a simple answer

Post by rsdworker »

i have question

how i make small buildings with walls around and forest around - i had ran in few problems - the walls was gone when i linked the forest tiles
User avatar
Thorham
Posts: 80
Joined: Sat May 04, 2013 5:12 pm

Re: Ask a simple question, get a simple answer

Post by Thorham »

I have a defineSpell with an onCast event where I want to call a function in that same script using delayedCall. How do I reference the script without self? Self doesn't seem to exist here.

This script is part of the scripts that are called through init.lua.

Something like this:

Code: Select all

local test = function()
    print("bla")
end

defineSpell{
    bla
    bla

    onCast = function(champion, x, y, direction, elevation, skillLevel)
        delayedCall(self.go.id, 1, "test") -- self doesn't exist
    end
end
I currently get around this by using delayedCall to call a function in a different script. This works, but isn't as nice as having everything in one script.
User avatar
LunasC
Posts: 38
Joined: Sun Feb 10, 2013 1:46 pm

Re: Ask a simple question, get a simple answer

Post by LunasC »

rsdworker wrote:i have question

how i make small buildings with walls around and forest around - i had ran in few problems - the walls was gone when i linked the forest tiles

Up load an example screen shot, I have run into a few problems like this and I might be able to help.
User avatar
LunasC
Posts: 38
Joined: Sun Feb 10, 2013 1:46 pm

Re: Ask a simple question, get a simple answer

Post by LunasC »

I'm new to this stuff, I have been working my way through the scripRef but there are things I just don't understand at all.
I am trying to make this little script do a few things and I have only been able to get what is here to work and nothing else.
Atop that.. the damageFlag section of the script either is not working or I really am confused. I understand that it is bits, but I have
no earthly idea how to get what I want out of it. I tried to add the bits together and got nothing, I tried just putting them all in there at once - 264256 that did not work.
I tried adding them in the binary -I dont even remember the binary number I got... I tried adding commas and quotes and I even tried to bribe my computer with a dollar I found.

I just don't seem to get it. My goal is:

♦ Ongoing damage for a 3 seconds at a power of 5.

♦ A red screen flash something like "Damage_screen".

♦ and ignore for damage resistance.

After that is all done ill pop a hudPrint in there for the party to wise crack about burning fingers and it will be done.

Here is the code so far.

SpoilerShow
function BurntFingers()

damageTile(1, 3, 6, 3, 0, 2, "fire", 5)

end

Sorry to keep asking for things.
Each time I get help I learn something new that I dont have to ask again.
Post Reply