Page 8 of 11
Posted: Tue Mar 11, 2008 9:08 pm
by Roberto
Cool - I'll remove the shuttle role when the time comes, then. Cheers!
(Oh, and the fight -> hyperspace -> fly-to-the-system-station thing is working too. Onwards!)
Posted: Tue Mar 11, 2008 11:20 pm
by Roberto
Another question: adding ships to take off from the planet. I'm guessing I should use addShipsAt to call them into existence at some point far away from anywhere, then have setTakeOffFromPlanet in the ships' AI to (almost) instantly move them to a suitable position/set them off. Does this sound about right? (I'm not sure how Oolite itself does it.)
Posted: Wed Mar 12, 2008 8:43 am
by Eric Walch
Roberto wrote:Another question: adding ships to take off from the planet. I'm guessing I should use addShipsAt to call them into existence at some point far away from anywhere, then have setTakeOffFromPlanet in the ships' AI to (almost) instantly move them to a suitable position/set them off. Does this sound about right? (I'm not sure how Oolite itself does it.)
Very difficult in legacy scripting as he command
setTakeOffFromPlanet has a bug. It is not setting the orientation of a ship, it only sets a desired range. Ships spawned near the surface will just fly in the random direction they were added. (Half of them crashing into the surface). The bug was filed long ago, but recently Kaks took it up to fix it for the 1.71 release.
I use ships launching from the surface in UPS. There I let them start at the witchpoint side of the planet. I needed this side as now I can make them turn into the witchpoint direction and i know they will fly from the surface. Originally I also wanted to let ships start from the back of the planet, but in legacy I did not see a way to give them a direction.
When you look in UPS, you will find
upsSatelliteDefenseAI.plist and
risingUpsShuttleAI.plist that take care of this lift of. You add them with
addShipsAtPrecisely: name pwp 1 0 0 1.02
Use the coordinate system "pwp". this is related to planet radii. 1 means surface and 1.01 is just a little above. You can even use lower values but in my experience they also need room to turn upwards before departure.
In JS with a shipscript this orientation can be done with JS, but likely Kaks has than fixed the
setTakeOffFromPlanet command so this will take care of the orientation.
Posted: Wed Mar 12, 2008 8:49 am
by Roberto
Many thanks, Eric - I'll give it a go in a sec.
Posted: Wed Mar 12, 2008 9:48 am
by Commander McLane
Eric Walch wrote:Roberto wrote:Another question: adding ships to take off from the planet. I'm guessing I should use addShipsAt to call them into existence at some point far away from anywhere, then have setTakeOffFromPlanet in the ships' AI to (almost) instantly move them to a suitable position/set them off. Does this sound about right? (I'm not sure how Oolite itself does it.)
Very difficult in legacy scripting as he command
setTakeOffFromPlanet has a bug. It is not setting the orientation of a ship, it only sets a desired range. Ships spawned near the surface will just fly in the random direction they were added. (Half of them crashing into the surface). The bug was filed long ago, but recently Kaks took it up to fix it for the 1.71 release.
I use ships launching from the surface in UPS. There I let them start at the witchpoint side of the planet. I needed this side as now I can make them turn into the witchpoint direction and i know they will fly from the surface. Originally I also wanted to let ships start from the back of the planet, but in legacy I did not see a way to give them a direction.
I
think (read: I'm not sure, but it's a suitable guess) ships are
not added in a random direction, but always along the internal z-axis, which happens to be very close to the wp-axis. So adding ships exactly opposite of the witchpoint (pwp 0 0 -1.02) should do the trick and have them launch straight automatically.
But this is only a suitable guess. You would have to try it out first.
Eric Walch wrote:When you look in UPS, you will find upsSatelliteDefenseAI.plist and risingUpsShuttleAI.plist that take care of this lift of. You add them with addShipsAtPrecisely: name pwp 1 0 0 1.02
Oh, and the last should of course be
addShipsAtPrecisely: name 1 pwp 0 0 1.02. (Note the change of order between
1 and
pwp.
Posted: Wed Mar 12, 2008 10:28 am
by Eric Walch
I think (read: I'm not sure, but it's a suitable guess) ships are not added in a random direction, but always along the internal z-axis, which happens to be very close to the wp-axis.
No, I have been working on this extensively. When I add a ship I always see him fly in an other direction. When I add a bunch of 5 ships I see them depart in a star like patron. On flight they turn into the direction I gave them and that takes time and is done with the AI scripting.
EDIT: Also on addition of the four satellites they all had an other orientation. Then I experimented with secondary role "station". This did the trick that the satellites now all have the same orientation. I also needed the station role for this to be able to work with alert levels, but that is an other issue. /EDIT
On the AddShips you are right I switched two values. In ups I use a distance of 1.01 not 1.02. But this value also depends on the size of your ship and if you first turn before you start flying. Just experiment with the value. You don't see a real planetary surface as reference so even a start at a 1000 meters above surface looks as surface start.
Posted: Wed Mar 12, 2008 10:46 am
by Roberto
Clearly I've done something horrendously stupid with the second function here, as Oolite objects to it:
Code: Select all
this.launchtaranistrafficwitch = function ()
{
system.legacy_addShips("taranis_traffic_witch", 1);
}
this.launchtaranistrafficplanet = function ()
{
system.legacy_addShipsAtPrecisely("taranis_traffic_planet", 1 pwp 0 0 1.02);
}
Do I need to stick some more quotes in somewhere?
Posted: Wed Mar 12, 2008 11:00 am
by Eric Walch
Roberto wrote:Clearly I've done something horrendously stupid with the second function here, as Oolite objects to it:
It should be:
Code: Select all
this.launchtaranistrafficwitch = function ()
{
system.legacy_addShips("taranis_traffic_witch", 1);
}
this.launchtaranistrafficplanet = function ()
{
system.legacy_addShipsAtPrecisely("taranis_traffic_planet", 1, "pwp", 0, 0, 1.02);
}
Not only the quotes were missing. But don't worry, it is the same mistake I made when starting with JS and ship additions.
Posted: Wed Mar 12, 2008 11:23 am
by Roberto
Cheers!
Posted: Wed Mar 12, 2008 3:19 pm
by Roberto
OK, as LB suggested (quite a while ago now), I've created a new system station using like_ship in order to launch extra traffic. I've had to modify the AI a bit more than I expected, as the constant switching between IDLE and CHECK_FOR_DEBRIS was messing things up. I've basically combined them into one:
Code: Select all
IDLE = {
ATTACKED = (setTargetToPrimaryAggressor, increaseAlertLevel, "setStateTo: DEFENSE_MODE");
"OFFENCE_COMMITTED" = (setTargetToFoundTarget, "markTargetForOffence: 15", launchDefenseShip, increaseAlertLevel);
"INCOMING_MISSILE" = (fireECM, increaseAlertLevel);
ENTER = ();
EXIT = ();
"ROLL_1" = ("launchShipWithRole: taranis_traffic_sysstation");
"ROLL_2" = ("launchShipWithRole: taranis_traffic_sysstation");
"ROLL_3" = ("launchShipWithRole: taranis_traffic_sysstation_nohyp");
"TARGET_FOUND" = (launchScavenger, "sendCommsMessage: Scouter launched!");
UPDATE = ("rollD: 12600", decreaseAlertLevel, scanForLoot);
};
Here's the thing - I've been dumping cargo like crazy (that is what it scans for, right?), but I haven't seen any scavengers being launched in response. Is this my bad, or some kind of wider problem? I ask because I noticed this on the Wiki, in the definition for scanForLoot:
Returns: "HOLD_FULL", "TARGET_FOUND" or "NOTHING_FOUND". If scanning ship is station or has no scoop it always return: "NOTHING_FOUND".
If scanForLoot doesn't work for stations... why is it in the default station AI?
*EDIT* One other thing - LB, I noticed that your replacement station (in AsteroidStorm) has the role "rotating-station" (in addition to "station" with a low probability). Does that do anything behind the scenes that I need to know about? I've left it off and everything *seems* to be working just fine... Well, apart from the scavenging!
Posted: Wed Mar 12, 2008 4:10 pm
by Svengali
Roberto wrote:If scanForLoot doesn't work for stations... why is it in the default station AI?
It is working. You can see it clearly that scavengers were launched if there is something to collect. Has your station scavengers? Shipdata.plist:
Code: Select all
<key>max_scavengers</key>
<integer>10</integer>
But I don't understand your
Code: Select all
UPDATE = ("rollD: 12600", decreaseAlertLevel, scanForLoot);
What should the 12600? Your are just handling 3 different things, so maybe you should use 3 instead of 12600. So in 12597 cases nothing will happen. And it could be useful to add a pauseAI.
EDIT: You don't want to handle every rollD, right?
Posted: Wed Mar 12, 2008 5:49 pm
by Roberto
Ah! It does work after all. I think when I tested it before there must have been too many other things going on. A very strange entry on the Wiki, then!
@Svengali
The idea is to launch ships at random intervals (though I think you've already guessed this). A long wait instead would cause launches to be boringly predictable (and "freeze" the station, making it incapable of responding to attacks etc).
Posted: Wed Mar 12, 2008 8:09 pm
by Eric Walch
Roberto wrote:Ah! It does work after all. I think when I tested it before there must have been too many other things going on. A very strange entry on the Wiki, then!
I am probably to blame for that entry. I just looked better I the code. There is a special check for stations in the
scanForLoot, but it also checks the station speed. Meaning it returns only nothing found if the station is moving. like carriers with a station definition inside (Added the word "moving" in the wiki entry now).
rotating-station is an old way to do this and can be left out. It is replaced by a key.
Rotating = YES
Posted: Wed Mar 12, 2008 9:07 pm
by Svengali
Roberto wrote:The idea is to launch ships at random intervals (though I think you've already guessed this). A long wait instead would cause launches to be boringly predictable (and "freeze" the station, making it incapable of responding to attacks etc).
Yes, I'm using something similiar in my harkovtransportAI, but I thought the ATTACKED-Message is a high-priority message and causes a immediate reaction.
Posted: Wed Mar 12, 2008 9:18 pm
by Roberto
Ah - I understand now. Thanks Eric.
I'm almost done on the AI/ship side of things - I just need to modify planetinfo.plist so the frigate doesn't always appear in the same place. Here's what I'm about to test (this is under script_actions):
Code: Select all
<string>checkForShips: taranis_frigate</string>
<dict>
<key>conditions</key>
<array>
<string>shipsFound_number lessthan 1</string>
</array>
<key>do</key>
<array>
<key>conditions</key>
<array>
<string>pseudoFixedD100_number lessthan 50</string>
</array>
<key>do</key>
<array>
<string>addShipsAtPrecisely: taranis_frigate 1 pwm 145000 -29000 60500</string>
</array>
<key>conditions</key>
<array>
<string>pseudoFixedD100_number greaterthan 49</string>
</array>
<key>do</key>
<array>
<string>addShipsAtPrecisely: taranis_frigate 1 pwm 250024.81 25.77 -102991.52</string>
</array>
</array>
</dict>
Have I got the "nesting" right, and am I right in thinking that pseudoFixedD100_number, once "invoked" for the first time, remains the same for as long as you're in the system - and that if you return to the same system later, it (probably) won't give the same result?
@Svengali
You might be right on ATTACKED actually - I bet Eric knows