So I want to make flying enemies that can only be damaged by long range weapons. So far I've made a state called Flying and attached it to enemies that can fly automatically when the battle starts. I've also added a Long Range element to the list of elements. The code I have so far is as follows.
if self.state?(24) and attacker.element_set != 14 #Flying enemies
print attacker.element_set
hit_result = false
else
# First hit detection
hit_result = (rand(100) < attacker.hit)
end
Where 14 is the Long Range element and 24 is the Flying state.
The problem is I don't know how to parse the element set to get just the number I need. The If statement always returns true no matter what weapon I'm using to attack flying enemies. Using print I can see that the number being displayed is 14 when I attack using long range weapons yet the statement still won't return false. I thought it might be because attacker.element_set is read as a string so I tried using "14" but that didn't help. I've also tested it with two elements and found that is lists them as a continous number so like 214 if a long range Ice Weapon. I'm sure there's a built in method for breaking up the array but even if I knew it, I'm not sure what it is and how I could use it to check for this specific element.
if self.state?(24) and attacker.element_set != 14 #Flying enemies
print attacker.element_set
hit_result = false
else
# First hit detection
hit_result = (rand(100) < attacker.hit)
end
Where 14 is the Long Range element and 24 is the Flying state.
The problem is I don't know how to parse the element set to get just the number I need. The If statement always returns true no matter what weapon I'm using to attack flying enemies. Using print I can see that the number being displayed is 14 when I attack using long range weapons yet the statement still won't return false. I thought it might be because attacker.element_set is read as a string so I tried using "14" but that didn't help. I've also tested it with two elements and found that is lists them as a continous number so like 214 if a long range Ice Weapon. I'm sure there's a built in method for breaking up the array but even if I knew it, I'm not sure what it is and how I could use it to check for this specific element.