Page 2 of 4

Re: How to use the lindworm?

Posted: Fri Mar 27, 2015 8:26 pm
by minmay
Use setPosition() and/or setWorldPosition() on the object immediately after spawning it.

Re: How to use the lindworm?

Posted: Sun Mar 29, 2015 6:59 pm
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?

Re: How to use the lindworm?

Posted: Sun Mar 29, 2015 7:15 pm
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.

Re: How to use the lindworm?

Posted: Mon Mar 30, 2015 8:28 pm
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?

Re: How to use the lindworm?

Posted: Mon Mar 30, 2015 8:37 pm
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?

Re: How to use the lindworm?

Posted: Tue Mar 31, 2015 11:19 pm
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:

Re: How to use the lindworm?

Posted: Tue Mar 31, 2015 11:31 pm
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.

Re: How to use the lindworm?

Posted: Tue Jun 09, 2015 10:34 am
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.

Re: How to use the lindworm?

Posted: Tue Jun 09, 2015 11:42 pm
by Eleven Warrior
Thxs Bongo have added him into my mod as well awesome job bro - 9/10 Kudo's

Re: How to use the lindworm?

Posted: Fri Feb 05, 2016 7:50 pm
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...