Confining a Viper Root to an area

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
Zo Kath Ra
Posts: 863
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Confining a Viper Root to an area

Post by Zo Kath Ra » Sun Jan 14, 2018 9:55 am

Blockers prevent monsters from moving onto tiles.
You can put a fence of blockers around a monster to prevent it from leaving an area.

But this doesn't work with Viper Roots, because they teleport.
I could put a blocker onto every tile where the VR is not supposed to go, or modify its brain.
Is there a simpler solution?

User avatar
Isaac
Posts: 2994
Joined: Fri Mar 02, 2012 10:02 pm

Re: Confining a Viper Root to an area

Post by Isaac » Sun Jan 14, 2018 11:27 am

Pit components

User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Confining a Viper Root to an area

Post by zimberzimber » Sun Jan 14, 2018 9:55 pm

Isaac wrote:Pit components
Would that prevent them from chasing you if you're not near a pit component like a wall would, or will it just prevent them from appearing on the tiles with the pit components?
My asset pack [v1.10]
Features a bit of everything! :D

User avatar
Isaac
Posts: 2994
Joined: Fri Mar 02, 2012 10:02 pm

Re: Confining a Viper Root to an area

Post by Isaac » Mon Jan 15, 2018 9:49 am

AFAIK, it prevents them from appearing on any tile with a (closed) pit.

User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Confining a Viper Root to an area

Post by zimberzimber » Mon Jan 15, 2018 4:38 pm

There's also the Viper Root I made for someone a long time ago which binds it to a specific elevation:

Code: Select all

--	This Viper Root will only attack the party if they're on the elevetion it was bound to. (through the counter named boundElevation)
--	Otherwise a regular Viper Root.
--	May linger to other elevations for just one attack when the party leaves the bound elevation
--	Will then burrow and wait for the party to appear on the bound elevation.
--	If it was above ground when party ascended an elevation, it will force-burrow itself through the brain function.
--	When the party returns to the bound elevation, it will play the burrow action again. Will have no effect, other than playing the sound.
defineObject{
	name = "viper_root_bound",
	baseObject = "base_monster",
	components = {
		{
			class = "Model",
			model = "assets/models/monsters/viper_root.fbx",
			storeSourceData = true,
		},
		{
			class = "Animation",
			animations = {
				idle = "assets/animations/monsters/viper_root/viper_root_idle.fbx",
				rise = "assets/animations/monsters/viper_root/viper_root_rise.fbx",
				descend = "assets/animations/monsters/viper_root/viper_root_descend.fbx",
				attack = "assets/animations/monsters/viper_root/viper_root_attack.fbx",
				attackFromBehind = "assets/animations/monsters/viper_root/viper_root_attack_from_behind.fbx",
				spit = "assets/animations/monsters/viper_root/viper_root_spit.fbx",
				getHitFrontLeft = "assets/animations/monsters/viper_root/viper_root_get_hit_front_left.fbx",
				getHitFrontRight = "assets/animations/monsters/viper_root/viper_root_get_hit_front_right.fbx",
				getHitBack = "assets/animations/monsters/viper_root/viper_root_get_hit_back.fbx",
				getHitLeft = "assets/animations/monsters/viper_root/viper_root_get_hit_left.fbx",
				getHitRight = "assets/animations/monsters/viper_root/viper_root_get_hit_right.fbx",
				fall = "assets/animations/monsters/viper_root/viper_root_get_hit_front_left.fbx",
				idleAction = "assets/animations/monsters/viper_root/viper_root_idle.fbx",
			},
			currentLevelOnly = true,
		},
		{
			class = "Monster",
			meshName = "viper_root_mesh",
			hitSound = "viper_root_hit",
			dieSound = "viper_root_die",
			hitEffect = "hit_goo",
			capsuleHeight = 0.2,
			capsuleRadius = 0.7,
			health = 500,
			protection = 0,
			evasion = 0,
			exp = 250,
			immunities = { "sleep", "blinded", "knockback" },
			resistances = { ["fire"] = "weak" },
			onInit = function(self)
				local dir = getDirection(party.x - self.go.x, party.y - self.go.y)
				self.go:setPosition(self.go.x, self.go.y, dir, self.go.elevation, self.go.level)
				self:performAction("rise")
			end,
			headRotation = vec(90, 0, 0),
		},
		{
			class = "ViperRootBrain",
			name = "brain",
			sight = 5,
			morale = 100,   -- fearless
			onThink = function(self)
				local e = self.go.boundElevation:getValue()
				if party.elevation ~= e then
					if self.go.burrowed:isEnabled() then
						return self:performAction("idleAction")
					else
						return self:performAction("descend")
					end
				end
			end,
		},
		{
			class = "Counter",
			name = "boundElevation",
			value = 0,
		},
		{
			class = "Null",		-- Checks if the monster is burrowed to prevent an exploit
			name = "burrowed",	-- Where it would stand near a higher elevation, allowing the player to fall on it and kill it
								-- If enabled, the brain treats the monster as burrowed. Enabling/disabling it through the editor has no effect.
		},
		{
			class = "MonsterAction",	-- Used when the Viper Root is burrowed through the custom brain.
			name = "idleAction",		-- Since it's an action, the monster will think again only once the action animation is over
			animation = "idleAction",	-- Which is why the animation speed is set to 15, so it'll think in shorter intervals.
			animationSpeed = 15,		-- A new animation is defined so the animation speed won't linger to the regular idle animation.
		},
		{
			class = "MonsterAttack",
			name = "rise",
			attackPower = 17,
			accuracy = 50,
			cooldown = 0,
			animation = "rise",
			--sound = "viper_root_attack",
			cameraShake = true,
			cameraShakeDuration = 0.8,
			onBeginAction = function(self)
				self.go:spawn("particle_system").particle:setParticleSystem("viper_root_rise")
				self.go.burrowed:disable()
			end,
		},
		{
			class = "MonsterAction",
			name = "descend",
			animation = "descend",
			onBeginAction = function(self)
				if not self.go.burrowed:isEnabled() then
					self.go:spawn("particle_system").particle:setParticleSystem("viper_root_descend")
				end
			end,
			onEndAction = function(self)
				if not self.go.burrowed:isEnabled() then
					self.go:setPosition(self.go.x, self.go.y, self.go.facing, self.go.elevation - 1, self.go.level)
					self.go.burrowed:enable()
				end
			end,
		},
		{
			class = "MonsterAttack",
			name = "basicAttack",
			attackFromBehindAnimation = "attackFromBehind",
			attackPower = 17,
			accuracy = 10,
			cooldown = 5,
			sound = "viper_root_attack",
			cameraShake = true,
			cameraShakeDuration = 0.8,
		},
		{
			class = "MonsterAttack",
			name = "rangedAttack",
			attackType = "projectile",
			animation = "spit",
			attackPower = 10,
			cooldown = 5,
			sound = "viper_root_ranged_attack",
			shootProjectile = "poison_bolt",
			projectileHeight = 1.3,
		},
		{
			class = "Gravity",
			enabled = false,	-- gravity disabled so that the monster is not lifted above ground when hidden
		},
	},
	editorIcon = 4,
}
My asset pack [v1.10]
Features a bit of everything! :D

CainOrdamoth
Posts: 32
Joined: Sun Mar 08, 2015 1:45 am

Re: Confining a Viper Root to an area

Post by CainOrdamoth » Sat Jan 20, 2018 1:09 am

I can vouch for zimberzimber's viper root def. I'm using it in my dungeon and it works very well. :twisted:

Post Reply