How are shields governed

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

Post Reply
User avatar
Commander Learner
Dangerous
Dangerous
Posts: 123
Joined: Thu Aug 20, 2009 12:08 pm
Location: Somewheeeeeere over the rainbooooooooooow~

How are shields governed

Post by Commander Learner »

Just curious as to which part of the source code deals with the strength and recharge rate of player shields. Can only find energy rates in the player entity...
Shooting polygons since 2001
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

From memory - whether you're an adder or an Anaconda Oolite shield technology is identical - strength and recharge rate is not definable therefore. And NPCs don't actually have shields just energy (which actually is all shielding is if you're the player, it's just an energy reserve you use up before your equipment can be damaged)
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: How are shields governed

Post by another_commander »

Commander Learner wrote:
Just curious as to which part of the source code deals with the strength and recharge rate of player shields. Can only find energy rates in the player entity...
Player shield management is inside PlayerEntity.m, -doBookkeeping method. There is a very conveniently placed line in there to help you locate it, that reads:
UPDATE_STAGE(@"updating energy and shield charges");
Everything happens between the line above and approximately the line that reads
UPDATE_STAGE(@"updating sun effects");
The recharge rate of any ship, including player, is set from ShipEntity.m, -shieldRechargeRate method.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: How are shields governed

Post by Smivs »

Commander Learner wrote:
Just curious as to which part of the source code deals with the strength and recharge rate of player shields. Can only find energy rates in the player entity...
This is specified in the shipdata.plist for player ships.
The recharge rate is fairly self-explanatory, with 1 being low and 5 being very high.
The number of Energy Banks is set by the 'Max Energy' setting. This works on a multiplyer of 64, so a Cobra with 4 energy banks has a Max Energy of 256 (4x64=256).
NPC ships don't really have the equivalent of things like shield boosters, so if you want to 'toughen-up' a NPC you have to tweak the recharge rate.
For example my Contractor has a recharge rate of 5 for the player ship, which can be augmented by adding Extra or Naval Energy Units. The pirate version has a recharge rate of 7 which is the roughly the equivalent of having an Extra Energy Unit, and the Bounty Hunter version has a rate of 10 to mimic a Naval Energy Unit.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

So what everybody is saying is that I was wrong then... :oops:
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Post by Smivs »

DaddyHoggy wrote:
So what everybody is saying is that I was wrong then... :oops:
No. In essence you are right...shields and energy are basically the same thing. They just work differently for players and NPCs where players have a greater variety of ways of improving things.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Cmdr James
Commodore
Commodore
Posts: 1357
Joined: Tue Jun 05, 2007 10:43 pm
Location: Berlin

Post by Cmdr James »

Im pretty sure handling of damage is different if it is taken by shields instead of hull. For example heating, and equipment damage are not the same (I think).

As previously stated NPCs dont have shields, but this can be "simulated" with more energy.
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

Cmdr James wrote:
Im pretty sure handling of damage is different if it is taken by shields instead of hull. For example heating, and equipment damage are not the same (I think).

As previously stated NPCs dont have shields, but this can be "simulated" with more energy.
Now (I think) we can damage equipment on NPC ships (or at least script its addition and removal) does not having shields make it unfair on NPCs as they don't get the "grace period" of having shields?
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Post by Smivs »

DaddyHoggy wrote:
Cmdr James wrote:
Im pretty sure handling of damage is different if it is taken by shields instead of hull. For example heating, and equipment damage are not the same (I think).

As previously stated NPCs dont have shields, but this can be "simulated" with more energy.
Now (I think) we can damage equipment on NPC ships (or at least script its addition and removal) does not having shields make it unfair on NPCs as they don't get the "grace period" of having shields?
I agree. I can see no justification for this imbalance, and I personally feel that if a player can have something, NPCs should also have it available. The Ooniverse is very one-sided in favour of the player, which is probably a good thing for a new player with a weak ship, but an experienced player with an Iron-Ass can find things a bit too easy sometimes.
I appreciate that this is a sticky problem...how do you give the novice a fighting chance while keeping things interesting for the more advanced player?
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Cmdr James
Commodore
Commodore
Posts: 1357
Joined: Tue Jun 05, 2007 10:43 pm
Location: Berlin

Post by Cmdr James »

I dont think anyone argues that it is correct that NPCs dont have shields, its just that it wasnt written that way, and noone has yet changed it.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Cmdr James wrote:
I dont think anyone argues that it is correct that NPCs dont have shields.
It just depends how you define shields. For the player you can add up shields energy and energy banks to get the total energy needed to kill a player ship.

However, during the period that shields still have energy, equipment can't be damaged. When you define that as having shields, one can say that NPC only have shields (One in total for both front and aft). As long as a NPC has energy, his equipment will not be at risk during a hit. That sounds as a shield to me.
Last edited by Eric Walch on Fri Jul 09, 2010 9:08 am, edited 1 time in total.
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

Which means no npc equipment gets damaged during fights! :)

There are a number of player specific features that we should be able to transfer to NPCs eventually, including battle damaged equipment & front/aft shields, but they're definitely something for EMMSRAN.

In the meantime, there's the unique opportunity for a 'realistic NPCs' oxp to implement NPC front/aft shield technology & battle damage for the immediate future... :)
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Commander Learner
Dangerous
Dangerous
Posts: 123
Joined: Thu Aug 20, 2009 12:08 pm
Location: Somewheeeeeere over the rainbooooooooooow~

Post by Commander Learner »

Does that mean that shield charge rates are fixed? The only code that looks like it is player entity.m

Code: Select all

if (energy < maxEnergy)
	{
		double energy_multiplier = 1.0 + 0.1 * [self installedEnergyUnitType]; // 1.8x recharge with normal energy unit, 2.6x with naval!
		energy += (float)(energy_recharge_rate * energy_multiplier * delta_t);
		if (energy > maxEnergy)
			energy = maxEnergy;
	}
	
	// Recharge shields from energy banks
	float rechargeFwd = (float)([self shieldRechargeRate] * delta_t);
	float rechargeAft = rechargeFwd;
	float fwdMax = [self maxForwardShieldLevel];
	float aftMax = [self maxAftShieldLevel];
	
	if (forward_shield < fwdMax)
	{
		if (forward_shield + rechargeFwd > fwdMax)  rechargeFwd = fwdMax - forward_shield;
		forward_shield += rechargeFwd;
		energy -= rechargeFwd;
	}
	if (aft_shield < aftMax)
	{
		if (aft_shield + rechargeAft > aftMax)  rechargeAft = aftMax - aft_shield;
		aft_shield += rechargeAft;
		energy -= rechargeAft;
	}
	forward_shield = OOClamp_0_max_f(forward_shield, fwdMax);
	aft_shield = OOClamp_0_max_f(aft_shield, aftMax);
Shooting polygons since 2001
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

Shield recharge rates are controlled from ShipEntity.m and are as follows:

Code: Select all

- (float) shieldRechargeRate
{
	return [self hasMilitaryShieldEnhancer] ? 3.0f : 2.0f;
}
Which means, with a military shield enhancer the shield recharge rate is 3, without one it is 2.
User avatar
Commander Learner
Dangerous
Dangerous
Posts: 123
Joined: Thu Aug 20, 2009 12:08 pm
Location: Somewheeeeeere over the rainbooooooooooow~

Post by Commander Learner »

Ahh...silly me, looking in the wrong file! :D Thanks!
Shooting polygons since 2001
Post Reply