Page 96 of 99

Re: Scripters cove

Posted: Tue Aug 21, 2018 5:59 am
by another_commander
UK_Eliter wrote:
Tue Aug 21, 2018 12:31 am
I am also looking at the Javascript function addCollisionException, but I am confused by it. For one thing, the name seems odd. For, the documentation seems to say that one uses it to prevent ships colliding. Also, how does that prevention work? Are the ships allowed to occupy the same space, but without taking damage? I presume that rather the ships are prevented from occupying the same space. How, though? Is it that, if the ship to which one adds the exception is powered, it will be made to try to avoid the other ship?
addCollisionException disables collision detection between the object it is applied on and the target object given by the function's argument. That's it, nothing special about it, really. When collision detection is disabled, stuff goes through other stuff. Here is a screenie of a Cobra which has its collision checks with the Coriolis disabled:
Image

Re: Scripters cove

Posted: Tue Aug 21, 2018 6:26 am
by UK_Eliter
Hello a.n.

Ah, now I understand. Thanks. That routine is useless for my current purpose, but it should be good for the Hijacked Generation Ship (tm) in my Interstellar Tweaks, because ships launched from that do sometimes end up in the entrails of their mothership . .

Re: Scripters cove

Posted: Mon Oct 01, 2018 6:46 pm
by UK_Eliter
Hey guys

How does the heat shield equipment work, programmatically? If I have a script increase the player ship's temperature, will the resulting temperature of that ship differ depending on whether the ship has a heat shield or not? Thanks. (I couldn't seem to find the answer in the docs.)

Re: Scripters cove

Posted: Fri Oct 12, 2018 11:22 pm
by UK_Eliter
Also ('also' because: see my post above) I have the following problem.

I have this in a ship script:

Code: Select all

this.$_fireQuirium = function() {
	log("ExtraThargoids", "OK 123." );
	this.ship.awardEquipment("EQ_QC_MINE");
	this.ship.commsMessage("We boom your bases!");
	this.ship.fireMissile("EQ_QC_MINE");
	this.$_deleteTimers();
};

And I get this in the log:

Code: Select all

00:08:08.621 [ExtraThargoids]: OK 123.
00:08:08.959 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (Oolite Q-bomb AI 1.87): TypeError: this.explosion is undefined
00:08:08.959 [script.javaScript.exception.unexpectedType]:       Resources/AIs/oolite-qbombAI.js, line 40.
Oolite development version 1.87.0.7085-180729-89d301b (x86-64 test release) under Windows 6.3.9600.19155 64-bit.

Re: Scripters cove

Posted: Sat Oct 13, 2018 4:20 am
by montana05
Rustem had a new AI for the Q-Bomb: viewtopic.php?f=4&t=19298

Personally I use a very simple one which (most of the time) is actually working:

Code: Select all

{
	GLOBAL = 
	{
		//ENTER = ("commsMessageByUnpiloted: [CWC_explosion_01]", "pauseAI: 5.0");
		ENTER = ("pauseAI: 5.0");
		UPDATE = ("setStateTo: DETONATE"); 
   };

	DETONATE = 
	{
		ENTER = (becomeEnergyBlast);
	};
}

Re: Scripters cove

Posted: Sat Oct 13, 2018 3:32 pm
by UK_Eliter
Montana: ah, I see from that link that the Q-bomb has indeed been banned! Ha!

OK, this is working:

Code: Select all

this.$_fireQuirium = function() {
	var qbomb = ship.spawnOne("extraThargoids_qmine"); 	 // inbuilt qmine AI is buggy.
	this.ship.commsMessage("We boom your bases!");
};
with this in shipdata:

Code: Select all

	"extraThargoids_qmine" =
	{
		like_ship = "qbomb";
		ai_type = "extraThargoids_qMineAI.plist";
		roles = "energy-bomb(0) EQ_QC_MINE(0) extraThargoids_qmine";
		"script_info" = {"npc_shields" = no;};
	};
and the AI provided by Montana. Thanks!

EDITED.

Re: Scripters cove

Posted: Sun Oct 14, 2018 3:41 am
by montana05
UK_Eliter wrote:
Sat Oct 13, 2018 3:32 pm
and the AI provided by Montana. Thanks!
Glad to help, I forgot to mention that you need to create your own Q-Weapon in order to make it work but you figured it out already. :)

Re: Scripters cove

Posted: Thu Oct 18, 2018 4:49 pm
by Nite Owl
While doing some minor tweaking to the CombatMFD.oxz found a reference to the combatSLBar which allows your HUD to show a gauge that displays the service level (when the next maintenance overhaul is needed) for your ship. Got my head around how to make the actual gauge and put it into my Coluber HUD (position, size, colors, etc.) but cannot figure out how to get the hud.plist and the script.js to recognize one another and talk back and forth to actually get the gauge working and updating itself. Always wanted a status update on my ship's service level. Found it odd that Maintenance Overhauls come as a surprise when you dock given the technical sophistication of the ships in the game.

Went through the function setCustomHUDDial(key : String, value : Value) for the script.js and the drawCustomBar: - a number between 0 and 1 for the hud.plist but any combination of things tried did not work.

In the script.js is the function setCustomHUDDial(key : String, value : Value) a this., a var., an if., or just a function? The (key : String, value : Value) part made some sense with the key being a number between 0 and 1 and the string referencing combatSLBar but what are the entries for (..., value : Value)?

My other guess for the hud.plist drawCustomBar: - a number between 0 and 1 is that this entry would reference whatever number between 0 and 1 was entered for the key value in the JavaScript string. Where exactly though does this entry go in hud.plist? Understood that it must go with the other entries for the specific gauge in question but does it go left or right? Does it look like this:

Code: Select all

 drawCustomBar: = <key#>;
or like this:

Code: Select all

<?something?> = drawCustomBar: <key#>;
Surely this is an easy one for you JavaScript / .plist pros out there and specific answers to help this scripting newcomer would be greatly appreciated. Thank you for your time and effort.

Re: Scripters cove

Posted: Thu Oct 18, 2018 7:19 pm
by spara
Let's see if I can be of some assistance. First you need to define the custom dial in hud.plist. Something like this in the dials section:

Code: Select all

		{
			...
			"selector" = "drawCustomBar:";
			"data_source" = "customDialExample";
			...
		}
Then you need to define that custom dial value (the one referenced with data_source) in a world script. And if you want it to change, you need to use a timer or some event trigger. For example something like this:

Code: Select all

this.shipLaunchedFromStation = function() {
	this.$customDialValue = 0;
	this.$customDialTimer = new Timer(this, this.$customDialUpdate, 0, 0.1);
}

this.$customDialUpdate = function() {
	this.$customDialValue = this.$customDialValue + 0.1;
	if (this.$customDialValue > 1) {
		this.$customDialValue = 0;
	}
	player.ship.setCustomHUDDial("customDialExample", this.$customDialValue);
}
Hope that makes some sense. It's been a while.

Re: Scripters cove

Posted: Thu Oct 18, 2018 8:53 pm
by Nite Owl
Thank you spara. What you posted does make sense to me. Adapting it to my needs will be another story.

Fingers crossed that it will work out.

Re: Scripters cove

Posted: Fri Oct 19, 2018 12:36 am
by Nite Owl
No luck. Can get the gauge to appear where desired in the HUD but cannot get it to update at all. Not sure why. The combatSLBar does have its own data set as follows:

Code: Select all

this.$setData("combatSLBar", (player.ship.serviceLevel-75)/25);
Perhaps Norby is the person to contact as he created the combatmfd.oxz and lent a hand to the Coluber HUD as well. PM on the way.

Re: Scripters cove

Posted: Fri Oct 19, 2018 2:41 pm
by spara
Nite Owl wrote:
Fri Oct 19, 2018 12:36 am
No luck. Can get the gauge to appear where desired in the HUD but cannot get it to update at all. Not sure why. The combatSLBar does have its own data set as follows:

Code: Select all

this.$setData("combatSLBar", (player.ship.serviceLevel-75)/25);
Perhaps Norby is the person to contact as he created the combatmfd.oxz and lent a hand to the Coluber HUD as well. PM on the way.
Let's hope that Norby answers your call. In the meantime, note that every time you want to change the gauge value, you need to call for
setCustomHUDDial. Don't know the exact pieces of your puzzle, but if that this.$setData... is a function that updates the gauge, check that it actually gets executed in a timer or in an event handler.

Re: Scripters cove

Posted: Fri Oct 19, 2018 9:02 pm
by Norby
Hi Nite Owl,

CombatMFD contain a 0.25s timer which update the value of combatSLBar and Large HUD in HUDSelector display it below the scanner, labeled as Hull.
If you want an independent solution then just set one in a timer like this:

Code: Select all

var p = player.ship; 
p.setCustomHUDDial("ColuberSLBar", (p.serviceLevel-75)/25);
Then place the selector into coluber_hud.plist, for example:

Code: Select all

{     data_source = "ColuberSLBar"; selector = "drawCustomBar:"; draw_surround = yes;
      alert_conditions = 14; //do not show in the dock
      alpha = 1.0; height = 2; width = 35; x = -125; y = 23; y_origin = -1; },

Re: Scripters cove

Posted: Sat Oct 20, 2018 12:08 am
by Nite Owl
Thank you Norby.

The scripting details are starting to make sense to me but before the time is spent putting them into practice there is a bit of confusion on my part as to exactly which player ship status the Combat Service Level Bar is measuring.

Service Level Bar made me think (as stated in my original post on this) that the maintenance level of the player's ship was being measured. That is the number of, and/or damage from, Witchspace Jumps that the player's ship had taken until the next Maintenance Overhaul was needed.

Looking through the Wiki entries you linked to in your post, and with the "Hull" label on the Combat Service Level Bar in the Wiki's pictures, it appears that the incoming battle damage to the hull, from whatever source, is being measured.

Not 100% sure which one of these two is correct. A very useful gauge to have in either case. Although, truth be told, option one was what was hoped for.

Thank you both, once again, for you help with this. It is deeply appreciated. My brain hurts much less now. May actually get some sleep tonight without variables dancing on my pillow.

Re: Scripters cove

Posted: Sat Oct 20, 2018 1:05 am
by phkb
Nite Owl wrote:Not 100% sure which one of these two is correct.
You're understanding of Service Level is correct in what it does from the game's perspective. However, that internal concept doesn't easily translate into a game-world concept. What Norby has done is given it a game-world frame of reference. It is not, in any way, related to the state of the hull, but the appearance of the hull would be a readily observable state someone in the game would be able to see. So Norby has drawn a line between the two.

It's worth noting that some properties of ships are not inherently designed to be displayed to the player, given the function they perform in the game (Service Level, AI states for NPC's, even roles sand role weights). They're used to maintain game state, but it doessn't always make sense to display them as-is.