package th; // Class for kinds of items (Not individual items, these are // Itm s.) // public class Kind { // Item uses public static final int NO_USE = 0; public static final int ESCAPE = 1; public static final int OFFENSE = 2; public static final int DEFENSE = 3; public static final int MISC = 4; // If false, monsters won't use this when it is wielded. public boolean using_does_not_destroy = true; public boolean fixed = false; // This sort of item can't be picked up. // public boolean pc_only = false; // Can only be touched by the player. public boolean drop_if_fleeing = false; // Drop if one is fleeing. Overrides non-dropping of pc-only items. // int veg_level = 0; // meaty death. public String tasty = "This tastes uninteresting."; public String name = null; // Name of the item // boolean deadly_weapon = false; public int damage = 0; // How much damage does this do when (ab)used as a weapon? public int heal = 0; // How much HP to you gain by eating it? // If 0, you can't eat it. public int to_hit = 0; // To hit bonus (%) when used as a weapon. // public int armor = 0; // Change the chances of getting a damaging hit. // // public int tainted_chance = 0; //Chance of being bad if eaten. // Special ability - when used. public int use = 0; Class special = null; public Itm make () { Itm tmp = new Itm(); tmp.kind = this; if (tainted_chance > Utl.rn(100)) tmp.tainted = true; // Time constraints being what they were, I did this rather // than rewrite quite a bit of code to incorporate things like // textbooks that are not all the same. // // Professor: I'm sorry if this is unacceptably arcane. // Anyway, it uses the reflection API... fun stuff. try { if (special != null) { tmp.special = (Special)special.newInstance(); } } catch (Exception e) { Ifc.msg("While making a " + name + ":"); e.printStackTrace(System.out); Ifc.msg(e.getMessage()); Ifc.you("feel like you should quit while you are ahead."); } // Slightly heavy wizardry ends here. return tmp; } }