示例#1
0
  private static void getQuestText(StringBuffer sb, String prefix, Thing q) {
    String desc = q.getString("Description");
    if (desc != null) {
      sb.append(prefix);
      sb.append(Text.capitalise(desc));
      if (q.getFlag("IsComplete")) {
        sb.append(" (complete)");
      }
      if (q.getFlag("IsFailed")) {
        sb.append(" (failed)");
      }
      sb.append("\n");

      ArrayList qs = getSubQuests(q);
      for (Iterator it = qs.iterator(); it.hasNext(); ) {
        Thing sq = (Thing) it.next();
        getQuestText(sb, prefix + " - ", sq);
      }
    }
  }
示例#2
0
  private static boolean notify(Event e) {
    ArrayList qs = getQuests();

    for (Iterator it = qs.iterator(); it.hasNext(); ) {
      Thing q = (Thing) it.next();

      if (q.getFlag("IsActive")) {
        q.handle(e);
      }
    }
    return false;
  }
示例#3
0
  /**
   * 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));
    }
  }
示例#4
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();
    }
  }
示例#5
0
  public static void setComplete(Thing q) {
    if (!q.getFlag("IsActive")) {
      throw new Error("Trying to complete a non-active quest");
    }
    q.set("IsComplete", 1);
    q.set("IsActive", 0);

    if (q.handles("OnQuestComplete")) {
      Event e = new Event("QuestComplete");
      e.set("Quest", q);
      q.handle(e);
    }

    Thing parent = q.getThing("Parent");
    if (parent != null) {
      Event e = new Event("SubQuestComplete");
      e.set("Quest", q);
      q.handle(e);
    }
  }