Search in sources :

Example 1 with DC_Player

use of eidolons.game.battlecraft.logic.battle.universal.DC_Player in project Eidolons by IDemiurge.

the class AI_Manager method resetGroups.

private void resetGroups() {
    // }
    if (groups == null)
        groups = new ArrayList<>();
    for (Object sub : game.getBattleMaster().getPlayerManager().getPlayers()) {
        DC_Player player = (DC_Player) sub;
        for (Unit unit : player.getControlledUnits_()) {
            GroupAI group = unit.getAI().getGroup();
            if (group == null)
                group = new GroupAI(unit);
            for (Unit unit1 : player.getControlledUnits_()) {
                if (unit1.getAI().getGroup() != null)
                    continue;
                if (unit1.equals(unit))
                    continue;
                double max_distance = 2.5;
                if (PositionMaster.getExactDistance(unit1.getCoordinates(), unit.getCoordinates()) >= max_distance)
                    continue;
                if (!game.getVisionMaster().getSightMaster().getClearShotCondition().check(unit, unit1))
                    continue;
                group.add(unit1);
            }
            if (!groups.contains(group))
                groups.add(group);
        }
    }
    if (!groups.isEmpty())
        return;
    else
        return;
}
Also used : ArrayList(java.util.ArrayList) Unit(eidolons.entity.obj.unit.Unit) DC_Player(eidolons.game.battlecraft.logic.battle.universal.DC_Player)

Example 2 with DC_Player

use of eidolons.game.battlecraft.logic.battle.universal.DC_Player in project Eidolons by IDemiurge.

the class Spawner method spawn.

@Refactor
public void spawn() {
    // initFacing(units, player, mode);
    for (Object player1 : getBattleMaster().getPlayerManager().getPlayers()) {
        DC_Player player = (DC_Player) player1;
        if (player.isNeutral()) {
            continue;
        }
        UnitData data = player.getUnitData();
        if (data == null)
            data = generateData("", player, null);
        spawn(data, player, getSpawnMode(player, true));
    }
    spawnDone();
// initEmblem
}
Also used : DC_Player(eidolons.game.battlecraft.logic.battle.universal.DC_Player) Refactor(main.system.util.Refactor)

Example 3 with DC_Player

use of eidolons.game.battlecraft.logic.battle.universal.DC_Player in project Eidolons by IDemiurge.

the class Spawner method spawnCustomParty.

public void spawnCustomParty(boolean me, String partyData) {
    DC_Player player = game.getPlayer(me);
    if (BooleanMaster.isTrue(me)) {
        Party party = PartyHelper.getParty();
        if (party != null) {
            DC_SoundMaster.playEffectSound(SOUNDS.READY, party.getLeader());
            spawnPlayerParty(party, partyData);
            return;
        }
    }
    if (!partyData.contains(DC_ObjInitializer.COORDINATES_OBJ_SEPARATOR)) {
        partyData = DC_ObjInitializer.convertVarStringToObjCoordinates(partyData);
    }
    UnitData data = generateData(partyData, player, null);
    spawn(data, player, SPAWN_MODE.PARTY);
// List<MicroObj> list = DC_ObjInitializer.processUnitDataString(player, partyData, game);
// if (!ListMaster.isNotEmpty(list)) {
// return;
// }
}
Also used : Party(eidolons.client.cc.logic.party.Party) DC_Player(eidolons.game.battlecraft.logic.battle.universal.DC_Player)

Example 4 with DC_Player

use of eidolons.game.battlecraft.logic.battle.universal.DC_Player 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)

Example 5 with DC_Player

use of eidolons.game.battlecraft.logic.battle.universal.DC_Player in project Eidolons by IDemiurge.

the class Loader method createObjects.

private static List<Obj> createObjects(List<String> objectNodes) {
    DC_Game game = DC_Game.game;
    List<Obj> objects = new ArrayList<>();
    // TODO ID ORDER MUST BE PRESERVED! put in parameter?
    for (String typesNode : objectNodes) {
        Document node = XML_Converter.getDoc(typesNode);
        DC_TYPE TYPE = DC_TYPE.getType(node.getNodeName());
        for (Node subNode : XML_Converter.getNodeList(node)) {
            String sub = XML_Converter.getStringFromXML(subNode);
            game.setIdManager(new DC_IdManager(game));
            Map<PROPERTY, String> props = getPropsFromNode(sub);
            Map<PARAMETER, String> params = getParamsFromNode(sub);
            ObjType type = DataManager.getType(subNode.getNodeName(), TYPE);
            // preset ID?! init containers by id... including buffs; but first create them
            Ref ref = new Ref(game);
            Node refNode = XML_Converter.findNode(sub, Saver.OBJ_NODE);
            if (refNode != null)
                for (String substring : StringMaster.open(refNode.getTextContent())) {
                    ref.setValue(KEYS.valueOf(substring.split("=")[0].toUpperCase()), substring.split("=")[1]);
                }
            String ownerName = null;
            DC_Player owner = game.getBattleMaster().getPlayerManager().getPlayer(// property?
            ownerName);
            if (owner == null) {
                owner = DC_Player.NEUTRAL;
            }
            Coordinates c = new Coordinates(params.get(G_PARAMS.POS_X) + "-" + params.get(G_PARAMS.POS_Y));
            Obj object = createObj(type, c.x, c.y, owner, game, ref);
            object.getPropMap().putAll(props);
            object.getParamMap().putAll(params);
            object.setId(StringMaster.getInteger(props.get(G_PROPS.ID)));
            objects.add(object);
            init(object);
        }
    }
    return objects;
}
Also used : DC_TYPE(main.content.DC_TYPE) PROPERTY(main.content.values.properties.PROPERTY) Node(org.w3c.dom.Node) Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) DC_Game(eidolons.game.core.game.DC_Game) Document(org.w3c.dom.Document) DC_Player(eidolons.game.battlecraft.logic.battle.universal.DC_Player) Ref(main.entity.Ref) DC_IdManager(eidolons.entity.DC_IdManager) ObjType(main.entity.type.ObjType) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj) DC_BuffObj(eidolons.entity.obj.attach.DC_BuffObj) DC_FeatObj(eidolons.entity.obj.attach.DC_FeatObj) DC_JewelryObj(eidolons.entity.item.DC_JewelryObj) DC_SpellObj(eidolons.entity.active.DC_SpellObj) Obj(main.entity.obj.Obj) DC_ArmorObj(eidolons.entity.item.DC_ArmorObj) PARAMETER(main.content.values.parameters.PARAMETER)

Aggregations

DC_Player (eidolons.game.battlecraft.logic.battle.universal.DC_Player)8 ObjType (main.entity.type.ObjType)4 Unit (eidolons.entity.obj.unit.Unit)3 ArrayList (java.util.ArrayList)3 DC_SpellObj (eidolons.entity.active.DC_SpellObj)2 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)2 Obj (main.entity.obj.Obj)2 Coordinates (main.game.bf.Coordinates)2 CreateObjectEffect (eidolons.ability.effects.oneshot.unit.CreateObjectEffect)1 SummonEffect (eidolons.ability.effects.oneshot.unit.SummonEffect)1 Party (eidolons.client.cc.logic.party.Party)1 DC_IdManager (eidolons.entity.DC_IdManager)1 DC_ArmorObj (eidolons.entity.item.DC_ArmorObj)1 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)1 DC_JewelryObj (eidolons.entity.item.DC_JewelryObj)1 DC_WeaponObj (eidolons.entity.item.DC_WeaponObj)1 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 DC_BuffObj (eidolons.entity.obj.attach.DC_BuffObj)1 DC_FeatObj (eidolons.entity.obj.attach.DC_FeatObj)1