Page 29 of 118

DESIRED_RANGE_ACHIEVED

Posted: Tue Aug 23, 2011 5:56 pm
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.

Re: DESIRED_RANGE_ACHIEVED

Posted: Tue Aug 23, 2011 7:07 pm
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.)

Re: Scripters cove

Posted: Tue Aug 23, 2011 7:58 pm
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?

Re: Scripters cove

Posted: Tue Aug 23, 2011 8:13 pm
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.

Re: Scripters cove

Posted: Tue Aug 23, 2011 8:14 pm
by UK_Eliter
Very helpful information (and a very prompt reply). Thank you!

Re: Scripters cove

Posted: Tue Sep 20, 2011 2:41 am
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.

Re: Scripters cove

Posted: Tue Sep 20, 2011 6:04 am
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.

Re: Scripters cove

Posted: Tue Sep 20, 2011 7:15 am
by CommonSenseOTB
That's just what I need, thanks Thargoid! :)

Re: Scripters cove

Posted: Fri Oct 07, 2011 1:11 am
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.

Re: Scripters cove

Posted: Fri Oct 07, 2011 2:50 am
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.

Re: Scripters cove

Posted: Fri Oct 07, 2011 3:02 am
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.

Re: Scripters cove

Posted: Fri Oct 07, 2011 3:38 am
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.

Re: Scripters cove

Posted: Fri Oct 07, 2011 5:47 am
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.

Re: Scripters cove

Posted: Fri Oct 07, 2011 1:42 pm
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.

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

Posted: Fri Oct 07, 2011 2:07 pm
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.