How to use the lindworm?

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!
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: How to use the lindworm?

Post by minmay »

Use setPosition() and/or setWorldPosition() on the object immediately after spawning it.
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.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: How to use the lindworm?

Post by bongobeat »

minmay wrote:Use setPosition() and/or setWorldPosition() on the object immediately after spawning it.
I can't figure how to do this correctly!

based on the ion spell, I have tried this:

but it works only when the party is facing 0, and the monster is in front of the party.
for the other directions, the spell is not on correct position. I 'm not sure on how the setWorldPosition works.
SpoilerShow

Code: Select all

			class = "MonsterAttack",
			name = "rangedAttack",
--			attackType = "projectile",
			attackPower = 50,
			minDistance = 2,
			cooldown = 4,
			animation = "rangedAttack",
			sound = "lindworm_roar",
--			shootProjectile = "magma_meteor",
			onAttack = function(self)
					local dx,dy = getForward(self.go.facing)
					local x = self.go.x + dx*2
					local y = self.go.y + dy*2
					local spell = spawn("magma_meteor", self.go.level, x, y, self.go.facing, self.go.elevation)
          local wpos = spell:getWorldPosition()
          local dx = nil
          local dz = nil
          if spell.facing == 0 then
             dx = left and -0.1 or 0.1
             dz = -1
          elseif spell.facing == 1 then
             dz = left and 0.1 or -0.1
             dx = -1
          elseif spell.facing == 2 then
             dx = left and 0.1 or -0.1
             dz = 1
          else -- spell.facing == 3
             dz = left and -0.1 or 0.1
             dx = 1
          end
          spell:setWorldPosition(vec(wpos[1]-0.65,wpos[2]+0.25,wpos[3]+dz))
			end,
can you help a bit please?
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: How to use the lindworm?

Post by minmay »

World position has global orientation, it is independent of facing. You have to adjust it depending on the facing of the caster. Your code is treating it as if the x position is local and the z position is global. All 3 positions are global. Also, you need to get rid of the lines with "left" because it will always be nil and only makes sense when it's a champion from the party casting the spell.

Also you need to check that your x and y positions are inside the map bounds, your current code will probably cause a crash if the lindworm breathes while on the edge of the map.
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.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: How to use the lindworm?

Post by bongobeat »

minmay wrote:World position has global orientation, it is independent of facing. You have to adjust it depending on the facing of the caster. Your code is treating it as if the x position is local and the z position is global. All 3 positions are global. Also, you need to get rid of the lines with "left" because it will always be nil and only makes sense when it's a champion from the party casting the spell.

Also you need to check that your x and y positions are inside the map bounds, your current code will probably cause a crash if the lindworm breathes while on the edge of the map.
thanks,

so far I ve modified the above script into this: don't know if this is good, but it works on all direction.
SpoilerShow

Code: Select all

		{
			class = "MonsterAttack",
			name = "rangedAttack",
			attackPower = 400,
			minDistance = 2,
			cooldown = 3,
			animation = "rangedAttack",
			sound = "lindworm_roar",
			onAttack = function(self)
					local dx,dy = getForward(self.go.facing)
					local x = self.go.x + dx*2
					local y = self.go.y + dy*2
					local spell = spawn("magma_meteor", self.go.level, x, y, self.go.facing, self.go.elevation)
          local wpos = spell:getWorldPosition()
          if spell.facing == 0 then
          spell:setWorldPosition(vec(wpos[1]+0.65,wpos[2]+0.25,wpos[3]+0))
          elseif spell.facing == 1 then
          spell:setWorldPosition(vec(wpos[1]+0,wpos[2]+0,wpos[3]-0.65))
          elseif spell.facing == 2 then
          spell:setWorldPosition(vec(wpos[1]-0.65,wpos[2]+0.25,wpos[3]+0))
          else -- spell.facing == 3
          spell:setWorldPosition(vec(wpos[1]+0,wpos[2]+0,wpos[3]+0.65))
          end
			end,
		},
I have no idea how to check positions. Can you help pls?
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: How to use the lindworm?

Post by minmay »

make sure your final x and y are not negative or above 31

also why do you have the Y position different for different directions?
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.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: How to use the lindworm?

Post by bongobeat »

lol I don't know

while trying how to represent that in a 3d space and use some values, I finally adjust it to that, and this works nice.

Code: Select all

spell:setWorldPosition(vec(wpos[1]-0.65,wpos[2]+0.25,wpos[3]+0))
did I understand this correctly?

here wpos[1] is the x , [2] the y , and [3] the z? or that does have nothing to do with that.

I'm kinda lost now! :roll:
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: How to use the lindworm?

Post by minmay »

bongobeat wrote:lol I don't know

while trying how to represent that in a 3d space and use some values, I finally adjust it to that, and this works nice.

Code: Select all

spell:setWorldPosition(vec(wpos[1]-0.65,wpos[2]+0.25,wpos[3]+0))
did I understand this correctly?

here wpos[1] is the x , [2] the y , and [3] the z? or that does have nothing to do with that.

I'm kinda lost now! :roll:
In Grimrock, the X world axis is west to east, the Y world axis is down to up, and the Z world axis is south to north. So for adjusting the world position position of a fired projectile, you'll want to change the X and Z positions depending on the facing of the monster. But the monster's animation will always be making the attack at the same height, regardless of which direction it's facing. So the Y world position, relative to the monster's Y position, should always be the same, and should not depend on facing.

It is a little strange since for map coordinates (the ones used by teleporters, GameObject:setPosition(), and so on), X is west to east and Y is north to south. And in 3D modeling programs the Z axis is usually the down/up one. But this is just the way things are in Grimrock.
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
Jhaelen
Posts: 74
Joined: Fri Oct 19, 2012 10:49 am
Location: Paris, France

Re: How to use the lindworm?

Post by Jhaelen »

Perfect ! I'm going tu use the "new" lindworm in my mod, and obviously I will put down yours names in my credits.
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: How to use the lindworm?

Post by Eleven Warrior »

Thxs Bongo have added him into my mod as well awesome job bro - 9/10 Kudo's
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: How to use the lindworm?

Post by AndakRainor »

How do the comments this boss makes during the fight work ? Is it linked to its brain, or some script ? I would like him to comment on other spells casts in addition to the meteor storm...
Post Reply