void Breakdown(Vessel v, ProtoCrewMember c)
  {
    // constants
    const double food_penality = 0.2;        // proportion of food lost on 'depressed'
    const double oxygen_penality = 0.2;      // proportion of oxygen lost on 'wrong_valve'

    // get info
    double food_amount = Lib.GetResourceAmount(v, "Food");
    double oxygen_amount = Lib.GetResourceAmount(v, "Oxygen");

    // compile list of events with condition satisfied
    List<KerbalBreakdown> events = new List<KerbalBreakdown>();
    events.Add(KerbalBreakdown.mumbling); //< do nothing, here so there is always something that can happen
    if (Lib.CrewCount(v) > 1) events.Add(KerbalBreakdown.argument); //< do nothing, add some variation to messages
    if (Lib.HasData(v)) events.Add(KerbalBreakdown.fat_finger);
    if (Malfunction.CanMalfunction(v)) events.Add(KerbalBreakdown.rage);
    if (food_amount > double.Epsilon) events.Add(KerbalBreakdown.depressed);
    if (oxygen_amount > double.Epsilon) events.Add(KerbalBreakdown.wrong_valve);

    // choose a breakdown event
    KerbalBreakdown breakdown = events[Lib.RandomInt(events.Count)];

    // post message first so this one is shown before malfunction message
    Message.Post(Severity.breakdown, KerbalEvent.stress, v, c, breakdown);

    // trigger the event
    switch(breakdown)
    {
      case KerbalBreakdown.mumbling: break; // do nothing
      case KerbalBreakdown.argument: break; // do nothing
      case KerbalBreakdown.fat_finger: Lib.RemoveData(v); break;
      case KerbalBreakdown.rage: Malfunction.CauseMalfunction(v); break;
      case KerbalBreakdown.depressed: Lib.RequestResource(v, "Food", food_amount * food_penality); break;
      case KerbalBreakdown.wrong_valve: Lib.RequestResource(v, "Oxygen", oxygen_amount * oxygen_penality); break;
    }
  }
Exemple #2
0
        // trigger a random breakdown event
        public static void Breakdown(Vessel v, ProtoCrewMember c)
        {
            // constants
            const double res_penalty = 0.1; // proportion of food lost on 'depressed' and 'wrong_valve'

            // get info
            Rule          supply = supply_rules.Count > 0 ? supply_rules[Lib.RandomInt(supply_rules.Count)] : null;
            resource_info res    = supply != null?ResourceCache.Info(v, supply.resource_name) : null;

            // compile list of events with condition satisfied
            List <KerbalBreakdown> events = new List <KerbalBreakdown>();

            events.Add(KerbalBreakdown.mumbling); //< do nothing, here so there is always something that can happen
            if (Lib.CrewCount(v) > 1)
            {
                events.Add(KerbalBreakdown.argument);               //< do nothing, add some variation to messages
            }
            if (Lib.HasData(v))
            {
                events.Add(KerbalBreakdown.fat_finger);
            }
            if (Reliability.CanMalfunction(v))
            {
                events.Add(KerbalBreakdown.rage);
            }
            if (supply != null && res.amount > double.Epsilon)
            {
                events.Add(KerbalBreakdown.depressed);
                events.Add(KerbalBreakdown.wrong_valve);
            }

            // choose a breakdown event
            KerbalBreakdown breakdown = events[Lib.RandomInt(events.Count)];

            // generate message
            string text    = "";
            string subtext = "";

            switch (breakdown)
            {
            case KerbalBreakdown.mumbling:    text = "$ON_VESSEL$KERBAL has been in space for too long"; subtext = "Mumbling incoherently"; break;

            case KerbalBreakdown.argument:    text = "$ON_VESSEL$KERBAL had an argument with the rest of the crew"; subtext = "Morale is degenerating at an alarming rate"; break;

            case KerbalBreakdown.fat_finger:  text = "$ON_VESSEL$KERBAL is pressing buttons at random on the control panel"; subtext = "Science data has been lost"; break;

            case KerbalBreakdown.rage:        text = "$ON_VESSEL$KERBAL is possessed by a blind rage"; subtext = "A component has been damaged"; break;

            case KerbalBreakdown.depressed:   text = "$ON_VESSEL$KERBAL is not respecting the rationing guidelines"; subtext = supply.resource_name + " has been lost"; break;

            case KerbalBreakdown.wrong_valve: text = "$ON_VESSEL$KERBAL opened the wrong valve"; subtext = supply.resource_name + " has been lost"; break;
            }

            // post message first so this one is shown before malfunction message
            Message.Post(Severity.breakdown, Lib.ExpandMsg(text, v, c), subtext);

            // trigger the event
            switch (breakdown)
            {
            case KerbalBreakdown.mumbling: break; // do nothing

            case KerbalBreakdown.argument: break; // do nothing

            case KerbalBreakdown.fat_finger: Lib.RemoveData(v); break;

            case KerbalBreakdown.rage: Reliability.CauseMalfunction(v); break;

            case KerbalBreakdown.depressed:
            case KerbalBreakdown.wrong_valve: res.Consume(res.amount * res_penalty); break;
            }

            // remove reputation
            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                Reputation.Instance.AddReputation(-Settings.BreakdownReputationPenalty, TransactionReasons.Any);
            }
        }
Exemple #3
0
        // trigger a random breakdown event
        public static void Breakdown(Vessel v, ProtoCrewMember c)
        {
            // constants
            const double res_penalty = 0.1;                    // proportion of food lost on 'depressed' and 'wrong_valve'

            // get a supply resource at random
            Resource_info res = null;

            if (Profile.supplies.Count > 0)
            {
                Supply supply = Profile.supplies[Lib.RandomInt(Profile.supplies.Count)];
                res = ResourceCache.Info(v, supply.resource);
            }

            // compile list of events with condition satisfied
            List <KerbalBreakdown> events = new List <KerbalBreakdown>
            {
                KerbalBreakdown.mumbling                 //< do nothing, here so there is always something that can happen
            };

            if (Lib.HasData(v))
            {
                events.Add(KerbalBreakdown.fat_finger);
            }
            if (Reliability.CanMalfunction(v))
            {
                events.Add(KerbalBreakdown.rage);
            }
            if (res != null && res.amount > double.Epsilon)
            {
                events.Add(KerbalBreakdown.wrong_valve);
            }

            // choose a breakdown event
            KerbalBreakdown breakdown = events[Lib.RandomInt(events.Count)];

            // generate message
            string text    = "";
            string subtext = "";

            switch (breakdown)
            {
            case KerbalBreakdown.mumbling:
                text    = "$ON_VESSEL$KERBAL has been in space for too long";
                subtext = "Mumbling incoherently";
                break;

            case KerbalBreakdown.fat_finger:
                text    = "$ON_VESSEL$KERBAL is pressing buttons at random on the control panel";
                subtext = "Science data has been lost";
                break;

            case KerbalBreakdown.rage:
                text    = "$ON_VESSEL$KERBAL is possessed by a blind rage";
                subtext = "A component has been damaged";
                break;

            case KerbalBreakdown.wrong_valve:
                text    = "$ON_VESSEL$KERBAL opened the wrong valve";
                subtext = res.resource_name + " has been lost";
                break;
            }

            // post message first so this one is shown before malfunction message
            Message.Post(Severity.breakdown, Lib.ExpandMsg(text, v, c), subtext);

            // trigger the event
            switch (breakdown)
            {
            case KerbalBreakdown.mumbling:
                break;                         // do nothing

            case KerbalBreakdown.fat_finger:
                Lib.RemoveData(v);
                break;

            case KerbalBreakdown.rage:
                Reliability.CauseMalfunction(v);
                break;

            case KerbalBreakdown.wrong_valve:
                res.Consume(res.amount * res_penalty);
                break;
            }

            // remove reputation
            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                Reputation.Instance.AddReputation(-PreferencesBasic.Instance.breakdownPenalty, TransactionReasons.Any);
            }
        }
Exemple #4
0
  // add a message related to a kerbal
  public static void Post(Severity severity, KerbalEvent e, Vessel v, ProtoCrewMember c, KerbalBreakdown breakdown = KerbalBreakdown.mumbling)
  {
    string pretext = (!v.isActiveVessel ? ("On " + (v.isEVA ? "EVA" : v.vesselName) + ", ") : "") + "<color=#ffffff>" + c.name + "</color> ";
    string text = "";
    string subtext = "";

    switch(e)
    {
      // climate (cold)
      case KerbalEvent.climate_low:

        switch(severity)
        {
          case Severity.relax:      text = "hypothermia is under control"; break;
          case Severity.warning:    text = "feels cold"; break;
          case Severity.danger:     text = "is freezing to death"; break;
          case Severity.fatality:   text = "freezed to death"; break;
        }
        break;

      // climate (hot)
      case KerbalEvent.climate_high:

        switch(severity)
        {
          case Severity.relax:      text = "is hugging the climatizer"; break;
          case Severity.warning:    text = "is sweating"; break;
          case Severity.danger:     text = "is burning alive"; break;
          case Severity.fatality:   text = "burned alive"; break;
        }
        break;

      // food
      case KerbalEvent.food:

        switch(severity)
        {
          case Severity.relax:      text = "has got a mouthful of snacks now"; break;
          case Severity.warning:    text = "is hungry"; break;
          case Severity.danger:     text = "is starving"; break;
          case Severity.fatality:   text = "starved to death"; break;
        }
        break;

      // oxygen
      case KerbalEvent.oxygen:

        switch(severity)
        {
          case Severity.relax:      text = "is breathing again"; break;
          case Severity.warning:    text = "can't breath"; break;
          case Severity.danger:     text = "is suffocating"; break;
          case Severity.fatality:   text = "suffocated to death"; break;
        }
        break;

      // radiation
      case KerbalEvent.radiation:

        switch(severity)
        {
          // note: no recovery from radiation
          case Severity.warning:    text = "has been exposed to intense radiation"; break;
          case Severity.danger:     text = "is reporting symptoms of radiation poisoning"; break;
          case Severity.fatality:   text = "died after being exposed to extreme radiation"; break;
        }
        break;

      // quality-of-life
      case KerbalEvent.stress:

        switch(severity)
        {
          // note: no recovery from stress
          case Severity.warning:    text = "is losing $HIS_HER mind"; subtext = "Concentration is becoming a problem"; break;
          case Severity.danger:     text = "is about to breakdown"; subtext = "Starting to hear voices"; break;
          case Severity.breakdown:
            switch(breakdown)
            {
              case KerbalBreakdown.mumbling:      text = "has been in space for too long"; subtext = "Mumbling incoherently"; break;
              case KerbalBreakdown.argument:      text = "had an argument with the rest of the crew"; subtext = "Morale is degenerating at an alarming rate"; break;
              case KerbalBreakdown.fat_finger:    text = "is pressing buttons at random on the control panel"; subtext = "Science data has been lost"; break;
              case KerbalBreakdown.rage:          text = "is possessed by a blind rage"; subtext = "A component has been damaged"; break;
              case KerbalBreakdown.depressed:     text = "is not respecting the rationing guidelines"; subtext = "Food has been lost"; break;
              case KerbalBreakdown.wrong_valve:   text = "opened the wrong valve"; subtext = "Oxygen has been lost"; break;
            }
            break;
        }
        break;
    }

    text = text.Replace("$HIS_HER", c.gender == ProtoCrewMember.Gender.Male ? "his" : "her");
    text = text.Replace("$HIM_HER", c.gender == ProtoCrewMember.Gender.Male ? "him" : "her");

    Post(severity, pretext + text, subtext);
  }