Page 1 of 1

How are shields governed

Posted: Fri Jul 09, 2010 2:50 am
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...

Posted: Fri Jul 09, 2010 6:16 am
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)

Re: How are shields governed

Posted: Fri Jul 09, 2010 7:06 am
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.

Re: How are shields governed

Posted: Fri Jul 09, 2010 7:37 am
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.

Posted: Fri Jul 09, 2010 7:39 am
by DaddyHoggy
So what everybody is saying is that I was wrong then... :oops:

Posted: Fri Jul 09, 2010 7:44 am
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.

Posted: Fri Jul 09, 2010 7:51 am
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.

Posted: Fri Jul 09, 2010 8:18 am
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?

Posted: Fri Jul 09, 2010 8:27 am
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?

Posted: Fri Jul 09, 2010 8:46 am
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.

Posted: Fri Jul 09, 2010 9:07 am
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.

Posted: Fri Jul 09, 2010 9:08 am
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... :)

Posted: Sat Jul 10, 2010 10:36 am
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);

Posted: Sat Jul 10, 2010 11:04 am
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.

Posted: Sat Jul 10, 2010 1:12 pm
by Commander Learner
Ahh...silly me, looking in the wrong file! :D Thanks!