Skip to content
This repository has been archived by the owner on Jul 15, 2020. It is now read-only.

Commit

Permalink
ported over 0.7.0b & c changes, updated version info
Browse files Browse the repository at this point in the history
  • Loading branch information
00-Evan committed Nov 11, 2018
1 parent 605d308 commit ebf7130
Show file tree
Hide file tree
Showing 59 changed files with 332 additions and 160 deletions.
Binary file modified android/assets/tiles_caves.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/assets/tiles_city.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/assets/tiles_halls.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/assets/tiles_prison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified android/assets/tiles_sewers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ allprojects {
apply plugin: "eclipse"
apply plugin: "idea"

version = '0.7.0a'
version = '0.7.0c'
ext {
versionCode = 305
versionCode = 311
appName = 'shattered-pixel-dungeon'
appTitle = 'Shattered Pixel Dungeon'
appId = 'com.shatteredpixel.shatteredpixeldungeon'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Graphics;
import com.shatteredpixel.shatteredpixeldungeon.input.GameAction;
import com.shatteredpixel.shatteredpixeldungeon.items.food.MeatPie;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.WelcomeScene;
import com.watabou.noosa.Game;
Expand Down Expand Up @@ -141,10 +140,6 @@ public ShatteredPixelDungeon(final PDPlatformSupport<GameAction> platformSupport
com.shatteredpixel.shatteredpixeldungeon.items.spells.MagicalInfusion.class,
"com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion" );

//v0.7.0 beta, remove before full release
com.watabou.utils.Bundle.addAlias(
MeatPie.class,
"com.shatteredpixel.shatteredpixeldungeon.items.food.Feast" );
}

@SuppressWarnings("deprecation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ public synchronized void updateSpriteState() {
}
}

public int stealth() {
public float stealth() {
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ public class MagicalSleep extends Buff {
@Override
public boolean attachTo( Char target ) {
if (!target.isImmune(Sleep.class) && super.attachTo( target )) {

if (target instanceof Hero)

target.paralysed++;

if (target instanceof Hero) {
if (target.HP == target.HT) {
GLog.i(Messages.get(this, "toohealthy"));
detach();
return true;
} else {
GLog.i(Messages.get(this, "fallasleep"));
}
else if (target instanceof Mob)
((Mob)target).state = ((Mob)target).SLEEPING;

target.paralysed++;
} else if (target instanceof Mob) {
((Mob) target).state = ((Mob) target).SLEEPING;
}

return true;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
import com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton;
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndResurrect;
Expand Down Expand Up @@ -411,25 +410,19 @@ public boolean canSurpriseAttack(){
}

public boolean canAttack(Char enemy){
if (enemy == null || pos == enemy.pos)
if (enemy == null || pos == enemy.pos) {
return false;
}

//can always attack adjacent enemies
if (Dungeon.level.adjacent(pos, enemy.pos))
if (Dungeon.level.adjacent(pos, enemy.pos)) {
return true;
}

KindOfWeapon wep = Dungeon.hero.belongings.weapon;

if (wep != null && Dungeon.level.distance( pos, enemy.pos ) <= wep.reachFactor(this)){

boolean[] passable = BArray.not(Dungeon.level.solid, null);
for (Mob m : Dungeon.level.mobs)
passable[m.pos] = false;

PathFinder.buildDistanceMap(enemy.pos, passable, wep.reachFactor(this));

return PathFinder.distance[pos] <= wep.reachFactor(this);

if (wep != null){
return wep.canReach(this, enemy.pos);
} else {
return false;
}
Expand Down Expand Up @@ -1299,11 +1292,11 @@ public void remove( Buff buff ) {
}

@Override
public int stealth() {
int stealth = super.stealth();
public float stealth() {
float stealth = super.stealth();

if (belongings.armor != null){
stealth = Math.round(belongings.armor.stealthFactor(this, stealth));
stealth = belongings.armor.stealthFactor(this, stealth);
}

return stealth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ protected class Sleeping implements AiState {

@Override
public boolean act( boolean enemyInFOV, boolean justAlerted ) {
if (enemyInFOV && Random.Int( distance( enemy ) + enemy.stealth() + (enemy.flying ? 2 : 0) ) == 0) {
if (enemyInFOV && Random.Float( distance( enemy ) + enemy.stealth() + (enemy.flying ? 2 : 0) ) < 1) {

enemySeen = true;

Expand Down Expand Up @@ -726,7 +726,7 @@ protected class Wandering implements AiState {

@Override
public boolean act( boolean enemyInFOV, boolean justAlerted ) {
if (enemyInFOV && (justAlerted || Random.Int( distance( enemy ) / 2 + enemy.stealth() ) == 0)) {
if (enemyInFOV && (justAlerted || Random.Float( distance( enemy ) / 2f + enemy.stealth() ) < 1)) {

enemySeen = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected float attackDelay() {

@Override
protected boolean canAttack(Char enemy) {
return Dungeon.level.distance( pos, enemy.pos ) <= weapon.reachFactor(this);
return super.canAttack(enemy) || weapon.canReach(this, enemy.pos);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,7 @@ protected float attackDelay() {

@Override
protected boolean canAttack(Char enemy) {
if (hero.belongings.weapon != null){
return Dungeon.level.distance( pos, enemy.pos ) <= hero.belongings.weapon.reachFactor(this);
} else {
return super.canAttack(enemy);
}
return super.canAttack(enemy) || (hero.belongings.weapon != null && hero.belongings.weapon.canReach(this, enemy.pos));
}

@Override
Expand Down
36 changes: 24 additions & 12 deletions core/src/com/shatteredpixel/shatteredpixeldungeon/items/Heap.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@
import java.util.LinkedList;

public class Heap implements Bundlable {

private static final int SEEDS_TO_POTION = 3;

public enum Type {
HEAP,
Expand All @@ -81,6 +79,7 @@ public enum Type {

public ItemSprite sprite;
public boolean seen = false;
public boolean haunted = false;

public LinkedList<Item> items = new LinkedList<Item>();

Expand Down Expand Up @@ -126,19 +125,17 @@ public void open( Hero hero ) {
case REMAINS:
case SKELETON:
CellEmitter.center( pos ).start(Speck.factory(Speck.RATTLE), 0.1f, 3);
for (Item item : items) {
if (item.cursed) {
if (Wraith.spawnAt( pos ) == null) {
hero.sprite.emitter().burst( ShadowParticle.CURSE, 6 );
hero.damage( hero.HP / 2, this );
}
Sample.INSTANCE.play( Assets.SND_CURSED );
break;
}
}
break;
default:
}

if (haunted){
if (Wraith.spawnAt( pos ) == null) {
hero.sprite.emitter().burst( ShadowParticle.CURSE, 6 );
hero.damage( hero.HP / 2, this );
}
Sample.INSTANCE.play( Assets.SND_CURSED );
}

if (type != Type.MIMIC) {
type = Type.HEAP;
Expand All @@ -152,6 +149,17 @@ public void open( Hero hero ) {
}
}

public Heap setHauntedIfCursed( float chance ){
for (Item item : items) {
if (item.cursed && Random.Float() < chance) {
haunted = true;
item.cursedKnown = true;
break;
}
}
return this;
}

public int size() {
return items.size();
}
Expand Down Expand Up @@ -428,6 +436,7 @@ else if (peek() instanceof Wand)
private static final String SEEN = "seen";
private static final String TYPE = "type";
private static final String ITEMS = "items";
private static final String HAUNTED = "haunted";

@SuppressWarnings("unchecked")
@Override
Expand All @@ -447,6 +456,8 @@ public void restoreFromBundle( Bundle bundle ) {
}
}

haunted = bundle.getBoolean( HAUNTED );

}

@Override
Expand All @@ -455,6 +466,7 @@ public void storeInBundle( Bundle bundle ) {
bundle.put( SEEN, seen );
bundle.put( TYPE, type.toString() );
bundle.put( ITEMS, items );
bundle.put( HAUNTED, haunted );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ public void saveSelectively( Bundle bundle, ArrayList<Item> itemsToSave ){
}
}
}

public void saveClassesSelectively( Bundle bundle, ArrayList<Class<?extends Item>> clsToSave ){
List<Class<? extends T>> items = Arrays.asList(this.items);
for (Class<?extends Item> cls : clsToSave){
if (items.contains(cls)){
Class<? extends T> toSave = items.get(items.indexOf(cls));
String itemName = toSave.toString();
bundle.put( itemName + PFX_LABEL, itemLabels.get( toSave ) );
bundle.put( itemName + PFX_KNOWN, known.contains( toSave ) );
}
}
}

private void restore( Bundle bundle, ArrayList<String> labelsLeft ) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.items;

import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;

abstract public class KindOfWeapon extends EquipableItem {
Expand Down Expand Up @@ -103,6 +107,21 @@ public float speedFactor( Char owner ) {
public int reachFactor( Char owner ){
return 1;
}

public boolean canReach( Char owner, int target){
if (Dungeon.level.distance( owner.pos, target ) > reachFactor(owner)){
return false;
} else {
boolean[] passable = BArray.not(Dungeon.level.solid, null);
for (Char ch : Actor.chars()) {
if (ch != owner) passable[ch.pos] = false;
}

PathFinder.buildDistanceMap(target, passable, reachFactor(owner));

return PathFinder.distance[owner.pos] <= reachFactor(owner);
}
}

public int defenseFactor( Char owner ) {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public void absorbEnergy( int energy ){
partialCharge -= 1;
charge++;

if (charge == chargeCap){
if (charge >= chargeCap){
charge = chargeCap;
partialCharge = 0;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs.AntiMagic;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRetribution;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.exotic.ScrollOfPsionicBlast;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MeleeWeapon;
Expand Down Expand Up @@ -504,11 +503,7 @@ protected float attackDelay() {

@Override
protected boolean canAttack(Char enemy) {
if (rose != null && rose.weapon != null) {
return Dungeon.level.distance(pos, enemy.pos) <= rose.weapon.reachFactor(this);
} else {
return super.canAttack(enemy);
}
return super.canAttack(enemy) || (rose != null && rose.weapon != null && rose.weapon.canReach(this, enemy.pos));
}

@Override
Expand Down Expand Up @@ -545,7 +540,7 @@ public int defenseProc(Char enemy, int damage) {
public void damage(int dmg, Object src) {
//TODO improve this when I have proper damage source logic
if (rose != null && rose.armor != null && rose.armor.hasGlyph(AntiMagic.class, this)
&& RingOfElements.RESISTS.contains(src.getClass())){
&& AntiMagic.RESISTS.contains(src.getClass())){
dmg -= Random.NormalIntRange(rose.armor.DRMin(), rose.armor.DRMax())/3;
}

Expand Down Expand Up @@ -575,11 +570,11 @@ public int defenseSkill(Char enemy) {
}

@Override
public int stealth() {
int stealth = super.stealth();
public float stealth() {
float stealth = super.stealth();

if (rose != null && rose.armor != null){
stealth = Math.round(rose.armor.stealthFactor(this, stealth));
stealth = rose.armor.stealthFactor(this, stealth);
}

return stealth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,19 @@ public static void save( Bundle bundle ) {
}

public static void saveSelectively( Bundle bundle, ArrayList<Item> items ) {
handler.saveSelectively( bundle, items );
ArrayList<Class<?extends Item>> classes = new ArrayList<>();
for (Item i : items){
if (i instanceof ExoticPotion){
if (!classes.contains(ExoticPotion.exoToReg.get(i.getClass()))){
classes.add(ExoticPotion.exoToReg.get(i.getClass()));
}
} else if (i instanceof Potion){
if (!classes.contains(i.getClass())){
classes.add(i.getClass());
}
}
}
handler.saveClassesSelectively( bundle, classes );
}

@SuppressWarnings("unchecked")
Expand Down
Loading

0 comments on commit ebf7130

Please sign in to comment.