Page 1 of 1

to freeze monster groups

Posted: Wed Aug 30, 2017 10:07 pm
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.

Re: to freeze monster groups

Posted: Thu Aug 31, 2017 12:41 am
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.

Re: to freeze monster groups

Posted: Tue Sep 05, 2017 9:19 pm
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.

Re: to freeze monster groups

Posted: Thu Sep 07, 2017 1:21 pm
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

Re: to freeze monster groups

Posted: Thu Sep 07, 2017 3:09 pm
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...

Re: to freeze monster groups

Posted: Thu Sep 07, 2017 4:32 pm
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!

Re: to freeze monster groups

Posted: Wed Sep 13, 2017 11:54 pm
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]

Re: to freeze monster groups

Posted: Tue Oct 17, 2017 1:13 pm
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.

Re: to freeze monster groups

Posted: Wed Oct 18, 2017 12:53 am
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
    
    

Re: to freeze monster groups

Posted: Wed Nov 01, 2017 3:31 pm
by AdrianKnight
Thank you.