use of objects.Creature in project ultimate-java by pantinor.
the class SpellUtil method spellTremor.
public static void spellTremor(BaseScreen screen, PartyMember caster) {
if (screen.scType == ScreenType.COMBAT) {
final CombatScreen combatScreen = (CombatScreen) screen;
SequenceAction seq = Actions.action(SequenceAction.class);
for (Creature cr : combatScreen.combatMap.getCreatures()) {
/* creatures with over 192 hp are unaffected */
if (cr.getHP() > 192) {
seq.addAction(Actions.run(new PlaySoundAction(Sound.EVADE)));
continue;
} else {
if (Utils.rand.nextInt(2) == 0) {
/* Deal maximum damage to creature */
Utils.dealDamage(caster, cr, 0xFF);
Tile tile = Ultima4.baseTileSet.getTileByName("hit_flash");
Drawable d = new Drawable(combatScreen.combatMap, cr.currentX, cr.currentY, tile, Ultima4.standardAtlas);
d.setX(cr.currentPos.x);
d.setY(cr.currentPos.y);
d.addAction(Actions.sequence(Actions.delay(.4f), Actions.fadeOut(.2f), Actions.removeActor()));
seq.addAction(Actions.run(new AddActorAction(combatScreen.getStage(), d)));
seq.addAction(Actions.run(new PlaySoundAction(Sound.NPC_STRUCK)));
} else if (Utils.rand.nextInt(2) == 0) {
/* Deal enough damage to creature to make it flee */
if (cr.getHP() > 23) {
Utils.dealDamage(caster, cr, cr.getHP() - 23);
Tile tile = Ultima4.baseTileSet.getTileByName("hit_flash");
Drawable d = new Drawable(combatScreen.combatMap, cr.currentX, cr.currentY, tile, Ultima4.standardAtlas);
d.setX(cr.currentPos.x);
d.setY(cr.currentPos.y);
d.addAction(Actions.sequence(Actions.delay(.4f), Actions.fadeOut(.2f), Actions.removeActor()));
seq.addAction(Actions.run(new AddActorAction(combatScreen.getStage(), d)));
seq.addAction(Actions.run(new PlaySoundAction(Sound.NPC_STRUCK)));
}
} else {
seq.addAction(Actions.run(new PlaySoundAction(Sound.EVADE)));
}
}
if (cr.getDamageStatus() == CreatureStatus.DEAD) {
seq.addAction(Actions.run(combatScreen.new RemoveCreatureAction(cr)));
}
}
seq.addAction(Actions.run(new Runnable() {
@Override
public void run() {
combatScreen.finishPlayerTurn();
}
}));
combatScreen.getStage().addAction(seq);
}
}
use of objects.Creature in project ultimate-java by pantinor.
the class SpellUtil method useRageOfGod.
public static void useRageOfGod(BaseScreen screen, PartyMember caster) {
if (screen.scType == ScreenType.COMBAT) {
final CombatScreen combatScreen = (CombatScreen) screen;
final SequenceAction seq = Actions.action(SequenceAction.class);
for (Creature cr : combatScreen.combatMap.getCreatures()) {
if (Utils.rand.nextInt(2) == 0) {
/* Deal maximum damage to creature */
Utils.dealDamage(caster, cr, 0xFF);
} else if (Utils.rand.nextInt(2) == 0) {
/* Deal enough damage to creature to make it flee */
if (cr.getHP() > 23) {
Utils.dealDamage(caster, cr, cr.getHP() - 23);
}
} else {
// deal damage of half its hit points
Utils.dealDamage(caster, cr, cr.getHP() / 2);
}
Actor d = new ExplosionLargeDrawable();
d.setX(cr.currentPos.x - 32 * 3 + 16);
d.setY(cr.currentPos.y - 32 * 3 + 16);
d.addAction(Actions.sequence(Actions.delay(2f), Actions.removeActor()));
seq.addAction(Actions.run(new PlaySoundAction(Sound.RAGE)));
seq.addAction(Actions.run(new AddActorAction(combatScreen.getStage(), d)));
seq.addAction(Actions.run(new PlaySoundAction(Sound.NPC_STRUCK)));
if (cr.getDamageStatus() == CreatureStatus.DEAD) {
seq.addAction(Actions.run(combatScreen.new RemoveCreatureAction(cr)));
}
}
seq.addAction(Actions.run(new Runnable() {
@Override
public void run() {
combatScreen.finishPlayerTurn();
}
}));
combatScreen.getStage().addAction(seq);
} else {
Sounds.play(Sound.ERROR);
}
}
Aggregations