Blowing up the reactor sets karma to 0, all jobs except assistant require a certain karma level

This commit is contained in:
juanjp600
2017-12-04 17:05:22 -03:00
parent 2347f2937e
commit a0782e5d8d
9 changed files with 57 additions and 15 deletions

View File

@@ -117,11 +117,20 @@ namespace Barotrauma
(GameMain.GameSession.Mission.Completed) ? GameMain.GameSession.Mission.SuccessMessage : GameMain.GameSession.Mission.FailureMessage,
"", innerFrame, true);
if (GameMain.GameSession.Mission.Completed)
{
GameMain.Server.ConnectedClients.ForEach(c => c.Karma += 0.1f);
}
if (GameMain.GameSession.Mission.Completed && singleplayer)
{
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Reward: " + GameMain.GameSession.Mission.Reward, "", Alignment.BottomLeft, Alignment.BottomLeft, innerFrame);
}
}
else
{
GameMain.Server.ConnectedClients.ForEach(c => c.Karma += 0.1f);
}
return frame;
}

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<Jobs>
<Job name="Captain" description="The Commanding Officer is responsible for commanding the entirety of the crew and ensuring that everything is running smoothly." minnumber="1" maxnumber="1">
<Job name="Captain" description="The Commanding Officer is responsible for commanding the entirety of the crew and ensuring that everything is running smoothly." minnumber="1" maxnumber="1" minkarma="0.7">
<Skills>
<Skill name="Weapons" level="50,60"/>
<Skill name="Construction" level="20,30"/>
@@ -22,7 +22,7 @@
</Items>
</Job>
<Job name="Engineer" description="Engineers are the backbone of a submarine's crew, complementing a mechanic's construction skill with their knowledge of electrical engineering. They are capable of performing maintenance on the various electrical pieces of the submarine." minnumber="1">
<Job name="Engineer" description="Engineers are the backbone of a submarine's crew, complementing a mechanic's construction skill with their knowledge of electrical engineering. They are capable of performing maintenance on the various electrical pieces of the submarine." minnumber="1" minkarma="0.5">
<Skills>
<Skill name="Weapons" level="10,30"/>
<Skill name="Construction" level="20,30"/>
@@ -40,7 +40,7 @@
</Items>
</Job>
<Job name="Mechanic" description="Mechanics are capable of fixing various mechanical devices with their high construction skill. Together with engineers they ensure a submarine is working to its fullest." minnumber="1">
<Job name="Mechanic" description="Mechanics are capable of fixing various mechanical devices with their high construction skill. Together with engineers they ensure a submarine is working to its fullest." minnumber="1" minkarma="0.5">
<Skills>
<Skill name="Weapons" level="10,30"/>
<Skill name="Construction" level="50,60"/>
@@ -58,7 +58,7 @@
</Items>
</Job>
<Job name="Security Officer" description="Security Officers are responsible for keeping the submarine safe from threats, both external and internal. The creatures inhabiting the ocean aren't the only threat they need to worry about, as several of the renegade groups opposing the Europa Coalition are known to have sent infiltrators on board the vessels." maxnumber="2">
<Job name="Security Officer" description="Security Officers are responsible for keeping the submarine safe from threats, both external and internal. The creatures inhabiting the ocean aren't the only threat they need to worry about, as several of the renegade groups opposing the Europa Coalition are known to have sent infiltrators on board the vessels." maxnumber="2" minkarma="0.7">
<Skills>
<Skill name="Weapons" level="50,60"/>
<Skill name="Medical" level="30,40"/>
@@ -78,7 +78,7 @@
</Items>
</Job>
<Job name="Medical Doctor" description="Although usually taken for granted, Doctors play an important role on the submarine, possessing the required skill to treat injured or unconscious crew members. Their skills can also be useful for creating various non-medicinal chemicals." maxnumber="2">
<Job name="Medical Doctor" description="Although usually taken for granted, Doctors play an important role on the submarine, possessing the required skill to treat injured or unconscious crew members. Their skills can also be useful for creating various non-medicinal chemicals." maxnumber="2" minkarma="0.7">
<Skills>
<Skill name="Weapons" level="10,20"/>
<Skill name="Construction" level="10,20"/>
@@ -97,7 +97,7 @@
</Items>
</Job>
<Job name="Assistant" description="Assistants don't have any specific responsibilities or areas of expertise. This job is a good choice for newcomers who want to get a hang of working on board the submarine without taking up tasks that they aren't qualified for." allowalways="true">
<Job name="Assistant" description="Assistants don't have any specific responsibilities or areas of expertise. This job is a good choice for newcomers who want to get a hang of working on board the submarine without taking up tasks that they aren't qualified for." allowalways="true" minkarma="0.0">
<Skills>
<Skill name="Weapons" level="20,30"/>
<Skill name="Construction" level="20,30"/>

View File

@@ -1565,7 +1565,7 @@ namespace Barotrauma
public virtual AttackResult AddDamage(IDamageable attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound = false)
{
Limb limbHit = null;
var attackResult = AddDamage(worldPosition, attack.DamageType, attack.GetDamage(deltaTime), attack.GetBleedingDamage(deltaTime), attack.Stun, playSound, attack.TargetForce, out limbHit);
var attackResult = AddDamage(worldPosition, attack.DamageType, attack.GetDamage(deltaTime), attack.GetBleedingDamage(deltaTime), attack.Stun, playSound, attack.TargetForce, out limbHit, attacker);
if (limbHit == null) return new AttackResult();
var attackingCharacter = attacker as Character;
@@ -1612,7 +1612,7 @@ namespace Barotrauma
return AddDamage(worldPosition, damageType, amount, bleedingAmount, stun, playSound, attackForce, out temp);
}
public AttackResult AddDamage(Vector2 worldPosition, DamageType damageType, float amount, float bleedingAmount, float stun, bool playSound, float attackForce, out Limb hitLimb)
public AttackResult AddDamage(Vector2 worldPosition, DamageType damageType, float amount, float bleedingAmount, float stun, bool playSound, float attackForce, out Limb hitLimb,IDamageable attacker=null)
{
hitLimb = null;
@@ -1640,7 +1640,7 @@ namespace Barotrauma
AttackResult attackResult = hitLimb.AddDamage(worldPosition, damageType, amount, bleedingAmount, playSound);
AddDamage(damageType == DamageType.Burn ? CauseOfDeath.Burn : causeOfDeath, attackResult.Damage, null);
AddDamage(damageType == DamageType.Burn ? CauseOfDeath.Burn : causeOfDeath, attackResult.Damage, attacker);
if (DoesBleed)
{

View File

@@ -47,6 +47,12 @@ namespace Barotrauma
private set;
}
public float MinKarma
{
get;
private set;
}
public float Commonness
{
get;
@@ -61,6 +67,7 @@ namespace Barotrauma
MinNumber = element.GetAttributeInt("minnumber", 0);
MaxNumber = element.GetAttributeInt("maxnumber", 10);
MinKarma = element.GetAttributeFloat("minkarma", 0.0f);
Commonness = element.GetAttributeInt("commonness", 10);

View File

@@ -209,7 +209,7 @@ namespace Barotrauma.Items.Components
if (progressBar != null) progressBar.Size = new Vector2(60.0f, 20.0f);
#endif
targetStructure.AddDamage(sectionIndex, -StructureFixAmount * degreeOfSuccess);
targetStructure.AddDamage(sectionIndex, -StructureFixAmount * degreeOfSuccess,user);
//if the next section is small enough, apply the effect to it as well
//(to make it easier to fix a small "left-over" section)

View File

@@ -20,6 +20,8 @@ namespace Barotrauma.Items.Components
private float temperature;
private Client BlameOnBroken;
//is automatic temperature control on
//(adjusts the cooling rate automatically to keep the
//amount of power generated balanced with the load)
@@ -326,6 +328,14 @@ namespace Barotrauma.Items.Components
if (containedItem == null) continue;
containedItem.Condition = 0.0f;
}
if (GameMain.Server != null)
{
if (GameMain.Server.ConnectedClients.Contains(BlameOnBroken))
{
BlameOnBroken.Karma = 0.0f;
}
}
}
public override bool Pick(Character picker)
@@ -387,8 +397,12 @@ namespace Barotrauma.Items.Components
float coolingRate = msg.ReadRangedSingle(0.0f, 100.0f, 8);
float fissionRate = msg.ReadRangedSingle(0.0f, 100.0f, 8);
if (!item.CanClientAccess(c)) return;
if (!item.CanClientAccess(c)) return;
if (!autoTemp && AutoTemp) BlameOnBroken = c;
if (shutDownTemp > ShutDownTemp) BlameOnBroken = c;
if (fissionRate > FissionRate) BlameOnBroken = c;
AutoTemp = autoTemp;
ShutDownTemp = shutDownTemp;

View File

@@ -1329,6 +1329,8 @@ namespace Barotrauma
Condition = prefab.Health;
}
c.Karma += 0.4f;
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
break;

View File

@@ -709,7 +709,7 @@ namespace Barotrauma
gapRect.Height += 20;
sections[sectionIndex].gap = new Gap(gapRect, !isHorizontal, Submarine);
sections[sectionIndex].gap.ConnectedWall = this;
AdjustKarma(attacker, 300);
//AdjustKarma(attacker, 300);
#if CLIENT
if(CastShadow) GenerateConvexHull();
#endif

View File

@@ -2082,7 +2082,7 @@ namespace Barotrauma.Networking
{
//the maximum number of players that can have this job hasn't been reached yet
// -> assign it to the client
if (assignedClientCount[preferredJob] < preferredJob.MaxNumber)
if (assignedClientCount[preferredJob] < preferredJob.MaxNumber && c.Karma >= preferredJob.MinKarma)
{
c.AssignedJob = preferredJob;
assignedClientCount[preferredJob]++;
@@ -2092,13 +2092,22 @@ namespace Barotrauma.Networking
else if (preferredJob == c.JobPreferences.Last())
{
//find all jobs that are still available
var remainingJobs = JobPrefab.List.FindAll(jp => assignedClientCount[preferredJob] < jp.MaxNumber);
var remainingJobs = JobPrefab.List.FindAll(jp => assignedClientCount[preferredJob] < jp.MaxNumber && c.Karma >= jp.MinKarma);
//all jobs taken, give a random job
if (remainingJobs.Count == 0)
{
DebugConsole.ThrowError("Failed to assign a suitable job for \"" + c.Name + "\" (all jobs already have the maximum numbers of players). Assigning a random job...");
c.AssignedJob = JobPrefab.List[Rand.Range(0, JobPrefab.List.Count)];
int jobIndex = Rand.Range(0,JobPrefab.List.Count);
int skips = 0;
while (c.Karma < JobPrefab.List[jobIndex].MinKarma)
{
jobIndex++;
skips++;
if (jobIndex >= JobPrefab.List.Count) jobIndex -= JobPrefab.List.Count;
if (skips >= JobPrefab.List.Count) break;
}
c.AssignedJob = JobPrefab.List[jobIndex];
assignedClientCount[c.AssignedJob]++;
}
else //some jobs still left, choose one of them by random
@@ -2117,6 +2126,7 @@ namespace Barotrauma.Networking
Client preferredClient = null;
foreach (Client c in clients)
{
if (c.Karma < job.MinKarma) continue;
int index = c.JobPreferences.IndexOf(job);
if (index == -1) index = 1000;