use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Dungeon method init.
public static void init() {
version = Game.versionCode;
challenges = SPDSettings.challenges();
seed = DungeonSeed.randomSeed();
Actor.clear();
Actor.resetNextID();
Random.seed(seed);
Scroll.initLabels();
Potion.initColors();
Ring.initGems();
SpecialRoom.initForRun();
SecretRoom.initForRun();
Random.seed();
Statistics.reset();
Notes.reset();
quickslot.reset();
QuickSlotButton.reset();
depth = 0;
gold = 0;
droppedItems = new SparseArray<ArrayList<Item>>();
for (LimitedDrops a : LimitedDrops.values()) a.count = 0;
chapters = new HashSet<Integer>();
Ghost.Quest.reset();
Wandmaker.Quest.reset();
Blacksmith.Quest.reset();
Imp.Quest.reset();
Generator.reset();
Generator.initArtifacts();
hero = new Hero();
hero.live();
Badges.reset();
GamesInProgress.selectedClass.initHero(hero);
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Burning method act.
@Override
public boolean act() {
if (target.isAlive()) {
int damage = Random.NormalIntRange(1, 3 + target.HT / 40);
Buff.detach(target, Chill.class);
if (target instanceof Hero) {
Hero hero = (Hero) target;
if (hero.belongings.armor != null && hero.belongings.armor.hasGlyph(Brimstone.class)) {
Buff.affect(target, Brimstone.BrimstoneShield.class);
} else {
hero.damage(damage, this);
burnIncrement++;
// at 4+ turns, there is a (turns-3)/3 chance an item burns
if (Random.Int(3) < (burnIncrement - 3)) {
burnIncrement = 0;
ArrayList<Item> burnable = new ArrayList<>();
// does not reach inside of containers
for (Item i : hero.belongings.backpack.items) {
if ((i instanceof Scroll && !(i instanceof ScrollOfUpgrade || i instanceof ScrollOfMagicalInfusion)) || i instanceof MysteryMeat) {
burnable.add(i);
}
}
if (!burnable.isEmpty()) {
Item toBurn = Random.element(burnable).detach(hero.belongings.backpack);
if (toBurn instanceof MysteryMeat) {
ChargrilledMeat steak = new ChargrilledMeat();
if (!steak.collect(hero.belongings.backpack)) {
Dungeon.level.drop(steak, hero.pos).sprite.drop();
}
}
Heap.burnFX(hero.pos);
GLog.w(Messages.get(this, "burnsup", Messages.capitalize(toBurn.toString())));
}
}
}
} else {
target.damage(damage, this);
}
if (target instanceof Thief) {
Item item = ((Thief) target).item;
if (item instanceof Scroll && !(item instanceof ScrollOfUpgrade || item instanceof ScrollOfMagicalInfusion)) {
target.sprite.emitter().burst(ElmoParticle.FACTORY, 6);
((Thief) target).item = null;
} else if (item instanceof MysteryMeat) {
target.sprite.emitter().burst(ElmoParticle.FACTORY, 6);
((Thief) target).item = new ChargrilledMeat();
}
}
} else {
Brimstone.BrimstoneShield brimShield = target.buff(Brimstone.BrimstoneShield.class);
if (brimShield != null)
brimShield.startDecay();
detach();
}
if (Dungeon.level.flamable[target.pos] && Blob.volumeAt(target.pos, Fire.class) == 0) {
GameScene.add(Blob.seed(target.pos, 4, Fire.class));
}
spend(TICK);
left -= TICK;
if (left <= 0 || (Dungeon.level.water[target.pos] && !target.flying)) {
detach();
}
return true;
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Frost method attachTo.
@Override
public boolean attachTo(Char target) {
if (super.attachTo(target)) {
target.paralysed++;
Buff.detach(target, Burning.class);
Buff.detach(target, Chill.class);
if (target instanceof Hero) {
Hero hero = (Hero) target;
ArrayList<Item> freezable = new ArrayList<>();
// does not reach inside of containers
for (Item i : hero.belongings.backpack.items) {
if ((i instanceof Potion && !(i instanceof PotionOfStrength || i instanceof PotionOfMight)) || i instanceof MysteryMeat) {
freezable.add(i);
}
}
if (!freezable.isEmpty()) {
Item toFreeze = Random.element(freezable).detach(hero.belongings.backpack);
if (toFreeze instanceof Potion) {
((Potion) toFreeze).shatter(hero.pos);
} else if (toFreeze instanceof MysteryMeat) {
FrozenCarpaccio carpaccio = new FrozenCarpaccio();
if (!carpaccio.collect(hero.belongings.backpack)) {
Dungeon.level.drop(carpaccio, target.pos).sprite.drop();
}
}
GLog.w(Messages.get(this, "freezes", toFreeze.toString()));
}
} else if (target instanceof Thief) {
Item item = ((Thief) target).item;
if (item instanceof Potion && !(item instanceof PotionOfStrength || item instanceof PotionOfMight)) {
((Potion) ((Thief) target).item).shatter(target.pos);
((Thief) target).item = null;
} else if (item instanceof MysteryMeat) {
((Thief) target).item = new FrozenCarpaccio();
;
}
}
return true;
} else {
return false;
}
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Hunger method act.
@Override
public boolean act() {
if (Dungeon.level.locked) {
spend(STEP);
return true;
}
if (target.isAlive()) {
Hero hero = (Hero) target;
if (isStarving()) {
partialDamage += STEP * target.HT / 1000f;
if (partialDamage > 1) {
target.damage((int) partialDamage, this);
partialDamage -= (int) partialDamage;
}
} else {
float newLevel = level + STEP;
boolean statusUpdated = false;
if (newLevel >= STARVING) {
GLog.n(Messages.get(this, "onstarving"));
hero.resting = false;
hero.damage(1, this);
statusUpdated = true;
hero.interrupt();
} else if (newLevel >= HUNGRY && level < HUNGRY) {
GLog.w(Messages.get(this, "onhungry"));
statusUpdated = true;
}
level = newLevel;
if (statusUpdated) {
BuffIndicator.refreshHero();
}
}
spend(target.buff(Shadows.class) == null ? STEP : STEP * 1.5f);
} else {
diactivate();
}
return true;
}
use of com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Level method updateFieldOfView.
public void updateFieldOfView(Char c, boolean[] fieldOfView) {
int cx = c.pos % width();
int cy = c.pos / width();
boolean sighted = c.buff(Blindness.class) == null && c.buff(Shadows.class) == null && c.buff(TimekeepersHourglass.timeStasis.class) == null && c.isAlive();
if (sighted) {
ShadowCaster.castShadow(cx, cy, fieldOfView, c.viewDistance);
} else {
BArray.setFalse(fieldOfView);
}
int sense = 1;
// Currently only the hero can get mind vision
if (c.isAlive() && c == Dungeon.hero) {
for (Buff b : c.buffs(MindVision.class)) {
sense = Math.max(((MindVision) b).distance, sense);
}
}
if ((sighted && sense > 1) || !sighted) {
int ax = Math.max(0, cx - sense);
int bx = Math.min(cx + sense, width() - 1);
int ay = Math.max(0, cy - sense);
int by = Math.min(cy + sense, height() - 1);
int len = bx - ax + 1;
int pos = ax + ay * width();
for (int y = ay; y <= by; y++, pos += width()) {
System.arraycopy(discoverable, pos, fieldOfView, pos, len);
}
}
// Currently only the hero can get mind vision or awareness
if (c.isAlive() && c == Dungeon.hero) {
Dungeon.hero.mindVisionEnemies.clear();
if (c.buff(MindVision.class) != null) {
for (Mob mob : mobs) {
int p = mob.pos;
if (!fieldOfView[p]) {
Dungeon.hero.mindVisionEnemies.add(mob);
}
}
} else if (((Hero) c).heroClass == HeroClass.HUNTRESS) {
for (Mob mob : mobs) {
int p = mob.pos;
if (distance(c.pos, p) == 2) {
if (!fieldOfView[p]) {
Dungeon.hero.mindVisionEnemies.add(mob);
}
}
}
}
for (Mob m : Dungeon.hero.mindVisionEnemies) {
for (int i : PathFinder.NEIGHBOURS9) {
fieldOfView[m.pos + i] = true;
}
}
if (c.buff(Awareness.class) != null) {
for (Heap heap : heaps.values()) {
int p = heap.pos;
for (int i : PathFinder.NEIGHBOURS9) fieldOfView[p + i] = true;
}
}
}
if (c == Dungeon.hero) {
for (Heap heap : heaps.values()) if (!heap.seen && fieldOfView[heap.pos])
heap.seen = true;
}
}
Aggregations