radar pings - how to detect via JS API?

For AI and campaign script related discussions and questions
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

radar pings - how to detect via JS API?

Post 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...
Last edited by aubergine on 02 Feb 2012, 14:43, edited 2 times in total.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

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

Post 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 :)
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

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

Post 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];
}
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

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

Post 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...
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
Emdek
Regular
Regular
Posts: 1329
Joined: 24 Jan 2010, 13:14
Location: Poland
Contact:

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

Post by Emdek »

Maybe that transmission counts as detectable signal?
Nadszedł już czas, najwyższy czas, nienawiść zniszczyć w sobie.
The time has come, the high time, to destroy hatred in oneself.


Beware! Mad Qt Evangelist.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

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

Post 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...
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
Emdek
Regular
Regular
Posts: 1329
Joined: 24 Jan 2010, 13:14
Location: Poland
Contact:

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

Post 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.
Nadszedł już czas, najwyższy czas, nienawiść zniszczyć w sobie.
The time has come, the high time, to destroy hatred in oneself.


Beware! Mad Qt Evangelist.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

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

Post by aubergine »

We already have a structure capable of detecting enemy satellite uplinks: our own satellite uplink :)
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
Emdek
Regular
Regular
Posts: 1329
Joined: 24 Jan 2010, 13:14
Location: Poland
Contact:

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

Post 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.
Nadszedł już czas, najwyższy czas, nienawiść zniszczyć w sobie.
The time has come, the high time, to destroy hatred in oneself.


Beware! Mad Qt Evangelist.
User avatar
dak180
Trained
Trained
Posts: 288
Joined: 01 Nov 2009, 23:58
Location: Keeper of the Mac Builds

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

Post 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.
User:dak180
Keeper of the Mac Builds
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

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

Post 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.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
dak180
Trained
Trained
Posts: 288
Joined: 01 Nov 2009, 23:58
Location: Keeper of the Mac Builds

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

Post 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.
User:dak180
Keeper of the Mac Builds
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

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

Post 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.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

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

Post 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.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

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

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