Merge pull request #284 from Ceikry/master

Again, I hate updating from main because of the .gitignore issue.
This commit is contained in:
The Celery Man 2020-03-30 13:26:57 -05:00 committed by GitHub
commit b67b658718
3 changed files with 73 additions and 9 deletions

2
.gitignore vendored
View file

@ -4,7 +4,7 @@
**/.idea/workspace.xml
**/.idea/tasks.xml
Server/**/*.class
CompiledServer/**/*.jar
CompiledServer/*
.idea/
.idea/workspace.xml
**/.idea/workspace.xml

View file

@ -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) {

View file

@ -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