Personalities.oxp

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Alnivel
Dangerous
Dangerous
Posts: 100
Joined: Fri Jun 10, 2022 7:05 pm

Re: Personalities.oxp

Post by Alnivel »

I got a bit carried away with the modification, so it's a bit more than "polishing" now, but anyway.

Changes:
  • requires Oolite 1.9 now
  • fixed several broken function calls
  • changed names of internal variables and resources to avoid conflicts
  • сhange in setting comms messages, it now requires a description.plist entry to be defined in format:
    "personalities-<personality name>-messageTypes" = "<list of space separated message types>";
  • added method for adding role to apppear on specified condition, such as system id, after some event etc. Usage example:

    Code: Select all

    worldScripts.personalities._addConditionalAppearance("personalities_daddyhoggy",
        function weight() {
    	    return galaxyNumber == 0 && system.ID == 147 ? 100 : 0;
        },		
        function position(type) {
    	    if(type === "LAUNCH")
    		    return undefined; // Use standart rules: spawn near station in space or via launching
    	    if(type === "EXIT_WITCHSPACE")
    		    return Math.random() < 0.5? new Vector3D() : undefined; // in half cases spawn near witchpoint
        });
    

Download

There is still a lot of work to be done here. For example, AI sometimes freezes for a couple of seconds after attacking it, sometimes it cannot decide whether it attacks the player or not. If I ever get around to changing the AI, and most likely I will try to rewrite it again, in plist form it scares me. It would also be nice to improve the talkativeness of the NPCs, from time to time they just say the same phrase - Disembodied once gave me the line "I hope you're insured!" three times in a row in one fight.

However, the main problem, of course, is too few personalities. You can send your personalities to me and I will be glad to try to implement them.
Also I will try not to forget to post instructions later on how to add new personalities on your own.

Edit: Posting in the middle of the night is not a good idea - before packing OXP I decided to disable the shiplibrary.plist file, but disabled shipdata.plist instead. The link now points to the corrected file.
Alnivel
Dangerous
Dangerous
Posts: 100
Joined: Fri Jun 10, 2022 7:05 pm

Re: Personalities.oxp

Post by Alnivel »

How to add personality

You need to do a couple of things:
  1. Make an entry about your ship in shipdata.plist. Among all parameters of the ship (you can take them as a basis from the game files or OXP where the ship is from), special attention should be paid to:
    • name - "shipname: charactername" goes here
    • ai_type - "personalitiesCruiserAI.plist" OR "personalitiesHunterAI.plist" OR "personalitiesPrivateerAI.plist" .
      You can also put your own AI script, but then OXP will only decide when to add your personality, and you have to implement everything else yourself.
    • script - If you use one of the suggested AI types, you need to use "personalities-ship-script.js" here
    • roles - you can read about it here
    • script_info - you can read about it (and also about standart AI types) here
    • pilot - if you use escape pod here you need to specify an entry from characters.plist
  2. Make sure that models, textures and shaders used be ship will be available not only for you. I think in most cases this will be to copy them to the appropriate folder of OXP and give them new names, including all references to them in the shipdata and models files.
  3. Add communication messages into desciption.plist.
    • there must be a record of what types of messages are used, "cholmondely" here - "name" from script_info :
      "personalities-cholmondely-messageTypes" = "attack attacked captured chatter dead flee jump kill launch witchspace";
    • and the messages themselves:
      "personalities-cholmondely-attack" = ("<Phrase to be sent when attacked>");
      "personalities-cholmondely-attacked" = ("<Either this phrase will be sent..>", "<or this one when ship attacked>");

If you have any questions, don't hesitate to ask, I'll be glad to help. Also I would like to hear if you have any ideas what else would be nice to add to the functionality of OXP.

And finally, the question: would someone want to limit the appearance of their personality to a single galaxy, or maybe only a certain set of systems?
Right now the "personalities" and "personalities_launcher" roles are used to choose personality to appear, but they are also used in the AI. If anyone is interested in the functionality above, I can change it so that the roles "personalities-galaxy-n" and "personalities_launcher-galaxy-n"(or something similar) will be used to determine if should personality appear in the galaxy sector, but then for those who can appear in any galaxy will have to add 8 or even 16 roles.
Alnivel
Dangerous
Dangerous
Posts: 100
Joined: Fri Jun 10, 2022 7:05 pm

Re: Personalities.oxp

Post by Alnivel »

Version 0.9.2

Changes:
  • new AI scripts, most personalities now use them
  • with new scripts standard communications keys can be used (however, it makes sense to use only those that are used by AI), old comms keys still works
  • fixed a bug in plistAI scripts that caused the ships themselves to never attack
  • pauses can be added to comms messages: "The message will be split{pause: 12}and the second half will be sent with specified delay"
  • appearance can be limited through the list of roles:
    1. "personalities personalities_privateer personalities_galaxy_any personalities_launcher_galaxy_any personalities_aodhan" -
      pirate by name "Aodhan" that can appear in any galaxy both in space and via launch from main station
    2. "personalities personalities_cruiser personalities_galaxy_0 ppersonalities_galaxy_1 personalities_galaxy_2 personalities_jameson" -
      trader by name "Jameson" that can appear only in Galaxy One, Two and Three and only in space
  • added methods for setting callbacks at escape pod scooping and unloading
  • added method to adjust spawn weight (for galaxies) in case if someone suddenly decides to use 100 ship variants with a weight of (0.01) each
Download link

I do not plan to add any new features more for now, but you can always suggest them.
The wiki page has also been updated - added more detailed instructions for adding your personality.
User avatar
Cholmondely
Archivist
Archivist
Posts: 5365
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Personalities.oxp

Post by Cholmondely »

Alnivel wrote: Sun Oct 23, 2022 10:23 am
Version 0.9.2
Impressive Sir! I'll be interested in seeing your representation in my game....
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
Cholmondely
Archivist
Archivist
Posts: 5365
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Personalities.oxp

Post by Cholmondely »

Alnivel wrote: Sun Oct 23, 2022 10:23 am
Version 0.9.2
Apologies, I've been flubbing the dub. Attempts to create my F-d-L failed dismally, and I just can't get my head around how to alter the AI. Plus, whenever I try anything in Javascript, it always goes pear-shaped... (my piddling about with .plists is only marginally more successful!). I've not even been able to work out to do more with phkb's new tweaks to Broadcast Comms (and that one, again, gets the imaginative juices flowing).

Extended Whine:
I suppose, trying to put it all into some sort of context, that I find Javascript a bit too much like black magic. I don't understand the formulae, and can never work out why things go wrong - which they always do. Hence, any enthusiasm to improve my knowledge is always met by a blast of icy water.

With the .plists, my trusty AppleMac Terminal's "plutil_" tells me if the script will work - and often directs me to the line which has the mistake. It's not perfect - I've been unable to get the Naval Carriers tucked away inside the Behemoth to appear in the Ship's Library, and am still failing dismally with the various ice-asteroids (despite your help), but I've gotten everything else to appear (50 items to date, all done by your nibs, pretty much on his tod!).

Edited to add:
Cholmondely wrote: Tue Oct 18, 2022 6:44 pm
Examples:
(Cast: Cholmondely, Araminta (fiancee), Benedict (butler))
◦ 
"personalities-cholmondely-attack" = ("<You perfidious philistine, prepare to plumb the depths of the Pool of Pellucid Placidity!>");

◦ "personalities-cholmondely-attacked" = ("<What-ho you earwig! Araminta will have your eyeballs for earrings!..>",
"<Benedict! Blast that blighter over there! He’s taking pot-shots at us!!>");
◦ "personalities-cholmondely-chatter" = ("<I say, old boy, do you happen to have any Lapsang Souchong tea by any chance?>",
"<What-ho! Nice day for a spot of Real Tennis, what?>" ,
"<Oh my giddy aunt! What the dickens are you up to?>");
◦ "personalities-cholmondely-dead" = ("<Keep that upper lip stiff, what!>");
◦ "personalities-cholmondely-flee" = ("<I say, Benedict, won’t this old crate go any faster, what?>”);
◦ "personalities-cholmondely-jump" = ("<Benedict, what does this button really do?>");
◦ "personalities-cholmondely-kill" = ("<Take that, you ghastly gertrude, you!>",
"<Heh-heh! That’s another blighter who won’t be having tea-cakes for his high tea!>”);
◦ "personalities-cholmondely-launch" = ("<I say, Benedict, should I really have pushed that button? [pause] Oh, look! Stars!! Why, Araminta, come and sneak a peek at this! And just look at all these people in their little tin-cans! What ever can they all be up to?>”);
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2687
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: Personalities.oxp

Post by Redspear »

Cholmondely wrote: Mon Nov 07, 2022 2:09 pm
Edited to add:
Is there one for missile lauched?
Benedict, old stick! Load up the next one would you? There's a good chap.
User avatar
Cholmondely
Archivist
Archivist
Posts: 5365
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Personalities.oxp

Post by Cholmondely »

Redspear wrote: Sun Jan 21, 2024 12:49 pm
Benedict, old stick! Load up the next one would you? There's a good chap.
Fair dibs!





But what about YOU, Redspear?

What sort of behaviour should we expect from your ship if we ran across it in-game?
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
Redspear
---- E L I T E ----
---- E L I T E ----
Posts: 2687
Joined: Thu Jun 20, 2013 10:22 pm
Location: On the moon Thought, orbiting the planet Ignorance.

Re: Personalities.oxp

Post by Redspear »

Cholmondely wrote: Sun Jan 21, 2024 2:55 pm
But what about YOU, Redspear?
Me? I don't have a personality ;-)

Cholmondely wrote: Sun Jan 21, 2024 2:55 pm
What sort of behaviour should we expect from your ship if we ran across it in-game?
It'd probably be lots of questionable mini-critiques e.g.
  • Killed, "You see, that's why the player should have access to the energy bomb."
    Sun-skimming, "This star could be much larger with a bit of system rearrangement."
    Launch, "What is this supposed to be? A moon."
    Chatter, "Masslocked again..."
    Flee, "They haven't got injectors have they?... They really shouldn't have injectors."
    Jump, "So for a ship this size with a grade of X and a tech level of Y, we should expect a jump distance of..."
If anyone wants that in their game then good luck to them.

As for a ship, the obvious one might be the lightspeeder but I'd have to think about that, especially as I've only tested it and never owned it... The neolite salamander and mussurana are others that I've long admired but never flown. But then there's Griff's Griffin, likewise his Bug and even Dertien's Tiger...
User avatar
Cholmondely
Archivist
Archivist
Posts: 5365
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Personalities.oxp

Post by Cholmondely »

Running the original version on Oolite v.1.77.1 on my AppleMac

The latest.log reads

Code: Select all

13:39:50.245 [script.javaScript.exception.notFunction] ReportJSError (OOJavaScriptEngine.m:198): ***** JavaScript exception (personalities 0.9): TypeError: system.systemNameForID is not a function
13:39:50.245 [script.javaScript.exception.notFunction] ReportJSError (OOJavaScriptEngine.m:209):       /Users/accountname/Library/Application Support/Oolite/AddOns/Personalities.oxp/Scripts/personalities.js, line 41.
line 41 reads as follows:

Code: Select all

this.startUp = this.reset = function()
{
	missionVariables.personalities_commander_name = expandDescription("[commander_name]");
	missionVariables.personalities_systemname = system.systemNameForID(Math.floor(Math.random() * 256));    <--   Line 41
}
The entire js file reads

Code: Select all

/*

personalities.js

Script to make special personalities appear in the Ooniverse.


Oolite
Copyright © 2004-2009 Giles C Williams and contributors

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.

*/


this.name			= "personalities";
this.author			= "Commander McLane";
this.copyright		= "� 2009 Commander McLane";
this.description	= "Script for spawning of special personalities";
this.version		= "0.9";


this.logging = false;

this.startUp = this.reset = function()
{
	missionVariables.personalities_commander_name = expandDescription("[commander_name]");
	missionVariables.personalities_systemname = system.systemNameForID(Math.floor(Math.random() * 256));
}

this.spawnPersonality = function()
{
	system.legacy_addShips("personalities", 1);
	delete this.waitUntilSpawn;
}

this.shipWillExitWitchspace = function()
{
	if(system.isInterstellarSpace) return;
	missionVariables.personalities_systemname = system.systemNameForID(Math.floor(Math.random() * 256));
	if(system.countShipsWithRole("personalities") > 0) return;
	if(galaxyNumber == 0 && system.ID == 147 && Math.random() < 0.5)
	{
		system.legacy_addShipsWithinRadius("personalities_daddyhoggy", 1, "wpu", [0, 0, ((Math.random() * 0.6) + 0.2)], 20000);
		return;
	}
	this.personalitiesAppearance = Math.random();
	if(this.personalitiesAppearance < 0.25)
	{
		this.waitUntilSpawn = new Timer(this, this.spawnPersonality, ((Math.random() * 7) + 5));
	}
	else if(this.personalitiesAppearance < 0.4)
	{
		system.legacy_addShips("personalities", 1);
	}
	else if(this.personalitiesAppearance < 0.65)
	{
		system.legacy_addShipsWithinRadius("personalities", 1, "wpu", [0, 0, ((Math.random() * 0.6) + 0.2)], 20000);
	}
}

this.shipWillLaunchFromStation = function(station)
{
	if(!station.isMainStation || system.countShipsWithRole("personalities") > 0) return;
	if(galaxyNumber == 0 && system.ID == 147)
	{
		this.personalitiesAppearance = Math.random();
		if(this.personalitiesAppearance < 0.3)
		{
			system.legacy_addSystemShips("personalities_daddyhoggy", 1, 1);
		}
		else if(this.personalitiesAppearance < 0.5)
		{
			system.legacy_addSystemShips("personalities_dh_launch_helper", 1, 1);
		}
		return;
	}
	this.personalitiesAppearance = Math.random();
	if(this.personalitiesAppearance < 0.25)
	{
		system.legacy_addSystemShips("personalities_launch_helper", 1, 1);
	}
	else if(this.personalitiesAppearance < 0.5)
	{
		system.legacy_addSystemShips("personalities", 1, 1);
	}
	else if(this.personalitiesAppearance < 0.65)
	{
		system.legacy_addShipsWithinRadius("personalities", 1, "wpu", [0, 0, ((Math.random() * 0.6) + 0.2)], 20000);
	}
}

this.shipWillDockWithStation = function()
{
	if(this.hesperusCaptured)
	{
		player.addMessageToArrivalReport(expandDescription("[personalities-hesperus-captured]"));
		player.credits += 132;
		delete this.hesperusCaptured;
	}
}

this.shipBeingAttacked = function(whom)
{
	if(!whom) return;
	if(whom.hasRole("personalities"))
	{
		whom.script.hitcounter--;
		if(whom.script.hitcounter < 1)
		{
			whom.script.broadcastMessage("hitting");
			whom.script.hitcounter = Math.ceil(Math.random() * 10) + 10;
		}
	}
}

this.shipDestroyedTarget = function(target)
{
	if(target.hasRole("personalities") && !missionVariables.personalities_killed_name)
	{
		if(target.hasRole("personalities_privateer") && Math.random() < 0.5) return;
		missionVariables.personalities_killed_name = target.scriptInfo.displayName;
	}
}

this.alertConditionChanged = function(newCondition, oldCondition)
{
	if(newCondition == 3 && oldCondition != 3)
	{
		system.shipsWithRole("personalities", player.ship, 25600).forEach(function(ship){ship.script.alertConditionChanged(newCondition, oldCondition)});
	}
}
The wiki currently says this:

Static Methods
infoForSystem
...

systemIDForName
...

systemNameForID
function systemNameForID(systemID : Integer) : String
Returns the name of a system in the current galaxy based on the given ID number.

And back in 2009 it said exactly the same about "systemNameForID".


Can anybody help?
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: Personalities.oxp

Post by another_commander »

It's System.systemNameForID(systenID). Note the capital S at the start.
User avatar
Cholmondely
Archivist
Archivist
Posts: 5365
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Personalities.oxp

Post by Cholmondely »

another_commander wrote: Mon Oct 07, 2024 1:07 pm
It's System.systemNameForID(systenID). Note the capital S at the start.
Thanking thee! Your advice seems to have knocked the issue over the head!
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
Cholmondely
Archivist
Archivist
Posts: 5365
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: Personalities.oxp

Post by Cholmondely »

Had a most exhilarating encounter (in Oolite v.1.77.1) thanks to this oxp.

Mooching about in the vicinity of Onrira (SW G1), and launched from the orbital station to witness a bun-fight going on!

Captain Hesperus was being chased by a posse of Vipers, running hither and yon, crying out for help. They eventually potshotted him leaving a cluster of cargo canisters (I did not touch them, his reputation as a trumble salesman being a tad off-putting!).

Image
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
Post Reply