Package games.stendhal.server.core.rule.defaultruleset

Examples of games.stendhal.server.core.rule.defaultruleset.DefaultCreature


        logger.error("Corrupt XML file: Bad tileid for creature("
            + name + ")");
        return;
      }

      final DefaultCreature creature = new DefaultCreature(clazz, subclass,
          name, tileid);
      creature.setRPStats(hp, atk, def, speed);
      creature.setLevel(level, xp);
      creature.setSize(sizeWidth, sizeHeight);
      creature.setEquipedItems(equipsItems);
     
      creature.setCorpse(corpseName, corpseWidth, corpseHeight);
      corpseName = null;
      corpseWidth = corpseHeight = 1;
     
      creature.setDropItems(dropsItems);
      creature.setAIProfiles(aiProfiles);
      creature.setNoiseLines(creatureSays);
      creature.setRespawnTime(respawn);
      creature.setDescription(description);
      creature.setSusceptibilities(susceptibilities);
      creature.setDamageType(damageType);
      list.add(creature);
    } else if (qName.equals("attributes")) {
      attributes = false;
    } else if (qName.equals("equips")) {
      equips = false;
View Full Code Here


      filteredCreatures = xml.getCreatures();
    }

    creatureList.setModel(new javax.swing.AbstractListModel() {
      public Object getElementAt(int i) {
        DefaultCreature creature = filteredCreatures.get(i);
        return "(" + creature.getLevel() + ") "
            + creature.getCreatureName();
      }

      public int getSize() {
        return filteredCreatures.size();
      }
View Full Code Here

    if (pos < 0) {
      return;
    }

    DefaultCreature actual = (DefaultCreature) filteredCreatures.get(pos);

    if (actual.getCreatureName() == null) {
      return;
    }
    creatureName.setText(actual.getCreatureName());
    creatureClass.setSelectedItem(actual.getCreatureClass());
    creatureSubclass.setText(actual.getCreatureSubclass());
    creatureSize.setText((int) actual.getWidth() + ","
        + (int) actual.getHeight());
    creatureTileid.setText(actual.getTileId().replace(
        "../../tileset/logic/creature/", ""));
    String gfxLocation = "/" + actual.getCreatureClass() + "/"
        + actual.getCreatureSubclass() + ".png";
    Sprite spr = SpriteStore.get().getSprite(
        "stendhal/data/sprites/monsters" + gfxLocation);

    drawSinglePart(spr, actual.getWidth(), actual.getHeight(),
        creatureImage.getGraphics());
    creatureGFXLocation.setText(gfxLocation);
    creatureDescription.setText(actual.getDescription());

    creatureATK.setText(Integer.toString(actual.getAtk()));
    creatureDEF.setText(Integer.toString(actual.getDef()));
    creatureHP.setText(Integer.toString(actual.getHP()));
    creatureSpeed.setText(Double.toString(actual.getSpeed()));

    creatureLevel.setText(Integer.toString(actual.getLevel()));
    creatureXP.setText(Integer.toString(actual.getXP() / 20));
    creatureRespawn.setText(Integer.toString(actual.getRespawnTime()));

    SuggestAttributeButtonActionPerformed(null);

    StringBuilder os = new StringBuilder("");

    double value = 0;
    for (DropItem item : actual.getDropItems()) {
      os.append(item.name + "; [" + item.min + "," + item.max + "]; "
          + item.probability + "\n");
      value += (getItemValue(item.name) * (item.probability)
          * (item.max + item.min) / 2.0);
    }

    creatureValue.setText(Integer.toString((int) value));

    if (actual.getCreatureName() != null) {
      creatureDrops.setText(os.toString());
    }

    os = new StringBuilder("");
    for (EquipItem item : actual.getEquipedItems()) {
      os.append(item.name + "; " + item.slot + "; " + item.quantity
          + "\n");
    }

    if (actual.getCreatureName() != null) {
      creatureEquips.setText(os.toString());
    }

    os = new StringBuilder("");
   
    HashMap<String, LinkedList<String>> noises = actual.getNoiseLines();
    for (Map.Entry<String, LinkedList<String>> it : noises.entrySet()) {
      for (String line : it.getValue()) {
        os.append("says[" + it.getKey() + "]: " + line + "\n");
      }
    }

    Map<String, String> aiList = actual.getAIProfiles();
    for (Map.Entry<String, String> profile : aiList.entrySet()) {
      os.append(profile.getKey());
      if (profile.getValue() != null) {
        os.append(" = " + profile.getValue());
      }
      os.append("\n");
    }

    if (actual.getCreatureName() != null) {
      creatureAI.setText(os.toString());
    }
  }
View Full Code Here

      xml.creaturesChange();
      addButton.setEnabled(true);
      setButton.setForeground(Color.BLACK);

      int pos = creatureList.getSelectedIndex();
      DefaultCreature actual = (DefaultCreature) filteredCreatures.get(pos);

      actual.setCreatureName(creatureName.getText());
      actual.setCreatureClass((String) creatureClass.getSelectedItem());
      actual.setCreatureSubclass(creatureSubclass.getText());
      String[] sizes = creatureSize.getText().split(",");
      actual.setSize(Integer.parseInt(sizes[0]),
          Integer.parseInt(sizes[1]));
      actual.setTileId(creatureTileid.getText());

      actual.setLevel(Integer.parseInt(creatureLevel.getText()),
          Integer.parseInt(creatureXP.getText()) * 20);
      actual.setRespawnTime(Integer.parseInt(creatureRespawn.getText()));

      actual.setDescription(creatureDescription.getText());

      actual.setRPStats(Integer.parseInt(creatureHP.getText()),
          Integer.parseInt(creatureATK.getText()),
          Integer.parseInt(creatureDEF.getText()),
          Double.parseDouble(creatureSpeed.getText()));

      /* Drops */
      List<DropItem> dropList = new LinkedList<DropItem>();
      BufferedReader reader = new BufferedReader(new StringReader(
          creatureDrops.getText()));
      String line = reader.readLine();
      while (line != null) {
        String[] tok = line.split(";");
        String[] minmax = tok[1].replace("[", "").replace("]", "").split(
            ",");
        dropList.add(new DropItem(tok[0].trim(),
            Double.parseDouble(tok[2].trim()),
            Integer.parseInt(minmax[0].trim()),
            Integer.parseInt(minmax[1].trim())));
        line = reader.readLine();
      }
      actual.setDropItems(dropList);

      List<EquipItem> equipList = new LinkedList<EquipItem>();
      reader = new BufferedReader(new StringReader(
          creatureEquips.getText()));
      line = reader.readLine();
      while (line != null) {
        String[] tok = line.split(";");
        equipList.add(new EquipItem(tok[1].trim(), tok[0].trim(),
            Integer.parseInt(tok[2].trim())));
        line = reader.readLine();
      }
      actual.setEquipedItems(equipList);

      Map<String, String> profiles = new LinkedHashMap<String, String>();
      List<String> noises = new LinkedList<String>();

      reader = new BufferedReader(new StringReader(creatureAI.getText()));
      line = reader.readLine();
      while (line != null) {
        if (line.startsWith("says")) {
          noises.add(line.replace("says", "").replace(":", "").trim());
        } else {
          int i = line.indexOf("=");
          String key = null;
          String val = null;
          if (i != -1) {
            key = line.substring(0, i - 1).trim();
            val = line.substring(i + 1).trim();
          } else {
            key = line;
          }

          profiles.put(key, val);
        }

        line = reader.readLine();
      }
      actual.setAIProfiles(profiles);
      //actual.setNoiseLines(noises);

      xml.sortCreatures(filteredCreatures);
      xml.updateFrameContents();
      refresh();
View Full Code Here

      e.printStackTrace();
    }
  } // GEN-LAST:event_setButtonActionPerformed

  private void addButtonActionPerformed(java.awt.event.ActionEvent evt) { // GEN-FIRST:event_addButtonActionPerformed
    xml.getCreatures().add(new DefaultCreature(null, null, null, null));
    updateItemLists();
    updateCreatureList(null, filter.getText());
    creatureList.setSelectedIndex(filteredCreatures.size() - 1);
    creatureList.ensureIndexIsVisible(filteredCreatures.size() - 1);
    refresh();
View Full Code Here

            new NotCondition(new TriggerInListCondition(ConversationPhrases.GOODBYE_MESSAGES)),
            ConversationStates.ATTENDING, null,
            new ChatAction() {
          public void fire(final Player player, final Sentence sentence, final EventRaiser speakerNPC) {
            final String creatureName = sentence.getTriggerExpression().getNormalized();
            final DefaultCreature creature = SingletonRepository.getEntityManager().getDefaultCreature(creatureName);
            if (creature == null) {
              speakerNPC.say("I have never heard of such a creature! Please tell the name again.");
              speakerNPC.setCurrentState(ConversationStates.QUESTION_1);
            } else {
              stateInfo.setCreatureName(creatureName);
              if (INFORMATION_BASE_COST > 0) {
                final int informationCost = getCost(player, creature);
                stateInfo.setInformationCost(informationCost);
                speakerNPC.say("This information costs "
                    + informationCost
                    + ". Are you still interested?");
                speakerNPC.setCurrentState(ConversationStates.BUY_PRICE_OFFERED);
              } else {
                speakerNPC.say(getCreatureInfo(player,
                    stateInfo.getCreatureName())
                    + " If you want to hear about another creature, just tell me which.");
                speakerNPC.setCurrentState(ConversationStates.QUESTION_1);
              }
            }
          }

          private int getCost(final Player player, final DefaultCreature creature) {
            return (int) (INFORMATION_BASE_COST + INFORMATION_COST_LEVEL_FACTOR
                * creature.getLevel());
          }
        });

        add(ConversationStates.BUY_PRICE_OFFERED,
            ConversationPhrases.YES_MESSAGES, null,
View Full Code Here

    zone.add(npc)
  }

  private static String getCreatureInfo(final Player player, final String creatureName) {
    String result;
    final DefaultCreature creature = SingletonRepository.getEntityManager().getDefaultCreature(creatureName);
    if (creature != null) {
      result = creatureInfo.getCreatureInfo(player, creature, 3, 8, true);
    } else {
      result = "I have never heard of such a creature!";
    }
View Full Code Here

TOP

Related Classes of games.stendhal.server.core.rule.defaultruleset.DefaultCreature

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.