[WIP] N-Shields

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

Moderators: winston, another_commander

Ngalo
Competent
Competent
Posts: 58
Joined: Mon Mar 02, 2015 2:08 pm
Location: drifting in remLock mask near Vezadi Station

[WIP] N-Shields

Post 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.
Last edited by Ngalo on Sat Jul 16, 2016 2:20 pm, edited 4 times in total.
Equal Rights for NPCs!
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: [WIP] N-Shields

Post by Cody »

For the record, I wholeheartedly approve of your 'Equal Rights for NPCs' campaign!
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
Amah
---- E L I T E ----
---- E L I T E ----
Posts: 486
Joined: Tue Aug 28, 2012 8:05 pm
Location: aboard the Laenina Crowne - Yasen-N class space freighter
Contact:

Re: [WIP] N-Shields

Post 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!
Amah
Anonymissimus
---- E L I T E ----
---- E L I T E ----
Posts: 299
Joined: Mon Apr 27, 2015 9:03 pm

Re: [WIP] N-Shields

Post 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).
warning sound if a missile is inbound: Missile warning
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: [WIP] N-Shields

Post 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)
Ngalo
Competent
Competent
Posts: 58
Joined: Mon Mar 02, 2015 2:08 pm
Location: drifting in remLock mask near Vezadi Station

Re: [WIP] N-Shields

Post 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.
Equal Rights for NPCs!
Anonymissimus
---- E L I T E ----
---- E L I T E ----
Posts: 299
Joined: Mon Apr 27, 2015 9:03 pm

Re: [WIP] N-Shields

Post 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.
warning sound if a missile is inbound: Missile warning
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: [WIP] N-Shields

Post 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.
Ngalo
Competent
Competent
Posts: 58
Joined: Mon Mar 02, 2015 2:08 pm
Location: drifting in remLock mask near Vezadi Station

Re: [WIP] N-Shields

Post 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.
Equal Rights for NPCs!
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: [WIP] N-Shields

Post 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.
Ngalo
Competent
Competent
Posts: 58
Joined: Mon Mar 02, 2015 2:08 pm
Location: drifting in remLock mask near Vezadi Station

Re: [WIP] N-Shields

Post 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.
Equal Rights for NPCs!
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6682
Joined: Wed Feb 28, 2007 7:54 am

Re: [WIP] N-Shields

Post 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.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: [WIP] N-Shields

Post 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;
		}
	}
Ngalo
Competent
Competent
Posts: 58
Joined: Mon Mar 02, 2015 2:08 pm
Location: drifting in remLock mask near Vezadi Station

Re: [WIP] N-Shields

Post 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]
Equal Rights for NPCs!
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: [WIP] N-Shields

Post 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;
Post Reply