Page 1 of 2

radar pings - how to detect via JS API?

Posted: 02 Feb 2012, 14:16
by aubergine
I'm loving the way radar detectors now work, however I'm not sure how to get my AI to "see" what they see?

Because a ping doesn't give any indication of what sort of building it is, I don't think radar pings should be enumerable or based on "base object".

Instead, would it be worth having an event that triggers when a new ping is detected?

Code: Select all

var pings = [];

eventRadarPing(nX,nY,bBig,nPlayer) {
  // nX = x coord (number)
  // nY = y coord (number)
  // bBig = is it a BIG ping, eg. satellite uplink? (boolean)
  // nPlayer = id of player who built the structure (number)

  pings.push({x:nX,y:nY,big:bBig,player:nPlayer}); // add to my list of pings
}
The script can then keep a record of pings and decide what to do about them.

Removing pings from the AI's internal list is also quite easy:

Code: Select all

eventSeen(viewer,seen) {
  var i = pings.length;
  while (-1<--i) {
    if (pings[i].x==seen.x && pings[i].y==seen.y) pings.splice(i,1); // remove ping
  }
}
The only downside is that if someone else destroys the structure, or its owner demolishes it, before my AI spots it, then the ping won't get removed from the array.

Suggestions on a postcard to the usual address please...

Re: radar pings - how to detect via JS API?

Posted: 02 Feb 2012, 14:24
by aubergine
Maybe if pings were given ID's (basically the object id of what what's been detected):

Code: Select all

var pings = []; // my list of pings

eventRadarPing(ping) {
  // ping.id = id of detected object
  // ping.x and ping.y = coords of object
  // ping.player = owner of object
  // ping.big = is it a big ping? (satellite uplink)
  // ping.active = is the ping active (boolean)

  if (ping.active) { // add to my list
    pings.push(ping);
  } else { // remove from my list
    var x = pings.length;
    while (-1<--x) if (pings[x].id==ping.id) pings.splice(x,1);
  }
}
That seems much nicer solution :)

Re: radar pings - how to detect via JS API?

Posted: 02 Feb 2012, 14:40
by aubergine
or even...

Code: Select all

var pings = {}; // use an object instead

eventRadarPing(ping) {
  (ping.active) ? pings[ping.id] = ping : delete pings[ping.id];
}

Re: radar pings - how to detect via JS API?

Posted: 02 Feb 2012, 14:47
by aubergine
Hrm, thinking some more - why are satellite uplinks detectable by radar sensors? The satellite uplink isn't a radar - it's not sending pulses out on to the map to detect stuff, it's communicating digitally with a satellite in orbit, and the satellite in orbit is doing the sensing, not the satellite uplink...

Re: radar pings - how to detect via JS API?

Posted: 02 Feb 2012, 15:03
by Emdek
Maybe that transmission counts as detectable signal?

Re: radar pings - how to detect via JS API?

Posted: 02 Feb 2012, 15:07
by aubergine
I wouldn't have thought so - the parabolic design of the satellite dish ensures a highly focussed signal that doesn't spread much so it's pretty much a direct link between dish and satellite. Also, I would imagine that the dish is just receiving info form the satellite, rather than sending info to it, just like the satellite TV dish on the side of my house. In which case it's completely passive and thus invisible to radar detectors...

Re: radar pings - how to detect via JS API?

Posted: 02 Feb 2012, 15:09
by Emdek
Well, but as it was stated many times, this is not simulation. ;-)
So to detect this we would need separate turret or upgrade or need to scout otherwise.

Re: radar pings - how to detect via JS API?

Posted: 02 Feb 2012, 15:10
by aubergine
We already have a structure capable of detecting enemy satellite uplinks: our own satellite uplink :)

Re: radar pings - how to detect via JS API?

Posted: 02 Feb 2012, 15:11
by Emdek
But you need lots of research to get it, and it's general purpose, not only for detecting others. :-P
In current state it allows users with lower tech to more successfully compete higher developed ones.

Re: radar pings - how to detect via JS API?

Posted: 02 Feb 2012, 16:18
by dak180
aubergine wrote:Hrm, thinking some more - why are satellite uplinks detectable by radar sensors? The satellite uplink isn't a radar - it's not sending pulses out on to the map to detect stuff, it's communicating digitally with a satellite in orbit, and the satellite in orbit is doing the sensing, not the satellite uplink...
My guess would be that the same reason that one can detect and preform intercepts on sat-phone traffic, there is a not insignificant amount of leakage even when using a parabolic antenna.

Re: radar pings - how to detect via JS API?

Posted: 02 Feb 2012, 17:02
by aubergine
But if the dish is just there to receive info from the satellite, then the dish isn't actually creating any EM radiation.

Re: radar pings - how to detect via JS API?

Posted: 02 Feb 2012, 17:44
by dak180
aubergine wrote:But if the dish is just there to receive info from the satellite, then the dish isn't actually creating any EM radiation.
Unless the satellite is doing a blind broadcast of the info it is picking up in the clear there will be some two way traffic, more coming down then going up due to data density, but still traffic going both ways.

Re: radar pings - how to detect via JS API?

Posted: 02 Feb 2012, 22:16
by Per
I've added a function enumBlips(player) to get all non-transient blips seen by a player. What you get is a list of x,y coordinates only. By non-transient, I mean that it includes sensors seen by radar detectors, and ecm jammers. It does not include droids going out of view.

As for satellite uplink - I did not know that it counted as a sensor. I'm inclined to think that is a mistake.

Re: radar pings - how to detect via JS API?

Posted: 03 Feb 2012, 03:40
by aubergine
Any chance of an event instead of an enum? With an enum, I need to set a timeout to keep checking for new or removed blips :s With an event, as shown earlier in this topic, my script would get prodded when something changes and thus not have to constantly poll the API to see if something has changed.

Re: radar pings - how to detect via JS API?

Posted: 03 Feb 2012, 08:56
by Per
There are no existing hooks to add such an event to inside the game, so that is harder to do at the moment. I'll see if I can't add an event too later on.