Page 1 of 2

[WIP] N-Shields

Posted: Tue Apr 26, 2016 1:14 pm
by Ngalo
You don't need this OXP. CustomShields does this perfectly well, doesn't it?

Shockingly, CustomShields is not quite 100% fair. It only recharges NPCs' shields once their energy banks are full, which clearly isn't the usual player ship behaviour. N-shields aims to rectify this, as well as letting NPC shields protect subentities as player ones have done since 1.77.
Other improvements are as follows:
-Attempting to provide better compatibility for other OXPs with shipTakingDamage overrides
-Support for very non-standard shield configurations(sorry, feature mostly removed in 0.7) Thargoids get dorsal/ventral shields.
-More customisable colours. The default multicolour set goes from green down to red for standard shields, extending to blue/purple with upgrades.
-New visual effects based on explosions.plist for shields and unshielded hits.

Version 0.7.1 OXZ download is here.

Re: [WIP] N-Shields

Posted: Tue Apr 26, 2016 1:19 pm
by Cody
For the record, I wholeheartedly approve of your 'Equal Rights for NPCs' campaign!

Re: [WIP] N-Shields

Posted: Tue Apr 26, 2016 4:19 pm
by Amah
count me in :-)

Fireworks!!! I like... Just tried it out, I'm not sure about the "star effect" when hit, being too dominant, but maybe one has to get accustomed to it.
Anyways, nice one!

Re: [WIP] N-Shields

Posted: Tue Apr 26, 2016 8:30 pm
by Anonymissimus
Cody wrote:
For the record, I wholeheartedly approve of your 'Equal Rights for NPCs' campaign!
I want the assassins' fuel injectors to get damaged when I hit them with shields down then.
I may get beaten here though. Sometimes they go down as if their injectors were damaged, or they perhaps eject because their injectors were damaged (core assassins never eject, but OXP ones sometimes do).

Re: [WIP] N-Shields

Posted: Wed Apr 27, 2016 3:40 am
by phkb
Just got these messages in my log file:

Code: Select all

13:29:20.745 [oxp-standards.deprecated]: Script ../AddOns/Testing.oxp/N-Shields.oxp/Scripts/N-Shields.js does not "use strict";
...
13:29:35.349 [mesh.error]: ***** Failed to find TEXTURES data (will use placeholder material)
 ..... from NShields-flare-marker.dat (from file)

Re: [WIP] N-Shields

Posted: Sat Apr 30, 2016 11:45 am
by Ngalo
phkb wrote:
Just got these messages in my log file:

Code: Select all

13:29:20.745 [oxp-standards.deprecated]: Script ../AddOns/Testing.oxp/N-Shields.oxp/Scripts/N-Shields.js does not "use strict";
...
13:29:35.349 [mesh.error]: ***** Failed to find TEXTURES data (will use placeholder material)
 ..... from NShields-flare-marker.dat (from file)
That's OK, I just couldn't be bothered to texture a tiny 1-poly marker nobody will ever actually see. Might get around to it one day if your log file desperately needs de-cluttering.

As for the star effects being too big, I'm actually inclined to agree and will tweak things a bit once the hemisphere glow effects work properly; for now you can unzip the OXZ and find the off-switch in the top of N-Shields.js if you like.

Anonymissimus, NPC Equipment Damage does happen to be in my WIP folder, although it's not exactly simple and has yet to reach the testing stage. Watch this space.

Re: [WIP] N-Shields

Posted: Sat Apr 30, 2016 12:23 pm
by Anonymissimus
Ngalo wrote:
Anonymissimus, NPC Equipment Damage does happen to be in my WIP folder, although it's not exactly simple and has yet to reach the testing stage. Watch this space.
Aha, so it is really so that the equipment of NPC ships cannot be damaged by default as of now ?
Fuel injectors are obviously the most interesting piece, but others such as shield boosters also count ofc.

Sorry for offtopic (somewhat), I should have created a dedicated thread for asking this.

Re: [WIP] N-Shields

Posted: Wed May 04, 2016 11:12 pm
by phkb
Small bug in the following routine:

Code: Select all

this.$drawSparks = function(position, ship, amount) //TODO: use amount to determine type?
{
	if (amount < 10) chance = 0.5;
	else chance = 1;
	
	if (Math.random() <= chance)
	{
		var sparks = ship.spawnOne("NShields-sparks");
		sparks.position = position;
		sparks.explode()
	}
}
The variable "chance" is not declared.

Re: [WIP] N-Shields

Posted: Tue May 10, 2016 11:04 am
by Ngalo
Thanks for pointing that out, phkb (although it seemed to work anyway). My problem is I think in Python too much.

Anyway, version 0.6.1 is now out with a Ship Configuration version check that actually works (sorry about the 0.5.3 attempt), some config options for users of Oolite-trunk and Library OXP, re-sized star explosions (maybe too small now?) and hemisphere glow effects working properly (although they are still disabled by default because they still look awful). Oh, and compatibility with NPC Equipment Damage OXP.

Re: [WIP] N-Shields

Posted: Wed May 11, 2016 3:18 am
by phkb
Small bug in the manifest.plist:

Code: Select all

12:40:05.844 [plist.parse.failed]: Failed to parse ../AddOns/Testing.oxp/N-Shields.oxz/manifest.plist as a property list.
Parse failed at line 20 (char 700) - unexpected character (wanted '=')
Looks like there's a missing "};" at the end of the optional oxps.

Re: [WIP] N-Shields

Posted: Thu May 26, 2016 12:34 pm
by Ngalo
Already found & fixed, but thanks for your vigilance. The fixed version is now available.

[Edit:]
Also, a question for any developers who happen to be around: Is the correct default value for shield_charge_energybank_threshold in global-settings.plist 0.0 (as that file says) or 0.25 (as the source code seems to say)? 0.0 is the value I've been using, in the absence of any ability to read the actual one directly.

Re: [WIP] N-Shields

Posted: Thu May 26, 2016 7:00 pm
by another_commander
Ngalo wrote:
Also, a question for any developers who happen to be around: Is the correct default value for shield_charge_energybank_threshold in global-settings.plist 0.0 (as that file says) or 0.25 (as the source code seems to say)? 0.0 is the value I've been using, in the absence of any ability to read the actual one directly.
It looks like it is set to 0.25. The value in the plist is commented out and is considered non-existent.

Re: [WIP] N-Shields

Posted: Fri May 27, 2016 6:47 am
by phkb
Getting this in my log file:

Code: Select all

16:38:57.864 [NPC_Equipment_Damage]: damaging EQ_NSHIELDS_NPC_SHIELD_BOOSTER on Wolf Mark I: Cursed Trumble V
16:38:58.052 [script.javaScript.exception.notDefined]: ***** JavaScript exception (griff_spawn_wreckage 1.1): ReferenceError: labels is not defined
16:38:58.052 [script.javaScript.exception.notDefined]:       ../AddOns/Testing.oxp/N-Shields.oxp/Scripts/N-Shields.js, line 911.
BTW, there's a bug in ShipConfig, in the code that damages energy equipment. I've got a "ship" reference rather than a "this.ship" on one of the lines.

Edit: I fixed it by changing these lines

Code: Select all

	if (equipment == "EQ_NSHIELDS_NPC_NAVAL_SHIELD_BOOSTER") //reverse the equipment upgrade changes
	{
		let eq = EquipmentInfo.infoForKey("EQ_NAVAL_SHIELD_BOOSTER");
		let shield_boost = parseInt(eq.scriptInfo.oolite_shield_increase);
		let recharge_boost = parseFloat(eq.scriptInfo.oolite_shield_recharge_multiplier);
		for (i in labels.maxShields)
		{
			ship[labels.maxShields[i]] -= shield_boost;
			if (recharge_boost) ship[labels.rechargeRates[i]] /= recharge_boost;
		}
	}
	
	if (equipment == "EQ_NSHIELDS_NPC_SHIELD_BOOSTER") //reverse the equipment upgrade changes
	{
		let eq = EquipmentInfo.infoForKey("EQ_SHIELD_BOOSTER");
		let shield_boost = parseInt(eq.scriptInfo.oolite_shield_increase);
		let recharge_boost = parseFloat(eq.scriptInfo.oolite_shield_recharge_multiplier);
		for (i in labels.maxShields)
		{
			ship[labels.maxShields[i]] -= shield_boost;
			if (recharge_boost) ship[labels.rechargeRates[i]] /= recharge_boost;
		}
	}
to this

Code: Select all

	if (equipment == "EQ_NSHIELDS_NPC_NAVAL_SHIELD_BOOSTER") //reverse the equipment upgrade changes
	{
		let eq = EquipmentInfo.infoForKey("EQ_NAVAL_SHIELD_BOOSTER");
		let shield_boost = parseInt(eq.scriptInfo.oolite_shield_increase);
		let recharge_boost = parseFloat(eq.scriptInfo.oolite_shield_recharge_multiplier);
		for (i in this.ship.script.NShields_labels.maxShields)
		{
			this.ship[this.ship.script.NShields_labels.maxShields[i]] -= shield_boost;
			if (recharge_boost) this.ship[this.ship.script.NShields_labels.rechargeRates[i]] /= recharge_boost;
		}
	}
	
	if (equipment == "EQ_NSHIELDS_NPC_SHIELD_BOOSTER") //reverse the equipment upgrade changes
	{
		let eq = EquipmentInfo.infoForKey("EQ_SHIELD_BOOSTER");
		let shield_boost = parseInt(eq.scriptInfo.oolite_shield_increase);
		let recharge_boost = parseFloat(eq.scriptInfo.oolite_shield_recharge_multiplier);
		for (i in this.ship.script.NShields_labels.maxShields)
		{
			this.ship[this.ship.script.NShields_labels.maxShields[i]] -= shield_boost;
			if (recharge_boost) this.ship[this.ship.script.NShields_labels.rechargeRates[i]] /= recharge_boost;
		}
	}

Re: [WIP] N-Shields

Posted: Tue Jun 07, 2016 2:25 pm
by Ngalo
Thanks phkb, I think I already found & fixed the shield damage bug (and found the shipconfig energy bug) for myself & will emergency-release N-Shields 0.6.3 today if time permits.

[Edit]
Done. The link above should now be the new version.
[/Edit]

Re: [WIP] N-Shields

Posted: Wed Jun 15, 2016 1:01 am
by phkb
One more bug. Line 594 of N-Shields.js reads

Code: Select all

		else if (ship.script.NShields_cloaked_attacker && ship.script.NShields_cloaked_attacker.distanceTo(ship) < 25600) attacker = ship.script.NShields_cloaked_attacker;
I think it should be

Code: Select all

		else if (ship.script.NShields_cloaked_attacker && ship.script.NShields_cloaked_attacker.position.distanceTo(ship) < 25600) attacker = ship.script.NShields_cloaked_attacker;