Greetings,
I have a bit of a complex issue to share this time around.
Terraria 1.4 added a new immunity frame system, which ensures that each enemy can be hit by each projectile no matter what, to increase the effectiveness of many piercing weapons. For more information, look here, and read up on Local Immunity: Invincibility frame - Official Terraria Wiki
Anyways, I’m trying to replicate this in my game with uhhhh, not ideal results… It shouldn’t be doing that much damage.
So basically, my thought process:
- Every single attack is given a UID.
- If an enemy is hit by an attack, the attack’s UID is stored temporarily in an array that the enemy has (immuneQueue in this case).
- The enemy CANNOT be harmed by the attack if it has the attack’s UID stored in it’s array.
- However, after a very brief amount of time passes (1/6th of a second), that UID is cleared out, and the enemy can be hit by that same projectile again.
- This is done for each child.
So I got to work and made this code, which of course, didn’t really work (Resulting in the GIF above):
After some debugging, I found out that EVERY child is cleaned out at once when the timer expires. So I tried to look for a solution to this. Maybe if I made the code check for every child in the array! That’s gotta work!
…oh…
It’s for global and scene variables only…
I tried using a structure variable instead, but sadly, the actions to remove the oldest child didn’t work out for me…
So uh… I’m kinda stuck here
If I could get the code to check for each child in the array individually, then maybe I could get it working. The only issue is HOW do I check for each child in an object array when the option to do so for object variables doesn’t seem to be present?