Reneer Posted July 8, 2016 Share Posted July 8, 2016 The simplest way would be to check if the player has the detonator equipped or not when the animation fires, though it sounds like the Animation Event isn't getting properly unregistered from the Detonator, thus it continues to blow up the mines when they are "fired" / placed. ScriptName RDE_DetonationScript extends ObjectReference {Detonation Script fro RDE. Attached to detonater} float Property WorkingRadius = 10000.0 Auto { what's the trigger range of the detonator } ; float Property SignalSpeed Auto Const ; { in units/second, used to determine the staggering effect } Projectile Property RDE_Projectile Auto Function Detonate(ObjectReference RDE) ; Test to see which if any of these works to make the mine explode, and give credit for potential kills RDE.DamageObject(100.0) ; RDE.DamageValue(Game.GetHealthAV(), 100.0) ; Below probably won't work ; RDE.Activate() ; RDE.Fire(akSender) ; RDE.Fire(Self as ObjectReference) ; RDE.Fire(Game.GetPlayer()) EndFunction Event OnEquipped(Actor akActor) If (akActor == Game.GetPlayer()) RegisterForAnimationEvent(akActor, "WeaponFire") EndIf EndEvent Event OnUnequipped(Actor akActor) If (akActor == Game.GetPlayer()) UnregisterForAnimationEvent(akActor, "WeaponFire") EndIf EndEvent Event OnAnimationEvent(ObjectReference akSource, string asEventName) ObjectReference[] RDEsToExplode = akSource.FindAllReferencesOfType(RDE_Projectile as Form, WorkingRadius) int i = 0 Debug.Notification("Found " + RDEsToExplode.Length + " RDEs.") if (Game.GetPlayer().IsEquipped(Self.GetBaseObject()) == false) While (i < RDEsToExplode.Length) Detonate(RDEsToExplode[i]) i += 1 EndWhile endif EndEvent Link to comment Share on other sites More sharing options...
MPankey Posted July 8, 2016 Author Share Posted July 8, 2016 The simplest way would be to check if the player has the detonator equipped or not when the animation fires, though it sounds like the Animation Event isn't getting properly unregistered from the Detonator, thus it continues to blow up the mines when they are "fired" / placed. ScriptName RDE_DetonationScript extends ObjectReference {Detonation Script fro RDE. Attached to detonater} float Property WorkingRadius = 10000.0 Auto { what's the trigger range of the detonator } ; float Property SignalSpeed Auto Const ; { in units/second, used to determine the staggering effect } Projectile Property RDE_Projectile Auto Function Detonate(ObjectReference RDE) ; Test to see which if any of these works to make the mine explode, and give credit for potential kills RDE.DamageObject(100.0) ; RDE.DamageValue(Game.GetHealthAV(), 100.0) ; Below probably won't work ; RDE.Activate() ; RDE.Fire(akSender) ; RDE.Fire(Self as ObjectReference) ; RDE.Fire(Game.GetPlayer()) EndFunction Event OnEquipped(Actor akActor) If (akActor == Game.GetPlayer()) RegisterForAnimationEvent(akActor, "WeaponFire") EndIf EndEvent Event OnUnequipped(Actor akActor) If (akActor == Game.GetPlayer()) UnregisterForAnimationEvent(akActor, "WeaponFire") EndIf EndEvent Event OnAnimationEvent(ObjectReference akSource, string asEventName) ObjectReference[] RDEsToExplode = akSource.FindAllReferencesOfType(RDE_Projectile as Form, WorkingRadius) int i = 0 Debug.Notification("Found " + RDEsToExplode.Length + " RDEs.") if (Game.GetPlayer().IsEquipped(Self.GetBaseObject()) == false) While (i < RDEsToExplode.Length) Detonate(RDEsToExplode[i]) i += 1 EndWhile endif EndEventThanks for the response! That blocked the detonation completely though Link to comment Share on other sites More sharing options...
Reneer Posted July 9, 2016 Share Posted July 9, 2016 (edited) Errr, derp, you want: if (Game.GetPlayer().IsEquipped(Self.GetBaseObject()) == true)because the script is attached to the detonator object / weapon. Edited July 9, 2016 by Reneer Link to comment Share on other sites More sharing options...
timtimman Posted July 9, 2016 Share Posted July 9, 2016 Yeah, we figured that out. Thanks for your input, but we'd like to be able to have both objects equipped at the same time. I have a few ideas on how to solve it which we'll get working on hopefully tonight. But this will be our last resort as we'll know it'll work. Will update on how we solved it if it's different than this. Thanks! Link to comment Share on other sites More sharing options...
MPankey Posted July 9, 2016 Author Share Posted July 9, 2016 Just so everybody knows timtimman is the man Link to comment Share on other sites More sharing options...
timtimman Posted July 10, 2016 Share Posted July 10, 2016 Though about it some more, your line of code won't work unfortunately. The issue apparently is that even though I register for animation event on this object, what's returned as akSource is the PC. Meaning that we'll get all WeaponFire animationevents. And hence, if you throw a mine (can be equipped at the same time), which is also sends a WeaponFire event, the result is that it blows up in your face. Checking to see if the current item is equipped wouldn't be necessary as I wouldn't receive the event unless it was equipped, where I register for it. Checking to see that our mines aren't equipped would work, but that won't allow us to place mines and detonate them without unequipping the mines, which we'd like to avoid. Some of the stuff we've tried to make it work the way we want, which unfortunately doesn't work. Sorting to see if the akSource came from out object in all possible ways; failed due to animation events being passed form the player actor. Tried overwriting the Fire function on weapon; didn't work as it probably isn't triggered when actually firing weapons. Right now my though of how to make it work is to only allow one of the items detonator/mines be equipped at a time. Any more suggestions are welcome! Link to comment Share on other sites More sharing options...
Reneer Posted July 10, 2016 Share Posted July 10, 2016 (edited) I did some looking at the Animations - maybe you can try registering for the animation "mineThrowStart" and / or "grenadeThrowStart" and separate everything out that way. I'm not sure if those animations will actually fire, but you can try. Not sure that would really help, though. Edited July 10, 2016 by Reneer Link to comment Share on other sites More sharing options...
Galvon94 Posted July 10, 2016 Share Posted July 10, 2016 Dear god, are there really no events for when you fire a specific weapon? Well if you don't get anywhere on your current path you could try it like this: Add a custom projectile and explosion, the explosion places a dummy object. Said dummy object would have a script to send a custom event and then delete itself. I think that should work anyway. Link to comment Share on other sites More sharing options...
Reneer Posted July 10, 2016 Share Posted July 10, 2016 (edited) I think I've got it: Use a variable that counts the number of mines the player has in their inventory. ScriptName RDE_DetonationScript extends ObjectReference {Detonation Script fro RDE. Attached to detonater} float Property WorkingRadius = 10000.0 Auto { what's the trigger range of the detonator } ; float Property SignalSpeed Auto Const ; { in units/second, used to determine the staggering effect } int totalmines Projectile Property RDE_Projectile Auto Ammo Property RDE_Mines Auto Function Detonate(ObjectReference RDE) ; Test to see which if any of these works to make the mine explode, and give credit for potential kills RDE.DamageObject(100.0) ; RDE.DamageValue(Game.GetHealthAV(), 100.0) ; Below probably won't work ; RDE.Activate() ; RDE.Fire(akSender) ; RDE.Fire(Self as ObjectReference) ; RDE.Fire(Game.GetPlayer()) EndFunction Event OnEquipped(Actor akActor) totalmines = Game.GetPlayer.GetItemCount(RDE_Mines) If (akActor == Game.GetPlayer()) RegisterForAnimationEvent(akActor, "WeaponFire") EndIf EndEvent Event OnUnequipped(Actor akActor) If (akActor == Game.GetPlayer()) UnregisterForAnimationEvent(akActor, "WeaponFire") EndIf EndEvent Event OnAnimationEvent(ObjectReference akSource, string asEventName) ObjectReference[] RDEsToExplode = akSource.FindAllReferencesOfType(RDE_Projectile as Form, WorkingRadius) int i = 0 Debug.Notification("Found " + RDEsToExplode.Length + " RDEs.") if (Game.GetPlayer.GetItemCount(RDE_Mines) >= totalmines) ; player pressed detonator and did not throw a mine. While (i < RDEsToExplode.Length) Detonate(RDEsToExplode[i]) i += 1 EndWhile endif totalmines = Game.GetPlayer.GetItemCount(RDE_Mines) EndEvent Edited July 10, 2016 by Reneer Link to comment Share on other sites More sharing options...
timtimman Posted July 10, 2016 Share Posted July 10, 2016 (edited) @Galvon94 That's one approach I've thought of taking, but avoided it as it would be easier to just copy and modify an already existing one. That and you apparently can't attach scripts to projectiles... But anything using Custom Events would be much better as the FindAllRef... function is very costly computational wise. @Reneer Will make sure to test those! If you've extracted all animation variables, I'd love to take a look :smile:You code example was my next thing to test. I just hope the remove ammo is completed before the animation event is sent out. Or can at least be given enough time using Wait(0.1). The issue still remains that the mines will be triggered if the player throws a grenade, while also having the detonator equipped, and this check is needed for all ammo. And, this makes it all more computationally heavy.One solution could be to not allow the detonator to be equipped with anything other than the RDE_Mines. I don't know if that can easily be set in the CK or if I also need to register a remote event on the actor to check so that this will unequip if any other throwable is equipped. Still, it's very sucky!For good measure though you should put your if statement before the FindAllRef... function since if it's false, the result of the search won't be needed, and hence saving computation. Thank's for the feedback, both of you! Will return once more testing has been performed, regardless of failure or success. Edited July 10, 2016 by timtimman Link to comment Share on other sites More sharing options...
Recommended Posts