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
TheLastOrder
Posts: 104
Joined: Wed Oct 17, 2012 1:56 am

Re: Ask a simple question, get a simple answer

Post by TheLastOrder »

NutJob wrote:It'll trigger the connector when it starts (0.0) and at your timerInterval (like normal).
Awesome. Couldn't deduce it was that. Thank you so much!
Kaliflour
Posts: 3
Joined: Sat Nov 29, 2014 6:20 pm

Re: Ask a simple question, get a simple answer

Post by Kaliflour »

Hello everyone. I'm new here. :) Thought messing around with the Grimrock editor would be a good way to try out programming/level design.

So, I have a simple question: How can I offset the location of an item within a cell? Such as placing a turtle egg in the middle of the nest.

Thanks!
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: Ask a simple question, get a simple answer

Post by Drakkan »

Kaliflour wrote:Hello everyone. I'm new here. :) Thought messing around with the Grimrock editor would be a good way to try out programming/level design.

So, I have a simple question: How can I offset the location of an item within a cell? Such as placing a turtle egg in the middle of the nest.

Thanks!
hi, yes.
check game reference for gameobject - there is more you can do with item. for example:

GameObject:getPosition()
GameObject:setPosition(x, y, facing, elevation, level)
GameObject:setWorldPosition()
GameObject:setWorldPositionY(y)
GameObject:setWorldRotation(…)
GameObject:setWorldRotationAngles(x, y, z)
GameObject:setWorldRotationAnglesWithOrder(x, y, z, order)

so for example you can move your item like this

youritemname:setWorldPosition(vec(3.002938, 0.00000, 3.054278, 0.000000))
Breath from the unpromising waters.
Eye of the Atlantis
Kaliflour
Posts: 3
Joined: Sat Nov 29, 2014 6:20 pm

Re: Ask a simple question, get a simple answer

Post by Kaliflour »

Thanks Drakkan! Got it working now.

EDIT: Just found setSubtileOffset(). Seems to be an easier way of doing what I wanted to do. Thanks for pointing me to the right place in the scripting reference.
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: Ask a simple question, get a simple answer

Post by cromcrom »

Ok, my turn :-)

I have this code in monsters.lua, but the placed monsters do not have these attributes...

Code: Select all

   defineObject{name = "crom_fjeld_warg",
	baseObject = "fjeld_warg",
	components = {

		{
			class = "Health",
			name = "health",
			spawnOnDeath = "",
			health = 20,
			onDie = function(self)
			
			for i=1,math.random(5,10) do
			spawn("coin_copper")
			end
			end,
		},
	}
}
Any help please ?
A trip of a thousand leagues starts with a step.
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Ask a simple question, get a simple answer

Post by GoldenShadowGS »

I think you need to change the monster component, not health.

EDIT:

Code: Select all

	defineObject{name = "crom_fjeld_warg",
	baseObject = "fjeld_warg",
	components = {
        {
		class = "Monster",
		meshName = "fjeld_warg_mesh",
		level= 1,
		health = 20,
		maxHealth = 20,
		exp = 60,
		hitSound = "warg_hit",
		hitEffect = "hit_blood_black",
		dieSound = "warg_die",
		onDie = function(self)
			for i = 1,math.random(5,10) do
				spawn("rock")
			end
		end,
		},
	}
}

I used something like this to pull the values from the default wargs

Code: Select all

m = fjeld_warg_1

print(m.monster:getCapsuleHeight())  
print(m.monster:getCapsuleRadius())  
print(m.monster:getCollisionRadius())  
print(m.monster:getCurrentAction())  
print(m.monster:getDeathEffect())  
print(m.monster:getDieSound())  
print(m.monster:getEvasion())  
print(m.monster:getExp())  
print(m.monster:getFlying())  
print(m.monster:getFootstepSound())  
print(m.monster:getGroupSize())  
print(m.monster:getHeadRotation())
print(m.monster:getHealth())
print(m.monster:getHitEffect())  
print(m.monster:getHitSound())  
print(m.monster:getIdleAnimation())  
print(m.monster:getImmunities())  
print(m.monster:getLevel())  
print(m.monster:getLootDrop())  
print(m.monster:getMaxHealth())  
print(m.monster:getMeshName())   
print(m.monster:getProtection())   
print(m.monster:getShape())  
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: Ask a simple question, get a simple answer

Post by Drakkan »

cromcrom wrote:Ok, my turn :-)
The most safe way is to copy original warg asset and just change what you want to change (e.c. health, drop etc...)

Code: Select all

defineObject{
	baseObject = "base_monster",
	name = "cromrcom_sand_warg",
	components = {
		{
			name = "model",
			class = "Model",
			storeSourceData = true,
			model = "assets/models/monsters/sand_warg.fbx"
		},
		{
			animations = {
				fall = "assets/animations/monsters/sand_warg/sand_warg_get_hit_front_left.fbx",
				attack = "assets/animations/monsters/sand_warg/sand_warg_attack.fbx",
				turnRight = "assets/animations/monsters/sand_warg/sand_warg_turn_right.fbx",
				moveForwardTurnRight = "assets/animations/monsters/sand_warg/sand_warg_walk_turn_right.fbx",
				getHitFrontLeft = "assets/animations/monsters/sand_warg/sand_warg_get_hit_front_left.fbx",
				getHitBack = "assets/animations/monsters/sand_warg/sand_warg_get_hit_back.fbx",
				getHitFrontRight = "assets/animations/monsters/sand_warg/sand_warg_get_hit_front_right.fbx",
				moveForwardTurnLeft = "assets/animations/monsters/sand_warg/sand_warg_walk_turn_left.fbx",
				howl = "assets/animations/monsters/sand_warg/sand_warg_howl.fbx",
				moveForward = "assets/animations/monsters/sand_warg/sand_warg_walk.fbx",
				turnLeft = "assets/animations/monsters/sand_warg/sand_warg_turn_left.fbx",
				idle = "assets/animations/monsters/sand_warg/sand_warg_idle.fbx",
				getHitLeft = "assets/animations/monsters/sand_warg/sand_warg_get_hit_left.fbx",
				getHitRight = "assets/animations/monsters/sand_warg/sand_warg_get_hit_right.fbx"
			},
			class = "Animation",
			name = "animation",
			currentLevelOnly = true
		},
		{
			lootDrop = {
				75,
				"warg_meat",
				10,
				"warg_meat"
			},
			hitSound = "warg_hit",
			resistances = {
				poison = "weak"
			},
			health = 400,
			class = "Monster",
			traits = {
				"animal"
			},
			meshName = "sand_warg_mesh",
			headRotation = {
				90,
				0,
				0,
				0 },
			exp = 350,
			hitEffect = "hit_blood_black",
			capsuleRadius = 0.7,
			dieSound = "warg_die",
			name = "monster",
			capsuleHeight = 0.2
		},
		{
			class = "WargBrain",
			name = "brain",
			sight = 5
		},
		{
			sound = "warg_walk",
			class = "MonsterMove",
			name = "move",
			cooldown = 0.5
		},
		{
			sound = "warg_walk",
			class = "MonsterTurn",
			resetBasicAttack = true,
			name = "turn"
		},
		{
			resetBasicAttack = true,
			turnDir = 1,
			cooldown = 2,
			sound = "warg_walk",
			class = "MonsterMove",
			name = "moveForwardAndTurnRight",
			animations = {
				forward = "moveForwardTurnRight"
			}
		},
		{
			resetBasicAttack = true,
			turnDir = -1,
			cooldown = 2,
			sound = "warg_walk",
			class = "MonsterMove",
			name = "moveForwardAndTurnLeft",
			animations = {
				forward = "moveForwardTurnLeft"
			}
		},
		{
			woundChance = 30,
			pierce = 5,
			class = "MonsterAttack",
			accuracy = 15,
			cooldown = 3,
			sound = "warg_attack",
			screenEffect = "damage_screen",
			name = "basicAttack",
			attackPower = 35
		},
		{
			animation = "howl",
			class = "MonsterAction",
			name = "howl",
			cooldown = 60
		}
	}
}
Breath from the unpromising waters.
Eye of the Atlantis
GoldenShadowGS
Posts: 168
Joined: Thu Oct 30, 2014 1:56 am

Re: Ask a simple question, get a simple answer

Post by GoldenShadowGS »

Where did you get the definitions for that?
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: Ask a simple question, get a simple answer

Post by JKos »

and most easy way is to use cloneObject ;)
(since you are already using it)

Code: Select all

cloneObject{
     name = "crom_fjeld_warg",
     baseObject = "fjeld_warg",
    components = {
      {
         class = "Monster",
         health = 20,
         onDie = function(self)
			 for i = 1,math.random(5,10) do
				spawn("coin_copper")
			 end
         end,		 
      }
   }
}
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
User avatar
cromcrom
Posts: 549
Joined: Tue Sep 11, 2012 7:16 am
Location: Chateauroux in a socialist s#!$*&% formerly known as "France"

Re: Ask a simple question, get a simple answer

Post by cromcrom »

Waow, I hardly have time to set up my random spawn system, and look at all this O_O . Thanks you so much guys, my issue was with monster class. Thanks again, crediting :-)
A trip of a thousand leagues starts with a step.
Post Reply