Пример #1
0
  /*
   * Gives a number of experience points to the hero
   */
  public static void gainExperience(int x) {
    Thing h = Game.hero();
    // if (QuestApp.debug) Game.warn("You gain "+x+" experience points");
    int exp = h.getBaseStat(RPG.ST_EXP) + x;
    int level = h.getBaseStat(RPG.ST_LEVEL);

    int requiredForNextLevel = calcXPRequirement(level + 1);
    while (exp >= requiredForNextLevel) {
      if (level < 50) {
        Being.gainLevel(h);
        exp -= requiredForNextLevel;
        level++;
        requiredForNextLevel = calcXPRequirement(level + 1);
      } else {
        exp = requiredForNextLevel - 1;
      }
    }
    h.set(RPG.ST_EXP, exp);
  }
Пример #2
0
  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;
  }
Пример #3
0
  // 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();
    }
  }