question on dying and ressurection

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!
Post Reply
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

question on dying and ressurection

Post by kelly1111 »

Hello There,

Is there a simple way to make a script that would do the following:

party steps inside a room (or on a certain tile): dies
and when the party dies, do not go to the game over screen but teleport them full health to another place in the dungeon?
Would this be possible to overide, or is the game over screen thing hard coded?
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: question on dying and ressurection

Post by Azel »

I believe minmay boasted of accomplishing this very thing, as a feature of boss battles in his someday-soon to be released mod. Maybe he'll share it with ya! ;)

As for insta-death, I believe this has been accomplished and solution sits somewhere in these threads. If I recall, you will need to do tile damage that reduces all party members health to 0
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: question on dying and ressurection

Post by Drakkan »

there is a onpartydie hook I believe so with little scripting this could be possible I think
Breath from the unpromising waters.
Eye of the Atlantis
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: question on dying and ressurection

Post by kelly1111 »

Any help to get started minmay :) ?
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: question on dying and ressurection

Post by minmay »

Just use PartyComponent.onDie(). Check if there are no other living champions left, and if so, do your teleport/heal/whatever and return false.
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
Zo Kath Ra
Posts: 944
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: question on dying and ressurection

Post by Zo Kath Ra »

Put this in your mod's init.lua:

Code: Select all

defineObject{
    name = "party",
    baseObject = "party",
    components = {
        {
            class = "Party",
            
            onDie = function(self, champion)
                local living_champions = 0
                
                for i = 1, 4 do
                    if (party.party:getChampionByOrdinal(i):isAlive()) then
                        living_champions = living_champions + 1
                    end
                end
                
                if (living_champions == 0) then
                    party:setPosition(starting_location_1.x, starting_location_1.y, starting_location_1.facing, starting_location_1.elevation, starting_location_1.level)
                    party.party:heal()
                end
            end,
        }
    }
}
kelly1111
Posts: 349
Joined: Sun Jan 20, 2013 6:28 pm

Re: question on dying and ressurection

Post by kelly1111 »

Thanks alot zo kath ra. One question tho,

what if I want to make it a one time use only ?
say for instance only in a certain area or if a certain counter is at a certain number?

is that possible?
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: question on dying and ressurection

Post by Azel »

You can probably just add to the "IF" statement,

So this:

Code: Select all

if (living_champions == 0) then
becomes something like this:

Code: Select all

if (living_champions == 0 AND mySpecialDeathCounter.counter:getValue() == 1) then
Just modify that to check for whatever value your Counter should be to allow for this circumstance. That should work!
Post Reply