Re: Scripters cove
Posted: Tue Aug 29, 2023 11:19 pm
Thanks for the code, seems the best option.
For information and discussion about Oolite.
https://bb.oolite.space/
Excuse me for intervening without being asked, but I think I should warn that using bitwise AND (&) to prevent out-of-bounds is a bad idea: unless the value on the right of the operator is a power of two minus one (7, 255, etc), some values will be never used, like in this case, 1&14 === 0 and it even worse for something like 33 - only 4 values can be accessed from 34 total.LittleBear wrote: ↑Tue Aug 29, 2023 9:32 pmYou can select a specific position number from an array in script if you want to. But this would mean C&Ping the names from descriptions into script in array format:You can then summon a particular position in the array by its number (but Oolite starts counting from 0) with:Code: Select all
this.feudalfirstnamegermanhe = ["Bruno","Dieter","Eric","Franz","Gustav","Heinrich","Johan","Lothar","Otto","Reinhard","Thorsten","Ulrich","Walter","Wilhelm","Wolfgang"];
Var name will now be the name in the array at position 0 out of 15 positions (the number for total number above is one less than the actual number as position 1 is 0 and so on).Code: Select all
var position = 0; var name = feudalfirstnamegermanhe[position &14];
Code: Select all
var name = feudalfirstnamegermanhe[position % 15];
Is that not working?alertCondition : Number (read-only integer)
The ship's current alert condition (Docked = 0, Green = 1, Yellow = 2, Red = 3). Non-Station non-Player ships are generally only found at condition Yellow or Red.
Code: Select all
// ship script event handler triggered when a new AI is loaded
this.aiStarted = function() {
// create a new AI controller and assign it this ship
var ai = new worldScripts["oolite-libPriorityAI"].PriorityAIController(this.ship);
// set up the priority list
var priorities = [
{
condition: ai.conditionLosingCombat,
behaviour: ai.behaviourFleeCombat,
reconsider: 20
},
{
condition: ai.conditionInCombat,
configuration: ai.configurationAcquireCombatTarget,
behaviour: ai.behaviourDestroyCurrentTarget,
reconsider: 5
},
{
condition: ai.conditionPlayerNearby,
configuration: ai.configurationAcquirePlayerAsTarget,
behaviour: ai.behaviourDestroyCurrentTarget,
reconsider: 5
},
{
configuration: ai.configurationSetDestinationToWitchpoint,
behaviour: ai.behaviourApproachDestination,
reconsider: 20
}
];
// apply the priority list to the AI
ai.setPriorities(priorities);
}
Tried again, and all works well using cloaking when fighting pirates but, alas not when fighting my test ship.
Code: Select all
21:44:06.822 [Prinz-Class Zerstoerer (Digebiti)]: Considering branch with 4 entries
21:44:06.822 [Prinz-Class Zerstoerer (Digebiti)]: Considering: entry 0
21:44:06.822 [Prinz-Class Zerstoerer (Digebiti)]: Considering: entry 1
21:44:06.822 [Prinz-Class Zerstoerer (Digebiti)]: Considering: entry 2
21:44:06.822 [Prinz-Class Zerstoerer (Digebiti)]: Considering: entry 3
21:44:06.822 [Prinz-Class Zerstoerer (Digebiti)]: Conditions met
21:44:06.822 [Prinz-Class Zerstoerer (Digebiti)]: Executing behaviour
21:44:26.839 [Prinz-Class Zerstoerer (Digebiti)]: Considering branch with 4 entries
21:44:26.839 [Prinz-Class Zerstoerer (Digebiti)]: Considering: entry 0
21:44:26.839 [Prinz-Class Zerstoerer (Digebiti)]: Considering: entry 1
21:44:26.839 [Prinz-Class Zerstoerer (Digebiti)]: Considering: entry 2
21:44:26.839 [Prinz-Class Zerstoerer (Digebiti)]: Considering: entry 3
21:44:26.839 [Prinz-Class Zerstoerer (Digebiti)]: Conditions met
21:44:26.839 [Prinz-Class Zerstoerer (Digebiti)]: Executing behaviour
21:44:46.842 [Prinz-Class Zerstoerer (Digebiti)]: Considering branch with 4 entries
21:44:46.842 [Prinz-Class Zerstoerer (Digebiti)]: Considering: entry 0
21:44:46.842 [Prinz-Class Zerstoerer (Digebiti)]: Considering: entry 1
21:44:46.842 [Prinz-Class Zerstoerer (Digebiti)]: Considering: entry 2
21:44:46.842 [Prinz-Class Zerstoerer (Digebiti)]: Conditions met
21:44:46.842 [Prinz-Class Zerstoerer (Digebiti)]: Executing behaviour
21:44:47.622 [Prinz-Class Zerstoerer (Digebiti)]: Considering branch with 4 entries
21:44:47.622 [Prinz-Class Zerstoerer (Digebiti)]: Considering: entry 0
21:44:47.622 [Prinz-Class Zerstoerer (Digebiti)]: Considering: entry 1
21:44:47.622 [Prinz-Class Zerstoerer (Digebiti)]: Conditions met
21:44:47.622 [Prinz-Class Zerstoerer (Digebiti)]: Executing behaviour
21:45:22.034 [exit.context]: Exiting: Shift-escape pressed.
21:45:22.041 [gameController.exitApp]: .GNUstepDefaults synchronized.
Have you checked if your AI script is being switched to something else after de-cloaking or starting a fight? Either by the ship's or world script.DGill wrote: ↑Tue Oct 24, 2023 9:04 pmTried again, and all works well using cloaking when fighting pirates but, alas not when fighting my test ship.
The oolite_flag_behaviourLogging gives:
. . .
which does not tell me much other than initially it selects entry 3 which I believe is head to witch point.
It then selects entry 2, probably on meeting me, which is acquirePlayerAsTarget
then entry 1, DestroyCurrentTarget
When I'm fired upon I cloak and then de-cloak at which point no more entries and I shoot at and destroy the ship .
I have checked which is why I was initially wondering whether there was a command to switch it back. But I'll have to do a more thorough search particularly, as you say, in other world-scripts.
You should be able to see what AI script is active by checking the
AIScript
property of the ship. You might also want to check autoAI
of the ship and see whether it's true or false.Code: Select all
this.shipWillDockWithStation = function (station)
{
if (system.techLevel == 0 && player.ship.dockedStation.hasRole ("coriolis") || player.ship.dockedStation.hasRole ("dodecahedron") || player.ship.dockedStation.hasRole ("icosahedron") || player.ship.dockedStation.hasRole ("sfep_station"))
{
player.addMessageToArrivalReport = (expandDescription("[dockmessage_0]"));
}
else
if (system.techLevel == 1 && player.ship.dockedStation.hasRole ("coriolis") || player.ship.dockedStation.hasRole ("dodecahedron") || player.ship.dockedStation.hasRole ("icosahedron") || player.ship.dockedStation.hasRole ("sfep_station"))
{
player.addMessageToArrivalReport = (expandDescription("[dockmessage_1]"));
}
// This continues on for all 14 Tech Levels. Individual Station Roles come into play next.
}
else
if (player.ship.dockedStation.hasRole ("rockhermit") || player.ship.dockedStation.hasRole ("rockhermit-chaotic") || player.ship.dockedStation.hasRole ("rockhermit-pirate"))
{
player.addMessageToArrivalReport = (expandDescription("[dockmessage_rock]"));
}
else
if (player.ship.dockedStation.hasRole ("constore"))
{
player.addMessageToArrivalReport = (expandDescription("[dockmessage_store]"));
}
//Etc. and so on.
}
Code: Select all
{
"dockmessage_0" =
(
"The Docking Bay is sticky with a rather pungent odor. The platform appears unattended. Local gangs of toughs mutter darkly from the overlook. A few Trumbles skitter away from the light and vanish into an air duct.",
"The Landing Berth is scrawled with crude graffiti and littered with trash. It takes some effort not to step on anything.",
"The Landing Pad creaks ominously. One of the Docking Bay lights flickers and then goes dark. Eyes seem to watch from everywhere.",
"The Docking Bay lights flicker unsteadily. Disembarking onto the creaking metal floor is an uneasy process. Hope springs eternal that the station holds together while business is conducted."
);
//============================================================================================================================
"dockmessage_1" =
(
"The place stinks, literally stinks, as if someone had deliberately painted the place with a vat of crushed sulfurous tree slugs. It is best to tread lightly in such places and to remember not to breath in too deeply. Get this over with quickly and get out.",
"The deserted Docking Bay is scrawled with rude graffiti. The walkway is sticky and noisome. What exactly is causing the stickiness is best left unknown. New shoes may be in order at a more well provisioned station.",
"A gang of locals are betting on a fight between a hauler bot and a giant %I [26] [30]. The raucous shouts quickly descend into some sort of turf war. Getting out of the way quickly provides some relief.",
"The Landing Berth lights are dim and flicker continuously. Someone is hiding in the corners of the bay's shadows. Quickly moving on is the best option. "
);
// This continues on as well.
}
Code: Select all
if (system.techLevel == 0 && player.ship.dockedStation.hasRole ("coriolis") || player.ship.dockedStation.hasRole ("dodecahedron") || player.ship.dockedStation.hasRole ("icosahedron") || player.ship.dockedStation.hasRole ("sfep_station"))
Code: Select all
if (system.techLevel == 0 && (station.hasRole ("coriolis") || station.hasRole ("dodecahedron") || station.hasRole ("icosahedron") || station.hasRole ("sfep_station")))
if (system.techLevel == ...