Ask a simple question, get a simple answer

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!
hyteria
Posts: 266
Joined: Sat Dec 29, 2012 8:22 pm

Re: Ask a simple question, get a simple answer

Post by hyteria »

well there are 2 kind of puzzle on where 2 spawner launch dispell , and another puzzle who use 3 spawner to launch fireball

in both case , spawner need to have a chance to launch a spell together

i need random for those puzzle cause there are just (dodge and intercept puzzle) this is too easy if there is a pattern
for intercept puzzle i dont need that 2 spawner work on the same time (cause player can t be on 2 differents place at the same time)
but for dodge one this can be much more fun and dangerous
Last edited by hyteria on Tue Nov 03, 2020 5:51 pm, edited 1 time in total.
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Is this [dispell] something the player actively causes?
hyteria
Posts: 266
Joined: Sat Dec 29, 2012 8:22 pm

Re: Ask a simple question, get a simple answer

Post by hyteria »

oups sorry i edit message to make it more clear
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

The way math.random works is this:
  • When called with no arguments, it returns a number between zero and one.
    math.random() —could return any (real) number between 0 and 1.
  • When called with one numerical argument, it returns a number that is between 1, and the argument.
    math.random(3) —could return 1,2, or 3
  • When called with two arguments, it returns a number between the two; both inclusive.
    math.random(2,7) —could return 2, 3, 4, 5, 6, or 7.
User avatar
ratman
Posts: 159
Joined: Fri Jan 10, 2020 1:13 am

Re: Ask a simple question, get a simple answer

Post by ratman »

Is it possible to make a lindworm that has instead of the wizard texture the spectral_wizard from zim assets? If so, how? Thanks
User avatar
THOM
Posts: 1274
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

Is is just a question of the texture? I mean: It's only that the wizard on the back has to look different?

Then use materialOverrides on the model in the monster definition:

Code: Select all

materialOverrides = { ["wizard"] = "textureXY", },
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
ratman
Posts: 159
Joined: Fri Jan 10, 2020 1:13 am

Re: Ask a simple question, get a simple answer

Post by ratman »

Thank you, I am now trying to create my own 'red lindworm' texture. I remember at the end of your mod Journey to Justice, (which was great by the way) you fight a lindworm. How did you make it work? for me it doesn't do anything and you can't damage it at all.
User avatar
THOM
Posts: 1274
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ask a simple question, get a simple answer

Post by THOM »

The problem with the Lindworm was, IIRR the brain.

The user fisch scripted a working version of that brain. (see here)

That's the brain-mechanics I'm using in Journey to Justice.

The brain-component(s):

Code: Select all

		{
			class = "RangedBrain",
			name = "brain",
			sight = 10,
         		morale = 100,
			seeInvisible = true,
			allAroundSight = true,
			onBloodied = function(self)
				self.go.move:setCooldown(1)
				self.go.basicAttack:setCooldown(2)
			end,
			onThink = function(self)
				-- call brain script
				local script = self.go.brainScript
				if script and script:isEnabled() and script.think then script.think(self) end
			end,
		}
		{
			class = "Script",
			name = "brainScript",
		},
		
And there was also something else needed.

These lines go into the model component:

Code: Select all

			onInit = function(self)
				self.go.brainScript:loadFile("mod_assets/monsters/lindworm_brainscript.lua")
			end
And at the mentioned path has to be a lua file named lindworm_brainscript.lua:

Code: Select all

scriptEntityHelper = "scriptHelper"
move = {{-1,-1},{-1,1},{1,-1},{1,1}}
cKnockback = 0


function think(self)
	
	local maxDist = 6
	local minDist = 3
	local retval = true
	local seq = math.random()
	local dist = math.max(math.abs(party.x - self.go.x), math.abs(party.y - self.go.y)) 
	local dx,dy = toLocal(self.go.x, self.go.y, self.go.facing, party.x, party.y)

	local udx,udy = getForward(self.go.facing)
	local urdx,urdy = getForward((self.go.facing +1) % 4)
	local ux = 0
	local uy = 0
	local front = 0
	local lateral = 0
	
	if (self.go.monster:getHealth()) <= 1 then 
		return self:performAction("die") or self:wait()
	end

	
  if self.go.map:checkLineOfFire(self.go.x+udx, self.go.y+udy, party.x, party.y, party.elevation) then
    if -2<dy and dy<2 and -2<dx and dx<2 then
      if cKnockback > 2 then
        local r = math.random(#move)
        for i = 1,#move do
          local j = (r+i)%#move+1
          if isSafeTile(self.go.x+move[j][1], self.go.y+move[j][2]) then
            local retval = self:seek(self.go.x+move[j][1], self.go.y+move[j][2])
            if retval then return retval end
          end
        end
      end
      cKnockback = cKnockback + 1
      return self:performAction("knockback")
		elseif dy == 2 then
			cKnockback = 0
			if dx == -1 then retval = self:performAction("wingAttack") or self:performAction("attackFrontLeft") or self:wait() end
			if dx == 1 then retval = self:performAction("attackFrontRight") or self:wait() end
			if dx == 0 then retval = self:performAction("basicAttack") or self:goTo("mine_rock_border_292") or self:wait() end  
		elseif (dx == 2 or dx == -2) and dy == 1 then
			cKnockback = 0
      return (dx==2 and self:turnRight() or self:turnLeft()) or self:wait()

		elseif  -2<dx and dx<2 and 2<dy and dy<6 then 
      return dx==0 and isSafeTile(self.go.x+5*udx, self.go.y+5*udy) 
      or self:performAction("rangedAttack") or moveTowardsParty(dx, dy, self.go.x+udx, self.go.y+udy) or self:wait()

		end
	end
	
	return retval
end

function isBlocked(front, lateral)
  local udx,udy = getForward(self.go.facing)
  local rdx,rdy = getForward((self.go.facing+1)%4)
  local x,y = self.go.x+udx*front+rdx*lateral, self.go.y+udy*front+rdy*lateral
  if not isSafeTile(x, y) then return true end
  for dy=-1,1 do for dx=-1,1 do if self.go.map:isBlocked(x+dx,y+dy,0) then return true end end end
  return false
end

function isSafeTile(x, y)
  return (x==11 or x==19) and (11<y and y<19) or (11<x and x<19 and 10<y and y<20)
end

function moveTowardsParty(dx, dy, mx, my)
  if dy>0 and isSafeTile(mx, my) then return self.go.brain:moveForward() end
  if dx<0 then return self.go.brain:turnLeft() end
  if dx>0 then return self.go.brain:turnRight() end
  return math.random()<0.5 and self.go.brain:turnLeft() or self.go.brain:turnRight() 
end

function wander()
  if self.go.x==wx and self.go.y==wy then wx,wy = math.random(11,19),math.random(11,19) end
  return self.go.brain:seek(wx,wy)
end
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
IttaBitta
Posts: 21
Joined: Thu Oct 22, 2020 12:14 am

Re: Ask a simple question, get a simple answer

Post by IttaBitta »

is there an archive of assets anywhere? looking through these forums it seems that a LOT of tilesets and such have been lost to time :I
User avatar
7Soul
Posts: 209
Joined: Sun Oct 19, 2014 1:56 am
Location: Brazil

Re: Ask a simple question, get a simple answer

Post by 7Soul »

IttaBitta wrote: Wed Nov 04, 2020 10:06 pm is there an archive of assets anywhere? looking through these forums it seems that a LOT of tilesets and such have been lost to time :I
There's some at nexusmods https://www.nexusmods.com/legendofgrimrock2
Join the LoG discord server: https://discord.gg/ArgAgNN :D

My Mods
Post Reply