cleaned up formatting:

- removed trailing whitespace
- changed all leading whitespace to tabs
- removed IDE created author comments
This commit is contained in:
Evan Debenham 2015-06-12 16:22:26 -04:00
parent baa83b7e43
commit cebdff0221
335 changed files with 8555 additions and 8714 deletions

View File

@ -5,20 +5,20 @@
android:versionName="0.3.0d" android:versionName="0.3.0d"
android:installLocation="auto"> android:installLocation="auto">
<uses-permission android:name="android.permission.VIBRATE"/> <uses-permission android:name="android.permission.VIBRATE"/>
<uses-sdk <uses-sdk
android:minSdkVersion="8" android:minSdkVersion="8"
android:targetSdkVersion="21"/> android:targetSdkVersion="21"/>
<uses-feature <uses-feature
android:glEsVersion="0x00020000"/> android:glEsVersion="0x00020000"/>
<supports-screens <supports-screens
android:smallScreens="false" android:smallScreens="false"
android:normalScreens="true" android:normalScreens="true"
android:largeScreens="true"/> android:largeScreens="true"/>
<!--android:xlargeScreens="true"--> <!--android:xlargeScreens="true"-->
<application <application
android:icon="@drawable/ic_launcher" android:icon="@drawable/ic_launcher"

View File

@ -40,7 +40,7 @@ public class Assets {
public static final String ROGUE = "rogue.png"; public static final String ROGUE = "rogue.png";
public static final String HUNTRESS = "ranger.png"; public static final String HUNTRESS = "ranger.png";
public static final String AVATARS = "avatars.png"; public static final String AVATARS = "avatars.png";
public static final String PET = "pet.png"; public static final String PET = "pet.png";
public static final String SURFACE = "surface.png"; public static final String SURFACE = "surface.png";

View File

@ -97,7 +97,7 @@ public class Badges {
BOSS_SLAIN_3_ASSASSIN, BOSS_SLAIN_3_ASSASSIN,
BOSS_SLAIN_3_SNIPER, BOSS_SLAIN_3_SNIPER,
BOSS_SLAIN_3_WARDEN, BOSS_SLAIN_3_WARDEN,
BOSS_SLAIN_3_ALL_SUBCLASSES( BOSS_SLAIN_3_ALL_SUBCLASSES(
"3rd boss slain by Gladiator, Berserker, Warlock, Battlemage, " + "3rd boss slain by Gladiator, Berserker, Warlock, Battlemage, " +
"Freerunner, Assassin, Sniper & Warden", 33, true ), "Freerunner, Assassin, Sniper & Warden", 33, true ),
RING_OF_HAGGLER( "Ring of Haggler obtained", 20 ), RING_OF_HAGGLER( "Ring of Haggler obtained", 20 ),
@ -144,7 +144,7 @@ public class Badges {
GAMES_PLAYED_3( "500 games played", 62, true ), GAMES_PLAYED_3( "500 games played", 62, true ),
GAMES_PLAYED_4( "2000 games played", 63, true ), GAMES_PLAYED_4( "2000 games played", 63, true ),
HAPPY_END( "Happy end", 38 ), HAPPY_END( "Happy end", 38 ),
CHAMPION( "Challenge won", 39, true ), CHAMPION( "Challenge won", 39, true ),
SUPPORTER( "Thanks for your support!", 31, true ); SUPPORTER( "Thanks for your support!", 31, true );
public boolean meta; public boolean meta;
@ -402,7 +402,7 @@ public class Badges {
// 2) When an item is upgraded (ScrollOfUpgrade, ScrollOfWeaponUpgrade, ShortSword, WandOfMagicMissile) // 2) When an item is upgraded (ScrollOfUpgrade, ScrollOfWeaponUpgrade, ShortSword, WandOfMagicMissile)
// 3) When an item is identified // 3) When an item is identified
// Note that artifacts should never trigger this badge as they are alternatively upgraded // Note that artifacts should never trigger this badge as they are alternatively upgraded
if (!item.levelKnown || item instanceof Artifact) { if (!item.levelKnown || item instanceof Artifact) {
return; return;
} }
@ -429,7 +429,7 @@ public class Badges {
} }
public static void validateAllPotionsIdentified() { public static void validateAllPotionsIdentified() {
if (Dungeon.hero != null && Dungeon.hero.isAlive() && if (Dungeon.hero != null && Dungeon.hero.isAlive() &&
!local.contains( Badge.ALL_POTIONS_IDENTIFIED ) && Potion.allKnown()) { !local.contains( Badge.ALL_POTIONS_IDENTIFIED ) && Potion.allKnown()) {
Badge badge = Badge.ALL_POTIONS_IDENTIFIED; Badge badge = Badge.ALL_POTIONS_IDENTIFIED;
@ -441,7 +441,7 @@ public class Badges {
} }
public static void validateAllScrollsIdentified() { public static void validateAllScrollsIdentified() {
if (Dungeon.hero != null && Dungeon.hero.isAlive() && if (Dungeon.hero != null && Dungeon.hero.isAlive() &&
!local.contains( Badge.ALL_SCROLLS_IDENTIFIED ) && Scroll.allKnown()) { !local.contains( Badge.ALL_SCROLLS_IDENTIFIED ) && Scroll.allKnown()) {
Badge badge = Badge.ALL_SCROLLS_IDENTIFIED; Badge badge = Badge.ALL_SCROLLS_IDENTIFIED;
@ -453,7 +453,7 @@ public class Badges {
} }
public static void validateAllRingsIdentified() { public static void validateAllRingsIdentified() {
if (Dungeon.hero != null && Dungeon.hero.isAlive() && if (Dungeon.hero != null && Dungeon.hero.isAlive() &&
!local.contains( Badge.ALL_RINGS_IDENTIFIED ) && Ring.allKnown()) { !local.contains( Badge.ALL_RINGS_IDENTIFIED ) && Ring.allKnown()) {
Badge badge = Badge.ALL_RINGS_IDENTIFIED; Badge badge = Badge.ALL_RINGS_IDENTIFIED;
@ -717,7 +717,7 @@ public class Badges {
} }
} }
//TODO: Replace this badge, delayed until an eventual badge rework //TODO: Replace this badge, delayed until an eventual badge rework
public static void validateRingOfHaggler() { public static void validateRingOfHaggler() {
if (!local.contains( Badge.RING_OF_HAGGLER )/* && new RingOfThorns().isKnown()*/) { if (!local.contains( Badge.RING_OF_HAGGLER )/* && new RingOfThorns().isKnown()*/) {
Badge badge = Badge.RING_OF_HAGGLER; Badge badge = Badge.RING_OF_HAGGLER;
@ -726,7 +726,7 @@ public class Badges {
} }
} }
//TODO: Replace this badge, delayed until an eventual badge rework //TODO: Replace this badge, delayed until an eventual badge rework
public static void validateRingOfThorns() { public static void validateRingOfThorns() {
if (!local.contains( Badge.RING_OF_THORNS )/* && new RingOfThorns().isKnown()*/) { if (!local.contains( Badge.RING_OF_THORNS )/* && new RingOfThorns().isKnown()*/) {
Badge badge = Badge.RING_OF_THORNS; Badge badge = Badge.RING_OF_THORNS;
@ -854,9 +854,9 @@ public class Badges {
displayBadge( Badge.HAPPY_END ); displayBadge( Badge.HAPPY_END );
} }
public static void validateChampion() { public static void validateChampion() {
displayBadge(Badge.CHAMPION); displayBadge(Badge.CHAMPION);
} }
private static void displayBadge( Badge badge ) { private static void displayBadge( Badge badge ) {
@ -879,7 +879,7 @@ public class Badges {
GLog.h( "New super badge: %s", badge.description ); GLog.h( "New super badge: %s", badge.description );
} else { } else {
GLog.h( "New badge: %s", badge.description ); GLog.h( "New badge: %s", badge.description );
} }
PixelScene.showBadge( badge ); PixelScene.showBadge( badge );
} }
} }

View File

@ -46,13 +46,13 @@ public class Bones {
public static void leave() { public static void leave() {
depth = Dungeon.depth; depth = Dungeon.depth;
//heroes which have won the game, who die far above their farthest depth, or who are challenged drop no bones. //heroes which have won the game, who die far above their farthest depth, or who are challenged drop no bones.
if (Statistics.amuletObtained || (Statistics.deepestFloor - 5) >= depth || Dungeon.challenges > 0) { if (Statistics.amuletObtained || (Statistics.deepestFloor - 5) >= depth || Dungeon.challenges > 0) {
depth = -1; depth = -1;
return; return;
} }
item = pickItem(Dungeon.hero); item = pickItem(Dungeon.hero);
@ -69,59 +69,59 @@ public class Bones {
} }
} }
private static Item pickItem(Hero hero){ private static Item pickItem(Hero hero){
Item item = null; Item item = null;
if (Random.Int(2) == 0) { if (Random.Int(2) == 0) {
switch (Random.Int(5)) { switch (Random.Int(5)) {
case 0: case 0:
item = hero.belongings.weapon; item = hero.belongings.weapon;
break; break;
case 1: case 1:
item = hero.belongings.armor; item = hero.belongings.armor;
break; break;
case 2: case 2:
item = hero.belongings.misc1; item = hero.belongings.misc1;
break; break;
case 3: case 3:
item = hero.belongings.misc2; item = hero.belongings.misc2;
break; break;
case 4: case 4:
item = Dungeon.quickslot.randomNonePlaceholder(); item = Dungeon.quickslot.randomNonePlaceholder();
break; break;
} }
if (item != null && !item.bones) if (item != null && !item.bones)
return pickItem(hero); return pickItem(hero);
} else { } else {
Iterator<Item> iterator = hero.belongings.backpack.iterator(); Iterator<Item> iterator = hero.belongings.backpack.iterator();
Item curItem; Item curItem;
ArrayList<Item> items = new ArrayList<Item>(); ArrayList<Item> items = new ArrayList<Item>();
while (iterator.hasNext()){ while (iterator.hasNext()){
curItem = iterator.next(); curItem = iterator.next();
if (curItem.bones) if (curItem.bones)
items.add(curItem); items.add(curItem);
} }
if (Random.Int(3) < items.size()) { if (Random.Int(3) < items.size()) {
item = Random.element(items); item = Random.element(items);
if (item.stackable){ if (item.stackable){
if (item instanceof MissileWeapon){ if (item instanceof MissileWeapon){
item.quantity(Random.NormalIntRange(1, item.quantity())); item.quantity(Random.NormalIntRange(1, item.quantity()));
} else { } else {
item.quantity(Random.NormalIntRange(1, (item.quantity() + 1) / 2)); item.quantity(Random.NormalIntRange(1, (item.quantity() + 1) / 2));
} }
} }
} }
} }
if (item == null) { if (item == null) {
if (Dungeon.gold > 50) { if (Dungeon.gold > 50) {
item = new Gold( Random.NormalIntRange( 50, Dungeon.gold ) ); item = new Gold( Random.NormalIntRange( 50, Dungeon.gold ) );
} else { } else {
item = new Gold( 50 ); item = new Gold( 50 );
} }
} }
return item; return item;
} }
public static Item get() { public static Item get() {
if (depth == -1) { if (depth == -1) {
@ -141,36 +141,36 @@ public class Bones {
} }
} else { } else {
//heroes who are challenged cannot find bones //heroes who are challenged cannot find bones
if (depth == Dungeon.depth && Dungeon.challenges == 0) { if (depth == Dungeon.depth && Dungeon.challenges == 0) {
Game.instance.deleteFile( BONES_FILE ); Game.instance.deleteFile( BONES_FILE );
depth = 0; depth = 0;
if (item instanceof Artifact){ if (item instanceof Artifact){
if (Generator.removeArtifact((Artifact)item)) { if (Generator.removeArtifact((Artifact)item)) {
try { try {
Artifact artifact = (Artifact)item.getClass().newInstance(); Artifact artifact = (Artifact)item.getClass().newInstance();
artifact.cursed = true; artifact.cursed = true;
artifact.cursedKnown = true; artifact.cursedKnown = true;
//caps displayed artifact level //caps displayed artifact level
artifact.transferUpgrade(Math.min( artifact.transferUpgrade(Math.min(
item.visiblyUpgraded(), item.visiblyUpgraded(),
1 + ((Dungeon.depth * 3) / 10))); 1 + ((Dungeon.depth * 3) / 10)));
return item; return item;
} catch (Exception e) { } catch (Exception e) {
return new Gold(item.price()); return new Gold(item.price());
} }
} else { } else {
return new Gold(item.price()); return new Gold(item.price());
} }
} }
if (item.isUpgradable()) { if (item.isUpgradable()) {
item.cursed = true; item.cursed = true;
item.cursedKnown = true; item.cursedKnown = true;
if (item.isUpgradable()) { if (item.isUpgradable()) {
//gain 1 level every 3.333 floors down plus one additional level. //gain 1 level every 3.333 floors down plus one additional level.
int lvl = 1 + ((Dungeon.depth * 3) / 10); int lvl = 1 + ((Dungeon.depth * 3) / 10);
if (lvl < item.level) { if (lvl < item.level) {
item.degrade( item.level - lvl ); item.degrade( item.level - lvl );
@ -186,5 +186,5 @@ public class Bones {
return null; return null;
} }
} }
} }
} }

View File

@ -19,26 +19,26 @@ package com.shatteredpixel.shatteredpixeldungeon;
public class Challenges { public class Challenges {
public static final int NO_FOOD = 1; public static final int NO_FOOD = 1;
public static final int NO_ARMOR = 2; public static final int NO_ARMOR = 2;
public static final int NO_HEALING = 4; public static final int NO_HEALING = 4;
public static final int NO_HERBALISM = 8; public static final int NO_HERBALISM = 8;
public static final int SWARM_INTELLIGENCE = 16; public static final int SWARM_INTELLIGENCE = 16;
public static final int DARKNESS = 32; public static final int DARKNESS = 32;
public static final int NO_SCROLLS = 64; public static final int NO_SCROLLS = 64;
public static final String[] NAMES = { public static final String[] NAMES = {
"On diet", "On diet",
"Faith is my armor", "Faith is my armor",
"Pharmacophobia", "Pharmacophobia",
"Barren land", "Barren land",
"Swarm intelligence", "Swarm intelligence",
"Into darkness", "Into darkness",
"Forbidden runes" "Forbidden runes"
}; };
public static final int[] MASKS = { public static final int[] MASKS = {
NO_FOOD, NO_ARMOR, NO_HEALING, NO_HERBALISM, SWARM_INTELLIGENCE, DARKNESS, NO_SCROLLS NO_FOOD, NO_ARMOR, NO_HEALING, NO_HERBALISM, SWARM_INTELLIGENCE, DARKNESS, NO_SCROLLS
}; };
} }

View File

@ -73,45 +73,45 @@ public class Dungeon {
public static int transmutation; // depth number for a well of transmutation public static int transmutation; // depth number for a well of transmutation
//enum of items which have limited spawns, records how many have spawned //enum of items which have limited spawns, records how many have spawned
//could all be their own separate numbers, but this allows iterating, much nicer for bundling/initializing. //could all be their own separate numbers, but this allows iterating, much nicer for bundling/initializing.
public static enum limitedDrops{ public static enum limitedDrops{
//limited world drops //limited world drops
strengthPotions, strengthPotions,
upgradeScrolls, upgradeScrolls,
arcaneStyli, arcaneStyli,
//all unlimited health potion sources //all unlimited health potion sources
swarmHP, swarmHP,
batHP, batHP,
warlockHP, warlockHP,
scorpioHP, scorpioHP,
cookingHP, cookingHP,
//blandfruit, which can technically be an unlimited health potion source //blandfruit, which can technically be an unlimited health potion source
blandfruitSeed, blandfruitSeed,
//doesn't use Generator, so we have to enforce one armband drop here //doesn't use Generator, so we have to enforce one armband drop here
armband, armband,
//containers //containers
dewVial, dewVial,
seedBag, seedBag,
scrollBag, scrollBag,
potionBag, potionBag,
wandBag; wandBag;
public int count = 0; public int count = 0;
//for items which can only be dropped once, should directly access count otherwise. //for items which can only be dropped once, should directly access count otherwise.
public boolean dropped(){ public boolean dropped(){
return count != 0; return count != 0;
} }
public void drop(){ public void drop(){
count = 1; count = 1;
} }
} }
public static int challenges; public static int challenges;
public static Hero hero; public static Hero hero;
public static Level level; public static Level level;
@ -130,17 +130,17 @@ public class Dungeon {
public static SparseArray<ArrayList<Item>> droppedItems; public static SparseArray<ArrayList<Item>> droppedItems;
public static int version; public static int version;
public static void init() { public static void init() {
version = Game.versionCode; version = Game.versionCode;
challenges = ShatteredPixelDungeon.challenges(); challenges = ShatteredPixelDungeon.challenges();
Generator.initArtifacts(); Generator.initArtifacts();
Actor.clear(); Actor.clear();
Actor.resetNextID(); Actor.resetNextID();
PathFinder.setMapSize( Level.WIDTH, Level.HEIGHT ); PathFinder.setMapSize( Level.WIDTH, Level.HEIGHT );
@ -152,7 +152,7 @@ public class Dungeon {
Journal.reset(); Journal.reset();
quickslot.reset(); quickslot.reset();
QuickSlotButton.reset(); QuickSlotButton.reset();
depth = 0; depth = 0;
gold = 0; gold = 0;
@ -160,7 +160,7 @@ public class Dungeon {
droppedItems = new SparseArray<ArrayList<Item>>(); droppedItems = new SparseArray<ArrayList<Item>>();
for (limitedDrops a : limitedDrops.values()) for (limitedDrops a : limitedDrops.values())
a.count = 0; a.count = 0;
transmutation = Random.IntRange( 6, 14 ); transmutation = Random.IntRange( 6, 14 );
@ -181,9 +181,9 @@ public class Dungeon {
StartScene.curClass.initHero( hero ); StartScene.curClass.initHero( hero );
} }
public static boolean isChallenged( int mask ) { public static boolean isChallenged( int mask ) {
return (challenges & mask) != 0; return (challenges & mask) != 0;
} }
public static Level newLevel() { public static Level newLevel() {
@ -315,12 +315,12 @@ public class Dungeon {
} }
observe(); observe();
try { try {
saveAll(); saveAll();
} catch (IOException e) { } catch (IOException e) {
/*This only catches IO errors. Yes, this means things can go wrong, and they can go wrong catastrophically. /*This only catches IO errors. Yes, this means things can go wrong, and they can go wrong catastrophically.
But when they do the user will get a nice 'report this issue' dialogue, and I can fix the bug.*/ But when they do the user will get a nice 'report this issue' dialogue, and I can fix the bug.*/
} }
} }
public static void dropToChasm( Item item ) { public static void dropToChasm( Item item ) {
@ -372,23 +372,23 @@ public class Dungeon {
private static final String RN_DEPTH_FILE = "ranger%d.dat"; private static final String RN_DEPTH_FILE = "ranger%d.dat";
private static final String VERSION = "version"; private static final String VERSION = "version";
private static final String CHALLENGES = "challenges"; private static final String CHALLENGES = "challenges";
private static final String HERO = "hero"; private static final String HERO = "hero";
private static final String GOLD = "gold"; private static final String GOLD = "gold";
private static final String DEPTH = "depth"; private static final String DEPTH = "depth";
private static final String DROPPED = "dropped%d"; private static final String DROPPED = "dropped%d";
private static final String LEVEL = "level"; private static final String LEVEL = "level";
private static final String LIMDROPS = "limiteddrops"; private static final String LIMDROPS = "limiteddrops";
private static final String DV = "dewVial"; private static final String DV = "dewVial";
private static final String WT = "transmutation"; private static final String WT = "transmutation";
private static final String CHAPTERS = "chapters"; private static final String CHAPTERS = "chapters";
private static final String QUESTS = "quests"; private static final String QUESTS = "quests";
private static final String BADGES = "badges"; private static final String BADGES = "badges";
//TODO: to support pre-0.2.3 saves, remove when needed //TODO: to support pre-0.2.3 saves, remove when needed
private static final String POS = "potionsOfStrength"; private static final String POS = "potionsOfStrength";
private static final String SOU = "scrollsOfEnhancement"; private static final String SOU = "scrollsOfEnhancement";
private static final String AS = "arcaneStyli"; private static final String AS = "arcaneStyli";
public static String gameFile( HeroClass cl ) { public static String gameFile( HeroClass cl ) {
switch (cl) { switch (cl) {
@ -422,7 +422,7 @@ public class Dungeon {
version = Game.versionCode; version = Game.versionCode;
bundle.put( VERSION, version ); bundle.put( VERSION, version );
bundle.put( CHALLENGES, challenges ); bundle.put( CHALLENGES, challenges );
bundle.put( HERO, hero ); bundle.put( HERO, hero );
bundle.put( GOLD, gold ); bundle.put( GOLD, gold );
bundle.put( DEPTH, depth ); bundle.put( DEPTH, depth );
@ -435,10 +435,10 @@ public class Dungeon {
bundle.put( WT, transmutation ); bundle.put( WT, transmutation );
int[] dropValues = new int[limitedDrops.values().length]; int[] dropValues = new int[limitedDrops.values().length];
for (limitedDrops value : limitedDrops.values()) for (limitedDrops value : limitedDrops.values())
dropValues[value.ordinal()] = value.count; dropValues[value.ordinal()] = value.count;
bundle.put ( LIMDROPS, dropValues ); bundle.put ( LIMDROPS, dropValues );
int count = 0; int count = 0;
int ids[] = new int[chapters.size()]; int ids[] = new int[chapters.size()];
@ -458,13 +458,13 @@ public class Dungeon {
Statistics.storeInBundle( bundle ); Statistics.storeInBundle( bundle );
Journal.storeInBundle( bundle ); Journal.storeInBundle( bundle );
Generator.storeInBundle( bundle ); Generator.storeInBundle( bundle );
Scroll.save( bundle ); Scroll.save( bundle );
Potion.save( bundle ); Potion.save( bundle );
Ring.save( bundle ); Ring.save( bundle );
Actor.storeNextID( bundle ); Actor.storeNextID( bundle );
Bundle badges = new Bundle(); Bundle badges = new Bundle();
Badges.saveLocal( badges ); Badges.saveLocal( badges );
@ -484,7 +484,7 @@ public class Dungeon {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.put( LEVEL, level ); bundle.put( LEVEL, level );
OutputStream output = Game.instance.openFileOutput( OutputStream output = Game.instance.openFileOutput(
Utils.format( depthFile( hero.heroClass ), depth ), Game.MODE_PRIVATE ); Utils.format( depthFile( hero.heroClass ), depth ), Game.MODE_PRIVATE );
Bundle.write( bundle, output ); Bundle.write( bundle, output );
output.close(); output.close();
@ -519,16 +519,16 @@ public class Dungeon {
Bundle bundle = gameBundle( fileName ); Bundle bundle = gameBundle( fileName );
version = bundle.getInt( VERSION ); version = bundle.getInt( VERSION );
Generator.reset(); Generator.reset();
Actor.restoreNextID( bundle ); Actor.restoreNextID( bundle );
quickslot.reset(); quickslot.reset();
QuickSlotButton.reset(); QuickSlotButton.reset();
Dungeon.challenges = bundle.getInt( CHALLENGES ); Dungeon.challenges = bundle.getInt( CHALLENGES );
Dungeon.level = null; Dungeon.level = null;
Dungeon.depth = -1; Dungeon.depth = -1;
@ -544,23 +544,23 @@ public class Dungeon {
quickslot.restorePlaceholders( bundle ); quickslot.restorePlaceholders( bundle );
if (fullLoad) { if (fullLoad) {
transmutation = bundle.getInt( WT ); transmutation = bundle.getInt( WT );
//TODO: adjust this when dropping support for pre-0.2.3 saves //TODO: adjust this when dropping support for pre-0.2.3 saves
if (bundle.contains( LIMDROPS )) { if (bundle.contains( LIMDROPS )) {
int[] dropValues = bundle.getIntArray(LIMDROPS); int[] dropValues = bundle.getIntArray(LIMDROPS);
for (limitedDrops value : limitedDrops.values()) for (limitedDrops value : limitedDrops.values())
value.count = value.ordinal() < dropValues.length ? value.count = value.ordinal() < dropValues.length ?
dropValues[value.ordinal()] : 0; dropValues[value.ordinal()] : 0;
} else { } else {
for (limitedDrops value : limitedDrops.values()) for (limitedDrops value : limitedDrops.values())
value.count = 0; value.count = 0;
limitedDrops.strengthPotions.count = bundle.getInt(POS); limitedDrops.strengthPotions.count = bundle.getInt(POS);
limitedDrops.upgradeScrolls.count = bundle.getInt(SOU); limitedDrops.upgradeScrolls.count = bundle.getInt(SOU);
limitedDrops.arcaneStyli.count = bundle.getInt(AS); limitedDrops.arcaneStyli.count = bundle.getInt(AS);
} }
//for pre-0.2.4 saves //for pre-0.2.4 saves
if (bundle.getBoolean(DV)) limitedDrops.dewVial.drop(); if (bundle.getBoolean(DV)) limitedDrops.dewVial.drop();
chapters = new HashSet<Integer>(); chapters = new HashSet<Integer>();
int ids[] = bundle.getIntArray( CHAPTERS ); int ids[] = bundle.getIntArray( CHAPTERS );
@ -601,7 +601,7 @@ public class Dungeon {
Statistics.restoreFromBundle( bundle ); Statistics.restoreFromBundle( bundle );
Journal.restoreFromBundle( bundle ); Journal.restoreFromBundle( bundle );
Generator.restoreFromBundle( bundle ); Generator.restoreFromBundle( bundle );
droppedItems = new SparseArray<ArrayList<Item>>(); droppedItems = new SparseArray<ArrayList<Item>>();
for (int i=2; i <= Statistics.deepestFloor + 1; i++) { for (int i=2; i <= Statistics.deepestFloor + 1; i++) {
@ -669,7 +669,7 @@ public class Dungeon {
public static void fail( String desc ) { public static void fail( String desc ) {
resultDescription = desc; resultDescription = desc;
if (hero.belongings.getItem( Ankh.class ) == null) { if (hero.belongings.getItem( Ankh.class ) == null) {
Rankings.INSTANCE.submit( false ); Rankings.INSTANCE.submit( false );
} }
} }
@ -678,9 +678,9 @@ public class Dungeon {
hero.belongings.identify(); hero.belongings.identify();
if (challenges != 0) { if (challenges != 0) {
Badges.validateChampion(); Badges.validateChampion();
} }
resultDescription = desc; resultDescription = desc;
Rankings.INSTANCE.submit( true ); Rankings.INSTANCE.submit( true );

View File

@ -32,8 +32,8 @@ public class DungeonTilemap extends Tilemap {
private static DungeonTilemap instance; private static DungeonTilemap instance;
public DungeonTilemap() { public DungeonTilemap() {
super( super(
Dungeon.level.tilesTex(), Dungeon.level.tilesTex(),
new TextureFilm( Dungeon.level.tilesTex(), SIZE, SIZE ) ); new TextureFilm( Dungeon.level.tilesTex(), SIZE, SIZE ) );
map( Dungeon.level.map, Level.WIDTH ); map( Dungeon.level.map, Level.WIDTH );
@ -76,8 +76,8 @@ public class DungeonTilemap extends Tilemap {
} }
public static PointF tileCenterToWorld( int pos ) { public static PointF tileCenterToWorld( int pos ) {
return new PointF( return new PointF(
(pos % Level.WIDTH + 0.5f) * SIZE, (pos % Level.WIDTH + 0.5f) * SIZE,
(pos / Level.WIDTH + 0.5f) * SIZE ); (pos / Level.WIDTH + 0.5f) * SIZE );
} }

View File

@ -65,8 +65,8 @@ public class FogOfWar extends Image {
texture( new FogTexture() ); texture( new FogTexture() );
scale.set( scale.set(
DungeonTilemap.SIZE, DungeonTilemap.SIZE,
DungeonTilemap.SIZE ); DungeonTilemap.SIZE );
x = y = -size / 2; x = y = -size / 2;
@ -84,16 +84,16 @@ public class FogOfWar extends Image {
for (int j=1; j < pWidth - 1; j++) { for (int j=1; j < pWidth - 1; j++) {
pos++; pos++;
int c = INVISIBLE; int c = INVISIBLE;
if (visible[pos] && visible[pos - (pWidth - 1)] && if (visible[pos] && visible[pos - (pWidth - 1)] &&
visible[pos - 1] && visible[pos - (pWidth - 1) - 1]) { visible[pos - 1] && visible[pos - (pWidth - 1) - 1]) {
c = VISIBLE; c = VISIBLE;
} else } else
if (visited[pos] && visited[pos - (pWidth - 1)] && if (visited[pos] && visited[pos - (pWidth - 1)] &&
visited[pos - 1] && visited[pos - (pWidth - 1) - 1]) { visited[pos - 1] && visited[pos - (pWidth - 1) - 1]) {
c = VISITED; c = VISITED;
} }
else else
if (mapped[pos] && mapped[pos - (pWidth - 1)] && if (mapped[pos] && mapped[pos - (pWidth - 1)] &&
mapped[pos - 1] && mapped[pos - (pWidth - 1) - 1]) { mapped[pos - 1] && mapped[pos - (pWidth - 1) - 1]) {
c = MAPPED; c = MAPPED;
} }

View File

@ -26,17 +26,17 @@ enum Preferences {
INSTANCE; INSTANCE;
public static final String KEY_LANDSCAPE = "landscape"; public static final String KEY_LANDSCAPE = "landscape";
public static final String KEY_IMMERSIVE = "immersive"; public static final String KEY_IMMERSIVE = "immersive";
public static final String KEY_SCALE_UP = "scaleup"; public static final String KEY_SCALE_UP = "scaleup";
public static final String KEY_MUSIC = "music"; public static final String KEY_MUSIC = "music";
public static final String KEY_SOUND_FX = "soundfx"; public static final String KEY_SOUND_FX = "soundfx";
public static final String KEY_ZOOM = "zoom"; public static final String KEY_ZOOM = "zoom";
public static final String KEY_LAST_CLASS = "last_class"; public static final String KEY_LAST_CLASS = "last_class";
public static final String KEY_CHALLENGES = "challenges"; public static final String KEY_CHALLENGES = "challenges";
public static final String KEY_QUICKSLOTS = "quickslots"; public static final String KEY_QUICKSLOTS = "quickslots";
public static final String KEY_INTRO = "intro"; public static final String KEY_INTRO = "intro";
public static final String KEY_BRIGHTNESS = "brightness"; public static final String KEY_BRIGHTNESS = "brightness";
public static final String KEY_VERSION = "version"; public static final String KEY_VERSION = "version";
private SharedPreferences prefs; private SharedPreferences prefs;

View File

@ -8,123 +8,120 @@ import com.watabou.utils.Random;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
/**
* Created by debenhame on 16/01/2015.
*/
public class QuickSlot { public class QuickSlot {
/** /**
* Slots contain objects which are also in a player's inventory. The one exception to this is when quantity is 0, * Slots contain objects which are also in a player's inventory. The one exception to this is when quantity is 0,
* which can happen for a stackable item that has been 'used up', these are refered to a placeholders. * which can happen for a stackable item that has been 'used up', these are refered to a placeholders.
*/ */
//note that the current max size is coded at 4, due to UI constraints, but it could be much much bigger with no issue. //note that the current max size is coded at 4, due to UI constraints, but it could be much much bigger with no issue.
public static int SIZE = 4; public static int SIZE = 4;
private Item[] slots = new Item[SIZE]; private Item[] slots = new Item[SIZE];
//direct array interaction methods, everything should build from these methods. //direct array interaction methods, everything should build from these methods.
public void setSlot(int slot, Item item){ public void setSlot(int slot, Item item){
clearItem(item); //we don't want to allow the same item in multiple slots. clearItem(item); //we don't want to allow the same item in multiple slots.
slots[slot] = item; slots[slot] = item;
} }
public void clearSlot(int slot){ public void clearSlot(int slot){
slots[slot] = null; slots[slot] = null;
} }
public void reset(){ public void reset(){
slots = new Item[SIZE]; slots = new Item[SIZE];
} }
public Item getItem(int slot){ public Item getItem(int slot){
return slots[slot]; return slots[slot];
} }
//utility methods, for easier use of the internal array. //utility methods, for easier use of the internal array.
public int getSlot(Item item) { public int getSlot(Item item) {
for (int i = 0; i < SIZE; i++) for (int i = 0; i < SIZE; i++)
if (getItem(i) == item) if (getItem(i) == item)
return i; return i;
return -1; return -1;
} }
public Boolean isPlaceholder(int slot){ public Boolean isPlaceholder(int slot){
return getItem(slot) != null && getItem(slot).quantity() == 0; return getItem(slot) != null && getItem(slot).quantity() == 0;
} }
public Boolean isNonePlaceholder(int slot){ public Boolean isNonePlaceholder(int slot){
return getItem(slot) != null && getItem(slot).quantity() > 0; return getItem(slot) != null && getItem(slot).quantity() > 0;
} }
public void clearItem(Item item){ public void clearItem(Item item){
if (contains(item)) if (contains(item))
clearSlot(getSlot(item)); clearSlot(getSlot(item));
} }
public boolean contains(Item item){ public boolean contains(Item item){
return getSlot(item) != -1; return getSlot(item) != -1;
} }
public void replaceSimilar(Item item){ public void replaceSimilar(Item item){
for (int i = 0; i < SIZE; i++) for (int i = 0; i < SIZE; i++)
if (getItem(i) != null && item.isSimilar(getItem(i))) if (getItem(i) != null && item.isSimilar(getItem(i)))
setSlot( i , item ); setSlot( i , item );
} }
public void convertToPlaceholder(Item item){ public void convertToPlaceholder(Item item){
Item placeholder = Item.virtual(item.getClass()); Item placeholder = Item.virtual(item.getClass());
if (placeholder != null && contains(item)) if (placeholder != null && contains(item))
for (int i = 0; i < SIZE; i++) for (int i = 0; i < SIZE; i++)
if (getItem(i) == item) if (getItem(i) == item)
setSlot( i , placeholder ); setSlot( i , placeholder );
} }
public Item randomNonePlaceholder(){ public Item randomNonePlaceholder(){
ArrayList<Item> result = new ArrayList<Item>(); ArrayList<Item> result = new ArrayList<Item>();
for (int i = 0; i < SIZE; i ++) for (int i = 0; i < SIZE; i ++)
if (getItem(i) != null && !isPlaceholder(i)) if (getItem(i) != null && !isPlaceholder(i))
result.add(getItem(i)); result.add(getItem(i));
return Random.element(result); return Random.element(result);
} }
private final String PLACEHOLDERS = "placeholders"; private final String PLACEHOLDERS = "placeholders";
private final String PLACEMENTS = "placements"; private final String PLACEMENTS = "placements";
/** /**
* Placements array is used as order is preserved while bundling, but exact index is not, so if we * Placements array is used as order is preserved while bundling, but exact index is not, so if we
* bundle both the placeholders (which preserves their order) and an array telling us where the placeholders are, * bundle both the placeholders (which preserves their order) and an array telling us where the placeholders are,
* we can reconstruct them perfectly. * we can reconstruct them perfectly.
*/ */
public void storePlaceholders(Bundle bundle){ public void storePlaceholders(Bundle bundle){
ArrayList<Item> placeholders = new ArrayList<Item>(SIZE); ArrayList<Item> placeholders = new ArrayList<Item>(SIZE);
boolean[] placements = new boolean[SIZE]; boolean[] placements = new boolean[SIZE];
for (int i = 0; i < SIZE; i++) for (int i = 0; i < SIZE; i++)
if (isPlaceholder(i)) { if (isPlaceholder(i)) {
placeholders.add(getItem(i)); placeholders.add(getItem(i));
placements[i] = true; placements[i] = true;
} }
bundle.put( PLACEHOLDERS, placeholders ); bundle.put( PLACEHOLDERS, placeholders );
bundle.put( PLACEMENTS, placements ); bundle.put( PLACEMENTS, placements );
} }
public void restorePlaceholders(Bundle bundle){ public void restorePlaceholders(Bundle bundle){
Collection<Bundlable> placeholders = bundle.getCollection(PLACEHOLDERS); Collection<Bundlable> placeholders = bundle.getCollection(PLACEHOLDERS);
boolean[] placements = bundle.getBooleanArray( PLACEMENTS ); boolean[] placements = bundle.getBooleanArray( PLACEMENTS );
int i = 0; int i = 0;
for (Bundlable item : placeholders){ for (Bundlable item : placeholders){
while (!placements[i]) i++; while (!placements[i]) i++;
setSlot( i, (Item)item ); setSlot( i, (Item)item );
i++; i++;
} }
} }
} }

View File

@ -140,7 +140,7 @@ public enum Rankings {
for (Bundlable record : bundle.getCollection( RECORDS )) { for (Bundlable record : bundle.getCollection( RECORDS )) {
records.add( (Record)record ); records.add( (Record)record );
} }
lastRecord = bundle.getInt( LATEST ); lastRecord = bundle.getInt( LATEST );
totalNumber = bundle.getInt( TOTAL ); totalNumber = bundle.getInt( TOTAL );

View File

@ -94,20 +94,20 @@ public class ShatteredPixelDungeon extends Game {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
/* if (android.os.Build.VERSION.SDK_INT >= 19) { /* if (android.os.Build.VERSION.SDK_INT >= 19) {
getWindow().getDecorView().setSystemUiVisibility( getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY ); View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY );
}*/ }*/
updateImmersiveMode(); updateImmersiveMode();
DisplayMetrics metrics = new DisplayMetrics(); DisplayMetrics metrics = new DisplayMetrics();
instance.getWindowManager().getDefaultDisplay().getMetrics( metrics ); instance.getWindowManager().getDefaultDisplay().getMetrics( metrics );
boolean landscape = metrics.widthPixels > metrics.heightPixels; boolean landscape = metrics.widthPixels > metrics.heightPixels;
if (Preferences.INSTANCE.getBoolean( Preferences.KEY_LANDSCAPE, false ) != landscape) { if (Preferences.INSTANCE.getBoolean( Preferences.KEY_LANDSCAPE, false ) != landscape) {
landscape( !landscape ); landscape( !landscape );
@ -121,16 +121,16 @@ public class ShatteredPixelDungeon extends Game {
Assets.SND_BADGE, Assets.SND_BADGE,
Assets.SND_GOLD, Assets.SND_GOLD,
Assets.SND_STEP, Assets.SND_STEP,
Assets.SND_WATER, Assets.SND_WATER,
Assets.SND_OPEN, Assets.SND_OPEN,
Assets.SND_UNLOCK, Assets.SND_UNLOCK,
Assets.SND_ITEM, Assets.SND_ITEM,
Assets.SND_DEWDROP, Assets.SND_DEWDROP,
Assets.SND_HIT, Assets.SND_HIT,
Assets.SND_MISS, Assets.SND_MISS,
Assets.SND_DESCEND, Assets.SND_DESCEND,
Assets.SND_EAT, Assets.SND_EAT,
Assets.SND_READ, Assets.SND_READ,
Assets.SND_LULLABY, Assets.SND_LULLABY,
@ -167,20 +167,20 @@ public class ShatteredPixelDungeon extends Game {
Assets.SND_MIMIC ); Assets.SND_MIMIC );
} }
@Override @Override
public void onWindowFocusChanged( boolean hasFocus ) { public void onWindowFocusChanged( boolean hasFocus ) {
super.onWindowFocusChanged( hasFocus ); super.onWindowFocusChanged( hasFocus );
if (hasFocus) { if (hasFocus) {
updateImmersiveMode(); updateImmersiveMode();
} }
} }
public static void switchNoFade( Class<? extends PixelScene> c ) { public static void switchNoFade( Class<? extends PixelScene> c ) {
PixelScene.noFade = true; PixelScene.noFade = true;
switchScene( c ); switchScene( c );
} }
/* /*
* ---> Prefernces * ---> Prefernces
@ -202,59 +202,59 @@ public class ShatteredPixelDungeon extends Game {
switchScene( TitleScene.class ); switchScene( TitleScene.class );
} }
// *** IMMERSIVE MODE **** // *** IMMERSIVE MODE ****
private static boolean immersiveModeChanged = false; private static boolean immersiveModeChanged = false;
@SuppressLint("NewApi") @SuppressLint("NewApi")
public static void immerse( boolean value ) { public static void immerse( boolean value ) {
Preferences.INSTANCE.put( Preferences.KEY_IMMERSIVE, value ); Preferences.INSTANCE.put( Preferences.KEY_IMMERSIVE, value );
instance.runOnUiThread( new Runnable() { instance.runOnUiThread( new Runnable() {
@Override @Override
public void run() { public void run() {
updateImmersiveMode(); updateImmersiveMode();
immersiveModeChanged = true; immersiveModeChanged = true;
} }
} ); } );
} }
@Override @Override
public void onSurfaceChanged( GL10 gl, int width, int height ) { public void onSurfaceChanged( GL10 gl, int width, int height ) {
super.onSurfaceChanged( gl, width, height ); super.onSurfaceChanged( gl, width, height );
if (immersiveModeChanged) { if (immersiveModeChanged) {
requestedReset = true; requestedReset = true;
immersiveModeChanged = false; immersiveModeChanged = false;
} }
} }
@SuppressLint("NewApi") @SuppressLint("NewApi")
public static void updateImmersiveMode() { public static void updateImmersiveMode() {
if (android.os.Build.VERSION.SDK_INT >= 19) { if (android.os.Build.VERSION.SDK_INT >= 19) {
try { try {
// Sometime NullPointerException happens here // Sometime NullPointerException happens here
instance.getWindow().getDecorView().setSystemUiVisibility( instance.getWindow().getDecorView().setSystemUiVisibility(
immersed() ? immersed() ?
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
: :
0 ); 0 );
} catch (Exception e) { } catch (Exception e) {
reportException( e ); reportException( e );
} }
} }
} }
public static boolean immersed() { public static boolean immersed() {
return Preferences.INSTANCE.getBoolean( Preferences.KEY_IMMERSIVE, false ); return Preferences.INSTANCE.getBoolean( Preferences.KEY_IMMERSIVE, false );
} }
// ***************************** // *****************************
public static boolean scaleUp() { public static boolean scaleUp() {
return Preferences.INSTANCE.getBoolean( Preferences.KEY_SCALE_UP, true ); return Preferences.INSTANCE.getBoolean( Preferences.KEY_SCALE_UP, true );
@ -305,13 +305,13 @@ public class ShatteredPixelDungeon extends Game {
return Preferences.INSTANCE.getInt( Preferences.KEY_LAST_CLASS, 0 ); return Preferences.INSTANCE.getInt( Preferences.KEY_LAST_CLASS, 0 );
} }
public static void challenges( int value ) { public static void challenges( int value ) {
Preferences.INSTANCE.put( Preferences.KEY_CHALLENGES, value ); Preferences.INSTANCE.put( Preferences.KEY_CHALLENGES, value );
} }
public static int challenges() { public static int challenges() {
return Preferences.INSTANCE.getInt( Preferences.KEY_CHALLENGES, 0 ); return Preferences.INSTANCE.getInt( Preferences.KEY_CHALLENGES, 0 );
} }
public static void quickSlots( int value ){ Preferences.INSTANCE.put( Preferences.KEY_QUICKSLOTS, value ); } public static void quickSlots( int value ){ Preferences.INSTANCE.put( Preferences.KEY_QUICKSLOTS, value ); }
@ -325,13 +325,13 @@ public class ShatteredPixelDungeon extends Game {
return Preferences.INSTANCE.getBoolean( Preferences.KEY_INTRO, true ); return Preferences.INSTANCE.getBoolean( Preferences.KEY_INTRO, true );
} }
public static void version( int value) { public static void version( int value) {
Preferences.INSTANCE.put( Preferences.KEY_VERSION, value ); Preferences.INSTANCE.put( Preferences.KEY_VERSION, value );
} }
public static int version() { public static int version() {
return Preferences.INSTANCE.getInt( Preferences.KEY_VERSION, 0 ); return Preferences.INSTANCE.getInt( Preferences.KEY_VERSION, 0 );
} }
/* /*
* <--- Preferences * <--- Preferences

View File

@ -45,7 +45,7 @@ public class Statistics {
foodEaten = 0; foodEaten = 0;
potionsCooked = 0; potionsCooked = 0;
piranhasKilled = 0; piranhasKilled = 0;
nightHunt = 0; nightHunt = 0;
ankhsUsed = 0; ankhsUsed = 0;
duration = 0; duration = 0;

View File

@ -83,7 +83,7 @@ public abstract class Actor implements Bundlable {
id = bundle.getInt( ID ); id = bundle.getInt( ID );
} }
private static int nextID = 1; private static int nextID = 1;
public int id() { public int id() {
if (id > 0) { if (id > 0) {
return id; return id;
@ -144,25 +144,25 @@ public abstract class Actor implements Bundlable {
current = null; current = null;
} }
private static final String NEXTID = "nextid"; private static final String NEXTID = "nextid";
public static void storeNextID( Bundle bundle){ public static void storeNextID( Bundle bundle){
bundle.put( NEXTID, nextID ); bundle.put( NEXTID, nextID );
} }
public static void restoreNextID( Bundle bundle){ public static void restoreNextID( Bundle bundle){
nextID = bundle.getInt( NEXTID ); nextID = bundle.getInt( NEXTID );
} }
public static void resetNextID(){ public static void resetNextID(){
nextID = 1; nextID = 1;
} }
/*protected*/public void next() { /*protected*/public void next() {
if (current == this) { if (current == this) {
current = null; current = null;
} }
} }
public static void process() { public static void process() {
@ -190,12 +190,12 @@ public abstract class Actor implements Bundlable {
if (current != null) { if (current != null) {
if (current instanceof Char && ((Char)current).sprite.isMoving) { if (current instanceof Char && ((Char)current).sprite.isMoving) {
// If it's character's turn to act, but its sprite // If it's character's turn to act, but its sprite
// is moving, wait till the movement is over // is moving, wait till the movement is over
current = null; current = null;
break; break;
} }
doNext = current.act(); doNext = current.act();
if (doNext && !Dungeon.hero.isAlive()) { if (doNext && !Dungeon.hero.isAlive()) {

View File

@ -121,7 +121,7 @@ public abstract class Char extends Actor {
// FIXME // FIXME
int dr = this instanceof Hero && ((Hero)this).rangedWeapon != null && ((Hero)this).subClass == int dr = this instanceof Hero && ((Hero)this).rangedWeapon != null && ((Hero)this).subClass ==
HeroSubClass.SNIPER ? 0 : Random.IntRange( 0, enemy.dr() ); HeroSubClass.SNIPER ? 0 : Random.IntRange( 0, enemy.dr() );
int dmg = damageRoll(); int dmg = damageRoll();
int effectiveDamage = Math.max( dmg - dr, 0 ); int effectiveDamage = Math.max( dmg - dr, 0 );
@ -242,11 +242,11 @@ public abstract class Char extends Actor {
return; return;
} }
if (this.buff(Frost.class) != null){ if (this.buff(Frost.class) != null){
Buff.detach( this, Frost.class ); Buff.detach( this, Frost.class );
} }
if (this.buff(MagicalSleep.class) != null){ if (this.buff(MagicalSleep.class) != null){
Buff.detach(this, MagicalSleep.class); Buff.detach(this, MagicalSleep.class);
} }
Class<?> srcClass = src.getClass(); Class<?> srcClass = src.getClass();
if (immunities().contains( srcClass )) { if (immunities().contains( srcClass )) {
@ -266,8 +266,8 @@ public abstract class Char extends Actor {
HP -= dmg; HP -= dmg;
if (dmg > 0 || src instanceof Char) { if (dmg > 0 || src instanceof Char) {
sprite.showStatus( HP > HT / 2 ? sprite.showStatus( HP > HT / 2 ?
CharSprite.WARNING : CharSprite.WARNING :
CharSprite.NEGATIVE, CharSprite.NEGATIVE,
Integer.toString( dmg ) ); Integer.toString( dmg ) );
} }

View File

@ -70,7 +70,7 @@ public class Alchemy extends Blob {
@Override @Override
public void use( BlobEmitter emitter ) { public void use( BlobEmitter emitter ) {
super.use( emitter ); super.use( emitter );
emitter.start( Speck.factory( Speck.BUBBLE ), 0.4f, 0 ); emitter.start( Speck.factory( Speck.BUBBLE ), 0.4f, 0 );
} }
} }

View File

@ -94,7 +94,7 @@ public class Blob extends Actor {
int[] data = bundle.getIntArray( CUR ); int[] data = bundle.getIntArray( CUR );
if (data != null) { if (data != null) {
int start = bundle.getInt( START ); int start = bundle.getInt( START );
for (int i=0; i < data.length; i++) { for (int i=0; i < data.length; i++) {
cur[i + start] = data[i]; cur[i + start] = data[i];
volume += data[i]; volume += data[i];

View File

@ -26,28 +26,28 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
public class ConfusionGas extends Blob { public class ConfusionGas extends Blob {
@Override @Override
protected void evolve() { protected void evolve() {
super.evolve(); super.evolve();
Char ch; Char ch;
for (int i=0; i < LENGTH; i++) { for (int i=0; i < LENGTH; i++) {
if (cur[i] > 0 && (ch = Actor.findChar( i )) != null) { if (cur[i] > 0 && (ch = Actor.findChar( i )) != null) {
if (!ch.immunities().contains(this.getClass())) if (!ch.immunities().contains(this.getClass()))
Buff.prolong( ch, Vertigo.class, 2 ); Buff.prolong( ch, Vertigo.class, 2 );
} }
} }
} }
@Override @Override
public void use( BlobEmitter emitter ) { public void use( BlobEmitter emitter ) {
super.use( emitter ); super.use( emitter );
emitter.pour( Speck.factory( Speck.CONFUSION, true ), 0.6f ); emitter.pour( Speck.factory( Speck.CONFUSION, true ), 0.6f );
} }
@Override @Override
public String tileDesc() { public String tileDesc() {
return "A cloud of confusion gas is swirling here."; return "A cloud of confusion gas is swirling here.";
} }
} }

View File

@ -75,7 +75,7 @@ public class Foliage extends Blob {
@Override @Override
public void use( BlobEmitter emitter ) { public void use( BlobEmitter emitter ) {
super.use( emitter ); super.use( emitter );
emitter.start( ShaftParticle.FACTORY, 0.9f, 0 ); emitter.start( ShaftParticle.FACTORY, 0.9f, 0 );
} }

View File

@ -33,13 +33,13 @@ public class Freezing {
// Returns true, if this cell is visible // Returns true, if this cell is visible
public static boolean affect( int cell, Fire fire ) { public static boolean affect( int cell, Fire fire ) {
Char ch = Actor.findChar( cell ); Char ch = Actor.findChar( cell );
if (ch != null) { if (ch != null) {
if (Level.water[ch.pos]){ if (Level.water[ch.pos]){
Buff.prolong(ch, Frost.class, Frost.duration(ch) * Random.Float(5f, 7.5f)); Buff.prolong(ch, Frost.class, Frost.duration(ch) * Random.Float(5f, 7.5f));
} else { } else {
Buff.prolong(ch, Frost.class, Frost.duration(ch) * Random.Float(1.0f, 1.5f)); Buff.prolong(ch, Frost.class, Frost.duration(ch) * Random.Float(1.0f, 1.5f));
} }
} }
if (fire != null) { if (fire != null) {

View File

@ -5,52 +5,49 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.sprites.GooSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.GooSprite;
/**
* Created by Evan on 29/09/2014.
*/
public class GooWarn extends Blob { public class GooWarn extends Blob {
//cosmetic blob, used to warn noobs that goo's pump up should, infact, be avoided. //cosmetic blob, used to warn noobs that goo's pump up should, infact, be avoided.
{ {
//this one needs to act after the Goo //this one needs to act after the Goo
actPriority = 3; actPriority = 3;
} }
protected int pos; protected int pos;
@Override @Override
protected void evolve() { protected void evolve() {
for (int i=0; i < LENGTH; i++) { for (int i=0; i < LENGTH; i++) {
int offv = cur[i] > 0 ? cur[i] - 1 : 0; int offv = cur[i] > 0 ? cur[i] - 1 : 0;
off[i] = offv; off[i] = offv;
if (offv > 0) { if (offv > 0) {
volume += offv; volume += offv;
} }
} }
} }
public void seed( int cell, int amount ) { public void seed( int cell, int amount ) {
int diff = amount - cur[cell]; int diff = amount - cur[cell];
if (diff > 0) { if (diff > 0) {
cur[cell] = amount; cur[cell] = amount;
volume += diff; volume += diff;
} }
} }
@Override @Override
public void use( BlobEmitter emitter ) { public void use( BlobEmitter emitter ) {
super.use( emitter ); super.use( emitter );
emitter.pour(GooSprite.GooParticle.FACTORY, 0.03f ); emitter.pour(GooSprite.GooParticle.FACTORY, 0.03f );
} }
@Override @Override
public String tileDesc() { public String tileDesc() {
return "Specs of dark energy are swarming here!"; return "Specs of dark energy are swarming here!";
} }
} }

View File

@ -33,8 +33,8 @@ public class ParalyticGas extends Blob {
Char ch; Char ch;
for (int i=0; i < LENGTH; i++) { for (int i=0; i < LENGTH; i++) {
if (cur[i] > 0 && (ch = Actor.findChar( i )) != null) { if (cur[i] > 0 && (ch = Actor.findChar( i )) != null) {
if (!ch.immunities().contains(this.getClass())) if (!ch.immunities().contains(this.getClass()))
Buff.prolong( ch, Paralysis.class, Paralysis.duration( ch ) ); Buff.prolong( ch, Paralysis.class, Paralysis.duration( ch ) );
} }
} }
} }

View File

@ -7,33 +7,30 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
/**
* Created by debenhame on 08/10/2014.
*/
public class StenchGas extends Blob { public class StenchGas extends Blob {
@Override @Override
protected void evolve() { protected void evolve() {
super.evolve(); super.evolve();
Char ch; Char ch;
for (int i=0; i < LENGTH; i++) { for (int i=0; i < LENGTH; i++) {
if (cur[i] > 0 && (ch = Actor.findChar(i)) != null) { if (cur[i] > 0 && (ch = Actor.findChar(i)) != null) {
if (!ch.immunities().contains(this.getClass())) if (!ch.immunities().contains(this.getClass()))
Buff.prolong( ch, Paralysis.class, Paralysis.duration( ch )/5 ); Buff.prolong( ch, Paralysis.class, Paralysis.duration( ch )/5 );
} }
} }
} }
@Override @Override
public void use( BlobEmitter emitter ) { public void use( BlobEmitter emitter ) {
super.use( emitter ); super.use( emitter );
emitter.pour( Speck.factory(Speck.STENCH), 0.6f ); emitter.pour( Speck.factory(Speck.STENCH), 0.6f );
} }
@Override @Override
public String tileDesc() { public String tileDesc() {
return "A cloud of fetid stench is swirling here."; return "A cloud of fetid stench is swirling here.";
} }
} }

View File

@ -31,20 +31,20 @@ import com.watabou.utils.Random;
public class ToxicGas extends Blob implements Hero.Doom { public class ToxicGas extends Blob implements Hero.Doom {
@Override @Override
protected void evolve() { protected void evolve() {
super.evolve(); super.evolve();
int levelDamage = 5 + Dungeon.depth * 5; int levelDamage = 5 + Dungeon.depth * 5;
Char ch; Char ch;
for (int i=0; i < LENGTH; i++) { for (int i=0; i < LENGTH; i++) {
if (cur[i] > 0 && (ch = Actor.findChar( i )) != null) { if (cur[i] > 0 && (ch = Actor.findChar( i )) != null) {
int damage = (ch.HT + levelDamage) / 40; int damage = (ch.HT + levelDamage) / 40;
if (Random.Int( 40 ) < (ch.HT + levelDamage) % 40) { if (Random.Int( 40 ) < (ch.HT + levelDamage) % 40) {
damage++; damage++;
} }
ch.damage( damage, this ); ch.damage( damage, this );
} }

View File

@ -8,58 +8,55 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.watabou.utils.Bundle; import com.watabou.utils.Bundle;
/**
* Created by Evan on 12/04/2015.
*/
public class VenomGas extends Blob { public class VenomGas extends Blob {
private int strength = 0; private int strength = 0;
@Override @Override
protected void evolve() { protected void evolve() {
super.evolve(); super.evolve();
if (volume == 0){ if (volume == 0){
strength = 0; strength = 0;
} else { } else {
Char ch; Char ch;
for (int i = 0; i < LENGTH; i++) { for (int i = 0; i < LENGTH; i++) {
if (cur[i] > 0 && (ch = Actor.findChar(i)) != null) { if (cur[i] > 0 && (ch = Actor.findChar(i)) != null) {
if (!ch.immunities().contains(this.getClass())) if (!ch.immunities().contains(this.getClass()))
Buff.affect(ch, Venom.class).set(2f, strength); Buff.affect(ch, Venom.class).set(2f, strength);
} }
} }
} }
} }
public void setStrength(int str){ public void setStrength(int str){
if (str > strength) if (str > strength)
strength = str; strength = str;
} }
private static final String STRENGTH = "strength"; private static final String STRENGTH = "strength";
@Override @Override
public void restoreFromBundle(Bundle bundle) { public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle); super.restoreFromBundle(bundle);
strength = bundle.getInt( STRENGTH ); strength = bundle.getInt( STRENGTH );
} }
@Override @Override
public void storeInBundle(Bundle bundle) { public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle); super.storeInBundle(bundle);
bundle.put( STRENGTH, strength ); bundle.put( STRENGTH, strength );
} }
@Override @Override
public void use( BlobEmitter emitter ) { public void use( BlobEmitter emitter ) {
super.use( emitter ); super.use( emitter );
emitter.pour( Speck.factory(Speck.VENOM), 0.6f ); emitter.pour( Speck.factory(Speck.VENOM), 0.6f );
} }
@Override @Override
public String tileDesc() { public String tileDesc() {
return "A could of foul acidic venom is swirling here."; return "A could of foul acidic venom is swirling here.";
} }
} }

View File

@ -94,13 +94,13 @@ public class WaterOfAwareness extends WellWater {
@Override @Override
public void use( BlobEmitter emitter ) { public void use( BlobEmitter emitter ) {
super.use( emitter ); super.use( emitter );
emitter.pour( Speck.factory( Speck.QUESTION ), 0.3f ); emitter.pour( Speck.factory( Speck.QUESTION ), 0.3f );
} }
@Override @Override
public String tileDesc() { public String tileDesc() {
return return
"Power of knowledge radiates from the water of this well. " + "Power of knowledge radiates from the water of this well. " +
"Take a sip from it to reveal all secrets of equipped items."; "Take a sip from it to reveal all secrets of equipped items.";
} }

View File

@ -70,13 +70,13 @@ public class WaterOfHealth extends WellWater {
@Override @Override
public void use( BlobEmitter emitter ) { public void use( BlobEmitter emitter ) {
super.use( emitter ); super.use( emitter );
emitter.start( Speck.factory( Speck.HEALING ), 0.5f, 0 ); emitter.start( Speck.factory( Speck.HEALING ), 0.5f, 0 );
} }
@Override @Override
public String tileDesc() { public String tileDesc() {
return return
"Power of health radiates from the water of this well. " + "Power of health radiates from the water of this well. " +
"Take a sip from it to heal your wounds and satisfy hunger."; "Take a sip from it to heal your wounds and satisfy hunger.";
} }

View File

@ -55,7 +55,7 @@ public class WaterOfTransmutation extends WellWater {
item = changeSeed( (Plant.Seed)item ); item = changeSeed( (Plant.Seed)item );
} else if (item instanceof Artifact) { } else if (item instanceof Artifact) {
item = changeArtifact( (Artifact)item ); item = changeArtifact( (Artifact)item );
} else { } else {
item = null; item = null;
} }
@ -69,7 +69,7 @@ public class WaterOfTransmutation extends WellWater {
@Override @Override
public void use( BlobEmitter emitter ) { public void use( BlobEmitter emitter ) {
super.use( emitter ); super.use( emitter );
emitter.start( Speck.factory( Speck.CHANGE ), 0.2f, 0 ); emitter.start( Speck.factory( Speck.CHANGE ), 0.2f, 0 );
} }
@ -149,18 +149,18 @@ public class WaterOfTransmutation extends WellWater {
return n; return n;
} }
private Artifact changeArtifact( Artifact a ) { private Artifact changeArtifact( Artifact a ) {
Artifact n = Generator.randomArtifact(); Artifact n = Generator.randomArtifact();
if (n != null){ if (n != null){
n.cursedKnown = a.cursedKnown; n.cursedKnown = a.cursedKnown;
n.cursed = a.cursed; n.cursed = a.cursed;
n.levelKnown = a.levelKnown; n.levelKnown = a.levelKnown;
n.transferUpgrade(a.visiblyUpgraded()); n.transferUpgrade(a.visiblyUpgraded());
} }
return n; return n;
} }
private Wand changeWand( Wand w ) { private Wand changeWand( Wand w ) {
@ -231,7 +231,7 @@ public class WaterOfTransmutation extends WellWater {
@Override @Override
public String tileDesc() { public String tileDesc() {
return return
"Power of change radiates from the water of this well. " + "Power of change radiates from the water of this well. " +
"Throw an item into the well to turn it into something else."; "Throw an item into the well to turn it into something else.";
} }

View File

@ -132,9 +132,9 @@ public class WellWater extends Blob {
for (Class<?>waterClass : waters) { for (Class<?>waterClass : waters) {
WellWater water = (WellWater)Dungeon.level.blobs.get( waterClass ); WellWater water = (WellWater)Dungeon.level.blobs.get( waterClass );
if (water != null && if (water != null &&
water.volume > 0 && water.volume > 0 &&
water.pos == cell && water.pos == cell &&
water.affect()) { water.affect()) {
Level.set( cell, Terrain.EMPTY_WELL ); Level.set( cell, Terrain.EMPTY_WELL );

View File

@ -31,14 +31,14 @@ public class Amok extends FlavourBuff {
return BuffIndicator.AMOK; return BuffIndicator.AMOK;
} }
@Override @Override
public void detach() { public void detach() {
super.detach(); super.detach();
if (target instanceof Mob) if (target instanceof Mob)
((Mob)target).aggro( null ); ((Mob)target).aggro( null );
} }
@Override @Override
public String toString() { public String toString() {
return "Amok"; return "Amok";
} }

View File

@ -72,7 +72,7 @@ public class Bleeding extends Buff {
target.damage( level, this ); target.damage( level, this );
if (target.sprite.visible) { if (target.sprite.visible) {
Splash.at( target.sprite.center(), -PointF.PI / 2, PointF.PI / 6, Splash.at( target.sprite.center(), -PointF.PI / 2, PointF.PI / 6,
target.sprite.blood(), Math.min( 10 * level / target.HT, 10 ) ); target.sprite.blood(), Math.min( 10 * level / target.HT, 10 ) );
} }

View File

@ -3,9 +3,6 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
/**
* Created by debenhame on 27/04/2015.
*/
public class Bless extends FlavourBuff { public class Bless extends FlavourBuff {
{ {

View File

@ -37,9 +37,9 @@ public class Buff extends Actor {
public enum buffType {POSITIVE, NEGATIVE, NEUTRAL, SILENT}; public enum buffType {POSITIVE, NEGATIVE, NEUTRAL, SILENT};
public buffType type = buffType.SILENT; public buffType type = buffType.SILENT;
public HashSet<Class<?>> resistances = new HashSet<Class<?>>(); public HashSet<Class<?>> resistances = new HashSet<Class<?>>();
public HashSet<Class<?>> immunities = new HashSet<Class<?>>(); public HashSet<Class<?>> immunities = new HashSet<Class<?>>();
public boolean attachTo( Char target ) { public boolean attachTo( Char target ) {
@ -50,11 +50,11 @@ public class Buff extends Actor {
this.target = target; this.target = target;
target.add( this ); target.add( this );
if (target.buffs().contains(this)){ if (target.buffs().contains(this)){
if (target.sprite != null) fx( true ); if (target.sprite != null) fx( true );
return true; return true;
} else } else
return false; return false;
} }
public void detach() { public void detach() {

View File

@ -89,7 +89,7 @@ public class Burning extends Buff implements Hero.Doom {
} else if (item instanceof MysteryMeat) { } else if (item instanceof MysteryMeat) {
item = item.detach( hero.belongings.backpack ); item = item.detach( hero.belongings.backpack );
ChargrilledMeat steak = new ChargrilledMeat(); ChargrilledMeat steak = new ChargrilledMeat();
if (!steak.collect( hero.belongings.backpack )) { if (!steak.collect( hero.belongings.backpack )) {
Dungeon.level.drop( steak, hero.pos ).sprite.drop(); Dungeon.level.drop( steak, hero.pos ).sprite.drop();
} }

View File

@ -15,9 +15,6 @@ import com.watabou.utils.Random;
import java.text.DecimalFormat; import java.text.DecimalFormat;
/**
* Created by debenhame on 23/04/2015.
*/
public class Chill extends FlavourBuff { public class Chill extends FlavourBuff {
private static final String TXT_FREEZES = "%s freezes!"; private static final String TXT_FREEZES = "%s freezes!";

View File

@ -3,9 +3,6 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
/**
* Created by Evan on 14/05/2015.
*/
public class Corruption extends Buff { public class Corruption extends Buff {
{ {

View File

@ -23,43 +23,43 @@ import com.watabou.utils.Random;
public class Drowsy extends Buff { public class Drowsy extends Buff {
{ {
type = buffType.NEUTRAL; type = buffType.NEUTRAL;
} }
@Override @Override
public int icon() { public int icon() {
return BuffIndicator.DROWSY; return BuffIndicator.DROWSY;
} }
public boolean attachTo( Char target ) { public boolean attachTo( Char target ) {
if (!target.immunities().contains(Sleep.class) && super.attachTo(target)) { if (!target.immunities().contains(Sleep.class) && super.attachTo(target)) {
if (cooldown() == 0) if (cooldown() == 0)
spend(Random.Int(3, 6)); spend(Random.Int(3, 6));
return true; return true;
} }
return false; return false;
} }
@Override @Override
public boolean act(){ public boolean act(){
Buff.affect(target, MagicalSleep.class); Buff.affect(target, MagicalSleep.class);
detach(); detach();
return true; return true;
} }
@Override @Override
public String toString() { public String toString() {
return "Drowsy"; return "Drowsy";
} }
@Override @Override
public String desc() { public String desc() {
return "A magical force is making it difficult to stay awake.\n" + return "A magical force is making it difficult to stay awake.\n" +
"\n" + "\n" +
"The hero can resist drowsiness by taking damage or by being at full health.\n" + "The hero can resist drowsiness by taking damage or by being at full health.\n" +
"\n" + "\n" +
"After " + dispTurns(cooldown()+1) + ", the target will fall into a deep magical sleep."; "After " + dispTurns(cooldown()+1) + ", the target will fall into a deep magical sleep.";
} }
} }

View File

@ -8,40 +8,37 @@ import com.watabou.utils.Bundle;
import java.util.HashSet; import java.util.HashSet;
/**
* Created by debenhame on 19/11/2014.
*/
public class EarthImbue extends FlavourBuff { public class EarthImbue extends FlavourBuff {
public static final float DURATION = 30f; public static final float DURATION = 30f;
public void proc(Char enemy){ public void proc(Char enemy){
Buff.affect(enemy, Roots.class, 2); Buff.affect(enemy, Roots.class, 2);
CellEmitter.bottom(enemy.pos).start(EarthParticle.FACTORY, 0.05f, 8); CellEmitter.bottom(enemy.pos).start(EarthParticle.FACTORY, 0.05f, 8);
} }
@Override @Override
public int icon() { public int icon() {
return BuffIndicator.ROOTS; return BuffIndicator.ROOTS;
} }
@Override @Override
public String toString() { public String toString() {
return "Imbued with Earth"; return "Imbued with Earth";
} }
@Override @Override
public String desc() { public String desc() {
return "You are inbued with the power of earth!\n" + return "You are inbued with the power of earth!\n" +
"\n" + "\n" +
"All physical attacks will command roots to lock the enemy in place while the effect lasts.\n" + "All physical attacks will command roots to lock the enemy in place while the effect lasts.\n" +
"\n" + "\n" +
"You are imbued for " + dispTurns() + "."; "You are imbued for " + dispTurns() + ".";
} }
{ {
immunities.add( Paralysis.class ); immunities.add( Paralysis.class );
immunities.add( Roots.class ); immunities.add( Roots.class );
immunities.add( Slow.class ); immunities.add( Slow.class );
} }
} }

View File

@ -11,77 +11,74 @@ import com.watabou.utils.Random;
import java.util.HashSet; import java.util.HashSet;
/**
* Created by debenhame on 19/11/2014.
*/
public class FireImbue extends Buff { public class FireImbue extends Buff {
public static final float DURATION = 30f; public static final float DURATION = 30f;
protected float left; protected float left;
private static final String LEFT = "left"; private static final String LEFT = "left";
@Override @Override
public void storeInBundle( Bundle bundle ) { public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle ); super.storeInBundle( bundle );
bundle.put( LEFT, left ); bundle.put( LEFT, left );
} }
@Override @Override
public void restoreFromBundle( Bundle bundle ) { public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle ); super.restoreFromBundle( bundle );
left = bundle.getFloat( LEFT ); left = bundle.getFloat( LEFT );
} }
public void set( float duration ) { public void set( float duration ) {
this.left = duration; this.left = duration;
}; };
@Override @Override
public boolean act() { public boolean act() {
if (Dungeon.level.map[target.pos] == Terrain.GRASS) { if (Dungeon.level.map[target.pos] == Terrain.GRASS) {
Dungeon.level.set(target.pos, Terrain.EMBERS); Dungeon.level.set(target.pos, Terrain.EMBERS);
GameScene.updateMap(target.pos); GameScene.updateMap(target.pos);
} }
spend(TICK); spend(TICK);
left -= TICK; left -= TICK;
if (left <= 0) if (left <= 0)
detach(); detach();
return true; return true;
} }
public void proc(Char enemy){ public void proc(Char enemy){
if (Random.Int(2) == 0) if (Random.Int(2) == 0)
Buff.affect( enemy, Burning.class ).reignite( enemy ); Buff.affect( enemy, Burning.class ).reignite( enemy );
enemy.sprite.emitter().burst( FlameParticle.FACTORY, 2 ); enemy.sprite.emitter().burst( FlameParticle.FACTORY, 2 );
} }
@Override @Override
public int icon() { public int icon() {
return BuffIndicator.FIRE; return BuffIndicator.FIRE;
} }
@Override @Override
public String toString() { public String toString() {
return "Imbued with Fire"; return "Imbued with Fire";
} }
@Override @Override
public String desc() { public String desc() {
return "You are imbued with the power of fire!\n" + return "You are imbued with the power of fire!\n" +
"\n" + "\n" +
"All physical attacks will have a chance to light enemies ablaze. " + "All physical attacks will have a chance to light enemies ablaze. " +
"Additionally, you are completely immune to the effects of fire.\n" + "Additionally, you are completely immune to the effects of fire.\n" +
"\n" + "\n" +
"You are imbued for " + dispTurns(left) + "."; "You are imbued for " + dispTurns(left) + ".";
} }
{ {
immunities.add( Burning.class ); immunities.add( Burning.class );
} }
} }

View File

@ -62,7 +62,7 @@ public class Frost extends FlavourBuff {
} else if (item instanceof MysteryMeat) { } else if (item instanceof MysteryMeat) {
item = item.detach( hero.belongings.backpack ); item = item.detach( hero.belongings.backpack );
FrozenCarpaccio carpaccio = new FrozenCarpaccio(); FrozenCarpaccio carpaccio = new FrozenCarpaccio();
if (!carpaccio.collect( hero.belongings.backpack )) { if (!carpaccio.collect( hero.belongings.backpack )) {
Dungeon.level.drop( carpaccio, target.pos ).sprite.drop(); Dungeon.level.drop( carpaccio, target.pos ).sprite.drop();
} }

View File

@ -39,10 +39,10 @@ public class GasesImmunity extends FlavourBuff {
} }
{ {
immunities.add( ParalyticGas.class ); immunities.add( ParalyticGas.class );
immunities.add( ToxicGas.class ); immunities.add( ToxicGas.class );
immunities.add( ConfusionGas.class ); immunities.add( ConfusionGas.class );
immunities.add( StenchGas.class ); immunities.add( StenchGas.class );
immunities.add( VenomGas.class ); immunities.add( VenomGas.class );
} }

View File

@ -44,8 +44,8 @@ public class Invisibility extends FlavourBuff {
@Override @Override
public void detach() { public void detach() {
if (target.invisible > 0) if (target.invisible > 0)
target.invisible--; target.invisible--;
super.detach(); super.detach();
} }
@ -80,15 +80,15 @@ public class Invisibility extends FlavourBuff {
if (buff != null) { if (buff != null) {
buff.detach(); buff.detach();
} }
CloakOfShadows.cloakStealth cloakBuff = Dungeon.hero.buff( CloakOfShadows.cloakStealth.class ); CloakOfShadows.cloakStealth cloakBuff = Dungeon.hero.buff( CloakOfShadows.cloakStealth.class );
if (cloakBuff != null) { if (cloakBuff != null) {
cloakBuff.act(); cloakBuff.act();
cloakBuff.detach(); cloakBuff.detach();
} }
//this isn't a form of invisibilty, but it is meant to dispel at the same time as it. //this isn't a form of invisibilty, but it is meant to dispel at the same time as it.
TimekeepersHourglass.timeFreeze timeFreeze = Dungeon.hero.buff( TimekeepersHourglass.timeFreeze.class ); TimekeepersHourglass.timeFreeze timeFreeze = Dungeon.hero.buff( TimekeepersHourglass.timeFreeze.class );
if (timeFreeze != null) { if (timeFreeze != null) {
timeFreeze.detach(); timeFreeze.detach();
} }
} }
} }

View File

@ -3,9 +3,6 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
/**
* Created by Evan on 04/04/2015.
*/
public class LockedFloor extends Buff { public class LockedFloor extends Buff {
//this buff is purely meant as a visual indicator that the gameplay implications of a level seal are in effect. //this buff is purely meant as a visual indicator that the gameplay implications of a level seal are in effect.

View File

@ -25,70 +25,70 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class MagicalSleep extends Buff { public class MagicalSleep extends Buff {
private static final float STEP = 1f; private static final float STEP = 1f;
public static final float SWS = 1.5f; public static final float SWS = 1.5f;
@Override @Override
public boolean attachTo( Char target ) { public boolean attachTo( Char target ) {
if (super.attachTo( target ) && !target.immunities().contains(Sleep.class)) { if (super.attachTo( target ) && !target.immunities().contains(Sleep.class)) {
if (target instanceof Hero) if (target instanceof Hero)
if (target.HP == target.HT) { if (target.HP == target.HT) {
GLog.i("You are too healthy, and resist the urge to sleep."); GLog.i("You are too healthy, and resist the urge to sleep.");
detach(); detach();
return true; return true;
} else { } else {
GLog.i("You fall into a deep magical sleep."); GLog.i("You fall into a deep magical sleep.");
} }
else if (target instanceof Mob) else if (target instanceof Mob)
((Mob)target).state = ((Mob)target).SLEEPING; ((Mob)target).state = ((Mob)target).SLEEPING;
target.paralysed = true; target.paralysed = true;
return true; return true;
} else { } else {
return false; return false;
} }
} }
@Override @Override
public boolean act(){ public boolean act(){
if (target instanceof Hero) { if (target instanceof Hero) {
target.HP = Math.min(target.HP+1, target.HT); target.HP = Math.min(target.HP+1, target.HT);
((Hero) target).restoreHealth = true; ((Hero) target).restoreHealth = true;
if (target.HP == target.HT) { if (target.HP == target.HT) {
GLog.p("You wake up feeling refreshed and healthy."); GLog.p("You wake up feeling refreshed and healthy.");
detach(); detach();
} }
} }
spend( STEP ); spend( STEP );
return true; return true;
} }
@Override @Override
public void detach() { public void detach() {
target.paralysed = false; target.paralysed = false;
if (target instanceof Hero) if (target instanceof Hero)
((Hero) target).restoreHealth = false; ((Hero) target).restoreHealth = false;
super.detach(); super.detach();
} }
@Override @Override
public int icon() { public int icon() {
return BuffIndicator.MAGIC_SLEEP; return BuffIndicator.MAGIC_SLEEP;
} }
@Override @Override
public String toString() { public String toString() {
return "Magical Sleep"; return "Magical Sleep";
} }
@Override @Override
public String desc() { public String desc() {
return "This character has fallen into a deep magical sleep which they will not wake from naturally.\n" + return "This character has fallen into a deep magical sleep which they will not wake from naturally.\n" +
"\n" + "\n" +
"Magical sleep is similar to regular sleep, except that only damage will cause the target to wake up. \n" + "Magical sleep is similar to regular sleep, except that only damage will cause the target to wake up. \n" +
"\n" + "\n" +
"For the hero, magical sleep has some restorative properties, allowing them to rapidly heal while resting."; "For the hero, magical sleep has some restorative properties, allowing them to rapidly heal while resting.";
} }
} }

View File

@ -55,10 +55,10 @@ public class Ooze extends Buff {
@Override @Override
public boolean act() { public boolean act() {
if (target.isAlive()) { if (target.isAlive()) {
if (Dungeon.depth > 4) if (Dungeon.depth > 4)
target.damage( Dungeon.depth/5, this ); target.damage( Dungeon.depth/5, this );
else if (Random.Int(2) == 0) else if (Random.Int(2) == 0)
target.damage( 1, this ); target.damage( 1, this );
if (!target.isAlive() && target == Dungeon.hero) { if (!target.isAlive() && target == Dungeon.hero) {
Dungeon.fail( ResultDescriptions.OOZE ); Dungeon.fail( ResultDescriptions.OOZE );
GLog.n( TXT_HERO_KILLED, toString() ); GLog.n( TXT_HERO_KILLED, toString() );

View File

@ -9,9 +9,6 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.LinkedList; import java.util.LinkedList;
/**
* Created by debenhame on 06/02/2015.
*/
public class PinCushion extends Buff { public class PinCushion extends Buff {
private ArrayList<MissileWeapon> items = new ArrayList<MissileWeapon>(); private ArrayList<MissileWeapon> items = new ArrayList<MissileWeapon>();

View File

@ -31,7 +31,7 @@ public class Regeneration extends Buff {
if (target.HP < target.HT && !((Hero)target).isStarving()) { if (target.HP < target.HT && !((Hero)target).isStarving()) {
target.HP += 1; target.HP += 1;
} }
@ -42,8 +42,8 @@ public class Regeneration extends Buff {
spend( REGENERATION_DELAY * 1.5f ); spend( REGENERATION_DELAY * 1.5f );
else else
spend( REGENERATION_DELAY - regenBuff.level()*0.9f ); spend( REGENERATION_DELAY - regenBuff.level()*0.9f );
else else
spend( REGENERATION_DELAY ); spend( REGENERATION_DELAY );
} else { } else {

View File

@ -8,69 +8,66 @@ import com.watabou.utils.Bundle;
import java.util.HashSet; import java.util.HashSet;
/**
* Created by debenhame on 19/11/2014.
*/
public class ToxicImbue extends Buff { public class ToxicImbue extends Buff {
public static final float DURATION = 30f; public static final float DURATION = 30f;
protected float left; protected float left;
private static final String LEFT = "left"; private static final String LEFT = "left";
@Override @Override
public void storeInBundle( Bundle bundle ) { public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle ); super.storeInBundle( bundle );
bundle.put( LEFT, left ); bundle.put( LEFT, left );
} }
@Override @Override
public void restoreFromBundle( Bundle bundle ) { public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle ); super.restoreFromBundle( bundle );
left = bundle.getFloat( LEFT ); left = bundle.getFloat( LEFT );
} }
public void set( float duration ) { public void set( float duration ) {
this.left = duration; this.left = duration;
}; };
@Override @Override
public boolean act() { public boolean act() {
GameScene.add(Blob.seed(target.pos, 50, ToxicGas.class)); GameScene.add(Blob.seed(target.pos, 50, ToxicGas.class));
spend(TICK); spend(TICK);
left -= TICK; left -= TICK;
if (left <= 0) if (left <= 0)
detach(); detach();
return true; return true;
} }
@Override @Override
public int icon() { public int icon() {
return BuffIndicator.IMMUNITY; return BuffIndicator.IMMUNITY;
} }
@Override @Override
public String toString() { public String toString() {
return "Imbued with Toxicity"; return "Imbued with Toxicity";
} }
@Override @Override
public String desc() { public String desc() {
return "You are imbued with poisonous energy!\n" + return "You are imbued with poisonous energy!\n" +
"\n" + "\n" +
"As you move around toxic gas will constantly billow forth from you, damaging your enemies. " + "As you move around toxic gas will constantly billow forth from you, damaging your enemies. " +
"You are immune to toxic gas and poison for the duration of the effect.\n" + "You are immune to toxic gas and poison for the duration of the effect.\n" +
"\n" + "\n" +
"You are imbued for " + dispTurns(left) + "."; "You are imbued for " + dispTurns(left) + ".";
} }
{ {
immunities.add( ToxicGas.class ); immunities.add( ToxicGas.class );
immunities.add( Poison.class ); immunities.add( Poison.class );
} }
} }

View File

@ -5,73 +5,70 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.watabou.utils.Bundle; import com.watabou.utils.Bundle;
/**
* Created by Evan on 12/04/2015.
*/
public class Venom extends Poison implements Hero.Doom { public class Venom extends Poison implements Hero.Doom {
private int damage = 1; private int damage = 1;
private static final String DAMAGE = "damage"; private static final String DAMAGE = "damage";
{ {
type = buffType.NEGATIVE; type = buffType.NEGATIVE;
} }
@Override @Override
public void storeInBundle( Bundle bundle ) { public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle ); super.storeInBundle( bundle );
bundle.put( DAMAGE, damage ); bundle.put( DAMAGE, damage );
} }
@Override @Override
public void restoreFromBundle( Bundle bundle ) { public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle ); super.restoreFromBundle( bundle );
damage = bundle.getInt( DAMAGE ); damage = bundle.getInt( DAMAGE );
} }
public void set(float duration, int damage) { public void set(float duration, int damage) {
set(duration); set(duration);
this.damage = damage; this.damage = damage;
} }
@Override @Override
public int icon() { public int icon() {
return BuffIndicator.POISON; return BuffIndicator.POISON;
} }
@Override @Override
public String toString() { public String toString() {
return "Venomed"; return "Venomed";
} }
@Override @Override
public String desc() { public String desc() {
return "Venom is a extremely caustic and dangerous poison.\n" + return "Venom is a extremely caustic and dangerous poison.\n" +
"\n" + "\n" +
"Unlike poison, whose damage lowers over time, venom does increasing damage the longer it stays on a target.\n" + "Unlike poison, whose damage lowers over time, venom does increasing damage the longer it stays on a target.\n" +
"\n" + "\n" +
"This venom will last for " + dispTurns(left) + ", and is currently dealing " + damage + " damage."; "This venom will last for " + dispTurns(left) + ", and is currently dealing " + damage + " damage.";
} }
@Override @Override
public boolean act() { public boolean act() {
if (target.isAlive()) { if (target.isAlive()) {
target.damage(damage, this); target.damage(damage, this);
if (damage < ((Dungeon.depth+1)/2)+1) if (damage < ((Dungeon.depth+1)/2)+1)
damage++; damage++;
//want it to act after the cloud of venom it came from. //want it to act after the cloud of venom it came from.
spend( TICK+0.1f ); spend( TICK+0.1f );
if ((left -= TICK) <= 0) { if ((left -= TICK) <= 0) {
detach(); detach();
} }
} else { } else {
detach(); detach();
} }
return true; return true;
} }
} }

View File

@ -22,34 +22,34 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
public class Vertigo extends FlavourBuff { public class Vertigo extends FlavourBuff {
public static final float DURATION = 10f; public static final float DURATION = 10f;
{ {
type = buffType.NEGATIVE; type = buffType.NEGATIVE;
} }
@Override @Override
public int icon() { public int icon() {
return BuffIndicator.VERTIGO; return BuffIndicator.VERTIGO;
} }
@Override @Override
public String toString() { public String toString() {
return "Vertigo"; return "Vertigo";
} }
@Override @Override
public String desc() { public String desc() {
return "Walking in a straight line can be difficult when the whole world is spinning.\n" + return "Walking in a straight line can be difficult when the whole world is spinning.\n" +
"\n" + "\n" +
"While under the effects of vertigo, characters who attempt to move will go in a random direction, " + "While under the effects of vertigo, characters who attempt to move will go in a random direction, " +
"instead of the one they intended to go in. \n" + "instead of the one they intended to go in. \n" +
"\n" + "\n" +
"This Vertigo effect with last for " + dispTurns() + "."; "This Vertigo effect with last for " + dispTurns() + ".";
} }
public static float duration( Char ch ) { public static float duration( Char ch ) {
Resistance r = ch.buff( Resistance.class ); Resistance r = ch.buff( Resistance.class );
return r != null ? r.durationFactor() * DURATION : DURATION; return r != null ? r.durationFactor() * DURATION : DURATION;
} }
} }

View File

@ -128,16 +128,16 @@ public class Belongings implements Iterable<Item> {
return null; return null;
} }
public void countIronKeys() { public void countIronKeys() {
IronKey.curDepthQuantity = 0; IronKey.curDepthQuantity = 0;
for (Item item : backpack) { for (Item item : backpack) {
if (item instanceof IronKey && ((IronKey)item).depth == Dungeon.depth) { if (item instanceof IronKey && ((IronKey)item).depth == Dungeon.depth) {
IronKey.curDepthQuantity += item.quantity(); IronKey.curDepthQuantity += item.quantity();
} }
} }
} }
public void identify() { public void identify() {
for (Item item : this) { for (Item item : this) {
@ -248,7 +248,7 @@ public class Belongings implements Iterable<Item> {
@Override @Override
public Iterator<Item> iterator() { public Iterator<Item> iterator() {
return new ItemIterator(); return new ItemIterator();
} }
private class ItemIterator implements Iterator<Item> { private class ItemIterator implements Iterator<Item> {

View File

@ -124,7 +124,7 @@ public class Hero extends Char {
public static final int MAX_LEVEL = 30; public static final int MAX_LEVEL = 30;
private static final String TXT_LEVEL_UP = "level up!"; private static final String TXT_LEVEL_UP = "level up!";
private static final String TXT_NEW_LEVEL = private static final String TXT_NEW_LEVEL =
"Welcome to level %d! Now you are healthier and more focused. " + "Welcome to level %d! Now you are healthier and more focused. " +
"It's easier for you to hit enemies and dodge their attacks."; "It's easier for you to hit enemies and dodge their attacks.";
private static final String TXT_LEVEL_CAP = private static final String TXT_LEVEL_CAP =
@ -152,8 +152,8 @@ public class Hero extends Char {
private int defenseSkill = 5; private int defenseSkill = 5;
public boolean ready = false; public boolean ready = false;
private boolean damageInterrupt = true; private boolean damageInterrupt = true;
public HeroAction curAction = null; public HeroAction curAction = null;
public HeroAction lastAction = null; public HeroAction lastAction = null;
private Char enemy; private Char enemy;
@ -162,7 +162,7 @@ public class Hero extends Char {
public boolean restoreHealth = false; public boolean restoreHealth = false;
public MissileWeapon rangedWeapon = null; public MissileWeapon rangedWeapon = null;
public Belongings belongings; public Belongings belongings;
public int STR; public int STR;
@ -173,7 +173,7 @@ public class Hero extends Char {
public int lvl = 1; public int lvl = 1;
public int exp = 0; public int exp = 0;
private ArrayList<Mob> visibleEnemies; private ArrayList<Mob> visibleEnemies;
public Hero() { public Hero() {
super(); super();
@ -189,11 +189,11 @@ public class Hero extends Char {
} }
public int STR() { public int STR() {
int STR = this.STR; int STR = this.STR;
for (Buff buff : buffs(RingOfMight.Might.class)) { for (Buff buff : buffs(RingOfMight.Might.class)) {
STR += ((RingOfMight.Might)buff).level; STR += ((RingOfMight.Might)buff).level;
} }
return weakened ? STR - 2 : STR; return weakened ? STR - 2 : STR;
} }
@ -255,7 +255,7 @@ public class Hero extends Char {
} }
public void live() { public void live() {
Buff.affect( this, Regeneration.class ); Buff.affect( this, Regeneration.class );
Buff.affect( this, Hunger.class ); Buff.affect( this, Hunger.class );
} }
@ -263,29 +263,29 @@ public class Hero extends Char {
return belongings.armor == null ? 0 : belongings.armor.tier; return belongings.armor == null ? 0 : belongings.armor.tier;
} }
public boolean shoot( Char enemy, MissileWeapon wep ) { public boolean shoot( Char enemy, MissileWeapon wep ) {
rangedWeapon = wep; rangedWeapon = wep;
boolean result = attack( enemy ); boolean result = attack( enemy );
Invisibility.dispel(); Invisibility.dispel();
rangedWeapon = null; rangedWeapon = null;
return result; return result;
} }
@Override @Override
public int attackSkill( Char target ) { public int attackSkill( Char target ) {
float accuracy = 1; float accuracy = 1;
if (rangedWeapon != null && Level.distance( pos, target.pos ) == 1) { if (rangedWeapon != null && Level.distance( pos, target.pos ) == 1) {
accuracy *= 0.5f; accuracy *= 0.5f;
} }
KindOfWeapon wep = rangedWeapon != null ? rangedWeapon : belongings.weapon; KindOfWeapon wep = rangedWeapon != null ? rangedWeapon : belongings.weapon;
if (wep != null) { if (wep != null) {
return (int)(attackSkill * accuracy * wep.acuracyFactor( this )); return (int)(attackSkill * accuracy * wep.acuracyFactor( this ));
} else { } else {
return (int)(attackSkill * accuracy); return (int)(attackSkill * accuracy);
} }
} }
@Override @Override
@ -327,12 +327,12 @@ public class Hero extends Char {
@Override @Override
public int damageRoll() { public int damageRoll() {
KindOfWeapon wep = rangedWeapon != null ? rangedWeapon : belongings.weapon; KindOfWeapon wep = rangedWeapon != null ? rangedWeapon : belongings.weapon;
int dmg; int dmg;
int bonus = 0; int bonus = 0;
for (Buff buff : buffs( RingOfForce.Force.class )) { for (Buff buff : buffs( RingOfForce.Force.class )) {
bonus += ((RingOfForce.Force)buff).level; bonus += ((RingOfForce.Force)buff).level;
} }
if (wep != null) { if (wep != null) {
dmg = wep.damageRoll( this ) + bonus; dmg = wep.damageRoll( this ) + bonus;
@ -351,15 +351,15 @@ public class Hero extends Char {
@Override @Override
public float speed() { public float speed() {
float speed = super.speed(); float speed = super.speed();
int hasteLevel = 0; int hasteLevel = 0;
for (Buff buff : buffs( RingOfHaste.Haste.class )) { for (Buff buff : buffs( RingOfHaste.Haste.class )) {
hasteLevel += ((RingOfHaste.Haste)buff).level; hasteLevel += ((RingOfHaste.Haste)buff).level;
} }
if (hasteLevel != 0) if (hasteLevel != 0)
speed *= Math.pow(1.2, hasteLevel); speed *= Math.pow(1.2, hasteLevel);
int aEnc = belongings.armor != null ? belongings.armor.STR - STR() : 0; int aEnc = belongings.armor != null ? belongings.armor.STR - STR() : 0;
if (aEnc > 0) { if (aEnc > 0) {
@ -378,29 +378,29 @@ public class Hero extends Char {
} }
public float attackDelay() { public float attackDelay() {
KindOfWeapon wep = rangedWeapon != null ? rangedWeapon : belongings.weapon; KindOfWeapon wep = rangedWeapon != null ? rangedWeapon : belongings.weapon;
if (wep != null) { if (wep != null) {
return wep.speedFactor( this ); return wep.speedFactor( this );
} else { } else {
//Normally putting furor speed on unarmed attacks would be unnecessary //Normally putting furor speed on unarmed attacks would be unnecessary
//But there's going to be that one guy who gets a furor+force ring combo //But there's going to be that one guy who gets a furor+force ring combo
//This is for that one guy, you shall get your fists of fury! //This is for that one guy, you shall get your fists of fury!
int bonus = 0; int bonus = 0;
for (Buff buff : buffs(RingOfFuror.Furor.class)) { for (Buff buff : buffs(RingOfFuror.Furor.class)) {
bonus += ((RingOfFuror.Furor)buff).level; bonus += ((RingOfFuror.Furor)buff).level;
} }
return (float)(0.25 + (1 - 0.25)*Math.pow(0.8, bonus)); return (float)(0.25 + (1 - 0.25)*Math.pow(0.8, bonus));
} }
} }
@Override @Override
public void spend( float time ) { public void spend( float time ) {
TimekeepersHourglass.timeFreeze buff = buff(TimekeepersHourglass.timeFreeze.class); TimekeepersHourglass.timeFreeze buff = buff(TimekeepersHourglass.timeFreeze.class);
if (!(buff != null && buff.processTime(time))) if (!(buff != null && buff.processTime(time)))
super.spend( time ); super.spend( time );
} }
public void spendAndNext( float time ) { public void spendAndNext( float time ) {
busy(); busy();
@ -436,7 +436,7 @@ public class Hero extends Char {
} }
ready(); ready();
return false; return false;
} else { } else {
@ -448,50 +448,50 @@ public class Hero extends Char {
return actMove( (HeroAction.Move)curAction ); return actMove( (HeroAction.Move)curAction );
} else } else
if (curAction instanceof HeroAction.Interact) { if (curAction instanceof HeroAction.Interact) {
return actInteract( (HeroAction.Interact)curAction ); return actInteract( (HeroAction.Interact)curAction );
} else } else
if (curAction instanceof HeroAction.Buy) { if (curAction instanceof HeroAction.Buy) {
return actBuy( (HeroAction.Buy)curAction ); return actBuy( (HeroAction.Buy)curAction );
}else }else
if (curAction instanceof HeroAction.PickUp) { if (curAction instanceof HeroAction.PickUp) {
return actPickUp( (HeroAction.PickUp)curAction ); return actPickUp( (HeroAction.PickUp)curAction );
} else } else
if (curAction instanceof HeroAction.OpenChest) { if (curAction instanceof HeroAction.OpenChest) {
return actOpenChest( (HeroAction.OpenChest)curAction ); return actOpenChest( (HeroAction.OpenChest)curAction );
} else } else
if (curAction instanceof HeroAction.Unlock) { if (curAction instanceof HeroAction.Unlock) {
return actUnlock((HeroAction.Unlock) curAction); return actUnlock((HeroAction.Unlock) curAction);
} else } else
if (curAction instanceof HeroAction.Descend) { if (curAction instanceof HeroAction.Descend) {
return actDescend( (HeroAction.Descend)curAction ); return actDescend( (HeroAction.Descend)curAction );
} else } else
if (curAction instanceof HeroAction.Ascend) { if (curAction instanceof HeroAction.Ascend) {
return actAscend( (HeroAction.Ascend)curAction ); return actAscend( (HeroAction.Ascend)curAction );
} else } else
if (curAction instanceof HeroAction.Attack) { if (curAction instanceof HeroAction.Attack) {
return actAttack( (HeroAction.Attack)curAction ); return actAttack( (HeroAction.Attack)curAction );
} else } else
if (curAction instanceof HeroAction.Cook) { if (curAction instanceof HeroAction.Cook) {
return actCook( (HeroAction.Cook)curAction ); return actCook( (HeroAction.Cook)curAction );
} }
} }
@ -506,10 +506,10 @@ public class Hero extends Char {
private void ready() { private void ready() {
sprite.idle(); sprite.idle();
curAction = null; curAction = null;
damageInterrupt = true; damageInterrupt = true;
ready = true; ready = true;
AttackIndicator.updateState(); AttackIndicator.updateState();
GameScene.ready(); GameScene.ready();
} }
@ -524,7 +524,7 @@ public class Hero extends Char {
public void resume() { public void resume() {
curAction = lastAction; curAction = lastAction;
lastAction = null; lastAction = null;
damageInterrupt = false; damageInterrupt = false;
act(); act();
} }
@ -532,7 +532,7 @@ public class Hero extends Char {
if (getCloser( action.dst )) { if (getCloser( action.dst )) {
return true; return true;
} else { } else {
if (Dungeon.level.map[pos] == Terrain.SIGN) { if (Dungeon.level.map[pos] == Terrain.SIGN) {
@ -540,7 +540,7 @@ public class Hero extends Char {
} }
ready(); ready();
return false; return false;
} }
} }
@ -553,17 +553,17 @@ public class Hero extends Char {
ready(); ready();
sprite.turnTo( pos, npc.pos ); sprite.turnTo( pos, npc.pos );
npc.interact(); npc.interact();
return false; return false;
} else { } else {
if (Level.fieldOfView[npc.pos] && getCloser( npc.pos )) { if (Level.fieldOfView[npc.pos] && getCloser( npc.pos )) {
return true; return true;
} else { } else {
ready(); ready();
return false; return false;
} }
} }
@ -580,15 +580,15 @@ public class Hero extends Char {
GameScene.show( new WndTradeItem( heap, true ) ); GameScene.show( new WndTradeItem( heap, true ) );
} }
return false; return false;
} else if (getCloser( dst )) { } else if (getCloser( dst )) {
return true; return true;
} else { } else {
ready(); ready();
return false; return false;
} }
} }
@ -598,15 +598,15 @@ public class Hero extends Char {
ready(); ready();
AlchemyPot.operate( this, dst ); AlchemyPot.operate( this, dst );
return false; return false;
} else if (getCloser( dst )) { } else if (getCloser( dst )) {
return true; return true;
} else { } else {
ready(); ready();
return false; return false;
} }
} }
@ -615,13 +615,13 @@ public class Hero extends Char {
if (pos == dst) { if (pos == dst) {
Heap heap = Dungeon.level.heaps.get( pos ); Heap heap = Dungeon.level.heaps.get( pos );
if (heap != null) { if (heap != null) {
Item item = heap.pickUp(); Item item = heap.pickUp();
if (item.doPickUp( this )) { if (item.doPickUp( this )) {
if (item instanceof Dewdrop if (item instanceof Dewdrop
|| item instanceof TimekeepersHourglass.sandBag || item instanceof TimekeepersHourglass.sandBag
|| item instanceof DriedRose.Petal) { || item instanceof DriedRose.Petal) {
//Do Nothing //Do Nothing
} else { } else {
@ -645,17 +645,17 @@ public class Hero extends Char {
} }
} else { } else {
ready(); ready();
} }
return false; return false;
} else if (getCloser( dst )) { } else if (getCloser( dst )) {
return true; return true;
} else { } else {
ready(); ready();
return false; return false;
} }
} }
@ -685,7 +685,7 @@ public class Hero extends Char {
Camera.main.shake( 1, 0.5f ); Camera.main.shake( 1, 0.5f );
break; break;
case SKELETON: case SKELETON:
case REMAINS: case REMAINS:
break; break;
default: default:
Sample.INSTANCE.play( Assets.SND_UNLOCK ); Sample.INSTANCE.play( Assets.SND_UNLOCK );
@ -696,18 +696,18 @@ public class Hero extends Char {
} else { } else {
ready(); ready();
} }
return false; return false;
} else if (getCloser( dst )) { } else if (getCloser( dst )) {
return true; return true;
} else { } else {
ready(); ready();
return false; return false;
} }
} }
private boolean actUnlock( HeroAction.Unlock action ) { private boolean actUnlock( HeroAction.Unlock action ) {
@ -737,18 +737,18 @@ public class Hero extends Char {
} else { } else {
GLog.w( TXT_LOCKED_DOOR ); GLog.w( TXT_LOCKED_DOOR );
ready(); ready();
} }
return false; return false;
} else if (getCloser( doorCell )) { } else if (getCloser( doorCell )) {
return true; return true;
} else { } else {
ready(); ready();
return false; return false;
} }
} }
private boolean actDescend( HeroAction.Descend action ) { private boolean actDescend( HeroAction.Descend action ) {
@ -760,22 +760,22 @@ public class Hero extends Char {
Buff buff = buff(TimekeepersHourglass.timeFreeze.class); Buff buff = buff(TimekeepersHourglass.timeFreeze.class);
if (buff != null) buff.detach(); if (buff != null) buff.detach();
for (Mob mob : Dungeon.level.mobs.toArray( new Mob[0] )) for (Mob mob : Dungeon.level.mobs.toArray( new Mob[0] ))
if (mob instanceof DriedRose.GhostHero) mob.destroy(); if (mob instanceof DriedRose.GhostHero) mob.destroy();
InterlevelScene.mode = InterlevelScene.Mode.DESCEND; InterlevelScene.mode = InterlevelScene.Mode.DESCEND;
Game.switchScene( InterlevelScene.class ); Game.switchScene( InterlevelScene.class );
return false; return false;
} else if (getCloser( stairs )) { } else if (getCloser( stairs )) {
return true; return true;
} else { } else {
ready(); ready();
return false; return false;
} }
} }
private boolean actAscend( HeroAction.Ascend action ) { private boolean actAscend( HeroAction.Ascend action ) {
@ -788,7 +788,7 @@ public class Hero extends Char {
GameScene.show( new WndMessage( TXT_LEAVE ) ); GameScene.show( new WndMessage( TXT_LEAVE ) );
ready(); ready();
} else { } else {
Dungeon.win( ResultDescriptions.WIN ); Dungeon.win( ResultDescriptions.WIN );
Dungeon.deleteGame( Dungeon.hero.heroClass, true ); Dungeon.deleteGame( Dungeon.hero.heroClass, true );
Game.switchScene( SurfaceScene.class ); Game.switchScene( SurfaceScene.class );
} }
@ -805,23 +805,23 @@ public class Hero extends Char {
Buff buff = buff(TimekeepersHourglass.timeFreeze.class); Buff buff = buff(TimekeepersHourglass.timeFreeze.class);
if (buff != null) buff.detach(); if (buff != null) buff.detach();
for (Mob mob : Dungeon.level.mobs.toArray( new Mob[0] )) for (Mob mob : Dungeon.level.mobs.toArray( new Mob[0] ))
if (mob instanceof DriedRose.GhostHero) mob.destroy(); if (mob instanceof DriedRose.GhostHero) mob.destroy();
InterlevelScene.mode = InterlevelScene.Mode.ASCEND; InterlevelScene.mode = InterlevelScene.Mode.ASCEND;
Game.switchScene( InterlevelScene.class ); Game.switchScene( InterlevelScene.class );
} }
return false; return false;
} else if (getCloser( stairs )) { } else if (getCloser( stairs )) {
return true; return true;
} else { } else {
ready(); ready();
return false; return false;
} }
} }
private boolean actAttack( HeroAction.Attack action ) { private boolean actAttack( HeroAction.Attack action ) {
@ -831,22 +831,22 @@ public class Hero extends Char {
if (Level.adjacent( pos, enemy.pos ) && enemy.isAlive() && !isCharmedBy( enemy )) { if (Level.adjacent( pos, enemy.pos ) && enemy.isAlive() && !isCharmedBy( enemy )) {
spend( attackDelay() ); spend( attackDelay() );
sprite.attack( enemy.pos ); sprite.attack( enemy.pos );
return false; return false;
} else { } else {
if (Level.fieldOfView[enemy.pos] && getCloser( enemy.pos )) { if (Level.fieldOfView[enemy.pos] && getCloser( enemy.pos )) {
return true; return true;
} else { } else {
ready(); ready();
return false; return false;
} }
} }
} }
public void rest( boolean tillHealthy ) { public void rest( boolean tillHealthy ) {
@ -859,7 +859,7 @@ public class Hero extends Char {
@Override @Override
public int attackProc( Char enemy, int damage ) { public int attackProc( Char enemy, int damage ) {
KindOfWeapon wep = rangedWeapon != null ? rangedWeapon : belongings.weapon; KindOfWeapon wep = rangedWeapon != null ? rangedWeapon : belongings.weapon;
if (wep != null) wep.proc( this, enemy, damage ); if (wep != null) wep.proc( this, enemy, damage );
@ -889,10 +889,10 @@ public class Hero extends Char {
damage = armor.absorb( damage ); damage = armor.absorb( damage );
} }
Sungrass.Health health = buff( Sungrass.Health.class ); Sungrass.Health health = buff( Sungrass.Health.class );
if (health != null) { if (health != null) {
health.absorb( damage ); health.absorb( damage );
} }
if (belongings.armor != null) { if (belongings.armor != null) {
damage = belongings.armor.proc( enemy, this, damage ); damage = belongings.armor.proc( enemy, this, damage );
@ -909,24 +909,24 @@ public class Hero extends Char {
restoreHealth = false; restoreHealth = false;
if (!(src instanceof Hunger || src instanceof Viscosity.DeferedDamage) && damageInterrupt) if (!(src instanceof Hunger || src instanceof Viscosity.DeferedDamage) && damageInterrupt)
interrupt(); interrupt();
if (this.buff(Drowsy.class) != null){ if (this.buff(Drowsy.class) != null){
Buff.detach(this, Drowsy.class); Buff.detach(this, Drowsy.class);
GLog.w("The pain helps you resist the urge to sleep."); GLog.w("The pain helps you resist the urge to sleep.");
} }
CapeOfThorns.Thorns thorns = buff( CapeOfThorns.Thorns.class ); CapeOfThorns.Thorns thorns = buff( CapeOfThorns.Thorns.class );
if (thorns != null) { if (thorns != null) {
dmg = thorns.proc(dmg, (src instanceof Char ? (Char)src : null), this); dmg = thorns.proc(dmg, (src instanceof Char ? (Char)src : null), this);
} }
int tenacity = 0; int tenacity = 0;
for (Buff buff : buffs(RingOfTenacity.Tenacity.class)) { for (Buff buff : buffs(RingOfTenacity.Tenacity.class)) {
tenacity += ((RingOfTenacity.Tenacity)buff).level; tenacity += ((RingOfTenacity.Tenacity)buff).level;
} }
if (tenacity != 0) //(HT - HP)/HT = heroes current % missing health. if (tenacity != 0) //(HT - HP)/HT = heroes current % missing health.
dmg = (int)Math.ceil((float)dmg * Math.pow(0.9, tenacity*((float)(HT - HP)/HT))); dmg = (int)Math.ceil((float)dmg * Math.pow(0.9, tenacity*((float)(HT - HP)/HT)));
super.damage( dmg, src ); super.damage( dmg, src );
@ -979,9 +979,9 @@ public class Hero extends Char {
if (Actor.findChar( target ) == null) { if (Actor.findChar( target ) == null) {
if (Level.pit[target] && !flying && !Chasm.jumpConfirmed) { if (Level.pit[target] && !flying && !Chasm.jumpConfirmed) {
if (!Level.solid[target]) { if (!Level.solid[target]) {
Chasm.heroJump(this); Chasm.heroJump(this);
interrupt(); interrupt();
} }
return false; return false;
} }
if (Level.passable[target] || Level.avoid[target]) { if (Level.passable[target] || Level.avoid[target]) {
@ -1005,9 +1005,9 @@ public class Hero extends Char {
if (step != -1) { if (step != -1) {
int oldPos = pos; int oldPos = pos;
move(step); move(step);
sprite.move(oldPos, pos); sprite.move(oldPos, pos);
spend( 1 / speed() ); spend( 1 / speed() );
return true; return true;
@ -1048,8 +1048,8 @@ public class Hero extends Char {
curAction = new HeroAction.PickUp( cell ); curAction = new HeroAction.PickUp( cell );
break; break;
case FOR_SALE: case FOR_SALE:
curAction = heap.size() == 1 && heap.peek().price() > 0 ? curAction = heap.size() == 1 && heap.peek().price() > 0 ?
new HeroAction.Buy( cell ) : new HeroAction.Buy( cell ) :
new HeroAction.PickUp( cell ); new HeroAction.PickUp( cell );
break; break;
default: default:
@ -1137,9 +1137,9 @@ public class Hero extends Char {
} }
void updateAwareness() { void updateAwareness() {
awareness = (float)(1 - Math.pow( awareness = (float)(1 - Math.pow(
(heroClass == HeroClass.ROGUE ? 0.85 : 0.90), (heroClass == HeroClass.ROGUE ? 0.85 : 0.90),
(1 + Math.min( lvl, 9 )) * 0.5 (1 + Math.min( lvl, 9 )) * 0.5
)); ));
} }
@ -1182,13 +1182,13 @@ public class Hero extends Char {
} else if (buff instanceof Bleeding) { } else if (buff instanceof Bleeding) {
GLog.w( "You are bleeding!" ); GLog.w( "You are bleeding!" );
} else if (buff instanceof RingOfMight.Might){ } else if (buff instanceof RingOfMight.Might){
if (((RingOfMight.Might)buff).level > 0) { if (((RingOfMight.Might)buff).level > 0) {
HT += ((RingOfMight.Might) buff).level * 5; HT += ((RingOfMight.Might) buff).level * 5;
} }
} else if (buff instanceof Vertigo) { } else if (buff instanceof Vertigo) {
GLog.w("Everything is spinning around you!"); GLog.w("Everything is spinning around you!");
interrupt(); interrupt();
} }
} }
@ -1200,11 +1200,11 @@ public class Hero extends Char {
super.remove( buff ); super.remove( buff );
if (buff instanceof RingOfMight.Might){ if (buff instanceof RingOfMight.Might){
if (((RingOfMight.Might)buff).level > 0){ if (((RingOfMight.Might)buff).level > 0){
HT -= ((RingOfMight.Might) buff).level * 5; HT -= ((RingOfMight.Might) buff).level * 5;
HP = Math.min(HT, HP); HP = Math.min(HT, HP);
} }
} }
BuffIndicator.refreshHero(); BuffIndicator.refreshHero();
} }
@ -1223,35 +1223,35 @@ public class Hero extends Char {
curAction = null; curAction = null;
Ankh ankh = null; Ankh ankh = null;
//look for ankhs in player inventory, prioritize ones which are blessed. //look for ankhs in player inventory, prioritize ones which are blessed.
for (Item item : belongings){ for (Item item : belongings){
if (item instanceof Ankh) { if (item instanceof Ankh) {
if (ankh == null || ((Ankh) item).isBlessed()) { if (ankh == null || ((Ankh) item).isBlessed()) {
ankh = (Ankh) item; ankh = (Ankh) item;
} }
} }
} }
if (ankh != null && ankh.isBlessed()) { if (ankh != null && ankh.isBlessed()) {
this.HP = HT/4; this.HP = HT/4;
//ensures that you'll get to act first in almost any case, to prevent reviving and then instantly dieing again. //ensures that you'll get to act first in almost any case, to prevent reviving and then instantly dieing again.
Buff.detach(this, Paralysis.class); Buff.detach(this, Paralysis.class);
spend(-cooldown()); spend(-cooldown());
new Flare(8, 32).color(0xFFFF66, true).show(sprite, 2f); new Flare(8, 32).color(0xFFFF66, true).show(sprite, 2f);
CellEmitter.get(this.pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3); CellEmitter.get(this.pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
ankh.detach(belongings.backpack); ankh.detach(belongings.backpack);
Sample.INSTANCE.play( Assets.SND_TELEPORT ); Sample.INSTANCE.play( Assets.SND_TELEPORT );
GLog.w( ankh.TXT_REVIVE ); GLog.w( ankh.TXT_REVIVE );
Statistics.ankhsUsed++; Statistics.ankhsUsed++;
return; return;
} }
Actor.fixTime(); Actor.fixTime();
super.die( cause ); super.die( cause );
@ -1384,7 +1384,7 @@ public class Hero extends Char {
theKey = null; theKey = null;
} }
Heap heap = Dungeon.level.heaps.get( ((HeroAction.OpenChest)curAction).dst ); Heap heap = Dungeon.level.heaps.get( ((HeroAction.OpenChest)curAction).dst );
if (heap.type == Type.SKELETON || heap.type == Type.REMAINS) { if (heap.type == Type.SKELETON || heap.type == Type.REMAINS) {
Sample.INSTANCE.play( Assets.SND_BONES ); Sample.INSTANCE.play( Assets.SND_BONES );
} }
@ -1429,7 +1429,7 @@ public class Hero extends Char {
by = Level.HEIGHT - 1; by = Level.HEIGHT - 1;
} }
TalismanOfForesight.Foresight foresight = buff( TalismanOfForesight.Foresight.class ); TalismanOfForesight.Foresight foresight = buff( TalismanOfForesight.Foresight.class );
//cursed talisman of foresight makes unintentionally finding things impossible. //cursed talisman of foresight makes unintentionally finding things impossible.
if (foresight != null && foresight.isCursed()){ if (foresight != null && foresight.isCursed()){
@ -1457,8 +1457,8 @@ public class Hero extends Char {
smthFound = true; smthFound = true;
if (foresight != null && !foresight.isCursed()) if (foresight != null && !foresight.isCursed())
foresight.charge(); foresight.charge();
} }
} }
} }
@ -1505,11 +1505,11 @@ public class Hero extends Char {
@Override @Override
public HashSet<Class<?>> immunities() { public HashSet<Class<?>> immunities() {
HashSet<Class<?>> immunities = new HashSet<Class<?>>(); HashSet<Class<?>> immunities = new HashSet<Class<?>>();
for (Buff buff : buffs()){ for (Buff buff : buffs()){
for (Class<?> immunity : buff.immunities) for (Class<?> immunity : buff.immunities)
immunities.add(immunity); immunities.add(immunity);
} }
return immunities; return immunities;
} }

View File

@ -83,110 +83,110 @@ public enum HeroClass {
"Potions of Mind Vision are identified from the beginning." "Potions of Mind Vision are identified from the beginning."
}; };
public void initHero( Hero hero ) { public void initHero( Hero hero ) {
hero.heroClass = this; hero.heroClass = this;
initCommon( hero ); initCommon( hero );
switch (this) { switch (this) {
case WARRIOR: case WARRIOR:
initWarrior( hero ); initWarrior( hero );
break; break;
case MAGE: case MAGE:
initMage( hero ); initMage( hero );
break; break;
case ROGUE: case ROGUE:
initRogue( hero ); initRogue( hero );
break; break;
case HUNTRESS: case HUNTRESS:
initHuntress( hero ); initHuntress( hero );
break; break;
} }
if (Badges.isUnlocked( masteryBadge() )) { if (Badges.isUnlocked( masteryBadge() )) {
new TomeOfMastery().collect(); new TomeOfMastery().collect();
} }
hero.updateAwareness(); hero.updateAwareness();
} }
private static void initCommon( Hero hero ) { private static void initCommon( Hero hero ) {
if (!Dungeon.isChallenged(Challenges.NO_ARMOR)) if (!Dungeon.isChallenged(Challenges.NO_ARMOR))
(hero.belongings.armor = new ClothArmor()).identify(); (hero.belongings.armor = new ClothArmor()).identify();
if (!Dungeon.isChallenged(Challenges.NO_FOOD)) if (!Dungeon.isChallenged(Challenges.NO_FOOD))
new Food().identify().collect(); new Food().identify().collect();
} }
public Badges.Badge masteryBadge() { public Badges.Badge masteryBadge() {
switch (this) { switch (this) {
case WARRIOR: case WARRIOR:
return Badges.Badge.MASTERY_WARRIOR; return Badges.Badge.MASTERY_WARRIOR;
case MAGE: case MAGE:
return Badges.Badge.MASTERY_MAGE; return Badges.Badge.MASTERY_MAGE;
case ROGUE: case ROGUE:
return Badges.Badge.MASTERY_ROGUE; return Badges.Badge.MASTERY_ROGUE;
case HUNTRESS: case HUNTRESS:
return Badges.Badge.MASTERY_HUNTRESS; return Badges.Badge.MASTERY_HUNTRESS;
} }
return null; return null;
} }
private static void initWarrior( Hero hero ) { private static void initWarrior( Hero hero ) {
hero.STR = hero.STR + 1; hero.STR = hero.STR + 1;
(hero.belongings.weapon = new ShortSword()).identify(); (hero.belongings.weapon = new ShortSword()).identify();
Dart darts = new Dart( 8 ); Dart darts = new Dart( 8 );
darts.identify().collect(); darts.identify().collect();
Dungeon.quickslot.setSlot(0, darts); Dungeon.quickslot.setSlot(0, darts);
new PotionOfStrength().setKnown(); new PotionOfStrength().setKnown();
} }
private static void initMage( Hero hero ) { private static void initMage( Hero hero ) {
MagesStaff staff = new MagesStaff(new WandOfMagicMissile()); MagesStaff staff = new MagesStaff(new WandOfMagicMissile());
(hero.belongings.weapon = staff).identify(); (hero.belongings.weapon = staff).identify();
hero.belongings.weapon.activate(hero); hero.belongings.weapon.activate(hero);
Dungeon.quickslot.setSlot(0, staff); Dungeon.quickslot.setSlot(0, staff);
new ScrollOfUpgrade().setKnown(); new ScrollOfUpgrade().setKnown();
} }
private static void initRogue( Hero hero ) { private static void initRogue( Hero hero ) {
(hero.belongings.weapon = new Dagger()).identify(); (hero.belongings.weapon = new Dagger()).identify();
CloakOfShadows cloak = new CloakOfShadows(); CloakOfShadows cloak = new CloakOfShadows();
(hero.belongings.misc1 = cloak).identify(); (hero.belongings.misc1 = cloak).identify();
hero.belongings.misc1.activate( hero ); hero.belongings.misc1.activate( hero );
Dart darts = new Dart( 8 ); Dart darts = new Dart( 8 );
darts.identify().collect(); darts.identify().collect();
Dungeon.quickslot.setSlot(0, cloak); Dungeon.quickslot.setSlot(0, cloak);
if (ShatteredPixelDungeon.quickSlots() > 1) if (ShatteredPixelDungeon.quickSlots() > 1)
Dungeon.quickslot.setSlot(1, darts); Dungeon.quickslot.setSlot(1, darts);
new ScrollOfMagicMapping().setKnown(); new ScrollOfMagicMapping().setKnown();
} }
private static void initHuntress( Hero hero ) { private static void initHuntress( Hero hero ) {
hero.HP = (hero.HT -= 5); hero.HP = (hero.HT -= 5);
(hero.belongings.weapon = new Dagger()).identify(); (hero.belongings.weapon = new Dagger()).identify();
Boomerang boomerang = new Boomerang(); Boomerang boomerang = new Boomerang();
boomerang.identify().collect(); boomerang.identify().collect();
Dungeon.quickslot.setSlot(0, boomerang); Dungeon.quickslot.setSlot(0, boomerang);
new PotionOfMindVision().setKnown(); new PotionOfMindVision().setKnown();
} }
public String title() { public String title() {
return title; return title;

View File

@ -23,30 +23,30 @@ public enum HeroSubClass {
NONE( null, null ), NONE( null, null ),
GLADIATOR( "gladiator", GLADIATOR( "gladiator",
"A successful attack with a melee weapon allows the _Gladiator_ to start a combo, " + "A successful attack with a melee weapon allows the _Gladiator_ to start a combo, " +
"in which every next successful hit inflicts more damage." ), "in which every next successful hit inflicts more damage." ),
BERSERKER( "berserker", BERSERKER( "berserker",
"When severely wounded, the _Berserker_ enters a state of wild fury " + "When severely wounded, the _Berserker_ enters a state of wild fury " +
"significantly increasing his damage output." ), "significantly increasing his damage output." ),
WARLOCK( "warlock", WARLOCK( "warlock",
"Normal food grants the _Warlock_ additional wand recharge, but does not satisfy his hunger. " + "Normal food grants the _Warlock_ additional wand recharge, but does not satisfy his hunger. " +
"Instead, after killing an enemy, he consumes its soul to heal his wounds and satisfy hunger." ), "Instead, after killing an enemy, he consumes its soul to heal his wounds and satisfy hunger." ),
BATTLEMAGE( "battlemage", BATTLEMAGE( "battlemage",
"When fighting with his staff, the _Battlemage_ conjures bonus effects depending on the wand " + "When fighting with his staff, the _Battlemage_ conjures bonus effects depending on the wand " +
"his staff is imbued with. His staff will also gain charge through combat." ), "his staff is imbued with. His staff will also gain charge through combat." ),
ASSASSIN( "assassin", ASSASSIN( "assassin",
"When performing a surprise attack, the _Assassin_ inflicts additional damage to his target." ), "When performing a surprise attack, the _Assassin_ inflicts additional damage to his target." ),
FREERUNNER( "freerunner", FREERUNNER( "freerunner",
"The _Freerunner_ moves faster when he unencumbered and not starving, " + "The _Freerunner_ moves faster when he unencumbered and not starving, " +
"if he is invisible, this speed boost is much stronger." ), "if he is invisible, this speed boost is much stronger." ),
SNIPER( "sniper", SNIPER( "sniper",
"_Snipers_ are able to detect weak points in an enemy's armor, " + "_Snipers_ are able to detect weak points in an enemy's armor, " +
"effectively ignoring it when using a missile weapon." ), "effectively ignoring it when using a missile weapon." ),
WARDEN( "warden", WARDEN( "warden",
"Having a strong connection with forces of nature gives _Wardens_ an ability to gather dewdrops and " + "Having a strong connection with forces of nature gives _Wardens_ an ability to gather dewdrops and " +
"seeds from plants. Also trampling a high grass grants them a temporary armor buff." ); "seeds from plants. Also trampling a high grass grants them a temporary armor buff." );

View File

@ -48,9 +48,9 @@ public class Albino extends Rat {
return damage; return damage;
} }
@Override @Override
public String description() { public String description() {
return return
"This is a rare breed of marsupial rat, with pure white fur and jagged teeth."; "This is a rare breed of marsupial rat, with pure white fur and jagged teeth.";
} }
} }

View File

@ -37,8 +37,8 @@ public class Bandit extends Thief {
name = "crazy bandit"; name = "crazy bandit";
spriteClass = BanditSprite.class; spriteClass = BanditSprite.class;
//1 in 30 chance to be a crazy bandit, equates to overall 1/90 chance. //1 in 30 chance to be a crazy bandit, equates to overall 1/90 chance.
lootChance = 0.333f; lootChance = 0.333f;
} }
@Override @Override
@ -46,8 +46,8 @@ public class Bandit extends Thief {
if (super.steal( hero )) { if (super.steal( hero )) {
Buff.prolong( hero, Blindness.class, Random.Int( 5, 12 ) ); Buff.prolong( hero, Blindness.class, Random.Int( 5, 12 ) );
Buff.affect( hero, Poison.class ).set(Random.Int(5, 7) * Poison.durationFactor(enemy)); Buff.affect( hero, Poison.class ).set(Random.Int(5, 7) * Poison.durationFactor(enemy));
Buff.prolong( hero, Cripple.class, Cripple.DURATION ); Buff.prolong( hero, Cripple.class, Cripple.DURATION );
Dungeon.observe(); Dungeon.observe();
return true; return true;

View File

@ -80,18 +80,18 @@ public class Bat extends Mob {
return damage; return damage;
} }
@Override @Override
public void die( Object cause ){ public void die( Object cause ){
//sets drop chance //sets drop chance
lootChance = 1f/((6 + Dungeon.limitedDrops.batHP.count )); lootChance = 1f/((6 + Dungeon.limitedDrops.batHP.count ));
super.die( cause ); super.die( cause );
} }
@Override @Override
protected Item createLoot(){ protected Item createLoot(){
Dungeon.limitedDrops.batHP.count++; Dungeon.limitedDrops.batHP.count++;
return super.createLoot(); return super.createLoot();
} }
@Override @Override
public String description() { public String description() {

View File

@ -49,23 +49,23 @@ public class Bee extends Mob {
private int potHolder; private int potHolder;
private static final String LEVEL = "level"; private static final String LEVEL = "level";
private static final String POTPOS = "potpos"; private static final String POTPOS = "potpos";
private static final String POTHOLDER = "potholder"; private static final String POTHOLDER = "potholder";
@Override @Override
public void storeInBundle( Bundle bundle ) { public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle ); super.storeInBundle( bundle );
bundle.put( LEVEL, level ); bundle.put( LEVEL, level );
bundle.put( POTPOS, potPos ); bundle.put( POTPOS, potPos );
bundle.put( POTHOLDER, potHolder ); bundle.put( POTHOLDER, potHolder );
} }
@Override @Override
public void restoreFromBundle( Bundle bundle ) { public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle ); super.restoreFromBundle( bundle );
spawn( bundle.getInt( LEVEL ) ); spawn( bundle.getInt( LEVEL ) );
potPos = bundle.getInt( POTPOS ); potPos = bundle.getInt( POTPOS );
potHolder = bundle.getInt( POTHOLDER ); potHolder = bundle.getInt( POTHOLDER );
} }
public void spawn( int level ) { public void spawn( int level ) {
@ -103,37 +103,37 @@ public class Bee extends Mob {
@Override @Override
protected Char chooseEnemy() { protected Char chooseEnemy() {
//if the pot is no longer present, target the hero //if the pot is no longer present, target the hero
if (potHolder == -1 && potPos == -1) if (potHolder == -1 && potPos == -1)
return Dungeon.hero; return Dungeon.hero;
//if something is holding the pot, target that //if something is holding the pot, target that
else if (Actor.findById(potHolder) != null) else if (Actor.findById(potHolder) != null)
return (Char)Actor.findById(potHolder); return (Char)Actor.findById(potHolder);
//if the pot is on the ground //if the pot is on the ground
else { else {
//if already targeting something, and that thing is still alive and near the pot, keeping targeting it. //if already targeting something, and that thing is still alive and near the pot, keeping targeting it.
if (enemy != null && enemy.isAlive() && Level.distance(enemy.pos, potPos) <= 3) return enemy; if (enemy != null && enemy.isAlive() && Level.distance(enemy.pos, potPos) <= 3) return enemy;
//find all mobs near the pot //find all mobs near the pot
HashSet<Char> enemies = new HashSet<Char>(); HashSet<Char> enemies = new HashSet<Char>();
for (Mob mob : Dungeon.level.mobs) for (Mob mob : Dungeon.level.mobs)
if (!(mob instanceof Bee) && Level.distance(mob.pos, potPos) <= 3 && (mob.hostile || mob.ally)) if (!(mob instanceof Bee) && Level.distance(mob.pos, potPos) <= 3 && (mob.hostile || mob.ally))
enemies.add(mob); enemies.add(mob);
//pick one, if there are none, check if the hero is near the pot, go for them, otherwise go for nothing. //pick one, if there are none, check if the hero is near the pot, go for them, otherwise go for nothing.
if (enemies.size() > 0) return Random.element(enemies); if (enemies.size() > 0) return Random.element(enemies);
else return (Level.distance(Dungeon.hero.pos, potPos) <= 3) ? Dungeon.hero : null ; else return (Level.distance(Dungeon.hero.pos, potPos) <= 3) ? Dungeon.hero : null ;
} }
} }
@Override @Override
protected boolean getCloser(int target) { protected boolean getCloser(int target) {
if (enemy != null && Actor.findById(potHolder) == enemy) { if (enemy != null && Actor.findById(potHolder) == enemy) {
target = enemy.pos; target = enemy.pos;
} else if (potPos != -1 && (state == WANDERING || Level.distance(target, potPos) > 3)) } else if (potPos != -1 && (state == WANDERING || Level.distance(target, potPos) > 3))
this.target = target = potPos; this.target = target = potPos;
return super.getCloser( target ); return super.getCloser( target );
} }
@ -148,7 +148,7 @@ public class Bee extends Mob {
private static final HashSet<Class<?>> IMMUNITIES = new HashSet<Class<?>>(); private static final HashSet<Class<?>> IMMUNITIES = new HashSet<Class<?>>();
static { static {
IMMUNITIES.add( Poison.class ); IMMUNITIES.add( Poison.class );
IMMUNITIES.add( Amok.class ); IMMUNITIES.add( Amok.class );
} }
@Override @Override

View File

@ -58,7 +58,7 @@ public class Brute extends Mob {
@Override @Override
public int damageRoll() { public int damageRoll() {
return enraged ? return enraged ?
Random.NormalIntRange( 10, 40 ) : Random.NormalIntRange( 10, 40 ) :
Random.NormalIntRange( 8, 18 ); Random.NormalIntRange( 8, 18 );
} }

View File

@ -98,10 +98,10 @@ public class DM300 extends Mob {
} }
int[] cells = { int[] cells = {
step-1, step+1, step-Level.WIDTH, step+Level.WIDTH, step-1, step+1, step-Level.WIDTH, step+Level.WIDTH,
step-1-Level.WIDTH, step-1-Level.WIDTH,
step-1+Level.WIDTH, step-1+Level.WIDTH,
step+1-Level.WIDTH, step+1-Level.WIDTH,
step+1+Level.WIDTH step+1+Level.WIDTH
}; };
int cell = cells[Random.Int( cells.length )]; int cell = cells[Random.Int( cells.length )];
@ -172,7 +172,7 @@ public class DM300 extends Mob {
private static final HashSet<Class<?>> IMMUNITIES = new HashSet<Class<?>>(); private static final HashSet<Class<?>> IMMUNITIES = new HashSet<Class<?>>();
static { static {
IMMUNITIES.add( ToxicGas.class ); IMMUNITIES.add( ToxicGas.class );
IMMUNITIES.add( Terror.class ); IMMUNITIES.add( Terror.class );
} }
@Override @Override

View File

@ -82,13 +82,13 @@ public class Elemental extends Mob {
sprite.emitter().burst( Speck.factory( Speck.HEALING ), 1 ); sprite.emitter().burst( Speck.factory( Speck.HEALING ), 1 );
} }
} else if (buff instanceof Frost || buff instanceof Chill) { } else if (buff instanceof Frost || buff instanceof Chill) {
if (Level.water[this.pos]) if (Level.water[this.pos])
damage( Random.NormalIntRange( HT / 2, HT ), buff ); damage( Random.NormalIntRange( HT / 2, HT ), buff );
else else
damage( Random.NormalIntRange( 1, HT * 2 / 3 ), buff ); damage( Random.NormalIntRange( 1, HT * 2 / 3 ), buff );
} else { } else {
super.add( buff ); super.add( buff );
} }
} }
@Override @Override

View File

@ -63,13 +63,13 @@ public class Goo extends Mob {
@Override @Override
public int damageRoll() { public int damageRoll() {
if (pumpedUp > 0) { if (pumpedUp > 0) {
pumpedUp = 0; pumpedUp = 0;
for (int i = 0; i < Level.NEIGHBOURS9DIST2.length; i++) { for (int i = 0; i < Level.NEIGHBOURS9DIST2.length; i++) {
int j = pos + Level.NEIGHBOURS9DIST2[i]; int j = pos + Level.NEIGHBOURS9DIST2[i];
if (Level.insideMap(j) && Level.passable[j]) if (Level.insideMap(j) && Level.passable[j])
CellEmitter.get(j).burst(ElmoParticle.FACTORY, 10); CellEmitter.get(j).burst(ElmoParticle.FACTORY, 10);
} }
Sample.INSTANCE.play( Assets.SND_BURNING ); Sample.INSTANCE.play( Assets.SND_BURNING );
return Random.NormalIntRange( 5, 30 ); return Random.NormalIntRange( 5, 30 );
} else { } else {
return Random.NormalIntRange( 2, 12 ); return Random.NormalIntRange( 2, 12 );
@ -118,35 +118,35 @@ public class Goo extends Mob {
@Override @Override
protected boolean doAttack( Char enemy ) { protected boolean doAttack( Char enemy ) {
if (pumpedUp == 1) { if (pumpedUp == 1) {
((GooSprite)sprite).pumpUp(); ((GooSprite)sprite).pumpUp();
for (int i = 0; i < Level.NEIGHBOURS9DIST2.length; i++) { for (int i = 0; i < Level.NEIGHBOURS9DIST2.length; i++) {
int j = pos + Level.NEIGHBOURS9DIST2[i]; int j = pos + Level.NEIGHBOURS9DIST2[i];
if (Level.insideMap(j) && Level.passable[j]) if (Level.insideMap(j) && Level.passable[j])
GameScene.add(Blob.seed(j, 2, GooWarn.class)); GameScene.add(Blob.seed(j, 2, GooWarn.class));
} }
pumpedUp++; pumpedUp++;
spend( attackDelay() ); spend( attackDelay() );
return true; return true;
} else if (pumpedUp >= 2 || Random.Int( 3 ) > 0) { } else if (pumpedUp >= 2 || Random.Int( 3 ) > 0) {
boolean visible = Dungeon.visible[pos]; boolean visible = Dungeon.visible[pos];
if (visible) { if (visible) {
if (pumpedUp >= 2) { if (pumpedUp >= 2) {
((GooSprite) sprite).pumpAttack(); ((GooSprite) sprite).pumpAttack();
} }
else else
sprite.attack( enemy.pos ); sprite.attack( enemy.pos );
} else { } else {
attack( enemy ); attack( enemy );
} }
spend( attackDelay() ); spend( attackDelay() );
return !visible; return !visible;
} else { } else {
@ -154,18 +154,18 @@ public class Goo extends Mob {
((GooSprite)sprite).pumpUp(); ((GooSprite)sprite).pumpUp();
for (int i=0; i < Level.NEIGHBOURS9.length; i++) { for (int i=0; i < Level.NEIGHBOURS9.length; i++) {
int j = pos + Level.NEIGHBOURS9[i]; int j = pos + Level.NEIGHBOURS9[i];
GameScene.add( Blob.seed( j , 2, GooWarn.class )); GameScene.add( Blob.seed( j , 2, GooWarn.class ));
} }
if (Dungeon.visible[pos]) { if (Dungeon.visible[pos]) {
sprite.showStatus( CharSprite.NEGATIVE, "!!!" ); sprite.showStatus( CharSprite.NEGATIVE, "!!!" );
GLog.n( "Goo is pumping itself up!" ); GLog.n( "Goo is pumping itself up!" );
} }
spend( attackDelay() ); spend( attackDelay() );
return true; return true;
} }
@ -216,28 +216,28 @@ public class Goo extends Mob {
return return
"Little is known about The Goo. It's quite possible that it is not even a creature, but rather a " + "Little is known about The Goo. It's quite possible that it is not even a creature, but rather a " +
"conglomerate of vile substances from the sewers that somehow gained basic intelligence. " + "conglomerate of vile substances from the sewers that somehow gained basic intelligence. " +
"Regardless, dark magic is certainly what has allowed Goo to exist.\n\n" + "Regardless, dark magic is certainly what has allowed Goo to exist.\n\n" +
"Its gelatinous nature has let it absorb lots of dark energy, you feel a chill just from being near. " + "Its gelatinous nature has let it absorb lots of dark energy, you feel a chill just from being near. " +
"If goo is able to attack with this energy you won't live for long."; "If goo is able to attack with this energy you won't live for long.";
} }
private final String PUMPEDUP = "pumpedup"; private final String PUMPEDUP = "pumpedup";
@Override @Override
public void storeInBundle( Bundle bundle ) { public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle ); super.storeInBundle( bundle );
bundle.put( PUMPEDUP , pumpedUp ); bundle.put( PUMPEDUP , pumpedUp );
} }
@Override @Override
public void restoreFromBundle( Bundle bundle ) { public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle ); super.restoreFromBundle( bundle );
pumpedUp = bundle.getInt( PUMPEDUP ); pumpedUp = bundle.getInt( PUMPEDUP );
} }
private static final HashSet<Class<?>> RESISTANCES = new HashSet<Class<?>>(); private static final HashSet<Class<?>> RESISTANCES = new HashSet<Class<?>>();
static { static {

View File

@ -101,15 +101,15 @@ public class King extends Mob {
@Override @Override
protected boolean getCloser( int target ) { protected boolean getCloser( int target ) {
return canTryToSummon() ? return canTryToSummon() ?
super.getCloser( CityBossLevel.pedestal( nextPedestal ) ) : super.getCloser( CityBossLevel.pedestal( nextPedestal ) ) :
super.getCloser( target ); super.getCloser( target );
} }
@Override @Override
protected boolean canAttack( Char enemy ) { protected boolean canAttack( Char enemy ) {
return canTryToSummon() ? return canTryToSummon() ?
pos == CityBossLevel.pedestal( nextPedestal ) : pos == CityBossLevel.pedestal( nextPedestal ) :
Level.adjacent( pos, enemy.pos ); Level.adjacent( pos, enemy.pos );
} }
@ -163,7 +163,7 @@ public class King extends Mob {
nextPedestal = !nextPedestal; nextPedestal = !nextPedestal;
sprite.centerEmitter().start( Speck.factory( Speck.SCREAM ), 0.4f, 2 ); sprite.centerEmitter().start( Speck.factory( Speck.SCREAM ), 0.4f, 2 );
Sample.INSTANCE.play( Assets.SND_CHALLENGE ); Sample.INSTANCE.play( Assets.SND_CHALLENGE );
boolean[] passable = Level.passable.clone(); boolean[] passable = Level.passable.clone();
@ -293,7 +293,7 @@ public class King extends Mob {
@Override @Override
public void damage( int dmg, Object src ) { public void damage( int dmg, Object src ) {
super.damage( dmg, src ); super.damage( dmg, src );
if (src instanceof ToxicGas) { if (src instanceof ToxicGas) {
((ToxicGas)src).clear( pos ); ((ToxicGas)src).clear( pos );
} }
} }

View File

@ -115,7 +115,7 @@ public class Mimic extends Mob {
} }
public static Mimic spawnAt( int pos, List<Item> items ) { public static Mimic spawnAt( int pos, List<Item> items ) {
Char ch = Actor.findChar( pos ); Char ch = Actor.findChar( pos );
if (ch != null) { if (ch != null) {
ArrayList<Integer> candidates = new ArrayList<Integer>(); ArrayList<Integer> candidates = new ArrayList<Integer>();
for (int n : Level.NEIGHBOURS8) { for (int n : Level.NEIGHBOURS8) {

View File

@ -59,12 +59,12 @@ public abstract class Mob extends Char {
protected static final String TXT_RAGE = "#$%^"; protected static final String TXT_RAGE = "#$%^";
protected static final String TXT_EXP = "%+dEXP"; protected static final String TXT_EXP = "%+dEXP";
public AiState SLEEPING = new Sleeping(); public AiState SLEEPING = new Sleeping();
public AiState HUNTING = new Hunting(); public AiState HUNTING = new Hunting();
public AiState WANDERING = new Wandering(); public AiState WANDERING = new Wandering();
public AiState FLEEING = new Fleeing(); public AiState FLEEING = new Fleeing();
public AiState PASSIVE = new Passive(); public AiState PASSIVE = new Passive();
public AiState state = SLEEPING; public AiState state = SLEEPING;
public Class<? extends CharSprite> spriteClass; public Class<? extends CharSprite> spriteClass;
@ -85,7 +85,7 @@ public abstract class Mob extends Char {
public boolean ally = false; public boolean ally = false;
private static final String STATE = "state"; private static final String STATE = "state";
private static final String SEEN = "seen"; private static final String SEEN = "seen";
private static final String TARGET = "target"; private static final String TARGET = "target";
@Override @Override
@ -93,19 +93,19 @@ public abstract class Mob extends Char {
super.storeInBundle( bundle ); super.storeInBundle( bundle );
if (state == SLEEPING) { if (state == SLEEPING) {
bundle.put( STATE, Sleeping.TAG ); bundle.put( STATE, Sleeping.TAG );
} else if (state == WANDERING) { } else if (state == WANDERING) {
bundle.put( STATE, Wandering.TAG ); bundle.put( STATE, Wandering.TAG );
} else if (state == HUNTING) { } else if (state == HUNTING) {
bundle.put( STATE, Hunting.TAG ); bundle.put( STATE, Hunting.TAG );
} else if (state == FLEEING) { } else if (state == FLEEING) {
bundle.put( STATE, Fleeing.TAG ); bundle.put( STATE, Fleeing.TAG );
} else if (state == PASSIVE) { } else if (state == PASSIVE) {
bundle.put( STATE, Passive.TAG ); bundle.put( STATE, Passive.TAG );
} }
bundle.put( SEEN, enemySeen ); bundle.put( SEEN, enemySeen );
bundle.put( TARGET, target ); bundle.put( TARGET, target );
} }
@Override @Override
@ -113,23 +113,23 @@ public abstract class Mob extends Char {
super.restoreFromBundle( bundle ); super.restoreFromBundle( bundle );
String state = bundle.getString( STATE ); String state = bundle.getString( STATE );
if (state.equals( Sleeping.TAG )) { if (state.equals( Sleeping.TAG )) {
this.state = SLEEPING; this.state = SLEEPING;
} else if (state.equals( Wandering.TAG )) { } else if (state.equals( Wandering.TAG )) {
this.state = WANDERING; this.state = WANDERING;
} else if (state.equals( Hunting.TAG )) { } else if (state.equals( Hunting.TAG )) {
this.state = HUNTING; this.state = HUNTING;
} else if (state.equals( Fleeing.TAG )) { } else if (state.equals( Fleeing.TAG )) {
this.state = FLEEING; this.state = FLEEING;
} else if (state.equals( Passive.TAG )) { } else if (state.equals( Passive.TAG )) {
this.state = PASSIVE; this.state = PASSIVE;
} }
enemySeen = bundle.getBoolean( SEEN ); enemySeen = bundle.getBoolean( SEEN );
target = bundle.getInt( TARGET ); target = bundle.getInt( TARGET );
} }
public CharSprite sprite() { public CharSprite sprite() {
CharSprite sprite = null; CharSprite sprite = null;
@ -160,7 +160,7 @@ public abstract class Mob extends Char {
boolean enemyInFOV = enemy != null && enemy.isAlive() && Level.fieldOfView[enemy.pos] && enemy.invisible <= 0; boolean enemyInFOV = enemy != null && enemy.isAlive() && Level.fieldOfView[enemy.pos] && enemy.invisible <= 0;
return state.act( enemyInFOV, justAlerted ); return state.act( enemyInFOV, justAlerted );
} }
protected Char chooseEnemy() { protected Char chooseEnemy() {
@ -247,7 +247,7 @@ public abstract class Mob extends Char {
state = FLEEING; state = FLEEING;
} else if (buff instanceof Sleep) { } else if (buff instanceof Sleep) {
state = SLEEPING; state = SLEEPING;
this.sprite().showSleep(); this.sprite().showSleep();
postpone( Sleep.SWS ); postpone( Sleep.SWS );
} }
} }
@ -271,8 +271,8 @@ public abstract class Mob extends Char {
return false; return false;
} }
int step = Dungeon.findPath( this, pos, target, int step = Dungeon.findPath( this, pos, target,
Level.passable, Level.passable,
Level.fieldOfView ); Level.fieldOfView );
if (step != -1) { if (step != -1) {
move( step ); move( step );
@ -283,8 +283,8 @@ public abstract class Mob extends Char {
} }
protected boolean getFurther( int target ) { protected boolean getFurther( int target ) {
int step = Dungeon.flee( this, pos, target, int step = Dungeon.flee( this, pos, target,
Level.passable, Level.passable,
Level.fieldOfView ); Level.fieldOfView );
if (step != -1) { if (step != -1) {
move( step ); move( step );
@ -294,14 +294,14 @@ public abstract class Mob extends Char {
} }
} }
@Override @Override
public void updateSpriteState() { public void updateSpriteState() {
super.updateSpriteState(); super.updateSpriteState();
if (Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class) != null) if (Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class) != null)
sprite.add( CharSprite.State.PARALYSED ); sprite.add( CharSprite.State.PARALYSED );
} }
@Override @Override
public void move( int step ) { public void move( int step ) {
super.move( step ); super.move( step );
@ -337,18 +337,18 @@ public abstract class Mob extends Char {
@Override @Override
public int defenseSkill( Char enemy ) { public int defenseSkill( Char enemy ) {
if (enemySeen && !paralysed) { if (enemySeen && !paralysed) {
int defenseSkill = this.defenseSkill; int defenseSkill = this.defenseSkill;
int penalty = 0; int penalty = 0;
for (Buff buff : enemy.buffs(RingOfAccuracy.Accuracy.class)) { for (Buff buff : enemy.buffs(RingOfAccuracy.Accuracy.class)) {
penalty += ((RingOfAccuracy.Accuracy) buff).level; penalty += ((RingOfAccuracy.Accuracy) buff).level;
} }
if (penalty != 0 && enemy == Dungeon.hero) if (penalty != 0 && enemy == Dungeon.hero)
defenseSkill *= Math.pow(0.75, penalty); defenseSkill *= Math.pow(0.75, penalty);
return defenseSkill; return defenseSkill;
} else { } else {
return 0; return 0;
} }
} }
@Override @Override
@ -382,9 +382,9 @@ public abstract class Mob extends Char {
Terror.recover( this ); Terror.recover( this );
if (state == SLEEPING) { if (state == SLEEPING) {
state = WANDERING; state = WANDERING;
} }
alerted = true; alerted = true;
super.damage( dmg, src ); super.damage( dmg, src );
@ -425,21 +425,21 @@ public abstract class Mob extends Char {
super.die( cause ); super.die( cause );
float lootChance = this.lootChance; float lootChance = this.lootChance;
int bonus = 0; int bonus = 0;
for (Buff buff : Dungeon.hero.buffs(RingOfWealth.Wealth.class)) { for (Buff buff : Dungeon.hero.buffs(RingOfWealth.Wealth.class)) {
bonus += ((RingOfWealth.Wealth) buff).level; bonus += ((RingOfWealth.Wealth) buff).level;
} }
lootChance *= Math.pow(1.1, bonus); lootChance *= Math.pow(1.1, bonus);
if (Random.Float() < lootChance && Dungeon.hero.lvl <= maxLvl + 2) { if (Random.Float() < lootChance && Dungeon.hero.lvl <= maxLvl + 2) {
Item loot = createLoot(); Item loot = createLoot();
if (loot != null) if (loot != null)
Dungeon.level.drop( loot , pos ).sprite.drop(); Dungeon.level.drop( loot , pos ).sprite.drop();
} }
if (Dungeon.hero.isAlive() && !Dungeon.visible[pos]) { if (Dungeon.hero.isAlive() && !Dungeon.visible[pos]) {
GLog.i( TXT_DIED ); GLog.i( TXT_DIED );
} }
} }
@ -449,21 +449,21 @@ public abstract class Mob extends Char {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected Item createLoot() { protected Item createLoot() {
Item item; Item item;
if (loot instanceof Generator.Category) { if (loot instanceof Generator.Category) {
item = Generator.random( (Generator.Category)loot ); item = Generator.random( (Generator.Category)loot );
} else if (loot instanceof Class<?>) { } else if (loot instanceof Class<?>) {
item = Generator.random( (Class<? extends Item>)loot ); item = Generator.random( (Class<? extends Item>)loot );
} else { } else {
item = (Item)loot; item = (Item)loot;
} }
return item; return item;
} }
public boolean reset() { public boolean reset() {
@ -497,177 +497,177 @@ public abstract class Mob extends Char {
return enemySeen && (target == Dungeon.hero.pos); return enemySeen && (target == Dungeon.hero.pos);
} }
public interface AiState { public interface AiState {
public boolean act( boolean enemyInFOV, boolean justAlerted ); public boolean act( boolean enemyInFOV, boolean justAlerted );
public String status(); public String status();
} }
private class Sleeping implements AiState { private class Sleeping implements AiState {
public static final String TAG = "SLEEPING"; public static final String TAG = "SLEEPING";
@Override @Override
public boolean act( boolean enemyInFOV, boolean justAlerted ) { public boolean act( boolean enemyInFOV, boolean justAlerted ) {
if (enemyInFOV && Random.Int( distance( enemy ) + enemy.stealth() + (enemy.flying ? 2 : 0) ) == 0) { if (enemyInFOV && Random.Int( distance( enemy ) + enemy.stealth() + (enemy.flying ? 2 : 0) ) == 0) {
enemySeen = true; enemySeen = true;
notice(); notice();
state = HUNTING; state = HUNTING;
target = enemy.pos; target = enemy.pos;
if (Dungeon.isChallenged( Challenges.SWARM_INTELLIGENCE )) { if (Dungeon.isChallenged( Challenges.SWARM_INTELLIGENCE )) {
for (Mob mob : Dungeon.level.mobs) { for (Mob mob : Dungeon.level.mobs) {
if (mob != Mob.this) { if (mob != Mob.this) {
mob.beckon( target ); mob.beckon( target );
} }
} }
} }
spend( TIME_TO_WAKE_UP ); spend( TIME_TO_WAKE_UP );
} else { } else {
enemySeen = false; enemySeen = false;
spend( TICK ); spend( TICK );
} }
return true; return true;
} }
@Override @Override
public String status() { public String status() {
return Utils.format( "This %s is sleeping", name ); return Utils.format( "This %s is sleeping", name );
} }
} }
private class Wandering implements AiState { private class Wandering implements AiState {
public static final String TAG = "WANDERING"; public static final String TAG = "WANDERING";
@Override @Override
public boolean act( boolean enemyInFOV, boolean justAlerted ) { public boolean act( boolean enemyInFOV, boolean justAlerted ) {
if (enemyInFOV && (justAlerted || Random.Int( distance( enemy ) / 2 + enemy.stealth() ) == 0)) { if (enemyInFOV && (justAlerted || Random.Int( distance( enemy ) / 2 + enemy.stealth() ) == 0)) {
enemySeen = true; enemySeen = true;
notice(); notice();
state = HUNTING; state = HUNTING;
target = enemy.pos; target = enemy.pos;
} else { } else {
enemySeen = false; enemySeen = false;
int oldPos = pos; int oldPos = pos;
if (target != -1 && getCloser( target )) { if (target != -1 && getCloser( target )) {
spend( 1 / speed() ); spend( 1 / speed() );
return moveSprite( oldPos, pos ); return moveSprite( oldPos, pos );
} else { } else {
target = Dungeon.level.randomDestination(); target = Dungeon.level.randomDestination();
spend( TICK ); spend( TICK );
} }
} }
return true; return true;
} }
@Override @Override
public String status() { public String status() {
return Utils.format( "This %s is wandering", name ); return Utils.format( "This %s is wandering", name );
} }
} }
private class Hunting implements AiState { private class Hunting implements AiState {
public static final String TAG = "HUNTING"; public static final String TAG = "HUNTING";
@Override @Override
public boolean act( boolean enemyInFOV, boolean justAlerted ) { public boolean act( boolean enemyInFOV, boolean justAlerted ) {
enemySeen = enemyInFOV; enemySeen = enemyInFOV;
if (enemyInFOV && !isCharmedBy( enemy ) && canAttack( enemy )) { if (enemyInFOV && !isCharmedBy( enemy ) && canAttack( enemy )) {
return doAttack( enemy ); return doAttack( enemy );
} else { } else {
if (enemyInFOV) { if (enemyInFOV) {
target = enemy.pos; target = enemy.pos;
} }
int oldPos = pos; int oldPos = pos;
if (target != -1 && getCloser( target )) { if (target != -1 && getCloser( target )) {
spend( 1 / speed() ); spend( 1 / speed() );
return moveSprite( oldPos, pos ); return moveSprite( oldPos, pos );
} else { } else {
spend( TICK ); spend( TICK );
state = WANDERING; state = WANDERING;
target = Dungeon.level.randomDestination(); target = Dungeon.level.randomDestination();
return true; return true;
} }
} }
} }
@Override @Override
public String status() { public String status() {
return Utils.format( "This %s is hunting", name ); return Utils.format( "This %s is hunting", name );
} }
} }
protected class Fleeing implements AiState { protected class Fleeing implements AiState {
public static final String TAG = "FLEEING"; public static final String TAG = "FLEEING";
@Override @Override
public boolean act( boolean enemyInFOV, boolean justAlerted ) { public boolean act( boolean enemyInFOV, boolean justAlerted ) {
enemySeen = enemyInFOV; enemySeen = enemyInFOV;
if (enemyInFOV) { if (enemyInFOV) {
target = enemy.pos; target = enemy.pos;
} }
int oldPos = pos; int oldPos = pos;
if (target != -1 && getFurther( target )) { if (target != -1 && getFurther( target )) {
spend( 1 / speed() ); spend( 1 / speed() );
return moveSprite( oldPos, pos ); return moveSprite( oldPos, pos );
} else { } else {
spend( TICK ); spend( TICK );
nowhereToRun(); nowhereToRun();
return true; return true;
} }
} }
protected void nowhereToRun() { protected void nowhereToRun() {
} }
@Override @Override
public String status() { public String status() {
return Utils.format( "This %s is fleeing", name ); return Utils.format( "This %s is fleeing", name );
} }
} }
private class Passive implements AiState { private class Passive implements AiState {
public static final String TAG = "PASSIVE"; public static final String TAG = "PASSIVE";
@Override @Override
public boolean act( boolean enemyInFOV, boolean justAlerted ) { public boolean act( boolean enemyInFOV, boolean justAlerted ) {
enemySeen = false; enemySeen = false;
spend( TICK ); spend( TICK );
return true; return true;
} }
@Override @Override
public String status() { public String status() {
return Utils.format( "This %s is passive", name ); return Utils.format( "This %s is passive", name );
} }
} }
} }

View File

@ -114,8 +114,8 @@ public class Piranha extends Mob {
return false; return false;
} }
int step = Dungeon.findPath( this, pos, target, int step = Dungeon.findPath( this, pos, target,
Level.water, Level.water,
Level.fieldOfView ); Level.fieldOfView );
if (step != -1) { if (step != -1) {
move( step ); move( step );
@ -127,8 +127,8 @@ public class Piranha extends Mob {
@Override @Override
protected boolean getFurther( int target ) { protected boolean getFurther( int target ) {
int step = Dungeon.flee( this, pos, target, int step = Dungeon.flee( this, pos, target,
Level.water, Level.water,
Level.fieldOfView ); Level.fieldOfView );
if (step != -1) { if (step != -1) {
move( step ); move( step );

View File

@ -92,10 +92,10 @@ public class Scorpio extends Mob {
@Override @Override
protected Item createLoot() { protected Item createLoot() {
//5/count+5 total chance of getting healing, failing the 2nd roll drops mystery meat instead. //5/count+5 total chance of getting healing, failing the 2nd roll drops mystery meat instead.
if (Random.Int( 5 + Dungeon.limitedDrops.scorpioHP.count ) <= 4) { if (Random.Int( 5 + Dungeon.limitedDrops.scorpioHP.count ) <= 4) {
Dungeon.limitedDrops.scorpioHP.count++; Dungeon.limitedDrops.scorpioHP.count++;
return (Item)loot; return (Item)loot;
} else { } else {
return new MysteryMeat(); return new MysteryMeat();
} }

View File

@ -84,7 +84,7 @@ public class Shaman extends Mob implements Callback {
} else { } else {
boolean visible = Level.fieldOfView[pos] || Level.fieldOfView[enemy.pos]; boolean visible = Level.fieldOfView[pos] || Level.fieldOfView[enemy.pos];
if (visible) { if (visible) {
((ShamanSprite)sprite).zap( enemy.pos ); ((ShamanSprite)sprite).zap( enemy.pos );
} }

View File

@ -47,8 +47,8 @@ public class Skeleton extends Mob {
EXP = 5; EXP = 5;
maxLvl = 10; maxLvl = 10;
loot = Generator.Category.WEAPON; loot = Generator.Category.WEAPON;
lootChance = 0.2f; lootChance = 0.2f;
} }
@Override @Override
@ -85,15 +85,15 @@ public class Skeleton extends Mob {
@Override @Override
protected Item createLoot() { protected Item createLoot() {
Item loot = Generator.random( Generator.Category.WEAPON ); Item loot = Generator.random( Generator.Category.WEAPON );
for (int i=0; i < 2; i++) { for (int i=0; i < 2; i++) {
Item l = Generator.random( Generator.Category.WEAPON ); Item l = Generator.random( Generator.Category.WEAPON );
if (l.level < loot.level) { if (l.level < loot.level) {
loot = l; loot = l;
} }
} }
return loot; return loot;
} }
@Override @Override
public int attackSkill( Char target ) { public int attackSkill( Char target ) {

View File

@ -33,103 +33,103 @@ import com.watabou.utils.Random;
public class Spinner extends Mob { public class Spinner extends Mob {
{ {
name = "cave spinner"; name = "cave spinner";
spriteClass = SpinnerSprite.class; spriteClass = SpinnerSprite.class;
HP = HT = 50; HP = HT = 50;
defenseSkill = 14; defenseSkill = 14;
EXP = 9; EXP = 9;
maxLvl = 16; maxLvl = 16;
loot = new MysteryMeat(); loot = new MysteryMeat();
lootChance = 0.125f; lootChance = 0.125f;
FLEEING = new Fleeing(); FLEEING = new Fleeing();
} }
@Override @Override
public int damageRoll() { public int damageRoll() {
return Random.NormalIntRange(12, 16); return Random.NormalIntRange(12, 16);
} }
@Override @Override
public int attackSkill(Char target) { public int attackSkill(Char target) {
return 20; return 20;
} }
@Override @Override
public int dr() { public int dr() {
return 6; return 6;
} }
@Override @Override
protected boolean act() { protected boolean act() {
boolean result = super.act(); boolean result = super.act();
if (state == FLEEING && buff( Terror.class ) == null && if (state == FLEEING && buff( Terror.class ) == null &&
enemy != null && enemySeen && enemy.buff( Poison.class ) == null) { enemy != null && enemySeen && enemy.buff( Poison.class ) == null) {
state = HUNTING; state = HUNTING;
} }
return result; return result;
} }
@Override @Override
public int attackProc(Char enemy, int damage) { public int attackProc(Char enemy, int damage) {
if (Random.Int(2) == 0) { if (Random.Int(2) == 0) {
Buff.affect(enemy, Poison.class).set(Random.Int(7, 9) * Poison.durationFactor(enemy)); Buff.affect(enemy, Poison.class).set(Random.Int(7, 9) * Poison.durationFactor(enemy));
state = FLEEING; state = FLEEING;
} }
return damage; return damage;
} }
@Override @Override
public void move(int step) { public void move(int step) {
if (state == FLEEING) { if (state == FLEEING) {
GameScene.add(Blob.seed(pos, Random.Int(5, 7), Web.class)); GameScene.add(Blob.seed(pos, Random.Int(5, 7), Web.class));
} }
super.move(step); super.move(step);
} }
@Override @Override
public String description() { public String description() {
return return
"These greenish furry cave spiders try to avoid direct combat, preferring to wait in the distance " + "These greenish furry cave spiders try to avoid direct combat, preferring to wait in the distance " +
"while their victim, entangled in the spinner's excreted cobweb, slowly dies from their poisonous bite."; "while their victim, entangled in the spinner's excreted cobweb, slowly dies from their poisonous bite.";
} }
private static final HashSet<Class<?>> RESISTANCES = new HashSet<Class<?>>(); private static final HashSet<Class<?>> RESISTANCES = new HashSet<Class<?>>();
static { static {
RESISTANCES.add(Poison.class); RESISTANCES.add(Poison.class);
} }
@Override @Override
public HashSet<Class<?>> resistances() { public HashSet<Class<?>> resistances() {
return RESISTANCES; return RESISTANCES;
} }
private static final HashSet<Class<?>> IMMUNITIES = new HashSet<Class<?>>(); private static final HashSet<Class<?>> IMMUNITIES = new HashSet<Class<?>>();
static { static {
IMMUNITIES.add(Roots.class); IMMUNITIES.add(Roots.class);
} }
@Override @Override
public HashSet<Class<?>> immunities() { public HashSet<Class<?>> immunities() {
return IMMUNITIES; return IMMUNITIES;
} }
private class Fleeing extends Mob.Fleeing { private class Fleeing extends Mob.Fleeing {
@Override @Override
protected void nowhereToRun() { protected void nowhereToRun() {
if (buff(Terror.class) == null) { if (buff(Terror.class) == null) {
state = HUNTING; state = HUNTING;
} else { } else {
super.nowhereToRun(); super.nowhereToRun();
} }
} }
} }
} }

View File

@ -50,8 +50,8 @@ public class Swarm extends Mob {
flying = true; flying = true;
loot = new PotionOfHealing(); loot = new PotionOfHealing();
lootChance = 0.2f; //by default, see die() lootChance = 0.2f; //by default, see die()
} }
private static final float SPLIT_DELAY = 1f; private static final float SPLIT_DELAY = 1f;
@ -139,16 +139,16 @@ public class Swarm extends Mob {
@Override @Override
public void die( Object cause ){ public void die( Object cause ){
//sets drop chance //sets drop chance
lootChance = 1f/((5 + Dungeon.limitedDrops.swarmHP.count ) * (generation+1) ); lootChance = 1f/((5 + Dungeon.limitedDrops.swarmHP.count ) * (generation+1) );
super.die( cause ); super.die( cause );
} }
@Override @Override
protected Item createLoot(){ protected Item createLoot(){
Dungeon.limitedDrops.swarmHP.count++; Dungeon.limitedDrops.swarmHP.count++;
return super.createLoot(); return super.createLoot();
} }
@Override @Override
public String description() { public String description() {

View File

@ -158,8 +158,8 @@ public class Tengu extends Mob {
do { do {
newPos = Random.Int( Level.LENGTH ); newPos = Random.Int( Level.LENGTH );
} while ( } while (
!Level.fieldOfView[newPos] || !Level.fieldOfView[newPos] ||
!Level.passable[newPos] || !Level.passable[newPos] ||
Level.adjacent( newPos, enemy.pos ) || Level.adjacent( newPos, enemy.pos ) ||
Actor.findChar( newPos ) != null); Actor.findChar( newPos ) != null);

View File

@ -50,132 +50,132 @@ public class Thief extends Mob {
maxLvl = 10; maxLvl = 10;
loot = new MasterThievesArmband().identify(); loot = new MasterThievesArmband().identify();
lootChance = 0.01f; lootChance = 0.01f;
FLEEING = new Fleeing(); FLEEING = new Fleeing();
} }
private static final String ITEM = "item"; private static final String ITEM = "item";
@Override @Override
public void storeInBundle( Bundle bundle ) { public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle ); super.storeInBundle( bundle );
bundle.put( ITEM, item ); bundle.put( ITEM, item );
} }
@Override @Override
public void restoreFromBundle( Bundle bundle ) { public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle ); super.restoreFromBundle( bundle );
item = (Item)bundle.get( ITEM ); item = (Item)bundle.get( ITEM );
} }
@Override @Override
public int damageRoll() { public int damageRoll() {
return Random.NormalIntRange( 1, 7 ); return Random.NormalIntRange( 1, 7 );
} }
@Override @Override
protected float attackDelay() { protected float attackDelay() {
return 0.5f; return 0.5f;
} }
@Override @Override
public void die( Object cause ) { public void die( Object cause ) {
super.die( cause ); super.die( cause );
if (item != null) { if (item != null) {
Dungeon.level.drop( item, pos ).sprite.drop(); Dungeon.level.drop( item, pos ).sprite.drop();
//updates position //updates position
if (item instanceof Honeypot.ShatteredPot) ((Honeypot.ShatteredPot)item).setHolder( this ); if (item instanceof Honeypot.ShatteredPot) ((Honeypot.ShatteredPot)item).setHolder( this );
} }
} }
@Override @Override
protected Item createLoot(){ protected Item createLoot(){
if (!Dungeon.limitedDrops.armband.dropped()) { if (!Dungeon.limitedDrops.armband.dropped()) {
Dungeon.limitedDrops.armband.drop(); Dungeon.limitedDrops.armband.drop();
return super.createLoot(); return super.createLoot();
} else } else
return new Gold(Random.NormalIntRange(100, 250)); return new Gold(Random.NormalIntRange(100, 250));
} }
@Override @Override
public int attackSkill( Char target ) { public int attackSkill( Char target ) {
return 12; return 12;
} }
@Override @Override
public int dr() { public int dr() {
return 3; return 3;
} }
@Override @Override
public int attackProc( Char enemy, int damage ) { public int attackProc( Char enemy, int damage ) {
if (item == null && enemy instanceof Hero && steal( (Hero)enemy )) { if (item == null && enemy instanceof Hero && steal( (Hero)enemy )) {
state = FLEEING; state = FLEEING;
} }
return damage; return damage;
} }
@Override @Override
public int defenseProc(Char enemy, int damage) { public int defenseProc(Char enemy, int damage) {
if (state == FLEEING) { if (state == FLEEING) {
Dungeon.level.drop( new Gold(), pos ).sprite.drop(); Dungeon.level.drop( new Gold(), pos ).sprite.drop();
} }
return super.defenseProc(enemy, damage); return super.defenseProc(enemy, damage);
} }
protected boolean steal( Hero hero ) { protected boolean steal( Hero hero ) {
Item item = hero.belongings.randomUnequipped(); Item item = hero.belongings.randomUnequipped();
if (item != null) { if (item != null) {
GLog.w( TXT_STOLE, this.name, item.name() ); GLog.w( TXT_STOLE, this.name, item.name() );
if (item instanceof Honeypot){ if (item instanceof Honeypot){
this.item = ((Honeypot)item).shatter(this, this.pos); this.item = ((Honeypot)item).shatter(this, this.pos);
item.detach( hero.belongings.backpack ); item.detach( hero.belongings.backpack );
} else { } else {
this.item = item; this.item = item;
if ( item instanceof Honeypot.ShatteredPot) if ( item instanceof Honeypot.ShatteredPot)
((Honeypot.ShatteredPot)item).setHolder(this); ((Honeypot.ShatteredPot)item).setHolder(this);
item.detachAll( hero.belongings.backpack ); item.detachAll( hero.belongings.backpack );
} }
return true; return true;
} else { } else {
return false; return false;
} }
} }
@Override @Override
public String description() { public String description() {
String desc = String desc =
"Deeper levels of the dungeon have always been a hiding place for all kinds of criminals. " + "Deeper levels of the dungeon have always been a hiding place for all kinds of criminals. " +
"Not all of them could keep a clear mind during their extended periods so far from daylight. Long ago, " + "Not all of them could keep a clear mind during their extended periods so far from daylight. Long ago, " +
"these crazy thieves and bandits have forgotten who they are and why they steal."; "these crazy thieves and bandits have forgotten who they are and why they steal.";
if (item != null) { if (item != null) {
desc += String.format( TXT_CARRIES, Utils.capitalize( this.name ), item.name() ); desc += String.format( TXT_CARRIES, Utils.capitalize( this.name ), item.name() );
} }
return desc; return desc;
} }
private class Fleeing extends Mob.Fleeing { private class Fleeing extends Mob.Fleeing {
@Override @Override
protected void nowhereToRun() { protected void nowhereToRun() {
if (buff( Terror.class ) == null) { if (buff( Terror.class ) == null) {
sprite.showStatus( CharSprite.NEGATIVE, TXT_RAGE ); sprite.showStatus( CharSprite.NEGATIVE, TXT_RAGE );
state = HUNTING; state = HUNTING;
} else { } else {
super.nowhereToRun(); super.nowhereToRun();
} }
} }
} }
} }

View File

@ -85,7 +85,7 @@ public class Warlock extends Mob implements Callback {
} else { } else {
boolean visible = Level.fieldOfView[pos] || Level.fieldOfView[enemy.pos]; boolean visible = Level.fieldOfView[pos] || Level.fieldOfView[enemy.pos];
if (visible) { if (visible) {
((WarlockSprite)sprite).zap( enemy.pos ); ((WarlockSprite)sprite).zap( enemy.pos );
} else { } else {
@ -126,22 +126,22 @@ public class Warlock extends Mob implements Callback {
next(); next();
} }
@Override @Override
public Item createLoot(){ public Item createLoot(){
Item loot = super.createLoot(); Item loot = super.createLoot();
if (loot instanceof PotionOfHealing){ if (loot instanceof PotionOfHealing){
//count/10 chance of not dropping potion //count/10 chance of not dropping potion
if (Random.Int(10)-Dungeon.limitedDrops.warlockHP.count < 0){ if (Random.Int(10)-Dungeon.limitedDrops.warlockHP.count < 0){
return null; return null;
} else } else
Dungeon.limitedDrops.warlockHP.count++; Dungeon.limitedDrops.warlockHP.count++;
} }
return loot; return loot;
} }
@Override @Override
public String description() { public String description() {

View File

@ -133,11 +133,11 @@ public class Yog extends Mob {
Actor.addDelayed( new Pushing( larva, pos, larva.pos ), -1 ); Actor.addDelayed( new Pushing( larva, pos, larva.pos ), -1 );
} }
for (Mob mob : Dungeon.level.mobs) { for (Mob mob : Dungeon.level.mobs) {
if (mob instanceof BurningFist || mob instanceof RottingFist || mob instanceof Larva) { if (mob instanceof BurningFist || mob instanceof RottingFist || mob instanceof Larva) {
mob.aggro( enemy ); mob.aggro( enemy );
} }
} }
return super.defenseProc(enemy, damage); return super.defenseProc(enemy, damage);
} }
@ -377,7 +377,7 @@ public class Yog extends Mob {
IMMUNITIES.add( Sleep.class ); IMMUNITIES.add( Sleep.class );
IMMUNITIES.add( Terror.class ); IMMUNITIES.add( Terror.class );
IMMUNITIES.add( Burning.class ); IMMUNITIES.add( Burning.class );
IMMUNITIES.add( ScrollOfPsionicBlast.class ); IMMUNITIES.add( ScrollOfPsionicBlast.class );
IMMUNITIES.add( Vertigo.class ); IMMUNITIES.add( Vertigo.class );
} }

View File

@ -75,7 +75,7 @@ public class Blacksmith extends NPC {
@Override @Override
protected boolean act() { protected boolean act() {
throwItem(); throwItem();
return super.act(); return super.act();
} }
@ -86,7 +86,7 @@ public class Blacksmith extends NPC {
if (!Quest.given) { if (!Quest.given) {
GameScene.show( new WndQuest( this, GameScene.show( new WndQuest( this,
Quest.alternative ? TXT_BLOOD_1 : TXT_GOLD_1 ) { Quest.alternative ? TXT_BLOOD_1 : TXT_GOLD_1 ) {
@Override @Override
@ -168,7 +168,7 @@ public class Blacksmith extends NPC {
return "Select 2 different items, not the same item twice!"; return "Select 2 different items, not the same item twice!";
} }
if (item1.getClass() != item2.getClass()) { if (item1.getClass() != item2.getClass()) {
return "Select 2 items of the same type!"; return "Select 2 items of the same type!";
} }
@ -244,7 +244,7 @@ public class Blacksmith extends NPC {
@Override @Override
public String description() { public String description() {
return return
"This troll blacksmith looks like all trolls look: he is tall and lean, and his skin resembles stone " + "This troll blacksmith looks like all trolls look: he is tall and lean, and his skin resembles stone " +
"in both color and texture. The troll blacksmith is tinkering with unproportionally small tools."; "in both color and texture. The troll blacksmith is tinkering with unproportionally small tools.";
} }

View File

@ -77,37 +77,37 @@ public class Ghost extends NPC {
} }
private static final String TXT_RAT1 = private static final String TXT_RAT1 =
"Hello %s... Once I was like you - strong and confident... " + "Hello %s... Once I was like you - strong and confident... " +
"But I was slain by a foul beast... I can't leave this place... Not until I have my revenge... " + "But I was slain by a foul beast... I can't leave this place... Not until I have my revenge... " +
"Slay the _fetid rat_, that has taken my life...\n\n" + "Slay the _fetid rat_, that has taken my life...\n\n" +
"It stalks this floor... Spreading filth everywhere... " + "It stalks this floor... Spreading filth everywhere... " +
"_Beware its cloud of stink and corrosive bite, the acid dissolves in water..._ "; "_Beware its cloud of stink and corrosive bite, the acid dissolves in water..._ ";
private static final String TXT_RAT2 = private static final String TXT_RAT2 =
"Please... Help me... Slay the abomination...\n\n" + "Please... Help me... Slay the abomination...\n\n" +
"_Fight it near water... Avoid the stench..._"; "_Fight it near water... Avoid the stench..._";
private static final String TXT_GNOLL1 = private static final String TXT_GNOLL1 =
"Hello %s... Once I was like you - strong and confident... " + "Hello %s... Once I was like you - strong and confident... " +
"But I was slain by a devious foe... I can't leave this place... Not until I have my revenge... " + "But I was slain by a devious foe... I can't leave this place... Not until I have my revenge... " +
"Slay the _gnoll trickster_, that has taken my life...\n\n" + "Slay the _gnoll trickster_, that has taken my life...\n\n" +
"It is not like the other gnolls... It hides and uses thrown weapons... " + "It is not like the other gnolls... It hides and uses thrown weapons... " +
"_Beware its poisonous and incendiary darts, don't attack from a distance..._"; "_Beware its poisonous and incendiary darts, don't attack from a distance..._";
private static final String TXT_GNOLL2 = private static final String TXT_GNOLL2 =
"Please... Help me... Slay the trickster...\n\n" + "Please... Help me... Slay the trickster...\n\n" +
"_Don't let it hit you... Get near to it..._"; "_Don't let it hit you... Get near to it..._";
private static final String TXT_CRAB1 = private static final String TXT_CRAB1 =
"Hello %s... Once I was like you - strong and confident... " + "Hello %s... Once I was like you - strong and confident... " +
"But I was slain by an ancient creature... I can't leave this place... Not until I have my revenge... " + "But I was slain by an ancient creature... I can't leave this place... Not until I have my revenge... " +
"Slay the _great crab_, that has taken my life...\n\n" + "Slay the _great crab_, that has taken my life...\n\n" +
"It is unnaturally old... With a massive single claw and a thick shell... " + "It is unnaturally old... With a massive single claw and a thick shell... " +
"_Beware its claw, you must surprise the crab or it will block with it..._"; "_Beware its claw, you must surprise the crab or it will block with it..._";
private static final String TXT_CRAB2 = private static final String TXT_CRAB2 =
"Please... Help me... Slay the Crustacean...\n\n" + "Please... Help me... Slay the Crustacean...\n\n" +
"_It will always block... When it sees you coming..._"; "_It will always block... When it sees you coming..._";
public Ghost() { public Ghost() {
super(); super();
@ -156,69 +156,69 @@ public class Ghost extends NPC {
if (Quest.given) { if (Quest.given) {
if (Quest.weapon != null) { if (Quest.weapon != null) {
if (Quest.processed) { if (Quest.processed) {
GameScene.show(new WndSadGhost(this, Quest.type)); GameScene.show(new WndSadGhost(this, Quest.type));
} else { } else {
switch (Quest.type) { switch (Quest.type) {
case 1: case 1:
default: default:
GameScene.show(new WndQuest(this, TXT_RAT2)); GameScene.show(new WndQuest(this, TXT_RAT2));
break; break;
case 2: case 2:
GameScene.show(new WndQuest(this, TXT_GNOLL2)); GameScene.show(new WndQuest(this, TXT_GNOLL2));
break; break;
case 3: case 3:
GameScene.show(new WndQuest(this, TXT_CRAB2)); GameScene.show(new WndQuest(this, TXT_CRAB2));
break; break;
} }
int newPos = -1; int newPos = -1;
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
newPos = Dungeon.level.randomRespawnCell(); newPos = Dungeon.level.randomRespawnCell();
if (newPos != -1) { if (newPos != -1) {
break; break;
} }
} }
if (newPos != -1) { if (newPos != -1) {
CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3); CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
pos = newPos; pos = newPos;
sprite.place(pos); sprite.place(pos);
sprite.visible = Dungeon.visible[pos]; sprite.visible = Dungeon.visible[pos];
} }
} }
} }
} else { } else {
Mob questBoss; Mob questBoss;
String txt_quest; String txt_quest;
switch (Quest.type){ switch (Quest.type){
case 1: default: case 1: default:
questBoss = new FetidRat(); questBoss = new FetidRat();
txt_quest = Utils.format(TXT_RAT1, Dungeon.hero.givenName()); break; txt_quest = Utils.format(TXT_RAT1, Dungeon.hero.givenName()); break;
case 2: case 2:
questBoss = new GnollTrickster(); questBoss = new GnollTrickster();
txt_quest = Utils.format(TXT_GNOLL1, Dungeon.hero.givenName()); break; txt_quest = Utils.format(TXT_GNOLL1, Dungeon.hero.givenName()); break;
case 3: case 3:
questBoss = new GreatCrab(); questBoss = new GreatCrab();
txt_quest = Utils.format(TXT_CRAB1, Dungeon.hero.givenName()); break; txt_quest = Utils.format(TXT_CRAB1, Dungeon.hero.givenName()); break;
} }
questBoss.pos = Dungeon.level.randomRespawnCell(); questBoss.pos = Dungeon.level.randomRespawnCell();
if (questBoss.pos != -1) { if (questBoss.pos != -1) {
GameScene.add(questBoss); GameScene.add(questBoss);
GameScene.show( new WndQuest( this, txt_quest ) ); GameScene.show( new WndQuest( this, txt_quest ) );
Quest.given = true; Quest.given = true;
Journal.add( Journal.Feature.GHOST ); Journal.add( Journal.Feature.GHOST );
} }
} }
} }
@Override @Override
public String description() { public String description() {
return return
"The ghost is barely visible. It looks like a shapeless " + "The ghost is barely visible. It looks like a shapeless " +
"spot of faint light with a sorrowful face."; "spot of faint light with a sorrowful face.";
} }
@ -240,7 +240,7 @@ public class Ghost extends NPC {
private static boolean spawned; private static boolean spawned;
private static int type; private static int type;
private static boolean given; private static boolean given;
private static boolean processed; private static boolean processed;
@ -251,7 +251,7 @@ public class Ghost extends NPC {
public static Armor armor; public static Armor armor;
public static void reset() { public static void reset() {
spawned = false; spawned = false;
weapon = null; weapon = null;
armor = null; armor = null;
@ -260,7 +260,7 @@ public class Ghost extends NPC {
private static final String NODE = "sadGhost"; private static final String NODE = "sadGhost";
private static final String SPAWNED = "spawned"; private static final String SPAWNED = "spawned";
private static final String TYPE = "type"; private static final String TYPE = "type";
private static final String GIVEN = "given"; private static final String GIVEN = "given";
private static final String PROCESSED = "processed"; private static final String PROCESSED = "processed";
private static final String DEPTH = "depth"; private static final String DEPTH = "depth";
@ -294,9 +294,9 @@ public class Ghost extends NPC {
if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) { if (!node.isNull() && (spawned = node.getBoolean( SPAWNED ))) {
type = node.getInt(TYPE); type = node.getInt(TYPE);
given = node.getBoolean( GIVEN ); given = node.getBoolean( GIVEN );
processed = node.getBoolean( PROCESSED ); processed = node.getBoolean( PROCESSED );
depth = node.getInt( DEPTH ); depth = node.getInt( DEPTH );
@ -317,32 +317,32 @@ public class Ghost extends NPC {
level.mobs.add( ghost ); level.mobs.add( ghost );
spawned = true; spawned = true;
//dungeon depth determines type of quest. //dungeon depth determines type of quest.
//depth2=fetid rat, 3=gnoll trickster, 4=great crab //depth2=fetid rat, 3=gnoll trickster, 4=great crab
type = Dungeon.depth-1; type = Dungeon.depth-1;
given = false; given = false;
processed = false; processed = false;
depth = Dungeon.depth; depth = Dungeon.depth;
do { do {
weapon = Generator.randomWeapon(10); weapon = Generator.randomWeapon(10);
} while (weapon instanceof MissileWeapon); } while (weapon instanceof MissileWeapon);
armor = Generator.randomArmor(10); armor = Generator.randomArmor(10);
for (int i = 1; i <= 3; i++) { for (int i = 1; i <= 3; i++) {
Item another; Item another;
do { do {
another = Generator.randomWeapon(10+i); another = Generator.randomWeapon(10+i);
} while (another instanceof MissileWeapon); } while (another instanceof MissileWeapon);
if (another.level >= weapon.level) { if (another.level >= weapon.level) {
weapon = (Weapon) another; weapon = (Weapon) another;
} }
another = Generator.randomArmor(10+i); another = Generator.randomArmor(10+i);
if (another.level >= armor.level) { if (another.level >= armor.level) {
armor = (Armor) another; armor = (Armor) another;
} }
} }
weapon.identify(); weapon.identify();
armor.identify(); armor.identify();
@ -352,9 +352,9 @@ public class Ghost extends NPC {
public static void process() { public static void process() {
if (spawned && given && !processed && (depth == Dungeon.depth)) { if (spawned && given && !processed && (depth == Dungeon.depth)) {
GLog.n("sad ghost: Thank you... come find me..."); GLog.n("sad ghost: Thank you... come find me...");
Sample.INSTANCE.play( Assets.SND_GHOST ); Sample.INSTANCE.play( Assets.SND_GHOST );
processed = true; processed = true;
Generator.Category.ARTIFACT.probs[10] = 1; //flags the dried rose as spawnable. Generator.Category.ARTIFACT.probs[10] = 1; //flags the dried rose as spawnable.
} }
} }
@ -379,7 +379,7 @@ public class Ghost extends NPC {
EXP = 4; EXP = 4;
state = WANDERING; state = WANDERING;
} }
@Override @Override
@ -392,14 +392,14 @@ public class Ghost extends NPC {
return 2; return 2;
} }
@Override @Override
public int attackProc( Char enemy, int damage ) { public int attackProc( Char enemy, int damage ) {
if (Random.Int( 3 ) == 0) { if (Random.Int( 3 ) == 0) {
Buff.affect(enemy, Ooze.class); Buff.affect(enemy, Ooze.class);
} }
return damage; return damage;
} }
@Override @Override
public int defenseProc( Char enemy, int damage ) { public int defenseProc( Char enemy, int damage ) {
@ -420,184 +420,184 @@ public class Ghost extends NPC {
public String description() { public String description() {
return return
"Something is clearly wrong with this rat. Its greasy black fur and rotting skin are very " + "Something is clearly wrong with this rat. Its greasy black fur and rotting skin are very " +
"different from the healthy rats you've seen previously. It's pale green eyes " + "different from the healthy rats you've seen previously. It's pale green eyes " +
"make it seem especially menacing.\n\n" + "make it seem especially menacing.\n\n" +
"The rat carries a cloud of horrible stench with it, it's overpoweringly strong up close.\n\n" + "The rat carries a cloud of horrible stench with it, it's overpoweringly strong up close.\n\n" +
"Dark ooze dribbles from the rat's mouth, it eats through the floor but seems to dissolve in water."; "Dark ooze dribbles from the rat's mouth, it eats through the floor but seems to dissolve in water.";
} }
private static final HashSet<Class<?>> IMMUNITIES = new HashSet<Class<?>>(); private static final HashSet<Class<?>> IMMUNITIES = new HashSet<Class<?>>();
static { static {
IMMUNITIES.add( StenchGas.class ); IMMUNITIES.add( StenchGas.class );
} }
@Override @Override
public HashSet<Class<?>> immunities() { public HashSet<Class<?>> immunities() {
return IMMUNITIES; return IMMUNITIES;
} }
} }
public static class GnollTrickster extends Gnoll { public static class GnollTrickster extends Gnoll {
{ {
name = "gnoll trickster"; name = "gnoll trickster";
spriteClass = GnollTricksterSprite.class; spriteClass = GnollTricksterSprite.class;
HP = HT = 20; HP = HT = 20;
defenseSkill = 5; defenseSkill = 5;
EXP = 5; EXP = 5;
state = WANDERING; state = WANDERING;
loot = Generator.random(CurareDart.class); loot = Generator.random(CurareDart.class);
lootChance = 1f; lootChance = 1f;
} }
private int combo = 0; private int combo = 0;
@Override @Override
public int attackSkill( Char target ) { public int attackSkill( Char target ) {
return 16; return 16;
} }
@Override @Override
protected boolean canAttack( Char enemy ) { protected boolean canAttack( Char enemy ) {
Ballistica attack = new Ballistica( pos, enemy.pos, Ballistica.PROJECTILE ); Ballistica attack = new Ballistica( pos, enemy.pos, Ballistica.PROJECTILE );
if (!Level.adjacent(pos, enemy.pos) && attack.collisionPos == enemy.pos){ if (!Level.adjacent(pos, enemy.pos) && attack.collisionPos == enemy.pos){
combo++; combo++;
return true; return true;
} else { } else {
return false; return false;
} }
} }
@Override @Override
public int attackProc( Char enemy, int damage ) { public int attackProc( Char enemy, int damage ) {
//The gnoll's attacks get more severe the more the player lets it hit them //The gnoll's attacks get more severe the more the player lets it hit them
int effect = Random.Int(4)+combo; int effect = Random.Int(4)+combo;
if (effect > 2) { if (effect > 2) {
if (effect >=6 && enemy.buff(Burning.class) == null){ if (effect >=6 && enemy.buff(Burning.class) == null){
if (Level.flamable[enemy.pos]) if (Level.flamable[enemy.pos])
GameScene.add( Blob.seed( enemy.pos, 4, Fire.class ) ); GameScene.add( Blob.seed( enemy.pos, 4, Fire.class ) );
Buff.affect( enemy, Burning.class ).reignite( enemy ); Buff.affect( enemy, Burning.class ).reignite( enemy );
} else } else
Buff.affect( enemy, Poison.class).set((effect-2) * Poison.durationFactor(enemy)); Buff.affect( enemy, Poison.class).set((effect-2) * Poison.durationFactor(enemy));
} }
return damage; return damage;
} }
@Override @Override
protected boolean getCloser( int target ) { protected boolean getCloser( int target ) {
combo = 0; //if he's moving, he isn't attacking, reset combo. combo = 0; //if he's moving, he isn't attacking, reset combo.
if (enemy != null && Level.adjacent(pos, enemy.pos)) { if (enemy != null && Level.adjacent(pos, enemy.pos)) {
return getFurther( target ); return getFurther( target );
} else { } else {
return super.getCloser( target ); return super.getCloser( target );
} }
} }
@Override @Override
public void die( Object cause ) { public void die( Object cause ) {
super.die( cause ); super.die( cause );
Quest.process(); Quest.process();
} }
@Override @Override
public String description() { public String description() {
return return
"A strange looking creature, even by gnoll standards. It hunches forward with a wicked grin, " + "A strange looking creature, even by gnoll standards. It hunches forward with a wicked grin, " +
"almost cradling the satchel hanging over its shoulder. Its eyes are wide with a strange mix of " + "almost cradling the satchel hanging over its shoulder. Its eyes are wide with a strange mix of " +
"fear and excitement.\n\n" + "fear and excitement.\n\n" +
"There is a large collection of poorly made darts in its satchel, they all seem to be " + "There is a large collection of poorly made darts in its satchel, they all seem to be " +
"tipped with various harmful substances."; "tipped with various harmful substances.";
} }
private static final String COMBO = "combo"; private static final String COMBO = "combo";
@Override @Override
public void storeInBundle( Bundle bundle ) { public void storeInBundle( Bundle bundle ) {
super.storeInBundle(bundle); super.storeInBundle(bundle);
bundle.put(COMBO, combo); bundle.put(COMBO, combo);
} }
@Override @Override
public void restoreFromBundle( Bundle bundle ) { public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle ); super.restoreFromBundle( bundle );
combo = bundle.getInt( COMBO ); combo = bundle.getInt( COMBO );
} }
} }
public static class GreatCrab extends Crab { public static class GreatCrab extends Crab {
{ {
name = "great crab"; name = "great crab";
spriteClass = GreatCrabSprite.class; spriteClass = GreatCrabSprite.class;
HP = HT = 30; HP = HT = 30;
defenseSkill = 0; //see damage() defenseSkill = 0; //see damage()
baseSpeed = 1f; baseSpeed = 1f;
EXP = 6; EXP = 6;
state = WANDERING; state = WANDERING;
} }
private int moving = 0; private int moving = 0;
@Override @Override
protected boolean getCloser( int target ) { protected boolean getCloser( int target ) {
//this is used so that the crab remains slower, but still detects the player at the expected rate. //this is used so that the crab remains slower, but still detects the player at the expected rate.
moving++; moving++;
if (moving < 3) { if (moving < 3) {
return super.getCloser( target ); return super.getCloser( target );
} else { } else {
moving = 0; moving = 0;
return true; return true;
} }
} }
@Override @Override
public void damage( int dmg, Object src ){ public void damage( int dmg, Object src ){
//crab blocks all attacks originating from the hero or enemy characters or traps if it is alerted. //crab blocks all attacks originating from the hero or enemy characters or traps if it is alerted.
//All direct damage from these sources is negated, no exceptions. blob/debuff effects go through as normal. //All direct damage from these sources is negated, no exceptions. blob/debuff effects go through as normal.
if (enemySeen && (src instanceof Wand || src instanceof LightningTrap.Electricity || src instanceof Char)){ if (enemySeen && (src instanceof Wand || src instanceof LightningTrap.Electricity || src instanceof Char)){
GLog.n("The crab notices the attack and blocks with its massive claw."); GLog.n("The crab notices the attack and blocks with its massive claw.");
sprite.showStatus( CharSprite.NEUTRAL, "blocked" ); sprite.showStatus( CharSprite.NEUTRAL, "blocked" );
} else { } else {
super.damage( dmg, src ); super.damage( dmg, src );
} }
} }
@Override @Override
public void die( Object cause ) { public void die( Object cause ) {
super.die( cause ); super.die( cause );
Quest.process(); Quest.process();
Dungeon.level.drop( new MysteryMeat(), pos ); Dungeon.level.drop( new MysteryMeat(), pos );
Dungeon.level.drop( new MysteryMeat(), pos ).sprite.drop(); Dungeon.level.drop( new MysteryMeat(), pos ).sprite.drop();
} }
@Override @Override
public String description() { public String description() {
return return
"This crab is gigantic, even compared to other sewer crabs. " + "This crab is gigantic, even compared to other sewer crabs. " +
"Its blue shell is covered in cracks and barnacles, showing great age. " + "Its blue shell is covered in cracks and barnacles, showing great age. " +
"It lumbers around slowly, barely keeping balance with its massive claw.\n\n" + "It lumbers around slowly, barely keeping balance with its massive claw.\n\n" +
"While the crab only has one claw, its size easily compensates. " + "While the crab only has one claw, its size easily compensates. " +
"The crab holds the claw infront of itself whenever it sees a threat, shielding " + "The crab holds the claw infront of itself whenever it sees a threat, shielding " +
"itself behind an impenetrable wall of carapace."; "itself behind an impenetrable wall of carapace.";
} }
} }
} }

View File

@ -62,11 +62,11 @@ public class Imp extends NPC {
"So please, kill... let's say _8 of them_ and a reward is yours."; "So please, kill... let's say _8 of them_ and a reward is yours.";
private static final String TXT_GOLEMS2 = private static final String TXT_GOLEMS2 =
"How is your golem safari going?"; "How is your golem safari going?";
private static final String TXT_MONKS2 = private static final String TXT_MONKS2 =
"Oh, you are still alive! I knew that your kung-fu is stronger ;) " + "Oh, you are still alive! I knew that your kung-fu is stronger ;) " +
"Just don't forget to grab these monks' tokens."; "Just don't forget to grab these monks' tokens.";
private static final String TXT_CYA = "See you, %s!"; private static final String TXT_CYA = "See you, %s!";
private static final String TXT_HEY = "Psst, %s!"; private static final String TXT_HEY = "Psst, %s!";
@ -136,7 +136,7 @@ public class Imp extends NPC {
} }
private void tell( String format, Object...args ) { private void tell( String format, Object...args ) {
GameScene.show( GameScene.show(
new WndQuest( this, Utils.format( format, args ) ) ); new WndQuest( this, Utils.format( format, args ) ) );
} }
@ -150,7 +150,7 @@ public class Imp extends NPC {
@Override @Override
public String description() { public String description() {
return return
"Imps are lesser demons. They are notable for neither their strength nor their magic talent, " + "Imps are lesser demons. They are notable for neither their strength nor their magic talent, " +
"but they are quite smart and sociable. Many imps prefer to live among non-demons."; "but they are quite smart and sociable. Many imps prefer to live among non-demons.";
} }

View File

@ -28,7 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
public class ImpShopkeeper extends Shopkeeper { public class ImpShopkeeper extends Shopkeeper {
private static final String TXT_GREETINGS = "Hello, %s!"; private static final String TXT_GREETINGS = "Hello, %s!";
public static final String TXT_THIEF = "I thought I could trust you!"; public static final String TXT_THIEF = "I thought I could trust you!";
{ {
@ -50,7 +50,7 @@ public class ImpShopkeeper extends Shopkeeper {
} }
@Override @Override
public void flee() { public void flee() {
for (Heap heap: Dungeon.level.heaps.values()) { for (Heap heap: Dungeon.level.heaps.values()) {
if (heap.type == Heap.Type.FOR_SALE) { if (heap.type == Heap.Type.FOR_SALE) {
CellEmitter.get( heap.pos ).burst( ElmoParticle.FACTORY, 4 ); CellEmitter.get( heap.pos ).burst( ElmoParticle.FACTORY, 4 );
@ -66,7 +66,7 @@ public class ImpShopkeeper extends Shopkeeper {
@Override @Override
public String description() { public String description() {
return return
"Imps are lesser demons. They are notable for neither their strength nor their magic talent. " + "Imps are lesser demons. They are notable for neither their strength nor their magic talent. " +
"But they are quite smart and sociable, and many of imps prefer to live and do business among non-demons."; "But they are quite smart and sociable, and many of imps prefer to live and do business among non-demons.";
} }

View File

@ -135,16 +135,16 @@ public class MirrorImage extends NPC {
Dungeon.hero.spend( 1 / Dungeon.hero.speed() ); Dungeon.hero.spend( 1 / Dungeon.hero.speed() );
Dungeon.hero.busy(); Dungeon.hero.busy();
} }
private static final HashSet<Class<?>> IMMUNITIES = new HashSet<Class<?>>(); private static final HashSet<Class<?>> IMMUNITIES = new HashSet<Class<?>>();
static { static {
IMMUNITIES.add( ToxicGas.class ); IMMUNITIES.add( ToxicGas.class );
IMMUNITIES.add( Burning.class ); IMMUNITIES.add( Burning.class );
} }
@Override @Override
public HashSet<Class<?>> immunities() { public HashSet<Class<?>> immunities() {
return IMMUNITIES; return IMMUNITIES;
} }
} }

View File

@ -25,28 +25,28 @@ import com.watabou.utils.Random;
public abstract class NPC extends Mob { public abstract class NPC extends Mob {
{ {
HP = HT = 1; HP = HT = 1;
EXP = 0; EXP = 0;
hostile = false; hostile = false;
state = PASSIVE; state = PASSIVE;
} }
protected void throwItem() { protected void throwItem() {
Heap heap = Dungeon.level.heaps.get( pos ); Heap heap = Dungeon.level.heaps.get( pos );
if (heap != null) { if (heap != null) {
int n; int n;
do { do {
n = pos + Level.NEIGHBOURS8[Random.Int( 8 )]; n = pos + Level.NEIGHBOURS8[Random.Int( 8 )];
} while (!Level.passable[n] && !Level.avoid[n]); } while (!Level.passable[n] && !Level.avoid[n]);
Dungeon.level.drop( heap.pickUp(), n ).sprite.drop( pos ); Dungeon.level.drop( heap.pickUp(), n ).sprite.drop( pos );
} }
} }
@Override @Override
public void beckon( int cell ) { public void beckon( int cell ) {
} }
abstract public void interact(); abstract public void interact();
} }

View File

@ -31,7 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem;
public class Shopkeeper extends NPC { public class Shopkeeper extends NPC {
public static final String TXT_THIEF = "Thief, Thief!"; public static final String TXT_THIEF = "Thief, Thief!";
{ {
name = "shopkeeper"; name = "shopkeeper";
@ -79,7 +79,7 @@ public class Shopkeeper extends NPC {
@Override @Override
public String description() { public String description() {
return return
"This stout guy looks more appropriate for a trade district in some large city " + "This stout guy looks more appropriate for a trade district in some large city " +
"than for a dungeon. His prices explain why he prefers to do business here."; "than for a dungeon. His prices explain why he prefers to do business here.";
} }

View File

@ -55,7 +55,7 @@ import com.watabou.utils.Random;
public class Wandmaker extends NPC { public class Wandmaker extends NPC {
{ {
name = "old wandmaker"; name = "old wandmaker";
spriteClass = WandmakerSprite.class; spriteClass = WandmakerSprite.class;
} }
@ -126,8 +126,8 @@ public class Wandmaker extends NPC {
Quest.placeItem(); Quest.placeItem();
if (Quest.given) if (Quest.given)
tell(Quest.alternative ? TXT_DUST1 : TXT_BERRY1); tell(Quest.alternative ? TXT_DUST1 : TXT_BERRY1);
Journal.add( Journal.Feature.WANDMAKER ); Journal.add( Journal.Feature.WANDMAKER );
} }
@ -139,7 +139,7 @@ public class Wandmaker extends NPC {
@Override @Override
public String description() { public String description() {
return return
"This old but hale gentleman wears a slightly confused " + "This old but hale gentleman wears a slightly confused " +
"expression. He is protected by a magic shield."; "expression. He is protected by a magic shield.";
} }
@ -241,19 +241,19 @@ public class Wandmaker extends NPC {
if (candidates.size() > 0) { if (candidates.size() > 0) {
Random.element( candidates ).drop( new CorpseDust() ); Random.element( candidates ).drop( new CorpseDust() );
given = true; given = true;
} else { } else {
int pos = Dungeon.level.randomRespawnCell(); int pos = Dungeon.level.randomRespawnCell();
while (Dungeon.level.heaps.get( pos ) != null) { while (Dungeon.level.heaps.get( pos ) != null) {
pos = Dungeon.level.randomRespawnCell(); pos = Dungeon.level.randomRespawnCell();
} }
if (pos != -1) { if (pos != -1) {
Heap heap = Dungeon.level.drop(new CorpseDust(), pos); Heap heap = Dungeon.level.drop(new CorpseDust(), pos);
heap.type = Heap.Type.SKELETON; heap.type = Heap.Type.SKELETON;
heap.sprite.link(); heap.sprite.link();
given = true; given = true;
} }
} }
} else { } else {
@ -263,10 +263,10 @@ public class Wandmaker extends NPC {
shrubPos = Dungeon.level.randomRespawnCell(); shrubPos = Dungeon.level.randomRespawnCell();
} }
if (shrubPos != -1) { if (shrubPos != -1) {
Dungeon.level.plant(new Rotberry.Seed(), shrubPos); Dungeon.level.plant(new Rotberry.Seed(), shrubPos);
given = true; given = true;
} }
} }
} }
@ -281,7 +281,7 @@ public class Wandmaker extends NPC {
public static class Rotberry extends Plant { public static class Rotberry extends Plant {
private static final String TXT_DESC = private static final String TXT_DESC =
"Berries of this shrub taste like sweet, sweet death."; "Berries of this shrub taste like sweet, sweet death.";
{ {

View File

@ -208,9 +208,9 @@ public class BadgeBanner extends Image {
break; break;
case 38: case 38:
p.offset( 5, 5 ); p.offset( 5, 5 );
break; break;
case 39: case 39:
p.offset( 5, 4 ); p.offset( 5, 4 );
break; break;
case 40: case 40:
case 41: case 41:
@ -256,10 +256,10 @@ public class BadgeBanner extends Image {
break; break;
} }
p.x *= image.scale.x; p.x *= image.scale.x;
p.y *= image.scale.y; p.y *= image.scale.y;
p.offset( p.offset(
-image.origin.x * (image.scale.x - 1), -image.origin.x * (image.scale.x - 1),
-image.origin.y * (image.scale.y - 1) ); -image.origin.y * (image.scale.y - 1) );
p.offset( image.point() ); p.offset( image.point() );

View File

@ -22,33 +22,33 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
public class BannerSprites { public class BannerSprites {
public enum Type { public enum Type {
PIXEL_DUNGEON, PIXEL_DUNGEON,
BOSS_SLAIN, BOSS_SLAIN,
GAME_OVER, GAME_OVER,
SELECT_YOUR_HERO, SELECT_YOUR_HERO,
PIXEL_DUNGEON_SIGNS PIXEL_DUNGEON_SIGNS
}; };
public static Image get( Type type ) { public static Image get( Type type ) {
Image icon = new Image( Assets.BANNERS ); Image icon = new Image( Assets.BANNERS );
switch (type) { switch (type) {
case PIXEL_DUNGEON: case PIXEL_DUNGEON:
icon.frame( icon.texture.uvRect( 0, 0, 128, 70 ) ); icon.frame( icon.texture.uvRect( 0, 0, 128, 70 ) );
break; break;
case BOSS_SLAIN: case BOSS_SLAIN:
icon.frame( icon.texture.uvRect( 0, 70, 128, 105 ) ); icon.frame( icon.texture.uvRect( 0, 70, 128, 105 ) );
break; break;
case GAME_OVER: case GAME_OVER:
icon.frame( icon.texture.uvRect( 0, 105, 128, 140 ) ); icon.frame( icon.texture.uvRect( 0, 105, 128, 140 ) );
break; break;
case SELECT_YOUR_HERO: case SELECT_YOUR_HERO:
icon.frame( icon.texture.uvRect( 0, 140, 128, 161 ) ); icon.frame( icon.texture.uvRect( 0, 140, 128, 161 ) );
break; break;
case PIXEL_DUNGEON_SIGNS: case PIXEL_DUNGEON_SIGNS:
icon.frame( icon.texture.uvRect( 0, 161, 128, 218 ) ); icon.frame( icon.texture.uvRect( 0, 161, 128, 218 ) );
break; break;
} }
return icon; return icon;
} }
} }

View File

@ -7,9 +7,6 @@ import com.watabou.noosa.Image;
import com.watabou.utils.Callback; import com.watabou.utils.Callback;
import com.watabou.utils.PointF; import com.watabou.utils.PointF;
/**
* Created by Evan on 23/05/2015.
*/
public class Chains extends Group { public class Chains extends Group {
private static final double A = 180 / Math.PI; private static final double A = 180 / Math.PI;

View File

@ -31,8 +31,8 @@ public class CheckedCell extends Image {
origin.set( 0.5f ); origin.set( 0.5f );
point( DungeonTilemap.tileToWorld( pos ).offset( point( DungeonTilemap.tileToWorld( pos ).offset(
DungeonTilemap.SIZE / 2, DungeonTilemap.SIZE / 2,
DungeonTilemap.SIZE / 2 ) ); DungeonTilemap.SIZE / 2 ) );
alpha = 0.8f; alpha = 0.8f;

View File

@ -6,9 +6,6 @@ import com.watabou.noosa.Game;
import com.watabou.noosa.Gizmo; import com.watabou.noosa.Gizmo;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
/**
* Created by Evan on 14/05/2015.
*/
public class DarkBlock extends Gizmo{ public class DarkBlock extends Gizmo{
private CharSprite target; private CharSprite target;

View File

@ -86,10 +86,10 @@ public class Fireball extends Component {
bLight.x = x - bLight.width / 2; bLight.x = x - bLight.width / 2;
bLight.y = y - bLight.height / 2; bLight.y = y - bLight.height / 2;
emitter.pos( emitter.pos(
x - bLight.width / 4, x - bLight.width / 4,
y - bLight.height / 4, y - bLight.height / 4,
bLight.width / 2, bLight.width / 2,
bLight.height / 2 ); bLight.height / 2 );
fLight.x = x - fLight.width / 2; fLight.x = x - fLight.width / 2;
@ -104,8 +104,8 @@ public class Fireball extends Component {
if (Random.Float() < Game.elapsed) { if (Random.Float() < Game.elapsed) {
PixelParticle spark = (PixelParticle)sparks.recycle( PixelParticle.Shrinking.class ); PixelParticle spark = (PixelParticle)sparks.recycle( PixelParticle.Shrinking.class );
spark.reset( x, y, ColorMath.random( COLOR, 0x66FF66 ), 2, Random.Float( 0.5f, 1.0f ) ); spark.reset( x, y, ColorMath.random( COLOR, 0x66FF66 ), 2, Random.Float( 0.5f, 1.0f ) );
spark.speed.set( spark.speed.set(
Random.Float( -40, +40 ), Random.Float( -40, +40 ),
Random.Float( -60, +20 ) ); Random.Float( -60, +20 ) );
spark.acc.set( 0, +80 ); spark.acc.set( 0, +80 );
sparks.add( spark ); sparks.add( spark );

View File

@ -157,8 +157,8 @@ public class Flare extends Visual {
texture.bind(); texture.bind();
script.uModel.valueM4( matrix ); script.uModel.valueM4( matrix );
script.lighting( script.lighting(
rm, gm, bm, am, rm, gm, bm, am,
ra, ga, ba, aa ); ra, ga, ba, aa );
script.camera( camera ); script.camera( camera );

View File

@ -25,7 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
public class IceBlock extends Gizmo { public class IceBlock extends Gizmo {
private float phase; private float phase;
private CharSprite target; private CharSprite target;

View File

@ -175,7 +175,7 @@ public class MagicMissile extends Emitter {
public static class MagicParticle extends PixelParticle { public static class MagicParticle extends PixelParticle {
public static final Emitter.Factory FACTORY = new Factory() { public static final Emitter.Factory FACTORY = new Factory() {
@Override @Override
public void emit( Emitter emitter, int index, float x, float y ) { public void emit( Emitter emitter, int index, float x, float y ) {
((MagicParticle)emitter.recycle( MagicParticle.class )).reset( x, y ); ((MagicParticle)emitter.recycle( MagicParticle.class )).reset( x, y );
@ -214,7 +214,7 @@ public class MagicMissile extends Emitter {
public static class EarthParticle extends PixelParticle.Shrinking { public static class EarthParticle extends PixelParticle.Shrinking {
public static final Emitter.Factory FACTORY = new Factory() { public static final Emitter.Factory FACTORY = new Factory() {
@Override @Override
public void emit( Emitter emitter, int index, float x, float y ) { public void emit( Emitter emitter, int index, float x, float y ) {
((EarthParticle)emitter.recycle( EarthParticle.class )).reset( x, y ); ((EarthParticle)emitter.recycle( EarthParticle.class )).reset( x, y );
@ -246,7 +246,7 @@ public class MagicMissile extends Emitter {
public static class WhiteParticle extends PixelParticle { public static class WhiteParticle extends PixelParticle {
public static final Emitter.Factory FACTORY = new Factory() { public static final Emitter.Factory FACTORY = new Factory() {
@Override @Override
public void emit( Emitter emitter, int index, float x, float y ) { public void emit( Emitter emitter, int index, float x, float y ) {
((WhiteParticle)emitter.recycle( WhiteParticle.class )).reset( x, y ); ((WhiteParticle)emitter.recycle( WhiteParticle.class )).reset( x, y );
@ -286,7 +286,7 @@ public class MagicMissile extends Emitter {
private Emitter emitter; private Emitter emitter;
public static final Emitter.Factory FACTORY = new Factory() { public static final Emitter.Factory FACTORY = new Factory() {
@Override @Override
public void emit( Emitter emitter, int index, float x, float y ) { public void emit( Emitter emitter, int index, float x, float y ) {
((SlowParticle)emitter.recycle( SlowParticle.class )).reset( x, y, emitter ); ((SlowParticle)emitter.recycle( SlowParticle.class )).reset( x, y, emitter );
@ -330,7 +330,7 @@ public class MagicMissile extends Emitter {
public static class ForceParticle extends PixelParticle { public static class ForceParticle extends PixelParticle {
public static final Emitter.Factory FACTORY = new Factory() { public static final Emitter.Factory FACTORY = new Factory() {
@Override @Override
public void emit( Emitter emitter, int index, float x, float y ) { public void emit( Emitter emitter, int index, float x, float y ) {
((ForceParticle)emitter.recycle( ForceParticle.class )).reset( x, y ); ((ForceParticle)emitter.recycle( ForceParticle.class )).reset( x, y );
@ -368,7 +368,7 @@ public class MagicMissile extends Emitter {
public static class ColdParticle extends PixelParticle.Shrinking { public static class ColdParticle extends PixelParticle.Shrinking {
public static final Emitter.Factory FACTORY = new Factory() { public static final Emitter.Factory FACTORY = new Factory() {
@Override @Override
public void emit( Emitter emitter, int index, float x, float y ) { public void emit( Emitter emitter, int index, float x, float y ) {
((ColdParticle)emitter.recycle( ColdParticle.class )).reset( x, y ); ((ColdParticle)emitter.recycle( ColdParticle.class )).reset( x, y );

View File

@ -58,9 +58,9 @@ public class Speck extends Image {
public static final int VENOM = 108; public static final int VENOM = 108;
public static final int PARALYSIS = 109; public static final int PARALYSIS = 109;
public static final int DUST = 110; public static final int DUST = 110;
public static final int STENCH = 111; public static final int STENCH = 111;
public static final int FORGE = 112; public static final int FORGE = 112;
public static final int CONFUSION = 113; public static final int CONFUSION = 113;
private static final int SIZE = 7; private static final int SIZE = 7;
@ -104,8 +104,8 @@ public class Speck extends Image {
case TOXIC: case TOXIC:
case VENOM: case VENOM:
case PARALYSIS: case PARALYSIS:
case STENCH: case STENCH:
case CONFUSION: case CONFUSION:
case DUST: case DUST:
frame( film.get( STEAM ) ); frame( film.get( STEAM ) );
break; break;
@ -218,7 +218,7 @@ public class Speck extends Image {
angularSpeed = Random.Float( -360, +360 ); angularSpeed = Random.Float( -360, +360 );
break; break;
case ROCK: case ROCK:
angle = Random.Float( 360 ); angle = Random.Float( 360 );
angularSpeed = Random.Float( -360, +360 ); angularSpeed = Random.Float( -360, +360 );
scale.set( Random.Float( 1, 2 ) ); scale.set( Random.Float( 1, 2 ) );
@ -287,28 +287,28 @@ public class Speck extends Image {
lifespan = Random.Float( 1f, 3f ); lifespan = Random.Float( 1f, 3f );
break; break;
case STENCH: case STENCH:
hardlight( 0x003300 ); hardlight( 0x003300 );
angularSpeed = -30; angularSpeed = -30;
angle = Random.Float( 360 ); angle = Random.Float( 360 );
lifespan = Random.Float( 1f, 3f ); lifespan = Random.Float( 1f, 3f );
break; break;
case CONFUSION: case CONFUSION:
hardlight( Random.Int( 0x1000000 ) | 0x000080 ); hardlight( Random.Int( 0x1000000 ) | 0x000080 );
angularSpeed = Random.Float( -20, +20 ); angularSpeed = Random.Float( -20, +20 );
angle = Random.Float( 360 ); angle = Random.Float( 360 );
lifespan = Random.Float( 1f, 3f ); lifespan = Random.Float( 1f, 3f );
break; break;
case DUST: case DUST:
hardlight( 0xFFFF66 ); hardlight( 0xFFFF66 );
angle = Random.Float( 360 ); angle = Random.Float( 360 );
speed.polar( Random.Float( 2 * 3.1415926f ), Random.Float( 16, 48 ) ); speed.polar( Random.Float( 2 * 3.1415926f ), Random.Float( 16, 48 ) );
lifespan = 0.5f; lifespan = 0.5f;
break; break;
case COIN: case COIN:
speed.polar( -PointF.PI * Random.Float( 0.3f, 0.7f ), Random.Float( 48, 96 ) ); speed.polar( -PointF.PI * Random.Float( 0.3f, 0.7f ), Random.Float( 48, 96 ) );
acc.y = 256; acc.y = 256;
lifespan = -speed.y / acc.y * 2; lifespan = -speed.y / acc.y * 2;
@ -340,12 +340,12 @@ public class Speck extends Image {
am = p < 0.2f ? p * 5f : (1 - p) * 1.25f; am = p < 0.2f ? p * 5f : (1 - p) * 1.25f;
break; break;
case KIT: case KIT:
case MASTERY: case MASTERY:
am = 1 - p * p; am = 1 - p * p;
break; break;
case EVOKE: case EVOKE:
case HEALING: case HEALING:
am = p < 0.5f ? 1 : 2 - p * 2; am = p < 0.5f ? 1 : 2 - p * 2;
@ -408,7 +408,7 @@ public class Speck extends Image {
case STEAM: case STEAM:
case TOXIC: case TOXIC:
case PARALYSIS: case PARALYSIS:
case CONFUSION: case CONFUSION:
case DUST: case DUST:
am = p < 0.5f ? p : 1 - p; am = p < 0.5f ? p : 1 - p;
scale.set( 1 + p * 2 ); scale.set( 1 + p * 2 );
@ -416,10 +416,10 @@ public class Speck extends Image {
case VENOM: case VENOM:
hardlight( ColorMath.interpolate( 0x8844FF, 0x00FF00 , p )); hardlight( ColorMath.interpolate( 0x8844FF, 0x00FF00 , p ));
case STENCH: case STENCH:
am = (p < 0.5f ? p : 1 - p) * 2; am = (p < 0.5f ? p : 1 - p) * 2;
scale.set( 1 + p * 2 ); scale.set( 1 + p * 2 );
break; break;
case JET: case JET:
am = (p < 0.5f ? p : 1 - p) * 2; am = (p < 0.5f ? p : 1 - p) * 2;
@ -435,29 +435,29 @@ public class Speck extends Image {
} }
} }
public static Emitter.Factory factory( final int type ) { public static Emitter.Factory factory( final int type ) {
return factory( type, false ); return factory( type, false );
} }
public static Emitter.Factory factory( final int type, final boolean lightMode ) { public static Emitter.Factory factory( final int type, final boolean lightMode ) {
Emitter.Factory factory = factories.get( type ); Emitter.Factory factory = factories.get( type );
if (factory == null) { if (factory == null) {
factory = new Emitter.Factory() { factory = new Emitter.Factory() {
@Override @Override
public void emit ( Emitter emitter, int index, float x, float y ) { public void emit ( Emitter emitter, int index, float x, float y ) {
Speck p = (Speck)emitter.recycle( Speck.class ); Speck p = (Speck)emitter.recycle( Speck.class );
p.reset( index, x, y, type ); p.reset( index, x, y, type );
} }
@Override @Override
public boolean lightMode() { public boolean lightMode() {
return lightMode; return lightMode;
} }
}; };
factories.put( type, factory ); factories.put( type, factory );
} }
return factory; return factory;
} }
} }

View File

@ -60,7 +60,7 @@ public class Splash {
emitter.burst( FACTORY, n ); emitter.burst( FACTORY, n );
} }
private static final SplashFactory FACTORY = new SplashFactory(); private static final SplashFactory FACTORY = new SplashFactory();
private static class SplashFactory extends Emitter.Factory { private static class SplashFactory extends Emitter.Factory {

View File

@ -8,64 +8,61 @@ import com.watabou.noosa.Game;
import com.watabou.noosa.Group; import com.watabou.noosa.Group;
import com.watabou.noosa.Image; import com.watabou.noosa.Image;
/**
* Created by Evan on 20/04/2015.
*/
public class Surprise extends Image { public class Surprise extends Image {
private static final float TIME_TO_FADE = 0.8f; private static final float TIME_TO_FADE = 0.8f;
private float time; private float time;
public Surprise() { public Surprise() {
super(Effects.get(Effects.Type.EXCLAMATION)); super(Effects.get(Effects.Type.EXCLAMATION));
origin.set(width / 2, height / 2); origin.set(width / 2, height / 2);
} }
public void reset(int p) { public void reset(int p) {
revive(); revive();
x = (p % Level.WIDTH) * DungeonTilemap.SIZE + (DungeonTilemap.SIZE - width) / 2; x = (p % Level.WIDTH) * DungeonTilemap.SIZE + (DungeonTilemap.SIZE - width) / 2;
y = (p / Level.WIDTH) * DungeonTilemap.SIZE + (DungeonTilemap.SIZE - height) / 2; y = (p / Level.WIDTH) * DungeonTilemap.SIZE + (DungeonTilemap.SIZE - height) / 2;
time = TIME_TO_FADE; time = TIME_TO_FADE;
} }
@Override @Override
public void update() { public void update() {
super.update(); super.update();
if ((time -= Game.elapsed) <= 0) { if ((time -= Game.elapsed) <= 0) {
kill(); kill();
} else { } else {
float p = time / TIME_TO_FADE; float p = time / TIME_TO_FADE;
alpha(p); alpha(p);
scale.y = 1 + p/2; scale.y = 1 + p/2;
} }
} }
public static void hit(Char ch) { public static void hit(Char ch) {
hit(ch, 0); hit(ch, 0);
} }
public static void hit(Char ch, float angle) { public static void hit(Char ch, float angle) {
if (ch.sprite.parent != null) { if (ch.sprite.parent != null) {
Surprise s = (Surprise) ch.sprite.parent.recycle(Surprise.class); Surprise s = (Surprise) ch.sprite.parent.recycle(Surprise.class);
ch.sprite.parent.bringToFront(s); ch.sprite.parent.bringToFront(s);
s.reset(ch.pos); s.reset(ch.pos);
s.angle = angle; s.angle = angle;
} }
} }
public static void hit(int pos) { public static void hit(int pos) {
hit(pos, 0); hit(pos, 0);
} }
public static void hit(int pos, float angle) { public static void hit(int pos, float angle) {
Group parent = Dungeon.hero.sprite.parent; Group parent = Dungeon.hero.sprite.parent;
Wound w = (Wound) parent.recycle(Wound.class); Wound w = (Wound) parent.recycle(Wound.class);
parent.bringToFront(w); parent.bringToFront(w);
w.reset(pos); w.reset(pos);
w.angle = angle; w.angle = angle;
} }
} }

View File

@ -63,12 +63,12 @@ public class Wound extends Image {
} }
public static void hit( Char ch, float angle ) { public static void hit( Char ch, float angle ) {
if (ch.sprite.parent != null) { if (ch.sprite.parent != null) {
Wound w = (Wound) ch.sprite.parent.recycle(Wound.class); Wound w = (Wound) ch.sprite.parent.recycle(Wound.class);
ch.sprite.parent.bringToFront(w); ch.sprite.parent.bringToFront(w);
w.reset(ch.pos); w.reset(ch.pos);
w.angle = angle; w.angle = angle;
} }
} }
public static void hit( int pos ) { public static void hit( int pos ) {

View File

@ -38,7 +38,7 @@ public class BlastParticle extends PixelParticle.Shrinking {
public BlastParticle() { public BlastParticle() {
super(); super();
color( 0xEE7722 ); color( 0xEE7722 );
acc.set( 0, +50 ); acc.set( 0, +50 );
} }

View File

@ -25,7 +25,7 @@ import com.watabou.utils.Random;
public class BloodParticle extends PixelParticle.Shrinking { public class BloodParticle extends PixelParticle.Shrinking {
public static final Emitter.Factory FACTORY = new Factory() { public static final Emitter.Factory FACTORY = new Factory() {
@Override @Override
public void emit( Emitter emitter, int index, float x, float y ) { public void emit( Emitter emitter, int index, float x, float y ) {
((BloodParticle)emitter.recycle( BloodParticle.class )).reset( x, y ); ((BloodParticle)emitter.recycle( BloodParticle.class )).reset( x, y );

View File

@ -23,9 +23,9 @@ import com.watabou.noosa.particles.Emitter.Factory;
import com.watabou.utils.ColorMath; import com.watabou.utils.ColorMath;
import com.watabou.utils.Random; import com.watabou.utils.Random;
public class EarthParticle extends PixelParticle { public class EarthParticle extends PixelParticle {
public static final Emitter.Factory FACTORY = new Factory() { public static final Emitter.Factory FACTORY = new Factory() {
@Override @Override
public void emit( Emitter emitter, int index, float x, float y ) { public void emit( Emitter emitter, int index, float x, float y ) {
((EarthParticle)emitter.recycle( EarthParticle.class )).reset( x, y ); ((EarthParticle)emitter.recycle( EarthParticle.class )).reset( x, y );

View File

@ -23,7 +23,7 @@ import com.watabou.noosa.particles.Emitter.Factory;
public class ElmoParticle extends PixelParticle.Shrinking { public class ElmoParticle extends PixelParticle.Shrinking {
public static final Emitter.Factory FACTORY = new Factory() { public static final Emitter.Factory FACTORY = new Factory() {
@Override @Override
public void emit( Emitter emitter, int index, float x, float y ) { public void emit( Emitter emitter, int index, float x, float y ) {
((ElmoParticle)emitter.recycle( ElmoParticle.class )).reset( x, y ); ((ElmoParticle)emitter.recycle( ElmoParticle.class )).reset( x, y );

Some files were not shown because too many files have changed in this diff Show More