Page 1 of 4

NPC shields [release]

Posted: Sun Mar 27, 2011 10:05 pm
by Commander McLane
Currently NPCs in Oolite have no shields like the player ship. It is possible that they'll get some in the code of Oolite 2.0.

What if you don't want to wait so long? Well, in the meantime you can help them with this small OXP.

[EliteWiki] NPC-shields.oxp gives shields to NPCs. If there is still shield strength left, the shield will absorb any hit, and the ship won't take damage. If a hit is absorbed by the shield, the ship glows red (NOTE: this works only with shaders set to FULL in Oolite's options; without full shaders you won't see the red glow, the shields will still be fully functional, though). As soon as the shield is depleted, the ship will take damage as usual.

There is only one shield per ship (not separate forward and aft shields like for the player). All NPC shields will absorb 128 points of energy damage, just like basic player shields. It is possible to raise that strength for NPCs with shield boosters or a military shield enhancement, and in fact the code for that is already included, but it is currently de-activated, because it may make NPCs just too tough.

Shields are recharged since version 0.91. Recharge only happens if the ship has full energy, with a rate of 2 points per second.

The OXP is expected to change game play dramatically. Generally NPCs get tougher through shields. You need more hits to kill them.

Also the usefulness of missiles will be affected. The first missile hitting a ship will not instantly kill it. Still, the NPC reaction to an incoming missile won't be affected. The AI will still attempt to flee.

It is possible to exclude missiles from the effects of this OXP. They could penetrate the shields and attack the ship's hull directly. On the other hand, the player ship's shields do protect it from missile hits as well. Any thoughts or suggestions on the matter?

There are still some glitches. A full implementation of NPC shields will probably only be possible in the game code itself:

(1) The glow effect is achieved simply by raising the ship's hull temperature. In open space, this lets the ship briefly glow red, before the temperature decreases again rapidly and immediately. If close to a sun, however, the temperature decreases much slower. It is even possible that the ship sustains additional damage through the heat. (This also means that the glow is only visible with shaders set to FULL.)

(2) It would be nice to decrease the ship's max energy as an exchange for increasing its shield strength. This would better allow to keep the overall balance. However, maxEnergy is read-only and thus cannot be changed by script. Hence I am reluctant to give ships with boosters a higher shield strength, because the shield boosting equipment is already reflected in the ship's max energy. If the property could be written to, balanced NPC-shields could be realized entirely by OXP.

Since version 1.0 ship designers can exclude their creations from getting shields. This can be useful for special OXP ships which are either already carefully balanced with regard to their strength, or are not supposed to have shields. The latter is true for both Generation Ships and the Flying Dutchman. I have therefore re-uploaded both OXPs in new versions which use the exclusion mechanism.

The exclusion works through the script_info key in shipdata. For any ship you don't want to have shields, insert a script_info key named npc_shields and set it to no. Please refer to the readMe for more information.


EDIT: added note about the red glow effect. Thanks to a_c for alerting me.

EDIT2: new download links for v 0.91

EDIT3: version 1.0 released

Re: NPC shields (proof-of-concept OXP)

Posted: Sun Mar 27, 2011 10:43 pm
by Cody
Nice little OXP McLane... gave me a good tussle with a Gecko and a Constrictor.
Add this to the improved npc evasion in 1.75.1 and things get a little more 'interesting'.

The shield glow idea is good:

Image

Re: NPC shields (proof-of-concept OXP)

Posted: Mon Mar 28, 2011 12:10 am
by CaptSolo
I need a new computer with a decent video card or purchase a video card to replace the onboard chipset I have. I think the first option is probably better. This OXP doesn't work for me but am sure it is not the OXP. Also, although I should test it some more, it seems DeepSpacePirates doesn't function with NPC Shields. I flew around for quite a long time without getting into the usual dogfight. I have Oolite version 1.75 but not the latest release. Again I am on foreign ground when it comes to these things and no insult is intended Commander McLane.

Re: NPC shields (proof-of-concept OXP)

Posted: Mon Mar 28, 2011 4:51 am
by Thargoid
So basically IronHide for NPCs (give or take the colour change)? I can see the commission profits rolling in now ;)

Implementing that for NPCs was on my to-do list to expand the OXP, but I guess I can cross it off now.

Re: NPC shields (proof-of-concept OXP)

Posted: Mon Mar 28, 2011 7:15 am
by Commander McLane
CaptSolo wrote:
This OXP doesn't work for me but am sure it is not the OXP. Also, although I should test it some more, it seems DeepSpacePirates doesn't function with NPC Shields.
Could you be a little more precise? 'Doesn't work' or 'doesn't function' isn't really helpful for understanding what's wrong.
CaptSolo wrote:
I flew around for quite a long time without getting into the usual dogfight.
Do you mean there were no pirates, or they were there but didn't fight you? Also, which version of DSP have you installed?

Re: NPC shields (proof-of-concept OXP)

Posted: Mon Mar 28, 2011 7:20 am
by another_commander
Commander McLane wrote:
CaptSolo wrote:
This OXP doesn't work for me but am sure it is not the OXP. Also, although I should test it some more, it seems DeepSpacePirates doesn't function with NPC Shields.
Could you be a little more precise? 'Doesn't work' or 'doesn't function' isn't really helpful for understanding what's wrong.
I believe CaptSolo refers to the ship shields not flashing when hit. The effect requires full shaders for it to be applied and may therefore create the perception that it is not working if shaders are set to simple or off. However, the shields are there.

Re: NPC shields (proof-of-concept OXP)

Posted: Mon Mar 28, 2011 7:39 am
by Commander McLane
Thargoid wrote:
So basically IronHide for NPCs (give or take the colour change)? I can see the commission profits rolling in now ;)
I was thinking of it as basically shields for NPCs. Inasmuch as IronHide adds another (the third after energy banks and shields) protective deplorable layer around player ships, it can be said that NPC shields are the next step in the arms race in order to balance out the advantage IronHide is giving to the player. :wink:

(EDIT: It seems that NPC shields are still weaker than IronHide. I forgot to mention that above, but I've set their strength to half the ship's max energy, but capped at 256. I'm even thinking about making it a universal 128 (equalling unmodified player ship shields). IronHide gives either 200 or 400 extra protection.)

To be honest, I didn't even think about IronHide before (I don't have it and wasn't really aware of it when I had the idea). It just struck me yesterday evening that the new shipTakingDamage handler can be put to good use, and that the newish shipSpawned world script handler is very convenient for amending ship scripts with minimal invasive technique. From there on the few lines of code developed rather naturally.

The little stroke of genius—if I may say so—however was to use the ship temperature for an optical effect. I had experimented with creating shield-absorbs-energy effect before by using a single red flasher bigger than the ship. But that never took off. Even now that we can add and remove subentities on the fly it wouldn't work very well. Multiple hits in quick succession (military laser salvo) wouldn't look realistic, not to mention how ships with other flashers would blink in a silly way.

I'm still waiting for more feedback. Do you like it? How should it be tweaked? In my version I have already added one more line of code in order to prevent 'overusing' the shields. If 23 damage are inflicted, and only 16 shield strength are left, the difference of 7 goes into energy damage now. In the released version even the 'insufficient' shield still gives complete protection.

Re: NPC shields (proof-of-concept OXP)

Posted: Mon Mar 28, 2011 7:40 am
by Commander McLane
another_commander wrote:
Commander McLane wrote:
CaptSolo wrote:
This OXP doesn't work for me but am sure it is not the OXP. Also, although I should test it some more, it seems DeepSpacePirates doesn't function with NPC Shields.
Could you be a little more precise? 'Doesn't work' or 'doesn't function' isn't really helpful for understanding what's wrong.
I believe CaptSolo refers to the ship shields not flashing when hit. The effect requires full shaders for it to be applied
Ah! I wasn't aware of that. Thanks for the info. Will amend the first post.

Re: NPC shields (proof-of-concept OXP)

Posted: Mon Mar 28, 2011 11:14 am
by Commander McLane
Version 0.91 brings some improvements and changes:
  • NPC-shields are now rechargeable.
  • Shield strength is 128 for all ships.
Detailed explanations are in the readMe and in the edited first post. Please re-download from there.

Re: NPC shields (proof-of-concept OXP)

Posted: Mon Mar 28, 2011 12:20 pm
by Okti
Nice work Commander McLane,

As far as I can see, your OXP always gives a shield to all NPC ships. How about making it random or dependent on the bounty of the ship.

Re: NPC shields (proof-of-concept OXP)

Posted: Mon Mar 28, 2011 1:09 pm
by Cody
McLane... if I reduce the ship.temperature in the js script, will that lessen the glow effect?

Re: NPC shields (proof-of-concept OXP)

Posted: Mon Mar 28, 2011 1:13 pm
by Commander McLane
Okti wrote:
Nice work Commander McLane,
Thanks! :D
Okti wrote:
As far as I can see, your OXP always gives a shield to all NPC ships. How about making it random or dependent on the bounty of the ship.
Why?

My basic idea was to treat NPCs like the player ship gets treated. The player ship has always shields, not only randomly or with a bounty, and regardless which ship he flies. Therefore I think it's safe to assume that all ships have shields (with the exceptions you surely noticed in the code, like asteroids or cargopods).

It's an experiment, to see in how far one of the wishes for Oolite 2 can already be accomplished in Oolite 1.7x. For this particular wish it's possible, given the caveats mentioned. For other wishes it isn't, which is why Oolite 2 is in development in the first place. But still, it's a nice scripting exercise to see how far we can get.

If you meet an NPC that comes straight out of a battle, it won't have shields (or only depleted ones), which is how it should be. Of course it's always possible for a script to alter the maxShieldStrength and shieldStrength of any existing ship, even retro-actively. So other can build upon it, and perhaps even introduce an element of random.

What I am mainly looking for at this point is to get some data on how NPC shields in their current form change game play. I strongly suspect that I'll need to further tweak shield strength and recharge, in order to balance things out better. My main concern is that it may make NPC too invulnerable. But I can be wrong. That's why I need feedback.

Re: NPC shields (proof-of-concept OXP)

Posted: Mon Mar 28, 2011 1:24 pm
by Commander McLane
El Viejo wrote:
McLane... if I reduce the ship.temperature in the js script, will that lessen the glow effect?
Yes. 0.99 is just short of the point where the ship starts taking heat damage. I've seen ships starting to throw sparks at 1.033 (at 1.032 the don't). I guess that's due to floating point and rounding. At that point they didn't sustain damage yet, but the colour becomes more orange than red.

The lower the peak temperature, the darker reddish the glow becomes. If you have a JS console at your hand you can do some experiments.

First create any ship in your vicitinity.

Second, target it.

Third, type in the console:

Code: Select all

PS.target.switchAI("dumbAI.plist")
This will cause the ship to stay at the same place and roll around, giving you a good view at it.

Now you have prepared your guinea pig, you fourth type in the console

Code: Select all

PS.target.temperature=1
and you'll see the short flash.

(Or, much easier, skip points one and three, and just target the station beacon. :) )

Obviously you now can try with other values. The basic temperature in open space is about 0.23, so you won't see any colour near that. For me the effect becomes too short and faint below 0.7.

Re: NPC shields (proof-of-concept OXP)

Posted: Mon Mar 28, 2011 1:30 pm
by Cody
Thanks McLane... no JS console here, but I was thinking of 0.75 to 0.80, which I'll try tonight with the updated OXP. Having been playing with the Tough Guys OXP installed over the last few months, the npcs with shields do not seem too difficult to take down... I'm used to it being hard out there. I'll give you some more feedback tomorrow.

Re: NPC shields (proof-of-concept OXP)

Posted: Tue Mar 29, 2011 3:52 pm
by Zireael
Yay, another one of my wishes coming true! I downloaded it and I'll try it tomorrow, as I won't have time today.