/** Performs a ranged attack according to the AI's rangedAttackID. */ private void doRangedAttack() { // 43% chance to "miss" int chanceToMiss = entityHost.isPotionActive(Potion.moveSpeed) ? 10 : 43; if (worldObj.rand.nextInt(100) < chanceToMiss) { AMCore.instance.proxy.particleManager.BoltFromPointToPoint( worldObj, entityHost.posX, entityHost.posY + entityHost.getEyeHeight(), entityHost.posZ, attackTarget.posX + worldObj.rand.nextFloat() - 0.5f, attackTarget.posY + attackTarget.getEyeHeight() + worldObj.rand.nextFloat() - 0.5f, attackTarget.posZ + worldObj.rand.nextFloat() - 0.5f, 2, -1); } else { AMCore.instance.proxy.particleManager.BoltFromEntityToEntity( worldObj, entityHost, entityHost, attackTarget, this.damage, 2, -1); float manaDrained = this.manaDrainedPerCasterLevel * ExtendedProperties.For(attackTarget).getMagicLevel(); ExtendedProperties.For(attackTarget) .setCurrentMana(ExtendedProperties.For(attackTarget).getCurrentMana() - (manaDrained)); ExtendedProperties.For(attackTarget).forceSync(); attackTarget.attackEntityFrom( DamageSource.causeIndirectMagicDamage(entityHost, entityHost), this.damage); if (manaDrained > 100) { entityHost.heal(1); if (entityHost.worldObj.difficultySetting == EnumDifficulty.HARD) { attackTarget.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 40, 1, true)); entityHost.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 40, 3, true)); } } } }
public EntityWaterElemental(World par1World) { super(par1World); this.hostileSpeed = 0.46F; initAI(); ExtendedProperties.For(this).setMagicLevel(5); ExtendedProperties.For(this).setMaxMana(300); ExtendedProperties.For(this).setCurrentMana(300); }
public boolean flingArm(ItemStack stack, World world, EntityPlayer player) { if (ExtendedProperties.For(player).getCurrentMana() < 250 && !player.capabilities.isCreativeMode) { if (world.isRemote) AMCore.proxy.flashManaBar(); return false; } if (!world.isRemote) { EntityWinterGuardianArm projectile = new EntityWinterGuardianArm(world, player, 1.25f); projectile.setThrowingEntity(player); projectile.setProjectileSpeed(2.0); world.spawnEntityInWorld(projectile); } ExtendedProperties.For(player).deductMana(250f); return true; }
public void RenderContingency(int i, int j) { AMVector2 contingencyPos = getShiftedVector(AMCore.config.getContingencyPosition(), i, j); IIcon icon = null; ContingencyTypes type = ExtendedProperties.For(Minecraft.getMinecraft().thePlayer).getContingencyType(); switch (type) { case DAMAGE_TAKEN: icon = SpellIconManager.instance.getIcon("Contingency_Damage"); break; case FALL: icon = SpellIconManager.instance.getIcon("Contingency_Fall"); break; case HEALTH_LOW: icon = SpellIconManager.instance.getIcon("Contingency_Health"); break; case ON_FIRE: icon = SpellIconManager.instance.getIcon("Contingency_Fire"); break; case DEATH: icon = SpellIconManager.instance.getIcon("Contingency_Death"); break; case NONE: default: return; } DrawIconAtXY(icon, "items", contingencyPos.iX, contingencyPos.iY, 16, 16, true); GL11.glColor3f(1.0f, 1.0f, 1.0f); }
public static void storeExtendedPropertiesForDimensionChange(EntityPlayer player) { // extended properties // ================================================================================ if (!storedExtProps_death.containsKey(player.getDisplayName())) { if (storedExtProps_dimension.containsKey(player.getDisplayName())) storedExtProps_dimension.remove(player.getDisplayName()); NBTTagCompound saveExprop = new NBTTagCompound(); ExtendedProperties.For(player).saveNBTData(saveExprop); storedExtProps_dimension.put(player.getDisplayName(), saveExprop); } // ================================================================================ // rift storage // ================================================================================ if (!riftStorage_death.containsKey(player.getDisplayName())) { if (riftStorage_dimension.containsKey(player.getDisplayName())) riftStorage_dimension.remove(player.getDisplayName()); NBTTagCompound saveRift = new NBTTagCompound(); RiftStorage.For(player).saveNBTData(saveRift); riftStorage_dimension.put(player.getDisplayName(), saveRift); } // ================================================================================ // affinity storage // ================================================================================ if (!affinityStorage_death.containsKey(player.getDisplayName())) { if (affinityStorage_dimension.containsKey(player.getDisplayName())) affinityStorage_dimension.remove(player.getDisplayName()); NBTTagCompound saveAffinity = new NBTTagCompound(); AffinityData.For(player).saveNBTData(saveAffinity); affinityStorage_dimension.put(player.getDisplayName(), saveAffinity); } // ================================================================================ // spell knowledge storage // ================================================================================ if (!spellKnowledgeStorage_death.containsKey(player.getDisplayName())) { if (spellKnowledgeStorage_dimension.containsKey(player.getDisplayName())) spellKnowledgeStorage_dimension.remove(player.getDisplayName()); NBTTagCompound spellKnowledge = new NBTTagCompound(); SkillData.For(player).saveNBTData(spellKnowledge); spellKnowledgeStorage_dimension.put(player.getDisplayName(), spellKnowledge); } // ================================================================================ }
public void RenderMagicXP(int i, int j) { ExtendedProperties props = ExtendedProperties.For(Minecraft.getMinecraft().thePlayer); if (props.getMagicLevel() > 0) { AMVector2 position = getShiftedVector(AMCore.config.getXPBarPosition(), i, j); AMVector2 dimensions = new AMVector2(182, 5); Minecraft.getMinecraft().renderEngine.bindTexture(mc_gui); GL11.glColor4f( 0.5f, 0.5f, 1.0f, AMCore.config.showXPAlways() ? 1.0f : AMGuiHelper.instance.getMagicXPBarAlpha()); // base XP bar drawTexturedModalRect_Classic( position.iX, position.iY, 0, 64, dimensions.iX, dimensions.iY, dimensions.iX, dimensions.iY); if (props.getMagicXP() > 0) { float pctXP = props.getMagicXP() / props.getXPToNextLevel(); if (pctXP > 1) pctXP = 1; int width = (int) ((dimensions.iX + 1) * pctXP); drawTexturedModalRect_Classic( position.iX, position.iY, 0, 69, width, dimensions.iY, width, dimensions.iY); } if (AMCore.config.getShowNumerics() && (AMCore.config.showXPAlways() || AMGuiHelper.instance.getMagicXPBarAlpha() > 0)) { String xpStr = StatCollector.translateToLocal("am2.gui.xp") + ": " + +(int) (props.getMagicXP() * 100) + "/" + (int) (props.getXPToNextLevel() * 100); AMVector2 numericPos = getShiftedVector(AMCore.config.getXPNumericPosition(), i, j); Minecraft.getMinecraft() .fontRenderer .drawString(xpStr, numericPos.iX, numericPos.iY, 0x999999); } } }
@Override public SpellCastResult beginStackStage( ItemSpellBase item, ItemStack stack, EntityLivingBase caster, EntityLivingBase target, World world, double x, double y, double z, int side, boolean giveXP, int useCount) { ExtendedProperties.For(target != null ? target : caster) .setContingency(ContingencyTypes.HEALTH_LOW, SpellUtils.instance.popStackStage(stack)); return SpellCastResult.SUCCESS; }
@SubscribeEvent public void onPlayerChangedDimension(PlayerChangedDimensionEvent event) { // kill any summoned creatures, eventually respawn them in the new dimension if (!event.player.worldObj.isRemote) { storeExtendedPropertiesForDimensionChange(event.player); List list = event.player.worldObj.loadedEntityList; for (Object o : list) { if (o instanceof EntityLivingBase && EntityUtilities.isSummon((EntityLivingBase) o) && EntityUtilities.getOwner((EntityLivingBase) o) == event.player.getEntityId()) { ((EntityLivingBase) o).setDead(); } } ExtendedProperties.For(event.player).setDelayedSync(40); AffinityData.For(event.player).setDelayedSync(40); SkillData.For(event.player).setDelayedSync(40); } }
public static void storeExtendedPropertiesForRespawn(EntityPlayer player) { // extended properties // ================================================================================ if (storedExtProps_death.containsKey(player.getDisplayName())) storedExtProps_death.remove(player.getDisplayName()); NBTTagCompound save = new NBTTagCompound(); ExtendedProperties.For(player).saveNBTData(save); storedExtProps_death.put(player.getDisplayName(), save); // ================================================================================ // rift storage // ================================================================================ if (riftStorage_death.containsKey(player.getDisplayName())) riftStorage_death.remove(player.getDisplayName()); NBTTagCompound saveRift = new NBTTagCompound(); RiftStorage.For(player).saveNBTData(saveRift); riftStorage_death.put(player.getDisplayName(), saveRift); // ================================================================================ // affinity storage // ================================================================================ if (affinityStorage_death.containsKey(player.getDisplayName())) affinityStorage_death.remove(player.getDisplayName()); NBTTagCompound saveAffinity = new NBTTagCompound(); AffinityData.For(player).saveNBTData(saveAffinity); affinityStorage_death.put(player.getDisplayName(), saveAffinity); // ================================================================================ // affinity storage // ================================================================================ if (spellKnowledgeStorage_death.containsKey(player.getDisplayName())) spellKnowledgeStorage_death.remove(player.getDisplayName()); NBTTagCompound saveSpellKnowledge = new NBTTagCompound(); SkillData.For(player).saveNBTData(saveSpellKnowledge); spellKnowledgeStorage_death.put(player.getDisplayName(), saveSpellKnowledge); // ================================================================================ }
@SubscribeEvent public void onPlayerRespawn(PlayerRespawnEvent event) { // extended properties // ================================================================================ if (storedExtProps_death.containsKey(event.player.getDisplayName())) { NBTTagCompound stored = storedExtProps_death.get(event.player.getDisplayName()); storedExtProps_death.remove(event.player.getDisplayName()); ExtendedProperties.For(event.player).loadNBTData(stored); ExtendedProperties.For(event.player).setDelayedSync(40); } else if (storedExtProps_dimension.containsKey(event.player.getDisplayName())) { NBTTagCompound stored = storedExtProps_dimension.get(event.player.getDisplayName()); storedExtProps_dimension.remove(event.player.getDisplayName()); ExtendedProperties.For(event.player).loadNBTData(stored); ExtendedProperties.For(event.player).setDelayedSync(40); } // ================================================================================ // rift storage // ================================================================================ if (riftStorage_death.containsKey(event.player.getDisplayName())) { NBTTagCompound stored = riftStorage_death.get(event.player.getDisplayName()); riftStorage_death.remove(event.player.getDisplayName()); RiftStorage.For(event.player).loadNBTData(stored); } else if (riftStorage_dimension.containsKey(event.player.getDisplayName())) { NBTTagCompound stored = riftStorage_dimension.get(event.player.getDisplayName()); riftStorage_dimension.remove(event.player.getDisplayName()); RiftStorage.For(event.player).loadNBTData(stored); } // ================================================================================ // affinity data // ================================================================================ if (affinityStorage_death.containsKey(event.player.getDisplayName())) { NBTTagCompound stored = affinityStorage_death.get(event.player.getDisplayName()); affinityStorage_death.remove(event.player.getDisplayName()); AffinityData.For(event.player).loadNBTData(stored); } else if (affinityStorage_dimension.containsKey(event.player.getDisplayName())) { NBTTagCompound stored = affinityStorage_dimension.get(event.player.getDisplayName()); affinityStorage_dimension.remove(event.player.getDisplayName()); AffinityData.For(event.player).loadNBTData(stored); } // ================================================================================ // spell knowledge data // ================================================================================ if (spellKnowledgeStorage_death.containsKey(event.player.getDisplayName())) { NBTTagCompound stored = spellKnowledgeStorage_death.get(event.player.getDisplayName()); spellKnowledgeStorage_death.remove(event.player.getDisplayName()); SkillData.For(event.player).loadNBTData(stored); } else if (spellKnowledgeStorage_dimension.containsKey(event.player.getDisplayName())) { NBTTagCompound stored = spellKnowledgeStorage_dimension.get(event.player.getDisplayName()); spellKnowledgeStorage_dimension.remove(event.player.getDisplayName()); SkillData.For(event.player).loadNBTData(stored); } // ================================================================================ // soulbound items // ================================================================================ if (soulbound_Storage.containsKey(event.player.getDisplayName())) { HashMap<Integer, ItemStack> soulboundItems = soulbound_Storage.get(event.player.getDisplayName()); for (Integer i : soulboundItems.keySet()) { if (i < event.player.inventory.getSizeInventory()) event.player.inventory.setInventorySlotContents(i, soulboundItems.get(i)); else event.player.entityDropItem(soulboundItems.get(i), 0); } } // ================================================================================ }
private void RenderArsMagicaGUIItems(int i, int j, FontRenderer fontRenderer) { if (ExtendedProperties.For(mc.thePlayer).getMagicLevel() > 0 || mc.thePlayer.capabilities.isCreativeMode) { RenderManaBar(i, j, fontRenderer); } }
private void RenderManaBar(int i, int j, FontRenderer fontRenderer) { int barWidth = i / 8; AMVector2 fatigue_hud = getShiftedVector(AMCore.config.getBurnoutHudPosition(), i, j); AMVector2 mana_hud = getShiftedVector(AMCore.config.getManaHudPosition(), i, j); float green = 0.5f; float blue = 1.0f; float red = 0.126f; ExtendedProperties props = ExtendedProperties.For(mc.thePlayer); // mana bar float mana = props.getCurrentMana(); float bonusMana = props.getBonusCurrentMana(); float maxMana = props.getMaxMana(); float fatigueBarWidth = barWidth; float fatigue = props.getCurrentFatigue(); float maxFatigue = props.getMaxFatigue(); if (mana + bonusMana > maxMana) mana = maxMana; float progressScaled = (mana / (maxMana + 0.01f)); if (AMCore.config.showHudBars()) { // handle flashing of mana bar float flashTimer = AMGuiHelper.instance.getFlashTimer(MANA_BAR_FLASH_SLOT); if (flashTimer > 0) { green = 0.0f; float redShift = 1.0f - red; float halfFlash = AMGuiHelper.instance.flashDuration / 2; if (flashTimer > halfFlash) { float pct = (flashTimer - halfFlash) / halfFlash; red += redShift - (redShift * pct); } else { float pct = flashTimer / halfFlash; red += (redShift * pct); } GL11.glColor3f(red, green, blue); } else { if (bonusMana > 0) GL11.glColor3f(0.2f, 0.9f, 0.6f); } ItemStack curItem = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem(); if (curItem != null && (curItem.getItem() == ItemsCommonProxy.spell || curItem.getItem() == ItemsCommonProxy.spellBook || curItem.getItem() == ItemsCommonProxy.arcaneSpellbook)) { ItemStack spellStack = curItem.getItem() == ItemsCommonProxy.spell ? curItem : ((ItemSpellBook) curItem.getItem()).GetActiveItemStack(curItem); if (spellStack != null) { int[] parts = SpellUtils.instance.getShapeGroupParts(spellStack); int sx = mana_hud.iX - 2 * parts.length / 2; int sy = mana_hud.iY - 2 * parts.length / 2; for (int p : parts) { IIcon icon = SpellIconManager.instance.getIcon( SkillManager.instance.getSkillName(SkillManager.instance.getSkill(p))); if (icon != null) { DrawIconAtXY(icon, "items", sx, sy, false); sx += 3; sy += 3; } } } } DrawPartialIconAtXY( AMGuiIcons.manaLevel, progressScaled, 1, mana_hud.iX + 16, mana_hud.iY + 1f, (int) (barWidth * 0.97f), 40, false); DrawIconAtXY( AMGuiIcons.manaBar, "items", mana_hud.iX + 15, mana_hud.iY + 3, barWidth, 50, false); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); progressScaled = (fatigue / (maxFatigue + 0.01f)); DrawIconAtXY( AMGuiIcons.fatigueIcon, "items", fatigue_hud.iX + barWidth, fatigue_hud.iY, false); DrawPartialIconAtXY( AMGuiIcons.fatigueLevel, progressScaled, 1, fatigue_hud.iX, fatigue_hud.iY + 3f, fatigueBarWidth, 40, false); DrawIconAtXY( AMGuiIcons.fatigueBar, "items", fatigue_hud.iX, fatigue_hud.iY + 4, barWidth, 48, false); green = 0.5f; blue = 1.0f; red = 0.126f; // magic level int manaBarColor = Math.round(red * 255); manaBarColor = (manaBarColor << 8) + Math.round(green * 255); manaBarColor = (manaBarColor << 8) + Math.round(blue * 255); String magicLevel = (new StringBuilder()) .append("") .append(ExtendedProperties.For(mc.thePlayer).getMagicLevel()) .toString(); AMVector2 magicLevelPos = getShiftedVector(AMCore.config.getLevelPosition(), i, j); magicLevelPos.iX -= Minecraft.getMinecraft().fontRenderer.getStringWidth(magicLevel) / 2; fontRenderer.drawStringWithShadow( magicLevel, magicLevelPos.iX, magicLevelPos.iY, manaBarColor); if (flashTimer > 0) { GL11.glColor3f(1.0f, 1.0f, 1.0f); } } if (AMCore.config.getShowNumerics()) { String manaStr = StatCollector.translateToLocal("am2.gui.mana") + ": " + (int) (mana + bonusMana) + "/" + (int) maxMana; String burnoutStr = StatCollector.translateToLocal("am2.gui.burnout") + ": " + (int) props.getCurrentFatigue() + "/" + (int) props.getMaxFatigue(); AMVector2 manaNumericPos = getShiftedVector(AMCore.config.getManaNumericPosition(), i, j); AMVector2 burnoutNumericPos = getShiftedVector(AMCore.config.getBurnoutNumericPosition(), i, j); fontRenderer.drawString( manaStr, manaNumericPos.iX, manaNumericPos.iY, bonusMana > 0 ? 0xeae31c : 0x2080FF); fontRenderer.drawString( burnoutStr, burnoutNumericPos.iX + 25 - fontRenderer.getStringWidth(burnoutStr), burnoutNumericPos.iY, 0xFF2020); } }