to freeze monster groups

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
AdrianKnight
Posts: 21
Joined: Wed Aug 30, 2017 9:21 pm

to freeze monster groups

Post by AdrianKnight »

Hello.

I noticed that in Grimrock 2 it is not possible to freeze monster groups.
In your opinion, is it possible to allow freezing monster groups modifying some scripts in my custom dungeon ?
How could it be possible ?

Thank you.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: to freeze monster groups

Post by Isaac »

I think it may have something to do with restoring a multi-textured monster's original materials after the thaw. Certain monsters cannot be frozen for that reason; or it may just be to avoid the need to account for one frozen monster in a group.
AdrianKnight
Posts: 21
Joined: Wed Aug 30, 2017 9:21 pm

Re: to freeze monster groups

Post by AdrianKnight »

I have not found a solution to freeze monster groups.
I think i will not put monster groups in my custom dungeon, or i will give all monster races included in monster groups immunity to freezing (if they don't already have it ). In this way, i could make my custom dungeon's logic more coherent.

Thank you.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: to freeze monster groups

Post by akroma222 »

Just an idea....
One possible way to hack around this could be to use the ice_cube model
(this model is used in AndakRainor's spell pack for an.... Ice Cube related spell)

If monsters are in a group and would be frozen > cancel the freeze component
spawn the ice_cube model over them and disable their brains

Sorry if this is vague...
I haven't explored the ice_cube model, nor Andak's spell he uses it in
It may be worth downloading his spell pack and taking a look :)

Akroma
User avatar
THOM
Posts: 1266
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: to freeze monster groups

Post by THOM »

Monsters, which have disabled brains are not frozen, they still move in their idle-animation.

Disableing their animation-component could have weired results...
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: to freeze monster groups

Post by akroma222 »

THOM wrote:Monsters, which have disabled brains are not frozen, they still move in their idle-animation.

Disableing their animation-component could have weired results...
Very true - probably more trouble than its worth in that case.
Cheers THOM!
User avatar
Leki
Posts: 550
Joined: Wed Sep 12, 2012 3:49 pm

Re: to freeze monster groups

Post by Leki »

AdrianKnight wrote:Hello.

I noticed that in Grimrock 2 it is not possible to freeze monster groups.
In your opinion, is it possible to allow freezing monster groups modifying some scripts in my custom dungeon ?
How could it be possible ?

Thank you.

you are looking for: monster:setCondition("frozen", 4)
just go through monsters on the cells ang give them this one

Overload frostbolt spell with your own definition loaded in init.lua (open frostbolt from assetpack), here is pseudo code, you have to write real code:

Code: Select all

defineObject{
	name = "frostbolt_blast",
	baseObject = "base_spell",
	components = {
		{
			class = "Particle",
			particleSystem = "frostbolt_hit",
			destroyObject = true,
		},
		{
			class = "Light",
			color = vec(0.25, 0.5, 1),
			brightness = 40,
			range = 10,
			fadeOut = 0.5,
			disableSelf = true,
		},
		{
			class = "TileDamager",
			attackPower = 10,
			damageType = "cold",
			sound = "frostbolt_hit",
			onHitMonster = function(self, monster)
				if math.random() < 0.25 then -- here set % chance for freeze
                                        -- get monster position
                                            -- for each entity at cell loop
                                                -- if its monster then
                                                        monster:setCondition("frozen", 4)
                                                -- close if
                                            -- close loop
				end
			end,
		},
	},
}
if you wanna your own custom setCondition("frozen",time), then my method is to use onHit
spawn timer
go through cell, for each monster do
monster.brain:disable()
monster.animation:setMaxUpdateDistance(0)
monster.model:setMaterial(material)

when timer is done, for each monster on cell do
monster.brain:enable()
monster.animation:setMaxUpdateDistance(32)
monster.model:setMaterial(originalmaterial)
destroy timer

[/color]
I'm the Gate I'm the Key.
Dawn of Lore
AdrianKnight
Posts: 21
Joined: Wed Aug 30, 2017 9:21 pm

Re: to freeze monster groups

Post by AdrianKnight »

Thank you.
Unfortunately, i have only a basic knowledge of modding. So, i don't know exactly how to carry out the following actions:

-- get monster position
-- for each entity at cell loop

-- go through cell, for each monster do

Could someone explain me how to write these commands ?

Thank you for your help.
User avatar
Isaac
Posts: 3172
Joined: Fri Mar 02, 2012 10:02 pm

Re: to freeze monster groups

Post by Isaac »

  • Get monster position:
    The findEntity function will give access to the monster by id, if it exists.

    Code: Select all

    findEntity( "my_monster_id" )
    
    SpoilerShow
    From there it depends on what information you are interested in.

    Code: Select all

    
    do
    
    	print( findEntity("air_elemental_1").name )
    	
    end	
    
    
    
    do
    	local monster = findEntity("air_elemental_1") 
    	print( monster.name, monster.level, monster.x, monster.y, monster.facing, monster.elevation )
    end
    
  • For each entity at cell loop:
    You need a map component for this function.
    SpoilerShow

    Code: Select all

    for entity in party.map:entitiesAt(15,15) do
    	print( entity.name, entity:getPosition() )
    end  print("---")
    
    for entity in torch_holder_1.map:entitiesAt(15,15) do
    	print( entity.name, entity:getPosition() ) 
    end  print("---")
    
    for entity in Dungeon.getMap(1):entitiesAt(15,15) do
    	print( entity.name, entity:getPosition() )
    end  print("---")
    
  • Go through cell, for each monster do:
    This normally only applies to monster groups, and they will show up as a single (grouped) object. If you just want to count them, then the monster's monstergroup component offers that.

    Code: Select all

    zarchton_pair_1:monstergroup:getCount()
    
    SpoilerShow

    Code: Select all

    do
    	--choose your location
    	local map, x, y = 1, 15, 14 
    	
    	local cell = Dungeon.getMap(map):entitiesAt(x, y)
    	for monster in cell do
    		if monster.monstergroup then --checking for .monstergroup component
    			local entityType = monster.monstergroup:getMonsterType()
    			
    			--print to console----------------------------------		
    				if type(entityType)=='table' then
    					entityType = tostring(unpack(entityType)) 
    				end
    				print( monster.name..": comprised of "..monster.monstergroup:getCount().." "..entityType )
    			
    			--print to hud--
    				entityType = entityType:match("%D+") --strips numbers
    				entityType = iff(entityType:find('y',-1),entityType:sub(1,-2)..'ies',entityType..'s')
    				hudPrint(  monster.name..": comprised of "..monster.monstergroup:getCount().." "..entityType )
    			----------------------------------------------------		
    		end	
    	end
    end
    
    
AdrianKnight
Posts: 21
Joined: Wed Aug 30, 2017 9:21 pm

Re: to freeze monster groups

Post by AdrianKnight »

Thank you.
Post Reply