1. Cannot say until I see the method that calls the method displayed.
2. Confused as fuck right now. I think you just explained what that piece of code does..?
3. 10/10.
4. Kill yourself. You said it, I'm just a supporter.
|
Hey guys, having a small issue:
DropManager.java
1. Should I be removing the '-' inCode:private double getModifier(Player player) { double modifier = 1.0; if (player.getItems().isWearingItem(2572)) { modifier -= .03; } else if (player.getItems().isWearingItem(12785)) { modifier -= .05; } else if (player.getItems().isWearingItem(11014)) { modifier -= .09; } else if (player.getItems().isWearingItem(7142)) { modifier -= 2.5; } if (player.getRights().contains(Right.MAX_DONATOR)) { modifier -= 0.200; } else if (player.getRights().contains(Right.UBER_DONATOR)) { modifier -= 0.175; } else if (player.getRights().contains(Right.LEGENDARY)) { modifier -= 0.150; } else if (player.getRights().contains(Right.EXTREME_DONATOR)) { modifier -= 0.120; } else if (player.getRights().contains(Right.SUPER_DONATOR)) { modifier -= 0.100; } else if (player.getRights().contains(Right.DONATOR)) { modifier -= 0.070; } else if (player.getRights().contains(Right.SUPPORTER)) { modifier -= 0.050; } else if (player.getRights().contains(Right.SPONSOR)) { modifier -= 0.035; } else if (player.getRights().contains(Right.CONTRIBUTOR)) { modifier -= 0.020; } return modifier; }to give higher drop rates? I believe -= should be subtracting percentages?Code:modifier -= #;
2. Is there a means of making the base number be multiplied by the percentage # you want to represent items/playerrights?
3. How much of a noob am I?
4. This is Os-V.. I know PI.. kill myself, yada, yada. I'd appreciate the help, thanks guys!
1. Cannot say until I see the method that calls the method displayed.
2. Confused as fuck right now. I think you just explained what that piece of code does..?
3. 10/10.
4. Kill yourself. You said it, I'm just a supporter.
1. It seems as the higher the drop rate the lower the modifier. I cannot guarantee that is the case, but judging from the fact that an Uber_Donators modifier is lower than a supporter, that is the take away. So you will want to lower modifier to increase the drop rate.
2. You should probably rewrite the DropRate-system. This chained if statement could be removed by creating an interface that has a "getModifierChange"-method that is implemented on every item that adjusts the droprate. Doing this in PI will probably be a huge project, which is why PI generally is avoided by serious developers.
3. You don't seem to be very comfortable in writing code or RSPS. But you will get there.
What I'm getting from it is:
= 100% * 2 (200%)Code:double modifier = 1.0
is used in buyFromShop to remove Points from players for items using Points (PK points, Mage Arena Points, PC Points, etc.)Code:-=
So, I assumedwould mean it'd be subtracting from 200% in the DropManager?Code:-=
i.e;
= -.2%; so a Max Donator would have a Drop Rate of 199.8%, whereasCode:if (player.getRights().contains(Right.MAX_DONATOR)) { modifier -= 0.200;
= -.175%; so a Uber Donator would have a Drop Rate of 199.825%.Code:} else if (player.getRights().contains(Right.UBER_DONATOR)) { modifier -= 0.175;
This is the way I'm interpreting it as and it doesn't make sense to me, so I'd assume I'd have to rewrite this?
I'm not entirely sure ifrepresents 200% or not?Code:double modifier = 1.0;
Thank you for the response, nonetheless, I appreciate it.
Here's another instance of the method being used in DropManager:
Code:public void create(Player player, NPC npc, Location3D location, int repeats) { Optional<TableGroup> group = groups.values().stream().filter(g -> g.getNpcIds().contains(npc.npcType)) .findFirst(); group.ifPresent(g -> { double modifier = getModifier(player); List<GameItem> drops = g.access(player, modifier, repeats); for (GameItem item : drops) { if (item.getId() == 536) { if (player.getRechargeItems().hasItem(13111) && player.inWild()) { item.changeDrop(537, item.getAmount()); } } if (item.getId() == 6529) { if (player.getRechargeItems().hasItem(11136)) { item.changeDrop(6529, (int) (item.getAmount() * 1.20)); } if (player.getRechargeItems().hasItem(11138)) { item.changeDrop(6529, (int) (item.getAmount() * 1.50)); } if (player.getRechargeItems().hasItem(11140)) { item.changeDrop(6529, (int) (item.getAmount() * 1.70)); } if (player.getRechargeItems().hasItem(13103)) { item.changeDrop(6529, (int) (item.getAmount() * 1.90)); } } if (item.getId() == 6729 && player.getRechargeItems().hasItem(13132)) { item.changeDrop(6730, item.getAmount()); } if (item.getId() == 13233 && !Boundary.isIn(player, Boundary.CERBERUS_BOSSROOMS)) { player.sendMessage("@red@Something hot drops from the body of your vanquished foe"); } if (IntStream.of(bosses).anyMatch(id -> id == npc.npcType)) { PlayerHandler.nonNullStream().filter(p -> p.distanceToPoint(player.absX, player.absY) < 10 && p.heightLevel == player.heightLevel).forEach(p -> { if (item.getAmount() > 1) p.sendMessage("@dre@" + Misc.formatPlayerName(player.playerName) + " received a drop: " + Misc.format(item.getAmount()) + " x " + Item.getItemName(item.getId()) + "."); else p.sendMessage("@dre@" + Misc.formatPlayerName(player.playerName) + " received a drop: " + Item.getItemName(item.getId()) + "."); }); } Server.itemHandler.createGroundItem(player, item.getId(), location.getX(), location.getY(), location.getZ(), item.getAmount(), player.getIndex()); }
& I'm not entirely sure if the source is written properly off the bat, it's Exotic.
Exotic is horribly written. But I did have the source downloaded.
The modifier value is used in the "access" method, which accesses a drop table X times with a modifier.
The modifier is used to determine the chance.
There is then a randomized variable roll which determines whether or not a player is eligible for a rollCode:double chance = (1.0 / (double) (table.getAccessibility() * modifier)) * 100D;
An item is then rolled randomly in the droptable (if the player is eligible for a roll).Code:if (roll <= chance)
If the chance is lower than 1.5 % (roll also needs to be lower than 1.5 % for this if case to be reached) and the table being accessed is a rare/very-rare item it broadcasts it (as I interpret it) - and the item isn't shit (there's a nested if case there that's really weird), then it broadcasts. I feel like that last part was being added to filter out the majority of broadcasts - but I am not sure.
The chance, as I view it, increases your chance of rolling on a table. The chance is higher the lower the modifier is.
As the user above me mentioned, do not use this source.
This is the method that generates drop. It's utter trash.
Recoded this method could look something like this:Code:public List<GameItem> access(Player player, double modifier, int repeats) { int rights = player.getRights().getPrimary().getValue() - 1; List<GameItem> items = new ArrayList<>(); for (Table table : this) { TablePolicy policy = table.getPolicy(); if (policy.equals(TablePolicy.CONSTANT)) { for (Drop drop : table) { int minimumAmount = drop.getMinimumAmount(); items.add(new GameItem(drop.getItemId(), minimumAmount + Misc.random(drop.getMaximumAmount() - minimumAmount))); } } else { for (int i = 0; i < repeats; i++) { double chance = (1.0 / (double) (table.getAccessibility() * modifier)) * 100D; double roll = Misc.preciseRandom(Range.between(0.0, 100.0)); if (chance > 100.0) { chance = 100.0; } if (roll <= chance) { Drop drop = table.fetchRandom(); int minimumAmount = drop.getMinimumAmount(); GameItem item = new GameItem(drop.getItemId(), minimumAmount + Misc.random(drop.getMaximumAmount() - minimumAmount)); items.add(item); if (chance <= 1.5) { if (policy.equals(TablePolicy.VERY_RARE) || policy.equals(TablePolicy.RARE)) { if (Item.getItemName(item.getId()).toLowerCase().contains("cowhide") || Item.getItemName(item.getId()).toLowerCase().contains("feather") || Item.getItemName(item.getId()).toLowerCase().contains("arrow") || Item.getItemName(item.getId()).toLowerCase().contains("sq shield") || Item.getItemName(item.getId()).toLowerCase().contains("rune warhammer") || Item.getItemName(item.getId()).toLowerCase().contains("rune battleaxe") || Item.getItemName(item.getId()).toLowerCase().contains("casket") || Item.getItemName(item.getId()).toLowerCase().contains("silver ore") || Item.getItemName(item.getId()).toLowerCase().contains("rune spear") || item.getId() >= 554 && item.getId() <= 566) { } else { PlayerHandler.executeGlobalMessage( "<col=FF0000>[Lootations] @cr19@ </col><col=255><img=" + rights + ">" + Misc.capitalize(player.playerName) + "</col> received <col=255>" + item.getAmount() + "</col>x <col=255>" + ItemAssistant.getItemName(item.getId()) + "</col>."); } } } } } } } return items; }
The table should decide whether or not the tables action needs recognition in a broadcast.Code:public List<GameItem> method(Player player, double modifier, int repeats) { int rights = player.getRights().getPrimary().getValue() - 1; List<GameItem> items = new ArrayList<>(); for (Table table : this) { items.add(table.roll(modifier, repeats, rights)); } }
The table should decide the chance of a roll for a drop, not the method that uses the table.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |