Search in sources :

Example 1 with SPAWN_MODE

use of eidolons.game.battlecraft.logic.dungeon.universal.Spawner.SPAWN_MODE in project Eidolons by IDemiurge.

the class CombatScriptExecutor method doSpawn.

private boolean doSpawn(Ref ref, String[] args) {
    int i = 0;
    DC_Player player = getPlayerManager().getPlayer(args[i]);
    if (player == null)
        player = getPlayerManager().getPlayer(false);
    else
        i++;
    List<String> units = new ArrayList<>();
    // if (args[i].contains(ScriptSyntax.SPAWN_ARG_UNITS_WAVE))
    String unitString = args[i];
    int level = StringMaster.getInteger(VariableManager.getVars(unitString));
    unitString = VariableManager.removeVarPart(unitString);
    ObjType wave = DataManager.getType(unitString, DC_TYPE.ENCOUNTERS);
    if (wave != null) {
        for (String sub : StringMaster.open(wave.getProperty(PROPS.PRESET_GROUP))) {
            if (level > 0)
                units.add(UnitLevelManager.getLeveledTypeName(level, sub));
            else
                units.add(sub);
        }
    }
    // TODO adjust wave? difficulty => level
    boolean group = false;
    if (units.isEmpty()) {
        units.addAll(StringMaster.openContainer(UnitGroupMaster.getUnitGroupData(unitString, level)));
    }
    if (units.isEmpty()) {
        // DataManager.gettypes
        units.addAll(StringMaster.openContainer(unitString));
    } else
        group = true;
    if (units.isEmpty())
        return false;
    i++;
    // CoordinatesFactory.createCoordinates(unitString);
    // if (origin==null )
    // origin = ref.getObj(unitString).getCoordinates();
    List<Coordinates> coordinates = null;
    if (group) {
        for (String sub : units) {
            coordinates.add(DC_ObjInitializer.getCoordinatesFromObjString(sub));
        }
    } else
        coordinates = getCoordinatesListForUnits(unitString, player, units, ref);
    String data = "";
    data += DataUnitFactory.getKeyValueString(UnitData.FORMAT, PARTY_VALUE.COORDINATES, StringMaster.joinList(coordinates, DataUnitFactory.getContainerSeparator(UnitData.FORMAT)));
    data += DataUnitFactory.getKeyValueString(UnitData.FORMAT, PARTY_VALUE.MEMBERS, StringMaster.joinStringList(units, DataUnitFactory.getContainerSeparator(UnitData.FORMAT)));
    UnitData unitData = new UnitData(data);
    SPAWN_MODE mode = SPAWN_MODE.SCRIPT;
    List<Unit> unitsList = getSpawner().spawn(unitData, player, mode);
    getSpawner().getFacingAdjuster().adjustFacing(unitsList);
    return true;
}
Also used : Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) Unit(eidolons.entity.obj.unit.Unit) DC_Player(eidolons.game.battlecraft.logic.battle.universal.DC_Player) UnitData(eidolons.game.battlecraft.logic.dungeon.universal.UnitData) SPAWN_MODE(eidolons.game.battlecraft.logic.dungeon.universal.Spawner.SPAWN_MODE) ObjType(main.entity.type.ObjType)

Aggregations

Unit (eidolons.entity.obj.unit.Unit)1 DC_Player (eidolons.game.battlecraft.logic.battle.universal.DC_Player)1 SPAWN_MODE (eidolons.game.battlecraft.logic.dungeon.universal.Spawner.SPAWN_MODE)1 UnitData (eidolons.game.battlecraft.logic.dungeon.universal.UnitData)1 ArrayList (java.util.ArrayList)1 ObjType (main.entity.type.ObjType)1 Coordinates (main.game.bf.Coordinates)1