mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-19 17:19:58 +02:00
Filter emblem elemental affixes not matching the trekker's element
This commit is contained in:
@@ -7,6 +7,7 @@ import emu.nebula.data.BaseDef;
|
|||||||
import emu.nebula.data.GameData;
|
import emu.nebula.data.GameData;
|
||||||
import emu.nebula.data.ResourceType;
|
import emu.nebula.data.ResourceType;
|
||||||
import emu.nebula.data.resources.CharGemAttrValueDef;
|
import emu.nebula.data.resources.CharGemAttrValueDef;
|
||||||
|
import emu.nebula.game.character.GameCharacter;
|
||||||
import emu.nebula.util.WeightedList;
|
import emu.nebula.util.WeightedList;
|
||||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
import it.unimi.dsi.fastutil.ints.IntList;
|
import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
@@ -42,7 +43,7 @@ public class CharGemAttrGroupDef extends BaseDef {
|
|||||||
return this.uniqueAttrNum.next();
|
return this.uniqueAttrNum.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CharGemAttrTypeData getRandomAttributeType(IntList list) {
|
public CharGemAttrTypeData getRandomAttributeType(GameCharacter character, IntList list) {
|
||||||
// Setup blacklist to prevent the same attribute from showing up twice
|
// Setup blacklist to prevent the same attribute from showing up twice
|
||||||
var blacklist = new IntOpenHashSet();
|
var blacklist = new IntOpenHashSet();
|
||||||
|
|
||||||
@@ -58,13 +59,23 @@ public class CharGemAttrGroupDef extends BaseDef {
|
|||||||
var random = new WeightedList<CharGemAttrTypeData>();
|
var random = new WeightedList<CharGemAttrTypeData>();
|
||||||
|
|
||||||
for (var type : this.getAttributeTypes()) {
|
for (var type : this.getAttributeTypes()) {
|
||||||
|
// Don't add types that we already have in the emblem
|
||||||
if (blacklist.contains(type.getId())) {
|
if (blacklist.contains(type.getId())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip attributes that don't match the trekker's element
|
||||||
|
if (type.isElementalAttr() && !character.getElementType().getGemAttrTypes().contains(type.getFirstSubType())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
random.add(100, type);
|
random.add(100, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (random.size() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return random.next();
|
return random.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,6 +102,7 @@ public class CharGemAttrGroupDef extends BaseDef {
|
|||||||
@Getter
|
@Getter
|
||||||
public static class CharGemAttrTypeData {
|
public static class CharGemAttrTypeData {
|
||||||
private int id;
|
private int id;
|
||||||
|
private int firstSubType;
|
||||||
private WeightedList<CharGemAttrValueDef> values;
|
private WeightedList<CharGemAttrValueDef> values;
|
||||||
|
|
||||||
public CharGemAttrTypeData(int id) {
|
public CharGemAttrTypeData(int id) {
|
||||||
@@ -98,7 +110,12 @@ public class CharGemAttrGroupDef extends BaseDef {
|
|||||||
this.values = new WeightedList<>();
|
this.values = new WeightedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isElementalAttr() {
|
||||||
|
return this.getFirstSubType() >= 17 && this.getFirstSubType() <= 28;
|
||||||
|
}
|
||||||
|
|
||||||
public void addValue(CharGemAttrValueDef value) {
|
public void addValue(CharGemAttrValueDef value) {
|
||||||
|
this.firstSubType = value.getAttrTypeFirstSubtype();
|
||||||
this.values.add(value.getRarity(), value);
|
this.values.add(value.getRarity(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class CharGemAttrValueDef extends BaseDef {
|
|||||||
private int Id;
|
private int Id;
|
||||||
private int TypeId;
|
private int TypeId;
|
||||||
private int AttrType;
|
private int AttrType;
|
||||||
|
private int AttrTypeFirstSubtype;
|
||||||
private int Rarity;
|
private int Rarity;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import emu.nebula.data.BaseDef;
|
|||||||
import emu.nebula.data.GameData;
|
import emu.nebula.data.GameData;
|
||||||
import emu.nebula.data.ResourceType;
|
import emu.nebula.data.ResourceType;
|
||||||
import emu.nebula.data.custom.CharGemAttrGroupDef;
|
import emu.nebula.data.custom.CharGemAttrGroupDef;
|
||||||
|
import emu.nebula.game.character.GameCharacter;
|
||||||
import emu.nebula.util.Utils;
|
import emu.nebula.util.Utils;
|
||||||
import emu.nebula.util.WeightedList;
|
import emu.nebula.util.WeightedList;
|
||||||
import emu.nebula.util.ints.CustomIntArray;
|
import emu.nebula.util.ints.CustomIntArray;
|
||||||
@@ -35,8 +36,8 @@ public class CharGemSlotControlDef extends BaseDef {
|
|||||||
return Id;
|
return Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntList generateAttributes() {
|
public IntList generateAttributes(GameCharacter character) {
|
||||||
return this.generateAttributes(new CustomIntArray());
|
return this.generateAttributes(character, new CustomIntArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we should add unique attributes based on the probablity
|
// Check if we should add unique attributes based on the probablity
|
||||||
@@ -45,14 +46,18 @@ public class CharGemSlotControlDef extends BaseDef {
|
|||||||
return random <= this.UniqueAttrGroupProb;
|
return random <= this.UniqueAttrGroupProb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntList generateAttributes(CustomIntArray list) {
|
public IntList generateAttributes(GameCharacter character, CustomIntArray list) {
|
||||||
// Add unique attributes
|
// Add unique attributes
|
||||||
if (this.UniqueAttrGroupId > 0 && this.shouldAddUniqueAttr()) {
|
if (this.UniqueAttrGroupId > 0 && this.shouldAddUniqueAttr()) {
|
||||||
var group = GameData.getCharGemAttrGroupDataTable().get(this.UniqueAttrGroupId);
|
var group = GameData.getCharGemAttrGroupDataTable().get(this.UniqueAttrGroupId);
|
||||||
int num = group.getRandomUniqueAttrNum();
|
int num = group.getRandomUniqueAttrNum();
|
||||||
|
|
||||||
for (int i = 0; i < num; i++) {
|
for (int i = 0; i < num; i++) {
|
||||||
var attributeType = group.getRandomAttributeType(list);
|
var attributeType = group.getRandomAttributeType(character, list);
|
||||||
|
if (attributeType == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
list.add(attributeType.getRandomValue());
|
list.add(attributeType.getRandomValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +81,8 @@ public class CharGemSlotControlDef extends BaseDef {
|
|||||||
// Add up to 4 attributes
|
// Add up to 4 attributes
|
||||||
while (list.getValueCount() < this.MaxAlterNum) {
|
while (list.getValueCount() < this.MaxAlterNum) {
|
||||||
var group = random.next();
|
var group = random.next();
|
||||||
var attributeType = group.getRandomAttributeType(list);
|
var attributeType = group.getRandomAttributeType(character, list);
|
||||||
|
|
||||||
list.add(attributeType.getRandomValue());
|
list.add(attributeType.getRandomValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,28 @@
|
|||||||
package emu.nebula.game.character;
|
package emu.nebula.game.character;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public enum ElementType {
|
public enum ElementType {
|
||||||
INHERIT (0),
|
INHERIT (0),
|
||||||
AQUA (1, 90018),
|
AQUA (1, 90018, new int[] {17, 23}),
|
||||||
FIRE (2, 90019),
|
FIRE (2, 90019, new int[] {18, 24}),
|
||||||
EARTH (3, 90021),
|
EARTH (3, 90021, new int[] {19, 25}),
|
||||||
WIND (4, 90020),
|
WIND (4, 90020, new int[] {20, 26}),
|
||||||
LIGHT (5, 90022),
|
LIGHT (5, 90022, new int[] {21, 27}),
|
||||||
DARK (6, 90023),
|
DARK (6, 90023, new int[] {22, 28}),
|
||||||
NONE (7);
|
NONE (7);
|
||||||
|
|
||||||
private final int value;
|
private final int value;
|
||||||
private final int subNoteSkillItemId;
|
private final int subNoteSkillItemId;
|
||||||
|
private final IntSet gemAttrTypes;
|
||||||
|
|
||||||
private final static Int2ObjectMap<ElementType> map = new Int2ObjectOpenHashMap<>();
|
private final static Int2ObjectMap<ElementType> map = new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -26,12 +32,15 @@ public enum ElementType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ElementType(int value) {
|
private ElementType(int value) {
|
||||||
this(value, 0);
|
this(value, 0, new int[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ElementType(int value, int subNoteSkillItemId) {
|
private ElementType(int value, int subNoteSkillItemId, int[] attrTypes) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.subNoteSkillItemId = subNoteSkillItemId;
|
this.subNoteSkillItemId = subNoteSkillItemId;
|
||||||
|
|
||||||
|
this.gemAttrTypes = new IntOpenHashSet();
|
||||||
|
Arrays.stream(attrTypes).forEach(this.gemAttrTypes::add);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ElementType getByValue(int value) {
|
public static ElementType getByValue(int value) {
|
||||||
|
|||||||
@@ -698,7 +698,7 @@ public class GameCharacter implements GameDatabaseObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate attributes and create gem
|
// Generate attributes and create gem
|
||||||
var attributes = gemControl.generateAttributes();
|
var attributes = gemControl.generateAttributes(this);
|
||||||
var gem = new CharacterGem(attributes);
|
var gem = new CharacterGem(attributes);
|
||||||
|
|
||||||
// Add gem to slot
|
// Add gem to slot
|
||||||
@@ -771,7 +771,7 @@ public class GameCharacter implements GameDatabaseObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate attributes and create gem
|
// Generate attributes and create gem
|
||||||
var attributes = gemControl.generateAttributes(list);
|
var attributes = gemControl.generateAttributes(this, list);
|
||||||
gem.setNewAttributes(attributes);
|
gem.setNewAttributes(attributes);
|
||||||
|
|
||||||
// Save to database
|
// Save to database
|
||||||
|
|||||||
Reference in New Issue
Block a user