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
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ask a simple question, get a simple answer

Post by Isaac »

Example object: ( Goes in mod_assets/scripts/object.lua )

Code: Select all

defineObject{
	name = "epic_castle_pillar_01",
	baseObject = "base_pillar",
	components = {
		{
			class = "Model",
			name = 'pillar',
			offset = vec(0,-3,0),
			model = "assets/models/env/castle_pillar_tall_01.fbx",
			staticShadow = true,
		},
		{
			class = "Model",
			name = "tapestry",
			offset = vec(0,5.3,.325),
			model = "assets/models/env/castle_wall_cloth.fbx",
		},
		{
			class = "Model",
			name = "crossbeam",
			offset = vec(0,5.3,.25),
			model = "assets/models/env/mine_support_beam_01.fbx",
		},
		{
			class = "Model",
			model = "assets/models/monsters/crowern01.fbx",
			storeSourceData = false,
			offset = vec(0,12.6,0),
			name = "finial",
			material = "castle_inside_pillar",
		},
		{
			class = "Model",
			name = "base",
			offset = vec(.20,0,0),
			rotation = vec(0,90,0),
			model = "assets/models/env/beach_pedestal.fbx",
			staticShadow = true,
		},
	},
	minimalSaveState = true,  --==========<<  TRUE
	placement = "floor",
	editorIcon = "256",
}

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 »

Yes. Isaac worked with offsets of all models and joined them together in one new object. That is probably the most clever solution for your aim.

But - wow - today you've got in contact with a lot of modding-tools... :P
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
zdenekhoub
Posts: 53
Joined: Fri Aug 26, 2016 11:56 am

Re: Ask a simple question, get a simple answer

Post by zdenekhoub »

Thank you all for your advices! Since I have so many objects to re-define I must ask this question:

Is there a way, to make re-defining of an object to minimalSaveState = true based on its type, or model, or group?

If I moved 50x mine_support_beam objects, and the editor names them mine_support_beam1-50, can't I just define minimalSaveState = true for all of the mine_support_beams at once? Since it is still the same game object? Or better - maybe there is a some smart way to tell the game engine that all the mine_support_beam objects in my mod must be in minimalSaveState = true by default?

Code: Select all

defineObject{
         class = "Model",
         name = "all_crossbeams", --------- something like this
         model = "assets/models/env/mine_support_beam_01-50.fbx", -- you get the idea  :) 
      },
   },
   minimalSaveState = true,
   placement = "floor",
   editorIcon = "256",
}
Simply tell the engine to minimalSaveState = true for all mine support beams and nothing else, let the offset be done by my setSubtileOffset already done in scripts. The saves will be larger, but still should not make any troubles on todays PC's right?
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 »

I see 3 option here:
1) You're confusing object ID with its model
2) You have imported 50 different mine pillar models
3) You defined 50 different objects using the same model, and confused the model with the object name

Solutions:
1) Objects present in the dungeon automatically alter themselves to what you defined them upon reloading the dungeon, so you don't have to change anything about them. (Unless you've added/removed special components such as a timer)
For example, I placed an object named my_object in the dungeon, and I told it to use the skull item model. It will appear as a skull.
Then I go back to the definition and tell it to use a sword model instead. Upon reloading, the object will use the sword model.

2) I really hope this isn't the case...
You can define a lot of objects by typing one definition with a "for" function.
Something like this: (You can just copy-paste it and change the model path to what you need)

Code: Select all

for i=0,3 do
	local str = function(str) return (string.gsub(str, "?", iff(i > 0, i, ""))) end
	defineObject{
		name = str("mummy?"),
		baseObject = "base_obstacle",
		components = {
			{
				class = "Model",
				model = str("assets/models/monsters/mummy?.fbx"),
				storeSourceData = true,
			},
		},
	}
end
Here, the definition will define 4 different models for mummies. (0,1,2,3)
Every question mark symbol inside an srt() will be changed to a number (or removed if the number would be 0) based on the current i.
In the for i=0,3 do, you can change the 3 to the number of models you have -1. (because 0 counts as 1 already)
All your models will have to same the same path, and same name except for the last number. For example:

Code: Select all

assets/models/monsters/mummy.fbx   (i = 0)
assets/models/monsters/mummy1.fbx  (i = 1)
assets/models/monsters/mummy2.fbx  (i = 2)
assets/models/monsters/mummy3.fbx  (i = 3)
3) Here you can only hope you're using a custom base_object so you could go there, and set minimalSaveState there to true.
base_object is what you're currently defining will use as a base. It copies all data from that object, and then it gets altered based on what you defined. (if at all)
For example, I'm using the base_door as my base_object. In my object, I change the model and add a particle. The door and the controller components from base_door will transfer to my object. Think of it as a son getting his fathers riches through a will.
So in this case, if you give the base_object minimalSaveState, it will transfer to everything that uses the base_object. I highly recommend you don't change/reimplement base_pillar with minimalSaveStae, because many vanilla pillar objects use base_pillar, and it might cause some issues.

If these custom object don't use a base_object, you have no choice but to go through all of the definitions by hand.
I suggest you implement a new object named base_pillar_minimalsave, give it minimalSaveState and have all of your custom pillar objects use it
as a base_object. Will also save trouble in the future if you're going to define new pillars.
My asset pack [v1.10]
Features a bit of everything! :D
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 »

zdenekhoub wrote:name = "all_crossbeams", --------- something like this
model = "assets/models/env/mine_support_beam_01-50.fbx", -- you get the idea :)
Object definitions are templates, and the 'name' field describes the template used. In the editor, when you place a pillar, or a statue, or a rock... the object has its [template] name, and its id string; so a rock in the dungeon may have an id of "rock_1", (or even "my special_rock_1"), but its [template] name will be the same as any other rock in the dungeon..."rock". If you change the definition of an object in any way, you are changing a template, and every object derived from that template will get the changes.

The way you fix your map is to closely look at each kind of customized [possibly compound] object that you have created, and decide how to adjust the template(s) of those props. Everything on your map is listed in the dungeon.lua file, in your project's scripts folder. Save a copy of that file somewhere safe, and you can begin editing the original in a good text editor (like Notepad++, SciTE, or Sublime). You can use the text editor's replace functionality to change the spawn statements that match the objects you are trying to alter. For example, to replace the 50 mine_support_beams, you could search the dungeon.lua file for: spawn("mine_support_beam_01",
and replace it (en masse) with: spawn("custom_support_beam_01" Where "custom_support_beam_01" is your new object, with built in offsets.

In dungeon.lua, the text editor might find many lines like this:
spawn("mine_support_beam_01",15,14,2,0,"mine_support_beam_01_1")

and can auto-replace/edit them to look like this:
spawn("custom_support_beam_01",15,14,2,0,"mine_support_beam_01_1")

When you reload ~if no mistakes were added to dungeon.lua ;), all of the "mine_support_beam_01" objects would have been swapped for "custom_support_beam_01" objects. Anytime you mass-edit the dungeon.lua file, unintended changes are possible; (that's why you save the backup before editing). To replace those giant pillars, you could do the above, but instead, change the object at the base of your pillar, to include all of the other models and their offsets; you can then delete those other objects; or ~if using the object I posted above, do the same spawn replace/edit mentioned for the 'mine_support_beam', but use the new epic_pillar object's name to swap out whatever object you used at the bottom of your pillar. [the pedestal?]

Either way, it will not be entirely automatic; you will have to either hand edit the map in the editor, or in the dungeon.lua file; but for the dungeon.lua file, you can use the convenience features of the text editor to help.
zdenekhoub
Posts: 53
Joined: Fri Aug 26, 2016 11:56 am

Re: Ask a simple question, get a simple answer

Post by zdenekhoub »

Thank you very very much again zimberzimber and Isaac!

I must read your advices several times before I will get the message, but that's ok :)

I will try them soon when I find some more time, and I will report how successful I was.
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 »

It might help to create a new project to use as a practice guide; add a few objects to it in the editor, save it, and try editing that [much smaller/simpler] dungeon.lua file first; to get an idea of the process before tackling a large multi-level map.
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 there a way to slow down an animation?

I know that you can do this with GrimrockMTK but it doesn't read LoG2 animations...

I've tried to load the animation into Blender and do the same but I couldn't find something like an animation-speed entry.

What I want to do is to slow down the idle animation of the Trickster so that he doesn't behave like a hyperactive kid anymore.
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
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 »

THOM wrote:I've tried to load the animation into Blender and do the same but I couldn't find something like an animation-speed entry.
What I want to do is to slow down the idle animation of the Trickster so that he doesn't behave like a hyperactive kid anymore.
In Blender, you would have to access the dopesheet, and scale the animation out (further along the timeline).
  • After the model and animation is imported, split the panel, and open the dopesheet.
  • Click/Select frame zero, and press 'a' to select all frames.
  • Press 's' then '2', to double the time it takes the animation to play.
User avatar
Eleven Warrior
Posts: 745
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Ask a simple question, get a simple answer

Post by Eleven Warrior »

WOW... Hey Thom when you do the Trickster can you share with us ? I like the idea he is not Hypo lol.

Issac I tried this and it still does not work:

Code: Select all

defineSpell{
	name = "cure_petrified_party_01",
	uiName = "Cure Petrification Party",
	gesture = 2589632,
	manaCost = 10,
	skill = "earth_magic",
	requirements = { "earth_magic", 1},
	icon = 60,
	spellIcon = 1,
	description = "Cures your entire parties petrified state.",
		onCast = function(champion, x, y, direction, skill)
			hudPrint(champion:getName() .. " Cures the parties petrified state.")
			playSound("magic_hit_10")
			local c
			for i = 1, 4 do
				c = party.party:getChampion(i)
				if c and c:isAlive() then
				if c:hasCondition("petrified") then
				---c:removeCondition("petrified")
				c:setCondition("petrified", false)
end
	end
		end
			end,
}
Post Reply