Author Topic: Finding a brick through eye vector  (Read 1183 times)

Okay, I'm working on a mod right now and was referencing the city rp mod just for the giving money command. It defines a variable as this:
Code: [Select]
%target = containerRayCast(%client.player.getEyePoint(), vectorAdd(vectorScale(vectorNormalize(%client.player.getEyeVector()), 8), %client.player.getEyePoint()), $typeMasks::playerObjectType).client;Now, how would I change that to target a brick (JVS Door)?
I tried just throwing in a pref from the JVS script randomly to see if miraculously that would work, haha. It didn't, I think. Heres what i put:
Code: [Select]
%target = containerRayCast(%client.player.getEyePoint(), vectorAdd(vectorScale(vectorNormalize(%client.player.getEyeVector()), 8), %client.player.getEyePoint()), $JVS::Doors::Category).client;

But, let me know what to do and thanks for any and all help!

$typeMasks::fxDtsBrickType should work. Also, should add an if(%target.category $= "JVS"), to make sure its a door, otherwise it'd pick up all bricks.

Thank you so much, I'll try it out.

Seeing as doors have their raycasting turned off I think you would need to use $TypeMasks::FxBrickAlwaysObjectType.
Quote
Fixed bug where container search for fxbrickobjecttype would return all bricks instead of just the ones with raycasting enabled. Note: this change was necessary to fix some bugs with blowing things up, but it is almost certainly going to break an add-on somewhere. If you want to do a container search that finds all bricks regardless of raycasting status, you need to use $TypeMasks::FxBrickAlwaysObjectType

EDIT:
I updated that, but it still isn't working. Here is the code as of now:
Code: [Select]
function servercmdopen(%client)
{
%target = containerRayCast(%client.player.getEyePoint(), vectorAdd(vectorScale(vectorNormalize(%client.player.getEyeVector()), 8), %client.player.getEyePoint()), $typeMasks::fxDtsBrickAlwaysObjectType).client;

if(!isObject(%target))
{
messageClient(%client, '', "\c6You must be looking at and be in a reasonable distance of the door to open it.");

return;
}
if(%target.category $= "JVS")
{
processInputEvent(doorOpen);
}
}
It loads up fine with no syntax errors, but when I look at the door and type "/open", it gives me the error message.
Any help?
Thanks again for the help already =)
« Last Edit: May 14, 2009, 09:52:58 PM by lilboarder32 »

At the end of your %target declaration you have .client.

Lol, woops. Thanks Truce.

EDIT:
It still is giving me the error message, and i removed the ".client" at the end.
And I am looking at the door in a reasonable distance. Any ideas?
Code as of now is:
Code: [Select]
function servercmdopen(%client)
{
%target = containerRayCast(%client.player.getEyePoint(), vectorAdd(vectorScale(vectorNormalize(%client.player.getEyeVector()), 8), %client.player.getEyePoint()), $typeMasks::fxDtsBrickAlwaysObjectType);

if(!isObject(%target))
{
messageClient(%client, '', "\c6You must be looking at and be in a reasonable distance of the door to open it.");

return;
}
if(%target.category $= "JVS")
{
processInputEvent(doorOpen);
}
}
« Last Edit: May 15, 2009, 09:42:55 AM by lilboarder32 »

Seeing as doors have their raycasting turned off I think you would need to use $TypeMasks::FxBrickAlwaysObjectType.
beat me to it :/

The raycast returns a string containing the targeted object, normal and collision position. Use firstWord(%raycast) for the target.

Seeing as doors have their raycasting turned off I think you would need to use $TypeMasks::FxBrickAlwaysObjectType.
No they don't. You can click them - raycasting = activatable. They have rendering off, which doesn't affect raycasts.

The raycast returns a string containing the targeted object, normal and collision position. Use firstWord(%raycast) for the target.
No they don't. You can click them - raycasting = activatable. They have rendering off, which doesn't affect raycasts.
Oh haha, woops - I had raycasting copied from something I was building. My mistake.

would it matter then if i had FxDtsBrickAlwaysObjectType? Or should I change it back to FxDtsBrickType?

would it matter then if i had FxDtsBrickAlwaysObjectType? Or should I change it back to FxDtsBrickType?
Well you could make doors that were only operable by using the command if you left always object and turning the door's raycasting off. But if you don't want anything like that then you can just use the basic fxDtsBrickType.

Well you could make doors that were only operable by using the command if you left always object and turning the door's raycasting off. But if you don't want anything like that then you can just use the basic fxDtsBrickType.

Well I have it so raycasting is off and the always object is on, yet it still isnt working. It says the message if I'm not looking at the door, when I am looking at the door in a reasonable distance.