v2.3.0: externalized the delayed rock fall buff from DM-300
This commit is contained in:
@@ -35,7 +35,6 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Charm;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Charm;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Chill;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Cripple;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Frost;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LockedFloor;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.LockedFloor;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
|
||||||
@@ -44,10 +43,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Sleep;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Slow;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Slow;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Terror;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Terror;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Vertigo;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Vertigo;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.TargetedCell;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.TargetedCell;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.EarthParticle;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SparkParticle;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SparkParticle;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.LloydsBeacon;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.LloydsBeacon;
|
||||||
@@ -55,7 +51,6 @@ import com.shatteredpixel.shatteredpixeldungeon.items.quest.MetalShard;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave;
|
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.CavesBossLevel;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.CavesBossLevel;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.MiningLevel;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
|
import com.shatteredpixel.shatteredpixeldungeon.mechanics.Ballistica;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.mechanics.ConeAOE;
|
import com.shatteredpixel.shatteredpixeldungeon.mechanics.ConeAOE;
|
||||||
@@ -64,13 +59,11 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.DM300Sprite;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.DM300Sprite;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.BossHealthBar;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.BossHealthBar;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
import com.watabou.noosa.Game;
|
import com.watabou.noosa.Game;
|
||||||
import com.watabou.noosa.audio.Music;
|
import com.watabou.noosa.audio.Music;
|
||||||
import com.watabou.noosa.audio.Sample;
|
import com.watabou.noosa.audio.Sample;
|
||||||
import com.watabou.noosa.particles.Emitter;
|
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.Callback;
|
import com.watabou.utils.Callback;
|
||||||
import com.watabou.utils.GameMath;
|
import com.watabou.utils.GameMath;
|
||||||
@@ -80,7 +73,6 @@ import com.watabou.utils.Random;
|
|||||||
import com.watabou.utils.Rect;
|
import com.watabou.utils.Rect;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class DM300 extends Mob {
|
public class DM300 extends Mob {
|
||||||
|
|
||||||
@@ -677,31 +669,11 @@ public class DM300 extends Mob {
|
|||||||
resistances.add(Slow.class);
|
resistances.add(Slow.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO we probably want to exernalize this as it's now being used by multiple characters
|
public static class FallingRockBuff extends DelayedRockFall {
|
||||||
public static class FallingRockBuff extends FlavourBuff {
|
|
||||||
|
|
||||||
private int[] rockPositions;
|
|
||||||
private ArrayList<Emitter> rockEmitters = new ArrayList<>();
|
|
||||||
|
|
||||||
public void setRockPositions( List<Integer> rockPositions ) {
|
|
||||||
this.rockPositions = new int[rockPositions.size()];
|
|
||||||
for (int i = 0; i < rockPositions.size(); i++){
|
|
||||||
this.rockPositions[i] = rockPositions.get(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
fx(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean act() {
|
public void affectChar(Char ch) {
|
||||||
for (int i : rockPositions){
|
if (!(ch instanceof DM300)){
|
||||||
CellEmitter.get( i ).start( Speck.factory( Speck.ROCK ), 0.07f, 10 );
|
|
||||||
|
|
||||||
Char ch = Actor.findChar(i);
|
|
||||||
if (ch != null && !(ch instanceof DM300)){
|
|
||||||
if (Dungeon.level instanceof MiningLevel){
|
|
||||||
Buff.prolong(ch, Paralysis.class, ch instanceof GnollGuard ? 10 : 3);
|
|
||||||
} else {
|
|
||||||
Buff.prolong(ch, Paralysis.class, Dungeon.isChallenged(Challenges.STRONGER_BOSSES) ? 5 : 3);
|
Buff.prolong(ch, Paralysis.class, Dungeon.isChallenged(Challenges.STRONGER_BOSSES) ? 5 : 3);
|
||||||
if (ch == Dungeon.hero) {
|
if (ch == Dungeon.hero) {
|
||||||
Statistics.bossScores[2] -= 100;
|
Statistics.bossScores[2] -= 100;
|
||||||
@@ -709,48 +681,11 @@ public class DM300 extends Mob {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ch == null && Dungeon.level instanceof MiningLevel && Random.Int(3) == 0){
|
|
||||||
Level.set( i, Terrain.MINE_BOULDER );
|
|
||||||
GameScene.updateMap(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PixelScene.shake( 3, 0.7f );
|
|
||||||
Sample.INSTANCE.play(Assets.Sounds.ROCKS);
|
|
||||||
|
|
||||||
detach();
|
|
||||||
return super.act();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fx(boolean on) {
|
public void affectCell(int cell) {
|
||||||
if (on && rockPositions != null){
|
if (Dungeon.level.traps.get(cell) != null){
|
||||||
for (int i : this.rockPositions){
|
Dungeon.level.pressCell(cell);
|
||||||
Emitter e = CellEmitter.get(i);
|
|
||||||
e.y -= DungeonTilemap.SIZE*0.2f;
|
|
||||||
e.height *= 0.4f;
|
|
||||||
e.pour(EarthParticle.FALLING, 0.1f);
|
|
||||||
rockEmitters.add(e);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
for (Emitter e : rockEmitters){
|
|
||||||
e.on = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String POSITIONS = "positions";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void storeInBundle(Bundle bundle) {
|
|
||||||
super.storeInBundle(bundle);
|
|
||||||
bundle.put(POSITIONS, rockPositions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void restoreFromBundle(Bundle bundle) {
|
|
||||||
super.restoreFromBundle(bundle);
|
|
||||||
rockPositions = bundle.getIntArray(POSITIONS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+114
@@ -0,0 +1,114 @@
|
|||||||
|
/*
|
||||||
|
* Pixel Dungeon
|
||||||
|
* Copyright (C) 2012-2015 Oleg Dolya
|
||||||
|
*
|
||||||
|
* Shattered Pixel Dungeon
|
||||||
|
* Copyright (C) 2014-2023 Evan Debenham
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.EarthParticle;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
|
||||||
|
import com.watabou.noosa.audio.Sample;
|
||||||
|
import com.watabou.noosa.particles.Emitter;
|
||||||
|
import com.watabou.utils.Bundle;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
//used for various enemy attacks to keep track of rocks that will fall after some number of turns
|
||||||
|
public class DelayedRockFall extends FlavourBuff {
|
||||||
|
|
||||||
|
private int[] rockPositions;
|
||||||
|
private ArrayList<Emitter> rockEmitters = new ArrayList<>();
|
||||||
|
|
||||||
|
public void setRockPositions( List<Integer> rockPositions ) {
|
||||||
|
this.rockPositions = new int[rockPositions.size()];
|
||||||
|
for (int i = 0; i < rockPositions.size(); i++){
|
||||||
|
this.rockPositions[i] = rockPositions.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
fx(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean act() {
|
||||||
|
for (int i : rockPositions){
|
||||||
|
CellEmitter.get( i ).start( Speck.factory( Speck.ROCK ), 0.07f, 10 );
|
||||||
|
|
||||||
|
Char ch = Actor.findChar(i);
|
||||||
|
if (ch != null){
|
||||||
|
affectChar(ch);
|
||||||
|
} else {
|
||||||
|
affectCell(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PixelScene.shake( 3, 0.7f );
|
||||||
|
Sample.INSTANCE.play(Assets.Sounds.ROCKS);
|
||||||
|
|
||||||
|
detach();
|
||||||
|
return super.act();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void affectChar( Char ch ){
|
||||||
|
//do nothing by default
|
||||||
|
}
|
||||||
|
|
||||||
|
public void affectCell( int cell ){
|
||||||
|
//do nothing by default
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fx(boolean on) {
|
||||||
|
if (on && rockPositions != null){
|
||||||
|
for (int i : this.rockPositions){
|
||||||
|
Emitter e = CellEmitter.get(i);
|
||||||
|
e.y -= DungeonTilemap.SIZE*0.2f;
|
||||||
|
e.height *= 0.4f;
|
||||||
|
e.pour(EarthParticle.FALLING, 0.1f);
|
||||||
|
rockEmitters.add(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (Emitter e : rockEmitters){
|
||||||
|
e.on = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String POSITIONS = "positions";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void storeInBundle(Bundle bundle) {
|
||||||
|
super.storeInBundle(bundle);
|
||||||
|
bundle.put(POSITIONS, rockPositions);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restoreFromBundle(Bundle bundle) {
|
||||||
|
super.restoreFromBundle(bundle);
|
||||||
|
rockPositions = bundle.getIntArray(POSITIONS);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+21
-1
@@ -280,7 +280,7 @@ public class GnollSapper extends Mob {
|
|||||||
for (int i : rockCells){
|
for (int i : rockCells){
|
||||||
sprite.parent.add(new TargetedCell(i, 0xFF0000));
|
sprite.parent.add(new TargetedCell(i, 0xFF0000));
|
||||||
}
|
}
|
||||||
Buff.append(this, DM300.FallingRockBuff.class, GameMath.gate(TICK, (int)Math.ceil(target.cooldown()), 3*TICK)).setRockPositions(rockCells);
|
Buff.append(this, SapperRockFall.class, GameMath.gate(TICK, (int)Math.ceil(target.cooldown()), 3*TICK)).setRockPositions(rockCells);
|
||||||
|
|
||||||
sprite.attack(target.pos, new Callback() {
|
sprite.attack(target.pos, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
@@ -292,6 +292,26 @@ public class GnollSapper extends Mob {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SapperRockFall extends DelayedRockFall {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void affectChar(Char ch) {
|
||||||
|
Buff.prolong(ch, Paralysis.class, ch instanceof GnollGuard ? 10 : 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void affectCell(int cell) {
|
||||||
|
if (Dungeon.level.traps.get(cell) != null){
|
||||||
|
Dungeon.level.pressCell(cell);
|
||||||
|
}
|
||||||
|
if (Random.Int(3) == 0) {
|
||||||
|
Level.set(cell, Terrain.MINE_BOULDER);
|
||||||
|
GameScene.updateMap(cell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public class Boulder extends Item {
|
public class Boulder extends Item {
|
||||||
{
|
{
|
||||||
image = ItemSpriteSheet.GEO_BOULDER;
|
image = ItemSpriteSheet.GEO_BOULDER;
|
||||||
|
|||||||
Reference in New Issue
Block a user