Search in sources :

Example 11 with ISpellModifier

use of am2.api.spell.component.interfaces.ISpellModifier in project ArsMagica2 by Mithion.

the class SpellUtils method getModifiedInt_Add.

public int getModifiedInt_Add(int defaultValue, ItemStack stack, EntityLivingBase caster, Entity target, World world, int stage, SpellModifiers check) {
    int ordinalCount = 0;
    double modifiedValue = defaultValue;
    for (ISpellModifier modifier : getModifiersForStage(stack, stage)) {
        if (modifier.getAspectsModified().contains(check)) {
            byte[] meta = getModifierMetadataFromStack(stack, modifier, stage, ordinalCount++);
            modifiedValue += modifier.getModifier(check, caster, target, world, meta);
        }
    }
    if (caster instanceof EntityPlayer) {
        if (SkillData.For((EntityPlayer) caster).isEntryKnown(SkillTreeManager.instance.getSkillTreeEntry(SkillManager.instance.getSkill("AugmentedCasting")))) {
            modifiedValue *= 1.1f;
        }
    }
    ModifierCalculatedEvent event = new ModifierCalculatedEvent(stack, caster, check, defaultValue, modifiedValue, OperationType.ADD);
    MinecraftForge.EVENT_BUS.post(event);
    return (int) Math.ceil(event.modifiedValue);
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ModifierCalculatedEvent(am2.api.events.ModifierCalculatedEvent)

Example 12 with ISpellModifier

use of am2.api.spell.component.interfaces.ISpellModifier in project ArsMagica2 by Mithion.

the class TileEntityInscriptionTable method GetUpdatePacketForServer.

private byte[] GetUpdatePacketForServer() {
    AMDataWriter writer = new AMDataWriter();
    writer.add(FULL_UPDATE);
    writer.add(this.currentPlayerUsing == null);
    if (this.currentPlayerUsing != null)
        writer.add(this.currentPlayerUsing.getEntityId());
    writer.add(this.currentRecipe.size());
    for (int i = 0; i < this.currentRecipe.size(); ++i) {
        ISpellPart part = this.currentRecipe.get(i);
        int id = part.getID();
        if (part instanceof ISpellComponent)
            id += SkillManager.COMPONENT_OFFSET;
        else if (part instanceof ISpellModifier)
            id += SkillManager.MODIFIER_OFFSET;
        writer.add(id);
    }
    writer.add(this.shapeGroups.size());
    for (ArrayList<ISpellPart> shapeGroup : this.shapeGroups) {
        int[] groupData = new int[shapeGroup.size()];
        for (int i = 0; i < shapeGroup.size(); ++i) {
            groupData[i] = SkillManager.instance.getShiftedPartID(shapeGroup.get(i));
        }
        writer.add(groupData);
    }
    writer.add(currentSpellName);
    writer.add(currentSpellIsReadOnly);
    return writer.generate();
}
Also used : AMDataWriter(am2.network.AMDataWriter)

Example 13 with ISpellModifier

use of am2.api.spell.component.interfaces.ISpellModifier in project ArsMagica2 by Mithion.

the class TileEntityInscriptionTable method countModifiersInList.

private void countModifiersInList(ArrayList<ISpellPart> currentStage) {
    for (ISpellPart part : currentStage) {
        if (part instanceof ISpellModifier) {
            EnumSet<SpellModifiers> modifiers = ((ISpellModifier) part).getAspectsModified();
            for (SpellModifiers modifier : modifiers) {
                int count = modifierCount.get(modifier) + 1;
                modifierCount.put(modifier, count);
            }
        }
    }
}
Also used : SpellModifiers(am2.api.spell.enums.SpellModifiers)

Example 14 with ISpellModifier

use of am2.api.spell.component.interfaces.ISpellModifier in project ArsMagica2 by Mithion.

the class AoE method manaCostMultiplier.

@Override
public float manaCostMultiplier(ItemStack spellStack) {
    int multiplier = 2;
    int radiusMods = 0;
    int stages = SpellUtils.instance.numStages(spellStack);
    for (int i = 0; i < stages; ++i) {
        if (SpellUtils.instance.getShapeForStage(spellStack, i).getID() != this.getID())
            continue;
        ISpellModifier[] mods = SpellUtils.instance.getModifiersForStage(spellStack, i);
        for (ISpellModifier modifier : mods) {
            if (modifier.getAspectsModified().contains(SpellModifiers.RADIUS)) {
                radiusMods++;
            }
        }
    }
    return multiplier * (radiusMods + 1);
}
Also used : ISpellModifier(am2.api.spell.component.interfaces.ISpellModifier)

Example 15 with ISpellModifier

use of am2.api.spell.component.interfaces.ISpellModifier in project ArsMagica2 by Mithion.

the class AoE method spawnAoEParticles.

private void spawnAoEParticles(ItemStack stack, EntityLivingBase caster, World world, double x, double y, double z, int radius) {
    String pfxName = AMParticleIcons.instance.getParticleForAffinity(SpellUtils.instance.mainAffinityFor(stack));
    float speed = 0.08f * radius;
    int color = 0xFFFFFF;
    if (SpellUtils.instance.modifierIsPresent(SpellModifiers.COLOR, stack, 0)) {
        ISpellModifier[] mods = SpellUtils.instance.getModifiersForStage(stack, 0);
        int ordinalCount = 0;
        for (ISpellModifier mod : mods) {
            if (mod instanceof Colour) {
                byte[] meta = SpellUtils.instance.getModifierMetadataFromStack(stack, mod, 0, ordinalCount++);
                color = (int) mod.getModifier(SpellModifiers.COLOR, null, null, null, meta);
            }
        }
    }
    for (int i = 0; i < 360; i += AMCore.config.FullGFX() ? 20 : AMCore.config.LowGFX() ? 40 : 60) {
        AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(world, pfxName, x, y + 1.5f, z);
        if (effect != null) {
            effect.setIgnoreMaxAge(true);
            effect.AddParticleController(new ParticleMoveOnHeading(effect, i, 0, speed, 1, false));
            effect.noClip = false;
            effect.setRGBColorI(color);
            effect.AddParticleController(new ParticleFadeOut(effect, 1, false).setFadeSpeed(0.05f).setKillParticleOnFinish(true));
            effect.AddParticleController(new ParticleLeaveParticleTrail(effect, pfxName, false, 5, 1, false).addControllerToParticleList(new ParticleFadeOut(effect, 1, false).setFadeSpeed(0.1f).setKillParticleOnFinish(true)).setParticleRGB_I(color).addRandomOffset(0.2f, 0.2f, 0.2f));
        }
    }
}
Also used : ISpellModifier(am2.api.spell.component.interfaces.ISpellModifier) Colour(am2.spell.modifiers.Colour)

Aggregations

ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)17 Colour (am2.spell.modifiers.Colour)13 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 ModifierCalculatedEvent (am2.api.events.ModifierCalculatedEvent)6 Entity (net.minecraft.entity.Entity)6 EntityLivingBase (net.minecraft.entity.EntityLivingBase)5 EntityDragonPart (net.minecraft.entity.boss.EntityDragonPart)5 ISpellComponent (am2.api.spell.component.interfaces.ISpellComponent)4 ISpellShape (am2.api.spell.component.interfaces.ISpellShape)4 ItemStack (net.minecraft.item.ItemStack)4 AMVector3 (am2.api.math.AMVector3)2 Affinity (am2.api.spell.enums.Affinity)2 AMDataWriter (am2.network.AMDataWriter)2 AMParticle (am2.particles.AMParticle)2 Summon (am2.spell.components.Summon)2 DummyEntityPlayer (am2.utility.DummyEntityPlayer)2 KeyValuePair (am2.utility.KeyValuePair)2 SkillLearnedEvent (am2.api.events.SkillLearnedEvent)1 AMLineSegment (am2.api.math.AMLineSegment)1 ISkillTreeEntry (am2.api.spell.component.interfaces.ISkillTreeEntry)1