Page 1 of 1

Getting the position of a thrown item in-air

Posted: Tue Mar 11, 2014 1:25 am
by flatline
Tinkering with different ways to make a lit thrown torch as a way to get back into Grimrock editing. Did anyone ever make one?

Is there a way to get the pos of a thrown item? If I am thinking straight, using the LoG framework you'd be able to move a light spawned on the torch in real time, more or less.

That would create a pretty good lit thrown torch. Unfortunately I realise I'm too rusty to create the code from scratch.

Re: Getting the position of a thrown item in-air

Posted: Tue Mar 11, 2014 3:19 pm
by DesperateGames
I made something similar with a lot of trickery in my "Prison Ward" dungeon:
SpoilerShow
There is a scene at the beginning where skeletons play ball with a glowing, holy orb. The orb is created by the "shootProjectile"-function. At the same time, a fx entity is being spawned and moved along together with the orb by using Diarmuds genius fxTranslator solution, see here: viewtopic.php?f=14&t=5801

Here you can see the effect in action (at 13:12 onward in the video):

http://www.youtube.com/watch?v=N5Syf0YqxFE#t=791

The "trick" is that the fx does not "know" the position of the thrown item, it is simply moved in the same speed as the orb. I am afraid I don't know any method to obtain the coordiantes of a thrown item. If this would be possible, the effect would be even better.
You could do the same with your torch, although I would not know for sure how to create / start the effect when the torch is thrown. Maybe the following could work: There is the "onDrawGui"-Scripting hook. Whenever it gets called, you could analyze whether

-The player has a torch under his mouse cursor
-If the player has just clicked the mouse button
-If the mouse cursor position is high enough (relative to the screen resolution ;) )so the click will result in throwing the torch.

If the above conditions are met, you could start the effect. A bit of trickery involved, but this could work.

Re: Getting the position of a thrown item in-air

Posted: Tue Mar 11, 2014 3:39 pm
by Dr.Disaster
It might be a bit far fetched but these advanced throwing weapons (the "Chakram" from Ralzakark and "The Glaive of Krull" from Pat Ferguson) had to deal with this too. Their scripts might brighten things up a bit.

Re: Getting the position of a thrown item in-air

Posted: Thu Mar 13, 2014 5:31 am
by Diarmuid
hey guys, while implementing something for the orrr2, I realized that "glitterEffect" can attach any particle system to an object, including when it's thrown. No light with it, but you can always attach the "torch" particle directly to the object and send a light without particle to go with it with the fxTranslator: if the flame is in the exact place but the light is approximate it won't show.

glitterEffect seems to center the particle system on the object, but you can adjust the placement by cloning the particle system def and tinkering with the boxMin / boxMax properties.

Re: Getting the position of a thrown item in-air

Posted: Thu Mar 13, 2014 8:07 pm
by flatline
Diarmuid wrote:hey guys, while implementing something for the orrr2, I realized that "glitterEffect" can attach any particle system to an object, including when it's thrown. No light with it, but you can always attach the "torch" particle directly to the object and send a light without particle to go with it with the fxTranslator: if the flame is in the exact place but the light is approximate it won't show.

glitterEffect seems to center the particle system on the object, but you can adjust the placement by cloning the particle system def and tinkering with the boxMin / boxMax properties.
Thanks, just the solution I was hoping for!