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

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

zimberzimber wrote:
minmay wrote:They aren't. Custom conditions were added in 2.2.4.
Alright, is there somewhere I can view an example of a condition to use as a reference for creating a new one? (if possible)
The only example I've been able to find:
https://github.com/JKos/log2doc/wiki/Asset-Definitions
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post by zimberzimber »

Zo Kath Ra wrote:The only example I've been able to find:
https://github.com/JKos/log2doc/wiki/Asset-Definitions
Oh this is perfect, thanks a lot!
My asset pack [v1.10]
Features a bit of everything! :D
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

Is it possible to combine a beach_ocean object and the under water effect of the water_surface object ? The goal is to build a map with water and no border walls.
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 »

AndakRainor wrote:Is it possible to combine a beach_ocean object and the under water effect of the water_surface object ? The goal is to build a map with water and no border walls.
For an Island with a full beach perimeter? (and/or inland underwater areas?)

I have one of those; but I did not add underwater areas inland.

I have used both water objects at once before, but IRRC, the Ocean waves interfere when they overlap submerged inland areas. On one map, I handled this by rotating the Ocean object ~to prevent overlaps while submerged; though one could enable/disable the model component I suppose.

The full 360° beach will likely require at least two Ocean objects. For my island, I had to use shipwrecks to cover the seams.
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

I use a scaled up model of ocean_water.model in my mod, with doubled dimensions. It is enough to cover an open island map, and the waves size is not bad.

What is missing for the map I try to build, is under water zones rendering. I should get the very dense blue fog effect of normal water tiles and the water_surface_underwater material when looking at the water surface from below. For the fog I am currently messing with sky fog dynamic updating.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post by minmay »

Use a WaterSurfaceComponent with no WaterSurfaceMeshComponent and make sure your tiles have "underwater = true".
minmay wrote:Whether the party (or a monster or item) is considered underwater or not actually has nothing to do with the water surface or water surface mesh object. It is tied solely to whether they are in a tile with the "underwater" flag and at a low enough world y position at the same time. You can even use the heightmap to let the party wade slowly into water (although the water shader looks incredibly bad when camera y is close to the plane y, so you don't want to do that).
What often trips people up is that the planeY value in the WaterSurfaceComponent determines the y position of the reflection plane. Generally you want this to be the same as the y position of the water plane, since objects are supposed to appear to reflect off the water, but I can imagine exceptions.
You might need to add an underwater side to your mesh, I forget.
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
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 »

I am trying to remove all weappons from my party.

Am am using the following function but it won't work.

I am sure I am missing something obvious again, but I can't figure out, what:

Code: Select all

function removeWeappons()

local weaptrait = { "light_weapon", "sword", "daggers", "weapon", "heavy_weapon", "mace", "axe", "two_handed", "firearm", "spear", "missile_weapon", "throwing_weapon", "wand" }

	for i=1,4 do
		local ch = party.party:getChampion(i)
		for a=1,32 do
			local cItem = ch:getItem(a)
			if cItem and cItem.go.item:hasTrait(weaptrait) ~= nil then	
				cItem:destroyDelayed()
			end
		end
	end
end

*next step would be to remove also weappons inside of containers, but that's another story...
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

A few things:
- your cItem variable references an item component, so "cItem.go.item" is just cItem, more direct that way :)
- so cItem:hasTrait(weaptrait) return a boolean for your test, "~= nil" is useless!
- destroying an item will work only for game objects (=> cItem.go:destroyDelayed(), not cItem directly) on the map (or in containers on the map iirc) so this won't work for champions inventories; you should use "ch:removeItemFromSlot(a)"
User avatar
Zo Kath Ra
Posts: 937
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ask a simple question, get a simple answer

Post by Zo Kath Ra »

You're passing a table to cItem.go.item:hasTrait(weaptrait)
but hasTrait expects a string (AFAIK, might be wrong)

cItem.go.item:hasTrait(weaptrait)
is the same as
cItem:hasTrait(weaptrait)
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post by AndakRainor »

minmay wrote:Use a WaterSurfaceComponent with no WaterSurfaceMeshComponent and make sure your tiles have "underwater = true".
minmay wrote:Whether the party (or a monster or item) is considered underwater or not actually has nothing to do with the water surface or water surface mesh object. It is tied solely to whether they are in a tile with the "underwater" flag and at a low enough world y position at the same time. You can even use the heightmap to let the party wade slowly into water (although the water shader looks incredibly bad when camera y is close to the plane y, so you don't want to do that).
What often trips people up is that the planeY value in the WaterSurfaceComponent determines the y position of the reflection plane. Generally you want this to be the same as the y position of the water plane, since objects are supposed to appear to reflect off the water, but I can imagine exceptions.
You might need to add an underwater side to your mesh, I forget.
I did it that way for the water surface, and used the sky object for the fog (not ideal I think):

Code: Select all

defineObject{
  name = "big_ocean",
  components = {
    {
      class = "Model",
      model = "mod_assets/models/env/ocean_water_big.fbx",
      offset = vec(0, -1.2, 0),
      renderHack = "ForceZWrite",
      sortOffset = 100000,  -- force water rendering before other transparent surfaces
    },
    {
      class = "Model",
      name = "bottom",
      model = "assets/models/env/water_bottom.fbx",
      offset = vec(0, -2, 0),
    },
    {
      class = "WaterSurface",
      planeY = -1.2,
      fogColor = vec(0.042, 0.09, 0.26) * 0.5,
      fogDensity = 0.2,
      reflectionColor = vec(0.77, 0.9, 1.0) * 0.9,
      refractionColor = vec(1,1,1),
    },
    {
      class = "Timer",
      timerInterval = 0,
      triggerOnStart = true,
      onActivate = function(self)
        if party:getWorldPositionY() < self.go:getWorldPositionY()-1.2 then
          if self.go.model:getMaterial() ~= "water_surface_underwater" then
            self.go.model:setMaterial("water_surface_underwater")
          end
        else
          if self.go.model:getMaterial() ~= "ocean_water" then
            self.go.model:setMaterial("ocean_water")
          end
        end
      end,
    },
  },
  placement = "floor",
  dontAdjustHeight = true,
  editorIcon = 264,
  reflectionMode = "never",
}
Post Reply