Search in sources :

Example 1 with AffinityData

use of am2.playerextensions.AffinityData 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 AffinityData

use of am2.playerextensions.AffinityData 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 3 with AffinityData

use of am2.playerextensions.AffinityData 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 4 with AffinityData

use of am2.playerextensions.AffinityData in project ArsMagica2 by Mithion.

the class ItemAffinityBook method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    if (par1ItemStack.getItemDamage() == META_GENERAL) {
        AffinityData data = AffinityData.For(par3EntityPlayer);
        data.setLocked(false);
        for (Affinity aff : Affinity.values()) {
            data.setAffinityAndDepth(aff, data.getAffinityDepth(aff) - 20);
        }
    } else {
        AffinityData.For(par3EntityPlayer).incrementAffinity(Affinity.getByID(par1ItemStack.getItemDamage()), 20);
    }
    if (!par2World.isRemote)
        par1ItemStack.stackSize--;
    return par1ItemStack;
}
Also used : AffinityData(am2.playerextensions.AffinityData) Affinity(am2.api.spell.enums.Affinity)

Example 5 with AffinityData

use of am2.playerextensions.AffinityData in project ArsMagica2 by Mithion.

the class SpellBase method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
    if (!stack.hasTagCompound())
        return;
    ItemStack legacySpell = SpellUtils.instance.constructSpellStack(stack);
    SpellRequirements reqs = SpellUtils.instance.getSpellRequirements(legacySpell, player);
    float manaCost = reqs.manaCost;
    float burnout = reqs.burnout;
    ArrayList<ItemStack> reagents = reqs.reagents;
    ManaCostEvent mce = new ManaCostEvent(legacySpell, player, manaCost, 0);
    MinecraftForge.EVENT_BUS.post(mce);
    manaCost = mce.manaCost;
    list.add(String.format("\2477Mana Cost: %.2f", manaCost));
    if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
        HashMap<Affinity, Float> affinityData = SpellUtils.instance.AffinityFor(legacySpell);
        for (Affinity aff : affinityData.keySet()) {
            list.add(String.format("%s (%.2f%%)", aff.toString(), affinityData.get(aff) * 100));
        }
        if (stack.stackTagCompound.hasKey("Lore")) {
            NBTTagList nbttaglist1 = stack.stackTagCompound.getTagList("Lore", Constants.NBT.TAG_COMPOUND);
            if (nbttaglist1.tagCount() > 0) {
                for (int j = 0; j < nbttaglist1.tagCount(); ++j) {
                    list.add(EnumChatFormatting.DARK_PURPLE + "" + EnumChatFormatting.ITALIC + nbttaglist1.getStringTagAt(j));
                }
            }
        }
    } else {
        list.add(StatCollector.translateToLocal("am2.tooltip.shiftForAffinity"));
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) SpellRequirements(am2.spell.SpellUtils.SpellRequirements) ManaCostEvent(am2.api.events.ManaCostEvent) Affinity(am2.api.spell.enums.Affinity) ItemStack(net.minecraft.item.ItemStack) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Aggregations

AffinityData (am2.playerextensions.AffinityData)10 Affinity (am2.api.spell.enums.Affinity)7 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)5 EntityLivingBase (net.minecraft.entity.EntityLivingBase)4 ItemStack (net.minecraft.item.ItemStack)3 EntityEnderman (net.minecraft.entity.monster.EntityEnderman)2 AffinityChangingEvent (am2.api.events.AffinityChangingEvent)1 ManaCostEvent (am2.api.events.ManaCostEvent)1 SpellRecipeItemsEvent (am2.api.events.SpellRecipeItemsEvent)1 AMVector2 (am2.api.math.AMVector2)1 AMVector3 (am2.api.math.AMVector3)1 PowerTypes (am2.api.power.PowerTypes)1 AMDataWriter (am2.network.AMDataWriter)1 ExtendedProperties (am2.playerextensions.ExtendedProperties)1 RiftStorage (am2.playerextensions.RiftStorage)1 SkillData (am2.playerextensions.SkillData)1 SpellRequirements (am2.spell.SpellUtils.SpellRequirements)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 Block (net.minecraft.block.Block)1