Merging 1.7.5 Source: items/ additions
This commit is contained in:
parent
41e1f20e95
commit
3f126e7a4f
115
src/com/shatteredpixel/shatteredpixeldungeon/items/Bomb.java
Normal file
115
src/com/shatteredpixel/shatteredpixeldungeon/items/Bomb.java
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
/*
|
||||||
|
* Pixel Dungeon
|
||||||
|
* Copyright (C) 2012-2015 Oleg Dolya
|
||||||
|
*
|
||||||
|
* 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.items;
|
||||||
|
|
||||||
|
import com.watabou.noosa.audio.Sample;
|
||||||
|
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;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.BlastParticle;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.SmokeParticle;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
|
public class Bomb extends Item {
|
||||||
|
|
||||||
|
{
|
||||||
|
name = "bomb";
|
||||||
|
image = ItemSpriteSheet.BOMB;
|
||||||
|
defaultAction = AC_THROW;
|
||||||
|
stackable = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onThrow( int cell ) {
|
||||||
|
if (Level.pit[cell]) {
|
||||||
|
super.onThrow( cell );
|
||||||
|
} else {
|
||||||
|
Sample.INSTANCE.play( Assets.SND_BLAST, 2 );
|
||||||
|
|
||||||
|
if (Dungeon.visible[cell]) {
|
||||||
|
CellEmitter.center( cell ).burst( BlastParticle.FACTORY, 30 );
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean terrainAffected = false;
|
||||||
|
for (int n : Level.NEIGHBOURS9) {
|
||||||
|
int c = cell + n;
|
||||||
|
if (c >= 0 && c < Level.LENGTH) {
|
||||||
|
if (Dungeon.visible[c]) {
|
||||||
|
CellEmitter.get( c ).burst( SmokeParticle.FACTORY, 4 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Level.flamable[c]) {
|
||||||
|
Level.set( c, Terrain.EMBERS );
|
||||||
|
GameScene.updateMap( c );
|
||||||
|
terrainAffected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Char ch = Actor.findChar( c );
|
||||||
|
if (ch != null) {
|
||||||
|
int dmg = Random.Int( 1 + Dungeon.depth, 10 + Dungeon.depth * 2 ) - Random.Int( ch.dr() );
|
||||||
|
if (dmg > 0) {
|
||||||
|
ch.damage( dmg, this );
|
||||||
|
if (ch.isAlive()) {
|
||||||
|
Buff.prolong( ch, Paralysis.class, 2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (terrainAffected) {
|
||||||
|
Dungeon.observe();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUpgradable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isIdentified() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Item random() {
|
||||||
|
quantity = Random.IntRange( 1, 3 );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int price() {
|
||||||
|
return 10 * quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String info() {
|
||||||
|
return
|
||||||
|
"This is a relatively small bomb, filled with black powder. Conveniently, its fuse is lit automatically when the bomb is thrown.";
|
||||||
|
}
|
||||||
|
}
|
136
src/com/shatteredpixel/shatteredpixeldungeon/items/Honeypot.java
Normal file
136
src/com/shatteredpixel/shatteredpixeldungeon/items/Honeypot.java
Normal file
|
@ -0,0 +1,136 @@
|
||||||
|
/*
|
||||||
|
* Pixel Dungeon
|
||||||
|
* Copyright (C) 2012-2015 Oleg Dolya
|
||||||
|
*
|
||||||
|
* 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.items;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import com.watabou.noosa.audio.Sample;
|
||||||
|
import com.watabou.noosa.tweeners.AlphaTweener;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Bee;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.effects.Splash;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
|
public class Honeypot extends Item {
|
||||||
|
|
||||||
|
public static final String AC_SHATTER = "SHATTER";
|
||||||
|
|
||||||
|
{
|
||||||
|
name = "honeypot";
|
||||||
|
image = ItemSpriteSheet.HONEYPOT;
|
||||||
|
defaultAction = AC_THROW;
|
||||||
|
stackable = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> actions( Hero hero ) {
|
||||||
|
ArrayList<String> actions = super.actions( hero );
|
||||||
|
actions.add( AC_SHATTER );
|
||||||
|
return actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute( final Hero hero, String action ) {
|
||||||
|
if (action.equals( AC_SHATTER )) {
|
||||||
|
|
||||||
|
hero.sprite.zap( hero.pos );
|
||||||
|
shatter( hero.pos );
|
||||||
|
|
||||||
|
detach( hero.belongings.backpack );
|
||||||
|
hero.spendAndNext( TIME_TO_THROW );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
super.execute( hero, action );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onThrow( int cell ) {
|
||||||
|
if (Level.pit[cell]) {
|
||||||
|
super.onThrow( cell );
|
||||||
|
} else {
|
||||||
|
shatter( cell );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shatter( int pos ) {
|
||||||
|
Sample.INSTANCE.play( Assets.SND_SHATTER );
|
||||||
|
|
||||||
|
if (Dungeon.visible[pos]) {
|
||||||
|
Splash.at( pos, 0xffd500, 5 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int newPos = pos;
|
||||||
|
if (Actor.findChar( pos ) != null) {
|
||||||
|
ArrayList<Integer> candidates = new ArrayList<Integer>();
|
||||||
|
boolean[] passable = Level.passable;
|
||||||
|
|
||||||
|
for (int n : Level.NEIGHBOURS4) {
|
||||||
|
int c = pos + n;
|
||||||
|
if (passable[c] && Actor.findChar( c ) == null) {
|
||||||
|
candidates.add( c );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newPos = candidates.size() > 0 ? Random.element( candidates ) : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newPos != -1) {
|
||||||
|
Bee bee = new Bee();
|
||||||
|
bee.spawn( Dungeon.depth );
|
||||||
|
bee.HP = bee.HT;
|
||||||
|
bee.pos = newPos;
|
||||||
|
|
||||||
|
GameScene.add( bee );
|
||||||
|
Actor.addDelayed( new Pushing( bee, pos, newPos ), -1 );
|
||||||
|
|
||||||
|
bee.sprite.alpha( 0 );
|
||||||
|
bee.sprite.parent.add( new AlphaTweener( bee.sprite, 1, 0.15f ) );
|
||||||
|
|
||||||
|
Sample.INSTANCE.play( Assets.SND_BEE );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUpgradable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isIdentified() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int price() {
|
||||||
|
return 50 * quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String info() {
|
||||||
|
return
|
||||||
|
"There is not much honey in this small honeypot, but there is a golden bee there and it doesn't want to leave it.";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user