Search in sources :

Example 1 with Summon

use of am2.spell.components.Summon in project ArsMagica2 by Mithion.

the class TileEntityCraftingAltar method matchCurrentRecipe.

private boolean matchCurrentRecipe() {
    ISpellPart part = SpellRecipeManager.instance.getPartByRecipe(currentAddedItems);
    if (part == null)
        return false;
    ArrayList<KeyValuePair<ISpellPart, byte[]>> currentShapeGroupList = getShapeGroupToAddTo();
    if (part instanceof Summon)
        handleSummonShape();
    if (part instanceof Binding)
        handleBindingShape();
    byte[] metaData = new byte[0];
    if (part instanceof ISpellModifier) {
        metaData = ((ISpellModifier) part).getModifierMetadata(currentAddedItems.toArray(new ItemStack[currentAddedItems.size()]));
        if (metaData == null) {
            metaData = new byte[0];
        }
    }
    //we're now creating the body of the spell
    if (currentShapeGroupList == null) {
        spellDef.add(new KeyValuePair<ISpellPart, byte[]>(part, metaData));
    } else {
        currentShapeGroupList.add(new KeyValuePair<ISpellPart, byte[]>(part, metaData));
    }
    return true;
}
Also used : Binding(am2.spell.shapes.Binding) KeyValuePair(am2.utility.KeyValuePair) Summon(am2.spell.components.Summon) ISpellModifier(am2.api.spell.component.interfaces.ISpellModifier) ISpellPart(am2.api.spell.component.interfaces.ISpellPart)

Example 2 with Summon

use of am2.spell.components.Summon in project ArsMagica2 by Mithion.

the class SpellValidator method validateStage.

private StageValidations validateStage(ArrayList<ISpellPart> stageDefinition, boolean isFinalStage) {
    boolean terminus = false;
    boolean principum = false;
    boolean one_component = !isFinalStage;
    boolean one_shape = false;
    for (ISpellPart part : stageDefinition) {
        if (part instanceof Summon)
            return StageValidations.TERMINUS;
        if (part instanceof ISpellShape) {
            one_shape = true;
            if (((ISpellShape) part).isTerminusShape())
                terminus = true;
            if (((ISpellShape) part).isPrincipumShape())
                principum = true;
            continue;
        }
        if (part instanceof ISpellComponent) {
            one_component = true;
            continue;
        }
    }
    if (principum)
        return StageValidations.PRINCIPUM;
    if (!one_component || !one_shape)
        return StageValidations.NOT_VALID;
    if (terminus)
        return StageValidations.TERMINUS;
    return StageValidations.VALID;
}
Also used : ISpellComponent(am2.api.spell.component.interfaces.ISpellComponent) Summon(am2.spell.components.Summon) ISpellShape(am2.api.spell.component.interfaces.ISpellShape) ISpellPart(am2.api.spell.component.interfaces.ISpellPart)

Example 3 with Summon

use of am2.spell.components.Summon in project ArsMagica2 by Mithion.

the class TileEntityCraftingAltar method AddSpecialMetadata.

private void AddSpecialMetadata(ItemStack craftStack) {
    if (addedPhylactery != null) {
        Summon summon = (Summon) SkillManager.instance.getSkill("Summon");
        summon.setSummonType(craftStack, addedPhylactery);
    }
    if (addedBindingCatalyst != null) {
        Binding binding = (Binding) SkillManager.instance.getSkill("Binding");
        binding.setBindingType(craftStack, addedBindingCatalyst);
    }
}
Also used : Binding(am2.spell.shapes.Binding) Summon(am2.spell.components.Summon)

Example 4 with Summon

use of am2.spell.components.Summon in project ArsMagica2 by Mithion.

the class EntityAISummonAllies method updateTask.

@Override
public void updateTask() {
    if (((IArsMagicaBoss) host).getCurrentAction() != BossActions.CASTING)
        ((IArsMagicaBoss) host).setCurrentAction(BossActions.CASTING);
    actionTicks++;
    if (actionTicks == 16) {
        if (!host.worldObj.isRemote)
            host.worldObj.playSoundAtEntity(host, "arsmagica2:mob.lifeguardian.summon", 1.0f, host.getRNG().nextFloat() * 0.5f + 0.5f);
        int numAllies = 3;
        for (int i = 0; i < numAllies; ++i) {
            Class summon = mobs[host.worldObj.rand.nextInt(mobs.length)];
            try {
                Constructor ctor = summon.getConstructor(World.class);
                EntityCreature mob = (EntityCreature) ctor.newInstance(host.worldObj);
                mob.setPosition(host.posX + host.worldObj.rand.nextDouble() * 2 - 1, host.posY, host.posZ + host.worldObj.rand.nextDouble() * 2 - 1);
                mob.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 99999, 1));
                mob.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 99999, 1));
                mob.addPotionEffect(new PotionEffect(Potion.regeneration.id, 99999, 1));
                mob.addPotionEffect(new BuffEffectMagicShield(99999, 1));
                if (host.getHealth() < host.getMaxHealth() / 2) {
                    mob.addPotionEffect(new BuffEffectShrink(99999, 1));
                }
                EntityUtilities.makeSummon_MonsterFaction(mob, false);
                EntityUtilities.setOwner(mob, host);
                EntityUtilities.setSummonDuration(mob, 1800);
                host.worldObj.spawnEntityInWorld(mob);
                host.queued_minions.add(mob);
            } catch (Throwable e) {
                e.printStackTrace();
                return;
            }
        }
    }
    if (actionTicks >= 23) {
        resetTask();
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) Constructor(java.lang.reflect.Constructor) BuffEffectShrink(am2.buffs.BuffEffectShrink) BuffEffectMagicShield(am2.buffs.BuffEffectMagicShield) EntityCreature(net.minecraft.entity.EntityCreature)

Example 5 with Summon

use of am2.spell.components.Summon in project ArsMagica2 by Mithion.

the class TileEntitySummoner method summonCreature.

private void summonCreature() {
    if (worldObj.isRemote || this.summonEntityID != -1)
        return;
    if (dummyCaster == null) {
        dummyCaster = new DummyEntityPlayer(worldObj);
    }
    EntityLiving summon = ((Summon) SkillManager.instance.getSkill("Summon")).summonCreature(inventory[SUMMON_SLOT], dummyCaster, dummyCaster, worldObj, xCoord, yCoord, zCoord);
    if (summon != null) {
        if (summon instanceof EntityCreature)
            EntityUtilities.setGuardSpawnLocation((EntityCreature) summon, xCoord, yCoord, zCoord);
        this.summonEntityID = summon.getEntityId();
        PowerNodeRegistry.For(this.worldObj).consumePower(this, PowerNodeRegistry.For(this.worldObj).getHighestPowerType(this), summonCost);
        this.summonCooldown = this.maxSummonCooldown;
        EntityUtilities.setTileSpawned(summon, this);
        worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
    }
}
Also used : DummyEntityPlayer(am2.utility.DummyEntityPlayer) EntityLiving(net.minecraft.entity.EntityLiving) Summon(am2.spell.components.Summon) EntityCreature(net.minecraft.entity.EntityCreature)

Aggregations

Summon (am2.spell.components.Summon)5 ISpellPart (am2.api.spell.component.interfaces.ISpellPart)2 Binding (am2.spell.shapes.Binding)2 KeyValuePair (am2.utility.KeyValuePair)2 EntityCreature (net.minecraft.entity.EntityCreature)2 ISpellComponent (am2.api.spell.component.interfaces.ISpellComponent)1 ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)1 ISpellShape (am2.api.spell.component.interfaces.ISpellShape)1 BuffEffectMagicShield (am2.buffs.BuffEffectMagicShield)1 BuffEffectShrink (am2.buffs.BuffEffectShrink)1 DummyEntityPlayer (am2.utility.DummyEntityPlayer)1 Constructor (java.lang.reflect.Constructor)1 ArrayList (java.util.ArrayList)1 EntityLiving (net.minecraft.entity.EntityLiving)1 ItemStack (net.minecraft.item.ItemStack)1 PotionEffect (net.minecraft.potion.PotionEffect)1