V0.2.0: Fully implemented Talisman of Foresight
This commit is contained in:
parent
f4e5060041
commit
6e9cc9dd69
|
@ -23,6 +23,7 @@ import java.util.HashSet;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Drowsy;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Drowsy;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CapeOfThorns;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CapeOfThorns;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TalismanOfForesight;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfForce;
|
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfForce;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfFuror;
|
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfFuror;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting;
|
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting;
|
||||||
|
@ -1293,6 +1294,8 @@ public class Hero extends Char {
|
||||||
by = Level.HEIGHT - 1;
|
by = Level.HEIGHT - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TalismanOfForesight.Foresight foresight = buff( TalismanOfForesight.Foresight.class );
|
||||||
|
|
||||||
for (int y = ay; y <= by; y++) {
|
for (int y = ay; y <= by; y++) {
|
||||||
for (int x = ax, p = ax + y * Level.WIDTH; x <= bx; x++, p++) {
|
for (int x = ax, p = ax + y * Level.WIDTH; x <= bx; x++, p++) {
|
||||||
|
|
||||||
|
@ -1315,6 +1318,9 @@ public class Hero extends Char {
|
||||||
ScrollOfMagicMapping.discover( p );
|
ScrollOfMagicMapping.discover( p );
|
||||||
|
|
||||||
smthFound = true;
|
smthFound = true;
|
||||||
|
|
||||||
|
if (foresight != null)
|
||||||
|
foresight.charge();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,83 @@
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.items.artifacts;
|
package com.shatteredpixel.shatteredpixeldungeon.items.artifacts;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Awareness;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.effects.CheckedCell;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.Utils;
|
||||||
|
import com.watabou.noosa.audio.Sample;
|
||||||
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by debenhame on 08/09/2014.
|
* Created by debenhame on 08/09/2014.
|
||||||
*/
|
*/
|
||||||
public class TalismanOfForesight extends Artifact {
|
public class TalismanOfForesight extends Artifact {
|
||||||
//TODO: actual implementation, i'm going to need to test this one as I write it.
|
//TODO: polish.
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "Talisman of Foresight";
|
name = "Talisman of Foresight";
|
||||||
image = ItemSpriteSheet.ARTIFACT_TALISMAN;
|
image = ItemSpriteSheet.ARTIFACT_TALISMAN;
|
||||||
level = 0;
|
level = 0;
|
||||||
levelCap = 10;
|
levelCap = 10;
|
||||||
charge = 0;
|
charge = 98;
|
||||||
exp = 0;
|
exp = 0;
|
||||||
//partialcharge and chargeCap are unused
|
partialCharge = 0;
|
||||||
|
chargeCap = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String AC_SCRY = "SCRY";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> actions( Hero hero ) {
|
||||||
|
ArrayList<String> actions = super.actions( hero );
|
||||||
|
if (isEquipped( hero ) && charge == 100)
|
||||||
|
actions.add(AC_SCRY);
|
||||||
|
return actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute( Hero hero, String action ) {
|
||||||
|
super.execute(hero, action);
|
||||||
|
if (action.equals(AC_SCRY)){
|
||||||
|
hero.sprite.operate( hero.pos );
|
||||||
|
hero.busy();
|
||||||
|
Sample.INSTANCE.play( Assets.SND_BEACON );
|
||||||
|
charge = 0;
|
||||||
|
for (int i=0; i < Level.LENGTH; i++) {
|
||||||
|
|
||||||
|
int terr = Dungeon.level.map[i];
|
||||||
|
if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
|
||||||
|
|
||||||
|
//Level.set( i, Terrain.discover( terr ) );
|
||||||
|
GameScene.updateMap( i );
|
||||||
|
|
||||||
|
if (Dungeon.visible[i]) {
|
||||||
|
GameScene.discoverTile( i, terr );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Buff.affect(hero, Awareness.class, Awareness.DURATION);
|
||||||
|
Dungeon.observe();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String status() {
|
public String status() {
|
||||||
if (charge > 0)
|
return Utils.format("%d%%", charge);
|
||||||
return Utils.format("%d", charge);
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,6 +92,92 @@ public class TalismanOfForesight extends Artifact {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Foresight extends ArtifactBuff{
|
public class Foresight extends ArtifactBuff{
|
||||||
|
private int warn = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean act() {
|
||||||
|
spend( TICK );
|
||||||
|
|
||||||
|
boolean smthFound = false;
|
||||||
|
|
||||||
|
int distance = 3;
|
||||||
|
|
||||||
|
int cx = target.pos % Level.WIDTH;
|
||||||
|
int cy = target.pos / Level.WIDTH;
|
||||||
|
int ax = cx - distance;
|
||||||
|
if (ax < 0) {
|
||||||
|
ax = 0;
|
||||||
|
}
|
||||||
|
int bx = cx + distance;
|
||||||
|
if (bx >= Level.WIDTH) {
|
||||||
|
bx = Level.WIDTH - 1;
|
||||||
|
}
|
||||||
|
int ay = cy - distance;
|
||||||
|
if (ay < 0) {
|
||||||
|
ay = 0;
|
||||||
|
}
|
||||||
|
int by = cy + distance;
|
||||||
|
if (by >= Level.HEIGHT) {
|
||||||
|
by = Level.HEIGHT - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int y = ay; y <= by; y++) {
|
||||||
|
for (int x = ax, p = ax + y * Level.WIDTH; x <= bx; x++, p++) {
|
||||||
|
|
||||||
|
if (Dungeon.visible[p] && Level.secret[p] && Dungeon.level.map[p] != Terrain.SECRET_DOOR)
|
||||||
|
smthFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (smthFound == true){
|
||||||
|
if (warn == 0){
|
||||||
|
GLog.w("You feel uneasy.");
|
||||||
|
if (target instanceof Hero){
|
||||||
|
((Hero)target).interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
warn = 3;
|
||||||
|
} else {
|
||||||
|
if (warn > 0){
|
||||||
|
warn --;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BuffIndicator.refreshHero();
|
||||||
|
|
||||||
|
//fully charges in 2400 turns at lvl=0, scaling to 800 turns at lvl = 10.
|
||||||
|
partialCharge += (1f/24) + (((float)level)/80);
|
||||||
|
|
||||||
|
|
||||||
|
if (partialCharge > 1 && charge < 100){
|
||||||
|
partialCharge--;
|
||||||
|
charge++;
|
||||||
|
} else if (charge >= 100)
|
||||||
|
partialCharge = 0;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void charge(){
|
||||||
|
charge = Math.min(charge+6, chargeCap);
|
||||||
|
exp++;
|
||||||
|
if (exp >= 5) {
|
||||||
|
upgrade();
|
||||||
|
GLog.p("Your Talisman grows stronger!");
|
||||||
|
exp -= 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Foresight";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int icon() {
|
||||||
|
if (warn == 0)
|
||||||
|
return BuffIndicator.NONE;
|
||||||
|
else
|
||||||
|
return BuffIndicator.FORESIGHT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ public class BuffIndicator extends Component {
|
||||||
public static final int DROWSY = 29;
|
public static final int DROWSY = 29;
|
||||||
public static final int MAGIC_SLEEP = 30;
|
public static final int MAGIC_SLEEP = 30;
|
||||||
public static final int THORNS = 31;
|
public static final int THORNS = 31;
|
||||||
|
public static final int FORESIGHT = 32;
|
||||||
|
|
||||||
public static final int SIZE = 7;
|
public static final int SIZE = 7;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user