Accessing an entity's parent [SOLVED]

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1248
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Accessing an entity's parent [SOLVED]

Post by UK_Eliter »

[EDIT: I meant to put this in the 'Scripters' Cove' thread - but it seems I failed to. Sorry.]

Dear all

I am trying to make a script detect whether (1) an entity's parent has been targeted in a hostile way by some other ship (that's to enable a missile to target ships attacking the ship that launched the missile), (2) the as-it-were grandparent of an entity has been targeted in a hostile way by some other ship (that's to enable subminitions that launch from the aforementioned missile to target ships attacking the ship that launched the missile).

Now, I've managed to do this (both 1 and 2) when the ship that launches the missile is the player. For then I can just use the following function.

Code: Select all

function isHostile(entity) 
{	 
	return (entity.isShip && entity.target && entity.target == player.ship && entity.hasHostileTarget);
}
But I'm having trouble with the situation when that is not the case, i.e. when a NPC launched the missile. There doesn't appear to be a this.ship.parent key (even for entities that are declared as both missiles and submunitions). Can anyone help?

Apologies if this has been discussed before. I couldn't find such a discussion.
Last edited by UK_Eliter on Tue Aug 16, 2011 3:40 pm, edited 2 times in total.
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: Accessing an entity's parent

Post by Eric Walch »

UK_Eliter wrote:
There doesn't appear to be a this.ship.parent key (even for entities that are declared as both missiles and submunitions). Can anyone help?

Apologies if this has been discussed before. I couldn't find such a discussion.
it is this.ship.owner as described here. When subminution is launched, it takes the target from the mother missile.
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1248
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: Accessing an entity's parent [SOLVED]

Post by UK_Eliter »

Eric: great. Thank you.
Post Reply