Hi and thank you, Cody! Whoo, cookies - luxury goods!
*grabs cookie* Thanks.
Ok, the Fool is already following me.
The priorities in the priorityAI script work in the order of first appearance.
So if you put the "follow me" at first, he will stick to you to the death like a Tibecean dog, even if you are the attacker.
But for now I want him to be a coward, fleeing combat on first shot. Thus my
foolAI.js (in AIs)
Code: Select all
this.aiStarted = function() {
var ai = new worldScripts["oolite-libPriorityAI"].PriorityAIController(this.ship);
var priorities = [
{
condition: ai.conditionLosingCombat,
behaviour: ai.behaviourFleeCombat,
reconsider: 5
},
{
condition: ai.conditionInCombat,
configuration: ai.configurationAcquireCombatTarget,
behaviour: ai.behaviourFleeCombat,
reconsider: 5
},
{
condition: ai.conditionPlayerNearby,
configuration: ai.configurationAcquirePlayerAsTarget,
behaviour: ai.behaviourFollowCurrentTarget,
reconsider: 10
},
{
configuration: ai.configurationSetDestinationToWitchpoint,
behaviour: ai.behaviourApproachDestination,
reconsider: 10
}
];
ai.setPriorities(priorities);
}
So this works fine already. Simple enough.
shipdata.plist (in Config)
Code: Select all
{
"Fool" =
{
like_ship = "adder"; // this ship is a 'modified' adder
ai_type = "foolAI.js"; // the AI file in the AI folder
autoAI = no; // take no other AI than this
cargo_type = "CARGO_NOT_CARGO";
forward_weapon_type = "WEAPON_BEAM_LASER";
aft_weapon_type = "WEAPON_PULSE_LASER";
auto_weapons = yes;
has_escape_pod = 0;
has_fuel_injection = 0;
has_scoop = 0;
has_shield_booster = 1;
has_shield_enhancer = 1;
laser_color = "128 64 128";
likely_cargo = 1;
missiles = 1;
name = "Adder Lovelace";
roles = "Fool";
script = "fool-actions.js"; // ?
};
}
No problems here. The adder flies around, then follows, shoots in self-defense or spends a rocket and finally flees.
fool-actions.js (in Scripts, should be called by the shipdata.plist, not as ai_type but as script)
Code: Select all
"use strict";
this.name = "Fool_Actions";
this.author = "Marten";
this.copyright = "© 2017 Marten";
this.description = "Fool's ship script";
this.version = "1.0";
// find player and greet him
this.scanForNearestShipHavingRole: player = function ()
{
// this.ship.target = player.ship;
this.ship.setTargetToFoundTarget;
this.ship.commsMessage(expandDescription("[FOOL_FIRST_MESSAGE]"),[TARGET_FOUND]);
// this.ship.commsMessage(expandDescription("[FOOL_FIRST_MESSAGE]"),player.ship);
// this.ship.sendTagetCommsMessage(expandDescription("[FOOL_FIRST_MESSAGE]"));
player.consoleMessage("Adder should have said something now." ,1);
}
// say something when hurt
this.shipBeingAttacked = function(whom)
{
if(whom.isPlayer)
{
// this.ship.commsMessage(expandDescription("[FOOL_ATTACKED_BY_PLAYER_MESSAGE]"),player.ship);
this.ship.sendTargetCommsMessage(expandDescription("[FOOL_ATTACKED_BY_PLAYER_MESSAGE]"));
}
else
{
// this.ship.commsMessage(expandDescription("[FOOL_ATTACKED_MESSAGE]"),player.ship);
this.ship.sendTargetCommsMessage(expandDescription("[FOOL_ATTACKED_BY_PLAYER_MESSAGE]"));
}
}
// die and say goodbye
this.shipDied = function(whom,why)
{
if(whom.isPlayer)
{
this.ship.commsMessage(expandDescription("[FOOL_KILLED_BY_PLAYER_MESSAGE]"),player.ship);
}
else
{
this.ship.commsMessage(expandDescription("[FOOL_KILLED_MESSAGE]"),player.ship);
}
}
Problem here!
This seems to get totally ignored, no matter which method I try to use, though I think I read a death message from it twice.
But could it have been a standard message? Because the adder will occassionally send a common distress call when attacked.
Also there is no consoleMessage.
descriptions.plist (in Config)
Code: Select all
// fool's talk
{
"FOOL_FIXED_DESC" = "Student of Lave Academy";
"FOOL_FIRST_MESSAGE" = ("Hi there.","Isn't space huge?","Hey, what about some company?","Hi, let's travel together.","Finally company, how nice!", "Hi, can I join you?", "Hey friend. Let's team up! Good idea, right?");
"FOOL_ATTACKED_MESSAGE" = ("Help me, [commander_name], I'm under attack!","I'm under attack!","Aaahhhh, I'm hit!","Ouch!","What's happening here?");
"FOOL_ATTACKED_BY_PLAYER_MESSAGE" = ("Hey, please don't do that!","Hey, friend! I spilled my coffee!","Hey, you're firing at me, pal!","Hey, watch your weapons, dude!","Buddy, you hit me! Stop it, please!");
"FOOL_KILLED_MESSAGE" = ("[commander_name], farewell!","Revenge me, [commander_name]!","Why did this happen?","[commander_name], they killed me!","Noooo...!");
"FOOL_KILLED_BY_PLAYER_MESSAGE" = ("[commander_name], you killed me!","I'm sure, it was a mistake, [commander_name]!","Why did you do this, [commander_name]?","[commander_name], you accidently killed me!","[commander_name], nooo...!");
}