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
Trollmann
Posts: 24
Joined: Sun Apr 15, 2012 6:31 pm

Re: Ask a simple question, get a simple answer

Post by Trollmann » Wed Nov 05, 2014 10:23 pm

Can someone help with creating custom items? I've started working on a dungeon with new models and item icons etc. but I have no idea how to set things up in Grimrock II.
It seems cloneObject isn't working the way it did in Grimrock I, and if I try to manually set stats etc. I just mess the dungeon up so it wont load anylonger.

Thanks in advance!

User avatar
Matlock19
Posts: 23
Joined: Sun Nov 02, 2014 2:11 am

Re: Ask a simple question, get a simple answer

Post by Matlock19 » Wed Nov 05, 2014 11:54 pm

Expanding on Trollman's question:
Could someone show (or throw me a link) how to clone objects and give them different properties? I don't want new icons or models, I just want to, for example, make a different longsword with a new name and higher damage, while keeping the regular old longsword in the game. That's possible, right?

NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Ask a simple question, get a simple answer

Post by NutJob » Thu Nov 06, 2014 12:01 am

Matlock19 wrote:Expanding on Trollman's question:
Could someone show (or throw me a link) how to clone objects and give them different properties? I don't want new icons or models, I just want to, for example, make a different longsword with a new name and higher damage, while keeping the regular old longsword in the game. That's possible, right?
If you only want to change some fundamentals of an object just spawn it in and change what you want.

Example

Code: Select all

local skull_of_dargoth = spawn("skull")
skull_of_dargoth.item:setDescription("Only in purest darkness\nshall the way be shown.")
skull_of_dargoth.item:setWeight(0.8)
skull_of_dargoth.item:setUiName("Brittle Human Skull")

NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Ask a simple question, get a simple answer

Post by NutJob » Thu Nov 06, 2014 12:13 am

What's the easiest way to listen to the sounds? ATM the best method I have is to drop a sound entity and "guess" at sounds then load the game, and, even then, it won't play most of the time (guessing only loops will play with the sound entity?), which is the most implausible way to do it.

User avatar
Matlock19
Posts: 23
Joined: Sun Nov 02, 2014 2:11 am

Re: Ask a simple question, get a simple answer

Post by Matlock19 » Thu Nov 06, 2014 12:22 am

NutJob wrote:

Code: Select all

local skull_of_dargoth = spawn("skull")
skull_of_dargoth.item:setDescription("Only in purest darkness\nshall the way be shown.")
skull_of_dargoth.item:setWeight(0.8)
skull_of_dargoth.item:setUiName("Brittle Human Skull")
So that script spawns the item at the location of the script entity when the level is loaded. Nice. Thank you!
And can I alter the properties of a spawned weapon by adding:

Code: Select all

sword_of_whatever.item:setattackPower = 10
sword_of_whatever.item:setaccuracy = 10
sword_of_whatever.item:setbaseDamageStat = dexterity
:?:

User avatar
zeltak
Posts: 119
Joined: Fri May 04, 2012 2:33 am

Re: Ask a simple question, get a simple answer

Post by zeltak » Thu Nov 06, 2014 12:25 am

What does the "currentLevelOnly" do in timers? It seems that timers pause even without it when you're in a different level. And is there a way to make them tick even when you're not in the same level as the timer?

NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Ask a simple question, get a simple answer

Post by NutJob » Thu Nov 06, 2014 12:30 am

Matlock19 wrote: And can I alter the properties of a spawned weapon by adding:

Code: Select all

sword_of_whatever.item:setattackPower = 10
sword_of_whatever.item:setaccuracy = 10
sword_of_whatever.item:setbaseDamageStat = dexterity
:?:
Yes, and you can wrap it up in a function and have it triggered by something, or on load of the game. Being you want to clone an object this may be the fastest way, really, without messing with defineObject.

You can give it to a player with insertItem or to a surface with addItem or to coordinates while spawn()'ing the item.

User avatar
Matlock19
Posts: 23
Joined: Sun Nov 02, 2014 2:11 am

Re: Ask a simple question, get a simple answer

Post by Matlock19 » Thu Nov 06, 2014 12:37 am

Well it seems that trying to change the attack power, accuracy, etc. gives me an error: " function arguments expected near '=' ".

Code: Select all

local new_rapier = spawn("rapier")
new_rapier.item:setDescription("A ceremonial sword.")
new_rapier.item:setattackPower = 10
new_rapier.item:setUiName("New Rapier")

NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Ask a simple question, get a simple answer

Post by NutJob » Thu Nov 06, 2014 12:42 am

try youritemname.meleeattack:setAttackPower(10) <-- might be wrong, not at the correct computer.

User avatar
Matlock19
Posts: 23
Joined: Sun Nov 02, 2014 2:11 am

Re: Ask a simple question, get a simple answer

Post by Matlock19 » Thu Nov 06, 2014 1:02 am

NutJob wrote:try youritemname.meleeattack:setAttackPower(10) <-- might be wrong, not at the correct computer.
Worked perfectly, thank you again. Don't know what I would do without this forum!

FURTHER EDITS!

Forget my dumb question, figured it out. I needed to call the cloak "new_cloak.equipmentitem" when setting those properties, not just ".item". Duh.
Last edited by Matlock19 on Thu Nov 06, 2014 4:52 am, edited 2 times in total.

Post Reply