Files
BattleBane/src/engine/objects/ItemTemplate.java
T

624 lines
30 KiB
Java
Raw Normal View History

2024-02-18 11:00:56 -05:00
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.objects;
2024-02-18 11:39:11 -05:00
import engine.math.Vector3fImmutable;
import engine.mbEnums;
2024-04-22 09:21:46 -04:00
import org.json.JSONArray;
import org.json.JSONObject;
2024-02-24 09:07:05 -05:00
import org.pmw.tinylog.Logger;
2024-02-18 11:00:56 -05:00
2024-02-27 14:36:27 -05:00
import java.util.ArrayList;
2024-02-18 14:03:41 -05:00
import java.util.EnumSet;
2024-02-18 11:00:56 -05:00
import java.util.HashMap;
public class ItemTemplate {
2024-04-26 15:32:17 -04:00
// MB Dev Notes:
// This class parses JSON data generated by mbEditor Pro 2.1.
// Cache definitions are loaded for ItemType.ITEM, ItemType,DEED
// and ItemType.RUNE.
//
2024-04-26 15:43:45 -04:00
// Exported JSON data is stored in db table static_item_templates
// and can be easily mass updated using tooling available on the Wiki.
//
2024-04-26 15:32:17 -04:00
// Always read never write!
// Use copies of fields to avoid side effects.
2024-02-18 11:39:11 -05:00
// Global template lookup
2024-04-26 15:32:17 -04:00
2024-03-16 07:57:17 -04:00
public static HashMap<Integer, ItemTemplate> templates = new HashMap<>();
2024-03-01 08:23:28 -05:00
public int template_id;
2024-02-18 11:39:11 -05:00
// Template Properties
2024-04-26 15:32:17 -04:00
2024-02-18 14:25:28 -05:00
public String obj_name;
2024-02-27 14:05:57 -05:00
public boolean obj_pickable;
2024-02-18 14:25:28 -05:00
public Vector3fImmutable obj_scale;
2024-02-27 13:55:26 -05:00
public Vector3fImmutable obj_forward_vector;
public Vector3fImmutable obj_default_alignment;
2024-02-18 11:41:24 -05:00
public int obj_render_object;
2024-02-18 13:29:01 -05:00
public int obj_icon;
2024-04-04 13:27:43 -04:00
public final HashMap<String, String> obj_sparse_data = new HashMap<>();
2024-02-18 12:35:55 -05:00
public float combat_health_current;
public float combat_health_full;
2024-04-04 13:27:43 -04:00
public final HashMap<String, Float> combat_attack_resist = new HashMap<>();
public mbEnums.ItemType item_type;
2024-02-18 14:03:41 -05:00
public int item_eq_slots_value;
public boolean item_eq_slots_type;
public final EnumSet<mbEnums.EquipSlotType> item_eq_slots_or = EnumSet.noneOf(mbEnums.EquipSlotType.class);
public final EnumSet<mbEnums.EquipSlotType> item_eq_slots_and = EnumSet.noneOf(mbEnums.EquipSlotType.class);
2024-02-28 14:59:17 -05:00
public boolean item_takeable;
2024-02-18 14:25:28 -05:00
public int item_value;
public int item_wt;
public float item_passive_defense_mod;
public String item_base_name;
public String item_dsc;
public int item_render_object_female;
public float item_health_full;
2024-03-06 14:36:25 -05:00
public String item_skill_used = "";
public String item_skill_mastery_used = "";
2024-03-07 20:32:35 -05:00
public int item_parry_anim_id;
2024-02-24 07:49:13 -05:00
public float item_bulk_factor;
public final HashMap<mbEnums.ShrineType, Integer> item_offering_info = new HashMap<>();
2024-02-26 03:10:11 -05:00
public int item_defense_rating;
2024-02-24 15:25:06 -05:00
public float item_weapon_wepspeed;
public float item_weapon_max_range;
public int item_weapon_projectile_id;
public float item_weapon_projectile_speed;
public int item_weapon_combat_idle_anim;
public final HashMap<mbEnums.DamageType, int[]> item_weapon_damage = new HashMap<>();
2024-04-04 13:27:43 -04:00
public final ArrayList<int[]> weapon_attack_anim_right = new ArrayList<>();
public final ArrayList<int[]> weapon_attack_anim_left = new ArrayList<>();
public mbEnums.AttributeType item_primary_attr = mbEnums.AttributeType.None;
public mbEnums.AttributeType item_secondary_attr = mbEnums.AttributeType.None;
public final EnumSet<mbEnums.ItemFlags> item_flags = EnumSet.noneOf(mbEnums.ItemFlags.class);
public final EnumSet<mbEnums.ItemUseFlags> item_use_flags = EnumSet.noneOf(mbEnums.ItemUseFlags.class);
2024-02-24 08:01:22 -05:00
public int item_initial_charges;
2024-04-04 13:27:43 -04:00
public final HashMap<String, Integer> item_skill_required = new HashMap<>();
public final EnumSet<mbEnums.MonsterType> item_race_req = EnumSet.noneOf(mbEnums.MonsterType.class);
public final EnumSet<mbEnums.MonsterType> item_race_res = EnumSet.noneOf(mbEnums.MonsterType.class);
public final EnumSet<mbEnums.ClassType> item_class_req = EnumSet.noneOf(mbEnums.ClassType.class);
public final EnumSet<mbEnums.ClassType> item_class_res = EnumSet.noneOf(mbEnums.ClassType.class);
public final EnumSet<mbEnums.DisciplineType> item_disc_req = EnumSet.noneOf(mbEnums.DisciplineType.class);
public final EnumSet<mbEnums.DisciplineType> item_disc_res = EnumSet.noneOf(mbEnums.DisciplineType.class);
2024-02-27 12:51:14 -05:00
public int item_level_req;
public mbEnums.SexType item_sex_req;
2024-04-04 13:27:43 -04:00
public final HashMap<String, int[]> item_user_power_action = new HashMap<>();
public final HashMap<String, Integer> item_power_grant = new HashMap<>();
public final HashMap<String, int[]> item_power_action = new HashMap<>();
public final HashMap<mbEnums.ResourceType, Integer> item_resource_cost = new HashMap<>();
2024-03-28 12:08:09 -04:00
public int modTable;
2024-03-16 07:27:20 -04:00
public int deed_type;
2024-03-16 07:15:11 -04:00
public int deed_furniture_id;
public int deed_target_id;
public int deed_employment;
public int deed_start_rank;
public int deed_name_lookup;
public boolean deed_indoors;
public boolean deed_is_fortress;
public float deed_namelookup_val;
public boolean deed_custom_city;
2024-03-11 12:07:46 -04:00
public int deed_structure_id;
public final HashMap<mbEnums.AttributeType, Integer> rune_attr_adj = new HashMap<>();
public final HashMap<mbEnums.AttributeType, Integer> rune_max_attr_adj = new HashMap<>();
2024-04-04 13:27:43 -04:00
public final HashMap<String, Integer> rune_skill_grant = new HashMap<>();
public final HashMap<String, Integer> skill_granted_skills = new HashMap<>();
public final HashMap<String, Integer> power_granted_skills = new HashMap<>();
2024-04-04 09:54:52 -04:00
public String rune_type;
public String rune_sub_type;
2024-04-04 09:56:25 -04:00
public boolean rune_is_standard_character_creation = false;
2024-04-04 10:07:42 -04:00
public int rune_creation_cost;
public int rune_rank;
public int rune_pracs_per_level;
public float rune_exp_req_to_level;
public mbEnums.SexType rune_sex;
2024-04-04 10:07:42 -04:00
public int rune_class_icon;
2024-04-04 10:54:43 -04:00
public int rune_health;
2024-04-04 10:07:42 -04:00
public int rune_mana;
public int rune_stamina;
public float rune_min_damage;
public float rune_max_damage;
public int rune_attack;
public int rune_defense;
public int rune_level;
public final HashMap<mbEnums.MovementType, Float> rune_speed = new HashMap<>();
2024-04-04 10:07:42 -04:00
public int rune_group_type;
public boolean rune_group_is_faction = false;
public boolean rune_group_is_guild = false;
public String rune_dsc;
public String rune_fx_txt;
2024-04-26 15:32:17 -04:00
public final EnumSet<mbEnums.MobBehaviourType> rune_group_tactics = EnumSet.noneOf(mbEnums.MobBehaviourType.class);
public final EnumSet<mbEnums.MobBehaviourType> rune_group_role_set = EnumSet.noneOf(mbEnums.MobBehaviourType.class);
2024-04-04 10:07:42 -04:00
public boolean rune_renderable = false;
public int rune_natural_power_attack;
2024-04-04 13:27:43 -04:00
public final HashMap<String, String> rune_sparse_data = new HashMap<>();
public final HashMap<String, int[]> rune_skill_adj = new HashMap<>();
public final EnumSet<mbEnums.MonsterType> rune_enemy_monster_types = EnumSet.noneOf(mbEnums.MonsterType.class);
public final EnumSet<mbEnums.MonsterType> rune_not_enemy_monster_types = EnumSet.noneOf(mbEnums.MonsterType.class);
2024-04-04 14:27:07 -04:00
public final ArrayList<Integer> rune_groupee_monster_types = new ArrayList<>();
public final ArrayList<Integer> rune_helper_monster_types = new ArrayList<>();
2024-04-10 17:22:45 -04:00
public int item_bane_rank;
2024-04-02 15:17:33 -04:00
2024-02-18 11:00:56 -05:00
public ItemTemplate(JSONObject jsonObject) {
2024-02-24 09:07:05 -05:00
try {
// Reading a String
2024-02-18 12:28:14 -05:00
2024-04-22 11:49:41 -04:00
obj_name = jsonObject.getString("obj_name");
2024-02-18 11:55:45 -05:00
2024-02-27 14:05:57 -05:00
// Reading a boolean
2024-04-22 11:49:41 -04:00
obj_pickable = jsonObject.getBoolean("obj_pickable");
2024-02-27 14:05:57 -05:00
// Reading floats from an array (note always check for empty arrays)
2024-02-18 12:28:14 -05:00
2024-04-22 11:49:41 -04:00
JSONArray scaleData = jsonObject.getJSONArray("obj_scale");
2024-02-27 13:55:26 -05:00
if (scaleData.isEmpty() == false)
2024-04-22 11:49:41 -04:00
obj_scale = new Vector3fImmutable(scaleData.getFloat(0), scaleData.getFloat(1),
scaleData.getFloat(2));
2024-02-18 11:55:45 -05:00
2024-04-22 11:49:41 -04:00
JSONArray forwardVector = jsonObject.getJSONArray("obj_forward_vector");
2024-02-27 13:55:26 -05:00
if (forwardVector.isEmpty() == false)
2024-04-22 11:49:41 -04:00
obj_forward_vector = new Vector3fImmutable(forwardVector.getFloat(0), forwardVector.getFloat(1),
forwardVector.getFloat(2));
2024-02-27 13:55:26 -05:00
2024-04-22 11:49:41 -04:00
JSONArray defaultAlignment = jsonObject.getJSONArray("obj_default_alignment");
2024-02-27 13:55:26 -05:00
2024-04-22 11:49:41 -04:00
if (defaultAlignment.isEmpty() == false)
obj_default_alignment = new Vector3fImmutable(defaultAlignment.getFloat(0), defaultAlignment.getFloat(1),
defaultAlignment.getFloat(2));
2024-02-27 13:55:26 -05:00
2024-02-24 09:07:05 -05:00
// Reading an integer value
2024-02-18 12:28:14 -05:00
2024-04-22 11:49:41 -04:00
obj_render_object = jsonObject.getInt("obj_render_object");
obj_icon = jsonObject.getInt("obj_icon");
2024-02-18 12:15:13 -05:00
2024-04-22 11:49:41 -04:00
JSONObject obj_sparse_json = jsonObject.getJSONObject("obj_sparse_data");
2024-04-04 11:13:58 -04:00
2024-04-26 15:37:37 -04:00
for (String sparseType : obj_sparse_json.keySet()) {
2024-04-22 13:23:18 -04:00
Object sparseValue = obj_sparse_json.get(sparseType);
obj_sparse_data.put(sparseType, sparseValue.toString());
2024-04-04 11:13:58 -04:00
}
2024-04-10 17:22:45 -04:00
// Banes are defined by their sparse data field
2024-04-10 17:40:00 -04:00
if (obj_sparse_data.get("ACTIONRESPONSE") != null)
2024-04-10 17:22:45 -04:00
if (obj_sparse_data.get("ACTIONRESPONSE").equals("4250517122"))
2024-04-22 11:49:41 -04:00
item_bane_rank = jsonObject.getInt("item_bane_rank");
2024-04-10 17:22:45 -04:00
2024-02-24 09:07:05 -05:00
// Reading float values
2024-02-18 12:35:55 -05:00
2024-04-22 11:49:41 -04:00
combat_health_current = jsonObject.getFloat("combat_health_current");
combat_health_full = jsonObject.getFloat("combat_health_full");
2024-02-18 12:35:55 -05:00
2024-02-24 09:07:05 -05:00
// Reading a hashmap of floats
2024-02-18 12:28:14 -05:00
2024-04-22 11:49:41 -04:00
JSONObject resist_json = jsonObject.getJSONObject("combat_attack_resist");
2024-02-18 12:26:11 -05:00
2024-04-26 15:37:37 -04:00
for (String resistType : resist_json.keySet()) {
float resistValue = resist_json.getFloat(resistType);
combat_attack_resist.put(resistType, resistValue);
2024-02-24 09:07:05 -05:00
}
2024-02-18 12:26:11 -05:00
2024-02-24 09:07:05 -05:00
// Parsing an enum
2024-02-18 13:40:16 -05:00
2024-04-22 11:49:41 -04:00
item_type = mbEnums.ItemType.valueOf(jsonObject.getString("item_type"));
item_eq_slots_value = jsonObject.getInt("item_eq_slots_value");
2024-04-22 12:20:53 -04:00
item_eq_slots_type = jsonObject.getBoolean("item_eq_slots_type");
2024-02-18 14:03:41 -05:00
2024-02-24 09:07:05 -05:00
// Parsing an enumset
2024-02-18 14:03:41 -05:00
2024-04-22 12:20:53 -04:00
JSONArray eq_slots_or = jsonObject.getJSONArray("item_eq_slots_or");
2024-02-18 14:03:41 -05:00
2024-02-24 09:07:05 -05:00
if (eq_slots_or.isEmpty() == false)
for (Object o : eq_slots_or)
item_eq_slots_or.add(mbEnums.EquipSlotType.valueOf((String) o));
2024-02-18 11:00:56 -05:00
2024-04-22 12:20:53 -04:00
JSONArray eq_slots_and = jsonObject.getJSONArray("item_eq_slots_and");
2024-02-18 14:17:11 -05:00
2024-02-24 09:07:05 -05:00
if (eq_slots_and.isEmpty() == false)
2024-02-24 13:54:16 -05:00
for (Object o : eq_slots_and)
item_eq_slots_and.add(mbEnums.EquipSlotType.valueOf((String) o));
2024-02-18 14:17:11 -05:00
2024-04-22 12:20:53 -04:00
item_takeable = jsonObject.getBoolean("item_takeable");
item_value = (jsonObject.getInt("item_value"));
item_wt = jsonObject.getInt("item_wt");
item_passive_defense_mod = jsonObject.getFloat("item_passive_defense_mod");
item_base_name = jsonObject.getString("item_base_name");
item_dsc = jsonObject.getString("item_dsc");
item_render_object_female = jsonObject.getInt("item_render_object_female");
item_health_full = jsonObject.getFloat("item_health_full");
2024-02-18 14:25:28 -05:00
Object skill_used = jsonObject.get("item_skill_used");
2024-02-19 03:50:26 -05:00
2024-03-10 14:53:14 -04:00
if (skill_used instanceof String) {
if (skill_used.equals("Cloth") == false)
item_skill_used = (String) skill_used;
}
2024-02-19 03:50:26 -05:00
2024-02-24 09:07:05 -05:00
Object mastery_used = jsonObject.get("item_skill_mastery_used");
2024-02-19 03:50:26 -05:00
2024-03-06 14:36:25 -05:00
if (mastery_used instanceof String)
item_skill_mastery_used = (String) mastery_used;
2024-02-19 03:54:47 -05:00
2024-04-22 12:20:53 -04:00
item_parry_anim_id = jsonObject.getInt("item_parry_anim_id");
2024-02-24 08:42:19 -05:00
2024-03-07 20:32:35 -05:00
// Reading offering data
2024-04-22 12:20:53 -04:00
JSONArray offering_data = jsonObject.getJSONArray("item_offering_info");
2024-03-07 20:32:35 -05:00
2024-03-07 20:39:31 -05:00
for (Object entry : offering_data) {
JSONObject offering_entry = (JSONObject) entry;
2024-04-22 12:20:53 -04:00
String offering_type = offering_entry.getString("offering_type").replaceAll("-", "");
int offering_value = offering_entry.getInt("offering_value");
item_offering_info.put(mbEnums.ShrineType.valueOf(offering_type), offering_value);
2024-03-07 20:32:35 -05:00
}
2024-02-24 14:52:52 -05:00
// Fields only present for ARMOR
2024-02-24 08:48:03 -05:00
if (item_type.equals(mbEnums.ItemType.ARMOR)) {
2024-04-22 12:20:53 -04:00
item_bulk_factor = jsonObject.getFloat("item_bulk_factor");
item_defense_rating = jsonObject.getInt("item_defense_rating");
2024-02-24 14:52:52 -05:00
}
2024-02-24 07:49:13 -05:00
2024-02-26 21:09:57 -05:00
// Fields only present for WEAPON
if (item_type.equals(mbEnums.ItemType.WEAPON)) {
2024-02-24 15:25:06 -05:00
2024-04-22 12:20:53 -04:00
JSONObject item_weapon = jsonObject.getJSONObject("item_weapon");
item_weapon_wepspeed = item_weapon.getFloat("weapon_wepspeed");
item_weapon_max_range = item_weapon.getFloat("weapon_max_range");
item_weapon_projectile_id = item_weapon.getInt("weapon_projectile_id");
item_weapon_projectile_speed = item_weapon.getFloat("weapon_projectile_speed");
item_weapon_combat_idle_anim = item_weapon.getInt("weapon_combat_idle_anim");
2024-02-24 15:41:48 -05:00
2024-04-22 12:20:53 -04:00
JSONArray weapon_damage = item_weapon.getJSONArray("weapon_damage");
2024-02-24 15:45:22 -05:00
if (weapon_damage.isEmpty() == false)
for (Object o : weapon_damage) {
JSONObject damage_entry = (JSONObject) o;
2024-04-22 12:20:53 -04:00
mbEnums.DamageType damageType = mbEnums.DamageType.getDamageType(damage_entry.getString("damage_type"));
int min = damage_entry.getInt("damage_min");
int max = damage_entry.getInt("damage_max");
int[] minMax = {min, max};
2024-04-01 09:19:37 -04:00
item_weapon_damage.put(damageType, minMax);
}
2024-02-27 14:14:16 -05:00
2024-04-22 12:20:53 -04:00
JSONArray attack_anim_right = item_weapon.getJSONArray("weapon_attack_anim_right");
2024-02-27 14:36:27 -05:00
if (attack_anim_right.isEmpty() == false)
2024-02-27 14:50:38 -05:00
for (Object o : attack_anim_right) {
2024-02-27 14:36:27 -05:00
JSONArray animationEntry = (JSONArray) o;
2024-04-22 12:20:53 -04:00
int animation = animationEntry.getInt(0);
int duration = animationEntry.getInt(1);
2024-02-27 14:36:27 -05:00
weapon_attack_anim_right.add(new int[]{animation, duration});
}
2024-04-22 12:20:53 -04:00
JSONArray attack_anim_left = item_weapon.getJSONArray("weapon_attack_anim_left");
2024-02-27 14:36:27 -05:00
if (attack_anim_left.isEmpty() == false)
2024-02-27 14:50:38 -05:00
for (Object o : attack_anim_left) {
2024-02-27 14:36:27 -05:00
JSONArray animationEntry = (JSONArray) o;
2024-04-22 12:20:53 -04:00
int animation = animationEntry.getInt(0);
int duration = animationEntry.getInt(1);
2024-02-27 14:36:27 -05:00
weapon_attack_anim_left.add(new int[]{animation, duration});
}
2024-04-22 12:20:53 -04:00
item_primary_attr = mbEnums.AttributeType.valueOf(jsonObject.getString("item_primary_attr"));
item_secondary_attr = mbEnums.AttributeType.valueOf(jsonObject.getString("item_secondary_attr"));
2024-02-24 15:25:06 -05:00
}
2024-04-22 12:20:53 -04:00
JSONArray itemflags = jsonObject.getJSONArray("item_flags");
2024-02-24 07:49:13 -05:00
2024-02-24 09:07:05 -05:00
if (itemflags.isEmpty() == false)
2024-02-24 13:54:16 -05:00
for (Object o : itemflags) {
String flag = (String) o;
if (flag.equals("None") == false)
item_flags.add(mbEnums.ItemFlags.valueOf((String) o));
2024-02-24 13:54:16 -05:00
}
2024-02-24 07:49:13 -05:00
2024-04-22 12:20:53 -04:00
JSONArray itemUseflags = jsonObject.getJSONArray("item_use_flags");
2024-02-24 08:01:22 -05:00
2024-02-24 09:07:05 -05:00
if (itemUseflags.isEmpty() == false)
for (Object o : itemUseflags)
item_use_flags.add(mbEnums.ItemUseFlags.valueOf((String) o));
2024-02-24 08:01:22 -05:00
2024-04-22 12:20:53 -04:00
item_initial_charges = jsonObject.getInt("item_initial_charges");
2024-02-24 08:01:22 -05:00
2024-04-22 12:20:53 -04:00
JSONArray skill_required = jsonObject.getJSONArray("item_skill_req");
2024-02-24 08:32:05 -05:00
if (skill_required.isEmpty() == false)
for (Object o : skill_required) {
JSONObject skill_req = (JSONObject) o;
2024-04-22 12:20:53 -04:00
String skill_type = skill_req.getString("skill_type");
int skill_level = skill_req.getInt("skill_level");
2024-03-10 14:53:14 -04:00
if (skill_type.equals("Cloth") == false)
item_skill_required.put(skill_type, skill_level);
}
2024-02-24 14:12:16 -05:00
2024-04-22 12:20:53 -04:00
JSONObject race_required = jsonObject.getJSONObject("item_race_req");
boolean restrict = race_required.getBoolean("restrict");
JSONArray races = race_required.getJSONArray("races");
2024-02-24 14:12:16 -05:00
if (races.isEmpty() == false)
for (Object o : races) {
String race = (String) o;
race = race.replaceAll("\\s", "");
race = race.replaceAll(",", "");
race = race.replaceAll("-", "");
if (restrict)
item_race_res.add(mbEnums.MonsterType.valueOf(race));
else
item_race_req.add(mbEnums.MonsterType.valueOf(race));
}
2024-02-24 14:12:16 -05:00
2024-04-22 12:20:53 -04:00
JSONObject class_required = jsonObject.getJSONObject("item_class_req");
restrict = class_required.getBoolean("restrict");
JSONArray classes = class_required.getJSONArray("classes");
2024-02-24 14:24:02 -05:00
if (classes.isEmpty() == false)
for (Object o : classes) {
String classEntry = (String) o;
classEntry = classEntry.replaceAll("\\s", "");
classEntry = classEntry.replaceAll(",", "");
2024-02-24 14:24:02 -05:00
if (restrict)
item_class_res.add(mbEnums.ClassType.valueOf(classEntry));
else
item_class_req.add(mbEnums.ClassType.valueOf(classEntry));
}
2024-02-24 14:24:02 -05:00
2024-04-22 12:20:53 -04:00
JSONObject disc_required = jsonObject.getJSONObject("item_disc_req");
restrict = disc_required.getBoolean("restrict");
JSONArray discs = disc_required.getJSONArray("discs");
2024-02-24 14:28:28 -05:00
if (discs.isEmpty() == false)
for (Object o : discs) {
String disc = (String) o;
disc = disc.replaceAll("\\s", "");
disc = disc.replaceAll(",", "");
2024-02-24 14:28:28 -05:00
if (restrict)
item_disc_res.add(mbEnums.DisciplineType.valueOf(disc));
else
item_disc_req.add(mbEnums.DisciplineType.valueOf(disc));
}
2024-02-24 14:28:28 -05:00
2024-04-22 12:20:53 -04:00
item_level_req = jsonObject.getInt("item_level_req");
item_sex_req = mbEnums.SexType.valueOf(jsonObject.getString("item_sex_req"));
2024-02-27 12:51:14 -05:00
2024-04-22 12:20:53 -04:00
JSONArray userPowerActions = jsonObject.getJSONArray("item_user_power_action");
2024-02-27 13:06:14 -05:00
2024-02-27 15:16:18 -05:00
if (userPowerActions.isEmpty() == false)
for (Object o : userPowerActions) {
JSONObject powerActionEntry = (JSONObject) o;
2024-04-22 12:20:53 -04:00
String power = powerActionEntry.getString("power");
JSONArray args = powerActionEntry.getJSONArray("arguments");
int[] arguments = {args.getInt(0), args.getInt(1)};
item_user_power_action.put(power, arguments);
}
2024-02-27 13:47:50 -05:00
2024-04-22 12:20:53 -04:00
JSONArray powerGrantsArray = jsonObject.getJSONArray("item_power_grant");
2024-04-01 15:53:36 -04:00
2024-04-01 16:12:52 -04:00
if (powerGrantsArray.isEmpty() == false) {
2024-04-01 15:53:36 -04:00
2024-04-01 16:20:03 -04:00
for (Object grantArrayEntry : powerGrantsArray) {
JSONObject powerGrantEntry = (JSONObject) grantArrayEntry;
2024-04-22 12:20:53 -04:00
String power_type = powerGrantEntry.getString("power_type");
int power_value = powerGrantEntry.getInt("power_value");
2024-04-01 16:32:17 -04:00
item_power_grant.put(power_type, power_value);
2024-04-04 09:43:41 -04:00
2024-04-22 12:20:53 -04:00
JSONArray skill_granted_array = powerGrantEntry.getJSONArray("power_granted_skills");
2024-04-04 09:43:41 -04:00
for (Object skillGrantEntry : skill_granted_array) {
JSONArray skill_entry = (JSONArray) skillGrantEntry;
2024-04-22 12:20:53 -04:00
String skill_type = skill_entry.getString(0);
int skill_level = skill_entry.getInt(1);
2024-04-04 09:52:19 -04:00
power_granted_skills.put(skill_type, skill_level);
2024-04-04 09:43:41 -04:00
}
2024-02-27 13:48:21 -05:00
}
2024-04-01 15:53:36 -04:00
}
2024-02-27 13:47:50 -05:00
2024-04-22 12:20:53 -04:00
JSONArray item_power_actions = jsonObject.getJSONArray("item_power_action");
2024-02-27 15:16:18 -05:00
if (item_power_actions.isEmpty() == false)
for (Object o : item_power_actions) {
JSONObject powerActionEntry = (JSONObject) o;
2024-04-22 12:20:53 -04:00
String power = powerActionEntry.getString("power_type");
JSONArray power_actions = powerActionEntry.getJSONArray("power_actions");
JSONObject argument_entry = power_actions.getJSONObject(0);
JSONArray power_args = argument_entry.getJSONArray("power_arguments");
int[] power_arguments = {power_args.getInt(0), power_args.getInt(1)};
2024-02-27 15:40:55 -05:00
item_power_action.put(power, power_arguments);
2024-02-27 15:16:18 -05:00
}
2024-02-27 13:47:50 -05:00
2024-04-22 12:20:53 -04:00
JSONArray resource_costs = jsonObject.getJSONArray("item_resource_costs");
2024-02-27 16:35:36 -05:00
if (resource_costs.isEmpty() == false)
for (Object o : resource_costs) {
JSONObject resource_entry = (JSONObject) o;
2024-04-22 12:20:53 -04:00
mbEnums.ResourceType resource_type = mbEnums.ResourceType.valueOf(resource_entry.getString("resource_type").toUpperCase());
int resource_value = resource_entry.getInt("resource_value");
2024-02-27 16:35:36 -05:00
item_resource_cost.put(resource_type, resource_value);
}
2024-03-11 12:07:46 -04:00
// Deed related fields
if (item_type.equals(mbEnums.ItemType.DEED)) {
2024-03-16 07:27:20 -04:00
2024-04-22 12:20:53 -04:00
deed_type = jsonObject.getInt("deed_type");
deed_furniture_id = jsonObject.getInt("deed_furniture_id");
deed_target_id = jsonObject.getInt("deed_target_id");
deed_employment = jsonObject.getInt("deed_employment");
deed_start_rank = jsonObject.getInt("deed_start_rank");
deed_name_lookup = jsonObject.getInt("deed_name_lookup");
deed_indoors = jsonObject.getBoolean("deed_indoors");
deed_is_fortress = jsonObject.getBoolean("deed_is_fortress");
deed_namelookup_val = jsonObject.getFloat("deed_namelookup_val");
deed_custom_city = jsonObject.getBoolean("deed_custom_city");
deed_structure_id = jsonObject.getInt("deed_structure_id");
2024-03-11 12:07:46 -04:00
}
if (item_type.equals(mbEnums.ItemType.RUNE)) {
2024-04-02 14:11:01 -04:00
2024-04-22 12:20:53 -04:00
rune_type = jsonObject.getString("rune_type");
2024-04-04 10:23:21 -04:00
Object subType = jsonObject.get("rune_sub_type");
if (subType instanceof String)
rune_sub_type = (String) subType;
2024-04-22 12:20:53 -04:00
rune_is_standard_character_creation = jsonObject.getBoolean("rune_is_standard_character_creation");
rune_creation_cost = jsonObject.getInt("rune_creation_cost");
rune_rank = jsonObject.getInt("rune_rank");
rune_pracs_per_level = jsonObject.getInt("rune_pracs_per_level");
rune_exp_req_to_level = jsonObject.getFloat("rune_exp_req_to_level");
rune_sex = mbEnums.SexType.valueOf(jsonObject.getString("rune_sex"));
rune_class_icon = jsonObject.getInt("rune_class_icon");
rune_health = jsonObject.getInt("rune_health");
rune_mana = jsonObject.getInt("rune_mana");
rune_stamina = jsonObject.getInt("rune_stamina");
rune_min_damage = jsonObject.getFloat("rune_min_damage");
rune_max_damage = jsonObject.getFloat("rune_max_damage");
rune_attack = jsonObject.getInt("rune_attack");
rune_defense = jsonObject.getInt("rune_defense");
rune_level = jsonObject.getInt("rune_level");
JSONObject rune_speed_json = jsonObject.getJSONObject("rune_speed");
2024-04-04 10:37:12 -04:00
2024-04-22 09:21:46 -04:00
for (String key : rune_speed_json.keySet()) {
2024-04-22 12:20:53 -04:00
mbEnums.MovementType movementType = mbEnums.MovementType.valueOf(key);
float speed = rune_speed_json.getFloat(key);
2024-04-04 10:37:12 -04:00
rune_speed.put(movementType, speed);
}
2024-04-04 10:46:40 -04:00
2024-04-22 12:20:53 -04:00
JSONObject rune_group = jsonObject.getJSONObject("rune_group");
2024-04-04 11:00:19 -04:00
2024-04-22 12:20:53 -04:00
rune_group_type = rune_group.getInt("group_type");
rune_group_is_faction = rune_group.getBoolean("group_is_faction");
rune_group_is_guild = rune_group.getBoolean("group_is_guild");
rune_dsc = jsonObject.getString("rune_dsc");
rune_fx_txt = jsonObject.getString("rune_fx_txt");
2024-04-04 15:05:25 -04:00
2024-04-22 12:50:45 -04:00
long group_tactics_bitvector = jsonObject.getLong("rune_group_tactics");
2024-04-04 15:18:43 -04:00
2024-04-22 12:50:45 -04:00
rune_group_tactics.addAll(mbEnums.fromLong(group_tactics_bitvector, mbEnums.MobBehaviourType.class));
2024-04-04 15:05:25 -04:00
2024-04-22 12:50:45 -04:00
long group_role_bitvector = jsonObject.getLong("rune_group_role_set");
2024-04-04 15:18:43 -04:00
2024-04-22 12:50:45 -04:00
rune_group_role_set.addAll(mbEnums.fromLong(group_role_bitvector, mbEnums.MobBehaviourType.class));
2024-04-22 12:20:53 -04:00
JSONArray enemy_types_json = jsonObject.getJSONArray("rune_enemy_monster_types");
2024-04-04 13:13:14 -04:00
for (Object o : enemy_types_json) {
String enemy = (String) o;
2024-04-04 13:14:21 -04:00
enemy = enemy.replaceAll("-", "");
mbEnums.MonsterType monsterType = mbEnums.MonsterType.valueOf(enemy);
2024-04-04 13:13:14 -04:00
rune_enemy_monster_types.add(monsterType);
}
2024-04-22 12:20:53 -04:00
JSONArray not_enemy_types_json = jsonObject.getJSONArray("rune_not_enemy_monster_types");
2024-04-04 13:15:53 -04:00
2024-04-04 13:18:37 -04:00
for (Object o : not_enemy_types_json) {
2024-04-04 13:15:53 -04:00
String notenemy = (String) o;
notenemy = notenemy.replaceAll("-", "");
mbEnums.MonsterType monsterType = mbEnums.MonsterType.valueOf(notenemy);
2024-04-04 13:18:19 -04:00
rune_not_enemy_monster_types.add(monsterType);
2024-04-04 13:15:53 -04:00
}
2024-04-22 12:20:53 -04:00
JSONArray groupee_types_json = jsonObject.getJSONArray("rune_groupee_monster_types");
2024-04-04 14:27:07 -04:00
for (Object o : groupee_types_json) {
2024-04-22 13:38:04 -04:00
int groupeeId = (int) o;
2024-04-04 14:27:07 -04:00
rune_groupee_monster_types.add(groupeeId);
}
2024-04-22 12:20:53 -04:00
JSONArray helper_types_json = jsonObject.getJSONArray("rune_helper_monster_types");
2024-04-04 14:27:07 -04:00
for (Object o : helper_types_json) {
2024-04-22 13:38:04 -04:00
int helperId = (int) o;
2024-04-04 14:27:07 -04:00
rune_helper_monster_types.add(helperId);
}
2024-04-22 12:20:53 -04:00
rune_renderable = jsonObject.getBoolean("rune_renderable");
rune_natural_power_attack = jsonObject.getInt("rune_natural_power_attack");
2024-04-04 11:13:58 -04:00
2024-04-22 12:20:53 -04:00
JSONObject rune_sparse_json = jsonObject.getJSONObject("rune_sparse_data");
2024-04-04 11:13:58 -04:00
2024-04-26 15:37:37 -04:00
for (String sparseType : rune_sparse_json.keySet()) {
2024-04-22 13:18:41 -04:00
Object sparseValue = rune_sparse_json.get(sparseType);
rune_sparse_data.put(sparseType, sparseValue.toString());
2024-04-04 11:13:58 -04:00
}
2024-04-04 09:54:52 -04:00
2024-04-04 11:54:01 -04:00
JSONArray skill_adj_json = (JSONArray) jsonObject.get("rune_skill_adj");
for (Object skillEntry : skill_adj_json) {
JSONObject skill = (JSONObject) skillEntry;
2024-04-22 12:20:53 -04:00
String typeString = skill.getString("skill_type");
JSONArray adjArray = skill.getJSONArray("skill_adjusts");
2024-04-04 11:54:01 -04:00
2024-04-04 12:16:29 -04:00
for (Object adjustList : adjArray) {
JSONArray adjustEntry = (JSONArray) adjustList;
2024-04-22 12:20:53 -04:00
int[] adjust = {adjustEntry.getInt(0), adjustEntry.getInt(1)};
2024-04-04 12:16:29 -04:00
rune_skill_adj.put(typeString, adjust);
}
}
2024-04-22 12:20:53 -04:00
JSONArray attr_adj_json = jsonObject.getJSONArray("rune_attr_adj");
2024-04-02 14:37:01 -04:00
2024-04-02 14:41:22 -04:00
for (Object attributeEntry : attr_adj_json) {
JSONObject attribute = (JSONObject) attributeEntry;
2024-04-22 12:20:53 -04:00
String typeString = attribute.getString("attr_type");
mbEnums.AttributeType attributeType = mbEnums.AttributeType.valueOf(typeString);
2024-04-22 12:20:53 -04:00
int attributeValue = attribute.getInt("attr_value");
2024-04-02 14:41:22 -04:00
rune_attr_adj.put(attributeType, attributeValue);
2024-04-02 14:11:01 -04:00
}
2024-04-22 12:20:53 -04:00
JSONArray max_attr_adj_json = jsonObject.getJSONArray("rune_max_attr_adj");
for (Object attributeEntry : max_attr_adj_json) {
JSONObject attribute = (JSONObject) attributeEntry;
2024-04-22 12:20:53 -04:00
String typeString = attribute.getString("attr_type");
mbEnums.AttributeType attributeType = mbEnums.AttributeType.valueOf(typeString);
2024-04-22 12:20:53 -04:00
int attributeValue = attribute.getInt("attr_value");
rune_max_attr_adj.put(attributeType, attributeValue);
}
2024-04-22 12:20:53 -04:00
JSONArray skill_grant_json = jsonObject.getJSONArray("rune_skill_grant");
2024-04-02 14:11:01 -04:00
2024-04-02 15:17:33 -04:00
if (skill_grant_json.isEmpty() == false)
2024-04-04 09:43:41 -04:00
for (Object runeSkillEntry : skill_grant_json) {
JSONObject skill_granted = (JSONObject) runeSkillEntry;
2024-04-22 12:20:53 -04:00
String typeString = skill_granted.getString("skill_type");
int skill_level = skill_granted.getInt("skill_value");
2024-04-02 15:24:52 -04:00
rune_skill_grant.put(typeString, skill_level);
2024-04-03 13:40:24 -04:00
2024-04-22 12:20:53 -04:00
JSONArray skill_granted_array = skill_granted.getJSONArray("skill_granted_skills");
2024-04-03 13:40:24 -04:00
2024-04-04 09:43:41 -04:00
for (Object skillGrantEntry : skill_granted_array) {
JSONArray skill_entry = (JSONArray) skillGrantEntry;
2024-04-22 12:20:53 -04:00
typeString = skill_entry.getString(0);
skill_level = skill_entry.getInt(1);
2024-04-04 09:34:44 -04:00
skill_granted_skills.put(typeString, skill_level);
}
2024-04-02 15:17:33 -04:00
}
}
2024-04-02 14:11:01 -04:00
2024-02-24 09:07:05 -05:00
} catch (Exception e) {
2024-04-04 10:47:55 -04:00
Logger.error(obj_name + ":" + e);
2024-02-24 08:32:05 -05:00
}
2024-03-10 16:21:23 -04:00
}
2024-02-18 11:00:56 -05:00
}