From df6c3addcf3479201ae2b3e5a1ce486b8695293e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 24 Feb 2024 15:37:59 -0500 Subject: [PATCH] Weapon field parsing --- src/engine/objects/ItemTemplate.java | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 2ad79448..41b4825f 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -158,18 +158,22 @@ public class ItemTemplate { if (item_type.equals(Enum.ItemType.WEAPON)) { - 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(); - - JSONObject weapon_damage = (JSONObject) item_weapon.get("weapon_damage"); - item_weapon_damage_type = Enum.DamageType.valueOf((String) weapon_damage.get("damage_type")); - item_weapon_damage_min = ((Long) weapon_damage.get("damage_min")).intValue(); - item_weapon_damage_max = ((Long) weapon_damage.get("damage_max")).intValue(); + JSONArray item_weapon = (JSONArray) jsonObject.get("item_weapon"); + for (Object o : item_weapon) { + JSONObject weapon_struct = (JSONObject) o; + + item_weapon_wepspeed = ((Double) weapon_struct.get("weapon_wepspeed")).floatValue(); + item_weapon_max_range = ((Double) weapon_struct.get("weapon_max_range")).floatValue(); + item_weapon_projectile_id = ((Long) weapon_struct.get("weapon_projectile_id")).intValue(); + item_weapon_projectile_speed = ((Double) weapon_struct.get("weapon_projectile_speed")).floatValue(); + item_weapon_combat_idle_anim = ((Long) weapon_struct.get("weapon_combat_idle_anim")).intValue(); + + JSONObject weapon_damage = (JSONObject) weapon_struct.get("weapon_damage"); + item_weapon_damage_type = Enum.DamageType.valueOf((String) weapon_damage.get("damage_type")); + item_weapon_damage_min = ((Long) weapon_damage.get("damage_min")).intValue(); + item_weapon_damage_max = ((Long) weapon_damage.get("damage_max")).intValue(); + } } JSONArray itemflags = (JSONArray) jsonObject.get("item_flags");