Terrain damage and i(nvincibility) frames

I am trying to solve a question in my game. I want to make terrain damage hitting over time instead on impact (movement) as it is now.

For example I want terrain damage to do its first 1 HP hit if you stay 10 or more frames in the tile and then hit for 1 damage each 30/60 frames. Do I need to plug some plugin?
I might as well opt for some kind of i frames although I really do not know how to make it work. I guess it will be plugin once again but I am really unsure.

Original thread: https://forums.rpgmakerweb.com/threads/terrain-damage-and-i-nvincibility-frames.97410/