From 155a309c0029f2b974c6e536015973623e636a92 Mon Sep 17 00:00:00 2001 From: Ceikry Date: Mon, 30 Mar 2020 13:25:31 -0500 Subject: [PATCH] Revs fixed --- .../world/map/zone/impl/WildernessZone.java | 71 +++++++++++++++++++ .../src/plugin/npc/revenant/RevenantNPC.java | 9 +-- 2 files changed, 72 insertions(+), 8 deletions(-) diff --git a/Server/src/org/crandor/game/world/map/zone/impl/WildernessZone.java b/Server/src/org/crandor/game/world/map/zone/impl/WildernessZone.java index fd65491ed..3ebda760f 100644 --- a/Server/src/org/crandor/game/world/map/zone/impl/WildernessZone.java +++ b/Server/src/org/crandor/game/world/map/zone/impl/WildernessZone.java @@ -11,17 +11,24 @@ import org.crandor.game.node.entity.npc.agg.AggressiveBehavior; import org.crandor.game.node.entity.npc.agg.AggressiveHandler; import org.crandor.game.node.entity.player.Player; import org.crandor.game.node.entity.player.info.Rights; +import org.crandor.game.node.item.GroundItemManager; import org.crandor.game.node.item.Item; import org.crandor.game.world.map.Location; import org.crandor.game.world.map.zone.MapZone; import org.crandor.game.world.map.zone.RegionZone; import org.crandor.game.world.map.zone.ZoneBorders; +import org.crandor.game.world.repository.Repository; +import org.crandor.tools.RandomFunction; /** * Handles the wilderness zone. * @author Emperor */ public final class WildernessZone extends MapZone { + /** + * The PvP gear items + */ + private static int[] PVP_GEAR = { 13887, 13893, 13899, 13905, 13870, 13873, 13876, 13879, 13883, 13884, 13890, 13896, 13902, 13858, 13861, 13864, 13867}; /** * The wilderness zone. @@ -48,6 +55,70 @@ public final class WildernessZone extends MapZone { } } + /** + * calculate drop rate for rev items based on combat level + * @author ceik + * @param combatLevel + * @return + */ + public int getNewDropRate(int combatLevel){ + double x = combatLevel; + double A = 44044.5491; + double B = -7360.19548; + return (int) (A + (B * Math.log(x))); + } + + /** + * Handles rev drops + * @author ceik + * @param e The entity dying. + * @param killer The killer. + * @return true + */ + @Override + public boolean death(Entity e, Entity killer) { + if(e instanceof NPC && killer instanceof Player && (e.asNpc().getName().contains("Revenant") || e.asNpc().getName().equals("Chaos elemental"))){ + int combatLevel = e.asNpc().getDefinition().getCombatLevel(); + int dropRate = getNewDropRate(combatLevel); + for(int i = 0; i < PVP_GEAR.length; i++){ + boolean chance = RandomFunction.random(dropRate) == dropRate / 2; + if(chance){ + Item reward; + if(PVP_GEAR[i] == 13879 || PVP_GEAR[i] == 13883){ // checks if it's a javelin or throwing axe + reward = new Item(PVP_GEAR[i],RandomFunction.random(15,50)); + } else { + reward = new Item(PVP_GEAR[i]); + } + Repository.sendNews(killer.asPlayer().getUsername() + " has received a " + reward.getName() + " from a " + e.asNpc().getName() + "!"); + GroundItemManager.create(reward,((NPC) e).getDropLocation(),killer.asPlayer()); + return true; + } + } + e.asNpc().getDefinition().getDropTables().drop(e.asNpc(),killer); + } + return true; + } + + /** + * Fixes attack options for the revs + * @param e The entity. + * @param target The target to interact with. + * @param option The option. + * @return true + */ + @Override + public boolean interact(Entity e, Node target, Option option) { + if(target instanceof NPC){ + if(target.asNpc().getName().contains("Revenant")){ + e.asPlayer().getProperties().getCombatPulse().attack(target); + return true; + } + } + return super.interact(e, target, option); + } + + + @Override public boolean enter(Entity e) { if (e instanceof Player) { diff --git a/Server/src/plugin/npc/revenant/RevenantNPC.java b/Server/src/plugin/npc/revenant/RevenantNPC.java index e4802daee..f64060fb7 100644 --- a/Server/src/plugin/npc/revenant/RevenantNPC.java +++ b/Server/src/plugin/npc/revenant/RevenantNPC.java @@ -38,7 +38,7 @@ public class RevenantNPC extends AbstractNPC { * The possible PVP item drops. */ private static final int[] PVP_DROPS = new int[] { 13896, 13884, 13890, 13902, 13887, 13899, 13893, 13905, 13864, 13858, 13861, 13867, 13876, 13879, 13870, 13873, 13883, 13908, 13911, 13914, 13917, 13920, 13923, 13926, 13929, 13932, 13935, 13938, 13941, 13944, 13947, 13950, 13953, 13958, 13961, 13964, 13967, 13970, 13973, 13976, 13979, 13982, 13985, 13988 }; - + /** * The swing handler. */ @@ -112,13 +112,6 @@ public class RevenantNPC extends AbstractNPC { if (killer instanceof Player) { killer.asPlayer().getAudioManager().send(4063, true); } - int chance = RandomFunction.getRandom(120); - if (chance == 1) { - int item = RandomFunction.getRandom(PVP_DROPS.length - 1); - Item i = new Item(PVP_DROPS[item]); - GroundItemManager.create(i, itemLoc, killer.asPlayer()); - Repository.sendNews(killer.getUsername() + " has just received a " + i.getName() + " from a " + getName() + "."); - } } @Override