Thread: RSModernSpellStore

Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1. #1 RSModernSpellStore 
    Registered Member

    Join Date
    Mar 2011
    Age
    23
    Posts
    512
    Thanks given
    128
    Thanks received
    129
    Rep Power
    100
    Code:
    package com.rs.game.player.actions.combat.modernspells;
    
    import com.rs.game.Entity;
    import com.rs.game.Graphics;
    import com.rs.game.player.Player;
    import com.rs.game.player.Skills;
    import com.rs.game.player.actions.combat.PlayerCombat;
    
    public class RSModernCombatSpells {
    
    	/*
    	 * @author -Andreas
    	 * 
    	 * @2018-06-21
    	 */
    
    	private static final int AIR_SPELL = 0, WATER_SPELL = 1, EARTH_SPELL = 2, FIRE_SPELL = 3;
    
    	public static enum ModernCombatSpellsStore {
    
    		// animationid -1 == standard 14221 animationId
    		WIND_RUSH(98, 2.5, 10, -1, null, 2699, 2700, AIR_SPELL),
    
    		AIR_STRIKE(25, 5.5, 20, -1, null, 458, 463, AIR_SPELL),
    
    		WATER_STRIKE(28, 7.5, 40, -1, new Graphics(2702), 2703, 2708, WATER_SPELL),
    
    		EARTH_STRIKE(30, 9.5, 60, -1, new Graphics(2713), 2718, 2723, EARTH_SPELL),
    
    		FIRE_STRIKE(32, 11.5, 80, -1, new Graphics(2728), 2729, 2737, FIRE_SPELL),
    
    		WIND_BOLT(34, 13.5, 90, -1, null, 2699, 2700, AIR_SPELL),
    
    		WATER_BOLT(39, 16.5, 100, 14220, new Graphics(2707), 2704, 2709, WATER_SPELL),
    
    		EARTH_BOLT(42, 19.5, 110, 14222, new Graphics(2714), 2719, 2724, EARTH_SPELL),
    
    		FIRE_BOLT(45, 22.5, 120, 14223, new Graphics(2728), 2731, 2738, FIRE_SPELL),
    
    		CRUMBLE_UNDEAD(47, 24.5, 160, 724, new Graphics(145, 0, 100), 146, 147),
    
    		WIND_BLAST(49, 25.5, 130, -1, null, 2699, 2700, AIR_SPELL),
    
    		WATER_BLAST(52, 28.5, 140, 14220, new Graphics(2701), 2705, 2710, WATER_SPELL),
    
    		IBAN_BLAST(54, 30.0, 250, 708, new Graphics(87, 0, 100), 88, 89),
    
    		MAGIC_DART(56, 30.0, 0, 1575, null, 328, 329),
    
    		EARTH_BLAST(58, 31.5, 150, 14222, new Graphics(2715), 2720, 2725, EARTH_SPELL),
    
    		FIRE_BLAST(63, 34.5, 160, 14223, new Graphics(2728), 2733, 2739, FIRE_SPELL),
    
    		SARADOMIN_STRIKE(66, 35.0, 200, 811, null, -1, 76),
    
    		CLAWS_OF_GUTHIX(67, 35.0, 200, 811, null, -1, 77),
    
    		FLAMES_OF_ZAMORAK(68, 35.0, 200, 811, null, -1, 78),
    
    		WIND_WAVE(70, 36.0, 170, -1, null, 2699, 2700, AIR_SPELL),
    
    		WATER_WAVE(73, 37.5, 180, 14220, new Graphics(2702), 2706, 2710, WATER_SPELL),
    
    		EARTH_WAVE(77, 40.0, 190, 14222, new Graphics(2716), 2721, 2726, EARTH_SPELL),
    
    		FIRE_WAVE(80, 42.5, 200, 14223, new Graphics(2728), 2735, 2740, FIRE_SPELL),
    
    		WIND_SURGE(84, 44.5, 220, 10546, new Graphics(457), 462, 2700, AIR_SPELL),
    
    		WATER_SURGE(87, 46.5, 240, 10542, new Graphics(2701), 2707, 2712, WATER_SPELL),
    
    		EARTH_SURGE(89, 48.5, 260, 14209, new Graphics(2717), 2722, 2727, EARTH_SPELL),
    
    		FIRE_SURGE(91, 50.5, 280, 2791, new Graphics(2728), new int[] { 2735, 2736 }, 2741, FIRE_SPELL),
    
    		STORM_OF_ARMADYL(99, 70, 0, 10546, new Graphics(457), 1019, 1019),
    
    		CONFUSE(26, 13.0, 1, 710, new Graphics(102, 0, 100), 103, 104),
    
    		WEAKEN(31, 21.0, 1, 710, new Graphics(105, 0, 100), 106, 107),
    
    		CURSE(35, 29.0, 1, 710, new Graphics(108, 0, 100), 109, 110),
    
    		VULNERABILITY(75, 76.0, 1, 710, new Graphics(167, 0, 100), 168, 169),
    
    		ENFEEBLE(78, 83.0, 1, 710, new Graphics(170, 0, 100), 171, 172),
    
    		STUN(82, 90.0, 1, 710, new Graphics(173, 0, 100), 174, 107),
    
    		BIND(36, 30.0, 20, 710, new Graphics(177, 0, 100), 178, 179),
    
    		SNARE(55, 60.0, 30, 710, new Graphics(177, 0, 100), 178, 180),
    
    		ENTANGLE(81, 90.0, 50, 710, new Graphics(177, 0, 100), 178, 181),
    
    		TELEPORT_BLOCK(86, 80, 30, 10503, new Graphics(1841), 1842, 1843);
    
    		private int id;
    		private double xp;
    		private int baseDamage;
    		private int animation;
    		private Graphics startGfx;
    		private int projectileId;
    		private int[] projectiles;
    		private int endGfx;
    		private int spell_type;
    
    		public static ModernCombatSpellsStore getSpell(int i) {
    			for (ModernCombatSpellsStore s : ModernCombatSpellsStore.values()) {
    				if (s.getId() == i)
    					return s;
    			}
    			return null;
    		}
    
    		private ModernCombatSpellsStore(int id, double xp, int baseDamage, int animation, Graphics startGfx,
    				int[] projectiles, int endGfx) {
    			this.setId(id);
    			this.setXp(xp);
    			this.setBaseDamage(baseDamage);
    			this.setAnimation(animation);
    			this.setStartGfx(startGfx);
    			this.setProjectiles(projectiles);
    			this.setEndGfx(endGfx);
    		}
    
    		private ModernCombatSpellsStore(int id, double xp, int baseDamage, int animation, Graphics startGfx,
    				int[] projectiles, int endGfx, int spell_type) {
    			this.setId(id);
    			this.setXp(xp);
    			this.setBaseDamage(baseDamage);
    			this.setAnimation(animation);
    			this.setStartGfx(startGfx);
    			this.setProjectiles(projectiles);
    			this.setEndGfx(endGfx);
    			this.setSpellType(spell_type);
    		}
    
    		private ModernCombatSpellsStore(int id, double xp, int baseDamage, int animation, Graphics startGfx,
    				int projectileId, int endGfx, int spell_type) {
    			this.setId(id);
    			this.setXp(xp);
    			this.setBaseDamage(baseDamage);
    			this.setAnimation(animation);
    			this.setStartGfx(startGfx);
    			this.setProjectileId(projectileId);
    			this.setEndGfx(endGfx);
    			this.setSpellType(spell_type);
    		}
    
    		private ModernCombatSpellsStore(int id, double xp, int baseDamage, int animation, Graphics startGfx,
    				int projectileId, int endGfx) {
    			this.setId(id);
    			this.setXp(xp);
    			this.setBaseDamage(baseDamage);
    			this.setAnimation(animation);
    			this.setStartGfx(startGfx);
    			this.setProjectileId(projectileId);
    			this.setEndGfx(endGfx);
    		}
    
    		public int getId() {
    			return id;
    		}
    
    		public void setId(int id) {
    			this.id = id;
    		}
    
    		public double getXp() {
    			return xp;
    		}
    
    		public void setXp(double xp) {
    			this.xp = xp;
    		}
    
    		public int getBaseDamage() {
    			return baseDamage;
    		}
    
    		public void setBaseDamage(int baseDamage) {
    			this.baseDamage = baseDamage;
    		}
    
    		public Graphics getStartGfx() {
    			return startGfx;
    		}
    
    		public void setStartGfx(Graphics startGfx) {
    			this.startGfx = startGfx;
    		}
    
    		public int getProjectileId() {
    			return projectileId;
    		}
    
    		public void setProjectileId(int projectileId) {
    			this.projectileId = projectileId;
    		}
    
    		public int getEndGfx() {
    			return endGfx;
    		}
    
    		public void setEndGfx(int endGfx) {
    			this.endGfx = endGfx;
    		}
    
    		public int getAnimation() {
    			return animation;
    		}
    
    		public void setAnimation(int animation) {
    			this.animation = animation;
    		}
    
    		public int[] getProjectiles() {
    			return projectiles;
    		}
    
    		public void setProjectiles(int[] projectiles) {
    			this.projectiles = projectiles;
    		}
    
    		public int getSpellType() {
    			return spell_type;
    		}
    
    		public void setSpellType(int spell_type) {
    			this.spell_type = spell_type;
    		}
    	}
    
    	public static int getDamageBoost(Player player, int spellId, int baseDamage) {
    		if (spellId == 99) {
    			int minDamage = 160 + (player.getSkills().getLevelForXp(Skills.MAGIC) - 77) * 5;
    			int boost = (player.getSkills().getLevelForXp(Skills.MAGIC) - 77) * 5;
    			int hit = minDamage + boost;
    			if (hit > 0 && hit < boost)
    				hit += boost;
    			return hit;
    		} else if (spellId == 34 || spellId == 39 || spellId == 42 || spellId == 45) {
    			if (player.getEquipment().getGlovesId() == 777) {
    				return baseDamage + 30;
    			}
    		} else if (spellId == 56) {
    			return (player.getSkills().getLevel(Skills.MAGIC) / 10) * 10 + 100;
    		}
    		return 0;
    	}
    
    	public static void instantSpellEffect(Player player, Entity target, int spellId, boolean successHit) {
    		if (spellId == 86) {
    			if (target instanceof Player) {
    				Player p2 = (Player) target;
    				PlayerCombat.teleBlockTime = (p2.getPrayer().usingPrayer(0, 17) || p2.getPrayer().usingPrayer(1, 7)
    						? 150000
    						: 300000);
    			}
    		} else if (spellId == 36) {
    			if (successHit) {
    				target.addFreezeDelay(5000, true);
    			}
    		} else if (spellId == 55) {
    			if (successHit) {
    				target.addFreezeDelay(10000, true);
    			}
    		} else if (spellId == 81) {
    			if (successHit) {
    				target.addFreezeDelay(15000, true);
    			}
    		}
    	}
    
    	public static void handleSpellEffect(Player player, Entity target, String spell_name) {
    		if (player.getCombatDefinitions().getSpellBook() != 192)
    			return;
    		if (spell_name.equalsIgnoreCase("confuse")) {
    			if (target instanceof Player) {
    				Player p2 = (Player) target;
    				p2.getPackets().sendGameMessage("Your attack level was drained by enemies confuse spell.");
    				p2.getSkills().drainLevel(Skills.ATTACK, (int) (p2.getSkills().getLevel(Skills.ATTACK) * 0.05));
    			}
    		} else if (spell_name.equalsIgnoreCase("weaken")) {
    			if (target instanceof Player) {
    				Player p2 = (Player) target;
    				p2.getPackets().sendGameMessage("Your strength level was drained by enemies weaken spell.");
    				p2.getSkills().drainLevel(Skills.STRENGTH, (int) (p2.getSkills().getLevel(Skills.STRENGTH) * 0.05));
    			}
    		} else if (spell_name.equalsIgnoreCase("curse")) {
    			if (target instanceof Player) {
    				Player p2 = (Player) target;
    				p2.getPackets().sendGameMessage("Your defence level was drained by enemies curse spell.");
    				p2.getSkills().drainLevel(Skills.DEFENCE, (int) (p2.getSkills().getLevel(Skills.DEFENCE) * 0.05));
    			}
    		} else if (spell_name.equalsIgnoreCase("stun")) {
    			if (target instanceof Player) {
    				Player p2 = (Player) target;
    				p2.getPackets().sendGameMessage("Your attack level was drained by enemies stun spell.");
    				p2.getSkills().drainLevel(Skills.ATTACK, (int) (p2.getSkills().getLevel(Skills.ATTACK) * 0.10));
    			}
    		} else if (spell_name.equalsIgnoreCase("enfeeble")) {
    			if (target instanceof Player) {
    				Player p2 = (Player) target;
    				p2.getPackets().sendGameMessage("Your strength level was drained by enemies enfeeble spell.");
    				p2.getSkills().drainLevel(Skills.STRENGTH, (int) (p2.getSkills().getLevel(Skills.STRENGTH) * 0.10));
    			}
    		} else if (spell_name.equalsIgnoreCase("vulnerability")) {
    			if (target instanceof Player) {
    				Player p2 = (Player) target;
    				p2.getPackets().sendGameMessage("Your defence level was drained by enemies vulnerability spell.");
    				p2.getSkills().drainLevel(Skills.DEFENCE, (int) (p2.getSkills().getLevel(Skills.DEFENCE) * 0.10));
    			}
    		} else if (spell_name.equalsIgnoreCase("saradomin_strike")) {
    			if (target instanceof Player) {
    				Player p2 = (Player) target;
    				p2.getPrayer().drainPrayer(10);
    			}
    		} else if (spell_name.equalsIgnoreCase("claws_of_guthix")) {
    			if (target instanceof Player) {
    				Player p2 = (Player) target;
    				p2.getSkills().drainLevel(Skills.DEFENCE, (int) (p2.getSkills().getLevel(Skills.DEFENCE) * 0.05));
    			}
    		} else if (spell_name.equalsIgnoreCase("flames_of_zamorak")) {
    			if (target instanceof Player) {
    				Player p2 = (Player) target;
    				p2.getSkills().drainLevel(Skills.MAGIC, (int) (p2.getSkills().getLevel(Skills.MAGIC) * 0.05));
    			}
    		}
    	}
    }
    AvalonPK Developer
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    van 't stad

    Shnek's Avatar
    Join Date
    Oct 2013
    Posts
    1,007
    Thanks given
    307
    Thanks received
    238
    Rep Power
    81
    Good release, maybe try using Lombok. Would save all this code
    [Only registered and activated users can see links. ]
    Code:
     
    public int getId() {
    			return id;
    		}
    
    		public void setId(int id) {
    			this.id = id;
    		}
    
    		public double getXp() {
    			return xp;
    		}
    
    		public void setXp(double xp) {
    			this.xp = xp;
    		}
    
    		public int getBaseDamage() {
    			return baseDamage;
    		}
    
    		public void setBaseDamage(int baseDamage) {
    			this.baseDamage = baseDamage;
    		}
    
    		public Graphics getStartGfx() {
    			return startGfx;
    		}
    
    		public void setStartGfx(Graphics startGfx) {
    			this.startGfx = startGfx;
    		}
    
    		public int getProjectileId() {
    			return projectileId;
    		}
    
    		public void setProjectileId(int projectileId) {
    			this.projectileId = projectileId;
    		}
    
    		public int getEndGfx() {
    			return endGfx;
    		}
    
    		public void setEndGfx(int endGfx) {
    			this.endGfx = endGfx;
    		}
    
    		public int getAnimation() {
    			return animation;
    		}
    
    		public void setAnimation(int animation) {
    			this.animation = animation;
    		}
    
    		public int[] getProjectiles() {
    			return projectiles;
    		}
    
    		public void setProjectiles(int[] projectiles) {
    			this.projectiles = projectiles;
    		}
    
    		public int getSpellType() {
    			return spell_type;
    		}
    
    		public void setSpellType(int spell_type) {
    			this.spell_type = spell_type;
    		}


    Do not use the vps from ovh, blocking vps without reason and no customer support
    Reply With Quote  
     

  4. Thankful users:


  5. #3  
    Registered Member

    Join Date
    Mar 2011
    Age
    23
    Posts
    512
    Thanks given
    128
    Thanks received
    129
    Rep Power
    100
    Ancients

    Code:
    package com.rs.game.player.actions.combat.ancientspells;
    
    import com.rs.game.Entity;
    import com.rs.game.Graphics;
    import com.rs.game.player.Player;
    import com.rs.game.player.Skills;
    import com.rs.game.tasks.WorldTask;
    import com.rs.game.tasks.WorldTasksManager;
    import com.rs.utils.Utils;
    
    public class RSAncientCombatSpells {//this gets the data from spells
    
    	/*
    	 * @author -Andreas
    	 * 
    	 * @2018-06-21
    	 */
    
    	private static final int SMOKE_SPELL = 4, SHADOW_SPELL = 5, BLOOD_SPELL = 6, ICE_SPELL = 7, MIASMIC_SPELL = 8;
    
    	public static enum AncientCombatSpellsStore {
    
    		SMOKE_RUSH(28, 30.0, 150, 1978, null, 386, 385, SMOKE_SPELL),
    
    		SHADOW_RUSH(32, 31.0, 160, 1978, null, 380, 379, SHADOW_SPELL),
    
    		BLOOD_RUSH(24, 33.0, 170, 1978, null, 374, 373, BLOOD_SPELL),
    
    		ICE_RUSH(20, 34.0, 180, 1978, null, 362, 361, ICE_SPELL),
    
    		MIASMIC_RUSH(36, 35.0, 200, 10513, new Graphics(1845), 1846, 1847, MIASMIC_SPELL),
    
    		SMOKE_BURST(30, 36.0, 190, 1979, null, -1, 389, true, SMOKE_SPELL),
    
    		SHADOW_BURST(34, 37.0, 200, 1979, null, -1, 383, true, SHADOW_SPELL),
    
    		BLOOD_BURST(26, 39.0, 210, 1979, null, -1, 376, true, BLOOD_SPELL),
    
    		ICE_BURST(22, 46.0, 220, 1979, null, 366, 363, true, ICE_SPELL),
    
    		MIASMIC_BURST(38, 42.0, 240, 10516, new Graphics(1848), -1, 1849, true, MIASMIC_SPELL),
    
    		SMOKE_BLITZ(29, 42.0, 230, 1978, null, 386, 387, SMOKE_SPELL),
    
    		SHADOW_BLITZ(33, 43.0, 240, 1978, null, 380, 381, SHADOW_SPELL),
    
    		BLOOD_BLITZ(25, 45.0, 250, 1978, null, 374, 375, BLOOD_SPELL),
    
    		ICE_BLITZ(21, 46.0, 260, 1978, new Graphics(366), 368, 367, ICE_SPELL),
    
    		MIASMIC_BLITZ(37, 48.0, 280, 10524, new Graphics(1850), 1852, 1851, MIASMIC_SPELL),
    
    		SMOKE_BARRAGE(31, 48.0, 270, 1979, null, 390, 391, true, SMOKE_SPELL),
    
    		SHADOW_BARRAGE(35, 49.0, 280, 1979, null, -1, 383, true, SHADOW_SPELL),
    
    		BLOOD_BARRAGE(27, 51.0, 290, 1979, null, -1, 377, true, BLOOD_SPELL),
    
    		ICE_BARRAGE(23, 52.0, 300, 1979, null, 368, 369, true, ICE_SPELL),
    
    		MIASMIC_BARRAGE(39, 54.0, 320, 10518, new Graphics(1853), -1, 1854, true, MIASMIC_SPELL),;
    
    		private int id;
    		private double xp;
    		private int baseDamage;
    		private int animation;
    		private Graphics startGfx;
    		private int projectileId;
    		private int[] projectiles;
    		private int endGfx;
    		private int spell_type;
    		private boolean multi_spell;
    
    		public static AncientCombatSpellsStore getSpell(int i) {
    			for (AncientCombatSpellsStore s : AncientCombatSpellsStore.values()) {
    				if (s.getId() == i)
    					return s;
    			}
    			return null;
    		}
    
    		private AncientCombatSpellsStore(int id, double xp, int baseDamage, int animation, Graphics startGfx,
    				int projectileId, int endGfx, boolean multi_spell, int spell_type) {
    			this.setId(id);
    			this.setXp(xp);
    			this.setBaseDamage(baseDamage);
    			this.setAnimation(animation);
    			this.setStartGfx(startGfx);
    			this.setProjectileId(projectileId);
    			this.setEndGfx(endGfx);
    			this.setMulti_spell(multi_spell);
    			this.setSpellType(spell_type);
    		}
    
    		private AncientCombatSpellsStore(int id, double xp, int baseDamage, int animation, Graphics startGfx,
    				int projectileId, int endGfx, int spell_type) {
    			this.setId(id);
    			this.setXp(xp);
    			this.setBaseDamage(baseDamage);
    			this.setAnimation(animation);
    			this.setStartGfx(startGfx);
    			this.setProjectileId(projectileId);
    			this.setEndGfx(endGfx);
    			this.setSpellType(spell_type);
    		}
    
    		public int getId() {
    			return id;
    		}
    
    		public void setId(int id) {
    			this.id = id;
    		}
    
    		public double getXp() {
    			return xp;
    		}
    
    		public void setXp(double xp) {
    			this.xp = xp;
    		}
    
    		public int getBaseDamage() {
    			return baseDamage;
    		}
    
    		public void setBaseDamage(int baseDamage) {
    			this.baseDamage = baseDamage;
    		}
    
    		public Graphics getStartGfx() {
    			return startGfx;
    		}
    
    		public void setStartGfx(Graphics startGfx) {
    			this.startGfx = startGfx;
    		}
    
    		public int getProjectileId() {
    			return projectileId;
    		}
    
    		public void setProjectileId(int projectileId) {
    			this.projectileId = projectileId;
    		}
    
    		public int getEndGfx() {
    			return endGfx;
    		}
    
    		public void setEndGfx(int endGfx) {
    			this.endGfx = endGfx;
    		}
    
    		public int getAnimation() {
    			return animation;
    		}
    
    		public void setAnimation(int animation) {
    			this.animation = animation;
    		}
    
    		public int[] getProjectiles() {
    			return projectiles;
    		}
    
    		public void setProjectiles(int[] projectiles) {
    			this.projectiles = projectiles;
    		}
    
    		public int getSpellType() {
    			return spell_type;
    		}
    
    		public void setSpellType(int spell_type) {
    			this.spell_type = spell_type;
    		}
    
    		public boolean isMulti_spell() {
    			return multi_spell;
    		}
    
    		public void setMulti_spell(boolean multi_spell) {
    			this.multi_spell = multi_spell;
    		}
    	}
    
    	public static void instantSpellEffect(Player player, Entity target, int damage, AncientCombatSpellsStore spell) {
    		if (spell.getSpellType() == SMOKE_SPELL) {
    			target.getPoison().makePoisoned(spell.getId() == 28 || spell.getId() == 30 ? 20 : 40);
    		}
    		if (spell.getSpellType() == SHADOW_SPELL) {
    			if (target instanceof Player) {
    				Player p2 = (Player) target;
    				p2.getSkills().drainLevel(Skills.ATTACK, (int) ((int) p2.getSkills().getLevel(Skills.ATTACK)
    						* (spell.getId() == 32 || spell.getId() == 34 ? 0.10 : 0.15)));
    			}
    
    		}
    		if (spell.getSpellType() == BLOOD_SPELL) {
    			player.heal(damage / 4);
    		}
    		if (spell.getSpellType() == ICE_SPELL) {
    			if (target.getSize() < 2 && target.getFreezeDelay() < Utils.currentTimeMillis()
    					&& target.getFrozenBlockedDelay() < Utils.currentTimeMillis()) {
    				int freeze_time = spell.getId() == 20 ? 5000
    						: spell.getId() == 21 ? 10000 : spell.getId() == 22 ? 15000 : 20000;
    				if (damage > 0) {
    					target.addFreezeDelay(freeze_time, false);
    					target.addFrozenBlockedDelay(freeze_time + (10 * 1000));
    				}
    			}
    		}
    		if (spell.getSpellType() == MIASMIC_SPELL) {
    			if (target.temporaryAttribute().get("miasmic_immunity") == Boolean.FALSE) {
    				if (target instanceof Player) {
    					Player p2 = (Player) target;
    					p2.getPackets().sendGameMessage("You feel slowed down.");
    				}
    				target.temporaryAttribute().put("miasmic_immunity", Boolean.TRUE);
    				target.temporaryAttribute().put("miasmic_effect", Boolean.TRUE);
    				final Entity t = target;
    				WorldTasksManager.schedule(new WorldTask() {
    					@Override
    					public void run() {
    						t.temporaryAttribute().remove("miasmic_effect");
    						WorldTasksManager.schedule(new WorldTask() {
    							@Override
    							public void run() {
    								t.temporaryAttribute().remove("miasmic_immunity");
    								stop();
    							}
    						}, 15);
    						stop();
    					}
    				}, 20);
    			}
    		}
    	}
    
    }
    AvalonPK Developer
    Reply With Quote  
     

  6. #4  
    Registered Member
    Tommeh's Avatar
    Join Date
    Nov 2015
    Age
    20
    Posts
    1,927
    Thanks given
    307
    Thanks received
    957
    Rep Power
    5000
    that's a lot of if statements
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  7. Thankful user:


  8. #5  
    Donator


    Join Date
    Jan 2014
    Posts
    1,643
    Thanks given
    423
    Thanks received
    494
    Rep Power
    221
    You should consider using if else, for example, if you have a smoke spell it'll still check 4 other conditions.
    Reply With Quote  
     

  9. Thankful user:


  10. #6  
    Registered Member
    Join Date
    May 2015
    Posts
    127
    Thanks given
    36
    Thanks received
    5
    Rep Power
    11
    Thanks, -Andreas.
    Reply With Quote  
     

  11. #7  
    Registered Member

    Join Date
    Mar 2011
    Age
    23
    Posts
    512
    Thanks given
    128
    Thanks received
    129
    Rep Power
    100
    Just incase anyone wanted cases instead of if statements

    Code:
    	public static int getDamageBoost(Player player, int spellId, int baseDamage) {
    		switch (spellId) {
    		case 99:
    			int minDamage = 160 + (player.getSkills().getLevelForXp(Skills.MAGIC) - 77) * 5;
    			int boost = (player.getSkills().getLevelForXp(Skills.MAGIC) - 77) * 5;
    			int hit = minDamage + boost;
    			if (hit > 0 && hit < boost)
    				hit += boost;
    			return hit;
    		case 34:
    		case 39:
    		case 42:
    		case 45:
    			if (player.getEquipment().getGlovesId() == 777)
    				return baseDamage + 30;
    		case 56:
    			return (player.getSkills().getLevel(Skills.MAGIC) / 10) * 10 + 100;
    		}
    		return 0;
    	}
    
    	public static void instantSpellEffect(Player player, Entity target, int spellId, boolean successHit) {
    		switch (spellId) {
    		case 86:
    			if (target instanceof Player && successHit) {
    				Player p2 = (Player) target;
    				PlayerCombat.teleBlockTime = (p2.getPrayer().usingPrayer(0, 17) || p2.getPrayer().usingPrayer(1, 7)
    						? 150000
    						: 300000);
    			}
    			break;
    		case 36:
    		case 55:
    		case 81:
    			if (successHit)
    				target.addFreezeDelay(spellId == 36 ? 5000 : spellId == 55 ? 10000 : 15000, true);
    			break;
    		}
    	}
    AvalonPK Developer
    Reply With Quote  
     

  12. Thankful user:


  13. #8  
    Mug Club


    Join Date
    Jul 2011
    Age
    24
    Posts
    1,701
    Thanks given
    484
    Thanks received
    790
    Rep Power
    189
    Quote Originally Posted by Shnek View Post
    Good release, maybe try using Lombok. Would save all this code
    [Only registered and activated users can see links. ]
    Code:
     
    public int getId() {
    			return id;
    		}
    
    		public void setId(int id) {
    			this.id = id;
    		}
    
    		public double getXp() {
    			return xp;
    		}
    
    		public void setXp(double xp) {
    			this.xp = xp;
    		}
    
    		public int getBaseDamage() {
    			return baseDamage;
    		}
    
    		public void setBaseDamage(int baseDamage) {
    			this.baseDamage = baseDamage;
    		}
    
    		public Graphics getStartGfx() {
    			return startGfx;
    		}
    
    		public void setStartGfx(Graphics startGfx) {
    			this.startGfx = startGfx;
    		}
    
    		public int getProjectileId() {
    			return projectileId;
    		}
    
    		public void setProjectileId(int projectileId) {
    			this.projectileId = projectileId;
    		}
    
    		public int getEndGfx() {
    			return endGfx;
    		}
    
    		public void setEndGfx(int endGfx) {
    			this.endGfx = endGfx;
    		}
    
    		public int getAnimation() {
    			return animation;
    		}
    
    		public void setAnimation(int animation) {
    			this.animation = animation;
    		}
    
    		public int[] getProjectiles() {
    			return projectiles;
    		}
    
    		public void setProjectiles(int[] projectiles) {
    			this.projectiles = projectiles;
    		}
    
    		public int getSpellType() {
    			return spell_type;
    		}
    
    		public void setSpellType(int spell_type) {
    			this.spell_type = spell_type;
    		}
    It's all automatically generated in the end either way. It serves such small convenience for having to include that package in your project. These libraries like lombok or even Kotlin turning Java into Javascript are starting to make me sick. Just use NodeJS at that point if Java is just too verbose or if it's too much work to click "generate getters and setters" in any modern IDE.
    Reply With Quote  
     

  14. #9  
    Super Donator

    Tyluur's Avatar
    Join Date
    Jun 2010
    Posts
    4,000
    Thanks given
    1,348
    Thanks received
    1,239
    Rep Power
    564
    Quote Originally Posted by Makar View Post
    It's all automatically generated in the end either way. It serves such small convenience for having to include that package in your project. These libraries like lombok or even Kotlin turning Java into Javascript are starting to make me sick. Just use NodeJS at that point if Java is just too verbose or if it's too much work to click "generate getters and setters" in any modern IDE.
    I think you're missing the point. Lombok replaces the 50+ lines of code with annotations, and Kotlin removes that completely with [Only registered and activated users can see links. ]. If you use maven or gradle, including libraries like Lombok is a 10-30 second job. Definitely worth the "hassle".
    [Only registered and activated users can see links. ]

    Quote Originally Posted by Velocity View Post
    i'd love to get called in the middle of the night just to hear an indian voice whisper "the nulls are back friend, how i fix"
    Reply With Quote  
     

  15. Thankful users:


  16. #10  
    Mug Club


    Join Date
    Jul 2011
    Age
    24
    Posts
    1,701
    Thanks given
    484
    Thanks received
    790
    Rep Power
    189
    Quote Originally Posted by Tyluur View Post
    I think you're missing the point. Lombok replaces the 50+ lines of code with annotations, and Kotlin removes that completely with [Only registered and activated users can see links. ]. If you use maven or gradle, including libraries like Lombok is a 10-30 second job. Definitely worth the "hassle".
    I am not missing the point, I completely understand lombok and how it works. If it was as easy as adding a maven dependency and doing nothing else, then sure I might be for it (regardless of the fact it is the same thing as just making data fields public...). It does require IDE plugins to use as well if you want intellisense, not just a simple build path addition. Also, the baseline of my argument isn't about how convenient or inconvenient it is to use. It is about my hate for how weakly typed Java is becoming for convenience (mostly Kotlin and the newer var garbage). People here used to be overly and rightly obsessed with saving every nanosecond possible and now chaining 500 stream filters, maps, and reduces is totally fine since it's 1 line long and debatably, "easier to understand", rather than 40 lines long in a single loop through the structure. If this was front end web development, small app development (like bots for example), or casual back-end, I wouldn't care at all, but highly scalable game development I refuse to listen to any "readable/shorthand" excuse. This is mainly aimed at Kotlin, by the way, as I know lombok has little effect on performance, but it is the direction it moves it in. I'm perfectly fine just making fields public if there is going to be zero validation on the data class whatsoever, makes no difference either way, one just requires a black box, build process modifying, IDE plugin requiring library.
    Reply With Quote  
     

  17. Thankful user:


Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •