/**
   * Check for accident in laboratory.
   *
   * @param time the amount of time researching (in millisols)
   */
  private void checkForAccident(double time) {

    double chance = .001D;

    // Science skill modification.
    SkillType scienceSkill = science.getSkill();
    int skill = person.getMind().getSkillManager().getEffectiveSkillLevel(scienceSkill);
    if (skill <= 3) {
      chance *= (4 - skill);
    } else {
      chance /= (skill - 2);
    }

    Malfunctionable entity = null;
    if (lab instanceof Research) {
      entity = ((Research) lab).getBuilding();
    } else {
      entity = person.getVehicle();
    }

    if (entity != null) {

      // Modify based on the entity's wear condition.
      chance *= entity.getMalfunctionManager().getWearConditionAccidentModifier();

      if (RandomUtil.lessThanRandPercent(chance * time)) {
        logger.info(person.getName() + " has a lab accident while doing " + science + " research.");
        entity.getMalfunctionManager().accident();
      }
    }
  }
Esempio n. 2
0
  public DeathInfo(Robot robot) {

    // Initialize data members
    timeOfDeath = Simulation.instance().getMasterClock().getMarsClock().getDateTimeStamp();
    /*
            Complaint serious = person.getPhysicalCondition().getMostSerious();
            if (serious != null) illness = serious.getName();

            if (person.getLocationSituation() == LocationSituation.OUTSIDE) placeOfDeath = "Outside";
            else {
                containerUnit = person.getContainerUnit();
                placeOfDeath = containerUnit.getName();
            }

            locationOfDeath = person.getCoordinates();
    */
    BotMind botMind = robot.getBotMind();

    robotJob = botMind.getRobotJob();
    /*
            if (mind.getMission() != null) {
                mission = mind.getMission().getName();
                missionPhase = mind.getMission().getPhaseDescription();
            }
    */
    TaskManager taskMgr = botMind.getTaskManager();
    if (taskMgr.hasTask()) {
      task = taskMgr.getTaskName();
      TaskPhase phase = taskMgr.getPhase();
      if (phase != null) {
        taskPhase = phase.getName();
      } else {
        taskPhase = "";
      }
    }

    Iterator<Malfunctionable> i = MalfunctionFactory.getMalfunctionables(robot).iterator();
    Malfunction mostSerious = null;
    int severity = 0;
    while (i.hasNext()) {
      Malfunctionable entity = i.next();
      MalfunctionManager malfunctionMgr = entity.getMalfunctionManager();
      if (malfunctionMgr.hasEmergencyMalfunction()) {
        Malfunction m = malfunctionMgr.getMostSeriousEmergencyMalfunction();
        if (m.getSeverity() > severity) {
          mostSerious = m;
          severity = m.getSeverity();
        }
      }
    }
    if (mostSerious != null) malfunction = mostSerious.getName();

    this.robotType = robot.getRobotType();
  }