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

602 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 14:03:41 -05:00
import engine.Enum;
2024-02-18 11:39:11 -05:00
import engine.math.Vector3fImmutable;
import org.json.simple.JSONArray;
2024-02-18 11:00:56 -05:00
import org.json.simple.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-02-18 11:39:11 -05:00
// Global template lookup
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-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<>();
2024-02-18 14:03:41 -05:00
public Enum.ItemType item_type;
public int item_eq_slots_value;
public boolean item_eq_slots_type;
2024-04-04 13:27:43 -04:00
public final EnumSet<Enum.EquipSlotType> item_eq_slots_or = EnumSet.noneOf(Enum.EquipSlotType.class);
public final EnumSet<Enum.EquipSlotType> item_eq_slots_and = EnumSet.noneOf(Enum.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;
2024-04-04 13:27:43 -04:00
public final HashMap<Enum.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;
2024-04-04 13:27:43 -04:00
public final HashMap<Enum.DamageType, int[]> item_weapon_damage = new HashMap<>();
public final ArrayList<int[]> weapon_attack_anim_right = new ArrayList<>();
public final ArrayList<int[]> weapon_attack_anim_left = new ArrayList<>();
2024-02-27 14:14:16 -05:00
public Enum.AttributeType item_primary_attr = Enum.AttributeType.None;
public Enum.AttributeType item_secondary_attr = Enum.AttributeType.None;
2024-04-04 13:27:43 -04:00
public final EnumSet<Enum.ItemFlags> item_flags = EnumSet.noneOf(Enum.ItemFlags.class);
public final EnumSet<Enum.ItemUseFlags> item_use_flags = EnumSet.noneOf(Enum.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<Enum.MonsterType> item_race_req = EnumSet.noneOf(Enum.MonsterType.class);
public final EnumSet<Enum.MonsterType> item_race_res = EnumSet.noneOf(Enum.MonsterType.class);
public final EnumSet<Enum.ClassType> item_class_req = EnumSet.noneOf(Enum.ClassType.class);
public final EnumSet<Enum.ClassType> item_class_res = EnumSet.noneOf(Enum.ClassType.class);
public final EnumSet<Enum.DisciplineType> item_disc_req = EnumSet.noneOf(Enum.DisciplineType.class);
public final EnumSet<Enum.DisciplineType> item_disc_res = EnumSet.noneOf(Enum.DisciplineType.class);
2024-02-27 12:51:14 -05:00
public int item_level_req;
public Enum.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<Enum.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;
2024-04-04 13:27:43 -04:00
public final HashMap<Enum.AttributeType, Integer> rune_attr_adj = new HashMap<>();
public final HashMap<Enum.AttributeType, Integer> rune_max_attr_adj = new HashMap<>();
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;
2024-04-04 10:13:25 -04:00
public Enum.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;
2024-04-04 13:27:43 -04:00
public final HashMap<Enum.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;
public int rune_group_tactics;
public int rune_group_role_set;
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<Enum.MonsterType> rune_enemy_monster_types = EnumSet.noneOf(Enum.MonsterType.class);
public final EnumSet<Enum.MonsterType> rune_not_enemy_monster_types = EnumSet.noneOf(Enum.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-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-02-24 09:07:05 -05:00
obj_name = (String) jsonObject.get("obj_name");
2024-02-18 11:55:45 -05:00
2024-02-27 14:05:57 -05:00
// Reading a boolean
obj_pickable = (boolean) jsonObject.get("obj_pickable");
// Reading floats from an array (note always check for empty arrays)
2024-02-18 12:28:14 -05:00
2024-02-24 09:07:05 -05:00
JSONArray scaleData = (JSONArray) jsonObject.get("obj_scale");
2024-02-27 13:55:26 -05:00
if (scaleData.isEmpty() == false)
obj_scale = new Vector3fImmutable(((Double) scaleData.get(0)).floatValue(), ((Double) scaleData.get(1)).floatValue(),
((Double) scaleData.get(2)).floatValue());
2024-02-18 11:55:45 -05:00
2024-02-27 13:55:26 -05:00
JSONArray forwardVector = (JSONArray) jsonObject.get("obj_forward_vector");
if (forwardVector.isEmpty() == false)
obj_forward_vector = new Vector3fImmutable(((Double) forwardVector.get(0)).floatValue(), ((Double) forwardVector.get(1)).floatValue(),
((Double) forwardVector.get(2)).floatValue());
JSONArray defaultAlighment = (JSONArray) jsonObject.get("obj_default_alignment");
if (defaultAlighment.isEmpty() == false)
obj_default_alignment = new Vector3fImmutable(((Double) defaultAlighment.get(0)).floatValue(), ((Double) defaultAlighment.get(1)).floatValue(),
((Double) defaultAlighment.get(2)).floatValue());
2024-02-24 09:07:05 -05:00
// Reading an integer value
2024-02-18 12:28:14 -05:00
2024-02-24 09:07:05 -05:00
obj_render_object = ((Long) jsonObject.get("obj_render_object")).intValue();
obj_icon = ((Long) jsonObject.get("obj_icon")).intValue();
2024-02-18 12:15:13 -05:00
2024-04-04 11:13:58 -04:00
JSONObject obj_sparse_json = (JSONObject) jsonObject.get("obj_sparse_data");
for (Object key : obj_sparse_json.keySet()) {
String sparseType = (String) key;
2024-04-04 11:43:02 -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-02-24 09:07:05 -05:00
// Reading float values
2024-02-18 12:35:55 -05:00
2024-02-24 09:07:05 -05:00
combat_health_current = ((Double) jsonObject.get("combat_health_current")).floatValue();
combat_health_full = ((Double) jsonObject.get("combat_health_full")).floatValue();
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-02-24 09:07:05 -05:00
JSONObject resist_json = (JSONObject) jsonObject.get("combat_attack_resist");
2024-02-18 12:26:11 -05:00
2024-02-24 09:07:05 -05:00
for (Object key : resist_json.keySet()) {
float resist = ((Double) resist_json.get(key)).floatValue();
combat_attack_resist.put((String) key, resist);
}
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-02-24 09:07:05 -05:00
item_type = Enum.ItemType.valueOf((String) jsonObject.get("item_type"));
item_eq_slots_value = ((Long) jsonObject.get("item_eq_slots_value")).intValue();
item_eq_slots_type = (boolean) jsonObject.get("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-02-24 09:07:05 -05:00
JSONArray eq_slots_or = (JSONArray) jsonObject.get("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)
2024-03-08 12:19:57 -05:00
item_eq_slots_or.add(Enum.EquipSlotType.valueOf((String) o));
2024-02-18 11:00:56 -05:00
2024-02-24 09:07:05 -05:00
JSONArray eq_slots_and = (JSONArray) jsonObject.get("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)
2024-03-08 12:19:57 -05:00
item_eq_slots_and.add(Enum.EquipSlotType.valueOf((String) o));
2024-02-18 14:17:11 -05:00
2024-02-28 14:59:17 -05:00
item_takeable = (boolean) jsonObject.get("item_takeable");
2024-02-24 09:07:05 -05:00
item_value = ((Long) jsonObject.get("item_value")).intValue();
item_wt = ((Long) jsonObject.get("item_wt")).intValue();
item_passive_defense_mod = ((Double) jsonObject.get("item_passive_defense_mod")).floatValue();
item_base_name = (String) jsonObject.get("item_base_name");
item_dsc = (String) jsonObject.get("item_dsc");
item_render_object_female = ((Long) jsonObject.get("item_render_object_female")).intValue();
item_health_full = ((Double) jsonObject.get("item_health_full")).floatValue();
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-02-24 09:07:05 -05:00
item_parry_anim_id = ((Long) jsonObject.get("item_parry_anim_id")).intValue();
2024-02-24 08:42:19 -05:00
2024-03-07 20:32:35 -05:00
// Reading offering data
2024-03-07 20:39:31 -05:00
JSONArray offering_data = (JSONArray) jsonObject.get("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;
String offering_type = ((String) offering_entry.get("offering_type")).replaceAll("-", "");
2024-03-07 20:40:32 -05:00
int offering_value = ((Long) offering_entry.get("offering_value")).intValue();
2024-03-11 00:53:14 -04:00
item_offering_info.put(Enum.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
2024-02-24 14:52:52 -05:00
if (item_type.equals(Enum.ItemType.ARMOR)) {
2024-02-24 09:07:05 -05:00
item_bulk_factor = ((Double) jsonObject.get("item_bulk_factor")).floatValue();
2024-02-26 03:10:11 -05:00
item_defense_rating = ((Long) jsonObject.get("item_defense_rating")).intValue();
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
2024-02-24 15:25:06 -05:00
if (item_type.equals(Enum.ItemType.WEAPON)) {
2024-02-24 15:41:48 -05:00
JSONObject item_weapon = (JSONObject) jsonObject.get("item_weapon");
item_weapon_wepspeed = ((Double) item_weapon.get("weapon_wepspeed")).floatValue();
item_weapon_max_range = ((Double) item_weapon.get("weapon_max_range")).floatValue();
item_weapon_projectile_id = ((Long) item_weapon.get("weapon_projectile_id")).intValue();
item_weapon_projectile_speed = ((Double) item_weapon.get("weapon_projectile_speed")).floatValue();
item_weapon_combat_idle_anim = ((Long) item_weapon.get("weapon_combat_idle_anim")).intValue();
2024-02-24 15:45:22 -05:00
JSONArray weapon_damage = (JSONArray) item_weapon.get("weapon_damage");
if (weapon_damage.isEmpty() == false)
for (Object o : weapon_damage) {
JSONObject damage_entry = (JSONObject) o;
2024-04-01 12:41:33 -04:00
Enum.DamageType damageType = Enum.DamageType.getDamageType(((String) damage_entry.get("damage_type")));
int min = ((Long) damage_entry.get("damage_min")).intValue();
int max = ((Long) damage_entry.get("damage_max")).intValue();
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-02-27 14:42:35 -05:00
JSONArray attack_anim_right = (JSONArray) item_weapon.get("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-02-27 14:52:07 -05:00
int animation = ((Long) animationEntry.get(0)).intValue();
int duration = ((Long) animationEntry.get(1)).intValue();
2024-02-27 14:36:27 -05:00
weapon_attack_anim_right.add(new int[]{animation, duration});
}
2024-02-27 14:48:55 -05:00
JSONArray attack_anim_left = (JSONArray) item_weapon.get("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-02-27 14:53:06 -05:00
int animation = ((Long) animationEntry.get(0)).intValue();
int duration = ((Long) animationEntry.get(1)).intValue();
2024-02-27 14:36:27 -05:00
weapon_attack_anim_left.add(new int[]{animation, duration});
}
2024-02-27 14:14:16 -05:00
item_primary_attr = Enum.AttributeType.valueOf((String) jsonObject.get("item_primary_attr"));
item_secondary_attr = Enum.AttributeType.valueOf((String) jsonObject.get("item_secondary_attr"));
2024-02-24 15:25:06 -05:00
}
2024-02-24 09:07:05 -05:00
JSONArray itemflags = (JSONArray) jsonObject.get("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(Enum.ItemFlags.valueOf((String) o));
}
2024-02-24 07:49:13 -05:00
2024-02-24 09:07:05 -05:00
JSONArray itemUseflags = (JSONArray) jsonObject.get("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(Enum.ItemUseFlags.valueOf((String) o));
2024-02-24 08:01:22 -05:00
2024-02-24 09:07:05 -05:00
item_initial_charges = ((Long) jsonObject.get("item_initial_charges")).intValue();
2024-02-24 08:01:22 -05:00
2024-02-24 09:07:05 -05:00
JSONArray skill_required = (JSONArray) jsonObject.get("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;
String skill_type = (String) skill_req.get("skill_type");
int skill_level = ((Long) skill_req.get("skill_level")).intValue();
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
JSONObject race_required = (JSONObject) jsonObject.get("item_race_req");
boolean restrict = ((Boolean) race_required.get("restrict"));
JSONArray races = (JSONArray) race_required.get("races");
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(Enum.MonsterType.valueOf(race));
else
item_race_req.add(Enum.MonsterType.valueOf(race));
}
2024-02-24 14:12:16 -05:00
2024-02-24 14:24:02 -05:00
JSONObject class_required = (JSONObject) jsonObject.get("item_class_req");
restrict = ((Boolean) class_required.get("restrict"));
JSONArray classes = (JSONArray) class_required.get("classes");
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(Enum.ClassType.valueOf(classEntry));
else
item_class_req.add(Enum.ClassType.valueOf(classEntry));
}
2024-02-24 14:24:02 -05:00
2024-02-24 14:28:28 -05:00
JSONObject disc_required = (JSONObject) jsonObject.get("item_disc_req");
restrict = ((Boolean) disc_required.get("restrict"));
2024-02-24 14:31:08 -05:00
JSONArray discs = (JSONArray) disc_required.get("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(Enum.DisciplineType.valueOf(disc));
else
item_disc_req.add(Enum.DisciplineType.valueOf(disc));
}
2024-02-24 14:28:28 -05:00
2024-02-27 12:51:14 -05:00
item_level_req = ((Long) jsonObject.get("item_level_req")).intValue();
item_sex_req = Enum.SexType.valueOf((String) jsonObject.get("item_sex_req"));
2024-02-27 15:16:18 -05:00
JSONArray userPowerActions = (JSONArray) jsonObject.get("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;
String power = (String) powerActionEntry.get("power");
JSONArray args = (JSONArray) powerActionEntry.get("arguments");
int[] arguments = {((Long) args.get(0)).intValue(), ((Long) args.get(1)).intValue()};
item_user_power_action.put(power, arguments);
}
2024-02-27 13:47:50 -05:00
2024-04-01 16:12:52 -04:00
JSONArray powerGrantsArray = (JSONArray) jsonObject.get("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-01 16:32:17 -04:00
String power_type = (String) powerGrantEntry.get("power_type");
int power_value = ((Long) powerGrantEntry.get("power_value")).intValue();
item_power_grant.put(power_type, power_value);
2024-04-04 09:43:41 -04:00
JSONArray skill_granted_array = (JSONArray) powerGrantEntry.get("power_granted_skills");
for (Object skillGrantEntry : skill_granted_array) {
JSONArray skill_entry = (JSONArray) skillGrantEntry;
String skill_type = (String) skill_entry.get(0);
int skill_level = ((Long) skill_entry.get(1)).intValue();
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 16:32:17 -04:00
2024-04-01 15:53:36 -04:00
}
2024-02-27 13:47:50 -05:00
2024-02-27 15:16:38 -05:00
JSONArray item_power_actions = (JSONArray) jsonObject.get("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;
String power = (String) powerActionEntry.get("power_type");
2024-02-27 15:35:03 -05:00
JSONArray power_actions = (JSONArray) powerActionEntry.get("power_actions");
2024-02-27 15:47:04 -05:00
JSONObject argument_entry = (JSONObject) power_actions.get(0);
JSONArray power_args = (JSONArray) argument_entry.get("power_arguments");
2024-02-27 15:40:55 -05:00
int[] power_arguments = {((Long) power_args.get(0)).intValue(), ((Long) power_args.get(1)).intValue()};
item_power_action.put(power, power_arguments);
2024-02-27 15:16:18 -05:00
}
2024-02-27 13:47:50 -05:00
2024-02-27 16:35:36 -05:00
JSONArray resource_costs = (JSONArray) jsonObject.get("item_resource_costs");
if (resource_costs.isEmpty() == false)
for (Object o : resource_costs) {
JSONObject resource_entry = (JSONObject) o;
2024-02-27 16:38:10 -05:00
Enum.ResourceType resource_type = Enum.ResourceType.valueOf(((String) resource_entry.get("resource_type")).toUpperCase());
2024-02-27 16:35:36 -05:00
int resource_value = ((Long) resource_entry.get("resource_value")).intValue();
item_resource_cost.put(resource_type, resource_value);
}
2024-03-11 12:07:46 -04:00
// Deed related fields
if (item_type.equals(Enum.ItemType.DEED)) {
2024-03-16 07:27:20 -04:00
deed_type = ((Long) jsonObject.get("deed_type")).intValue();
deed_furniture_id = ((Long) jsonObject.get("deed_furniture_id")).intValue();
deed_target_id = ((Long) jsonObject.get("deed_target_id")).intValue();
deed_employment = ((Long) jsonObject.get("deed_employment")).intValue();
deed_start_rank = ((Long) jsonObject.get("deed_start_rank")).intValue();
2024-03-16 07:41:16 -04:00
deed_name_lookup = ((Long) jsonObject.get("deed_name_lookup")).intValue();
deed_indoors = ((Boolean) jsonObject.get("deed_indoors"));
deed_is_fortress = ((Boolean) jsonObject.get("deed_is_fortress"));
2024-03-16 07:27:20 -04:00
deed_namelookup_val = ((Double) jsonObject.get("deed_namelookup_val")).floatValue();
2024-03-16 07:41:16 -04:00
deed_custom_city = ((Boolean) jsonObject.get("deed_custom_city"));
2024-03-11 12:07:46 -04:00
deed_structure_id = ((Long) jsonObject.get("deed_structure_id")).intValue();
}
2024-04-02 14:11:01 -04:00
if (item_type.equals(Enum.ItemType.RUNE)) {
2024-04-04 09:54:52 -04:00
rune_type = (String) jsonObject.get("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-04 09:56:25 -04:00
rune_is_standard_character_creation = ((Boolean) jsonObject.get("rune_is_standard_character_creation"));
2024-04-04 10:13:25 -04:00
rune_creation_cost = ((Long) jsonObject.get("rune_creation_cost")).intValue();
rune_rank = ((Long) jsonObject.get("rune_rank")).intValue();
rune_pracs_per_level = ((Long) jsonObject.get("rune_pracs_per_level")).intValue();
rune_exp_req_to_level = ((Double) jsonObject.get("rune_exp_req_to_level")).floatValue();
rune_sex = Enum.SexType.valueOf((String) jsonObject.get("rune_sex"));
2024-04-04 10:37:12 -04:00
rune_class_icon = ((Long) jsonObject.get("rune_class_icon")).intValue();
2024-04-04 10:54:22 -04:00
rune_health = ((Long) jsonObject.get("rune_health")).intValue();
2024-04-04 10:37:12 -04:00
rune_mana = ((Long) jsonObject.get("rune_mana")).intValue();
rune_stamina = ((Long) jsonObject.get("rune_stamina")).intValue();
rune_min_damage = ((Double) jsonObject.get("rune_min_damage")).floatValue();
rune_max_damage = ((Double) jsonObject.get("rune_max_damage")).floatValue();
rune_attack = ((Long) jsonObject.get("rune_attack")).intValue();
rune_defense = ((Long) jsonObject.get("rune_defense")).intValue();
rune_level = ((Long) jsonObject.get("rune_level")).intValue();
JSONObject rune_speed_json = (JSONObject) jsonObject.get("rune_speed");
2024-04-04 10:46:40 -04:00
for (Object key : rune_speed_json.keySet()) {
2024-04-04 10:37:12 -04:00
Enum.MovementType movementType = Enum.MovementType.valueOf((String) key);
float speed = ((Double) rune_speed_json.get(key)).floatValue();
rune_speed.put(movementType, speed);
}
2024-04-04 10:46:40 -04:00
2024-04-04 11:00:19 -04:00
JSONObject rune_group = (JSONObject) jsonObject.get("rune_group");
rune_group_type = ((Long) rune_group.get("group_type")).intValue();
rune_group_is_faction = ((Boolean) rune_group.get("group_is_faction"));
2024-04-04 11:02:50 -04:00
rune_group_is_guild = ((Boolean) rune_group.get("group_is_guild"));
rune_dsc = (String) jsonObject.get("rune_dsc");
rune_fx_txt = (String) jsonObject.get("rune_fx_txt");
rune_group_tactics = ((Long) jsonObject.get("rune_group_tactics")).intValue();
2024-04-04 15:02:19 -04:00
EnumSet<Enum.MobBehaviourType> tactics = Enum.fromLong(rune_group_tactics, Enum.MobBehaviourType.class);
rune_group_role_set = ((Long) jsonObject.get("rune_group_role_set")).intValue();
2024-04-04 13:13:14 -04:00
JSONArray enemy_types_json = (JSONArray) jsonObject.get("rune_enemy_monster_types");
for (Object o : enemy_types_json) {
String enemy = (String) o;
2024-04-04 13:14:21 -04:00
enemy = enemy.replaceAll("-", "");
2024-04-04 13:13:14 -04:00
Enum.MonsterType monsterType = Enum.MonsterType.valueOf(enemy);
rune_enemy_monster_types.add(monsterType);
}
2024-04-04 13:15:53 -04:00
JSONArray not_enemy_types_json = (JSONArray) jsonObject.get("rune_not_enemy_monster_types");
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("-", "");
Enum.MonsterType monsterType = Enum.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-04 14:27:07 -04:00
JSONArray groupee_types_json = (JSONArray) jsonObject.get("rune_groupee_monster_types");
for (Object o : groupee_types_json) {
int groupeeId = ((Long) o).intValue();
rune_groupee_monster_types.add(groupeeId);
}
JSONArray helper_types_json = (JSONArray) jsonObject.get("rune_helper_monster_types");
for (Object o : helper_types_json) {
int helperId = ((Long) o).intValue();
rune_helper_monster_types.add(helperId);
}
rune_renderable = ((Boolean) jsonObject.get("rune_renderable"));
rune_natural_power_attack = ((Long) jsonObject.get("rune_natural_power_attack")).intValue();
2024-04-04 11:13:58 -04:00
2024-04-04 11:15:47 -04:00
JSONObject rune_sparse_json = (JSONObject) jsonObject.get("rune_sparse_data");
2024-04-04 11:13:58 -04:00
for (Object key : rune_sparse_json.keySet()) {
String sparseType = (String) key;
2024-04-04 11:43:02 -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;
String typeString = (String) skill.get("skill_type");
JSONArray adjArray = (JSONArray) skill.get("skill_adjusts");
2024-04-04 12:16:29 -04:00
for (Object adjustList : adjArray) {
JSONArray adjustEntry = (JSONArray) adjustList;
int[] adjust = {((Long) adjustEntry.get(0)).intValue(), ((Long) adjustEntry.get(1)).intValue()};
rune_skill_adj.put(typeString, adjust);
}
}
2024-04-02 14:37:01 -04:00
JSONArray attr_adj_json = (JSONArray) jsonObject.get("rune_attr_adj");
2024-04-02 14:41:22 -04:00
for (Object attributeEntry : attr_adj_json) {
JSONObject attribute = (JSONObject) attributeEntry;
String typeString = (String) attribute.get("attr_type");
Enum.AttributeType attributeType = Enum.AttributeType.valueOf(typeString);
int attributeValue = ((Long) attribute.get("attr_value")).intValue();
rune_attr_adj.put(attributeType, attributeValue);
2024-04-02 14:11:01 -04:00
}
JSONArray max_attr_adj_json = (JSONArray) jsonObject.get("rune_max_attr_adj");
for (Object attributeEntry : max_attr_adj_json) {
JSONObject attribute = (JSONObject) attributeEntry;
String typeString = (String) attribute.get("attr_type");
Enum.AttributeType attributeType = Enum.AttributeType.valueOf(typeString);
int attributeValue = ((Long) attribute.get("attr_value")).intValue();
rune_max_attr_adj.put(attributeType, attributeValue);
}
2024-04-02 15:17:33 -04:00
JSONArray skill_grant_json = (JSONArray) jsonObject.get("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-02 15:17:33 -04:00
String typeString = (String) skill_granted.get("skill_type");
int skill_level = ((Long) skill_granted.get("skill_value")).intValue();
2024-04-02 15:24:52 -04:00
rune_skill_grant.put(typeString, skill_level);
2024-04-03 13:40:24 -04:00
JSONArray skill_granted_array = (JSONArray) skill_granted.get("skill_granted_skills");
2024-04-04 09:43:41 -04:00
for (Object skillGrantEntry : skill_granted_array) {
JSONArray skill_entry = (JSONArray) skillGrantEntry;
2024-04-04 09:34:44 -04:00
typeString = (String) skill_entry.get(0);
skill_level = ((Long) skill_entry.get(1)).intValue();
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
}