player.commsMessage() broadcasting to far.

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

player.commsMessage() broadcasting to far.

Post by Eric Walch »

It is reported in the past that thargoid messages are broadcasted when no one is visible. I thought it was because of their longer scanner range. But now I also discovered it with my own scripts: When a ship at the other end of the system is broadcasts something, the player gets it on screen.

The AI command "commsMessage" is always checking for range and sends the message to all ships in scanner range. The JS command only sends the message to the player (I assume it is only to the player) but has no distance check.

I think it needs a distance check. Or by the JS function internally or by the scripter. It is probably more efficient and flexible when done by the scripter.

I think the current thargoid-warship script in Oolite

Code: Select all

this.shipDied = function ()
{
	player.commsMessage(expandDescription("[thargoid_curses]"));
}
should be changed to:

Code: Select all

this.shipDied = function ()
{
	if(this.ship.position.distanceTo(player) < 25600) player.commsMessage(expandDescription("[thargoid_curses]"));
}
It will be a good example for other scripts with messages.

Or miss I something and are there other opinions?
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

I also noticed that I sometimes get Thargoid Curses when I'm docked at the main station. I guess in most cases the sending Thargoid ship is at the other end of the system. So I think a distance check would be good.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: player.commsMessage() broadcasting to far.

Post by Eric Walch »

Eric Walch wrote:
I think it needs a distance check. Or by the JS function internally or by the scripter. ... Or miss I something and are there other opinions?
I just browsed through the current trunc code and noticed the ships will in future have their own commsMessage that does the range checking. So that seems to be solved already.

this.ship.commsMessage will do the range check, player.commsMessage not. It suits to have both versions. (one with and one without rangecheck)
Post Reply