v2.0.0: fixed champion 2nd wep ability using main weapon stats

This commit is contained in:
Evan Debenham
2023-01-05 17:18:16 -05:00
parent 7080f7e3fb
commit 5d32f70631
16 changed files with 46 additions and 17 deletions

View File

@@ -84,6 +84,9 @@ public class Belongings implements Iterable<Item> {
//used when thrown weapons temporary become the current weapon
public KindOfWeapon thrownWeapon = null;
//used to ensure that the duelist always uses the weapon she's using the ability of
public KindOfWeapon abilityWeapon = null;
//used by the champion subclass
public KindOfWeapon secondWep = null;
@@ -94,6 +97,7 @@ public class Belongings implements Iterable<Item> {
public KindOfWeapon weapon(){
//no point in lost invent check, if it's assigned it must be usable
if (thrownWeapon != null) return thrownWeapon;
if (abilityWeapon != null) return abilityWeapon;
boolean lostInvent = owner != null && owner.buff(LostInventory.class) != null;
if (!lostInvent || (weapon != null && weapon.keptThoughLostInvent)){

View File

@@ -201,7 +201,7 @@ public class Pickaxe extends MeleeWeapon {
|| enemy instanceof Scorpio) {
damageMulti = 2f;
}
onAbilityUsed(hero);
beforeAbilityUsed(hero);
if (hero.attack(enemy, damageMulti, 0, Char.INFINITE_ACCURACY)) {
if (enemy.isAlive()) {
Buff.affect(enemy, Vulnerable.class, 3f);
@@ -211,6 +211,7 @@ public class Pickaxe extends MeleeWeapon {
Sample.INSTANCE.play(Assets.Sounds.HIT_STRONG);
}
hero.spendAndNext(hero.attackDelay());
afterAbilityUsed(hero);
}
});
}

View File

@@ -110,7 +110,7 @@ public class Dagger extends MeleeWeapon {
return;
}
wep.onAbilityUsed(hero);
wep.beforeAbilityUsed(hero);
Buff.affect(hero, Invisibility.class, Math.max(1, 1/hero.speed()));
hero.spendAndNext(1/hero.speed());
@@ -124,6 +124,7 @@ public class Dagger extends MeleeWeapon {
Dungeon.hero.sprite.place( Dungeon.hero.pos );
CellEmitter.get( Dungeon.hero.pos ).burst( Speck.factory( Speck.WOOL ), 6 );
Sample.INSTANCE.play( Assets.Sounds.PUFF );
wep.afterAbilityUsed(hero);
}
}

View File

@@ -22,7 +22,6 @@
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
@@ -102,7 +101,7 @@ public class Flail extends MeleeWeapon {
@Override
protected void duelistAbility(Hero hero, Integer target) {
onAbilityUsed(hero);
beforeAbilityUsed(hero);
SpinAbilityTracker spin = hero.buff(SpinAbilityTracker.class);
if (spin == null){
@@ -119,6 +118,7 @@ public class Flail extends MeleeWeapon {
} else {
GLog.w(Messages.get(this, "spin_warn"));
}
afterAbilityUsed(hero);
}
public static class SpinAbilityTracker extends FlavourBuff {

View File

@@ -83,7 +83,7 @@ public class Greataxe extends MeleeWeapon {
hero.sprite.attack(enemy.pos, new Callback() {
@Override
public void call() {
onAbilityUsed(hero);
beforeAbilityUsed(hero);
if (hero.attack(enemy, 1.5f, 0, Char.INFINITE_ACCURACY)){
Sample.INSTANCE.play(Assets.Sounds.HIT_STRONG);
if (!enemy.isAlive()){
@@ -91,6 +91,7 @@ public class Greataxe extends MeleeWeapon {
}
}
hero.spendAndNext(hero.attackDelay());
afterAbilityUsed(hero);
}
});
}

View File

@@ -80,7 +80,7 @@ public class Mace extends MeleeWeapon {
hero.sprite.attack(enemy.pos, new Callback() {
@Override
public void call() {
wep.onAbilityUsed(hero);
wep.beforeAbilityUsed(hero);
if (hero.attack(enemy, dmgMulti, 0, 0.25f)) {
Sample.INSTANCE.play(Assets.Sounds.HIT_STRONG);
if (enemy.isAlive()){
@@ -90,6 +90,7 @@ public class Mace extends MeleeWeapon {
}
}
hero.spendAndNext(hero.attackDelay());
wep.afterAbilityUsed(hero);
}
});
}

View File

@@ -30,6 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Haste;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LockedFloor;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Recharging;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroClass;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass;
@@ -159,7 +160,8 @@ public class MeleeWeapon extends Weapon {
//TODO make abstract
protected void duelistAbility( Hero hero, Integer target ){}
protected void onAbilityUsed( Hero hero ){
protected void beforeAbilityUsed(Hero hero ){
hero.belongings.abilityWeapon = this;
Charger charger = Buff.affect(hero, Charger.class);
if (Dungeon.hero.belongings.weapon == this) {
@@ -185,6 +187,10 @@ public class MeleeWeapon extends Weapon {
updateQuickslot();
}
protected void afterAbilityUsed( Hero hero ){
hero.belongings.abilityWeapon = null;
}
protected void onAbilityKill( Hero hero ){
if (hero.hasTalent(Talent.LETHAL_HASTE)){
//effectively 1/2 turns of haste
@@ -436,11 +442,16 @@ public class MeleeWeapon extends Weapon {
public static final String CHARGES = "charges";
private static final String PARTIALCHARGE = "partialCharge";
public static final String SECOND_CHARGES = "second_charges";
private static final String SECOND_PARTIALCHARGE = "second_partialCharge";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put(CHARGES, charges);
bundle.put(PARTIALCHARGE, partialCharge);
bundle.put(SECOND_CHARGES, secondCharges);
bundle.put(SECOND_PARTIALCHARGE, secondPartialCharge);
}
@Override
@@ -448,6 +459,8 @@ public class MeleeWeapon extends Weapon {
super.restoreFromBundle(bundle);
charges = bundle.getInt(CHARGES);
partialCharge = bundle.getFloat(PARTIALCHARGE);
secondCharges = bundle.getInt(SECOND_CHARGES);
secondPartialCharge = bundle.getFloat(SECOND_PARTIALCHARGE);
}
@Override

View File

@@ -22,7 +22,6 @@
package com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
@@ -58,10 +57,11 @@ public class Quarterstaff extends MeleeWeapon {
@Override
protected void duelistAbility(Hero hero, Integer target) {
onAbilityUsed(hero);
beforeAbilityUsed(hero);
Buff.prolong(hero, DefensiveStance.class, 5f); //4 turns as using the ability is instant
hero.sprite.operate(hero.pos);
hero.next();
afterAbilityUsed(hero);
}
public static class DefensiveStance extends FlavourBuff {

View File

@@ -102,7 +102,7 @@ public class Rapier extends MeleeWeapon {
@Override
public void call() {
//+3+lvl damage, equivalent to +67% damage, but more consistent
onAbilityUsed(hero);
beforeAbilityUsed(hero);
if (hero.attack(enemy, 1f, augment.damageFactor(3 + level()), Char.INFINITE_ACCURACY)){
Sample.INSTANCE.play(Assets.Sounds.HIT_STRONG);
if (!enemy.isAlive()){
@@ -110,6 +110,7 @@ public class Rapier extends MeleeWeapon {
}
}
hero.spendAndNext(hero.attackDelay());
afterAbilityUsed(hero);
}
});
}

View File

@@ -67,10 +67,11 @@ public class RoundShield extends MeleeWeapon {
}
public static void guardAbility(Hero hero, int duration, MeleeWeapon wep){
wep.onAbilityUsed(hero);
wep.beforeAbilityUsed(hero);
Buff.prolong(hero, GuardTracker.class, duration);
hero.sprite.operate(hero.pos);
hero.spendAndNext(Actor.TICK);
wep.afterAbilityUsed(hero);
}
public static class GuardTracker extends FlavourBuff {

View File

@@ -81,7 +81,7 @@ public class RunicBlade extends MeleeWeapon {
hero.sprite.attack(enemy.pos, new Callback() {
@Override
public void call() {
onAbilityUsed(hero);
beforeAbilityUsed(hero);
if (hero.attack(enemy, 1f, 0, Char.INFINITE_ACCURACY)){
Sample.INSTANCE.play(Assets.Sounds.HIT_STRONG);
if (!enemy.isAlive()){
@@ -90,6 +90,7 @@ public class RunicBlade extends MeleeWeapon {
}
tracker.detach();
hero.spendAndNext(hero.attackDelay());
afterAbilityUsed(hero);
}
});
}

View File

@@ -82,7 +82,7 @@ public class Sai extends MeleeWeapon {
hero.sprite.attack(enemy.pos, new Callback() {
@Override
public void call() {
wep.onAbilityUsed(hero);
wep.beforeAbilityUsed(hero);
boolean hit = hero.attack(enemy, 1, 0, Char.INFINITE_ACCURACY);
if (hit && !enemy.isAlive()){
wep.onAbilityKill(hero);
@@ -105,6 +105,7 @@ public class Sai extends MeleeWeapon {
} else {
hero.spendAndNext(hero.attackDelay());
}
wep.afterAbilityUsed(hero);
}
});
}

View File

@@ -52,10 +52,11 @@ public class Scimitar extends MeleeWeapon {
@Override
protected void duelistAbility(Hero hero, Integer target) {
onAbilityUsed(hero);
beforeAbilityUsed(hero);
Buff.prolong(hero, SwordDance.class, 5f); //5 turns as using the ability is instant
hero.sprite.operate(hero.pos);
hero.next();
afterAbilityUsed(hero);
}
public static class SwordDance extends FlavourBuff {

View File

@@ -81,7 +81,7 @@ public class Spear extends MeleeWeapon {
hero.sprite.attack(enemy.pos, new Callback() {
@Override
public void call() {
wep.onAbilityUsed(hero);
wep.beforeAbilityUsed(hero);
if (hero.attack(enemy, dmgMulti, 0, Char.INFINITE_ACCURACY)) {
if (enemy.isAlive()){
//trace a ballistica to our target (which will also extend past them
@@ -96,6 +96,7 @@ public class Spear extends MeleeWeapon {
Sample.INSTANCE.play(Assets.Sounds.HIT_STRONG);
}
hero.spendAndNext(hero.attackDelay());
wep.afterAbilityUsed(hero);
}
});
}

View File

@@ -83,7 +83,7 @@ public class Sword extends MeleeWeapon {
hero.sprite.attack(enemy.pos, new Callback() {
@Override
public void call() {
wep.onAbilityUsed(hero);
wep.beforeAbilityUsed(hero);
if (hero.attack(enemy, dmgMulti, 0, Char.INFINITE_ACCURACY)){
Sample.INSTANCE.play(Assets.Sounds.HIT_STRONG);
}
@@ -98,6 +98,7 @@ public class Sword extends MeleeWeapon {
hero.buff(CleaveTracker.class).detach();
}
}
wep.afterAbilityUsed(hero);
}
});
}

View File

@@ -73,7 +73,7 @@ public class Whip extends MeleeWeapon {
hero.sprite.attack(hero.pos, new Callback() {
@Override
public void call() {
onAbilityUsed(hero);
beforeAbilityUsed(hero);
for (Char ch : targets) {
hero.attack(ch);
if (!ch.isAlive()){
@@ -81,6 +81,7 @@ public class Whip extends MeleeWeapon {
}
}
hero.spendAndNext(hero.attackDelay());
afterAbilityUsed(hero);
}
});
}