예제 #1
0
파일: Hero.java 프로젝트: Nekrofage/tyrant
 public static String hungerString(Thing h) {
   int threshold = h.getStat(RPG.ST_HUNGERTHRESHOLD);
   int hp = (threshold > 0) ? (h.getStat(RPG.ST_HUNGER) * 100) / threshold : 0;
   if (hp < -50) return "bloated";
   if (hp < 0) return "satiated";
   if (hp < 20) return "well fed";
   if (hp < 70) return "contented";
   if (hp < 100) return "peckish";
   if (hp < 150) return "hungry";
   if (hp < 200) return "very hungry";
   if (hp < 250) return "ravenous";
   if (hp < 300) return "starving";
   return "starving!";
 }
예제 #2
0
파일: Hero.java 프로젝트: Nekrofage/tyrant
  public static int gainKillExperience(Thing h, Thing t) {
    int hlevel = h.getLevel();
    int tlevel = t.getLevel();

    int killcount = 0;
    if (h.isHero()) {
      killcount = incKillCount(t);
      if (killcount == 1) {
        Score.scoreFirstKill(t);
      }
    }

    int base = t.getStat("XPValue");
    double xp = base;
    xp = xp * Math.pow(experienceDecay, killcount);
    xp = xp * Math.pow(experienceLevelMultiplier, tlevel - 1);

    // decrease xp gain for killing lower level monsters
    if (hlevel > tlevel) xp = xp / (hlevel - tlevel);

    int gain = (int) xp;

    Hero.gainExperience(gain);
    return gain;
  }
예제 #3
0
    public boolean handle(Thing t, Event e) {
      int time = e.getStat("Time");

      // set actor
      Game.actor = t;

      // Game.warn("**poison action**");
      Thing h = t.holder();

      int dam = 0;
      int hits = RPG.po(time * t.getStat("Strength"), 1000000);
      for (int i = 0; i < hits; i++) {
        dam += Damage.inflict(h, t.getStat("Damage"), t.getString("DamageType"));
        // Game.warn("**poison damage**");
      }
      if (dam > 0) h.message(t.getString("DamageMessage"));

      // might be other effects....
      return false;
    }
예제 #4
0
파일: Hero.java 프로젝트: Nekrofage/tyrant
  public static Thing createHero(String name, String race, String profession) {

    Thing h = createBaseHero(race);
    Game.instance().initialize(h);

    if ((name == null) || (name.equals(""))) name = "Tester";
    setHeroName(h, name);

    // Debug mode modifications
    if (Game.isDebug()) {
      addDebugModifications(h);
    }

    // Race Modifications
    applyRace(h, race);

    // Professions
    applyProfession(h, profession);

    // Bonus items based on skills
    applyBonusItems(h);

    // set up HPS and MPS
    h.set(RPG.ST_HPSMAX, h.getBaseStat(RPG.ST_TG) + RPG.d(6));
    h.set(RPG.ST_MPSMAX, h.getBaseStat(RPG.ST_WP) + RPG.d(6));

    h.set(RPG.ST_HPS, h.getStat(RPG.ST_HPSMAX));
    h.set(RPG.ST_MPS, h.getStat(RPG.ST_MPSMAX));

    Being.utiliseItems(h);

    Wish.makeWish("id", 100);

    // score starts at zero
    h.set("Score", 0);

    // religion
    ArrayList gods = Gods.getPossibleGods(h);
    int gl = gods.size();
    if (gl > 0) {
      h.set("Religion", gods.get(RPG.r(gl)));
    } else {
      Game.warn("No religion available for " + race + " " + profession);
    }

    createHeroHistory(h);

    // performance improvement with flattened properties
    h.flattenProperties();

    return h;
  }
예제 #5
0
파일: Hero.java 프로젝트: Nekrofage/tyrant
  /**
   * This function awards some bonus items based on the hero's professional skills.
   *
   * @param h
   */
  private static void applyBonusItems(Thing h) {
    if (h.getFlag(Skill.PRAYER)) {
      Thing t = Lib.create("potion of holy water");
      t.set("Number", h.getStat(Skill.PRAYER));
      h.addThingWithStacking(t);
    }

    if (h.getFlag(Skill.TRADING)) {
      Thing t = Lib.create("sovereign");
      t.set("Number", h.getStat(Skill.TRADING));
      h.addThingWithStacking(t);
    }

    if (h.getFlag(Skill.WEAPONLORE)) {
      Thing t = Lib.createType("IsWeapon", RPG.d(2, 6));
      h.addThingWithStacking(t);
    }

    if (h.getFlag(Skill.COOKING)) {
      Thing t = Lib.createType("IsFood", 25);
      t.set("Number", h.getStat(Skill.COOKING));
      h.addThingWithStacking(t);
    }

    if (h.getFlag(Skill.ARCHERY)) {
      //			 a reanged weapon + ammo
      Thing t = Lib.createType("IsRangedWeapon", RPG.d(h.getStat(Skill.ARCHERY), 6));
      Thing ms = RangedWeapon.createAmmo(t, RPG.d(h.getStat(Skill.ARCHERY), 6));
      h.addThing(t);
      h.addThing(ms);
    }

    Thing[] ws = h.getFlaggedContents("IsWeapon");
    if (ws.length == 0) {
      h.addThing(Lib.createType("IsWeapon", 1));
    }
  }
예제 #6
0
파일: Hero.java 프로젝트: Nekrofage/tyrant
  // can't do anything in monster action phase
  // but allow for hunger effects
  public static void action(Thing h, int t) {
    // hunger
    int hunger = h.getStat(RPG.ST_HUNGER);
    int hungerThreshold = h.getStat("HungerThreshold");
    hunger = RPG.min(hungerThreshold * 3, hunger + (t * 6) / (6 + h.getStat(Skill.SURVIVAL)));
    h.set(RPG.ST_HUNGER, hunger);

    // bad things
    int hl = hunger / hungerThreshold;
    switch (hl) {
      case 0:
      case 1:
        // OK
        break;
      case 2:
        for (int i = RPG.po(t, 10000); i > 0; i--) {
          Game.message("You feel weak with hunger!");
          String stat = RPG.pick(hungerDecayStats);
          int sv = h.getBaseStat(stat);
          if (!h.getFlag("IsImmortal")) h.set(stat, RPG.max(sv - 1, 1));
        }
        break;
      case 3:
        // dying of hunger
        int loss = RPG.po(t / 1000.0);
        if (loss > 0) Game.message("You are dying of hunger!!");
        if (!h.getFlag("IsImmortal")) h.incStat("HPSMAX", -loss);
        if (!h.getFlag("IsImmortal")) h.incStat("HPS", -loss * 2);
        break;
    }

    // SPECIAL ABILITIES
    // thief searches
    for (int i = RPG.po(t * h.getStat(Skill.ALERTNESS) * h.getStat(RPG.ST_CR), 10000); i > 0; i--) {
      Secret.search();
    }
  }
예제 #7
0
 public static void cure(Thing t, int power) {
   Thing[] poisons = t.getFlaggedContents("IsPoison");
   boolean cured = false;
   for (int i = 0; i < poisons.length; i++) {
     Thing p = poisons[i];
     Game.warn("Poison.cure(): " + power);
     if (RPG.test(power, poisons.length * p.getStat("CureDifficulty"))) {
       p.remove();
       cured = true;
     }
   }
   if (cured) {
     t.message("You feel refreshed");
   }
 }
예제 #8
0
파일: Hero.java 프로젝트: Nekrofage/tyrant
  public static void createHeroHistory(Thing h) {
    StringBuffer sb = new StringBuffer();

    ///////////////
    // Birth-day
    Calendar today = Calendar.getInstance();
    int day = today.get(Calendar.DAY_OF_MONTH);
    int month = today.get(Calendar.MONTH) + 1;
    String birthDay = (day) + "/" + (month);
    String dayString = Text.ordinal(day);
    String monthString = months[month];

    String r = h.getString("Race");
    sb.append(
        "You are born "
            + (Text.isVowel(r.charAt(0)) ? "an" : "a")
            + " "
            + r
            + " on the "
            + dayString
            + " of "
            + monthString
            + ". ");

    if (birthDay.equals("14/2")) {
      sb.append("Everyone agreed you were a charming baby. ");
      h.incStat("CH", RPG.d(6));
      h.incStat(Skill.SEDUCTION, 1);
    }

    if (birthDay.equals("1/1")) {
      sb.append("A bright star shone in the sky when you were born. ");
      h.incStat("WP", RPG.d(6));
    }

    sb.append("\n\n");

    //////////////////
    // childhood
    switch (RPG.d(7)) {
      case 1:
        sb.append("You had an unhappy childhood, finding it hard to relate to your peers.");
        h.incStat("WP", RPG.d(3));
        h.incStat("CH", -1);
        break;
      case 2:
        sb.append("You had a happy childhood, with supportive parents who taught you well.");
        h.incStat("IN", RPG.d(3));
        h.incStat("CH", -1);
        break;
      case 3:
        sb.append(
            "You were always getting into trouble as a child, but somehow everything seemed to work out for you. Wise elders were convinced that fortune favoured you. ");
        h.incStat("Luck", 5);
        break;
      case 4:
        sb.append(
            "You enjoyed playing outdoors as a child, and excelled in particular at sports. Your peers developed a healthy respect for your talents.");
        h.incStat(Skill.ATHLETICS, 1);
        h.incStat("CH", RPG.d(4));
        h.incStat("IN", -2);
        break;
      case 5:
        sb.append(
            "You were badly behaved as a child. You bullied smaller children relentlessly. You came to lead an impressive gang, though they followed you more out of fear than respect.");
        h.incStat("CH", -1);
        h.incStat("IN", -3);
        h.incStat("ST", 2);
        break;
      default:
        sb.append("You had an uneventful childhood, and yearned for adventure.");
        break;
    }
    sb.append("\n\n");

    /////////////
    // religion
    String god = h.getString("Religion");
    sb.append("You were brough up to worship " + god + ". ");
    switch (RPG.d(5)) {
      case 1:
        sb.append(
            "You avoided religious ceremonies, as you disliked your priest intensely. You even came to feel that he had laid a curse upon you. ");
        h.incStat("Luck", -4);
        break;
      case 2:
        sb.append(
            "You were extremely devout. It caused you great anguish because you never felt that "
                + god
                + " was truly close to you. ");
        h.incStat("WP", 1);
        h.incStat("CH", -1);

        break;
      case 3:
        sb.append(
            "You were extremely devout, and your priest praised you for having earnt the blessing of "
                + god
                + ". ");
        h.incStat("Luck", 4);
        h.incStat(RPG.ST_FATE, 1);
        break;
      default:
        sb.append(
            "You were not particularly devout, but still felt that "
                + god
                + " would protect you. ");
        break;
    }
    sb.append(Gods.get(god).getString("UpbringingText") + " ");
    sb.append("\n\n");

    ////////////////
    // growing up
    switch (RPG.d(5)) {
      case 1:
        sb.append(
            "As you grew up, you felt that you were destined for greatness. Everyone else thought that you were merely arrogant. ");
        h.incStat(RPG.ST_SKILLPOINTS, 1);
        h.incStat("CH", -3);
        break;
      case 2:
        sb.append(
            "As you grew up, you found yourself with the remarkable ability to learn creative skills. You had a tendency to dedicate too much time to creative pursuits at the expense of other activities. ");
        h.incStat(
            RPG.pick(new String[] {Skill.SMITHING, Skill.PAINTING, Skill.MUSIC, Skill.COOKING}), 1);
        h.incStat("ST", -1);
        h.incStat("IN", -1);
      case 3:
        sb.append(
            "Later in your youth, you fell hopelessly in love. Sadly, this was not returned. Heartbroken, you spent countless days wandering alone trying to fathom the meaning of life. ");
        h.incStat("CH", -1);
        h.incStat("ST", -1);
        h.incStat("IN", 2);
        h.incStat(Skill.PERCEPTION, 1);
        break;
      default:
        sb.append(
            "You grew up without any particularly great events shaping your life. But you still knew that one day you would set out to achieve greatness. ");
        break;
    }
    sb.append("\n\n");

    /////////////
    // training
    String p = h.getString("Profession");
    sb.append(
        "Determined to make something of your life, you began your "
            + p
            + " training as soon as you were old enough. ");
    switch (RPG.d(5)) {
      default:
        sb.append(
            "You showed a good aptitude for your chosen career, and before too long your tutor proclaimed you as a fully trained "
                + p
                + ".");
        break;
    }
    sb.append("\n\n");

    // ensure all stats are >=1
    String[] sks = Being.statNames();
    for (int i = 0; i < sks.length; i++) {
      if (h.getStat(sks[i]) <= 0) {
        h.set(sks[i], 1);
      }
    }

    h.set("HeroHistory", sb.toString());
  }
예제 #9
0
파일: Hero.java 프로젝트: Nekrofage/tyrant
 public static int getHunger(Thing t) {
   int hunger = t.getStat(RPG.ST_HUNGER);
   return (hunger >= t.getStat("HungerThreshold")) ? 1 : 0;
 }