Compare commits

..

7 Commits

Author SHA1 Message Date
Ponk
5fabbaf7ab Merge pull request #261 from pimittens/vanillafixes #patch
chaos scroll fix
2024-09-13 21:25:51 +02:00
pimittens
215dc42294 Create RandomizerTest.java 2024-09-10 13:49:16 -07:00
Ponk
314916279a Merge pull request #271 from P0nk/fix/global-drop-concurrency #patch
Fix global drops thread issue
2024-08-28 21:30:39 +02:00
P0nk
dbf1a1bb36 Fix global drops thread issue
This randomly caused global drops to stop working after a while.
Originally reported by Crabo of MapleHorizons.
2024-08-28 21:22:47 +02:00
Ponk
8f2b8dd013 Merge pull request #248 from HarkuLi/fix/vard-plastic-surgery #patch
NPC (Vard): Fix "Plastic Surgery" option
2024-08-28 19:57:04 +02:00
pimittens
ec90df9c58 chaos scroll fix
The intention of the rand method is to return a pseudorandom uniformly distributed int between lbound and ubound (both inclusive). The previous implementation did not work as intended when the lower bound was negative since java round up instead of down when casting a negative double to an int. Adding the lower bound after the cast rather than before fixes this.

Also changed the CHSCROLL_STAT_RANGE from 6 to 5 to be consistent with gms.
2024-08-06 20:42:23 -07:00
HarkuLi
0245e7d1af NPC (Vard): Fix "Plastic Surgery" option
Correct typos for variable `fface_v`.
2024-06-19 18:56:14 +08:00
6 changed files with 52 additions and 23 deletions

View File

@@ -344,7 +344,7 @@ server:
USE_ENHANCED_CRAFTING: false #Apply chaos scroll on every equip crafted.
SCROLL_CHANCE_ROLLS: 1 #Number of rolls for success on a scroll, set 1 for default.
CHSCROLL_STAT_RATE: 1 #Number of rolls of stat upgrade on a successfully applied chaos scroll, set 1 for default.
CHSCROLL_STAT_RANGE: 6 #Stat upgrade range (-N, N) on chaos scrolls.
CHSCROLL_STAT_RANGE: 5 #Stat upgrade range (-N, N) on chaos scrolls.
#Beginner Skills Configuration
USE_ULTRA_NIMBLE_FEET: false #Massive speed & jump upgrade.

View File

@@ -58,8 +58,8 @@ function action(mode, type, selection) {
}
}
if (cm.getChar().getGender() == 1) {
for (var i = 0; i < fface.length; i++) {
pushIfItemExists(facenew, fface[i] + cm.getChar().getFace()
for (var i = 0; i < fface_v.length; i++) {
pushIfItemExists(facenew, fface_v[i] + cm.getChar().getFace()
% 1000 - (cm.getChar().getFace()
% 100));
}

View File

@@ -58,7 +58,7 @@ public class MonsterInformationProvider {
private final Map<Integer, List<MonsterDropEntry>> drops = new HashMap<>();
private final List<MonsterGlobalDropEntry> globaldrops = new ArrayList<>();
private final Map<Integer, List<MonsterGlobalDropEntry>> continentdrops = new HashMap<>();
private final Map<Integer, List<MonsterGlobalDropEntry>> continentDrops = new HashMap<>();
private final Map<Integer, List<Integer>> dropsChancePool = new HashMap<>(); // thanks to ronan
private final Set<Integer> hasNoMultiEquipDrops = new HashSet<>();
@@ -76,23 +76,15 @@ public class MonsterInformationProvider {
retrieveGlobal();
}
public final List<MonsterGlobalDropEntry> getRelevantGlobalDrops(int mapid) {
int continentid = mapid / 100000000;
public final List<MonsterGlobalDropEntry> getRelevantGlobalDrops(int mapId) {
final int continentId = mapId / 100000000;
return continentDrops.computeIfAbsent(continentId, this::loadContinentDrops);
}
List<MonsterGlobalDropEntry> contiItems = continentdrops.get(continentid);
if (contiItems == null) { // continent separated global drops found thanks to marcuswoon
contiItems = new ArrayList<>();
for (MonsterGlobalDropEntry e : globaldrops) {
if (e.continentid < 0 || e.continentid == continentid) {
contiItems.add(e);
}
}
continentdrops.put(continentid, contiItems);
}
return contiItems;
private List<MonsterGlobalDropEntry> loadContinentDrops(int continentId) {
return globaldrops.stream()
.filter(dropEntry -> dropEntry.continentid < 0 || dropEntry.continentid == continentId)
.toList();
}
private void retrieveGlobal() {
@@ -291,7 +283,7 @@ public class MonsterInformationProvider {
extraMultiEquipDrops.clear();
dropsChancePool.clear();
globaldrops.clear();
continentdrops.clear();
continentDrops.clear();
retrieveGlobal();
}
}

View File

@@ -751,7 +751,7 @@ public class MapleMap {
}
final MonsterInformationProvider mi = MonsterInformationProvider.getInstance();
final List<MonsterGlobalDropEntry> globalEntry = mi.getRelevantGlobalDrops(this.getId());
final List<MonsterGlobalDropEntry> globalEntry = new ArrayList<>(mi.getRelevantGlobalDrops(mapid));
final List<MonsterDropEntry> dropEntry = new ArrayList<>();
final List<MonsterDropEntry> visibleQuestEntry = new ArrayList<>();

View File

@@ -35,6 +35,6 @@ public class Randomizer {
}
public static int rand(final int lbound, final int ubound) {
return (int) ((rand.nextDouble() * (ubound - lbound + 1)) + lbound);
return ((int) (rand.nextDouble() * (ubound - lbound + 1))) + lbound;
}
}

View File

@@ -0,0 +1,37 @@
package tools;
import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class RandomizerTest {
@Test
void randShouldIncludeEntireRange() {
Map<Integer, Integer> rands = new HashMap<>();
final int rounds = 100_000;
for (int i = 0; i < rounds; i++) {
int randomValue = Randomizer.rand(-5, 5);
rands.compute(randomValue, (k, v) -> v == null ? 0 : v + 1);
}
assertFalse(rands.containsKey(-6));
assertTrue(rands.containsKey(-5));
assertTrue(rands.containsKey(-4));
assertTrue(rands.containsKey(-3));
assertTrue(rands.containsKey(-2));
assertTrue(rands.containsKey(-1));
assertTrue(rands.containsKey(0));
assertTrue(rands.containsKey(1));
assertTrue(rands.containsKey(2));
assertTrue(rands.containsKey(3));
assertTrue(rands.containsKey(4));
assertTrue(rands.containsKey(5));
assertFalse(rands.containsKey(6));
}
}