Magic Ladder

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
User avatar
QuintinStone
Posts: 72
Joined: Sat Nov 01, 2014 9:58 pm

Magic Ladder

Post by QuintinStone »

Working with some magic bridges, so I figured a magic ladder would go well with them.

Image

Particle:

Code: Select all

defineParticleSystem{
	name = "magic_ladder",
	emitters = {
		{
			velocity = {
				0.1,
				0.4
			},
			lifetime = {
				3,
				3
			},
			maxParticles = 100,
			rotationSpeed = 0.3,
			blendMode = "Additive",
			emitterShape = "MeshShape",
			airResistance = 0.1,
			emissionRate = 10,
			size = {
				1,
				2
			},
			fadeIn = 2,
			gravity = {
				0,
				0,
				0
			},
			color0 = {
				0.15,
				0.1,
				0.125
			},
			objectSpace = true,
			fadeOut = 2,
			sprayAngle = {
				0,
				360
			},
			texture = "assets/textures/particles/fog.tga",
			emissionTime = 0,
			opacity = 0.2
		},
		{
			velocity = {
				0,
				0.1
			},
			lifetime = {
				1,
				1.7
			},
			maxParticles = 200,
			rotationSpeed = 2,
			blendMode = "Additive",
			emitterShape = "MeshShape",
			airResistance = 0.1,
			emissionRate = 100,
			size = {
				0.05,
				0.15
			},
			fadeIn = 0.1,
			gravity = {
				0,
				-0.5,
				0
			},
			color0 = {
				1.5,
				1,
				1.25
			},
			objectSpace = true,
			fadeOut = 0.5,
			sprayAngle = {
				0,
				30
			},
			texture = "assets/textures/particles/glitter_silver.tga",
			emissionTime = 0,
			opacity = 1
		},
		{
			velocity = {
				0,
				0.1
			},
			lifetime = {
				1,
				1
			},
			maxParticles = 400,
			rotationSpeed = 2,
			blendMode = "Additive",
			emitterShape = "MeshShape",
			airResistance = 0.1,
			emissionRate = 400,
			size = {
				0.05,
				0.25
			},
			fadeIn = 0.1,
			gravity = {
				0,
				-0.2,
				0
			},
			color0 = {
				2.25,
				1.5,
				1.875
			},
			objectSpace = true,
			fadeOut = 0.5,
			sprayAngle = {
				0,
				30
			},
			texture = "assets/textures/particles/glitter_silver.tga",
			emissionTime = 0,
			opacity = 1
		}
	}
}
Object:

Code: Select all

defineObject{
	components = {
		{
			name = "model",
			model = "assets/models/env/ladder_metal.fbx",
			enabled = false,
			storeSourceData = true,
			class = "Model"
		},
		{
			name = "ladder",
			class = "Ladder"
		},
		{
			name = "particle",
			class = "Particle",
			emitterMesh = "assets/models/env/ladder_metal.fbx",
			particleSystem = "magic_ladder"
		},
	},
	baseObject = "base_wall_decoration",
	editorIcon = 248,
	name = "ladder_magic",
	automapIcon = 140
}
Crypt of Zulfar
User avatar
MadCatter
Posts: 34
Joined: Mon Nov 03, 2014 5:02 am
Location: Southampton, UK

Re: Magic Ladder

Post by MadCatter »

That looks great!

So, in theory could you use the same technique to make a particle version of any object in the game?
So many ideas :D
User avatar
QuintinStone
Posts: 72
Joined: Sat Nov 01, 2014 9:58 pm

Re: Magic Ladder

Post by QuintinStone »

MadCatter wrote:That looks great!

So, in theory could you use the same technique to make a particle version of any object in the game?
So many ideas :D
Definitely.
Crypt of Zulfar
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Magic Ladder

Post by GoldenShadowGS »

I'm going to turn this into a castable spell.
edit:
Add this to model and particle so its not inside the walls.

Code: Select all

offset = vec(0,0,-0.4),
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Magic Ladder

Post by minmay »

QuintinStone wrote:
MadCatter wrote:That looks great!

So, in theory could you use the same technique to make a particle version of any object in the game?
So many ideas :D
Definitely.
Well, you can't use MeshShape to make a "particle version" of an animated object. You need UggardianFlamesComponent for that, which is a bit harder (it at least seems to require a MonsterComponent and a working monster mesh). Also, unlike a ParticleComponent, you can't add an UggardianFlamesComponent to an object dynamically (the particle effect won't play). However, you can dynamically change the particle system (but not the EmitFromMaterial), so it's still pretty flexible.
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.
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Magic Ladder

Post by Grimfan »

Great work Quintin! I know exactly where this is going in my mod. :)
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Magic Ladder

Post by GoldenShadowGS »

Castable Magic Ladder! Cast it with the rune symbols 7 8 5 6 3. It makes a stair step pattern. Requires concentration 2 and air magic 2
Only valid locations will summon a ladder. You can only cast it against a wall and the elevation above you must be accessible to drop down from by one level to be considered a valid location.


Name a script entity "ladder_remover_script" in your dungeon somewhere and paste the following script into it.

Code: Select all

function removeladder()
	if magic_spell_ladder ~= nil then
		magic_spell_ladder:destroyDelayed(.01)
		playSound("spell_expires")
	end
	if magic_spell_ladder_trigger ~= nil then
		magic_spell_ladder_trigger:destroyDelayed(.01)
	end
end

function checkladder(caster)
	if magic_spell_ladder ~= nil then
		if party.party:getChampion(caster):getEnergy() >= 5 then
			if magic_spell_ladder_trigger.floortrigger:isActivated() then
				delayedCall("ladder_remover_script",0.1,"checkladder", caster)
			else
				delayedCall("ladder_remover_script",0.1,"checkladder", caster)
				party.party:getChampion(caster):regainEnergy(-1)
			end
		else
			removeladder()
		end
	end
end
Paste the following code into spells.lua

Code: Select all

defineSpell{
	name = "magic_ladder_spell",
	uiName = "Magic Ladder",
	skill = "air_magic",
	requirements = {"air_magic", 2, "concentration", 2},
	gesture = 78563,
	manaCost = 10,
	icon = 14,
	spellIcon = 13,
	description = "Conjure a magical ladder in front of the party.",
    onCast = function(champion, x, y, direction, elevation, skillLevel)
		local myx = x
		local myy = y
		if direction == 0 then
			myy = y - 1
		end
		if direction == 1 then
			myx = x + 1
		end
		if direction == 2 then
			myy = y + 1
		end
		if direction == 3 then
			myx = x - 1
		end
		if findEntity("magic_spell_ladder") == nil then
			local ladderelevation = party.map:getElevation(myx,myy)
			local ladderceiling = party.map:getCeilingElevation(myx,myy)
			local partyceiling = party.map:getCeilingElevation(x,y)
			local hasladder = false
			local wall = false
			for i in party.map:entitiesAt(x,y) do
				if i.elevation == elevation then	
					if i.name == "ladder" or i.name == "ladder_magic" or i.name == "ladder_metal" or i.name == "ladder_metal_4m" then
						if i.facing == direction then
							hasladder = true
						end
					end
				end
			end
			if party.map:checkLineOfSight(x,y,myx,myy,elevation) then
			else
				wall = true
			end
			if ladderelevation == elevation + 1 and ladderceiling > ladderelevation and ladderceiling > elevation + 1 and hasladder == false and partyceiling >= elevation + 2 and wall == true and  party.map:checkLineOfSight(x,y,myx,myy,elevation+1) then
				spawn("ladder_magic",party.level,x,y,direction,elevation,"magic_spell_ladder")
				local ele2 = elevation + 1
				spawn("floor_trigger",party.level,x,y,direction,ele2, "magic_spell_ladder_trigger")
				magic_spell_ladder_trigger.floortrigger:setTriggeredByDigging(false)
				magic_spell_ladder_trigger.floortrigger:setTriggeredByItem(false)
				magic_spell_ladder_trigger.floortrigger:setTriggeredByMonster(false)
				magic_spell_ladder_trigger.floortrigger:setTriggeredByParty(true)
				magic_spell_ladder_trigger.floortrigger:addConnector("onDeactivate", "ladder_remover_script", "removeladder")
				delayedCall("ladder_remover_script",0.1,"checkladder", champion:getOrdinal())
				playSound("generic_spell")
			else
				hudPrint("You can not create a magic ladder here.")
				playSound("spell_fizzle")
			end
		else
			delayedCall("ladder_remover_script",0.1,"removeladder")
			playSound("spell_fizzle")
		end
	end,
}
Paste the following into materials.lua

Code: Select all

defineParticleSystem{
   name = "magic_ladder",
   emitters = {
      {
         velocity = {
            0.1,
            0.4
         },
         lifetime = {
            3,
            3
         },
         maxParticles = 100,
         rotationSpeed = 0.3,
         blendMode = "Additive",
         emitterShape = "MeshShape",
         airResistance = 0.1,
         emissionRate = 10,
         size = {
            1,
            2
         },
         fadeIn = 2,
         gravity = {
            0,
            0,
            0
         },
         color0 = {
            0.15,
            0.1,
            0.125
         },
         objectSpace = true,
         fadeOut = 2,
         sprayAngle = {
            0,
            360
         },
         texture = "assets/textures/particles/fog.tga",
         emissionTime = 0,
         opacity = 0.2
      },
      {
         velocity = {
            0,
            0.1
         },
         lifetime = {
            1,
            1.7
         },
         maxParticles = 200,
         rotationSpeed = 2,
         blendMode = "Additive",
         emitterShape = "MeshShape",
         airResistance = 0.1,
         emissionRate = 100,
         size = {
            0.05,
            0.15
         },
         fadeIn = 0.1,
         gravity = {
            0,
            -0.5,
            0
         },
         color0 = {
            1.5,
            1,
            1.25
         },
         objectSpace = true,
         fadeOut = 0.5,
         sprayAngle = {
            0,
            30
         },
         texture = "assets/textures/particles/glitter_silver.tga",
         emissionTime = 0,
         opacity = 1
      },
      {
         velocity = {
            0,
            0.1
         },
         lifetime = {
            1,
            1
         },
         maxParticles = 400,
         rotationSpeed = 2,
         blendMode = "Additive",
         emitterShape = "MeshShape",
         airResistance = 0.1,
         emissionRate = 400,
         size = {
            0.05,
            0.25
         },
         fadeIn = 0.1,
         gravity = {
            0,
            -0.2,
            0
         },
         color0 = {
            2.25,
            1.5,
            1.875
         },
         objectSpace = true,
         fadeOut = 0.5,
         sprayAngle = {
            0,
            30
         },
         texture = "assets/textures/particles/glitter_silver.tga",
         emissionTime = 0,
         opacity = 1
      }
   }
}

Paste the following into objects.lua

Code: Select all

defineObject{
	components = 
	{
		{
			name = "model",
			model = "assets/models/env/ladder_metal.fbx",
			enabled = false,
			storeSourceData = true,
			class = "Model",
			offset = vec(0,0,-0.4),
		},
		{
			name = "ladder",
			class = "Ladder"
		},
		{
			name = "particle",
			class = "Particle",
			emitterMesh = "assets/models/env/ladder_metal.fbx",
			particleSystem = "magic_ladder",
			offset = vec(0,0,-0.4),
		},
	},
	baseObject = "base_wall_decoration",
	editorIcon = 248,
	name = "ladder_magic",
	automapIcon = 140
}
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: Magic Ladder

Post by Drakkan »

wow cool, I have some interesting ideas in my head. thanks !
Breath from the unpromising waters.
Eye of the Atlantis
User avatar
QuintinStone
Posts: 72
Joined: Sat Nov 01, 2014 9:58 pm

Re: Magic Ladder

Post by QuintinStone »

minmay wrote:Well, you can't use MeshShape to make a "particle version" of an animated object. You need UggardianFlamesComponent for that, which is a bit harder (it at least seems to require a MonsterComponent and a working monster mesh). Also, unlike a ParticleComponent, you can't add an UggardianFlamesComponent to an object dynamically (the particle effect won't play). However, you can dynamically change the particle system (but not the EmitFromMaterial), so it's still pretty flexible.
With the assets script pack released, it should be pretty straightforward to see how to apply Air Elemental effects to other monster definitions.
Crypt of Zulfar
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Magic Ladder

Post by minmay »

The Air Elemental effect is an UggardianFlamesComponent.
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.
Post Reply