v2.0.0: cleaned up code references to equipped wep vs. attacking wep
This fixes a bug with twin upgrades and primary weapon crossbow
This commit is contained in:
@@ -329,7 +329,7 @@ public abstract class Char extends Actor {
|
||||
|
||||
if (this instanceof Hero){
|
||||
Hero h = (Hero)this;
|
||||
if (h.belongings.weapon() instanceof MissileWeapon
|
||||
if (h.belongings.attackingWeapon() instanceof MissileWeapon
|
||||
&& h.subClass == HeroSubClass.SNIPER
|
||||
&& !Dungeon.level.adjacent(h.pos, enemy.pos)){
|
||||
dr = 0;
|
||||
|
||||
@@ -94,11 +94,14 @@ public class Belongings implements Iterable<Item> {
|
||||
// we still want to access the raw equipped items in cases where effects should be ignored though,
|
||||
// such as when equipping something, showing an interface, or dealing with items from a dead hero
|
||||
|
||||
public KindOfWeapon weapon(){
|
||||
//no point in lost invent check, if it's assigned it must be usable
|
||||
//normally the primary equipped weapon, but can also be a thrown weapon or an ability's weapon
|
||||
public KindOfWeapon attackingWeapon(){
|
||||
if (thrownWeapon != null) return thrownWeapon;
|
||||
if (abilityWeapon != null) return abilityWeapon;
|
||||
return weapon();
|
||||
}
|
||||
|
||||
public KindOfWeapon weapon(){
|
||||
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
|
||||
if (!lostInvent || (weapon != null && weapon.keptThoughLostInvent)){
|
||||
return weapon;
|
||||
|
||||
@@ -401,7 +401,7 @@ public class Hero extends Char {
|
||||
@Override
|
||||
public void hitSound(float pitch) {
|
||||
if (!RingOfForce.fightingUnarmed(this)) {
|
||||
belongings.weapon().hitSound(pitch);
|
||||
belongings.attackingWeapon().hitSound(pitch);
|
||||
} else if (RingOfForce.getBuffedBonus(this, RingOfForce.Force.class) > 0) {
|
||||
//pitch deepens by 2.5% (additive) per point of strength, down to 75%
|
||||
super.hitSound( pitch * GameMath.gate( 0.75f, 1.25f - 0.025f*STR(), 1f) );
|
||||
@@ -464,7 +464,7 @@ public class Hero extends Char {
|
||||
|
||||
@Override
|
||||
public int attackSkill( Char target ) {
|
||||
KindOfWeapon wep = belongings.weapon();
|
||||
KindOfWeapon wep = belongings.attackingWeapon();
|
||||
|
||||
float accuracy = 1;
|
||||
accuracy *= RingOfAccuracy.accuracyMultiplier( this );
|
||||
@@ -577,7 +577,7 @@ public class Hero extends Char {
|
||||
|
||||
@Override
|
||||
public int damageRoll() {
|
||||
KindOfWeapon wep = belongings.weapon();
|
||||
KindOfWeapon wep = belongings.attackingWeapon();
|
||||
int dmg;
|
||||
|
||||
if (!RingOfForce.fightingUnarmed(this)) {
|
||||
@@ -597,7 +597,7 @@ public class Hero extends Char {
|
||||
} else {
|
||||
dmg = RingOfForce.damageRoll(this);
|
||||
if (RingOfForce.unarmedGetsWeaponEffects(this)){
|
||||
dmg = ((Weapon)belongings.weapon()).augment.damageFactor(dmg);
|
||||
dmg = ((Weapon)belongings.attackingWeapon()).augment.damageFactor(dmg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,10 +653,11 @@ public class Hero extends Char {
|
||||
|
||||
@Override
|
||||
public boolean canSurpriseAttack(){
|
||||
if (belongings.weapon() == null || !(belongings.weapon() instanceof Weapon)) return true;
|
||||
if (RingOfForce.fightingUnarmed(this)) return true;
|
||||
if (STR() < ((Weapon)belongings.weapon()).STRReq()) return false;
|
||||
if (belongings.weapon() instanceof Flail) return false;
|
||||
KindOfWeapon w = belongings.attackingWeapon();
|
||||
if (!(w instanceof Weapon)) return true;
|
||||
if (RingOfForce.fightingUnarmed(this)) return true;
|
||||
if (STR() < ((Weapon)w).STRReq()) return false;
|
||||
if (w instanceof Flail) return false;
|
||||
|
||||
return super.canSurpriseAttack();
|
||||
}
|
||||
@@ -671,7 +672,7 @@ public class Hero extends Char {
|
||||
return true;
|
||||
}
|
||||
|
||||
KindOfWeapon wep = Dungeon.hero.belongings.weapon();
|
||||
KindOfWeapon wep = Dungeon.hero.belongings.attackingWeapon();
|
||||
|
||||
if (wep != null){
|
||||
return wep.canReach(this, enemy.pos);
|
||||
@@ -694,7 +695,7 @@ public class Hero extends Char {
|
||||
|
||||
if (!RingOfForce.fightingUnarmed(this)) {
|
||||
|
||||
return delay * belongings.weapon().delayFactor( this );
|
||||
return delay * belongings.attackingWeapon().delayFactor( this );
|
||||
|
||||
} else {
|
||||
//Normally putting furor speed on unarmed attacks would be unnecessary
|
||||
@@ -1265,7 +1266,7 @@ public class Hero extends Char {
|
||||
damage = super.attackProc( enemy, damage );
|
||||
|
||||
//procs with weapon even in brawler's stance
|
||||
KindOfWeapon wep = belongings.weapon();
|
||||
KindOfWeapon wep = belongings.attackingWeapon();
|
||||
|
||||
if (wep != null) damage = wep.proc( this, enemy, damage );
|
||||
|
||||
|
||||
@@ -609,7 +609,7 @@ public enum Talent {
|
||||
}
|
||||
|
||||
if (hero.hasTalent(Talent.FOLLOWUP_STRIKE)) {
|
||||
if (hero.belongings.weapon() instanceof MissileWeapon) {
|
||||
if (hero.belongings.attackingWeapon() instanceof MissileWeapon) {
|
||||
Buff.affect(enemy, FollowupStrikeTracker.class);
|
||||
} else if (enemy.buff(FollowupStrikeTracker.class) != null){
|
||||
dmg += 1 + hero.pointsInTalent(FOLLOWUP_STRIKE);
|
||||
@@ -638,7 +638,7 @@ public enum Talent {
|
||||
}
|
||||
|
||||
if (hero.hasTalent(DEADLY_FOLLOWUP)) {
|
||||
if (hero.belongings.weapon() instanceof MissileWeapon) {
|
||||
if (hero.belongings.attackingWeapon() instanceof MissileWeapon) {
|
||||
Buff.prolong(enemy, DeadlyFollowupTracker.class, 5f);
|
||||
} else if (enemy.buff(DeadlyFollowupTracker.class) != null){
|
||||
dmg = Math.round(dmg * (1.0f + .08f*hero.pointsInTalent(DEADLY_FOLLOWUP)));
|
||||
|
||||
@@ -620,7 +620,7 @@ public abstract class Mob extends Char {
|
||||
public int defenseProc( Char enemy, int damage ) {
|
||||
|
||||
if (enemy instanceof Hero
|
||||
&& ((Hero) enemy).belongings.weapon() instanceof MissileWeapon){
|
||||
&& ((Hero) enemy).belongings.attackingWeapon() instanceof MissileWeapon){
|
||||
Statistics.thrownAttacks++;
|
||||
Badges.validateHuntressUnlock();
|
||||
}
|
||||
@@ -630,8 +630,8 @@ public abstract class Mob extends Char {
|
||||
Badges.validateRogueUnlock();
|
||||
//TODO this is somewhat messy, it would be nicer to not have to manually handle delays here
|
||||
// playing the strong hit sound might work best as another property of weapon?
|
||||
if (Dungeon.hero.belongings.weapon() instanceof SpiritBow.SpiritArrow
|
||||
|| Dungeon.hero.belongings.weapon() instanceof Dart){
|
||||
if (Dungeon.hero.belongings.attackingWeapon() instanceof SpiritBow.SpiritArrow
|
||||
|| Dungeon.hero.belongings.attackingWeapon() instanceof Dart){
|
||||
Sample.INSTANCE.playDelayed(Assets.Sounds.HIT_STRONG, 0.125f);
|
||||
} else {
|
||||
Sample.INSTANCE.play(Assets.Sounds.HIT_STRONG);
|
||||
|
||||
@@ -195,7 +195,7 @@ public class RingOfForce extends Ring {
|
||||
}
|
||||
|
||||
public static boolean fightingUnarmed( Hero hero ){
|
||||
if (hero.belongings.weapon() == null){
|
||||
if (hero.belongings.attackingWeapon() == null){
|
||||
return true;
|
||||
}
|
||||
if (hero.belongings.thrownWeapon != null || hero.belongings.abilityWeapon != null){
|
||||
@@ -216,7 +216,7 @@ public class RingOfForce extends Ring {
|
||||
}
|
||||
|
||||
public static boolean unarmedGetsWeaponEffects( Hero hero ){
|
||||
if (hero.belongings.weapon() == null){
|
||||
if (hero.belongings.attackingWeapon() == null){
|
||||
return false;
|
||||
}
|
||||
BrawlersStance stance = hero.buff(BrawlersStance.class);
|
||||
|
||||
@@ -251,13 +251,8 @@ public class MeleeWeapon extends Weapon {
|
||||
public int buffedLvl() {
|
||||
if (!evaluatingTwinUpgrades && isEquipped(Dungeon.hero) && Dungeon.hero.hasTalent(Talent.TWIN_UPGRADES)){
|
||||
KindOfWeapon other = null;
|
||||
if (Dungeon.hero.belongings.weapon != this) other = Dungeon.hero.belongings.weapon;
|
||||
if (Dungeon.hero.belongings.secondWep != this) other = Dungeon.hero.belongings.secondWep;
|
||||
|
||||
//need to manually check for lost inventory here
|
||||
if (other instanceof MeleeWeapon && Dungeon.hero.buff(LostInventory.class) != null && !other.keptThoughLostInvent){
|
||||
other = null;
|
||||
}
|
||||
if (Dungeon.hero.belongings.weapon() != this) other = Dungeon.hero.belongings.weapon();
|
||||
if (Dungeon.hero.belongings.secondWep() != this) other = Dungeon.hero.belongings.secondWep();
|
||||
|
||||
if (other instanceof MeleeWeapon) {
|
||||
evaluatingTwinUpgrades = true;
|
||||
|
||||
Reference in New Issue
Block a user