Jump to content

Please help me kill someone!


Recommended Posts

I've been trying to more or less script a fight with a life heart (see my Lucky 444 VRCade to get the idea).

 

At the start of the fight there's a random roll to see who will win the fight, the correct fighters (one loser and winner) are spawned into the ring and the quest hands over to a secondary quest which tracks the fight.

 

The problem is I was having all sorts of crazy going on with the life heart when I tried to track the health of the fighters (I think it was down to health regeneration). In an attempt to fix it (and stop the 10 minute long fights) I buffed up the fighters health and tracked attacks. I set a counter for each player, and for each OnHit there was a random percentage (between 1 and 5) deducted from the appropriate counter. As soon as one hits zero they're "killed", but as they're essential they go into bleed out.

 

The problem is occurring when the player's fighter hits zero. It catches the event, but does absolutely nothing. They just carry on fighting. It works fine for the house fighter, but with the player it's not playing ball.

 

Could someone please have a look at the script, and tell me where I'm going wrong. Thanks in advance.

Scriptname lfvr_fr_lifeupdater extends Quest

Actor Property PlayerRef Auto
GlobalVariable Property lfvr_fr_brutality Auto
GlobalVariable Property lfvr_fr_hmulti Auto
GlobalVariable Property lfvr_fr_hstarthealth Auto
GlobalVariable Property lfvr_fr_pstarthealth Auto
GlobalVariable Property lfvr_fr_pmulti Auto
GlobalVariable Property lfvr_fr_pwin Auto
ObjectReference Property playerlifeheart Auto
ObjectReference Property houselifeheart Auto
ReferenceAlias Property cloneyclone Auto
ReferenceAlias Property fighterclone Auto
Quest Property FightRoomLite Auto Const


Function StartMonitoring()
Float pwin = lfvr_fr_pwin.GetValue()

	If pwin == 1	;; Set multiplier to scale heart correctly.
		lfvr_fr_hmulti.SetValue(1)
		lfvr_fr_pmulti.SetValue(0.5)
		Debug.Notification("PLAYER WILL WIN!")	;; Debug notification to show expected result
	ElseIf pwin == 0
		lfvr_fr_hmulti.SetValue(0.5)
		lfvr_fr_pmulti.SetValue(1)
		Debug.Notification("PLAYER WILL LOSE!")
	EndIf

playerlifeheart.SetScale(1)
houselifeheart.SetScale(1)
playerlifeheart.Enable()
houselifeheart.Enable()
RegisterForHitEvent(cloneyclone)
RegisterForHitEvent(fighterclone)

Debug.EnableDetection()	;; Allow the fighters to start fighting.

EndFunction



Event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string apMaterial)

Actor housetoon = fighterclone.GetActorReference()
Actor playertoon = cloneyclone.GetActorReference()

Int pctorem = Utility.RandomInt(1, 5)
Float hhealth = lfvr_fr_hstarthealth.GetValue() As Int
Float phealth = lfvr_fr_pstarthealth.GetValue() As Int
Float hmulti = lfvr_fr_hmulti.GetValue()
Float pmulti = lfvr_fr_pmulti.GetValue()

	If akAggressor == playertoon && akTarget == housetoon	;; Cloney has hit
		hhealth = (hhealth - pctorem)
		lfvr_fr_hstarthealth.SetValue(hhealth)
		Utility.Wait(0.1)
		hhealth = (hhealth / 100)

		lighthouse.SetHealthPercent(housetoon, hhealth)
		lfvr_fr_brutality.Mod(pctorem)

			If hhealth > 0
				hhealth = (hhealth * hmulti)
				houselifeheart.Disable()
				houselifeheart.SetScale(hhealth)
				houselifeheart.Enable()
				RegisterForHitEvent(housetoon)
			ElseIf hhealth <= 0
				houselifeheart.Disable()
				housetoon.Kill()
				(Self As Quest).Stop()
			EndIf

	ElseIf akAggressor == housetoon && akTarget == Playertoon	;; House has hit
			phealth = (phealth - pctorem)
			lfvr_fr_pstarthealth.SetValue(phealth)
			Utility.Wait(0.1)
			phealth = (phealth / 100)
			lighthouse.SetHealthPercent(playertoon, phealth)

				If phealth > 0	;; Is health over 0?  If so rescale the heart.
					phealth = (phealth * pmulti)
					playerlifeheart.Disable()
					playerlifeheart.SetScale(phealth)
					playerlifeheart.Enable()
					RegisterForHitEvent(playertoon)				
				ElseIf phealth <= 0		;; Is heath at or below zero?  If so kill the player fighter
					playerlifeheart.Disable()
					playertoon.Kill()
					Debug.Messagebox("Should be dead")
					(Self As Quest).Stop()
				EndIf
		
	EndIf

EndEvent
Link to comment
Share on other sites

I've redone the script and moved it to the aliases (each alias handles it's own hits now), and it works as intended, but I'm still having a problem with kill() or killessential() not working.

 

Please, does anyone have any ideas why my NPCs aren't dying?

Link to comment
Share on other sites

It looks like some of the NPCs were messed up somewhere in their forms. I remade them, swapped over to using aliases even when I had known values of the NPCs, and it seems to be working now.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...