Jump to content

Photo

getting SetOnCrippledLimbEventHandler to work on target

scripting jip plugin geck

  • Please log in to reply
13 replies to this topic

#1
LolzMan1325

LolzMan1325

    Old hand

  • Members
  • PipPipPip
  • 705 posts

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 by LolzMan1325, 13 September 2020 - 11:24 PM.


#2
ashtonlp101

ashtonlp101

    Fan

  • Supporter
  • PipPipPip
  • 349 posts

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 != Player

If GetGameRestarted

 

SetOnCrippledLimbEventGandler CrippledEventFUNCTION 1 Self

Endif

Endif

 

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. 



#3
LolzMan1325

LolzMan1325

    Old hand

  • Members
  • PipPipPip
  • 705 posts

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 by LolzMan1325, 14 September 2020 - 09:47 AM.


#4
UnvalidUserName

UnvalidUserName

    Enthusiast

  • Members
  • PipPip
  • 188 posts

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 by UnvalidUserName, 14 September 2020 - 10:46 PM.


#5
LolzMan1325

LolzMan1325

    Old hand

  • Members
  • PipPipPip
  • 705 posts

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.



#6
dubiousintent

dubiousintent

    Resident poster

  • Premium Member
  • 8,128 posts

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-



#7
UnvalidUserName

UnvalidUserName

    Enthusiast

  • Members
  • PipPip
  • 188 posts
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.

#8
LolzMan1325

LolzMan1325

    Old hand

  • Members
  • PipPipPip
  • 705 posts

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 by LolzMan1325, 15 September 2020 - 10:00 PM.


#9
UnvalidUserName

UnvalidUserName

    Enthusiast

  • Members
  • PipPip
  • 188 posts
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.

#10
LolzMan1325

LolzMan1325

    Old hand

  • Members
  • PipPipPip
  • 705 posts

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 by LolzMan1325, 15 September 2020 - 10:55 PM.






Also tagged with one or more of these keywords: scripting, jip plugin, geck

Page loaded in: 1.082 seconds