Need help with damage over time script (i.e. poison)
Posted: Sun Feb 25, 2018 7:47 am
Hello all,
This is my first foray into the world of modding factorio, and so far everything is going smoothly. I have however encountered a small stumbling block.
What I want to do is create a new type of bullet magazine that, when fired, will inflict poison damage to the target over a short duration of time (for example, 4 damage every half second for 3 seconds). The solution that first comes to mind is to use a script to check when entities are damaged, and if the cause of damage is an entity or player using the "poison" bullets, cause "n" amount of damage to the target entity every "x" ticks. I have been able to make a script to check the cause of damage to entities and if the attacker has my "poison" bullets in their inventory easily enough, but what I'm having trouble with is detecting if the attacker used my poison bullets to attack and applying damage to the target entity.
Any help with this problem is greatly appreciated!
I can, upon request, upload my mod as a .zip file for those that wish to look at my code.
This is my first foray into the world of modding factorio, and so far everything is going smoothly. I have however encountered a small stumbling block.
What I want to do is create a new type of bullet magazine that, when fired, will inflict poison damage to the target over a short duration of time (for example, 4 damage every half second for 3 seconds). The solution that first comes to mind is to use a script to check when entities are damaged, and if the cause of damage is an entity or player using the "poison" bullets, cause "n" amount of damage to the target entity every "x" ticks. I have been able to make a script to check the cause of damage to entities and if the attacker has my "poison" bullets in their inventory easily enough, but what I'm having trouble with is detecting if the attacker used my poison bullets to attack and applying damage to the target entity.
Any help with this problem is greatly appreciated!
I can, upon request, upload my mod as a .zip file for those that wish to look at my code.