Beispiel #1
0
 public String getInfoString() {
   Attribute a = attacker.getAttribute(damageAttrib);
   Skill s = attacker.getSkills()[skill_n];
   String weapon = "";
   if (host != null) {
     weapon = host.getName();
     if (caliber != null) {
       Ammo ammo = host.getAmmo(caliber);
       String am = "(";
       if (ammo != null) am += "(" + ammo.getQty();
       else am += "0";
       am += "/" + host.getMaxAmmo(caliber) + ")";
       weapon += am + ":";
     }
   }
   String str = "[" + weapon + name + "] damage: ";
   int max_d = a.getValue() * damageAttribPart + getDamageFixedPart() + getDamageRandomPart();
   int min_d = 1 + getDamageFixedPart();
   double th = basicTohit + (float) s.getValue() / 50;
   String d = min_d + "-" + max_d;
   if (attacksNumber != 1 || getProjectiles() != 1) {
     d = "(" + d + ")";
     if (getProjectiles() != 1) d = getProjectiles() + d;
     if (attacksNumber != 1) d = attacksNumber + "x" + d;
   }
   str = str + d;
   str += "; tohit: ";
   NumberFormat nf = NumberFormat.getNumberInstance();
   nf.setMaximumFractionDigits(2);
   str = str + nf.format(th) + "; t: " + time + " s.";
   return str;
 }
Beispiel #2
0
 public String getShortInfoString() {
   String weapon = "";
   if (host != null) {
     weapon = host.getName();
     if (caliber != null) {
       Ammo ammo = host.getAmmo(caliber);
       String am = "(";
       if (ammo != null) am += "(" + ammo.getQty();
       else am += "0";
       am += "/" + host.getMaxAmmo(caliber) + ")";
       weapon += am + ":";
     }
   }
   String str = "[" + weapon + name + "]";
   return str;
 }
Beispiel #3
0
 public RangedAttack[] getShotRangedAttacks(Creature attacker) {
   int n = attacksNumber;
   int m = getProjectiles();
   if (caliber != null) {
     Ammo ammo = host.getAmmo(caliber);
     if (ammo != null) {
       if (ammo.getQty() < n * ammoPerShot) n = (int) Math.floor(ammo.getQty() / ammoPerShot);
       ammo.setQty(ammo.getQty() - n * ammoPerShot);
     } else n = 0;
   }
   RangedAttack[] ret = new RangedAttack[n * m];
   int actor_spread = 0;
   for (int i = 0; i < n; i++) {
     actor_spread = 0; // TODO: calculate creature-dependent spreading
     for (int j = 0; j < m; j++) {
       int d =
           1
               + (int)
                   Math.ceil(
                       Math.random()
                               * attacker.getAttributeValue(damageAttrib)
                               * getDamageAttribPart()
                           - 1)
               + (int) Math.ceil(Math.random() * getDamageRandomPart())
               + getDamageFixedPart();
       double th = basicTohit + (double) attacker.getSkills()[skill_n].getValue() / 50;
       ret[m * i + j] =
           new RangedAttack(
               attacker,
               d,
               damageFactor,
               getDamageType(),
               th,
               tohitFactor,
               this.range,
               this.tileEffect);
       ret[m * i + j].setAzimuth(
           Math.random() * getSpreading() - getSpreading() / 2 + actor_spread);
       ret[m * i + j].setAttackCounter(i * attacksDelay);
     }
   }
   return ret;
 }