Search in sources :

Example 31 with Creature

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);
    }
}
Also used : Creature(objects.Creature) Drawable(objects.Drawable) Tile(objects.Tile) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)

Example 32 with Creature

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);
    }
}
Also used : Creature(objects.Creature) Actor(com.badlogic.gdx.scenes.scene2d.Actor) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)

Aggregations

Creature (objects.Creature)32 Tile (objects.Tile)12 Drawable (objects.Drawable)8 TiledMapTile (com.badlogic.gdx.maps.tiled.TiledMapTile)6 StaticTiledMapTile (com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile)6 Vector3 (com.badlogic.gdx.math.Vector3)6 SequenceAction (com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)6 Actor (com.badlogic.gdx.scenes.scene2d.Actor)5 PartyMember (objects.Party.PartyMember)5 PartyDeathException (util.PartyDeathException)5 MapLayer (com.badlogic.gdx.maps.MapLayer)3 DungeonTileModelInstance (util.DungeonTileModelInstance)3 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)2 Texture (com.badlogic.gdx.graphics.Texture)2 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)2 MapObject (com.badlogic.gdx.maps.MapObject)2 TiledMap (com.badlogic.gdx.maps.tiled.TiledMap)2 Portal (objects.Portal)2 AssetManager (com.badlogic.gdx.assets.AssetManager)1 FileHandle (com.badlogic.gdx.files.FileHandle)1