Page 73 of 396

Re: Ask a simple question, get a simple answer

Posted: Wed Jun 10, 2015 8:27 pm
by minmay
Ah. Yes, I'm afraid you will have to do something like that. Adding animation events to the beginning of your first model's animations and using the first AnimationComponent's onAnimationEvent hook is probably easier than using onBeginAction, since then you will easily catch when the monster falls through a pit/flinches/gets knocked back/etc. For example:

Code: Select all

do
local listOfAnimations = { -- the same animation table as your first AnimationComponent
	turnRightNormal = "assets/animations/monsters/fjeld_warg/fjeld_warg_turn_right.fbx",
	fall = "assets/animations/monsters/fjeld_warg/fjeld_warg_get_hit_front_left.fbx",
	attack = "assets/animations/monsters/fjeld_warg/fjeld_warg_attack.fbx",
	getHitFrontLeft = "assets/animations/monsters/fjeld_warg/fjeld_warg_get_hit_front_left.fbx",
	turnLeftNormal = "assets/animations/monsters/fjeld_warg/fjeld_warg_turn_left.fbx",
	getHitFrontRight = "assets/animations/monsters/fjeld_warg/fjeld_warg_get_hit_front_right.fbx",
	turnRight = "assets/animations/monsters/fjeld_warg/fjeld_warg_turn_right.fbx",
	getHitBack = "assets/animations/monsters/fjeld_warg/fjeld_warg_get_hit_back.fbx",
	moveForward = "assets/animations/monsters/fjeld_warg/fjeld_warg_walk.fbx",
	turnLeft = "assets/animations/monsters/fjeld_warg/fjeld_warg_turn_left.fbx",
	idle = "assets/animations/monsters/fjeld_warg/fjeld_warg_idle.fbx",
	getHitLeft = "assets/animations/monsters/fjeld_warg/fjeld_warg_get_hit_left.fbx",
	getHitRight = "assets/animations/monsters/fjeld_warg/fjeld_warg_get_hit_right.fbx"
}
for name,filename in pairs(listOfAnimations) do
defineAnimationEvent{
	animation = filename,
	event = "anim2play_"..name,
	normalizedTime = 0,
}
end
end
Then in your first AnimationComponent:

Code: Select all

onAnimationEvent = function(self,event)
  if event:find("anim2play_") then
    otherAnimationComponent:play(event:sub(11))
  end
end,
Now otherAnimationComponent will play its own animation of the same name every time the first AnimationComponent does. Obviously, you can get rid of the dumb string parsing part, this is just for illustrative purposes.

Re: Ask a simple question, get a simple answer

Posted: Wed Jun 10, 2015 9:49 pm
by Leki
minmay wrote:Ah. Yes, I'm afraid you will have to do something like that. Adding animation events to the beginning of your first model's animations and using the first AnimationComponent's onAnimationEvent hook is probably easier than using onBeginAction, since then you will easily catch when the monster falls through a pit/flinches/gets knocked back/etc. For example:

Code: Select all

do
local listOfAnimations = { -- the same animation table as your first AnimationComponent
	turnRightNormal = "assets/animations/monsters/fjeld_warg/fjeld_warg_turn_right.fbx",
	fall = "assets/animations/monsters/fjeld_warg/fjeld_warg_get_hit_front_left.fbx",
	attack = "assets/animations/monsters/fjeld_warg/fjeld_warg_attack.fbx",
	getHitFrontLeft = "assets/animations/monsters/fjeld_warg/fjeld_warg_get_hit_front_left.fbx",
	turnLeftNormal = "assets/animations/monsters/fjeld_warg/fjeld_warg_turn_left.fbx",
	getHitFrontRight = "assets/animations/monsters/fjeld_warg/fjeld_warg_get_hit_front_right.fbx",
	turnRight = "assets/animations/monsters/fjeld_warg/fjeld_warg_turn_right.fbx",
	getHitBack = "assets/animations/monsters/fjeld_warg/fjeld_warg_get_hit_back.fbx",
	moveForward = "assets/animations/monsters/fjeld_warg/fjeld_warg_walk.fbx",
	turnLeft = "assets/animations/monsters/fjeld_warg/fjeld_warg_turn_left.fbx",
	idle = "assets/animations/monsters/fjeld_warg/fjeld_warg_idle.fbx",
	getHitLeft = "assets/animations/monsters/fjeld_warg/fjeld_warg_get_hit_left.fbx",
	getHitRight = "assets/animations/monsters/fjeld_warg/fjeld_warg_get_hit_right.fbx"
}
for name,filename in pairs(listOfAnimations) do
defineAnimationEvent{
	animation = filename,
	event = "anim2play_"..name,
	normalizedTime = 0,
}
end
end
Then in your first AnimationComponent:

Code: Select all

onAnimationEvent = function(self,event)
  if event:find("anim2play_") then
    otherAnimationComponent:play(event:sub(11))
  end
end,
Now otherAnimationComponent will play its own animation of the same name every time the first AnimationComponent does. Obviously, you can get rid of the dumb string parsing part, this is just for illustrative purposes.
Yes, animation events on 1st frame is the best way, I agree - I used onBegin just as a simple example here in questions.
What I dont understand is this part:

Code: Select all

otherAnimationComponent:play(event:sub(11))
it's the same problem as I have with

Code: Select all

self.go.animation("weapons"):play("moveForward")
I mean - what is the propper syntax to call that component?[/color]

Re: Ask a simple question, get a simple answer

Posted: Wed Jun 10, 2015 9:57 pm
by minmay
Sorry, that shorthand was confusing. If your other animation component is named "goat", it would be:

Code: Select all

onAnimationEvent = function(self,event)
  if event:find("anim2play_") then
    self.go.goat:play(event:sub(11))
  end
end,

Re: Ask a simple question, get a simple answer

Posted: Wed Jun 10, 2015 10:14 pm
by Leki
minmay wrote:Sorry, that shorthand was confusing. If your other animation component is named "goat", it would be:

Code: Select all

onAnimationEvent = function(self,event)
  if event:find("anim2play_") then
    self.go.goat:play(event:sub(11))
  end
end,
Cool, so the answer is: propper syntax is just: self.go.component_name:play(). Thanks for help m8.

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 11, 2015 7:41 am
by petri
@Leki: a simple way to attach a weapon like a sword to a monster's hand is to use the parentNode property. This way you don't need to animate the weapon at all.

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 11, 2015 8:28 am
by Leki
petri wrote:@Leki: a simple way to attach a weapon like a sword to a monster's hand is to use the parentNode property. This way you don't need to animate the weapon at all.

Yes, sword is fine, axe and morning star as well, but I have armoured body parts, bow etc and they have more komplex skin and parent node cannot manage it - I need "full animation" for them. The point is that I have geared monster and onActivate script will turn on random weapons and gear parts around the main body (and activate brain for a selected weapon) - so with one "smart" object I have nice visual variability of one monster type.

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 11, 2015 8:58 am
by minmay
petri wrote:@Leki: a simple way to attach a weapon like a sword to a monster's hand is to use the parentNode property. This way you don't need to animate the weapon at all.
Oh wow, I never realized ModelComponent supported that! I have a lot of things to redesign now...

Re: Ask a simple question, get a simple answer

Posted: Fri Jun 12, 2015 5:25 pm
by The cube
Is it possible to check what tile (forest_trees/forest_wall/...) is in a certain tile?

for example, is it possible to check if there is a forest_ground tile with elevation equal to our monster's elevation in front of the monster?

or is there a way to circument this withought adding a shitton of blockers or other objects to use as walls.

Re: Ask a simple question, get a simple answer

Posted: Fri Jun 12, 2015 5:43 pm
by Isaac
It is possible to check the decorations present, and make an assumption... It is also possible check what the automap tile is. Provided you don't alter it in your mod, it's a reasonably reliable way to check for certain aspects using the Map component.

Ground can be distinguished from water, and a few other types.
The automap tile number can be 0 (ground), 1 (grassy_ground), 2 (water), 3 (wall), 4 (rocky_wall), 5 (trees) or 6 (chasm).

A combination check of the automap tile, and the decorations present could give a good guess as to the tile used. Elevation check is another feature of the Map component.

Re: Ask a simple question, get a simple answer

Posted: Sun Jun 14, 2015 8:05 am
by Eleven Warrior
Hi guys. I am trying to get this script to work. What happens is when the counter gets to 9 nothing will happen. It comes up with a error with the rat_shank. The player can pull the level 9 times to get a rat_shank, but after that they get nothing. I go this script from LOG 1. Any help would be appreciated thxs :)

Oh a lever is connected to the function (feedTheParty) I can name the rat_shank to rat_shank_1 but when you pull the lever the second time it says duplicate item etc...

Code: Select all

fed_counter = 0

function feedTheParty()
if fed_counter > 9 then
	hudPrint("Nothing happens.")
else
	fed_counter = fed_counter + 1
		spawn("rat_shank",5,26,18,2,0)
			pickup_food_alcove.surface:addItem(rat_shank.item)
				playSound("level_up")
end
	end