fatmanmagister Posted January 4, 2017 Share Posted January 4, 2017 (edited) I'm trying to make a mod to make objects like Mini Nukes, Mines, Grenades, etc, explode when they're hit. Now I've hit a wall trying to figure out how to make the explosion from an affected object trigger other nearby objects. My script is dynamically added to certain objects in the loaded cell. Relevant code: Event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, \ bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string apMaterial) akTarget.PlaceAtMe(fragMineExplosion, 1) //Doesn't trigger OnHit events of other objects akTarget.Delete() EndEvent The fact that explosions or projectiles placed with PlaceAtMe() doesn't trigger OnHit events wasn't all that surprising but I'm stumped to find any other way to trigger the explosion. I guess I could just use FindAllReferencesWithKeyword() and iterate over all nearby explosives, but I feel like that will require quite a bit more complex scripting and will be more prone to bugs. So does anyone know of a way to trigger an explosion from a script that will then also trigger the OnHit events of nearby objects? Any help would be very much appreciated. Edited January 4, 2017 by fatmanmagister Link to comment Share on other sites More sharing options...
werr92 Posted January 4, 2017 Share Posted January 4, 2017 To trigger OnHit events you must first register the form you need using RegisterForHitEvent(Mine01). And then your reference is able to recieve an event. Don't forget to unregister or register for another hit after this event is triggered (just a reminder, suit yourself here). This is a minor improvement over the Skyrim's CK where you were able to use this event w/o registering for it. Link to comment Share on other sites More sharing options...
fatmanmagister Posted January 4, 2017 Author Share Posted January 4, 2017 To trigger OnHit events you must first register the form you need using RegisterForHitEvent(Mine01). And then your reference is able to recieve an event. Don't forget to unregister or register for another hit after this event is triggered (just a reminder, suit yourself here). This is a minor improvement over the Skyrim's CK where you were able to use this event w/o registering for it. All my references can detect OnHit events, I've already tested that. The problem is that explosions placed with PlaceAtMe() does not actually count as a hit. If the player shoots at a Mini Nuke, the explosion goes off, but any nearby explosives remain unaffected and does not receive an OnHit event. The problem isn't with detecting an OnHit event, I got that working, it's that I don't know how to send an OnHit Event programmatically. Link to comment Share on other sites More sharing options...
JesterDoobie Posted January 4, 2017 Share Posted January 4, 2017 (edited) Ya working with non-persistent objects ingame like this is a beep, lots of script stuff just doesn't work like it should, returns empty objectreferences or you just can't get a "handle" on the obj to work with it at all. I'm pretty sure your explosions need to come from a projectile of some sort, ideally fired from a weapon to trigger a proper OnHit() event. You might be able to make "fake" grenades with a modded projectile that only has a speed and range of like 1,then use Event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, \ bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string apMaterial)ObjectReference Boom = akTarget.PlaceAtMe(DummyGrenadeMODDED, 1)Boom.Fire()Boom.DisableNoWait()Boom.Delete() akTarget.Delete()EndEventWeapon Property DummyGrenadeMODDED Auto Cus without a Fire() event there just IS no OnHit() event. (AFAIK, that is) Edited January 4, 2017 by JesterDoobie Link to comment Share on other sites More sharing options...
fatmanmagister Posted January 7, 2017 Author Share Posted January 7, 2017 (edited) Ya working with non-persistent objects ingame like this is a beep, lots of script stuff just doesn't work like it should, returns empty objectreferences or you just can't get a "handle" on the obj to work with it at all. I'm pretty sure your explosions need to come from a projectile of some sort, ideally fired from a weapon to trigger a proper OnHit() event. You might be able to make "fake" grenades with a modded projectile that only has a speed and range of like 1,then use ... Cus without a Fire() event there just IS no OnHit() event. (AFAIK, that is) Ok, that looks like a viable way to do it, but I already decided to go with the iterative approach. It has it's drawbacks but I managed to get it working fairly well. Thanks anyway! Edited January 7, 2017 by fatmanmagister Link to comment Share on other sites More sharing options...
MrJoseCuervo Posted April 11, 2017 Share Posted April 11, 2017 (edited) Ya working with non-persistent objects ingame like this is a beep, lots of script stuff just doesn't work like it should, returns empty objectreferences or you just can't get a "handle" on the obj to work with it at all. I'm pretty sure your explosions need to come from a projectile of some sort, ideally fired from a weapon to trigger a proper OnHit() event. You might be able to make "fake" grenades with a modded projectile that only has a speed and range of like 1,then use ... Cus without a Fire() event there just IS no OnHit() event. (AFAIK, that is) Ok, that looks like a viable way to do it, but I already decided to go with the iterative approach. It has it's drawbacks but I managed to get it working fairly well. Thanks anyway! And the fact that you failed to mention how you did it makes this thread worthless. Thanks... Edited April 11, 2017 by MrJoseCuervo Link to comment Share on other sites More sharing options...
fatmanmagister Posted May 14, 2017 Author Share Posted May 14, 2017 (edited) And the fact that you failed to mention how you did it makes this thread worthless. Thanks... I said I went with the iterative approach, meaning I used "FindAllReferencesWithKeyword()" which I mentioned in my original question. If you wanted details on how I did it you could just ask, instead of being passive aggressive about it. The source code is packaged with my mod: http://www.nexusmods.com/fallout4/mods/24184 Edited May 14, 2017 by fatmanmagister Link to comment Share on other sites More sharing options...
Recommended Posts