That's one heck of a commit you've got there...
I may have got a bit behind with version control. A lot behind, in fact. Maybe I'll go back and split this sometime - then again, I probably won't. But hey, at least it's here!
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
package electroblob.wizardry.spell;
|
||||
|
||||
import electroblob.wizardry.constants.Element;
|
||||
import electroblob.wizardry.constants.SpellType;
|
||||
import electroblob.wizardry.constants.Tier;
|
||||
import electroblob.wizardry.entity.living.EntityDecoy;
|
||||
import electroblob.wizardry.registry.WizardrySounds;
|
||||
import electroblob.wizardry.util.SpellModifiers;
|
||||
import electroblob.wizardry.util.WizardryUtilities;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
@@ -16,8 +12,13 @@ import net.minecraft.world.World;
|
||||
|
||||
public class Decoy extends Spell {
|
||||
|
||||
public static final String DECOY_LIFETIME = "decoy_lifetime";
|
||||
public static final String MOB_TRICK_CHANCE = "mob_trick_chance";
|
||||
|
||||
public Decoy(){
|
||||
super("decoy", Tier.ADVANCED, Element.SORCERY, SpellType.UTILITY, 40, 200, EnumAction.BOW, false);
|
||||
super("decoy", EnumAction.BOW, false);
|
||||
this.soundValues(1, 0.9f, 0.2f);
|
||||
addProperties(DECOY_LIFETIME, MOB_TRICK_CHANCE);
|
||||
}
|
||||
|
||||
@Override public boolean canBeCastByNPCs(){ return true; }
|
||||
@@ -28,7 +29,7 @@ public class Decoy extends Spell {
|
||||
// Uses the synchronised entity id to ensure it is consistent on client and server, but not always the same.
|
||||
double splitSpeed = caster.getEntityId() % 2 == 0 ? 0.3 : -0.3;
|
||||
spawnDecoy(world, caster, modifiers, splitSpeed);
|
||||
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
|
||||
this.playSound(world, caster, ticksInUse, -1, modifiers);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ public class Decoy extends Spell {
|
||||
// Determines whether the caster moves left and the decoy moves right, or vice versa.
|
||||
double splitSpeed = world.rand.nextBoolean() ? 0.3 : -0.3;
|
||||
spawnDecoy(world, caster, modifiers, splitSpeed);
|
||||
caster.playSound(WizardrySounds.SPELL_CONJURATION, 1.0F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
|
||||
this.playSound(world, caster, ticksInUse, -1, modifiers);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ public class Decoy extends Spell {
|
||||
if(!world.isRemote){
|
||||
EntityDecoy decoy = new EntityDecoy(world);
|
||||
decoy.setCaster(caster);
|
||||
decoy.setLifetime(600);
|
||||
decoy.setLifetime(getProperty(DECOY_LIFETIME).intValue());
|
||||
decoy.setLocationAndAngles(caster.posX, caster.posY, caster.posZ, caster.rotationYaw, caster.rotationPitch);
|
||||
decoy.addVelocity(-caster.getLookVec().z * splitSpeed, 0, caster.getLookVec().x * splitSpeed);
|
||||
// Ignores the show names setting, since this would allow a player to easily detect a decoy
|
||||
@@ -58,9 +59,11 @@ public class Decoy extends Spell {
|
||||
// Tricks any mobs that are targeting the caster into targeting the decoy instead.
|
||||
for(EntityLiving creature : WizardryUtilities.getEntitiesWithinRadius(16, caster.posX, caster.posY,
|
||||
caster.posZ, world, EntityLiving.class)){
|
||||
// More likely to trick mobs the higher the damage multiplier. Starts off at 50%.
|
||||
if(world.rand.nextInt((int)(6 * modifiers.get(SpellModifiers.POTENCY))) < 3){
|
||||
if(creature.getAttackTarget() == caster) creature.setAttackTarget(decoy);
|
||||
// More likely to trick mobs the higher the damage multiplier
|
||||
// The default base value is 0.5, so modifiers of 2 or more will guarantee mobs are tricked
|
||||
if(creature.getAttackTarget() == caster && world.rand.nextFloat()
|
||||
< getProperty(MOB_TRICK_CHANCE).floatValue() * modifiers.get(SpellModifiers.POTENCY)){
|
||||
creature.setAttackTarget(decoy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user