I develop a text based non-interactive randomized fighting game script (where the fight plays out like an old style MUD). My latest innovation is to use arrays to store the active fighters and or items during a battle. This is the method I worked out to create and utilize dynamic arrays that can be referenced from the main 'actors' array. The following is my proof of concept code that I've been working out. The part that may help you is down where the arrays get created and populated:
    # action line:
my_name (eg. johnny cage) uses obj_name (eg. duck)
    # 'duck' item details:
obj=duck.s.2.3
obj_name=$(echo "$item" | cut -d. -f1)
obj_type=$(echo "$item" | cut -d. -f2)
obj_min=$(echo "$item" | cut -d. -f3)
obj_max=$(echo "$item" | cut -d. -f4)
if obj_type="a" (actor) then they can use items:
obj_useitems=1
else it cant use items:
obj_useitems=0
obj_owner="$my_name"
if obj_name="duck" then set a delay before it attacks:
obj_delay=$(( (RANDOM % 6) + 6 ))
obj_id=$(( ${#actors[@]} + 1 ))
    # if it's an actor (eg. if obj_name="duck" or obj_type="a"), add to the array of actors that exist:
actors+=( "$obj_name.$obj_id" )
    # create the object array for the item / actor with all its/their stats:
declare -A new_obj=( [name]=$obj_name [type]=$obj_type [min]=$obj_min [max]=$obj_max [id]=$obj_id [use items]=$obj_useitems [owner]=$obj_owner [active]=$obj_delay )
    # create the dynamic named array with the object's id:
declare -A obj_$obj_id
    # assign the new_obj values to the dynamic array:
    eval obj_$obj_id[name]="\${new_obj[name]}"; eval obj_$obj_id[type]="\${new_obj[type]}"; eval obj_$obj_id[min]="\${new_obj[min]}"
    eval obj_$obj_id[max]="\${new_obj[max]}";eval obj_$obj_id[id]="\${new_obj[id]}";eval obj_$obj_id[life]="\${new_obj[life]}"
    eval obj_$obj_id[use items]="\${new_obj[use items]}"; eval obj_$obj_id[owner]="\${new_obj[owner]}"; eval obj_$obj_id[active]="\${new_obj[active]}"
    
# loop through list of actors, and retrieve values from their associated dynamic array that contains all of their stats:
for actor in "${actors[@]}"; do
    actor_name=$(echo "$actor" | cut -d. -f1)
    actor_id=$(echo "$actor" | cut -d. -f2)
    if [[ $(eval echo \${obj_$actor_id[type]}) = "s" ]]; then echo yes; else echo no; fi
done
 
                