FlashyJoer Posted December 8, 2017 Posted December 8, 2017 (edited) Hi all, I have an OnHit event set up that tells me if the player has been hit by an explosion - this works, no problem but I would like to refine it to say by WHAT explosion. Is it possible to limit to 'form akSource' to a specific formid? Many thanks for insight... Right now the script fragment looks like: If akTarget == PlayerREF && (akSource as explosion)...Endif Edited December 8, 2017 by joerqc
ThoraldGM Posted December 8, 2017 Posted December 8, 2017 Explosion Property pcryoMineExplosion Auto Const Mandatory Explosion Property pfragMineExplosion Auto Const Mandatory Event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, \ bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string apMaterial) If akTarget == PlayerREF && (akSource as explosion) If akSource == pcryoMineExplosion Debug.Notification("Brrr... It's chilly in here.") ElseIf akSource == pfragMineExplosion Debug.Notification("Beep beep beep BOOM!") Else ; Else explosion is not a cryo mine or frag mine... EndIf Else ; Else hit was not an explosion on player... EndIf EndEvent Creation Kit > SpecialEffect > Explosion. Note that exploding objects like cars appear to have 17 variants, but the use count shows the top one is probably the best. If you wanted to check for all variants of cars, all grenades, all mines, etc then you might need to create formlists and search them to refine akSource.
shavkacagarikia Posted December 9, 2017 Posted December 9, 2017 (edited) Like thorald suggested. But other small suggestion, use type check instead of cast because its not needed. So for your code its better to have:If akTarget == PlayerREF && akSource is Explosion Edited December 9, 2017 by shavkacagarikia
FlashyJoer Posted December 9, 2017 Author Posted December 9, 2017 Awesome! Thank you both! As always, I am humbled to learn new things from those with the skills :)
ThoraldGM Posted December 10, 2017 Posted December 10, 2017 It's all good. I just learned about type checks. Very useful :D
Recommended Posts