cosmetics recharge slowdown

This commit is contained in:
Cheese 2015-12-01 11:38:52 +11:00
parent 1a1fa684e4
commit 208eaf3a01
15 changed files with 61 additions and 23 deletions

View File

@ -30,7 +30,7 @@ public class ItemFirework extends ItemGadget
},
-1,
Material.FIREWORK, (byte)0,
250, new Ammo("Fireworks", "50 Fireworks", Material.FIREWORK, (byte)0, new String[] { C.cWhite + "50 Fireworks for you to launch!" }, 500, 50));
500, new Ammo("Fireworks", "50 Fireworks", Material.FIREWORK, (byte)0, new String[] { C.cWhite + "50 Fireworks for you to launch!" }, 500, 50));
}
@Override

View File

@ -140,7 +140,7 @@ public class ItemMelonLauncher extends ItemGadget implements IThrown
{
Item melon = melonIterator.next();
if (melon.isDead() || !melon.isValid() || melon.getTicksLived() > 400)
if (melon.isDead() || !melon.isValid() || melon.getTicksLived() > 100)
{
melonIterator.remove();
melon.remove();

View File

@ -70,7 +70,7 @@ public class ItemTNT extends ItemGadget
double mult = players.get(player);
//Knockback
UtilAction.velocity(player, UtilAlg.getTrajectory(event.getLocation(), player.getLocation()), 2 * mult, false, 0, 0.5 + 1 * mult, 10, true);
UtilAction.velocity(player, UtilAlg.getTrajectory(event.getLocation(), player.getLocation()), 1 * mult, false, 0, 0.5 + 0.5 * mult, 10, true);
}
// Simulating explosion to prevent water from being evaporated.

View File

@ -85,7 +85,7 @@ public class MorphBat extends MorphGadget implements IThrown
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 100, false, false))
if (!Recharge.Instance.use(player, GetName(), 100, false, false, "Cosmetics"))
return;
//Effect
@ -106,7 +106,7 @@ public class MorphBat extends MorphGadget implements IThrown
if (!IsActive(player))
return;
if (!Recharge.Instance.use(player, "Poop", 4000, true, false))
if (!Recharge.Instance.use(player, "Poop", 4000, true, false, "Cosmetics"))
return;
//Action

View File

@ -76,7 +76,7 @@ public class MorphChicken extends MorphGadget
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 100, false, false))
if (!Recharge.Instance.use(player, GetName(), 100, false, false, "Cosmetics"))
return;
Vector offset = player.getLocation().getDirection();

View File

@ -57,7 +57,7 @@ public class MorphCow extends MorphGadget
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 2500, false, false))
if (!Recharge.Instance.use(player, GetName(), 2500, false, false, "Cosmetics"))
return;
player.getWorld().playSound(player.getLocation(), Sound.COW_IDLE, 1f, 1f);

View File

@ -119,7 +119,7 @@ public class MorphCreeper extends MorphGadget
double mult = players.get(other);
//Knockback
UtilAction.velocity(other, UtilAlg.getTrajectory(player.getLocation(), other.getLocation()), 1 + 1.5 * mult, false, 0, 0.5 + 1 * mult, 3, true);
UtilAction.velocity(other, UtilAlg.getTrajectory(player.getLocation(), other.getLocation()), 1 + 1 * mult, false, 0, 0.6 + 0.6 * mult, 3, true);
}
}
}

View File

@ -78,7 +78,7 @@ public class MorphEnderman extends MorphGadget
player.setAllowFlight(false);
//Set Recharge
Recharge.Instance.use(player, GetName(), 2000, false, false);
Recharge.Instance.use(player, GetName(), 2000, false, false, "Cosmetics");
//Smoke Trail
Block lastSmoke = player.getLocation().getBlock();

View File

@ -73,7 +73,7 @@ public class MorphPig extends MorphGadget
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 400, false, false))
if (!Recharge.Instance.use(player, GetName(), 400, false, false, "Cosmetics"))
return;
player.getWorld().playSound(player.getLocation(), Sound.PIG_IDLE, 1f, (float)(0.75 + Math.random() * 0.5));

View File

@ -83,7 +83,7 @@ public class MorphSlime extends MorphGadget
if (!UtilEnt.isGrounded(player))
return;
if (!Recharge.Instance.use(player, GetName(), 1000, false, false))
if (!Recharge.Instance.use(player, GetName(), 1000, false, false, "Cosmetics"))
return;
player.getWorld().playSound(player.getLocation(), Sound.SLIME_ATTACK, 1f, 1f);

View File

@ -94,7 +94,7 @@ public class MorphTitan extends MorphGadget
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, "Guardians Laser", 4000, true, false))
if (!Recharge.Instance.use(player, "Guardians Laser", 6000, true, false, "Cosmetics"))
return;
DisguiseBase base = Manager.getDisguiseManager().getDisguise(player);
@ -148,7 +148,7 @@ public class MorphTitan extends MorphGadget
double mult = players.get(ent);
//Knockback
UtilAction.velocity(ent, UtilAlg.getTrajectory(stand.getLocation(), ent.getLocation()), 3 * mult, false, 0, 1 + 2 * mult, 10, true);
UtilAction.velocity(ent, UtilAlg.getTrajectory(stand.getLocation(), ent.getLocation()), 2 * mult, false, 0, 1 + 1 * mult, 10, true);
}
//Sound

View File

@ -87,7 +87,7 @@ public class MorphVillager extends MorphGadget implements IThrown
return;
}
if (!Recharge.Instance.use(player, GetName(), 800, false, false))
if (!Recharge.Instance.use(player, GetName(), 800, false, false, "Cosmetics"))
return;
player.getWorld().playSound(player.getLocation(), Sound.VILLAGER_IDLE, 1f, 1f);

View File

@ -96,7 +96,7 @@ public class MorphWither extends MorphGadget
if (!UtilEvent.isAction(event, ActionType.L))
return;
if (!Recharge.Instance.use(player, GetName(), 1600, false, false))
if (!Recharge.Instance.use(player, GetName(), 2500, false, false, "Cosmetics"))
return;
Vector offset = player.getLocation().getDirection();

View File

@ -153,7 +153,7 @@ public abstract class ItemGadget extends Gadget
}
//Recharge
if (!Recharge.Instance.use(player, GetName(), _recharge, _recharge > 1000, false))
if (!Recharge.Instance.use(player, GetName(), GetName(), _recharge, _recharge > 1000, true, false, true, "Cosmetics"))
{
UtilInv.Update(player);
return;

View File

@ -29,6 +29,9 @@ public class Recharge extends MiniPlugin
public HashSet<String> informSet = new HashSet<String>();
public NautHashMap<String, NautHashMap<String, RechargeData>> _recharge = new NautHashMap<String, NautHashMap<String, RechargeData>>();
//Used to increase cooldown when gadgets are being spammed
public NautHashMap<String, ArrayList<Long>> _gadgetSlow = new NautHashMap<String, ArrayList<Long>>();
protected Recharge(JavaPlugin plugin)
{
super("Recharge", plugin);
@ -76,10 +79,22 @@ public class Recharge extends MiniPlugin
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (event.getType() == UpdateType.TICK)
recharge();
recharge();
if (event.getType() == UpdateType.SLOW)
for (ArrayList<Long> times : _gadgetSlow.values())
{
Iterator<Long> timeIter = times.iterator();
while (timeIter.hasNext())
{
long time = timeIter.next();
if (UtilTime.elapsed(time, 20000))
timeIter.remove();
}
}
}
public void recharge()
@ -112,24 +127,43 @@ public class Recharge extends MiniPlugin
public boolean use(Player player, String ability, long recharge, boolean inform, boolean attachItem)
{
return use(player, ability, ability, recharge, inform, attachItem);
return use(player, ability, ability, recharge, inform, attachItem, false, true, null);
}
public boolean use(Player player, String ability, long recharge, boolean inform, boolean attachItem, String cooldownPool)
{
return use(player, ability, ability, recharge, inform, attachItem, false, true, cooldownPool);
}
public boolean use(Player player, String ability, String abilityFull, long recharge, boolean inform, boolean attachItem)
{
return use(player, ability, abilityFull, recharge, inform, attachItem, false, true);
return use(player, ability, abilityFull, recharge, inform, attachItem, false, true, null);
}
public boolean use(Player player, String ability, long recharge, boolean inform, boolean attachItem, boolean attachDurability)
{
return use(player, ability, ability, recharge, inform, attachItem, attachDurability, true);
return use(player, ability, ability, recharge, inform, attachItem, attachDurability, true, null);
}
public boolean use(Player player, String ability, String abilityFull, long recharge, boolean inform,
boolean attachItem, boolean attachDurability, boolean clearOnDeath)
boolean attachItem, boolean attachDurability, boolean clearOnDeath, String cooldownPool)
{
if (recharge == 0)
return true;
//Cooldown Pool
if (cooldownPool != null)
{
if (!_gadgetSlow.containsKey(cooldownPool))
_gadgetSlow.put(cooldownPool, new ArrayList<Long>());
int count = _gadgetSlow.get(cooldownPool).size();
recharge += count * 40;
player.sendMessage("Cosmetics Last Minute: " + count);
player.sendMessage("Additional Cooldown: " + (count * 50) + "ms");
}
//Ensure Expirey
recharge();
@ -149,6 +183,10 @@ public class Recharge extends MiniPlugin
return false;
}
//Add Slow
if (cooldownPool != null)
_gadgetSlow.get(cooldownPool).add(System.currentTimeMillis());
//Insert
UseRecharge(player, ability, recharge, attachItem, attachDurability, clearOnDeath);