When you are on a mac you could try to get the plist editor that shipped with Tiger. That one placed the ending comma in a way that it works on all platforms. Even Tiger refuses to open the open-step plist files saved with the newer plist editor that ships with Leopard. When you only want to use the code yourself, you can use the new one and its better features but when you want to share the saved plists with others, better try getting the old one or maybe switch to plistEditPro. When you save in XML format, there is no problem with the newer mac plistEdit between platforms.
On the "checkEnergy"; it is future code. Maybe I should have written it even more clear that it is future code, or only add it after 1.74 becomes a release. But my experience it that when you don't add the the documentation immediately in the wiki after adding it to the code, it tends to get forgotten to add it at all.
In your case you don't need it at all because oolite itself is already sending a "ENERGY_LOW" message every time you ships gets a hit under low energy conditions.
I added this new command in Oolite to improve future pirateAI. In the next Oolite version, pirates that have fled into space will return to their original position in the spacelane after their energy has recovered. In current Oolite, a pirate can flee for a missile while undamaged himself. So there currently is no guarantee that he always receives a "ENERGY_FULL" message after fleeing. Therefor I added the "checkEnergy" command to query the energy state. For an "ENERGY_LOW" while under attack you don't need it, Oolite already sends it on every hit.
AI Scripting for mine/turret
Moderators: winston, another_commander
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
I’ve filed a bug with Apple about the comma issue. Either I’ll be told I should be using XML or the bug will be marked as a duplicate, but I tried. :-)
E-mail: [email protected]
I looked at you'r OXPs and came up with this:Thargoid wrote:see my hired guns or drones OXPs for examples
Code: Select all
this.checkTargetDistance = function()
{
this.targetDistance = this.ship.position.distanceTo(player.ship.position);
if(this.targetDistance > 6000) // check distance from mine to target
{
this.ship.AIState = "TARGET_RANGE_HIGH";
}
else
{
this.ship.AIState = "TARGET_RANGE_LOW";
}
}
this.shipDestroyedTarget = function(target)
{
player.score += 1; // accredit kills & bounty to player
player.credits += target.bounty;
log("Krypton Mine Kill - " + target.name + " : " + target.bounty);
}
I think (player.ship.position) should be something like this (target.ship.position).
I searched for target position on the wiki but didn't find anything suitable.
McSpider
You'll want this.ship.target.position . But it would also there be worth checking that the mine actually has a target (or else you'll generate errors). Something like:
if(!this.ship.target) {return;}
That will exit the function if the mine doesn't have a target. You get the idea, you can have it do other things too (the ! means not in JS - basically the above says "if this ship does not have a target, perform "return;" (return; means stop processing this function at this point).
If you want a reference for that, check target autolock OXP
if(!this.ship.target) {return;}
That will exit the function if the mine doesn't have a target. You get the idea, you can have it do other things too (the ! means not in JS - basically the above says "if this ship does not have a target, perform "return;" (return; means stop processing this function at this point).
If you want a reference for that, check target autolock OXP
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
Thanks for the Quick reply.
Now my code looks like this:
And it works perfectly.
My Ai now shoots missiles in 8 sec intervals (till it runs out) if target is out of range of the plasma accelerator.
EDIT: spelling & grammar fixed
Now my code looks like this:
Code: Select all
this.checkTargetDistance = function()
{
if(!this.ship.target) {return;}
this.playerDistance = this.ship.position.distanceTo(this.ship.target.position);
if(this.playerDistance > 5000) // check target distance
{
this.ship.AIState = "TARGET_RANGE_HIGH";
}
else
{
this.ship.AIState = "TARGET_RANGE_LOW";
}
}
this.shipDestroyedTarget = function(target)
{
player.score += 1;
player.credits += target.bounty;
log("Krypton Mine Kill - " + target.name + " : " + target.bounty);
}
My Ai now shoots missiles in 8 sec intervals (till it runs out) if target is out of range of the plasma accelerator.
EDIT: spelling & grammar fixed
Last edited by McSpider on Mon Nov 09, 2009 12:14 am, edited 2 times in total.
McSpider
The only other comment I would add is you may want to change this.playerDistance to something more appropriate now (this.targetDistance perhaps?).
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link