Search in sources :

Example 1 with Affinity

use of am2.api.spell.enums.Affinity in project ArsMagica2 by Mithion.

the class AMIngameGUI method RenderAffinity.

public void RenderAffinity(int i, int j) {
    AMVector2 affinityPos = getShiftedVector(AMCore.config.getAffinityPosition(), i, j);
    int x = affinityPos.iX;
    int y = affinityPos.iY;
    AffinityData ad = AffinityData.For(Minecraft.getMinecraft().thePlayer);
    for (Affinity affinity : ad.getHighestAffinities()) {
        if (affinity == null || affinity == Affinity.NONE)
            continue;
        GL11.glColor3f(1.0f, 1.0f, 1.0f);
        AMGuiHelper.instance.DrawIconAtXY(affinity.representItem.getIconFromDamage(affinity.representMeta), x, y, j, 12, 12, true);
        if (AMCore.config.getShowNumerics()) {
            String display = String.format("%.2f%%", AffinityData.For(mc.thePlayer).getAffinityDepth(affinity) * 100);
            if (x < i / 2)
                Minecraft.getMinecraft().fontRenderer.drawString(display, x + 14, y + 2, affinity.color);
            else
                Minecraft.getMinecraft().fontRenderer.drawString(display, x - 2 - Minecraft.getMinecraft().fontRenderer.getStringWidth(display), y + 2, affinity.color);
        }
        y += 15;
    }
}
Also used : AMVector2(am2.api.math.AMVector2) AffinityData(am2.playerextensions.AffinityData) Affinity(am2.api.spell.enums.Affinity)

Example 2 with Affinity

use of am2.api.spell.enums.Affinity in project ArsMagica2 by Mithion.

the class Chain method spawnChainParticles.

private void spawnChainParticles(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, ItemStack spellStack) {
    int color = getPFXColor(spellStack);
    Affinity aff = SpellUtils.instance.mainAffinityFor(spellStack);
    if (aff == Affinity.LIGHTNING) {
        AMCore.proxy.particleManager.BoltFromPointToPoint(world, startX, startY, startZ, endX, endY, endZ, 1, color);
    } else {
        if (color == -1)
            color = aff.color;
        AMCore.proxy.particleManager.BeamFromPointToPoint(world, startX, startY, startZ, endX, endY, endZ, color);
    }
}
Also used : Affinity(am2.api.spell.enums.Affinity)

Example 3 with Affinity

use of am2.api.spell.enums.Affinity in project ArsMagica2 by Mithion.

the class SpellUtils method modifySpellRequirementsByAffinity.

public SpellRequirements modifySpellRequirementsByAffinity(ItemStack stack, EntityLivingBase caster, SpellRequirements reqs) {
    HashMap<Affinity, Float> affinities = this.AffinityFor(stack);
    AffinityData affData = AffinityData.For(caster);
    if (affData == null)
        return reqs;
    float manaCost = reqs.manaCost;
    for (Affinity aff : affinities.keySet()) {
        float depth = affData.getAffinityDepth(aff);
        // calculate the modifier based on the player's affinity depth as well as how much of the spell is that affinity
        // how much does this affinity affect the overall mana cost?
        float effectiveness = affinities.get(aff);
        // how much will the player's affinity reduce the mana cost? (max 50%)
        float multiplier = 0.5f * depth;
        float manaMod = manaCost * effectiveness;
        manaCost -= manaMod * multiplier;
    }
    return new SpellRequirements(manaCost, reqs.burnout, reqs.reagents);
}
Also used : AffinityData(am2.playerextensions.AffinityData) Affinity(am2.api.spell.enums.Affinity)

Example 4 with Affinity

use of am2.api.spell.enums.Affinity in project ArsMagica2 by Mithion.

the class SpellUtils method doAffinityShift.

public void doAffinityShift(EntityLivingBase caster, ISpellComponent component, ISpellShape governingShape) {
    if (!(caster instanceof EntityPlayer))
        return;
    AffinityData aff = AffinityData.For(caster);
    EnumSet<Affinity> affList = component.getAffinity();
    for (Affinity affinity : affList) {
        float shift = component.getAffinityShift(affinity) * aff.getDiminishingReturnsFactor() * 5;
        float xp = 0.05f * aff.getDiminishingReturnsFactor();
        if (governingShape.isChanneled()) {
            shift /= 4;
            xp /= 4;
        }
        if (caster instanceof EntityPlayer) {
            if (SkillData.For((EntityPlayer) caster).isEntryKnown(SkillTreeManager.instance.getSkillTreeEntry(SkillManager.instance.getSkill("AffinityGains")))) {
                shift *= 1.1f;
                xp *= 0.9f;
            }
            ItemStack chestArmor = ((EntityPlayer) caster).getCurrentArmor(2);
            if (chestArmor != null && ArmorHelper.isInfusionPreset(chestArmor, GenericImbuement.magicXP))
                xp *= 1.25f;
        }
        if (shift > 0) {
            AffinityChangingEvent event = new AffinityChangingEvent((EntityPlayer) caster, affinity, shift);
            MinecraftForge.EVENT_BUS.post(event);
            if (!event.isCanceled())
                aff.incrementAffinity(affinity, event.amount);
        }
        if (xp > 0) {
            xp *= caster.getAttributeMap().getAttributeInstance(ArsMagicaApi.xpGainModifier).getAttributeValue();
            ExtendedProperties.For(caster).addMagicXP(xp);
        }
    }
    aff.addDiminishingReturns(governingShape.isChanneled());
}
Also used : AffinityChangingEvent(am2.api.events.AffinityChangingEvent) AffinityData(am2.playerextensions.AffinityData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Affinity(am2.api.spell.enums.Affinity) ItemStack(net.minecraft.item.ItemStack)

Example 5 with Affinity

use of am2.api.spell.enums.Affinity in project ArsMagica2 by Mithion.

the class GuiSkillTrees method initGui.

@Override
public void initGui() {
    super.initGui();
    int l = (width - xSize) / 2 + 8;
    int i1 = (height - ySize) / 2;
    offense = new GuiButtonSkillTreeTab(0, l, i1, SkillTrees.Offense);
    defense = new GuiButtonSkillTreeTab(0, l + GuiButtonSkillTreeTab.buttonWidth + buttonPadding, i1, SkillTrees.Defense);
    utility = new GuiButtonSkillTreeTab(0, l + GuiButtonSkillTreeTab.buttonWidth * 2 + buttonPadding * 2, i1, SkillTrees.Utility);
    talents = new GuiButtonSkillTreeTab(0, l + GuiButtonSkillTreeTab.buttonWidth * 3 + buttonPadding * 3, i1, SkillTrees.Talents);
    affinity = new GuiButtonSkillTreeTab(0, l + GuiButtonSkillTreeTab.buttonWidth * 4 + buttonPadding * 4, i1, SkillTrees.Affinity);
    offense.setActive(true);
    this.buttonList.add(offense);
    this.buttonList.add(defense);
    this.buttonList.add(utility);
    if (ExtendedProperties.For(Minecraft.getMinecraft().thePlayer).getMagicLevel() >= 5)
        this.buttonList.add(talents);
    if (!ArcaneCompendium.instance.getEntry("affinity").isLocked())
        this.buttonList.add(affinity);
}
Also used : GuiButtonSkillTreeTab(am2.guis.controls.GuiButtonSkillTreeTab)

Aggregations

Affinity (am2.api.spell.enums.Affinity)27 AffinityData (am2.playerextensions.AffinityData)6 ItemStack (net.minecraft.item.ItemStack)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 TileEntity (net.minecraft.tileentity.TileEntity)4 ArrayList (java.util.ArrayList)3 AMVector2 (am2.api.math.AMVector2)2 AMVector3 (am2.api.math.AMVector3)2 ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)2 AMParticle (am2.particles.AMParticle)2 Colour (am2.spell.modifiers.Colour)2 HashMap (java.util.HashMap)2 Block (net.minecraft.block.Block)2 WrongUsageException (net.minecraft.command.WrongUsageException)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 ChatComponentText (net.minecraft.util.ChatComponentText)2 AffinityChangingEvent (am2.api.events.AffinityChangingEvent)1 ManaCostEvent (am2.api.events.ManaCostEvent)1 SpellRecipeItemsEvent (am2.api.events.SpellRecipeItemsEvent)1