OFFENCE_COMMITTED

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

Moderators: winston, another_commander, Getafix

Post Reply
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:

OFFENCE_COMMITTED

Post by Commander McLane »

Question about this AI message: When is it sent to AIs? Only as a response to scanForOffenders? Or whenever an offence is committed in scanner range? And what counts as an offence? Attacks on clean ships?

Probably it is only the positive response to scanForOffenders, but in that case the name of the message may lead to false expectations (as it would be in my case).

I was following the tail of a ship with an OFFENCE_COMMITTED message in its current state. Another ship attacked and destroyed me. The ship I was following never received an OFFENCE_COMMITTED. But the Wiki says it should. Or does a ship need a "hunter" role in order to listen to OFFENCE_COMMITTED?
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Post by Svengali »

If I remember right this is only sent to ships with class POLICE or STATION.
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 »

That would be an explanation.

And the list in the Wiki certainly looks odd: CLASS_NEUTRAL, CLASS_STATION, CLASS_BUOY, CLASS_POLICE, CLASS_MILITARY, CLASS_PLAYER. Why should buoys and the player get the message?
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Commander McLane wrote:
And the list in the Wiki certainly looks odd: CLASS_NEUTRAL, CLASS_STATION, CLASS_BUOY, CLASS_POLICE, CLASS_MILITARY, CLASS_PLAYER. Why should buoys and the player get the message?
The description with that list is wrong. It are not the classes that receive the message but the classes that automatic send a message when hit. The message OFFENCE_COMMITTED is only send to POLICE ships and the main-station when they are in range. I just corrected the wiki text to:

Code: Select all

Hitting a clean ship with scanClass equal to CLASS_NEUTRAL, CLASS_STATION, CLASS_BUOY, CLASS_POLICE, CLASS_MILITARY or CLASS_PLAYER, automatically sends a OFFENCE_COMMITTED to all nearby police ships and the system station. 
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 »

How are police ships defined in this case? CLASS_POLICE or role police?

And which kinds of ships are receiving distress calls? role police and hunter? Or is it dependent on class?
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Commander McLane wrote:
How are police ships defined in this case? CLASS_POLICE or role police?

And which kinds of ships are receiving distress calls? role police and hunter? Or is it dependent on class?
To be very precise, to all authorities and those are defined by:

Code: Select all

static BOOL AuthorityPredicate(Entity *entity, void *parameter)
{
	ShipEntity			*victim = parameter;
	
	// Select main station, if victim is in aegis
	if (entity == [UNIVERSE station] && [victim withinStationAegis])
	{
		return YES;
	}
	
	// Select police units in scanner range
	if ([entity scanClass] == CLASS_POLICE &&
		distance2([victim position], [entity position]) < SCANNER_MAX_RANGE2)
	{
		return YES;
	}
	
	// Reject others
	return NO;
}
So it uses scanclass and the max scanner range of 25600. (Not the scannerrange of the police ship itself if that was defined shorter. )

And on the distress message you probably figure it out yourself with the code below:

Code: Select all

- (void) broadcastDistressMessage
{
	/*-- Locates all the stations, bounty hunters and police ships in range and tells them that you are under attack --*/

	//...[deleted code]
	unsigned i;
	for (i = 0; i < n_scanned_ships; i++)
	{
		ShipEntity*	ship = scanned_ships[i];
		d2 = distance2_scanned_ships[i];
		if (d2 < found_d2)
		{
			// tell it! //
			if (ship->isPlayer)
			{
				if ((primaryAggressor == [ship universalID])&&(energy < 0.375 * maxEnergy)&&(!is_buoy))
				{
					[self sendExpandedMessage:ExpandDescriptionForCurrentSystem(@"[beg-for-mercy]") toShip:ship];
					[self ejectCargo];
					[self performFlee];
				}
				else
					[self sendExpandedMessage:ExpandDescriptionForCurrentSystem(distress_message) toShip:ship];
				// reset the thanked_ship_id
				//
				thanked_ship_id = NO_TARGET;
			}
			if ([self bounty] == 0) // Only clean ships can have their distress calls accepted
			{
				if (ship->isStation)
					[ship acceptDistressMessageFrom:self];
				if ([ship hasPrimaryRole:@"police"])	// Not isPolice because we don't want wingmen shooting off... 
					[ship acceptDistressMessageFrom:self];
				if ([ship hasPrimaryRole:@"hunter"])
					[ship acceptDistressMessageFrom:self];
			}
		}
	}
}
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 »

:(

So this basically means that I cannot make personalities ships (which all have "personalities" as primary role and CLASS_NEUTRAL) react to offences committed in their vicinity, unless I find a very clever way to have them check for close-by fights in their ship script.

Or of course I have to assign a primary role of "hunter" to those of them which I want to react on distress calls. Have to think about which possible side-effects that could have.
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

Not exactly the same, but they should all react to ecm pulses, and to player status changes (so they'd be able to tell when the player is being attacked)

Alternatively, but it could be quite time consuming, you could scan for all ships in the system every 2 minutes or so, and if you get a cluster of pirate & some other ships within the same scanner range volume, that should mean a fight...

Hmmm, actually this second option could be the basis of a 'police band intercept' radio oxp: 'disturbance in progress, follow beacon 2' and then create a class_no_draw beacon (using the letter '2', of course) in the right spot. The possibilities are endless! :)
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
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 »

Kaks wrote:
they should all react ... to player status changes (so they'd be able to tell when the player is being attacked)
That seems promising. Especially as I have discovered that the player entity doesn't seem to send distress messages...
Post Reply