Scripters cove

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

Moderators: winston, another_commander

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

DESIRED_RANGE_ACHIEVED

Post by UK_Eliter »

Dear Ooniverse members

I have the impression, from the AI documentation on the wiki, that DESIRED_RANGE_ACHIEVED is not a 'priority' message. But, if that is so, how come the default missile AI has a five second pause in its 'UPDATE'?

I need to know the answer to this because I've been building in only very small 'update' delays into missile AIs I've written - and now I wonder whether I can make them bigger. (I want to do a checkDistanceTravelled, but only every so-many seconds, and not as often as I want the missile interception to see whether it has reached its target.) Thanks.
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: DESIRED_RANGE_ACHIEVED

Post by Eric Walch »

UK_Eliter wrote:
I have the impression, from the AI documentation on the wiki, that DESIRED_RANGE_ACHIEVED is not a 'priority' message. But, if that is so, how come the default missile AI has a five second pause in its 'UPDATE'?
When send by a 'performIntercept', the DESIRED_RANGE_ACHIEVED has priority and ignores any pauses between updates. In the frame that the missile comes in range, it will execute the corresponding AI line.

(When send by performFlyToDestination, DESIRED_RANGE_ACHIEVED has no priority and is only executed on the next update.)
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: Scripters cove

Post by UK_Eliter »

Eric: thank you very much. That's great. But here's another question. What about messages scripts send to AIs? Do they get acted upon immediately, please?
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: Scripters cove

Post by Eric Walch »

UK_Eliter wrote:
What about messages scripts send to AIs? Do they get acted upon immediately, please?
There are two messages possible: reactToAIMessage and sendAIMessage
The first is executed immediately, the second is postponed until the next update. The second is new in 1.75.
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: Scripters cove

Post by UK_Eliter »

Very helpful information (and a very prompt reply). Thank you!
User avatar
CommonSenseOTB
---- E L I T E ----
---- E L I T E ----
Posts: 1397
Joined: Wed May 04, 2011 10:42 am
Location: Saskatchewan, Canada

Re: Scripters cove

Post by CommonSenseOTB »

I have a scripting question involving vectors. I'm looking for an equation that returns a position that is exactly halfway between player.ship and another entity. Thankyou for any help you can give me on this.
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

this.halfWayPoint = Vector3D.interpolate(player.ship.position, this.otherEntity.position, 0.5)

Using the Interpolate function of Vector3D, where this.otherEntity is the second entity involved. this.halfWayPoint will contain the required mid-point position.
User avatar
CommonSenseOTB
---- E L I T E ----
---- E L I T E ----
Posts: 1397
Joined: Wed May 04, 2011 10:42 am
Location: Saskatchewan, Canada

Re: Scripters cove

Post by CommonSenseOTB »

That's just what I need, thanks Thargoid! :)
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs
User avatar
CaptSolo
---- E L I T E ----
---- E L I T E ----
Posts: 909
Joined: Wed Feb 23, 2011 10:08 pm
Location: Preying Manta
Contact:

Re: Scripters cove

Post by CaptSolo »

I've started coding a mission set in galaxy 3. I have a simple scripting question for which the answer is either yes or no: Is their a condition where NPC ships can detect if the player has targeted them?

I suppose the Wiki has the answer but I'm too lazy to look for it.
User avatar
CommonSenseOTB
---- E L I T E ----
---- E L I T E ----
Posts: 1397
Joined: Wed May 04, 2011 10:42 am
Location: Saskatchewan, Canada

Re: Scripters cove

Post by CommonSenseOTB »

CaptSolo wrote:
I've started coding a mission set in galaxy 3. I have a simple scripting question for which the answer is either yes or no: Is their a condition where NPC ships can detect if the player has targeted them?

I suppose the Wiki has the answer but I'm too lazy to look for it.
No.
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs
User avatar
CaptSolo
---- E L I T E ----
---- E L I T E ----
Posts: 909
Joined: Wed Feb 23, 2011 10:08 pm
Location: Preying Manta
Contact:

Re: Scripters cove

Post by CaptSolo »

CommonSenseOTB wrote:
CaptSolo wrote:
I've started coding a mission set in galaxy 3. I have a simple scripting question for which the answer is either yes or no: Is their a condition where NPC ships can detect if the player has targeted them?

I suppose the Wiki has the answer but I'm too lazy to look for it.
No.
Thanks for the quick replay CSOTB. Tis a shame! Would have been nice to alter NPC behaviour based on such a condition.
User avatar
CommonSenseOTB
---- E L I T E ----
---- E L I T E ----
Posts: 1397
Joined: Wed May 04, 2011 10:42 am
Location: Saskatchewan, Canada

Re: Scripters cove

Post by CommonSenseOTB »

While there is no condition like what you want there is a possible workaround. If you place this.shipTargetAquired = function(target) into a worldscript that should give you the player's target when the player selects a target. Then you could set some kind of flag variable to true if the NPC is the target. Then have the NPC's AI periodically send a script message to go into a function and have that function look for the flag being true and if it is send the AI a message that causes it to react like you want. I think there are many ways to set this up depending on what you intend to do. I'm probably the wrong person to ask for a specific workaround in this area as I have no experience at all in this area. Perhaps someone more skilled in AI and scripting could give a better answer for you.
Take an idea from one person and twist or modify it in a different way as a return suggestion so another person can see a part of it that can apply to the oxp they are working on.


CommonSense 'Outside-the-Box' Design Studios Ltd.
WIKI+OXPs
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

It depends if you mean targetted as in just has a target lock on them (for a missile for example) or whether you mean actually attacked them.

If you actually mean attacked, then this.shipBeingAttacked is your man, checking on the whom parameter (if whom.isPlayer). You can also use shipBeingAttackedByCloaked and shipAttackedWithMissile to cover those eventualities, but the cloaked one does not pass the attacking ship (as it's invisible).

If you just mean targetted, then you'd have to do a scan periodically of the ships in the area and check that they have a target, that the target is the ship in question and that the target is the player (much as OTB says). If you want an example of something like that, look in the scripting for the guardians in Aquatics, or the drones in Armoury. It's not quite the same, but you can build your requirements quite easily from those bases.

But I would be wary of gettign to aggressive just on a target lock, as the ID system may also trigger it (I'm not 100% sure there) and many players (inc me) will ID a ship without following through to a missile lock. And of course if we're talking lasers then there is no lock, just shooting.
User avatar
CaptSolo
---- E L I T E ----
---- E L I T E ----
Posts: 909
Joined: Wed Feb 23, 2011 10:08 pm
Location: Preying Manta
Contact:

Re: Scripters cove

Post by CaptSolo »

Thargoid wrote:
It depends if you mean targetted as in just has a target lock on them (for a missile for example) or whether you mean actually attacked them.

If you just mean targetted, then you'd have to do a scan periodically of the ships in the area and check that they have a target, that the target is the ship in question and that the target is the player (much as OTB says). If you want an example of something like that, look in the scripting for the guardians in Aquatics, or the drones in Armoury. It's not quite the same, but you can build your requirements quite easily from those bases.

But I would be wary of gettign to aggressive just on a target lock, as the ID system may also trigger it (I'm not 100% sure there) and many players (inc me) will ID a ship without following through to a missile lock. And of course if we're talking lasers then there is no lock, just shooting.
To clarify, my question was premised on a player having a missile lock on a NPC but no other aggressive action taken. The hoped for response based on said NPC being aware of this condition would be that it could alter it's behaviour. The idea I had was not that said NPC would turn aggressive but rather the opposite. I will certainly take a look at the OXP scripts you mentioned.
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: Scripters cove [hope I'm not hijaking this thread . .]

Post by UK_Eliter »

Hi everyone

Can anyone tell me, please, if/how I can detect whether a ship (specifically: the player) has initiated an ECM pulse?

Cheers.
Post Reply