NOTE: This code replaces the one that I have found people are currently using: trigger? = (enemy, numhelper) . That code may seem to works for some characters but it actually detects any helper being used, not just projectiles! So an enemy with a helper on screen at all times, such as Megaman and his dog Rush will always trigger that code or any enemy that uses a helper for an effect will also trigger that code.
This is a helper that stays bound to the character to detect if an enemy spawns a (Helper) Projectile. That PlayerId can then be used to find out a lot more about the projectile. Including velocity, distance, position on screen etc.
This system does use one root variable (var(48)) and IntPersistIndex in the constants part of the cns has to be set different than most characters defaults. (see notes in code.)
There are plenty of notes included. If anyone thinks of a way to improve this let me know!
This goes in state -2
[state -2, AI Detect Projectile System]
type = helper
trigger1 = ailevel && !numhelper(33333333)
name = "AI Detect Projectile System"
ID = 33333333
stateno = 33333333
postype = p1
ownpal = 1
keyctrl = 0
size.xscale = 1.0
size.yscale = 1.0
supermovetime = 2147483647
pausemovetime = 2147483647
ignorehitpause = 1
This goes in CNS
Spoiler: New Condensed Version (click to see content)
Spoiler: Old Long Version (click to see content)
Examples of use:
trigger1 = PlayerIDExist(helper(33333333),var(3))
trigger1 = PlayerID(helper(33333333),var(3)),p2bodydist X < 10 ; Distance between character and enemy's projectile is less than 10.