Bunslinger Posted September 13, 2020 Share Posted September 13, 2020 (edited) the JIP event handler "SetOnCrippledLimbEventHandler" needs either a reference or formID list in order to work, but the problem is i want it to run on whoever the player is attacking. here's what i have so far: scn CrippledEventSCRIPT begin GameMode if GetGameRestarted SetOnCrippledLimbEventHandler CrippledEventFUNCTION 1 (actorref/formID list) endif end i can't compile it since I don't know what to put for the last spot, i know i don't want to make it a specific actor since that wouldn't do anything to anyone other than that specific actor, and there's no form list that contains every actor in the game, nor do i want to make one since that's horribly incompatible with most things is there a way i can set the last reference to be whoever the player is attacking? i've looked at the geck wiki page for this function but it's of no help Edited September 13, 2020 by LolzMan1325 Link to comment Share on other sites More sharing options...
ashtonlp101 Posted September 14, 2020 Share Posted September 14, 2020 The best I can think of is if you made this into a script Effect script and wrote something along the lines of this: Ref Self Begin ScriptEffectStart Set Self to GetSelf If Self != PlayerIf GetGameRestarted SetOnCrippledLimbEventGandler CrippledEventFUNCTION 1 SelfEndifEndif END I'm not sure exactly what you're aiming to do with this script but the best I could think of is adding this script to an effect then adding that effect to a weapon. Link to comment Share on other sites More sharing options...
Bunslinger Posted September 14, 2020 Author Share Posted September 14, 2020 (edited) ok so wait, let me start over, i've made some adjustments and i'll go into the details basically what i'm trying to do is get a sound to play whenever an enemy's limb is crippled so first we have the event handler script scn CrippledEventSCRIPT ref rTarget begin GameMode set rTarget to PlayerRef.GetCombatTarget SetOnCrippledLimbEventHandler CrippledEventFUNCTION 1 rTarget end and then we have the function script scn CrippledEventFUNCTION ref rTarget int iWhichLimb begin Function {rTarget, iWhichLimb} set rTarget to this if GetHitAttacker != PlayerRef return elseif rTarget == PlayerRef return elseif rTarget.IsActor == 0 return elseif rTarget.GetHitHealthDamage > rTarget.GetAV Health return else iWhichLimb >= 0 PlaySound SFXCripplesound endif end now, this actually does work, but there's one problem: PlayerRef.GetCombatTarget doesn't work until after you shoot someone, and only if their healthbar is on-screen (since it's the same getter used for displaying that information). The problem with this is that I need it to register on any NPC, not just the one the game considers you to be in combat with, so that if the first shot (or any shot) you land on an NPC (whether you're in combat with them or not) cripples a limb, it'll make a sound. Edited September 14, 2020 by LolzMan1325 Link to comment Share on other sites More sharing options...
UnvalidUserName Posted September 14, 2020 Share Posted September 14, 2020 (edited) Try by iterating through the Actors on the Cell by using NextRef and etc. Mind you that setting it on everyone could be a problem if many actors get their limbs crippled at the same time. Also, If you don't mind tell us what do you want to achieve for us to see what you need the Event Handler for. Edited September 14, 2020 by UnvalidUserName Link to comment Share on other sites More sharing options...
Bunslinger Posted September 15, 2020 Author Share Posted September 15, 2020 what i want to do is for there to be a sound when an enemy's limb is crippled, i figure the best way to do that is with JIP's event handler made specifically for checking that, and the iWhichLimb >= 0 makes it so it's indiscriminate, but like i said the problem is that PlayerRef.GetCombatTarget only works on NPCs who you've already shot at least once, so if you cripple on the first shot, there's no sound. Link to comment Share on other sites More sharing options...
dubiousintent Posted September 15, 2020 Share Posted September 15, 2020 As you want this to occur whenever an Actor is hit, regardless of by whom or type of damage source, why can't you use an "OnHit" or "OnHitWith" eventhandler, and then call your check script from within that block? Should eliminate the need to iterate through the Actors in the cell yourself. -Dubious- Link to comment Share on other sites More sharing options...
UnvalidUserName Posted September 15, 2020 Share Posted September 15, 2020 What dubious said, and you can probably just check if the enemy starts playing a stagger animation when hit. GetAnimAction can do this but you'll will have to make few extra checks. Otherwise IsAnimationPlaying could work but I don't remember if there is a PlayGroup for stagger animation, maybe IsAnimationPlayingEx can recognize it. Link to comment Share on other sites More sharing options...
Bunslinger Posted September 15, 2020 Author Share Posted September 15, 2020 (edited) I feel like that would clash horribly with Immersive Hit Reactions since it uses the same animations. Expanding upon dubious' suggestion, couldn't I just use OnHit and rTarget.GetAV PerceptionCondition <= 0 (for seeing if the head is crippled on hit, for example), and by that point would I even need an event handler? or would I just need one script that looks like this scn CrippledSCRIPT ref rTarget begin OnHit set rTarget to This if GetHitAttacker != PlayerRef return elseif rTarget == PlayerRef return elseif rTarget.IsActor == 0 return elseif rTarget.GetHitHealthDamage > rTarget.GetAV Health return elseif rTarget.GetAV PerceptionConditon <=0 playsound SFXCripplesound elseif rTarget.GetAV EnduranceCondition <=0 playsound SFXCripplesound elseif rTarget.GetAV LeftAttackCondition <=0 playsound SFXCripplesound elseif rTarget.GetAV RightAttackCondition <=0 playsound SFXCripplesound elseif rTarget.GetAV LeftMobilityCondition <=0 playsound SFXCripplesound elseif rTarget.GetAV RightMobilityCondition <=0 playsound SFXCripplesound elseif rTarget.GetAV BrainCondition <=0 playsound SFXCripplesound else return endif end It's a little repetitive, but I think it would work, my only fear is that the numerous checks for limb condition would result in the sound playing 7 times Edited September 15, 2020 by LolzMan1325 Link to comment Share on other sites More sharing options...
UnvalidUserName Posted September 15, 2020 Share Posted September 15, 2020 Well it could work but I see a few problems. First, once someone has a limb crippled the sound will keep playing after every shot. Second, you could land a headshot on someone with a crippled leg and it will also play the sound. To fix it I suggest you check for hit location and also keep tabs on limbs that first get crippled. With a few variables and keeping tab of the target ref. You will have to declare these outside the UDF script all together because they will otherwise not persist and flush them every time the target ref changes. Link to comment Share on other sites More sharing options...
Bunslinger Posted September 15, 2020 Author Share Posted September 15, 2020 (edited) I suppose this is what I was hoping to use SetOnCrippledLimbEventHandler for, again, the only problem is I can't leave the reference open or set any potential targets to one reference, which sucks because this event handler does exactly what i need it to Edited September 15, 2020 by LolzMan1325 Link to comment Share on other sites More sharing options...
Recommended Posts