Author Topic: Chat Mod to limit talking through bricks  (Read 4342 times)

I started working on this a few months ago and gave it up, came back to it today and fixed it in about 5 minutes. I modified the chat function so that a player has to be a certain distance away and there can't be bricks between you. Now this is the basic of what I want.

I'm trying to figure a way out so that if say a player is standing against like a fence wall and can't see the person they can still hear them. I have no idea how to go about doing this though. Any help is greatly appreciated.

Package serverCmdMessageSent(%client,%message). Parent it, then use InitContainerRadiusSearch(%centerPos ,%radius ,%masks) in the function. Such as:

initContainerRadiusSearch(%client.player.getHackPosition(), 12, $TypeMasks::PlayerObjectType);
while(isObject(%searchObj = containerSearchNext()))
{
//Do stuff
}


You may need ContainerRayCast(%startPos,%endPos,%masks) to see if there is some kind of wall, too.
« Last Edit: July 09, 2014, 03:14:50 AM by Advanced Bot »


This is what I have so far and it works. I guess what I'm trying to say is that if the person is on the other side of a tall fence they can't hear them. I have no clue how to get around that. Like the only way would be doing pathfinding or something I think.

Code: [Select]
package Chat
{
function serverCmdMessageSent(%client,%msg)
{
if(!isObject(%client.player))
return;

%position = %client.player.getPosition();
InitContainerRadiusSearch(%position,30,$TypeMasks::PlayerObjectType);

while((%targetObject = containerSearchNext()) !$= 0)
{
if(!ContainerRayCast(%client.player.getEyePoint(), %targetObject.client.player.getEyePoint(), $TypeMasks::FXBrickObjectType))
{
messageClient(%targetObject.client,'',"\c4[Local] \c7" SPC %client.clanPrefix @ "\c3" @ %client.name @ "\c7" @ %client.clanSuffix @ "\c6:" SPC %msg);
}
}
}
};
« Last Edit: July 09, 2014, 03:25:18 AM by devildogelite »

I'm sorry, I'm a little confused on what you're trying to accomplish. What I'm gathering from what you're saying is that you want to calculate how many steps it would take to get to a receiving player from the broadcasting player, and not send the message to them if they're too far. That would be extremely resource intensive for Blockland because you'd need a pathfinding algorithm with dynamic nodes. I'm not sure if that's actually what you're looking for though.

I'm having trouble wording what I want but I'm pretty sure it wouldn't work. I wanted to make a local chat that doesn't go through walls, but it ends that a player can only chat with another if they are in line of site. I figured the only way to do it would be using some sort of pathfinding that can only go so far before it stops.

It sounds like you already have what you want then, but you seem to be upset that you can't talk through fences (which are walls). That's why I'm confused.

He probably wants you to be able to talk around corners and over low walls if there's no roof (like a fence)

He probably wants you to be able to talk around corners and over low walls if there's no roof (like a fence)
That's why I was asking if he wants pathfinding, but then he says stuff like "a player can only chat with another if they are in line of sight" which even a fence would obstruct.




In something like this the chat wouldn't work for them. They're not actually separated by a wall or anything, they're just not within each other's field of view. I want it to work where something like this wouldn't stop the chat from going through.


That's why I was asking if he wants pathfinding, but then he says stuff like "a player can only chat with another if they are in line of sight" which even a fence would obstruct.

If I said I wanted it to work line of sight only than I made a mistake, right now it only works in line of sight it was I meant.

They appear to be in each others field of view to me.

They appear to be in each others field of view to me.

They're not

so why not use a combination of raycasting and seeing if the receiver is inside the senders field of view (and vice versa)?

so why not use a combination of raycasting and seeing if the receiver is inside the senders field of view (and vice versa)?

I guess I worded this all poorly, I want them to be able to talk to each other in a scenario like that picture. Currently they have to be in line of site of each other which I don't want. But I don't want it to be able to go through walls of like a house or something. Right now if someone is around a corner from someone they won't see the chat which I don't want.

Short version: It's not possible.
Long version: It's possible if you make builders put chat relay bricks, but most of them won't.

Why not so a second raycast a few units above the first?

It's entirely possible